Wed, 15 Dec 2004 01:09:22 +0000
[gaim-migrate @ 11598]
this cleans up the yahoo status code, and fixes some bugs.
setting available messages now works for the first time.
| 6513 | 1 | /** |
| 2 | * @file yahoo.h The Yahoo! protocol plugin | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
| 8046 | 6 | * Gaim 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. | |
| 6513 | 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 23 | */ | |
| 24 | ||
| 25 | #ifndef _YAHOO_H_ | |
| 26 | #define _YAHOO_H_ | |
| 27 | ||
| 6784 | 28 | #include "prpl.h" |
| 29 | ||
| 7883 | 30 | #define YAHOO_PAGER_HOST "scs.msg.yahoo.com" |
| 7827 | 31 | #define YAHOO_PAGER_PORT 5050 |
| 32 | #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/" | |
| 9221 | 33 | #define YAHOO_MAIL_URL "http://mail.yahoo.com/" |
| 7651 | 34 | #define YAHOO_XFER_HOST "filetransfer.msg.yahoo.com" |
| 35 | #define YAHOO_XFER_PORT 80 | |
| 8113 | 36 | #define YAHOO_ROOMLIST_URL "http://insider.msg.yahoo.com/ycontent/" |
| 7651 | 37 | |
| 9164 | 38 | /* really we should get the list of servers from |
| 39 | http://update.messenger.yahoo.co.jp/servers.html */ | |
| 40 | #define YAHOOJP_PAGER_HOST "cs.yahoo.co.jp" | |
| 9221 | 41 | #define YAHOOJP_PROFILE_URL "http://profiles.yahoo.co.jp/" |
| 42 | #define YAHOOJP_MAIL_URL "http://mail.yahoo.co.jp/" | |
| 9164 | 43 | #define YAHOOJP_XFER_HOST "filetransfer.msg.yahoo.co.jp" |
| 44 | #define YAHOOJP_WEBCAM_HOST "wc.yahoo.co.jp" | |
| 45 | ||
| 7134 | 46 | #define WEBMESSENGER_URL "http://login.yahoo.com/config/login?.src=pg" |
| 47 | ||
| 9306 | 48 | #define YAHOO_ICON_CHECKSUM_KEY "icon_checksum" |
| 49 | #define YAHOO_PICURL_SETTING "picture_url" | |
| 50 | #define YAHOO_PICCKSUM_SETTING "picture_checksum" | |
| 51 | #define YAHOO_PICEXPIRE_SETTING "picture_expire" | |
| 52 | ||
| 6729 | 53 | enum yahoo_service { /* these are easier to see in hex */ |
| 54 | YAHOO_SERVICE_LOGON = 1, | |
| 55 | YAHOO_SERVICE_LOGOFF, | |
| 56 | YAHOO_SERVICE_ISAWAY, | |
| 57 | YAHOO_SERVICE_ISBACK, | |
| 58 | YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ | |
| 59 | YAHOO_SERVICE_MESSAGE, | |
| 60 | YAHOO_SERVICE_IDACT, | |
| 61 | YAHOO_SERVICE_IDDEACT, | |
| 62 | YAHOO_SERVICE_MAILSTAT, | |
| 63 | YAHOO_SERVICE_USERSTAT, /* 0xa */ | |
| 64 | YAHOO_SERVICE_NEWMAIL, | |
| 65 | YAHOO_SERVICE_CHATINVITE, | |
| 66 | YAHOO_SERVICE_CALENDAR, | |
| 67 | YAHOO_SERVICE_NEWPERSONALMAIL, | |
| 68 | YAHOO_SERVICE_NEWCONTACT, | |
| 69 | YAHOO_SERVICE_ADDIDENT, /* 0x10 */ | |
| 70 | YAHOO_SERVICE_ADDIGNORE, | |
| 71 | YAHOO_SERVICE_PING, | |
| 72 | YAHOO_SERVICE_GOTGROUPRENAME, | |
| 73 | YAHOO_SERVICE_SYSMESSAGE = 0x14, | |
| 9306 | 74 | YAHOO_SERVICE_SKINNAME = 0x15, |
| 6729 | 75 | YAHOO_SERVICE_PASSTHROUGH2 = 0x16, |
| 76 | YAHOO_SERVICE_CONFINVITE = 0x18, | |
| 77 | YAHOO_SERVICE_CONFLOGON, | |
| 78 | YAHOO_SERVICE_CONFDECLINE, | |
| 79 | YAHOO_SERVICE_CONFLOGOFF, | |
| 80 | YAHOO_SERVICE_CONFADDINVITE, | |
| 81 | YAHOO_SERVICE_CONFMSG, | |
| 82 | YAHOO_SERVICE_CHATLOGON, | |
| 83 | YAHOO_SERVICE_CHATLOGOFF, | |
| 84 | YAHOO_SERVICE_CHATMSG = 0x20, | |
| 85 | YAHOO_SERVICE_GAMELOGON = 0x28, | |
| 86 | YAHOO_SERVICE_GAMELOGOFF, | |
| 87 | YAHOO_SERVICE_GAMEMSG = 0x2a, | |
| 88 | YAHOO_SERVICE_FILETRANSFER = 0x46, | |
| 89 | YAHOO_SERVICE_VOICECHAT = 0x4A, | |
| 90 | YAHOO_SERVICE_NOTIFY = 0x4B, | |
| 91 | YAHOO_SERVICE_VERIFY, | |
| 92 | YAHOO_SERVICE_P2PFILEXFER, | |
| 93 | YAHOO_SERVICE_PEEPTOPEER = 0x4F, | |
| 94 | YAHOO_SERVICE_WEBCAM, | |
| 95 | YAHOO_SERVICE_AUTHRESP = 0x54, | |
| 96 | YAHOO_SERVICE_LIST = 0x55, | |
| 97 | YAHOO_SERVICE_AUTH = 0x57, | |
| 98 | YAHOO_SERVICE_ADDBUDDY = 0x83, | |
| 99 | YAHOO_SERVICE_REMBUDDY = 0x84, | |
| 100 | YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0*/ | |
| 101 | YAHOO_SERVICE_REJECTCONTACT, | |
| 102 | YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ | |
| 6847 | 103 | /* YAHOO_SERVICE_??? = 0x8A, */ |
| 6729 | 104 | YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/ |
| 105 | YAHOO_SERVICE_CHATGOTO, | |
| 106 | YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */ | |
| 107 | YAHOO_SERVICE_CHATLEAVE, | |
| 108 | YAHOO_SERVICE_CHATEXIT = 0x9b, | |
| 109 | YAHOO_SERVICE_CHATADDINVITE = 0x9d, | |
| 110 | YAHOO_SERVICE_CHATLOGOUT = 0xa0, | |
| 111 | YAHOO_SERVICE_CHATPING, | |
| 7134 | 112 | YAHOO_SERVICE_COMMENT = 0xa8, |
| 9292 | 113 | YAHOO_SERVICE_AVATAR = 0xbc, |
| 114 | YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, | |
| 9062 | 115 | YAHOO_SERVICE_PICTURE = 0xbe, |
| 116 | YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, | |
| 9306 | 117 | YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, |
| 10373 | 118 | YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, |
| 119 | YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, | |
| 9292 | 120 | YAHOO_SERVICE_AVATAR_UPDATE = 0xc7, |
| 10360 | 121 | YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8, |
| 9604 | 122 | YAHOO_SERVICE_AUDIBLE = 0xd0, |
| 9342 | 123 | YAHOO_SERVICE_WEBLOGIN = 0x0226, |
| 124 | YAHOO_SERVICE_SMS_MSG = 0x02ea | |
| 6729 | 125 | }; |
| 6513 | 126 | |
| 10373 | 127 | #define YAHOO_STATUS_TYPE_OFFLINE "offline" |
| 128 | #define YAHOO_STATUS_TYPE_ONLINE "online" | |
| 129 | #define YAHOO_STATUS_TYPE_AVAILABLE "available" | |
| 130 | #define YAHOO_STATUS_TYPE_AVAILABLE_WM "available-wm" | |
| 131 | #define YAHOO_STATUS_TYPE_BRB "brb" | |
| 132 | #define YAHOO_STATUS_TYPE_BUSY "busy" | |
| 133 | #define YAHOO_STATUS_TYPE_NOTATHOME "notathome" | |
| 134 | #define YAHOO_STATUS_TYPE_NOTATDESK "notatdesk" | |
| 135 | #define YAHOO_STATUS_TYPE_NOTINOFFICE "notinoffice" | |
| 136 | #define YAHOO_STATUS_TYPE_ONPHONE "onphone" | |
| 137 | #define YAHOO_STATUS_TYPE_ONVACATION "onvacation" | |
| 138 | #define YAHOO_STATUS_TYPE_OUTTOLUNCH "outtolunch" | |
| 139 | #define YAHOO_STATUS_TYPE_STEPPEDOUT "steppedout" | |
| 140 | #define YAHOO_STATUS_TYPE_AWAY "away" | |
| 141 | #define YAHOO_STATUS_TYPE_INVISIBLE "invisible" | |
| 142 | ||
| 6729 | 143 | enum yahoo_status { |
| 144 | YAHOO_STATUS_AVAILABLE = 0, | |
| 145 | YAHOO_STATUS_BRB, | |
| 146 | YAHOO_STATUS_BUSY, | |
| 147 | YAHOO_STATUS_NOTATHOME, | |
| 148 | YAHOO_STATUS_NOTATDESK, | |
| 149 | YAHOO_STATUS_NOTINOFFICE, | |
| 150 | YAHOO_STATUS_ONPHONE, | |
| 151 | YAHOO_STATUS_ONVACATION, | |
| 152 | YAHOO_STATUS_OUTTOLUNCH, | |
| 153 | YAHOO_STATUS_STEPPEDOUT, | |
| 154 | YAHOO_STATUS_INVISIBLE = 12, | |
| 155 | YAHOO_STATUS_CUSTOM = 99, | |
| 156 | YAHOO_STATUS_IDLE = 999, | |
| 7134 | 157 | YAHOO_STATUS_WEBLOGIN = 0x5a55aa55, |
| 6729 | 158 | YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ |
| 159 | YAHOO_STATUS_TYPING = 0x16 | |
| 160 | }; | |
| 161 | ||
| 9306 | 162 | struct yahoo_buddy_icon_upload_data { |
| 163 | GaimConnection *gc; | |
| 164 | GString *str; | |
| 165 | char *filename; | |
| 166 | int pos; | |
| 167 | int fd; | |
| 168 | guint watcher; | |
| 169 | }; | |
| 170 | ||
| 9376 | 171 | struct _YchtConn; |
| 172 | ||
| 6729 | 173 | struct yahoo_data { |
| 174 | int fd; | |
| 175 | guchar *rxqueue; | |
| 176 | int rxlen; | |
| 6784 | 177 | GHashTable *friends; |
| 6729 | 178 | int current_status; |
| 179 | gboolean logged_in; | |
| 6784 | 180 | GString *tmp_serv_blist, *tmp_serv_ilist; |
| 6729 | 181 | GSList *confs; |
| 182 | unsigned int conf_id; /* just a counter */ | |
| 183 | gboolean chat_online; | |
| 184 | gboolean in_chat; | |
| 185 | char *chat_name; | |
| 7134 | 186 | char *auth; |
| 7651 | 187 | char *cookie_y; |
| 188 | char *cookie_t; | |
| 189 | int session_id; | |
| 9164 | 190 | gboolean jp; |
| 9370 | 191 | gboolean wm; |
| 9306 | 192 | /* picture aka buddy icon stuff */ |
| 193 | char *picture_url; | |
| 194 | int picture_checksum; | |
| 195 | ||
| 196 | /* ew. we have to check the icon before we connect, | |
| 197 | * but can't upload it til we're connected. */ | |
| 198 | struct yahoo_buddy_icon_upload_data *picture_upload_todo; | |
| 9376 | 199 | |
| 200 | struct _YchtConn *ycht; | |
| 6729 | 201 | }; |
| 202 | ||
| 203 | struct yahoo_pair { | |
| 204 | int key; | |
| 205 | char *value; | |
| 206 | }; | |
| 207 | ||
| 208 | struct yahoo_packet { | |
| 209 | guint16 service; | |
| 210 | guint32 status; | |
| 211 | guint32 id; | |
| 212 | GSList *hash; | |
| 213 | }; | |
| 214 | ||
| 6784 | 215 | |
| 9603 | 216 | #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255) |
| 6847 | 217 | |
| 9371 | 218 | |
| 219 | #define YAHOO_WEBMESSENGER_PROTO_VER 0x0065 | |
| 9408 | 220 | #define YAHOO_PROTO_VER 0x000c |
| 9371 | 221 | |
| 7651 | 222 | |
| 223 | #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
| 224 | ||
| 225 | /* sometimes i wish prpls could #include things from other prpls. then i could just | |
| 226 | * use the routines from libfaim and not have to admit to knowing how they work. */ | |
| 227 | #define yahoo_put16(buf, data) ( \ | |
| 228 | (*(buf) = (unsigned char)((data)>>8)&0xff), \ | |
| 229 | (*((buf)+1) = (unsigned char)(data)&0xff), \ | |
| 230 | 2) | |
| 231 | #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
| 232 | #define yahoo_put32(buf, data) ( \ | |
| 233 | (*((buf)) = (unsigned char)((data)>>24)&0xff), \ | |
| 234 | (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \ | |
| 235 | (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \ | |
| 236 | (*((buf)+3) = (unsigned char)(data)&0xff), \ | |
| 237 | 4) | |
| 238 | #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
| 239 | (((*((buf)+1))<<16)&0x00ff0000) + \ | |
| 240 | (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
| 241 | (((*((buf)+3) )&0x000000ff))) | |
| 242 | ||
| 243 | ||
| 6729 | 244 | struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id); |
| 245 | void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value); | |
| 246 | int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt); | |
| 9306 | 247 | int yahoo_send_packet_special(int fd, struct yahoo_packet *pkt, int pad); |
| 7651 | 248 | void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data); |
| 249 | int yahoo_packet_length(struct yahoo_packet *pkt); | |
| 6729 | 250 | void yahoo_packet_free(struct yahoo_packet *pkt); |
| 251 | ||
| 252 | /* util.c */ | |
| 6513 | 253 | void yahoo_init_colorht(); |
| 254 | void yahoo_dest_colorht(); | |
| 6629 | 255 | char *yahoo_codes_to_html(const char *x); |
| 256 | char *yahoo_html_to_codes(const char *src); | |
| 6513 | 257 | |
| 7827 | 258 | /** |
| 259 | * Encode some text to send to the yahoo server. | |
| 260 | * | |
| 261 | * @param gc The connection handle. | |
| 262 | * @param str The null terminated utf8 string to encode. | |
| 263 | * @param utf8 If not @c NULL, whether utf8 is okay or not. | |
| 264 | * Even if it is okay, we may not use it. If we | |
| 265 | * used it, we set this to @c TRUE, else to | |
| 266 | * @c FALSE. If @c NULL, false is assumed, and | |
| 267 | * it is not dereferenced. | |
| 268 | * @return The g_malloced string in the appropriate encoding. | |
| 269 | */ | |
| 270 | char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8); | |
| 271 | ||
| 272 | /** | |
| 273 | * Decode some text received from the server. | |
| 274 | * | |
| 275 | * @param gc The gc handle. | |
| 276 | * @param str The null terminated string to decode. | |
| 277 | * @param utf8 Did the server tell us it was supposed to be utf8? | |
| 278 | * @return The decoded, utf-8 string, which must be g_free()'d. | |
| 279 | */ | |
| 280 | char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8); | |
| 281 | ||
| 9220 | 282 | /* previously-static functions, now needed for yahoo_profile.c */ |
| 283 | char *yahoo_tooltip_text(GaimBuddy *b); | |
| 284 | ||
| 9161 | 285 | /* yahoo_profile.c */ |
| 286 | void yahoo_get_info(GaimConnection *gc, const char *name); | |
| 287 | ||
| 6513 | 288 | #endif /* _YAHOO_H_ */ |