Frameworks/libpurple.framework/Versions/0.6.2/Headers/libymsg.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2571 Frameworks/libpurple.framework/Versions/0.6.0/Headers/libymsg.h@75fb8ee8f2e6
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /**
     2  * @file libymsg.h The Yahoo! and Yahoo! JAPAN Protocol Plugins
     3  *
     4  * purple
     5  *
     6  * Purple is the legal property of its developers, whose names are too numerous
     7  * to list here.  Please refer to the COPYRIGHT file distributed with this
     8  * source distribution.
     9  *
    10  * This program is free software; you can redistribute it and/or modify
    11  * it under the terms of the GNU General Public License as published by
    12  * the Free Software Foundation; either version 2 of the License, or
    13  * (at your option) any later version.
    14  *
    15  * This program is distributed in the hope that it will be useful,
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    18  * GNU General Public License for more details.
    19  *
    20  * You should have received a copy of the GNU General Public License
    21  * along with this program; if not, write to the Free Software
    22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    23  */
    24 
    25 #ifndef _LIBYMSG_H_
    26 #define _LIBYMSG_H_
    27 
    28 #include "circbuffer.h"
    29 #include "cmds.h"
    30 #include "prpl.h"
    31 
    32 #define YAHOO_PAGER_HOST "scsa.msg.yahoo.com"
    33 #define YAHOO_PAGER_PORT 5050
    34 #define YAHOO_PAGER_PORT_P2P 5101
    35 #define YAHOO_LOGIN_URL "https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%s"
    36 #define YAHOO_TOKEN_URL "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
    37 #define YAHOO_P2P_KEEPALIVE_SECS 300
    38 #define YAHOO_P2P_SERVER_TIMEOUT 10
    39 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
    40 #define YAHOO_MAIL_URL "http://rd.yahoo.com/messenger/client/?http://mail.yahoo.com/"
    41 #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com"
    42 #define YAHOO_XFER_PORT 80
    43 #define YAHOO_XFER_RELAY_HOST "relay.msg.yahoo.com"
    44 #define YAHOO_XFER_RELAY_PORT 80
    45 #define YAHOO_ROOMLIST_URL "http://insider.msg.yahoo.com/ycontent/"
    46 #define YAHOO_ROOMLIST_LOCALE "us"
    47 /* really we should get the list of servers from
    48  http://update.messenger.yahoo.co.jp/servers.html */
    49 #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
    50 #define YAHOOJP_TOKEN_URL "https://login.yahoo.co.jp/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
    51 #define YAHOOJP_LOGIN_URL "https://login.yahoo.co.jp/config/pwtoken_login?src=ymsgr&ts=&token=%s"
    52 #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"
    53 #define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/"
    54 #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp"
    55 #define YAHOOJP_WEBCAM_HOST "wc.yahoo.co.jp"
    56 /* not sure, must test: */
    57 #define YAHOOJP_XFER_RELAY_HOST "relay.msg.yahoo.co.jp"
    58 #define YAHOOJP_XFER_RELAY_PORT 80
    59 #define YAHOOJP_ROOMLIST_URL "http://insider.msg.yahoo.co.jp/ycontent/"
    60 #define YAHOOJP_ROOMLIST_LOCALE "ja"
    61 
    62 #define YAHOO_AUDIBLE_URL "http://us.dl1.yimg.com/download.yahoo.com/dl/aud"
    63 
    64 #define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg"
    65 
    66 #define YAHOO_SMS_CARRIER_URL "http://lookup.msg.vip.mud.yahoo.com"
    67 
    68 #define YAHOO_USERINFO_URL "http://address.yahoo.com/yab/us?v=XM&sync=1&tags=short&useutf8=1&noclear=1&legenc=codepage-1252"
    69 #define YAHOOJP_USERINFO_URL "http://address.yahoo.co.jp/yab/jp?v=XM&sync=1&tags=short&useutf8=1&noclear=1&legenc=codepage-1252"
    70 
    71 #define YAHOO_PICURL_SETTING "picture_url"
    72 #define YAHOO_PICCKSUM_SETTING "picture_checksum"
    73 #define YAHOO_PICEXPIRE_SETTING "picture_expire"
    74 
    75 #define YAHOO_STATUS_TYPE_OFFLINE "offline"
    76 #define YAHOO_STATUS_TYPE_AVAILABLE "available"
    77 #define YAHOO_STATUS_TYPE_BRB "brb"
    78 #define YAHOO_STATUS_TYPE_BUSY "busy"
    79 #define YAHOO_STATUS_TYPE_NOTATHOME "notathome"
    80 #define YAHOO_STATUS_TYPE_NOTATDESK "notatdesk"
    81 #define YAHOO_STATUS_TYPE_NOTINOFFICE "notinoffice"
    82 #define YAHOO_STATUS_TYPE_ONPHONE "onphone"
    83 #define YAHOO_STATUS_TYPE_ONVACATION "onvacation"
    84 #define YAHOO_STATUS_TYPE_OUTTOLUNCH "outtolunch"
    85 #define YAHOO_STATUS_TYPE_STEPPEDOUT "steppedout"
    86 #define YAHOO_STATUS_TYPE_AWAY "away"
    87 #define YAHOO_STATUS_TYPE_INVISIBLE "invisible"
    88 #define YAHOO_STATUS_TYPE_MOBILE "mobile"
    89 
    90 #define YAHOO_CLIENT_VERSION_ID "4194239"
    91 #define YAHOO_CLIENT_VERSION "9.0.0.2162"
    92 
    93 #define YAHOOJP_CLIENT_VERSION_ID "4194239"
    94 #define YAHOOJP_CLIENT_VERSION "9.0.0.2162"
    95 
    96 #define YAHOO_CLIENT_USERAGENT "Mozilla/5.0"
    97 
    98 /* Index into attention types list. */
    99 #define YAHOO_BUZZ 0
   100 
   101 typedef enum {
   102 	YAHOO_PKT_TYPE_SERVER = 0,
   103 	YAHOO_PKT_TYPE_P2P
   104 } yahoo_pkt_type;
   105 
   106 typedef enum {
   107 	YAHOO_P2P_WE_ARE_CLIENT =0,
   108 	YAHOO_P2P_WE_ARE_SERVER
   109 } yahoo_p2p_connection_type;
   110 
   111 enum yahoo_status {
   112 	YAHOO_STATUS_AVAILABLE = 0,
   113 	YAHOO_STATUS_BRB,
   114 	YAHOO_STATUS_BUSY,
   115 	YAHOO_STATUS_NOTATHOME,
   116 	YAHOO_STATUS_NOTATDESK,
   117 	YAHOO_STATUS_NOTINOFFICE,
   118 	YAHOO_STATUS_ONPHONE,
   119 	YAHOO_STATUS_ONVACATION,
   120 	YAHOO_STATUS_OUTTOLUNCH,
   121 	YAHOO_STATUS_STEPPEDOUT,
   122 	YAHOO_STATUS_INVISIBLE = 12,
   123 	YAHOO_STATUS_CUSTOM = 99,
   124 	YAHOO_STATUS_IDLE = 999,
   125 	YAHOO_STATUS_WEBLOGIN = 0x5a55aa55,
   126 	YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
   127 	YAHOO_STATUS_TYPING = 0x16,
   128 	YAHOO_STATUS_DISCONNECTED = 0xffffffff /* in ymsg 15. doesnt mean the normal sense of 'disconnected' */
   129 };
   130 
   131 struct yahoo_buddy_icon_upload_data {
   132 	PurpleConnection *gc;
   133 	GString *str;
   134 	char *filename;
   135 	int pos;
   136 	int fd;
   137 	guint watcher;
   138 };
   139 
   140 struct yahoo_p2p_data	{
   141 	PurpleConnection *gc;
   142 	char *host_ip;
   143 	char *host_username;
   144 	int val_13;
   145 	guint input_event;
   146 	gint source;
   147 	int session_id;
   148 	yahoo_p2p_connection_type connection_type;
   149 };
   150 
   151 struct _YchtConn;
   152 
   153 typedef struct _YahooPersonalDetails {
   154 	char *id;
   155 
   156 	struct {
   157 		char *first;
   158 		char *last;
   159 		char *middle;
   160 		char *nick;
   161 	} names;
   162 
   163 	struct {
   164 		char *work;
   165 		char *home;
   166 		char *mobile;
   167 	} phone;
   168 } YahooPersonalDetails;
   169 
   170 typedef struct {
   171 	PurpleConnection *gc;
   172 	int fd;
   173 	guchar *rxqueue;
   174 	int rxlen;
   175 	PurpleCircBuffer *txbuf;
   176 	guint txhandler;
   177 	GHashTable *friends;
   178 
   179 	char **profiles;  /* Multiple profiles can be associated with an account */
   180 	YahooPersonalDetails ypd;
   181 
   182 	/**
   183 	 * This is used to keep track of the IMVironment chosen
   184 	 * by people you talk to.  We don't do very much with
   185 	 * this right now... but at least now if the remote user
   186 	 * selects an IMVironment we won't reset it back to the
   187 	 * default of nothing.
   188 	 */
   189 	GHashTable *imvironments;
   190 
   191 	int current_status;
   192 	gboolean logged_in;
   193 	GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist;
   194 	GSList *confs;
   195 	unsigned int conf_id; /* just a counter */
   196 	gboolean chat_online;
   197 	gboolean in_chat;
   198 	char *chat_name;
   199 	char *pending_chat_room;
   200 	char *pending_chat_id;
   201 	char *pending_chat_topic;
   202 	char *pending_chat_goto;
   203 	char *auth;
   204 	gsize auth_written;
   205 	char *cookie_y;
   206 	char *cookie_t;
   207 	int session_id;
   208 	gboolean jp;
   209 	gboolean wm; /* connected w/ web messenger method */
   210 	/* picture aka buddy icon stuff */
   211 	char *picture_url;
   212 	int picture_checksum;
   213 
   214 	/* ew. we have to check the icon before we connect,
   215 	 * but can't upload it til we're connected. */
   216 	struct yahoo_buddy_icon_upload_data *picture_upload_todo;
   217 	PurpleProxyConnectData *buddy_icon_connect_data;
   218 
   219 	struct _YchtConn *ycht;
   220 
   221 	/**
   222 	 * This linked list contains PurpleUtilFetchUrlData structs
   223 	 * for when we lookup people profile or photo information.
   224 	 */
   225 	GSList *url_datas;
   226 	GHashTable *xfer_peer_idstring_map;/* Hey, i dont know, but putting this HashTable next to friends gives a run time fault... */
   227 	GSList *cookies;/* contains all cookies, including _y and _t */
   228 
   229 	/**
   230 	 * We may receive a list15 in multiple packets with no prior warning as to how many we'll be getting;
   231 	 * the server expects us to keep track of the group for which it is sending us contact names.
   232 	 */
   233 	char *current_list15_grp;
   234 	time_t last_ping;
   235 	time_t last_keepalive;
   236 	GHashTable *peers;	/* information about p2p data */
   237 	int yahoo_p2p_timer;
   238 	int yahoo_local_p2p_server_fd;
   239 	int yahoo_p2p_server_watcher;
   240 	GHashTable *sms_carrier;	/* sms carrier data */
   241 	guint yahoo_p2p_server_timeout_handle;
   242 } YahooData;
   243 
   244 #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255)
   245 
   246 /*
   247  * Current Maximum Length for Instant Messages
   248  *
   249  * This was found by experiment.
   250  *
   251  * The YMSG protocol allows a message of up to 948 bytes, but the official client
   252  * limits to 800 characters.  According to experiments I conducted, it seems that
   253  * the discrepancy is to allow some leeway for messages with mixed single- and
   254  * multi-byte characters, as I was able to send messages of 840 and 932 bytes
   255  * by using some multibyte characters (some random Chinese or Japanese characters,
   256  * to be precise). - rekkanoryo
   257  */
   258 #define YAHOO_MAX_MESSAGE_LENGTH_BYTES 948
   259 #define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
   260 
   261 /* sometimes i wish prpls could #include things from other prpls. then i could just
   262  * use the routines from libfaim and not have to admit to knowing how they work. */
   263 #define yahoo_put16(buf, data) ( \
   264 		(*(buf) = (unsigned char)((data)>>8)&0xff), \
   265 		(*((buf)+1) = (unsigned char)(data)&0xff),  \
   266 		2)
   267 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
   268 #define yahoo_put32(buf, data) ( \
   269 		(*((buf)) = (unsigned char)((data)>>24)&0xff), \
   270 		(*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
   271 		(*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
   272 		(*((buf)+3) = (unsigned char)(data)&0xff), \
   273 		4)
   274 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \
   275 		(((*((buf)+1))<<16)&0x00ff0000) + \
   276 		(((*((buf)+2))<< 8)&0x0000ff00) + \
   277 		(((*((buf)+3)    )&0x000000ff)))
   278 
   279 /* util.c */
   280 void yahoo_init_colorht(void);
   281 void yahoo_dest_colorht(void);
   282 char *yahoo_codes_to_html(const char *x);
   283 char *yahoo_html_to_codes(const char *src);
   284 
   285 gboolean
   286 yahoo_account_use_http_proxy(PurpleConnection *conn);
   287 
   288 /**
   289  * Encode some text to send to the yahoo server.
   290  *
   291  * @param gc The connection handle.
   292  * @param str The null terminated utf8 string to encode.
   293  * @param utf8 If not @c NULL, whether utf8 is okay or not.
   294  *             Even if it is okay, we may not use it. If we
   295  *             used it, we set this to @c TRUE, else to
   296  *             @c FALSE. If @c NULL, false is assumed, and
   297  *             it is not dereferenced.
   298  * @return The g_malloced string in the appropriate encoding.
   299  */
   300 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8);
   301 
   302 /**
   303  * Decode some text received from the server.
   304  *
   305  * @param gc The gc handle.
   306  * @param str The null terminated string to decode.
   307  * @param utf8 Did the server tell us it was supposed to be utf8?
   308  * @return The decoded, utf-8 string, which must be g_free()'d.
   309  */
   310 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8);
   311 
   312 char *yahoo_convert_to_numeric(const char *str);
   313 
   314 
   315 /* yahoo_profile.c */
   316 void yahoo_get_info(PurpleConnection *gc, const char *name);
   317 
   318 /* libymsg.h  - these functions were formerly static but need not to be for the
   319  * new two-prpl model. */
   320 const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b);
   321 const char *yahoo_list_emblem(PurpleBuddy *b);
   322 char *yahoo_status_text(PurpleBuddy *b);
   323 void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full);
   324 GList *yahoo_status_types(PurpleAccount *account);
   325 GList *yahoo_blist_node_menu(PurpleBlistNode *node);
   326 void yahoo_login(PurpleAccount *account);
   327 void yahoo_close(PurpleConnection *gc);
   328 int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags);
   329 unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state);
   330 void yahoo_set_status(PurpleAccount *account, PurpleStatus *status);
   331 void yahoo_set_idle(PurpleConnection *gc, int idle);
   332 void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g);
   333 void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
   334 void yahoo_add_deny(PurpleConnection *gc, const char *who);
   335 void yahoo_rem_deny(PurpleConnection *gc, const char *who);
   336 void yahoo_set_permit_deny(PurpleConnection *gc);
   337 void yahoo_keepalive(PurpleConnection *gc);
   338 void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, const char *old_group, const char *new_group);
   339 void yahoo_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies);
   340 gboolean yahoo_offline_message(const PurpleBuddy *buddy);
   341 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type);
   342 GList *yahoo_attention_types(PurpleAccount *account);
   343 
   344 GList *yahoo_actions(PurplePlugin *plugin, gpointer context);
   345 void yahoopurple_register_commands(void);
   346 
   347 PurpleCmdRet yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data);
   348 PurpleCmdRet yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data);
   349 PurpleCmdRet yahoopurple_cmd_chat_list(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data);
   350 /* needed for xfer, thought theyd be useful for other enhancements later on
   351    Returns list of cookies stored in yahoo_data formatted as a single null terminated string
   352    returned value must be g_freed
   353 */
   354 gchar* yahoo_get_cookies(PurpleConnection *gc);
   355 
   356 /* send p2p pkt containing our encoded ip, asking peer to connect to us */
   357 void yahoo_send_p2p_pkt(PurpleConnection *gc, const char *who, int val_13);
   358 
   359 #endif /* _LIBYMSG_H_ */