Sun, 06 Jun 2004 18:45:06 +0000
[gaim-migrate @ 10017]
a yahoo japan patch from wing:
1. Recognize ISO2022 in Subject header
2. Go to mail.yahoo.co.jp if account is marked as
"Yahoo Japan"
3. Make profiles.yahoo.co.jp a #define and use it in
yahoo_profile.c
I poked at it myself some too, to make it give the right profile url
in the get info box for yahoo japan.
I also added a new macro to connection.h to check if a connection is valid.
I'm not very good at macros, however, and used its argument twice. Someone
should fix that :)
committer: Tim Ringenbach <marv@pidgin.im>
| 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 | ||
| 6729 | 48 | enum yahoo_service { /* these are easier to see in hex */ |
| 49 | YAHOO_SERVICE_LOGON = 1, | |
| 50 | YAHOO_SERVICE_LOGOFF, | |
| 51 | YAHOO_SERVICE_ISAWAY, | |
| 52 | YAHOO_SERVICE_ISBACK, | |
| 53 | YAHOO_SERVICE_IDLE, /* 5 (placemarker) */ | |
| 54 | YAHOO_SERVICE_MESSAGE, | |
| 55 | YAHOO_SERVICE_IDACT, | |
| 56 | YAHOO_SERVICE_IDDEACT, | |
| 57 | YAHOO_SERVICE_MAILSTAT, | |
| 58 | YAHOO_SERVICE_USERSTAT, /* 0xa */ | |
| 59 | YAHOO_SERVICE_NEWMAIL, | |
| 60 | YAHOO_SERVICE_CHATINVITE, | |
| 61 | YAHOO_SERVICE_CALENDAR, | |
| 62 | YAHOO_SERVICE_NEWPERSONALMAIL, | |
| 63 | YAHOO_SERVICE_NEWCONTACT, | |
| 64 | YAHOO_SERVICE_ADDIDENT, /* 0x10 */ | |
| 65 | YAHOO_SERVICE_ADDIGNORE, | |
| 66 | YAHOO_SERVICE_PING, | |
| 67 | YAHOO_SERVICE_GOTGROUPRENAME, | |
| 68 | YAHOO_SERVICE_SYSMESSAGE = 0x14, | |
| 69 | YAHOO_SERVICE_PASSTHROUGH2 = 0x16, | |
| 70 | YAHOO_SERVICE_CONFINVITE = 0x18, | |
| 71 | YAHOO_SERVICE_CONFLOGON, | |
| 72 | YAHOO_SERVICE_CONFDECLINE, | |
| 73 | YAHOO_SERVICE_CONFLOGOFF, | |
| 74 | YAHOO_SERVICE_CONFADDINVITE, | |
| 75 | YAHOO_SERVICE_CONFMSG, | |
| 76 | YAHOO_SERVICE_CHATLOGON, | |
| 77 | YAHOO_SERVICE_CHATLOGOFF, | |
| 78 | YAHOO_SERVICE_CHATMSG = 0x20, | |
| 79 | YAHOO_SERVICE_GAMELOGON = 0x28, | |
| 80 | YAHOO_SERVICE_GAMELOGOFF, | |
| 81 | YAHOO_SERVICE_GAMEMSG = 0x2a, | |
| 82 | YAHOO_SERVICE_FILETRANSFER = 0x46, | |
| 83 | YAHOO_SERVICE_VOICECHAT = 0x4A, | |
| 84 | YAHOO_SERVICE_NOTIFY = 0x4B, | |
| 85 | YAHOO_SERVICE_VERIFY, | |
| 86 | YAHOO_SERVICE_P2PFILEXFER, | |
| 87 | YAHOO_SERVICE_PEEPTOPEER = 0x4F, | |
| 88 | YAHOO_SERVICE_WEBCAM, | |
| 89 | YAHOO_SERVICE_AUTHRESP = 0x54, | |
| 90 | YAHOO_SERVICE_LIST = 0x55, | |
| 91 | YAHOO_SERVICE_AUTH = 0x57, | |
| 92 | YAHOO_SERVICE_ADDBUDDY = 0x83, | |
| 93 | YAHOO_SERVICE_REMBUDDY = 0x84, | |
| 94 | YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0*/ | |
| 95 | YAHOO_SERVICE_REJECTCONTACT, | |
| 96 | YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ | |
| 6847 | 97 | /* YAHOO_SERVICE_??? = 0x8A, */ |
| 6729 | 98 | YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/ |
| 99 | YAHOO_SERVICE_CHATGOTO, | |
| 100 | YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */ | |
| 101 | YAHOO_SERVICE_CHATLEAVE, | |
| 102 | YAHOO_SERVICE_CHATEXIT = 0x9b, | |
| 103 | YAHOO_SERVICE_CHATADDINVITE = 0x9d, | |
| 104 | YAHOO_SERVICE_CHATLOGOUT = 0xa0, | |
| 105 | YAHOO_SERVICE_CHATPING, | |
| 7134 | 106 | YAHOO_SERVICE_COMMENT = 0xa8, |
| 9062 | 107 | YAHOO_SERVICE_PICTURE = 0xbe, |
| 108 | YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, | |
| 7134 | 109 | YAHOO_SERVICE_WEBLOGIN = 0x0226 |
| 6729 | 110 | }; |
| 6513 | 111 | |
| 6729 | 112 | enum yahoo_status { |
| 113 | YAHOO_STATUS_AVAILABLE = 0, | |
| 114 | YAHOO_STATUS_BRB, | |
| 115 | YAHOO_STATUS_BUSY, | |
| 116 | YAHOO_STATUS_NOTATHOME, | |
| 117 | YAHOO_STATUS_NOTATDESK, | |
| 118 | YAHOO_STATUS_NOTINOFFICE, | |
| 119 | YAHOO_STATUS_ONPHONE, | |
| 120 | YAHOO_STATUS_ONVACATION, | |
| 121 | YAHOO_STATUS_OUTTOLUNCH, | |
| 122 | YAHOO_STATUS_STEPPEDOUT, | |
| 123 | YAHOO_STATUS_INVISIBLE = 12, | |
| 124 | YAHOO_STATUS_CUSTOM = 99, | |
| 125 | YAHOO_STATUS_IDLE = 999, | |
| 7134 | 126 | YAHOO_STATUS_WEBLOGIN = 0x5a55aa55, |
| 6729 | 127 | YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ |
| 128 | YAHOO_STATUS_TYPING = 0x16 | |
| 129 | }; | |
| 130 | ||
| 131 | struct yahoo_data { | |
| 132 | int fd; | |
| 133 | guchar *rxqueue; | |
| 134 | int rxlen; | |
| 6784 | 135 | GHashTable *friends; |
| 6729 | 136 | int current_status; |
| 137 | gboolean logged_in; | |
| 6784 | 138 | GString *tmp_serv_blist, *tmp_serv_ilist; |
| 6729 | 139 | GSList *confs; |
| 140 | unsigned int conf_id; /* just a counter */ | |
| 141 | gboolean chat_online; | |
| 142 | gboolean in_chat; | |
| 143 | char *chat_name; | |
| 7134 | 144 | char *auth; |
| 7651 | 145 | char *cookie_y; |
| 146 | char *cookie_t; | |
| 147 | int session_id; | |
| 9164 | 148 | gboolean jp; |
| 6729 | 149 | }; |
| 150 | ||
| 151 | struct yahoo_pair { | |
| 152 | int key; | |
| 153 | char *value; | |
| 154 | }; | |
| 155 | ||
| 156 | struct yahoo_packet { | |
| 157 | guint16 service; | |
| 158 | guint32 status; | |
| 159 | guint32 id; | |
| 160 | GSList *hash; | |
| 161 | }; | |
| 162 | ||
| 6784 | 163 | struct yahoo_friend { /* we'll call them friends, so we don't confuse them with GaimBuddy */ |
| 164 | enum yahoo_status status; | |
| 165 | char *msg; | |
| 166 | char *game; | |
| 167 | int idle; | |
| 168 | int away; | |
| 169 | gboolean sms; | |
| 170 | }; | |
| 171 | ||
| 6895 | 172 | #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (48) |
| 6847 | 173 | |
| 7651 | 174 | #ifdef YAHOO_WEBMESSENGER |
| 175 | #define YAHOO_PROTO_VER 0x0065 | |
| 176 | #else | |
| 177 | #define YAHOO_PROTO_VER 0x000b | |
| 178 | #endif | |
| 179 | ||
| 180 | #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4) | |
| 181 | ||
| 182 | /* sometimes i wish prpls could #include things from other prpls. then i could just | |
| 183 | * use the routines from libfaim and not have to admit to knowing how they work. */ | |
| 184 | #define yahoo_put16(buf, data) ( \ | |
| 185 | (*(buf) = (unsigned char)((data)>>8)&0xff), \ | |
| 186 | (*((buf)+1) = (unsigned char)(data)&0xff), \ | |
| 187 | 2) | |
| 188 | #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff)) | |
| 189 | #define yahoo_put32(buf, data) ( \ | |
| 190 | (*((buf)) = (unsigned char)((data)>>24)&0xff), \ | |
| 191 | (*((buf)+1) = (unsigned char)((data)>>16)&0xff), \ | |
| 192 | (*((buf)+2) = (unsigned char)((data)>>8)&0xff), \ | |
| 193 | (*((buf)+3) = (unsigned char)(data)&0xff), \ | |
| 194 | 4) | |
| 195 | #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \ | |
| 196 | (((*((buf)+1))<<16)&0x00ff0000) + \ | |
| 197 | (((*((buf)+2))<< 8)&0x0000ff00) + \ | |
| 198 | (((*((buf)+3) )&0x000000ff))) | |
| 199 | ||
| 200 | ||
| 6729 | 201 | struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id); |
| 202 | void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value); | |
| 203 | int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt); | |
| 7651 | 204 | void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data); |
| 205 | int yahoo_packet_length(struct yahoo_packet *pkt); | |
| 6729 | 206 | void yahoo_packet_free(struct yahoo_packet *pkt); |
| 207 | ||
| 208 | /* util.c */ | |
| 6513 | 209 | void yahoo_init_colorht(); |
| 210 | void yahoo_dest_colorht(); | |
| 6629 | 211 | char *yahoo_codes_to_html(const char *x); |
| 212 | char *yahoo_html_to_codes(const char *src); | |
| 6513 | 213 | |
| 7827 | 214 | /** |
| 215 | * Encode some text to send to the yahoo server. | |
| 216 | * | |
| 217 | * @param gc The connection handle. | |
| 218 | * @param str The null terminated utf8 string to encode. | |
| 219 | * @param utf8 If not @c NULL, whether utf8 is okay or not. | |
| 220 | * Even if it is okay, we may not use it. If we | |
| 221 | * used it, we set this to @c TRUE, else to | |
| 222 | * @c FALSE. If @c NULL, false is assumed, and | |
| 223 | * it is not dereferenced. | |
| 224 | * @return The g_malloced string in the appropriate encoding. | |
| 225 | */ | |
| 226 | char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8); | |
| 227 | ||
| 228 | /** | |
| 229 | * Decode some text received from the server. | |
| 230 | * | |
| 231 | * @param gc The gc handle. | |
| 232 | * @param str The null terminated string to decode. | |
| 233 | * @param utf8 Did the server tell us it was supposed to be utf8? | |
| 234 | * @return The decoded, utf-8 string, which must be g_free()'d. | |
| 235 | */ | |
| 236 | char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8); | |
| 237 | ||
| 9220 | 238 | /* previously-static functions, now needed for yahoo_profile.c */ |
| 239 | char *yahoo_tooltip_text(GaimBuddy *b); | |
| 240 | ||
| 9161 | 241 | /* yahoo_profile.c */ |
| 242 | void yahoo_get_info(GaimConnection *gc, const char *name); | |
| 243 | ||
| 6513 | 244 | #endif /* _YAHOO_H_ */ |