libpurple/protocols/yahoo/libymsg.h

branch
cpw.rekkanoryo.yahoo.separate_prpls
changeset 27554
44a936179f2f
parent 27416
e99beec5e5c7
child 27555
afb7cb5c350c
equal deleted inserted replaced
27548:a34ef8df842f 27554:44a936179f2f
1 /**
2 * @file yahoo.h The Yahoo! protocol plugin
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 _YAHOO_H_
26 #define _YAHOO_H_
27
28 #include "circbuffer.h"
29 #include "prpl.h"
30
31 #define YAHOO_PAGER_HOST "scsa.msg.yahoo.com"
32 #define YAHOO_PAGER_PORT 5050
33 #define YAHOO_PAGER_PORT_P2P 5101
34 #define YAHOO_LOGIN_URL "https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token=%s"
35 #define YAHOO_TOKEN_URL "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
36 #define YAHOO_P2P_KEEPALIVE_SECS 300
37 #define YAHOO_P2P_SERVER_TIMEOUT 10
38 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
39 #define YAHOO_MAIL_URL "http://rd.yahoo.com/messenger/client/?http://mail.yahoo.com/"
40 #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com"
41 #define YAHOO_XFER_PORT 80
42 #define YAHOO_XFER_RELAY_HOST "relay.msg.yahoo.com"
43 #define YAHOO_XFER_RELAY_PORT 80
44 #define YAHOO_ROOMLIST_URL "http://insider.msg.yahoo.com/ycontent/"
45 #define YAHOO_ROOMLIST_LOCALE "us"
46 /* really we should get the list of servers from
47 http://update.messenger.yahoo.co.jp/servers.html */
48 #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp"
49 #define YAHOOJP_TOKEN_URL "https://login.yahoo.co.jp/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s"
50 #define YAHOOJP_LOGIN_URL "https://login.yahoo.co.jp/config/pwtoken_login?src=ymsgr&ts=&token=%s"
51 #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/"
52 #define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/"
53 #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp"
54 #define YAHOOJP_WEBCAM_HOST "wc.yahoo.co.jp"
55 /* not sure, must test: */
56 #define YAHOOJP_XFER_RELAY_HOST "relay.msg.yahoo.co.jp"
57 #define YAHOOJP_XFER_RELAY_PORT 80
58 #define YAHOOJP_ROOMLIST_URL "http://insider.msg.yahoo.co.jp/ycontent/"
59 #define YAHOOJP_ROOMLIST_LOCALE "ja"
60
61 #define YAHOO_AUDIBLE_URL "http://us.dl1.yimg.com/download.yahoo.com/dl/aud"
62
63 #define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg"
64
65 #define YAHOO_SMS_CARRIER_URL "http://lookup.msg.vip.mud.yahoo.com"
66
67 #define YAHOO_PICURL_SETTING "picture_url"
68 #define YAHOO_PICCKSUM_SETTING "picture_checksum"
69 #define YAHOO_PICEXPIRE_SETTING "picture_expire"
70
71 #define YAHOO_STATUS_TYPE_OFFLINE "offline"
72 #define YAHOO_STATUS_TYPE_AVAILABLE "available"
73 #define YAHOO_STATUS_TYPE_BRB "brb"
74 #define YAHOO_STATUS_TYPE_BUSY "busy"
75 #define YAHOO_STATUS_TYPE_NOTATHOME "notathome"
76 #define YAHOO_STATUS_TYPE_NOTATDESK "notatdesk"
77 #define YAHOO_STATUS_TYPE_NOTINOFFICE "notinoffice"
78 #define YAHOO_STATUS_TYPE_ONPHONE "onphone"
79 #define YAHOO_STATUS_TYPE_ONVACATION "onvacation"
80 #define YAHOO_STATUS_TYPE_OUTTOLUNCH "outtolunch"
81 #define YAHOO_STATUS_TYPE_STEPPEDOUT "steppedout"
82 #define YAHOO_STATUS_TYPE_AWAY "away"
83 #define YAHOO_STATUS_TYPE_INVISIBLE "invisible"
84 #define YAHOO_STATUS_TYPE_MOBILE "mobile"
85
86 #define YAHOO_CLIENT_VERSION_ID "4194239"
87 #define YAHOO_CLIENT_VERSION "9.0.0.2152"
88
89 #define YAHOOJP_CLIENT_VERSION_ID "4194239"
90 #define YAHOOJP_CLIENT_VERSION "9.0.0.2152"
91
92 #define YAHOO_CLIENT_USERAGENT "Mozilla/5.0"
93
94 /* Index into attention types list. */
95 #define YAHOO_BUZZ 0
96
97 typedef enum {
98 YAHOO_PKT_TYPE_SERVER = 0,
99 YAHOO_PKT_TYPE_P2P
100 } yahoo_pkt_type;
101
102 typedef enum {
103 YAHOO_P2P_WE_ARE_CLIENT =0,
104 YAHOO_P2P_WE_ARE_SERVER
105 } yahoo_p2p_connection_type;
106
107 enum yahoo_status {
108 YAHOO_STATUS_AVAILABLE = 0,
109 YAHOO_STATUS_BRB,
110 YAHOO_STATUS_BUSY,
111 YAHOO_STATUS_NOTATHOME,
112 YAHOO_STATUS_NOTATDESK,
113 YAHOO_STATUS_NOTINOFFICE,
114 YAHOO_STATUS_ONPHONE,
115 YAHOO_STATUS_ONVACATION,
116 YAHOO_STATUS_OUTTOLUNCH,
117 YAHOO_STATUS_STEPPEDOUT,
118 YAHOO_STATUS_INVISIBLE = 12,
119 YAHOO_STATUS_CUSTOM = 99,
120 YAHOO_STATUS_IDLE = 999,
121 YAHOO_STATUS_WEBLOGIN = 0x5a55aa55,
122 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
123 YAHOO_STATUS_TYPING = 0x16,
124 YAHOO_STATUS_DISCONNECTED = 0xffffffff /* in ymsg 15. doesnt mean the normal sense of 'disconnected' */
125 };
126
127 struct yahoo_buddy_icon_upload_data {
128 PurpleConnection *gc;
129 GString *str;
130 char *filename;
131 int pos;
132 int fd;
133 guint watcher;
134 };
135
136 struct yahoo_p2p_data {
137 PurpleConnection *gc;
138 char *host_ip;
139 char *host_username;
140 int val_13;
141 guint input_event;
142 gint source;
143 int session_id;
144 yahoo_p2p_connection_type connection_type;
145 };
146
147 struct _YchtConn;
148
149 struct yahoo_data {
150 PurpleConnection *gc;
151 int fd;
152 guchar *rxqueue;
153 int rxlen;
154 PurpleCircBuffer *txbuf;
155 guint txhandler;
156 GHashTable *friends;
157
158 char **profiles; /* Multiple profiles can be associated with an account */
159
160 /**
161 * This is used to keep track of the IMVironment chosen
162 * by people you talk to. We don't do very much with
163 * this right now... but at least now if the remote user
164 * selects an IMVironment we won't reset it back to the
165 * default of nothing.
166 */
167 GHashTable *imvironments;
168
169 int current_status;
170 gboolean logged_in;
171 GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist;
172 GSList *confs;
173 unsigned int conf_id; /* just a counter */
174 gboolean chat_online;
175 gboolean in_chat;
176 char *chat_name;
177 char *pending_chat_room;
178 char *pending_chat_id;
179 char *pending_chat_topic;
180 char *pending_chat_goto;
181 char *auth;
182 gsize auth_written;
183 char *cookie_y;
184 char *cookie_t;
185 int session_id;
186 gboolean jp;
187 gboolean wm; /* connected w/ web messenger method */
188 /* picture aka buddy icon stuff */
189 char *picture_url;
190 int picture_checksum;
191
192 /* ew. we have to check the icon before we connect,
193 * but can't upload it til we're connected. */
194 struct yahoo_buddy_icon_upload_data *picture_upload_todo;
195 PurpleProxyConnectData *buddy_icon_connect_data;
196
197 struct _YchtConn *ycht;
198
199 /**
200 * This linked list contains PurpleUtilFetchUrlData structs
201 * for when we lookup people profile or photo information.
202 */
203 GSList *url_datas;
204 GHashTable *xfer_peer_idstring_map;/* Hey, i dont know, but putting this HashTable next to friends gives a run time fault... */
205 GSList *cookies;/* contains all cookies, including _y and _t */
206
207 /**
208 * We may receive a list15 in multiple packets with no prior warning as to how many we'll be getting;
209 * the server expects us to keep track of the group for which it is sending us contact names.
210 */
211 char *current_list15_grp;
212 time_t last_ping;
213 time_t last_keepalive;
214 GHashTable *peers; /* information about p2p data */
215 int yahoo_p2p_timer;
216 int yahoo_local_p2p_server_fd;
217 int yahoo_p2p_server_watcher;
218 GHashTable *sms_carrier; /* sms carrier data */
219 guint yahoo_p2p_server_timeout_handle;
220 };
221
222 #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255)
223
224 /*
225 * Current Maximum Length for Instant Messages
226 *
227 * This was found by experiment.
228 *
229 * The YMSG protocol allows a message of up to 948 bytes, but the official client
230 * limits to 800 characters. According to experiments I conducted, it seems that
231 * the discrepancy is to allow some leeway for messages with mixed single- and
232 * multi-byte characters, as I was able to send messages of 840 and 932 bytes
233 * by using some multibyte characters (some random Chinese or Japanese characters,
234 * to be precise). - rekkanoryo
235 */
236 #define YAHOO_MAX_MESSAGE_LENGTH_BYTES 948
237 #define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
238
239 /* sometimes i wish prpls could #include things from other prpls. then i could just
240 * use the routines from libfaim and not have to admit to knowing how they work. */
241 #define yahoo_put16(buf, data) ( \
242 (*(buf) = (unsigned char)((data)>>8)&0xff), \
243 (*((buf)+1) = (unsigned char)(data)&0xff), \
244 2)
245 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
246 #define yahoo_put32(buf, data) ( \
247 (*((buf)) = (unsigned char)((data)>>24)&0xff), \
248 (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \
249 (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \
250 (*((buf)+3) = (unsigned char)(data)&0xff), \
251 4)
252 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \
253 (((*((buf)+1))<<16)&0x00ff0000) + \
254 (((*((buf)+2))<< 8)&0x0000ff00) + \
255 (((*((buf)+3) )&0x000000ff)))
256
257 /* util.c */
258 void yahoo_init_colorht(void);
259 void yahoo_dest_colorht(void);
260 char *yahoo_codes_to_html(const char *x);
261 char *yahoo_html_to_codes(const char *src);
262
263 gboolean
264 yahoo_account_use_http_proxy(PurpleConnection *conn);
265
266 /**
267 * Encode some text to send to the yahoo server.
268 *
269 * @param gc The connection handle.
270 * @param str The null terminated utf8 string to encode.
271 * @param utf8 If not @c NULL, whether utf8 is okay or not.
272 * Even if it is okay, we may not use it. If we
273 * used it, we set this to @c TRUE, else to
274 * @c FALSE. If @c NULL, false is assumed, and
275 * it is not dereferenced.
276 * @return The g_malloced string in the appropriate encoding.
277 */
278 char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8);
279
280 /**
281 * Decode some text received from the server.
282 *
283 * @param gc The gc handle.
284 * @param str The null terminated string to decode.
285 * @param utf8 Did the server tell us it was supposed to be utf8?
286 * @return The decoded, utf-8 string, which must be g_free()'d.
287 */
288 char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8);
289
290 char *yahoo_convert_to_numeric(const char *str);
291
292 /* previously-static functions, now needed for yahoo_profile.c */
293 void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full);
294
295 /* yahoo_profile.c */
296 void yahoo_get_info(PurpleConnection *gc, const char *name);
297
298 /* needed for xfer, thought theyd be useful for other enhancements later on
299 Returns list of cookies stored in yahoo_data formatted as a single null terminated string
300 returned value must be g_freed
301 */
302 gchar* yahoo_get_cookies(PurpleConnection *gc);
303
304 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type);
305 GList *yahoo_attention_types(PurpleAccount *account);
306
307 /* send p2p pkt containing our encoded ip, asking peer to connect to us */
308 void yahoo_send_p2p_pkt(PurpleConnection *gc, const char *who, int val_13);
309
310 #endif /* _YAHOO_H_ */

mercurial