Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 9595:7541a9bee2cd
[gaim-migrate @ 10438]
I combined oscar_encoding_parse() and oscar_encoding_to_utf8() in oscar.c
No functionality change, but I think this makes it a bit easier to follow.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 25 Jul 2004 22:44:44 +0000 |
| parents | 70fe6ef5d3a3 |
| children | c001be3c330e |
| rev | line source |
|---|---|
| 2086 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 6302 | 5 * Some code copyright (C) 1999-2001, Eric Warmenhoven |
| 6 * Some code copyright (C) 2001-2003, Sean Egan | |
| 8151 | 7 * Some code copyright (C) 2001-2004, Mark Doliner <thekingant@users.sourceforge.net> |
| 6302 | 8 * |
| 9 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
| 8151 | 10 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
| 2086 | 11 * |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU General Public License as published by | |
| 14 * the Free Software Foundation; either version 2 of the License, or | |
| 15 * (at your option) any later version. | |
| 16 * | |
| 17 * This program is distributed in the hope that it will be useful, | |
| 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 * GNU General Public License for more details. | |
| 21 * | |
| 22 * You should have received a copy of the GNU General Public License | |
| 23 * along with this program; if not, write to the Free Software | |
| 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 25 * | |
| 26 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
27 #include "internal.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 #include "account.h" |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
30 #include "accountopt.h" |
| 8476 | 31 #include "away.h" |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
33 #include "conversation.h" |
|
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
34 #include "core.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
35 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "ft.h" |
| 6982 | 37 #include "imgstore.h" |
| 2086 | 38 #include "multi.h" |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
39 #include "network.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
40 #include "notify.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
41 #include "privacy.h" |
| 2086 | 42 #include "prpl.h" |
| 4889 | 43 #include "proxy.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
44 #include "request.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
45 #include "util.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
46 |
| 2086 | 47 #include "aim.h" |
| 5842 | 48 #include "md5.h" |
| 2086 | 49 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
50 #define UC_AOL 0x02 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
51 #define UC_ADMIN 0x04 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
52 #define UC_UNCONFIRMED 0x08 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
53 #define UC_NORMAL 0x10 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
54 #define UC_AB 0x20 |
| 3079 | 55 #define UC_WIRELESS 0x40 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
56 |
| 2086 | 57 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
| 58 | |
| 7283 | 59 #define OSCAR_CONNECT_STEPS 6 |
| 60 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
61 static GaimPlugin *my_protocol = NULL; |
| 4249 | 62 |
| 7376 | 63 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
| 64 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
| 3458 | 65 |
| 4665 | 66 static fu8_t features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
| 67 static fu8_t features_icq[] = {0x01, 0x06}; | |
| 8341 | 68 static fu8_t ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 2086 | 69 |
| 7283 | 70 typedef struct _OscarData OscarData; |
| 71 struct _OscarData { | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
72 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
73 aim_conn_t *conn; |
| 2086 | 74 |
| 75 guint cnpa; | |
| 76 guint paspa; | |
| 3694 | 77 guint emlpa; |
| 4804 | 78 guint icopa; |
| 2086 | 79 |
| 4823 | 80 gboolean iconconnecting; |
| 5842 | 81 gboolean set_icon; |
| 4823 | 82 |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
83 GSList *create_rooms; |
| 2086 | 84 |
| 85 gboolean conf; | |
| 86 gboolean reqemail; | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
87 gboolean setemail; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
88 char *email; |
| 2979 | 89 gboolean setnick; |
| 90 char *newsn; | |
| 2086 | 91 gboolean chpass; |
| 92 char *oldp; | |
| 93 char *newp; | |
| 5842 | 94 |
| 2086 | 95 GSList *oscar_chats; |
| 96 GSList *direct_ims; | |
| 3630 | 97 GSList *file_transfers; |
| 4738 | 98 GHashTable *buddyinfo; |
| 4804 | 99 GSList *requesticon; |
| 2086 | 100 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
101 gboolean killme; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
102 gboolean icq; |
| 4804 | 103 guint icontimer; |
| 5968 | 104 guint getblisttimer; |
| 8341 | 105 guint getinfotimer; |
| 2993 | 106 |
| 107 struct { | |
| 4230 | 108 guint maxwatchers; /* max users who can watch you */ |
| 2993 | 109 guint maxbuddies; /* max users you can watch */ |
| 4230 | 110 guint maxgroups; /* max groups in server list */ |
| 2993 | 111 guint maxpermits; /* max users on permit list */ |
| 112 guint maxdenies; /* max users on deny list */ | |
| 113 guint maxsiglen; /* max size (bytes) of profile */ | |
| 114 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
| 115 } rights; | |
| 2086 | 116 }; |
| 117 | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
118 struct create_room { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
119 char *name; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
120 int exchange; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
121 }; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
122 |
| 2086 | 123 struct chat_connection { |
| 124 char *name; | |
| 125 char *show; /* AOL did something funny to us */ | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
126 fu16_t exchange; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
127 fu16_t instance; |
| 2086 | 128 int fd; /* this is redundant since we have the conn below */ |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
129 aim_conn_t *conn; |
| 2086 | 130 int inpa; |
| 131 int id; | |
| 5575 | 132 GaimConnection *gc; /* i hate this. */ |
| 8733 | 133 GaimConversation *conv; /* bah. */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
134 int maxlen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
135 int maxvis; |
| 2086 | 136 }; |
| 137 | |
| 8971 | 138 struct oscar_direct_im { |
| 5575 | 139 GaimConnection *gc; |
| 2086 | 140 char name[80]; |
| 141 int watcher; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
142 aim_conn_t *conn; |
| 3008 | 143 gboolean connected; |
| 8978 | 144 gboolean gpc_pend; |
| 145 gboolean killme; | |
| 8984 | 146 gboolean donttryagain; |
| 2086 | 147 }; |
| 148 | |
| 149 struct ask_direct { | |
| 5575 | 150 GaimConnection *gc; |
| 2086 | 151 char *sn; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
152 char ip[64]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
153 fu8_t cookie[8]; |
| 8984 | 154 gboolean donttryagain; |
| 2086 | 155 }; |
| 156 | |
| 7011 | 157 /* |
| 158 * Various PRPL-specific buddy info that we want to keep track of | |
| 159 * Some other info is maintained by locate.c, and I'd like to move | |
| 160 * the rest of this to libfaim, mostly im.c | |
| 161 */ | |
| 4738 | 162 struct buddyinfo { |
| 163 gboolean typingnot; | |
| 6292 | 164 gchar *availmsg; |
| 6857 | 165 fu32_t ipaddr; |
| 5836 | 166 |
| 167 unsigned long ico_me_len; | |
| 168 unsigned long ico_me_csum; | |
| 169 time_t ico_me_time; | |
| 170 gboolean ico_informed; | |
| 4738 | 171 |
| 172 unsigned long ico_len; | |
| 173 unsigned long ico_csum; | |
| 174 time_t ico_time; | |
| 175 gboolean ico_need; | |
| 7406 | 176 gboolean ico_sent; |
| 2086 | 177 }; |
| 178 | |
| 4230 | 179 struct name_data { |
| 5575 | 180 GaimConnection *gc; |
| 4230 | 181 gchar *name; |
| 3453 | 182 gchar *nick; |
| 3141 | 183 }; |
| 184 | |
| 5129 | 185 static char *msgerrreason[] = { |
| 186 N_("Invalid error"), | |
| 187 N_("Invalid SNAC"), | |
| 188 N_("Rate to host"), | |
| 189 N_("Rate to client"), | |
| 190 N_("Not logged in"), | |
| 191 N_("Service unavailable"), | |
| 192 N_("Service not defined"), | |
| 193 N_("Obsolete SNAC"), | |
| 194 N_("Not supported by host"), | |
| 195 N_("Not supported by client"), | |
| 196 N_("Refused by client"), | |
| 197 N_("Reply too big"), | |
| 198 N_("Responses lost"), | |
| 199 N_("Request denied"), | |
| 200 N_("Busted SNAC payload"), | |
| 201 N_("Insufficient rights"), | |
| 202 N_("In local permit/deny"), | |
| 203 N_("Too evil (sender)"), | |
| 204 N_("Too evil (receiver)"), | |
| 205 N_("User temporarily unavailable"), | |
| 206 N_("No match"), | |
| 207 N_("List overflow"), | |
| 208 N_("Request ambiguous"), | |
| 209 N_("Queue full"), | |
| 210 N_("Not while on AOL") | |
| 211 }; | |
| 212 static int msgerrreasonlen = 25; | |
| 213 | |
| 214 /* All the libfaim->gaim callback functions */ | |
| 215 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); | |
| 216 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); | |
| 217 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); | |
| 218 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); | |
| 219 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); | |
| 220 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); | |
| 221 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); | |
| 222 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); | |
| 223 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); | |
| 224 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); | |
| 7011 | 225 static int gaim_parse_userinfo (aim_session_t *, aim_frame_t *, ...); |
| 8341 | 226 static int gaim_reqinfo_timeout (aim_session_t *, aim_frame_t *, ...); |
| 5129 | 227 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
| 228 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
229 static int gaim_conv_chat_join (aim_session_t *, aim_frame_t *, ...); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
230 static int gaim_conv_chat_leave (aim_session_t *, aim_frame_t *, ...); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
231 static int gaim_conv_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
232 static int gaim_conv_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
| 5129 | 233 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
| 234 static int gaim_icon_error (aim_session_t *, aim_frame_t *, ...); | |
| 235 static int gaim_icon_parseicon (aim_session_t *, aim_frame_t *, ...); | |
| 5844 | 236 static int oscar_icon_req (aim_session_t *, aim_frame_t *, ...); |
| 5129 | 237 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
| 238 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); | |
| 239 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); | |
| 240 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); | |
| 241 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); | |
| 242 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); | |
| 243 static int gaim_connerr (aim_session_t *, aim_frame_t *, ...); | |
| 244 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); | |
| 245 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); | |
| 246 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); | |
| 247 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); | |
| 248 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); | |
| 249 static int conninitdone_icon (aim_session_t *, aim_frame_t *, ...); | |
| 250 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); | |
| 251 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); | |
| 252 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); | |
| 253 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); | |
| 254 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); | |
| 255 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); | |
| 256 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); | |
| 257 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); | |
| 258 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); | |
| 259 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); | |
| 260 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); | |
| 261 static int gaim_icqalias (aim_session_t *, aim_frame_t *, ...); | |
| 262 static int gaim_icqinfo (aim_session_t *, aim_frame_t *, ...); | |
| 263 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); | |
| 264 #ifndef NOSSI | |
| 265 static int gaim_ssi_parseerr (aim_session_t *, aim_frame_t *, ...); | |
| 266 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); | |
| 267 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
| 268 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); | |
| 8227 | 269 static int gaim_ssi_parseadd (aim_session_t *, aim_frame_t *, ...); |
| 5129 | 270 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); |
| 271 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
| 272 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
| 273 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
| 274 #endif | |
| 275 | |
| 276 /* for DirectIM/image transfer */ | |
| 277 static int gaim_odc_initiate (aim_session_t *, aim_frame_t *, ...); | |
| 278 static int gaim_odc_incoming (aim_session_t *, aim_frame_t *, ...); | |
| 279 static int gaim_odc_typing (aim_session_t *, aim_frame_t *, ...); | |
| 6982 | 280 static int gaim_odc_update_ui (aim_session_t *, aim_frame_t *, ...); |
| 5129 | 281 |
| 282 /* for file transfer */ | |
| 283 static int oscar_sendfile_estblsh(aim_session_t *, aim_frame_t *, ...); | |
| 284 static int oscar_sendfile_prompt (aim_session_t *, aim_frame_t *, ...); | |
| 285 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | |
| 286 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | |
| 287 | |
| 288 /* for icons */ | |
| 289 static gboolean gaim_icon_timerfunc(gpointer data); | |
| 290 | |
| 8971 | 291 /* just because */ |
| 292 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | |
| 8983 | 293 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); |
| 8971 | 294 |
| 8076 | 295 /* remove these at some point? */ |
| 7282 | 296 /* Because I don't like forward declarations? I think that was why... */ |
| 5954 | 297 static void oscar_set_info(GaimConnection *gc, const char *text); |
| 8076 | 298 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message); |
| 5306 | 299 |
| 5836 | 300 static void oscar_free_name_data(struct name_data *data) { |
| 4230 | 301 g_free(data->name); |
| 302 g_free(data->nick); | |
| 303 g_free(data); | |
| 304 } | |
| 305 | |
| 5836 | 306 static void oscar_free_buddyinfo(void *data) { |
| 307 struct buddyinfo *bi = data; | |
| 6292 | 308 g_free(bi->availmsg); |
| 5836 | 309 g_free(bi); |
| 310 } | |
| 311 | |
| 5129 | 312 static fu32_t oscar_encoding_check(const char *utf8) |
| 313 { | |
| 314 int i = 0; | |
| 315 fu32_t encodingflag = 0; | |
| 316 | |
| 317 /* Determine how we can send this message. Per the warnings elsewhere | |
| 318 * in this file, these little checks determine the simplest encoding | |
| 319 * we can use for a given message send using it. */ | |
| 320 while (utf8[i]) { | |
| 321 if ((unsigned char)utf8[i] > 0x7f) { | |
| 322 /* not ASCII! */ | |
| 323 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
| 324 break; | |
| 325 } | |
| 326 i++; | |
| 327 } | |
| 328 while (utf8[i]) { | |
| 329 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
| 330 * followed by 0xc0-0xc3 in the second */ | |
| 331 if ((unsigned char)utf8[i] < 0x80) { | |
| 332 i++; | |
| 333 continue; | |
| 334 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
| 335 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
| 336 i += 2; | |
| 337 continue; | |
| 338 } | |
| 339 encodingflag = AIM_IMFLAGS_UNICODE; | |
| 340 break; | |
| 341 } | |
| 342 | |
| 343 return encodingflag; | |
| 344 } | |
| 345 | |
| 8225 | 346 /* |
| 347 * Take a string of the form charset="bleh" where bleh is | |
| 348 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and | |
| 349 * return a newly allocated string containing bleh. | |
| 350 */ | |
| 351 static gchar *oscar_encoding_extract(const char *encoding) | |
| 5129 | 352 { |
| 8225 | 353 gchar *ret = NULL; |
| 354 char *begin, *end; | |
| 355 | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
356 /* Make sure encoding begins with charset= */ |
| 8225 | 357 if (strncmp(encoding, "text/aolrtf; charset=", 21)) |
| 358 return NULL; | |
| 359 | |
| 360 begin = strchr(encoding, '"'); | |
| 361 end = strrchr(encoding, '"'); | |
| 362 | |
| 363 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
| 364 return NULL; | |
| 365 | |
| 366 ret = g_strndup(begin+1, (end-1) - begin); | |
| 367 | |
| 368 return ret; | |
| 369 } | |
| 370 | |
| 8233 | 371 gchar *oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) |
| 5129 | 372 { |
| 373 gchar *utf8 = NULL; | |
| 9595 | 374 |
| 375 if ((encoding == NULL) || encoding[0] == '\0') { | |
| 376 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
| 377 | |
| 378 } else if (!strcmp(encoding, "iso-8859-1")) { | |
| 379 utf8 = g_convert(text, textlen, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
| 380 | |
| 381 } else if (!strcmp(encoding, "unicode-2-0")) { | |
| 382 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
| 383 | |
| 384 } else if (strcmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { | |
| 385 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " | |
| 386 "attempting to convert to UTF-8 anyway\n"); | |
| 387 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); | |
| 388 } | |
| 389 | |
| 390 /* | |
| 391 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
| 392 * we have been unable to convert the text to utf-8 from the encoding | |
| 393 * that was specified. So we check if the text is valid utf-8 then | |
| 394 * just copy it. | |
| 395 */ | |
| 396 if (utf8 == NULL) { | |
| 9476 | 397 if (!g_utf8_validate(text, textlen, NULL)) |
| 398 utf8 = g_strdup(_("(There was an error converting this message. The buddy you are speaking to most likely has a buggy client.)")); | |
| 399 else | |
| 9481 | 400 utf8 = g_strndup(text, textlen); |
| 5129 | 401 } |
| 402 | |
| 403 return utf8; | |
| 404 } | |
| 405 | |
| 9407 | 406 gchar *oscar_caps_to_string(guint caps) |
| 8701 | 407 { |
| 9407 | 408 GString *str; |
| 409 gchar *tmp; | |
| 8701 | 410 guint bit = 1; |
| 411 | |
| 9407 | 412 str = g_string_new(""); |
| 413 | |
| 8701 | 414 if (!caps) { |
| 415 return NULL; | |
| 416 } else while (bit <= AIM_CAPS_LAST) { | |
| 417 if (bit & caps) { | |
| 418 switch (bit) { | |
| 419 case AIM_CAPS_BUDDYICON: | |
| 420 tmp = _("Buddy Icon"); | |
| 421 break; | |
| 422 case AIM_CAPS_TALK: | |
| 423 tmp = _("Voice"); | |
| 424 break; | |
| 425 case AIM_CAPS_DIRECTIM: | |
| 426 tmp = _("AIM Direct IM"); | |
| 427 break; | |
| 428 case AIM_CAPS_CHAT: | |
| 429 tmp = _("Chat"); | |
| 430 break; | |
| 431 case AIM_CAPS_GETFILE: | |
| 432 tmp = _("Get File"); | |
| 433 break; | |
| 434 case AIM_CAPS_SENDFILE: | |
| 435 tmp = _("Send File"); | |
| 436 break; | |
| 437 case AIM_CAPS_GAMES: | |
| 438 case AIM_CAPS_GAMES2: | |
| 439 tmp = _("Games"); | |
| 440 break; | |
| 441 case AIM_CAPS_ADDINS: | |
| 442 tmp = _("Add-Ins"); | |
| 443 break; | |
| 444 case AIM_CAPS_SENDBUDDYLIST: | |
| 445 tmp = _("Send Buddy List"); | |
| 446 break; | |
| 447 case AIM_CAPS_ICQ_DIRECT: | |
| 448 tmp = _("ICQ Direct Connect"); | |
| 449 break; | |
| 450 case AIM_CAPS_APINFO: | |
| 451 tmp = _("AP User"); | |
| 452 break; | |
| 453 case AIM_CAPS_ICQRTF: | |
| 454 tmp = _("ICQ RTF"); | |
| 455 break; | |
| 456 case AIM_CAPS_EMPTY: | |
| 457 tmp = _("Nihilist"); | |
| 458 break; | |
| 459 case AIM_CAPS_ICQSERVERRELAY: | |
| 460 tmp = _("ICQ Server Relay"); | |
| 461 break; | |
| 462 case AIM_CAPS_ICQUTF8OLD: | |
| 463 tmp = _("Old ICQ UTF8"); | |
| 464 break; | |
| 465 case AIM_CAPS_TRILLIANCRYPT: | |
| 466 tmp = _("Trillian Encryption"); | |
| 467 break; | |
| 468 case AIM_CAPS_ICQUTF8: | |
| 469 tmp = _("ICQ UTF8"); | |
| 470 break; | |
| 471 case AIM_CAPS_HIPTOP: | |
| 472 tmp = _("Hiptop"); | |
| 473 break; | |
| 474 case AIM_CAPS_SECUREIM: | |
| 475 tmp = _("Security Enabled"); | |
| 476 break; | |
| 477 case AIM_CAPS_VIDEO: | |
| 478 tmp = _("Video Chat"); | |
| 479 break; | |
| 480 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
| 481 case AIM_CAPS_ICHATAV: | |
| 482 tmp = _("iChat AV"); | |
| 483 break; | |
| 484 case AIM_CAPS_LIVEVIDEO: | |
| 485 tmp = _("Live Video"); | |
| 486 break; | |
| 487 case AIM_CAPS_CAMERA: | |
| 488 tmp = _("Camera"); | |
| 489 break; | |
| 490 default: | |
| 491 tmp = NULL; | |
| 492 break; | |
| 493 } | |
| 494 if (tmp) | |
| 9532 | 495 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
| 8701 | 496 } |
| 497 bit <<= 1; | |
| 498 } | |
| 9407 | 499 |
| 500 return g_string_free(str, FALSE); | |
| 8701 | 501 } |
| 502 | |
| 503 static char *oscar_icqstatus(int state) { | |
| 504 /* Make a cute little string that shows the status of the dude or dudet */ | |
| 505 if (state & AIM_ICQ_STATE_CHAT) | |
| 506 return g_strdup_printf(_("Free For Chat")); | |
| 507 else if (state & AIM_ICQ_STATE_DND) | |
| 508 return g_strdup_printf(_("Do Not Disturb")); | |
| 509 else if (state & AIM_ICQ_STATE_OUT) | |
| 510 return g_strdup_printf(_("Not Available")); | |
| 511 else if (state & AIM_ICQ_STATE_BUSY) | |
| 512 return g_strdup_printf(_("Occupied")); | |
| 513 else if (state & AIM_ICQ_STATE_AWAY) | |
| 514 return g_strdup_printf(_("Away")); | |
| 515 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
| 516 return g_strdup_printf(_("Web Aware")); | |
| 517 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
| 518 return g_strdup_printf(_("Invisible")); | |
| 519 else | |
| 520 return g_strdup_printf(_("Online")); | |
| 521 } | |
| 522 | |
| 523 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
| 8700 | 524 { |
| 525 gchar *utf8; | |
| 526 | |
| 527 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
| 8701 | 528 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
| 8700 | 529 g_free(utf8); |
| 530 } | |
| 531 } | |
| 532 | |
| 8701 | 533 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
| 534 { | |
| 535 OscarData *od = gc->proto_data; | |
| 536 GaimAccount *account = gaim_connection_get_account(gc); | |
| 537 GaimGroup *g = NULL; | |
| 538 struct buddyinfo *bi = NULL; | |
| 539 char *tmp; | |
| 540 | |
| 541 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
| 542 return; | |
| 543 | |
| 544 if (userinfo == NULL) | |
| 545 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
| 546 | |
| 547 if (b == NULL) | |
| 548 b = gaim_find_buddy(gc->account, userinfo->sn); | |
| 549 | |
| 550 if (b != NULL) | |
| 551 g = gaim_find_buddys_group(b); | |
| 552 | |
| 553 if (userinfo != NULL) | |
| 554 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
| 555 | |
| 8733 | 556 if (b != NULL) { |
| 557 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
| 558 if (isdigit(b->name[0])) { | |
| 559 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
| 560 oscar_string_append(str, newline, _("Status"), tmp); | |
| 561 g_free(tmp); | |
| 562 } | |
| 563 } else { | |
| 564 char *tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
| 565 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) | |
| 566 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
| 567 else | |
| 568 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
| 8701 | 569 } |
| 8733 | 570 } |
| 8701 | 571 |
| 572 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
| 573 char *tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
| 574 (bi->ipaddr & 0xff000000) >> 24, | |
| 575 (bi->ipaddr & 0x00ff0000) >> 16, | |
| 576 (bi->ipaddr & 0x0000ff00) >> 8, | |
| 577 (bi->ipaddr & 0x000000ff)); | |
| 578 oscar_string_append(str, newline, _("IP Address"), tmp); | |
| 579 g_free(tmp); | |
| 580 } | |
| 581 | |
| 582 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
| 583 tmp = oscar_caps_to_string(userinfo->capabilities); | |
| 584 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
| 9407 | 585 g_free(tmp); |
| 8701 | 586 } |
| 587 | |
| 588 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
| 589 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
| 590 if (tmp != NULL) { | |
| 591 oscar_string_append(str, newline, _("Buddy Comment"), tmp); | |
| 592 g_free(tmp); | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
| 597 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
| 598 oscar_string_append(str, newline, _("Available"), tmp); | |
| 599 g_free(tmp); | |
| 600 } | |
| 601 } | |
| 602 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
603 static char *extract_name(const char *name) { |
| 4121 | 604 char *tmp, *x; |
| 2086 | 605 int i, j; |
| 4120 | 606 |
| 607 if (!name) | |
| 4121 | 608 return NULL; |
| 609 | |
| 4120 | 610 x = strchr(name, '-'); |
| 4121 | 611 |
| 2086 | 612 if (!x) return NULL; |
| 613 x = strchr(++x, '-'); | |
| 614 if (!x) return NULL; | |
| 615 tmp = g_strdup(++x); | |
| 616 | |
| 617 for (i = 0, j = 0; x[i]; i++) { | |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
618 char hex[3]; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
619 if (x[i] != '%') { |
| 2086 | 620 tmp[j++] = x[i]; |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
621 continue; |
| 2086 | 622 } |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
623 strncpy(hex, x + ++i, 2); hex[2] = 0; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
624 i++; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
625 tmp[j++] = strtol(hex, NULL, 16); |
| 2086 | 626 } |
| 627 | |
| 628 tmp[j] = 0; | |
| 629 return tmp; | |
| 630 } | |
| 631 | |
| 5575 | 632 static struct chat_connection *find_oscar_chat(GaimConnection *gc, int id) { |
| 7283 | 633 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
| 2086 | 634 struct chat_connection *c = NULL; |
| 635 | |
| 636 while (g) { | |
| 637 c = (struct chat_connection *)g->data; | |
| 638 if (c->id == id) | |
| 639 break; | |
| 640 g = g->next; | |
| 641 c = NULL; | |
| 642 } | |
| 643 | |
| 644 return c; | |
| 645 } | |
| 646 | |
| 5575 | 647 static struct chat_connection *find_oscar_chat_by_conn(GaimConnection *gc, |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
648 aim_conn_t *conn) { |
| 7283 | 649 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; |
| 2086 | 650 struct chat_connection *c = NULL; |
| 651 | |
| 652 while (g) { | |
| 653 c = (struct chat_connection *)g->data; | |
| 654 if (c->conn == conn) | |
| 655 break; | |
| 656 g = g->next; | |
| 657 c = NULL; | |
| 658 } | |
| 659 | |
| 660 return c; | |
| 661 } | |
| 662 | |
| 8219 | 663 static struct chat_connection *find_oscar_chat_by_conv(GaimConnection *gc, |
| 664 GaimConversation *conv) { | |
| 665 GSList *g = ((OscarData *)gc->proto_data)->oscar_chats; | |
| 666 struct chat_connection *c = NULL; | |
| 667 | |
| 668 while (g) { | |
| 669 c = (struct chat_connection *)g->data; | |
| 8733 | 670 if (c->conv == conv) |
| 8219 | 671 break; |
| 672 g = g->next; | |
| 673 c = NULL; | |
| 674 } | |
| 675 | |
| 676 return c; | |
| 677 } | |
| 678 | |
| 8971 | 679 /***************************************************************************** |
| 680 * Begin scary direct im stuff | |
| 681 *****************************************************************************/ | |
| 682 | |
| 683 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
| 684 GSList *d = od->direct_ims; | |
| 685 struct oscar_direct_im *m = NULL; | |
| 686 | |
| 687 while (d) { | |
| 688 m = (struct oscar_direct_im *)d->data; | |
| 689 if (!aim_sncmp(who, m->name)) | |
| 690 return m; | |
| 691 d = d->next; | |
| 692 } | |
| 693 | |
| 694 return NULL; | |
| 695 } | |
| 696 | |
| 697 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
| 698 { | |
| 699 gaim_debug_info("oscar", | |
| 700 "destroying Direct IM for %s.\n", dim->name); | |
| 701 | |
| 702 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
| 8978 | 703 if (dim->gpc_pend) { |
| 704 dim->killme = TRUE; | |
| 705 return; | |
| 706 } | |
| 8971 | 707 if (dim->watcher) |
| 708 gaim_input_remove(dim->watcher); | |
| 709 if (dim->conn) { | |
| 710 aim_conn_close(dim->conn); | |
| 711 aim_conn_kill(od->sess, &dim->conn); | |
| 712 } | |
| 713 g_free(dim); | |
| 714 } | |
| 715 | |
| 716 /* the only difference between this and destroy is this writes a conv message */ | |
| 717 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
| 718 { | |
| 719 GaimConversation *conv; | |
| 720 char buf[256]; | |
| 721 | |
| 722 gaim_debug_info("oscar", | |
| 723 "%s disconnected Direct IM.\n", dim->name); | |
| 724 | |
| 725 if (dim->connected) | |
| 726 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
| 8978 | 727 else |
| 8971 | 728 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
| 729 | |
| 730 conv = gaim_find_conversation_with_account(dim->name, gaim_connection_get_account(dim->gc)); | |
| 731 if (conv) { | |
| 732 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 9463 | 733 gaim_conversation_update_progress(conv, 0); |
| 8971 | 734 } else { |
| 735 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
| 736 } | |
| 737 | |
| 738 oscar_direct_im_destroy(od, dim); | |
| 739 | |
| 740 return; | |
| 741 } | |
| 742 | |
| 743 /* oops i made two of these. this one just calls the other one. */ | |
| 744 static void gaim_odc_disconnect(aim_session_t *sess, aim_conn_t *conn) | |
| 745 { | |
| 746 GaimConnection *gc = sess->aux_data; | |
| 747 OscarData *od = (OscarData *)gc->proto_data; | |
| 748 struct oscar_direct_im *dim; | |
| 749 char *sn; | |
| 750 | |
| 751 sn = g_strdup(aim_odc_getsn(conn)); | |
| 752 dim = oscar_direct_im_find(od, sn); | |
| 753 oscar_direct_im_disconnect(od, dim); | |
| 754 g_free(sn); | |
| 755 } | |
| 756 | |
| 757 static void destroy_direct_im_request(struct ask_direct *d) { | |
| 758 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
| 759 | |
| 760 g_free(d->sn); | |
| 761 g_free(d); | |
| 762 } | |
| 763 | |
| 764 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
| 765 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
| 766 struct oscar_direct_im *dim = data; | |
| 767 GaimConnection *gc = dim->gc; | |
| 768 OscarData *od = gc->proto_data; | |
| 769 GaimConversation *conv; | |
| 770 char buf[256]; | |
| 771 struct sockaddr name; | |
| 772 socklen_t name_len = 1; | |
| 773 | |
| 774 g_return_if_fail(gc != NULL); | |
| 775 | |
| 8978 | 776 dim->gpc_pend = FALSE; |
| 777 if (dim->killme) { | |
| 778 oscar_direct_im_destroy(od, dim); | |
| 779 return; | |
| 780 } | |
| 781 | |
| 8971 | 782 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 783 oscar_direct_im_destroy(od, dim); | |
| 784 return; | |
| 785 } | |
| 786 | |
| 787 if (source < 0) { | |
| 8984 | 788 if (dim->donttryagain) { |
| 789 oscar_direct_im_disconnect(od, dim); | |
| 790 return; | |
| 791 } else { | |
| 792 fu8_t cookie[8]; | |
| 793 char *who = g_strdup(dim->name); | |
| 794 const char *tmp = aim_odc_getcookie(dim->conn); | |
| 795 | |
| 796 memcpy(cookie, tmp, 8); | |
| 797 oscar_direct_im_destroy(od, dim); | |
| 798 oscar_direct_im_initiate(gc, who, cookie); | |
| 799 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
| 800 g_free(who); | |
| 801 return; | |
| 802 } | |
| 8971 | 803 } |
| 804 | |
| 805 dim->conn->fd = source; | |
| 806 aim_conn_completeconnect(od->sess, dim->conn); | |
| 807 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, dim->name); | |
| 808 | |
| 809 /* This is the best way to see if we're connected or not */ | |
| 8983 | 810 /* Is this really needed? */ |
| 8971 | 811 if (getpeername(source, &name, &name_len) == 0) { |
| 812 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
| 813 dim->connected = TRUE; | |
| 814 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 8983 | 815 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
| 816 } else { | |
| 8984 | 817 if (dim->donttryagain) { |
| 818 oscar_direct_im_disconnect(od, dim); | |
| 819 return; | |
| 820 } else { | |
| 821 fu8_t cookie[8]; | |
| 822 char *who = g_strdup(dim->name); | |
| 823 const char *tmp = aim_odc_getcookie(dim->conn); | |
| 824 | |
| 825 memcpy(cookie, tmp, 8); | |
| 826 oscar_direct_im_destroy(od, dim); | |
| 827 oscar_direct_im_initiate(gc, who, cookie); | |
| 828 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
| 829 g_free(who); | |
| 830 return; | |
| 831 } | |
| 8983 | 832 } |
| 833 | |
| 834 | |
| 8971 | 835 } |
| 836 | |
| 837 static void accept_direct_im_request(struct ask_direct *d) { | |
| 838 GaimConnection *gc = d->gc; | |
| 839 OscarData *od; | |
| 840 struct oscar_direct_im *dim; | |
| 841 char *host; int port = 5190; | |
| 842 int i, rc; | |
| 8982 | 843 char *tmp; |
| 844 GaimConversation *conv; | |
| 8971 | 845 |
| 846 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 847 destroy_direct_im_request(d); | |
| 848 return; | |
| 849 } | |
| 850 | |
| 851 od = (OscarData *)gc->proto_data; | |
| 852 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
| 853 | |
| 854 dim = oscar_direct_im_find(od, d->sn); | |
| 855 if (dim && dim->connected) { | |
| 856 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
| 857 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
| 858 return; | |
| 859 } | |
| 860 dim = g_new0(struct oscar_direct_im, 1); | |
| 861 dim->gc = d->gc; | |
| 8984 | 862 dim->donttryagain = d->donttryagain; |
| 8971 | 863 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
| 864 | |
| 865 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
| 866 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
| 867 if (!dim->conn) { | |
| 868 oscar_direct_im_disconnect(od, dim); | |
| 869 destroy_direct_im_request(d); | |
| 870 return; | |
| 871 } | |
| 872 | |
| 873 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
| 874 gaim_odc_incoming, 0); | |
| 875 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
| 876 gaim_odc_typing, 0); | |
| 877 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, | |
| 878 gaim_odc_update_ui, 0); | |
| 879 | |
| 880 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
| 881 for (i = 0; i < (int)strlen(d->ip); i++) { | |
| 882 if (d->ip[i] == ':') { | |
| 883 port = atoi(&(d->ip[i+1])); | |
| 884 break; | |
| 885 } | |
| 886 } | |
| 887 host = g_strndup(d->ip, i); | |
| 888 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 8978 | 889 dim->gpc_pend = TRUE; |
| 8971 | 890 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
| 8982 | 891 |
| 892 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, d->sn); | |
| 893 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), d->sn, host, | |
| 894 port); | |
| 895 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 896 g_free(tmp); | |
| 8983 | 897 |
| 8971 | 898 g_free(host); |
| 899 if (rc < 0) { | |
| 8978 | 900 dim->gpc_pend = FALSE; |
| 8971 | 901 oscar_direct_im_disconnect(od, dim); |
| 902 destroy_direct_im_request(d); | |
| 903 return; | |
| 904 } | |
| 905 | |
| 906 destroy_direct_im_request(d); | |
| 907 | |
| 908 return; | |
| 909 } | |
| 910 | |
| 911 /* | |
| 912 * We have just established a socket with the other dude, so set up some handlers. | |
| 913 */ | |
| 914 static int gaim_odc_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 915 GaimConnection *gc = sess->aux_data; |
| 7283 | 916 OscarData *od = (OscarData *)gc->proto_data; |
| 8733 | 917 GaimConversation *conv; |
| 8971 | 918 struct oscar_direct_im *dim; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
919 char buf[256]; |
| 8971 | 920 char *sn; |
| 921 va_list ap; | |
| 922 aim_conn_t *newconn, *listenerconn; | |
| 923 | |
| 924 va_start(ap, fr); | |
| 925 newconn = va_arg(ap, aim_conn_t *); | |
| 926 listenerconn = va_arg(ap, aim_conn_t *); | |
| 927 va_end(ap); | |
| 928 | |
| 929 aim_conn_close(listenerconn); | |
| 930 aim_conn_kill(sess, &listenerconn); | |
| 931 | |
| 932 sn = g_strdup(aim_odc_getsn(newconn)); | |
| 933 | |
| 934 gaim_debug_info("oscar", | |
| 935 "DirectIM: initiate success to %s\n", sn); | |
| 936 dim = oscar_direct_im_find(od, sn); | |
| 937 | |
| 938 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, sn); | |
| 939 gaim_input_remove(dim->watcher); | |
| 940 dim->conn = newconn; | |
| 941 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
| 942 dim->connected = TRUE; | |
| 943 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
| 944 g_free(sn); | |
| 945 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 946 | |
| 947 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_odc_incoming, 0); | |
| 948 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_odc_typing, 0); | |
| 949 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
| 950 | |
| 951 return 1; | |
| 952 } | |
| 953 | |
| 954 /* | |
| 955 * This is called when each chunk of an image is received. It can be used to | |
| 956 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
| 957 * nasty, you sicko. | |
| 958 */ | |
| 959 static int gaim_odc_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 960 va_list ap; | |
| 961 char *sn; | |
| 962 double percent; | |
| 963 GaimConnection *gc = sess->aux_data; | |
| 964 OscarData *od = (OscarData *)gc->proto_data; | |
| 965 GaimConversation *c; | |
| 966 struct oscar_direct_im *dim; | |
| 967 | |
| 968 va_start(ap, fr); | |
| 969 sn = va_arg(ap, char *); | |
| 970 percent = va_arg(ap, double); | |
| 971 va_end(ap); | |
| 972 | |
| 973 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
| 974 return 1; | |
| 975 if (dim->watcher) { | |
| 976 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
| 977 /* The callback will callback? I don't get how that would happen here. */ | |
| 978 dim->watcher = 0; | |
| 979 } | |
| 980 | |
| 981 c = gaim_find_conversation_with_account(sn, gaim_connection_get_account(gc)); | |
| 982 if (c != NULL) | |
| 983 gaim_conversation_update_progress(c, percent); | |
| 984 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
| 985 oscar_callback, dim->conn); | |
| 986 | |
| 987 return 1; | |
| 988 } | |
| 989 | |
| 990 /* | |
| 991 * This is called after a direct IM has been received in its entirety. This | |
| 992 * function is passed a long chunk of data which contains the IM with any | |
| 993 * data chunks (images) appended to it. | |
| 994 * | |
| 995 * This function rips out all the data chunks and creates an imgstore for | |
| 996 * each one. In order to do this, it first goes through the IM and takes | |
| 997 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
| 998 * with one compatible with the imgstore Gaim core code. For each one, we | |
| 999 * then read in chunks of data from the end of the message and actually | |
| 1000 * create the img store using the given data. | |
| 1001 * | |
| 1002 * For somewhat easy reference, here's a sample message | |
| 1003 * (without the whitespace and asterisks): | |
| 1004 * | |
| 1005 * <HTML><BODY BGCOLOR="#ffffff"> | |
| 1006 * <FONT LANG="0"> | |
| 1007 * This is a really stupid picture:<BR> | |
| 1008 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
| 1009 * Yeah it is<BR> | |
| 1010 * Here is another one:<BR> | |
| 1011 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
| 1012 * </FONT> | |
| 1013 * </BODY></HTML> | |
| 1014 * <BINARY> | |
| 1015 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
| 1016 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
| 1017 * </BINARY> | |
| 1018 */ | |
| 1019 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 1020 GaimConnection *gc = sess->aux_data; | |
| 1021 GaimConvImFlags imflags = 0; | |
| 1022 gchar *utf8; | |
| 1023 GString *newmsg = g_string_new(""); | |
| 1024 GSList *images = NULL; | |
| 1025 va_list ap; | |
| 1026 const char *sn, *msg, *msgend, *binary; | |
| 1027 size_t len; | |
| 1028 int encoding, isawaymsg; | |
| 1029 | |
| 1030 va_start(ap, fr); | |
| 1031 sn = va_arg(ap, const char *); | |
| 1032 msg = va_arg(ap, const char *); | |
| 1033 len = va_arg(ap, size_t); | |
| 1034 encoding = va_arg(ap, int); | |
| 1035 isawaymsg = va_arg(ap, int); | |
| 1036 va_end(ap); | |
| 1037 msgend = msg + len; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1038 |
| 8660 | 1039 gaim_debug_info("oscar", |
| 8971 | 1040 "Got DirectIM message from %s\n", sn); |
| 1041 | |
| 1042 if (isawaymsg) | |
| 1043 imflags |= GAIM_CONV_IM_AUTO_RESP; | |
| 1044 | |
| 1045 /* message has a binary trailer */ | |
| 1046 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
| 1047 GData *attribs; | |
| 1048 const char *tmp, *start, *end, *last = NULL; | |
| 1049 | |
| 1050 tmp = msg; | |
| 1051 | |
| 1052 /* for each valid image tag... */ | |
| 1053 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
| 1054 const char *id, *src, *datasize; | |
| 1055 const char *tag = NULL, *data = NULL; | |
| 1056 size_t size; | |
| 1057 int imgid = 0; | |
| 1058 | |
| 1059 /* update the location of the last img tag */ | |
| 1060 last = end; | |
| 1061 | |
| 1062 /* grab attributes */ | |
| 1063 id = g_datalist_get_data(&attribs, "id"); | |
| 1064 src = g_datalist_get_data(&attribs, "src"); | |
| 1065 datasize = g_datalist_get_data(&attribs, "datasize"); | |
| 1066 | |
| 1067 /* if we have id & datasize, build the data tag */ | |
| 1068 if (id && datasize) | |
| 1069 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
| 1070 | |
| 1071 /* if we have a tag, find the start of the data */ | |
| 1072 if (tag && (data = gaim_strcasestr(binary, tag))) | |
| 1073 data += strlen(tag); | |
| 1074 | |
| 1075 /* check the data is here and store it */ | |
| 1076 if (data + (size = atoi(datasize)) <= msgend) | |
| 1077 imgid = gaim_imgstore_add(data, size, src); | |
| 1078 | |
| 1079 /* | |
| 1080 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
| 1081 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
| 1082 */ | |
| 1083 /* if we have a stored image... */ | |
| 1084 if (imgid) { | |
| 1085 /* append the message up to the tag */ | |
| 1086 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
| 1087 if (utf8 != NULL) { | |
| 1088 newmsg = g_string_append(newmsg, utf8); | |
| 1089 g_free(utf8); | |
| 1090 } | |
| 1091 | |
| 1092 /* write the new image tag */ | |
| 1093 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
| 1094 | |
| 1095 /* and record the image number */ | |
| 1096 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
| 1097 } else { | |
| 1098 /* otherwise, copy up to the end of the tag */ | |
| 1099 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
| 1100 if (utf8 != NULL) { | |
| 1101 newmsg = g_string_append(newmsg, utf8); | |
| 1102 g_free(utf8); | |
| 1103 } | |
| 1104 } | |
| 1105 | |
| 1106 /* clear the attribute list */ | |
| 1107 g_datalist_clear(&attribs); | |
| 1108 | |
| 1109 /* continue from the end of the tag */ | |
| 1110 tmp = end + 1; | |
| 1111 } | |
| 1112 | |
| 1113 /* append any remaining message data (without the > :-) */ | |
| 1114 if (last++ && (last < binary)) | |
| 1115 newmsg = g_string_append_len(newmsg, last, binary - last); | |
| 1116 | |
| 1117 /* set the flag if we caught any images */ | |
| 1118 if (images) | |
| 1119 imflags |= GAIM_CONV_IM_IMAGES; | |
| 1120 } else { | |
| 1121 g_string_append_len(newmsg, msg, len); | |
| 1122 } | |
| 1123 | |
| 1124 /* XXX - I imagine Paco-Paco will want to do some voodoo with the encoding here */ | |
| 1125 serv_got_im(gc, sn, newmsg->str, imflags, time(NULL)); | |
| 1126 | |
| 1127 /* free up the message */ | |
| 1128 g_string_free(newmsg, TRUE); | |
| 1129 | |
| 1130 /* unref any images we allocated */ | |
| 1131 if (images) { | |
| 1132 GSList *tmp; | |
| 1133 int id; | |
| 1134 | |
| 1135 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
| 1136 id = GPOINTER_TO_INT(tmp->data); | |
| 1137 gaim_imgstore_unref(id); | |
| 1138 } | |
| 1139 | |
| 1140 g_slist_free(images); | |
| 1141 } | |
| 1142 | |
| 1143 return 1; | |
| 1144 } | |
| 1145 | |
| 1146 static int gaim_odc_typing(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 1147 va_list ap; | |
| 1148 char *sn; | |
| 1149 int typing; | |
| 1150 GaimConnection *gc = sess->aux_data; | |
| 1151 | |
| 1152 va_start(ap, fr); | |
| 1153 sn = va_arg(ap, char *); | |
| 1154 typing = va_arg(ap, int); | |
| 1155 va_end(ap); | |
| 1156 | |
| 1157 if (typing == 0x0002) { | |
| 1158 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
| 1159 gaim_debug_info("oscar", | |
| 1160 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
| 1161 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
| 1162 } else if (typing == 0x0001) | |
| 1163 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
| 1164 else | |
| 1165 serv_got_typing_stopped(gc, sn); | |
| 1166 return 1; | |
| 1167 } | |
| 1168 | |
| 1169 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | |
| 1170 char *buf; | |
| 1171 size_t len; | |
| 1172 int ret; | |
| 1173 GString *msg = g_string_new("<HTML><BODY>"); | |
| 1174 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
| 1175 GData *attribs; | |
| 1176 const char *start, *end, *last; | |
| 1177 int oscar_id = 0; | |
| 1178 | |
| 1179 last = message; | |
| 1180 | |
| 1181 /* for each valid IMG tag... */ | |
| 1182 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
| 1183 GaimStoredImage *image = NULL; | |
| 1184 const char *id; | |
| 1185 | |
| 1186 if (start - last) { | |
| 1187 g_string_append_len(msg, last, start - last); | |
| 1188 } | |
| 1189 | |
| 1190 id = g_datalist_get_data(&attribs, "id"); | |
| 1191 | |
| 1192 /* ... if it refers to a valid gaim image ... */ | |
| 1193 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
| 1194 /* ... append the message from start to the tag ... */ | |
| 9126 | 1195 unsigned long size = gaim_imgstore_get_size(image); |
| 8971 | 1196 const char *filename = gaim_imgstore_get_filename(image); |
| 1197 gpointer imgdata = gaim_imgstore_get_data(image); | |
| 1198 | |
| 1199 oscar_id++; | |
| 1200 | |
| 1201 /* ... insert a new img tag with the oscar id ... */ | |
| 1202 if (filename) | |
| 1203 g_string_append_printf(msg, | |
| 9126 | 1204 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
| 8971 | 1205 filename, oscar_id, size); |
| 1206 else | |
| 1207 g_string_append_printf(msg, | |
| 9126 | 1208 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
| 8971 | 1209 oscar_id, size); |
| 1210 | |
| 1211 /* ... and append the data to the binary section ... */ | |
| 9126 | 1212 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
| 8971 | 1213 oscar_id, size); |
| 1214 data = g_string_append_len(data, imgdata, size); | |
| 1215 data = g_string_append(data, "</DATA>"); | |
| 1216 } | |
| 1217 /* If the tag is invalid, skip it, thus no else here */ | |
| 1218 | |
| 1219 g_datalist_clear(&attribs); | |
| 1220 | |
| 1221 /* continue from the end of the tag */ | |
| 1222 last = end + 1; | |
| 1223 } | |
| 1224 | |
| 1225 /* append any remaining message data (without the > :-) */ | |
| 1226 if (last && *last) | |
| 1227 msg = g_string_append(msg, last); | |
| 1228 | |
| 1229 /* if we inserted any images in the binary section, append it */ | |
| 1230 if (oscar_id) { | |
| 1231 msg = g_string_append_len(msg, data->str, data->len); | |
| 1232 msg = g_string_append(msg, "</BINARY>"); | |
| 1233 } | |
| 1234 | |
| 1235 len = msg->len; | |
| 1236 buf = msg->str; | |
| 1237 g_string_free(msg, FALSE); | |
| 1238 g_string_free(data, TRUE); | |
| 1239 | |
| 1240 | |
| 1241 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
| 1242 if (imflags & GAIM_CONV_IM_AUTO_RESP) | |
| 1243 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | |
| 1244 else | |
| 1245 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
| 1246 | |
| 1247 g_free(buf); | |
| 1248 | |
| 1249 return ret; | |
| 1250 } | |
| 1251 | |
| 1252 struct ask_do_dir_im { | |
| 1253 char *who; | |
| 1254 GaimConnection *gc; | |
| 1255 }; | |
| 1256 | |
| 1257 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
| 1258 g_free(data->who); | |
| 1259 g_free(data); | |
| 1260 } | |
| 1261 | |
| 8983 | 1262 /* this function is used to initiate a direct im session with someone. |
| 1263 * we start listening on a port and send a request. they either connect | |
| 1264 * or send some kind of reply. If they can't connect, they ask us to | |
| 1265 * connect to them, and so we do that. | |
| 1266 * | |
| 1267 * this function will also get called if the other side initiate's a direct | |
| 1268 * im and we try to connect and fail. in that case cookie will not be null. | |
| 1269 * | |
| 1270 * note that cookie is an 8 byte string that isn't NULL terminated | |
| 1271 */ | |
| 1272 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | |
| 8971 | 1273 OscarData *od; |
| 1274 struct oscar_direct_im *dim; | |
| 1275 int listenfd; | |
| 8982 | 1276 const char *ip; |
| 8971 | 1277 |
| 1278 od = (OscarData *)gc->proto_data; | |
| 1279 | |
| 8983 | 1280 dim = oscar_direct_im_find(od, who); |
| 8971 | 1281 if (dim) { |
| 1282 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ | |
| 1283 oscar_direct_im_disconnect(od, dim); | |
| 1284 gaim_debug_info("oscar", | |
| 1285 "Gave up on old direct IM, trying again\n"); | |
| 1286 } else { | |
| 1287 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
| 8980 | 1288 return; |
| 8971 | 1289 } |
| 1290 } | |
| 1291 dim = g_new0(struct oscar_direct_im, 1); | |
| 1292 dim->gc = gc; | |
| 8983 | 1293 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
| 8971 | 1294 |
| 1295 listenfd = gaim_network_listen_range(5190, 5199); | |
| 8982 | 1296 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
| 9455 | 1297 if (listenfd >= 0) |
| 1298 dim->conn = aim_odc_initiate(od->sess, who, listenfd, gaim_network_ip_atoi(ip), gaim_network_get_port_from_fd(listenfd), cookie); | |
| 8971 | 1299 if (dim->conn != NULL) { |
| 8982 | 1300 char *tmp; |
| 1301 GaimConversation *conv; | |
| 1302 | |
| 8971 | 1303 od->direct_ims = g_slist_append(od->direct_ims, dim); |
| 1304 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
| 1305 oscar_callback, dim->conn); | |
| 1306 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIM_ESTABLISHED, | |
| 1307 gaim_odc_initiate, 0); | |
| 8982 | 1308 |
| 8983 | 1309 conv = gaim_conversation_new(GAIM_CONV_IM, dim->gc->account, who); |
| 1310 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), who, ip, | |
| 8982 | 1311 gaim_network_get_port_from_fd(listenfd)); |
| 1312 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 1313 g_free(tmp); | |
| 8971 | 1314 } else { |
| 1315 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); | |
| 1316 oscar_direct_im_destroy(od, dim); | |
| 1317 } | |
| 8983 | 1318 } |
| 1319 | |
| 1320 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
| 1321 GaimConnection *gc = data->gc; | |
| 1322 | |
| 1323 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 1324 g_free(data->who); | |
| 1325 g_free(data); | |
| 1326 return; | |
| 1327 } | |
| 1328 | |
| 1329 oscar_direct_im_initiate(gc, data->who, NULL); | |
| 8971 | 1330 g_free(data->who); |
| 1331 g_free(data); | |
| 1332 } | |
| 1333 | |
| 1334 /* this is the right click menu cb thingy */ | |
| 9030 | 1335 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
| 1336 | |
| 1337 GaimBuddy *buddy; | |
| 1338 GaimConnection *gc; | |
| 8971 | 1339 gchar *buf; |
| 9030 | 1340 struct ask_do_dir_im *data; |
| 1341 | |
| 1342 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 1343 | |
| 1344 buddy = (GaimBuddy *) node; | |
| 1345 gc = gaim_account_get_connection(buddy->account); | |
| 1346 | |
| 1347 data = g_new0(struct ask_do_dir_im, 1); | |
| 1348 data->who = g_strdup(buddy->name); | |
| 8971 | 1349 data->gc = gc; |
| 9030 | 1350 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
| 1351 buddy->name); | |
| 8971 | 1352 |
| 1353 gaim_request_action(gc, NULL, buf, | |
| 9030 | 1354 _("Because this reveals your IP address, it " |
| 1355 "may be considered a privacy risk. Do you " | |
| 1356 "wish to continue?"), | |
| 1357 0, data, 2, | |
| 1358 _("Connect"), G_CALLBACK(oscar_direct_im), | |
| 1359 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); | |
| 8971 | 1360 g_free(buf); |
| 1361 } | |
| 1362 | |
| 1363 /***************************************************************************** | |
| 1364 * End scary direct im stuff | |
| 1365 *****************************************************************************/ | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1366 |
| 4617 | 1367 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1368 aim_conn_t *conn = (aim_conn_t *)data; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1369 aim_session_t *sess = aim_conn_getsess(conn); |
| 5575 | 1370 GaimConnection *gc = sess ? sess->aux_data : NULL; |
| 7283 | 1371 OscarData *od; |
| 2086 | 1372 |
| 1373 if (!gc) { | |
| 8660 | 1374 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1375 "oscar callback for closed connection (1).\n"); |
| 2086 | 1376 return; |
| 1377 } | |
| 1378 | |
| 7283 | 1379 od = (OscarData *)gc->proto_data; |
| 2086 | 1380 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1381 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 1382 /* oh boy. this is probably bad. i guess the only thing we |
| 1383 * can really do is return? */ | |
| 8660 | 1384 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1385 "oscar callback for closed connection (2).\n"); |
| 8660 | 1386 gaim_debug_misc("oscar", "gc = %p\n", gc); |
| 2086 | 1387 return; |
| 1388 } | |
| 1389 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1390 if (condition & GAIM_INPUT_READ) { |
| 4617 | 1391 if (conn->type == AIM_CONN_TYPE_LISTENER) { |
| 8660 | 1392 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1393 "got information on rendezvous listener\n"); |
| 4617 | 1394 if (aim_handlerendconnect(od->sess, conn) < 0) { |
| 8660 | 1395 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1396 "connection error (rendezvous listener)\n"); |
| 4617 | 1397 aim_conn_kill(od->sess, &conn); |
| 8446 | 1398 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ |
| 2086 | 1399 } |
| 1400 } else { | |
| 4617 | 1401 if (aim_get_command(od->sess, conn) >= 0) { |
| 1402 aim_rxdispatch(od->sess); | |
| 6029 | 1403 if (od->killme) { |
| 8660 | 1404 gaim_debug_error("oscar", "Waiting to be destroyed\n"); |
| 6029 | 1405 return; |
| 1406 } | |
| 2086 | 1407 } else { |
| 1408 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
| 4617 | 1409 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) { |
| 8660 | 1410 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1411 "major connection error\n"); |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1412 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 1413 } else if (conn->type == AIM_CONN_TYPE_CHAT) { |
| 1414 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
| 5420 | 1415 char *buf; |
| 8660 | 1416 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1417 "disconnected from chat room %s\n", c->name); |
| 2086 | 1418 c->conn = NULL; |
| 1419 if (c->inpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1420 gaim_input_remove(c->inpa); |
| 2086 | 1421 c->inpa = 0; |
| 1422 c->fd = -1; | |
| 4617 | 1423 aim_conn_kill(od->sess, &conn); |
| 5420 | 1424 buf = g_strdup_printf(_("You have been disconnected from chat room %s."), c->name); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1425 gaim_notify_error(gc, NULL, buf, NULL); |
| 5420 | 1426 g_free(buf); |
| 2086 | 1427 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
| 4617 | 1428 if (od->cnpa > 0) |
| 1429 gaim_input_remove(od->cnpa); | |
| 1430 od->cnpa = 0; | |
| 8660 | 1431 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1432 "removing chatnav input watcher\n"); |
| 4617 | 1433 while (od->create_rooms) { |
| 1434 struct create_room *cr = od->create_rooms->data; | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1435 g_free(cr->name); |
| 4617 | 1436 od->create_rooms = |
| 1437 g_slist_remove(od->create_rooms, cr); | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1438 g_free(cr); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1439 gaim_notify_error(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1440 _("Chat is currently unavailable"), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
1441 NULL); |
| 2086 | 1442 } |
| 4617 | 1443 aim_conn_kill(od->sess, &conn); |
| 2086 | 1444 } else if (conn->type == AIM_CONN_TYPE_AUTH) { |
| 4617 | 1445 if (od->paspa > 0) |
| 1446 gaim_input_remove(od->paspa); | |
| 1447 od->paspa = 0; | |
| 8660 | 1448 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1449 "removing authconn input watcher\n"); |
| 4617 | 1450 aim_conn_kill(od->sess, &conn); |
| 3694 | 1451 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
| 4617 | 1452 if (od->emlpa > 0) |
| 1453 gaim_input_remove(od->emlpa); | |
| 1454 od->emlpa = 0; | |
| 8660 | 1455 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1456 "removing email input watcher\n"); |
| 4617 | 1457 aim_conn_kill(od->sess, &conn); |
| 4804 | 1458 } else if (conn->type == AIM_CONN_TYPE_ICON) { |
| 1459 if (od->icopa > 0) | |
| 1460 gaim_input_remove(od->icopa); | |
| 1461 od->icopa = 0; | |
| 8660 | 1462 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1463 "removing icon input watcher\n"); |
| 4804 | 1464 aim_conn_kill(od->sess, &conn); |
| 2086 | 1465 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1466 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
| 4617 | 1467 gaim_odc_disconnect(od->sess, conn); |
| 1468 aim_conn_kill(od->sess, &conn); | |
| 2086 | 1469 } else { |
| 8660 | 1470 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1471 "holy crap! generic connection error! %hu\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1472 conn->type); |
| 4617 | 1473 aim_conn_kill(od->sess, &conn); |
| 2086 | 1474 } |
| 1475 } | |
| 1476 } | |
| 1477 } | |
| 1478 } | |
| 1479 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1480 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
| 5575 | 1481 GaimConnection *gc = sess->aux_data; |
| 7285 | 1482 gchar *s = g_strdup_vprintf(format, va); |
| 1483 gchar *buf; | |
| 1484 | |
| 1485 buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s); | |
| 8660 | 1486 gaim_debug_info("oscar", buf); |
| 7285 | 1487 if (buf[strlen(buf)-1] != '\n') |
| 8660 | 1488 gaim_debug_info(NULL, "\n"); |
| 7285 | 1489 g_free(buf); |
| 2086 | 1490 g_free(s); |
| 1491 } | |
| 1492 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1493 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1494 { |
| 5575 | 1495 GaimConnection *gc = data; |
| 7283 | 1496 OscarData *od; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1497 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1498 aim_conn_t *conn; |
| 2086 | 1499 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1500 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 1501 close(source); |
| 1502 return; | |
| 1503 } | |
| 1504 | |
| 4617 | 1505 od = gc->proto_data; |
| 1506 sess = od->sess; | |
| 2086 | 1507 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
| 4366 | 1508 conn->fd = source; |
| 2086 | 1509 |
| 1510 if (source < 0) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1511 gaim_connection_error(gc, _("Couldn't connect to host")); |
| 2086 | 1512 return; |
| 1513 } | |
| 1514 | |
| 1515 aim_conn_completeconnect(sess, conn); | |
| 4617 | 1516 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
| 7282 | 1517 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
| 1518 | |
| 8660 | 1519 gaim_debug_info("oscar", |
| 7282 | 1520 "Screen name sent, waiting for response\n"); |
| 7283 | 1521 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
| 8341 | 1522 ck[1] = 0x65; |
| 2086 | 1523 } |
| 1524 | |
| 5575 | 1525 static void oscar_login(GaimAccount *account) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1526 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1527 aim_conn_t *conn; |
| 5575 | 1528 GaimConnection *gc = gaim_account_get_connection(account); |
| 7283 | 1529 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
| 2086 | 1530 |
| 8660 | 1531 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1532 |
| 8437 | 1533 if (!aim_snvalid(gaim_account_get_username(account))) { |
| 1534 gchar *buf; | |
| 8590 | 1535 buf = g_strdup_printf(_("Unable to login: Could not sign on as %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), gaim_account_get_username(account)); |
| 8437 | 1536 gaim_connection_error(gc, buf); |
| 1537 g_free(buf); | |
| 1538 } | |
| 1539 | |
| 5575 | 1540 if (isdigit(*(gaim_account_get_username(account)))) { |
| 4617 | 1541 od->icq = TRUE; |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1542 } else { |
| 6622 | 1543 gc->flags |= GAIM_CONNECTION_HTML; |
| 1544 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1545 } |
| 5836 | 1546 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
| 2086 | 1547 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1548 sess = g_new0(aim_session_t, 1); |
| 7285 | 1549 aim_session_init(sess, TRUE, 0); |
| 2086 | 1550 aim_setdebuggingcb(sess, oscar_debug); |
| 7282 | 1551 /* |
| 1552 * We need an immediate queue because we don't use a while-loop | |
| 1553 * to see if things need to be sent. | |
| 1554 */ | |
| 2086 | 1555 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
| 4617 | 1556 od->sess = sess; |
| 2086 | 1557 sess->aux_data = gc; |
| 1558 | |
| 1559 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
| 1560 if (conn == NULL) { | |
| 8660 | 1561 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1562 "internal connection error\n"); |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1563 gaim_connection_error(gc, _("Unable to login to AIM")); |
| 2086 | 1564 return; |
| 1565 } | |
| 1566 | |
| 4649 | 1567 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2086 | 1568 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
| 1569 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
| 1570 | |
| 1571 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1572 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", FAIM_LOGIN_SERVER), |
| 5575 | 1573 gaim_account_get_int(account, "port", FAIM_LOGIN_PORT), |
| 1574 oscar_login_connect, gc) < 0) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1575 gaim_connection_error(gc, _("Couldn't connect to host")); |
| 2086 | 1576 return; |
| 1577 } | |
| 7282 | 1578 |
| 7283 | 1579 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
| 8341 | 1580 ck[0] = 0x5a; |
| 5575 | 1581 } |
| 1582 | |
| 1583 static void oscar_close(GaimConnection *gc) { | |
| 7283 | 1584 OscarData *od = (OscarData *)gc->proto_data; |
| 4617 | 1585 |
| 1586 while (od->oscar_chats) { | |
| 1587 struct chat_connection *n = od->oscar_chats->data; | |
| 2086 | 1588 if (n->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1589 gaim_input_remove(n->inpa); |
| 2086 | 1590 g_free(n->name); |
| 1591 g_free(n->show); | |
| 4617 | 1592 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
| 2086 | 1593 g_free(n); |
| 1594 } | |
| 4617 | 1595 while (od->direct_ims) { |
| 8971 | 1596 struct oscar_direct_im *n = od->direct_ims->data; |
| 1597 oscar_direct_im_destroy(od, n); | |
| 2086 | 1598 } |
| 4617 | 1599 /* BBB */ |
| 1600 while (od->file_transfers) { | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1601 GaimXfer *xfer; |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1602 xfer = (GaimXfer *)od->file_transfers->data; |
| 7805 | 1603 gaim_xfer_cancel_local(xfer); |
| 3630 | 1604 } |
| 4804 | 1605 while (od->requesticon) { |
| 1606 char *sn = od->requesticon->data; | |
| 1607 od->requesticon = g_slist_remove(od->requesticon, sn); | |
| 1608 free(sn); | |
| 1609 } | |
| 4738 | 1610 g_hash_table_destroy(od->buddyinfo); |
| 4617 | 1611 while (od->create_rooms) { |
| 1612 struct create_room *cr = od->create_rooms->data; | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1613 g_free(cr->name); |
| 4617 | 1614 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1615 g_free(cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1616 } |
| 4617 | 1617 if (od->email) |
| 1618 g_free(od->email); | |
| 1619 if (od->newp) | |
| 1620 g_free(od->newp); | |
| 1621 if (od->oldp) | |
| 1622 g_free(od->oldp); | |
| 2086 | 1623 if (gc->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1624 gaim_input_remove(gc->inpa); |
| 4617 | 1625 if (od->cnpa > 0) |
| 1626 gaim_input_remove(od->cnpa); | |
| 1627 if (od->paspa > 0) | |
| 1628 gaim_input_remove(od->paspa); | |
| 1629 if (od->emlpa > 0) | |
| 1630 gaim_input_remove(od->emlpa); | |
| 4804 | 1631 if (od->icopa > 0) |
| 1632 gaim_input_remove(od->icopa); | |
| 6907 | 1633 if (od->icontimer > 0) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1634 gaim_timeout_remove(od->icontimer); |
| 8341 | 1635 if (od->getblisttimer > 0) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1636 gaim_timeout_remove(od->getblisttimer); |
| 8341 | 1637 if (od->getinfotimer > 0) |
| 1638 gaim_timeout_remove(od->getinfotimer); | |
| 4617 | 1639 aim_session_kill(od->sess); |
| 1640 g_free(od->sess); | |
| 1641 od->sess = NULL; | |
| 2086 | 1642 g_free(gc->proto_data); |
| 1643 gc->proto_data = NULL; | |
| 8660 | 1644 gaim_debug_info("oscar", "Signed off.\n"); |
| 2086 | 1645 } |
| 1646 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1647 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 1648 GaimConnection *gc = data; |
| 7283 | 1649 OscarData *od; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1650 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1651 aim_conn_t *bosconn; |
| 2086 | 1652 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1653 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 1654 close(source); |
| 1655 return; | |
| 1656 } | |
| 1657 | |
| 4617 | 1658 od = gc->proto_data; |
| 1659 sess = od->sess; | |
| 1660 bosconn = od->conn; | |
| 4366 | 1661 bosconn->fd = source; |
| 2086 | 1662 |
| 1663 if (source < 0) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1664 gaim_connection_error(gc, _("Could Not Connect")); |
| 2086 | 1665 return; |
| 1666 } | |
| 1667 | |
| 1668 aim_conn_completeconnect(sess, bosconn); | |
| 4617 | 1669 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
| 7283 | 1670 |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1671 gaim_connection_update_progress(gc, |
| 7283 | 1672 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
| 8341 | 1673 ck[4] = 0x61; |
| 2086 | 1674 } |
| 1675 | |
| 4617 | 1676 /* BBB */ |
| 4656 | 1677 /* |
| 1678 * This little area in oscar.c is the nexus of file transfer code, | |
| 1679 * so I wrote a little explanation of what happens. I am such a | |
| 1680 * ninja. | |
| 1681 * | |
| 1682 * The series of events for a file send is: | |
| 1683 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1684 * -User chooses a file and oscar_xfer_init is called. It establishes a |
| 4656 | 1685 * listening socket, then asks the remote user to connect to us (and |
| 1686 * gives them the file name, port, IP, etc.) | |
| 1687 * -They connect to us and we send them an AIM_CB_OFT_PROMPT (this happens | |
| 1688 * in oscar_sendfile_estblsh) | |
| 1689 * -They send us an AIM_CB_OFT_ACK and then we start sending data | |
| 1690 * -When we finish, they send us an AIM_CB_OFT_DONE and they close the | |
| 1691 * connection. | |
| 1692 * -We get drunk because file transfer kicks ass. | |
| 1693 * | |
| 1694 * The series of events for a file receive is: | |
| 1695 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
| 1696 * -Gaim user selects file to name and location to save file to and | |
| 1697 * oscar_xfer_init is called | |
| 1698 * -It connects to the remote user using the IP they gave us earlier | |
| 1699 * -After connecting, they send us an AIM_CB_OFT_PROMPT. In reply, we send | |
| 1700 * them an AIM_CB_OFT_ACK. | |
| 1701 * -They begin to send us lots of raw data. | |
| 1702 * -When they finish sending data we send an AIM_CB_OFT_DONE and then close | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
1703 * the connection. |
| 4656 | 1704 */ |
| 1705 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
| 1706 | |
| 8446 | 1707 /* |
| 1708 * Miscellaneous xfer functions | |
| 1709 */ | |
| 1710 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const fu8_t *ck) | |
| 4656 | 1711 { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1712 GaimXfer *xfer; |
| 5146 | 1713 struct aim_oft_info *oft_info; |
| 4656 | 1714 |
| 1715 while (fts) { | |
| 1716 xfer = fts->data; | |
| 5146 | 1717 oft_info = xfer->data; |
| 1718 | |
| 8446 | 1719 if (oft_info && !memcmp(ck, oft_info->cookie, 8)) |
| 4656 | 1720 return xfer; |
| 1721 | |
| 1722 fts = g_slist_next(fts); | |
| 1723 } | |
| 1724 | |
| 1725 return NULL; | |
| 1726 } | |
| 1727 | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1728 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, aim_conn_t *conn) |
| 4656 | 1729 { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1730 GaimXfer *xfer; |
| 5146 | 1731 struct aim_oft_info *oft_info; |
| 4656 | 1732 |
| 1733 while (fts) { | |
| 1734 xfer = fts->data; | |
| 5146 | 1735 oft_info = xfer->data; |
| 1736 | |
| 1737 if (oft_info && (conn == oft_info->conn)) | |
| 4656 | 1738 return xfer; |
| 1739 | |
| 1740 fts = g_slist_next(fts); | |
| 1741 } | |
| 1742 | |
| 1743 return NULL; | |
| 1744 } | |
| 1745 | |
| 8446 | 1746 static void oscar_xfer_end(GaimXfer *xfer) |
| 1747 { | |
| 1748 struct aim_oft_info *oft_info = xfer->data; | |
| 1749 GaimConnection *gc = oft_info->sess->aux_data; | |
| 1750 OscarData *od = gc->proto_data; | |
| 1751 | |
| 8660 | 1752 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
| 8446 | 1753 |
| 1754 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
| 1755 oft_info->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); | |
| 1756 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_DONE, oft_info); | |
| 1757 } | |
| 1758 | |
| 1759 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
| 1760 aim_oft_destroyinfo(oft_info); | |
| 1761 xfer->data = NULL; | |
| 1762 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 1763 } | |
| 1764 | |
| 1765 /* | |
| 1766 * xfer functions used when receiving files | |
| 1767 */ | |
| 1768 | |
| 1769 static void oscar_xfer_init_recv(GaimXfer *xfer) | |
| 1770 { | |
| 1771 struct aim_oft_info *oft_info = xfer->data; | |
| 1772 GaimConnection *gc = oft_info->sess->aux_data; | |
| 1773 OscarData *od = gc->proto_data; | |
| 1774 | |
| 8660 | 1775 gaim_debug_info("oscar", "AAA - in oscar_xfer_recv_init\n"); |
| 8446 | 1776 |
| 1777 oft_info->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS, NULL); | |
| 1778 if (oft_info->conn) { | |
| 1779 oft_info->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
| 1780 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_PROMPT, oscar_sendfile_prompt, 0); | |
| 1781 oft_info->conn->fd = xfer->fd = gaim_proxy_connect(gaim_connection_get_account(gc), | |
| 1782 xfer->remote_ip, xfer->remote_port, oscar_sendfile_connected, xfer); | |
| 1783 if (xfer->fd == -1) { | |
| 1784 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
| 1785 _("Unable to establish file descriptor.")); | |
| 1786 gaim_xfer_cancel_local(xfer); | |
| 1787 } | |
| 1788 } else { | |
| 1789 gaim_xfer_error(GAIM_XFER_RECEIVE, xfer->who, | |
| 1790 _("Unable to create new connection.")); | |
| 1791 gaim_xfer_cancel_local(xfer); | |
| 1792 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
| 1793 } | |
| 1794 | |
| 1795 } | |
| 1796 | |
| 1797 static void oscar_xfer_cancel_recv(GaimXfer *xfer) | |
| 1798 { | |
| 1799 struct aim_oft_info *oft_info = xfer->data; | |
| 1800 GaimConnection *gc = oft_info->sess->aux_data; | |
| 1801 OscarData *od = gc->proto_data; | |
| 1802 | |
| 8660 | 1803 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
| 8446 | 1804 |
| 1805 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
| 1806 | |
| 1807 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
| 1808 aim_oft_destroyinfo(oft_info); | |
| 1809 xfer->data = NULL; | |
| 1810 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 1811 } | |
| 1812 | |
| 1813 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | |
| 1814 { | |
| 1815 struct aim_oft_info *oft_info = xfer->data; | |
| 1816 | |
| 1817 /* Update our rolling checksum. Like Walmart, yo. */ | |
| 1818 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | |
| 1819 } | |
| 1820 | |
| 1821 /* | |
| 1822 * xfer functions used when sending files | |
| 1823 */ | |
| 1824 | |
| 1825 static void oscar_xfer_init_send(GaimXfer *xfer) | |
| 1826 { | |
| 1827 struct aim_oft_info *oft_info = xfer->data; | |
| 1828 GaimConnection *gc = oft_info->sess->aux_data; | |
| 1829 OscarData *od = gc->proto_data; | |
| 1830 int listenfd; | |
| 1831 | |
| 8660 | 1832 gaim_debug_info("oscar", "AAA - in oscar_xfer_send_init\n"); |
| 8446 | 1833 |
| 1834 xfer->filename = g_path_get_basename(xfer->local_filename); | |
| 1835 strncpy(oft_info->fh.name, xfer->filename, 64); | |
| 1836 oft_info->fh.name[63] = '\0'; | |
| 1837 oft_info->fh.totsize = gaim_xfer_get_size(xfer); | |
| 1838 oft_info->fh.size = gaim_xfer_get_size(xfer); | |
| 1839 oft_info->fh.checksum = aim_oft_checksum_file(xfer->local_filename); | |
| 1840 | |
| 1841 /* Create a listening socket and an associated libfaim conn */ | |
| 1842 if ((listenfd = gaim_network_listen_range(5190, 5199)) < 0) { | |
| 1843 gaim_xfer_cancel_local(xfer); | |
| 1844 return; | |
| 1845 } | |
| 1846 xfer->local_port = gaim_network_get_port_from_fd(listenfd); | |
| 1847 oft_info->port = xfer->local_port; | |
| 1848 if (aim_sendfile_listen(od->sess, oft_info, listenfd) != 0) { | |
| 1849 gaim_xfer_cancel_local(xfer); | |
| 1850 return; | |
| 1851 } | |
| 8660 | 1852 gaim_debug_misc("oscar", |
| 8446 | 1853 "port is %hu, ip is %s\n", |
| 1854 xfer->local_port, oft_info->clientip); | |
| 1855 if (oft_info->conn) { | |
| 1856 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
| 1857 aim_im_sendch2_sendfile_ask(od->sess, oft_info); | |
| 1858 aim_conn_addhandler(od->sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ESTABLISHED, oscar_sendfile_estblsh, 0); | |
| 1859 } else { | |
| 1860 gaim_xfer_error(GAIM_XFER_SEND, xfer->who, | |
| 1861 _("Unable to establish listener socket.")); | |
| 1862 gaim_xfer_cancel_local(xfer); | |
| 1863 } | |
| 1864 } | |
| 1865 | |
| 1866 static void oscar_xfer_cancel_send(GaimXfer *xfer) | |
| 1867 { | |
| 1868 struct aim_oft_info *oft_info = xfer->data; | |
| 1869 GaimConnection *gc = oft_info->sess->aux_data; | |
| 1870 OscarData *od = gc->proto_data; | |
| 1871 | |
| 8660 | 1872 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
| 8446 | 1873 |
| 1874 aim_im_sendch2_sendfile_cancel(oft_info->sess, oft_info); | |
| 1875 | |
| 1876 aim_conn_kill(oft_info->sess, &oft_info->conn); | |
| 1877 aim_oft_destroyinfo(oft_info); | |
| 1878 xfer->data = NULL; | |
| 1879 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 1880 } | |
| 1881 | |
| 1882 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | |
| 1883 { | |
| 1884 struct aim_oft_info *oft_info = xfer->data; | |
| 1885 | |
| 1886 /* I'm not sure I like how we do this. --marv | |
| 1887 * I do. AIM file transfers aren't really meant to be thought | |
| 1888 * of as a transferring just a single file. The rendezvous | |
| 1889 * establishes a connection between two computers, and then | |
| 1890 * those computers can use the same connection for transferring | |
| 1891 * multiple files. So we don't want the Gaim core up and closing | |
| 1892 * the socket all willy-nilly. We want to do that in the oscar | |
| 1893 * prpl, whenever one side or the other says they're finished | |
| 1894 * using the connection. There might be a better way to intercept | |
| 1895 * the socket from the core, however... --KingAnt | |
| 1896 */ | |
| 1897 | |
| 1898 /* | |
| 1899 * If we're done sending, intercept the socket from the core ft code | |
| 1900 * and wait for the other guy to send the "done" OFT packet. | |
| 1901 */ | |
| 1902 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
| 1903 gaim_input_remove(xfer->watcher); | |
| 1904 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
| 1905 xfer->fd = 0; | |
| 1906 gaim_xfer_set_completed(xfer, TRUE); | |
| 1907 } | |
| 1908 } | |
| 1909 | |
| 9466 | 1910 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
| 1911 gboolean can_receive = FALSE; | |
| 1912 OscarData *od = gc->proto_data; | |
| 1913 | |
| 1914 if (!od->icq) { | |
| 1915 aim_userinfo_t *userinfo; | |
| 1916 userinfo = aim_locate_finduserinfo(od->sess, who); | |
| 1917 if (userinfo && userinfo->capabilities & AIM_CAPS_SENDFILE) | |
| 1918 can_receive = TRUE; | |
| 1919 } | |
| 1920 | |
| 1921 return can_receive; | |
| 1922 } | |
| 1923 | |
| 1924 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { | |
| 9030 | 1925 |
| 1926 OscarData *od; | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1927 GaimXfer *xfer; |
| 5146 | 1928 struct aim_oft_info *oft_info; |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
1929 const char *ip; |
| 3752 | 1930 |
| 9030 | 1931 od = (OscarData *)gc->proto_data; |
| 1932 | |
| 4617 | 1933 /* You want to send a file to someone else, you're so generous */ |
| 1934 | |
| 1935 /* Build the file transfer handle */ | |
| 9466 | 1936 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
| 4617 | 1937 |
| 5146 | 1938 /* Create the oscar-specific data */ |
| 8838 | 1939 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
| 9466 | 1940 oft_info = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL); |
| 5146 | 1941 xfer->data = oft_info; |
| 1942 | |
| 4617 | 1943 /* Setup our I/O op functions */ |
| 8446 | 1944 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); |
| 4617 | 1945 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
1946 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
| 8446 | 1947 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
| 1948 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
| 4617 | 1949 |
| 1950 /* Keep track of this transfer for later */ | |
| 1951 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
| 1952 | |
| 1953 /* Now perform the request */ | |
| 9466 | 1954 if (file) |
| 1955 gaim_xfer_request_accepted(xfer, file); | |
| 1956 else | |
| 1957 gaim_xfer_request(xfer); | |
| 3630 | 1958 } |
| 1959 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1960 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 6029 | 1961 GaimConnection *gc = sess->aux_data; |
| 7283 | 1962 OscarData *od = gc->proto_data; |
| 6029 | 1963 GaimAccount *account = gc->account; |
| 1964 aim_conn_t *bosconn; | |
| 1965 char *host; int port; | |
| 1966 int i, rc; | |
| 2086 | 1967 va_list ap; |
| 2704 | 1968 struct aim_authresp_info *info; |
| 6029 | 1969 |
| 5575 | 1970 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
| 2086 | 1971 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1972 va_start(ap, fr); |
| 2704 | 1973 info = va_arg(ap, struct aim_authresp_info *); |
| 2086 | 1974 va_end(ap); |
| 1975 | |
| 8660 | 1976 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1977 "inside auth_resp (Screen name: %s)\n", info->sn); |
| 2704 | 1978 |
| 4293 | 1979 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
| 4056 | 1980 char buf[256]; |
| 2704 | 1981 switch (info->errorcode) { |
| 2086 | 1982 case 0x05: |
| 1983 /* Incorrect nick/password */ | |
| 6498 | 1984 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1985 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
| 2086 | 1986 break; |
| 1987 case 0x11: | |
| 1988 /* Suspended account */ | |
| 6498 | 1989 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1990 gaim_connection_error(gc, _("Your account is currently suspended.")); |
| 2086 | 1991 break; |
| 3498 | 1992 case 0x14: |
| 1993 /* service temporarily unavailable */ | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1994 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
| 3498 | 1995 break; |
| 2086 | 1996 case 0x18: |
| 1997 /* connecting too frequently */ | |
| 6498 | 1998 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1999 gaim_connection_error(gc, _("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.")); |
| 2086 | 2000 break; |
| 2001 case 0x1c: | |
| 2002 /* client too old */ | |
| 6498 | 2003 gc->wants_to_die = TRUE; |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2004 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), GAIM_WEBSITE); |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2005 gaim_connection_error(gc, buf); |
| 2086 | 2006 break; |
| 2007 default: | |
| 6623 | 2008 gaim_connection_error(gc, _("Authentication failed")); |
| 2086 | 2009 break; |
| 2010 } | |
| 8660 | 2011 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2012 "Login Error Code 0x%04hx\n", info->errorcode); |
| 8660 | 2013 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2014 "Error URL: %s\n", info->errorurl); |
| 2086 | 2015 od->killme = TRUE; |
| 2016 return 1; | |
| 2017 } | |
| 2018 | |
| 2019 | |
| 8660 | 2020 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2021 "Reg status: %hu\n", info->regstatus); |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2022 |
| 2704 | 2023 if (info->email) { |
| 8660 | 2024 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
| 2086 | 2025 } else { |
| 8660 | 2026 gaim_debug_misc("oscar", "Email is NULL\n"); |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2027 } |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2028 |
| 8660 | 2029 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
| 2030 gaim_debug_info("oscar", | |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2031 "Closing auth connection...\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2032 aim_conn_kill(sess, &fr->conn); |
| 2086 | 2033 |
| 2034 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
| 2035 if (bosconn == NULL) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2036 gaim_connection_error(gc, _("Internal Error")); |
| 2086 | 2037 od->killme = TRUE; |
| 2038 return 0; | |
| 2039 } | |
| 2040 | |
| 4649 | 2041 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 2042 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
| 2086 | 2043 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
| 2044 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
| 2045 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
| 2993 | 2046 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
| 2086 | 2047 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
| 2048 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
| 2049 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
| 2050 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
| 2051 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
| 2052 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
| 3212 | 2053 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
| 2086 | 2054 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
| 2055 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
| 2056 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
| 2057 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
| 2058 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
| 3595 | 2059 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
| 7011 | 2060 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_userinfo, 0); |
| 8341 | 2061 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); |
| 2086 | 2062 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); |
| 2063 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2064 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
| 2086 | 2065 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
| 2066 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
| 2067 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
| 2068 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2069 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
| 5844 | 2070 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0021, oscar_icon_req,0); |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2071 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
2072 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
2073 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
| 4759 | 2074 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS, gaim_icqalias, 0); |
| 4624 | 2075 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO, gaim_icqinfo, 0); |
| 4230 | 2076 #ifndef NOSSI |
| 4642 | 2077 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ERROR, gaim_ssi_parseerr, 0); |
| 2991 | 2078 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
| 2079 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
| 2080 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
| 4230 | 2081 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
| 8227 | 2082 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADD, gaim_ssi_parseadd, 0); |
| 4230 | 2083 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); |
| 2084 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
| 2085 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
| 2086 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
| 2087 #endif | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2088 |
| 7283 | 2089 od->conn = bosconn; |
| 2704 | 2090 for (i = 0; i < (int)strlen(info->bosip); i++) { |
| 2091 if (info->bosip[i] == ':') { | |
| 2092 port = atoi(&(info->bosip[i+1])); | |
| 2086 | 2093 break; |
| 2094 } | |
| 2095 } | |
| 2704 | 2096 host = g_strndup(info->bosip, i); |
| 2086 | 2097 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2098 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
| 2086 | 2099 g_free(host); |
| 4366 | 2100 if (rc < 0) { |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2101 gaim_connection_error(gc, _("Could Not Connect")); |
| 2086 | 2102 od->killme = TRUE; |
| 2103 return 0; | |
| 2104 } | |
| 4293 | 2105 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2106 gaim_input_remove(gc->inpa); |
| 2704 | 2107 |
| 7283 | 2108 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
| 8341 | 2109 ck[3] = 0x64; |
| 7282 | 2110 |
| 2086 | 2111 return 1; |
| 2112 } | |
| 2113 | |
| 7285 | 2114 /* XXX - Should use gaim_url_fetch for the below stuff */ |
| 2086 | 2115 struct pieceofcrap { |
| 5575 | 2116 GaimConnection *gc; |
| 2086 | 2117 unsigned long offset; |
| 2118 unsigned long len; | |
| 2119 char *modname; | |
| 2120 int fd; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2121 aim_conn_t *conn; |
| 2086 | 2122 unsigned int inpa; |
| 2123 }; | |
| 2124 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2125 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
| 2086 | 2126 { |
| 2127 struct pieceofcrap *pos = data; | |
| 7283 | 2128 OscarData *od = pos->gc->proto_data; |
| 2086 | 2129 char in = '\0'; |
| 2130 int x = 0; | |
| 2131 unsigned char m[17]; | |
| 2132 | |
| 2133 while (read(pos->fd, &in, 1) == 1) { | |
| 2134 if (in == '\n') | |
| 2135 x++; | |
| 2136 else if (in != '\r') | |
| 2137 x = 0; | |
| 2138 if (x == 2) | |
| 2139 break; | |
| 2140 in = '\0'; | |
| 2141 } | |
| 2142 if (in != '\n') { | |
| 4056 | 2143 char buf[256]; |
| 2144 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2145 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2146 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 2147 _("Gaim was unable to get a valid AIM login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2148 buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2149 gaim_input_remove(pos->inpa); |
| 2086 | 2150 close(pos->fd); |
| 2151 g_free(pos); | |
| 2152 return; | |
| 2153 } | |
| 2154 read(pos->fd, m, 16); | |
| 2155 m[16] = '\0'; | |
| 8660 | 2156 gaim_debug_misc("oscar", "Sending hash: "); |
| 2086 | 2157 for (x = 0; x < 16; x++) |
| 8660 | 2158 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
| 2159 | |
| 2160 gaim_debug_misc(NULL, "\n"); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2161 gaim_input_remove(pos->inpa); |
| 2086 | 2162 close(pos->fd); |
| 2163 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
| 2164 g_free(pos); | |
| 2165 } | |
| 2166 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2167 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
| 2086 | 2168 struct pieceofcrap *pos = data; |
| 5420 | 2169 gchar *buf; |
| 2086 | 2170 |
| 4366 | 2171 pos->fd = source; |
| 2172 | |
| 2086 | 2173 if (source < 0) { |
| 5420 | 2174 buf = g_strdup_printf(_("You may be disconnected shortly. You may want to use TOC until " |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2175 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2176 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 2177 _("Gaim was unable to get a valid AIM login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2178 buf); |
| 5420 | 2179 g_free(buf); |
| 2086 | 2180 if (pos->modname) |
| 2181 g_free(pos->modname); | |
| 2182 g_free(pos); | |
| 2183 return; | |
| 2184 } | |
| 2185 | |
| 5420 | 2186 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
| 2086 | 2187 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
| 2188 write(pos->fd, buf, strlen(buf)); | |
| 5420 | 2189 g_free(buf); |
| 2086 | 2190 if (pos->modname) |
| 2191 g_free(pos->modname); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2192 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
| 2086 | 2193 return; |
| 2194 } | |
| 2195 | |
| 2196 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
| 2197 #define AIM_MAX_FILE_SIZE 98304 | |
| 2198 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2199 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2200 va_list ap; |
| 2201 struct pieceofcrap *pos; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2202 fu32_t offset, len; |
| 2086 | 2203 char *modname; |
| 2204 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2205 va_start(ap, fr); |
| 4200 | 2206 offset = va_arg(ap, fu32_t); |
| 2207 len = va_arg(ap, fu32_t); | |
| 2086 | 2208 modname = va_arg(ap, char *); |
| 2209 va_end(ap); | |
| 2210 | |
| 8660 | 2211 gaim_debug_misc("oscar", |
| 5556 | 2212 "offset: %u, len: %u, file: %s\n", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2213 offset, len, (modname ? modname : "aim.exe")); |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2214 |
| 2086 | 2215 if (len == 0) { |
| 8660 | 2216 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2217 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
| 2086 | 2218 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
| 2219 return 1; | |
| 2220 } | |
| 2221 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
| 2222 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
| 2223 char *buf; | |
| 2224 int i = 8; | |
| 2225 if (modname) | |
| 2226 i += strlen(modname); | |
| 2227 buf = g_malloc(i); | |
| 2228 i = 0; | |
| 2229 if (modname) { | |
| 2230 memcpy(buf, modname, strlen(modname)); | |
| 2231 i += strlen(modname); | |
| 2232 } | |
| 2233 buf[i++] = offset & 0xff; | |
| 2234 buf[i++] = (offset >> 8) & 0xff; | |
| 2235 buf[i++] = (offset >> 16) & 0xff; | |
| 2236 buf[i++] = (offset >> 24) & 0xff; | |
| 2237 buf[i++] = len & 0xff; | |
| 2238 buf[i++] = (len >> 8) & 0xff; | |
| 2239 buf[i++] = (len >> 16) & 0xff; | |
| 2240 buf[i++] = (len >> 24) & 0xff; | |
| 8660 | 2241 gaim_debug_misc("oscar", "len + offset is invalid, " |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2242 "hashing request\n"); |
| 2086 | 2243 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
| 2244 g_free(buf); | |
| 2245 return 1; | |
| 2246 } | |
| 2247 */ | |
| 2248 | |
| 2249 pos = g_new0(struct pieceofcrap, 1); | |
| 2250 pos->gc = sess->aux_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2251 pos->conn = fr->conn; |
| 2086 | 2252 |
| 2253 pos->offset = offset; | |
| 2254 pos->len = len; | |
| 2255 pos->modname = modname ? g_strdup(modname) : NULL; | |
| 2256 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2257 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
| 4056 | 2258 char buf[256]; |
| 2086 | 2259 if (pos->modname) |
| 2260 g_free(pos->modname); | |
| 2261 g_free(pos); | |
| 4056 | 2262 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2263 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2264 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 2265 _("Gaim was unable to get a valid login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
2266 buf); |
| 2086 | 2267 } |
| 2268 | |
| 2269 return 1; | |
| 2270 } | |
| 2271 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2272 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2273 GaimConnection *gc = sess->aux_data; |
| 7283 | 2274 OscarData *od = gc->proto_data; |
|
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2275 GaimAccount *account = gaim_connection_get_account(gc); |
| 5575 | 2276 GaimAccount *ac = gaim_connection_get_account(gc); |
| 7282 | 2277 #if 0 |
| 2278 struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b}; | |
| 2279 #endif | |
| 7011 | 2280 va_list ap; |
| 2281 char *key; | |
| 2086 | 2282 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2283 va_start(ap, fr); |
| 2086 | 2284 key = va_arg(ap, char *); |
| 2285 va_end(ap); | |
| 2286 | |
| 4617 | 2287 if (od->icq) { |
| 3458 | 2288 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; |
|
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2289 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
|
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2290 gaim_account_get_password(account), &info, key); |
| 3458 | 2291 } else { |
| 2292 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
|
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2293 aim_send_login(sess, fr->conn, gaim_account_get_username(ac), |
|
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
2294 gaim_account_get_password(account), &info, key); |
| 3458 | 2295 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2296 |
| 7283 | 2297 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
| 8341 | 2298 ck[2] = 0x6c; |
| 7282 | 2299 |
| 2086 | 2300 return 1; |
| 2301 } | |
| 2302 | |
| 2675 | 2303 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2304 GaimConnection *gc = sess->aux_data; |
| 2647 | 2305 struct chat_connection *chatcon; |
| 2306 static int id = 1; | |
| 2307 | |
| 6905 | 2308 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, 0x0001, gaim_parse_genericerr, 0); |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2309 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_conv_chat_join, 0); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2310 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_conv_chat_leave, 0); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2311 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
2312 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); |
| 2675 | 2313 |
| 2672 | 2314 aim_clientready(sess, fr->conn); |
| 2675 | 2315 |
| 2647 | 2316 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
| 2317 chatcon->id = id; | |
| 8733 | 2318 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
| 2647 | 2319 |
| 2320 return 1; | |
| 2321 } | |
| 2322 | |
| 2675 | 2323 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2324 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2325 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
| 2647 | 2326 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
| 2675 | 2327 |
| 2328 aim_clientready(sess, fr->conn); | |
| 2329 | |
| 2330 aim_chatnav_reqrights(sess, fr->conn); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2331 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2332 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2333 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2334 |
| 3694 | 2335 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2336 | |
| 2337 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
| 2338 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
| 2339 | |
| 7282 | 2340 aim_email_sendcookies(sess); |
| 2341 aim_email_activate(sess); | |
| 3694 | 2342 aim_clientready(sess, fr->conn); |
| 2343 | |
| 2344 return 1; | |
| 2345 } | |
| 2346 | |
| 4804 | 2347 static int conninitdone_icon(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2348 GaimConnection *gc = sess->aux_data; |
| 7283 | 2349 OscarData *od = gc->proto_data; |
| 4804 | 2350 |
| 2351 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
| 2352 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_ERROR, gaim_icon_error, 0); | |
| 2353 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ICO, AIM_CB_ICO_RESPONSE, gaim_icon_parseicon, 0); | |
| 2354 | |
| 2355 aim_clientready(sess, fr->conn); | |
| 2356 | |
| 4823 | 2357 od->iconconnecting = FALSE; |
| 2358 | |
| 4804 | 2359 if (od->icontimer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2360 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2361 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
| 4804 | 2362 |
| 2363 return 1; | |
| 2364 } | |
| 2365 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2366 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 2367 GaimConnection *gc = data; |
| 7283 | 2368 OscarData *od; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2369 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2370 aim_conn_t *tstconn; |
| 2086 | 2371 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2372 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 2373 close(source); |
| 2374 return; | |
| 2375 } | |
| 2376 | |
| 4617 | 2377 od = gc->proto_data; |
| 2378 sess = od->sess; | |
| 2086 | 2379 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
| 4366 | 2380 tstconn->fd = source; |
| 2086 | 2381 |
| 2382 if (source < 0) { | |
| 2383 aim_conn_kill(sess, &tstconn); | |
| 8660 | 2384 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2385 "unable to connect to chatnav server\n"); |
| 2086 | 2386 return; |
| 2387 } | |
| 2388 | |
| 2389 aim_conn_completeconnect(sess, tstconn); | |
| 4617 | 2390 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 8660 | 2391 gaim_debug_info("oscar", "chatnav: connected\n"); |
| 2086 | 2392 } |
| 2393 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2394 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 2395 { |
| 5575 | 2396 GaimConnection *gc = data; |
| 7283 | 2397 OscarData *od; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2398 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2399 aim_conn_t *tstconn; |
| 2086 | 2400 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2401 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 2402 close(source); |
| 2403 return; | |
| 2404 } | |
| 2405 | |
| 4617 | 2406 od = gc->proto_data; |
| 2407 sess = od->sess; | |
| 2086 | 2408 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
| 4366 | 2409 tstconn->fd = source; |
| 2086 | 2410 |
| 2411 if (source < 0) { | |
| 2412 aim_conn_kill(sess, &tstconn); | |
| 8660 | 2413 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2414 "unable to connect to authorizer\n"); |
| 2086 | 2415 return; |
| 2416 } | |
| 2417 | |
| 2418 aim_conn_completeconnect(sess, tstconn); | |
| 4617 | 2419 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 8660 | 2420 gaim_debug_info("oscar", "admin: connected\n"); |
| 2086 | 2421 } |
| 2422 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2423 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 2424 { |
| 2425 struct chat_connection *ccon = data; | |
| 5575 | 2426 GaimConnection *gc = ccon->gc; |
| 7283 | 2427 OscarData *od; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2428 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2429 aim_conn_t *tstconn; |
| 2086 | 2430 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2431 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 2432 close(source); |
| 2433 g_free(ccon->show); | |
| 2434 g_free(ccon->name); | |
| 2435 g_free(ccon); | |
| 2436 return; | |
| 2437 } | |
| 2438 | |
| 4617 | 2439 od = gc->proto_data; |
| 2440 sess = od->sess; | |
| 2086 | 2441 tstconn = ccon->conn; |
| 4366 | 2442 tstconn->fd = source; |
| 2086 | 2443 |
| 2444 if (source < 0) { | |
| 2445 aim_conn_kill(sess, &tstconn); | |
| 2446 g_free(ccon->show); | |
| 2447 g_free(ccon->name); | |
| 2448 g_free(ccon); | |
| 2449 return; | |
| 2450 } | |
| 2451 | |
| 2452 aim_conn_completeconnect(sess, ccon->conn); | |
| 4617 | 2453 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 2454 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
| 2086 | 2455 } |
| 2456 | |
| 3694 | 2457 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 2458 GaimConnection *gc = data; |
| 7283 | 2459 OscarData *od; |
| 3694 | 2460 aim_session_t *sess; |
| 2461 aim_conn_t *tstconn; | |
| 2462 | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2463 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 3694 | 2464 close(source); |
| 2465 return; | |
| 2466 } | |
| 2467 | |
| 4617 | 2468 od = gc->proto_data; |
| 2469 sess = od->sess; | |
| 3694 | 2470 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
| 4366 | 2471 tstconn->fd = source; |
| 3694 | 2472 |
| 2473 if (source < 0) { | |
| 2474 aim_conn_kill(sess, &tstconn); | |
| 8660 | 2475 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2476 "unable to connect to email server\n"); |
| 3694 | 2477 return; |
| 2478 } | |
| 2479 | |
| 2480 aim_conn_completeconnect(sess, tstconn); | |
| 4617 | 2481 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 8660 | 2482 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2483 "email: connected\n"); |
| 3694 | 2484 } |
| 2485 | |
| 4804 | 2486 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 2487 GaimConnection *gc = data; |
| 7283 | 2488 OscarData *od; |
| 4804 | 2489 aim_session_t *sess; |
| 2490 aim_conn_t *tstconn; | |
| 2491 | |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
2492 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 4804 | 2493 close(source); |
| 2494 return; | |
| 2495 } | |
| 2496 | |
| 2497 od = gc->proto_data; | |
| 2498 sess = od->sess; | |
| 2499 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
| 2500 tstconn->fd = source; | |
| 2501 | |
| 2502 if (source < 0) { | |
| 2503 aim_conn_kill(sess, &tstconn); | |
| 8660 | 2504 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2505 "unable to connect to icon server\n"); |
| 4804 | 2506 return; |
| 2507 } | |
| 2508 | |
| 2509 aim_conn_completeconnect(sess, tstconn); | |
| 2510 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
| 8660 | 2511 gaim_debug_info("oscar", "icon: connected\n"); |
| 4804 | 2512 } |
| 2513 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2514 /* Hrmph. I don't know how to make this look better. --mid */ |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2515 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2516 GaimConnection *gc = sess->aux_data; |
| 2517 GaimAccount *account = gaim_connection_get_account(gc); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2518 aim_conn_t *tstconn; |
| 4452 | 2519 int i; |
| 2086 | 2520 char *host; |
| 2521 int port; | |
| 4821 | 2522 va_list ap; |
| 2523 struct aim_redirect_data *redir; | |
| 2086 | 2524 |
| 5575 | 2525 port = gaim_account_get_int(account, "port", FAIM_LOGIN_PORT); |
| 2086 | 2526 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2527 va_start(ap, fr); |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2528 redir = va_arg(ap, struct aim_redirect_data *); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2529 va_end(ap); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2530 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2531 for (i = 0; i < (int)strlen(redir->ip); i++) { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2532 if (redir->ip[i] == ':') { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2533 port = atoi(&(redir->ip[i+1])); |
| 2086 | 2534 break; |
| 2535 } | |
| 2536 } | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2537 host = g_strndup(redir->ip, i); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2538 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2539 switch(redir->group) { |
| 2086 | 2540 case 0x7: /* Authorizer */ |
| 8660 | 2541 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2542 "Reconnecting with authorizor...\n"); |
| 2086 | 2543 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); |
| 2544 if (tstconn == NULL) { | |
| 8660 | 2545 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2546 "unable to reconnect with authorizer\n"); |
| 2086 | 2547 g_free(host); |
| 2548 return 1; | |
| 2549 } | |
| 4649 | 2550 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 2551 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
| 2086 | 2552 |
| 2553 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2554 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
| 2086 | 2555 aim_conn_kill(sess, &tstconn); |
| 8660 | 2556 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2557 "unable to reconnect with authorizer\n"); |
| 2086 | 2558 g_free(host); |
| 2559 return 1; | |
| 2560 } | |
| 4293 | 2561 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 2562 break; |
| 2563 | |
| 2086 | 2564 case 0xd: /* ChatNav */ |
| 2565 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
| 2566 if (tstconn == NULL) { | |
| 8660 | 2567 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2568 "unable to connect to chatnav server\n"); |
| 2086 | 2569 g_free(host); |
| 2570 return 1; | |
| 2571 } | |
| 4649 | 2572 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 2573 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
| 2086 | 2574 |
| 2575 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2576 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
| 2086 | 2577 aim_conn_kill(sess, &tstconn); |
| 8660 | 2578 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2579 "unable to connect to chatnav server\n"); |
| 2086 | 2580 g_free(host); |
| 2581 return 1; | |
| 2582 } | |
| 4293 | 2583 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 2584 break; |
| 2585 | |
| 2586 case 0xe: { /* Chat */ | |
| 2086 | 2587 struct chat_connection *ccon; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2588 |
| 2086 | 2589 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
| 2590 if (tstconn == NULL) { | |
| 8660 | 2591 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2592 "unable to connect to chat server\n"); |
| 2086 | 2593 g_free(host); |
| 2594 return 1; | |
| 2595 } | |
| 2596 | |
| 4649 | 2597 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 2598 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
| 2599 | |
| 2086 | 2600 ccon = g_new0(struct chat_connection, 1); |
| 2601 ccon->conn = tstconn; | |
| 2602 ccon->gc = gc; | |
| 2603 ccon->fd = -1; | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2604 ccon->name = g_strdup(redir->chat.room); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2605 ccon->exchange = redir->chat.exchange; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2606 ccon->instance = redir->chat.instance; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
2607 ccon->show = extract_name(redir->chat.room); |
| 4634 | 2608 |
| 2086 | 2609 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2610 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
| 2086 | 2611 aim_conn_kill(sess, &tstconn); |
| 8660 | 2612 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2613 "unable to connect to chat server\n"); |
| 2086 | 2614 g_free(host); |
| 2615 g_free(ccon->show); | |
| 2616 g_free(ccon->name); | |
| 2617 g_free(ccon); | |
| 2618 return 1; | |
| 2619 } | |
| 4293 | 2620 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 8660 | 2621 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2622 "Connected to chat room %s exchange %hu\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2623 ccon->name, ccon->exchange); |
| 4194 | 2624 } break; |
| 3694 | 2625 |
| 4804 | 2626 case 0x0010: { /* icon */ |
| 2627 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON, NULL))) { | |
| 8660 | 2628 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2629 "unable to connect to icon server\n"); |
| 4804 | 2630 g_free(host); |
| 2631 return 1; | |
| 2632 } | |
| 2633 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
| 2634 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
| 2635 | |
| 2636 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2637 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
| 4804 | 2638 aim_conn_kill(sess, &tstconn); |
| 8660 | 2639 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2640 "unable to connect to icon server\n"); |
| 4804 | 2641 g_free(host); |
| 2642 return 1; | |
| 2643 } | |
| 2644 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
| 2645 } break; | |
| 2646 | |
| 3694 | 2647 case 0x0018: { /* email */ |
| 2648 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
| 8660 | 2649 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2650 "unable to connect to email server\n"); |
| 3694 | 2651 g_free(host); |
| 2652 return 1; | |
| 2653 } | |
| 4649 | 2654 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 3694 | 2655 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
| 2656 | |
| 2657 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2658 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
| 3694 | 2659 aim_conn_kill(sess, &tstconn); |
| 8660 | 2660 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2661 "unable to connect to email server\n"); |
| 3694 | 2662 g_free(host); |
| 2663 return 1; | |
| 2664 } | |
| 4293 | 2665 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 3694 | 2666 } break; |
| 2667 | |
| 2086 | 2668 default: /* huh? */ |
| 8660 | 2669 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2670 "got redirect for unknown service 0x%04hx\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2671 redir->group); |
| 2086 | 2672 break; |
| 2673 } | |
| 2674 | |
| 2675 g_free(host); | |
| 2676 return 1; | |
| 2677 } | |
| 2678 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2679 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2680 GaimConnection *gc = sess->aux_data; |
| 9058 | 2681 GaimAccount *account = gaim_connection_get_account(gc); |
| 7283 | 2682 OscarData *od = gc->proto_data; |
| 4738 | 2683 struct buddyinfo *bi; |
| 2993 | 2684 time_t time_idle = 0, signon = 0; |
| 2685 int type = 0; | |
| 2686 int caps = 0; | |
| 2086 | 2687 va_list ap; |
| 4738 | 2688 aim_userinfo_t *info; |
| 4194 | 2689 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2690 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2691 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 2692 va_end(ap); |
| 2693 | |
| 2993 | 2694 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
| 2695 caps = info->capabilities; | |
| 3267 | 2696 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
| 2697 type |= UC_AB; | |
| 2698 | |
| 4766 | 2699 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
| 2700 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
| 2701 type |= UC_UNCONFIRMED; | |
| 2702 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
| 2703 type |= UC_ADMIN; | |
| 2704 if (info->flags & AIM_FLAG_AOL) | |
| 2705 type |= UC_AOL; | |
| 2706 if (info->flags & AIM_FLAG_FREE) | |
| 2707 type |= UC_NORMAL; | |
| 2708 if (info->flags & AIM_FLAG_AWAY) | |
| 2709 type |= UC_UNAVAILABLE; | |
| 2710 if (info->flags & AIM_FLAG_WIRELESS) | |
| 2711 type |= UC_WIRELESS; | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
2712 } |
| 2993 | 2713 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
| 3595 | 2714 type = (info->icqinfo.status << 16); |
| 3013 | 2715 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
| 2716 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
| 2993 | 2717 type |= UC_UNAVAILABLE; |
| 3013 | 2718 } |
| 2993 | 2719 } |
| 2720 | |
| 7141 | 2721 if (caps & AIM_CAPS_ICQ_DIRECT) |
| 2722 caps ^= AIM_CAPS_ICQ_DIRECT; | |
| 2993 | 2723 |
| 2724 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
| 2086 | 2725 time(&time_idle); |
| 2726 time_idle -= info->idletime*60; | |
| 9295 | 2727 /* time_idle should be the seconds since epoch at which the user became idle */ |
| 2993 | 2728 } |
| 2729 | |
| 5836 | 2730 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
| 2731 signon = info->onlinesince; | |
| 2732 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
| 2993 | 2733 signon = time(NULL) - info->sessionlen; |
| 2086 | 2734 |
| 5575 | 2735 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), info->sn)) |
| 2736 gaim_connection_set_display_name(gc, info->sn); | |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
2737 |
| 7261 | 2738 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
| 4738 | 2739 if (!bi) { |
| 2740 bi = g_new0(struct buddyinfo, 1); | |
| 7261 | 2741 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, info->sn)), bi); |
| 4738 | 2742 } |
| 4739 | 2743 bi->typingnot = FALSE; |
| 2744 bi->ico_informed = FALSE; | |
| 6857 | 2745 bi->ipaddr = info->icqinfo.ipaddr; |
| 2746 | |
| 2747 /* Available message stuff */ | |
| 6292 | 2748 free(bi->availmsg); |
| 7011 | 2749 if (info->avail != NULL) |
| 8225 | 2750 bi->availmsg = oscar_encoding_to_utf8(info->avail_encoding, info->avail, info->avail_len); |
| 5837 | 2751 else |
| 6292 | 2752 bi->availmsg = NULL; |
| 4732 | 2753 |
| 4804 | 2754 /* Server stored icon stuff */ |
| 4853 | 2755 if (info->iconcsumlen) { |
| 7125 | 2756 const char *filename = NULL, *saved_b16 = NULL; |
| 2757 char *b16 = NULL; | |
| 7093 | 2758 GaimBuddy *b = NULL; |
| 4853 | 2759 |
|
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
2760 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
| 4853 | 2761 b = gaim_find_buddy(gc->account, info->sn); |
| 7093 | 2762 /* |
| 2763 * If for some reason the checksum is valid, but cached file is not.. | |
| 2764 * we want to know. | |
| 2765 */ | |
| 7693 | 2766 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
| 7093 | 2767 if (filename != NULL) { |
| 2768 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
| 7693 | 2769 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
| 2770 "icon_checksum"); | |
| 7093 | 2771 } else |
| 2772 saved_b16 = NULL; | |
|
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
2773 |
| 4853 | 2774 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
| 2775 GSList *cur = od->requesticon; | |
| 2776 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
| 2777 cur = cur->next; | |
| 2778 if (!cur) { | |
| 7475 | 2779 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(gc->account, info->sn))); |
| 4853 | 2780 if (od->icontimer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
2781 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
2782 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
| 4853 | 2783 } |
| 2784 } | |
| 6053 | 2785 g_free(b16); |
| 4853 | 2786 } |
| 2787 | |
| 9058 | 2788 /* |
| 2789 * If we have info for ourselves, then update our local warning | |
| 2790 * level and set our official time of login. Is this necessary? | |
| 2791 * XXX - This needs to be changed some how. evil should not be | |
| 2792 * handled by the core at all? | |
| 2793 */ | |
| 2794 if (!aim_sncmp(info->sn, gaim_account_get_username(account))) { | |
| 2795 gc->evil = (info->warnlevel/10.0); | |
| 2796 gc->login_time_official = signon; | |
| 2797 } | |
| 2798 | |
| 5628 | 2799 serv_got_update(gc, info->sn, 1, (info->warnlevel/10.0) + 0.5, signon, time_idle, type); |
| 2086 | 2800 |
| 2801 return 1; | |
| 2802 } | |
| 2803 | |
| 8341 | 2804 static void gaim_check_comment(OscarData *od, const char *str) { |
| 2805 if ((str == NULL) || strcmp(str, ck)) | |
| 2806 aim_locate_setcaps(od->sess, caps_aim); | |
| 2807 else | |
| 2808 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
| 2809 } | |
| 2810 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2811 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2812 GaimConnection *gc = sess->aux_data; |
| 7283 | 2813 OscarData *od = gc->proto_data; |
| 2086 | 2814 va_list ap; |
| 4739 | 2815 aim_userinfo_t *info; |
| 2086 | 2816 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2817 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2818 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 2819 va_end(ap); |
| 2820 | |
| 4732 | 2821 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0); |
| 2086 | 2822 |
| 7261 | 2823 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
| 5837 | 2824 |
| 2086 | 2825 return 1; |
| 2826 } | |
| 2827 | |
| 4617 | 2828 /* BBB */ |
| 3952 | 2829 /* |
| 4617 | 2830 * This is called after a remote AIM user has connected to us. We |
| 2831 * want to do some voodoo with the socket file descriptors, add a | |
| 2832 * callback or two, and then send the AIM_CB_OFT_PROMPT. | |
| 3952 | 2833 */ |
| 4656 | 2834 static int oscar_sendfile_estblsh(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2835 GaimConnection *gc = sess->aux_data; |
| 7283 | 2836 OscarData *od = (OscarData *)gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2837 GaimXfer *xfer; |
| 5146 | 2838 struct aim_oft_info *oft_info; |
| 3630 | 2839 va_list ap; |
| 2840 aim_conn_t *conn, *listenerconn; | |
| 4656 | 2841 |
| 8660 | 2842 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2843 "AAA - in oscar_sendfile_estblsh\n"); |
| 3630 | 2844 va_start(ap, fr); |
| 2845 conn = va_arg(ap, aim_conn_t *); | |
| 2846 listenerconn = va_arg(ap, aim_conn_t *); | |
| 2847 va_end(ap); | |
| 2848 | |
| 4617 | 2849 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) |
| 2850 return 1; | |
| 2851 | |
| 5146 | 2852 if (!(oft_info = xfer->data)) |
| 4617 | 2853 return 1; |
| 2854 | |
| 3630 | 2855 /* Stop watching listener conn; watch transfer conn instead */ |
| 4617 | 2856 gaim_input_remove(xfer->watcher); |
| 3630 | 2857 aim_conn_kill(sess, &listenerconn); |
| 2858 | |
| 5146 | 2859 oft_info->conn = conn; |
| 2860 xfer->fd = oft_info->conn->fd; | |
| 2861 | |
| 2862 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_ACK, oscar_sendfile_ack, 0); | |
| 2863 aim_conn_addhandler(sess, oft_info->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DONE, oscar_sendfile_done, 0); | |
| 2864 xfer->watcher = gaim_input_add(oft_info->conn->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
| 4617 | 2865 |
| 2866 /* Inform the other user that we are connected and ready to transfer */ | |
| 5146 | 2867 aim_oft_sendheader(sess, AIM_CB_OFT_PROMPT, oft_info); |
| 3630 | 2868 |
| 2869 return 0; | |
| 2870 } | |
| 2871 | |
| 3952 | 2872 /* |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2873 * This is the gaim callback passed to gaim_proxy_connect when connecting to another AIM |
| 4617 | 2874 * user in order to transfer a file. |
| 3952 | 2875 */ |
| 4617 | 2876 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition) { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2877 GaimXfer *xfer; |
| 5146 | 2878 struct aim_oft_info *oft_info; |
| 4656 | 2879 |
| 8660 | 2880 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2881 "AAA - in oscar_sendfile_connected\n"); |
| 4617 | 2882 if (!(xfer = data)) |
| 2883 return; | |
| 5146 | 2884 if (!(oft_info = xfer->data)) |
| 3630 | 2885 return; |
| 8446 | 2886 if (source < 0) { |
| 2887 gaim_xfer_cancel_remote(xfer); | |
| 4617 | 2888 return; |
| 8446 | 2889 } |
| 4617 | 2890 |
| 2891 xfer->fd = source; | |
| 5146 | 2892 oft_info->conn->fd = source; |
| 2893 | |
| 2894 aim_conn_completeconnect(oft_info->sess, oft_info->conn); | |
| 2895 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, oft_info->conn); | |
| 4617 | 2896 |
| 2897 /* Inform the other user that we are connected and ready to transfer */ | |
| 5146 | 2898 aim_im_sendch2_sendfile_accept(oft_info->sess, oft_info); |
| 4617 | 2899 |
| 2900 return; | |
| 3630 | 2901 } |
| 2902 | |
| 3952 | 2903 /* |
| 4617 | 2904 * This is called when a buddy sends us some file info. This happens when they |
| 2905 * are sending a file to you, and you have just established a connection to them. | |
| 4650 | 2906 * You should send them the exact same info except use the real cookie. We also |
| 4617 | 2907 * get like totally ready to like, receive the file, kay? |
| 3952 | 2908 */ |
| 4617 | 2909 static int oscar_sendfile_prompt(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2910 GaimConnection *gc = sess->aux_data; |
| 7283 | 2911 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2912 GaimXfer *xfer; |
| 5146 | 2913 struct aim_oft_info *oft_info; |
| 4617 | 2914 va_list ap; |
| 2915 aim_conn_t *conn; | |
| 2916 fu8_t *cookie; | |
| 2917 struct aim_fileheader_t *fh; | |
| 4656 | 2918 |
| 8660 | 2919 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2920 "AAA - in oscar_sendfile_prompt\n"); |
| 4617 | 2921 va_start(ap, fr); |
| 2922 conn = va_arg(ap, aim_conn_t *); | |
| 2923 cookie = va_arg(ap, fu8_t *); | |
| 2924 fh = va_arg(ap, struct aim_fileheader_t *); | |
| 2925 va_end(ap); | |
| 2926 | |
| 2927 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
| 2928 return 1; | |
| 2929 | |
| 5146 | 2930 if (!(oft_info = xfer->data)) |
| 4617 | 2931 return 1; |
| 2932 | |
| 2933 /* We want to stop listening with a normal thingy */ | |
| 2934 gaim_input_remove(xfer->watcher); | |
| 2935 xfer->watcher = 0; | |
| 2936 | |
| 5146 | 2937 /* They sent us some information about the file they're sending */ |
| 2938 memcpy(&oft_info->fh, fh, sizeof(*fh)); | |
| 2939 | |
| 2940 /* Fill in the cookie */ | |
| 2941 memcpy(&oft_info->fh.bcookie, oft_info->cookie, 8); | |
| 2942 | |
| 4617 | 2943 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
| 5146 | 2944 aim_oft_sendheader(oft_info->sess, AIM_CB_OFT_ACK, oft_info); |
| 4617 | 2945 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
| 2946 | |
| 2947 return 0; | |
| 3630 | 2948 } |
| 2949 | |
| 3952 | 2950 /* |
| 4657 | 2951 * We are sending a file to someone else. They have just acknowledged our |
| 4617 | 2952 * prompt, so we want to start sending data like there's no tomorrow. |
| 3952 | 2953 */ |
| 4617 | 2954 static int oscar_sendfile_ack(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 2955 GaimConnection *gc = sess->aux_data; |
| 7283 | 2956 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2957 GaimXfer *xfer; |
| 4617 | 2958 va_list ap; |
| 2959 aim_conn_t *conn; | |
| 2960 fu8_t *cookie; | |
| 2961 struct aim_fileheader_t *fh; | |
| 4656 | 2962 |
| 8660 | 2963 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
| 4617 | 2964 va_start(ap, fr); |
| 2965 conn = va_arg(ap, aim_conn_t *); | |
| 2966 cookie = va_arg(ap, fu8_t *); | |
| 2967 fh = va_arg(ap, struct aim_fileheader_t *); | |
| 2968 va_end(ap); | |
| 2969 | |
| 2970 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
| 2971 return 1; | |
| 2972 | |
| 4656 | 2973 /* We want to stop listening with a normal thingy */ |
| 2974 gaim_input_remove(xfer->watcher); | |
| 2975 xfer->watcher = 0; | |
| 2976 | |
| 4617 | 2977 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
| 2978 | |
| 2979 return 0; | |
| 3630 | 2980 } |
| 4617 | 2981 |
| 2982 /* | |
| 2983 * We just sent a file to someone. They said they got it and everything, | |
| 2984 * so we can close our direct connection and what not. | |
| 2985 */ | |
| 2986 static int oscar_sendfile_done(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 2987 GaimConnection *gc = sess->aux_data; |
| 7283 | 2988 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2989 GaimXfer *xfer; |
| 4617 | 2990 va_list ap; |
| 2991 aim_conn_t *conn; | |
| 2992 fu8_t *cookie; | |
| 2993 struct aim_fileheader_t *fh; | |
| 4656 | 2994 |
| 8660 | 2995 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
| 4617 | 2996 va_start(ap, fr); |
| 2997 conn = va_arg(ap, aim_conn_t *); | |
| 2998 cookie = va_arg(ap, fu8_t *); | |
| 2999 fh = va_arg(ap, struct aim_fileheader_t *); | |
| 3000 va_end(ap); | |
| 3001 | |
| 3002 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
| 3003 return 1; | |
| 3004 | |
| 4656 | 3005 xfer->fd = conn->fd; |
| 4617 | 3006 gaim_xfer_end(xfer); |
| 3007 | |
| 3008 return 0; | |
| 3009 } | |
| 3630 | 3010 |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3011 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
| 5575 | 3012 GaimConnection *gc = sess->aux_data; |
| 7283 | 3013 OscarData *od = gc->proto_data; |
| 8708 | 3014 GaimAccount *account = gaim_connection_get_account(gc); |
| 7475 | 3015 gchar *tmp; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3016 GaimConvImFlags flags = 0; |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
3017 gsize convlen; |
| 3659 | 3018 GError *err = NULL; |
| 4738 | 3019 struct buddyinfo *bi; |
| 5575 | 3020 const char *iconfile; |
| 4738 | 3021 |
| 8708 | 3022 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
| 4738 | 3023 if (!bi) { |
| 3024 bi = g_new0(struct buddyinfo, 1); | |
| 8708 | 3025 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
| 4738 | 3026 } |
|
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3027 |
|
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
3028 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
3029 flags |= GAIM_CONV_IM_AUTO_RESP; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3030 |
| 4738 | 3031 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
| 3032 bi->typingnot = TRUE; | |
| 3033 else | |
| 3034 bi->typingnot = FALSE; | |
| 3035 | |
| 4380 | 3036 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
| 8660 | 3037 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3038 "%s has an icon\n", userinfo->sn); |
| 4738 | 3039 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
| 3040 bi->ico_need = TRUE; | |
| 3041 bi->ico_len = args->iconlen; | |
| 3042 bi->ico_csum = args->iconsum; | |
| 3043 bi->ico_time = args->iconstamp; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3044 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3045 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3046 |
| 8708 | 3047 if ((iconfile = gaim_account_get_buddy_icon(account)) && |
| 7406 | 3048 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) && !bi->ico_sent && bi->ico_informed) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3049 FILE *file; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3050 struct stat st; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3051 |
| 5575 | 3052 if (!stat(iconfile, &st)) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3053 char *buf = g_malloc(st.st_size); |
| 5575 | 3054 file = fopen(iconfile, "rb"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3055 if (file) { |
| 9532 | 3056 /* XXX - Use g_file_get_contents() */ |
|
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
3057 int len = fread(buf, 1, st.st_size, file); |
| 8660 | 3058 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3059 "Sending buddy icon to %s (%d bytes, " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3060 "%lu reported)\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3061 userinfo->sn, len, st.st_size); |
| 4617 | 3062 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
| 3063 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3064 fclose(file); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3065 } else |
| 8660 | 3066 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3067 "Can't open buddy icon file!\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3068 g_free(buf); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
3069 } else |
| 8660 | 3070 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3071 "Can't stat buddy icon file!\n"); |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3072 } |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3073 |
| 8660 | 3074 gaim_debug_misc("oscar", |
| 8623 | 3075 "Received message from %s with charset %hu %hu\n", |
| 3076 userinfo->sn, args->charset, args->charsubset); | |
| 3077 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3078 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
| 3722 | 3079 /* This message is marked as UNICODE, so we have to |
| 3080 * convert it to utf-8 before handing it to the gaim core. | |
| 3081 * This conversion should *never* fail, if it does it | |
| 3082 * means that either the incoming ICBM is corrupted or | |
| 4662 | 3083 * there is something we don't understand about it. |
| 3084 * For the record, AIM Unicode is big-endian UCS-2 */ | |
| 3085 | |
| 8660 | 3086 gaim_debug_info("oscar", "Received UNICODE IM\n"); |
| 4121 | 3087 |
| 3088 if (!args->msg || !args->msglen) | |
| 3089 return 1; | |
| 4641 | 3090 |
| 3659 | 3091 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
| 3092 if (err) { | |
| 8660 | 3093 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3094 "Unicode IM conversion: %s\n", err->message); |
| 7475 | 3095 tmp = g_strdup(_("(There was an error receiving this message)")); |
| 4800 | 3096 g_error_free(err); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3097 } |
| 3722 | 3098 } else { |
| 3850 | 3099 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
| 3722 | 3100 * unflagged messages, which are ASCII. That's OK because |
| 3101 * ASCII is a strict subset of ISO-8859-1; this should | |
| 3102 * help with compatibility with old, broken versions of | |
| 3103 * gaim (everything before 0.60) and other broken clients | |
| 3104 * that will happily send ISO-8859-1 without marking it as | |
| 3105 * such */ | |
| 4662 | 3106 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) |
| 8660 | 3107 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3108 "Received ISO-8859-1 IM\n"); |
| 4121 | 3109 |
| 3110 if (!args->msg || !args->msglen) | |
| 3111 return 1; | |
| 3112 | |
| 3659 | 3113 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
| 3114 if (err) { | |
| 8660 | 3115 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3116 "ISO-8859-1 IM conversion: %s\n", err->message); |
| 7475 | 3117 tmp = g_strdup(_("(There was an error receiving this message)")); |
| 4800 | 3118 g_error_free(err); |
| 3659 | 3119 } |
| 3642 | 3120 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3121 |
| 8666 | 3122 /* |
| 8995 | 3123 * If the message is being received by an ICQ user then escape any HTML, |
| 9016 | 3124 * because HTML is not sent over ICQ as a means to format a message. |
| 8995 | 3125 * so any HTML we receive is intended to be displayed |
| 3126 * | |
| 3127 * Note: There *may* be some clients which send messages as HTML formatted - | |
| 3128 * they need to be special-cased somehow. | |
| 8666 | 3129 */ |
| 8995 | 3130 if (isdigit(gaim_account_get_username(account)[0]) && isdigit(userinfo->sn[0])) { |
| 3131 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ | |
| 3132 gchar *tmp2 = gaim_escape_html(tmp); | |
| 8493 | 3133 g_free(tmp); |
| 3134 tmp = tmp2; | |
| 3135 } | |
| 3136 | |
| 6982 | 3137 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3138 g_free(tmp); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3139 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3140 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3141 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3142 |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3143 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
| 9070 | 3144 GaimConnection *gc; |
| 3145 OscarData *od; | |
| 3146 const char *username; | |
| 3147 | |
| 3148 g_return_val_if_fail(sess != NULL, 0); | |
| 3149 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
| 3150 | |
| 3151 gc = sess->aux_data; | |
| 3152 od = gc->proto_data; | |
| 3153 username = gaim_account_get_username(gaim_connection_get_account(gc)); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3154 |
| 4121 | 3155 if (!args) |
| 3156 return 0; | |
| 4194 | 3157 |
| 8660 | 3158 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3159 "rendezvous with %s, status is %hu\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3160 userinfo->sn, args->status); |
| 2869 | 3161 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3162 if (args->reqclass & AIM_CAPS_CHAT) { |
| 4121 | 3163 char *name; |
| 5234 | 3164 GHashTable *components; |
| 3165 | |
| 4121 | 3166 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
| 3167 return 1; | |
| 5234 | 3168 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 3169 g_free); | |
| 4121 | 3170 name = extract_name(args->info.chat.roominfo.name); |
| 5234 | 3171 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
| 3172 g_hash_table_replace(components, g_strdup("exchange"), g_strdup_printf("%d", args->info.chat.roominfo.exchange)); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3173 serv_got_chat_invite(gc, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3174 name ? name : args->info.chat.roominfo.name, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3175 userinfo->sn, |
| 6059 | 3176 args->msg, |
| 5234 | 3177 components); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3178 if (name) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3179 g_free(name); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3180 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
| 4617 | 3181 /* BBB */ |
| 3182 if (args->status == AIM_RENDEZVOUS_PROPOSE) { | |
| 3183 /* Someone wants to send a file (or files) to us */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3184 GaimXfer *xfer; |
| 5146 | 3185 struct aim_oft_info *oft_info; |
| 3186 | |
| 3187 if (!args->cookie || !args->port || !args->verifiedip || | |
| 3188 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
| 4656 | 3189 !args->info.sendfile.totfiles || !args->reqclass) { |
| 8660 | 3190 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3191 "%s tried to send you a file with incomplete " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3192 "information.\n", userinfo->sn); |
| 5146 | 3193 if (args->proxyip) |
| 8660 | 3194 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3195 "IP for a proxy server was given. Gaim " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3196 "does not support this yet.\n"); |
| 4617 | 3197 return 1; |
| 4656 | 3198 } |
| 4617 | 3199 |
| 3200 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
| 3201 /* last char of the ft req is a star, they are sending us a | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3202 * directory -- remove the star and trailing slash so we don't save |
| 4617 | 3203 * directories that look like 'dirname\*' -- arl */ |
| 3204 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
| 3205 if (tmp && (tmp[1] == '*')) { | |
| 3206 tmp[0] = '\0'; | |
| 3207 } | |
| 8660 | 3208 gaim_debug_warning("oscar", |
| 8446 | 3209 "We're receiving a whole directory! What fun! " |
| 3210 "Especially since we don't support that!\n"); | |
| 4617 | 3211 } |
| 3212 | |
| 3213 /* Build the file transfer handle */ | |
| 3214 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
| 5163 | 3215 xfer->remote_ip = g_strdup(args->verifiedip); |
| 5146 | 3216 xfer->remote_port = args->port; |
| 4617 | 3217 gaim_xfer_set_filename(xfer, args->info.sendfile.filename); |
| 3218 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); | |
| 5146 | 3219 |
| 3220 /* Create the oscar-specific data */ | |
| 5163 | 3221 oft_info = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, xfer->remote_port, 0, 0, NULL); |
| 4898 | 3222 if (args->proxyip) |
| 5146 | 3223 oft_info->proxyip = g_strdup(args->proxyip); |
| 4898 | 3224 if (args->verifiedip) |
| 5146 | 3225 oft_info->verifiedip = g_strdup(args->verifiedip); |
| 3226 xfer->data = oft_info; | |
| 4617 | 3227 |
| 3228 /* Setup our I/O op functions */ | |
| 8446 | 3229 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
| 4617 | 3230 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
| 8446 | 3231 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_recv); |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
3232 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
| 8446 | 3233 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
| 4617 | 3234 |
| 3235 /* | |
| 3236 * XXX - Should do something with args->msg, args->encoding, and args->language | |
| 3237 * probably make it apply to all ch2 messages. | |
| 3752 | 3238 */ |
| 4617 | 3239 |
| 3240 /* Keep track of this transfer for later */ | |
| 3241 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
| 3242 | |
| 3243 /* Now perform the request */ | |
| 3244 gaim_xfer_request(xfer); | |
| 3245 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { | |
| 3246 /* The other user wants to cancel a file transfer */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3247 GaimXfer *xfer; |
| 8660 | 3248 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3249 "AAA - File transfer canceled by remote user\n"); |
| 4617 | 3250 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
3251 gaim_xfer_cancel_remote(xfer); |
| 4617 | 3252 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
| 3253 /* | |
| 3254 * This gets sent by the receiver of a file | |
| 3255 * as they connect directly to us. If we don't | |
| 3256 * get this, then maybe a third party connected | |
| 3257 * to us, and we shouldn't send them anything. | |
| 3258 */ | |
| 3259 } else { | |
| 8660 | 3260 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3261 "unknown rendezvous status!\n"); |
| 3630 | 3262 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3263 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
| 8092 | 3264 } else if (args->reqclass & AIM_CAPS_TALK) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3265 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3266 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3267 userinfo->sn, args->info.icon.icon, |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
3268 args->info.icon.length); |
| 6871 | 3269 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
| 8971 | 3270 /* Consider moving all this into a helper func in the direct im block way up there */ |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3271 struct ask_direct *d = g_new0(struct ask_direct, 1); |
| 8971 | 3272 struct oscar_direct_im *dim = oscar_direct_im_find(od, userinfo->sn); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3273 char buf[256]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3274 |
| 4212 | 3275 if (!args->verifiedip) { |
| 8983 | 3276 /* TODO: do something about this, after figuring out what it means */ |
| 8660 | 3277 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3278 "directim kill blocked (%s)\n", userinfo->sn); |
| 4650 | 3279 return 1; |
| 4212 | 3280 } |
| 3281 | |
| 8660 | 3282 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3283 "%s received direct im request from %s (%s)\n", |
| 8983 | 3284 username, userinfo->sn, args->clientip); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3285 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3286 d->gc = gc; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3287 d->sn = g_strdup(userinfo->sn); |
| 8983 | 3288 /* Let's use the clientip here, because I think that's what AIM does. |
| 3289 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
| 3290 * and then ask them to connect to us. */ | |
| 3291 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->clientip, args->port?args->port:5190); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3292 memcpy(d->cookie, args->cookie, 8); |
| 9070 | 3293 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
| 3294 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { | |
| 3295 | |
| 8971 | 3296 oscar_direct_im_destroy(od, dim); |
| 8984 | 3297 d->donttryagain = TRUE; |
| 8971 | 3298 accept_direct_im_request(d); |
| 3299 } else { | |
| 8983 | 3300 if (dim && !dim->connected) |
| 8971 | 3301 gaim_debug_warning("oscar", "DirectIM: received direct im request while " |
| 3302 "already connected to that buddy!"); | |
| 5575 | 3303 g_snprintf(buf, sizeof buf, _("%s has just asked to directly connect to %s"), userinfo->sn, username); |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3304 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3305 gaim_request_action(gc, NULL, buf, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3306 _("This requires a direct connection between " |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3307 "the two computers and is necessary for IM " |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3308 "Images. Because your IP address will be " |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3309 "revealed, this may be considered a privacy " |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3310 "risk."), 0, d, 2, |
| 8971 | 3311 _("Connect"), G_CALLBACK(accept_direct_im_request), |
| 3312 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); | |
| 3313 /* FIXME: we should actually send a packet on cancel */ | |
| 3314 } | |
| 8708 | 3315 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
| 3316 gaim_debug_error("oscar", "Got an ICQ Server Relay message of type %d\n", args->info.rtfmsg.msgtype); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3317 } else { |
| 8660 | 3318 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3319 "Unknown reqclass %hu\n", args->reqclass); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3320 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3321 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3322 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3323 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3324 |
| 3453 | 3325 /* |
| 4230 | 3326 * Authorization Functions |
| 3327 * Most of these are callbacks from dialogs. They're used by both | |
| 3328 * methods of authorization (SSI and old-school channel 4 ICBM) | |
| 3453 | 3329 */ |
| 4269 | 3330 /* When you ask other people for authorization */ |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3331 static void gaim_auth_request(struct name_data *data, char *msg) { |
| 5575 | 3332 GaimConnection *gc = data->gc; |
| 4244 | 3333 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3334 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 3335 OscarData *od = gc->proto_data; |
| 6695 | 3336 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
| 3337 GaimGroup *group = gaim_find_buddys_group(buddy); | |
| 4244 | 3338 if (buddy && group) { |
| 8660 | 3339 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3340 "ssi: adding buddy %s to group %s\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3341 buddy->name, group->name); |
| 4889 | 3342 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
| 4269 | 3343 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
| 4889 | 3344 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 1); |
| 4244 | 3345 } |
| 4230 | 3346 } |
| 4337 | 3347 } |
| 3348 | |
| 3349 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3350 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
| 8697 | 3351 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3352 _("OK"), G_CALLBACK(gaim_auth_request), |
| 5836 | 3353 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3354 data); |
| 4230 | 3355 } |
| 3356 | |
| 3357 static void gaim_auth_dontrequest(struct name_data *data) { | |
| 5575 | 3358 GaimConnection *gc = data->gc; |
| 4244 | 3359 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3360 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 8151 | 3361 /* Remove from local list */ |
| 3362 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
| 3363 gaim_blist_remove_buddy(b); | |
| 4244 | 3364 } |
| 3365 | |
| 5836 | 3366 oscar_free_name_data(data); |
| 4230 | 3367 } |
| 3368 | |
| 9030 | 3369 |
| 3370 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
| 4269 | 3371 struct name_data *data = g_new(struct name_data, 1); |
| 6695 | 3372 GaimBuddy *buddy; |
| 4269 | 3373 gchar *dialog_msg, *nombre; |
| 3374 | |
| 4687 | 3375 buddy = gaim_find_buddy(gc->account, name); |
| 3376 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
| 3377 nombre = g_strdup_printf("%s (%s)", name, gaim_get_buddy_alias_only(buddy)); | |
| 4269 | 3378 else |
| 4830 | 3379 nombre = NULL; |
| 3380 | |
| 3381 dialog_msg = g_strdup_printf(_("The user %s requires authorization before being added to a buddy list. Do you want to send an authorization request?"), (nombre ? nombre : name)); | |
| 4269 | 3382 data->gc = gc; |
| 3383 data->name = g_strdup(name); | |
| 3384 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3385 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3386 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3387 0, data, 2, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3388 _("Request Authorization"), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3389 G_CALLBACK(gaim_auth_request_msgprompt), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3390 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
| 4269 | 3391 |
| 3392 g_free(dialog_msg); | |
| 3393 g_free(nombre); | |
| 3394 } | |
| 3395 | |
| 9030 | 3396 |
| 3397 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
| 3398 GaimBuddy *buddy; | |
| 3399 GaimConnection *gc; | |
| 3400 | |
| 3401 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 3402 | |
| 3403 buddy = (GaimBuddy *) node; | |
| 3404 gc = gaim_account_get_connection(buddy->account); | |
| 3405 gaim_auth_sendrequest(gc, buddy->name); | |
| 3406 } | |
| 3407 | |
| 4230 | 3408 /* When other people ask you for authorization */ |
| 3409 static void gaim_auth_grant(struct name_data *data) { | |
| 5575 | 3410 GaimConnection *gc = data->gc; |
| 4244 | 3411 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3412 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 3413 OscarData *od = gc->proto_data; |
| 4236 | 3414 #ifdef NOSSI |
| 6695 | 3415 GaimBuddy *buddy; |
| 4244 | 3416 gchar message; |
| 3417 message = 0; | |
| 4687 | 3418 buddy = gaim_find_buddy(gc->account, data->name); |
| 4617 | 3419 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
3420 gaim_account_notify_added(gc->account, NULL, data->name, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
| 4230 | 3421 #else |
| 4889 | 3422 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
| 4230 | 3423 #endif |
| 4244 | 3424 } |
| 3425 | |
| 5836 | 3426 oscar_free_name_data(data); |
| 3141 | 3427 } |
| 3428 | |
| 4230 | 3429 /* When other people ask you for authorization */ |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3430 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
| 5575 | 3431 GaimConnection *gc = data->gc; |
| 4244 | 3432 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3433 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 3434 OscarData *od = gc->proto_data; |
| 4230 | 3435 #ifdef NOSSI |
| 4617 | 3436 aim_im_sendch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
| 4230 | 3437 #else |
| 4889 | 3438 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
| 4230 | 3439 #endif |
| 4244 | 3440 } |
| 4337 | 3441 } |
| 3442 | |
| 3443 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3444 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
| 8697 | 3445 NULL, _("No reason given."), TRUE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3446 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
| 5836 | 3447 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
3448 data); |
| 3141 | 3449 } |
| 3450 | |
| 7023 | 3451 /* When someone sends you buddies */ |
| 3452 static void gaim_icq_buddyadd(struct name_data *data) { | |
| 5575 | 3453 GaimConnection *gc = data->gc; |
| 4244 | 3454 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3455 if (g_list_find(gaim_connections_get_all(), gc)) { |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
3456 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
| 4244 | 3457 } |
| 3458 | |
| 5836 | 3459 oscar_free_name_data(data); |
| 3453 | 3460 } |
| 3461 | |
| 4075 | 3462 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
| 5575 | 3463 GaimConnection *gc = sess->aux_data; |
| 4076 | 3464 gchar **msg1, **msg2; |
| 3465 GError *err = NULL; | |
| 6051 | 3466 int i, numtoks; |
| 4076 | 3467 |
| 4121 | 3468 if (!args->type || !args->msg || !args->uin) |
| 3469 return 1; | |
| 4194 | 3470 |
| 8660 | 3471 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3472 "Received a channel 4 message of type 0x%02hhx.\n", args->type); |
| 4076 | 3473 |
| 3474 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
| 4173 | 3475 msg1 = g_strsplit(args->msg, "\376", 0); |
| 6051 | 3476 for (numtoks=0; msg1[numtoks]; numtoks++); |
| 3477 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
| 4076 | 3478 for (i=0; msg1[i]; i++) { |
|
7478
3c21f3084ff0
[gaim-migrate @ 8091]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7475
diff
changeset
|
3479 gaim_str_strip_cr(msg1[i]); |
| 4076 | 3480 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); |
| 4800 | 3481 if (err) { |
| 8660 | 3482 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3483 "Error converting a string from ISO-8859-1 to " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3484 "UTF-8 in oscar ICBM channel 4 parsing\n"); |
| 4800 | 3485 g_error_free(err); |
| 3486 } | |
| 4076 | 3487 } |
| 3488 msg2[i] = NULL; | |
| 3489 | |
| 3952 | 3490 switch (args->type) { |
| 4173 | 3491 case 0x01: { /* MacICQ message or basic offline message */ |
| 4076 | 3492 if (i >= 1) { |
| 5556 | 3493 gchar *uin = g_strdup_printf("%u", args->uin); |
| 8493 | 3494 gchar *tmp; |
| 3495 | |
| 3496 /* If the message came from an ICQ user then escape any HTML */ | |
| 8501 | 3497 tmp = gaim_escape_html(msg2[0]); |
| 8493 | 3498 |
| 4076 | 3499 if (t) { /* This is an offline message */ |
| 3500 /* I think this timestamp is in UTC, or something */ | |
| 8514 | 3501 serv_got_im(gc, uin, tmp, 0, t); |
| 4076 | 3502 } else { /* This is a message from MacICQ/Miranda */ |
| 8514 | 3503 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
| 4076 | 3504 } |
| 3505 g_free(uin); | |
| 8493 | 3506 g_free(tmp); |
| 4075 | 3507 } |
| 3316 | 3508 } break; |
| 3509 | |
| 4173 | 3510 case 0x04: { /* Someone sent you a URL */ |
| 4076 | 3511 if (i >= 2) { |
| 7385 | 3512 if (msg2[1] != NULL) { |
| 3513 gchar *uin = g_strdup_printf("%u", args->uin); | |
| 3514 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
| 3515 msg2[1], | |
| 3516 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
| 3517 serv_got_im(gc, uin, message, 0, time(NULL)); | |
| 3518 g_free(uin); | |
| 3519 g_free(message); | |
| 3520 } | |
| 3453 | 3521 } |
| 3522 } break; | |
| 3523 | |
| 4173 | 3524 case 0x06: { /* Someone requested authorization */ |
| 4076 | 3525 if (i >= 6) { |
| 4230 | 3526 struct name_data *data = g_new(struct name_data, 1); |
| 5556 | 3527 gchar *dialog_msg = g_strdup_printf(_("The user %u wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
| 8660 | 3528 gaim_debug_info("oscar", |
| 5556 | 3529 "Received an authorization request from UIN %u\n", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3530 args->uin); |
| 4076 | 3531 data->gc = gc; |
| 5556 | 3532 data->name = g_strdup_printf("%u", args->uin); |
| 4230 | 3533 data->nick = NULL; |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3534 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3535 gaim_request_action(gc, NULL, _("Authorization Request"), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3536 dialog_msg, 0, data, 2, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3537 _("Authorize"), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3538 G_CALLBACK(gaim_auth_grant), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3539 _("Deny"), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3540 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
| 4076 | 3541 g_free(dialog_msg); |
| 3542 } | |
| 3141 | 3543 } break; |
| 3544 | |
| 4173 | 3545 case 0x07: { /* Someone has denied you authorization */ |
| 4076 | 3546 if (i >= 1) { |
| 7023 | 3547 gchar *dialog_msg = g_strdup_printf(_("The user %u has denied your request to add them to your buddy list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given.")); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3548 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3549 dialog_msg); |
| 4076 | 3550 g_free(dialog_msg); |
| 3551 } | |
| 3141 | 3552 } break; |
| 3553 | |
| 4173 | 3554 case 0x08: { /* Someone has granted you authorization */ |
| 7023 | 3555 gchar *dialog_msg = g_strdup_printf(_("The user %u has granted your request to add them to your buddy list."), args->uin); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3556 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3557 dialog_msg); |
| 3141 | 3558 g_free(dialog_msg); |
| 3559 } break; | |
| 3560 | |
| 4333 | 3561 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
| 3562 if (i >= 5) { | |
| 3563 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3564 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
| 4333 | 3565 g_free(dialog_msg); |
| 3566 } | |
| 3567 } break; | |
| 3568 | |
| 4173 | 3569 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
| 4076 | 3570 if (i >= 6) { |
| 4194 | 3571 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3572 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
| 4076 | 3573 g_free(dialog_msg); |
| 3574 } | |
| 4075 | 3575 } break; |
| 3576 | |
| 4173 | 3577 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
| 4076 | 3578 if (i >= 6) { |
| 4308 | 3579 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ email from %s [%s]\n\nMessage is:\n%s"), msg2[0], msg2[3], msg2[5]); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3580 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
| 4076 | 3581 g_free(dialog_msg); |
| 3582 } | |
| 4075 | 3583 } break; |
| 3584 | |
| 4173 | 3585 case 0x12: { |
| 3141 | 3586 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
| 7023 | 3587 /* Someone added you to their buddy list? */ |
| 3141 | 3588 } break; |
| 3589 | |
| 7023 | 3590 case 0x13: { /* Someone has sent you some ICQ buddies */ |
| 7631 | 3591 guint i, num; |
| 3453 | 3592 gchar **text; |
| 4173 | 3593 text = g_strsplit(args->msg, "\376", 0); |
| 3453 | 3594 if (text) { |
| 3595 num = 0; | |
| 3596 for (i=0; i<strlen(text[0]); i++) | |
| 3597 num = num*10 + text[0][i]-48; | |
| 3598 for (i=0; i<num; i++) { | |
| 4230 | 3599 struct name_data *data = g_new(struct name_data, 1); |
| 7023 | 3600 gchar *message = g_strdup_printf(_("ICQ user %u has sent you a buddy: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); |
| 3453 | 3601 data->gc = gc; |
| 4790 | 3602 data->name = g_strdup(text[i*2+1]); |
| 3603 data->nick = g_strdup(text[i*2+2]); | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3604 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3605 gaim_request_action(gc, NULL, message, |
| 7023 | 3606 _("Do you want to add this buddy " |
| 3607 "to your buddy list?"), | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
3608 0, data, 2, |
| 7023 | 3609 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
| 5836 | 3610 _("Decline"), G_CALLBACK(oscar_free_name_data)); |
| 3453 | 3611 g_free(message); |
| 3612 } | |
| 3613 g_strfreev(text); | |
| 3614 } | |
| 3615 } break; | |
| 3616 | |
| 7023 | 3617 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
| 3453 | 3618 /* This is boring and silly. */ |
| 3619 } break; | |
| 3620 | |
| 3141 | 3621 default: { |
| 8660 | 3622 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3623 "Received a channel 4 message of unknown type " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3624 "(type 0x%02hhx).\n", args->type); |
| 3141 | 3625 } break; |
| 3626 } | |
| 3627 | |
| 4076 | 3628 g_strfreev(msg1); |
| 3629 g_strfreev(msg2); | |
| 3630 | |
| 3141 | 3631 return 1; |
| 3632 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3633 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3634 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4200 | 3635 fu16_t channel; |
| 3636 int ret = 0; | |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3637 aim_userinfo_t *userinfo; |
| 2086 | 3638 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3639 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3640 va_start(ap, fr); |
| 4200 | 3641 channel = (fu16_t)va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3642 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 3643 |
| 3141 | 3644 switch (channel) { |
| 3645 case 1: { /* standard message */ | |
| 3646 struct aim_incomingim_ch1_args *args; | |
| 3647 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
| 3648 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
| 3649 } break; | |
| 3650 | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
3651 case 2: { /* rendezvous */ |
| 3141 | 3652 struct aim_incomingim_ch2_args *args; |
| 3653 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
| 3654 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
| 3655 } break; | |
| 3656 | |
| 3657 case 4: { /* ICQ */ | |
| 3658 struct aim_incomingim_ch4_args *args; | |
| 3659 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
| 4075 | 3660 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
| 3141 | 3661 } break; |
| 3662 | |
| 3663 default: { | |
| 8660 | 3664 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3665 "ICBM received on unsupported channel (channel " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3666 "0x%04hx).", channel); |
| 3141 | 3667 } break; |
| 2086 | 3668 } |
| 3669 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3670 va_end(ap); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3671 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3672 return ret; |
| 2086 | 3673 } |
| 3674 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3675 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 8733 | 3676 GaimConnection *gc = sess->aux_data; |
| 3677 GaimAccount *account = gaim_connection_get_account(gc); | |
| 3678 GaimConversation *conv; | |
| 5420 | 3679 char *buf; |
| 2086 | 3680 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3681 fu16_t chan, nummissed, reason; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3682 aim_userinfo_t *userinfo; |
| 2086 | 3683 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3684 va_start(ap, fr); |
| 4200 | 3685 chan = (fu16_t)va_arg(ap, unsigned int); |
| 3686 userinfo = va_arg(ap, aim_userinfo_t *); | |
| 3687 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
| 3688 reason = (fu16_t)va_arg(ap, unsigned int); | |
| 2086 | 3689 va_end(ap); |
| 3690 | |
| 3691 switch(reason) { | |
| 5420 | 3692 case 0: /* Invalid (0) */ |
| 3693 buf = g_strdup_printf( | |
| 3694 ngettext( | |
| 4276 | 3695 "You missed %hu message from %s because it was invalid.", |
| 3696 "You missed %hu messages from %s because they were invalid.", | |
| 3697 nummissed), | |
| 4282 | 3698 nummissed, |
| 3699 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3700 break; |
| 5420 | 3701 case 1: /* Message too large */ |
| 3702 buf = g_strdup_printf( | |
| 3703 ngettext( | |
| 4276 | 3704 "You missed %hu message from %s because it was too large.", |
| 3705 "You missed %hu messages from %s because they were too large.", | |
| 3706 nummissed), | |
| 4282 | 3707 nummissed, |
| 3708 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3709 break; |
| 5420 | 3710 case 2: /* Rate exceeded */ |
| 3711 buf = g_strdup_printf( | |
| 3712 ngettext( | |
| 4276 | 3713 "You missed %hu message from %s because the rate limit has been exceeded.", |
| 3714 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
| 3715 nummissed), | |
| 4282 | 3716 nummissed, |
| 3717 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3718 break; |
| 5420 | 3719 case 3: /* Evil Sender */ |
| 3720 buf = g_strdup_printf( | |
| 3721 ngettext( | |
| 4276 | 3722 "You missed %hu message from %s because he/she was too evil.", |
| 3723 "You missed %hu messages from %s because he/she was too evil.", | |
| 3724 nummissed), | |
| 4282 | 3725 nummissed, |
| 3726 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3727 break; |
| 5420 | 3728 case 4: /* Evil Receiver */ |
| 3729 buf = g_strdup_printf( | |
| 3730 ngettext( | |
| 4276 | 3731 "You missed %hu message from %s because you are too evil.", |
| 3732 "You missed %hu messages from %s because you are too evil.", | |
| 3733 nummissed), | |
| 4282 | 3734 nummissed, |
| 3735 userinfo->sn); | |
| 2086 | 3736 break; |
| 3737 default: | |
| 5420 | 3738 buf = g_strdup_printf( |
| 3739 ngettext( | |
| 4276 | 3740 "You missed %hu message from %s for an unknown reason.", |
| 3741 "You missed %hu messages from %s for an unknown reason.", | |
| 3742 nummissed), | |
| 4282 | 3743 nummissed, |
| 3744 userinfo->sn); | |
| 2086 | 3745 break; |
| 3746 } | |
| 8733 | 3747 |
| 3748 conv = gaim_find_conversation_with_account(userinfo->sn, account); | |
| 3749 if (conv != NULL) | |
| 3750 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
| 3751 else | |
| 3752 gaim_notify_error(sess->aux_data, NULL, buf, NULL); | |
| 5420 | 3753 g_free(buf); |
| 2086 | 3754 |
| 3755 return 1; | |
| 3756 } | |
| 3757 | |
| 4194 | 3758 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
| 5575 | 3759 GaimConnection *gc = sess->aux_data; |
| 7283 | 3760 OscarData *od = gc->proto_data; |
| 4617 | 3761 |
| 3762 /* BBB */ | |
| 3630 | 3763 switch (reason) { |
| 4151 | 3764 case 3: { /* Decline sendfile. */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3765 GaimXfer *xfer; |
| 8971 | 3766 struct oscar_direct_im *dim; |
| 3767 | |
| 8660 | 3768 gaim_debug_info("oscar", |
| 9070 | 3769 "AAA - Other user declined some sort of direct " |
| 8971 | 3770 "connect attempt (automaticly?)\n"); |
| 4617 | 3771 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
3772 gaim_xfer_cancel_remote(xfer); |
| 8971 | 3773 else if ((dim = oscar_direct_im_find(od, who))) { |
| 3774 /* AAA should use find by cookie or something here */ | |
| 3775 oscar_direct_im_disconnect(od, dim); | |
| 3776 } | |
| 4151 | 3777 } break; |
| 3778 | |
| 3779 default: { | |
| 8660 | 3780 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3781 "Received an unknown rendezvous client auto-response " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3782 "from %s. Type 0x%04hx\n", who, reason); |
| 4151 | 3783 } |
| 3630 | 3784 |
| 3785 } | |
| 3786 | |
| 3787 return 0; | |
| 3788 } | |
| 3789 | |
| 4194 | 3790 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
| 5575 | 3791 GaimConnection *gc = sess->aux_data; |
| 4151 | 3792 |
| 3793 switch(reason) { | |
| 3794 case 0x0003: { /* Reply from an ICQ status message request */ | |
| 9244 | 3795 char *title, *statusmsg, **splitmsg, *dialogmsg; |
| 3796 | |
| 3797 title = g_strdup_printf(_("Info for %s"), who); | |
| 4151 | 3798 |
| 3799 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
| 9244 | 3800 statusmsg = oscar_icqstatus(state); |
| 4151 | 3801 splitmsg = g_strsplit(msg, "\r\n", 0); |
| 9244 | 3802 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
| 3803 g_free(statusmsg); | |
| 4151 | 3804 g_strfreev(splitmsg); |
| 9244 | 3805 |
| 3806 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, dialogmsg, NULL, NULL); | |
| 3807 | |
| 3808 g_free(title); | |
| 3809 g_free(dialogmsg); | |
| 4151 | 3810 } break; |
| 3811 | |
| 3812 default: { | |
| 8660 | 3813 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3814 "Received an unknown client auto-response from %s. " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3815 "Type 0x%04hx\n", who, reason); |
| 4151 | 3816 } break; |
| 3817 } /* end of switch */ | |
| 3818 | |
| 3819 return 0; | |
| 3820 } | |
| 3821 | |
| 3212 | 3822 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 3823 va_list ap; | |
| 3824 fu16_t chan, reason; | |
| 3825 char *who; | |
| 3826 | |
| 3827 va_start(ap, fr); | |
| 4200 | 3828 chan = (fu16_t)va_arg(ap, unsigned int); |
| 3212 | 3829 who = va_arg(ap, char *); |
| 4200 | 3830 reason = (fu16_t)va_arg(ap, unsigned int); |
| 3212 | 3831 |
| 3952 | 3832 if (chan == 0x0002) { /* File transfer declined */ |
| 3630 | 3833 char *cookie = va_arg(ap, char *); |
| 4151 | 3834 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
| 3952 | 3835 } else if (chan == 0x0004) { /* ICQ message */ |
| 4200 | 3836 fu32_t state = 0; |
| 4151 | 3837 char *msg = NULL; |
| 3838 if (reason == 0x0003) { | |
| 4200 | 3839 state = va_arg(ap, fu32_t); |
| 4151 | 3840 msg = va_arg(ap, char *); |
| 3841 } | |
| 3842 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
| 3843 } | |
| 3952 | 3844 |
| 3212 | 3845 va_end(ap); |
| 3846 | |
| 3847 return 1; | |
| 3848 } | |
| 3849 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3850 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 3851 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3852 fu16_t reason; |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3853 char *m; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3854 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3855 va_start(ap, fr); |
| 4199 | 3856 reason = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 3857 va_end(ap); |
| 3858 | |
| 8660 | 3859 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3860 "snac threw error (reason 0x%04hx: %s)\n", reason, |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3861 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
| 2086 | 3862 |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3863 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
| 5411 | 3864 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3865 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3866 g_free(m); |
|
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
3867 |
| 2086 | 3868 return 1; |
| 3869 } | |
| 3870 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3871 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4617 | 3872 #if 0 |
| 5575 | 3873 GaimConnection *gc = sess->aux_data; |
| 7283 | 3874 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3875 GaimXfer *xfer; |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3876 #endif |
| 4617 | 3877 va_list ap; |
| 3878 fu16_t reason; | |
| 3879 char *data, *buf; | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3880 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3881 va_start(ap, fr); |
| 4617 | 3882 reason = (fu16_t)va_arg(ap, unsigned int); |
| 3752 | 3883 data = va_arg(ap, char *); |
| 2086 | 3884 va_end(ap); |
| 3885 | |
| 8660 | 3886 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3887 "Message error with data %s and reason %hu\n", data, reason); |
| 4617 | 3888 |
| 3889 /* BBB */ | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3890 #if 0 |
| 4617 | 3891 /* If this was a file transfer request, data is a cookie */ |
| 3892 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, data))) { | |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
3893 gaim_xfer_cancel_remote(xfer); |
| 3630 | 3894 return 1; |
| 3895 } | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
3896 #endif |
| 3630 | 3897 |
| 4617 | 3898 /* Data is assumed to be the destination sn */ |
| 3899 buf = g_strdup_printf(_("Your message to %s did not get sent:"), data); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3900 gaim_notify_error(sess->aux_data, NULL, buf, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3901 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); |
| 4617 | 3902 g_free(buf); |
| 2086 | 3903 |
| 3904 return 1; | |
| 3905 } | |
| 3906 | |
| 3595 | 3907 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 3908 GaimConnection *gc = sess->aux_data; |
| 3595 | 3909 va_list ap; |
| 3910 fu16_t type1, type2; | |
| 3911 char *sn; | |
| 3912 | |
| 3913 va_start(ap, fr); | |
| 4199 | 3914 type1 = (fu16_t) va_arg(ap, unsigned int); |
| 3595 | 3915 sn = va_arg(ap, char *); |
| 4199 | 3916 type2 = (fu16_t) va_arg(ap, unsigned int); |
| 3595 | 3917 va_end(ap); |
| 3918 | |
| 3919 switch (type2) { | |
| 3920 case 0x0000: { /* Text has been cleared */ | |
| 3921 serv_got_typing_stopped(gc, sn); | |
| 3922 } break; | |
| 3923 | |
| 3924 case 0x0001: { /* Paused typing */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3925 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
| 3595 | 3926 } break; |
| 3927 | |
| 3928 case 0x0002: { /* Typing */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
3929 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
| 3595 | 3930 } break; |
| 3931 | |
| 3932 default: { | |
| 8660 | 3933 gaim_debug_error("oscar", "Received unknown typing notification message from %s. Type1 is 0x%04x and type2 is 0x%04hx.\n", sn, type1, type2); |
| 3595 | 3934 } break; |
| 3935 } | |
| 3936 | |
| 3937 return 1; | |
| 3938 } | |
| 3939 | |
| 7141 | 3940 /* |
| 3941 * We get this error when there was an error in the locate family. This | |
| 7259 | 3942 * happens when you request info of someone who is offline. |
| 7141 | 3943 */ |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3944 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 7259 | 3945 gchar *buf; |
| 2086 | 3946 va_list ap; |
| 5420 | 3947 fu16_t reason; |
| 2086 | 3948 char *destn; |
| 3949 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3950 va_start(ap, fr); |
| 4199 | 3951 reason = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 3952 destn = va_arg(ap, char *); |
| 3953 va_end(ap); | |
| 3954 | |
| 7781 | 3955 if (destn == NULL) |
| 7793 | 3956 return 1; |
| 3957 | |
| 3958 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); | |
| 7781 | 3959 |
| 3960 gaim_notify_error(sess->aux_data, NULL, buf, | |
| 3961 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("No reason given.")); | |
| 3962 g_free(buf); | |
| 2086 | 3963 |
| 3964 return 1; | |
| 3965 } | |
| 3966 | |
| 7011 | 3967 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 3968 GaimConnection *gc = sess->aux_data; |
| 8700 | 3969 GaimAccount *account = gaim_connection_get_account(gc); |
| 3970 GString *str; | |
| 9244 | 3971 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL, *title = NULL; |
| 4791 | 3972 va_list ap; |
| 7011 | 3973 aim_userinfo_t *userinfo; |
| 2086 | 3974 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3975 va_start(ap, fr); |
| 7011 | 3976 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 3977 va_end(ap); |
| 3978 | |
| 8700 | 3979 str = g_string_new(""); |
| 3980 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
| 3981 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
| 7011 | 3982 |
| 3983 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | |
| 8701 | 3984 oscar_string_append(str, "\n<br>", _("Online Since"), |
| 8700 | 3985 asctime(localtime((time_t *)&userinfo->onlinesince))); |
| 7011 | 3986 |
| 3987 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | |
| 8701 | 3988 oscar_string_append(str, "\n<br>", _("Member Since"), |
| 8700 | 3989 asctime(localtime((time_t *)&userinfo->membersince))); |
| 7011 | 3990 |
| 3991 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | |
| 8700 | 3992 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
| 8701 | 3993 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
| 8700 | 3994 g_free(tmp); |
| 3995 } | |
| 3996 | |
| 8701 | 3997 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
| 7011 | 3998 |
| 3999 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
| 8700 | 4000 tmp = oscar_encoding_extract(userinfo->away_encoding); |
| 4001 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
| 4002 g_free(tmp); | |
| 7011 | 4003 if (away_utf8 != NULL) { |
| 8700 | 4004 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
| 7011 | 4005 g_free(away_utf8); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4006 } |
| 7011 | 4007 } |
| 4008 | |
| 4009 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | |
| 8700 | 4010 tmp = oscar_encoding_extract(userinfo->info_encoding); |
| 4011 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
| 4012 g_free(tmp); | |
| 7011 | 4013 if (info_utf8 != NULL) { |
| 8700 | 4014 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
| 7011 | 4015 g_free(info_utf8); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4016 } |
| 7011 | 4017 } |
| 4018 | |
| 8701 | 4019 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
| 8700 | 4020 g_string_free(str, TRUE); |
| 9244 | 4021 title = g_strdup_printf(_("Info for %s"), userinfo->sn); |
| 4022 gaim_notify_formatted(gc, title, _("Buddy Information"), NULL, tmp, NULL, NULL); | |
| 4023 g_free(title); | |
| 8700 | 4024 g_free(tmp); |
| 4151 | 4025 |
| 2086 | 4026 return 1; |
| 4027 } | |
| 4028 | |
| 8341 | 4029 static gboolean gaim_reqinfo_timeout_cb(void *data) |
| 4030 { | |
| 4031 aim_session_t *sess = data; | |
| 4032 GaimConnection *gc = sess->aux_data; | |
| 4033 OscarData *od = (OscarData *)gc->proto_data; | |
| 4034 | |
| 4035 aim_locate_dorequest(data); | |
| 4036 od->getinfotimer = 0; | |
| 4037 | |
| 4038 return FALSE; | |
| 4039 } | |
| 4040 | |
| 4041 static int gaim_reqinfo_timeout(aim_session_t *sess, aim_frame_t *fr, ...) | |
| 4042 { | |
| 4043 GaimConnection *gc = sess->aux_data; | |
| 4044 OscarData *od = (OscarData *)gc->proto_data; | |
| 4045 | |
| 4046 /* | |
| 4047 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
| 4048 * us from hitting the rate limit due to request away messages and info | |
| 4049 * too quickly. | |
| 4050 */ | |
| 4051 if (od->getinfotimer == 0) | |
| 4052 od->getinfotimer = gaim_timeout_add(1200, gaim_reqinfo_timeout_cb, sess); | |
| 4053 | |
| 4054 return 1; | |
| 4055 } | |
| 4056 | |
| 4057 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) | |
| 4058 { | |
| 2086 | 4059 char *msg; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4060 fu16_t id; |
| 2086 | 4061 va_list ap; |
| 4062 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4063 va_start(ap, fr); |
| 4199 | 4064 id = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 4065 msg = va_arg(ap, char *); |
| 4066 va_end(ap); | |
| 4067 | |
| 8660 | 4068 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4069 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
|
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
4070 if (id < 4) |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4071 gaim_notify_warning(sess->aux_data, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4072 _("Your AIM connection may be lost."), NULL); |
| 2086 | 4073 |
| 4074 return 1; | |
| 4075 } | |
| 4076 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4077 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4078 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4079 fu16_t type; |
| 5575 | 4080 GaimConnection *gc = sess->aux_data; |
| 7283 | 4081 OscarData *od = (OscarData *)gc->proto_data; |
| 2086 | 4082 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4083 va_start(ap, fr); |
| 4199 | 4084 type = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 4085 |
| 4086 switch(type) { | |
| 4087 case 0x0002: { | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4088 fu8_t maxrooms; |
| 2086 | 4089 struct aim_chat_exchangeinfo *exchanges; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4090 int exchangecount, i; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4091 |
| 4199 | 4092 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
| 2086 | 4093 exchangecount = va_arg(ap, int); |
| 4094 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
| 4095 | |
| 8660 | 4096 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4097 "chat info: Chat Rights:\n"); |
| 8660 | 4098 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4099 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
| 8660 | 4100 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4101 "chat info: \tExchange List: (%d total)\n", exchangecount); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4102 for (i = 0; i < exchangecount; i++) |
| 8660 | 4103 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4104 "chat info: \t\t%hu %s\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4105 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
| 4617 | 4106 while (od->create_rooms) { |
| 4107 struct create_room *cr = od->create_rooms->data; | |
| 8660 | 4108 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4109 "creating room %s\n", cr->name); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4110 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4111 g_free(cr->name); |
| 4617 | 4112 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4113 g_free(cr); |
| 2086 | 4114 } |
| 4115 } | |
| 4116 break; | |
| 4117 case 0x0008: { | |
| 4118 char *fqcn, *name, *ck; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4119 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4120 fu8_t createperms; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4121 fu32_t createtime; |
| 2086 | 4122 |
| 4123 fqcn = va_arg(ap, char *); | |
| 4200 | 4124 instance = (fu16_t)va_arg(ap, unsigned int); |
| 4125 exchange = (fu16_t)va_arg(ap, unsigned int); | |
| 4126 flags = (fu16_t)va_arg(ap, unsigned int); | |
| 4127 createtime = va_arg(ap, fu32_t); | |
| 4128 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
| 4129 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
| 4130 createperms = (fu8_t)va_arg(ap, unsigned int); | |
| 4131 unknown = (fu16_t)va_arg(ap, unsigned int); | |
| 4132 name = va_arg(ap, char *); | |
| 4133 ck = va_arg(ap, char *); | |
| 4194 | 4134 |
| 8660 | 4135 gaim_debug_misc("oscar", |
| 5556 | 4136 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
| 2086 | 4137 fqcn, |
| 4138 exchange, instance, flags, | |
| 4139 createtime, | |
| 4140 maxmsglen, maxoccupancy, createperms, unknown, | |
| 4141 name, ck); | |
| 4617 | 4142 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
| 2086 | 4143 } |
| 4144 break; | |
| 4145 default: | |
| 8660 | 4146 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4147 "chatnav info: unknown type (%04hx)\n", type); |
| 2086 | 4148 break; |
| 4149 } | |
| 4194 | 4150 |
| 4151 va_end(ap); | |
| 4152 | |
| 2086 | 4153 return 1; |
| 4154 } | |
| 4155 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4156 static int gaim_conv_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4157 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4158 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4159 aim_userinfo_t *info; |
| 5575 | 4160 GaimConnection *g = sess->aux_data; |
| 2086 | 4161 |
| 4162 struct chat_connection *c = NULL; | |
| 4163 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4164 va_start(ap, fr); |
| 2086 | 4165 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4166 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 4167 va_end(ap); |
| 4168 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4169 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 4170 if (!c) |
| 4171 return 1; | |
| 4172 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4173 for (i = 0; i < count; i++) |
| 9554 | 4174 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE); |
| 2086 | 4175 |
| 4176 return 1; | |
| 4177 } | |
| 4178 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4179 static int gaim_conv_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4180 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4181 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4182 aim_userinfo_t *info; |
| 5575 | 4183 GaimConnection *g = sess->aux_data; |
| 2086 | 4184 |
| 4185 struct chat_connection *c = NULL; | |
| 4186 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4187 va_start(ap, fr); |
| 2086 | 4188 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4189 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 4190 va_end(ap); |
| 4191 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4192 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 4193 if (!c) |
| 4194 return 1; | |
| 4195 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4196 for (i = 0; i < count; i++) |
| 8733 | 4197 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
| 2086 | 4198 |
| 4199 return 1; | |
| 4200 } | |
| 4201 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4202 static int gaim_conv_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4203 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4204 aim_userinfo_t *userinfo; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4205 struct aim_chat_roominfo *roominfo; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4206 char *roomname; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4207 int usercount; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4208 char *roomdesc; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4209 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4210 fu32_t creationtime; |
| 5575 | 4211 GaimConnection *gc = sess->aux_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4212 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4213 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4214 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4215 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4216 roomname = va_arg(ap, char *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4217 usercount= va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4218 userinfo = va_arg(ap, aim_userinfo_t *); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4219 roomdesc = va_arg(ap, char *); |
| 4200 | 4220 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
| 4221 creationtime = va_arg(ap, fu32_t); | |
| 4222 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
| 4223 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
| 4224 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
| 4225 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4226 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4227 |
| 8660 | 4228 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4229 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4230 maxmsglen, maxvisiblemsglen); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4231 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4232 ccon->maxlen = maxmsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4233 ccon->maxvis = maxvisiblemsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4234 |
| 2086 | 4235 return 1; |
| 4236 } | |
| 4237 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
4238 static int gaim_conv_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 4239 GaimConnection *gc = sess->aux_data; |
| 8225 | 4240 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
| 4241 gchar *utf8; | |
| 2086 | 4242 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4243 aim_userinfo_t *info; |
| 8225 | 4244 int len; |
| 2086 | 4245 char *msg; |
| 8219 | 4246 char *charset; |
| 2086 | 4247 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4248 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4249 info = va_arg(ap, aim_userinfo_t *); |
| 8219 | 4250 len = va_arg(ap, int); |
| 4194 | 4251 msg = va_arg(ap, char *); |
| 8219 | 4252 charset = va_arg(ap, char *); |
| 4194 | 4253 va_end(ap); |
| 2086 | 4254 |
| 8225 | 4255 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
| 8667 | 4256 if (utf8 == NULL) |
| 4257 /* The conversion failed! */ | |
| 8668 | 4258 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
| 8225 | 4259 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
| 4260 g_free(utf8); | |
| 2086 | 4261 |
| 4262 return 1; | |
| 4263 } | |
| 4264 | |
| 3694 | 4265 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4266 va_list ap; | |
| 5575 | 4267 GaimConnection *gc = sess->aux_data; |
| 3694 | 4268 struct aim_emailinfo *emailinfo; |
| 3725 | 4269 int havenewmail; |
| 7297 | 4270 char *alertitle, *alerturl; |
| 3694 | 4271 |
| 4272 va_start(ap, fr); | |
| 4273 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
| 3725 | 4274 havenewmail = va_arg(ap, int); |
| 7301 | 4275 alertitle = va_arg(ap, char *); |
| 4276 alerturl = va_arg(ap, char *); | |
| 3694 | 4277 va_end(ap); |
| 4278 | |
| 5628 | 4279 if (emailinfo && gaim_account_get_check_mail(gc->account)) { |
| 5575 | 4280 gchar *to = g_strdup_printf("%s@%s", gaim_account_get_username(gaim_connection_get_account(gc)), emailinfo->domain); |
| 5542 | 4281 if (emailinfo->unread && havenewmail) |
| 4282 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
| 5537 | 4283 g_free(to); |
| 3694 | 4284 } |
| 7297 | 4285 |
| 7301 | 4286 if (alertitle) |
| 8660 | 4287 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
| 3694 | 4288 |
| 4289 return 1; | |
| 4290 } | |
| 4291 | |
| 4804 | 4292 static int gaim_icon_error(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 4293 GaimConnection *gc = sess->aux_data; |
| 7283 | 4294 OscarData *od = gc->proto_data; |
| 4804 | 4295 char *sn; |
| 4296 | |
| 4297 sn = od->requesticon->data; | |
| 8660 | 4298 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4299 "removing %s from hash table\n", sn); |
| 4804 | 4300 od->requesticon = g_slist_remove(od->requesticon, sn); |
| 4301 free(sn); | |
| 4302 | |
| 4303 if (od->icontimer) | |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4304 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4305 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
| 4804 | 4306 |
| 4307 return 1; | |
| 4308 } | |
| 4309 | |
| 4310 static int gaim_icon_parseicon(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 4311 GaimConnection *gc = sess->aux_data; |
| 7283 | 4312 OscarData *od = gc->proto_data; |
| 4804 | 4313 GSList *cur; |
| 4314 va_list ap; | |
| 4315 char *sn; | |
| 4853 | 4316 fu8_t *iconcsum, *icon; |
| 4317 fu16_t iconcsumlen, iconlen; | |
| 4804 | 4318 |
| 4319 va_start(ap, fr); | |
| 4320 sn = va_arg(ap, char *); | |
| 4853 | 4321 iconcsum = va_arg(ap, fu8_t *); |
| 4322 iconcsumlen = va_arg(ap, int); | |
| 4804 | 4323 icon = va_arg(ap, fu8_t *); |
| 4324 iconlen = va_arg(ap, int); | |
| 4325 va_end(ap); | |
| 4326 | |
| 4853 | 4327 if (iconlen > 0) { |
| 4328 char *b16; | |
| 6695 | 4329 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4330 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4331 sn, icon, iconlen); |
|
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
4332 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
| 5129 | 4333 if (b16) { |
| 7693 | 4334 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
| 7162 | 4335 g_free(b16); |
| 5129 | 4336 } |
| 4853 | 4337 } |
| 4804 | 4338 |
| 4339 cur = od->requesticon; | |
| 4340 while (cur) { | |
| 4341 char *cursn = cur->data; | |
| 4342 if (!aim_sncmp(cursn, sn)) { | |
| 4343 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
| 4344 free(cursn); | |
| 4345 cur = od->requesticon; | |
| 4346 } else | |
| 4347 cur = cur->next; | |
| 4348 } | |
| 4349 | |
| 4350 if (od->icontimer) | |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
4351 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
4352 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
| 4804 | 4353 |
| 4354 return 1; | |
| 4355 } | |
| 4356 | |
| 4357 static gboolean gaim_icon_timerfunc(gpointer data) { | |
| 5575 | 4358 GaimConnection *gc = data; |
| 7283 | 4359 OscarData *od = gc->proto_data; |
| 7011 | 4360 aim_userinfo_t *userinfo; |
| 4804 | 4361 aim_conn_t *conn; |
| 4362 | |
| 4363 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
| 5892 | 4364 if (!conn) { |
| 4365 if (!od->iconconnecting) { | |
| 4366 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
| 4367 od->iconconnecting = TRUE; | |
| 4368 } | |
| 4804 | 4369 return FALSE; |
| 4370 } | |
| 4371 | |
| 5842 | 4372 if (od->set_icon) { |
| 6039 | 4373 struct stat st; |
| 4374 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
| 4375 if (iconfile == NULL) { | |
| 8363 | 4376 aim_ssi_delicon(od->sess); |
| 6039 | 4377 } else if (!stat(iconfile, &st)) { |
| 4378 char *buf = g_malloc(st.st_size); | |
| 4379 FILE *file = fopen(iconfile, "rb"); | |
| 4380 if (file) { | |
| 9532 | 4381 /* XXX - Use g_file_get_contents()? */ |
| 6039 | 4382 fread(buf, 1, st.st_size, file); |
| 4383 fclose(file); | |
| 8660 | 4384 gaim_debug_info("oscar", |
| 6039 | 4385 "Uploading icon to icon server\n"); |
| 6879 | 4386 aim_bart_upload(od->sess, buf, st.st_size); |
| 5842 | 4387 } else |
| 8660 | 4388 gaim_debug_error("oscar", |
| 6039 | 4389 "Can't open buddy icon file!\n"); |
| 4390 g_free(buf); | |
| 4391 } else { | |
| 8660 | 4392 gaim_debug_error("oscar", |
| 6039 | 4393 "Can't stat buddy icon file!\n"); |
| 5842 | 4394 } |
| 4395 od->set_icon = FALSE; | |
| 4396 } | |
| 4397 | |
| 4398 if (!od->requesticon) { | |
| 8660 | 4399 gaim_debug_misc("oscar", |
| 5842 | 4400 "no more icons to request\n"); |
| 4401 return FALSE; | |
| 4402 } | |
| 4403 | |
| 7045 | 4404 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
| 7011 | 4405 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
| 4406 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsum, userinfo->iconcsumlen); | |
| 4804 | 4407 return FALSE; |
| 4408 } else { | |
| 4409 char *sn = od->requesticon->data; | |
| 4410 od->requesticon = g_slist_remove(od->requesticon, sn); | |
| 4411 free(sn); | |
| 4412 } | |
| 4413 | |
| 4414 return TRUE; | |
| 4415 } | |
| 4416 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4417 /* |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4418 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4419 */ |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4420 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4421 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4422 fu16_t type; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4423 char *sn; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4424 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4425 va_start(ap, fr); |
| 4199 | 4426 type = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 4427 sn = va_arg(ap, char *); |
| 4428 va_end(ap); | |
| 4429 | |
| 8660 | 4430 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
| 2086 | 4431 |
| 4432 return 1; | |
| 4433 } | |
| 4434 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4435 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4436 static const char *codes[5] = { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4437 "invalid", |
| 4194 | 4438 "change", |
| 4439 "warning", | |
| 4440 "limit", | |
| 4441 "limit cleared", | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4442 }; |
| 2086 | 4443 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4444 fu16_t code, rateclass; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4445 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4446 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4447 va_start(ap, fr); |
| 4200 | 4448 code = (fu16_t)va_arg(ap, unsigned int); |
| 4449 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
| 4450 windowsize = va_arg(ap, fu32_t); | |
| 4451 clear = va_arg(ap, fu32_t); | |
| 4452 alert = va_arg(ap, fu32_t); | |
| 4453 limit = va_arg(ap, fu32_t); | |
| 4454 disconnect = va_arg(ap, fu32_t); | |
| 4455 currentavg = va_arg(ap, fu32_t); | |
| 4456 maxavg = va_arg(ap, fu32_t); | |
| 2086 | 4457 va_end(ap); |
| 4458 | |
| 8660 | 4459 gaim_debug_misc("oscar", |
| 5556 | 4460 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
| 4461 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
| 2086 | 4462 (code < 5) ? codes[code] : codes[0], |
| 4463 rateclass, | |
| 4464 currentavg, maxavg, | |
| 4465 alert, clear, | |
| 4466 limit, disconnect, | |
| 4467 windowsize); | |
| 4468 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4469 /* XXX fix these values */ |
| 2086 | 4470 if (code == AIM_RATE_CODE_CHANGE) { |
| 4471 if (currentavg >= clear) | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4472 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 4473 } else if (code == AIM_RATE_CODE_WARNING) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4474 aim_conn_setlatency(fr->conn, windowsize/4); |
|
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
4475 } else if (code == AIM_RATE_CODE_LIMIT) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4476 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
| 6040 | 4477 _("The last action you attempted could not be " |
| 4478 "performed because you are over the rate limit. " | |
| 4479 "Please wait 10 seconds and try again.")); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4480 aim_conn_setlatency(fr->conn, windowsize/2); |
| 2086 | 4481 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4482 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 4483 } |
| 4484 | |
| 4485 return 1; | |
| 4486 } | |
| 4487 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4488 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4489 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4490 fu16_t newevil; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4491 aim_userinfo_t *userinfo; |
| 5575 | 4492 GaimConnection *gc = sess->aux_data; |
| 2086 | 4493 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4494 va_start(ap, fr); |
| 4199 | 4495 newevil = (fu16_t) va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4496 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 4497 va_end(ap); |
| 4498 | |
| 7111 | 4499 serv_got_eviled(gc, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); |
| 2086 | 4500 |
| 4501 return 1; | |
| 4502 } | |
| 4503 | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4504 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4505 va_list ap; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4506 aim_userinfo_t *info; |
| 5575 | 4507 GaimConnection *gc = sess->aux_data; |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4508 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4509 va_start(ap, fr); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4510 info = va_arg(ap, aim_userinfo_t *); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4511 va_end(ap); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4512 |
| 5628 | 4513 gc->evil = (info->warnlevel/10.0) + 0.5; |
| 4841 | 4514 |
| 7872 | 4515 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
| 4841 | 4516 gc->login_time_official = info->onlinesince; |
| 7872 | 4517 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) |
| 4518 gc->login_time_official = time(NULL) - info->sessionlen; | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4519 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4520 return 1; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4521 } |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
4522 |
| 4649 | 4523 static int gaim_connerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 4524 GaimConnection *gc = sess->aux_data; |
| 7283 | 4525 OscarData *od = gc->proto_data; |
| 4649 | 4526 va_list ap; |
| 4527 fu16_t code; | |
| 4528 char *msg; | |
| 4529 | |
| 4530 va_start(ap, fr); | |
| 4531 code = (fu16_t)va_arg(ap, int); | |
| 4532 msg = va_arg(ap, char *); | |
| 4533 va_end(ap); | |
| 4534 | |
| 8660 | 4535 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4536 "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); |
| 4649 | 4537 if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { |
| 4651 | 4538 if (code == 0x0001) { |
| 6113 | 4539 gc->wants_to_die = TRUE; |
| 5579 | 4540 gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); |
| 4651 | 4541 } else { |
| 5579 | 4542 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
| 4651 | 4543 } |
| 4666 | 4544 od->killme = TRUE; |
| 4649 | 4545 } |
| 4546 | |
| 4547 return 1; | |
| 4548 } | |
| 4549 | |
| 2675 | 4550 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 7283 | 4551 GaimConnection *gc = sess->aux_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4552 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4553 aim_reqpersonalinfo(sess, fr->conn); |
| 4230 | 4554 |
| 4555 #ifndef NOSSI | |
| 8660 | 4556 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
| 4889 | 4557 aim_ssi_reqrights(sess); |
| 6350 | 4558 aim_ssi_reqdata(sess); |
| 4230 | 4559 #endif |
| 4560 | |
| 7011 | 4561 aim_locate_reqrights(sess); |
| 7285 | 4562 aim_buddylist_reqrights(sess, fr->conn); |
| 4617 | 4563 aim_im_reqparams(sess); |
| 7334 | 4564 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
| 4230 | 4565 |
| 4566 #ifdef NOSSI | |
| 8660 | 4567 gaim_debug_info("oscar", "bos: requesting rights\n"); |
| 7334 | 4568 aim_bos_reqrights(sess, fr->conn); |
| 4230 | 4569 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); |
| 4570 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
| 4571 #endif | |
| 2086 | 4572 |
| 7283 | 4573 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
| 4574 | |
| 2086 | 4575 return 1; |
| 4576 } | |
| 4577 | |
| 2675 | 4578 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 4579 GaimConnection *gc = sess->aux_data; |
| 7283 | 4580 OscarData *od = gc->proto_data; |
| 2647 | 4581 |
| 6905 | 4582 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0003, gaim_info_change, 0); |
| 4583 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0005, gaim_info_change, 0); | |
| 4584 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_ADM, 0x0007, gaim_account_confirm, 0); | |
| 4585 | |
| 2672 | 4586 aim_clientready(sess, fr->conn); |
| 8660 | 4587 gaim_debug_info("oscar", "connected to admin\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4588 |
| 2647 | 4589 if (od->chpass) { |
| 8660 | 4590 gaim_debug_info("oscar", "changing password\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4591 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
| 2647 | 4592 g_free(od->oldp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4593 od->oldp = NULL; |
| 2647 | 4594 g_free(od->newp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4595 od->newp = NULL; |
| 2647 | 4596 od->chpass = FALSE; |
| 4597 } | |
| 2979 | 4598 if (od->setnick) { |
| 8660 | 4599 gaim_debug_info("oscar", "formatting screen name\n"); |
| 2979 | 4600 aim_admin_setnick(sess, fr->conn, od->newsn); |
| 4601 g_free(od->newsn); | |
| 4602 od->newsn = NULL; | |
| 4603 od->setnick = FALSE; | |
| 4604 } | |
| 2647 | 4605 if (od->conf) { |
| 8660 | 4606 gaim_debug_info("oscar", "confirming account\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4607 aim_admin_reqconfirm(sess, fr->conn); |
| 2647 | 4608 od->conf = FALSE; |
| 4609 } | |
| 4610 if (od->reqemail) { | |
| 8660 | 4611 gaim_debug_info("oscar", "requesting email\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4612 aim_admin_getinfo(sess, fr->conn, 0x0011); |
| 2647 | 4613 od->reqemail = FALSE; |
| 4614 } | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4615 if (od->setemail) { |
| 8660 | 4616 gaim_debug_info("oscar", "setting email\n"); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4617 aim_admin_setemail(sess, fr->conn, od->email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4618 g_free(od->email); |
| 5497 | 4619 od->email = NULL; |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4620 od->setemail = FALSE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4621 } |
| 2647 | 4622 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4623 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4624 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4625 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4626 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4627 struct aim_icbmparameters *params; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4628 va_list ap; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4629 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4630 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4631 params = va_arg(ap, struct aim_icbmparameters *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4632 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4633 |
| 4194 | 4634 /* XXX - evidently this crashes on solaris. i have no clue why |
| 8660 | 4635 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
| 5556 | 4636 "max sender evil = %f, max receiver evil = %f, min msg interval = %u\n", |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4637 params->maxchan, params->flags, params->maxmsglen, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4638 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4639 params->minmsginterval); |
|
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
4640 */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4641 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4642 /* Maybe senderwarn and recverwarn should be user preferences... */ |
| 3595 | 4643 params->flags = 0x0000000b; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4644 params->maxmsglen = 8000; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4645 params->minmsginterval = 0; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4646 |
| 4617 | 4647 aim_im_setparams(sess, params); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4648 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4649 return 1; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4650 } |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4651 |
| 2993 | 4652 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
| 4653 { | |
| 5575 | 4654 GaimConnection *gc = sess->aux_data; |
| 7283 | 4655 OscarData *od = (OscarData *)gc->proto_data; |
| 5306 | 4656 va_list ap; |
| 4657 fu16_t maxsiglen; | |
| 2993 | 4658 |
| 4659 va_start(ap, fr); | |
| 4199 | 4660 maxsiglen = (fu16_t) va_arg(ap, int); |
| 2993 | 4661 va_end(ap); |
| 4662 | |
| 8660 | 4663 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4664 "locate rights: max sig len = %d\n", maxsiglen); |
| 2993 | 4665 |
| 4617 | 4666 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
| 4667 | |
| 4668 if (od->icq) | |
| 7334 | 4669 aim_locate_setcaps(od->sess, caps_icq); |
| 5301 | 4670 else |
| 7334 | 4671 aim_locate_setcaps(od->sess, caps_aim); |
| 4672 oscar_set_info(gc, gc->account->user_info); | |
| 2993 | 4673 |
| 4674 return 1; | |
| 4675 } | |
| 4676 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4677 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4678 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4679 fu16_t maxbuddies, maxwatchers; |
| 5575 | 4680 GaimConnection *gc = sess->aux_data; |
| 7283 | 4681 OscarData *od = (OscarData *)gc->proto_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4682 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4683 va_start(ap, fr); |
| 4199 | 4684 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
| 4685 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
| 2086 | 4686 va_end(ap); |
| 4687 | |
| 8660 | 4688 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4689 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
| 2086 | 4690 |
| 4617 | 4691 od->rights.maxbuddies = (guint)maxbuddies; |
| 4692 od->rights.maxwatchers = (guint)maxwatchers; | |
| 2993 | 4693 |
| 2086 | 4694 return 1; |
| 4695 } | |
| 4696 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4697 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 4698 GaimConnection *gc = sess->aux_data; |
| 7283 | 4699 OscarData *od = (OscarData *)gc->proto_data; |
| 7334 | 4700 va_list ap; |
| 4701 fu16_t maxpermits, maxdenies; | |
| 2086 | 4702 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4703 va_start(ap, fr); |
| 4199 | 4704 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
| 4705 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
| 2086 | 4706 va_end(ap); |
| 4707 | |
| 8660 | 4708 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4709 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
| 2086 | 4710 |
| 4617 | 4711 od->rights.maxpermits = (guint)maxpermits; |
| 4712 od->rights.maxdenies = (guint)maxdenies; | |
| 2993 | 4713 |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
4714 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 2993 | 4715 serv_finish_login(gc); |
| 4716 | |
| 8660 | 4717 gaim_debug_info("oscar", "buddy list loaded\n"); |
| 2993 | 4718 |
| 2672 | 4719 aim_clientready(sess, fr->conn); |
| 5948 | 4720 aim_srv_setavailmsg(sess, NULL); |
| 7474 | 4721 aim_srv_setidle(sess, 0); |
| 4617 | 4722 |
| 4664 | 4723 if (od->icq) { |
| 4724 aim_icq_reqofflinemsgs(sess); | |
| 4725 aim_icq_hideip(sess); | |
| 4726 } | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4727 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4728 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
| 4102 | 4729 if (sess->authinfo->email) |
| 4730 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
| 2086 | 4731 |
| 4732 return 1; | |
| 4733 } | |
| 4734 | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4735 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4736 va_list ap; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4737 struct aim_icq_offlinemsg *msg; |
| 4075 | 4738 struct aim_incomingim_ch4_args args; |
| 4739 time_t t; | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4740 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4741 va_start(ap, fr); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4742 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4743 va_end(ap); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4744 |
| 8660 | 4745 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4746 "Received offline message. Converting to channel 4 ICBM...\n"); |
| 4075 | 4747 args.uin = msg->sender; |
| 4748 args.type = msg->type; | |
| 4173 | 4749 args.flags = msg->flags; |
| 4076 | 4750 args.msglen = msg->msglen; |
| 4075 | 4751 args.msg = msg->msg; |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4752 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
| 4075 | 4753 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4754 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4755 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4756 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4757 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4758 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4759 { |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4760 aim_icq_ackofflinemsgs(sess); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4761 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4762 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
4763 |
| 7388 | 4764 #if 0 |
| 4765 /* | |
| 7465 | 4766 * Update, 2003-11-09: |
| 4767 * Joseph S. Myers, a gcc dude, fixed this for gcc 3.4! Rock on! | |
| 4768 * | |
| 7388 | 4769 * It may not be my place to do this, but... |
| 4770 * I feel pretty strongly that the "last 2 digits" warning is ridiculously | |
| 4771 * stupid, and should not exist for % switches (%x in our case) that request | |
| 4772 * a year in the preferred representation for the current locale. For that | |
| 4773 * reason I've chosen to not use this workaround (n., see kluge). | |
| 4774 * | |
| 4775 * I have a date. I want to show it to the user in the "preferred" way. | |
| 4776 * Whether that displays a 2 digit year is perfectly fine--after all, it's | |
| 4777 * what the locale wanted. | |
| 4778 * | |
| 4779 * If I have a necessity for a full representation of the year in the current | |
| 4780 * locale, then I'll use a switch that returns a full representation of the | |
| 4781 * year. | |
| 4782 * | |
| 4783 * If you think the preferred locale should show 4 digits instead of 2 digits | |
| 4784 * (because you're anal, or whatever), then change the f***ing locale. | |
| 4785 * | |
| 4786 * I guess the bottom line is--I'm trying to show a date to the user how they | |
| 4787 * prefer to see it, why the hell does gcc want me to change that? | |
| 7389 | 4788 * |
| 4789 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3190 | |
| 4790 * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8714 | |
| 7388 | 4791 */ |
| 4792 | |
| 4793 /* | |
| 4794 * This function was recommended by the STRFTIME(3) man page to remove the | |
| 7386 | 4795 * "last 2 digits" warning. |
| 4796 */ | |
| 4797 static size_t my_strftime(char *s, size_t max, const char *fmt, | |
| 4798 const struct tm *tm) | |
| 4799 { | |
| 4800 return strftime(s, max, fmt, tm); | |
| 4801 } | |
| 7388 | 4802 #endif |
| 7386 | 4803 |
| 4624 | 4804 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4805 { |
| 5575 | 4806 GaimConnection *gc = sess->aux_data; |
| 8670 | 4807 OscarData *od = (OscarData *)gc->proto_data; |
| 4808 GaimBuddy *buddy; | |
| 8853 | 4809 struct buddyinfo *bi = NULL; |
| 4624 | 4810 gchar who[16]; |
| 8670 | 4811 GString *str; |
| 4812 gchar *primary, *utf8; | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4813 va_list ap; |
| 4151 | 4814 struct aim_icq_info *info; |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4815 |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4816 va_start(ap, fr); |
| 4151 | 4817 info = va_arg(ap, struct aim_icq_info *); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4818 va_end(ap); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4819 |
| 4664 | 4820 if (!info->uin) |
| 4821 return 0; | |
| 4822 | |
| 8670 | 4823 str = g_string_sized_new(100); |
| 5556 | 4824 g_snprintf(who, sizeof(who), "%u", info->uin); |
| 8670 | 4825 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
| 4826 if (buddy != NULL) | |
| 4827 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
| 4828 | |
| 4829 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
| 8701 | 4830 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
| 8670 | 4831 if ((bi != NULL) && (bi->ipaddr != 0)) { |
| 4832 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
| 4833 (bi->ipaddr & 0xff000000) >> 24, | |
| 4834 (bi->ipaddr & 0x00ff0000) >> 16, | |
| 4835 (bi->ipaddr & 0x0000ff00) >> 8, | |
| 4836 (bi->ipaddr & 0x000000ff)); | |
| 8701 | 4837 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
| 8670 | 4838 g_free(tstr); |
| 4839 } | |
| 8701 | 4840 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
| 4841 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4842 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
| 8670 | 4843 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
| 4844 g_free(utf8); | |
| 4625 | 4845 } |
| 4846 if (info->numaddresses && info->email2) { | |
| 4847 int i; | |
| 4848 for (i = 0; i < info->numaddresses; i++) { | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4849 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
| 8670 | 4850 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
| 4851 g_free(utf8); | |
| 4643 | 4852 } |
| 4625 | 4853 } |
| 4624 | 4854 } |
| 8701 | 4855 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
| 8902 | 4856 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 0 ? _("Not specified") : |
| 4857 info->gender == 1 ? _("Female") : _("Male")); | |
| 4624 | 4858 if (info->birthyear || info->birthmonth || info->birthday) { |
| 4627 | 4859 char date[30]; |
| 4860 struct tm tm; | |
| 4861 tm.tm_mday = (int)info->birthday; | |
| 4862 tm.tm_mon = (int)info->birthmonth-1; | |
| 4863 tm.tm_year = (int)info->birthyear-1900; | |
| 7388 | 4864 strftime(date, sizeof(date), "%x", &tm); |
| 8701 | 4865 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
| 4151 | 4866 } |
| 4624 | 4867 if (info->age) { |
| 4868 char age[5]; | |
| 4869 snprintf(age, sizeof(age), "%hhd", info->age); | |
| 8701 | 4870 oscar_string_append(str, "\n<br>", _("Age"), age); |
| 4819 | 4871 } |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4872 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
| 8670 | 4873 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
| 4874 g_free(utf8); | |
| 4819 | 4875 } |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4876 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
| 8670 | 4877 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
| 4878 g_free(utf8); | |
| 4879 } | |
| 4880 g_string_append_printf(str, "<hr>\n"); | |
| 4641 | 4881 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
| 8670 | 4882 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
| 8701 | 4883 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
| 4884 oscar_string_append(str, "\n<br>", _("City"), info->homecity); | |
| 4885 oscar_string_append(str, "\n<br>", _("State"), info->homestate); | |
| 4886 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); | |
| 8670 | 4887 g_string_append_printf(str, "\n<hr>\n"); |
| 4151 | 4888 } |
| 4641 | 4889 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
| 8670 | 4890 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
| 8701 | 4891 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
| 4892 oscar_string_append(str, "\n<br>", _("City"), info->workcity); | |
| 4893 oscar_string_append(str, "\n<br>", _("State"), info->workstate); | |
| 4894 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); | |
| 8670 | 4895 g_string_append_printf(str, "\n<hr>\n"); |
| 4624 | 4896 } |
| 4641 | 4897 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
| 8670 | 4898 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
| 8701 | 4899 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
| 4900 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); | |
| 4901 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4902 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
| 8670 | 4903 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
| 4904 g_free(utf8); | |
| 4624 | 4905 } |
| 8670 | 4906 g_string_append_printf(str, "\n<hr>\n"); |
| 4907 } | |
| 4908 | |
| 6873 | 4909 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); |
| 8670 | 4910 gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); |
| 6873 | 4911 g_free(primary); |
| 8670 | 4912 g_string_free(str, TRUE); |
| 4151 | 4913 |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4914 return 1; |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4915 } |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
4916 |
| 4759 | 4917 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
| 4918 { | |
| 5575 | 4919 GaimConnection *gc = sess->aux_data; |
| 4820 | 4920 gchar who[16], *utf8; |
| 6695 | 4921 GaimBuddy *b; |
| 4759 | 4922 va_list ap; |
| 4923 struct aim_icq_info *info; | |
| 4924 | |
| 4925 va_start(ap, fr); | |
| 4926 info = va_arg(ap, struct aim_icq_info *); | |
| 4927 va_end(ap); | |
| 4928 | |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
4929 if (info->uin && info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { |
| 5556 | 4930 g_snprintf(who, sizeof(who), "%u", info->uin); |
| 4820 | 4931 serv_got_alias(gc, who, utf8); |
| 4759 | 4932 if ((b = gaim_find_buddy(gc->account, who))) { |
| 7693 | 4933 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
| 4759 | 4934 } |
| 4820 | 4935 g_free(utf8); |
| 4759 | 4936 } |
| 4937 | |
| 4938 return 1; | |
| 4939 } | |
| 4940 | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4941 static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...) |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4942 { |
| 7032 | 4943 GaimConnection *gc = sess->aux_data; |
| 4944 gchar *text; | |
| 4945 va_list ap; | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4946 char *msg, *url; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4947 fu16_t wid, hei, delay; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4948 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4949 va_start(ap, fr); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4950 msg = va_arg(ap, char *); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4951 url = va_arg(ap, char *); |
| 4199 | 4952 wid = (fu16_t) va_arg(ap, int); |
| 4953 hei = (fu16_t) va_arg(ap, int); | |
| 4954 delay = (fu16_t) va_arg(ap, int); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4955 va_end(ap); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4956 |
| 7032 | 4957 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
| 4958 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
| 4959 g_free(text); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4960 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4961 return 1; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4962 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
4963 |
| 7032 | 4964 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) |
| 4965 { | |
| 6873 | 4966 GaimConnection *gc = sess->aux_data; |
| 4967 gchar *secondary; | |
| 4968 GString *text; | |
| 4969 int i, num; | |
| 2086 | 4970 va_list ap; |
| 6873 | 4971 char *email, *SNs; |
| 2086 | 4972 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4973 va_start(ap, fr); |
| 6873 | 4974 email = va_arg(ap, char *); |
| 2086 | 4975 num = va_arg(ap, int); |
| 4976 SNs = va_arg(ap, char *); | |
| 4977 va_end(ap); | |
| 4978 | |
| 8152 | 4979 secondary = g_strdup_printf(_("The following screen names are associated with %s"), email); |
| 6873 | 4980 text = g_string_new(""); |
| 2086 | 4981 for (i = 0; i < num; i++) |
| 6873 | 4982 g_string_append_printf(text, "%s<br>", &SNs[i * (MAXSNLEN + 1)]); |
| 4983 gaim_notify_formatted(gc, NULL, _("Search Results"), secondary, text->str, NULL, NULL); | |
| 4984 | |
| 4985 g_free(secondary); | |
| 4986 g_string_free(text, TRUE); | |
| 2086 | 4987 |
| 4988 return 1; | |
| 4989 } | |
| 4990 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4991 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4992 va_list ap; |
| 6873 | 4993 char *email; |
| 5420 | 4994 char *buf; |
| 2086 | 4995 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4996 va_start(ap, fr); |
| 6873 | 4997 email = va_arg(ap, char *); |
| 2086 | 4998 va_end(ap); |
| 4999 | |
| 6873 | 5000 buf = g_strdup_printf(_("No results found for email address %s"), email); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5001 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
| 5420 | 5002 g_free(buf); |
| 2086 | 5003 |
| 5004 return 1; | |
| 5005 } | |
| 5006 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5007 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 6873 | 5008 GaimConnection *gc = sess->aux_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5009 fu16_t status; |
| 2086 | 5010 va_list ap; |
| 5011 char msg[256]; | |
| 5012 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5013 va_start(ap, fr); |
| 4199 | 5014 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
| 2086 | 5015 va_end(ap); |
| 5016 | |
| 8660 | 5017 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5018 "account confirmation returned status 0x%04x (%s)\n", status, |
| 3912 | 5019 status ? "unknown" : "email sent"); |
| 5020 if (!status) { | |
| 5302 | 5021 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
| 5575 | 5022 gaim_account_get_username(gaim_connection_get_account(gc))); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5023 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
| 2086 | 5024 } |
| 5025 | |
| 5026 return 1; | |
| 5027 } | |
| 5028 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5029 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 5030 GaimConnection *gc = sess->aux_data; |
| 2086 | 5031 va_list ap; |
| 3912 | 5032 fu16_t perms, err; |
| 5033 char *url, *sn, *email; | |
| 5034 int change; | |
| 2086 | 5035 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5036 va_start(ap, fr); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5037 change = va_arg(ap, int); |
| 4199 | 5038 perms = (fu16_t) va_arg(ap, unsigned int); |
| 5039 err = (fu16_t) va_arg(ap, unsigned int); | |
| 3912 | 5040 url = va_arg(ap, char *); |
| 5041 sn = va_arg(ap, char *); | |
| 5042 email = va_arg(ap, char *); | |
| 2086 | 5043 va_end(ap); |
| 5044 | |
| 8660 | 5045 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5046 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
| 3912 | 5047 change ? "change" : "request", perms, err, url, sn, email); |
| 5048 | |
| 5049 if (err && url) { | |
| 5050 char *dialog_msg; | |
| 5051 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
| 5052 switch (err) { | |
| 5053 case 0x0001: { | |
| 5054 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
| 5055 } break; | |
| 5056 case 0x0006: { | |
| 5057 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
| 5058 } break; | |
| 5059 case 0x000b: { | |
| 5060 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
| 5061 } break; | |
| 5062 case 0x001d: { | |
| 5063 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because there is already a request pending for this screen name."), err); | |
| 5064 } break; | |
| 5065 case 0x0021: { | |
| 5066 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address has too many screen names associated with it."), err); | |
| 5067 } break; | |
| 5068 case 0x0023: { | |
| 5069 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
| 5070 } break; | |
| 5071 default: { | |
| 5072 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
| 5073 } break; | |
| 5074 } | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5075 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
| 3912 | 5076 g_free(dialog_top); |
| 5077 g_free(dialog_msg); | |
| 5078 return 1; | |
| 5079 } | |
| 5080 | |
| 5081 if (sn) { | |
| 4585 | 5082 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formatted as follows:\n%s"), sn); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5083 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
| 3912 | 5084 g_free(dialog_msg); |
| 5085 } | |
| 5086 | |
| 5087 if (email) { | |
| 5575 | 5088 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
| 5089 gaim_account_get_username(gaim_connection_get_account(gc)), email); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5090 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
| 3912 | 5091 g_free(dialog_msg); |
| 2086 | 5092 } |
| 5093 | |
| 5094 return 1; | |
| 5095 } | |
| 5096 | |
| 5575 | 5097 static void oscar_keepalive(GaimConnection *gc) { |
| 7283 | 5098 OscarData *od = (OscarData *)gc->proto_data; |
| 4617 | 5099 aim_flap_nop(od->sess, od->conn); |
| 2086 | 5100 } |
| 5101 | |
| 6059 | 5102 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
| 7283 | 5103 OscarData *od = (OscarData *)gc->proto_data; |
| 8971 | 5104 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
| 5105 if (dim && dim->connected) | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5106 if (typing == GAIM_TYPING) |
| 4870 | 5107 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5108 else if (typing == GAIM_TYPED) |
| 4870 | 5109 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
| 5110 else | |
| 5111 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
| 3595 | 5112 else { |
| 5300 | 5113 /* Don't send if this turkey is in our deny list */ |
| 5114 GSList *list; | |
| 5115 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
| 5116 if (!list) { | |
| 7261 | 5117 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
| 5300 | 5118 if (bi && bi->typingnot) { |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5119 if (typing == GAIM_TYPING) |
| 5300 | 5120 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5121 else if (typing == GAIM_TYPED) |
| 5300 | 5122 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
| 5123 else | |
| 5124 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
| 5125 } | |
| 3595 | 5126 } |
| 5127 } | |
| 2993 | 5128 return 0; |
| 5129 } | |
| 9030 | 5130 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5131 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5132 |
|
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5133 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { |
| 7283 | 5134 OscarData *od = (OscarData *)gc->proto_data; |
| 8971 | 5135 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5136 int ret = 0; |
| 3659 | 5137 GError *err = NULL; |
| 5575 | 5138 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
| 8800 | 5139 char *tmpmsg = NULL, *tmpmsg2 = NULL; |
| 3458 | 5140 |
| 4838 | 5141 if (dim && dim->connected) { |
| 5142 /* If we're directly connected, send a direct IM */ | |
| 6982 | 5143 ret = gaim_odc_send_im(od->sess, dim->conn, message, imflags); |
| 2086 | 5144 } else { |
| 4738 | 5145 struct buddyinfo *bi; |
| 3008 | 5146 struct aim_sendimext_args args; |
| 5147 struct stat st; | |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5148 gsize len; |
| 8962 | 5149 GaimConversation *conv = gaim_find_conversation_with_account(name, gaim_connection_get_account(gc)); |
| 5150 | |
| 5151 if (strstr(message, "<IMG ")) | |
| 5152 gaim_conversation_write(conv, "", | |
| 5153 _("Your IM Image was not sent. " | |
| 5154 "You must be Direct Connected to send IM Images."), | |
| 5155 GAIM_MESSAGE_ERROR, time(NULL)); | |
| 4269 | 5156 |
| 7261 | 5157 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
| 4738 | 5158 if (!bi) { |
| 5159 bi = g_new0(struct buddyinfo, 1); | |
| 7261 | 5160 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(gc->account, name)), bi); |
| 4738 | 5161 } |
| 5162 | |
| 3008 | 5163 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
| 4665 | 5164 if (od->icq) { |
| 5165 args.features = features_icq; | |
| 5166 args.featureslen = sizeof(features_icq); | |
| 3008 | 5167 args.flags |= AIM_IMFLAGS_OFFLINE; |
| 4665 | 5168 } else { |
| 5169 args.features = features_aim; | |
| 5170 args.featureslen = sizeof(features_aim); | |
| 4972 | 5171 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
5172 if (imflags & GAIM_CONV_IM_AUTO_RESP) |
| 4972 | 5173 args.flags |= AIM_IMFLAGS_AWAY; |
| 4665 | 5174 } |
| 4269 | 5175 |
| 4738 | 5176 if (bi->ico_need) { |
| 8660 | 5177 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5178 "Sending buddy icon request with message\n"); |
| 3008 | 5179 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
| 4738 | 5180 bi->ico_need = FALSE; |
| 3008 | 5181 } |
| 4269 | 5182 |
| 5575 | 5183 if (iconfile && !stat(iconfile, &st)) { |
| 8361 | 5184 FILE *file = fopen(iconfile, "rb"); |
| 3008 | 5185 if (file) { |
| 5186 char *buf = g_malloc(st.st_size); | |
| 9532 | 5187 /* XXX - Use g_file_get_contents()? */ |
| 3008 | 5188 fread(buf, 1, st.st_size, file); |
| 6039 | 5189 fclose(file); |
| 4269 | 5190 |
| 3008 | 5191 args.iconlen = st.st_size; |
| 4617 | 5192 args.iconsum = aimutil_iconsum(buf, st.st_size); |
| 3008 | 5193 args.iconstamp = st.st_mtime; |
| 5194 | |
| 7406 | 5195 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
| 4738 | 5196 bi->ico_informed = FALSE; |
| 7406 | 5197 bi->ico_sent = FALSE; |
| 5198 } | |
| 4738 | 5199 |
| 5200 if (!bi->ico_informed) { | |
| 8660 | 5201 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5202 "Claiming to have a buddy icon\n"); |
| 4738 | 5203 args.flags |= AIM_IMFLAGS_HASICON; |
| 5204 bi->ico_me_len = args.iconlen; | |
| 5205 bi->ico_me_csum = args.iconsum; | |
| 5206 bi->ico_me_time = args.iconstamp; | |
| 5207 bi->ico_informed = TRUE; | |
| 5208 } | |
| 5209 | |
| 3008 | 5210 g_free(buf); |
| 2086 | 5211 } |
| 5212 } | |
| 4269 | 5213 |
| 3008 | 5214 args.destsn = name; |
| 4269 | 5215 |
| 8985 | 5216 /* |
| 5217 * If we're IMing an ICQ user then send newlines as CR/LF and | |
| 5218 * strip all HTML | |
| 5219 */ | |
| 8995 | 5220 if (isdigit(name[0]) ) { |
| 5221 /* being sent to an ICQ user */ | |
| 5222 if (!isdigit(gaim_account_get_username(gc->account)[0])) { | |
| 5223 /* from an AIM user - ICQ receiving from AIM *expects the messsage to be HTML formatted* */ | |
| 5224 tmpmsg = gaim_str_add_cr(message); | |
| 5225 } else { | |
| 5226 /* from an ICQ user - do nothing */ | |
| 5227 tmpmsg = g_strdup(message); | |
| 5228 } | |
| 5229 } else { | |
| 5230 /* being sent to an AIM user */ | |
| 5231 if (isdigit(gaim_account_get_username(gc->account)[0])) { | |
| 5232 /* from an ICQ user */ | |
| 5233 tmpmsg2 = gaim_strdup_withhtml(message); | |
| 5234 tmpmsg = gaim_escape_html(tmpmsg2); | |
| 5235 g_free(tmpmsg2); | |
| 5236 } else | |
| 5237 tmpmsg = gaim_strdup_withhtml(message); | |
| 5238 } | |
| 6310 | 5239 len = strlen(tmpmsg); |
| 5240 | |
| 5241 args.flags |= oscar_encoding_check(tmpmsg); | |
| 3642 | 5242 if (args.flags & AIM_IMFLAGS_UNICODE) { |
| 8660 | 5243 gaim_debug_info("oscar", "Sending Unicode IM\n"); |
| 4662 | 5244 args.charset = 0x0002; |
| 4665 | 5245 args.charsubset = 0x0000; |
| 6310 | 5246 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
| 3659 | 5247 if (err) { |
| 8660 | 5248 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5249 "Error converting a unicode message: %s\n", err->message); |
| 8660 | 5250 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5251 "This really shouldn't happen!\n"); |
| 3659 | 5252 /* We really shouldn't try to send the |
| 5253 * IM now, but I'm not sure what to do */ | |
| 4800 | 5254 g_error_free(err); |
| 3659 | 5255 } |
| 3850 | 5256 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
| 8660 | 5257 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5258 "Sending ISO-8859-1 IM\n"); |
| 4662 | 5259 args.charset = 0x0003; |
| 4665 | 5260 args.charsubset = 0x0000; |
| 6310 | 5261 args.msg = g_convert(tmpmsg, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
| 3659 | 5262 if (err) { |
| 8660 | 5263 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5264 "conversion error: %s\n", err->message); |
| 8660 | 5265 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5266 "Someone tell Ethan his 8859-1 detection is wrong\n"); |
| 3642 | 5267 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; |
| 6310 | 5268 len = strlen(tmpmsg); |
| 4800 | 5269 g_error_free(err); |
| 6310 | 5270 args.msg = g_convert(tmpmsg, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
| 3659 | 5271 if (err) { |
| 8660 | 5272 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5273 "Error in unicode fallback: %s\n", err->message); |
| 4800 | 5274 g_error_free(err); |
| 3659 | 5275 } |
| 3642 | 5276 } |
| 5277 } else { | |
| 4662 | 5278 args.charset = 0x0000; |
| 5279 args.charsubset = 0x0000; | |
| 6310 | 5280 args.msg = tmpmsg; |
| 3642 | 5281 } |
| 5282 args.msglen = len; | |
| 4269 | 5283 |
| 4617 | 5284 ret = aim_im_sendch1_ext(od->sess, &args); |
| 2086 | 5285 } |
| 4838 | 5286 |
| 6310 | 5287 g_free(tmpmsg); |
| 5288 | |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5289 if (ret >= 0) |
|
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5290 return 1; |
| 6310 | 5291 |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
5292 return ret; |
| 2086 | 5293 } |
| 5294 | |
| 7011 | 5295 static void oscar_get_info(GaimConnection *gc, const char *name) { |
| 7283 | 5296 OscarData *od = (OscarData *)gc->proto_data; |
| 7011 | 5297 |
| 7173 | 5298 if (od->icq && isdigit(name[0])) |
| 4624 | 5299 aim_icq_getallinfo(od->sess, name); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
5300 else |
| 7235 | 5301 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
| 7011 | 5302 } |
| 5303 | |
| 8950 | 5304 #if 0 |
| 7011 | 5305 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
| 3466 | 5306 const char *maiden, const char *city, const char *state, const char *country, int web) { |
| 4617 | 5307 /* XXX - some of these things are wrong, but i'm lazy */ |
| 7283 | 5308 OscarData *od = (OscarData *)gc->proto_data; |
| 7011 | 5309 aim_locate_setdirinfo(od->sess, first, middle, last, |
| 2086 | 5310 maiden, NULL, NULL, city, state, NULL, 0, web); |
| 5311 } | |
| 8950 | 5312 #endif |
| 2086 | 5313 |
| 5575 | 5314 static void oscar_set_idle(GaimConnection *gc, int time) { |
| 7283 | 5315 OscarData *od = (OscarData *)gc->proto_data; |
| 7474 | 5316 aim_srv_setidle(od->sess, time); |
| 2086 | 5317 } |
| 5318 | |
| 5954 | 5319 static void oscar_set_info(GaimConnection *gc, const char *text) { |
| 7283 | 5320 OscarData *od = (OscarData *)gc->proto_data; |
| 5129 | 5321 fu32_t flags = 0; |
| 6019 | 5322 char *text_html = NULL; |
| 5129 | 5323 char *msg = NULL; |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5324 gsize msglen = 0; |
| 2993 | 5325 |
| 4617 | 5326 if (od->rights.maxsiglen == 0) |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5327 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5328 _("You have probably requested to set your " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5329 "profile before the login procedure completed. " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5330 "Your profile remains unset; try setting it " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5331 "again when you are fully connected.")); |
| 4617 | 5332 |
| 7334 | 5333 if (!text) { |
| 5334 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | |
| 5335 return; | |
| 5336 } | |
| 6019 | 5337 |
| 7334 | 5338 text_html = gaim_strdup_withhtml(text); |
| 5339 flags = oscar_encoding_check(text_html); | |
| 5340 if (flags & AIM_IMFLAGS_UNICODE) { | |
| 5341 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
| 5342 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
| 5343 g_free(msg); | |
| 5344 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
| 5345 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); | |
| 5346 aim_locate_setprofile(od->sess, "iso-8859-1", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
| 5347 g_free(msg); | |
| 5348 } else { | |
| 5349 msglen = strlen(text_html); | |
| 5350 aim_locate_setprofile(od->sess, "us-ascii", text_html, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | |
| 5351 } | |
| 5352 | |
| 5353 if (msglen > od->rights.maxsiglen) { | |
| 5354 gchar *errstr; | |
| 5355 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
| 5356 "has been exceeded. Gaim has truncated it for you.", | |
| 5357 "The maximum profile length of %d bytes " | |
| 5358 "has been exceeded. Gaim has truncated it for you.", | |
| 5359 od->rights.maxsiglen), od->rights.maxsiglen); | |
| 5360 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
| 5361 g_free(errstr); | |
| 5362 } | |
| 5363 | |
| 5364 g_free(text_html); | |
| 2993 | 5365 |
| 5366 return; | |
| 2086 | 5367 } |
| 5368 | |
| 8257 | 5369 static void oscar_set_away_aim(GaimConnection *gc, OscarData *od, const char *state, const char *text) |
| 2993 | 5370 { |
| 5129 | 5371 fu32_t flags = 0; |
| 6019 | 5372 gchar *text_html = NULL; |
| 5129 | 5373 char *msg = NULL; |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
5374 gsize msglen = 0; |
| 2993 | 5375 |
| 8257 | 5376 if (!strcmp(state, _("Visible"))) { |
| 5377 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); | |
| 5378 return; | |
| 5379 } else if (!strcmp(state, _("Invisible"))) { | |
| 5380 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); | |
| 5381 return; | |
| 5382 } /* else... */ | |
| 5383 | |
| 8476 | 5384 if (!strcmp(state, _("Back"))) { |
| 5385 /* If this is our only online account then globally set Gaim not-away */ | |
| 5386 GList *gcs = gaim_connections_get_all(); | |
| 5387 if (gcs->next == NULL) | |
| 5388 do_im_back(NULL, NULL); | |
| 5389 } | |
| 5390 | |
| 8257 | 5391 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
| 5392 | |
| 2993 | 5393 if (od->rights.maxawaymsglen == 0) |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5394 gaim_notify_warning(gc, NULL, _("Unable to set AIM away message."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5395 _("You have probably requested to set your " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5396 "away message before the login procedure " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5397 "completed. You remain in a \"present\" " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5398 "state; try setting it again when you are " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5399 "fully connected.")); |
| 5129 | 5400 |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5401 if (gc->away) { |
| 2993 | 5402 g_free(gc->away); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5403 gc->away = NULL; |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5404 } |
| 2993 | 5405 |
| 5129 | 5406 if (!text) { |
| 7334 | 5407 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5408 return; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5409 } |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5410 |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
5411 text_html = gaim_strdup_withhtml(text); |
| 6019 | 5412 flags = oscar_encoding_check(text_html); |
| 5129 | 5413 if (flags & AIM_IMFLAGS_UNICODE) { |
| 6019 | 5414 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
| 7011 | 5415 aim_locate_setprofile(od->sess, NULL, NULL, 0, "unicode-2-0", msg, |
| 7334 | 5416 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
| 5129 | 5417 g_free(msg); |
| 5418 gc->away = g_strndup(text, od->rights.maxawaymsglen/2); | |
| 5419 } else if (flags & AIM_IMFLAGS_ISO_8859_1) { | |
| 6019 | 5420 msg = g_convert(text_html, strlen(text_html), "ISO-8859-1", "UTF-8", NULL, &msglen, NULL); |
| 7011 | 5421 aim_locate_setprofile(od->sess, NULL, NULL, 0, "iso-8859-1", msg, |
| 7334 | 5422 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
| 5129 | 5423 g_free(msg); |
| 6019 | 5424 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
| 5129 | 5425 } else { |
| 6019 | 5426 msglen = strlen(text_html); |
| 7011 | 5427 aim_locate_setprofile(od->sess, NULL, NULL, 0, "us-ascii", text_html, |
| 7334 | 5428 (msglen > od->rights.maxawaymsglen ? od->rights.maxawaymsglen : msglen)); |
| 6019 | 5429 gc->away = g_strndup(text_html, od->rights.maxawaymsglen); |
| 5129 | 5430 } |
| 5431 | |
| 5432 if (msglen > od->rights.maxawaymsglen) { | |
| 2993 | 5433 gchar *errstr; |
| 5434 | |
| 6308 | 5435 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " |
| 5436 "has been exceeded. Gaim has truncated it for you.", | |
| 5437 "The maximum away message length of %d bytes " | |
| 5438 "has been exceeded. Gaim has truncated it for you.", | |
| 5439 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5440 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
| 2993 | 5441 g_free(errstr); |
| 5442 } | |
| 6019 | 5443 |
| 5444 g_free(text_html); | |
| 8257 | 5445 |
| 2993 | 5446 return; |
| 5447 } | |
| 5448 | |
| 7283 | 5449 static void oscar_set_away_icq(GaimConnection *gc, OscarData *od, const char *state, const char *message) |
| 2993 | 5450 { |
| 5575 | 5451 GaimAccount *account = gaim_connection_get_account(gc); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5452 if (gc->away) { |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5453 g_free(gc->away); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5454 gc->away = NULL; |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5455 } |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5456 |
| 8265 | 5457 if (strcmp(state, _("Invisible"))) |
| 5575 | 5458 account->perm_deny = 4; |
| 8265 | 5459 else |
| 5575 | 5460 account->perm_deny = 3; |
| 8265 | 5461 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
| 5462 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
| 4342 | 5463 |
| 5464 if (!strcmp(state, _("Online"))) | |
| 4901 | 5465 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
| 4342 | 5466 else if (!strcmp(state, _("Away"))) { |
| 4901 | 5467 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5468 gc->away = g_strdup(""); |
| 4342 | 5469 } else if (!strcmp(state, _("Do Not Disturb"))) { |
| 4901 | 5470 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5471 gc->away = g_strdup(""); |
| 4342 | 5472 } else if (!strcmp(state, _("Not Available"))) { |
| 4901 | 5473 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5474 gc->away = g_strdup(""); |
| 4342 | 5475 } else if (!strcmp(state, _("Occupied"))) { |
| 4901 | 5476 aim_setextstatus(od->sess, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5477 gc->away = g_strdup(""); |
| 4342 | 5478 } else if (!strcmp(state, _("Free For Chat"))) { |
| 4901 | 5479 aim_setextstatus(od->sess, AIM_ICQ_STATE_CHAT); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5480 gc->away = g_strdup(""); |
| 4342 | 5481 } else if (!strcmp(state, _("Invisible"))) { |
| 4901 | 5482 aim_setextstatus(od->sess, AIM_ICQ_STATE_INVISIBLE); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5483 gc->away = g_strdup(""); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5484 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
| 2998 | 5485 if (message) { |
| 4901 | 5486 aim_setextstatus(od->sess, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
5487 gc->away = g_strdup(""); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5488 } else { |
| 4901 | 5489 aim_setextstatus(od->sess, AIM_ICQ_STATE_NORMAL); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5490 } |
| 2086 | 5491 } |
| 2993 | 5492 |
| 5493 return; | |
| 5494 } | |
| 5495 | |
| 6059 | 5496 static void oscar_set_away(GaimConnection *gc, const char *state, const char *message) |
| 2993 | 5497 { |
| 7283 | 5498 OscarData *od = (OscarData *)gc->proto_data; |
| 2993 | 5499 |
| 5500 if (od->icq) | |
| 5501 oscar_set_away_icq(gc, od, state, message); | |
| 5502 else | |
| 8257 | 5503 oscar_set_away_aim(gc, od, state, message); |
| 2993 | 5504 |
| 5505 return; | |
| 2086 | 5506 } |
| 5507 | |
| 6059 | 5508 static void oscar_warn(GaimConnection *gc, const char *name, int anon) { |
| 7283 | 5509 OscarData *od = (OscarData *)gc->proto_data; |
| 4617 | 5510 aim_im_warn(od->sess, od->conn, name, anon ? AIM_WARN_ANON : 0); |
| 2086 | 5511 } |
| 5512 | |
| 9285 | 5513 static void oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
| 7283 | 5514 OscarData *od = (OscarData *)gc->proto_data; |
| 9285 | 5515 |
| 5516 if (!aim_snvalid(buddy->name)) { | |
| 8092 | 5517 gchar *buf; |
| 9285 | 5518 buf = g_strdup_printf(_("Could not add the buddy %s because the screen name is invalid. Screen names must either start with a letter and contain only letters, numbers and spaces, or contain only numbers."), buddy->name); |
| 8092 | 5519 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
| 5520 g_free(buf); | |
| 8150 | 5521 |
| 5522 /* Remove from local list */ | |
| 9285 | 5523 gaim_blist_remove_buddy(buddy); |
| 8150 | 5524 |
| 8092 | 5525 return; |
| 5526 } | |
| 5527 | |
| 4230 | 5528 #ifdef NOSSI |
| 9285 | 5529 aim_buddylist_addbuddy(od->sess, od->conn, buddy->name); |
| 4230 | 5530 #else |
| 9285 | 5531 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
| 5532 if (buddy && group) { | |
| 8660 | 5533 gaim_debug_info("oscar", |
| 9285 | 5534 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
| 5535 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_get_buddy_alias_only(buddy), NULL, NULL, 0); | |
| 4230 | 5536 } |
| 5537 } | |
| 5538 #endif | |
| 8150 | 5539 |
| 4759 | 5540 if (od->icq) |
| 9285 | 5541 aim_icq_getalias(od->sess, buddy->name); |
| 5542 } | |
| 5543 | |
| 5544 static void oscar_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) { | |
| 7283 | 5545 OscarData *od = (OscarData *)gc->proto_data; |
| 4230 | 5546 #ifdef NOSSI |
| 5547 char buf[MSG_LEN]; | |
| 5548 int n=0; | |
| 9285 | 5549 |
| 4230 | 5550 while (buddies) { |
| 9381 | 5551 GaimBuddy *buddy = buddies->data; |
| 4230 | 5552 if (n > MSG_LEN - 18) { |
| 7285 | 5553 aim_buddylist_set(od->sess, od->conn, buf); |
| 4230 | 5554 n = 0; |
| 3092 | 5555 } |
| 9381 | 5556 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", buddy->name); |
| 4230 | 5557 buddies = buddies->next; |
| 5558 } | |
| 7285 | 5559 aim_buddylist_set(od->sess, od->conn, buf); |
| 4230 | 5560 #else |
| 9285 | 5561 |
| 4230 | 5562 if (od->sess->ssi.received_data) { |
| 9285 | 5563 GList *curb = buddies; |
| 5564 GList *curg = groups; | |
| 5565 while ((curb != NULL) && (curg != NULL)) { | |
| 5566 GaimBuddy *buddy = curb->data; | |
| 5567 GaimGroup *group = curg->data; | |
| 5568 oscar_add_buddy(gc, buddy, group); | |
| 5569 curb = curb->next; | |
| 5570 curg = curg->next; | |
| 4230 | 5571 } |
| 5572 } | |
| 5573 #endif | |
| 5574 } | |
| 5575 | |
| 9285 | 5576 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { |
| 7283 | 5577 OscarData *od = (OscarData *)gc->proto_data; |
| 9285 | 5578 |
| 4230 | 5579 #ifdef NOSSI |
| 9285 | 5580 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); |
| 4230 | 5581 #else |
| 5582 if (od->sess->ssi.received_data) { | |
| 8660 | 5583 gaim_debug_info("oscar", |
| 9285 | 5584 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
| 5585 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
| 4230 | 5586 } |
| 5587 #endif | |
| 5588 } | |
| 5589 | |
| 9285 | 5590 static void oscar_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) { |
| 7283 | 5591 OscarData *od = (OscarData *)gc->proto_data; |
| 9285 | 5592 |
| 4230 | 5593 #ifdef NOSSI |
| 9285 | 5594 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 5595 GaimBuddy *buddy = cur->data; | |
| 5596 aim_buddylist_removebuddy(od->sess, od->conn, buddy->name); | |
| 5597 } | |
| 4230 | 5598 #else |
| 5599 if (od->sess->ssi.received_data) { | |
| 9285 | 5600 GList *curb = buddies; |
| 5601 GList *curg = groups; | |
| 5602 while ((curb != NULL) && (curg != NULL)) { | |
| 5603 GaimBuddy *buddy = curb->data; | |
| 5604 GaimGroup *group = curg->data; | |
| 5605 oscar_remove_buddy(gc, buddy, group); | |
| 5606 curb = curb->next; | |
| 5607 curg = curg->next; | |
| 3092 | 5608 } |
| 4230 | 5609 } |
| 5610 #endif | |
| 5611 } | |
| 5612 | |
| 5613 #ifndef NOSSI | |
| 5575 | 5614 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
| 7283 | 5615 OscarData *od = (OscarData *)gc->proto_data; |
| 4303 | 5616 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
| 8660 | 5617 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5618 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
| 4889 | 5619 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
| 4269 | 5620 } |
| 5621 } | |
| 5622 | |
| 5575 | 5623 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
| 7283 | 5624 OscarData *od = (OscarData *)gc->proto_data; |
| 4269 | 5625 if (od->sess->ssi.received_data) { |
| 5626 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
| 5627 if (gname) { | |
| 8660 | 5628 gaim_debug_info("oscar", |
| 9586 | 5629 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
| 4889 | 5630 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
| 4269 | 5631 } |
| 5632 } | |
| 5633 } | |
| 5634 | |
| 9285 | 5635 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
| 8341 | 5636 OscarData *od = (OscarData *)gc->proto_data; |
| 4230 | 5637 |
| 5638 if (od->sess->ssi.received_data) { | |
| 9285 | 5639 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
| 5640 GList *cur, *groups = NULL; | |
| 5641 | |
| 5642 /* Make a list of what the groups each buddy is in */ | |
| 5643 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
| 5644 GaimBlistNode *node = cur->data; | |
| 5645 groups = g_list_append(groups, node->parent); | |
| 5646 } | |
| 5647 | |
| 5648 oscar_remove_buddies(gc, moved_buddies, groups); | |
| 5649 oscar_add_buddies(gc, moved_buddies, groups); | |
| 5650 g_list_free(groups); | |
| 8660 | 5651 gaim_debug_info("oscar", |
| 9285 | 5652 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
| 4230 | 5653 } else { |
| 9285 | 5654 aim_ssi_rename_group(od->sess, old_name, group->name); |
| 8660 | 5655 gaim_debug_info("oscar", |
| 9285 | 5656 "ssi: renamed group %s to %s\n", old_name, group->name); |
| 2995 | 5657 } |
| 5658 } | |
| 5659 } | |
| 5660 | |
| 5968 | 5661 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
| 5662 aim_session_t *sess = data; | |
| 6350 | 5663 aim_ssi_reqdata(sess); |
| 5968 | 5664 return FALSE; |
| 5665 } | |
| 5666 | |
| 4642 | 5667 static int gaim_ssi_parseerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 5668 GaimConnection *gc = sess->aux_data; |
| 7283 | 5669 OscarData *od = gc->proto_data; |
| 4642 | 5670 va_list ap; |
| 5671 fu16_t reason; | |
| 5672 | |
| 5673 va_start(ap, fr); | |
| 5674 reason = (fu16_t)va_arg(ap, unsigned int); | |
| 5675 va_end(ap); | |
| 5676 | |
| 8660 | 5677 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
| 4642 | 5678 |
| 5679 if (reason == 0x0005) { | |
| 5892 | 5680 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
| 5828 | 5681 _("Gaim was temporarily unable to retrieve your buddy list from the AIM servers. Your buddy list is not lost, and will probably become available in a few hours.")); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5682 od->getblisttimer = gaim_timeout_add(300000, gaim_ssi_rerequestdata, od->sess); |
| 4642 | 5683 } |
| 5684 | |
| 5685 /* Activate SSI */ | |
| 5686 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
| 5687 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
| 8660 | 5688 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
| 4642 | 5689 aim_ssi_enable(od->sess); |
| 5690 | |
| 5691 return 1; | |
| 5692 } | |
| 5693 | |
| 2991 | 5694 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 5695 GaimConnection *gc = sess->aux_data; |
| 7283 | 5696 OscarData *od = (OscarData *)gc->proto_data; |
| 4230 | 5697 int numtypes, i; |
| 5698 fu16_t *maxitems; | |
| 2991 | 5699 va_list ap; |
| 5700 | |
| 5701 va_start(ap, fr); | |
| 4230 | 5702 numtypes = va_arg(ap, int); |
| 5703 maxitems = va_arg(ap, fu16_t *); | |
| 2991 | 5704 va_end(ap); |
| 5705 | |
| 8660 | 5706 gaim_debug_misc("oscar", "ssi rights:"); |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5707 |
| 4230 | 5708 for (i=0; i<numtypes; i++) |
| 8660 | 5709 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5710 i, maxitems[i]); |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
5711 |
| 8660 | 5712 gaim_debug_misc(NULL, "\n"); |
| 4230 | 5713 |
| 5714 if (numtypes >= 0) | |
| 5715 od->rights.maxbuddies = maxitems[0]; | |
| 5716 if (numtypes >= 1) | |
| 5717 od->rights.maxgroups = maxitems[1]; | |
| 5718 if (numtypes >= 2) | |
| 5719 od->rights.maxpermits = maxitems[2]; | |
| 5720 if (numtypes >= 3) | |
| 5721 od->rights.maxdenies = maxitems[3]; | |
| 2991 | 5722 |
| 5723 return 1; | |
| 5724 } | |
| 5725 | |
| 5726 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 5727 GaimConnection *gc = sess->aux_data; |
| 5728 GaimAccount *account = gaim_connection_get_account(gc); | |
| 7283 | 5729 OscarData *od = (OscarData *)gc->proto_data; |
| 8150 | 5730 GaimGroup *g; |
| 5731 GaimBuddy *b; | |
| 2995 | 5732 struct aim_ssi_item *curitem; |
| 2991 | 5733 int tmp; |
| 4230 | 5734 va_list ap; |
| 8219 | 5735 fu16_t fmtver, numitems; |
| 5736 struct aim_ssi_item *items; | |
| 5737 fu32_t timestamp; | |
| 4230 | 5738 |
| 5739 va_start(ap, fr); | |
| 5740 fmtver = (fu16_t)va_arg(ap, int); | |
| 5741 numitems = (fu16_t)va_arg(ap, int); | |
| 8219 | 5742 items = va_arg(ap, struct aim_ssi_item *); |
| 4230 | 5743 timestamp = va_arg(ap, fu32_t); |
| 8219 | 5744 va_end(ap); |
| 2991 | 5745 |
| 8660 | 5746 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5747 "ssi: syncing local list and server list\n"); |
| 2991 | 5748 |
| 8219 | 5749 if ((timestamp == 0) || (numitems == 0)) { |
| 8660 | 5750 gaim_debug_info("oscar", "Got AIM SSI with a 0 timestamp or 0 numitems--not syncing. This probably means your buddy list is empty.", NULL); |
| 8219 | 5751 return 1; |
| 5752 } | |
| 5753 | |
| 2991 | 5754 /* Clean the buddy list */ |
| 4889 | 5755 aim_ssi_cleanlist(sess); |
| 2991 | 5756 |
| 8150 | 5757 { /* If not in server list then prune from local list */ |
| 5758 GaimBlistNode *gnode, *cnode, *bnode; | |
| 5759 GaimBuddyList *blist; | |
| 9539 | 5760 GSList *cur, *next; |
| 8150 | 5761 |
| 5762 /* Buddies */ | |
| 5763 cur = NULL; | |
| 5764 if ((blist = gaim_get_blist()) != NULL) { | |
| 5765 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
| 5766 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 5767 continue; | |
| 5768 g = (GaimGroup *)gnode; | |
| 5769 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 5770 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 5771 continue; | |
| 5772 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 5773 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 5774 continue; | |
| 5775 b = (GaimBuddy *)bnode; | |
| 5776 if (b->account == gc->account) { | |
| 5777 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
| 5778 /* If the buddy is an ICQ user then load his nickname */ | |
| 5779 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
| 8214 | 5780 char *alias; |
| 8150 | 5781 if (servernick) |
| 5782 serv_got_alias(gc, b->name, servernick); | |
| 5783 | |
| 5784 /* Store local alias on server */ | |
| 8214 | 5785 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
| 8150 | 5786 if (!alias && b->alias && strlen(b->alias)) |
| 5787 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
| 5788 free(alias); | |
| 5789 } else { | |
| 8660 | 5790 gaim_debug_info("oscar", |
| 8150 | 5791 "ssi: removing buddy %s from local list\n", b->name); |
| 5792 /* We can't actually remove now because it will screw up our looping */ | |
| 5793 cur = g_slist_prepend(cur, b); | |
| 5794 } | |
| 5795 } | |
| 5796 } | |
| 5797 } | |
| 5798 } | |
| 5799 } | |
| 8175 | 5800 |
| 8150 | 5801 while (cur != NULL) { |
| 5802 b = cur->data; | |
| 5803 cur = g_slist_remove(cur, b); | |
| 5804 gaim_blist_remove_buddy(b); | |
| 5805 } | |
| 5806 | |
| 5807 /* Permit list */ | |
| 5808 if (gc->account->permit) { | |
| 9539 | 5809 next = gc->account->permit; |
| 5810 while (next != NULL) { | |
| 5811 cur = next; | |
| 5812 next = next->next; | |
| 8150 | 5813 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
| 8660 | 5814 gaim_debug_info("oscar", |
| 8150 | 5815 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
| 5816 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
| 5817 } | |
| 9539 | 5818 } |
| 8150 | 5819 } |
| 5820 | |
| 5821 /* Deny list */ | |
| 5822 if (gc->account->deny) { | |
| 9539 | 5823 next = gc->account->deny; |
| 5824 while (next != NULL) { | |
| 5825 cur = next; | |
| 5826 next = next->next; | |
| 8150 | 5827 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
| 8660 | 5828 gaim_debug_info("oscar", |
| 8150 | 5829 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
| 5830 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
| 5831 } | |
| 9539 | 5832 } |
| 8150 | 5833 } |
| 5834 /* Presence settings (idle time visibility) */ | |
| 5835 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
| 5836 if (!(tmp & 0x400)) | |
| 5837 aim_ssi_setpresence(sess, tmp | 0x400); | |
| 5838 } /* end pruning buddies from local list */ | |
| 5839 | |
| 2991 | 5840 /* Add from server list to local list */ |
| 4230 | 5841 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
| 7328 | 5842 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
| 2991 | 5843 switch (curitem->type) { |
| 4230 | 5844 case 0x0000: { /* Buddy */ |
| 4251 | 5845 if (curitem->name) { |
| 4292 | 5846 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
| 7166 | 5847 char *gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; |
| 4282 | 5848 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
| 7166 | 5849 char *alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; |
| 8150 | 5850 b = gaim_find_buddy(gc->account, curitem->name); |
| 4458 | 5851 /* Should gname be freed here? -- elb */ |
| 4754 | 5852 /* Not with the current code, but that might be cleaner -- med */ |
| 4458 | 5853 free(alias); |
| 8150 | 5854 if (b) { |
| 4292 | 5855 /* Get server stored alias */ |
| 4705 | 5856 if (alias_utf8) { |
| 8150 | 5857 g_free(b->alias); |
| 5858 b->alias = g_strdup(alias_utf8); | |
| 4705 | 5859 } |
| 4282 | 5860 } else { |
| 8150 | 5861 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
| 5146 | 5862 |
| 4754 | 5863 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
| 4687 | 5864 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
| 4754 | 5865 gaim_blist_add_group(g, NULL); |
| 5866 } | |
| 5146 | 5867 |
| 8660 | 5868 gaim_debug_info("oscar", |
| 9285 | 5869 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
| 8150 | 5870 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 4251 | 5871 } |
| 8341 | 5872 if (!aim_sncmp(curitem->name, account->username)) { |
| 5873 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
| 5874 gaim_check_comment(od, comment); | |
| 5875 free(comment); | |
| 5876 } | |
| 7162 | 5877 g_free(gname_utf8); |
| 5878 g_free(alias_utf8); | |
| 2991 | 5879 } |
| 4230 | 5880 } break; |
| 5881 | |
| 5882 case 0x0001: { /* Group */ | |
| 4282 | 5883 /* Shouldn't add empty groups */ |
| 4230 | 5884 } break; |
| 5885 | |
| 5886 case 0x0002: { /* Permit buddy */ | |
| 2991 | 5887 if (curitem->name) { |
| 4230 | 5888 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
| 2991 | 5889 GSList *list; |
| 5575 | 5890 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 5891 if (!list) { |
| 8660 | 5892 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5893 "ssi: adding permit buddy %s to local list\n", curitem->name); |
|
6400
588e88bcdac5
[gaim-migrate @ 6905]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
5894 gaim_privacy_permit_add(account, curitem->name, TRUE); |
| 2991 | 5895 } |
| 5896 } | |
| 4230 | 5897 } break; |
| 5898 | |
| 5899 case 0x0003: { /* Deny buddy */ | |
| 2991 | 5900 if (curitem->name) { |
| 5901 GSList *list; | |
| 5575 | 5902 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 5903 if (!list) { |
| 8660 | 5904 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5905 "ssi: adding deny buddy %s to local list\n", curitem->name); |
|
6400
588e88bcdac5
[gaim-migrate @ 6905]
Christian Hammond <chipx86@chipx86.com>
parents:
6378
diff
changeset
|
5906 gaim_privacy_deny_add(account, curitem->name, TRUE); |
| 2991 | 5907 } |
| 5908 } | |
| 4230 | 5909 } break; |
| 5910 | |
| 5911 case 0x0004: { /* Permit/deny setting */ | |
| 2991 | 5912 if (curitem->data) { |
| 5913 fu8_t permdeny; | |
| 5575 | 5914 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
| 8660 | 5915 gaim_debug_info("oscar", |
| 5575 | 5916 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
| 5917 account->perm_deny = permdeny; | |
| 5918 if (od->icq && account->perm_deny == 0x03) { | |
| 4342 | 5919 serv_set_away(gc, "Invisible", ""); |
| 5920 } | |
| 2991 | 5921 } |
| 5922 } | |
| 4230 | 5923 } break; |
| 5924 | |
| 5925 case 0x0005: { /* Presence setting */ | |
| 3109 | 5926 /* We don't want to change Gaim's setting because it applies to all accounts */ |
| 4230 | 5927 } break; |
| 2991 | 5928 } /* End of switch on curitem->type */ |
| 5929 } /* End of for loop */ | |
| 4230 | 5930 |
| 4901 | 5931 /* Set our ICQ status */ |
| 8257 | 5932 if (!gc->away) { |
| 4901 | 5933 aim_setextstatus(sess, AIM_ICQ_STATE_NORMAL); |
| 5934 } | |
| 5935 | |
| 4342 | 5936 /* Activate SSI */ |
| 5937 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
| 5938 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
| 8660 | 5939 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5940 "ssi: activating server-stored buddy list\n"); |
| 4642 | 5941 aim_ssi_enable(sess); |
| 4342 | 5942 |
| 2991 | 5943 return 1; |
| 2086 | 5944 } |
| 4230 | 5945 |
| 5946 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 5947 GaimConnection *gc = sess->aux_data; |
| 4230 | 5948 va_list ap; |
| 5949 struct aim_ssi_tmp *retval; | |
| 5950 | |
| 5951 va_start(ap, fr); | |
| 5952 retval = va_arg(ap, struct aim_ssi_tmp *); | |
| 5953 va_end(ap); | |
| 5954 | |
| 5955 while (retval) { | |
| 8660 | 5956 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5957 "ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack, retval->action, retval->item ? (retval->item->name ? retval->item->name : "no name") : "no item"); |
| 4230 | 5958 |
| 5959 if (retval->ack != 0xffff) | |
| 5960 switch (retval->ack) { | |
| 5961 case 0x0000: { /* added successfully */ | |
| 5962 } break; | |
| 5963 | |
| 4829 | 5964 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
| 5965 gchar *buf; | |
| 5966 buf = g_strdup_printf(_("Could not add the buddy %s because you have too many buddies in your buddy list. Please remove one and try again."), (retval->name ? retval->name : _("(no name)"))); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5967 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
| 4829 | 5968 g_free(buf); |
| 5969 } | |
| 5970 | |
| 7023 | 5971 case 0x000e: { /* buddy requires authorization */ |
| 4828 | 5972 if ((retval->action == AIM_CB_SSI_ADD) && (retval->name)) |
| 4269 | 5973 gaim_auth_sendrequest(gc, retval->name); |
| 4230 | 5974 } break; |
| 5975 | |
| 5976 default: { /* La la la */ | |
| 5197 | 5977 gchar *buf; |
| 8660 | 5978 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
| 5402 | 5979 buf = g_strdup_printf(_("Could not add the buddy %s for an unknown reason. The most common reason for this is that you have the maximum number of allowed buddies in your buddy list."), (retval->name ? retval->name : _("(no name)"))); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5980 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
| 5197 | 5981 g_free(buf); |
| 4230 | 5982 } break; |
| 5983 } | |
| 5984 | |
| 5985 retval = retval->next; | |
| 5986 } | |
| 5987 | |
| 5988 return 1; | |
| 5989 } | |
| 5990 | |
| 8227 | 5991 static int gaim_ssi_parseadd(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5992 GaimConnection *gc = sess->aux_data; | |
| 5993 char *gname, *gname_utf8, *alias, *alias_utf8; | |
| 5994 GaimBuddy *b; | |
| 5995 GaimGroup *g; | |
| 5996 va_list ap; | |
| 5997 fu16_t type; | |
| 5998 const char *name; | |
| 5999 | |
| 6000 va_start(ap, fr); | |
| 6001 type = (fu16_t)va_arg(ap, int); | |
| 6002 name = va_arg(ap, char *); | |
| 6003 va_end(ap); | |
| 6004 | |
| 6005 if ((type != 0x0000) || (name == NULL)) | |
| 6006 return 1; | |
| 6007 | |
| 6008 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
| 6009 gname_utf8 = gname ? gaim_utf8_try_convert(gname) : NULL; | |
| 6010 alias = aim_ssi_getalias(sess->ssi.local, gname, name); | |
| 6011 alias_utf8 = alias ? gaim_utf8_try_convert(alias) : NULL; | |
| 6012 b = gaim_find_buddy(gc->account, name); | |
| 6013 free(alias); | |
| 6014 | |
| 6015 if (b) { | |
| 6016 /* Get server stored alias */ | |
| 6017 if (alias_utf8) { | |
| 6018 g_free(b->alias); | |
| 6019 b->alias = g_strdup(alias_utf8); | |
| 6020 } | |
| 6021 } else { | |
| 6022 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
| 6023 | |
| 6024 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
| 6025 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
| 6026 gaim_blist_add_group(g, NULL); | |
| 6027 } | |
| 6028 | |
| 8660 | 6029 gaim_debug_info("oscar", |
| 9285 | 6030 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
| 8227 | 6031 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 6032 } | |
| 6033 g_free(gname_utf8); | |
| 6034 g_free(alias_utf8); | |
| 6035 | |
| 6036 return 1; | |
| 6037 } | |
| 6038 | |
| 4230 | 6039 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5575 | 6040 GaimConnection *gc = sess->aux_data; |
| 4230 | 6041 va_list ap; |
| 6042 char *sn, *msg; | |
| 4236 | 6043 gchar *dialog_msg, *nombre; |
| 4230 | 6044 struct name_data *data; |
| 6695 | 6045 GaimBuddy *buddy; |
| 4230 | 6046 |
| 6047 va_start(ap, fr); | |
| 6048 sn = va_arg(ap, char *); | |
| 6049 msg = va_arg(ap, char *); | |
| 6050 va_end(ap); | |
| 6051 | |
| 8660 | 6052 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6053 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
| 4230 | 6054 |
| 4687 | 6055 buddy = gaim_find_buddy(gc->account, sn); |
| 6056 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
| 6057 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
| 4236 | 6058 else |
| 6059 nombre = g_strdup(sn); | |
| 6060 | |
| 6061 dialog_msg = g_strdup_printf(_("The user %s has given you permission to add you to their buddy list. Do you want to add them?"), nombre); | |
| 4230 | 6062 data = g_new(struct name_data, 1); |
| 6063 data->gc = gc; | |
| 6064 data->name = g_strdup(sn); | |
| 6065 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6066 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6067 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6068 0, data, |
| 7023 | 6069 G_CALLBACK(gaim_icq_buddyadd), |
| 5836 | 6070 G_CALLBACK(oscar_free_name_data)); |
| 4236 | 6071 |
| 4230 | 6072 g_free(dialog_msg); |
| 4236 | 6073 g_free(nombre); |
| 4230 | 6074 |
| 6075 return 1; | |
| 6076 } | |
| 6077 | |
| 6078 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 6079 GaimConnection *gc = sess->aux_data; |
| 4230 | 6080 va_list ap; |
| 6081 char *sn, *msg; | |
| 4236 | 6082 gchar *dialog_msg, *nombre; |
| 4230 | 6083 struct name_data *data; |
| 6695 | 6084 GaimBuddy *buddy; |
| 4230 | 6085 |
| 6086 va_start(ap, fr); | |
| 6087 sn = va_arg(ap, char *); | |
| 6088 msg = va_arg(ap, char *); | |
| 6089 va_end(ap); | |
| 6090 | |
| 8660 | 6091 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6092 "ssi: received authorization request from %s\n", sn); |
| 4230 | 6093 |
| 4687 | 6094 buddy = gaim_find_buddy(gc->account, sn); |
| 6095 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
| 6096 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
| 4236 | 6097 else |
| 6098 nombre = g_strdup(sn); | |
| 6099 | |
| 4337 | 6100 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
| 4230 | 6101 data = g_new(struct name_data, 1); |
| 6102 data->gc = gc; | |
| 6103 data->name = g_strdup(sn); | |
| 6104 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6105 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6106 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6107 0, data, 2, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6108 _("Authorize"), G_CALLBACK(gaim_auth_grant), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
6109 _("Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
| 4236 | 6110 |
| 4230 | 6111 g_free(dialog_msg); |
| 4236 | 6112 g_free(nombre); |
| 4230 | 6113 |
| 6114 return 1; | |
| 6115 } | |
| 6116 | |
| 6117 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 6118 GaimConnection *gc = sess->aux_data; |
| 4230 | 6119 va_list ap; |
| 6120 char *sn, *msg; | |
| 4236 | 6121 gchar *dialog_msg, *nombre; |
| 4230 | 6122 fu8_t reply; |
| 6695 | 6123 GaimBuddy *buddy; |
| 4230 | 6124 |
| 6125 va_start(ap, fr); | |
| 6126 sn = va_arg(ap, char *); | |
| 6127 reply = (fu8_t)va_arg(ap, int); | |
| 6128 msg = va_arg(ap, char *); | |
| 6129 va_end(ap); | |
| 6130 | |
| 8660 | 6131 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6132 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
| 4236 | 6133 |
| 4687 | 6134 buddy = gaim_find_buddy(gc->account, sn); |
| 6135 if (buddy && (gaim_get_buddy_alias_only(buddy))) | |
| 6136 nombre = g_strdup_printf("%s (%s)", sn, gaim_get_buddy_alias_only(buddy)); | |
| 4236 | 6137 else |
| 6138 nombre = g_strdup(sn); | |
| 6139 | |
| 4230 | 6140 if (reply) { |
| 6141 /* Granted */ | |
| 7023 | 6142 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your buddy list."), nombre); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6143 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
| 4230 | 6144 } else { |
| 6145 /* Denied */ | |
| 7023 | 6146 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6147 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
| 4230 | 6148 } |
| 6149 g_free(dialog_msg); | |
| 4236 | 6150 g_free(nombre); |
| 4230 | 6151 |
| 6152 return 1; | |
| 6153 } | |
| 6154 | |
| 6155 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 5575 | 6156 GaimConnection *gc = sess->aux_data; |
| 4230 | 6157 va_list ap; |
| 6158 char *sn; | |
| 6695 | 6159 GaimBuddy *buddy; |
| 4230 | 6160 |
| 6161 va_start(ap, fr); | |
| 6162 sn = va_arg(ap, char *); | |
| 6163 va_end(ap); | |
| 6164 | |
| 4687 | 6165 buddy = gaim_find_buddy(gc->account, sn); |
| 8660 | 6166 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6167 "ssi: %s added you to their buddy list\n", sn); |
|
7015
dece74f05509
[gaim-migrate @ 7578]
Christian Hammond <chipx86@chipx86.com>
parents:
7011
diff
changeset
|
6168 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_get_buddy_alias_only(buddy) : NULL), NULL); |
| 4230 | 6169 |
| 6170 return 1; | |
| 6171 } | |
| 4269 | 6172 #endif |
| 2086 | 6173 |
| 5575 | 6174 static GList *oscar_chat_info(GaimConnection *gc) { |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6175 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6176 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6177 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6178 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 6179 pce->label = _("_Group:"); |
| 5234 | 6180 pce->identifier = "room"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6181 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6182 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6183 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 6184 pce->label = _("_Exchange:"); |
| 5234 | 6185 pce->identifier = "exchange"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6186 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6187 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6188 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6189 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6190 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6191 return m; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6192 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6193 |
| 8308 | 6194 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
| 6195 OscarData *od = (OscarData *)gc->proto_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6196 aim_conn_t *cur; |
| 5234 | 6197 char *name, *exchange; |
| 6198 | |
| 6199 name = g_hash_table_lookup(data, "room"); | |
| 6200 exchange = g_hash_table_lookup(data, "exchange"); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
6201 |
| 8660 | 6202 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6203 "Attempting to join chat room %s.\n", name); |
| 8308 | 6204 |
| 6205 if ((name == NULL) || (*name == '\0')) { | |
| 6206 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
| 6207 return; | |
| 6208 } | |
| 6209 | |
| 4617 | 6210 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
| 8660 | 6211 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6212 "chatnav exists, creating room\n"); |
| 5234 | 6213 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
| 2086 | 6214 } else { |
| 6215 /* this gets tricky */ | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6216 struct create_room *cr = g_new0(struct create_room, 1); |
| 8660 | 6217 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6218 "chatnav does not exist, opening chatnav\n"); |
| 5234 | 6219 cr->exchange = atoi(exchange); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
6220 cr->name = g_strdup(name); |
| 4617 | 6221 od->create_rooms = g_slist_append(od->create_rooms, cr); |
| 6222 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
| 2086 | 6223 } |
| 6224 } | |
| 6225 | |
| 8308 | 6226 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
| 6227 OscarData *od = (OscarData *)gc->proto_data; | |
| 6228 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
| 2086 | 6229 |
| 6230 if (!ccon) | |
| 6231 return; | |
| 6232 | |
| 8225 | 6233 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
| 2086 | 6234 ccon->exchange, ccon->name, 0x0); |
| 6235 } | |
| 6236 | |
| 8308 | 6237 static void oscar_chat_leave(GaimConnection *gc, int id) { |
| 6238 OscarData *od = gc ? (OscarData *)gc->proto_data : NULL; | |
| 6239 GSList *bcs = gc->buddy_chats; | |
| 5679 | 6240 GaimConversation *b = NULL; |
| 2086 | 6241 struct chat_connection *c = NULL; |
| 6242 int count = 0; | |
| 6243 | |
| 6244 while (bcs) { | |
| 6245 count++; | |
| 5679 | 6246 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7111
diff
changeset
|
6247 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 6248 break; |
| 6249 bcs = bcs->next; | |
| 6250 b = NULL; | |
| 6251 } | |
| 6252 | |
| 6253 if (!b) | |
| 6254 return; | |
| 6255 | |
| 8660 | 6256 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6257 "Attempting to leave room %s (currently in %d rooms)\n", b->name, count); |
| 2086 | 6258 |
| 8308 | 6259 c = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
| 2086 | 6260 if (c != NULL) { |
| 4617 | 6261 if (od) |
| 6262 od->oscar_chats = g_slist_remove(od->oscar_chats, c); | |
| 2086 | 6263 if (c->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
6264 gaim_input_remove(c->inpa); |
| 8308 | 6265 if (gc && od->sess) |
| 4617 | 6266 aim_conn_kill(od->sess, &c->conn); |
| 2086 | 6267 g_free(c->name); |
| 6268 g_free(c->show); | |
| 6269 g_free(c); | |
| 6270 } | |
| 6271 /* we do this because with Oscar it doesn't tell us we left */ | |
| 8308 | 6272 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))); |
| 2086 | 6273 } |
| 6274 | |
| 8219 | 6275 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { |
| 6276 OscarData *od = (OscarData *)gc->proto_data; | |
| 6277 GError *err = NULL; | |
| 6278 GaimConversation *conv = NULL; | |
| 2086 | 6279 struct chat_connection *c = NULL; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6280 char *buf, *buf2; |
| 8219 | 6281 char *charset = NULL; |
| 6282 int encoding; | |
| 8907 | 6283 gsize len; |
| 8219 | 6284 |
| 6285 if (!(conv = gaim_find_chat(gc, id))) | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6286 return -EINVAL; |
| 2086 | 6287 |
| 8219 | 6288 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6289 return -EINVAL; |
| 2086 | 6290 |
| 8219 | 6291 buf = gaim_strdup_withhtml(message); |
| 6292 len = strlen(buf); | |
| 6293 | |
| 8962 | 6294 if (strstr(buf, "<IMG ")) |
| 6295 gaim_conversation_write(conv, "", | |
| 6296 _("Your IM Image was not sent. " | |
| 6297 "You cannot send IM Images in AIM chats."), | |
| 6298 GAIM_MESSAGE_ERROR, time(NULL)); | |
| 6299 | |
| 8219 | 6300 encoding = oscar_encoding_check(buf); |
| 8233 | 6301 if (encoding & AIM_IMFLAGS_UNICODE) { |
| 8660 | 6302 gaim_debug_info("oscar", "Sending Unicode chat\n"); |
| 8219 | 6303 charset = "unicode-2-0"; |
| 6304 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
| 6305 if (err) { | |
| 8660 | 6306 gaim_debug_error("oscar", |
| 8359 | 6307 "Error converting to unicode-2-0: %s\n", err->message); |
| 6308 g_error_free(err); | |
| 6309 } | |
| 8219 | 6310 } else if (encoding & AIM_IMFLAGS_ISO_8859_1) { |
| 8660 | 6311 gaim_debug_info("oscar", "Sending ISO-8859-1 chat\n"); |
| 8219 | 6312 charset = "iso-8859-1"; |
| 6313 buf2 = g_convert(buf, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); | |
| 6314 if (err) { | |
| 8660 | 6315 gaim_debug_error("oscar", |
| 8359 | 6316 "Error converting to iso-8859-1: %s\n", err->message); |
| 8219 | 6317 g_error_free(err); |
| 8359 | 6318 err = NULL; |
| 6319 | |
| 8660 | 6320 gaim_debug_info("oscar", "Falling back to Unicode\n"); |
| 8359 | 6321 charset = "unicode-2-0"; |
| 6322 buf2 = g_convert(buf, len, "UCS-2BE", "UTF-8", NULL, &len, &err); | |
| 8219 | 6323 if (err) { |
| 8660 | 6324 gaim_debug_error("oscar", |
| 8359 | 6325 "Error converting to unicode-2-0: %s\n", |
| 6326 err->message); | |
| 8219 | 6327 g_error_free(err); |
| 6328 } | |
| 2086 | 6329 } |
| 8219 | 6330 } else { |
| 6331 charset = "us-ascii"; | |
| 6332 buf2 = g_strdup(buf); | |
| 6333 } | |
| 8359 | 6334 g_free(buf); |
| 6335 | |
| 6336 if ((len > c->maxlen) || (len > c->maxvis)) { | |
| 6337 g_free(buf2); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6338 return -E2BIG; |
| 8359 | 6339 } |
| 6340 | |
| 6341 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charset, "en"); | |
| 8219 | 6342 g_free(buf2); |
| 8359 | 6343 |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
6344 return 0; |
| 2086 | 6345 } |
| 6346 | |
| 6695 | 6347 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) { |
| 4766 | 6348 if (!b || (b && b->name && b->name[0] == '+')) { |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6349 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
| 4687 | 6350 return "icq"; |
| 6351 else | |
| 6352 return "aim"; | |
| 6353 } | |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6354 |
|
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
6355 if (b != NULL && isdigit(b->name[0])) |
| 4687 | 6356 return "icq"; |
| 6357 return "aim"; | |
| 6358 } | |
| 6359 | |
| 6695 | 6360 static void oscar_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
| 4687 | 6361 { |
| 7334 | 6362 GaimAccount *account = NULL; |
| 6363 GaimConnection *gc = NULL; | |
| 6364 OscarData *od = NULL; | |
| 4687 | 6365 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
| 6366 int i = 0; | |
| 7334 | 6367 aim_userinfo_t *userinfo = NULL; |
| 6368 | |
| 6369 if (b != NULL) | |
| 6370 account = b->account; | |
| 6371 if (account != NULL) | |
| 6372 gc = account->gc; | |
| 6373 if (gc != NULL) | |
| 6374 od = gc->proto_data; | |
| 7945 | 6375 if (od != NULL) |
| 6376 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
| 4687 | 6377 |
| 5131 | 6378 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
| 6379 char *gname; | |
| 7334 | 6380 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
| 5131 | 6381 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && |
| 6382 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { | |
| 6383 emblems[i++] = "notauthorized"; | |
| 6384 } else { | |
| 6385 emblems[i++] = "offline"; | |
| 6386 } | |
| 6387 } | |
| 4916 | 6388 |
| 4766 | 6389 if (b->name && (b->uc & 0xffff0000) && isdigit(b->name[0])) { |
| 4960 | 6390 int uc = b->uc >> 16; |
| 4766 | 6391 if (uc & AIM_ICQ_STATE_INVISIBLE) |
| 4960 | 6392 emblems[i++] = "invisible"; |
| 4766 | 6393 else if (uc & AIM_ICQ_STATE_CHAT) |
| 4960 | 6394 emblems[i++] = "freeforchat"; |
| 4766 | 6395 else if (uc & AIM_ICQ_STATE_DND) |
| 4960 | 6396 emblems[i++] = "dnd"; |
| 4766 | 6397 else if (uc & AIM_ICQ_STATE_OUT) |
| 4960 | 6398 emblems[i++] = "na"; |
| 4766 | 6399 else if (uc & AIM_ICQ_STATE_BUSY) |
| 4960 | 6400 emblems[i++] = "occupied"; |
| 4766 | 6401 else if (uc & AIM_ICQ_STATE_AWAY) |
| 6402 emblems[i++] = "away"; | |
| 6403 } else { | |
| 6404 if (b->uc & UC_UNAVAILABLE) | |
| 6405 emblems[i++] = "away"; | |
| 6406 } | |
| 4687 | 6407 if (b->uc & UC_WIRELESS) |
| 6408 emblems[i++] = "wireless"; | |
| 6409 if (b->uc & UC_AOL) | |
| 6410 emblems[i++] = "aol"; | |
| 6411 if (b->uc & UC_ADMIN) | |
| 6412 emblems[i++] = "admin"; | |
| 6413 if (b->uc & UC_AB && i < 4) | |
| 6414 emblems[i++] = "activebuddy"; | |
| 4766 | 6415 /* if (b->uc & UC_UNCONFIRMED && i < 4) |
| 6416 emblems[i++] = "unconfirmed"; */ | |
| 7334 | 6417 |
| 7945 | 6418 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) |
| 6419 emblems[i++] = "hiptop"; | |
| 6420 | |
| 6421 if ((i < 4) && (userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) | |
| 7334 | 6422 emblems[i++] = "secure"; |
| 6423 | |
| 4687 | 6424 *se = emblems[0]; |
| 6425 *sw = emblems[1]; | |
| 6426 *nw = emblems[2]; | |
| 6427 *ne = emblems[3]; | |
| 6428 } | |
| 6429 | |
| 6695 | 6430 static char *oscar_tooltip_text(GaimBuddy *b) { |
| 5575 | 6431 GaimConnection *gc = b->account->gc; |
| 7283 | 6432 OscarData *od = gc->proto_data; |
| 7045 | 6433 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
| 8701 | 6434 GString *str = g_string_new(""); |
| 5131 | 6435 |
| 6436 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
| 8701 | 6437 oscar_string_append_info(gc, str, "\n", b, userinfo); |
| 7011 | 6438 |
| 6439 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
| 8225 | 6440 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
| 8392 | 6441 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
| 8225 | 6442 g_free(charset); |
| 7011 | 6443 if (away_utf8 != NULL) { |
| 7091 | 6444 gchar *tmp1, *tmp2; |
| 8341 | 6445 tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); |
| 6446 g_free(away_utf8); | |
|
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7093
diff
changeset
|
6447 tmp2 = gaim_markup_strip_html(tmp1); |
| 7091 | 6448 g_free(tmp1); |
| 8571 | 6449 tmp1 = gaim_escape_html(tmp2); |
| 7091 | 6450 g_free(tmp2); |
| 8700 | 6451 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
| 8461 | 6452 g_free(tmp1); |
| 8701 | 6453 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
| 8700 | 6454 g_free(tmp2); |
| 5836 | 6455 } |
| 5131 | 6456 } |
| 8701 | 6457 } |
| 6458 | |
| 6459 return g_string_free(str, FALSE); | |
| 5131 | 6460 } |
| 6461 | |
| 6695 | 6462 static char *oscar_status_text(GaimBuddy *b) { |
| 5575 | 6463 GaimConnection *gc = b->account->gc; |
| 7283 | 6464 OscarData *od = gc->proto_data; |
| 5167 | 6465 gchar *ret = NULL; |
| 6466 | |
| 6467 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | |
| 6468 if (isdigit(b->name[0])) | |
| 8701 | 6469 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
| 7038 | 6470 else |
| 6471 ret = g_strdup(_("Away")); | |
| 5836 | 6472 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
| 7261 | 6473 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
| 6292 | 6474 if (bi->availmsg) |
| 6475 ret = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
| 5836 | 6476 } else { |
| 5167 | 6477 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
| 6478 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
| 6479 ret = g_strdup(_("Not Authorized")); | |
| 6480 else | |
| 6481 ret = g_strdup(_("Offline")); | |
| 6482 } | |
| 6483 | |
| 6484 return ret; | |
| 6485 } | |
| 6486 | |
| 5842 | 6487 |
| 5844 | 6488 static int oscar_icon_req(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 5842 | 6489 GaimConnection *gc = sess->aux_data; |
| 7283 | 6490 OscarData *od = gc->proto_data; |
| 5892 | 6491 va_list ap; |
| 5842 | 6492 fu16_t type; |
| 5892 | 6493 fu8_t flags = 0, length = 0; |
| 6494 char *md5 = NULL; | |
| 6495 | |
| 7334 | 6496 |
| 5842 | 6497 va_start(ap, fr); |
| 6498 type = va_arg(ap, int); | |
| 5892 | 6499 |
| 6500 switch(type) { | |
| 6501 case 0x0000: | |
| 6502 case 0x0001: { | |
| 6503 flags = va_arg(ap, int); | |
| 6504 length = va_arg(ap, int); | |
| 6505 md5 = va_arg(ap, char *); | |
| 6506 | |
| 6507 if (flags == 0x41) { | |
| 6508 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
| 6509 od->iconconnecting = TRUE; | |
| 6510 od->set_icon = TRUE; | |
| 6511 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
| 6512 } else { | |
| 6039 | 6513 struct stat st; |
| 6514 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
| 6515 if (iconfile == NULL) { | |
| 8363 | 6516 aim_ssi_delicon(od->sess); |
| 6039 | 6517 } else if (!stat(iconfile, &st)) { |
| 6518 char *buf = g_malloc(st.st_size); | |
| 6519 FILE *file = fopen(iconfile, "rb"); | |
| 6520 if (file) { | |
| 9532 | 6521 /* XXX - Use g_file_get_contents()? */ |
| 6039 | 6522 fread(buf, 1, st.st_size, file); |
| 6523 fclose(file); | |
| 8660 | 6524 gaim_debug_info("oscar", |
| 6039 | 6525 "Uploading icon to icon server\n"); |
| 6879 | 6526 aim_bart_upload(od->sess, buf, st.st_size); |
| 5892 | 6527 } else |
| 8660 | 6528 gaim_debug_error("oscar", |
| 6039 | 6529 "Can't open buddy icon file!\n"); |
| 6530 g_free(buf); | |
| 6531 } else { | |
| 8660 | 6532 gaim_debug_error("oscar", |
| 6039 | 6533 "Can't stat buddy icon file!\n"); |
| 5892 | 6534 } |
| 6535 } | |
| 8363 | 6536 } else if (flags == 0x81) { |
| 6537 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | |
| 6538 if (iconfile == NULL) | |
| 6539 aim_ssi_delicon(od->sess); | |
| 6540 else | |
| 6541 aim_ssi_seticon(od->sess, md5, length); | |
| 6542 } | |
| 5892 | 6543 } break; |
| 6544 | |
| 6545 case 0x0002: { /* We just set an "available" message? */ | |
| 6546 } break; | |
| 6547 } | |
| 6548 | |
| 5842 | 6549 va_end(ap); |
| 5844 | 6550 |
| 6551 return 0; | |
| 5842 | 6552 } |
| 5892 | 6553 |
| 5575 | 6554 static void oscar_set_permit_deny(GaimConnection *gc) { |
| 6555 GaimAccount *account = gaim_connection_get_account(gc); | |
| 7283 | 6556 OscarData *od = (OscarData *)gc->proto_data; |
| 4230 | 6557 #ifdef NOSSI |
| 8143 | 6558 GSList *list; |
| 4230 | 6559 char buf[MAXMSGLEN]; |
| 6560 int at; | |
| 6561 | |
| 5575 | 6562 switch(account->perm_deny) { |
| 8175 | 6563 case GAIM_PRIVACY_ALLOW_ALL: |
| 5575 | 6564 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account)); |
| 4230 | 6565 break; |
| 8175 | 6566 case GAIM_PRIVACY_DENY_ALL: |
| 5575 | 6567 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account)); |
| 4230 | 6568 break; |
| 8175 | 6569 case GAIM_PRIVACY_ALLOW_USERS: |
| 5575 | 6570 list = account->permit; |
| 4230 | 6571 at = 0; |
| 6572 while (list) { | |
| 6573 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
| 6574 list = list->next; | |
| 6575 } | |
| 6576 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
| 6577 break; | |
| 8175 | 6578 case GAIM_PRIVACY_DENY_USERS: |
| 5575 | 6579 list = account->deny; |
| 4230 | 6580 at = 0; |
| 6581 while (list) { | |
| 6582 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
| 6583 list = list->next; | |
| 6584 } | |
| 6585 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
| 6586 break; | |
| 6587 default: | |
| 6588 break; | |
| 2086 | 6589 } |
| 4230 | 6590 #else |
| 8175 | 6591 if (od->sess->ssi.received_data) { |
| 6592 switch (account->perm_deny) { | |
| 6593 case GAIM_PRIVACY_ALLOW_ALL: | |
| 6594 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
| 6595 break; | |
| 6596 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
| 6597 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
| 6598 break; | |
| 6599 case GAIM_PRIVACY_ALLOW_USERS: | |
| 6600 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
| 6601 break; | |
| 6602 case GAIM_PRIVACY_DENY_ALL: | |
| 6603 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
| 6604 break; | |
| 6605 case GAIM_PRIVACY_DENY_USERS: | |
| 6606 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
| 6607 break; | |
| 6608 default: | |
| 6609 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
| 6610 break; | |
| 6611 } | |
| 6612 } | |
| 4230 | 6613 #endif |
| 2086 | 6614 } |
| 6615 | |
| 5575 | 6616 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
| 4269 | 6617 #ifdef NOSSI |
| 8143 | 6618 if (gc->account->perm_deny == 3) |
| 4269 | 6619 oscar_set_permit_deny(gc); |
| 6620 #else | |
| 7283 | 6621 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 6622 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
| 4230 | 6623 if (od->sess->ssi.received_data) |
| 4889 | 6624 aim_ssi_addpermit(od->sess, who); |
| 4230 | 6625 #endif |
| 2086 | 6626 } |
| 6627 | |
| 5575 | 6628 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
| 4269 | 6629 #ifdef NOSSI |
| 8143 | 6630 if (gc->account->perm_deny == 4) |
| 4269 | 6631 oscar_set_permit_deny(gc); |
| 6632 #else | |
| 7283 | 6633 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 6634 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
| 4230 | 6635 if (od->sess->ssi.received_data) |
| 4889 | 6636 aim_ssi_adddeny(od->sess, who); |
| 4230 | 6637 #endif |
| 2086 | 6638 } |
| 6639 | |
| 5575 | 6640 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
| 4269 | 6641 #ifdef NOSSI |
| 8143 | 6642 if (gc->account->perm_deny == 3) |
| 4269 | 6643 oscar_set_permit_deny(gc); |
| 6644 #else | |
| 7283 | 6645 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 6646 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
| 4230 | 6647 if (od->sess->ssi.received_data) |
| 4889 | 6648 aim_ssi_delpermit(od->sess, who); |
| 4230 | 6649 #endif |
| 2086 | 6650 } |
| 6651 | |
| 5575 | 6652 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
| 4269 | 6653 #ifdef NOSSI |
| 8143 | 6654 if (gc->account->perm_deny == 4) |
| 4269 | 6655 oscar_set_permit_deny(gc); |
| 6656 #else | |
| 7283 | 6657 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 6658 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
| 4230 | 6659 if (od->sess->ssi.received_data) |
| 4889 | 6660 aim_ssi_deldeny(od->sess, who); |
| 4230 | 6661 #endif |
| 2086 | 6662 } |
| 6663 | |
| 5575 | 6664 static GList *oscar_away_states(GaimConnection *gc) |
| 2086 | 6665 { |
| 7283 | 6666 OscarData *od = gc->proto_data; |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6667 GList *m = NULL; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
6668 |
| 8257 | 6669 if (od->icq) { |
| 6670 m = g_list_append(m, _("Online")); | |
| 6671 m = g_list_append(m, _("Away")); | |
| 6672 m = g_list_append(m, _("Do Not Disturb")); | |
| 6673 m = g_list_append(m, _("Not Available")); | |
| 6674 m = g_list_append(m, _("Occupied")); | |
| 6675 m = g_list_append(m, _("Free For Chat")); | |
| 6676 m = g_list_append(m, _("Invisible")); | |
| 6677 } else { | |
| 6678 m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
| 8476 | 6679 m = g_list_append(m, _("Back")); |
| 8257 | 6680 m = g_list_append(m, _("Visible")); |
| 6681 m = g_list_append(m, _("Invisible")); | |
| 6682 } | |
| 4333 | 6683 |
| 6684 return m; | |
| 6685 } | |
| 6686 | |
| 7172 | 6687 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
| 8341 | 6688 GaimConnection *gc = data->gc; |
| 6689 OscarData *od = gc->proto_data; | |
| 7172 | 6690 GaimBuddy *b; |
| 6691 GaimGroup *g; | |
| 6692 | |
| 6693 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
| 6694 oscar_free_name_data(data); | |
| 6695 return; | |
| 6696 } | |
| 6697 | |
| 6698 if (!(g = gaim_find_buddys_group(b))) { | |
| 6699 oscar_free_name_data(data); | |
| 6700 return; | |
| 6701 } | |
| 6702 | |
| 6703 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
| 8341 | 6704 |
| 6705 if (!aim_sncmp(data->name, gc->account->username)) | |
| 6706 gaim_check_comment(od, text); | |
| 6707 | |
| 7172 | 6708 oscar_free_name_data(data); |
| 6709 } | |
| 6710 | |
| 9030 | 6711 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
| 6712 | |
| 6713 GaimBuddy *buddy; | |
| 6714 GaimConnection *gc; | |
| 6715 OscarData *od; | |
| 6716 struct name_data *data; | |
| 7172 | 6717 GaimGroup *g; |
| 6718 char *comment; | |
| 6719 gchar *comment_utf8; | |
| 6720 | |
| 9030 | 6721 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
| 6722 | |
| 6723 buddy = (GaimBuddy *) node; | |
| 6724 gc = gaim_account_get_connection(buddy->account); | |
| 6725 od = gc->proto_data; | |
| 6726 | |
| 6727 data = g_new(struct name_data, 1); | |
| 6728 | |
| 6729 if (!(g = gaim_find_buddys_group(buddy))) | |
| 7172 | 6730 return; |
| 9030 | 6731 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
| 7172 | 6732 comment_utf8 = comment ? gaim_utf8_try_convert(comment) : NULL; |
| 6733 | |
| 6734 data->gc = gc; | |
| 9030 | 6735 data->name = g_strdup(buddy->name); |
| 7172 | 6736 data->nick = NULL; |
| 6737 | |
| 6738 gaim_request_input(gc, NULL, _("Buddy Comment:"), NULL, | |
| 8697 | 6739 comment_utf8, TRUE, FALSE, NULL, |
| 7172 | 6740 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
| 6741 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
| 6742 data); | |
| 6743 | |
| 6744 free(comment); | |
| 6745 g_free(comment_utf8); | |
| 6746 } | |
| 6747 | |
| 9030 | 6748 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
| 6749 | |
| 6750 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
| 7283 | 6751 OscarData *od = gc->proto_data; |
| 9030 | 6752 |
| 4333 | 6753 GList *m = NULL; |
| 9030 | 6754 GaimBlistNodeAction *act; |
| 6755 | |
| 6756 act = gaim_blist_node_action_new(_("Edit Buddy Comment"), | |
| 6757 oscar_buddycb_edit_comment, NULL); | |
| 6758 m = g_list_append(m, act); | |
| 7172 | 6759 |
| 4333 | 6760 if (od->icq) { |
| 4624 | 6761 #if 0 |
| 9030 | 6762 act = gaim_blist_node_action_new(_("Get Status Msg"), |
| 6763 oscar_get_icqstatusmsg, NULL); | |
| 6764 m = g_list_append(m, act); | |
| 4624 | 6765 #endif |
| 4333 | 6766 } else { |
| 7011 | 6767 aim_userinfo_t *userinfo; |
| 9030 | 6768 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
| 6769 | |
| 6770 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
| 6771 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 6772 | |
| 7011 | 6773 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
| 9030 | 6774 act = gaim_blist_node_action_new(_("Direct IM"), |
| 6775 oscar_ask_direct_im, NULL); | |
| 6776 m = g_list_append(m, act); | |
| 5917 | 6777 } |
| 9466 | 6778 #if 0 |
| 7650 | 6779 if (userinfo->capabilities & AIM_CAPS_SENDFILE) { |
| 9030 | 6780 act = gaim_blist_node_action_new(_("Send File"), |
| 6781 oscar_ask_sendfile, NULL); | |
| 6782 m = g_list_append(m, act); | |
| 7650 | 6783 } |
| 7011 | 6784 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
| 9030 | 6785 act = gaim_blist_node_action_new(_("Get File"), |
| 6786 oscar_ask_getfile, NULL); | |
| 6787 m = g_list_append(m, act); | |
| 5917 | 6788 } |
| 4826 | 6789 #endif |
| 4333 | 6790 } |
| 5131 | 6791 } |
| 5197 | 6792 |
| 5131 | 6793 if (od->sess->ssi.received_data) { |
| 9030 | 6794 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
| 6795 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
| 6796 act = gaim_blist_node_action_new(_("Re-request Authorization"), | |
| 6797 gaim_auth_sendrequest_menu, NULL); | |
| 6798 m = g_list_append(m, act); | |
| 4333 | 6799 } |
| 4916 | 6800 } |
| 6801 | |
| 4333 | 6802 return m; |
| 6803 } | |
| 6804 | |
| 9030 | 6805 |
| 6806 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
| 6807 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 6808 return oscar_buddy_menu((GaimBuddy *) node); | |
| 6809 } else { | |
| 6810 return NULL; | |
| 6811 } | |
| 6812 } | |
| 6813 | |
| 6814 | |
| 5575 | 6815 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
| 7283 | 6816 OscarData *od = gc->proto_data; |
| 5575 | 6817 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
| 4333 | 6818 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
| 6819 od->setnick = TRUE; | |
| 6820 od->newsn = g_strdup(nick); | |
| 6821 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 6822 } else { | |
| 6823 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
| 6824 } | |
| 6825 } else { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6826 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
| 8152 | 6827 _("Screen name formatting can change only capitalization and whitespace.")); |
| 4333 | 6828 } |
| 6829 } | |
| 6830 | |
| 9015 | 6831 static void oscar_show_format_screenname(GaimPluginAction *action) |
| 4333 | 6832 { |
| 9015 | 6833 GaimConnection *gc = (GaimConnection *) action->context; |
| 8152 | 6834 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
| 8697 | 6835 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6836 _("OK"), G_CALLBACK(oscar_format_screenname), |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6837 _("Cancel"), NULL, |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6838 gc); |
| 4333 | 6839 } |
| 6840 | |
| 9015 | 6841 static void oscar_confirm_account(GaimPluginAction *action) |
| 4333 | 6842 { |
| 9015 | 6843 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 6844 OscarData *od = gc->proto_data; |
| 4333 | 6845 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 6846 | |
| 6847 if (conn) { | |
| 6848 aim_admin_reqconfirm(od->sess, conn); | |
| 6849 } else { | |
| 6850 od->conf = TRUE; | |
| 6851 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 6852 } | |
| 6853 } | |
| 6854 | |
| 9015 | 6855 static void oscar_show_email(GaimPluginAction *action) |
| 4333 | 6856 { |
| 9015 | 6857 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 6858 OscarData *od = gc->proto_data; |
| 4333 | 6859 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 6860 | |
| 6861 if (conn) { | |
| 6862 aim_admin_getinfo(od->sess, conn, 0x11); | |
| 6863 } else { | |
| 6864 od->reqemail = TRUE; | |
| 6865 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 6866 } | |
| 6867 } | |
| 6868 | |
| 5575 | 6869 static void oscar_change_email(GaimConnection *gc, const char *email) |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6870 { |
| 7283 | 6871 OscarData *od = gc->proto_data; |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6872 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6873 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6874 if (conn) { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6875 aim_admin_setemail(od->sess, conn, email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6876 } else { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6877 od->setemail = TRUE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6878 od->email = g_strdup(email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6879 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6880 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6881 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6882 |
| 9015 | 6883 static void oscar_show_change_email(GaimPluginAction *action) |
| 4333 | 6884 { |
| 9015 | 6885 GaimConnection *gc = (GaimConnection *) action->context; |
|
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
6886 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
| 8697 | 6887 FALSE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6888 _("OK"), G_CALLBACK(oscar_change_email), |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6889 _("Cancel"), NULL, |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
6890 gc); |
| 4333 | 6891 } |
| 6892 | |
| 9015 | 6893 static void oscar_show_awaitingauth(GaimPluginAction *action) |
| 4333 | 6894 { |
| 9015 | 6895 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 6896 OscarData *od = gc->proto_data; |
| 4333 | 6897 gchar *nombre, *text, *tmp; |
| 6695 | 6898 GaimBlistNode *gnode, *cnode, *bnode; |
| 4333 | 6899 int num=0; |
| 6900 | |
| 6873 | 6901 text = g_strdup(""); |
| 4333 | 6902 |
| 4785 | 6903 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 6695 | 6904 GaimGroup *group = (GaimGroup *)gnode; |
| 4785 | 6905 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 6906 continue; | |
| 6695 | 6907 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 6908 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 4785 | 6909 continue; |
| 6695 | 6910 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 6911 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 6912 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 6913 continue; | |
| 6914 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
| 6915 if (gaim_get_buddy_alias_only(buddy)) | |
| 6916 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_get_buddy_alias_only(buddy)); | |
| 6917 else | |
| 6918 nombre = g_strdup_printf(" %s", buddy->name); | |
| 6873 | 6919 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
| 6695 | 6920 g_free(text); |
| 6921 text = tmp; | |
| 6922 g_free(nombre); | |
| 6923 num++; | |
| 6924 } | |
| 4333 | 6925 } |
| 2979 | 6926 } |
| 4333 | 6927 } |
| 6928 | |
| 6929 if (!num) { | |
| 6930 g_free(text); | |
| 6873 | 6931 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
| 6932 } | |
| 6933 | |
| 6934 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
| 6935 "the following buddies"), _("You can re-request " | |
| 6936 "authorization from these buddies by " | |
| 6937 "right-clicking on them and selecting " | |
| 6938 "\"Re-request Authorization.\""), text, NULL, NULL); | |
| 4333 | 6939 g_free(text); |
| 2979 | 6940 } |
| 6941 | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6942 static void search_by_email_cb(GaimConnection *gc, const char *email) |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6943 { |
| 8950 | 6944 OscarData *od = (OscarData *)gc->proto_data; |
| 6945 | |
| 6946 aim_search_address(od->sess, od->conn, email); | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6947 } |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6948 |
| 9015 | 6949 static void oscar_show_find_email(GaimPluginAction *action) |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6950 { |
| 9015 | 6951 GaimConnection *gc = (GaimConnection *) action->context; |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6952 gaim_request_input(gc, _("Find Buddy by E-mail"), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6953 _("Search for a buddy by e-mail address"), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6954 _("Type the e-mail address of the buddy you are " |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6955 "searching for."), |
| 8697 | 6956 NULL, FALSE, FALSE, NULL, |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6957 _("Search"), G_CALLBACK(search_by_email_cb), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6958 _("Cancel"), NULL, gc); |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6959 } |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
6960 |
| 7366 | 6961 #if 0 |
| 5917 | 6962 static void oscar_setavailmsg(GaimConnection *gc, char *text) { |
| 7283 | 6963 OscarData *od = (OscarData *)gc->proto_data; |
| 5917 | 6964 |
| 7334 | 6965 aim_locate_setprofile(od->sess, NULL, NULL, 0, NULL, "", 0); |
| 5917 | 6966 aim_srv_setavailmsg(od->sess, text); |
| 6967 } | |
| 6968 | |
| 6969 static void oscar_show_setavailmsg(GaimConnection *gc) | |
| 6970 { | |
| 7313 | 6971 gaim_request_input(gc, NULL, _("Available Message:"), NULL, |
| 6972 _("I'm doing work and hoping for a distraction--IM me!"), | |
| 8697 | 6973 TRUE, FALSE, NULL, |
| 5917 | 6974 _("OK"), G_CALLBACK(oscar_setavailmsg), |
| 6975 _("Cancel"), NULL, | |
| 6976 gc); | |
| 6977 } | |
| 7366 | 6978 #endif |
| 5917 | 6979 |
| 9015 | 6980 static void oscar_show_set_info(GaimPluginAction *action) |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6981 { |
| 9015 | 6982 GaimConnection *gc = (GaimConnection *) action->context; |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6983 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6984 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
6985 |
| 9015 | 6986 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
| 8576 | 6987 { |
| 9015 | 6988 GaimConnection *gc = (GaimConnection *) action->context; |
| 8576 | 6989 gaim_notify_uri(gc, "http://web.icq.com/whitepages/login/1,,,00.html"); |
| 6990 } | |
| 6991 | |
| 9015 | 6992 static void oscar_change_pass(GaimPluginAction *action) |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6993 { |
| 9015 | 6994 GaimConnection *gc = (GaimConnection *) action->context; |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6995 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6996 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
6997 |
| 9015 | 6998 static void oscar_show_chpassurl(GaimPluginAction *action) |
| 4333 | 6999 { |
| 9015 | 7000 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 7001 OscarData *od = gc->proto_data; |
| 5575 | 7002 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
|
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6400
diff
changeset
|
7003 gaim_notify_uri(gc, substituted); |
| 5517 | 7004 g_free(substituted); |
| 4333 | 7005 } |
| 7006 | |
| 9015 | 7007 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
| 7026 | 7008 { |
| 9015 | 7009 GaimConnection *gc = (GaimConnection *) action->context; |
| 7026 | 7010 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
| 7011 } | |
| 7012 | |
| 5842 | 7013 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
| 7014 { | |
| 7283 | 7015 OscarData *od = gc->proto_data; |
| 5844 | 7016 aim_session_t *sess = od->sess; |
| 5842 | 7017 FILE *file; |
| 7018 struct stat st; | |
| 5844 | 7019 |
| 6039 | 7020 if (iconfile == NULL) { |
| 8363 | 7021 aim_ssi_delicon(od->sess); |
| 6039 | 7022 } else if (!stat(iconfile, &st)) { |
| 5842 | 7023 char *buf = g_malloc(st.st_size); |
| 7024 file = fopen(iconfile, "rb"); | |
| 7025 if (file) { | |
| 6052 | 7026 md5_state_t *state; |
| 6039 | 7027 char md5[16]; |
| 9532 | 7028 /* XXX - Use g_file_get_contents()? */ |
| 5842 | 7029 int len = fread(buf, 1, st.st_size, file); |
| 6039 | 7030 fclose(file); |
| 6052 | 7031 state = g_malloc(sizeof(md5_state_t)); |
| 5842 | 7032 md5_init(state); |
| 7033 md5_append(state, buf, len); | |
| 7034 md5_finish(state, md5); | |
| 7035 g_free(state); | |
| 7036 aim_ssi_seticon(sess, md5, 16); | |
| 7037 } else | |
| 8660 | 7038 gaim_debug_error("oscar", |
| 5842 | 7039 "Can't open buddy icon file!\n"); |
| 7040 g_free(buf); | |
| 7041 } else | |
| 8660 | 7042 gaim_debug_error("oscar", |
| 5842 | 7043 "Can't stat buddy icon file!\n"); |
| 7044 } | |
| 7045 | |
| 7046 | |
| 9015 | 7047 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
| 2086 | 7048 { |
| 9015 | 7049 GaimConnection *gc = (GaimConnection *) context; |
| 7283 | 7050 OscarData *od = gc->proto_data; |
| 4333 | 7051 GList *m = NULL; |
| 9015 | 7052 GaimPluginAction *act; |
| 7053 | |
| 7054 act = gaim_plugin_action_new(_("Set User Info..."), | |
| 7055 oscar_show_set_info); | |
| 7056 m = g_list_append(m, act); | |
| 4333 | 7057 |
| 8576 | 7058 if (od->icq) { |
| 9015 | 7059 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
| 7060 oscar_show_set_info_icqurl); | |
| 7061 m = g_list_append(m, act); | |
| 8576 | 7062 } |
| 7063 | |
| 7366 | 7064 #if 0 |
| 9015 | 7065 act = gaim_plugin_action_new(_("Set Available Message..."), |
| 7066 oscar_show_setavailmsg); | |
| 7067 m = g_list_append(m, act); | |
| 7366 | 7068 #endif |
| 5917 | 7069 |
| 9015 | 7070 act = gaim_plugin_action_new(_("Change Password..."), |
| 7071 oscar_change_pass); | |
| 7072 m = g_list_append(m, act); | |
| 4617 | 7073 |
| 7074 if (od->sess->authinfo->chpassurl) { | |
| 9015 | 7075 act = gaim_plugin_action_new(_("Change Password (URL)"), |
| 7076 oscar_show_chpassurl); | |
| 7077 m = g_list_append(m, act); | |
| 7078 | |
| 7079 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
| 7080 oscar_show_imforwardingurl); | |
| 7081 m = g_list_append(m, act); | |
| 7026 | 7082 } |
| 7083 | |
| 5238 | 7084 if (!od->icq) { |
| 4617 | 7085 /* AIM actions */ |
| 7086 m = g_list_append(m, NULL); | |
| 4333 | 7087 |
| 9015 | 7088 act = gaim_plugin_action_new(_("Format Screen Name..."), |
| 7089 oscar_show_format_screenname); | |
| 7090 m = g_list_append(m, act); | |
| 7091 | |
| 7092 act = gaim_plugin_action_new(_("Confirm Account"), | |
| 7093 oscar_confirm_account); | |
| 7094 m = g_list_append(m, act); | |
| 7095 | |
| 7096 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
| 7097 oscar_show_email); | |
| 7098 m = g_list_append(m, act); | |
| 7099 | |
| 7100 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
| 7101 oscar_show_change_email); | |
| 7102 m = g_list_append(m, act); | |
| 2086 | 7103 } |
| 4333 | 7104 |
| 7105 m = g_list_append(m, NULL); | |
| 7106 | |
| 9015 | 7107 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
| 7108 oscar_show_awaitingauth); | |
| 7109 m = g_list_append(m, act); | |
| 4333 | 7110 |
| 2086 | 7111 m = g_list_append(m, NULL); |
| 4333 | 7112 |
| 9015 | 7113 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
| 7114 oscar_show_find_email); | |
| 7115 m = g_list_append(m, act); | |
| 4333 | 7116 |
| 8591 | 7117 #if 0 |
| 9015 | 7118 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
| 7119 show_find_info); | |
| 7120 m = g_list_append(m, act); | |
| 8591 | 7121 #endif |
| 2086 | 7122 |
| 7123 return m; | |
| 7124 } | |
| 7125 | |
| 5575 | 7126 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
| 2086 | 7127 { |
| 7283 | 7128 OscarData *od = gc->proto_data; |
| 4617 | 7129 |
| 7130 if (od->icq) { | |
| 7131 aim_icq_changepasswd(od->sess, new); | |
| 2086 | 7132 } else { |
| 4617 | 7133 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 7134 if (conn) { | |
| 7135 aim_admin_changepasswd(od->sess, conn, new, old); | |
| 7136 } else { | |
| 7137 od->chpass = TRUE; | |
| 7138 od->oldp = g_strdup(old); | |
| 7139 od->newp = g_strdup(new); | |
| 7140 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 7141 } | |
| 2086 | 7142 } |
| 7143 } | |
| 7144 | |
| 6059 | 7145 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7146 { |
| 7283 | 7147 OscarData *od = gc->proto_data; |
| 8971 | 7148 struct oscar_direct_im *dim = oscar_direct_im_find(od, who); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7149 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7150 if (!dim) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7151 return; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7152 |
| 8971 | 7153 oscar_direct_im_destroy(od, dim); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7154 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
7155 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7156 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7157 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7158 GAIM_PRPL_API_VERSION, |
| 9308 | 7159 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
| 9475 | 7160 NULL, /* user_splits */ |
| 7161 NULL, /* protocol_options */ | |
| 7162 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
| 7163 oscar_list_icon, /* list_icon */ | |
| 7164 oscar_list_emblems, /* list_emblems */ | |
| 7165 oscar_status_text, /* status_text */ | |
| 7166 oscar_tooltip_text, /* tooltip_text */ | |
| 7167 oscar_away_states, /* away_states */ | |
| 7168 oscar_blist_node_menu, /* blist_node_menu */ | |
| 7169 oscar_chat_info, /* chat_info */ | |
| 7170 oscar_login, /* login */ | |
| 7171 oscar_close, /* close */ | |
| 7172 oscar_send_im, /* send_im */ | |
| 7173 oscar_set_info, /* set_info */ | |
| 7174 oscar_send_typing, /* send_typing */ | |
| 7175 oscar_get_info, /* get_info */ | |
| 7176 oscar_set_away, /* set_away */ | |
| 7177 oscar_set_idle, /* set_idle */ | |
| 7178 oscar_change_passwd, /* change_passwd */ | |
| 7179 oscar_add_buddy, /* add_buddy */ | |
| 7180 oscar_add_buddies, /* add_buddies */ | |
| 7181 oscar_remove_buddy, /* remove_buddy */ | |
| 7182 oscar_remove_buddies, /* remove_buddies */ | |
| 7183 oscar_add_permit, /* add_permit */ | |
| 7184 oscar_add_deny, /* add_deny */ | |
| 7185 oscar_rem_permit, /* rem_permit */ | |
| 7186 oscar_rem_deny, /* rem_deny */ | |
| 7187 oscar_set_permit_deny, /* set_permit_deny */ | |
| 7188 oscar_warn, /* warn */ | |
| 7189 oscar_join_chat, /* join_chat */ | |
| 7190 NULL, /* reject_chat */ | |
| 7191 oscar_chat_invite, /* chat_invite */ | |
| 7192 oscar_chat_leave, /* chat_leave */ | |
| 7193 NULL, /* chat_whisper */ | |
| 7194 oscar_send_chat, /* chat_send */ | |
| 7195 oscar_keepalive, /* keepalive */ | |
| 7196 NULL, /* register_user */ | |
| 7197 NULL, /* get_cb_info */ | |
| 7198 NULL, /* get_cb_away */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7199 #ifndef NOSSI |
| 9475 | 7200 oscar_alias_buddy, /* alias_buddy */ |
| 7201 oscar_move_buddy, /* group_buddy */ | |
| 7202 oscar_rename_group, /* rename_group */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7203 #else |
| 9475 | 7204 NULL, /* alias_buddy */ |
| 7205 NULL, /* group_buddy */ | |
| 7206 NULL, /* rename_group */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7207 #endif |
| 9475 | 7208 NULL, /* buddy_free */ |
| 7209 oscar_convo_closed, /* convo_closed */ | |
| 7210 NULL, /* normalize */ | |
| 7211 oscar_set_icon, /* set_buddy_icon */ | |
| 7212 NULL, /* remove_group */ | |
| 7213 NULL, /* get_cb_real_name */ | |
| 7214 NULL, /* set_chat_topic */ | |
| 7215 NULL, /* find_blist_chat */ | |
| 7216 NULL, /* roomlist_get_list */ | |
| 7217 NULL, /* roomlist_cancel */ | |
| 7218 NULL, /* roomlist_expand_category */ | |
| 7219 oscar_can_receive_file, /* can_receive_file */ | |
| 7220 oscar_send_file /* send_file */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7221 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7222 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7223 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7224 { |
|
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
7225 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7226 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7227 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7228 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7229 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7230 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7231 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7232 "prpl-oscar", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7233 "AIM/ICQ", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7234 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7235 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7236 N_("AIM/ICQ Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7237 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7238 N_("AIM/ICQ Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7239 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
7240 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7241 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7242 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7243 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7244 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7245 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7246 NULL, /**< ui_info */ |
| 8993 | 7247 &prpl_info, /**< extra_info */ |
| 7248 NULL, | |
| 9015 | 7249 oscar_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7250 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7251 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7252 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7253 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7254 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7255 GaimAccountOption *option; |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7256 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7257 option = gaim_account_option_string_new(_("Auth host"), "server", |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7258 "login.oscar.aol.com"); |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7259 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7260 option); |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7261 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
7262 option = gaim_account_option_int_new(_("Auth port"), "port", 5190); |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7263 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
7264 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7265 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
7266 my_protocol = plugin; |
| 2086 | 7267 } |
| 7268 | |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
7269 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |
