Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 13253:87a7c3077c19
[gaim-migrate @ 15619]
More cleaning up of oscar. Renamed some functions to be more clear.
Got rid of some stuff that wasn't used. Inlined some small things
in conn.c that were only used once.
The goals of all this are
1. Non-blocking I/O for all connections
2. p2p stuff won't use the same struct as oscar connections, because
that's stupid
3. The oscar PRPL should be less scary
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 12 Feb 2006 21:27:04 +0000 |
| parents | 2871c385c45a |
| children | e9802db22b06 |
| 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 | |
| 11155 | 7 * Some code copyright (C) 2001-2005, Mark Doliner <thekingant@users.sourceforge.net> |
| 11049 | 8 * Some code copyright (C) 2005, Jonathan Clark <ardentlygnarly@users.sourceforge.net> |
| 6302 | 9 * |
| 10 * Most libfaim code copyright (C) 1998-2001 Adam Fritzler <afritz@auk.cx> | |
| 8151 | 11 * Some libfaim code copyright (C) 2001-2004 Mark Doliner <thekingant@users.sourceforge.net> |
| 2086 | 12 * |
| 13 * This program is free software; you can redistribute it and/or modify | |
| 14 * it under the terms of the GNU General Public License as published by | |
| 15 * the Free Software Foundation; either version 2 of the License, or | |
| 16 * (at your option) any later version. | |
| 17 * | |
| 18 * This program is distributed in the hope that it will be useful, | |
| 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10485 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2086 | 21 * GNU General Public License for more details. |
| 22 * | |
| 23 * You should have received a copy of the GNU General Public License | |
| 24 * along with this program; if not, write to the Free Software | |
| 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 26 * | |
| 27 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
28 #include "internal.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
29 |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
30 #include "account.h" |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
31 #include "accountopt.h" |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
32 #include "buddyicon.h" |
| 11404 | 33 #include "cipher.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
34 #include "conversation.h" |
|
7083
3100a6e03644
[gaim-migrate @ 7648]
Christian Hammond <chipx86@chipx86.com>
parents:
7082
diff
changeset
|
35 #include "core.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
36 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
37 #include "ft.h" |
| 6982 | 38 #include "imgstore.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" |
| 9943 | 46 #include "version.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
47 |
| 13234 | 48 #include "oscar.h" |
| 49 #include "peer.h" | |
| 2086 | 50 |
| 9976 | 51 #define OSCAR_STATUS_ID_INVISIBLE "invisible" |
| 52 #define OSCAR_STATUS_ID_OFFLINE "offline" | |
| 9991 | 53 #define OSCAR_STATUS_ID_AVAILABLE "available" |
| 9976 | 54 #define OSCAR_STATUS_ID_AWAY "away" |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
55 #define OSCAR_STATUS_ID_DND "dnd" |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
56 #define OSCAR_STATUS_ID_NA "na" |
| 9976 | 57 #define OSCAR_STATUS_ID_OCCUPIED "occupied" |
| 58 #define OSCAR_STATUS_ID_FREE4CHAT "free4chat" | |
| 59 #define OSCAR_STATUS_ID_CUSTOM "custom" | |
| 9975 | 60 |
| 2086 | 61 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
| 62 | |
| 7283 | 63 #define OSCAR_CONNECT_STEPS 6 |
| 11338 | 64 #define OSCAR_DEFAULT_LOGIN_SERVER "login.oscar.aol.com" |
| 65 #define OSCAR_DEFAULT_LOGIN_PORT 5190 | |
| 9830 | 66 #define OSCAR_DEFAULT_CUSTOM_ENCODING "ISO-8859-1" |
| 10570 | 67 #define OSCAR_DEFAULT_AUTHORIZATION TRUE |
| 68 #define OSCAR_DEFAULT_HIDE_IP TRUE | |
| 69 #define OSCAR_DEFAULT_WEB_AWARE FALSE | |
| 13071 | 70 #define OSCAR_DEFAULT_USE_RV_PROXY TRUE |
| 7283 | 71 |
| 11369 | 72 /* Milliseconds each file transfer ip address will be given to make a connection. */ |
| 73 #define FT_CLIENTIP_TIMEOUT 1000 /* 5000 */ | |
| 74 #define FT_VERIFIEDIP_TIMEOUT 5000 /* 15000 */ | |
| 75 #define FT_REDIR_TIMEOUT 10000 /* 20000 */ /* Time to wait for redirected transfer */ | |
| 76 #define FT_PROXYIP_TIMEOUT 300000 /* 120000 */ /* Time to create a checksum for VERY large files */ | |
| 11084 | 77 |
| 7376 | 78 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; |
| 79 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_DIRECTIM | AIM_CAPS_SENDFILE | AIM_CAPS_ICQUTF8 | AIM_CAPS_INTEROPERATE | AIM_CAPS_ICHAT; | |
| 3458 | 80 |
| 13234 | 81 static guint8 features_aim[] = {0x01, 0x01, 0x01, 0x02}; |
| 82 static guint8 features_icq[] = {0x01, 0x06}; | |
| 83 static guint8 features_icq_offline[] = {0x01}; | |
| 84 static guint8 ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | |
| 2086 | 85 |
| 7283 | 86 typedef struct _OscarData OscarData; |
| 87 struct _OscarData { | |
| 13239 | 88 OscarSession *sess; |
| 89 OscarConnection *conn; | |
| 2086 | 90 |
| 91 guint cnpa; | |
| 92 guint paspa; | |
| 3694 | 93 guint emlpa; |
| 4804 | 94 guint icopa; |
| 2086 | 95 |
| 4823 | 96 gboolean iconconnecting; |
| 5842 | 97 gboolean set_icon; |
| 4823 | 98 |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
99 GSList *create_rooms; |
| 2086 | 100 |
| 101 gboolean conf; | |
| 102 gboolean reqemail; | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
103 gboolean setemail; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
104 char *email; |
| 2979 | 105 gboolean setnick; |
| 106 char *newsn; | |
| 2086 | 107 gboolean chpass; |
| 108 char *oldp; | |
| 109 char *newp; | |
| 11651 | 110 |
| 2086 | 111 GSList *oscar_chats; |
| 112 GSList *direct_ims; | |
| 3630 | 113 GSList *file_transfers; |
| 4738 | 114 GHashTable *buddyinfo; |
| 4804 | 115 GSList *requesticon; |
| 2086 | 116 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
117 gboolean killme; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
118 gboolean icq; |
| 4804 | 119 guint icontimer; |
| 5968 | 120 guint getblisttimer; |
| 8341 | 121 guint getinfotimer; |
| 10567 | 122 gint timeoffset; |
| 2993 | 123 |
| 124 struct { | |
| 4230 | 125 guint maxwatchers; /* max users who can watch you */ |
| 2993 | 126 guint maxbuddies; /* max users you can watch */ |
| 4230 | 127 guint maxgroups; /* max groups in server list */ |
| 2993 | 128 guint maxpermits; /* max users on permit list */ |
| 129 guint maxdenies; /* max users on deny list */ | |
| 130 guint maxsiglen; /* max size (bytes) of profile */ | |
| 131 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
| 132 } rights; | |
| 2086 | 133 }; |
| 134 | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
135 struct create_room { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
136 char *name; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
137 int exchange; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
138 }; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
139 |
| 2086 | 140 struct chat_connection { |
| 141 char *name; | |
| 142 char *show; /* AOL did something funny to us */ | |
| 13234 | 143 guint16 exchange; |
| 144 guint16 instance; | |
| 13239 | 145 OscarConnection *conn; |
| 2086 | 146 int inpa; |
| 147 int id; | |
| 5575 | 148 GaimConnection *gc; /* i hate this. */ |
| 8733 | 149 GaimConversation *conv; /* bah. */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
150 int maxlen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
151 int maxvis; |
| 2086 | 152 }; |
| 153 | |
| 8971 | 154 struct oscar_direct_im { |
| 5575 | 155 GaimConnection *gc; |
| 2086 | 156 char name[80]; |
| 157 int watcher; | |
| 13239 | 158 OscarConnection *conn; |
| 3008 | 159 gboolean connected; |
| 8978 | 160 gboolean gpc_pend; |
| 161 gboolean killme; | |
| 8984 | 162 gboolean donttryagain; |
| 2086 | 163 }; |
| 164 | |
| 165 struct ask_direct { | |
| 5575 | 166 GaimConnection *gc; |
| 2086 | 167 char *sn; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
168 char ip[64]; |
| 13234 | 169 guint8 cookie[8]; |
| 8984 | 170 gboolean donttryagain; |
| 2086 | 171 }; |
| 172 | |
| 7011 | 173 /* |
| 174 * Various PRPL-specific buddy info that we want to keep track of | |
| 11651 | 175 * Some other info is maintained by locate.c, and I'd like to move |
| 7011 | 176 * the rest of this to libfaim, mostly im.c |
| 11651 | 177 * |
| 178 * TODO: I think all of this should use the status API. | |
| 7011 | 179 */ |
| 4738 | 180 struct buddyinfo { |
| 181 gboolean typingnot; | |
| 13234 | 182 guint32 ipaddr; |
| 5836 | 183 |
| 184 unsigned long ico_me_len; | |
| 185 unsigned long ico_me_csum; | |
| 186 time_t ico_me_time; | |
| 187 gboolean ico_informed; | |
| 4738 | 188 |
| 189 unsigned long ico_len; | |
| 190 unsigned long ico_csum; | |
| 191 time_t ico_time; | |
| 192 gboolean ico_need; | |
| 7406 | 193 gboolean ico_sent; |
| 2086 | 194 }; |
| 195 | |
| 4230 | 196 struct name_data { |
| 5575 | 197 GaimConnection *gc; |
| 4230 | 198 gchar *name; |
| 3453 | 199 gchar *nick; |
| 3141 | 200 }; |
| 201 | |
| 5129 | 202 static char *msgerrreason[] = { |
| 203 N_("Invalid error"), | |
| 204 N_("Invalid SNAC"), | |
| 205 N_("Rate to host"), | |
| 206 N_("Rate to client"), | |
| 207 N_("Not logged in"), | |
| 208 N_("Service unavailable"), | |
| 209 N_("Service not defined"), | |
| 210 N_("Obsolete SNAC"), | |
| 211 N_("Not supported by host"), | |
| 212 N_("Not supported by client"), | |
| 213 N_("Refused by client"), | |
| 214 N_("Reply too big"), | |
| 215 N_("Responses lost"), | |
| 216 N_("Request denied"), | |
| 217 N_("Busted SNAC payload"), | |
| 218 N_("Insufficient rights"), | |
| 219 N_("In local permit/deny"), | |
| 220 N_("Too evil (sender)"), | |
| 221 N_("Too evil (receiver)"), | |
| 222 N_("User temporarily unavailable"), | |
| 223 N_("No match"), | |
| 224 N_("List overflow"), | |
| 225 N_("Request ambiguous"), | |
| 226 N_("Queue full"), | |
| 227 N_("Not while on AOL") | |
| 228 }; | |
| 229 static int msgerrreasonlen = 25; | |
| 230 | |
| 231 /* All the libfaim->gaim callback functions */ | |
| 13239 | 232 static int gaim_parse_auth_resp (OscarSession *, FlapFrame *, ...); |
| 233 static int gaim_parse_login (OscarSession *, FlapFrame *, ...); | |
| 234 static int gaim_parse_auth_securid_request(OscarSession *, FlapFrame *, ...); | |
| 235 static int gaim_handle_redirect (OscarSession *, FlapFrame *, ...); | |
| 236 static int gaim_info_change (OscarSession *, FlapFrame *, ...); | |
| 237 static int gaim_account_confirm (OscarSession *, FlapFrame *, ...); | |
| 238 static int gaim_parse_oncoming (OscarSession *, FlapFrame *, ...); | |
| 239 static int gaim_parse_offgoing (OscarSession *, FlapFrame *, ...); | |
| 240 static int gaim_parse_incoming_im(OscarSession *, FlapFrame *, ...); | |
| 241 static int gaim_parse_misses (OscarSession *, FlapFrame *, ...); | |
| 242 static int gaim_parse_clientauto (OscarSession *, FlapFrame *, ...); | |
| 243 static int gaim_parse_userinfo (OscarSession *, FlapFrame *, ...); | |
| 244 static int gaim_reqinfo_timeout (OscarSession *, FlapFrame *, ...); | |
| 245 static int gaim_got_infoblock (OscarSession *sess, FlapFrame *fr, ...); | |
| 246 static int gaim_parse_motd (OscarSession *, FlapFrame *, ...); | |
| 247 static int gaim_chatnav_info (OscarSession *, FlapFrame *, ...); | |
| 248 static int gaim_conv_chat_join (OscarSession *, FlapFrame *, ...); | |
| 249 static int gaim_conv_chat_leave (OscarSession *, FlapFrame *, ...); | |
| 250 static int gaim_conv_chat_info_update (OscarSession *, FlapFrame *, ...); | |
| 251 static int gaim_conv_chat_incoming_msg(OscarSession *, FlapFrame *, ...); | |
| 252 static int gaim_email_parseupdate(OscarSession *, FlapFrame *, ...); | |
| 253 static int gaim_icon_error (OscarSession *, FlapFrame *, ...); | |
| 254 static int gaim_icon_parseicon (OscarSession *, FlapFrame *, ...); | |
| 255 static int oscar_icon_req (OscarSession *, FlapFrame *, ...); | |
| 256 static int gaim_parse_msgack (OscarSession *, FlapFrame *, ...); | |
| 257 static int gaim_parse_ratechange (OscarSession *, FlapFrame *, ...); | |
| 258 static int gaim_parse_evilnotify (OscarSession *, FlapFrame *, ...); | |
| 259 static int gaim_parse_searcherror(OscarSession *, FlapFrame *, ...); | |
| 260 static int gaim_parse_searchreply(OscarSession *, FlapFrame *, ...); | |
| 261 static int gaim_bosrights (OscarSession *, FlapFrame *, ...); | |
| 262 static int gaim_connerr (OscarSession *, FlapFrame *, ...); | |
| 263 static int conninitdone_admin (OscarSession *, FlapFrame *, ...); | |
| 264 static int conninitdone_bos (OscarSession *, FlapFrame *, ...); | |
| 265 static int conninitdone_chatnav (OscarSession *, FlapFrame *, ...); | |
| 266 static int conninitdone_chat (OscarSession *, FlapFrame *, ...); | |
| 267 static int conninitdone_email (OscarSession *, FlapFrame *, ...); | |
| 268 static int conninitdone_icon (OscarSession *, FlapFrame *, ...); | |
| 269 static int gaim_parse_msgerr (OscarSession *, FlapFrame *, ...); | |
| 270 static int gaim_parse_mtn (OscarSession *, FlapFrame *, ...); | |
| 271 static int gaim_parse_locaterights(OscarSession *, FlapFrame *, ...); | |
| 272 static int gaim_parse_buddyrights(OscarSession *, FlapFrame *, ...); | |
| 273 static int gaim_parse_locerr (OscarSession *, FlapFrame *, ...); | |
| 274 static int gaim_icbm_param_info (OscarSession *, FlapFrame *, ...); | |
| 275 static int gaim_parse_genericerr (OscarSession *, FlapFrame *, ...); | |
| 276 static int gaim_memrequest (OscarSession *, FlapFrame *, ...); | |
| 277 static int gaim_selfinfo (OscarSession *, FlapFrame *, ...); | |
| 278 static int gaim_offlinemsg (OscarSession *, FlapFrame *, ...); | |
| 279 static int gaim_offlinemsgdone (OscarSession *, FlapFrame *, ...); | |
| 280 static int gaim_icqalias (OscarSession *, FlapFrame *, ...); | |
| 281 static int gaim_icqinfo (OscarSession *, FlapFrame *, ...); | |
| 282 static int gaim_popup (OscarSession *, FlapFrame *, ...); | |
| 283 | |
| 284 static int gaim_ssi_parseerr (OscarSession *, FlapFrame *, ...); | |
| 285 static int gaim_ssi_parserights (OscarSession *, FlapFrame *, ...); | |
| 286 static int gaim_ssi_parselist (OscarSession *, FlapFrame *, ...); | |
| 287 static int gaim_ssi_parseack (OscarSession *, FlapFrame *, ...); | |
| 288 static int gaim_ssi_parseadd (OscarSession *, FlapFrame *, ...); | |
| 289 static int gaim_ssi_authgiven (OscarSession *, FlapFrame *, ...); | |
| 290 static int gaim_ssi_authrequest (OscarSession *, FlapFrame *, ...); | |
| 291 static int gaim_ssi_authreply (OscarSession *, FlapFrame *, ...); | |
| 292 static int gaim_ssi_gotadded (OscarSession *, FlapFrame *, ...); | |
| 5129 | 293 |
| 294 /* for DirectIM/image transfer */ | |
| 13239 | 295 static int gaim_odc_initiate (OscarSession *, FlapFrame *, ...); |
| 296 static int gaim_odc_incoming (OscarSession *, FlapFrame *, ...); | |
| 297 static int gaim_odc_typing (OscarSession *, FlapFrame *, ...); | |
| 298 static int gaim_odc_update_ui (OscarSession *, FlapFrame *, ...); | |
| 5129 | 299 |
| 300 /* for file transfer */ | |
| 13239 | 301 static int oscar_sendfile_estblsh(OscarSession *, FlapFrame *, ...); |
| 302 static int oscar_sendfile_prompt (OscarSession *, FlapFrame *, ...); | |
| 303 static int oscar_sendfile_ack (OscarSession *, FlapFrame *, ...); | |
| 304 static int oscar_sendfile_done (OscarSession *, FlapFrame *, ...); | |
| 5129 | 305 |
| 306 static gboolean gaim_icon_timerfunc(gpointer data); | |
| 8971 | 307 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
| 11369 | 308 static void oscar_xfer_init_recv(GaimXfer *xfer); |
| 309 static void oscar_xfer_init_send(GaimXfer *xfer); | |
| 310 | |
| 11159 | 311 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
| 12816 | 312 static void recent_buddies_cb(const char *name, GaimPrefType type, gconstpointer value, gpointer data); |
| 11347 | 313 static void oscar_set_info(GaimConnection *gc, const char *info); |
| 11965 | 314 static void oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, GaimStatus *status); |
| 12652 | 315 static void oscar_set_extendedstatus(GaimConnection *gc); |
| 12663 | 316 static gboolean gaim_ssi_rerequestdata(gpointer data); |
| 9935 | 317 |
| 5836 | 318 static void oscar_free_name_data(struct name_data *data) { |
| 4230 | 319 g_free(data->name); |
| 320 g_free(data->nick); | |
| 321 g_free(data); | |
| 322 } | |
| 323 | |
| 5836 | 324 static void oscar_free_buddyinfo(void *data) { |
| 325 struct buddyinfo *bi = data; | |
| 326 g_free(bi); | |
| 327 } | |
| 328 | |
| 13234 | 329 static guint32 oscar_charset_check(const char *utf8) |
| 5129 | 330 { |
| 331 int i = 0; | |
| 9826 | 332 int charset = AIM_CHARSET_ASCII; |
| 5129 | 333 |
| 13226 | 334 /* Determine how we can send this message. Per the warnings elsewhere |
| 335 * in this file, these little checks determine the simplest encoding | |
| 5129 | 336 * we can use for a given message send using it. */ |
| 337 while (utf8[i]) { | |
| 338 if ((unsigned char)utf8[i] > 0x7f) { | |
| 339 /* not ASCII! */ | |
| 9826 | 340 charset = AIM_CHARSET_CUSTOM; |
| 5129 | 341 break; |
| 342 } | |
| 343 i++; | |
| 344 } | |
| 345 while (utf8[i]) { | |
| 346 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
| 347 * followed by 0xc0-0xc3 in the second */ | |
| 348 if ((unsigned char)utf8[i] < 0x80) { | |
| 349 i++; | |
| 350 continue; | |
| 351 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
| 13226 | 352 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { |
| 5129 | 353 i += 2; |
| 354 continue; | |
| 355 } | |
| 9826 | 356 charset = AIM_CHARSET_UNICODE; |
| 5129 | 357 break; |
| 358 } | |
| 359 | |
| 9807 | 360 return charset; |
| 5129 | 361 } |
| 362 | |
| 8225 | 363 /* |
| 364 * Take a string of the form charset="bleh" where bleh is | |
| 13226 | 365 * one of us-ascii, utf-8, iso-8859-1, or unicode-2-0, and |
| 8225 | 366 * return a newly allocated string containing bleh. |
| 367 */ | |
| 368 static gchar *oscar_encoding_extract(const char *encoding) | |
| 5129 | 369 { |
| 8225 | 370 gchar *ret = NULL; |
| 371 char *begin, *end; | |
| 372 | |
| 9933 | 373 g_return_val_if_fail(encoding != NULL, NULL); |
| 374 | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
375 /* Make sure encoding begins with charset= */ |
| 10540 | 376 if (strncmp(encoding, "text/aolrtf; charset=", 21) && |
| 377 strncmp(encoding, "text/x-aolrtf; charset=", 23)) | |
| 378 { | |
| 8225 | 379 return NULL; |
| 10540 | 380 } |
| 8225 | 381 |
| 382 begin = strchr(encoding, '"'); | |
| 383 end = strrchr(encoding, '"'); | |
| 384 | |
| 385 if ((begin == NULL) || (end == NULL) || (begin >= end)) | |
| 386 return NULL; | |
| 387 | |
| 388 ret = g_strndup(begin+1, (end-1) - begin); | |
| 389 | |
| 390 return ret; | |
| 391 } | |
| 392 | |
| 9830 | 393 static gchar * |
| 394 oscar_encoding_to_utf8(const char *encoding, const char *text, int textlen) | |
| 5129 | 395 { |
| 396 gchar *utf8 = NULL; | |
| 9595 | 397 |
| 398 if ((encoding == NULL) || encoding[0] == '\0') { | |
| 399 gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n"); | |
| 10396 | 400 } else if (!strcasecmp(encoding, "iso-8859-1")) { |
| 10376 | 401 utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL); |
| 10396 | 402 } else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1")) { |
| 10375 | 403 utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL); |
| 10396 | 404 } else if (!strcasecmp(encoding, "unicode-2-0")) { |
| 9595 | 405 utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL); |
| 10396 | 406 } else if (strcasecmp(encoding, "us-ascii") && strcmp(encoding, "utf-8")) { |
| 9595 | 407 gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", " |
| 10096 | 408 "attempting to convert to UTF-8 anyway\n", encoding); |
| 9595 | 409 utf8 = g_convert(text, textlen, "UTF-8", encoding, NULL, NULL, NULL); |
| 410 } | |
| 411 | |
| 412 /* | |
| 413 * If utf8 is still NULL then either the encoding is us-ascii/utf-8 or | |
| 414 * we have been unable to convert the text to utf-8 from the encoding | |
| 415 * that was specified. So we check if the text is valid utf-8 then | |
| 416 * just copy it. | |
| 417 */ | |
| 418 if (utf8 == NULL) { | |
| 9638 | 419 if (textlen != 0 && *text != '\0' |
| 13226 | 420 && !g_utf8_validate(text, textlen, NULL)) |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
421 utf8 = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
| 9476 | 422 else |
| 9481 | 423 utf8 = g_strndup(text, textlen); |
| 5129 | 424 } |
| 425 | |
| 426 return utf8; | |
| 427 } | |
| 428 | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
429 static gchar *oscar_utf8_try_convert(GaimAccount *account, const gchar *msg) |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
430 { |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
431 const char *charset = NULL; |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
432 char *ret = NULL; |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
433 |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
434 if(aim_sn_is_icq(gaim_account_get_username(account))) |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
435 charset = gaim_account_get_string(account, "encoding", NULL); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
436 |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
437 if(charset && *charset) |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
438 ret = g_convert(msg, -1, "UTF-8", charset, NULL, NULL, NULL); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
439 |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
440 if(!ret) |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
441 ret = gaim_utf8_try_convert(msg); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
442 |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
443 return ret; |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
444 } |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
445 |
| 9830 | 446 static gchar * |
| 11159 | 447 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
| 9830 | 448 { |
| 449 gchar *ret = NULL; | |
| 450 GError *err = NULL; | |
| 451 | |
| 9908 | 452 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
| 453 return NULL; | |
| 454 | |
| 455 if (strcasecmp("UTF-8", charsetstr)) { | |
| 456 if (fallback) | |
| 457 ret = g_convert_with_fallback(data, datalen, "UTF-8", charsetstr, "?", NULL, NULL, &err); | |
| 458 else | |
| 459 ret = g_convert(data, datalen, "UTF-8", charsetstr, NULL, NULL, &err); | |
| 460 if (err != NULL) { | |
| 461 gaim_debug_warning("oscar", "Conversation from %s failed: %s.\n", | |
| 462 charsetstr, err->message); | |
| 463 g_error_free(err); | |
| 464 } | |
| 465 } else { | |
| 466 if (g_utf8_validate(data, datalen, NULL)) | |
| 467 ret = g_strndup(data, datalen); | |
| 468 else | |
| 469 gaim_debug_warning("oscar", "String is not valid UTF-8.\n"); | |
| 470 } | |
| 471 | |
| 472 return ret; | |
| 473 } | |
| 474 | |
| 475 /* | |
| 11081 | 476 * This attemps to decode an incoming IM into a UTF8 string. |
| 477 * | |
| 9908 | 478 * We try decoding using two different character sets. The charset |
| 479 * specified in the IM determines the order in which we attempt to | |
| 480 * decode. We do this because there are lots of broken ICQ clients | |
| 481 * that don't correctly send non-ASCII messages. And if Gaim isn't | |
| 482 * able to deal with that crap, then people complain like banshees. | |
| 483 * charsetstr1 is always set to what the correct encoding should be. | |
| 484 */ | |
| 485 static gchar * | |
| 13234 | 486 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, guint16 charset, guint16 charsubset, const gchar *data, gsize datalen) |
| 9908 | 487 { |
| 488 gchar *ret = NULL; | |
| 489 const gchar *charsetstr1, *charsetstr2; | |
| 490 | |
| 491 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | |
| 9830 | 492 |
| 493 if ((datalen == 0) || (data == NULL)) | |
| 494 return NULL; | |
| 495 | |
| 9908 | 496 if (charset == AIM_CHARSET_UNICODE) { |
| 497 charsetstr1 = "UCS-2BE"; | |
| 498 charsetstr2 = "UTF-8"; | |
| 499 } else if (charset == AIM_CHARSET_CUSTOM) { | |
| 11369 | 500 if ((sourcesn != NULL) && isdigit(sourcesn[0])) |
| 9908 | 501 charsetstr1 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
| 9830 | 502 else |
| 9908 | 503 charsetstr1 = "ISO-8859-1"; |
| 504 charsetstr2 = "UTF-8"; | |
| 505 } else if (charset == AIM_CHARSET_ASCII) { | |
| 506 /* Should just be "ASCII" */ | |
| 9914 | 507 charsetstr1 = "ASCII"; |
| 9908 | 508 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
| 509 } else if (charset == 0x000d) { | |
| 9830 | 510 /* Mobile AIM client on a Nokia 3100 and an LG VX6000 */ |
| 9908 | 511 charsetstr1 = "ISO-8859-1"; |
| 512 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
| 513 } else { | |
| 9830 | 514 /* Unknown, hope for valid UTF-8... */ |
| 9908 | 515 charsetstr1 = "UTF-8"; |
| 516 charsetstr2 = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
| 517 } | |
| 518 | |
| 519 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE); | |
| 520 if (ret == NULL) | |
| 521 ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE); | |
| 522 if (ret == NULL) | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
523 ret = g_strdup(_("(There was an error receiving this message. The buddy you are speaking to most likely has a buggy client.)")); |
| 9830 | 524 |
| 525 return ret; | |
| 526 } | |
| 527 | |
| 11081 | 528 /* |
| 529 * Figure out what encoding to use when sending a given outgoing message. | |
| 530 */ | |
| 9830 | 531 static void |
| 13226 | 532 gaim_plugin_oscar_convert_to_best_encoding(GaimConnection *gc, |
| 533 const char *destsn, const gchar *from, | |
| 534 gchar **msg, int *msglen_int, | |
| 13234 | 535 guint16 *charset, guint16 *charsubset) |
| 9830 | 536 { |
| 537 OscarData *od = gc->proto_data; | |
| 538 GaimAccount *account = gaim_connection_get_account(gc); | |
| 539 GError *err = NULL; | |
| 540 aim_userinfo_t *userinfo = NULL; | |
| 541 const gchar *charsetstr; | |
| 10039 | 542 gsize msglen; |
| 9830 | 543 |
| 544 /* Attempt to send as ASCII */ | |
| 10098 | 545 if (oscar_charset_check(from) == AIM_CHARSET_ASCII) { |
| 10097 | 546 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
| 10098 | 547 *charset = AIM_CHARSET_ASCII; |
| 9830 | 548 *charsubset = 0x0000; |
| 10039 | 549 *msglen_int = msglen; |
| 9830 | 550 return; |
| 551 } | |
| 552 | |
| 553 /* | |
| 10565 | 554 * If we're sending to an ICQ user, and they are in our |
| 555 * buddy list, and they are advertising the Unicode | |
| 556 * capability, and they are online, then attempt to send | |
| 557 * as UCS-2BE. | |
| 9830 | 558 */ |
| 9975 | 559 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
| 9830 | 560 userinfo = aim_locate_finduserinfo(od->sess, destsn); |
| 561 | |
| 10565 | 562 if ((userinfo != NULL) && (userinfo->capabilities & AIM_CAPS_ICQUTF8)) |
| 563 { | |
| 564 GaimBuddy *b; | |
| 565 b = gaim_find_buddy(account, destsn); | |
| 566 if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b))) | |
| 567 { | |
| 568 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | |
| 569 if (*msg != NULL) | |
| 570 { | |
| 571 *charset = AIM_CHARSET_UNICODE; | |
| 572 *charsubset = 0x0000; | |
| 573 *msglen_int = msglen; | |
| 574 return; | |
| 575 } | |
| 9830 | 576 } |
| 577 } | |
| 578 | |
| 579 /* | |
| 580 * If this is AIM then attempt to send as ISO-8859-1. If this is | |
| 581 * ICQ then attempt to send as the user specified character encoding. | |
| 582 */ | |
| 583 charsetstr = "ISO-8859-1"; | |
| 9975 | 584 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
| 9830 | 585 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
| 586 | |
| 10097 | 587 /* |
| 588 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
| 589 * can be converted to "charsetstr" | |
| 590 */ | |
| 10039 | 591 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
| 9830 | 592 if (*msg != NULL) { |
| 593 *charset = AIM_CHARSET_CUSTOM; | |
| 594 *charsubset = 0x0000; | |
| 10039 | 595 *msglen_int = msglen; |
| 9830 | 596 return; |
| 597 } | |
| 598 | |
| 599 /* | |
| 600 * Nothing else worked, so send as UCS-2BE. | |
| 601 */ | |
| 10039 | 602 *msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err); |
| 9830 | 603 if (*msg != NULL) { |
| 604 *charset = AIM_CHARSET_UNICODE; | |
| 605 *charsubset = 0x0000; | |
| 10039 | 606 *msglen_int = msglen; |
| 9830 | 607 return; |
| 608 } | |
| 609 | |
| 9908 | 610 gaim_debug_error("oscar", "Error converting a Unicode message: %s\n", err->message); |
| 9830 | 611 g_error_free(err); |
| 612 | |
| 613 gaim_debug_error("oscar", "This should NEVER happen! Sending UTF-8 text flagged as ASCII.\n"); | |
| 614 *msg = g_strdup(from); | |
| 10039 | 615 *msglen_int = strlen(*msg); |
| 9830 | 616 *charset = AIM_CHARSET_ASCII; |
| 617 *charsubset = 0x0000; | |
| 618 return; | |
| 619 } | |
| 620 | |
|
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
621 static gchar *oscar_caps_to_string(guint caps) |
| 8701 | 622 { |
| 9407 | 623 GString *str; |
|
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
624 const gchar *tmp; |
| 8701 | 625 guint bit = 1; |
| 626 | |
| 9407 | 627 str = g_string_new(""); |
| 628 | |
| 8701 | 629 if (!caps) { |
| 630 return NULL; | |
| 631 } else while (bit <= AIM_CAPS_LAST) { | |
| 632 if (bit & caps) { | |
| 633 switch (bit) { | |
| 634 case AIM_CAPS_BUDDYICON: | |
| 635 tmp = _("Buddy Icon"); | |
| 636 break; | |
| 637 case AIM_CAPS_TALK: | |
| 638 tmp = _("Voice"); | |
| 639 break; | |
| 640 case AIM_CAPS_DIRECTIM: | |
| 641 tmp = _("AIM Direct IM"); | |
| 642 break; | |
| 643 case AIM_CAPS_CHAT: | |
| 644 tmp = _("Chat"); | |
| 645 break; | |
| 646 case AIM_CAPS_GETFILE: | |
| 647 tmp = _("Get File"); | |
| 648 break; | |
| 649 case AIM_CAPS_SENDFILE: | |
| 650 tmp = _("Send File"); | |
| 651 break; | |
| 652 case AIM_CAPS_GAMES: | |
| 653 case AIM_CAPS_GAMES2: | |
| 654 tmp = _("Games"); | |
| 655 break; | |
| 656 case AIM_CAPS_ADDINS: | |
| 657 tmp = _("Add-Ins"); | |
| 658 break; | |
| 659 case AIM_CAPS_SENDBUDDYLIST: | |
| 660 tmp = _("Send Buddy List"); | |
| 661 break; | |
| 662 case AIM_CAPS_ICQ_DIRECT: | |
| 663 tmp = _("ICQ Direct Connect"); | |
| 664 break; | |
| 665 case AIM_CAPS_APINFO: | |
| 666 tmp = _("AP User"); | |
| 667 break; | |
| 668 case AIM_CAPS_ICQRTF: | |
| 669 tmp = _("ICQ RTF"); | |
| 670 break; | |
| 671 case AIM_CAPS_EMPTY: | |
| 672 tmp = _("Nihilist"); | |
| 673 break; | |
| 674 case AIM_CAPS_ICQSERVERRELAY: | |
| 675 tmp = _("ICQ Server Relay"); | |
| 676 break; | |
| 677 case AIM_CAPS_ICQUTF8OLD: | |
| 678 tmp = _("Old ICQ UTF8"); | |
| 679 break; | |
| 680 case AIM_CAPS_TRILLIANCRYPT: | |
| 681 tmp = _("Trillian Encryption"); | |
| 682 break; | |
| 683 case AIM_CAPS_ICQUTF8: | |
| 684 tmp = _("ICQ UTF8"); | |
| 685 break; | |
| 686 case AIM_CAPS_HIPTOP: | |
| 687 tmp = _("Hiptop"); | |
| 688 break; | |
| 689 case AIM_CAPS_SECUREIM: | |
| 690 tmp = _("Security Enabled"); | |
| 691 break; | |
| 692 case AIM_CAPS_VIDEO: | |
| 693 tmp = _("Video Chat"); | |
| 694 break; | |
| 695 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
| 696 case AIM_CAPS_ICHATAV: | |
| 697 tmp = _("iChat AV"); | |
| 698 break; | |
| 699 case AIM_CAPS_LIVEVIDEO: | |
| 700 tmp = _("Live Video"); | |
| 701 break; | |
| 702 case AIM_CAPS_CAMERA: | |
| 703 tmp = _("Camera"); | |
| 704 break; | |
| 705 default: | |
| 706 tmp = NULL; | |
| 707 break; | |
| 708 } | |
| 709 if (tmp) | |
| 9532 | 710 g_string_append_printf(str, "%s%s", (*(str->str) == '\0' ? "" : ", "), tmp); |
| 8701 | 711 } |
| 712 bit <<= 1; | |
| 713 } | |
| 9407 | 714 |
| 715 return g_string_free(str, FALSE); | |
| 8701 | 716 } |
| 717 | |
| 718 static char *oscar_icqstatus(int state) { | |
| 719 /* Make a cute little string that shows the status of the dude or dudet */ | |
| 720 if (state & AIM_ICQ_STATE_CHAT) | |
| 721 return g_strdup_printf(_("Free For Chat")); | |
| 722 else if (state & AIM_ICQ_STATE_DND) | |
| 723 return g_strdup_printf(_("Do Not Disturb")); | |
| 724 else if (state & AIM_ICQ_STATE_OUT) | |
| 725 return g_strdup_printf(_("Not Available")); | |
| 726 else if (state & AIM_ICQ_STATE_BUSY) | |
| 727 return g_strdup_printf(_("Occupied")); | |
| 728 else if (state & AIM_ICQ_STATE_AWAY) | |
| 729 return g_strdup_printf(_("Away")); | |
| 730 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
| 731 return g_strdup_printf(_("Web Aware")); | |
| 732 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
| 733 return g_strdup_printf(_("Invisible")); | |
| 734 else | |
| 735 return g_strdup_printf(_("Online")); | |
| 736 } | |
| 737 | |
| 9973 | 738 static void |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
739 oscar_string_append(GaimAccount *account, GString *str, const char *newline, |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
740 const char *name, const char *value) |
| 8700 | 741 { |
| 742 gchar *utf8; | |
| 743 | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
744 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) { |
| 8701 | 745 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
| 8700 | 746 g_free(utf8); |
| 747 } | |
| 748 } | |
| 749 | |
| 9973 | 750 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) |
| 8701 | 751 { |
| 10042 | 752 OscarData *od; |
| 753 GaimAccount *account; | |
|
10517
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
754 GaimPresence *presence = NULL; |
|
461334f300d7
[gaim-migrate @ 11821]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
755 GaimStatus *status = NULL; |
| 8701 | 756 GaimGroup *g = NULL; |
| 757 struct buddyinfo *bi = NULL; | |
| 758 char *tmp; | |
| 759 | |
| 10042 | 760 od = gc->proto_data; |
| 761 account = gaim_connection_get_account(gc); | |
| 762 | |
| 763 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
| 8701 | 764 return; |
| 765 | |
| 766 if (userinfo == NULL) | |
| 767 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
| 768 | |
| 769 if (b == NULL) | |
| 10042 | 770 b = gaim_find_buddy(account, userinfo->sn); |
| 8701 | 771 |
| 11369 | 772 if (b != NULL) { |
| 12088 | 773 g = gaim_buddy_get_group(b); |
| 10498 | 774 presence = gaim_buddy_get_presence(b); |
| 775 status = gaim_presence_get_active_status(presence); | |
| 776 } | |
| 8701 | 777 |
| 778 if (userinfo != NULL) | |
| 779 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
| 780 | |
| 8733 | 781 if (b != NULL) { |
| 10498 | 782 if (gaim_presence_is_online(presence)) { |
| 9975 | 783 if (aim_sn_is_icq(b->name)) { |
| 11510 | 784 GaimStatus *status = gaim_presence_get_active_status(presence); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
785 oscar_string_append(gc->account, str, newline, _("Status"), |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
786 gaim_status_get_name(status)); |
| 8733 | 787 } |
| 788 } else { | |
| 9625 | 789 tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
| 8733 | 790 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
791 oscar_string_append(gc->account, str, newline, _("Status"), |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
792 _("Not Authorized")); |
| 8733 | 793 else |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
794 oscar_string_append(gc->account, str, newline, _("Status"), |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
795 _("Offline")); |
| 8701 | 796 } |
| 8733 | 797 } |
| 8701 | 798 |
| 799 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
| 9625 | 800 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
| 8701 | 801 (bi->ipaddr & 0xff000000) >> 24, |
| 802 (bi->ipaddr & 0x00ff0000) >> 16, | |
| 803 (bi->ipaddr & 0x0000ff00) >> 8, | |
| 804 (bi->ipaddr & 0x000000ff)); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
805 oscar_string_append(gc->account, str, newline, _("IP Address"), tmp); |
| 8701 | 806 g_free(tmp); |
| 807 } | |
| 808 | |
| 11257 | 809 |
| 810 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { | |
| 11285 | 811 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
812 oscar_string_append(gc->account, str, newline, _("Warning Level"), tmp); |
| 11257 | 813 g_free(tmp); |
| 814 } | |
| 815 | |
| 8701 | 816 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { |
| 817 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
| 818 if (tmp != NULL) { | |
| 9625 | 819 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); |
| 8701 | 820 g_free(tmp); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
821 oscar_string_append(gc->account, str, newline, _("Buddy Comment"), tmp2); |
| 9625 | 822 g_free(tmp2); |
| 8701 | 823 } |
| 824 } | |
| 825 } | |
| 826 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
827 static char *extract_name(const char *name) { |
| 4121 | 828 char *tmp, *x; |
| 2086 | 829 int i, j; |
| 4120 | 830 |
| 831 if (!name) | |
| 4121 | 832 return NULL; |
| 11369 | 833 |
| 4120 | 834 x = strchr(name, '-'); |
| 4121 | 835 |
| 2086 | 836 if (!x) return NULL; |
| 837 x = strchr(++x, '-'); | |
| 838 if (!x) return NULL; | |
| 839 tmp = g_strdup(++x); | |
| 840 | |
| 841 for (i = 0, j = 0; x[i]; i++) { | |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
842 char hex[3]; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
843 if (x[i] != '%') { |
| 2086 | 844 tmp[j++] = x[i]; |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
845 continue; |
| 2086 | 846 } |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
847 strncpy(hex, x + ++i, 2); hex[2] = 0; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
848 i++; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
849 tmp[j++] = strtol(hex, NULL, 16); |
| 2086 | 850 } |
| 851 | |
| 852 tmp[j] = 0; | |
| 853 return tmp; | |
| 854 } | |
| 855 | |
| 10458 | 856 static struct chat_connection * |
| 857 find_oscar_chat(GaimConnection *gc, int id) | |
| 858 { | |
| 859 OscarData *od = (OscarData *)gc->proto_data; | |
| 860 GSList *cur; | |
| 861 struct chat_connection *cc; | |
| 862 | |
| 863 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
| 864 { | |
| 865 cc = (struct chat_connection *)cur->data; | |
| 866 if (cc->id == id) | |
| 867 return cc; | |
| 868 } | |
| 869 | |
| 870 return NULL; | |
| 871 } | |
| 872 | |
| 873 static struct chat_connection * | |
| 13239 | 874 find_oscar_chat_by_conn(GaimConnection *gc, OscarConnection *conn) |
| 10458 | 875 { |
| 876 OscarData *od = (OscarData *)gc->proto_data; | |
| 877 GSList *cur; | |
| 878 struct chat_connection *cc; | |
| 879 | |
| 880 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
| 881 { | |
| 882 cc = (struct chat_connection *)cur->data; | |
| 883 if (cc->conn == conn) | |
| 884 return cc; | |
| 885 } | |
| 886 | |
| 887 return NULL; | |
| 888 } | |
| 889 | |
| 890 static struct chat_connection * | |
| 891 find_oscar_chat_by_conv(GaimConnection *gc, GaimConversation *conv) | |
| 892 { | |
| 893 OscarData *od = (OscarData *)gc->proto_data; | |
| 894 GSList *cur; | |
| 895 struct chat_connection *cc; | |
| 896 | |
| 897 for (cur = od->oscar_chats; cur != NULL; cur = cur->next) | |
| 898 { | |
| 899 cc = (struct chat_connection *)cur->data; | |
| 900 if (cc->conv == conv) | |
| 901 return cc; | |
| 902 } | |
| 903 | |
| 904 return NULL; | |
| 905 } | |
| 906 | |
| 907 static void | |
| 908 oscar_chat_kill(GaimConnection *gc, struct chat_connection *cc) | |
| 909 { | |
| 910 OscarData *od = (OscarData *)gc->proto_data; | |
| 911 | |
| 912 /* Notify the conversation window that we've left the chat */ | |
| 913 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(cc->conv))); | |
| 914 | |
| 915 /* Destroy the chat_connection */ | |
| 916 od->oscar_chats = g_slist_remove(od->oscar_chats, cc); | |
| 917 if (cc->inpa > 0) | |
| 918 gaim_input_remove(cc->inpa); | |
| 919 aim_conn_kill(od->sess, &cc->conn); | |
| 920 g_free(cc->name); | |
| 921 g_free(cc->show); | |
| 922 g_free(cc); | |
| 8219 | 923 } |
| 924 | |
| 8971 | 925 /***************************************************************************** |
| 926 * Begin scary direct im stuff | |
| 927 *****************************************************************************/ | |
| 928 | |
| 929 static struct oscar_direct_im *oscar_direct_im_find(OscarData *od, const char *who) { | |
| 930 GSList *d = od->direct_ims; | |
| 931 struct oscar_direct_im *m = NULL; | |
| 932 | |
| 933 while (d) { | |
| 934 m = (struct oscar_direct_im *)d->data; | |
| 935 if (!aim_sncmp(who, m->name)) | |
| 936 return m; | |
| 937 d = d->next; | |
| 938 } | |
| 939 | |
| 940 return NULL; | |
| 941 } | |
| 942 | |
| 943 static void oscar_direct_im_destroy(OscarData *od, struct oscar_direct_im *dim) | |
| 944 { | |
| 945 gaim_debug_info("oscar", | |
| 13226 | 946 "destroying Direct IM for %s.\n", dim->name); |
| 8971 | 947 |
| 948 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
| 8978 | 949 if (dim->gpc_pend) { |
| 950 dim->killme = TRUE; | |
| 951 return; | |
| 952 } | |
| 8971 | 953 if (dim->watcher) |
| 954 gaim_input_remove(dim->watcher); | |
| 955 if (dim->conn) { | |
| 10271 | 956 aim_conn_close(dim->conn); |
| 8971 | 957 aim_conn_kill(od->sess, &dim->conn); |
| 958 } | |
| 959 g_free(dim); | |
| 960 } | |
| 961 | |
| 962 /* the only difference between this and destroy is this writes a conv message */ | |
| 963 static void oscar_direct_im_disconnect(OscarData *od, struct oscar_direct_im *dim) | |
| 964 { | |
| 965 GaimConversation *conv; | |
| 966 char buf[256]; | |
| 967 | |
| 968 gaim_debug_info("oscar", | |
| 13226 | 969 "%s disconnected Direct IM.\n", dim->name); |
| 8971 | 970 |
| 971 if (dim->connected) | |
| 972 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), dim->name); | |
| 8978 | 973 else |
| 8971 | 974 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), dim->name); |
| 975 | |
| 11338 | 976 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, dim->name, |
| 11369 | 977 gaim_connection_get_account(dim->gc)); |
| 13226 | 978 |
| 8971 | 979 if (conv) { |
| 980 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 981 } else { | |
| 982 gaim_notify_error(dim->gc, NULL, _("Direct Connect failed"), buf); | |
| 983 } | |
| 984 | |
| 985 oscar_direct_im_destroy(od, dim); | |
| 986 | |
| 987 return; | |
| 988 } | |
| 989 | |
| 990 /* oops i made two of these. this one just calls the other one. */ | |
| 13239 | 991 static void gaim_odc_disconnect(OscarSession *sess, OscarConnection *conn) |
| 8971 | 992 { |
| 993 GaimConnection *gc = sess->aux_data; | |
| 994 OscarData *od = (OscarData *)gc->proto_data; | |
| 995 struct oscar_direct_im *dim; | |
| 996 char *sn; | |
| 997 | |
| 998 sn = g_strdup(aim_odc_getsn(conn)); | |
| 999 dim = oscar_direct_im_find(od, sn); | |
| 1000 oscar_direct_im_disconnect(od, dim); | |
| 1001 g_free(sn); | |
| 1002 } | |
| 1003 | |
| 1004 static void destroy_direct_im_request(struct ask_direct *d) { | |
| 1005 gaim_debug_info("oscar", "Freeing DirectIM prompts.\n"); | |
| 1006 | |
| 1007 g_free(d->sn); | |
| 1008 g_free(d); | |
| 1009 } | |
| 1010 | |
| 1011 /* this is just a gaim_proxy_connect cb that sets up the rest of the cbs */ | |
| 1012 static void oscar_odc_callback(gpointer data, gint source, GaimInputCondition condition) { | |
| 1013 struct oscar_direct_im *dim = data; | |
| 1014 GaimConnection *gc = dim->gc; | |
| 1015 OscarData *od = gc->proto_data; | |
| 1016 GaimConversation *conv; | |
| 1017 char buf[256]; | |
| 1018 struct sockaddr name; | |
| 1019 socklen_t name_len = 1; | |
| 1020 | |
| 1021 g_return_if_fail(gc != NULL); | |
| 1022 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1023 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1024 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1025 |
| 8978 | 1026 dim->gpc_pend = FALSE; |
| 1027 if (dim->killme) { | |
| 1028 oscar_direct_im_destroy(od, dim); | |
| 1029 return; | |
| 1030 } | |
| 1031 | |
| 8971 | 1032 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 1033 oscar_direct_im_destroy(od, dim); | |
| 1034 return; | |
| 1035 } | |
| 1036 | |
| 1037 if (source < 0) { | |
| 8984 | 1038 if (dim->donttryagain) { |
| 1039 oscar_direct_im_disconnect(od, dim); | |
| 1040 return; | |
| 1041 } else { | |
| 11159 | 1042 guchar cookie[8]; |
| 8984 | 1043 char *who = g_strdup(dim->name); |
| 11159 | 1044 const guchar *tmp = aim_odc_getcookie(dim->conn); |
| 8984 | 1045 |
| 1046 memcpy(cookie, tmp, 8); | |
| 1047 oscar_direct_im_destroy(od, dim); | |
| 1048 oscar_direct_im_initiate(gc, who, cookie); | |
| 1049 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
| 1050 g_free(who); | |
| 1051 return; | |
| 1052 } | |
| 8971 | 1053 } |
| 1054 | |
| 1055 dim->conn->fd = source; | |
| 1056 aim_conn_completeconnect(od->sess, dim->conn); | |
| 11338 | 1057 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
| 8971 | 1058 |
| 1059 /* This is the best way to see if we're connected or not */ | |
| 8983 | 1060 /* Is this really needed? */ |
| 8971 | 1061 if (getpeername(source, &name, &name_len) == 0) { |
| 1062 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
| 1063 dim->connected = TRUE; | |
| 1064 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 8983 | 1065 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); |
| 1066 } else { | |
| 8984 | 1067 if (dim->donttryagain) { |
| 1068 oscar_direct_im_disconnect(od, dim); | |
| 1069 return; | |
| 1070 } else { | |
| 11159 | 1071 guchar cookie[8]; |
| 8984 | 1072 char *who = g_strdup(dim->name); |
| 11159 | 1073 const guchar *tmp = aim_odc_getcookie(dim->conn); |
| 8984 | 1074 |
| 1075 memcpy(cookie, tmp, 8); | |
| 1076 oscar_direct_im_destroy(od, dim); | |
| 1077 oscar_direct_im_initiate(gc, who, cookie); | |
| 1078 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | |
| 1079 g_free(who); | |
| 1080 return; | |
| 1081 } | |
| 8983 | 1082 } |
| 1083 | |
| 1084 | |
| 8971 | 1085 } |
| 1086 | |
| 1087 static void accept_direct_im_request(struct ask_direct *d) { | |
| 1088 GaimConnection *gc = d->gc; | |
| 1089 OscarData *od; | |
| 1090 struct oscar_direct_im *dim; | |
| 1091 char *host; int port = 5190; | |
| 1092 int i, rc; | |
| 8982 | 1093 char *tmp; |
| 1094 GaimConversation *conv; | |
| 8971 | 1095 |
| 1096 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 1097 destroy_direct_im_request(d); | |
| 1098 return; | |
| 1099 } | |
| 1100 | |
| 1101 od = (OscarData *)gc->proto_data; | |
| 1102 gaim_debug_info("oscar", "Accepted DirectIM.\n"); | |
| 1103 | |
| 1104 dim = oscar_direct_im_find(od, d->sn); | |
| 1105 if (dim && dim->connected) { | |
| 1106 destroy_direct_im_request(d); /* 40 */ /* what does that 40 mean? */ | |
| 1107 gaim_debug_info("oscar", "Wait, we're already connected, ignoring DirectIM.\n"); | |
| 1108 return; | |
| 1109 } | |
| 1110 dim = g_new0(struct oscar_direct_im, 1); | |
| 1111 dim->gc = d->gc; | |
| 8984 | 1112 dim->donttryagain = d->donttryagain; |
| 8971 | 1113 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); |
| 1114 | |
| 1115 dim->conn = aim_odc_connect(od->sess, d->sn, NULL, d->cookie); | |
| 1116 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
| 1117 if (!dim->conn) { | |
| 1118 oscar_direct_im_disconnect(od, dim); | |
| 1119 destroy_direct_im_request(d); | |
| 1120 return; | |
| 1121 } | |
| 1122 | |
| 13226 | 1123 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
| 13239 | 1124 PEER_TYPE_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
| 13226 | 1125 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, |
| 13239 | 1126 PEER_TYPE_DIRECTIMTYPING, gaim_odc_typing, 0); |
| 13226 | 1127 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, |
| 1128 AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); | |
| 8971 | 1129 |
| 1130 gaim_debug_info("oscar", "ip is %s.\n", d->ip); | |
| 1131 for (i = 0; i < (int)strlen(d->ip); i++) { | |
| 1132 if (d->ip[i] == ':') { | |
| 1133 port = atoi(&(d->ip[i+1])); | |
| 1134 break; | |
| 1135 } | |
| 1136 } | |
| 1137 host = g_strndup(d->ip, i); | |
| 1138 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 8978 | 1139 dim->gpc_pend = TRUE; |
| 8971 | 1140 rc = gaim_proxy_connect(gc->account, host, port, oscar_odc_callback, dim); |
| 8982 | 1141 |
| 11338 | 1142 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, d->sn); |
| 13226 | 1143 tmp = g_strdup_printf(_("Attempting to connect to %s at %s:%hu for Direct IM."), |
| 1144 d->sn, host, port); | |
| 8982 | 1145 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 1146 g_free(tmp); | |
| 8983 | 1147 |
| 8971 | 1148 g_free(host); |
| 1149 if (rc < 0) { | |
| 8978 | 1150 dim->gpc_pend = FALSE; |
| 8971 | 1151 oscar_direct_im_disconnect(od, dim); |
| 1152 destroy_direct_im_request(d); | |
| 1153 return; | |
| 1154 } | |
| 1155 | |
| 1156 destroy_direct_im_request(d); | |
| 1157 | |
| 1158 return; | |
| 1159 } | |
| 1160 | |
| 1161 /* | |
| 1162 * We have just established a socket with the other dude, so set up some handlers. | |
| 1163 */ | |
| 13239 | 1164 static int gaim_odc_initiate(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 1165 GaimConnection *gc = sess->aux_data; |
| 7283 | 1166 OscarData *od = (OscarData *)gc->proto_data; |
| 8733 | 1167 GaimConversation *conv; |
| 8971 | 1168 struct oscar_direct_im *dim; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1169 char buf[256]; |
| 8971 | 1170 char *sn; |
| 1171 va_list ap; | |
| 13239 | 1172 OscarConnection *newconn, *listenerconn; |
| 8971 | 1173 |
| 1174 va_start(ap, fr); | |
| 13239 | 1175 newconn = va_arg(ap, OscarConnection *); |
| 1176 listenerconn = va_arg(ap, OscarConnection *); | |
| 8971 | 1177 va_end(ap); |
| 1178 | |
| 10271 | 1179 aim_conn_close(listenerconn); |
| 8971 | 1180 aim_conn_kill(sess, &listenerconn); |
| 1181 | |
| 1182 sn = g_strdup(aim_odc_getsn(newconn)); | |
| 1183 | |
| 13226 | 1184 gaim_debug_info("oscar", "DirectIM: initiate success to %s\n", sn); |
| 8971 | 1185 dim = oscar_direct_im_find(od, sn); |
| 1186 | |
| 11338 | 1187 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, sn); |
| 8971 | 1188 gaim_input_remove(dim->watcher); |
| 1189 dim->conn = newconn; | |
| 1190 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, oscar_callback, dim->conn); | |
| 1191 dim->connected = TRUE; | |
| 1192 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); | |
| 1193 g_free(sn); | |
| 1194 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | |
| 1195 | |
| 13239 | 1196 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIMINCOMING, gaim_odc_incoming, 0); |
| 1197 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIMTYPING, gaim_odc_typing, 0); | |
| 8971 | 1198 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, gaim_odc_update_ui, 0); |
| 1199 | |
| 1200 return 1; | |
| 1201 } | |
| 1202 | |
| 1203 /* | |
| 1204 * This is called when each chunk of an image is received. It can be used to | |
| 1205 * update a progress bar, or to eat lots of dry cat food. Wet cat food is | |
| 1206 * nasty, you sicko. | |
| 1207 */ | |
| 13239 | 1208 static int gaim_odc_update_ui(OscarSession *sess, FlapFrame *fr, ...) { |
| 8971 | 1209 va_list ap; |
| 1210 char *sn; | |
| 1211 double percent; | |
| 1212 GaimConnection *gc = sess->aux_data; | |
| 1213 OscarData *od = (OscarData *)gc->proto_data; | |
| 1214 struct oscar_direct_im *dim; | |
| 1215 | |
| 1216 va_start(ap, fr); | |
| 1217 sn = va_arg(ap, char *); | |
| 1218 percent = va_arg(ap, double); | |
| 1219 va_end(ap); | |
| 1220 | |
| 1221 if (!sn || !(dim = oscar_direct_im_find(od, sn))) | |
| 1222 return 1; | |
| 1223 if (dim->watcher) { | |
| 13226 | 1224 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ |
| 8971 | 1225 /* The callback will callback? I don't get how that would happen here. */ |
| 1226 dim->watcher = 0; | |
| 1227 } | |
| 1228 | |
| 1229 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, | |
| 13226 | 1230 oscar_callback, dim->conn); |
| 8971 | 1231 |
| 1232 return 1; | |
| 1233 } | |
| 1234 | |
| 1235 /* | |
| 1236 * This is called after a direct IM has been received in its entirety. This | |
| 1237 * function is passed a long chunk of data which contains the IM with any | |
| 1238 * data chunks (images) appended to it. | |
| 1239 * | |
| 1240 * This function rips out all the data chunks and creates an imgstore for | |
| 1241 * each one. In order to do this, it first goes through the IM and takes | |
| 1242 * out all the IMG tags. When doing so, it rewrites the original IMG tag | |
| 1243 * with one compatible with the imgstore Gaim core code. For each one, we | |
| 1244 * then read in chunks of data from the end of the message and actually | |
| 1245 * create the img store using the given data. | |
| 1246 * | |
| 1247 * For somewhat easy reference, here's a sample message | |
| 1248 * (without the whitespace and asterisks): | |
| 1249 * | |
| 1250 * <HTML><BODY BGCOLOR="#ffffff"> | |
| 1251 * <FONT LANG="0"> | |
| 1252 * This is a really stupid picture:<BR> | |
| 1253 * <IMG SRC="Sample.jpg" ID="1" WIDTH="283" HEIGHT="212" DATASIZE="9894"><BR> | |
| 1254 * Yeah it is<BR> | |
| 1255 * Here is another one:<BR> | |
| 1256 * <IMG SRC="Soap Bubbles.bmp" ID="2" WIDTH="256" HEIGHT="256" DATASIZE="65978"> | |
| 1257 * </FONT> | |
| 1258 * </BODY></HTML> | |
| 1259 * <BINARY> | |
| 1260 * <DATA ID="1" SIZE="9894">datadatadatadata</DATA> | |
| 1261 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | |
| 1262 * </BINARY> | |
| 1263 */ | |
| 13239 | 1264 static int gaim_odc_incoming(OscarSession *sess, FlapFrame *fr, ...) { |
| 8971 | 1265 GaimConnection *gc = sess->aux_data; |
| 12216 | 1266 GaimMessageFlags imflags = 0; |
| 8971 | 1267 gchar *utf8; |
| 1268 GString *newmsg = g_string_new(""); | |
| 1269 GSList *images = NULL; | |
| 1270 va_list ap; | |
| 1271 const char *sn, *msg, *msgend, *binary; | |
| 1272 size_t len; | |
| 1273 int encoding, isawaymsg; | |
| 1274 | |
| 1275 va_start(ap, fr); | |
| 1276 sn = va_arg(ap, const char *); | |
| 1277 msg = va_arg(ap, const char *); | |
| 1278 len = va_arg(ap, size_t); | |
| 1279 encoding = va_arg(ap, int); | |
| 1280 isawaymsg = va_arg(ap, int); | |
| 1281 va_end(ap); | |
| 1282 msgend = msg + len; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1283 |
| 13226 | 1284 gaim_debug_info("oscar", "Got DirectIM message from %s\n", sn); |
| 8971 | 1285 |
| 1286 if (isawaymsg) | |
| 12216 | 1287 imflags |= GAIM_MESSAGE_AUTO_RESP; |
| 8971 | 1288 |
| 1289 /* message has a binary trailer */ | |
| 1290 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | |
| 1291 GData *attribs; | |
| 1292 const char *tmp, *start, *end, *last = NULL; | |
| 1293 | |
| 1294 tmp = msg; | |
| 1295 | |
| 1296 /* for each valid image tag... */ | |
| 1297 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
| 1298 const char *id, *src, *datasize; | |
| 10504 | 1299 const char *data = NULL; |
| 1300 char *tag = NULL; | |
| 8971 | 1301 size_t size; |
| 1302 int imgid = 0; | |
| 1303 | |
| 1304 /* update the location of the last img tag */ | |
| 1305 last = end; | |
| 1306 | |
| 1307 /* grab attributes */ | |
| 1308 id = g_datalist_get_data(&attribs, "id"); | |
| 1309 src = g_datalist_get_data(&attribs, "src"); | |
| 1310 datasize = g_datalist_get_data(&attribs, "datasize"); | |
| 1311 | |
| 1312 /* if we have id & datasize, build the data tag */ | |
| 1313 if (id && datasize) | |
| 1314 tag = g_strdup_printf("<data id=\"%s\" size=\"%s\">", id, datasize); | |
| 1315 | |
| 1316 /* if we have a tag, find the start of the data */ | |
| 1317 if (tag && (data = gaim_strcasestr(binary, tag))) | |
| 1318 data += strlen(tag); | |
| 1319 | |
| 10504 | 1320 g_free(tag); |
| 1321 | |
| 8971 | 1322 /* check the data is here and store it */ |
| 1323 if (data + (size = atoi(datasize)) <= msgend) | |
| 1324 imgid = gaim_imgstore_add(data, size, src); | |
| 1325 | |
| 1326 /* | |
| 1327 * XXX - The code below contains some calls to oscar_encoding_to_utf8 | |
| 1328 * The hardcoded "us-ascii" value REALLY needs to be removed. | |
| 1329 */ | |
| 1330 /* if we have a stored image... */ | |
| 1331 if (imgid) { | |
| 1332 /* append the message up to the tag */ | |
| 1333 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, start - tmp); | |
| 1334 if (utf8 != NULL) { | |
| 1335 newmsg = g_string_append(newmsg, utf8); | |
| 1336 g_free(utf8); | |
| 1337 } | |
| 1338 | |
| 1339 /* write the new image tag */ | |
| 1340 g_string_append_printf(newmsg, "<IMG ID=\"%d\">", imgid); | |
| 1341 | |
| 1342 /* and record the image number */ | |
| 1343 images = g_slist_append(images, GINT_TO_POINTER(imgid)); | |
| 1344 } else { | |
| 1345 /* otherwise, copy up to the end of the tag */ | |
| 1346 utf8 = oscar_encoding_to_utf8("us-ascii", tmp, (end + 1) - tmp); | |
| 1347 if (utf8 != NULL) { | |
| 1348 newmsg = g_string_append(newmsg, utf8); | |
| 1349 g_free(utf8); | |
| 1350 } | |
| 1351 } | |
| 1352 | |
| 1353 /* clear the attribute list */ | |
| 1354 g_datalist_clear(&attribs); | |
| 1355 | |
| 1356 /* continue from the end of the tag */ | |
| 1357 tmp = end + 1; | |
| 1358 } | |
| 1359 | |
| 1360 /* append any remaining message data (without the > :-) */ | |
| 1361 if (last++ && (last < binary)) | |
| 1362 newmsg = g_string_append_len(newmsg, last, binary - last); | |
| 1363 | |
| 1364 /* set the flag if we caught any images */ | |
| 1365 if (images) | |
| 12216 | 1366 imflags |= GAIM_MESSAGE_IMAGES; |
| 8971 | 1367 } else { |
| 1368 g_string_append_len(newmsg, msg, len); | |
| 1369 } | |
| 1370 | |
| 10318 | 1371 /* Convert to UTF8 */ |
| 1372 /* (This hasn't been tested very much) */ | |
| 1373 utf8 = gaim_plugin_oscar_decode_im_part(gc->account, sn, encoding, 0x0000, newmsg->str, len); | |
| 1374 if (utf8 != NULL) { | |
| 1375 serv_got_im(gc, sn, utf8, imflags, time(NULL)); | |
| 1376 g_free(utf8); | |
| 1377 } | |
| 1378 | |
| 1379 /* free the message */ | |
| 8971 | 1380 g_string_free(newmsg, TRUE); |
| 1381 | |
| 1382 /* unref any images we allocated */ | |
| 1383 if (images) { | |
| 1384 GSList *tmp; | |
| 1385 int id; | |
| 1386 | |
| 1387 for (tmp = images; tmp != NULL; tmp = tmp->next) { | |
| 1388 id = GPOINTER_TO_INT(tmp->data); | |
| 1389 gaim_imgstore_unref(id); | |
| 1390 } | |
| 1391 | |
| 1392 g_slist_free(images); | |
| 1393 } | |
| 1394 | |
| 1395 return 1; | |
| 1396 } | |
| 1397 | |
| 13239 | 1398 static int gaim_odc_typing(OscarSession *sess, FlapFrame *fr, ...) { |
| 8971 | 1399 va_list ap; |
| 1400 char *sn; | |
| 1401 int typing; | |
| 1402 GaimConnection *gc = sess->aux_data; | |
| 1403 | |
| 1404 va_start(ap, fr); | |
| 1405 sn = va_arg(ap, char *); | |
| 1406 typing = va_arg(ap, int); | |
| 1407 va_end(ap); | |
| 1408 | |
| 1409 if (typing == 0x0002) { | |
| 1410 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
| 1411 gaim_debug_info("oscar", | |
| 1412 "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
| 1413 serv_got_typing(gc, sn, 0, GAIM_TYPING); | |
| 1414 } else if (typing == 0x0001) | |
| 1415 serv_got_typing(gc, sn, 0, GAIM_TYPED); | |
| 1416 else | |
| 1417 serv_got_typing_stopped(gc, sn); | |
| 1418 return 1; | |
| 1419 } | |
| 1420 | |
| 13239 | 1421 static int gaim_odc_send_im(OscarSession *sess, OscarConnection *conn, const char *message, GaimMessageFlags imflags) { |
| 8971 | 1422 char *buf; |
| 1423 size_t len; | |
| 1424 int ret; | |
| 1425 GString *msg = g_string_new("<HTML><BODY>"); | |
| 1426 GString *data = g_string_new("</BODY></HTML><BINARY>"); | |
| 1427 GData *attribs; | |
| 1428 const char *start, *end, *last; | |
| 1429 int oscar_id = 0; | |
| 1430 | |
| 1431 last = message; | |
| 1432 | |
| 1433 /* for each valid IMG tag... */ | |
| 1434 while (last && *last && gaim_markup_find_tag("img", last, &start, &end, &attribs)) { | |
| 1435 GaimStoredImage *image = NULL; | |
| 1436 const char *id; | |
| 1437 | |
| 1438 if (start - last) { | |
| 1439 g_string_append_len(msg, last, start - last); | |
| 1440 } | |
| 1441 | |
| 1442 id = g_datalist_get_data(&attribs, "id"); | |
| 1443 | |
| 1444 /* ... if it refers to a valid gaim image ... */ | |
| 1445 if (id && (image = gaim_imgstore_get(atoi(id)))) { | |
| 1446 /* ... append the message from start to the tag ... */ | |
| 9126 | 1447 unsigned long size = gaim_imgstore_get_size(image); |
| 8971 | 1448 const char *filename = gaim_imgstore_get_filename(image); |
| 1449 gpointer imgdata = gaim_imgstore_get_data(image); | |
| 1450 | |
| 1451 oscar_id++; | |
| 1452 | |
| 1453 /* ... insert a new img tag with the oscar id ... */ | |
| 1454 if (filename) | |
| 1455 g_string_append_printf(msg, | |
| 9126 | 1456 "<IMG SRC=\"%s\" ID=\"%d\" DATASIZE=\"%lu\">", |
| 8971 | 1457 filename, oscar_id, size); |
| 1458 else | |
| 1459 g_string_append_printf(msg, | |
| 9126 | 1460 "<IMG ID=\"%d\" DATASIZE=\"%lu\">", |
| 8971 | 1461 oscar_id, size); |
| 1462 | |
| 1463 /* ... and append the data to the binary section ... */ | |
| 9126 | 1464 g_string_append_printf(data, "<DATA ID=\"%d\" SIZE=\"%lu\">", |
| 8971 | 1465 oscar_id, size); |
| 1466 data = g_string_append_len(data, imgdata, size); | |
| 1467 data = g_string_append(data, "</DATA>"); | |
| 1468 } | |
| 1469 /* If the tag is invalid, skip it, thus no else here */ | |
| 1470 | |
| 1471 g_datalist_clear(&attribs); | |
| 1472 | |
| 1473 /* continue from the end of the tag */ | |
| 1474 last = end + 1; | |
| 1475 } | |
| 1476 | |
| 1477 /* append any remaining message data (without the > :-) */ | |
| 1478 if (last && *last) | |
| 1479 msg = g_string_append(msg, last); | |
| 1480 | |
| 1481 /* if we inserted any images in the binary section, append it */ | |
| 1482 if (oscar_id) { | |
| 1483 msg = g_string_append_len(msg, data->str, data->len); | |
| 1484 msg = g_string_append(msg, "</BINARY>"); | |
| 1485 } | |
| 1486 | |
| 1487 len = msg->len; | |
| 1488 buf = msg->str; | |
| 1489 g_string_free(msg, FALSE); | |
| 1490 g_string_free(data, TRUE); | |
| 1491 | |
| 1492 | |
| 1493 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | |
| 12216 | 1494 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
| 8971 | 1495 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
| 1496 else | |
| 1497 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | |
| 1498 | |
| 1499 g_free(buf); | |
| 1500 | |
| 1501 return ret; | |
| 1502 } | |
| 1503 | |
| 1504 struct ask_do_dir_im { | |
| 1505 char *who; | |
| 1506 GaimConnection *gc; | |
| 1507 }; | |
| 1508 | |
| 1509 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { | |
| 1510 g_free(data->who); | |
| 1511 g_free(data); | |
| 1512 } | |
| 1513 | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1514 struct dir_im_listen { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1515 struct oscar_direct_im *dim; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1516 const guchar *cookie; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1517 }; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1518 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1519 static void |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1520 oscar_direct_im_listen_cb(int listenfd, gpointer data) { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1521 struct dir_im_listen *dim_l = data; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1522 const char *ip; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1523 OscarData *od; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1524 struct oscar_direct_im *dim = dim_l->dim; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1525 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1526 od = (OscarData *)dim->gc->proto_data; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1527 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1528 /* XXX: shouldn't this be your public IP or something? */ |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1529 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1530 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1531 if (listenfd >= 0) |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1532 dim->conn = aim_odc_initiate(od->sess, dim->name, listenfd, |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1533 gaim_network_ip_atoi(ip), |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1534 gaim_network_get_port_from_fd(listenfd), dim_l->cookie); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1535 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1536 if (dim->conn != NULL) { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1537 char *tmp; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1538 GaimConversation *conv; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1539 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1540 od->direct_ims = g_slist_append(od->direct_ims, dim); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1541 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1542 oscar_callback, dim->conn); |
| 13239 | 1543 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, PEER_TYPE_DIRECTIM_ESTABLISHED, |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1544 gaim_odc_initiate, 0); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1545 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1546 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, dim->gc->account, dim->name); |
| 13226 | 1547 tmp = g_strdup_printf(_("Asking %s to connect to us at %s:%hu for Direct IM."), |
| 1548 dim->name, ip, gaim_network_get_port_from_fd(listenfd)); | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1549 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1550 g_free(tmp); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1551 } else { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1552 gaim_notify_error(dim->gc, NULL, _("Unable to open Direct IM"), NULL); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1553 oscar_direct_im_destroy(od, dim); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1554 } |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1555 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1556 g_free(dim_l); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1557 } |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1558 |
| 8983 | 1559 /* this function is used to initiate a direct im session with someone. |
| 1560 * we start listening on a port and send a request. they either connect | |
| 1561 * or send some kind of reply. If they can't connect, they ask us to | |
| 1562 * connect to them, and so we do that. | |
| 1563 * | |
| 1564 * this function will also get called if the other side initiate's a direct | |
| 1565 * im and we try to connect and fail. in that case cookie will not be null. | |
| 1566 * | |
| 1567 * note that cookie is an 8 byte string that isn't NULL terminated | |
| 1568 */ | |
| 11159 | 1569 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
| 8971 | 1570 OscarData *od; |
| 1571 struct oscar_direct_im *dim; | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1572 struct dir_im_listen *dim_l; |
| 8971 | 1573 |
| 1574 od = (OscarData *)gc->proto_data; | |
| 1575 | |
| 8983 | 1576 dim = oscar_direct_im_find(od, who); |
| 8971 | 1577 if (dim) { |
|
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1578 /* TODO: we need to somehow not do this if we're waiting |
|
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1579 for the gaim_network_listen_range() call to finish */ |
| 8971 | 1580 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
| 1581 oscar_direct_im_disconnect(od, dim); | |
| 1582 gaim_debug_info("oscar", | |
| 1583 "Gave up on old direct IM, trying again\n"); | |
| 1584 } else { | |
| 1585 gaim_notify_error(gc, NULL, "DirectIM already open.", NULL); | |
| 8980 | 1586 return; |
| 8971 | 1587 } |
| 1588 } | |
| 1589 dim = g_new0(struct oscar_direct_im, 1); | |
| 1590 dim->gc = gc; | |
| 8983 | 1591 g_snprintf(dim->name, sizeof dim->name, "%s", who); |
| 8971 | 1592 |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1593 dim_l = g_new0(struct dir_im_listen, 1); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1594 dim_l->dim = dim; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1595 dim_l->cookie = cookie; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1596 |
|
12918
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1597 if(!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
|
a05fbd9dcc31
[gaim-migrate @ 15271]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12909
diff
changeset
|
1598 oscar_direct_im_listen_cb, dim_l)) { |
| 8971 | 1599 gaim_notify_error(gc, NULL, _("Unable to open Direct IM"), NULL); |
| 1600 oscar_direct_im_destroy(od, dim); | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
1601 g_free(dim_l); |
| 8971 | 1602 } |
| 8983 | 1603 } |
| 1604 | |
| 1605 static void oscar_direct_im(struct ask_do_dir_im *data) { | |
| 1606 GaimConnection *gc = data->gc; | |
| 1607 | |
| 1608 if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 1609 g_free(data->who); | |
| 1610 g_free(data); | |
| 1611 return; | |
| 1612 } | |
| 1613 | |
| 1614 oscar_direct_im_initiate(gc, data->who, NULL); | |
| 8971 | 1615 g_free(data->who); |
| 1616 g_free(data); | |
| 1617 } | |
| 1618 | |
| 1619 /* this is the right click menu cb thingy */ | |
| 9030 | 1620 static void oscar_ask_direct_im(GaimBlistNode *node, gpointer ignored) { |
| 1621 | |
| 1622 GaimBuddy *buddy; | |
| 1623 GaimConnection *gc; | |
| 8971 | 1624 gchar *buf; |
| 9030 | 1625 struct ask_do_dir_im *data; |
| 1626 | |
| 1627 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 1628 | |
| 1629 buddy = (GaimBuddy *) node; | |
| 1630 gc = gaim_account_get_connection(buddy->account); | |
| 1631 | |
| 1632 data = g_new0(struct ask_do_dir_im, 1); | |
| 1633 data->who = g_strdup(buddy->name); | |
| 8971 | 1634 data->gc = gc; |
| 9030 | 1635 buf = g_strdup_printf(_("You have selected to open a Direct IM connection with %s."), |
| 1636 buddy->name); | |
| 8971 | 1637 |
| 1638 gaim_request_action(gc, NULL, buf, | |
| 9030 | 1639 _("Because this reveals your IP address, it " |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1640 "may be considered a privacy risk. Do you " |
| 9030 | 1641 "wish to continue?"), |
| 1642 0, data, 2, | |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1643 _("_Connect"), G_CALLBACK(oscar_direct_im), |
| 9030 | 1644 _("Cancel"), G_CALLBACK(oscar_cancel_direct_im)); |
| 8971 | 1645 g_free(buf); |
| 1646 } | |
| 1647 | |
| 1648 /***************************************************************************** | |
| 1649 * End scary direct im stuff | |
| 1650 *****************************************************************************/ | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1651 |
| 13231 | 1652 static void |
| 1653 oscar_callback(gpointer data, gint source, GaimInputCondition condition) | |
| 1654 { | |
| 13239 | 1655 OscarConnection *conn; |
| 1656 OscarSession *sess; | |
| 13231 | 1657 GaimConnection *gc; |
| 7283 | 1658 OscarData *od; |
| 11369 | 1659 |
| 13239 | 1660 conn = (OscarConnection *)data; |
| 13231 | 1661 sess = aim_conn_getsess(conn); |
| 1662 gc = sess ? sess->aux_data : NULL; | |
| 1663 | |
| 1664 if (gc == NULL) | |
| 1665 { | |
| 1666 gaim_debug_info("oscar", "oscar callback for closed connection (1).\n"); | |
| 2086 | 1667 return; |
| 1668 } | |
| 13226 | 1669 |
| 13231 | 1670 od = gc->proto_data; |
| 1671 if (od == NULL) | |
| 1672 { | |
| 11369 | 1673 gaim_debug_warning("oscar","NULL od in oscar_callback; conn closed?\n"); |
| 1674 return; | |
| 1675 } | |
| 2086 | 1676 |
| 13231 | 1677 if (!g_list_find(gaim_connections_get_all(), gc)) |
| 1678 { | |
| 13226 | 1679 /* oh boy. this is probably bad. i guess the only thing we |
| 2086 | 1680 * can really do is return? */ |
| 8660 | 1681 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
1682 "oscar callback for closed connection (2).\n"); |
| 8660 | 1683 gaim_debug_misc("oscar", "gc = %p\n", gc); |
| 2086 | 1684 return; |
| 1685 } | |
| 1686 | |
| 13231 | 1687 /* We only care about READ conditions */ |
| 1688 if (!(condition & GAIM_INPUT_READ)) | |
| 1689 return; | |
| 1690 | |
| 1691 if (conn->type == AIM_CONN_TYPE_LISTENER) { | |
| 1692 gaim_debug_info("oscar", | |
| 1693 "got information on rendezvous listener\n"); | |
| 1694 if (aim_handlerendconnect(od->sess, conn) < 0) { | |
| 1695 gaim_debug_error("oscar", | |
| 1696 "connection error (rendezvous listener)\n"); | |
| 1697 aim_conn_kill(od->sess, &conn); | |
| 1698 /* AAA - Don't we need to gaim_xfer_cancel here? --marv */ | |
| 1699 } | |
| 1700 } else { | |
| 1701 if (aim_get_command(od->sess, conn) >= 0) { | |
| 1702 aim_rxdispatch(od->sess); | |
| 1703 if (od->killme) { | |
| 1704 gaim_debug_error("oscar", "Waiting to be destroyed\n"); | |
| 1705 return; | |
| 2086 | 1706 } |
| 1707 } else { | |
| 13231 | 1708 if ((conn->type == AIM_CONN_TYPE_BOS) || |
| 1709 !(aim_getconn_type(od->sess, AIM_CONN_TYPE_BOS))) | |
| 1710 { | |
| 1711 gaim_debug_error("oscar", "Major connection error " | |
| 1712 "(invalid data was received on the oscar TCP stream).\n"); | |
| 1713 gaim_connection_error(gc, _("Disconnected.")); | |
| 1714 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
| 1715 struct chat_connection *cc = find_oscar_chat_by_conn(gc, conn); | |
| 1716 GaimConversation *conv = gaim_find_chat(gc, cc->id); | |
| 1717 char *buf; | |
| 1718 gaim_debug_info("oscar", "Lost connection " | |
| 1719 "to chat room %s\n", cc->name); | |
| 1720 | |
| 1721 buf = g_strdup_printf(_("You have lost your connection " | |
| 1722 "to chat room %s."), cc->name); | |
| 1723 if (conv != NULL) | |
| 1724 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
| 1725 else | |
| 1726 gaim_notify_error(gc, NULL, buf, NULL); | |
| 1727 g_free(buf); | |
| 1728 | |
| 1729 oscar_chat_kill(gc, cc); | |
| 1730 | |
| 1731 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
| 1732 if (od->cnpa > 0) | |
| 1733 gaim_input_remove(od->cnpa); | |
| 1734 od->cnpa = 0; | |
| 1735 gaim_debug_info("oscar", | |
| 1736 "removing chatnav input watcher\n"); | |
| 1737 while (od->create_rooms) { | |
| 1738 struct create_room *cr = od->create_rooms->data; | |
| 1739 g_free(cr->name); | |
| 1740 od->create_rooms = | |
| 1741 g_slist_remove(od->create_rooms, cr); | |
| 1742 g_free(cr); | |
| 1743 gaim_notify_error(gc, NULL, | |
| 1744 _("Chat is currently unavailable"), | |
| 1745 NULL); | |
| 6029 | 1746 } |
| 13231 | 1747 gaim_debug_info("oscar","killing rendezvous connection\n"); |
| 1748 aim_conn_kill(od->sess, &conn); | |
| 1749 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
| 1750 if (od->paspa > 0) | |
| 1751 gaim_input_remove(od->paspa); | |
| 1752 od->paspa = 0; | |
| 1753 gaim_debug_info("oscar", | |
| 1754 "removing authconn input watcher\n"); | |
| 1755 aim_conn_kill(od->sess, &conn); | |
| 1756 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { | |
| 1757 if (od->emlpa > 0) | |
| 1758 gaim_input_remove(od->emlpa); | |
| 1759 od->emlpa = 0; | |
| 1760 gaim_debug_info("oscar", | |
| 1761 "removing email input watcher\n"); | |
| 1762 aim_conn_kill(od->sess, &conn); | |
| 1763 } else if (conn->type == AIM_CONN_TYPE_ICON) { | |
| 1764 if (od->icopa > 0) | |
| 1765 gaim_input_remove(od->icopa); | |
| 1766 od->icopa = 0; | |
| 1767 gaim_debug_info("oscar", | |
| 1768 "removing icon input watcher\n"); | |
| 1769 aim_conn_kill(od->sess, &conn); | |
| 1770 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { | |
| 1771 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) | |
| 1772 gaim_odc_disconnect(od->sess, conn); | |
| 1773 gaim_debug_info("oscar","killing rendezvous connection\n"); | |
| 1774 aim_conn_kill(od->sess, &conn); | |
| 2086 | 1775 } else { |
| 13231 | 1776 gaim_debug_error("oscar", |
| 1777 "holy crap! generic connection error! %hu\n", | |
| 1778 conn->type); | |
| 1779 aim_conn_kill(od->sess, &conn); | |
| 2086 | 1780 } |
| 1781 } | |
| 1782 } | |
| 1783 } | |
| 1784 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1785 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1786 { |
| 5575 | 1787 GaimConnection *gc = data; |
| 7283 | 1788 OscarData *od; |
| 13239 | 1789 OscarSession *sess; |
| 1790 OscarConnection *conn; | |
| 2086 | 1791 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1792 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 1793 close(source); |
| 1794 return; | |
| 1795 } | |
| 1796 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1797 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1798 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1799 |
| 4617 | 1800 od = gc->proto_data; |
| 1801 sess = od->sess; | |
| 2086 | 1802 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
| 4366 | 1803 conn->fd = source; |
| 2086 | 1804 |
| 1805 if (source < 0) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1806 gaim_connection_error(gc, _("Couldn't connect to host")); |
| 2086 | 1807 return; |
| 1808 } | |
| 1809 | |
| 1810 aim_conn_completeconnect(sess, conn); | |
| 4617 | 1811 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, oscar_callback, conn); |
| 7282 | 1812 aim_request_login(sess, conn, gaim_account_get_username(gaim_connection_get_account(gc))); |
| 1813 | |
| 8660 | 1814 gaim_debug_info("oscar", |
| 7282 | 1815 "Screen name sent, waiting for response\n"); |
| 7283 | 1816 gaim_connection_update_progress(gc, _("Screen name sent"), 1, OSCAR_CONNECT_STEPS); |
| 8341 | 1817 ck[1] = 0x65; |
| 2086 | 1818 } |
| 1819 | |
| 10444 | 1820 static void |
| 11837 | 1821 oscar_login(GaimAccount *account) |
| 10444 | 1822 { |
| 13239 | 1823 OscarSession *sess; |
| 1824 OscarConnection *conn; | |
| 5575 | 1825 GaimConnection *gc = gaim_account_get_connection(account); |
| 7283 | 1826 OscarData *od = gc->proto_data = g_new0(OscarData, 1); |
| 2086 | 1827 |
| 8660 | 1828 gaim_debug_misc("oscar", "oscar_login: gc = %p\n", gc); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
1829 |
| 8437 | 1830 if (!aim_snvalid(gaim_account_get_username(account))) { |
| 1831 gchar *buf; | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
1832 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 | 1833 gaim_connection_error(gc, buf); |
| 1834 g_free(buf); | |
| 1835 } | |
| 1836 | |
| 9975 | 1837 if (aim_sn_is_icq((gaim_account_get_username(account)))) { |
| 4617 | 1838 od->icq = TRUE; |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1839 } else { |
| 6622 | 1840 gc->flags |= GAIM_CONNECTION_HTML; |
| 1841 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
1842 } |
| 5836 | 1843 od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo); |
| 2086 | 1844 |
| 13253 | 1845 sess = oscar_session_new(); |
| 7282 | 1846 /* |
| 11837 | 1847 * We need an immediate queue because we don't use a while-loop |
| 7282 | 1848 * to see if things need to be sent. |
| 1849 */ | |
| 2086 | 1850 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); |
| 4617 | 1851 od->sess = sess; |
| 2086 | 1852 sess->aux_data = gc; |
| 1853 | |
| 9935 | 1854 /* Connect to core Gaim signals */ |
| 10087 | 1855 gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); |
| 9935 | 1856 |
| 11162 | 1857 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
| 2086 | 1858 if (conn == NULL) { |
| 10444 | 1859 gaim_debug_error("oscar", "internal connection error\n"); |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1860 gaim_connection_error(gc, _("Unable to login to AIM")); |
| 2086 | 1861 return; |
| 1862 } | |
| 1863 | |
| 4649 | 1864 aim_conn_addhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 10464 | 1865 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); |
| 2086 | 1866 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); |
| 13234 | 1867 aim_conn_addhandler(sess, conn, OSCAR_FAMILY_AUTH, OSCAR_SUBTYPE_AUTH_SECURID_REQUEST, gaim_parse_auth_securid_request, 0); |
| 2086 | 1868 |
| 1869 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 11338 | 1870 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), |
| 1871 gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), | |
| 5575 | 1872 oscar_login_connect, gc) < 0) { |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1873 gaim_connection_error(gc, _("Couldn't connect to host")); |
| 2086 | 1874 return; |
| 1875 } | |
| 7282 | 1876 |
| 7283 | 1877 gaim_connection_update_progress(gc, _("Connecting"), 0, OSCAR_CONNECT_STEPS); |
| 8341 | 1878 ck[0] = 0x5a; |
| 5575 | 1879 } |
| 1880 | |
| 1881 static void oscar_close(GaimConnection *gc) { | |
| 7283 | 1882 OscarData *od = (OscarData *)gc->proto_data; |
| 4617 | 1883 |
| 1884 while (od->oscar_chats) { | |
| 1885 struct chat_connection *n = od->oscar_chats->data; | |
| 2086 | 1886 if (n->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1887 gaim_input_remove(n->inpa); |
| 2086 | 1888 g_free(n->name); |
| 1889 g_free(n->show); | |
| 4617 | 1890 od->oscar_chats = g_slist_remove(od->oscar_chats, n); |
| 2086 | 1891 g_free(n); |
| 1892 } | |
| 4617 | 1893 while (od->direct_ims) { |
| 8971 | 1894 struct oscar_direct_im *n = od->direct_ims->data; |
| 1895 oscar_direct_im_destroy(od, n); | |
| 2086 | 1896 } |
| 4617 | 1897 /* BBB */ |
| 1898 while (od->file_transfers) { | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1899 GaimXfer *xfer; |
|
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
1900 xfer = (GaimXfer *)od->file_transfers->data; |
| 7805 | 1901 gaim_xfer_cancel_local(xfer); |
| 3630 | 1902 } |
| 4804 | 1903 while (od->requesticon) { |
| 1904 char *sn = od->requesticon->data; | |
| 1905 od->requesticon = g_slist_remove(od->requesticon, sn); | |
| 1906 free(sn); | |
| 1907 } | |
| 4738 | 1908 g_hash_table_destroy(od->buddyinfo); |
| 4617 | 1909 while (od->create_rooms) { |
| 1910 struct create_room *cr = od->create_rooms->data; | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1911 g_free(cr->name); |
| 4617 | 1912 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1913 g_free(cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
1914 } |
| 4617 | 1915 if (od->email) |
| 1916 g_free(od->email); | |
| 1917 if (od->newp) | |
| 1918 g_free(od->newp); | |
| 1919 if (od->oldp) | |
| 1920 g_free(od->oldp); | |
| 2086 | 1921 if (gc->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1922 gaim_input_remove(gc->inpa); |
| 4617 | 1923 if (od->cnpa > 0) |
| 1924 gaim_input_remove(od->cnpa); | |
| 1925 if (od->paspa > 0) | |
| 1926 gaim_input_remove(od->paspa); | |
| 1927 if (od->emlpa > 0) | |
| 1928 gaim_input_remove(od->emlpa); | |
| 4804 | 1929 if (od->icopa > 0) |
| 1930 gaim_input_remove(od->icopa); | |
| 6907 | 1931 if (od->icontimer > 0) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1932 gaim_timeout_remove(od->icontimer); |
| 8341 | 1933 if (od->getblisttimer > 0) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1934 gaim_timeout_remove(od->getblisttimer); |
| 8341 | 1935 if (od->getinfotimer > 0) |
| 1936 gaim_timeout_remove(od->getinfotimer); | |
| 10087 | 1937 gaim_prefs_disconnect_by_handle(gc); |
| 12663 | 1938 |
| 13253 | 1939 oscar_session_destroy(od->sess); |
| 4617 | 1940 od->sess = NULL; |
| 2086 | 1941 g_free(gc->proto_data); |
| 1942 gc->proto_data = NULL; | |
| 8660 | 1943 gaim_debug_info("oscar", "Signed off.\n"); |
| 2086 | 1944 } |
| 1945 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1946 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 1947 GaimConnection *gc = data; |
| 7283 | 1948 OscarData *od; |
| 13239 | 1949 OscarSession *sess; |
| 1950 OscarConnection *bosconn; | |
| 2086 | 1951 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
1952 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 1953 close(source); |
| 1954 return; | |
| 1955 } | |
| 1956 | |
| 4617 | 1957 od = gc->proto_data; |
| 1958 sess = od->sess; | |
| 12653 | 1959 bosconn = od->conn; |
| 4366 | 1960 bosconn->fd = source; |
| 2086 | 1961 |
| 1962 if (source < 0) { | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1963 gaim_connection_error(gc, _("Could Not Connect")); |
| 2086 | 1964 return; |
| 1965 } | |
| 1966 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1967 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1968 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
1969 |
| 2086 | 1970 aim_conn_completeconnect(sess, bosconn); |
| 4617 | 1971 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, oscar_callback, bosconn); |
| 7283 | 1972 |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
1973 gaim_connection_update_progress(gc, |
| 7283 | 1974 _("Connection established, cookie sent"), 4, OSCAR_CONNECT_STEPS); |
| 8341 | 1975 ck[4] = 0x61; |
| 2086 | 1976 } |
| 1977 | |
| 4617 | 1978 /* BBB */ |
| 4656 | 1979 /* |
| 12653 | 1980 * This little area in oscar.c is the nexus of file transfer code, |
| 1981 * so I wrote a little explanation of what happens. I am such a | |
| 4656 | 1982 * ninja. |
| 1983 * | |
| 1984 * The series of events for a file send is: | |
| 1985 * -Create xfer and call gaim_xfer_request (this happens in oscar_ask_sendfile) | |
| 12653 | 1986 * -User chooses a file and oscar_xfer_init is called. It establishes a |
| 1987 * listening socket, then asks the remote user to connect to us (and | |
| 4656 | 1988 * gives them the file name, port, IP, etc.) |
| 13239 | 1989 * -They connect to us and we send them an PEER_TYPE_PROMPT (this happens |
| 4656 | 1990 * in oscar_sendfile_estblsh) |
| 13239 | 1991 * -They send us an PEER_TYPE_ACK and then we start sending data |
| 1992 * -When we finish, they send us an PEER_TYPE_DONE and they close the | |
| 4656 | 1993 * connection. |
| 1994 * -We get drunk because file transfer kicks ass. | |
| 1995 * | |
| 1996 * The series of events for a file receive is: | |
| 1997 * -Create xfer and call gaim_xfer request (this happens in incomingim_chan2) | |
| 12653 | 1998 * -Gaim user selects file to name and location to save file to and |
| 4656 | 1999 * oscar_xfer_init is called |
| 2000 * -It connects to the remote user using the IP they gave us earlier | |
| 13239 | 2001 * -After connecting, they send us an PEER_TYPE_PROMPT. In reply, we send |
| 2002 * them an PEER_TYPE_ACK. | |
| 4656 | 2003 * -They begin to send us lots of raw data. |
| 13239 | 2004 * -When they finish sending data we send an PEER_TYPE_DONE and then close |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
2005 * the connection. |
| 11369 | 2006 * |
| 2007 * Update August 2005: | |
| 2008 * The series of events for transfers has been seriously complicated by the addition | |
| 2009 * of transfer redirects and proxied connections. I could throw a whole lot of words | |
| 2010 * at trying to explain things here, but it probably wouldn't do much good. To get | |
| 2011 * a better idea of what happens, take a look at the diagrams and documentation | |
| 2012 * from my Summer of Code project. -- Jonathan Clark | |
| 4656 | 2013 */ |
| 2014 static void oscar_sendfile_connected(gpointer data, gint source, GaimInputCondition condition); | |
| 11369 | 2015 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition); |
| 2016 static void oscar_send_file_request(GaimXfer *xfer); | |
| 4656 | 2017 |
| 8446 | 2018 /* |
| 2019 * Miscellaneous xfer functions | |
| 2020 */ | |
| 13234 | 2021 static GaimXfer *oscar_find_xfer_by_cookie(GSList *fts, const guint8 *ck) |
| 4656 | 2022 { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2023 GaimXfer *xfer; |
| 13252 | 2024 PeerConnection *peer_connection; |
| 4656 | 2025 |
| 2026 while (fts) { | |
| 2027 xfer = fts->data; | |
| 13252 | 2028 peer_connection = xfer->data; |
| 2029 | |
| 2030 if (peer_connection && !memcmp(ck, peer_connection->cookie, 8)) | |
| 4656 | 2031 return xfer; |
| 2032 | |
| 2033 fts = g_slist_next(fts); | |
| 2034 } | |
| 2035 | |
| 2036 return NULL; | |
| 2037 } | |
| 2038 | |
| 13239 | 2039 static GaimXfer *oscar_find_xfer_by_conn(GSList *fts, OscarConnection *conn) |
| 4656 | 2040 { |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2041 GaimXfer *xfer; |
| 13252 | 2042 PeerConnection *peer_connection; |
| 4656 | 2043 |
| 2044 while (fts) { | |
| 2045 xfer = fts->data; | |
| 13252 | 2046 peer_connection = xfer->data; |
| 2047 | |
| 2048 if (peer_connection && (conn == peer_connection->conn)) | |
| 4656 | 2049 return xfer; |
| 2050 | |
| 2051 fts = g_slist_next(fts); | |
| 2052 } | |
| 2053 | |
| 2054 return NULL; | |
| 2055 } | |
| 2056 | |
| 11369 | 2057 /* |
| 2058 * We're done sending/receiving raw data through the connection. | |
| 2059 * If we're the receiver, send an OFT header with the bytes received | |
| 2060 * filled in to indicate this party's over. | |
| 2061 */ | |
| 8446 | 2062 static void oscar_xfer_end(GaimXfer *xfer) |
| 2063 { | |
| 13252 | 2064 PeerConnection *peer_connection = xfer->data; |
| 2065 GaimConnection *gc = peer_connection->sess->aux_data; | |
| 8446 | 2066 OscarData *od = gc->proto_data; |
| 2067 | |
| 8660 | 2068 gaim_debug_info("oscar", "AAA - in oscar_xfer_end\n"); |
| 8446 | 2069 |
| 2070 if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { | |
| 13252 | 2071 peer_connection->fh.nrecvd = gaim_xfer_get_bytes_sent(xfer); |
| 2072 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_DONE, peer_connection); | |
| 2073 } | |
| 2074 | |
| 2075 aim_conn_kill(peer_connection->sess, &peer_connection->conn); | |
| 2076 aim_oft_destroyinfo(peer_connection); | |
| 8446 | 2077 xfer->data = NULL; |
| 2078 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 2079 } | |
| 2080 | |
| 2081 /* | |
| 2082 * xfer functions used when receiving files | |
| 2083 */ | |
| 2084 | |
| 11084 | 2085 /* |
| 11369 | 2086 * This is a gaim timeout callback called X milliseconds after a connection is attempted |
| 2087 * By this point, we've lost faith in the connection method we just tried and want to | |
| 2088 * try something new. Hopefully, that new connection method will be more successful, | |
| 2089 * otherwise, we'll end up here again and again until the connection is successful | |
| 2090 * or we've tried every method... if that happens we just throw our hands up | |
| 2091 * and inform the user of his bad karma. | |
| 2092 */ | |
| 2093 static gboolean oscar_xfer_ip_timeout(gpointer data) { | |
| 11084 | 2094 GaimXfer *xfer; |
| 13074 | 2095 GaimAccount *account; |
| 13252 | 2096 PeerConnection *peer_connection; |
| 11084 | 2097 char *msg = NULL; |
| 12653 | 2098 |
| 11369 | 2099 gaim_debug_info("oscar","AAA - in oscar_xfer_ip_timeout\n"); |
| 2100 | |
| 11084 | 2101 xfer = (GaimXfer*) data; |
| 13074 | 2102 account = gaim_xfer_get_account(xfer); |
| 11084 | 2103 if(xfer->data) { |
| 13252 | 2104 peer_connection = (PeerConnection*) xfer->data; |
| 12653 | 2105 |
| 11084 | 2106 /* Check to see if the clientip has produced any results */ |
| 13252 | 2107 if(!peer_connection->success) { |
| 11369 | 2108 /* This connection has worn out its welcome. Goodbye. */ |
| 13252 | 2109 if(peer_connection->conn) { |
| 2110 close(peer_connection->conn->fd); | |
| 2111 aim_conn_kill(peer_connection->sess, &peer_connection->conn); | |
| 11369 | 2112 } |
| 12653 | 2113 |
| 13252 | 2114 if(peer_connection->method == AIM_XFER_DIRECT || peer_connection->method == AIM_XFER_REDIR) { |
| 11369 | 2115 /* If (we're currently using the verified ip) |
| 2116 * In case clientip & verifiedip are the same, | |
| 2117 * we must prevent an infinite loop */ | |
| 13252 | 2118 if(xfer->remote_ip && peer_connection->verifiedip |
| 2119 && g_ascii_strcasecmp(xfer->remote_ip, peer_connection->verifiedip) == 0 | |
| 2120 && g_ascii_strcasecmp(peer_connection->clientip, peer_connection->verifiedip) != 0 ) | |
| 11369 | 2121 { |
| 2122 /* The verifiedip timed out */ | |
| 13252 | 2123 if (peer_connection->method == AIM_XFER_DIRECT && !peer_connection->redir_attempted) |
| 13071 | 2124 { |
| 11369 | 2125 /* clientip & verifiedip failed, request a redirect |
| 13071 | 2126 * that is, we want the sender to connect to us |
| 2127 * | |
| 2128 * Above, we checked if we had previously attempted a connection | |
| 2129 * redirect to prevent a conflict with the joscar library | |
| 2130 */ | |
| 12653 | 2131 |
| 11369 | 2132 /* Let the user not to lose hope quite yet*/ |
| 2133 msg = g_strdup_printf(_("Attempting connection redirect...")); | |
| 2134 gaim_xfer_conversation_write(xfer, msg, FALSE); | |
| 2135 g_free(msg); | |
| 12653 | 2136 |
| 11369 | 2137 gaim_timeout_add(FT_REDIR_TIMEOUT, |
| 2138 oscar_xfer_ip_timeout, xfer); | |
| 13252 | 2139 peer_connection->method = AIM_XFER_REDIR; |
| 2140 peer_connection->redir_attempted = TRUE; | |
| 2141 g_free(peer_connection->proxyip); | |
| 2142 peer_connection->proxyip = NULL; | |
| 2143 peer_connection->clientip = g_strdup( gaim_network_get_my_ip( | |
| 2144 peer_connection->conn ? peer_connection->conn->fd : -1)); | |
| 11369 | 2145 oscar_xfer_init_send(xfer); |
| 2146 } else { | |
| 2147 /* clientip, verifiedip, and redirect all failed. */ | |
| 2148 gaim_debug_info("oscar", | |
| 2149 "redirect timed out. requesting stg3 proxy\n"); | |
| 12653 | 2150 |
| 11369 | 2151 /* Kill our listener */ |
| 2152 gaim_input_remove(xfer->watcher); | |
| 13252 | 2153 aim_conn_kill(peer_connection->sess, &peer_connection->conn); |
| 12653 | 2154 |
| 11369 | 2155 /* Instead of failing here, request a stage 3 proxy */ |
| 13252 | 2156 g_free(peer_connection->clientip); |
| 2157 g_free(peer_connection->verifiedip); | |
| 2158 peer_connection->clientip = NULL; | |
| 2159 peer_connection->verifiedip = NULL; | |
| 2160 peer_connection->port = 0; | |
| 2161 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS; | |
| 2162 peer_connection->method = AIM_XFER_PROXY; | |
| 2163 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
| 2164 | |
| 2165 aim_im_sendch2_sendfile_ask(peer_connection->sess, peer_connection); | |
| 11369 | 2166 } |
| 2167 } else { | |
| 2168 /* clientip timed out, now try verifiedip */ | |
| 2169 g_free(xfer->remote_ip); | |
| 13252 | 2170 xfer->remote_ip = g_strdup(peer_connection->verifiedip); |
| 11369 | 2171 gaim_debug_info("oscar","attempting connection using verifiedip\n"); |
| 2172 oscar_xfer_init_recv(xfer); | |
| 2173 } | |
| 13252 | 2174 } else if(peer_connection->method == AIM_XFER_PROXY) { |
| 11369 | 2175 /* proxyip timed out |
| 2176 * Yes, it's a bit odd to ask the user to enable proxied file transfers | |
| 2177 * when it's a proxied transfer that timed out. It is possible that a | |
| 13071 | 2178 * stage 1 or 2 proxied transfer might work when a stage 3 will not. */ |
| 13074 | 2179 msg = g_strdup_printf(_("Transfer of file %s timed out.\n Try enabling proxy servers for file transfers in Accounts->%s->Edit Account->Advanced."), |
| 2180 gaim_xfer_get_filename(xfer), gaim_account_get_username(account)); | |
| 11369 | 2181 gaim_xfer_conversation_write(xfer, msg, TRUE); |
| 2182 g_free(msg); | |
| 2183 gaim_xfer_cancel_local(xfer); | |
| 13252 | 2184 if(peer_connection->xfer_reffed) { |
| 2185 peer_connection->xfer_reffed = FALSE; | |
| 11369 | 2186 gaim_xfer_unref(xfer); |
| 2187 } | |
| 2188 } else { | |
| 2189 gaim_debug_warning("oscar","unknown xfer method encountered in timout\n"); | |
| 2190 } | |
| 11214 | 2191 } else { |
| 13252 | 2192 if(peer_connection->xfer_reffed) { |
| 2193 peer_connection->xfer_reffed = FALSE; | |
| 11369 | 2194 gaim_xfer_unref(xfer); |
| 2195 } | |
| 2196 gaim_debug_info("oscar","connection successful; timeout off\n"); | |
| 11084 | 2197 } |
| 11369 | 2198 } else { |
| 2199 gaim_debug_info("oscar","transfer already done; nothing to do\n"); | |
| 11084 | 2200 } |
| 2201 return FALSE; | |
| 2202 } | |
| 2203 | |
| 2204 /* | |
| 11369 | 2205 * Connect to another client or a file transfer proxy server. |
| 2206 * Though this function has traditionally only been used during file receives, | |
| 2207 * it is now called to make any sort of file transfer connection via gaim_proxy_connect. | |
| 11084 | 2208 */ |
| 8446 | 2209 static void oscar_xfer_init_recv(GaimXfer *xfer) |
| 2210 { | |
| 13252 | 2211 PeerConnection *peer_connection; |
| 13239 | 2212 PeerProxyInfo *proxy_info; |
| 11369 | 2213 GaimConnection *gc; |
| 2214 OscarData *od; | |
| 2215 GaimInputFunction nextstop_cb; | |
| 2216 int rc; | |
| 2217 | |
| 2218 g_return_if_fail(xfer != NULL); | |
| 2219 g_return_if_fail(xfer->data != NULL); | |
| 2220 | |
| 13252 | 2221 peer_connection = xfer->data; |
| 2222 proxy_info = peer_connection->proxy_info; | |
| 2223 gc = peer_connection->sess->aux_data; | |
| 11369 | 2224 od = gc->proto_data; |
| 2225 | |
| 2226 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_recv\n"); | |
| 13074 | 2227 |
| 11084 | 2228 /* Start a timer for this ip address |
| 11369 | 2229 * If the clientip fails, try the verifiedip |
| 2230 * If that fails, wait for the transfer to redirect | |
| 2231 * This xfer reference will be released in oscar_xfer_ip_timeout */ | |
| 13252 | 2232 if(!peer_connection->xfer_reffed) { |
| 2233 peer_connection->xfer_reffed = TRUE; | |
| 11084 | 2234 gaim_xfer_ref(xfer); |
| 11369 | 2235 } |
| 13074 | 2236 |
| 13252 | 2237 if(peer_connection->method != AIM_XFER_PROXY) { |
| 11369 | 2238 /* If (we're currently using the verified ip) |
| 2239 * In case clientip & verifiedip are the same, we must prevent an infinite loop */ | |
| 13252 | 2240 if(xfer->remote_ip && peer_connection->verifiedip |
| 2241 && g_ascii_strcasecmp(xfer->remote_ip, peer_connection->verifiedip) == 0 | |
| 2242 && g_ascii_strcasecmp(peer_connection->clientip, peer_connection->verifiedip) != 0 ) { | |
| 11369 | 2243 gaim_timeout_add(FT_VERIFIEDIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
| 11084 | 2244 } else { |
| 11369 | 2245 gaim_timeout_add(FT_CLIENTIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); |
| 11084 | 2246 } |
| 11369 | 2247 } else { |
| 2248 gaim_timeout_add(FT_PROXYIP_TIMEOUT, oscar_xfer_ip_timeout, xfer); | |
| 2249 } | |
| 13252 | 2250 peer_connection->conn = aim_newconn(od->sess, AIM_CONN_TYPE_RENDEZVOUS); |
| 13074 | 2251 |
| 11369 | 2252 /* If we're routing this transfer through a AOL proxy server, do the special login |
| 2253 * before telling the other client we're ready for action. | |
| 2254 * Note, firststop_cb is the first function called after gaim has made a connection | |
| 2255 * Also, the connection type is changed until the proxy login is complete */ | |
| 13252 | 2256 if(peer_connection->method == AIM_XFER_PROXY) { |
| 11369 | 2257 if(proxy_info) |
| 13252 | 2258 proxy_info->conn = peer_connection->conn; |
| 11369 | 2259 else { |
| 2260 gaim_debug_warning("oscar","NULL proxy_info\n"); | |
| 2261 gaim_xfer_cancel_local(xfer); | |
| 2262 } | |
| 2263 nextstop_cb = oscar_xfer_proxylogin; | |
| 13252 | 2264 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS_PROXY; |
| 11369 | 2265 } else { |
| 2266 nextstop_cb = oscar_sendfile_connected; | |
| 2267 } | |
| 13074 | 2268 |
| 13252 | 2269 if (peer_connection->conn) { |
| 2270 peer_connection->conn->subtype = AIM_CONN_SUBTYPE_OFT_SENDFILE; | |
| 2271 aim_conn_addhandler(od->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_PROMPT, | |
| 11369 | 2272 oscar_sendfile_prompt, 0); |
| 2273 rc = gaim_proxy_connect(gaim_connection_get_account(gc), | |
| 2274 xfer->remote_ip, xfer->remote_port, nextstop_cb, xfer); | |
| 2275 if (rc == -1) { | |
| 10654 | 2276 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
| 8446 | 2277 _("Unable to establish file descriptor.")); |
| 2278 gaim_xfer_cancel_local(xfer); | |
| 2279 } | |
| 2280 } else { | |
| 10654 | 2281 gaim_xfer_error(GAIM_XFER_RECEIVE, gaim_xfer_get_account(xfer), xfer->who, |
| 8446 | 2282 _("Unable to create new connection.")); |
| 2283 gaim_xfer_cancel_local(xfer); | |
| 2284 /* Try a different port? Ask them to connect to us? /join #gaim and whine? */ | |
| 2285 } | |
| 11369 | 2286 } |
| 2287 | |
| 2288 /* | |
| 2289 * "Never mind. This transfer wasn't such a great idea after all." | |
| 2290 */ | |
| 8446 | 2291 static void oscar_xfer_cancel_recv(GaimXfer *xfer) |
| 2292 { | |
| 13252 | 2293 PeerConnection *peer_connection = xfer->data; |
| 2294 GaimConnection *gc = peer_connection->sess->aux_data; | |
| 11369 | 2295 OscarData *od = gc->proto_data; |
| 8446 | 2296 |
| 8660 | 2297 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_recv\n"); |
| 8446 | 2298 |
| 9771 | 2299 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
| 13252 | 2300 aim_im_sendch2_sendfile_cancel(peer_connection->sess, peer_connection); |
| 2301 | |
| 2302 aim_conn_kill(peer_connection->sess, &peer_connection->conn); | |
| 2303 aim_oft_destroyinfo(peer_connection); | |
| 8446 | 2304 xfer->data = NULL; |
| 2305 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 2306 } | |
| 2307 | |
| 11369 | 2308 /* |
| 2309 * Called after every data packet we receive | |
| 2310 */ | |
| 11159 | 2311 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
| 8446 | 2312 { |
| 13252 | 2313 PeerConnection *peer_connection = xfer->data; |
| 8446 | 2314 |
| 2315 /* Update our rolling checksum. Like Walmart, yo. */ | |
| 13252 | 2316 peer_connection->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, peer_connection->fh.recvcsum); |
| 8446 | 2317 } |
| 2318 | |
| 2319 /* | |
| 11369 | 2320 * xfer functions used for proxied file transfers |
| 2321 */ | |
| 2322 | |
| 2323 /* | |
| 2324 * Called by oscar_send_proxylogin_cb when we receive a ready packet | |
| 2325 * BBB | |
| 2326 */ | |
|
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2327 static void oscar_xfer_proxylogin_ready(GaimXfer *xfer, gint fd) { |
| 13252 | 2328 PeerConnection *peer_connection; |
| 13239 | 2329 PeerProxyInfo *proxy_info; |
| 12653 | 2330 |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2331 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2332 fcntl(fd, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
2333 |
| 11369 | 2334 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ready\n"); |
| 13252 | 2335 if (!(peer_connection = xfer->data)) { |
| 2336 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
| 11369 | 2337 gaim_xfer_cancel_local(xfer); |
| 2338 return; | |
| 2339 } | |
| 13252 | 2340 if (!(proxy_info = peer_connection->proxy_info)) { |
| 11369 | 2341 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
| 2342 gaim_xfer_cancel_local(xfer); | |
| 2343 return; | |
| 2344 } | |
| 12653 | 2345 |
| 11369 | 2346 /* Remove the rv proxy watcher and put the connection type back the way we found it */ |
| 2347 gaim_input_remove(xfer->watcher); | |
| 2348 xfer->watcher = 0; | |
| 13252 | 2349 peer_connection->conn->type = AIM_CONN_TYPE_RENDEZVOUS; |
| 2350 | |
| 2351 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
| 2352 | |
| 2353 if(peer_connection->stage == AIM_XFER_PROXY_STG2) { | |
| 2354 aim_im_sendch2_sendfile_accept(peer_connection->sess, peer_connection); | |
| 12653 | 2355 |
| 11369 | 2356 /* For stage 2, both file headers are filled in */ |
| 13252 | 2357 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
| 11369 | 2358 } |
| 12653 | 2359 |
| 11369 | 2360 /* The following is taken from oscar_sendfile_estblsh */ |
| 13252 | 2361 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, |
| 11369 | 2362 oscar_sendfile_ack, 0); |
| 13252 | 2363 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
| 11369 | 2364 oscar_sendfile_done, 0); |
| 13252 | 2365 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, |
| 2366 peer_connection->conn); | |
| 12653 | 2367 |
| 11369 | 2368 /* Inform the other user that we are connected and ready to transfer */ |
| 13252 | 2369 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_PROMPT, peer_connection); |
| 2370 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { | |
| 11369 | 2371 oscar_sendfile_connected(xfer, fd, GAIM_INPUT_READ); |
| 2372 } else { | |
| 2373 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
| 2374 gaim_xfer_cancel_local(xfer); | |
| 12653 | 2375 } |
| 11369 | 2376 } |
| 2377 | |
| 2378 /* | |
| 2379 * Called by oscar_sendfile_proxylogin_cb when we receive an ack packet in reply to an init_send | |
| 2380 * BBB | |
| 2381 */ | |
|
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
2382 static void oscar_xfer_proxylogin_ack(GaimXfer *xfer) { |
| 13252 | 2383 PeerConnection *peer_connection; |
| 13239 | 2384 PeerProxyInfo *proxy_info; |
| 12653 | 2385 |
| 11369 | 2386 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_ack\n"); |
| 13252 | 2387 if (!(peer_connection = xfer->data)) { |
| 2388 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
| 11369 | 2389 gaim_xfer_cancel_local(xfer); |
| 2390 return; | |
| 2391 } | |
| 13252 | 2392 if (!(proxy_info = peer_connection->proxy_info)) { |
| 11369 | 2393 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
| 2394 gaim_xfer_cancel_local(xfer); | |
| 2395 return; | |
| 2396 } | |
| 12653 | 2397 |
| 11369 | 2398 /* Use the proxy "port" we just ACK-quired (hah) so that the proxy will love us */ |
| 13252 | 2399 peer_connection->port = proxy_info->port; |
| 2400 peer_connection->proxyip = g_strdup(proxy_info->ip); | |
| 11369 | 2401 gaim_debug_info("oscar","received client ip and port: %s:%d\n", |
| 13252 | 2402 peer_connection->proxyip, peer_connection->port); |
| 2403 | |
| 2404 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
| 11369 | 2405 oscar_send_file_request(xfer); |
| 13252 | 2406 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { |
| 2407 strncpy(peer_connection->fh.name, xfer->filename, 64); | |
| 2408 peer_connection->fh.name[63] = '\0'; | |
| 2409 peer_connection->fh.totsize = gaim_xfer_get_size(xfer); | |
| 2410 peer_connection->fh.size = gaim_xfer_get_size(xfer); | |
| 12653 | 2411 |
| 11369 | 2412 /* Calculating the checksum can take a very long time for large files */ |
| 2413 gaim_debug_info("oscar","calculating file checksum\n"); | |
| 13252 | 2414 peer_connection->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
| 11369 | 2415 gaim_debug_info("oscar","checksum calculated\n"); |
| 12653 | 2416 |
| 13252 | 2417 aim_im_sendch2_sendfile_ask(peer_connection->sess, peer_connection); |
| 11369 | 2418 } else { |
| 2419 gaim_debug_warning("oscar","no value for send_or_recv; aborting transfer\n"); | |
| 2420 gaim_xfer_cancel_local(xfer); | |
| 2421 } | |
| 2422 } | |
| 2423 | |
| 2424 /* | |
| 2425 * This is called whenever we receive data while negotiating a rendezvous proxy connection | |
| 2426 * BBB | |
| 2427 */ | |
| 2428 static void oscar_xfer_proxylogin_cb(gpointer data, gint source, GaimInputCondition condition) { | |
| 2429 GaimXfer *xfer; | |
| 13252 | 2430 PeerConnection *peer_connection; |
| 12653 | 2431 |
| 11369 | 2432 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin_cb\n"); |
| 2433 if (!(xfer = data)) { | |
| 2434 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
| 2435 gaim_xfer_cancel_local(xfer); | |
| 2436 return; | |
| 12653 | 2437 } |
| 13252 | 2438 if (!(peer_connection = xfer->data)) { |
| 2439 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
| 11369 | 2440 gaim_xfer_cancel_local(xfer); |
| 2441 return; | |
| 2442 } | |
| 12653 | 2443 |
| 13252 | 2444 if( (peer_connection->proxy_info = aim_rv_proxy_read(peer_connection->sess, peer_connection->conn)) ) { |
| 2445 | |
| 2446 switch(peer_connection->proxy_info->cmd_type) { | |
| 11369 | 2447 case AIM_RV_PROXY_READY: |
| 2448 oscar_xfer_proxylogin_ready(xfer, source); | |
| 13252 | 2449 free(peer_connection->proxy_info); |
| 2450 peer_connection->proxy_info = NULL; | |
| 11369 | 2451 break; |
| 2452 case AIM_RV_PROXY_ACK: | |
| 2453 oscar_xfer_proxylogin_ack(xfer); | |
| 13252 | 2454 free(peer_connection->proxy_info); |
| 2455 peer_connection->proxy_info = NULL; | |
| 11369 | 2456 break; |
| 2457 case AIM_RV_PROXY_ERROR: | |
| 2458 gaim_debug_info("oscar","error logging into rendezvous proxy; err code is %x\n", | |
| 13252 | 2459 peer_connection->proxy_info->err_code); |
| 11369 | 2460 gaim_input_remove(xfer->watcher); |
| 2461 xfer->watcher = 0; | |
| 13252 | 2462 free(peer_connection->proxy_info); |
| 2463 peer_connection->proxy_info = NULL; | |
| 11369 | 2464 gaim_xfer_cancel_remote(xfer); |
| 2465 break; | |
| 2466 /* We should never get here */ | |
| 2467 default: | |
| 2468 gaim_debug_info("oscar","proxylogin switch defaulted unexpectedly\n"); | |
| 2469 } | |
| 2470 } else { | |
| 2471 gaim_debug_info("oscar","could not read rv proxy packet\n"); | |
| 2472 } | |
| 2473 } | |
| 2474 | |
| 2475 /* | |
| 2476 * Called to send necessary login data to a rendezvous proxy server once we're connected | |
| 2477 * Takes xfer is data and fd as source | |
| 2478 */ | |
| 2479 static void oscar_xfer_proxylogin(gpointer data, gint source, GaimInputCondition condition) | |
| 2480 { | |
| 2481 GaimXfer *xfer; | |
| 13252 | 2482 PeerConnection *peer_connection; |
| 13239 | 2483 PeerProxyInfo *proxy_info; |
| 11369 | 2484 int err; |
| 12653 | 2485 |
| 11369 | 2486 gaim_debug_info("oscar","AAA - in oscar_xfer_proxylogin\n"); |
| 2487 if (!(xfer = data)) { | |
| 2488 gaim_debug_warning("oscar","NULL xfer; aborting\n"); | |
| 2489 gaim_xfer_cancel_local(xfer); | |
| 2490 return; | |
| 12653 | 2491 } |
| 13252 | 2492 if (!(peer_connection = xfer->data)) { |
| 2493 gaim_debug_warning("oscar","NULL peer_connection; aborting\n"); | |
| 11369 | 2494 gaim_xfer_cancel_local(xfer); |
| 2495 return; | |
| 2496 } | |
| 13252 | 2497 if (!(proxy_info = peer_connection->proxy_info)) { |
| 11369 | 2498 gaim_debug_warning("oscar","NULL proxy_info; aborting\n"); |
| 2499 gaim_xfer_cancel_local(xfer); | |
| 2500 return; | |
| 2501 } | |
| 13252 | 2502 if(peer_connection->success) { |
| 11369 | 2503 gaim_debug_info("oscar","connection already successful, ignoring 2nd conn\n"); |
| 2504 return; | |
| 2505 } | |
| 2506 | |
| 2507 xfer->fd = source; | |
| 13252 | 2508 peer_connection->conn->fd = source; |
| 2509 | |
| 2510 proxy_info->conn = peer_connection->conn; | |
| 11369 | 2511 proxy_info->flags = AIM_RV_PROXY_CLIENT_FLAGS; |
| 13252 | 2512 memcpy(proxy_info->cookie, peer_connection->cookie, 8); |
| 2513 | |
| 2514 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
| 2515 if(peer_connection->stage == AIM_XFER_PROXY_STG1 || peer_connection->stage == AIM_XFER_PROXY_STG3) { | |
| 11369 | 2516 gaim_debug_info("oscar","sending INIT SEND for stage 1/3 rv proxied send\n"); |
| 2517 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
| 2518 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
| 2519 _("Unable to log into file transfer proxy.")); | |
| 2520 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
| 2521 strerror(err)); | |
| 2522 gaim_xfer_cancel_local(xfer); | |
| 2523 } | |
| 13252 | 2524 } else if(peer_connection->stage == AIM_XFER_PROXY_STG2) { |
| 11369 | 2525 gaim_debug_info("oscar","sending INIT RECV for stage 2 rv proxied send\n"); |
| 2526 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
| 2527 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
| 2528 _("Unable to log into file transfer proxy.")); | |
| 2529 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
| 2530 strerror(err)); | |
| 2531 gaim_xfer_cancel_local(xfer); | |
| 2532 } | |
| 2533 } else { | |
| 2534 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
| 2535 gaim_xfer_cancel_local(xfer); | |
| 2536 } | |
| 13252 | 2537 } else if(peer_connection->send_or_recv == AIM_XFER_RECV) { |
| 2538 if(peer_connection->stage == AIM_XFER_PROXY_STG2) { | |
| 11369 | 2539 gaim_debug_info("oscar","sending INIT SEND for stage 2 rv proxied receive\n"); |
| 2540 if( (err = aim_rv_proxy_init_send(proxy_info)) ) { | |
| 2541 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
| 2542 _("Unable to log into file transfer proxy.")); | |
| 2543 gaim_debug_info("oscar", "error while sending INIT SEND rv proxy packet: %s\n", | |
| 2544 strerror(err)); | |
| 2545 gaim_xfer_cancel_local(xfer); | |
| 2546 } | |
| 13252 | 2547 } else if(peer_connection->stage == AIM_XFER_PROXY_STG1 |
| 2548 || peer_connection->stage == AIM_XFER_PROXY_STG3) { | |
| 11369 | 2549 gaim_debug_info("oscar","sending INIT RECV for stage 1/3 rv proxied receive\n"); |
| 2550 if( (err = aim_rv_proxy_init_recv(proxy_info)) ) { | |
| 2551 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
| 2552 _("Unable to log into file transfer proxy.")); | |
| 2553 gaim_debug_info("oscar", "error while sending INIT RECV rv proxy packet: %s\n", | |
| 2554 strerror(err)); | |
| 2555 gaim_xfer_cancel_local(xfer); | |
| 2556 } | |
| 2557 } else { | |
| 2558 gaim_debug_warning("oscar","no proxy type specified; aborting transfer\n"); | |
| 2559 gaim_xfer_cancel_local(xfer); | |
| 2560 } | |
| 2561 } else { | |
| 2562 gaim_debug_warning("oscar","no send_or_recv value specified; aborting\n"); | |
| 2563 gaim_xfer_cancel_local(xfer); | |
| 2564 } | |
| 2565 free(proxy_info); | |
| 13252 | 2566 peer_connection->proxy_info = NULL; |
| 12653 | 2567 |
| 11369 | 2568 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_xfer_proxylogin_cb, xfer); |
| 2569 } | |
| 2570 | |
| 12653 | 2571 |
| 11369 | 2572 /* |
| 8446 | 2573 * xfer functions used when sending files |
| 2574 */ | |
| 2575 | |
| 11369 | 2576 /* |
| 2577 * Send a request to another client notifying them we want to sent a file | |
| 2578 */ | |
| 2579 static void oscar_send_file_request(GaimXfer *xfer) | |
| 2580 { | |
| 13252 | 2581 PeerConnection *peer_connection = xfer->data; |
| 2582 GaimConnection *gc = peer_connection->sess->aux_data; | |
| 12653 | 2583 OscarData *od = gc->proto_data; |
| 2584 | |
| 11369 | 2585 gaim_debug_info("oscar", "AAA - in oscar_send_file_request\n"); |
| 12653 | 2586 |
| 13252 | 2587 if (peer_connection->conn) { |
| 11369 | 2588 xfer->filename = g_path_get_basename(xfer->local_filename); |
| 13252 | 2589 strncpy(peer_connection->fh.name, xfer->filename, 64); |
| 2590 peer_connection->fh.name[63] = '\0'; | |
| 2591 peer_connection->fh.totsize = gaim_xfer_get_size(xfer); | |
| 2592 peer_connection->fh.size = gaim_xfer_get_size(xfer); | |
| 12653 | 2593 |
| 11369 | 2594 /* Calculating the checksum can take a very long time for large files */ |
| 2595 gaim_debug_info("oscar","calculating file checksum\n"); | |
| 13252 | 2596 peer_connection->fh.checksum = aim_oft_checksum_file(xfer->local_filename); |
| 11369 | 2597 gaim_debug_info("oscar","checksum calculated\n"); |
| 2598 | |
| 13252 | 2599 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
| 2600 | |
| 2601 aim_im_sendch2_sendfile_ask(od->sess, peer_connection); | |
| 2602 aim_conn_addhandler(od->sess, peer_connection->conn, AIM_CB_FAM_OFT, | |
| 13239 | 2603 PEER_TYPE_ESTABLISHED, oscar_sendfile_estblsh, 0); |
| 11369 | 2604 } else { |
| 2605 gaim_xfer_error(GAIM_XFER_SEND, gaim_xfer_get_account(xfer), xfer->who, | |
| 2606 _("Unable to establish listener socket or no AOL proxy connection present.")); | |
| 2607 gaim_xfer_cancel_local(xfer); | |
| 2608 } | |
| 2609 } | |
| 2610 | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2611 static void |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2612 oscar_xfer_init_listen_cb(int listenfd, gpointer data) { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2613 GaimXfer *xfer = data; |
| 13252 | 2614 PeerConnection *peer_connection; |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2615 GaimConnection *gc; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2616 OscarData *od; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2617 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2618 /* If the ft was canceled before we get here, don't continue */ |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2619 if(gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2620 gaim_xfer_unref(xfer); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2621 return; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2622 } |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2623 |
| 13252 | 2624 peer_connection = xfer->data; |
| 2625 gc = peer_connection->sess->aux_data; | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2626 od = gc->proto_data; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2627 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2628 if (listenfd < 0) { |
| 8446 | 2629 gaim_xfer_cancel_local(xfer); |
| 2630 return; | |
| 2631 } | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2632 |
| 8446 | 2633 xfer->local_port = gaim_network_get_port_from_fd(listenfd); |
| 13252 | 2634 peer_connection->port = xfer->local_port; |
| 2635 if (aim_sendfile_listen(od->sess, peer_connection, listenfd) != 0) { | |
| 8446 | 2636 gaim_xfer_cancel_local(xfer); |
| 2637 return; | |
| 2638 } | |
| 13226 | 2639 gaim_debug_misc("oscar", "port is %hu, ip is %s\n", |
| 13252 | 2640 xfer->local_port, peer_connection->clientip); |
| 2641 | |
| 2642 if(peer_connection->conn) | |
| 2643 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, | |
| 2644 peer_connection->conn); | |
| 11369 | 2645 else |
| 13252 | 2646 gaim_debug_info("oscar","NULL peer_connection->conn; not adding watcher\n"); |
| 12653 | 2647 |
| 11369 | 2648 oscar_send_file_request(xfer); |
| 2649 } | |
| 2650 | |
|
12909
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2651 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2652 /* |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2653 * Opens a listener socket in preparation for sending a file |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2654 * This is not called if we are using a rendezvous proxy server |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2655 */ |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2656 static void oscar_xfer_init_send(GaimXfer *xfer) |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2657 { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2658 gaim_debug_info("oscar", "AAA - in oscar_xfer_init_send\n"); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2659 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2660 gaim_xfer_ref(xfer); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2661 |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2662 /* Create a listening socket and an associated libfaim conn */ |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2663 if (!gaim_network_listen_range(5190, 5199, SOCK_STREAM, |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2664 oscar_xfer_init_listen_cb, xfer)) { |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2665 gaim_xfer_unref(xfer); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2666 gaim_xfer_cancel_local(xfer); |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2667 return; |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2668 } |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2669 } |
|
8e3b85fe4a55
[gaim-migrate @ 15262]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12816
diff
changeset
|
2670 |
| 11369 | 2671 /* |
| 2672 * "On second thought, you don't deserve this file." | |
| 2673 */ | |
| 8446 | 2674 static void oscar_xfer_cancel_send(GaimXfer *xfer) |
| 2675 { | |
| 13252 | 2676 PeerConnection *peer_connection = xfer->data; |
| 2677 GaimConnection *gc = peer_connection->sess->aux_data; | |
| 8446 | 2678 OscarData *od = gc->proto_data; |
| 2679 | |
| 8660 | 2680 gaim_debug_info("oscar", "AAA - in oscar_xfer_cancel_send\n"); |
| 8446 | 2681 |
| 9771 | 2682 if (gaim_xfer_get_status(xfer) != GAIM_XFER_STATUS_CANCEL_REMOTE) |
| 13252 | 2683 aim_im_sendch2_sendfile_cancel(peer_connection->sess, peer_connection); |
| 8446 | 2684 |
| 11369 | 2685 /* Added a few sanity checks to prevent segfaulting */ |
| 13252 | 2686 if(peer_connection) { |
| 2687 if(peer_connection->sess && peer_connection->conn) | |
| 2688 aim_conn_kill(peer_connection->sess, &peer_connection->conn); | |
| 2689 aim_oft_destroyinfo(peer_connection); | |
| 11369 | 2690 } |
| 8446 | 2691 xfer->data = NULL; |
| 2692 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | |
| 2693 } | |
| 2694 | |
| 11369 | 2695 /* |
| 2696 * Called when we send some data to the other client | |
| 2697 */ | |
| 11159 | 2698 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
| 8446 | 2699 { |
| 13252 | 2700 PeerConnection *peer_connection = xfer->data; |
| 8446 | 2701 |
| 2702 /* I'm not sure I like how we do this. --marv | |
| 2703 * I do. AIM file transfers aren't really meant to be thought | |
| 2704 * of as a transferring just a single file. The rendezvous | |
| 2705 * establishes a connection between two computers, and then | |
| 2706 * those computers can use the same connection for transferring | |
| 2707 * multiple files. So we don't want the Gaim core up and closing | |
| 2708 * the socket all willy-nilly. We want to do that in the oscar | |
| 2709 * prpl, whenever one side or the other says they're finished | |
| 2710 * using the connection. There might be a better way to intercept | |
| 2711 * the socket from the core, however... --KingAnt | |
| 2712 */ | |
| 2713 | |
| 2714 /* | |
| 2715 * If we're done sending, intercept the socket from the core ft code | |
| 2716 * and wait for the other guy to send the "done" OFT packet. | |
| 2717 */ | |
| 2718 if (gaim_xfer_get_bytes_remaining(xfer) <= 0) { | |
| 2719 gaim_input_remove(xfer->watcher); | |
| 13252 | 2720 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); |
| 8446 | 2721 xfer->fd = 0; |
| 2722 gaim_xfer_set_completed(xfer, TRUE); | |
| 2723 } | |
| 2724 } | |
| 2725 | |
| 11369 | 2726 /* |
| 2727 * Called by the Gaim core to determine whether or not we're allowed to send a file | |
| 2728 * to this user. | |
| 2729 */ | |
| 9466 | 2730 static gboolean oscar_can_receive_file(GaimConnection *gc, const char *who) { |
| 2731 OscarData *od = gc->proto_data; | |
| 2732 | |
| 11049 | 2733 if (od != NULL) { |
| 9466 | 2734 aim_userinfo_t *userinfo; |
| 2735 userinfo = aim_locate_finduserinfo(od->sess, who); | |
| 12714 | 2736 |
| 2737 /* | |
| 2738 * Don't allowing sending a file to a user that does not support | |
| 2739 * file transfer, and don't allow sending to ourselves. | |
| 2740 */ | |
| 2741 if (userinfo && (userinfo->capabilities & AIM_CAPS_SENDFILE) && | |
| 12723 | 2742 aim_sncmp(who, gaim_account_get_username(gaim_connection_get_account(gc)))) |
| 12714 | 2743 { |
| 2744 return TRUE; | |
| 2745 } | |
| 13071 | 2746 |
| 12714 | 2747 } |
| 2748 | |
| 2749 return FALSE; | |
| 9466 | 2750 } |
| 2751 | |
|
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2752 static GaimXfer* |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2753 oscar_new_xfer(GaimConnection *gc, const char *who) { |
| 9030 | 2754 OscarData *od; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
2755 GaimXfer *xfer; |
| 13252 | 2756 PeerConnection *peer_connection; |
|
8231
f50c059b6384
[gaim-migrate @ 8954]
Christian Hammond <chipx86@chipx86.com>
parents:
8227
diff
changeset
|
2757 const char *ip; |
| 11369 | 2758 gboolean use_rv_proxy; |
| 2759 | |
| 2760 use_rv_proxy = gaim_prefs_get_bool("/plugins/prpl/oscar/use_rv_proxy"); | |
| 11401 | 2761 if(use_rv_proxy) |
| 11369 | 2762 gaim_debug_info("oscar","using stage 1 proxied transfer\n"); |
| 11401 | 2763 |
| 9030 | 2764 od = (OscarData *)gc->proto_data; |
| 2765 | |
| 4617 | 2766 /* You want to send a file to someone else, you're so generous */ |
| 2767 | |
| 2768 /* Build the file transfer handle */ | |
| 9466 | 2769 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); |
| 4617 | 2770 |
| 5146 | 2771 /* Create the oscar-specific data */ |
| 11369 | 2772 if (use_rv_proxy) { |
| 2773 /* This hostname will be resolved by gaim_proxy_connect */ | |
| 2774 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
| 2775 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 13252 | 2776 peer_connection = aim_oft_createinfo(od->sess, NULL /*cookie*/, who, 0 /*ip*/, 0, 0, 0, NULL, |
| 11369 | 2777 AIM_XFER_SEND, AIM_XFER_PROXY, AIM_XFER_PROXY_STG1); |
| 13252 | 2778 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, NULL, 0); |
| 11369 | 2779 /* We must create a cookie before the request is sent |
|
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2780 * so that it can be sent to the proxy */ |
| 13252 | 2781 aim_icbm_makecookie(peer_connection->cookie); |
| 11369 | 2782 } else { |
| 2783 ip = gaim_network_get_my_ip(od->conn ? od->conn->fd : -1); | |
| 13252 | 2784 peer_connection = aim_oft_createinfo(od->sess, NULL, who, ip, 0, 0, 0, NULL, |
| 11369 | 2785 AIM_XFER_SEND, AIM_XFER_DIRECT, AIM_XFER_PROXY_NONE); |
| 2786 } | |
| 13252 | 2787 xfer->data = peer_connection; |
| 5146 | 2788 |
| 11369 | 2789 /* Setup our I/O op functions */ |
| 2790 if (use_rv_proxy) | |
| 11399 | 2791 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
| 11369 | 2792 else |
| 2793 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_send); | |
| 4617 | 2794 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
|
4675
3145c5c45877
[gaim-migrate @ 4986]
Christian Hammond <chipx86@chipx86.com>
parents:
4666
diff
changeset
|
2795 gaim_xfer_set_cancel_send_fnc(xfer, oscar_xfer_cancel_send); |
| 8446 | 2796 gaim_xfer_set_request_denied_fnc(xfer, oscar_xfer_cancel_send); |
| 2797 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_send); | |
| 4617 | 2798 |
| 2799 /* Keep track of this transfer for later */ | |
| 2800 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
| 2801 | |
|
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2802 return xfer; |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2803 } |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2804 |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2805 /* |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2806 * Called by the Gaim core when the user indicates that a file is to be sent to |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2807 * a special someone. |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2808 */ |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2809 static void oscar_send_file(GaimConnection *gc, const char *who, const char *file) { |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2810 GaimXfer *xfer = oscar_new_xfer(gc, who); |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
2811 |
| 4617 | 2812 /* Now perform the request */ |
| 9466 | 2813 if (file) |
| 2814 gaim_xfer_request_accepted(xfer, file); | |
| 2815 else | |
| 2816 gaim_xfer_request(xfer); | |
| 3630 | 2817 } |
| 2818 | |
| 13239 | 2819 static int gaim_parse_auth_resp(OscarSession *sess, FlapFrame *fr, ...) { |
| 6029 | 2820 GaimConnection *gc = sess->aux_data; |
| 7283 | 2821 OscarData *od = gc->proto_data; |
| 6029 | 2822 GaimAccount *account = gc->account; |
| 13239 | 2823 OscarConnection *bosconn; |
| 6029 | 2824 char *host; int port; |
| 2825 int i, rc; | |
| 2086 | 2826 va_list ap; |
| 2704 | 2827 struct aim_authresp_info *info; |
| 6029 | 2828 |
| 11338 | 2829 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
| 2086 | 2830 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2831 va_start(ap, fr); |
| 2704 | 2832 info = va_arg(ap, struct aim_authresp_info *); |
| 2086 | 2833 va_end(ap); |
| 2834 | |
| 8660 | 2835 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2836 "inside auth_resp (Screen name: %s)\n", info->sn); |
| 2704 | 2837 |
| 4293 | 2838 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
| 4056 | 2839 char buf[256]; |
| 2704 | 2840 switch (info->errorcode) { |
| 2086 | 2841 case 0x05: |
| 2842 /* Incorrect nick/password */ | |
| 6498 | 2843 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2844 gaim_connection_error(gc, _("Incorrect nickname or password.")); |
| 2086 | 2845 break; |
| 2846 case 0x11: | |
| 2847 /* Suspended account */ | |
| 6498 | 2848 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2849 gaim_connection_error(gc, _("Your account is currently suspended.")); |
| 2086 | 2850 break; |
| 3498 | 2851 case 0x14: |
| 2852 /* service temporarily unavailable */ | |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2853 gaim_connection_error(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); |
| 3498 | 2854 break; |
| 2086 | 2855 case 0x18: |
| 2856 /* connecting too frequently */ | |
| 6498 | 2857 gc->wants_to_die = TRUE; |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2858 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 | 2859 break; |
| 2860 case 0x1c: | |
| 2861 /* client too old */ | |
| 6498 | 2862 gc->wants_to_die = TRUE; |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
2863 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
|
2864 gaim_connection_error(gc, buf); |
| 2086 | 2865 break; |
| 2866 default: | |
| 6623 | 2867 gaim_connection_error(gc, _("Authentication failed")); |
| 2086 | 2868 break; |
| 2869 } | |
| 13226 | 2870 gaim_debug_error("oscar", "Login Error Code 0x%04hx\n", info->errorcode); |
| 2871 gaim_debug_error("oscar", "Error URL: %s\n", info->errorurl); | |
| 2086 | 2872 od->killme = TRUE; |
| 2873 return 1; | |
| 2874 } | |
| 2875 | |
| 2876 | |
| 9992 | 2877 gaim_debug_misc("oscar", "Reg status: %hu\n", info->regstatus); |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2878 |
| 2704 | 2879 if (info->email) { |
| 8660 | 2880 gaim_debug_misc("oscar", "Email: %s\n", info->email); |
| 2086 | 2881 } else { |
| 8660 | 2882 gaim_debug_misc("oscar", "Email is NULL\n"); |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
2883 } |
| 13226 | 2884 |
| 8660 | 2885 gaim_debug_misc("oscar", "BOSIP: %s\n", info->bosip); |
| 13226 | 2886 gaim_debug_info("oscar", "Closing auth connection...\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2887 aim_conn_kill(sess, &fr->conn); |
| 2086 | 2888 |
| 11162 | 2889 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS); |
| 2086 | 2890 if (bosconn == NULL) { |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2891 gaim_connection_error(gc, _("Internal Error")); |
| 2086 | 2892 od->killme = TRUE; |
| 2893 return 0; | |
| 2894 } | |
| 2895 | |
| 4649 | 2896 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 2897 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
| 2086 | 2898 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
| 2899 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
| 13234 | 2900 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_REDIRECT, gaim_handle_redirect, 0); |
| 2901 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_RIGHTSINFO, gaim_parse_locaterights, 0); | |
| 2902 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_RIGHTSINFO, gaim_parse_buddyrights, 0); | |
| 2903 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_ONCOMING, gaim_parse_oncoming, 0); | |
| 2904 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_BUDDY, OSCAR_SUBTYPE_BUDDY_OFFGOING, gaim_parse_offgoing, 0); | |
| 2905 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_INCOMING, gaim_parse_incoming_im, 0); | |
| 2906 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_ERROR, gaim_parse_locerr, 0); | |
| 2907 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_MISSEDCALL, gaim_parse_misses, 0); | |
| 2908 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_CLIENTAUTORESP, gaim_parse_clientauto, 0); | |
| 2909 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_RATECHANGE, gaim_parse_ratechange, 0); | |
| 2910 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_EVIL, gaim_parse_evilnotify, 0); | |
| 2911 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_USERLOOKUP, OSCAR_SUBTYPE_USERLOOKUP_ERROR, gaim_parse_searcherror, 0); | |
| 2912 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_USERLOOKUP, 0x0003, gaim_parse_searchreply, 0); | |
| 2913 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_ERROR, gaim_parse_msgerr, 0); | |
| 2914 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_MTN, gaim_parse_mtn, 0); | |
| 2915 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_USERINFO, gaim_parse_userinfo, 0); | |
| 2916 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_REQUESTINFOTIMEOUT, gaim_reqinfo_timeout, 0); | |
| 2917 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_LOCATE, OSCAR_SUBTYPE_LOCATE_GOTINFOBLOCK, gaim_got_infoblock, 0); | |
| 2918 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICBM, OSCAR_SUBTYPE_ICBM_ACK, gaim_parse_msgack, 0); | |
| 2919 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_OSERVICE, OSCAR_SUBTYPE_OSERVICE_MOTD, gaim_parse_motd, 0); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2920 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
| 2086 | 2921 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
| 2922 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
| 2923 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
| 2924 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
2925 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
| 5844 | 2926 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0021, oscar_icon_req,0); |
| 13234 | 2927 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
| 2928 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); | |
| 2929 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_POPUP, 0x0002, gaim_popup, 0); | |
| 2930 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_ALIAS, gaim_icqalias, 0); | |
| 2931 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_INFO, gaim_icqinfo, 0); | |
| 2932 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ERROR, gaim_ssi_parseerr, 0); | |
| 2933 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RIGHTSINFO, gaim_ssi_parserights, 0); | |
| 2934 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_LIST, gaim_ssi_parselist, 0); | |
| 2935 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_NOLIST, gaim_ssi_parselist, 0); | |
| 2936 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_SRVACK, gaim_ssi_parseack, 0); | |
| 2937 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ADD, gaim_ssi_parseadd, 0); | |
| 2938 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTH, gaim_ssi_authgiven, 0); | |
| 2939 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
| 2940 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_RECVAUTHREP, gaim_ssi_authreply, 0); | |
| 2941 aim_conn_addhandler(sess, bosconn, OSCAR_FAMILY_FEEDBAG, OSCAR_SUBTYPE_FEEDBAG_ADDED, gaim_ssi_gotadded, 0); | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2942 |
| 7283 | 2943 od->conn = bosconn; |
| 2704 | 2944 for (i = 0; i < (int)strlen(info->bosip); i++) { |
| 2945 if (info->bosip[i] == ':') { | |
| 2946 port = atoi(&(info->bosip[i+1])); | |
| 2086 | 2947 break; |
| 2948 } | |
| 2949 } | |
| 2704 | 2950 host = g_strndup(info->bosip, i); |
| 2086 | 2951 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2952 rc = gaim_proxy_connect(gc->account, host, port, oscar_bos_connect, gc); |
| 2086 | 2953 g_free(host); |
| 4366 | 2954 if (rc < 0) { |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
2955 gaim_connection_error(gc, _("Could Not Connect")); |
| 2086 | 2956 od->killme = TRUE; |
| 2957 return 0; | |
| 2958 } | |
| 4293 | 2959 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2960 gaim_input_remove(gc->inpa); |
| 2704 | 2961 |
| 7283 | 2962 gaim_connection_update_progress(gc, _("Received authorization"), 3, OSCAR_CONNECT_STEPS); |
| 8341 | 2963 ck[3] = 0x64; |
| 7282 | 2964 |
| 2086 | 2965 return 1; |
| 2966 } | |
| 2967 | |
| 10464 | 2968 static void |
| 2969 gaim_parse_auth_securid_request_yes_cb(gpointer user_data, const char *msg) | |
| 2970 { | |
| 2971 GaimConnection *gc = user_data; | |
| 2972 OscarData *od = gc->proto_data; | |
| 13239 | 2973 OscarSession *sess = od->sess; |
| 10464 | 2974 |
| 2975 aim_auth_securid_send(sess, msg); | |
| 2976 } | |
| 2977 | |
| 2978 static void | |
| 2979 gaim_parse_auth_securid_request_no_cb(gpointer user_data, const char *value) | |
| 2980 { | |
| 2981 GaimConnection *gc = user_data; | |
| 2982 OscarData *od = gc->proto_data; | |
| 2983 | |
| 2984 /* Disconnect */ | |
| 2985 gc->wants_to_die = TRUE; | |
| 2986 gaim_connection_error(gc, _("The SecurID key entered is invalid.")); | |
| 2987 od->killme = TRUE; | |
| 2988 } | |
| 2989 | |
| 2990 static int | |
| 13239 | 2991 gaim_parse_auth_securid_request(OscarSession *sess, FlapFrame *fr, ...) |
| 10464 | 2992 { |
| 2993 GaimConnection *gc = sess->aux_data; | |
| 2994 GaimAccount *account = gaim_connection_get_account(gc); | |
| 2995 gchar *primary; | |
| 2996 | |
| 2997 gaim_debug_info("oscar", "Got SecurID request\n"); | |
| 2998 | |
| 2999 primary = g_strdup_printf("Enter the SecurID key for %s.", gaim_account_get_username(account)); | |
| 3000 gaim_request_input(gc, NULL, _("Enter SecurID"), primary, | |
| 3001 _("Enter the 6 digit number from the digital display."), | |
| 3002 FALSE, FALSE, NULL, | |
| 3003 _("OK"), G_CALLBACK(gaim_parse_auth_securid_request_yes_cb), | |
| 3004 _("Cancel"), G_CALLBACK(gaim_parse_auth_securid_request_no_cb), | |
| 3005 gc); | |
| 3006 g_free(primary); | |
| 3007 | |
| 3008 return 1; | |
| 3009 } | |
| 3010 | |
| 7285 | 3011 /* XXX - Should use gaim_url_fetch for the below stuff */ |
| 2086 | 3012 struct pieceofcrap { |
| 5575 | 3013 GaimConnection *gc; |
| 2086 | 3014 unsigned long offset; |
| 3015 unsigned long len; | |
| 3016 char *modname; | |
| 3017 int fd; | |
| 13239 | 3018 OscarConnection *conn; |
| 2086 | 3019 unsigned int inpa; |
| 3020 }; | |
| 3021 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3022 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
| 2086 | 3023 { |
| 3024 struct pieceofcrap *pos = data; | |
| 7283 | 3025 OscarData *od = pos->gc->proto_data; |
| 2086 | 3026 char in = '\0'; |
| 3027 int x = 0; | |
| 3028 unsigned char m[17]; | |
| 3029 | |
| 3030 while (read(pos->fd, &in, 1) == 1) { | |
| 3031 if (in == '\n') | |
| 3032 x++; | |
| 3033 else if (in != '\r') | |
| 3034 x = 0; | |
| 3035 if (x == 2) | |
| 3036 break; | |
| 3037 in = '\0'; | |
| 3038 } | |
| 3039 if (in != '\n') { | |
| 4056 | 3040 char buf[256]; |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3041 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
|
3042 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3043 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 3044 _("Gaim was unable to get a valid AIM login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3045 buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3046 gaim_input_remove(pos->inpa); |
| 2086 | 3047 close(pos->fd); |
| 3048 g_free(pos); | |
| 3049 return; | |
| 3050 } | |
| 3051 read(pos->fd, m, 16); | |
| 3052 m[16] = '\0'; | |
| 8660 | 3053 gaim_debug_misc("oscar", "Sending hash: "); |
| 2086 | 3054 for (x = 0; x < 16; x++) |
| 8660 | 3055 gaim_debug_misc(NULL, "%02hhx ", (unsigned char)m[x]); |
| 3056 | |
| 3057 gaim_debug_misc(NULL, "\n"); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3058 gaim_input_remove(pos->inpa); |
| 2086 | 3059 close(pos->fd); |
| 3060 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
| 3061 g_free(pos); | |
| 3062 } | |
| 3063 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3064 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
| 2086 | 3065 struct pieceofcrap *pos = data; |
| 5420 | 3066 gchar *buf; |
| 2086 | 3067 |
| 4366 | 3068 pos->fd = source; |
| 3069 | |
| 2086 | 3070 if (source < 0) { |
| 5420 | 3071 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
|
3072 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3073 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 3074 _("Gaim was unable to get a valid AIM login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3075 buf); |
| 5420 | 3076 g_free(buf); |
| 2086 | 3077 if (pos->modname) |
| 3078 g_free(pos->modname); | |
| 3079 g_free(pos); | |
| 3080 return; | |
| 3081 } | |
| 3082 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3083 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3084 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3085 |
| 5420 | 3086 buf = g_strdup_printf("GET " AIMHASHDATA "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", |
| 2086 | 3087 pos->offset, pos->len, pos->modname ? pos->modname : ""); |
| 3088 write(pos->fd, buf, strlen(buf)); | |
| 5420 | 3089 g_free(buf); |
| 2086 | 3090 if (pos->modname) |
| 3091 g_free(pos->modname); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3092 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
| 2086 | 3093 return; |
| 3094 } | |
| 3095 | |
| 3096 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
| 3097 #define AIM_MAX_FILE_SIZE 98304 | |
| 3098 | |
| 13239 | 3099 int gaim_memrequest(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 3100 va_list ap; |
| 3101 struct pieceofcrap *pos; | |
| 13234 | 3102 guint32 offset, len; |
| 2086 | 3103 char *modname; |
| 3104 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3105 va_start(ap, fr); |
| 13234 | 3106 offset = va_arg(ap, guint32); |
| 3107 len = va_arg(ap, guint32); | |
| 2086 | 3108 modname = va_arg(ap, char *); |
| 3109 va_end(ap); | |
| 3110 | |
| 13226 | 3111 gaim_debug_misc("oscar", "offset: %u, len: %u, file: %s\n", |
| 3112 offset, len, (modname ? modname : "aim.exe")); | |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3113 |
| 2086 | 3114 if (len == 0) { |
| 8660 | 3115 gaim_debug_misc("oscar", "len is 0, hashing NULL\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3116 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
| 2086 | 3117 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
| 3118 return 1; | |
| 3119 } | |
| 9625 | 3120 /* uncomment this when you're convinced it's right. remember, it's been wrong before. */ |
| 3121 #if 0 | |
| 2086 | 3122 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { |
| 3123 char *buf; | |
| 3124 int i = 8; | |
| 3125 if (modname) | |
| 3126 i += strlen(modname); | |
| 3127 buf = g_malloc(i); | |
| 3128 i = 0; | |
| 3129 if (modname) { | |
| 3130 memcpy(buf, modname, strlen(modname)); | |
| 3131 i += strlen(modname); | |
| 3132 } | |
| 3133 buf[i++] = offset & 0xff; | |
| 3134 buf[i++] = (offset >> 8) & 0xff; | |
| 3135 buf[i++] = (offset >> 16) & 0xff; | |
| 3136 buf[i++] = (offset >> 24) & 0xff; | |
| 3137 buf[i++] = len & 0xff; | |
| 3138 buf[i++] = (len >> 8) & 0xff; | |
| 3139 buf[i++] = (len >> 16) & 0xff; | |
| 3140 buf[i++] = (len >> 24) & 0xff; | |
| 8660 | 3141 gaim_debug_misc("oscar", "len + offset is invalid, " |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3142 "hashing request\n"); |
| 2086 | 3143 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
| 3144 g_free(buf); | |
| 3145 return 1; | |
| 3146 } | |
| 9625 | 3147 #endif |
| 2086 | 3148 |
| 3149 pos = g_new0(struct pieceofcrap, 1); | |
| 3150 pos->gc = sess->aux_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3151 pos->conn = fr->conn; |
| 2086 | 3152 |
| 3153 pos->offset = offset; | |
| 3154 pos->len = len; | |
| 3155 pos->modname = modname ? g_strdup(modname) : NULL; | |
| 3156 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3157 if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, straight_to_hell, pos) != 0) { |
| 4056 | 3158 char buf[256]; |
| 2086 | 3159 if (pos->modname) |
| 3160 g_free(pos->modname); | |
| 3161 g_free(pos); | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3162 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
|
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
3163 "this is fixed. Check %s for updates."), GAIM_WEBSITE); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3164 gaim_notify_warning(pos->gc, NULL, |
| 7422 | 3165 _("Gaim was unable to get a valid login hash."), |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
3166 buf); |
| 2086 | 3167 } |
| 3168 | |
| 3169 return 1; | |
| 3170 } | |
| 3171 | |
| 13239 | 3172 static int gaim_parse_login(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3173 GaimConnection *gc = sess->aux_data; |
|
5591
74a0e79ad627
[gaim-migrate @ 5995]
Christian Hammond <chipx86@chipx86.com>
parents:
5580
diff
changeset
|
3174 GaimAccount *account = gaim_connection_get_account(gc); |
| 13239 | 3175 ClientInfo info = CLIENTINFO_GAIM; |
| 7011 | 3176 va_list ap; |
| 3177 char *key; | |
| 2086 | 3178 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3179 va_start(ap, fr); |
| 2086 | 3180 key = va_arg(ap, char *); |
| 3181 va_end(ap); | |
| 3182 | |
| 12049 | 3183 aim_send_login(sess, fr->conn, gaim_account_get_username(account), |
| 3184 gaim_connection_get_password(gc), &info, key); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3185 |
| 7283 | 3186 gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS); |
| 8341 | 3187 ck[2] = 0x6c; |
| 7282 | 3188 |
| 2086 | 3189 return 1; |
| 3190 } | |
| 3191 | |
| 13239 | 3192 static int conninitdone_chat(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3193 GaimConnection *gc = sess->aux_data; |
| 2647 | 3194 struct chat_connection *chatcon; |
| 3195 static int id = 1; | |
| 3196 | |
| 13234 | 3197 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, 0x0001, gaim_parse_genericerr, 0); |
| 3198 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_USERJOIN, gaim_conv_chat_join, 0); | |
| 3199 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_USERLEAVE, gaim_conv_chat_leave, 0); | |
| 3200 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_ROOMINFOUPDATE, gaim_conv_chat_info_update, 0); | |
| 3201 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHAT, OSCAR_SUBTYPE_CHAT_INCOMINGMSG, gaim_conv_chat_incoming_msg, 0); | |
| 2675 | 3202 |
| 2672 | 3203 aim_clientready(sess, fr->conn); |
| 2675 | 3204 |
| 2647 | 3205 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
| 3206 chatcon->id = id; | |
| 8733 | 3207 chatcon->conv = serv_got_joined_chat(gc, id++, chatcon->show); |
| 2647 | 3208 |
| 3209 return 1; | |
| 3210 } | |
| 3211 | |
| 13239 | 3212 static int conninitdone_chatnav(OscarSession *sess, FlapFrame *fr, ...) { |
| 2675 | 3213 |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3214 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
| 13234 | 3215 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_CHATNAV, OSCAR_SUBTYPE_CHATNAV_INFO, gaim_chatnav_info, 0); |
| 2675 | 3216 |
| 3217 aim_clientready(sess, fr->conn); | |
| 3218 | |
| 3219 aim_chatnav_reqrights(sess, fr->conn); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3220 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3221 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3222 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3223 |
| 13239 | 3224 static int conninitdone_email(OscarSession *sess, FlapFrame *fr, ...) { |
| 3694 | 3225 |
| 3226 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
| 13234 | 3227 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ALERT, OSCAR_SUBTYPE_ALERT_MAILSTATUS, gaim_email_parseupdate, 0); |
| 3694 | 3228 |
| 7282 | 3229 aim_email_sendcookies(sess); |
| 3230 aim_email_activate(sess); | |
| 3694 | 3231 aim_clientready(sess, fr->conn); |
| 3232 | |
| 3233 return 1; | |
| 3234 } | |
| 3235 | |
| 13239 | 3236 static int conninitdone_icon(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3237 GaimConnection *gc = sess->aux_data; |
| 7283 | 3238 OscarData *od = gc->proto_data; |
| 4804 | 3239 |
| 3240 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
| 13234 | 3241 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_BART, OSCAR_SUBTYPE_BART_ERROR, gaim_icon_error, 0); |
| 3242 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_BART, OSCAR_SUBTYPE_BART_RESPONSE, gaim_icon_parseicon, 0); | |
| 4804 | 3243 |
| 3244 aim_clientready(sess, fr->conn); | |
| 3245 | |
| 4823 | 3246 od->iconconnecting = FALSE; |
| 3247 | |
| 4804 | 3248 if (od->icontimer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3249 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3250 od->icontimer = gaim_timeout_add(100, gaim_icon_timerfunc, gc); |
| 4804 | 3251 |
| 3252 return 1; | |
| 3253 } | |
| 3254 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3255 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 3256 GaimConnection *gc = data; |
| 7283 | 3257 OscarData *od; |
| 13239 | 3258 OscarSession *sess; |
| 3259 OscarConnection *tstconn; | |
| 2086 | 3260 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3261 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 3262 close(source); |
| 3263 return; | |
| 3264 } | |
| 3265 | |
| 4617 | 3266 od = gc->proto_data; |
| 3267 sess = od->sess; | |
| 2086 | 3268 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); |
| 4366 | 3269 tstconn->fd = source; |
| 2086 | 3270 |
| 3271 if (source < 0) { | |
| 3272 aim_conn_kill(sess, &tstconn); | |
| 13226 | 3273 gaim_debug_error("oscar", "unable to connect to chatnav server\n"); |
| 2086 | 3274 return; |
| 3275 } | |
| 3276 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3277 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3278 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3279 |
| 2086 | 3280 aim_conn_completeconnect(sess, tstconn); |
| 4617 | 3281 od->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 8660 | 3282 gaim_debug_info("oscar", "chatnav: connected\n"); |
| 2086 | 3283 } |
| 3284 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3285 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 3286 { |
| 5575 | 3287 GaimConnection *gc = data; |
| 7283 | 3288 OscarData *od; |
| 13239 | 3289 OscarSession *sess; |
| 3290 OscarConnection *tstconn; | |
| 2086 | 3291 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3292 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 3293 close(source); |
| 3294 return; | |
| 3295 } | |
| 3296 | |
| 4617 | 3297 od = gc->proto_data; |
| 3298 sess = od->sess; | |
| 2086 | 3299 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); |
| 4366 | 3300 tstconn->fd = source; |
| 2086 | 3301 |
| 3302 if (source < 0) { | |
| 3303 aim_conn_kill(sess, &tstconn); | |
| 13226 | 3304 gaim_debug_error("oscar", "unable to connect to authorizer\n"); |
| 2086 | 3305 return; |
| 3306 } | |
| 3307 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3308 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3309 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3310 |
| 2086 | 3311 aim_conn_completeconnect(sess, tstconn); |
| 4617 | 3312 od->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 8660 | 3313 gaim_debug_info("oscar", "admin: connected\n"); |
| 2086 | 3314 } |
| 3315 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
3316 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 3317 { |
| 3318 struct chat_connection *ccon = data; | |
| 5575 | 3319 GaimConnection *gc = ccon->gc; |
| 7283 | 3320 OscarData *od; |
| 13239 | 3321 OscarSession *sess; |
| 3322 OscarConnection *tstconn; | |
| 2086 | 3323 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3324 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2086 | 3325 close(source); |
| 3326 g_free(ccon->show); | |
| 3327 g_free(ccon->name); | |
| 3328 g_free(ccon); | |
| 3329 return; | |
| 3330 } | |
| 3331 | |
| 4617 | 3332 od = gc->proto_data; |
| 3333 sess = od->sess; | |
| 2086 | 3334 tstconn = ccon->conn; |
| 4366 | 3335 tstconn->fd = source; |
| 2086 | 3336 |
| 3337 if (source < 0) { | |
| 3338 aim_conn_kill(sess, &tstconn); | |
| 3339 g_free(ccon->show); | |
| 3340 g_free(ccon->name); | |
| 3341 g_free(ccon); | |
| 3342 return; | |
| 3343 } | |
| 3344 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3345 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3346 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3347 |
| 2086 | 3348 aim_conn_completeconnect(sess, ccon->conn); |
| 4617 | 3349 ccon->inpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 3350 od->oscar_chats = g_slist_append(od->oscar_chats, ccon); | |
| 2086 | 3351 } |
| 3352 | |
| 3694 | 3353 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 3354 GaimConnection *gc = data; |
| 7283 | 3355 OscarData *od; |
| 13239 | 3356 OscarSession *sess; |
| 3357 OscarConnection *tstconn; | |
| 3694 | 3358 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3359 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 3694 | 3360 close(source); |
| 3361 return; | |
| 3362 } | |
| 3363 | |
| 4617 | 3364 od = gc->proto_data; |
| 3365 sess = od->sess; | |
| 3694 | 3366 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); |
| 4366 | 3367 tstconn->fd = source; |
| 3694 | 3368 |
| 3369 if (source < 0) { | |
| 3370 aim_conn_kill(sess, &tstconn); | |
| 13226 | 3371 gaim_debug_error("oscar", "unable to connect to email server\n"); |
| 3694 | 3372 return; |
| 3373 } | |
| 3374 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3375 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3376 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3377 |
| 3694 | 3378 aim_conn_completeconnect(sess, tstconn); |
| 4617 | 3379 od->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); |
| 13226 | 3380 gaim_debug_info("oscar", "email: connected\n"); |
| 3694 | 3381 } |
| 3382 | |
| 4804 | 3383 static void oscar_icon_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 5575 | 3384 GaimConnection *gc = data; |
| 7283 | 3385 OscarData *od; |
| 13239 | 3386 OscarSession *sess; |
| 3387 OscarConnection *tstconn; | |
| 4804 | 3388 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
3389 if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 4804 | 3390 close(source); |
| 3391 return; | |
| 3392 } | |
| 3393 | |
| 3394 od = gc->proto_data; | |
| 3395 sess = od->sess; | |
| 3396 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_ICON); | |
| 3397 tstconn->fd = source; | |
| 3398 | |
| 3399 if (source < 0) { | |
| 3400 aim_conn_kill(sess, &tstconn); | |
| 13226 | 3401 gaim_debug_error("oscar", "unable to connect to icon server\n"); |
| 4804 | 3402 return; |
| 3403 } | |
| 3404 | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3405 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3406 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3407 |
| 4804 | 3408 aim_conn_completeconnect(sess, tstconn); |
| 3409 od->icopa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
| 8660 | 3410 gaim_debug_info("oscar", "icon: connected\n"); |
| 4804 | 3411 } |
| 3412 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3413 /* Hrmph. I don't know how to make this look better. --mid */ |
| 13239 | 3414 static int gaim_handle_redirect(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3415 GaimConnection *gc = sess->aux_data; |
| 3416 GaimAccount *account = gaim_connection_get_account(gc); | |
| 13239 | 3417 OscarConnection *tstconn; |
| 4452 | 3418 int i; |
| 2086 | 3419 char *host; |
| 3420 int port; | |
| 4821 | 3421 va_list ap; |
| 3422 struct aim_redirect_data *redir; | |
| 2086 | 3423 |
| 11338 | 3424 port = gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT); |
| 2086 | 3425 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3426 va_start(ap, fr); |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3427 redir = va_arg(ap, struct aim_redirect_data *); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3428 va_end(ap); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3429 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3430 for (i = 0; i < (int)strlen(redir->ip); i++) { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3431 if (redir->ip[i] == ':') { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3432 port = atoi(&(redir->ip[i+1])); |
| 2086 | 3433 break; |
| 3434 } | |
| 3435 } | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3436 host = g_strndup(redir->ip, i); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3437 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3438 switch(redir->group) { |
| 2086 | 3439 case 0x7: /* Authorizer */ |
| 13226 | 3440 gaim_debug_info("oscar", "Reconnecting with authorizor...\n"); |
| 11162 | 3441 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH); |
| 2086 | 3442 if (tstconn == NULL) { |
| 8660 | 3443 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3444 "unable to reconnect with authorizer\n"); |
| 2086 | 3445 g_free(host); |
| 3446 return 1; | |
| 3447 } | |
| 4649 | 3448 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 3449 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
| 2086 | 3450 |
| 3451 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3452 if (gaim_proxy_connect(account, host, port, oscar_auth_connect, gc) != 0) { |
| 2086 | 3453 aim_conn_kill(sess, &tstconn); |
| 8660 | 3454 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3455 "unable to reconnect with authorizer\n"); |
| 2086 | 3456 g_free(host); |
| 3457 return 1; | |
| 3458 } | |
| 4293 | 3459 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 3460 break; |
| 3461 | |
| 2086 | 3462 case 0xd: /* ChatNav */ |
| 11162 | 3463 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV); |
| 2086 | 3464 if (tstconn == NULL) { |
| 8660 | 3465 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3466 "unable to connect to chatnav server\n"); |
| 2086 | 3467 g_free(host); |
| 3468 return 1; | |
| 3469 } | |
| 4649 | 3470 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 3471 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
| 2086 | 3472 |
| 3473 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3474 if (gaim_proxy_connect(account, host, port, oscar_chatnav_connect, gc) != 0) { |
| 2086 | 3475 aim_conn_kill(sess, &tstconn); |
| 8660 | 3476 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3477 "unable to connect to chatnav server\n"); |
| 2086 | 3478 g_free(host); |
| 3479 return 1; | |
| 3480 } | |
| 4293 | 3481 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 3482 break; |
| 3483 | |
| 3484 case 0xe: { /* Chat */ | |
| 2086 | 3485 struct chat_connection *ccon; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3486 |
| 11162 | 3487 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT); |
| 2086 | 3488 if (tstconn == NULL) { |
| 8660 | 3489 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3490 "unable to connect to chat server\n"); |
| 2086 | 3491 g_free(host); |
| 3492 return 1; | |
| 3493 } | |
| 3494 | |
| 4649 | 3495 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 2675 | 3496 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
| 3497 | |
| 2086 | 3498 ccon = g_new0(struct chat_connection, 1); |
| 3499 ccon->conn = tstconn; | |
| 3500 ccon->gc = gc; | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3501 ccon->name = g_strdup(redir->chat.room); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3502 ccon->exchange = redir->chat.exchange; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3503 ccon->instance = redir->chat.instance; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
3504 ccon->show = extract_name(redir->chat.room); |
| 4634 | 3505 |
| 2086 | 3506 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3507 if (gaim_proxy_connect(account, host, port, oscar_chat_connect, ccon) != 0) { |
| 2086 | 3508 aim_conn_kill(sess, &tstconn); |
| 8660 | 3509 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3510 "unable to connect to chat server\n"); |
| 2086 | 3511 g_free(host); |
| 3512 g_free(ccon->show); | |
| 3513 g_free(ccon->name); | |
| 3514 g_free(ccon); | |
| 3515 return 1; | |
| 3516 } | |
| 4293 | 3517 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 8660 | 3518 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3519 "Connected to chat room %s exchange %hu\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3520 ccon->name, ccon->exchange); |
| 4194 | 3521 } break; |
| 3694 | 3522 |
| 4804 | 3523 case 0x0010: { /* icon */ |
| 11162 | 3524 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_ICON))) { |
| 8660 | 3525 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3526 "unable to connect to icon server\n"); |
| 4804 | 3527 g_free(host); |
| 3528 return 1; | |
| 3529 } | |
| 3530 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); | |
| 3531 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_icon, 0); | |
| 3532 | |
| 3533 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3534 if (gaim_proxy_connect(account, host, port, oscar_icon_connect, gc) != 0) { |
| 4804 | 3535 aim_conn_kill(sess, &tstconn); |
| 8660 | 3536 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3537 "unable to connect to icon server\n"); |
| 4804 | 3538 g_free(host); |
| 3539 return 1; | |
| 3540 } | |
| 3541 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); | |
| 3542 } break; | |
| 3543 | |
| 3694 | 3544 case 0x0018: { /* email */ |
| 11162 | 3545 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL))) { |
| 8660 | 3546 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3547 "unable to connect to email server\n"); |
| 3694 | 3548 g_free(host); |
| 3549 return 1; | |
| 3550 } | |
| 4649 | 3551 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNERR, gaim_connerr, 0); |
| 3694 | 3552 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); |
| 3553 | |
| 3554 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
3555 if (gaim_proxy_connect(account, host, port, oscar_email_connect, gc) != 0) { |
| 3694 | 3556 aim_conn_kill(sess, &tstconn); |
| 8660 | 3557 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3558 "unable to connect to email server\n"); |
| 3694 | 3559 g_free(host); |
| 3560 return 1; | |
| 3561 } | |
| 4293 | 3562 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 3694 | 3563 } break; |
| 3564 | |
| 2086 | 3565 default: /* huh? */ |
| 8660 | 3566 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3567 "got redirect for unknown service 0x%04hx\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
3568 redir->group); |
| 2086 | 3569 break; |
| 3570 } | |
| 3571 | |
| 3572 g_free(host); | |
| 3573 return 1; | |
| 3574 } | |
| 3575 | |
| 13239 | 3576 static int gaim_parse_oncoming(OscarSession *sess, FlapFrame *fr, ...) |
| 10042 | 3577 { |
| 3578 GaimConnection *gc; | |
| 3579 GaimAccount *account; | |
| 11973 | 3580 GaimPresence *presence; |
| 10042 | 3581 OscarData *od; |
| 4738 | 3582 struct buddyinfo *bi; |
| 2993 | 3583 time_t time_idle = 0, signon = 0; |
| 3584 int type = 0; | |
| 12349 | 3585 gboolean buddy_is_away = FALSE; |
| 3586 const char *status_id; | |
| 3587 gboolean have_status_message = FALSE; | |
| 3588 char *message = NULL; | |
| 2086 | 3589 va_list ap; |
| 4738 | 3590 aim_userinfo_t *info; |
| 10042 | 3591 |
| 3592 gc = sess->aux_data; | |
| 3593 account = gaim_connection_get_account(gc); | |
| 11973 | 3594 presence = gaim_account_get_presence(account); |
| 10042 | 3595 od = gc->proto_data; |
| 4194 | 3596 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3597 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3598 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 3599 va_end(ap); |
| 11973 | 3600 |
| 10130 | 3601 g_return_val_if_fail(info != NULL, 1); |
| 3602 g_return_val_if_fail(info->sn != NULL, 1); | |
| 3603 | |
| 4766 | 3604 if (info->present & AIM_USERINFO_PRESENT_FLAGS) { |
| 3605 if (info->flags & AIM_FLAG_AWAY) | |
| 11369 | 3606 buddy_is_away = TRUE; |
| 3607 } | |
| 2993 | 3608 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
| 11510 | 3609 type = info->icqinfo.status; |
| 3013 | 3610 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
| 3611 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
| 10042 | 3612 buddy_is_away = TRUE; |
| 3013 | 3613 } |
| 2993 | 3614 } |
| 3615 | |
| 12349 | 3616 if (aim_sn_is_icq(info->sn)) { |
| 3617 if (type & AIM_ICQ_STATE_CHAT) | |
| 3618 status_id = OSCAR_STATUS_ID_FREE4CHAT; | |
| 3619 else if (type & AIM_ICQ_STATE_DND) | |
| 3620 status_id = OSCAR_STATUS_ID_DND; | |
| 3621 else if (type & AIM_ICQ_STATE_OUT) | |
| 3622 status_id = OSCAR_STATUS_ID_NA; | |
| 3623 else if (type & AIM_ICQ_STATE_BUSY) | |
| 3624 status_id = OSCAR_STATUS_ID_OCCUPIED; | |
| 3625 else if (type & AIM_ICQ_STATE_AWAY) | |
| 3626 status_id = OSCAR_STATUS_ID_AWAY; | |
| 3627 else if (type & AIM_ICQ_STATE_INVISIBLE) | |
| 3628 status_id = OSCAR_STATUS_ID_INVISIBLE; | |
| 3629 else | |
| 3630 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
| 3631 } else { | |
| 12653 | 3632 if (buddy_is_away) |
| 12349 | 3633 status_id = OSCAR_STATUS_ID_AWAY; |
| 3634 else | |
| 3635 status_id = OSCAR_STATUS_ID_AVAILABLE; | |
| 3636 } | |
| 3637 | |
| 3638 /* | |
| 3639 * Handle the available message. If info->status is NULL then the user | |
| 3640 * may or may not have an available message, so don't do anything. If | |
| 3641 * info->status is set to the empty string, then the user's client DOES | |
| 3642 * support available messages and the user DOES NOT have one set. | |
| 3643 * Otherwise info->status contains the available message. | |
| 3644 */ | |
| 3645 if (info->status != NULL) | |
| 3646 { | |
| 3647 have_status_message = TRUE; | |
| 3648 if (info->status[0] != '\0') | |
| 3649 message = oscar_encoding_to_utf8(info->status_encoding, | |
| 3650 info->status, info->status_len); | |
| 3651 } | |
| 3652 | |
| 3653 if (have_status_message) | |
| 3654 { | |
| 3655 gaim_prpl_got_user_status(account, info->sn, status_id, | |
| 3656 "message", message, NULL); | |
| 3657 g_free(message); | |
| 3658 } | |
| 3659 else | |
| 3660 gaim_prpl_got_user_status(account, info->sn, status_id, NULL); | |
| 3661 | |
| 12350 | 3662 /* Login time stuff */ |
| 5836 | 3663 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
| 3664 signon = info->onlinesince; | |
| 3665 else if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
| 2993 | 3666 signon = time(NULL) - info->sessionlen; |
| 10567 | 3667 if (!aim_sncmp(gaim_account_get_username(account), info->sn)) { |
| 5575 | 3668 gaim_connection_set_display_name(gc, info->sn); |
| 11973 | 3669 od->timeoffset = signon - gaim_presence_get_login_time(presence); |
| 10567 | 3670 } |
| 12350 | 3671 gaim_prpl_got_user_login_time(account, info->sn, signon - od->timeoffset); |
| 3672 | |
| 3673 /* Idle time stuff */ | |
| 3674 /* info->idletime is the number of minutes that this user has been idle */ | |
| 3675 if (info->present & AIM_USERINFO_PRESENT_IDLE) | |
| 3676 time_idle = time(NULL) - info->idletime * 60; | |
| 3677 | |
| 3678 if (time_idle > 0) | |
| 3679 gaim_prpl_got_user_idle(account, info->sn, TRUE, time_idle); | |
| 3680 else | |
| 3681 gaim_prpl_got_user_idle(account, info->sn, FALSE, 0); | |
| 3682 | |
| 3683 /* Server stored icon stuff */ | |
| 9982 | 3684 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, info->sn)); |
| 4738 | 3685 if (!bi) { |
| 3686 bi = g_new0(struct buddyinfo, 1); | |
| 9982 | 3687 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, info->sn)), bi); |
| 4738 | 3688 } |
| 4739 | 3689 bi->typingnot = FALSE; |
| 3690 bi->ico_informed = FALSE; | |
| 6857 | 3691 bi->ipaddr = info->icqinfo.ipaddr; |
| 3692 | |
| 4853 | 3693 if (info->iconcsumlen) { |
| 7125 | 3694 const char *filename = NULL, *saved_b16 = NULL; |
| 9801 | 3695 char *b16 = NULL, *filepath = NULL; |
| 7093 | 3696 GaimBuddy *b = NULL; |
| 4853 | 3697 |
|
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
3698 b16 = gaim_base16_encode(info->iconcsum, info->iconcsumlen); |
| 9982 | 3699 b = gaim_find_buddy(account, info->sn); |
| 7093 | 3700 /* |
| 3701 * If for some reason the checksum is valid, but cached file is not.. | |
| 3702 * we want to know. | |
| 3703 */ | |
| 7693 | 3704 filename = gaim_blist_node_get_string((GaimBlistNode*)b, "buddy_icon"); |
| 7093 | 3705 if (filename != NULL) { |
| 3706 if (g_file_test(filename, G_FILE_TEST_EXISTS)) | |
| 7693 | 3707 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, |
| 3708 "icon_checksum"); | |
| 9801 | 3709 else { |
| 3710 filepath = g_build_filename(gaim_buddy_icons_get_cache_dir(), | |
| 3711 filename, NULL); | |
| 3712 if (g_file_test(filepath, G_FILE_TEST_EXISTS)) | |
| 3713 saved_b16 = gaim_blist_node_get_string((GaimBlistNode*)b, | |
| 3714 "icon_checksum"); | |
| 3715 g_free(filepath); | |
| 3716 } | |
| 7093 | 3717 } else |
| 3718 saved_b16 = NULL; | |
|
7054
7c04a0775918
[gaim-migrate @ 7617]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7045
diff
changeset
|
3719 |
| 4853 | 3720 if (!b16 || !saved_b16 || strcmp(b16, saved_b16)) { |
| 3721 GSList *cur = od->requesticon; | |
| 3722 while (cur && aim_sncmp((char *)cur->data, info->sn)) | |
| 3723 cur = cur->next; | |
| 3724 if (!cur) { | |
| 9982 | 3725 od->requesticon = g_slist_append(od->requesticon, g_strdup(gaim_normalize(account, info->sn))); |
| 4853 | 3726 if (od->icontimer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
3727 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
3728 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
| 4853 | 3729 } |
| 3730 } | |
| 6053 | 3731 g_free(b16); |
| 4853 | 3732 } |
| 3733 | |
| 2086 | 3734 return 1; |
| 3735 } | |
| 3736 | |
| 8341 | 3737 static void gaim_check_comment(OscarData *od, const char *str) { |
| 11159 | 3738 if ((str == NULL) || strcmp(str, (const char *)ck)) |
| 8341 | 3739 aim_locate_setcaps(od->sess, caps_aim); |
| 3740 else | |
| 3741 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | |
| 3742 } | |
| 3743 | |
| 13239 | 3744 static int gaim_parse_offgoing(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3745 GaimConnection *gc = sess->aux_data; |
| 7283 | 3746 OscarData *od = gc->proto_data; |
| 9982 | 3747 GaimAccount *account = gaim_connection_get_account(gc); |
| 2086 | 3748 va_list ap; |
| 4739 | 3749 aim_userinfo_t *info; |
| 2086 | 3750 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3751 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3752 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 3753 va_end(ap); |
| 3754 | |
| 12349 | 3755 gaim_prpl_got_user_status(account, info->sn, OSCAR_STATUS_ID_OFFLINE, NULL); |
| 2086 | 3756 |
| 7261 | 3757 g_hash_table_remove(od->buddyinfo, gaim_normalize(gc->account, info->sn)); |
| 5837 | 3758 |
| 2086 | 3759 return 1; |
| 3760 } | |
| 3761 | |
| 4617 | 3762 /* BBB */ |
| 3952 | 3763 /* |
| 11369 | 3764 * This is called after a remote AIM user has connected to us. |
| 3765 * If not using a rendezvous proxy, then we want to do some | |
| 3766 * voodoo with the socket file descriptors. Then we always | |
| 13239 | 3767 * add a callback or two, and then send the PEER_TYPE_PROMPT. |
| 3952 | 3768 */ |
| 13239 | 3769 static int oscar_sendfile_estblsh(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3770 GaimConnection *gc = sess->aux_data; |
| 7283 | 3771 OscarData *od = (OscarData *)gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3772 GaimXfer *xfer; |
| 13252 | 3773 PeerConnection *peer_connection; |
| 3630 | 3774 va_list ap; |
| 13239 | 3775 OscarConnection *conn, *listenerconn; |
| 4656 | 3776 |
| 11369 | 3777 gaim_debug_info("oscar", "AAA - in oscar_sendfile_estblsh\n"); |
| 13226 | 3778 |
| 3630 | 3779 va_start(ap, fr); |
| 13239 | 3780 conn = va_arg(ap, OscarConnection *); |
| 3781 listenerconn = va_arg(ap, OscarConnection *); | |
| 3630 | 3782 va_end(ap); |
| 3783 | |
| 11369 | 3784 /* Finding by conn will work for proxied connections only |
| 3785 * Finding by listenerconn will work for direct connections only */ | |
| 3786 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { | |
| 3787 if(!(xfer = oscar_find_xfer_by_conn(od->file_transfers, listenerconn))) { | |
| 3788 gaim_debug_warning("oscar","xfer not found via connection\n"); | |
| 3789 return 1; | |
| 3790 } | |
| 3791 } | |
| 13252 | 3792 if (!(peer_connection = xfer->data)) { |
| 11369 | 3793 gaim_debug_warning("oscar","NULL data\n"); |
| 4617 | 3794 return 1; |
| 11369 | 3795 } |
| 13226 | 3796 |
| 11369 | 3797 /* Mark connection as success so further connections aren't attempted |
| 3798 * This is important here since some receive file code paths pass through here */ | |
| 13252 | 3799 peer_connection->success = TRUE; |
| 3800 | |
| 3801 if(peer_connection->method != AIM_XFER_PROXY) { | |
| 11369 | 3802 /* Stop watching listener conn; watch transfer conn instead */ |
| 3803 gaim_input_remove(xfer->watcher); | |
| 13226 | 3804 |
| 11369 | 3805 aim_conn_kill(sess, &listenerconn); |
| 13226 | 3806 |
| 13252 | 3807 peer_connection->conn = conn; |
| 3808 xfer->fd = peer_connection->conn->fd; | |
| 3809 } | |
| 3810 | |
| 3811 xfer->watcher = gaim_input_add(peer_connection->conn->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); | |
| 3812 | |
| 3813 if(peer_connection->send_or_recv == AIM_XFER_SEND) { | |
| 3814 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, | |
| 11369 | 3815 oscar_sendfile_ack, 0); |
| 13252 | 3816 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
| 11369 | 3817 oscar_sendfile_done, 0); |
| 3818 | |
| 3819 /* Inform the other user that we are connected and ready to transfer */ | |
| 13252 | 3820 aim_oft_sendheader(sess, PEER_TYPE_PROMPT, peer_connection); |
| 11369 | 3821 } |
| 13226 | 3822 |
| 11369 | 3823 /* For a file send, we'll hopefully end up in oscar_sendfile_ack next |
| 3824 * For a file receive, oscar_sendfile_prompt */ | |
| 13226 | 3825 |
| 3630 | 3826 return 0; |
| 3827 } | |
| 3828 | |
| 3952 | 3829 /* |
| 13226 | 3830 * This is the gaim callback passed to gaim_proxy_connect when |
| 3831 * connecting to another AIM user in order to transfer a file | |
| 3832 * Takes xfer as data and fd as source | |
| 11369 | 3833 * BBB |
| 3952 | 3834 */ |
| 4617 | 3835 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
|
3836 GaimXfer *xfer; |
| 13252 | 3837 PeerConnection *peer_connection; |
| 4656 | 3838 |
| 13226 | 3839 gaim_debug_info("oscar", "AAA - in oscar_sendfile_connected\n"); |
| 4617 | 3840 if (!(xfer = data)) |
| 3841 return; | |
| 13252 | 3842 if (!(peer_connection = xfer->data)) |
| 3630 | 3843 return; |
| 13252 | 3844 if(peer_connection->success) { |
| 11369 | 3845 gaim_debug_info("oscar","connection already successful; ignoring 2nd conn\n"); |
| 3846 return; | |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3847 } |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3848 |
| 8446 | 3849 if (source < 0) { |
| 11369 | 3850 gaim_debug_info("oscar","received fd of %d; aborting transfer\n", source); |
| 3851 gaim_xfer_cancel_remote(xfer); | |
| 3852 return; | |
| 3853 } | |
| 13252 | 3854 peer_connection->success = TRUE; /* Mark this connection as successful before it times out */ |
|
13200
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3855 |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3856 /* XXX:NBIO remove when nonblocking I/O implemented for oscar */ |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3857 fcntl(source, F_SETFL, 0); |
|
33bef17125c2
[gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13168
diff
changeset
|
3858 |
| 11369 | 3859 /* We might have already set these in oscar_sendfile_proxylogin, but it won't |
| 3860 * hurt to do it again since it is rather necessary */ | |
| 4617 | 3861 xfer->fd = source; |
| 13252 | 3862 peer_connection->conn->fd = source; |
| 3863 | |
| 3864 aim_conn_completeconnect(peer_connection->sess, peer_connection->conn); | |
| 3865 | |
| 3866 xfer->watcher = gaim_input_add(xfer->fd, GAIM_INPUT_READ, oscar_callback, peer_connection->conn); | |
| 4617 | 3867 |
| 11369 | 3868 /* Inform the other user that we are connected and accept the transfer |
| 3869 * Except for a stage 2 receive, then we'll be the ones receiving this accept message */ | |
| 13252 | 3870 if(peer_connection->stage != AIM_XFER_PROXY_STG2) |
| 3871 aim_im_sendch2_sendfile_accept(peer_connection->sess, peer_connection); | |
| 13226 | 3872 |
| 11369 | 3873 /* Don't wait around if this is a redirected send */ |
| 13252 | 3874 if(peer_connection->send_or_recv == AIM_XFER_SEND) { |
| 11369 | 3875 /* We should only get here if this is a redirected file send */ |
| 13252 | 3876 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_ACK, |
| 11369 | 3877 oscar_sendfile_ack, 0); |
| 13252 | 3878 aim_conn_addhandler(peer_connection->sess, peer_connection->conn, AIM_CB_FAM_OFT, PEER_TYPE_DONE, |
| 11369 | 3879 oscar_sendfile_done, 0); |
| 13226 | 3880 |
| 11369 | 3881 /* Inform the other user that we are ready to transfer */ |
| 13252 | 3882 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_PROMPT, peer_connection); |
| 11369 | 3883 } |
| 3630 | 3884 } |
| 3885 | |
| 3952 | 3886 /* |
| 13226 | 3887 * This is called when a buddy sends us some file info. This happens when they |
| 4617 | 3888 * are sending a file to you, and you have just established a connection to them. |
| 13226 | 3889 * You should send them the exact same info except use the real cookie. We also |
| 4617 | 3890 * get like totally ready to like, receive the file, kay? |
| 3952 | 3891 */ |
| 13239 | 3892 static int oscar_sendfile_prompt(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3893 GaimConnection *gc = sess->aux_data; |
| 7283 | 3894 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3895 GaimXfer *xfer; |
| 13252 | 3896 PeerConnection *peer_connection; |
| 4617 | 3897 va_list ap; |
| 13239 | 3898 OscarConnection *conn; |
| 13234 | 3899 guint8 *cookie; |
| 13239 | 3900 PeerFrame *fh; |
| 13226 | 3901 |
| 3902 gaim_debug_info("oscar", "AAA - in oscar_sendfile_prompt\n"); | |
| 3903 | |
| 4617 | 3904 va_start(ap, fr); |
| 13239 | 3905 conn = va_arg(ap, OscarConnection *); |
| 13234 | 3906 cookie = va_arg(ap, guint8 *); |
| 13239 | 3907 fh = va_arg(ap, PeerFrame *); |
| 4617 | 3908 va_end(ap); |
| 3909 | |
| 3910 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) | |
| 3911 return 1; | |
| 3912 | |
| 13252 | 3913 if (!(peer_connection = xfer->data)) |
| 4617 | 3914 return 1; |
| 3915 | |
| 3916 /* We want to stop listening with a normal thingy */ | |
| 3917 gaim_input_remove(xfer->watcher); | |
| 3918 xfer->watcher = 0; | |
| 3919 | |
| 5146 | 3920 /* They sent us some information about the file they're sending */ |
| 13252 | 3921 memcpy(&peer_connection->fh, fh, sizeof(*fh)); |
| 5146 | 3922 |
| 3923 /* Fill in the cookie */ | |
| 13252 | 3924 memcpy(&peer_connection->fh.bcookie, peer_connection->cookie, 8); |
| 5146 | 3925 |
| 4617 | 3926 /* XXX - convert the name from UTF-8 to UCS-2 if necessary, and pass the encoding to the call below */ |
| 13252 | 3927 aim_oft_sendheader(peer_connection->sess, PEER_TYPE_ACK, peer_connection); |
| 4617 | 3928 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
| 3929 | |
| 3930 return 0; | |
| 3630 | 3931 } |
| 3932 | |
| 3952 | 3933 /* |
| 13226 | 3934 * We are sending a file to someone else. They have just acknowledged our |
| 4617 | 3935 * prompt, so we want to start sending data like there's no tomorrow. |
| 3952 | 3936 */ |
| 13239 | 3937 static int oscar_sendfile_ack(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3938 GaimConnection *gc = sess->aux_data; |
| 7283 | 3939 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3940 GaimXfer *xfer; |
| 4617 | 3941 va_list ap; |
| 13239 | 3942 OscarConnection *conn; |
| 13234 | 3943 guint8 *cookie; |
| 13239 | 3944 PeerFrame *fh; |
| 4656 | 3945 |
| 8660 | 3946 gaim_debug_info("oscar", "AAA - in oscar_sendfile_ack\n"); |
| 4617 | 3947 va_start(ap, fr); |
| 13239 | 3948 conn = va_arg(ap, OscarConnection *); |
| 13234 | 3949 cookie = va_arg(ap, guint8 *); |
| 13239 | 3950 fh = va_arg(ap, PeerFrame *); |
| 4617 | 3951 va_end(ap); |
| 3952 | |
| 3953 if (!(xfer = oscar_find_xfer_by_cookie(od->file_transfers, cookie))) | |
| 3954 return 1; | |
| 3955 | |
| 4656 | 3956 /* We want to stop listening with a normal thingy */ |
| 3957 gaim_input_remove(xfer->watcher); | |
| 3958 xfer->watcher = 0; | |
| 3959 | |
| 4617 | 3960 gaim_xfer_start(xfer, xfer->fd, NULL, 0); |
| 3961 | |
| 3962 return 0; | |
| 3630 | 3963 } |
| 4617 | 3964 |
| 3965 /* | |
| 13226 | 3966 * We just sent a file to someone. They said they got it and everything, |
| 4617 | 3967 * so we can close our direct connection and what not. |
| 3968 */ | |
| 13239 | 3969 static int oscar_sendfile_done(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 3970 GaimConnection *gc = sess->aux_data; |
| 7283 | 3971 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
3972 GaimXfer *xfer; |
| 4617 | 3973 va_list ap; |
| 13239 | 3974 OscarConnection *conn; |
| 13234 | 3975 guint8 *cookie; |
| 13239 | 3976 PeerFrame *fh; |
| 13252 | 3977 PeerConnection *peer_connection; |
| 4656 | 3978 |
| 8660 | 3979 gaim_debug_info("oscar", "AAA - in oscar_sendfile_done\n"); |
| 4617 | 3980 va_start(ap, fr); |
| 13239 | 3981 conn = va_arg(ap, OscarConnection *); |
| 13234 | 3982 cookie = va_arg(ap, guint8 *); |
| 13239 | 3983 fh = va_arg(ap, PeerFrame *); |
| 4617 | 3984 va_end(ap); |
| 3985 | |
| 11369 | 3986 if (!(xfer = oscar_find_xfer_by_conn(od->file_transfers, conn))) { |
| 3987 gaim_debug_warning("oscar","xfer not found\n"); | |
| 4617 | 3988 return 1; |
| 11369 | 3989 } |
| 13252 | 3990 if(!(peer_connection = xfer->data)) { |
| 3991 gaim_debug_warning("oscar","NULL peer_connection\n"); | |
| 11369 | 3992 return 1; |
| 3993 } | |
| 3994 if(fh->nrecvd == fh->size) | |
| 3995 gaim_xfer_set_completed(xfer, TRUE); | |
| 4617 | 3996 |
| 4656 | 3997 xfer->fd = conn->fd; |
| 4617 | 3998 gaim_xfer_end(xfer); |
| 3999 | |
| 4000 return 0; | |
| 4001 } | |
| 3630 | 4002 |
| 13239 | 4003 static int incomingim_chan1(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
| 5575 | 4004 GaimConnection *gc = sess->aux_data; |
| 7283 | 4005 OscarData *od = gc->proto_data; |
| 8708 | 4006 GaimAccount *account = gaim_connection_get_account(gc); |
| 12216 | 4007 GaimMessageFlags flags = 0; |
| 4738 | 4008 struct buddyinfo *bi; |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4009 char *iconfile; |
| 9806 | 4010 GString *message; |
| 4011 gchar *tmp; | |
| 4012 aim_mpmsg_section_t *curpart; | |
| 12675 | 4013 const char *start; |
| 4014 const char *end; | |
| 4015 GData *attribs; | |
| 9806 | 4016 |
| 11537 | 4017 gaim_debug_misc("oscar", "Received IM from %s with %d parts\n", |
| 9806 | 4018 userinfo->sn, args->mpmsg.numparts); |
| 4738 | 4019 |
| 10595 | 4020 if (args->mpmsg.numparts == 0) |
| 4021 return 1; | |
| 4022 | |
| 8708 | 4023 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
| 4738 | 4024 if (!bi) { |
| 4025 bi = g_new0(struct buddyinfo, 1); | |
| 8708 | 4026 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
| 4738 | 4027 } |
|
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
4028 |
|
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
4029 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
| 12216 | 4030 flags |= GAIM_MESSAGE_AUTO_RESP; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4031 |
| 4738 | 4032 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
| 4033 bi->typingnot = TRUE; | |
| 4034 else | |
| 4035 bi->typingnot = FALSE; | |
| 4036 | |
| 4380 | 4037 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
| 13226 | 4038 gaim_debug_misc("oscar", "%s has an icon\n", userinfo->sn); |
| 4738 | 4039 if ((args->iconlen != bi->ico_len) || (args->iconsum != bi->ico_csum) || (args->iconstamp != bi->ico_time)) { |
| 4040 bi->ico_need = TRUE; | |
| 4041 bi->ico_len = args->iconlen; | |
| 4042 bi->ico_csum = args->iconsum; | |
| 4043 bi->ico_time = args->iconstamp; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4044 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4045 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4046 |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4047 iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
|
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4048 if ((iconfile != NULL) && |
| 7406 | 4049 (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
|
4050 FILE *file; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4051 struct stat st; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4052 |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4053 if (!g_stat(iconfile, &st)) { |
| 11159 | 4054 guchar *buf = g_malloc(st.st_size); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
4055 file = g_fopen(iconfile, "rb"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4056 if (file) { |
| 9532 | 4057 /* XXX - Use g_file_get_contents() */ |
|
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
4058 int len = fread(buf, 1, st.st_size, file); |
| 8660 | 4059 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4060 "Sending buddy icon to %s (%d bytes, " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4061 "%lu reported)\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4062 userinfo->sn, len, st.st_size); |
| 4617 | 4063 aim_im_sendch2_icon(sess, userinfo->sn, buf, st.st_size, |
| 4064 st.st_mtime, aimutil_iconsum(buf, st.st_size)); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4065 fclose(file); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4066 } else |
| 13226 | 4067 gaim_debug_error("oscar", "Can't open buddy icon file!\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4068 g_free(buf); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
4069 } else |
| 13226 | 4070 gaim_debug_error("oscar", "Can't stat buddy icon file!\n"); |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4071 } |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
4072 g_free(iconfile); |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4073 |
| 9806 | 4074 message = g_string_new(""); |
| 4075 curpart = args->mpmsg.parts; | |
| 4076 while (curpart != NULL) { | |
| 11159 | 4077 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
| 12675 | 4078 curpart->charsubset, curpart->data, curpart->datalen); |
| 9806 | 4079 if (tmp != NULL) { |
| 4080 g_string_append(message, tmp); | |
| 4081 g_free(tmp); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4082 } |
| 9806 | 4083 |
| 4084 curpart = curpart->next; | |
| 4085 } | |
| 4086 tmp = g_string_free(message, FALSE); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4087 |
| 8666 | 4088 /* |
| 10781 | 4089 * If the message is from an ICQ user and to an ICQ user then escape any HTML, |
| 9016 | 4090 * because HTML is not sent over ICQ as a means to format a message. |
| 10781 | 4091 * So any HTML we receive is intended to be displayed. Also, \r\n must be |
| 4092 * replaced with <br> | |
| 8995 | 4093 * |
| 4094 * Note: There *may* be some clients which send messages as HTML formatted - | |
| 4095 * they need to be special-cased somehow. | |
| 8666 | 4096 */ |
| 9982 | 4097 if (aim_sn_is_icq(gaim_account_get_username(account)) && aim_sn_is_icq(userinfo->sn)) { |
| 8995 | 4098 /* being recevied by ICQ from ICQ - escape HTML so it is displayed as sent */ |
|
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
4099 gchar *tmp2 = g_markup_escape_text(tmp, -1); |
| 8493 | 4100 g_free(tmp); |
| 4101 tmp = tmp2; | |
| 10783 | 4102 tmp2 = gaim_strreplace(tmp, "\r\n", "<br>"); |
| 10781 | 4103 g_free(tmp); |
| 4104 tmp = tmp2; | |
| 8493 | 4105 } |
| 4106 | |
| 12675 | 4107 /* |
| 4108 * Convert iChat color tags to normal font tags. | |
| 4109 */ | |
| 4110 if (gaim_markup_find_tag("body", tmp, &start, &end, &attribs)) | |
| 4111 { | |
| 4112 const char *ichattextcolor, *ichatballooncolor; | |
| 4113 | |
| 4114 ichattextcolor = g_datalist_get_data(&attribs, "ichattextcolor"); | |
| 4115 if (ichattextcolor != NULL) | |
| 4116 { | |
| 4117 gchar *tmp2; | |
| 4118 tmp2 = g_strdup_printf("<font color=\"%s\">%s</font>", ichattextcolor, tmp); | |
| 4119 g_free(tmp); | |
| 4120 tmp = tmp2; | |
| 4121 } | |
| 4122 | |
| 4123 ichatballooncolor = g_datalist_get_data(&attribs, "ichatballooncolor"); | |
| 4124 if (ichatballooncolor != NULL) | |
| 4125 { | |
| 4126 gchar *tmp2; | |
| 4127 tmp2 = g_strdup_printf("<font back=\"%s\">%s</font>", ichatballooncolor, tmp); | |
| 4128 g_free(tmp); | |
| 4129 tmp = tmp2; | |
| 4130 } | |
| 4131 | |
| 4132 g_datalist_clear(&attribs); | |
| 4133 } | |
| 4134 | |
| 6982 | 4135 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL)); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4136 g_free(tmp); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4137 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4138 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4139 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4140 |
| 13239 | 4141 static int incomingim_chan2(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
| 9070 | 4142 GaimConnection *gc; |
| 9933 | 4143 GaimAccount *account; |
| 9070 | 4144 OscarData *od; |
| 9933 | 4145 const char *username = NULL; |
| 4146 char *message = NULL; | |
| 9070 | 4147 |
| 4148 g_return_val_if_fail(sess != NULL, 0); | |
| 4149 g_return_val_if_fail(sess->aux_data != NULL, 0); | |
| 4150 | |
| 4151 gc = sess->aux_data; | |
| 9933 | 4152 account = gaim_connection_get_account(gc); |
| 9070 | 4153 od = gc->proto_data; |
| 9933 | 4154 username = gaim_account_get_username(account); |
| 4155 | |
| 4156 if (args == NULL) | |
| 4121 | 4157 return 0; |
| 4194 | 4158 |
| 9933 | 4159 gaim_debug_misc("oscar", "rendezvous with %s, status is %hu\n", |
| 4160 userinfo->sn, args->status); | |
| 4161 | |
| 4162 if (args->msg != NULL) | |
| 4163 { | |
| 4164 if (args->encoding != NULL) | |
| 4165 { | |
| 4166 char *encoding = NULL; | |
| 4167 encoding = oscar_encoding_extract(args->encoding); | |
| 4168 message = oscar_encoding_to_utf8(encoding, args->msg, args->msglen); | |
| 4169 g_free(encoding); | |
| 4170 } else { | |
| 4171 if (g_utf8_validate(args->msg, args->msglen, NULL)) | |
| 4172 message = g_strdup(args->msg); | |
| 4173 } | |
| 4174 } | |
| 2869 | 4175 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4176 if (args->reqclass & AIM_CAPS_CHAT) { |
| 4121 | 4177 char *name; |
| 5234 | 4178 GHashTable *components; |
| 4179 | |
| 9933 | 4180 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) { |
| 4181 g_free(message); | |
| 4121 | 4182 return 1; |
| 9933 | 4183 } |
| 5234 | 4184 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 4185 g_free); | |
| 4121 | 4186 name = extract_name(args->info.chat.roominfo.name); |
| 5234 | 4187 g_hash_table_replace(components, g_strdup("room"), g_strdup(name ? name : args->info.chat.roominfo.name)); |
| 4188 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
|
4189 serv_got_chat_invite(gc, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4190 name ? name : args->info.chat.roominfo.name, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4191 userinfo->sn, |
| 9933 | 4192 message, |
| 5234 | 4193 components); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4194 if (name) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4195 g_free(name); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4196 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
| 4617 | 4197 /* BBB */ |
| 11369 | 4198 /* This is the first sendfile request where we need to notify the user that someone |
| 4199 * wants to send a file */ | |
| 4200 if (args->status == AIM_RENDEZVOUS_PROPOSE | |
| 4201 && (args->info.sendfile.reqnum == 0x0001)) { | |
| 4617 | 4202 /* Someone wants to send a file (or files) to us */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4203 GaimXfer *xfer; |
| 13252 | 4204 PeerConnection *peer_connection; |
| 13239 | 4205 PeerProxyInfo *proxy_info = NULL; |
| 11369 | 4206 gboolean use_rv_proxy; |
| 4207 int proxy_stage; | |
| 4208 int xfer_method; | |
| 4209 const char *proxy_ip = NULL; | |
| 13073 | 4210 |
| 11369 | 4211 if (!args->cookie || !args->port || |
| 13073 | 4212 !args->info.sendfile.filename || !args->info.sendfile.totsize || |
| 4656 | 4213 !args->info.sendfile.totfiles || !args->reqclass) { |
| 8660 | 4214 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4215 "%s tried to send you a file with incomplete " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4216 "information.\n", userinfo->sn); |
| 9933 | 4217 g_free(message); |
| 4617 | 4218 return 1; |
| 4656 | 4219 } |
| 4617 | 4220 |
| 4221 if (args->info.sendfile.subtype == AIM_OFT_SUBTYPE_SEND_DIR) { | |
| 4222 /* 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
|
4223 * directory -- remove the star and trailing slash so we don't save |
| 4617 | 4224 * directories that look like 'dirname\*' -- arl */ |
| 4225 char *tmp = strrchr(args->info.sendfile.filename, '\\'); | |
| 4226 if (tmp && (tmp[1] == '*')) { | |
| 4227 tmp[0] = '\0'; | |
| 4228 } | |
| 8660 | 4229 gaim_debug_warning("oscar", |
| 8446 | 4230 "We're receiving a whole directory! What fun! " |
| 4231 "Especially since we don't support that!\n"); | |
| 4617 | 4232 } |
| 4233 | |
| 4234 /* Build the file transfer handle */ | |
| 4235 xfer = gaim_xfer_new(gc->account, GAIM_XFER_RECEIVE, userinfo->sn); | |
| 13073 | 4236 |
| 11369 | 4237 use_rv_proxy = gaim_prefs_get_bool("/plugins/prpl/oscar/use_rv_proxy"); |
| 13073 | 4238 |
| 11369 | 4239 if(args->info.sendfile.use_proxy) { |
| 4240 /* The sender requested (stage 1) that we use a rendezvous proxy */ | |
| 4241 xfer_method = AIM_XFER_PROXY; | |
| 4242 proxy_stage = AIM_XFER_PROXY_STG1; | |
| 4243 gaim_debug_info("oscar","using stage 1 proxy with ip: %s\n", | |
| 4244 args->proxyip, args->port); | |
| 4245 xfer->remote_ip = g_strdup(args->proxyip); | |
| 4246 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 4247 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, args->port); | |
| 4248 } else if(use_rv_proxy) { | |
| 4249 /* If the local user indicated that a rendezvous proxy is necessary | |
| 4250 * start a stage 2 proxied transfer */ | |
| 4251 gaim_debug_info("oscar","using stage 2 proxied transfer\n"); | |
| 4252 xfer_method = AIM_XFER_PROXY; | |
| 4253 proxy_stage = AIM_XFER_PROXY_STG2; | |
| 4254 /* This hostname will be resolved by gaim_proxy_connect */ | |
| 4255 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
| 4256 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 4257 proxy_info = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); | |
| 4258 } else { | |
| 4259 /* We are receiving a file directly with no rendezvous proxy */ | |
| 4260 xfer_method = AIM_XFER_DIRECT; | |
| 4261 proxy_stage = AIM_XFER_PROXY_NONE; | |
| 4262 xfer->remote_ip = g_strdup(args->clientip); | |
| 4263 xfer->remote_port = args->port; | |
| 4264 } | |
| 13226 | 4265 |
| 11369 | 4266 /* Use UTF8 so that the world will be a happier place */ |
| 11238 | 4267 if (g_utf8_validate(args->info.sendfile.filename, -1, |
| 4268 NULL)) { | |
| 4269 gaim_xfer_set_filename(xfer, | |
| 4270 args->info.sendfile.filename); | |
| 4271 } else { | |
| 4272 gchar * utf8_filename = gaim_utf8_salvage( | |
| 4273 args->info.sendfile.filename); | |
| 4274 gaim_xfer_set_filename(xfer, utf8_filename); | |
| 4275 g_free(utf8_filename); | |
| 4276 } | |
| 4277 | |
| 4617 | 4278 gaim_xfer_set_size(xfer, args->info.sendfile.totsize); |
| 13226 | 4279 |
| 11369 | 4280 /* Ignore messages that start with <ICQ_COOL_FT> (XML that is sent along |
| 4281 * with ICQ sendfile requests) & <HTML> message that is sent with AOL file | |
| 4282 * transfers (Note: this latter message is ignored only if whole message | |
| 4283 * is <HTML>, but not if it starts with <HTML> */ | |
| 4284 if(message && ( g_ascii_strncasecmp(message,"<ICQ_COOL_FT>",13) < 0 | |
| 4285 || g_ascii_strcasecmp(message,"<HTML>") == 0) ) { | |
| 4286 gaim_debug_info("oscar","Ignoring file transfer message: %s\n", message); | |
| 11084 | 4287 g_free(message); |
| 4288 message = NULL; | |
| 4289 } | |
| 9933 | 4290 gaim_xfer_set_message(xfer, message); |
| 5146 | 4291 |
| 4292 /* Create the oscar-specific data */ | |
| 13252 | 4293 peer_connection = aim_oft_createinfo(od->sess, args->cookie, userinfo->sn, args->clientip, |
| 11369 | 4294 xfer->remote_port, 0, 0, NULL, AIM_XFER_RECV, xfer_method, proxy_stage); |
| 4295 if(proxy_stage == AIM_XFER_PROXY_STG2 && proxy_ip) { | |
| 13252 | 4296 peer_connection->proxyip = g_strdup(proxy_ip); |
| 11369 | 4297 } else { |
| 4298 if (args->proxyip) | |
| 13252 | 4299 peer_connection->proxyip = g_strdup(args->proxyip); |
| 11369 | 4300 if (args->verifiedip) |
| 13252 | 4301 peer_connection->verifiedip = g_strdup(args->verifiedip); |
| 11369 | 4302 } |
| 13252 | 4303 peer_connection->proxy_info = proxy_info; |
| 4304 xfer->data = peer_connection; | |
| 4617 | 4305 |
| 4306 /* Setup our I/O op functions */ | |
| 8446 | 4307 gaim_xfer_set_init_fnc(xfer, oscar_xfer_init_recv); |
| 4617 | 4308 gaim_xfer_set_end_fnc(xfer, oscar_xfer_end); |
| 8446 | 4309 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
|
4310 gaim_xfer_set_cancel_recv_fnc(xfer, oscar_xfer_cancel_recv); |
| 8446 | 4311 gaim_xfer_set_ack_fnc(xfer, oscar_xfer_ack_recv); |
| 4617 | 4312 |
| 4313 /* Keep track of this transfer for later */ | |
| 4314 od->file_transfers = g_slist_append(od->file_transfers, xfer); | |
| 13226 | 4315 |
| 4617 | 4316 /* Now perform the request */ |
| 4317 gaim_xfer_request(xfer); | |
| 11369 | 4318 /* A secondary request has been sent to negotiate the connection method */ |
| 4319 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0002) { | |
| 4320 /* We have asked to send a file to someone else, but they sent us a reply request | |
| 4321 * asking us to use an alternative method of connecting */ | |
| 4322 GaimXfer *xfer; | |
| 13252 | 4323 PeerConnection *peer_connection; |
| 13226 | 4324 |
| 11369 | 4325 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
| 13252 | 4326 peer_connection = xfer->data; |
| 13226 | 4327 |
| 11369 | 4328 /* Stop the listener connection */ |
| 4329 gaim_input_remove(xfer->watcher); | |
| 13252 | 4330 aim_conn_kill(sess, &peer_connection->conn); /* This is currently the listener */ |
| 11369 | 4331 |
| 4332 if(args->info.sendfile.use_proxy) { | |
| 4333 gaim_debug_info("oscar", | |
| 4334 "received request for stage 2 rv proxy with ip: %s\n", | |
| 4335 args->proxyip); | |
| 13252 | 4336 peer_connection->method = AIM_XFER_PROXY; |
| 4337 peer_connection->stage = AIM_XFER_PROXY_STG2; | |
| 4338 | |
| 4339 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, | |
| 11369 | 4340 args->cookie, args->port); |
| 4341 if(args->proxyip) { | |
| 4342 if(xfer->remote_ip) | |
| 4343 g_free(xfer->remote_ip); | |
| 4344 xfer->remote_ip = g_strdup(args->proxyip); | |
| 4345 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 4346 oscar_xfer_init_recv(xfer); | |
| 4347 } else { | |
| 4348 gaim_debug_warning("oscar", | |
| 4349 "stage 2 rv proxy file send: no proxy ip specified\n"); | |
| 4350 } | |
| 4351 } else if(args->clientip | |
| 4352 && g_ascii_strcasecmp(args->clientip,"0.0.0.0") == 0) | |
| 4353 { | |
| 4354 gaim_debug_warning("oscar", | |
| 4355 "other client wants us to send stage 3 proxy info\n"); | |
| 13252 | 4356 peer_connection->method = AIM_XFER_PROXY; |
| 4357 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
| 4358 | |
| 4359 /* Clean useless data from peer_connection */ | |
| 4360 peer_connection->clientip = NULL; | |
| 4361 peer_connection->verifiedip = NULL; | |
| 13226 | 4362 |
| 11369 | 4363 /* This hostname will be resolved in gaim_proxy_connect */ |
| 4364 xfer->remote_ip = g_strdup(AIM_RV_PROXY_SERVER_URL); | |
| 4365 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 13226 | 4366 |
| 13252 | 4367 peer_connection->proxy_info |
| 11369 | 4368 = aim_rv_proxy_createinfo(od->sess, args->cookie, 0); |
| 4369 oscar_xfer_init_recv(xfer); | |
| 4370 } else { | |
| 4371 gaim_debug_info("oscar","received request to redirect transfer; clientip/verifiedip: %s / %s\n", | |
| 4372 args->clientip, args->verifiedip); | |
| 13252 | 4373 peer_connection->method = AIM_XFER_REDIR; |
| 11369 | 4374 if (args->verifiedip) |
| 13252 | 4375 peer_connection->verifiedip = g_strdup(args->verifiedip); |
| 11369 | 4376 if (args->clientip) { |
| 13252 | 4377 peer_connection->clientip = g_strdup(args->clientip); |
| 11369 | 4378 xfer->remote_ip = g_strdup(args->clientip); |
| 4379 } | |
| 4380 xfer->remote_port = args->port; | |
| 13226 | 4381 |
| 11369 | 4382 /* This file send will briefly follow file receive codepaths */ |
| 4383 oscar_xfer_init_recv(xfer); | |
| 4384 } | |
| 4385 } else { | |
| 4386 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
| 4387 } | |
| 4388 /* A THIRD request has been sent trying to figure out what connection method will be used | |
| 4389 * to transfer this file */ | |
| 4390 } else if (args->status == AIM_RENDEZVOUS_PROPOSE && args->info.sendfile.reqnum == 0x0003) { | |
| 4391 /* We are receiving a file from someone. We sent a request to use a stage 3 | |
| 4392 * proxy. They did the initial proxy login and have sent us the info in a | |
| 4393 * third file transfer request. */ | |
| 4394 GaimXfer *xfer; | |
| 13252 | 4395 PeerConnection *peer_connection; |
| 13226 | 4396 |
| 11369 | 4397 if ((xfer = oscar_find_xfer_by_cookie(od->file_transfers, args->cookie))) { |
| 13252 | 4398 peer_connection = xfer->data; |
| 11369 | 4399 |
| 4400 /* We are receiving a file */ | |
| 4401 gaim_debug_info("oscar", | |
| 4402 "other client sent us stage 3 proxy info\n"); | |
| 13226 | 4403 |
| 11369 | 4404 /* The following pieces of information should already have |
| 4405 * been set in oscar_xfer_ip_timeout, but we'll list them | |
| 4406 * again just for clarity. */ | |
| 13252 | 4407 peer_connection->method = AIM_XFER_PROXY; |
| 4408 peer_connection->stage = AIM_XFER_PROXY_STG3; | |
| 4409 | |
| 4410 peer_connection->proxy_info = aim_rv_proxy_createinfo(peer_connection->sess, | |
| 11369 | 4411 args->cookie, args->port); |
| 4412 if(args->proxyip) { | |
| 4413 if(xfer->remote_ip) | |
| 4414 g_free(xfer->remote_ip); | |
| 4415 xfer->remote_ip = g_strdup(args->proxyip); | |
| 4416 xfer->remote_port = AIM_RV_PROXY_CONNECT_PORT; | |
| 4417 oscar_xfer_init_recv(xfer); | |
| 4418 } else { | |
| 4419 gaim_debug_warning("oscar", | |
| 4420 "stage 3 rv proxy file receive: no proxy ip specified\n"); | |
| 4421 } | |
| 4422 } else { | |
| 4423 gaim_debug_warning("oscar","received file tranfer reply request: xfer not found\n"); | |
| 4424 } | |
| 4617 | 4425 } else if (args->status == AIM_RENDEZVOUS_CANCEL) { |
| 4426 /* The other user wants to cancel a file transfer */ | |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4427 GaimXfer *xfer; |
| 8660 | 4428 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4429 "AAA - File transfer canceled by remote user\n"); |
| 4617 | 4430 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
|
4431 gaim_xfer_cancel_remote(xfer); |
| 4617 | 4432 } else if (args->status == AIM_RENDEZVOUS_ACCEPT) { |
| 4433 /* | |
| 13226 | 4434 * This gets sent by the receiver of a file |
| 4435 * as they connect directly to us. If we don't | |
| 4436 * get this, then maybe a third party connected | |
| 4617 | 4437 * to us, and we shouldn't send them anything. |
| 4438 */ | |
| 11214 | 4439 gaim_debug_info("oscar", |
| 13226 | 4440 "AAA - received chan 2 AIM_RENDEZVOUS_ACCEPT; ignoring\n"); |
| 4617 | 4441 } else { |
| 8660 | 4442 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4443 "unknown rendezvous status!\n"); |
| 3630 | 4444 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4445 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
| 8092 | 4446 } else if (args->reqclass & AIM_CAPS_TALK) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4447 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
| 9933 | 4448 gaim_buddy_icons_set_for_user(account, userinfo->sn, |
| 4449 args->info.icon.icon, | |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
4450 args->info.icon.length); |
| 6871 | 4451 } else if (args->reqclass & AIM_CAPS_DIRECTIM) { |
| 8971 | 4452 /* 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
|
4453 struct ask_direct *d = g_new0(struct ask_direct, 1); |
| 8971 | 4454 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
|
4455 char buf[256]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4456 |
| 4212 | 4457 if (!args->verifiedip) { |
| 8983 | 4458 /* TODO: do something about this, after figuring out what it means */ |
| 8660 | 4459 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4460 "directim kill blocked (%s)\n", userinfo->sn); |
| 9933 | 4461 g_free(message); |
| 4650 | 4462 return 1; |
| 4212 | 4463 } |
| 4464 | |
| 8660 | 4465 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4466 "%s received direct im request from %s (%s)\n", |
| 10594 | 4467 username, userinfo->sn, args->verifiedip); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4468 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4469 d->gc = gc; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4470 d->sn = g_strdup(userinfo->sn); |
| 8983 | 4471 /* Let's use the clientip here, because I think that's what AIM does. |
| 4472 * Besides, if the clientip is wrong, we'll probably timeout faster, | |
| 4473 * and then ask them to connect to us. */ | |
| 10594 | 4474 /* |
| 4475 * I disagree, let's use the verifiedip. I think AIM tries the | |
| 4476 * verified IP first, then tries the client IP if that fails. In | |
| 4477 * any case, there's a better chance the verified IP will be correct. | |
| 4478 * The client IP is what the other person _thinks_ their IP address | |
| 4479 * is. The verified IP is the address that the AIM server sees the | |
| 4480 * other person using. | |
| 4481 */ | |
| 4482 snprintf(d->ip, sizeof(d->ip), "%s:%d", args->verifiedip, args->port?args->port:5190); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4483 memcpy(d->cookie, args->cookie, 8); |
| 9070 | 4484 if (dim && !dim->connected && aim_odc_getcookie(dim->conn) && args->cookie && |
| 13226 | 4485 (!memcmp(aim_odc_getcookie(dim->conn), args->cookie, 8))) { |
| 9070 | 4486 |
| 8971 | 4487 oscar_direct_im_destroy(od, dim); |
| 8984 | 4488 d->donttryagain = TRUE; |
| 8971 | 4489 accept_direct_im_request(d); |
| 4490 } else { | |
| 8983 | 4491 if (dim && !dim->connected) |
| 13226 | 4492 gaim_debug_warning("oscar", "DirectIM: received direct im request " |
| 4493 "while already connected to that buddy!"); | |
| 5575 | 4494 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
|
4495 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4496 gaim_request_action(gc, NULL, buf, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4497 _("This requires a direct connection between " |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4498 "the two computers and is necessary for IM " |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4499 "Images. Because your IP address will be " |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4500 "revealed, this may be considered a privacy " |
| 13226 | 4501 "risk."), |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4502 GAIM_DEFAULT_ACTION_NONE, d, 2, |
|
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4503 _("_Connect"), G_CALLBACK(accept_direct_im_request), |
| 8971 | 4504 _("Cancel"), G_CALLBACK(destroy_direct_im_request)); |
| 4505 /* FIXME: we should actually send a packet on cancel */ | |
| 4506 } | |
| 8708 | 4507 } else if (args->reqclass & AIM_CAPS_ICQSERVERRELAY) { |
| 4508 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
|
4509 } else { |
| 8660 | 4510 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4511 "Unknown reqclass %hu\n", args->reqclass); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4512 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4513 |
| 9933 | 4514 g_free(message); |
| 4515 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4516 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4517 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4518 |
| 3453 | 4519 /* |
| 4230 | 4520 * Authorization Functions |
| 13226 | 4521 * Most of these are callbacks from dialogs. They're used by both |
| 4230 | 4522 * methods of authorization (SSI and old-school channel 4 ICBM) |
| 3453 | 4523 */ |
| 4269 | 4524 /* When you ask other people for authorization */ |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4525 static void gaim_auth_request(struct name_data *data, char *msg) { |
| 5575 | 4526 GaimConnection *gc = data->gc; |
| 4244 | 4527 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4528 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 4529 OscarData *od = gc->proto_data; |
| 6695 | 4530 GaimBuddy *buddy = gaim_find_buddy(gc->account, data->name); |
| 12088 | 4531 GaimGroup *group = gaim_buddy_get_group(buddy); |
| 4244 | 4532 if (buddy && group) { |
| 8660 | 4533 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4534 "ssi: adding buddy %s to group %s\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4535 buddy->name, group->name); |
| 4889 | 4536 aim_ssi_sendauthrequest(od->sess, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
| 4269 | 4537 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
| 9620 | 4538 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 1); |
| 4244 | 4539 } |
| 4230 | 4540 } |
| 4337 | 4541 } |
| 4542 | |
| 4543 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4544 gaim_request_input(data->gc, NULL, _("Authorization Request Message:"), |
| 8697 | 4545 NULL, _("Please authorize me!"), TRUE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4546 _("OK"), G_CALLBACK(gaim_auth_request), |
| 5836 | 4547 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4548 data); |
| 4230 | 4549 } |
| 4550 | |
| 4551 static void gaim_auth_dontrequest(struct name_data *data) { | |
| 5575 | 4552 GaimConnection *gc = data->gc; |
| 4244 | 4553 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4554 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 8151 | 4555 /* Remove from local list */ |
| 4556 GaimBuddy *b = gaim_find_buddy(gaim_connection_get_account(gc), data->name); | |
| 4557 gaim_blist_remove_buddy(b); | |
| 4244 | 4558 } |
| 4559 | |
| 5836 | 4560 oscar_free_name_data(data); |
| 4230 | 4561 } |
| 4562 | |
| 9030 | 4563 |
| 4564 static void gaim_auth_sendrequest(GaimConnection *gc, char *name) { | |
| 4269 | 4565 struct name_data *data = g_new(struct name_data, 1); |
| 6695 | 4566 GaimBuddy *buddy; |
| 4269 | 4567 gchar *dialog_msg, *nombre; |
| 4568 | |
| 4687 | 4569 buddy = gaim_find_buddy(gc->account, name); |
| 9620 | 4570 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
| 4571 nombre = g_strdup_printf("%s (%s)", name, gaim_buddy_get_alias_only(buddy)); | |
| 4269 | 4572 else |
| 4830 | 4573 nombre = NULL; |
| 4574 | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4575 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 | 4576 data->gc = gc; |
| 4577 data->name = g_strdup(name); | |
| 4578 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4579 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4580 gaim_request_action(gc, NULL, _("Request Authorization"), dialog_msg, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4581 0, data, 2, |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4582 _("_Request Authorization"), |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4583 G_CALLBACK(gaim_auth_request_msgprompt), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4584 _("Cancel"), G_CALLBACK(gaim_auth_dontrequest)); |
| 4269 | 4585 |
| 4586 g_free(dialog_msg); | |
| 4587 g_free(nombre); | |
| 4588 } | |
| 4589 | |
| 9030 | 4590 |
| 4591 static void gaim_auth_sendrequest_menu(GaimBlistNode *node, gpointer ignored) { | |
| 4592 GaimBuddy *buddy; | |
| 4593 GaimConnection *gc; | |
| 4594 | |
| 4595 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 4596 | |
| 4597 buddy = (GaimBuddy *) node; | |
| 4598 gc = gaim_account_get_connection(buddy->account); | |
| 4599 gaim_auth_sendrequest(gc, buddy->name); | |
| 4600 } | |
| 4601 | |
| 4230 | 4602 /* When other people ask you for authorization */ |
| 4603 static void gaim_auth_grant(struct name_data *data) { | |
| 5575 | 4604 GaimConnection *gc = data->gc; |
| 4244 | 4605 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4606 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 4607 OscarData *od = gc->proto_data; |
| 4889 | 4608 aim_ssi_sendauthreply(od->sess, data->name, 0x01, NULL); |
| 4244 | 4609 } |
| 4610 | |
| 5836 | 4611 oscar_free_name_data(data); |
| 3141 | 4612 } |
| 4613 | |
| 4230 | 4614 /* When other people ask you for authorization */ |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4615 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
| 5575 | 4616 GaimConnection *gc = data->gc; |
| 4244 | 4617 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4618 if (g_list_find(gaim_connections_get_all(), gc)) { |
| 7283 | 4619 OscarData *od = gc->proto_data; |
| 4889 | 4620 aim_ssi_sendauthreply(od->sess, data->name, 0x00, msg ? msg : _("No reason given.")); |
| 4244 | 4621 } |
| 4337 | 4622 } |
| 4623 | |
| 4624 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4625 gaim_request_input(data->gc, NULL, _("Authorization Denied Message:"), |
| 8697 | 4626 NULL, _("No reason given."), TRUE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4627 _("OK"), G_CALLBACK(gaim_auth_dontgrant), |
| 5836 | 4628 _("Cancel"), G_CALLBACK(oscar_free_name_data), |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
4629 data); |
| 3141 | 4630 } |
| 4631 | |
| 7023 | 4632 /* When someone sends you buddies */ |
| 4633 static void gaim_icq_buddyadd(struct name_data *data) { | |
| 5575 | 4634 GaimConnection *gc = data->gc; |
| 4244 | 4635 |
|
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5579
diff
changeset
|
4636 if (g_list_find(gaim_connections_get_all(), gc)) { |
|
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7054
diff
changeset
|
4637 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), data->name, NULL, data->nick); |
| 4244 | 4638 } |
| 4639 | |
| 5836 | 4640 oscar_free_name_data(data); |
| 3453 | 4641 } |
| 4642 | |
| 13239 | 4643 static int incomingim_chan4(OscarSession *sess, OscarConnection *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
| 5575 | 4644 GaimConnection *gc = sess->aux_data; |
| 9908 | 4645 GaimAccount *account = gaim_connection_get_account(gc); |
| 4076 | 4646 gchar **msg1, **msg2; |
| 6051 | 4647 int i, numtoks; |
| 4076 | 4648 |
| 4121 | 4649 if (!args->type || !args->msg || !args->uin) |
| 4650 return 1; | |
| 4194 | 4651 |
| 8660 | 4652 gaim_debug_info("oscar", |
| 9908 | 4653 "Received a channel 4 message of type 0x%02hhx.\n", |
| 4654 args->type); | |
| 4076 | 4655 |
| 9919 | 4656 /* |
| 4657 * Split up the message at the delimeter character, then convert each | |
| 4658 * string to UTF-8. Unless, of course, this is a type 1 message. If | |
| 4659 * this is a type 1 message, then the delimiter 0xfe could be a valid | |
| 4660 * character in whatever encoding the message was sent in. Type 1 | |
| 4661 * messages are always made up of only one part, so we can easily account | |
| 4662 * for this suck-ass part of the protocol by splitting the string into at | |
| 4663 * most 1 baby string. | |
| 4664 */ | |
| 4665 msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); | |
| 6051 | 4666 for (numtoks=0; msg1[numtoks]; numtoks++); |
| 4667 msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *)); | |
| 4076 | 4668 for (i=0; msg1[i]; i++) { |
| 11920 | 4669 gaim_str_strip_char(msg1[i], '\r'); |
| 9908 | 4670 msg2[i] = gaim_plugin_oscar_decode_im_part(account, "1", AIM_CHARSET_ASCII, 0x0000, msg1[i], strlen(msg1[i])); |
| 4076 | 4671 } |
| 4672 msg2[i] = NULL; | |
| 4673 | |
| 3952 | 4674 switch (args->type) { |
| 4173 | 4675 case 0x01: { /* MacICQ message or basic offline message */ |
| 4076 | 4676 if (i >= 1) { |
| 5556 | 4677 gchar *uin = g_strdup_printf("%u", args->uin); |
| 8493 | 4678 gchar *tmp; |
| 4679 | |
| 4680 /* If the message came from an ICQ user then escape any HTML */ | |
|
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
4681 tmp = g_markup_escape_text(msg2[0], -1); |
| 8493 | 4682 |
| 4076 | 4683 if (t) { /* This is an offline message */ |
| 9680 | 4684 /* The timestamp is UTC-ish, so we need to get the offset */ |
| 9698 | 4685 #ifdef HAVE_TM_GMTOFF |
| 9724 | 4686 time_t now; |
| 4687 struct tm *tm; | |
| 4688 now = time(NULL); | |
| 4689 tm = localtime(&now); | |
| 4690 t += tm->tm_gmtoff; | |
| 9698 | 4691 #else |
| 4692 # ifdef HAVE_TIMEZONE | |
| 9680 | 4693 tzset(); |
| 4694 t -= timezone; | |
| 9698 | 4695 # endif |
| 4696 #endif | |
| 8514 | 4697 serv_got_im(gc, uin, tmp, 0, t); |
| 4076 | 4698 } else { /* This is a message from MacICQ/Miranda */ |
| 8514 | 4699 serv_got_im(gc, uin, tmp, 0, time(NULL)); |
| 4076 | 4700 } |
| 4701 g_free(uin); | |
| 8493 | 4702 g_free(tmp); |
| 4075 | 4703 } |
| 3316 | 4704 } break; |
| 4705 | |
| 4173 | 4706 case 0x04: { /* Someone sent you a URL */ |
| 4076 | 4707 if (i >= 2) { |
| 7385 | 4708 if (msg2[1] != NULL) { |
| 4709 gchar *uin = g_strdup_printf("%u", args->uin); | |
| 4710 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", | |
| 4711 msg2[1], | |
| 4712 (msg2[0] && msg2[0][0]) ? msg2[0] : msg2[1]); | |
| 4713 serv_got_im(gc, uin, message, 0, time(NULL)); | |
| 4714 g_free(uin); | |
| 4715 g_free(message); | |
| 4716 } | |
| 3453 | 4717 } |
| 4718 } break; | |
| 4719 | |
| 4173 | 4720 case 0x06: { /* Someone requested authorization */ |
| 4076 | 4721 if (i >= 6) { |
| 4230 | 4722 struct name_data *data = g_new(struct name_data, 1); |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4723 gchar *sn = g_strdup_printf("%u", args->uin); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4724 gchar *reason; |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4725 gchar *dialog_msg; |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4726 |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4727 if (msg2[5] != NULL) |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4728 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg2[5], strlen(msg2[5])); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4729 else |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4730 reason = g_strdup(_("No reason given.")); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4731 |
| 11369 | 4732 dialog_msg = g_strdup_printf(_("The user %u wants to add %s to their buddy list for the following reason:\n%s"), |
| 4733 args->uin, gaim_account_get_username(gc->account), reason); | |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4734 g_free(reason); |
| 8660 | 4735 gaim_debug_info("oscar", |
| 5556 | 4736 "Received an authorization request from UIN %u\n", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4737 args->uin); |
| 4076 | 4738 data->gc = gc; |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
4739 data->name = sn; |
| 4230 | 4740 data->nick = NULL; |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4741 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4742 gaim_request_action(gc, NULL, _("Authorization Request"), |
| 9948 | 4743 dialog_msg, GAIM_DEFAULT_ACTION_NONE, data, |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4744 2, _("_Authorize"), |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4745 G_CALLBACK(gaim_auth_grant), |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4746 _("_Deny"), |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4747 G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
| 4076 | 4748 g_free(dialog_msg); |
| 4749 } | |
| 3141 | 4750 } break; |
| 4751 | |
| 4173 | 4752 case 0x07: { /* Someone has denied you authorization */ |
| 4076 | 4753 if (i >= 1) { |
| 7023 | 4754 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
|
4755 gaim_notify_info(gc, NULL, _("ICQ authorization denied."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4756 dialog_msg); |
| 4076 | 4757 g_free(dialog_msg); |
| 4758 } | |
| 3141 | 4759 } break; |
| 4760 | |
| 4173 | 4761 case 0x08: { /* Someone has granted you authorization */ |
| 7023 | 4762 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
|
4763 gaim_notify_info(gc, NULL, "ICQ authorization accepted.", |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
4764 dialog_msg); |
| 3141 | 4765 g_free(dialog_msg); |
| 4766 } break; | |
| 4767 | |
| 4333 | 4768 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
| 4769 if (i >= 5) { | |
| 4770 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
|
4771 gaim_notify_info(gc, NULL, "ICQ Server Message", dialog_msg); |
| 4333 | 4772 g_free(dialog_msg); |
| 4773 } | |
| 4774 } break; | |
| 4775 | |
| 4173 | 4776 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
| 4076 | 4777 if (i >= 6) { |
| 4194 | 4778 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
|
4779 gaim_notify_info(gc, NULL, "ICQ Page", dialog_msg); |
| 4076 | 4780 g_free(dialog_msg); |
| 4781 } | |
| 4075 | 4782 } break; |
| 4783 | |
| 4173 | 4784 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
| 4076 | 4785 if (i >= 6) { |
| 4308 | 4786 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
|
4787 gaim_notify_info(gc, NULL, "ICQ Email", dialog_msg); |
| 4076 | 4788 g_free(dialog_msg); |
| 4789 } | |
| 4075 | 4790 } break; |
| 4791 | |
| 4173 | 4792 case 0x12: { |
| 3141 | 4793 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
| 7023 | 4794 /* Someone added you to their buddy list? */ |
| 3141 | 4795 } break; |
| 4796 | |
| 7023 | 4797 case 0x13: { /* Someone has sent you some ICQ buddies */ |
| 7631 | 4798 guint i, num; |
| 3453 | 4799 gchar **text; |
| 4173 | 4800 text = g_strsplit(args->msg, "\376", 0); |
| 3453 | 4801 if (text) { |
| 4802 num = 0; | |
| 4803 for (i=0; i<strlen(text[0]); i++) | |
| 4804 num = num*10 + text[0][i]-48; | |
| 4805 for (i=0; i<num; i++) { | |
| 4230 | 4806 struct name_data *data = g_new(struct name_data, 1); |
| 7023 | 4807 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 | 4808 data->gc = gc; |
| 4790 | 4809 data->name = g_strdup(text[i*2+1]); |
| 4810 data->nick = g_strdup(text[i*2+2]); | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4811 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
4812 gaim_request_action(gc, NULL, message, |
| 7023 | 4813 _("Do you want to add this buddy " |
| 4814 "to your buddy list?"), | |
| 9972 | 4815 GAIM_DEFAULT_ACTION_NONE, data, 2, |
| 7023 | 4816 _("Add"), G_CALLBACK(gaim_icq_buddyadd), |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
4817 _("_Decline"), G_CALLBACK(oscar_free_name_data)); |
| 3453 | 4818 g_free(message); |
| 4819 } | |
| 4820 g_strfreev(text); | |
| 4821 } | |
| 4822 } break; | |
| 4823 | |
| 7023 | 4824 case 0x1a: { /* Someone has sent you a greeting card or requested buddies? */ |
| 3453 | 4825 /* This is boring and silly. */ |
| 4826 } break; | |
| 4827 | |
| 3141 | 4828 default: { |
| 8660 | 4829 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4830 "Received a channel 4 message of unknown type " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4831 "(type 0x%02hhx).\n", args->type); |
| 3141 | 4832 } break; |
| 4833 } | |
| 4834 | |
| 4076 | 4835 g_strfreev(msg1); |
| 4836 g_strfreev(msg2); | |
| 4837 | |
| 3141 | 4838 return 1; |
| 4839 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4840 |
| 13239 | 4841 static int gaim_parse_incoming_im(OscarSession *sess, FlapFrame *fr, ...) { |
| 13234 | 4842 guint16 channel; |
| 4200 | 4843 int ret = 0; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4844 aim_userinfo_t *userinfo; |
| 2086 | 4845 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4846 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4847 va_start(ap, fr); |
| 13234 | 4848 channel = (guint16)va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4849 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 4850 |
| 3141 | 4851 switch (channel) { |
| 4852 case 1: { /* standard message */ | |
| 4853 struct aim_incomingim_ch1_args *args; | |
| 4854 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
| 4855 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
| 4856 } break; | |
| 4857 | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8733
diff
changeset
|
4858 case 2: { /* rendezvous */ |
| 3141 | 4859 struct aim_incomingim_ch2_args *args; |
| 4860 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
| 4861 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
| 4862 } break; | |
| 4863 | |
| 4864 case 4: { /* ICQ */ | |
| 4865 struct aim_incomingim_ch4_args *args; | |
| 4866 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
| 4075 | 4867 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
| 3141 | 4868 } break; |
| 4869 | |
| 4870 default: { | |
| 8660 | 4871 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4872 "ICBM received on unsupported channel (channel " |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4873 "0x%04hx).", channel); |
| 3141 | 4874 } break; |
| 2086 | 4875 } |
| 4876 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4877 va_end(ap); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4878 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4879 return ret; |
| 2086 | 4880 } |
| 4881 | |
| 13239 | 4882 static int gaim_parse_misses(OscarSession *sess, FlapFrame *fr, ...) { |
| 8733 | 4883 GaimConnection *gc = sess->aux_data; |
| 4884 GaimAccount *account = gaim_connection_get_account(gc); | |
| 5420 | 4885 char *buf; |
| 2086 | 4886 va_list ap; |
| 13234 | 4887 guint16 chan, nummissed, reason; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
4888 aim_userinfo_t *userinfo; |
| 2086 | 4889 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4890 va_start(ap, fr); |
| 13234 | 4891 chan = (guint16)va_arg(ap, unsigned int); |
| 4200 | 4892 userinfo = va_arg(ap, aim_userinfo_t *); |
| 13234 | 4893 nummissed = (guint16)va_arg(ap, unsigned int); |
| 4894 reason = (guint16)va_arg(ap, unsigned int); | |
| 2086 | 4895 va_end(ap); |
| 4896 | |
| 4897 switch(reason) { | |
| 5420 | 4898 case 0: /* Invalid (0) */ |
| 4899 buf = g_strdup_printf( | |
| 4900 ngettext( | |
| 4276 | 4901 "You missed %hu message from %s because it was invalid.", |
| 4902 "You missed %hu messages from %s because they were invalid.", | |
| 4903 nummissed), | |
| 4282 | 4904 nummissed, |
| 4905 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4906 break; |
| 5420 | 4907 case 1: /* Message too large */ |
| 4908 buf = g_strdup_printf( | |
| 4909 ngettext( | |
| 4276 | 4910 "You missed %hu message from %s because it was too large.", |
| 4911 "You missed %hu messages from %s because they were too large.", | |
| 4912 nummissed), | |
| 4282 | 4913 nummissed, |
| 4914 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4915 break; |
| 5420 | 4916 case 2: /* Rate exceeded */ |
| 4917 buf = g_strdup_printf( | |
| 4918 ngettext( | |
| 4276 | 4919 "You missed %hu message from %s because the rate limit has been exceeded.", |
| 4920 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
| 4921 nummissed), | |
| 4282 | 4922 nummissed, |
| 4923 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4924 break; |
| 5420 | 4925 case 3: /* Evil Sender */ |
| 4926 buf = g_strdup_printf( | |
| 4927 ngettext( | |
| 4276 | 4928 "You missed %hu message from %s because he/she was too evil.", |
| 4929 "You missed %hu messages from %s because he/she was too evil.", | |
| 4930 nummissed), | |
| 4282 | 4931 nummissed, |
| 4932 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4933 break; |
| 5420 | 4934 case 4: /* Evil Receiver */ |
| 4935 buf = g_strdup_printf( | |
| 4936 ngettext( | |
| 4276 | 4937 "You missed %hu message from %s because you are too evil.", |
| 4938 "You missed %hu messages from %s because you are too evil.", | |
| 4939 nummissed), | |
| 4282 | 4940 nummissed, |
| 4941 userinfo->sn); | |
| 2086 | 4942 break; |
| 4943 default: | |
| 5420 | 4944 buf = g_strdup_printf( |
| 4945 ngettext( | |
| 4276 | 4946 "You missed %hu message from %s for an unknown reason.", |
| 4947 "You missed %hu messages from %s for an unknown reason.", | |
| 4948 nummissed), | |
| 4282 | 4949 nummissed, |
| 4950 userinfo->sn); | |
| 2086 | 4951 break; |
| 4952 } | |
| 8733 | 4953 |
| 9627 | 4954 if (!gaim_conv_present_error(userinfo->sn, account, buf)) |
| 8733 | 4955 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
| 5420 | 4956 g_free(buf); |
| 2086 | 4957 |
| 4958 return 1; | |
| 4959 } | |
| 4960 | |
| 13239 | 4961 static int gaim_parse_clientauto_ch2(OscarSession *sess, const char *who, guint16 reason, const guchar *cookie) { |
| 5575 | 4962 GaimConnection *gc = sess->aux_data; |
| 7283 | 4963 OscarData *od = gc->proto_data; |
| 4617 | 4964 |
| 4965 /* BBB */ | |
| 3630 | 4966 switch (reason) { |
| 4151 | 4967 case 3: { /* Decline sendfile. */ |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
4968 GaimXfer *xfer; |
| 8971 | 4969 struct oscar_direct_im *dim; |
| 4970 | |
| 8660 | 4971 gaim_debug_info("oscar", |
| 9070 | 4972 "AAA - Other user declined some sort of direct " |
| 8971 | 4973 "connect attempt (automaticly?)\n"); |
| 4617 | 4974 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
|
4975 gaim_xfer_cancel_remote(xfer); |
| 8971 | 4976 else if ((dim = oscar_direct_im_find(od, who))) { |
| 4977 /* AAA should use find by cookie or something here */ | |
| 4978 oscar_direct_im_disconnect(od, dim); | |
| 4979 } | |
| 4151 | 4980 } break; |
| 4981 | |
| 4982 default: { | |
| 8660 | 4983 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
4984 "Received an unknown rendezvous client auto-response " |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
4985 "from %s. Type 0x%04hx\n", who, reason); |
| 4151 | 4986 } |
| 3630 | 4987 |
| 4988 } | |
| 4989 | |
| 4990 return 0; | |
| 4991 } | |
| 4992 | |
| 13239 | 4993 static int gaim_parse_clientauto_ch4(OscarSession *sess, char *who, guint16 reason, guint32 state, char *msg) { |
| 5575 | 4994 GaimConnection *gc = sess->aux_data; |
| 4151 | 4995 |
| 4996 switch(reason) { | |
| 4997 case 0x0003: { /* Reply from an ICQ status message request */ | |
| 9244 | 4998 char *title, *statusmsg, **splitmsg, *dialogmsg; |
| 4999 | |
| 5000 title = g_strdup_printf(_("Info for %s"), who); | |
| 4151 | 5001 |
| 5002 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
| 9244 | 5003 statusmsg = oscar_icqstatus(state); |
| 4151 | 5004 splitmsg = g_strsplit(msg, "\r\n", 0); |
| 9244 | 5005 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); |
| 5006 g_free(statusmsg); | |
| 4151 | 5007 g_strfreev(splitmsg); |
| 9244 | 5008 |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
5009 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL); |
| 9244 | 5010 |
| 5011 g_free(title); | |
| 5012 g_free(dialogmsg); | |
| 4151 | 5013 } break; |
| 5014 | |
| 5015 default: { | |
| 8660 | 5016 gaim_debug_warning("oscar", |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5017 "Received an unknown client auto-response from %s. " |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5018 "Type 0x%04hx\n", who, reason); |
| 4151 | 5019 } break; |
| 5020 } /* end of switch */ | |
| 5021 | |
| 5022 return 0; | |
| 5023 } | |
| 5024 | |
| 13239 | 5025 static int gaim_parse_clientauto(OscarSession *sess, FlapFrame *fr, ...) { |
| 3212 | 5026 va_list ap; |
| 13234 | 5027 guint16 chan, reason; |
| 3212 | 5028 char *who; |
| 5029 | |
| 5030 va_start(ap, fr); | |
| 13234 | 5031 chan = (guint16)va_arg(ap, unsigned int); |
| 3212 | 5032 who = va_arg(ap, char *); |
| 13234 | 5033 reason = (guint16)va_arg(ap, unsigned int); |
| 3212 | 5034 |
| 3952 | 5035 if (chan == 0x0002) { /* File transfer declined */ |
| 11159 | 5036 guchar *cookie = va_arg(ap, guchar *); |
| 4151 | 5037 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
| 3952 | 5038 } else if (chan == 0x0004) { /* ICQ message */ |
| 13234 | 5039 guint32 state = 0; |
| 4151 | 5040 char *msg = NULL; |
| 5041 if (reason == 0x0003) { | |
| 13234 | 5042 state = va_arg(ap, guint32); |
| 4151 | 5043 msg = va_arg(ap, char *); |
| 5044 } | |
| 5045 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
| 5046 } | |
| 3952 | 5047 |
| 3212 | 5048 va_end(ap); |
| 5049 | |
| 5050 return 1; | |
| 5051 } | |
| 5052 | |
| 13239 | 5053 static int gaim_parse_genericerr(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5054 va_list ap; |
| 13234 | 5055 guint16 reason; |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5056 char *m; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5057 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5058 va_start(ap, fr); |
| 13234 | 5059 reason = (guint16) va_arg(ap, unsigned int); |
| 2086 | 5060 va_end(ap); |
| 5061 | |
| 8660 | 5062 gaim_debug_error("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5063 "snac threw error (reason 0x%04hx: %s)\n", reason, |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5064 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
| 2086 | 5065 |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5066 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
| 5411 | 5067 reason < msgerrreasonlen ? _(msgerrreason[reason]) : _("Unknown error")); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5068 gaim_notify_error(sess->aux_data, NULL, m, NULL); |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5069 g_free(m); |
|
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
5070 |
| 2086 | 5071 return 1; |
| 5072 } | |
| 5073 | |
| 13239 | 5074 static int gaim_parse_msgerr(OscarSession *sess, FlapFrame *fr, ...) { |
| 9627 | 5075 GaimConnection *gc = sess->aux_data; |
| 4617 | 5076 #if 0 |
| 7283 | 5077 OscarData *od = gc->proto_data; |
|
6240
ac191233b816
[gaim-migrate @ 6734]
Christian Hammond <chipx86@chipx86.com>
parents:
6173
diff
changeset
|
5078 GaimXfer *xfer; |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5079 #endif |
| 4617 | 5080 va_list ap; |
| 13234 | 5081 guint16 reason; |
| 4617 | 5082 char *data, *buf; |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5083 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5084 va_start(ap, fr); |
| 13234 | 5085 reason = (guint16)va_arg(ap, unsigned int); |
| 3752 | 5086 data = va_arg(ap, char *); |
| 2086 | 5087 va_end(ap); |
| 5088 | |
| 8660 | 5089 gaim_debug_error("oscar", |
| 10130 | 5090 "Message error with data %s and reason %hu\n", |
| 5091 (data != NULL ? data : ""), reason); | |
| 4617 | 5092 |
| 5093 /* BBB */ | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5094 #if 0 |
| 4617 | 5095 /* If this was a file transfer request, data is a cookie */ |
| 5096 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
|
5097 gaim_xfer_cancel_remote(xfer); |
| 3630 | 5098 return 1; |
| 5099 } | |
|
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
5100 #endif |
| 3630 | 5101 |
| 4617 | 5102 /* Data is assumed to be the destination sn */ |
| 9826 | 5103 buf = g_strdup_printf(_("Unable to send message: %s"), (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Unknown reason.")); |
| 5104 if (!gaim_conv_present_error(data, gaim_connection_get_account(gc), buf)) { | |
| 5105 g_free(buf); | |
| 5106 buf = g_strdup_printf(_("Unable to send message to %s:"), data ? data : "(unknown)"); | |
| 9627 | 5107 gaim_notify_error(sess->aux_data, NULL, buf, |
| 9826 | 5108 (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
| 5109 } | |
| 5110 g_free(buf); | |
| 5111 | |
| 2086 | 5112 return 1; |
| 5113 } | |
| 5114 | |
| 13239 | 5115 static int gaim_parse_mtn(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5116 GaimConnection *gc = sess->aux_data; |
| 3595 | 5117 va_list ap; |
| 13234 | 5118 guint16 type1, type2; |
| 3595 | 5119 char *sn; |
| 5120 | |
| 5121 va_start(ap, fr); | |
| 13234 | 5122 type1 = (guint16) va_arg(ap, unsigned int); |
| 3595 | 5123 sn = va_arg(ap, char *); |
| 13234 | 5124 type2 = (guint16) va_arg(ap, unsigned int); |
| 3595 | 5125 va_end(ap); |
| 5126 | |
| 5127 switch (type2) { | |
| 5128 case 0x0000: { /* Text has been cleared */ | |
| 5129 serv_got_typing_stopped(gc, sn); | |
| 5130 } break; | |
| 5131 | |
| 5132 case 0x0001: { /* Paused typing */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5133 serv_got_typing(gc, sn, 0, GAIM_TYPED); |
| 3595 | 5134 } break; |
| 5135 | |
| 5136 case 0x0002: { /* Typing */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
5137 serv_got_typing(gc, sn, 0, GAIM_TYPING); |
| 3595 | 5138 } break; |
| 5139 | |
| 5140 default: { | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5141 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 | 5142 } break; |
| 5143 } | |
| 5144 | |
| 5145 return 1; | |
| 5146 } | |
| 5147 | |
| 7141 | 5148 /* |
| 5149 * We get this error when there was an error in the locate family. This | |
| 7259 | 5150 * happens when you request info of someone who is offline. |
| 7141 | 5151 */ |
| 13239 | 5152 static int gaim_parse_locerr(OscarSession *sess, FlapFrame *fr, ...) { |
| 9826 | 5153 gchar *buf; |
| 2086 | 5154 va_list ap; |
| 13234 | 5155 guint16 reason; |
| 2086 | 5156 char *destn; |
| 5157 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5158 va_start(ap, fr); |
| 13234 | 5159 reason = (guint16) va_arg(ap, unsigned int); |
| 2086 | 5160 destn = va_arg(ap, char *); |
| 5161 va_end(ap); | |
| 5162 | |
| 7781 | 5163 if (destn == NULL) |
| 7793 | 5164 return 1; |
| 12653 | 5165 |
| 9826 | 5166 buf = g_strdup_printf(_("User information not available: %s"), (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
| 5167 if (!gaim_conv_present_error(destn, gaim_connection_get_account((GaimConnection*)sess->aux_data), buf)) { | |
| 5168 g_free(buf); | |
| 9627 | 5169 buf = g_strdup_printf(_("User information for %s unavailable:"), destn); |
| 9826 | 5170 gaim_notify_error(sess->aux_data, NULL, buf, (reason < msgerrreasonlen) ? _(msgerrreason[reason]) : _("Unknown reason.")); |
| 5171 } | |
| 5172 g_free(buf); | |
| 2086 | 5173 |
| 5174 return 1; | |
| 5175 } | |
| 5176 | |
| 13239 | 5177 static int gaim_parse_userinfo(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5178 GaimConnection *gc = sess->aux_data; |
| 8700 | 5179 GaimAccount *account = gaim_connection_get_account(gc); |
| 10567 | 5180 OscarData *od = gc->proto_data; |
| 8700 | 5181 GString *str; |
|
11532
57439a383f4f
[gaim-migrate @ 13781]
Luke Schierer <lschiere@pidgin.im>
parents:
11531
diff
changeset
|
5182 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; |
| 4791 | 5183 va_list ap; |
| 7011 | 5184 aim_userinfo_t *userinfo; |
| 2086 | 5185 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5186 va_start(ap, fr); |
| 7011 | 5187 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 5188 va_end(ap); |
| 5189 | |
| 8700 | 5190 str = g_string_new(""); |
| 5191 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
| 5192 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
| 7011 | 5193 |
| 10116 | 5194 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
| 10567 | 5195 time_t t = userinfo->onlinesince - od->timeoffset; |
|
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5196 oscar_string_append(gc->account, str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t))); |
| 10116 | 5197 } |
| 5198 | |
| 5199 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
| 10567 | 5200 time_t t = userinfo->membersince - od->timeoffset; |
|
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
5201 oscar_string_append(gc->account, str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t))); |
| 10116 | 5202 } |
| 7011 | 5203 |
| 12430 | 5204 if (userinfo->capabilities != 0) { |
| 5205 tmp = oscar_caps_to_string(userinfo->capabilities); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5206 oscar_string_append(gc->account, str, "\n<br>", _("Capabilities"), tmp); |
| 12430 | 5207 g_free(tmp); |
| 5208 } | |
| 5209 | |
| 7011 | 5210 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
| 8700 | 5211 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
5212 oscar_string_append(gc->account, str, "\n<br>", _("Idle"), tmp); |
| 8700 | 5213 g_free(tmp); |
| 5214 } | |
| 5215 | |
| 8701 | 5216 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
| 7011 | 5217 |
| 13007 | 5218 /* Available message */ |
| 5219 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY)) | |
| 5220 { | |
| 5221 if (userinfo->status[0] != '\0') | |
| 5222 tmp = oscar_encoding_to_utf8(userinfo->status_encoding, | |
| 5223 userinfo->status, userinfo->status_len); | |
| 5224 oscar_string_append(gc->account, str, "\n<br>", _("Available Message"), tmp); | |
| 5225 g_free(tmp); | |
| 5226 } | |
| 5227 | |
| 5228 /* Away message */ | |
| 7011 | 5229 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
| 8700 | 5230 tmp = oscar_encoding_extract(userinfo->away_encoding); |
| 5231 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | |
| 5232 g_free(tmp); | |
| 7011 | 5233 if (away_utf8 != NULL) { |
| 12661 | 5234 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
| 7011 | 5235 g_free(away_utf8); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5236 } |
| 7011 | 5237 } |
| 5238 | |
| 13007 | 5239 /* Info */ |
| 7011 | 5240 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { |
| 8700 | 5241 tmp = oscar_encoding_extract(userinfo->info_encoding); |
| 5242 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); | |
| 5243 g_free(tmp); | |
| 7011 | 5244 if (info_utf8 != NULL) { |
| 12661 | 5245 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
| 7011 | 5246 g_free(info_utf8); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5247 } |
| 7011 | 5248 } |
| 5249 | |
| 8701 | 5250 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
| 8700 | 5251 g_string_free(str, TRUE); |
| 11920 | 5252 gaim_str_strip_char(tmp, '\r'); |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
5253 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL); |
| 8700 | 5254 g_free(tmp); |
| 4151 | 5255 |
| 2086 | 5256 return 1; |
| 5257 } | |
| 5258 | |
| 13239 | 5259 static int gaim_got_infoblock(OscarSession *sess, FlapFrame *fr, ...) |
| 12189 | 5260 { |
| 5261 GaimConnection *gc = sess->aux_data; | |
| 5262 GaimBuddy *b; | |
| 5263 GaimPresence *presence; | |
| 12349 | 5264 GaimStatus *status; |
| 12189 | 5265 gchar *message = NULL; |
| 5266 | |
| 5267 va_list ap; | |
| 5268 aim_userinfo_t *userinfo; | |
| 5269 | |
| 5270 va_start(ap, fr); | |
| 5271 userinfo = va_arg(ap, aim_userinfo_t *); | |
| 5272 va_end(ap); | |
| 5273 | |
| 5274 b = gaim_find_buddy(gaim_connection_get_account(gc), userinfo->sn); | |
| 5275 if (b == NULL) | |
| 5276 return 1; | |
| 5277 | |
| 5278 presence = gaim_buddy_get_presence(b); | |
| 12349 | 5279 status = gaim_presence_get_active_status(presence); |
| 5280 | |
| 12426 | 5281 if (!gaim_status_is_available(status) && gaim_status_is_online(status)) |
| 12271 | 5282 { |
| 12189 | 5283 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && |
| 5284 (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | |
| 5285 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | |
| 5286 message = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | |
| 5287 g_free(charset); | |
| 12393 | 5288 gaim_status_set_attr_string(status, "message", message); |
| 5289 g_free(message); | |
| 12189 | 5290 } |
| 12349 | 5291 |
| 5292 gaim_blist_update_buddy_status(b, status); | |
| 5293 } | |
| 12189 | 5294 |
| 5295 return 1; | |
| 5296 } | |
| 5297 | |
| 8341 | 5298 static gboolean gaim_reqinfo_timeout_cb(void *data) |
| 5299 { | |
| 13239 | 5300 OscarSession *sess = data; |
| 8341 | 5301 GaimConnection *gc = sess->aux_data; |
| 5302 OscarData *od = (OscarData *)gc->proto_data; | |
| 5303 | |
| 5304 aim_locate_dorequest(data); | |
| 5305 od->getinfotimer = 0; | |
| 5306 | |
| 5307 return FALSE; | |
| 5308 } | |
| 5309 | |
| 13239 | 5310 static int gaim_reqinfo_timeout(OscarSession *sess, FlapFrame *fr, ...) |
| 8341 | 5311 { |
| 5312 GaimConnection *gc = sess->aux_data; | |
| 5313 OscarData *od = (OscarData *)gc->proto_data; | |
| 5314 | |
| 5315 /* | |
| 5316 * Wait a little while then call aim_locate_dorequest(sess). This keeps | |
| 5317 * us from hitting the rate limit due to request away messages and info | |
| 5318 * too quickly. | |
| 5319 */ | |
| 5320 if (od->getinfotimer == 0) | |
| 11670 | 5321 od->getinfotimer = gaim_timeout_add(10000, gaim_reqinfo_timeout_cb, sess); |
| 8341 | 5322 |
| 5323 return 1; | |
| 5324 } | |
| 5325 | |
| 13239 | 5326 static int gaim_parse_motd(OscarSession *sess, FlapFrame *fr, ...) |
| 8341 | 5327 { |
| 2086 | 5328 char *msg; |
| 13234 | 5329 guint16 id; |
| 2086 | 5330 va_list ap; |
| 5331 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5332 va_start(ap, fr); |
| 13234 | 5333 id = (guint16) va_arg(ap, unsigned int); |
| 2086 | 5334 msg = va_arg(ap, char *); |
| 5335 va_end(ap); | |
| 5336 | |
| 8660 | 5337 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5338 "MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
|
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
5339 if (id < 4) |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5340 gaim_notify_warning(sess->aux_data, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5341 _("Your AIM connection may be lost."), NULL); |
| 2086 | 5342 |
| 5343 return 1; | |
| 5344 } | |
| 5345 | |
| 13239 | 5346 static int gaim_chatnav_info(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5347 va_list ap; |
| 13234 | 5348 guint16 type; |
| 5575 | 5349 GaimConnection *gc = sess->aux_data; |
| 7283 | 5350 OscarData *od = (OscarData *)gc->proto_data; |
| 2086 | 5351 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5352 va_start(ap, fr); |
| 13234 | 5353 type = (guint16) va_arg(ap, unsigned int); |
| 2086 | 5354 |
| 5355 switch(type) { | |
| 5356 case 0x0002: { | |
| 13234 | 5357 guint8 maxrooms; |
| 2086 | 5358 struct aim_chat_exchangeinfo *exchanges; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5359 int exchangecount, i; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5360 |
| 13234 | 5361 maxrooms = (guint8) va_arg(ap, unsigned int); |
| 2086 | 5362 exchangecount = va_arg(ap, int); |
| 5363 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
| 5364 | |
| 8660 | 5365 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5366 "chat info: Chat Rights:\n"); |
| 8660 | 5367 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5368 "chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
| 8660 | 5369 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5370 "chat info: \tExchange List: (%d total)\n", exchangecount); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5371 for (i = 0; i < exchangecount; i++) |
| 8660 | 5372 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5373 "chat info: \t\t%hu %s\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5374 exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
| 4617 | 5375 while (od->create_rooms) { |
| 5376 struct create_room *cr = od->create_rooms->data; | |
| 8660 | 5377 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5378 "creating room %s\n", cr->name); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5379 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5380 g_free(cr->name); |
| 4617 | 5381 od->create_rooms = g_slist_remove(od->create_rooms, cr); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
5382 g_free(cr); |
| 2086 | 5383 } |
| 5384 } | |
| 5385 break; | |
| 5386 case 0x0008: { | |
| 5387 char *fqcn, *name, *ck; | |
| 13234 | 5388 guint16 instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
| 5389 guint8 createperms; | |
| 5390 guint32 createtime; | |
| 2086 | 5391 |
| 5392 fqcn = va_arg(ap, char *); | |
| 13234 | 5393 instance = (guint16)va_arg(ap, unsigned int); |
| 5394 exchange = (guint16)va_arg(ap, unsigned int); | |
| 5395 flags = (guint16)va_arg(ap, unsigned int); | |
| 5396 createtime = va_arg(ap, guint32); | |
| 5397 maxmsglen = (guint16)va_arg(ap, unsigned int); | |
| 5398 maxoccupancy = (guint16)va_arg(ap, unsigned int); | |
| 5399 createperms = (guint8)va_arg(ap, unsigned int); | |
| 5400 unknown = (guint16)va_arg(ap, unsigned int); | |
| 4200 | 5401 name = va_arg(ap, char *); |
| 5402 ck = va_arg(ap, char *); | |
| 4194 | 5403 |
| 8660 | 5404 gaim_debug_misc("oscar", |
| 5556 | 5405 "created room: %s %hu %hu %hu %u %hu %hu %hhu %hu %s %s\n", |
| 2086 | 5406 fqcn, |
| 5407 exchange, instance, flags, | |
| 5408 createtime, | |
| 5409 maxmsglen, maxoccupancy, createperms, unknown, | |
| 5410 name, ck); | |
| 4617 | 5411 aim_chat_join(od->sess, od->conn, exchange, ck, instance); |
| 2086 | 5412 } |
| 5413 break; | |
| 5414 default: | |
| 8660 | 5415 gaim_debug_warning("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5416 "chatnav info: unknown type (%04hx)\n", type); |
| 2086 | 5417 break; |
| 5418 } | |
| 4194 | 5419 |
| 5420 va_end(ap); | |
| 5421 | |
| 2086 | 5422 return 1; |
| 5423 } | |
| 5424 | |
| 13239 | 5425 static int gaim_conv_chat_join(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5426 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5427 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5428 aim_userinfo_t *info; |
| 5575 | 5429 GaimConnection *g = sess->aux_data; |
| 2086 | 5430 |
| 5431 struct chat_connection *c = NULL; | |
| 5432 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5433 va_start(ap, fr); |
| 2086 | 5434 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5435 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 5436 va_end(ap); |
| 5437 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5438 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 5439 if (!c) |
| 5440 return 1; | |
| 5441 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5442 for (i = 0; i < count; i++) |
| 9846 | 5443 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL, GAIM_CBFLAGS_NONE, TRUE); |
| 2086 | 5444 |
| 5445 return 1; | |
| 5446 } | |
| 5447 | |
| 13239 | 5448 static int gaim_conv_chat_leave(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5449 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5450 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5451 aim_userinfo_t *info; |
| 5575 | 5452 GaimConnection *g = sess->aux_data; |
| 2086 | 5453 |
| 5454 struct chat_connection *c = NULL; | |
| 5455 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5456 va_start(ap, fr); |
| 2086 | 5457 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5458 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 5459 va_end(ap); |
| 5460 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5461 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 5462 if (!c) |
| 5463 return 1; | |
| 5464 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5465 for (i = 0; i < count; i++) |
| 8733 | 5466 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c->conv), info[i].sn, NULL); |
| 2086 | 5467 |
| 5468 return 1; | |
| 5469 } | |
| 5470 | |
| 13239 | 5471 static int gaim_conv_chat_info_update(OscarSession *sess, FlapFrame *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5472 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5473 aim_userinfo_t *userinfo; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5474 struct aim_chat_roominfo *roominfo; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5475 char *roomname; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5476 int usercount; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5477 char *roomdesc; |
| 13234 | 5478 guint16 unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
| 5479 guint32 creationtime; | |
| 5575 | 5480 GaimConnection *gc = sess->aux_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5481 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
|
5482 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5483 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5484 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5485 roomname = va_arg(ap, char *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5486 usercount= va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5487 userinfo = va_arg(ap, aim_userinfo_t *); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5488 roomdesc = va_arg(ap, char *); |
| 13234 | 5489 unknown_c9 = (guint16)va_arg(ap, unsigned int); |
| 5490 creationtime = va_arg(ap, guint32); | |
| 5491 maxmsglen = (guint16)va_arg(ap, unsigned int); | |
| 5492 unknown_d2 = (guint16)va_arg(ap, unsigned int); | |
| 5493 unknown_d5 = (guint16)va_arg(ap, unsigned int); | |
| 5494 maxvisiblemsglen = (guint16)va_arg(ap, unsigned int); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5495 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5496 |
| 8660 | 5497 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5498 "inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
|
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5499 maxmsglen, maxvisiblemsglen); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5500 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5501 ccon->maxlen = maxmsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5502 ccon->maxvis = maxvisiblemsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5503 |
| 2086 | 5504 return 1; |
| 5505 } | |
| 5506 | |
| 13239 | 5507 static int gaim_conv_chat_incoming_msg(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5508 GaimConnection *gc = sess->aux_data; |
| 8225 | 5509 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
| 5510 gchar *utf8; | |
| 2086 | 5511 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5512 aim_userinfo_t *info; |
| 8225 | 5513 int len; |
| 2086 | 5514 char *msg; |
| 8219 | 5515 char *charset; |
| 2086 | 5516 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5517 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5518 info = va_arg(ap, aim_userinfo_t *); |
| 8219 | 5519 len = va_arg(ap, int); |
| 4194 | 5520 msg = va_arg(ap, char *); |
| 8219 | 5521 charset = va_arg(ap, char *); |
| 4194 | 5522 va_end(ap); |
| 2086 | 5523 |
| 8225 | 5524 utf8 = oscar_encoding_to_utf8(charset, msg, len); |
| 8667 | 5525 if (utf8 == NULL) |
| 5526 /* The conversion failed! */ | |
| 8668 | 5527 utf8 = g_strdup(_("[Unable to display a message from this user because it contained invalid characters.]")); |
| 8225 | 5528 serv_got_chat_in(gc, ccon->id, info->sn, 0, utf8, time((time_t)NULL)); |
| 5529 g_free(utf8); | |
| 2086 | 5530 |
| 5531 return 1; | |
| 5532 } | |
| 5533 | |
| 13239 | 5534 static int gaim_email_parseupdate(OscarSession *sess, FlapFrame *fr, ...) { |
| 3694 | 5535 va_list ap; |
| 5575 | 5536 GaimConnection *gc = sess->aux_data; |
| 3694 | 5537 struct aim_emailinfo *emailinfo; |
| 3725 | 5538 int havenewmail; |
| 7297 | 5539 char *alertitle, *alerturl; |
| 3694 | 5540 |
| 5541 va_start(ap, fr); | |
| 5542 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
| 3725 | 5543 havenewmail = va_arg(ap, int); |
| 7301 | 5544 alertitle = va_arg(ap, char *); |
| 5545 alerturl = va_arg(ap, char *); | |
| 3694 | 5546 va_end(ap); |
| 5547 | |
| 9661 | 5548 if ((emailinfo != NULL) && gaim_account_get_check_mail(gc->account)) { |
| 5549 gchar *to = g_strdup_printf("%s%s%s", gaim_account_get_username(gaim_connection_get_account(gc)), | |
| 5550 emailinfo->domain ? "@" : "", | |
| 5551 emailinfo->domain ? emailinfo->domain : ""); | |
| 5542 | 5552 if (emailinfo->unread && havenewmail) |
| 5553 gaim_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL, (const char **)&to, (const char **)&emailinfo->url, NULL, NULL); | |
| 5537 | 5554 g_free(to); |
| 3694 | 5555 } |
| 13226 | 5556 |
| 7301 | 5557 if (alertitle) |
| 8660 | 5558 gaim_debug_misc("oscar", "Got an alert '%s' %s\n", alertitle, alerturl ? alerturl : ""); |
| 3694 | 5559 |
| 5560 return 1; | |
| 5561 } | |
| 5562 | |
| 13239 | 5563 static int gaim_icon_error(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5564 GaimConnection *gc = sess->aux_data; |
| 7283 | 5565 OscarData *od = gc->proto_data; |
| 4804 | 5566 char *sn; |
| 5567 | |
| 5568 sn = od->requesticon->data; | |
| 8660 | 5569 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5570 "removing %s from hash table\n", sn); |
| 4804 | 5571 od->requesticon = g_slist_remove(od->requesticon, sn); |
| 5572 free(sn); | |
| 5573 | |
| 5574 if (od->icontimer) | |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5575 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5576 od->icontimer = gaim_timeout_add(500, gaim_icon_timerfunc, gc); |
| 4804 | 5577 |
| 5578 return 1; | |
| 5579 } | |
| 5580 | |
| 13239 | 5581 static int gaim_icon_parseicon(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5582 GaimConnection *gc = sess->aux_data; |
| 7283 | 5583 OscarData *od = gc->proto_data; |
| 4804 | 5584 GSList *cur; |
| 5585 va_list ap; | |
| 5586 char *sn; | |
| 13234 | 5587 guint8 iconcsumtype, *iconcsum, *icon; |
| 5588 guint16 iconcsumlen, iconlen; | |
| 4804 | 5589 |
| 5590 va_start(ap, fr); | |
| 5591 sn = va_arg(ap, char *); | |
| 11024 | 5592 iconcsumtype = va_arg(ap, int); |
| 13234 | 5593 iconcsum = va_arg(ap, guint8 *); |
| 4853 | 5594 iconcsumlen = va_arg(ap, int); |
| 13234 | 5595 icon = va_arg(ap, guint8 *); |
| 4804 | 5596 iconlen = va_arg(ap, int); |
| 5597 va_end(ap); | |
| 5598 | |
| 11024 | 5599 /* |
| 5600 * Some AIM clients will send a blank GIF image with iconlen 90 when | |
| 5601 * no icon is set. Ignore these. | |
| 5602 */ | |
| 5603 if ((iconlen > 0) && (iconlen != 90)) { | |
| 4853 | 5604 char *b16; |
| 6695 | 5605 GaimBuddy *b = gaim_find_buddy(gc->account, sn); |
|
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5606 gaim_buddy_icons_set_for_user(gaim_connection_get_account(gc), |
|
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6787
diff
changeset
|
5607 sn, icon, iconlen); |
|
7106
db6bd3e794d8
[gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents:
7098
diff
changeset
|
5608 b16 = gaim_base16_encode(iconcsum, iconcsumlen); |
| 5129 | 5609 if (b16) { |
| 7693 | 5610 gaim_blist_node_set_string((GaimBlistNode*)b, "icon_checksum", b16); |
| 7162 | 5611 g_free(b16); |
| 5129 | 5612 } |
| 4853 | 5613 } |
| 4804 | 5614 |
| 5615 cur = od->requesticon; | |
| 5616 while (cur) { | |
| 5617 char *cursn = cur->data; | |
| 5618 if (!aim_sncmp(cursn, sn)) { | |
| 5619 od->requesticon = g_slist_remove(od->requesticon, cursn); | |
| 5620 free(cursn); | |
| 5621 cur = od->requesticon; | |
| 5622 } else | |
| 5623 cur = cur->next; | |
| 5624 } | |
| 5625 | |
| 5626 if (od->icontimer) | |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
5627 gaim_timeout_remove(od->icontimer); |
|
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8266
diff
changeset
|
5628 od->icontimer = gaim_timeout_add(250, gaim_icon_timerfunc, gc); |
| 4804 | 5629 |
| 5630 return 1; | |
| 5631 } | |
| 5632 | |
| 5633 static gboolean gaim_icon_timerfunc(gpointer data) { | |
| 5575 | 5634 GaimConnection *gc = data; |
| 7283 | 5635 OscarData *od = gc->proto_data; |
| 7011 | 5636 aim_userinfo_t *userinfo; |
| 13239 | 5637 OscarConnection *conn; |
| 4804 | 5638 |
| 5639 conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON); | |
| 5892 | 5640 if (!conn) { |
| 5641 if (!od->iconconnecting) { | |
| 5642 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
| 5643 od->iconconnecting = TRUE; | |
| 5644 } | |
| 4804 | 5645 return FALSE; |
| 5646 } | |
| 5647 | |
| 5842 | 5648 if (od->set_icon) { |
| 6039 | 5649 struct stat st; |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5650 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
| 6039 | 5651 if (iconfile == NULL) { |
| 8363 | 5652 aim_ssi_delicon(od->sess); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5653 } else if (!g_stat(iconfile, &st)) { |
| 11159 | 5654 guchar *buf = g_malloc(st.st_size); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
5655 FILE *file = g_fopen(iconfile, "rb"); |
| 6039 | 5656 if (file) { |
| 9532 | 5657 /* XXX - Use g_file_get_contents()? */ |
| 6039 | 5658 fread(buf, 1, st.st_size, file); |
| 5659 fclose(file); | |
| 8660 | 5660 gaim_debug_info("oscar", |
| 6039 | 5661 "Uploading icon to icon server\n"); |
| 6879 | 5662 aim_bart_upload(od->sess, buf, st.st_size); |
| 5842 | 5663 } else |
| 8660 | 5664 gaim_debug_error("oscar", |
| 6039 | 5665 "Can't open buddy icon file!\n"); |
| 5666 g_free(buf); | |
| 5667 } else { | |
| 8660 | 5668 gaim_debug_error("oscar", |
| 6039 | 5669 "Can't stat buddy icon file!\n"); |
| 5842 | 5670 } |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
5671 g_free(iconfile); |
| 5842 | 5672 od->set_icon = FALSE; |
| 5673 } | |
| 5674 | |
| 5675 if (!od->requesticon) { | |
| 8660 | 5676 gaim_debug_misc("oscar", |
| 5842 | 5677 "no more icons to request\n"); |
| 5678 return FALSE; | |
| 5679 } | |
| 5680 | |
| 7045 | 5681 userinfo = aim_locate_finduserinfo(od->sess, (char *)od->requesticon->data); |
| 7011 | 5682 if ((userinfo != NULL) && (userinfo->iconcsumlen > 0)) { |
| 11024 | 5683 aim_bart_request(od->sess, od->requesticon->data, userinfo->iconcsumtype, userinfo->iconcsum, userinfo->iconcsumlen); |
| 4804 | 5684 return FALSE; |
| 5685 } else { | |
| 5686 char *sn = od->requesticon->data; | |
| 5687 od->requesticon = g_slist_remove(od->requesticon, sn); | |
| 5688 free(sn); | |
| 5689 } | |
| 5690 | |
| 5691 return TRUE; | |
| 5692 } | |
| 5693 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5694 /* |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5695 * 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
|
5696 */ |
| 13239 | 5697 static int gaim_parse_msgack(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5698 va_list ap; |
| 13234 | 5699 guint16 type; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5700 char *sn; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5701 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5702 va_start(ap, fr); |
| 13234 | 5703 type = (guint16) va_arg(ap, unsigned int); |
| 2086 | 5704 sn = va_arg(ap, char *); |
| 5705 va_end(ap); | |
| 5706 | |
| 8660 | 5707 gaim_debug_info("oscar", "Sent message to %s.\n", sn); |
| 2086 | 5708 |
| 5709 return 1; | |
| 5710 } | |
| 5711 | |
| 13239 | 5712 static int gaim_parse_ratechange(OscarSession *sess, FlapFrame *fr, ...) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5713 static const char *codes[5] = { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5714 "invalid", |
| 4194 | 5715 "change", |
| 5716 "warning", | |
| 5717 "limit", | |
| 5718 "limit cleared", | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5719 }; |
| 2086 | 5720 va_list ap; |
| 13234 | 5721 guint16 code, rateclass; |
| 5722 guint32 windowsize, clear, alert, limit, disconnect, currentavg, maxavg; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5723 |
| 13226 | 5724 va_start(ap, fr); |
| 13234 | 5725 code = (guint16)va_arg(ap, unsigned int); |
| 5726 rateclass= (guint16)va_arg(ap, unsigned int); | |
| 5727 windowsize = va_arg(ap, guint32); | |
| 5728 clear = va_arg(ap, guint32); | |
| 5729 alert = va_arg(ap, guint32); | |
| 5730 limit = va_arg(ap, guint32); | |
| 5731 disconnect = va_arg(ap, guint32); | |
| 5732 currentavg = va_arg(ap, guint32); | |
| 5733 maxavg = va_arg(ap, guint32); | |
| 2086 | 5734 va_end(ap); |
| 5735 | |
| 8660 | 5736 gaim_debug_misc("oscar", |
| 5556 | 5737 "rate %s (param ID 0x%04hx): curavg = %u, maxavg = %u, alert at %u, " |
| 5738 "clear warning at %u, limit at %u, disconnect at %u (window size = %u)\n", | |
| 2086 | 5739 (code < 5) ? codes[code] : codes[0], |
| 5740 rateclass, | |
| 5741 currentavg, maxavg, | |
| 5742 alert, clear, | |
| 5743 limit, disconnect, | |
| 5744 windowsize); | |
| 5745 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5746 /* XXX fix these values */ |
| 2086 | 5747 if (code == AIM_RATE_CODE_CHANGE) { |
| 5748 if (currentavg >= clear) | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5749 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 5750 } else if (code == AIM_RATE_CODE_WARNING) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5751 aim_conn_setlatency(fr->conn, windowsize/4); |
|
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
5752 } else if (code == AIM_RATE_CODE_LIMIT) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
5753 gaim_notify_error(sess->aux_data, NULL, _("Rate limiting error."), |
| 6040 | 5754 _("The last action you attempted could not be " |
| 5755 "performed because you are over the rate limit. " | |
| 5756 "Please wait 10 seconds and try again.")); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5757 aim_conn_setlatency(fr->conn, windowsize/2); |
| 2086 | 5758 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5759 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 5760 } |
| 5761 | |
| 5762 return 1; | |
| 5763 } | |
| 5764 | |
| 13239 | 5765 static int gaim_parse_evilnotify(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 5766 va_list ap; |
| 13234 | 5767 guint16 newevil; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5768 aim_userinfo_t *userinfo; |
| 2086 | 5769 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5770 va_start(ap, fr); |
| 13234 | 5771 newevil = (guint16) va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
5772 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 5773 va_end(ap); |
| 5774 | |
| 11285 | 5775 #ifdef CRAZY_WARNING |
| 5776 gaim_prpl_got_account_warning_level(account, (userinfo && userinfo->sn) ? userinfo->sn : NULL, (newevil/10.0) + 0.5); | |
| 5777 #endif | |
| 2086 | 5778 |
| 5779 return 1; | |
| 5780 } | |
| 5781 | |
| 13239 | 5782 static int gaim_selfinfo(OscarSession *sess, FlapFrame *fr, ...) { |
| 9982 | 5783 int warning_level; |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5784 va_list ap; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5785 aim_userinfo_t *info; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5786 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5787 va_start(ap, fr); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5788 info = va_arg(ap, aim_userinfo_t *); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5789 va_end(ap); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5790 |
| 11285 | 5791 /* |
| 5792 * What's with the + 0.5? | |
| 5793 * The 0.5 is basically poor-man's rounding. Normally | |
| 5794 * casting "13.7" to an int will truncate to "13," but | |
| 5795 * with 13.7 + 0.5 = 14.2, which becomes "14" when | |
| 5796 * truncated. | |
| 5797 */ | |
| 9982 | 5798 warning_level = info->warnlevel/10.0 + 0.5; |
| 5799 | |
| 11285 | 5800 #ifdef CRAZY_WARNING |
| 5801 gaim_presence_set_warning_level(presence, warning_level); | |
| 5802 #endif | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5803 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5804 return 1; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5805 } |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
5806 |
| 13239 | 5807 static int gaim_connerr(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5808 GaimConnection *gc = sess->aux_data; |
| 7283 | 5809 OscarData *od = gc->proto_data; |
| 4649 | 5810 va_list ap; |
| 13234 | 5811 guint16 code; |
| 4649 | 5812 char *msg; |
| 5813 | |
| 5814 va_start(ap, fr); | |
| 13234 | 5815 code = (guint16)va_arg(ap, int); |
| 4649 | 5816 msg = va_arg(ap, char *); |
| 5817 va_end(ap); | |
| 5818 | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
5819 gaim_debug_info("oscar", "Disconnected. Code is 0x%04x and msg is %s\n", |
| 10458 | 5820 code, (msg != NULL ? msg : "")); |
| 5821 | |
| 5822 g_return_val_if_fail(fr != NULL, 1); | |
| 5823 g_return_val_if_fail(fr->conn != NULL, 1); | |
| 5824 | |
| 5825 if (fr->conn->type == AIM_CONN_TYPE_BOS) { | |
| 4651 | 5826 if (code == 0x0001) { |
| 6113 | 5827 gc->wants_to_die = TRUE; |
| 10715 | 5828 gaim_connection_error(gc, _("You have signed on from another location.")); |
| 4651 | 5829 } else { |
| 5579 | 5830 gaim_connection_error(gc, _("You have been signed off for an unknown reason.")); |
| 4651 | 5831 } |
| 4666 | 5832 od->killme = TRUE; |
| 10458 | 5833 } else if (fr->conn->type == AIM_CONN_TYPE_CHAT) { |
| 5834 struct chat_connection *cc; | |
| 5835 GaimConversation *conv; | |
| 5836 | |
| 5837 cc = find_oscar_chat_by_conn(gc, fr->conn); | |
| 5838 conv = gaim_find_chat(gc, cc->id); | |
| 5839 | |
| 5840 if (conv != NULL) | |
| 5841 { | |
| 5842 gchar *buf; | |
| 5843 buf = g_strdup_printf(_("You have been disconnected from chat " | |
| 5844 "room %s."), cc->name); | |
| 5845 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_ERROR, time(NULL)); | |
| 5846 g_free(buf); | |
| 5847 } | |
| 5848 oscar_chat_kill(gc, cc); | |
| 4649 | 5849 } |
| 5850 | |
| 5851 return 1; | |
| 5852 } | |
| 5853 | |
| 13239 | 5854 static int conninitdone_bos(OscarSession *sess, FlapFrame *fr, ...) { |
| 7283 | 5855 GaimConnection *gc = sess->aux_data; |
| 12663 | 5856 OscarData *od = gc->proto_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5857 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5858 aim_reqpersonalinfo(sess, fr->conn); |
| 4230 | 5859 |
| 8660 | 5860 gaim_debug_info("oscar", "ssi: requesting rights and list\n"); |
| 4889 | 5861 aim_ssi_reqrights(sess); |
| 6350 | 5862 aim_ssi_reqdata(sess); |
| 12663 | 5863 if (od->getblisttimer > 0) |
| 5864 gaim_timeout_remove(od->getblisttimer); | |
| 5865 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
| 4230 | 5866 |
| 7011 | 5867 aim_locate_reqrights(sess); |
| 7285 | 5868 aim_buddylist_reqrights(sess, fr->conn); |
| 4617 | 5869 aim_im_reqparams(sess); |
| 7334 | 5870 aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi */ |
| 4230 | 5871 |
| 7283 | 5872 gaim_connection_update_progress(gc, _("Finalizing connection"), 5, OSCAR_CONNECT_STEPS); |
| 5873 | |
| 2086 | 5874 return 1; |
| 5875 } | |
| 5876 | |
| 13239 | 5877 static int conninitdone_admin(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 5878 GaimConnection *gc = sess->aux_data; |
| 7283 | 5879 OscarData *od = gc->proto_data; |
| 2647 | 5880 |
| 13234 | 5881 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0003, gaim_info_change, 0); |
| 5882 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0005, gaim_info_change, 0); | |
| 5883 aim_conn_addhandler(sess, fr->conn, OSCAR_FAMILY_ADMIN, 0x0007, gaim_account_confirm, 0); | |
| 6905 | 5884 |
| 2672 | 5885 aim_clientready(sess, fr->conn); |
| 8660 | 5886 gaim_debug_info("oscar", "connected to admin\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5887 |
| 2647 | 5888 if (od->chpass) { |
| 8660 | 5889 gaim_debug_info("oscar", "changing password\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5890 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
| 2647 | 5891 g_free(od->oldp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5892 od->oldp = NULL; |
| 2647 | 5893 g_free(od->newp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5894 od->newp = NULL; |
| 2647 | 5895 od->chpass = FALSE; |
| 5896 } | |
| 2979 | 5897 if (od->setnick) { |
| 8660 | 5898 gaim_debug_info("oscar", "formatting screen name\n"); |
| 2979 | 5899 aim_admin_setnick(sess, fr->conn, od->newsn); |
| 5900 g_free(od->newsn); | |
| 5901 od->newsn = NULL; | |
| 5902 od->setnick = FALSE; | |
| 5903 } | |
| 2647 | 5904 if (od->conf) { |
| 8660 | 5905 gaim_debug_info("oscar", "confirming account\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5906 aim_admin_reqconfirm(sess, fr->conn); |
| 2647 | 5907 od->conf = FALSE; |
| 5908 } | |
| 5909 if (od->reqemail) { | |
| 8660 | 5910 gaim_debug_info("oscar", "requesting email\n"); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5911 aim_admin_getinfo(sess, fr->conn, 0x0011); |
| 2647 | 5912 od->reqemail = FALSE; |
| 5913 } | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5914 if (od->setemail) { |
| 8660 | 5915 gaim_debug_info("oscar", "setting email\n"); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5916 aim_admin_setemail(sess, fr->conn, od->email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5917 g_free(od->email); |
| 5497 | 5918 od->email = NULL; |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5919 od->setemail = FALSE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5920 } |
| 2647 | 5921 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5922 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5923 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5924 |
| 13239 | 5925 static int gaim_icbm_param_info(OscarSession *sess, FlapFrame *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5926 struct aim_icbmparameters *params; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5927 va_list ap; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5928 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5929 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5930 params = va_arg(ap, struct aim_icbmparameters *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5931 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5932 |
| 4194 | 5933 /* XXX - evidently this crashes on solaris. i have no clue why |
| 8660 | 5934 gaim_debug_misc("oscar", "ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " |
| 5556 | 5935 "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
|
5936 params->maxchan, params->flags, params->maxmsglen, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5937 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5938 params->minmsginterval); |
|
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
5939 */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5940 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5941 /* Maybe senderwarn and recverwarn should be user preferences... */ |
| 3595 | 5942 params->flags = 0x0000000b; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5943 params->maxmsglen = 8000; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5944 params->minmsginterval = 0; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5945 |
| 4617 | 5946 aim_im_setparams(sess, params); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5947 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5948 return 1; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5949 } |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5950 |
| 13239 | 5951 static int gaim_parse_locaterights(OscarSession *sess, FlapFrame *fr, ...) |
| 2993 | 5952 { |
| 5575 | 5953 GaimConnection *gc = sess->aux_data; |
| 11338 | 5954 GaimAccount *account = gaim_connection_get_account(gc); |
| 7283 | 5955 OscarData *od = (OscarData *)gc->proto_data; |
| 5306 | 5956 va_list ap; |
| 13234 | 5957 guint16 maxsiglen; |
| 2993 | 5958 |
| 5959 va_start(ap, fr); | |
| 13234 | 5960 maxsiglen = (guint16) va_arg(ap, int); |
| 2993 | 5961 va_end(ap); |
| 5962 | |
| 8660 | 5963 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5964 "locate rights: max sig len = %d\n", maxsiglen); |
| 2993 | 5965 |
| 4617 | 5966 od->rights.maxsiglen = od->rights.maxawaymsglen = (guint)maxsiglen; |
| 5967 | |
| 5968 if (od->icq) | |
| 7334 | 5969 aim_locate_setcaps(od->sess, caps_icq); |
| 5301 | 5970 else |
| 7334 | 5971 aim_locate_setcaps(od->sess, caps_aim); |
| 11965 | 5972 oscar_set_info_and_status(account, TRUE, account->user_info, TRUE, |
| 5973 gaim_account_get_active_status(account)); | |
| 2993 | 5974 |
| 5975 return 1; | |
| 5976 } | |
| 5977 | |
| 13239 | 5978 static int gaim_parse_buddyrights(OscarSession *sess, FlapFrame *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
5979 va_list ap; |
| 13234 | 5980 guint16 maxbuddies, maxwatchers; |
| 5575 | 5981 GaimConnection *gc = sess->aux_data; |
| 7283 | 5982 OscarData *od = (OscarData *)gc->proto_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5983 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5984 va_start(ap, fr); |
| 13234 | 5985 maxbuddies = (guint16) va_arg(ap, unsigned int); |
| 5986 maxwatchers = (guint16) va_arg(ap, unsigned int); | |
| 2086 | 5987 va_end(ap); |
| 5988 | |
| 8660 | 5989 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
5990 "buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
| 2086 | 5991 |
| 4617 | 5992 od->rights.maxbuddies = (guint)maxbuddies; |
| 5993 od->rights.maxwatchers = (guint)maxwatchers; | |
| 2993 | 5994 |
| 2086 | 5995 return 1; |
| 5996 } | |
| 5997 | |
| 13239 | 5998 static int gaim_bosrights(OscarSession *sess, FlapFrame *fr, ...) { |
| 11808 | 5999 GaimConnection *gc; |
| 6000 OscarData *od; | |
| 6001 GaimAccount *account; | |
| 6002 GaimStatus *status; | |
| 6003 const char *message; | |
| 12344 | 6004 char *tmp; |
| 7334 | 6005 va_list ap; |
| 13234 | 6006 guint16 maxpermits, maxdenies; |
| 2086 | 6007 |
| 11808 | 6008 gc = sess->aux_data; |
| 6009 od = (OscarData *)gc->proto_data; | |
| 11809 | 6010 account = gaim_connection_get_account(gc); |
| 11808 | 6011 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6012 va_start(ap, fr); |
| 13234 | 6013 maxpermits = (guint16) va_arg(ap, unsigned int); |
| 6014 maxdenies = (guint16) va_arg(ap, unsigned int); | |
| 2086 | 6015 va_end(ap); |
| 6016 | |
| 8660 | 6017 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6018 "BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
| 2086 | 6019 |
| 4617 | 6020 od->rights.maxpermits = (guint)maxpermits; |
| 6021 od->rights.maxdenies = (guint)maxdenies; | |
| 2993 | 6022 |
|
5576
8c398efc88f2
[gaim-migrate @ 5980]
Christian Hammond <chipx86@chipx86.com>
parents:
5575
diff
changeset
|
6023 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 2993 | 6024 |
| 8660 | 6025 gaim_debug_info("oscar", "buddy list loaded\n"); |
| 2993 | 6026 |
| 2672 | 6027 aim_clientready(sess, fr->conn); |
| 11808 | 6028 |
| 6029 /* Set our available message based on the current status */ | |
| 6030 status = gaim_account_get_active_status(account); | |
| 6031 if (gaim_status_is_available(status)) | |
| 6032 message = gaim_status_get_attr_string(status, "message"); | |
| 11810 | 6033 else |
| 6034 message = NULL; | |
| 12344 | 6035 tmp = gaim_markup_strip_html(message); |
| 12349 | 6036 aim_srv_setstatusmsg(sess, tmp); |
| 12344 | 6037 free(tmp); |
| 11808 | 6038 |
| 7474 | 6039 aim_srv_setidle(sess, 0); |
| 4617 | 6040 |
| 4664 | 6041 if (od->icq) { |
| 6042 aim_icq_reqofflinemsgs(sess); | |
| 12652 | 6043 oscar_set_extendedstatus(gc); |
| 10570 | 6044 aim_icq_setsecurity(sess, |
| 6045 gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION), | |
| 12652 | 6046 gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)); |
| 4664 | 6047 } |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6048 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
6049 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
| 4102 | 6050 if (sess->authinfo->email) |
| 6051 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
| 2086 | 6052 |
| 6053 return 1; | |
| 6054 } | |
| 6055 | |
| 13239 | 6056 static int gaim_offlinemsg(OscarSession *sess, FlapFrame *fr, ...) { |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6057 va_list ap; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6058 struct aim_icq_offlinemsg *msg; |
| 4075 | 6059 struct aim_incomingim_ch4_args args; |
| 6060 time_t t; | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6061 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6062 va_start(ap, fr); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6063 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6064 va_end(ap); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6065 |
| 8660 | 6066 gaim_debug_info("oscar", |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6067 "Received offline message. Converting to channel 4 ICBM...\n"); |
| 4075 | 6068 args.uin = msg->sender; |
| 6069 args.type = msg->type; | |
| 4173 | 6070 args.flags = msg->flags; |
| 4076 | 6071 args.msglen = msg->msglen; |
| 4075 | 6072 args.msg = msg->msg; |
|
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
6073 t = gaim_time_build(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); |
| 4075 | 6074 incomingim_chan4(sess, fr->conn, NULL, &args, t); |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6075 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6076 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6077 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6078 |
| 13239 | 6079 static int gaim_offlinemsgdone(OscarSession *sess, FlapFrame *fr, ...) |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6080 { |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6081 aim_icq_ackofflinemsgs(sess); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6082 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6083 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
6084 |
| 13239 | 6085 static int gaim_icqinfo(OscarSession *sess, FlapFrame *fr, ...) |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6086 { |
| 5575 | 6087 GaimConnection *gc = sess->aux_data; |
| 8670 | 6088 OscarData *od = (OscarData *)gc->proto_data; |
| 6089 GaimBuddy *buddy; | |
| 8853 | 6090 struct buddyinfo *bi = NULL; |
| 4624 | 6091 gchar who[16]; |
| 8670 | 6092 GString *str; |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6093 gchar *utf8; |
| 9634 | 6094 const gchar *alias; |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6095 va_list ap; |
| 4151 | 6096 struct aim_icq_info *info; |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6097 |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6098 va_start(ap, fr); |
| 4151 | 6099 info = va_arg(ap, struct aim_icq_info *); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6100 va_end(ap); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6101 |
| 4664 | 6102 if (!info->uin) |
| 6103 return 0; | |
| 6104 | |
| 8670 | 6105 str = g_string_sized_new(100); |
| 5556 | 6106 g_snprintf(who, sizeof(who), "%u", info->uin); |
| 8670 | 6107 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
| 6108 if (buddy != NULL) | |
| 6109 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | |
| 6110 | |
| 6111 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6112 oscar_string_append(gc->account, str, "\n<br>", _("Nick"), info->nick); |
| 8670 | 6113 if ((bi != NULL) && (bi->ipaddr != 0)) { |
| 6114 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
| 6115 (bi->ipaddr & 0xff000000) >> 24, | |
| 6116 (bi->ipaddr & 0x00ff0000) >> 16, | |
| 6117 (bi->ipaddr & 0x0000ff00) >> 8, | |
| 6118 (bi->ipaddr & 0x000000ff)); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6119 oscar_string_append(gc->account, str, "\n<br>", _("IP Address"), tstr); |
| 8670 | 6120 g_free(tstr); |
| 6121 } | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6122 oscar_string_append(gc->account, str, "\n<br>", _("First Name"), info->first); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6123 oscar_string_append(gc->account, str, "\n<br>", _("Last Name"), info->last); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6124 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) { |
| 8670 | 6125 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
| 6126 g_free(utf8); | |
| 4625 | 6127 } |
| 6128 if (info->numaddresses && info->email2) { | |
| 6129 int i; | |
| 6130 for (i = 0; i < info->numaddresses; i++) { | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6131 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) { |
| 10683 | 6132 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
| 8670 | 6133 g_free(utf8); |
| 4643 | 6134 } |
| 4625 | 6135 } |
| 4624 | 6136 } |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6137 oscar_string_append(gc->account, str, "\n<br>", _("Mobile Phone"), info->mobile); |
| 10022 | 6138 if (info->gender != 0) |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6139 oscar_string_append(gc->account, str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); |
| 12491 | 6140 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { |
| 4627 | 6141 struct tm tm; |
| 6142 tm.tm_mday = (int)info->birthday; | |
| 6143 tm.tm_mon = (int)info->birthmonth-1; | |
| 6144 tm.tm_year = (int)info->birthyear-1900; | |
|
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6145 oscar_string_append(gc->account, str, "\n<br>", _("Birthday"), |
|
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13074
diff
changeset
|
6146 gaim_date_format_short(&tm)); |
| 4151 | 6147 } |
| 12491 | 6148 if ((info->age > 0) && (info->age < 255)) { |
| 4624 | 6149 char age[5]; |
| 6150 snprintf(age, sizeof(age), "%hhd", info->age); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6151 oscar_string_append(gc->account, str, "\n<br>", _("Age"), age); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6152 } |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6153 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) { |
| 8670 | 6154 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
| 6155 g_free(utf8); | |
| 4819 | 6156 } |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6157 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) { |
| 8670 | 6158 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
| 6159 g_free(utf8); | |
| 6160 } | |
| 10683 | 6161 g_string_append_printf(str, "<hr>"); |
| 4641 | 6162 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
| 8670 | 6163 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6164 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->homeaddr); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6165 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->homecity); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6166 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->homestate); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6167 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->homezip); |
| 10683 | 6168 g_string_append_printf(str, "\n<hr>"); |
| 4151 | 6169 } |
| 4641 | 6170 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
| 8670 | 6171 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6172 oscar_string_append(gc->account, str, "\n<br>", _("Address"), info->workaddr); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6173 oscar_string_append(gc->account, str, "\n<br>", _("City"), info->workcity); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6174 oscar_string_append(gc->account, str, "\n<br>", _("State"), info->workstate); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6175 oscar_string_append(gc->account, str, "\n<br>", _("Zip Code"), info->workzip); |
| 10683 | 6176 g_string_append_printf(str, "\n<hr>"); |
| 4624 | 6177 } |
| 4641 | 6178 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
| 8670 | 6179 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6180 oscar_string_append(gc->account, str, "\n<br>", _("Company"), info->workcompany); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6181 oscar_string_append(gc->account, str, "\n<br>", _("Division"), info->workdivision); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6182 oscar_string_append(gc->account, str, "\n<br>", _("Position"), info->workposition); |
|
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6183 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) { |
| 8670 | 6184 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
| 6185 g_free(utf8); | |
| 4624 | 6186 } |
| 10683 | 6187 g_string_append_printf(str, "\n<hr>"); |
| 8670 | 6188 } |
| 6189 | |
| 9634 | 6190 if (buddy != NULL) |
| 6191 alias = gaim_buddy_get_alias(buddy); | |
| 6192 else | |
| 6193 alias = who; | |
|
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11532
diff
changeset
|
6194 gaim_notify_userinfo(gc, who, str->str, NULL, NULL); |
| 8670 | 6195 g_string_free(str, TRUE); |
| 4151 | 6196 |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6197 return 1; |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6198 } |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6199 |
| 13239 | 6200 static int gaim_icqalias(OscarSession *sess, FlapFrame *fr, ...) |
| 4759 | 6201 { |
| 5575 | 6202 GaimConnection *gc = sess->aux_data; |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6203 GaimAccount *account = gaim_connection_get_account(gc); |
| 4820 | 6204 gchar who[16], *utf8; |
| 6695 | 6205 GaimBuddy *b; |
| 4759 | 6206 va_list ap; |
| 6207 struct aim_icq_info *info; | |
| 6208 | |
| 6209 va_start(ap, fr); | |
| 6210 info = va_arg(ap, struct aim_icq_info *); | |
| 6211 va_end(ap); | |
| 6212 | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
6213 if (info->uin && info->nick && info->nick[0] && (utf8 = oscar_utf8_try_convert(account, info->nick))) { |
| 5556 | 6214 g_snprintf(who, sizeof(who), "%u", info->uin); |
| 4820 | 6215 serv_got_alias(gc, who, utf8); |
| 4759 | 6216 if ((b = gaim_find_buddy(gc->account, who))) { |
| 7693 | 6217 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", utf8); |
| 4759 | 6218 } |
| 4820 | 6219 g_free(utf8); |
| 4759 | 6220 } |
| 6221 | |
| 6222 return 1; | |
| 6223 } | |
| 6224 | |
| 13239 | 6225 static int gaim_popup(OscarSession *sess, FlapFrame *fr, ...) |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6226 { |
| 7032 | 6227 GaimConnection *gc = sess->aux_data; |
| 6228 gchar *text; | |
| 6229 va_list ap; | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6230 char *msg, *url; |
| 13234 | 6231 guint16 wid, hei, delay; |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6232 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6233 va_start(ap, fr); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6234 msg = va_arg(ap, char *); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6235 url = va_arg(ap, char *); |
| 13234 | 6236 wid = (guint16) va_arg(ap, int); |
| 6237 hei = (guint16) va_arg(ap, int); | |
| 6238 delay = (guint16) va_arg(ap, int); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6239 va_end(ap); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6240 |
| 7032 | 6241 text = g_strdup_printf("%s<br><a href=\"%s\">%s</a>", msg, url, url); |
| 6242 gaim_notify_formatted(gc, NULL, _("Pop-Up Message"), NULL, text, NULL, NULL); | |
| 6243 g_free(text); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6244 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6245 return 1; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6246 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
6247 |
| 11359 | 6248 static void oscar_searchresults_add_buddy_cb(GaimConnection *gc, GList *row) |
| 6249 { | |
| 6250 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), | |
| 6251 g_list_nth_data(row, 0), NULL, NULL); | |
| 6252 } | |
| 6253 | |
| 13239 | 6254 static int gaim_parse_searchreply(OscarSession *sess, FlapFrame *fr, ...) |
| 7032 | 6255 { |
| 6873 | 6256 GaimConnection *gc = sess->aux_data; |
| 11359 | 6257 GaimNotifySearchResults *results; |
| 6258 GaimNotifySearchColumn *column; | |
| 6873 | 6259 gchar *secondary; |
| 6260 int i, num; | |
| 2086 | 6261 va_list ap; |
| 6873 | 6262 char *email, *SNs; |
| 2086 | 6263 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6264 va_start(ap, fr); |
| 6873 | 6265 email = va_arg(ap, char *); |
| 2086 | 6266 num = va_arg(ap, int); |
| 6267 SNs = va_arg(ap, char *); | |
| 6268 va_end(ap); | |
| 6269 | |
|
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6270 results = gaim_notify_searchresults_new(); |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6271 |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6272 if (results == NULL) { |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6273 gaim_debug_error("oscar", "gaim_parse_searchreply: " |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6274 "Unable to display the search results.\n"); |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6275 gaim_notify_error(gc, NULL, |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6276 _("Unable to display the search results."), |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6277 NULL); |
| 12260 | 6278 return 1; |
|
12257
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6279 } |
|
ca27de274225
[gaim-migrate @ 14559]
Richard Laager <rlaager@wiktel.com>
parents:
12254
diff
changeset
|
6280 |
|
12254
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6281 secondary = g_strdup_printf( |
|
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6282 ngettext("The following screen name is associated with %s", |
|
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6283 "The following screen names are associated with %s", |
|
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6284 num), |
|
95fd673021f6
[gaim-migrate @ 14556]
Richard Laager <rlaager@wiktel.com>
parents:
12243
diff
changeset
|
6285 email); |
| 10439 | 6286 |
| 11359 | 6287 column = gaim_notify_searchresults_column_new("Screen name"); |
| 6288 gaim_notify_searchresults_column_add(results, column); | |
| 6289 | |
| 6290 for (i = 0; i < num; i++) { | |
| 6291 GList *row = NULL; | |
| 6292 row = g_list_append(row, g_strdup(&SNs[i * (MAXSNLEN + 1)])); | |
| 6293 gaim_notify_searchresults_row_add(results, row); | |
| 6294 } | |
|
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12617
diff
changeset
|
6295 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD, |
| 11359 | 6296 oscar_searchresults_add_buddy_cb); |
| 6297 gaim_notify_searchresults(gc, NULL, NULL, secondary, results, NULL, NULL); | |
| 6873 | 6298 |
| 6299 g_free(secondary); | |
| 2086 | 6300 |
| 6301 return 1; | |
| 6302 } | |
| 6303 | |
| 13239 | 6304 static int gaim_parse_searcherror(OscarSession *sess, FlapFrame *fr, ...) { |
| 2086 | 6305 va_list ap; |
| 6873 | 6306 char *email; |
| 5420 | 6307 char *buf; |
| 2086 | 6308 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6309 va_start(ap, fr); |
| 6873 | 6310 email = va_arg(ap, char *); |
| 2086 | 6311 va_end(ap); |
| 6312 | |
| 6873 | 6313 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
|
6314 gaim_notify_error(sess->aux_data, NULL, buf, NULL); |
| 5420 | 6315 g_free(buf); |
| 2086 | 6316 |
| 6317 return 1; | |
| 6318 } | |
| 6319 | |
| 13239 | 6320 static int gaim_account_confirm(OscarSession *sess, FlapFrame *fr, ...) { |
| 6873 | 6321 GaimConnection *gc = sess->aux_data; |
| 13234 | 6322 guint16 status; |
| 2086 | 6323 va_list ap; |
| 6324 char msg[256]; | |
| 6325 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6326 va_start(ap, fr); |
| 13234 | 6327 status = (guint16) va_arg(ap, unsigned int); /* status code of confirmation request */ |
| 2086 | 6328 va_end(ap); |
| 6329 | |
| 8660 | 6330 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6331 "account confirmation returned status 0x%04x (%s)\n", status, |
| 3912 | 6332 status ? "unknown" : "email sent"); |
| 6333 if (!status) { | |
| 5302 | 6334 g_snprintf(msg, sizeof(msg), _("You should receive an email asking to confirm %s."), |
| 5575 | 6335 gaim_account_get_username(gaim_connection_get_account(gc))); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6336 gaim_notify_info(gc, NULL, _("Account Confirmation Requested"), msg); |
| 2086 | 6337 } |
| 6338 | |
| 6339 return 1; | |
| 6340 } | |
| 6341 | |
| 13239 | 6342 static int gaim_info_change(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 6343 GaimConnection *gc = sess->aux_data; |
| 2086 | 6344 va_list ap; |
| 13234 | 6345 guint16 perms, err; |
| 3912 | 6346 char *url, *sn, *email; |
| 6347 int change; | |
| 2086 | 6348 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6349 va_start(ap, fr); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
6350 change = va_arg(ap, int); |
| 13234 | 6351 perms = (guint16) va_arg(ap, unsigned int); |
| 6352 err = (guint16) va_arg(ap, unsigned int); | |
| 3912 | 6353 url = va_arg(ap, char *); |
| 6354 sn = va_arg(ap, char *); | |
| 6355 email = va_arg(ap, char *); | |
| 2086 | 6356 va_end(ap); |
| 6357 | |
| 8660 | 6358 gaim_debug_misc("oscar", |
| 9626 | 6359 "account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
| 6360 change ? "change" : "request", perms, err, | |
| 6361 (url != NULL) ? url : "(null)", | |
| 6362 (sn != NULL) ? sn : "(null)", | |
| 6363 (email != NULL) ? email : "(null)"); | |
| 6364 | |
| 6365 if ((err > 0) && (url != NULL)) { | |
| 3912 | 6366 char *dialog_msg; |
| 6367 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
| 6368 switch (err) { | |
| 6369 case 0x0001: { | |
| 6370 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
| 6371 } break; | |
| 6372 case 0x0006: { | |
| 11399 | 6373 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because it is invalid."), err); |
| 3912 | 6374 } break; |
| 6375 case 0x000b: { | |
| 6376 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
| 6377 } break; | |
| 6378 case 0x001d: { | |
| 6379 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); | |
| 6380 } break; | |
| 6381 case 0x0021: { | |
| 6382 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); | |
| 6383 } break; | |
| 6384 case 0x0023: { | |
| 6385 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
| 6386 } break; | |
| 6387 default: { | |
| 6388 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
| 6389 } break; | |
| 6390 } | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6391 gaim_notify_error(gc, NULL, dialog_top, dialog_msg); |
| 3912 | 6392 g_free(dialog_top); |
| 6393 g_free(dialog_msg); | |
| 6394 return 1; | |
| 6395 } | |
| 6396 | |
| 9626 | 6397 if (sn != NULL) { |
| 4585 | 6398 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
|
6399 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
| 3912 | 6400 g_free(dialog_msg); |
| 6401 } | |
| 6402 | |
| 9626 | 6403 if (email != NULL) { |
| 13226 | 6404 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), |
| 5575 | 6405 gaim_account_get_username(gaim_connection_get_account(gc)), email); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6406 gaim_notify_info(gc, NULL, _("Account Info"), dialog_msg); |
| 3912 | 6407 g_free(dialog_msg); |
| 2086 | 6408 } |
| 6409 | |
| 6410 return 1; | |
| 6411 } | |
| 6412 | |
| 5575 | 6413 static void oscar_keepalive(GaimConnection *gc) { |
| 7283 | 6414 OscarData *od = (OscarData *)gc->proto_data; |
| 4617 | 6415 aim_flap_nop(od->sess, od->conn); |
| 2086 | 6416 } |
| 6417 | |
| 6059 | 6418 static int oscar_send_typing(GaimConnection *gc, const char *name, int typing) { |
| 7283 | 6419 OscarData *od = (OscarData *)gc->proto_data; |
| 8971 | 6420 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
| 6421 if (dim && dim->connected) | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6422 if (typing == GAIM_TYPING) |
| 4870 | 6423 aim_odc_send_typing(od->sess, dim->conn, 0x0002); |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6424 else if (typing == GAIM_TYPED) |
| 4870 | 6425 aim_odc_send_typing(od->sess, dim->conn, 0x0001); |
| 6426 else | |
| 6427 aim_odc_send_typing(od->sess, dim->conn, 0x0000); | |
| 3595 | 6428 else { |
| 5300 | 6429 /* Don't send if this turkey is in our deny list */ |
| 6430 GSList *list; | |
| 6431 for (list=gc->account->deny; (list && aim_sncmp(name, list->data)); list=list->next); | |
| 6432 if (!list) { | |
| 7261 | 6433 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(gc->account, name)); |
| 5300 | 6434 if (bi && bi->typingnot) { |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6435 if (typing == GAIM_TYPING) |
| 5300 | 6436 aim_im_sendmtn(od->sess, 0x0001, name, 0x0002); |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5868
diff
changeset
|
6437 else if (typing == GAIM_TYPED) |
| 5300 | 6438 aim_im_sendmtn(od->sess, 0x0001, name, 0x0001); |
| 6439 else | |
| 6440 aim_im_sendmtn(od->sess, 0x0001, name, 0x0000); | |
| 6441 } | |
| 3595 | 6442 } |
| 6443 } | |
| 2993 | 6444 return 0; |
| 6445 } | |
| 9030 | 6446 |
| 13239 | 6447 static int gaim_odc_send_im(OscarSession *, OscarConnection *, const char *, GaimMessageFlags); |
| 12216 | 6448 |
| 6449 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags) { | |
| 7283 | 6450 OscarData *od = (OscarData *)gc->proto_data; |
| 10246 | 6451 GaimAccount *account = gaim_connection_get_account(gc); |
| 8971 | 6452 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
|
6453 int ret = 0; |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6454 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
| 12677 | 6455 char *tmp1, *tmp2; |
| 6456 | |
| 6457 if (imflags & GAIM_MESSAGE_AUTO_RESP) | |
| 6458 tmp1 = gaim_str_sub_away_formatters(message, name); | |
| 6459 else | |
| 6460 tmp1 = g_strdup(message); | |
| 3458 | 6461 |
| 4838 | 6462 if (dim && dim->connected) { |
| 6463 /* If we're directly connected, send a direct IM */ | |
| 12677 | 6464 ret = gaim_odc_send_im(od->sess, dim->conn, tmp1, imflags); |
| 2086 | 6465 } else { |
| 4738 | 6466 struct buddyinfo *bi; |
| 3008 | 6467 struct aim_sendimext_args args; |
| 6468 struct stat st; | |
|
6478
338147ea6896
[gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
6469 gsize len; |
| 10246 | 6470 GaimConversation *conv; |
| 6471 | |
| 11338 | 6472 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account); |
| 8962 | 6473 |
| 12677 | 6474 if (strstr(tmp1, "<IMG ")) |
| 8962 | 6475 gaim_conversation_write(conv, "", |
| 6476 _("Your IM Image was not sent. " | |
| 6477 "You must be Direct Connected to send IM Images."), | |
| 6478 GAIM_MESSAGE_ERROR, time(NULL)); | |
| 4269 | 6479 |
| 10246 | 6480 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, name)); |
| 4738 | 6481 if (!bi) { |
| 6482 bi = g_new0(struct buddyinfo, 1); | |
| 10246 | 6483 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, name)), bi); |
| 4738 | 6484 } |
| 6485 | |
| 3008 | 6486 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
| 4665 | 6487 if (od->icq) { |
| 11185 | 6488 /* We have to present different "features" (whose meaning |
| 11172 | 6489 is unclear and are merely a result of protocol inspection) |
| 6490 to offline ICQ buddies. Otherwise, the official | |
| 6491 ICQ client doesn't treat those messages as being "ANSI- | |
| 6492 encoded" (and instead, assumes them to be UTF-8). | |
| 6493 For more details, see SF issue 1179452. | |
| 6494 */ | |
| 6495 GaimBuddy *buddy = gaim_find_buddy(gc->account, name); | |
| 11910 | 6496 if (buddy && GAIM_BUDDY_IS_ONLINE(buddy)) { |
| 11172 | 6497 args.features = features_icq; |
| 6498 args.featureslen = sizeof(features_icq); | |
| 6499 } else { | |
| 6500 args.features = features_icq_offline; | |
| 6501 args.featureslen = sizeof(features_icq_offline); | |
| 6502 } | |
| 3008 | 6503 args.flags |= AIM_IMFLAGS_OFFLINE; |
| 4665 | 6504 } else { |
| 6505 args.features = features_aim; | |
| 6506 args.featureslen = sizeof(features_aim); | |
| 4972 | 6507 |
| 12216 | 6508 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
| 4972 | 6509 args.flags |= AIM_IMFLAGS_AWAY; |
| 4665 | 6510 } |
| 4269 | 6511 |
| 4738 | 6512 if (bi->ico_need) { |
| 8660 | 6513 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6514 "Sending buddy icon request with message\n"); |
| 3008 | 6515 args.flags |= AIM_IMFLAGS_BUDDYREQ; |
| 4738 | 6516 bi->ico_need = FALSE; |
| 3008 | 6517 } |
| 4269 | 6518 |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6519 if (iconfile && !g_stat(iconfile, &st)) { |
|
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
6520 FILE *file = g_fopen(iconfile, "rb"); |
| 3008 | 6521 if (file) { |
| 11159 | 6522 guchar *buf = g_malloc(st.st_size); |
| 9532 | 6523 /* XXX - Use g_file_get_contents()? */ |
| 3008 | 6524 fread(buf, 1, st.st_size, file); |
| 6039 | 6525 fclose(file); |
| 4269 | 6526 |
| 3008 | 6527 args.iconlen = st.st_size; |
| 4617 | 6528 args.iconsum = aimutil_iconsum(buf, st.st_size); |
| 3008 | 6529 args.iconstamp = st.st_mtime; |
| 6530 | |
| 7406 | 6531 if ((args.iconlen != bi->ico_me_len) || (args.iconsum != bi->ico_me_csum) || (args.iconstamp != bi->ico_me_time)) { |
| 4738 | 6532 bi->ico_informed = FALSE; |
| 7406 | 6533 bi->ico_sent = FALSE; |
| 6534 } | |
| 4738 | 6535 |
| 6536 if (!bi->ico_informed) { | |
| 8660 | 6537 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6538 "Claiming to have a buddy icon\n"); |
| 4738 | 6539 args.flags |= AIM_IMFLAGS_HASICON; |
| 6540 bi->ico_me_len = args.iconlen; | |
| 6541 bi->ico_me_csum = args.iconsum; | |
| 6542 bi->ico_me_time = args.iconstamp; | |
| 6543 bi->ico_informed = TRUE; | |
| 6544 } | |
| 6545 | |
| 3008 | 6546 g_free(buf); |
| 2086 | 6547 } |
| 6548 } | |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
6549 g_free(iconfile); |
| 4269 | 6550 |
| 3008 | 6551 args.destsn = name; |
| 4269 | 6552 |
| 8985 | 6553 /* |
|
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6554 * If we're IMing an SMS user or an ICQ user from an ICQ account, then strip HTML. |
| 13226 | 6555 */ |
|
13168
bdb8d7beb5a7
[gaim-migrate @ 15531]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13165
diff
changeset
|
6556 if (aim_sn_is_sms(name)) { |
|
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6557 /* Messaging an SMS (mobile) user */ |
| 13226 | 6558 tmp2 = gaim_unescape_html(tmp1); |
|
13165
c0a6b8f29035
[gaim-migrate @ 15528]
Evan Schoenberg <evan.s@dreskin.net>
parents:
13158
diff
changeset
|
6559 } else if (aim_sn_is_icq(gaim_account_get_username(account))) { |
| 10781 | 6560 if (aim_sn_is_icq(name)) |
| 6561 /* From ICQ to ICQ */ | |
| 12677 | 6562 tmp2 = gaim_unescape_html(tmp1); |
| 10781 | 6563 else |
| 6564 /* From ICQ to AIM */ | |
| 12677 | 6565 tmp2 = g_strdup(tmp1); |
| 8995 | 6566 } else { |
| 10785 | 6567 /* From AIM to AIM and AIM to ICQ */ |
| 12677 | 6568 tmp2 = g_strdup(tmp1); |
| 8995 | 6569 } |
| 12677 | 6570 g_free(tmp1); |
| 6571 tmp1 = tmp2; | |
| 6572 len = strlen(tmp1); | |
| 6573 | |
| 6574 gaim_plugin_oscar_convert_to_best_encoding(gc, name, tmp1, (char **)&args.msg, &args.msglen, &args.charset, &args.charsubset); | |
| 9830 | 6575 gaim_debug_info("oscar", "Sending IM, charset=0x%04hx, charsubset=0x%04hx, length=%d\n", |
| 6576 args.charset, args.charsubset, args.msglen); | |
| 4617 | 6577 ret = aim_im_sendch1_ext(od->sess, &args); |
| 9830 | 6578 g_free((char *)args.msg); |
| 2086 | 6579 } |
| 4838 | 6580 |
| 12677 | 6581 g_free(tmp1); |
| 6310 | 6582 |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6583 if (ret >= 0) |
|
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6584 return 1; |
| 6310 | 6585 |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
6586 return ret; |
| 2086 | 6587 } |
| 6588 | |
| 7011 | 6589 static void oscar_get_info(GaimConnection *gc, const char *name) { |
| 7283 | 6590 OscarData *od = (OscarData *)gc->proto_data; |
| 7011 | 6591 |
| 9975 | 6592 if (od->icq && aim_sn_is_icq(name)) |
| 4624 | 6593 aim_icq_getallinfo(od->sess, name); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
6594 else |
| 7235 | 6595 aim_locate_getinfoshort(od->sess, name, 0x00000003); |
| 7011 | 6596 } |
| 6597 | |
| 8950 | 6598 #if 0 |
| 7011 | 6599 static void oscar_set_dir(GaimConnection *gc, const char *first, const char *middle, const char *last, |
| 3466 | 6600 const char *maiden, const char *city, const char *state, const char *country, int web) { |
| 4617 | 6601 /* XXX - some of these things are wrong, but i'm lazy */ |
| 7283 | 6602 OscarData *od = (OscarData *)gc->proto_data; |
| 7011 | 6603 aim_locate_setdirinfo(od->sess, first, middle, last, |
| 2086 | 6604 maiden, NULL, NULL, city, state, NULL, 0, web); |
| 6605 } | |
| 8950 | 6606 #endif |
| 2086 | 6607 |
| 5575 | 6608 static void oscar_set_idle(GaimConnection *gc, int time) { |
| 7283 | 6609 OscarData *od = (OscarData *)gc->proto_data; |
| 7474 | 6610 aim_srv_setidle(od->sess, time); |
| 2086 | 6611 } |
| 6612 | |
| 11347 | 6613 static |
| 6614 gchar *gaim_prpl_oscar_convert_to_infotext(const gchar *str, gsize *ret_len, char **encoding) | |
| 6615 { | |
| 9807 | 6616 int charset = 0; |
| 11347 | 6617 char *encoded = NULL; |
| 6618 | |
| 6619 charset = oscar_charset_check(str); | |
| 6620 if (charset == AIM_CHARSET_UNICODE) { | |
| 6621 encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL); | |
| 6622 *encoding = "unicode-2-0"; | |
| 6623 } else if (charset == AIM_CHARSET_CUSTOM) { | |
| 6624 encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL); | |
| 6625 *encoding = "iso-8859-1"; | |
| 6626 } else { | |
| 6627 encoded = g_strdup(str); | |
| 6628 *ret_len = strlen(str); | |
| 6629 *encoding = "us-ascii"; | |
| 6630 } | |
| 6631 | |
| 6632 return encoded; | |
| 6633 } | |
| 6634 | |
| 6635 static void | |
| 6636 oscar_set_info(GaimConnection *gc, const char *rawinfo) | |
| 6637 { | |
| 11965 | 6638 GaimAccount *account; |
| 11347 | 6639 GaimStatus *status; |
| 11965 | 6640 |
| 6641 account = gaim_connection_get_account(gc); | |
| 6642 status = gaim_account_get_active_status(account); | |
| 6643 oscar_set_info_and_status(account, TRUE, rawinfo, FALSE, status); | |
| 6644 } | |
| 6645 | |
| 6646 static void | |
| 6647 oscar_set_extendedstatus(GaimConnection *gc) | |
| 6648 { | |
| 6649 OscarData *od; | |
| 6650 GaimAccount *account; | |
| 12653 | 6651 GaimStatus *status; |
| 6652 const gchar *status_id; | |
| 13234 | 6653 guint32 data = 0x00000000; |
| 11965 | 6654 |
| 6655 od = gc->proto_data; | |
| 6656 account = gaim_connection_get_account(gc); | |
| 12653 | 6657 status = gaim_account_get_active_status(account); |
| 6658 status_id = gaim_status_get_id(status); | |
| 11965 | 6659 |
| 12652 | 6660 data |= AIM_ICQ_STATE_HIDEIP; |
| 6661 if (gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE)) | |
| 6662 data |= AIM_ICQ_STATE_WEBAWARE; | |
| 6663 | |
| 12653 | 6664 if (!strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE) || !strcmp(status_id, OSCAR_STATUS_ID_AVAILABLE)) |
| 6665 data |= AIM_ICQ_STATE_NORMAL; | |
| 6666 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) | |
| 6667 data |= AIM_ICQ_STATE_AWAY; | |
| 6668 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) | |
| 6669 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY; | |
| 6670 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) | |
| 6671 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
| 6672 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) | |
| 6673 data |= AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY; | |
| 6674 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
| 6675 data |= AIM_ICQ_STATE_CHAT; | |
| 6676 else if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
| 12652 | 6677 data |= AIM_ICQ_STATE_INVISIBLE; |
| 12653 | 6678 else if (!strcmp(status_id, OSCAR_STATUS_ID_CUSTOM)) |
| 6679 data |= AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY; | |
| 12652 | 6680 |
| 6681 aim_setextstatus(od->sess, data); | |
| 11965 | 6682 } |
| 6683 | |
| 6684 static void | |
| 6685 oscar_set_info_and_status(GaimAccount *account, gboolean setinfo, const char *rawinfo, | |
| 6686 gboolean setstatus, GaimStatus *status) | |
| 6687 { | |
| 6688 GaimConnection *gc = gaim_account_get_connection(account); | |
| 6689 OscarData *od = gc->proto_data; | |
| 6690 GaimPresence *presence; | |
| 11347 | 6691 GaimStatusType *status_type; |
| 6692 GaimStatusPrimitive primitive; | |
| 11965 | 6693 gboolean invisible; |
| 11347 | 6694 |
| 6695 char *htmlinfo; | |
| 6696 char *info_encoding = NULL; | |
| 6697 char *info = NULL; | |
| 6698 gsize infolen = 0; | |
| 6699 | |
| 6700 const char *htmlaway; | |
| 6701 char *away_encoding = NULL; | |
| 6702 char *away = NULL; | |
| 6703 gsize awaylen = 0; | |
| 6704 | |
| 6705 status_type = gaim_status_get_type(status); | |
| 6706 primitive = gaim_status_type_get_primitive(status_type); | |
| 11965 | 6707 presence = gaim_account_get_presence(account); |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6708 invisible = gaim_presence_is_status_primitive_active(presence, GAIM_STATUS_INVISIBLE); |
| 11965 | 6709 |
| 6710 if (!setinfo) | |
| 6711 { | |
| 6712 /* Do nothing! */ | |
| 6713 } | |
| 6714 else if (od->rights.maxsiglen == 0) | |
| 6715 { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6716 gaim_notify_warning(gc, NULL, _("Unable to set AIM profile."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6717 _("You have probably requested to set your " |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6718 "profile before the login procedure completed. " |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6719 "Your profile remains unset; try setting it " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
6720 "again when you are fully connected.")); |
| 11965 | 6721 } |
| 6722 else if (rawinfo != NULL) | |
| 11347 | 6723 { |
| 6724 htmlinfo = gaim_strdup_withhtml(rawinfo); | |
| 6725 info = gaim_prpl_oscar_convert_to_infotext(htmlinfo, &infolen, &info_encoding); | |
| 6726 g_free(htmlinfo); | |
| 6727 | |
| 6728 if (infolen > od->rights.maxsiglen) | |
| 6729 { | |
| 6730 gchar *errstr; | |
| 6731 errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte " | |
| 6732 "has been exceeded. Gaim has truncated it for you.", | |
| 6733 "The maximum profile length of %d bytes " | |
| 6734 "has been exceeded. Gaim has truncated it for you.", | |
| 6735 od->rights.maxsiglen), od->rights.maxsiglen); | |
| 6736 gaim_notify_warning(gc, NULL, _("Profile too long."), errstr); | |
| 6737 g_free(errstr); | |
| 6738 } | |
| 6739 } | |
| 6740 | |
| 11965 | 6741 if (!setstatus) |
| 6742 { | |
| 6743 /* Do nothing! */ | |
| 6744 } | |
| 6745 else if (primitive == GAIM_STATUS_AVAILABLE) | |
| 11347 | 6746 { |
| 12349 | 6747 const char *status_html; |
| 6748 char *status_text; | |
| 6749 | |
| 6750 status_html = gaim_status_get_attr_string(status, "message"); | |
| 6751 if (status_html != NULL) | |
| 11965 | 6752 { |
| 12349 | 6753 status_text = gaim_markup_strip_html(status_html); |
| 12617 | 6754 /* If the status_text is longer than 60 character then truncate it */ |
| 6755 if (strlen(status_text) > 60) | |
| 6756 { | |
| 6757 char *tmp = g_utf8_find_prev_char(status_text, &status_text[58]); | |
| 6758 strcpy(tmp, "..."); | |
| 6759 } | |
| 12349 | 6760 aim_srv_setstatusmsg(od->sess, status_text); |
| 6761 g_free(status_text); | |
| 11965 | 6762 } |
| 6763 | |
| 6764 /* This is needed for us to un-set any previous away message. */ | |
| 6765 away = g_strdup(""); | |
| 6766 } | |
| 6767 else if (primitive == GAIM_STATUS_AWAY) | |
| 6768 { | |
| 11347 | 6769 htmlaway = gaim_status_get_attr_string(status, "message"); |
| 11965 | 6770 if ((htmlaway == NULL) || (*htmlaway == '\0')) |
| 11347 | 6771 htmlaway = _("Away"); |
| 6772 away = gaim_prpl_oscar_convert_to_infotext(htmlaway, &awaylen, &away_encoding); | |
| 6773 | |
| 6774 if (awaylen > od->rights.maxawaymsglen) | |
| 6775 { | |
| 6776 gchar *errstr; | |
| 6777 | |
| 6778 errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte " | |
| 6779 "has been exceeded. Gaim has truncated it for you.", | |
| 6780 "The maximum away message length of %d bytes " | |
| 6781 "has been exceeded. Gaim has truncated it for you.", | |
| 6782 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | |
| 6783 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | |
| 6784 g_free(errstr); | |
| 6785 } | |
| 6786 } | |
| 6787 | |
| 11965 | 6788 if (setstatus) |
| 6789 oscar_set_extendedstatus(gc); | |
| 6790 | |
| 11347 | 6791 aim_locate_setprofile(od->sess, info_encoding, info, MIN(infolen, od->rights.maxsiglen), |
| 6792 away_encoding, away, MIN(awaylen, od->rights.maxawaymsglen)); | |
| 6793 g_free(info); | |
| 6794 g_free(away); | |
| 2086 | 6795 } |
| 6796 | |
| 9991 | 6797 static void |
| 6798 oscar_set_status_icq(GaimAccount *account, GaimStatus *status) | |
| 2993 | 6799 { |
| 9991 | 6800 GaimConnection *gc = gaim_account_get_connection(account); |
| 10646 | 6801 OscarData *od = NULL; |
| 9991 | 6802 |
| 10646 | 6803 if (gc) |
| 6804 od = (OscarData *)gc->proto_data; | |
| 6805 if (!od) | |
| 6806 return; | |
| 6807 | |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
6808 if (gaim_status_type_get_primitive(gaim_status_get_type(status)) == GAIM_STATUS_INVISIBLE) |
| 11766 | 6809 account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; |
| 8265 | 6810 else |
| 11766 | 6811 account->perm_deny = GAIM_PRIVACY_DENY_USERS; |
| 9991 | 6812 |
| 8265 | 6813 if ((od->sess->ssi.received_data) && (aim_ssi_getpermdeny(od->sess->ssi.local) != account->perm_deny)) |
| 6814 aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff); | |
| 4342 | 6815 |
| 12653 | 6816 oscar_set_extendedstatus(gc); |
| 2993 | 6817 } |
| 6818 | |
| 9991 | 6819 static void |
| 6820 oscar_set_status(GaimAccount *account, GaimStatus *status) | |
| 2993 | 6821 { |
| 10747 | 6822 gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status)); |
| 6823 | |
| 10498 | 6824 if (!gaim_status_is_active(status)) |
| 10485 | 6825 return; |
| 6826 | |
| 11718 | 6827 if (!gaim_account_is_connected(account)) |
| 6828 return; | |
| 6829 | |
| 12653 | 6830 /* Set the AIM-style away message for both AIM and ICQ accounts */ |
| 6831 oscar_set_info_and_status(account, FALSE, NULL, TRUE, status); | |
| 6832 | |
| 6833 /* Set the ICQ status for ICQ accounts only */ | |
| 11718 | 6834 if (aim_sn_is_icq(gaim_account_get_username(account))) |
| 6835 oscar_set_status_icq(account, status); | |
| 2086 | 6836 } |
| 6837 | |
| 11285 | 6838 #ifdef CRAZY_WARN |
| 9991 | 6839 static void |
| 6840 oscar_warn(GaimConnection *gc, const char *name, gboolean anonymous) { | |
| 7283 | 6841 OscarData *od = (OscarData *)gc->proto_data; |
| 9753 | 6842 aim_im_warn(od->sess, od->conn, name, anonymous ? AIM_WARN_ANON : 0); |
| 2086 | 6843 } |
| 11285 | 6844 #endif |
| 2086 | 6845 |
| 10747 | 6846 static void |
| 6847 oscar_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
| 7283 | 6848 OscarData *od = (OscarData *)gc->proto_data; |
| 9285 | 6849 |
| 6850 if (!aim_snvalid(buddy->name)) { | |
| 8092 | 6851 gchar *buf; |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6852 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); |
| 9627 | 6853 if (!gaim_conv_present_error(buddy->name, gaim_connection_get_account(gc), buf)) |
| 6854 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); | |
| 8092 | 6855 g_free(buf); |
| 8150 | 6856 |
| 6857 /* Remove from local list */ | |
| 9285 | 6858 gaim_blist_remove_buddy(buddy); |
| 8150 | 6859 |
| 8092 | 6860 return; |
| 6861 } | |
| 6862 | |
| 9285 | 6863 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY))) { |
| 6864 if (buddy && group) { | |
| 8660 | 6865 gaim_debug_info("oscar", |
| 9285 | 6866 "ssi: adding buddy %s to group %s\n", buddy->name, group->name); |
| 9620 | 6867 aim_ssi_addbuddy(od->sess, buddy->name, group->name, gaim_buddy_get_alias_only(buddy), NULL, NULL, 0); |
| 4230 | 6868 } |
| 6869 } | |
| 8150 | 6870 |
| 10157 | 6871 /* XXX - Should this be done from AIM accounts, as well? */ |
| 4759 | 6872 if (od->icq) |
| 9285 | 6873 aim_icq_getalias(od->sess, buddy->name); |
| 6874 } | |
| 6875 | |
| 6876 static void oscar_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { | |
| 7283 | 6877 OscarData *od = (OscarData *)gc->proto_data; |
| 9285 | 6878 |
| 4230 | 6879 if (od->sess->ssi.received_data) { |
| 8660 | 6880 gaim_debug_info("oscar", |
| 9285 | 6881 "ssi: deleting buddy %s from group %s\n", buddy->name, group->name); |
| 6882 aim_ssi_delbuddy(od->sess, buddy->name, group->name); | |
| 4230 | 6883 } |
| 10866 | 6884 } |
| 6885 | |
| 5575 | 6886 static void oscar_move_buddy(GaimConnection *gc, const char *name, const char *old_group, const char *new_group) { |
| 7283 | 6887 OscarData *od = (OscarData *)gc->proto_data; |
| 4303 | 6888 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
| 8660 | 6889 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
6890 "ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
| 4889 | 6891 aim_ssi_movebuddy(od->sess, old_group, new_group, name); |
| 4269 | 6892 } |
| 6893 } | |
| 6894 | |
| 5575 | 6895 static void oscar_alias_buddy(GaimConnection *gc, const char *name, const char *alias) { |
| 7283 | 6896 OscarData *od = (OscarData *)gc->proto_data; |
| 4269 | 6897 if (od->sess->ssi.received_data) { |
| 6898 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
| 6899 if (gname) { | |
| 8660 | 6900 gaim_debug_info("oscar", |
| 9586 | 6901 "ssi: changing the alias for buddy %s to %s\n", name, alias ? alias : "(none)"); |
| 4889 | 6902 aim_ssi_aliasbuddy(od->sess, gname, name, alias); |
| 4269 | 6903 } |
| 6904 } | |
| 6905 } | |
| 6906 | |
| 11005 | 6907 /* |
| 6908 * FYI, the OSCAR SSI code removes empty groups automatically. | |
| 6909 */ | |
| 9285 | 6910 static void oscar_rename_group(GaimConnection *gc, const char *old_name, GaimGroup *group, GList *moved_buddies) { |
| 8341 | 6911 OscarData *od = (OscarData *)gc->proto_data; |
| 4230 | 6912 |
| 6913 if (od->sess->ssi.received_data) { | |
| 9285 | 6914 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, NULL, AIM_SSI_TYPE_GROUP)) { |
| 6915 GList *cur, *groups = NULL; | |
| 11643 | 6916 GaimAccount *account = gaim_connection_get_account(gc); |
| 9285 | 6917 |
| 6918 /* Make a list of what the groups each buddy is in */ | |
| 6919 for (cur = moved_buddies; cur != NULL; cur = cur->next) { | |
| 6920 GaimBlistNode *node = cur->data; | |
|
11002
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6921 /* node is GaimBuddy, parent is a GaimContact. |
|
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6922 * We must go two levels up to get the Group */ |
|
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6923 groups = g_list_append(groups, |
|
bf03a5271395
[gaim-migrate @ 12857]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10949
diff
changeset
|
6924 node->parent->parent); |
| 9285 | 6925 } |
| 6926 | |
| 11643 | 6927 gaim_account_remove_buddies(account, moved_buddies, groups); |
| 6928 gaim_account_add_buddies(account, moved_buddies); | |
| 9285 | 6929 g_list_free(groups); |
| 8660 | 6930 gaim_debug_info("oscar", |
| 9285 | 6931 "ssi: moved all buddies from group %s to %s\n", old_name, group->name); |
| 4230 | 6932 } else { |
| 9285 | 6933 aim_ssi_rename_group(od->sess, old_name, group->name); |
| 8660 | 6934 gaim_debug_info("oscar", |
| 9285 | 6935 "ssi: renamed group %s to %s\n", old_name, group->name); |
| 2995 | 6936 } |
| 6937 } | |
| 6938 } | |
| 6939 | |
| 5968 | 6940 static gboolean gaim_ssi_rerequestdata(gpointer data) { |
| 13239 | 6941 OscarSession *sess = data; |
| 12663 | 6942 |
| 6350 | 6943 aim_ssi_reqdata(sess); |
| 12663 | 6944 |
| 13060 | 6945 return TRUE; |
| 5968 | 6946 } |
| 6947 | |
| 13239 | 6948 static int gaim_ssi_parseerr(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 6949 GaimConnection *gc = sess->aux_data; |
| 7283 | 6950 OscarData *od = gc->proto_data; |
| 4642 | 6951 va_list ap; |
| 13234 | 6952 guint16 reason; |
| 4642 | 6953 |
| 6954 va_start(ap, fr); | |
| 13234 | 6955 reason = (guint16)va_arg(ap, unsigned int); |
| 4642 | 6956 va_end(ap); |
| 6957 | |
| 8660 | 6958 gaim_debug_error("oscar", "ssi: SNAC error %hu\n", reason); |
| 4642 | 6959 |
| 6960 if (reason == 0x0005) { | |
| 5892 | 6961 gaim_notify_error(gc, NULL, _("Unable To Retrieve Buddy List"), |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
6962 _("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.")); |
| 12663 | 6963 if (od->getblisttimer > 0) |
| 6964 gaim_timeout_remove(od->getblisttimer); | |
| 6965 od->getblisttimer = gaim_timeout_add(30000, gaim_ssi_rerequestdata, od->sess); | |
| 4642 | 6966 } |
| 6967 | |
| 11965 | 6968 oscar_set_extendedstatus(gc); |
| 6969 | |
| 4642 | 6970 /* Activate SSI */ |
| 6971 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
| 6972 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
| 8660 | 6973 gaim_debug_info("oscar", "ssi: activating server-stored buddy list\n"); |
| 4642 | 6974 aim_ssi_enable(od->sess); |
| 6975 | |
| 6976 return 1; | |
| 6977 } | |
| 6978 | |
| 13239 | 6979 static int gaim_ssi_parserights(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 6980 GaimConnection *gc = sess->aux_data; |
| 7283 | 6981 OscarData *od = (OscarData *)gc->proto_data; |
| 9982 | 6982 int i; |
| 6983 va_list ap; | |
| 6984 int numtypes; | |
| 13234 | 6985 guint16 *maxitems; |
| 2991 | 6986 |
| 6987 va_start(ap, fr); | |
| 4230 | 6988 numtypes = va_arg(ap, int); |
| 13234 | 6989 maxitems = va_arg(ap, guint16 *); |
| 2991 | 6990 va_end(ap); |
| 6991 | |
| 8660 | 6992 gaim_debug_misc("oscar", "ssi rights:"); |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6993 |
| 4230 | 6994 for (i=0; i<numtypes; i++) |
| 8660 | 6995 gaim_debug_misc(NULL, " max type 0x%04x=%hd,", |
|
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6996 i, maxitems[i]); |
|
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5208
diff
changeset
|
6997 |
| 8660 | 6998 gaim_debug_misc(NULL, "\n"); |
| 4230 | 6999 |
| 7000 if (numtypes >= 0) | |
| 7001 od->rights.maxbuddies = maxitems[0]; | |
| 7002 if (numtypes >= 1) | |
| 7003 od->rights.maxgroups = maxitems[1]; | |
| 7004 if (numtypes >= 2) | |
| 7005 od->rights.maxpermits = maxitems[2]; | |
| 7006 if (numtypes >= 3) | |
| 7007 od->rights.maxdenies = maxitems[3]; | |
| 2991 | 7008 |
| 7009 return 1; | |
| 7010 } | |
| 7011 | |
| 13239 | 7012 static int gaim_ssi_parselist(OscarSession *sess, FlapFrame *fr, ...) |
| 11965 | 7013 { |
| 7014 GaimConnection *gc; | |
| 7015 OscarData *od; | |
| 7016 GaimAccount *account; | |
| 8150 | 7017 GaimGroup *g; |
| 7018 GaimBuddy *b; | |
| 2995 | 7019 struct aim_ssi_item *curitem; |
| 13234 | 7020 guint32 tmp; |
| 4230 | 7021 va_list ap; |
| 13234 | 7022 guint16 fmtver, numitems; |
| 8219 | 7023 struct aim_ssi_item *items; |
| 13234 | 7024 guint32 timestamp; |
| 4230 | 7025 |
| 11965 | 7026 gc = sess->aux_data; |
| 7027 od = gc->proto_data; | |
| 7028 account = gaim_connection_get_account(gc); | |
| 7029 | |
| 4230 | 7030 va_start(ap, fr); |
| 13234 | 7031 fmtver = (guint16)va_arg(ap, int); |
| 7032 numitems = (guint16)va_arg(ap, int); | |
| 8219 | 7033 items = va_arg(ap, struct aim_ssi_item *); |
| 13234 | 7034 timestamp = va_arg(ap, guint32); |
| 8219 | 7035 va_end(ap); |
| 2991 | 7036 |
| 12663 | 7037 /* Don't attempt to re-request our buddy list later */ |
| 7038 if (od->getblisttimer != 0) | |
| 7039 gaim_timeout_remove(od->getblisttimer); | |
| 7040 od->getblisttimer = 0; | |
| 7041 | |
| 8660 | 7042 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7043 "ssi: syncing local list and server list\n"); |
| 2991 | 7044 |
| 8219 | 7045 if ((timestamp == 0) || (numitems == 0)) { |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7046 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 | 7047 return 1; |
| 7048 } | |
| 7049 | |
| 2991 | 7050 /* Clean the buddy list */ |
| 4889 | 7051 aim_ssi_cleanlist(sess); |
| 2991 | 7052 |
| 8150 | 7053 { /* If not in server list then prune from local list */ |
| 7054 GaimBlistNode *gnode, *cnode, *bnode; | |
| 7055 GaimBuddyList *blist; | |
| 9539 | 7056 GSList *cur, *next; |
| 8150 | 7057 |
| 7058 /* Buddies */ | |
| 7059 cur = NULL; | |
| 7060 if ((blist = gaim_get_blist()) != NULL) { | |
| 7061 for (gnode = blist->root; gnode; gnode = gnode->next) { | |
| 7062 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 7063 continue; | |
| 7064 g = (GaimGroup *)gnode; | |
| 7065 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 7066 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 7067 continue; | |
| 7068 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
| 7069 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 7070 continue; | |
| 7071 b = (GaimBuddy *)bnode; | |
| 7072 if (b->account == gc->account) { | |
| 7073 if (aim_ssi_itemlist_exists(sess->ssi.local, b->name)) { | |
| 7074 /* If the buddy is an ICQ user then load his nickname */ | |
| 7075 const char *servernick = gaim_blist_node_get_string((GaimBlistNode*)b, "servernick"); | |
| 8214 | 7076 char *alias; |
| 8150 | 7077 if (servernick) |
| 7078 serv_got_alias(gc, b->name, servernick); | |
| 7079 | |
| 7080 /* Store local alias on server */ | |
| 8214 | 7081 alias = aim_ssi_getalias(sess->ssi.local, g->name, b->name); |
| 8150 | 7082 if (!alias && b->alias && strlen(b->alias)) |
| 7083 aim_ssi_aliasbuddy(sess, g->name, b->name, b->alias); | |
| 7084 free(alias); | |
| 7085 } else { | |
| 8660 | 7086 gaim_debug_info("oscar", |
| 8150 | 7087 "ssi: removing buddy %s from local list\n", b->name); |
| 7088 /* We can't actually remove now because it will screw up our looping */ | |
| 7089 cur = g_slist_prepend(cur, b); | |
| 7090 } | |
| 7091 } | |
| 7092 } | |
| 7093 } | |
| 7094 } | |
| 7095 } | |
| 8175 | 7096 |
| 8150 | 7097 while (cur != NULL) { |
| 7098 b = cur->data; | |
| 7099 cur = g_slist_remove(cur, b); | |
| 7100 gaim_blist_remove_buddy(b); | |
| 7101 } | |
| 7102 | |
| 7103 /* Permit list */ | |
| 7104 if (gc->account->permit) { | |
| 9539 | 7105 next = gc->account->permit; |
| 7106 while (next != NULL) { | |
| 7107 cur = next; | |
| 7108 next = next->next; | |
| 8150 | 7109 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
| 8660 | 7110 gaim_debug_info("oscar", |
| 8150 | 7111 "ssi: removing permit %s from local list\n", (const char *)cur->data); |
| 7112 gaim_privacy_permit_remove(account, cur->data, TRUE); | |
| 7113 } | |
| 9539 | 7114 } |
| 8150 | 7115 } |
| 7116 | |
| 7117 /* Deny list */ | |
| 7118 if (gc->account->deny) { | |
| 9539 | 7119 next = gc->account->deny; |
| 7120 while (next != NULL) { | |
| 7121 cur = next; | |
| 7122 next = next->next; | |
| 8150 | 7123 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
| 8660 | 7124 gaim_debug_info("oscar", |
| 8150 | 7125 "ssi: removing deny %s from local list\n", (const char *)cur->data); |
| 7126 gaim_privacy_deny_remove(account, cur->data, TRUE); | |
| 7127 } | |
| 9539 | 7128 } |
| 8150 | 7129 } |
| 7130 /* Presence settings (idle time visibility) */ | |
| 7131 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) | |
| 7132 if (!(tmp & 0x400)) | |
| 7133 aim_ssi_setpresence(sess, tmp | 0x400); | |
| 7134 } /* end pruning buddies from local list */ | |
| 7135 | |
| 2991 | 7136 /* Add from server list to local list */ |
| 4230 | 7137 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
| 7328 | 7138 if ((curitem->name == NULL) || (g_utf8_validate(curitem->name, -1, NULL))) |
| 2991 | 7139 switch (curitem->type) { |
| 4230 | 7140 case 0x0000: { /* Buddy */ |
| 4251 | 7141 if (curitem->name) { |
| 4292 | 7142 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7143 char *gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
| 4282 | 7144 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7145 char *alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
| 8150 | 7146 b = gaim_find_buddy(gc->account, curitem->name); |
| 4458 | 7147 /* Should gname be freed here? -- elb */ |
| 4754 | 7148 /* Not with the current code, but that might be cleaner -- med */ |
| 4458 | 7149 free(alias); |
| 8150 | 7150 if (b) { |
| 4292 | 7151 /* Get server stored alias */ |
| 4705 | 7152 if (alias_utf8) { |
| 8150 | 7153 g_free(b->alias); |
| 7154 b->alias = g_strdup(alias_utf8); | |
| 4705 | 7155 } |
| 4282 | 7156 } else { |
| 8150 | 7157 b = gaim_buddy_new(gc->account, curitem->name, alias_utf8); |
| 5146 | 7158 |
| 4754 | 7159 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { |
| 4687 | 7160 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); |
| 4754 | 7161 gaim_blist_add_group(g, NULL); |
| 7162 } | |
| 5146 | 7163 |
| 8660 | 7164 gaim_debug_info("oscar", |
| 9285 | 7165 "ssi: adding buddy %s to group %s to local list\n", curitem->name, gname_utf8 ? gname_utf8 : _("Orphans")); |
| 8150 | 7166 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 4251 | 7167 } |
| 8341 | 7168 if (!aim_sncmp(curitem->name, account->username)) { |
| 7169 char *comment = aim_ssi_getcomment(sess->ssi.local, gname, curitem->name); | |
| 7170 gaim_check_comment(od, comment); | |
| 7171 free(comment); | |
| 7172 } | |
| 7162 | 7173 g_free(gname_utf8); |
| 7174 g_free(alias_utf8); | |
| 2991 | 7175 } |
| 4230 | 7176 } break; |
| 7177 | |
| 7178 case 0x0001: { /* Group */ | |
| 4282 | 7179 /* Shouldn't add empty groups */ |
| 4230 | 7180 } break; |
| 7181 | |
| 7182 case 0x0002: { /* Permit buddy */ | |
| 2991 | 7183 if (curitem->name) { |
| 4230 | 7184 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
| 2991 | 7185 GSList *list; |
| 5575 | 7186 for (list=account->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 7187 if (!list) { |
| 8660 | 7188 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7189 "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
|
7190 gaim_privacy_permit_add(account, curitem->name, TRUE); |
| 2991 | 7191 } |
| 7192 } | |
| 4230 | 7193 } break; |
| 7194 | |
| 7195 case 0x0003: { /* Deny buddy */ | |
| 2991 | 7196 if (curitem->name) { |
| 7197 GSList *list; | |
| 5575 | 7198 for (list=account->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 7199 if (!list) { |
| 8660 | 7200 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7201 "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
|
7202 gaim_privacy_deny_add(account, curitem->name, TRUE); |
| 2991 | 7203 } |
| 7204 } | |
| 4230 | 7205 } break; |
| 7206 | |
| 7207 case 0x0004: { /* Permit/deny setting */ | |
| 2991 | 7208 if (curitem->data) { |
| 13234 | 7209 guint8 permdeny; |
| 5575 | 7210 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != account->perm_deny)) { |
| 8660 | 7211 gaim_debug_info("oscar", |
| 5575 | 7212 "ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny); |
| 7213 account->perm_deny = permdeny; | |
| 11766 | 7214 if (od->icq && account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) { |
| 7215 gaim_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE); | |
| 4342 | 7216 } |
| 2991 | 7217 } |
| 7218 } | |
| 4230 | 7219 } break; |
| 7220 | |
| 7221 case 0x0005: { /* Presence setting */ | |
| 3109 | 7222 /* We don't want to change Gaim's setting because it applies to all accounts */ |
| 4230 | 7223 } break; |
| 2991 | 7224 } /* End of switch on curitem->type */ |
| 7225 } /* End of for loop */ | |
| 4230 | 7226 |
| 11965 | 7227 oscar_set_extendedstatus(gc); |
| 4901 | 7228 |
| 4342 | 7229 /* Activate SSI */ |
| 7230 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
| 7231 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
| 8660 | 7232 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7233 "ssi: activating server-stored buddy list\n"); |
| 4642 | 7234 aim_ssi_enable(sess); |
| 4342 | 7235 |
| 2991 | 7236 return 1; |
| 2086 | 7237 } |
| 4230 | 7238 |
| 13239 | 7239 static int gaim_ssi_parseack(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 7240 GaimConnection *gc = sess->aux_data; |
| 4230 | 7241 va_list ap; |
| 7242 struct aim_ssi_tmp *retval; | |
| 7243 | |
| 7244 va_start(ap, fr); | |
| 7245 retval = va_arg(ap, struct aim_ssi_tmp *); | |
| 7246 va_end(ap); | |
| 7247 | |
| 7248 while (retval) { | |
| 8660 | 7249 gaim_debug_misc("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7250 "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 | 7251 |
| 7252 if (retval->ack != 0xffff) | |
| 7253 switch (retval->ack) { | |
| 7254 case 0x0000: { /* added successfully */ | |
| 7255 } break; | |
| 7256 | |
| 4829 | 7257 case 0x000c: { /* you are over the limit, the cheat is to the limit, come on fhqwhgads */ |
| 7258 gchar *buf; | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7259 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)"))); |
| 9758 | 7260 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
| 9627 | 7261 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
| 4829 | 7262 g_free(buf); |
| 7263 } | |
| 7264 | |
| 7023 | 7265 case 0x000e: { /* buddy requires authorization */ |
| 13234 | 7266 if ((retval->action == OSCAR_SUBTYPE_FEEDBAG_ADD) && (retval->name)) |
| 4269 | 7267 gaim_auth_sendrequest(gc, retval->name); |
| 4230 | 7268 } break; |
| 7269 | |
| 7270 default: { /* La la la */ | |
| 5197 | 7271 gchar *buf; |
| 8660 | 7272 gaim_debug_error("oscar", "ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7273 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)"))); |
| 9758 | 7274 if ((retval->name != NULL) && !gaim_conv_present_error(retval->name, gaim_connection_get_account(gc), buf)) |
| 9627 | 7275 gaim_notify_error(gc, NULL, _("Unable To Add"), buf); |
| 5197 | 7276 g_free(buf); |
| 4230 | 7277 } break; |
| 7278 } | |
| 7279 | |
| 7280 retval = retval->next; | |
| 7281 } | |
| 7282 | |
| 7283 return 1; | |
| 7284 } | |
| 7285 | |
| 13239 | 7286 static int gaim_ssi_parseadd(OscarSession *sess, FlapFrame *fr, ...) { |
| 8227 | 7287 GaimConnection *gc = sess->aux_data; |
| 7288 char *gname, *gname_utf8, *alias, *alias_utf8; | |
| 7289 GaimBuddy *b; | |
| 7290 GaimGroup *g; | |
| 7291 va_list ap; | |
| 13234 | 7292 guint16 type; |
| 8227 | 7293 const char *name; |
| 7294 | |
| 7295 va_start(ap, fr); | |
| 13234 | 7296 type = (guint16)va_arg(ap, int); |
| 8227 | 7297 name = va_arg(ap, char *); |
| 7298 va_end(ap); | |
| 7299 | |
| 7300 if ((type != 0x0000) || (name == NULL)) | |
| 7301 return 1; | |
| 7302 | |
| 7303 gname = aim_ssi_itemlist_findparentname(sess->ssi.local, name); | |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7304 gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL; |
| 8227 | 7305 alias = aim_ssi_getalias(sess->ssi.local, gname, name); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
7306 alias_utf8 = alias ? oscar_utf8_try_convert(gc->account, alias) : NULL; |
| 8227 | 7307 b = gaim_find_buddy(gc->account, name); |
| 7308 free(alias); | |
| 7309 | |
| 7310 if (b) { | |
| 7311 /* Get server stored alias */ | |
| 7312 if (alias_utf8) { | |
| 7313 g_free(b->alias); | |
| 7314 b->alias = g_strdup(alias_utf8); | |
| 7315 } | |
| 7316 } else { | |
| 7317 b = gaim_buddy_new(gc->account, name, alias_utf8); | |
| 7318 | |
| 7319 if (!(g = gaim_find_group(gname_utf8 ? gname_utf8 : _("Orphans")))) { | |
| 7320 g = gaim_group_new(gname_utf8 ? gname_utf8 : _("Orphans")); | |
| 7321 gaim_blist_add_group(g, NULL); | |
| 7322 } | |
| 7323 | |
| 8660 | 7324 gaim_debug_info("oscar", |
| 9285 | 7325 "ssi: adding buddy %s to group %s to local list\n", name, gname_utf8 ? gname_utf8 : _("Orphans")); |
| 8227 | 7326 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 7327 } | |
| 7328 g_free(gname_utf8); | |
| 7329 g_free(alias_utf8); | |
| 7330 | |
| 7331 return 1; | |
| 7332 } | |
| 7333 | |
| 13239 | 7334 static int gaim_ssi_authgiven(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 7335 GaimConnection *gc = sess->aux_data; |
| 4230 | 7336 va_list ap; |
| 7337 char *sn, *msg; | |
| 4236 | 7338 gchar *dialog_msg, *nombre; |
| 4230 | 7339 struct name_data *data; |
| 6695 | 7340 GaimBuddy *buddy; |
| 4230 | 7341 |
| 7342 va_start(ap, fr); | |
| 7343 sn = va_arg(ap, char *); | |
| 7344 msg = va_arg(ap, char *); | |
| 7345 va_end(ap); | |
| 7346 | |
| 8660 | 7347 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7348 "ssi: %s has given you permission to add him to your buddy list\n", sn); |
| 4230 | 7349 |
| 4687 | 7350 buddy = gaim_find_buddy(gc->account, sn); |
| 9620 | 7351 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
| 7352 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
| 4236 | 7353 else |
| 7354 nombre = g_strdup(sn); | |
| 7355 | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7356 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 | 7357 data = g_new(struct name_data, 1); |
| 7358 data->gc = gc; | |
| 7359 data->name = g_strdup(sn); | |
| 7360 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7361 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7362 gaim_request_yes_no(gc, NULL, _("Authorization Given"), dialog_msg, |
| 10116 | 7363 GAIM_DEFAULT_ACTION_NONE, data, |
| 7023 | 7364 G_CALLBACK(gaim_icq_buddyadd), |
| 5836 | 7365 G_CALLBACK(oscar_free_name_data)); |
| 4236 | 7366 |
| 4230 | 7367 g_free(dialog_msg); |
| 4236 | 7368 g_free(nombre); |
| 4230 | 7369 |
| 7370 return 1; | |
| 7371 } | |
| 7372 | |
| 13239 | 7373 static int gaim_ssi_authrequest(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 7374 GaimConnection *gc = sess->aux_data; |
| 4230 | 7375 va_list ap; |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7376 char *sn; |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7377 char *msg; |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7378 GaimAccount *account = gaim_connection_get_account(gc); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7379 gchar *nombre; |
|
11567
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7380 gchar *reason = NULL; |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7381 gchar *dialog_msg; |
| 4230 | 7382 struct name_data *data; |
| 6695 | 7383 GaimBuddy *buddy; |
| 4230 | 7384 |
| 7385 va_start(ap, fr); | |
| 7386 sn = va_arg(ap, char *); | |
| 7387 msg = va_arg(ap, char *); | |
| 7388 va_end(ap); | |
| 7389 | |
| 8660 | 7390 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7391 "ssi: received authorization request from %s\n", sn); |
| 4230 | 7392 |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7393 buddy = gaim_find_buddy(account, sn); |
| 9620 | 7394 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
| 7395 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
| 4236 | 7396 else |
| 7397 nombre = g_strdup(sn); | |
| 7398 | |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7399 if (msg != NULL) |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7400 reason = gaim_plugin_oscar_decode_im_part(account, sn, AIM_CHARSET_CUSTOM, 0x0000, msg, strlen(msg)); |
|
11567
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7401 |
|
603a0e626332
[gaim-migrate @ 13834]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11537
diff
changeset
|
7402 if (reason == NULL) |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7403 reason = g_strdup(_("No reason given.")); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7404 |
| 10949 | 7405 dialog_msg = g_strdup_printf( |
| 7406 _("The user %s wants to add %s to their buddy list for the following reason:\n%s"), | |
|
11102
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7407 nombre, gaim_account_get_username(account), reason); |
|
eac408c8900f
[gaim-migrate @ 13142]
Richard Laager <rlaager@wiktel.com>
parents:
11084
diff
changeset
|
7408 g_free(reason); |
| 10949 | 7409 |
| 4230 | 7410 data = g_new(struct name_data, 1); |
| 7411 data->gc = gc; | |
| 7412 data->name = g_strdup(sn); | |
| 7413 data->nick = NULL; | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7414 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
7415 gaim_request_action(gc, NULL, _("Authorization Request"), dialog_msg, |
| 9972 | 7416 GAIM_DEFAULT_ACTION_NONE, data, 2, |
|
12603
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7417 _("_Authorize"), G_CALLBACK(gaim_auth_grant), |
|
e4e47871c373
[gaim-migrate @ 14938]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
7418 _("_Deny"), G_CALLBACK(gaim_auth_dontgrant_msgprompt)); |
| 4236 | 7419 |
| 4230 | 7420 g_free(dialog_msg); |
| 4236 | 7421 g_free(nombre); |
| 4230 | 7422 |
| 7423 return 1; | |
| 7424 } | |
| 7425 | |
| 13239 | 7426 static int gaim_ssi_authreply(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 7427 GaimConnection *gc = sess->aux_data; |
| 4230 | 7428 va_list ap; |
| 7429 char *sn, *msg; | |
| 4236 | 7430 gchar *dialog_msg, *nombre; |
| 13234 | 7431 guint8 reply; |
| 6695 | 7432 GaimBuddy *buddy; |
| 4230 | 7433 |
| 7434 va_start(ap, fr); | |
| 7435 sn = va_arg(ap, char *); | |
| 13234 | 7436 reply = (guint8)va_arg(ap, int); |
| 4230 | 7437 msg = va_arg(ap, char *); |
| 7438 va_end(ap); | |
| 7439 | |
| 8660 | 7440 gaim_debug_info("oscar", |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
7441 "ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
| 4236 | 7442 |
| 4687 | 7443 buddy = gaim_find_buddy(gc->account, sn); |
| 9620 | 7444 if (buddy && (gaim_buddy_get_alias_only(buddy))) |
| 7445 nombre = g_strdup_printf("%s (%s)", sn, gaim_buddy_get_alias_only(buddy)); | |
| 4236 | 7446 else |
| 7447 nombre = g_strdup(sn); | |
| 7448 | |
| 4230 | 7449 if (reply) { |
| 7450 /* Granted */ | |
| 7023 | 7451 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
|
7452 gaim_notify_info(gc, NULL, _("Authorization Granted"), dialog_msg); |
| 4230 | 7453 } else { |
| 7454 /* Denied */ | |
| 7023 | 7455 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
|
7456 gaim_notify_info(gc, NULL, _("Authorization Denied"), dialog_msg); |
| 4230 | 7457 } |
| 7458 g_free(dialog_msg); | |
| 4236 | 7459 g_free(nombre); |
| 4230 | 7460 |
| 7461 return 1; | |
| 7462 } | |
| 7463 | |
| 13239 | 7464 static int gaim_ssi_gotadded(OscarSession *sess, FlapFrame *fr, ...) { |
| 5575 | 7465 GaimConnection *gc = sess->aux_data; |
| 4230 | 7466 va_list ap; |
| 7467 char *sn; | |
| 6695 | 7468 GaimBuddy *buddy; |
| 4230 | 7469 |
| 7470 va_start(ap, fr); | |
| 7471 sn = va_arg(ap, char *); | |
| 7472 va_end(ap); | |
| 7473 | |
| 4687 | 7474 buddy = gaim_find_buddy(gc->account, sn); |
| 8660 | 7475 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7476 "ssi: %s added you to their buddy list\n", sn); |
| 9620 | 7477 gaim_account_notify_added(gc->account, NULL, sn, (buddy ? gaim_buddy_get_alias_only(buddy) : NULL), NULL); |
| 4230 | 7478 |
| 7479 return 1; | |
| 7480 } | |
| 2086 | 7481 |
| 5575 | 7482 static GList *oscar_chat_info(GaimConnection *gc) { |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7483 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7484 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7485 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7486 pce = g_new0(struct proto_chat_entry, 1); |
| 9770 | 7487 pce->label = _("_Room:"); |
| 5234 | 7488 pce->identifier = "room"; |
| 10475 | 7489 pce->required = TRUE; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7490 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7491 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7492 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 7493 pce->label = _("_Exchange:"); |
| 5234 | 7494 pce->identifier = "exchange"; |
| 10475 | 7495 pce->required = TRUE; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7496 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7497 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7498 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7499 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7500 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7501 return m; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7502 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7503 |
|
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
12393
diff
changeset
|
7504 static GHashTable *oscar_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
| 9754 | 7505 { |
| 7506 GHashTable *defaults; | |
| 7507 | |
| 7508 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 7509 | |
| 7510 if (chat_name != NULL) | |
| 7511 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
| 7512 | |
| 7513 return defaults; | |
| 7514 } | |
| 7515 | |
| 9917 | 7516 static char *oscar_get_chat_name(GHashTable *data) { |
| 7517 return g_strdup(g_hash_table_lookup(data, "room")); | |
| 7518 } | |
| 7519 | |
| 8308 | 7520 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) { |
| 7521 OscarData *od = (OscarData *)gc->proto_data; | |
| 13239 | 7522 OscarConnection *cur; |
| 5234 | 7523 char *name, *exchange; |
| 7524 | |
| 7525 name = g_hash_table_lookup(data, "room"); | |
| 7526 exchange = g_hash_table_lookup(data, "exchange"); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
7527 |
| 8308 | 7528 if ((name == NULL) || (*name == '\0')) { |
| 7529 gaim_notify_error(gc, NULL, _("Invalid chat name specified."), NULL); | |
| 7530 return; | |
| 7531 } | |
| 7532 | |
|
11461
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7533 gaim_debug_info("oscar", |
|
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7534 "Attempting to join chat room %s.\n", name); |
|
8e749b7c8ccc
[gaim-migrate @ 13701]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11404
diff
changeset
|
7535 |
| 4617 | 7536 if ((cur = aim_getconn_type(od->sess, AIM_CONN_TYPE_CHATNAV))) { |
| 8660 | 7537 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7538 "chatnav exists, creating room\n"); |
| 5234 | 7539 aim_chatnav_createroom(od->sess, cur, name, atoi(exchange)); |
| 2086 | 7540 } else { |
| 7541 /* this gets tricky */ | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7542 struct create_room *cr = g_new0(struct create_room, 1); |
| 8660 | 7543 gaim_debug_info("oscar", |
|
5219
e807abdcee83
[gaim-migrate @ 5589]
Christian Hammond <chipx86@chipx86.com>
parents:
5211
diff
changeset
|
7544 "chatnav does not exist, opening chatnav\n"); |
| 5234 | 7545 cr->exchange = atoi(exchange); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
7546 cr->name = g_strdup(name); |
| 4617 | 7547 od->create_rooms = g_slist_append(od->create_rooms, cr); |
| 7548 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_CHATNAV); | |
| 2086 | 7549 } |
| 7550 } | |
| 7551 | |
| 8308 | 7552 static void oscar_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) { |
| 7553 OscarData *od = (OscarData *)gc->proto_data; | |
| 7554 struct chat_connection *ccon = find_oscar_chat(gc, id); | |
| 10404 | 7555 |
| 7556 if (ccon == NULL) | |
| 2086 | 7557 return; |
| 10404 | 7558 |
| 8225 | 7559 aim_im_sendch2_chatinvite(od->sess, name, message ? message : "", |
| 2086 | 7560 ccon->exchange, ccon->name, 0x0); |
| 7561 } | |
| 7562 | |
| 10458 | 7563 static void |
| 7564 oscar_chat_leave(GaimConnection *gc, int id) | |
| 7565 { | |
| 7566 GaimConversation *conv; | |
| 7567 struct chat_connection *cc; | |
| 7568 | |
| 7569 conv = gaim_find_chat(gc, id); | |
| 7570 | |
| 7571 g_return_if_fail(conv != NULL); | |
| 7572 | |
| 7573 gaim_debug_info("oscar", "Leaving chat room %s\n", conv->name); | |
| 7574 | |
| 7575 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | |
| 7576 oscar_chat_kill(gc, cc); | |
| 2086 | 7577 } |
| 7578 | |
| 12216 | 7579 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) { |
| 8219 | 7580 OscarData *od = (OscarData *)gc->proto_data; |
| 7581 GaimConversation *conv = NULL; | |
| 2086 | 7582 struct chat_connection *c = NULL; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7583 char *buf, *buf2; |
| 13234 | 7584 guint16 charset, charsubset; |
| 9807 | 7585 char *charsetstr = NULL; |
| 10111 | 7586 int len; |
| 8219 | 7587 |
| 7588 if (!(conv = gaim_find_chat(gc, id))) | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7589 return -EINVAL; |
| 2086 | 7590 |
| 8219 | 7591 if (!(c = find_oscar_chat_by_conv(gc, conv))) |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7592 return -EINVAL; |
| 2086 | 7593 |
| 8219 | 7594 buf = gaim_strdup_withhtml(message); |
| 7595 len = strlen(buf); | |
| 7596 | |
| 8962 | 7597 if (strstr(buf, "<IMG ")) |
| 7598 gaim_conversation_write(conv, "", | |
| 13226 | 7599 _("Your IM Image was not sent. " |
| 7600 "You cannot send IM Images in AIM chats."), | |
| 7601 GAIM_MESSAGE_ERROR, time(NULL)); | |
| 8962 | 7602 |
| 9830 | 7603 gaim_plugin_oscar_convert_to_best_encoding(gc, NULL, buf, &buf2, &len, &charset, &charsubset); |
| 8359 | 7604 if ((len > c->maxlen) || (len > c->maxvis)) { |
| 7605 g_free(buf2); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7606 return -E2BIG; |
| 8359 | 7607 } |
| 7608 | |
| 9831 | 7609 if (charset == AIM_CHARSET_ASCII) |
| 7610 charsetstr = "us-ascii"; | |
| 7611 else if (charset == AIM_CHARSET_UNICODE) | |
| 7612 charsetstr = "unicode-2-0"; | |
| 7613 else if (charset == AIM_CHARSET_CUSTOM) | |
| 7614 charsetstr = "iso-8859-1"; | |
| 9807 | 7615 aim_chat_send_im(od->sess, c->conn, 0, buf2, len, charsetstr, "en"); |
| 8219 | 7616 g_free(buf2); |
| 8359 | 7617 |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
7618 return 0; |
| 2086 | 7619 } |
| 7620 | |
| 10042 | 7621 static const char *oscar_list_icon(GaimAccount *a, GaimBuddy *b) |
| 7622 { | |
| 4766 | 7623 if (!b || (b && b->name && b->name[0] == '+')) { |
| 9975 | 7624 if (a != NULL && aim_sn_is_icq(gaim_account_get_username(a))) |
| 4687 | 7625 return "icq"; |
| 7626 else | |
| 7627 return "aim"; | |
| 7628 } | |
|
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5638
diff
changeset
|
7629 |
| 9975 | 7630 if (b != NULL && aim_sn_is_icq(b->name)) |
| 4687 | 7631 return "icq"; |
| 7632 return "aim"; | |
| 7633 } | |
| 7634 | |
| 9972 | 7635 static void oscar_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
| 4687 | 7636 { |
| 7334 | 7637 GaimConnection *gc = NULL; |
| 7638 OscarData *od = NULL; | |
| 10042 | 7639 GaimAccount *account = NULL; |
| 7640 GaimPresence *presence; | |
| 7641 GaimStatus *status; | |
| 7642 const char *status_id; | |
| 4687 | 7643 char *emblems[4] = {NULL,NULL,NULL,NULL}; |
| 7644 int i = 0; | |
| 7334 | 7645 aim_userinfo_t *userinfo = NULL; |
| 7646 | |
| 7647 if (b != NULL) | |
| 7648 account = b->account; | |
| 7649 if (account != NULL) | |
| 7650 gc = account->gc; | |
| 7651 if (gc != NULL) | |
| 7652 od = gc->proto_data; | |
| 7945 | 7653 if (od != NULL) |
| 7654 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
| 4687 | 7655 |
| 10042 | 7656 presence = gaim_buddy_get_presence(b); |
| 7657 status = gaim_presence_get_active_status(presence); | |
| 7658 status_id = gaim_status_get_id(status); | |
| 7659 | |
| 7660 if (gaim_presence_is_online(presence) == FALSE) { | |
| 5131 | 7661 char *gname; |
| 13226 | 7662 if ((b->name) && (od) && (od->sess->ssi.received_data) && |
| 7663 (gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name)) && | |
| 5131 | 7664 (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name))) { |
| 7665 emblems[i++] = "notauthorized"; | |
| 7666 } else { | |
| 7667 emblems[i++] = "offline"; | |
| 7668 } | |
| 7669 } | |
| 4916 | 7670 |
| 10042 | 7671 if (b->name && aim_sn_is_icq(b->name)) { |
| 7672 if (!strcmp(status_id, OSCAR_STATUS_ID_INVISIBLE)) | |
| 7673 emblems[i++] = "invisible"; | |
| 7674 else if (!strcmp(status_id, OSCAR_STATUS_ID_FREE4CHAT)) | |
| 4960 | 7675 emblems[i++] = "freeforchat"; |
| 10042 | 7676 else if (!strcmp(status_id, OSCAR_STATUS_ID_DND)) |
| 4960 | 7677 emblems[i++] = "dnd"; |
| 10042 | 7678 else if (!strcmp(status_id, OSCAR_STATUS_ID_NA)) |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7679 emblems[i++] = "unavailable"; |
| 10042 | 7680 else if (!strcmp(status_id, OSCAR_STATUS_ID_OCCUPIED)) |
| 4960 | 7681 emblems[i++] = "occupied"; |
| 10042 | 7682 else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) |
| 4766 | 7683 emblems[i++] = "away"; |
| 10042 | 7684 } else if (!strcmp(status_id, OSCAR_STATUS_ID_AWAY)) { |
| 7685 emblems[i++] = "away"; | |
| 7686 } | |
| 7687 | |
| 7688 if (userinfo != NULL ) { | |
| 7689 /* if (userinfo->flags & AIM_FLAG_UNCONFIRMED) | |
| 7690 emblems[i++] = "unconfirmed"; */ | |
|
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7691 if ((i < 4) && userinfo->flags & AIM_FLAG_ADMINISTRATOR) |
| 10042 | 7692 emblems[i++] = "admin"; |
|
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7693 if ((i < 4) && userinfo->flags & AIM_FLAG_AOL) |
| 10042 | 7694 emblems[i++] = "aol"; |
|
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7695 if ((i < 4) && userinfo->flags & AIM_FLAG_WIRELESS) |
| 10042 | 7696 emblems[i++] = "wireless"; |
|
11873
346bd669c8f2
[gaim-migrate @ 14164]
Luke Schierer <lschiere@pidgin.im>
parents:
11837
diff
changeset
|
7697 if ((i < 4) && userinfo->flags & AIM_FLAG_ACTIVEBUDDY) |
| 10042 | 7698 emblems[i++] = "activebuddy"; |
| 7699 | |
| 7700 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_HIPTOP)) | |
| 7945 | 7701 emblems[i++] = "hiptop"; |
| 7702 | |
| 10042 | 7703 if ((i < 4) && (userinfo->capabilities & AIM_CAPS_SECUREIM)) |
| 7334 | 7704 emblems[i++] = "secure"; |
| 10042 | 7705 } |
| 7334 | 7706 |
| 4687 | 7707 *se = emblems[0]; |
| 7708 *sw = emblems[1]; | |
| 7709 *nw = emblems[2]; | |
| 7710 *ne = emblems[3]; | |
| 7711 } | |
| 7712 | |
|
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12948
diff
changeset
|
7713 static void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) { |
| 5575 | 7714 GaimConnection *gc = b->account->gc; |
| 7283 | 7715 OscarData *od = gc->proto_data; |
| 7045 | 7716 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
| 5131 | 7717 |
| 7718 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
| 12189 | 7719 GaimPresence *presence; |
| 7720 GaimStatus *status; | |
| 7721 const char *message; | |
| 7722 | |
|
12948
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7723 if (full) |
|
563fb4f1e9fc
[gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents:
12946
diff
changeset
|
7724 oscar_string_append_info(gc, str, "\n", b, userinfo); |
| 7011 | 7725 |
| 12189 | 7726 presence = gaim_buddy_get_presence(b); |
| 7727 status = gaim_presence_get_active_status(presence); | |
| 7728 message = gaim_status_get_attr_string(status, "message"); | |
| 7729 | |
| 12433 | 7730 if (gaim_status_is_available(status)) |
| 7731 { | |
| 7732 if (message != NULL) | |
| 7733 { | |
| 12189 | 7734 /* Available status messages are plain text */ |
|
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7735 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), message); |
| 12433 | 7736 } |
| 7737 } | |
| 7738 else | |
| 7739 { | |
| 7740 if (message != NULL) | |
| 7741 { | |
| 12189 | 7742 /* Away messages are HTML */ |
| 7091 | 7743 gchar *tmp1, *tmp2; |
| 12189 | 7744 tmp2 = gaim_markup_strip_html(message); |
|
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10715
diff
changeset
|
7745 tmp1 = g_markup_escape_text(tmp2, -1); |
| 7091 | 7746 g_free(tmp2); |
| 8700 | 7747 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
| 8461 | 7748 g_free(tmp1); |
|
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7749 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2); |
| 8700 | 7750 g_free(tmp2); |
| 5836 | 7751 } |
| 12433 | 7752 else |
| 7753 { | |
|
12946
a63227edcff0
[gaim-migrate @ 15299]
Richard Laager <rlaager@wiktel.com>
parents:
12943
diff
changeset
|
7754 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>")); |
| 12433 | 7755 } |
| 5131 | 7756 } |
| 8701 | 7757 } |
| 5131 | 7758 } |
| 7759 | |
| 10042 | 7760 static char *oscar_status_text(GaimBuddy *b) |
| 7761 { | |
| 7762 GaimConnection *gc; | |
| 12347 | 7763 GaimAccount *account; |
| 10042 | 7764 OscarData *od; |
| 12347 | 7765 const GaimPresence *presence; |
| 7766 const GaimStatus *status; | |
| 7767 const char *id; | |
| 7768 const char *message; | |
| 5167 | 7769 gchar *ret = NULL; |
| 7770 | |
| 10042 | 7771 gc = gaim_account_get_connection(gaim_buddy_get_account(b)); |
| 12347 | 7772 account = gaim_connection_get_account(gc); |
| 10042 | 7773 od = gc->proto_data; |
| 11248 | 7774 presence = gaim_buddy_get_presence(b); |
| 12347 | 7775 status = gaim_presence_get_active_status(presence); |
| 7776 id = gaim_status_get_id(status); | |
| 11248 | 7777 |
| 7778 if (!gaim_presence_is_online(presence)) | |
| 7779 { | |
| 5167 | 7780 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
| 7781 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | |
| 7782 ret = g_strdup(_("Not Authorized")); | |
| 7783 else | |
| 7784 ret = g_strdup(_("Offline")); | |
| 7785 } | |
| 12365 | 7786 else if (gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AVAILABLE)) |
| 12347 | 7787 { |
| 12365 | 7788 /* Available */ |
| 12347 | 7789 message = gaim_status_get_attr_string(status, "message"); |
| 7790 if (message != NULL) | |
| 7791 { | |
| 7792 ret = g_markup_escape_text(message, -1); | |
| 7793 gaim_util_chrreplace(ret, '\n', ' '); | |
| 7794 } | |
| 7795 } | |
| 12365 | 7796 else if (!gaim_status_is_available(status) && !strcmp(id, OSCAR_STATUS_ID_AWAY)) |
| 11248 | 7797 { |
| 12365 | 7798 /* Away */ |
| 12347 | 7799 message = gaim_status_get_attr_string(status, "message"); |
| 7800 if (message != NULL) | |
| 7801 { | |
| 7802 gchar *tmp1, *tmp2; | |
| 7803 tmp1 = gaim_markup_strip_html(message); | |
| 12361 | 7804 gaim_util_chrreplace(tmp1, '\n', ' '); |
| 12347 | 7805 tmp2 = g_markup_escape_text(tmp1, -1); |
| 7806 ret = gaim_str_sub_away_formatters(tmp2, gaim_account_get_username(account)); | |
| 7807 g_free(tmp1); | |
| 7808 g_free(tmp2); | |
| 7809 } | |
| 7810 else | |
| 7811 { | |
| 7812 ret = g_strdup(_("Away")); | |
| 11510 | 7813 } |
| 11248 | 7814 } |
| 7815 else | |
| 12347 | 7816 ret = g_strdup(gaim_status_get_name(status)); |
| 5167 | 7817 |
| 7818 return ret; | |
| 7819 } | |
| 7820 | |
| 5842 | 7821 |
| 13239 | 7822 static int oscar_icon_req(OscarSession *sess, FlapFrame *fr, ...) { |
| 5842 | 7823 GaimConnection *gc = sess->aux_data; |
| 7283 | 7824 OscarData *od = gc->proto_data; |
| 5892 | 7825 va_list ap; |
| 13234 | 7826 guint16 type; |
| 7827 guint8 flags = 0, length = 0; | |
| 11159 | 7828 guchar *md5 = NULL; |
| 5892 | 7829 |
| 5842 | 7830 va_start(ap, fr); |
| 7831 type = va_arg(ap, int); | |
| 5892 | 7832 |
| 7833 switch(type) { | |
| 7834 case 0x0000: | |
| 7835 case 0x0001: { | |
| 7836 flags = va_arg(ap, int); | |
| 7837 length = va_arg(ap, int); | |
| 11159 | 7838 md5 = va_arg(ap, guchar *); |
| 5892 | 7839 |
| 7840 if (flags == 0x41) { | |
| 7841 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | |
| 7842 od->iconconnecting = TRUE; | |
| 7843 od->set_icon = TRUE; | |
| 7844 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_ICON); | |
| 7845 } else { | |
| 6039 | 7846 struct stat st; |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7847 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
| 6039 | 7848 if (iconfile == NULL) { |
| 8363 | 7849 aim_ssi_delicon(od->sess); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7850 } else if (!g_stat(iconfile, &st)) { |
| 11159 | 7851 guchar *buf = g_malloc(st.st_size); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
7852 FILE *file = g_fopen(iconfile, "rb"); |
| 6039 | 7853 if (file) { |
| 9532 | 7854 /* XXX - Use g_file_get_contents()? */ |
| 6039 | 7855 fread(buf, 1, st.st_size, file); |
| 7856 fclose(file); | |
| 8660 | 7857 gaim_debug_info("oscar", |
| 10042 | 7858 "Uploading icon to icon server\n"); |
| 6879 | 7859 aim_bart_upload(od->sess, buf, st.st_size); |
| 5892 | 7860 } else |
| 8660 | 7861 gaim_debug_error("oscar", |
| 10042 | 7862 "Can't open buddy icon file!\n"); |
| 6039 | 7863 g_free(buf); |
| 7864 } else { | |
| 8660 | 7865 gaim_debug_error("oscar", |
| 10042 | 7866 "Can't stat buddy icon file!\n"); |
| 5892 | 7867 } |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7868 g_free(iconfile); |
| 5892 | 7869 } |
| 8363 | 7870 } else if (flags == 0x81) { |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7871 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gaim_connection_get_account(gc))); |
| 8363 | 7872 if (iconfile == NULL) |
| 7873 aim_ssi_delicon(od->sess); | |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7874 else { |
| 8363 | 7875 aim_ssi_seticon(od->sess, md5, length); |
|
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7876 g_free(iconfile); |
|
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11285
diff
changeset
|
7877 } |
| 8363 | 7878 } |
| 5892 | 7879 } break; |
| 7880 | |
| 7881 case 0x0002: { /* We just set an "available" message? */ | |
| 7882 } break; | |
| 7883 } | |
| 7884 | |
| 5842 | 7885 va_end(ap); |
| 5844 | 7886 |
| 7887 return 0; | |
| 5842 | 7888 } |
| 5892 | 7889 |
| 5575 | 7890 static void oscar_set_permit_deny(GaimConnection *gc) { |
| 7891 GaimAccount *account = gaim_connection_get_account(gc); | |
| 7283 | 7892 OscarData *od = (OscarData *)gc->proto_data; |
| 10866 | 7893 |
| 8175 | 7894 if (od->sess->ssi.received_data) { |
| 7895 switch (account->perm_deny) { | |
| 7896 case GAIM_PRIVACY_ALLOW_ALL: | |
| 7897 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
| 7898 break; | |
| 7899 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
| 7900 aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff); | |
| 7901 break; | |
| 7902 case GAIM_PRIVACY_ALLOW_USERS: | |
| 7903 aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff); | |
| 7904 break; | |
| 7905 case GAIM_PRIVACY_DENY_ALL: | |
| 7906 aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff); | |
| 7907 break; | |
| 7908 case GAIM_PRIVACY_DENY_USERS: | |
| 7909 aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff); | |
| 7910 break; | |
| 7911 default: | |
| 7912 aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff); | |
| 7913 break; | |
| 7914 } | |
| 7915 } | |
| 2086 | 7916 } |
| 7917 | |
| 5575 | 7918 static void oscar_add_permit(GaimConnection *gc, const char *who) { |
| 7283 | 7919 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 7920 gaim_debug_info("oscar", "ssi: About to add a permit\n"); |
| 4230 | 7921 if (od->sess->ssi.received_data) |
| 4889 | 7922 aim_ssi_addpermit(od->sess, who); |
| 2086 | 7923 } |
| 7924 | |
| 5575 | 7925 static void oscar_add_deny(GaimConnection *gc, const char *who) { |
| 7283 | 7926 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 7927 gaim_debug_info("oscar", "ssi: About to add a deny\n"); |
| 4230 | 7928 if (od->sess->ssi.received_data) |
| 4889 | 7929 aim_ssi_adddeny(od->sess, who); |
| 2086 | 7930 } |
| 7931 | |
| 5575 | 7932 static void oscar_rem_permit(GaimConnection *gc, const char *who) { |
| 7283 | 7933 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 7934 gaim_debug_info("oscar", "ssi: About to delete a permit\n"); |
| 4230 | 7935 if (od->sess->ssi.received_data) |
| 4889 | 7936 aim_ssi_delpermit(od->sess, who); |
| 2086 | 7937 } |
| 7938 | |
| 5575 | 7939 static void oscar_rem_deny(GaimConnection *gc, const char *who) { |
| 7283 | 7940 OscarData *od = (OscarData *)gc->proto_data; |
| 8660 | 7941 gaim_debug_info("oscar", "ssi: About to delete a deny\n"); |
| 4230 | 7942 if (od->sess->ssi.received_data) |
| 4889 | 7943 aim_ssi_deldeny(od->sess, who); |
| 2086 | 7944 } |
| 7945 | |
| 9975 | 7946 static GList * |
| 7947 oscar_status_types(GaimAccount *account) | |
| 2086 | 7948 { |
| 12662 | 7949 gboolean is_icq; |
| 9975 | 7950 GList *status_types = NULL; |
| 7951 GaimStatusType *type; | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
7952 |
| 9973 | 7953 g_return_val_if_fail(account != NULL, NULL); |
| 7954 | |
| 13007 | 7955 /* Used to flag some statuses as "user settable" or not */ |
| 12662 | 7956 is_icq = aim_sn_is_icq(gaim_account_get_username(account)); |
| 7957 | |
| 13007 | 7958 /* Common status types */ |
| 7959 /* Really the available message should only be settable for AIM accounts */ | |
| 7960 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, | |
| 7961 OSCAR_STATUS_ID_AVAILABLE, | |
| 7962 NULL, TRUE, TRUE, FALSE, | |
| 7963 "message", _("Message"), | |
| 7964 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 7965 status_types = g_list_append(status_types, type); | |
| 7966 | |
| 7967 type = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, | |
| 7968 OSCAR_STATUS_ID_FREE4CHAT, | |
| 7969 _("Free For Chat"), TRUE, is_icq, FALSE); | |
| 7970 status_types = g_list_append(status_types, type); | |
| 9976 | 7971 |
| 10195 | 7972 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, |
| 7973 OSCAR_STATUS_ID_AWAY, | |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7974 NULL, TRUE, TRUE, FALSE, |
| 10195 | 7975 "message", _("Message"), |
| 7976 gaim_value_new(GAIM_TYPE_STRING), NULL); | |
| 10042 | 7977 status_types = g_list_append(status_types, type); |
| 7978 | |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7979 type = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, |
| 10042 | 7980 OSCAR_STATUS_ID_INVISIBLE, |
|
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12588
diff
changeset
|
7981 NULL, TRUE, TRUE, FALSE); |
| 10042 | 7982 status_types = g_list_append(status_types, type); |
| 7983 | |
| 7984 /* ICQ-specific status types */ | |
| 13007 | 7985 type = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, |
| 7986 OSCAR_STATUS_ID_OCCUPIED, | |
| 7987 _("Occupied"), TRUE, is_icq, FALSE); | |
| 7988 status_types = g_list_append(status_types, type); | |
| 7989 | |
| 7990 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
| 7991 OSCAR_STATUS_ID_DND, | |
| 7992 _("Do Not Disturb"), TRUE, is_icq, FALSE); | |
| 7993 status_types = g_list_append(status_types, type); | |
| 7994 | |
| 7995 type = gaim_status_type_new_full(GAIM_STATUS_EXTENDED_AWAY, | |
| 7996 OSCAR_STATUS_ID_NA, | |
| 7997 _("Not Available"), TRUE, is_icq, FALSE); | |
| 7998 status_types = g_list_append(status_types, type); | |
| 12658 | 7999 |
| 8000 type = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, | |
| 8001 OSCAR_STATUS_ID_OFFLINE, | |
| 8002 NULL, TRUE, TRUE, FALSE); | |
| 9976 | 8003 status_types = g_list_append(status_types, type); |
| 9975 | 8004 |
| 8005 return status_types; | |
| 4333 | 8006 } |
| 8007 | |
| 7172 | 8008 static void oscar_ssi_editcomment(struct name_data *data, const char *text) { |
| 8341 | 8009 GaimConnection *gc = data->gc; |
| 8010 OscarData *od = gc->proto_data; | |
| 7172 | 8011 GaimBuddy *b; |
| 8012 GaimGroup *g; | |
| 8013 | |
| 8014 if (!(b = gaim_find_buddy(gaim_connection_get_account(data->gc), data->name))) { | |
| 8015 oscar_free_name_data(data); | |
| 8016 return; | |
| 8017 } | |
| 8018 | |
| 12088 | 8019 if (!(g = gaim_buddy_get_group(b))) { |
| 7172 | 8020 oscar_free_name_data(data); |
| 8021 return; | |
| 8022 } | |
| 8023 | |
| 8024 aim_ssi_editcomment(od->sess, g->name, data->name, text); | |
| 8341 | 8025 |
| 8026 if (!aim_sncmp(data->name, gc->account->username)) | |
| 8027 gaim_check_comment(od, text); | |
| 8028 | |
| 7172 | 8029 oscar_free_name_data(data); |
| 8030 } | |
| 8031 | |
| 9030 | 8032 static void oscar_buddycb_edit_comment(GaimBlistNode *node, gpointer ignore) { |
| 8033 | |
| 8034 GaimBuddy *buddy; | |
| 8035 GaimConnection *gc; | |
| 8036 OscarData *od; | |
| 8037 struct name_data *data; | |
| 7172 | 8038 GaimGroup *g; |
| 8039 char *comment; | |
| 8040 gchar *comment_utf8; | |
| 9631 | 8041 gchar *title; |
| 7172 | 8042 |
| 9030 | 8043 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
| 8044 | |
| 8045 buddy = (GaimBuddy *) node; | |
| 8046 gc = gaim_account_get_connection(buddy->account); | |
| 8047 od = gc->proto_data; | |
| 8048 | |
| 8049 data = g_new(struct name_data, 1); | |
| 8050 | |
| 12088 | 8051 if (!(g = gaim_buddy_get_group(buddy))) |
| 7172 | 8052 return; |
| 9030 | 8053 comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, buddy->name); |
|
12608
d13810de5bb3
[gaim-migrate @ 14944]
Richard Laager <rlaager@wiktel.com>
parents:
12603
diff
changeset
|
8054 comment_utf8 = comment ? oscar_utf8_try_convert(gc->account, comment) : NULL; |
| 7172 | 8055 |
| 8056 data->gc = gc; | |
| 9030 | 8057 data->name = g_strdup(buddy->name); |
| 7172 | 8058 data->nick = NULL; |
| 8059 | |
| 9631 | 8060 title = g_strdup_printf(_("Buddy Comment for %s"), data->name); |
| 8061 gaim_request_input(gc, title, _("Buddy Comment:"), NULL, | |
| 8697 | 8062 comment_utf8, TRUE, FALSE, NULL, |
| 7172 | 8063 _("OK"), G_CALLBACK(oscar_ssi_editcomment), |
| 8064 _("Cancel"), G_CALLBACK(oscar_free_name_data), | |
| 8065 data); | |
| 9631 | 8066 g_free(title); |
| 7172 | 8067 |
| 8068 free(comment); | |
| 8069 g_free(comment_utf8); | |
| 8070 } | |
| 8071 | |
| 9030 | 8072 static GList *oscar_buddy_menu(GaimBuddy *buddy) { |
| 8073 | |
| 8074 GaimConnection *gc = gaim_account_get_connection(buddy->account); | |
| 7283 | 8075 OscarData *od = gc->proto_data; |
| 9030 | 8076 |
| 4333 | 8077 GList *m = NULL; |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8078 GaimMenuAction *act; |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8079 |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8080 act = gaim_menu_action_new(_("Edit Buddy Comment"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8081 GAIM_CALLBACK(oscar_buddycb_edit_comment), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8082 NULL, NULL); |
| 9030 | 8083 m = g_list_append(m, act); |
| 7172 | 8084 |
| 4333 | 8085 if (od->icq) { |
| 4624 | 8086 #if 0 |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8087 act = gaim_menu_action_new(_("Get Status Msg"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8088 GAIM_CALLBACK(oscar_get_icqstatusmsg), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8089 NULL, NULL); |
| 9030 | 8090 m = g_list_append(m, act); |
| 4624 | 8091 #endif |
| 4333 | 8092 } else { |
| 7011 | 8093 aim_userinfo_t *userinfo; |
| 9030 | 8094 userinfo = aim_locate_finduserinfo(od->sess, buddy->name); |
| 8095 | |
| 8096 if (userinfo && aim_sncmp(gaim_account_get_username(buddy->account), buddy->name) && | |
| 8097 GAIM_BUDDY_IS_ONLINE(buddy)) { | |
| 8098 | |
| 7011 | 8099 if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8100 act = gaim_menu_action_new(_("Direct IM"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8101 GAIM_CALLBACK(oscar_ask_direct_im), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8102 NULL, NULL); |
| 9030 | 8103 m = g_list_append(m, act); |
| 5917 | 8104 } |
| 9466 | 8105 #if 0 |
| 7011 | 8106 if (userinfo->capabilities & AIM_CAPS_GETFILE) { |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8107 act = gaim_menu_action_new(_("Get File"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8108 GAIM_CALLBACK(oscar_ask_getfile), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8109 NULL, NULL); |
| 9030 | 8110 m = g_list_append(m, act); |
| 5917 | 8111 } |
| 4826 | 8112 #endif |
| 4333 | 8113 } |
| 5131 | 8114 } |
| 5197 | 8115 |
| 5131 | 8116 if (od->sess->ssi.received_data) { |
| 9030 | 8117 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); |
| 8118 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { | |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8119 act = gaim_menu_action_new(_("Re-request Authorization"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8120 GAIM_CALLBACK(gaim_auth_sendrequest_menu), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12918
diff
changeset
|
8121 NULL, NULL); |
| 9030 | 8122 m = g_list_append(m, act); |
| 4333 | 8123 } |
| 4916 | 8124 } |
| 10157 | 8125 |
| 4333 | 8126 return m; |
| 8127 } | |
| 8128 | |
| 9030 | 8129 |
| 8130 static GList *oscar_blist_node_menu(GaimBlistNode *node) { | |
| 8131 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { | |
| 8132 return oscar_buddy_menu((GaimBuddy *) node); | |
| 8133 } else { | |
| 8134 return NULL; | |
| 8135 } | |
| 8136 } | |
| 8137 | |
| 10570 | 8138 static void |
| 8139 oscar_icq_privacy_opts(GaimConnection *gc, GaimRequestFields *fields) | |
| 8140 { | |
| 8141 OscarData *od = gc->proto_data; | |
| 8142 GaimAccount *account = gaim_connection_get_account(gc); | |
| 8143 GaimRequestField *f; | |
| 12652 | 8144 gboolean auth, web_aware; |
| 10570 | 8145 |
| 8146 f = gaim_request_fields_get_field(fields, "authorization"); | |
| 8147 auth = gaim_request_field_bool_get_value(f); | |
| 8148 | |
| 8149 f = gaim_request_fields_get_field(fields, "web_aware"); | |
| 8150 web_aware = gaim_request_field_bool_get_value(f); | |
| 8151 | |
| 8152 gaim_account_set_bool(account, "authorization", auth); | |
| 8153 gaim_account_set_bool(account, "web_aware", web_aware); | |
| 8154 | |
| 12652 | 8155 oscar_set_extendedstatus(gc); |
| 8156 aim_icq_setsecurity(od->sess, auth, web_aware); | |
| 10570 | 8157 } |
| 8158 | |
| 8159 static void | |
| 8160 oscar_show_icq_privacy_opts(GaimPluginAction *action) | |
| 8161 { | |
| 8162 GaimConnection *gc = (GaimConnection *) action->context; | |
| 8163 GaimAccount *account = gaim_connection_get_account(gc); | |
| 8164 GaimRequestFields *fields; | |
| 8165 GaimRequestFieldGroup *g; | |
| 8166 GaimRequestField *f; | |
| 12652 | 8167 gboolean auth, web_aware; |
| 10570 | 8168 |
| 8169 auth = gaim_account_get_bool(account, "authorization", OSCAR_DEFAULT_AUTHORIZATION); | |
| 8170 web_aware = gaim_account_get_bool(account, "web_aware", OSCAR_DEFAULT_WEB_AWARE); | |
| 8171 | |
| 8172 fields = gaim_request_fields_new(); | |
| 8173 | |
| 8174 g = gaim_request_field_group_new(NULL); | |
| 8175 | |
| 8176 f = gaim_request_field_bool_new("authorization", _("Require authorization"), auth); | |
| 8177 gaim_request_field_group_add_field(g, f); | |
| 8178 | |
| 12617 | 8179 f = gaim_request_field_bool_new("web_aware", _("Web aware (enabling this will cause you to receive SPAM!)"), web_aware); |
| 10570 | 8180 gaim_request_field_group_add_field(g, f); |
| 8181 | |
| 8182 gaim_request_fields_add_group(fields, g); | |
| 8183 | |
| 8184 gaim_request_fields(gc, _("ICQ Privacy Options"), _("ICQ Privacy Options"), | |
| 8185 NULL, fields, | |
| 8186 _("OK"), G_CALLBACK(oscar_icq_privacy_opts), | |
| 8187 _("Cancel"), NULL, gc); | |
| 8188 } | |
| 9030 | 8189 |
| 5575 | 8190 static void oscar_format_screenname(GaimConnection *gc, const char *nick) { |
| 7283 | 8191 OscarData *od = gc->proto_data; |
| 5575 | 8192 if (!aim_sncmp(gaim_account_get_username(gaim_connection_get_account(gc)), nick)) { |
| 4333 | 8193 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { |
| 8194 od->setnick = TRUE; | |
| 8195 od->newsn = g_strdup(nick); | |
| 8196 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 8197 } else { | |
| 8198 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
| 8199 } | |
| 8200 } else { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5435
diff
changeset
|
8201 gaim_notify_error(gc, NULL, _("The new formatting is invalid."), |
| 8152 | 8202 _("Screen name formatting can change only capitalization and whitespace.")); |
| 4333 | 8203 } |
| 8204 } | |
| 8205 | |
| 9015 | 8206 static void oscar_show_format_screenname(GaimPluginAction *action) |
| 4333 | 8207 { |
| 9015 | 8208 GaimConnection *gc = (GaimConnection *) action->context; |
| 8152 | 8209 gaim_request_input(gc, NULL, _("New screen name formatting:"), NULL, |
| 8697 | 8210 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8211 _("OK"), G_CALLBACK(oscar_format_screenname), |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8212 _("Cancel"), NULL, |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8213 gc); |
| 4333 | 8214 } |
| 8215 | |
| 9015 | 8216 static void oscar_confirm_account(GaimPluginAction *action) |
| 4333 | 8217 { |
| 9015 | 8218 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 8219 OscarData *od = gc->proto_data; |
| 13239 | 8220 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 4333 | 8221 |
| 8222 if (conn) { | |
| 8223 aim_admin_reqconfirm(od->sess, conn); | |
| 8224 } else { | |
| 8225 od->conf = TRUE; | |
| 8226 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 8227 } | |
| 8228 } | |
| 8229 | |
| 9015 | 8230 static void oscar_show_email(GaimPluginAction *action) |
| 4333 | 8231 { |
| 9015 | 8232 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 8233 OscarData *od = gc->proto_data; |
| 13239 | 8234 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 4333 | 8235 |
| 8236 if (conn) { | |
| 8237 aim_admin_getinfo(od->sess, conn, 0x11); | |
| 8238 } else { | |
| 8239 od->reqemail = TRUE; | |
| 8240 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 8241 } | |
| 8242 } | |
| 8243 | |
| 5575 | 8244 static void oscar_change_email(GaimConnection *gc, const char *email) |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8245 { |
| 7283 | 8246 OscarData *od = gc->proto_data; |
| 13239 | 8247 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8248 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8249 if (conn) { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8250 aim_admin_setemail(od->sess, conn, email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8251 } else { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8252 od->setemail = TRUE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8253 od->email = g_strdup(email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8254 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8255 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8256 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
8257 |
| 9015 | 8258 static void oscar_show_change_email(GaimPluginAction *action) |
| 4333 | 8259 { |
| 9015 | 8260 GaimConnection *gc = (GaimConnection *) action->context; |
|
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
6029
diff
changeset
|
8261 gaim_request_input(gc, NULL, _("Change Address To:"), NULL, NULL, |
| 8697 | 8262 FALSE, FALSE, NULL, |
|
5493
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8263 _("OK"), G_CALLBACK(oscar_change_email), |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8264 _("Cancel"), NULL, |
|
3e8487580024
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
8265 gc); |
| 4333 | 8266 } |
| 8267 | |
| 9015 | 8268 static void oscar_show_awaitingauth(GaimPluginAction *action) |
| 4333 | 8269 { |
| 9015 | 8270 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 8271 OscarData *od = gc->proto_data; |
| 4333 | 8272 gchar *nombre, *text, *tmp; |
| 6695 | 8273 GaimBlistNode *gnode, *cnode, *bnode; |
| 4333 | 8274 int num=0; |
| 8275 | |
| 6873 | 8276 text = g_strdup(""); |
| 4333 | 8277 |
| 4785 | 8278 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 6695 | 8279 GaimGroup *group = (GaimGroup *)gnode; |
| 4785 | 8280 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 8281 continue; | |
| 6695 | 8282 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 8283 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 4785 | 8284 continue; |
| 6695 | 8285 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 8286 GaimBuddy *buddy = (GaimBuddy *)bnode; | |
| 8287 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 8288 continue; | |
| 8289 if (buddy->account == gc->account && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { | |
| 9620 | 8290 if (gaim_buddy_get_alias_only(buddy)) |
| 8291 nombre = g_strdup_printf(" %s (%s)", buddy->name, gaim_buddy_get_alias_only(buddy)); | |
| 6695 | 8292 else |
| 8293 nombre = g_strdup_printf(" %s", buddy->name); | |
| 6873 | 8294 tmp = g_strdup_printf("%s%s<br>", text, nombre); |
| 6695 | 8295 g_free(text); |
| 8296 text = tmp; | |
| 8297 g_free(nombre); | |
| 8298 num++; | |
| 8299 } | |
| 4333 | 8300 } |
| 2979 | 8301 } |
| 4333 | 8302 } |
| 8303 | |
| 8304 if (!num) { | |
| 8305 g_free(text); | |
| 6873 | 8306 text = g_strdup(_("<i>you are not waiting for authorization</i>")); |
| 8307 } | |
| 8308 | |
| 8309 gaim_notify_formatted(gc, NULL, _("You are awaiting authorization from " | |
| 8310 "the following buddies"), _("You can re-request " | |
| 8311 "authorization from these buddies by " | |
| 8312 "right-clicking on them and selecting " | |
| 8313 "\"Re-request Authorization.\""), text, NULL, NULL); | |
| 4333 | 8314 g_free(text); |
| 2979 | 8315 } |
| 8316 | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8317 static void search_by_email_cb(GaimConnection *gc, const char *email) |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8318 { |
| 8950 | 8319 OscarData *od = (OscarData *)gc->proto_data; |
| 8320 | |
| 8321 aim_search_address(od->sess, od->conn, email); | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8322 } |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8323 |
| 9015 | 8324 static void oscar_show_find_email(GaimPluginAction *action) |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8325 { |
| 9015 | 8326 GaimConnection *gc = (GaimConnection *) action->context; |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8327 gaim_request_input(gc, _("Find Buddy by E-mail"), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8328 _("Search for a buddy by e-mail address"), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8329 _("Type the e-mail address of the buddy you are " |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8330 "searching for."), |
| 8697 | 8331 NULL, FALSE, FALSE, NULL, |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8332 _("Search"), G_CALLBACK(search_by_email_cb), |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8333 _("Cancel"), NULL, gc); |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8334 } |
|
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
8335 |
| 9015 | 8336 static void oscar_show_set_info(GaimPluginAction *action) |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8337 { |
| 9015 | 8338 GaimConnection *gc = (GaimConnection *) action->context; |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8339 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8340 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
8341 |
| 9015 | 8342 static void oscar_show_set_info_icqurl(GaimPluginAction *action) |
| 8576 | 8343 { |
| 9015 | 8344 GaimConnection *gc = (GaimConnection *) action->context; |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8345 gaim_notify_uri(gc, "http://www.icq.com/whitepages/user_details.php"); |
| 8576 | 8346 } |
| 8347 | |
| 9015 | 8348 static void oscar_change_pass(GaimPluginAction *action) |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8349 { |
| 9015 | 8350 GaimConnection *gc = (GaimConnection *) action->context; |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8351 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8352 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7060
diff
changeset
|
8353 |
| 9015 | 8354 static void oscar_show_chpassurl(GaimPluginAction *action) |
| 4333 | 8355 { |
| 9015 | 8356 GaimConnection *gc = (GaimConnection *) action->context; |
| 7283 | 8357 OscarData *od = gc->proto_data; |
| 5575 | 8358 gchar *substituted = gaim_strreplace(od->sess->authinfo->chpassurl, "%s", gaim_account_get_username(gaim_connection_get_account(gc))); |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8359 gaim_notify_uri(gc, substituted); |
| 5517 | 8360 g_free(substituted); |
| 4333 | 8361 } |
| 8362 | |
| 9015 | 8363 static void oscar_show_imforwardingurl(GaimPluginAction *action) |
| 7026 | 8364 { |
| 9015 | 8365 GaimConnection *gc = (GaimConnection *) action->context; |
|
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10209
diff
changeset
|
8366 gaim_notify_uri(gc, "http://mymobile.aol.com/dbreg/register?action=imf&clientID=1"); |
| 7026 | 8367 } |
| 8368 | |
| 5842 | 8369 static void oscar_set_icon(GaimConnection *gc, const char *iconfile) |
| 8370 { | |
| 7283 | 8371 OscarData *od = gc->proto_data; |
| 13239 | 8372 OscarSession *sess = od->sess; |
| 5842 | 8373 FILE *file; |
| 8374 struct stat st; | |
| 5844 | 8375 |
| 6039 | 8376 if (iconfile == NULL) { |
| 8363 | 8377 aim_ssi_delicon(od->sess); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8378 } else if (!g_stat(iconfile, &st)) { |
| 11159 | 8379 guchar *buf = g_malloc(st.st_size); |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10574
diff
changeset
|
8380 file = g_fopen(iconfile, "rb"); |
| 11404 | 8381 if (file) |
| 8382 { | |
| 8383 GaimCipher *cipher; | |
| 8384 GaimCipherContext *context; | |
| 11159 | 8385 guchar md5[16]; |
| 11404 | 8386 int len; |
| 8387 | |
| 9532 | 8388 /* XXX - Use g_file_get_contents()? */ |
| 11404 | 8389 len = fread(buf, 1, st.st_size, file); |
| 6039 | 8390 fclose(file); |
| 11404 | 8391 |
| 8392 cipher = gaim_ciphers_find_cipher("md5"); | |
| 8393 context = gaim_cipher_context_new(cipher, NULL); | |
| 8394 gaim_cipher_context_append(context, buf, len); | |
| 8395 gaim_cipher_context_digest(context, 16, md5, NULL); | |
| 8396 gaim_cipher_context_destroy(context); | |
| 8397 | |
| 5842 | 8398 aim_ssi_seticon(sess, md5, 16); |
| 8399 } else | |
| 8660 | 8400 gaim_debug_error("oscar", |
| 5842 | 8401 "Can't open buddy icon file!\n"); |
| 8402 g_free(buf); | |
| 8403 } else | |
| 8660 | 8404 gaim_debug_error("oscar", |
| 5842 | 8405 "Can't stat buddy icon file!\n"); |
| 8406 } | |
| 8407 | |
| 8408 | |
| 9015 | 8409 static GList *oscar_actions(GaimPlugin *plugin, gpointer context) |
| 2086 | 8410 { |
| 9015 | 8411 GaimConnection *gc = (GaimConnection *) context; |
| 7283 | 8412 OscarData *od = gc->proto_data; |
| 4333 | 8413 GList *m = NULL; |
| 9015 | 8414 GaimPluginAction *act; |
| 8415 | |
| 8416 act = gaim_plugin_action_new(_("Set User Info..."), | |
| 8417 oscar_show_set_info); | |
| 8418 m = g_list_append(m, act); | |
| 4333 | 8419 |
| 10570 | 8420 if (od->icq) |
| 8421 { | |
| 9015 | 8422 act = gaim_plugin_action_new(_("Set User Info (URL)..."), |
| 8423 oscar_show_set_info_icqurl); | |
| 8424 m = g_list_append(m, act); | |
| 8576 | 8425 } |
| 8426 | |
| 9015 | 8427 act = gaim_plugin_action_new(_("Change Password..."), |
| 8428 oscar_change_pass); | |
| 8429 m = g_list_append(m, act); | |
| 4617 | 8430 |
| 10570 | 8431 if (od->sess->authinfo->chpassurl != NULL) |
| 8432 { | |
| 9015 | 8433 act = gaim_plugin_action_new(_("Change Password (URL)"), |
| 8434 oscar_show_chpassurl); | |
| 8435 m = g_list_append(m, act); | |
| 8436 | |
| 8437 act = gaim_plugin_action_new(_("Configure IM Forwarding (URL)"), | |
| 8438 oscar_show_imforwardingurl); | |
| 8439 m = g_list_append(m, act); | |
| 7026 | 8440 } |
| 8441 | |
| 10570 | 8442 m = g_list_append(m, NULL); |
| 8443 | |
| 8444 if (od->icq) | |
| 8445 { | |
| 8446 /* ICQ actions */ | |
| 12652 | 8447 act = gaim_plugin_action_new(_("Set Privacy Options..."), |
| 10570 | 8448 oscar_show_icq_privacy_opts); |
| 8449 m = g_list_append(m, act); | |
| 8450 } | |
| 8451 else | |
| 8452 { | |
| 4617 | 8453 /* AIM actions */ |
| 9015 | 8454 act = gaim_plugin_action_new(_("Format Screen Name..."), |
| 8455 oscar_show_format_screenname); | |
| 8456 m = g_list_append(m, act); | |
| 8457 | |
| 8458 act = gaim_plugin_action_new(_("Confirm Account"), | |
| 8459 oscar_confirm_account); | |
| 8460 m = g_list_append(m, act); | |
| 8461 | |
| 8462 act = gaim_plugin_action_new(_("Display Currently Registered Address"), | |
| 8463 oscar_show_email); | |
| 8464 m = g_list_append(m, act); | |
| 8465 | |
| 8466 act = gaim_plugin_action_new(_("Change Currently Registered Address..."), | |
| 8467 oscar_show_change_email); | |
| 8468 m = g_list_append(m, act); | |
| 2086 | 8469 } |
| 4333 | 8470 |
| 8471 m = g_list_append(m, NULL); | |
| 8472 | |
| 9015 | 8473 act = gaim_plugin_action_new(_("Show Buddies Awaiting Authorization"), |
| 8474 oscar_show_awaitingauth); | |
| 8475 m = g_list_append(m, act); | |
| 4333 | 8476 |
| 2086 | 8477 m = g_list_append(m, NULL); |
| 4333 | 8478 |
| 9015 | 8479 act = gaim_plugin_action_new(_("Search for Buddy by Email..."), |
| 8480 oscar_show_find_email); | |
| 8481 m = g_list_append(m, act); | |
| 4333 | 8482 |
| 8591 | 8483 #if 0 |
| 9015 | 8484 act = gaim_plugin_action_new(_("Search for Buddy by Information"), |
| 8485 show_find_info); | |
| 8486 m = g_list_append(m, act); | |
| 8591 | 8487 #endif |
| 2086 | 8488 |
| 8489 return m; | |
| 8490 } | |
| 8491 | |
| 5575 | 8492 static void oscar_change_passwd(GaimConnection *gc, const char *old, const char *new) |
| 2086 | 8493 { |
| 7283 | 8494 OscarData *od = gc->proto_data; |
| 4617 | 8495 |
| 8496 if (od->icq) { | |
| 8497 aim_icq_changepasswd(od->sess, new); | |
| 2086 | 8498 } else { |
| 13239 | 8499 OscarConnection *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
| 4617 | 8500 if (conn) { |
| 8501 aim_admin_changepasswd(od->sess, conn, new, old); | |
| 8502 } else { | |
| 8503 od->chpass = TRUE; | |
| 8504 od->oldp = g_strdup(old); | |
| 8505 od->newp = g_strdup(new); | |
| 8506 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 8507 } | |
| 2086 | 8508 } |
| 8509 } | |
| 8510 | |
| 6059 | 8511 static void oscar_convo_closed(GaimConnection *gc, const char *who) |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8512 { |
| 7283 | 8513 OscarData *od = gc->proto_data; |
| 8971 | 8514 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
|
8515 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8516 if (!dim) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8517 return; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8518 |
| 8971 | 8519 oscar_direct_im_destroy(od, dim); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8520 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
8521 |
| 9935 | 8522 static void |
| 12816 | 8523 recent_buddies_cb(const char *name, GaimPrefType type, |
| 8524 gconstpointer value, gpointer data) | |
| 9935 | 8525 { |
| 8526 GaimConnection *gc = data; | |
| 8527 OscarData *od = gc->proto_data; | |
| 13239 | 8528 OscarSession *sess = od->sess; |
| 13234 | 8529 guint32 presence; |
| 9935 | 8530 |
| 8531 presence = aim_ssi_getpresence(sess->ssi.local); | |
| 8532 | |
| 8533 if (value) { | |
| 12486 | 8534 presence &= ~AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
| 9935 | 8535 aim_ssi_setpresence(sess, presence); |
| 8536 } else { | |
| 12486 | 8537 presence |= AIM_SSI_PRESENCE_FLAG_NORECENTBUDDIES; |
| 9935 | 8538 aim_ssi_setpresence(sess, presence); |
| 8539 } | |
| 8540 } | |
| 8541 | |
| 8542 static GaimPluginPrefFrame * | |
| 9936 | 8543 get_plugin_pref_frame(GaimPlugin *plugin) |
| 8544 { | |
| 9935 | 8545 GaimPluginPrefFrame *frame; |
| 8546 GaimPluginPref *ppref; | |
| 8547 | |
| 8548 frame = gaim_plugin_pref_frame_new(); | |
| 8549 | |
|
12317
1baf4cbcf84d
[gaim-migrate @ 14621]
Richard Laager <rlaager@wiktel.com>
parents:
12271
diff
changeset
|
8550 #ifdef USE_PRPL_PREFERENCES |
| 9935 | 8551 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/recent_buddies", _("Use recent buddies group")); |
| 8552 gaim_plugin_pref_frame_add(frame, ppref); | |
| 8553 | |
| 8554 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/oscar/show_idle", _("Show how long you have been idle")); | |
| 8555 gaim_plugin_pref_frame_add(frame, ppref); | |
| 11369 | 8556 #endif |
| 13071 | 8557 |
| 11369 | 8558 ppref = gaim_plugin_pref_new_with_label(_("File Transfers")); |
| 8559 gaim_plugin_pref_frame_add(frame, ppref); | |
| 8560 | |
| 8561 ppref = gaim_plugin_pref_new_with_name_and_label( | |
| 8562 "/plugins/prpl/oscar/use_rv_proxy", | |
| 13071 | 8563 _("Use AIM/ICQ proxy server (slower, but usually works)")); |
| 11369 | 8564 gaim_plugin_pref_frame_add(frame, ppref); |
| 9935 | 8565 |
| 8566 return frame; | |
| 8567 } | |
| 8568 | |
| 11153 | 8569 static const char * |
| 8570 oscar_normalize(const GaimAccount *account, const char *str) | |
| 8571 { | |
| 8572 static char buf[BUF_LEN]; | |
| 8573 char *tmp1, *tmp2; | |
| 8574 int i, j; | |
| 8575 | |
| 8576 g_return_val_if_fail(str != NULL, NULL); | |
| 8577 | |
| 8578 strncpy(buf, str, BUF_LEN); | |
| 8579 for (i=0, j=0; buf[j]; i++, j++) | |
| 8580 { | |
| 8581 while (buf[j] == ' ') | |
| 8582 j++; | |
| 8583 buf[i] = buf[j]; | |
| 8584 } | |
| 8585 buf[i] = '\0'; | |
| 8586 | |
| 8587 tmp1 = g_utf8_strdown(buf, -1); | |
| 8588 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
| 8589 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
| 8590 g_free(tmp2); | |
| 8591 g_free(tmp1); | |
| 8592 | |
| 8593 return buf; | |
| 8594 } | |
| 8595 | |
|
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8596 static gboolean oscar_offline_message(const GaimBuddy *buddy) |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8597 { |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8598 OscarData *od; |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8599 GaimAccount *account; |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8600 GaimConnection *gc; |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8601 |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8602 account = gaim_buddy_get_account(buddy); |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8603 gc = gaim_account_get_connection(account); |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8604 od = (OscarData *)gc->proto_data; |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8605 |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8606 return (od->icq && aim_sn_is_icq(gaim_account_get_username(account))); |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8607 } |
|
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8608 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8609 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8610 { |
| 9308 | 8611 OPT_PROTO_MAIL_CHECK | OPT_PROTO_IM_IMAGE, |
| 9475 | 8612 NULL, /* user_splits */ |
| 8613 NULL, /* protocol_options */ | |
| 10674 | 8614 {"jpeg,gif,bmp,ico", 48, 48, 50, 50, |
| 8615 GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ | |
| 9475 | 8616 oscar_list_icon, /* list_icon */ |
| 8617 oscar_list_emblems, /* list_emblems */ | |
| 8618 oscar_status_text, /* status_text */ | |
| 8619 oscar_tooltip_text, /* tooltip_text */ | |
| 9973 | 8620 oscar_status_types, /* status_types */ |
| 9475 | 8621 oscar_blist_node_menu, /* blist_node_menu */ |
| 8622 oscar_chat_info, /* chat_info */ | |
| 9754 | 8623 oscar_chat_info_defaults, /* chat_info_defaults */ |
| 9475 | 8624 oscar_login, /* login */ |
| 8625 oscar_close, /* close */ | |
| 8626 oscar_send_im, /* send_im */ | |
| 8627 oscar_set_info, /* set_info */ | |
| 8628 oscar_send_typing, /* send_typing */ | |
| 8629 oscar_get_info, /* get_info */ | |
| 9973 | 8630 oscar_set_status, /* set_status */ |
| 9475 | 8631 oscar_set_idle, /* set_idle */ |
| 8632 oscar_change_passwd, /* change_passwd */ | |
| 8633 oscar_add_buddy, /* add_buddy */ | |
| 10866 | 8634 NULL, /* add_buddies */ |
| 9475 | 8635 oscar_remove_buddy, /* remove_buddy */ |
| 10866 | 8636 NULL, /* remove_buddies */ |
| 9475 | 8637 oscar_add_permit, /* add_permit */ |
| 8638 oscar_add_deny, /* add_deny */ | |
| 8639 oscar_rem_permit, /* rem_permit */ | |
| 8640 oscar_rem_deny, /* rem_deny */ | |
| 8641 oscar_set_permit_deny, /* set_permit_deny */ | |
| 8642 oscar_join_chat, /* join_chat */ | |
| 8643 NULL, /* reject_chat */ | |
| 9973 | 8644 oscar_get_chat_name, /* get_chat_name */ |
| 9475 | 8645 oscar_chat_invite, /* chat_invite */ |
| 8646 oscar_chat_leave, /* chat_leave */ | |
| 8647 NULL, /* chat_whisper */ | |
| 8648 oscar_send_chat, /* chat_send */ | |
| 8649 oscar_keepalive, /* keepalive */ | |
| 8650 NULL, /* register_user */ | |
| 8651 NULL, /* get_cb_info */ | |
| 8652 NULL, /* get_cb_away */ | |
| 8653 oscar_alias_buddy, /* alias_buddy */ | |
| 8654 oscar_move_buddy, /* group_buddy */ | |
| 8655 oscar_rename_group, /* rename_group */ | |
| 8656 NULL, /* buddy_free */ | |
| 8657 oscar_convo_closed, /* convo_closed */ | |
| 11153 | 8658 oscar_normalize, /* normalize */ |
| 9475 | 8659 oscar_set_icon, /* set_buddy_icon */ |
| 8660 NULL, /* remove_group */ | |
| 8661 NULL, /* get_cb_real_name */ | |
| 8662 NULL, /* set_chat_topic */ | |
| 8663 NULL, /* find_blist_chat */ | |
| 8664 NULL, /* roomlist_get_list */ | |
| 8665 NULL, /* roomlist_cancel */ | |
| 8666 NULL, /* roomlist_expand_category */ | |
| 8667 oscar_can_receive_file, /* can_receive_file */ | |
|
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8668 oscar_send_file, /* send_file */ |
|
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12088
diff
changeset
|
8669 oscar_new_xfer, /* new_xfer */ |
|
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
8670 oscar_offline_message, /* offline_message */ |
|
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8671 NULL, /* whiteboard_prpl_ops */ |
| 12617 | 8672 NULL, /* media_prpl_ops */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8673 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8674 |
| 9935 | 8675 static GaimPluginUiInfo prefs_info = { |
|
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8676 get_plugin_pref_frame, |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8677 0, /* page_num (Reserved) */ |
|
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
8678 NULL /* frame (Reserved) */ |
| 9935 | 8679 }; |
| 8680 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8681 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8682 { |
| 9943 | 8683 GAIM_PLUGIN_MAGIC, |
| 8684 GAIM_MAJOR_VERSION, | |
| 8685 GAIM_MINOR_VERSION, | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8686 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8687 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8688 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8689 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8690 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8691 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8692 "prpl-oscar", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8693 "AIM/ICQ", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8694 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8695 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8696 N_("AIM/ICQ Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8697 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8698 N_("AIM/ICQ Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8699 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6350
diff
changeset
|
8700 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8701 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8702 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8703 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8704 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8705 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8706 NULL, /**< ui_info */ |
| 8993 | 8707 &prpl_info, /**< extra_info */ |
| 11369 | 8708 &prefs_info, |
| 9015 | 8709 oscar_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8710 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8711 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8712 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8713 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5197
diff
changeset
|
8714 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8715 GaimAccountOption *option; |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5631
diff
changeset
|
8716 |
| 11338 | 8717 option = gaim_account_option_string_new(_("Auth host"), "server", OSCAR_DEFAULT_LOGIN_SERVER); |
| 9830 | 8718 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 8719 | |
| 11338 | 8720 option = gaim_account_option_int_new(_("Auth port"), "port", OSCAR_DEFAULT_LOGIN_PORT); |
| 9830 | 8721 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 8722 | |
| 8723 option = gaim_account_option_string_new(_("Encoding"), "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | |
| 8724 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 13073 | 8725 |
| 13071 | 8726 option = gaim_account_option_bool_new( |
| 13073 | 8727 _("Use AIM/ICQ proxy server\n(slower, but usually works)"), "use_rv_proxy", |
| 13071 | 8728 OSCAR_DEFAULT_USE_RV_PROXY); |
| 8729 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 11338 | 8730 |
| 11369 | 8731 /* Preferences */ |
| 9935 | 8732 gaim_prefs_add_none("/plugins/prpl/oscar"); |
| 8733 gaim_prefs_add_bool("/plugins/prpl/oscar/recent_buddies", FALSE); | |
| 9942 | 8734 gaim_prefs_add_bool("/plugins/prpl/oscar/show_idle", FALSE); |
| 11369 | 8735 gaim_prefs_add_bool("/plugins/prpl/oscar/use_rv_proxy", FALSE); |
| 2086 | 8736 } |
| 8737 | |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5917
diff
changeset
|
8738 GAIM_INIT_PLUGIN(oscar, init_plugin, info); |
