2
* @file libymsg.h The Yahoo! and Yahoo! JAPAN Protocol Plugins
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
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.
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.
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
28
#include "circbuffer.h"
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"
62
#define YAHOO_AUDIBLE_URL "http://us.dl1.yimg.com/download.yahoo.com/dl/aud"
64
#define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg"
66
#define YAHOO_SMS_CARRIER_URL "http://lookup.msg.vip.mud.yahoo.com"
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"
71
#define YAHOO_PICURL_SETTING "picture_url"
72
#define YAHOO_PICCKSUM_SETTING "picture_checksum"
73
#define YAHOO_PICEXPIRE_SETTING "picture_expire"
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"
90
#define YAHOO_CLIENT_VERSION_ID "4194239"
91
#define YAHOO_CLIENT_VERSION "9.0.0.2162"
93
#define YAHOOJP_CLIENT_VERSION_ID "4194239"
94
#define YAHOOJP_CLIENT_VERSION "9.0.0.2162"
96
#define YAHOO_CLIENT_USERAGENT "Mozilla/5.0"
98
/* Index into attention types list. */
102
YAHOO_PKT_TYPE_SERVER = 0,
107
YAHOO_P2P_WE_ARE_CLIENT =0,
108
YAHOO_P2P_WE_ARE_SERVER
109
} yahoo_p2p_connection_type;
112
YAHOO_STATUS_AVAILABLE = 0,
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' */
131
struct yahoo_buddy_icon_upload_data {
132
PurpleConnection *gc;
140
struct yahoo_p2p_data {
141
PurpleConnection *gc;
148
yahoo_p2p_connection_type connection_type;
153
typedef struct _YahooPersonalDetails {
168
} YahooPersonalDetails;
171
PurpleConnection *gc;
175
PurpleCircBuffer *txbuf;
179
char **profiles; /* Multiple profiles can be associated with an account */
180
YahooPersonalDetails ypd;
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.
189
GHashTable *imvironments;
193
GString *tmp_serv_blist, *tmp_serv_ilist, *tmp_serv_plist;
195
unsigned int conf_id; /* just a counter */
196
gboolean chat_online;
199
char *pending_chat_room;
200
char *pending_chat_id;
201
char *pending_chat_topic;
202
char *pending_chat_goto;
209
gboolean wm; /* connected w/ web messenger method */
210
/* picture aka buddy icon stuff */
212
int picture_checksum;
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;
219
struct _YchtConn *ycht;
222
* This linked list contains PurpleUtilFetchUrlData structs
223
* for when we lookup people profile or photo information.
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 */
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.
233
char *current_list15_grp;
235
time_t last_keepalive;
236
GHashTable *peers; /* information about p2p data */
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;
244
#define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255)
247
* Current Maximum Length for Instant Messages
249
* This was found by experiment.
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
258
#define YAHOO_MAX_MESSAGE_LENGTH_BYTES 948
259
#define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
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), \
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), \
274
#define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \
275
(((*((buf)+1))<<16)&0x00ff0000) + \
276
(((*((buf)+2))<< 8)&0x0000ff00) + \
277
(((*((buf)+3) )&0x000000ff)))
280
void yahoo_init_colorht(void);
281
void yahoo_dest_colorht(void);
282
char *yahoo_codes_to_html(const char *x);
285
* This function takes a normal HTML message and converts it to the message
286
* format used by Yahoo, which uses a frankensteinish combination of ANSI
287
* escape codes and broken HTML.
289
* It results in slightly different output than would be sent by official
290
* Yahoo clients. The two main differences are:
292
* 1. We always close all tags, whereas official Yahoo clients leave tags
293
* dangling open at the end of each message (and the client treats them
295
* 2. We always close inner tags first before closing outter tags.
297
* For example, if you want to send this message:
298
* <b> bold <i> bolditalic </i></b><i> italic </i>
299
* Official Yahoo clients would send:
300
* ESC[1m bold ESC[2m bolditalic ESC[x1m italic
302
* ESC[1m bold ESC[2m bolditalic ESC[x2mESC[x1mESC[2m italic ESC[x2m
304
char *yahoo_html_to_codes(const char *src);
307
yahoo_account_use_http_proxy(PurpleConnection *conn);
310
* Encode some text to send to the yahoo server.
312
* @param gc The connection handle.
313
* @param str The null terminated utf8 string to encode.
314
* @param utf8 If not @c NULL, whether utf8 is okay or not.
315
* Even if it is okay, we may not use it. If we
316
* used it, we set this to @c TRUE, else to
317
* @c FALSE. If @c NULL, false is assumed, and
318
* it is not dereferenced.
319
* @return The g_malloced string in the appropriate encoding.
321
char *yahoo_string_encode(PurpleConnection *gc, const char *str, gboolean *utf8);
324
* Decode some text received from the server.
326
* @param gc The gc handle.
327
* @param str The null terminated string to decode.
328
* @param utf8 Did the server tell us it was supposed to be utf8?
329
* @return The decoded, utf-8 string, which must be g_free()'d.
331
char *yahoo_string_decode(PurpleConnection *gc, const char *str, gboolean utf8);
333
char *yahoo_convert_to_numeric(const char *str);
336
/* yahoo_profile.c */
337
void yahoo_get_info(PurpleConnection *gc, const char *name);
339
/* libymsg.h - these functions were formerly static but need not to be for the
340
* new two-prpl model. */
341
const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b);
342
const char *yahoo_list_emblem(PurpleBuddy *b);
343
char *yahoo_status_text(PurpleBuddy *b);
344
void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full);
345
GList *yahoo_status_types(PurpleAccount *account);
346
GList *yahoo_blist_node_menu(PurpleBlistNode *node);
347
void yahoo_login(PurpleAccount *account);
348
void yahoo_close(PurpleConnection *gc);
349
int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags);
350
unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state);
351
void yahoo_set_status(PurpleAccount *account, PurpleStatus *status);
352
void yahoo_set_idle(PurpleConnection *gc, int idle);
353
void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g);
354
void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group);
355
void yahoo_add_deny(PurpleConnection *gc, const char *who);
356
void yahoo_rem_deny(PurpleConnection *gc, const char *who);
357
void yahoo_set_permit_deny(PurpleConnection *gc);
358
void yahoo_keepalive(PurpleConnection *gc);
359
void yahoo_change_buddys_group(PurpleConnection *gc, const char *who, const char *old_group, const char *new_group);
360
void yahoo_rename_group(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies);
361
gboolean yahoo_offline_message(const PurpleBuddy *buddy);
362
gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type);
363
GList *yahoo_attention_types(PurpleAccount *account);
365
GList *yahoo_actions(PurplePlugin *plugin, gpointer context);
366
void yahoopurple_register_commands(void);
368
PurpleCmdRet yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data);
369
PurpleCmdRet yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data);
370
PurpleCmdRet yahoopurple_cmd_chat_list(PurpleConversation *conv, const char *cmd, char **args, char **error, void *data);
371
/* needed for xfer, thought theyd be useful for other enhancements later on
372
Returns list of cookies stored in yahoo_data formatted as a single null terminated string
373
returned value must be g_freed
375
gchar* yahoo_get_cookies(PurpleConnection *gc);
377
/* send p2p pkt containing our encoded ip, asking peer to connect to us */
378
void yahoo_send_p2p_pkt(PurpleConnection *gc, const char *who, int val_13);
380
#endif /* _LIBYMSG_H_ */