Mercurial > pidgin
annotate src/protocols/oscar/oscar.c @ 4443:00a22e2e8367
[gaim-migrate @ 4718]
Thanks to David Walluck for pointing out the incorrect comment.
And I'm commenting out the cleanlist thing until I have more time
to look at why it's crashing for Luke.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Tue, 28 Jan 2003 06:45:08 +0000 |
| parents | 3299863ab060 |
| children | 2afc0f845e74 |
| rev | line source |
|---|---|
| 2086 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
| 6 * | |
| 7 * This program is free software; you can redistribute it and/or modify | |
| 8 * it under the terms of the GNU General Public License as published by | |
| 9 * the Free Software Foundation; either version 2 of the License, or | |
| 10 * (at your option) any later version. | |
| 11 * | |
| 12 * This program is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 * GNU General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU General Public License | |
| 18 * along with this program; if not, write to the Free Software | |
| 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 * | |
| 21 */ | |
| 22 | |
| 23 #ifdef HAVE_CONFIG_H | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
24 #include <config.h> |
| 2086 | 25 #endif |
| 26 | |
| 3664 | 27 #include <sys/types.h> |
| 28 /*this must happen before sys/socket.h or freebsd won't compile*/ | |
| 29 | |
| 3630 | 30 #ifndef _WIN32 |
| 2086 | 31 #include <netdb.h> |
| 32 #include <netinet/in.h> | |
| 33 #include <arpa/inet.h> | |
| 3630 | 34 #include <sys/socket.h> |
| 35 #include <unistd.h> | |
| 36 #endif | |
| 37 | |
| 38 #include <errno.h> | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
39 #include <ctype.h> |
| 2086 | 40 #include <string.h> |
| 41 #include <stdlib.h> | |
| 42 #include <stdio.h> | |
| 43 #include <time.h> | |
| 44 #include <sys/stat.h> | |
| 3630 | 45 #include <signal.h> |
| 46 | |
| 2086 | 47 #include "multi.h" |
| 48 #include "prpl.h" | |
| 49 #include "gaim.h" | |
|
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4366
diff
changeset
|
50 #include "core.h" |
| 2086 | 51 #include "aim.h" |
| 52 #include "proxy.h" | |
| 53 | |
| 3630 | 54 #ifdef _WIN32 |
| 55 #include "win32dep.h" | |
| 56 #endif | |
| 57 | |
| 3490 | 58 #include "pixmaps/protocols/oscar/ab.xpm" |
| 59 #include "pixmaps/protocols/oscar/admin_icon.xpm" | |
| 60 #include "pixmaps/protocols/oscar/aol_icon.xpm" | |
| 61 #include "pixmaps/protocols/oscar/away_icon.xpm" | |
| 62 #include "pixmaps/protocols/oscar/dt_icon.xpm" | |
| 63 #include "pixmaps/protocols/oscar/free_icon.xpm" | |
| 64 #include "pixmaps/protocols/oscar/wireless_icon.xpm" | |
| 2086 | 65 |
| 3579 | 66 #include "pixmaps/protocols/icq/gnomeicu-online.xpm" |
| 67 #include "pixmaps/protocols/icq/gnomeicu-offline.xpm" | |
| 68 #include "pixmaps/protocols/icq/gnomeicu-away.xpm" | |
| 69 #include "pixmaps/protocols/icq/gnomeicu-dnd.xpm" | |
| 70 #include "pixmaps/protocols/icq/gnomeicu-na.xpm" | |
| 71 #include "pixmaps/protocols/icq/gnomeicu-occ.xpm" | |
| 72 #include "pixmaps/protocols/icq/gnomeicu-ffc.xpm" | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
73 |
| 2086 | 74 /* constants to identify proto_opts */ |
| 75 #define USEROPT_AUTH 0 | |
| 76 #define USEROPT_AUTHPORT 1 | |
| 77 | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
78 #define UC_AOL 0x02 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
79 #define UC_ADMIN 0x04 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
80 #define UC_UNCONFIRMED 0x08 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
81 #define UC_NORMAL 0x10 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
82 #define UC_AB 0x20 |
| 3079 | 83 #define UC_WIRELESS 0x40 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
84 |
| 2086 | 85 #define AIMHASHDATA "http://gaim.sourceforge.net/aim_data.php3" |
| 86 | |
| 4249 | 87 static struct prpl *my_protocol = NULL; |
| 88 | |
| 3630 | 89 /* For win32 compatability */ |
| 90 G_MODULE_IMPORT GSList *connections; | |
| 91 G_MODULE_IMPORT int report_idle; | |
|
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4366
diff
changeset
|
92 G_MODULE_IMPORT GSList *groups; |
| 3630 | 93 |
| 94 static int caps_aim = AIM_CAPS_CHAT | AIM_CAPS_BUDDYICON | | |
| 95 AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE; | |
| 3458 | 96 |
| 97 /* Set AIM caps, because Gaim can still do them over ICQ and | |
| 98 * Winicq doesn't mind. */ | |
| 4154 | 99 static int caps_icq = AIM_CAPS_BUDDYICON | AIM_CAPS_IMIMAGE | AIM_CAPS_SENDFILE; |
| 3595 | 100 /* static int caps_icq = AIM_CAPS_ICQ; */ |
| 101 /* What does AIM_CAPS_ICQ actually mean? -SE */ | |
| 3458 | 102 |
|
2308
a90be9567452
[gaim-migrate @ 2318]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2305
diff
changeset
|
103 static fu8_t gaim_features[] = {0x01, 0x01, 0x01, 0x02}; |
| 2086 | 104 |
| 105 struct oscar_data { | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
106 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
107 aim_conn_t *conn; |
| 2086 | 108 |
| 109 guint cnpa; | |
| 110 guint paspa; | |
| 3694 | 111 guint emlpa; |
| 2086 | 112 |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
113 GSList *create_rooms; |
| 2086 | 114 |
| 115 gboolean conf; | |
| 116 gboolean reqemail; | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
117 gboolean setemail; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
118 char *email; |
| 2979 | 119 gboolean setnick; |
| 120 char *newsn; | |
| 2086 | 121 gboolean chpass; |
| 122 char *oldp; | |
| 123 char *newp; | |
| 124 | |
| 125 GSList *oscar_chats; | |
| 126 GSList *direct_ims; | |
| 3630 | 127 GSList *file_transfers; |
| 2086 | 128 GSList *hasicons; |
| 3600 | 129 GHashTable *supports_tn; |
| 2086 | 130 |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
131 gboolean killme; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
132 gboolean icq; |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
133 GSList *evilhack; |
| 2993 | 134 |
| 135 struct { | |
| 4230 | 136 guint maxwatchers; /* max users who can watch you */ |
| 2993 | 137 guint maxbuddies; /* max users you can watch */ |
| 4230 | 138 guint maxgroups; /* max groups in server list */ |
| 2993 | 139 guint maxpermits; /* max users on permit list */ |
| 140 guint maxdenies; /* max users on deny list */ | |
| 141 guint maxsiglen; /* max size (bytes) of profile */ | |
| 142 guint maxawaymsglen; /* max size (bytes) of posted away message */ | |
| 143 } rights; | |
| 2086 | 144 }; |
| 145 | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
146 struct create_room { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
147 char *name; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
148 int exchange; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
149 }; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
150 |
| 2086 | 151 struct chat_connection { |
| 152 char *name; | |
| 153 char *show; /* AOL did something funny to us */ | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
154 fu16_t exchange; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
155 fu16_t instance; |
| 2086 | 156 int fd; /* this is redundant since we have the conn below */ |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
157 aim_conn_t *conn; |
| 2086 | 158 int inpa; |
| 159 int id; | |
| 160 struct gaim_connection *gc; /* i hate this. */ | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
161 struct gaim_conversation *cnv; /* bah. */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
162 int maxlen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
163 int maxvis; |
| 2086 | 164 }; |
| 165 | |
| 166 struct direct_im { | |
| 167 struct gaim_connection *gc; | |
| 168 char name[80]; | |
| 169 int watcher; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
170 aim_conn_t *conn; |
| 3008 | 171 gboolean connected; |
| 2086 | 172 }; |
| 173 | |
| 174 struct ask_direct { | |
| 175 struct gaim_connection *gc; | |
| 176 char *sn; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
177 char ip[64]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
178 fu8_t cookie[8]; |
| 2086 | 179 }; |
| 180 | |
| 3630 | 181 struct oscar_file_transfer { |
| 182 enum { OFT_SENDFILE_IN, OFT_SENDFILE_OUT } type; | |
| 183 aim_conn_t *conn; | |
| 184 struct file_transfer *xfer; | |
| 185 char *sn; | |
| 186 char ip[64]; | |
| 187 fu16_t port; | |
| 188 fu8_t cookie[8]; | |
| 189 int totsize; | |
| 190 int filesdone; | |
| 191 int totfiles; | |
| 192 int watcher; | |
| 193 }; | |
| 194 | |
| 2086 | 195 struct icon_req { |
| 196 char *user; | |
| 197 time_t timestamp; | |
|
2196
016c5307f26b
[gaim-migrate @ 2206]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2194
diff
changeset
|
198 unsigned long length; |
|
2191
657dbe515608
[gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2172
diff
changeset
|
199 unsigned long checksum; |
| 2086 | 200 gboolean request; |
| 201 }; | |
| 202 | |
| 4230 | 203 struct name_data { |
| 3141 | 204 struct gaim_connection *gc; |
| 4230 | 205 gchar *name; |
| 3453 | 206 gchar *nick; |
| 3141 | 207 }; |
| 208 | |
| 4230 | 209 static void gaim_free_name_data(struct name_data *data) { |
| 210 g_free(data->name); | |
| 211 g_free(data->nick); | |
| 212 g_free(data); | |
| 213 } | |
| 214 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
215 static struct direct_im *find_direct_im(struct oscar_data *od, const char *who) { |
| 2086 | 216 GSList *d = od->direct_ims; |
| 217 struct direct_im *m = NULL; | |
| 218 | |
| 219 while (d) { | |
| 220 m = (struct direct_im *)d->data; | |
| 4355 | 221 if (!aim_sncmp(who, m->name)) |
| 4269 | 222 return m; |
| 2086 | 223 d = d->next; |
| 224 } | |
| 225 | |
| 4269 | 226 return NULL; |
| 2086 | 227 } |
| 228 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
229 static char *extract_name(const char *name) { |
| 4121 | 230 char *tmp, *x; |
| 2086 | 231 int i, j; |
| 4120 | 232 |
| 233 if (!name) | |
| 4121 | 234 return NULL; |
| 235 | |
| 4120 | 236 x = strchr(name, '-'); |
| 4121 | 237 |
| 2086 | 238 if (!x) return NULL; |
| 239 x = strchr(++x, '-'); | |
| 240 if (!x) return NULL; | |
| 241 tmp = g_strdup(++x); | |
| 242 | |
| 243 for (i = 0, j = 0; x[i]; i++) { | |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
244 char hex[3]; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
245 if (x[i] != '%') { |
| 2086 | 246 tmp[j++] = x[i]; |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
247 continue; |
| 2086 | 248 } |
|
2361
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
249 strncpy(hex, x + ++i, 2); hex[2] = 0; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
250 i++; |
|
554b001d7d98
[gaim-migrate @ 2374]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2357
diff
changeset
|
251 tmp[j++] = strtol(hex, NULL, 16); |
| 2086 | 252 } |
| 253 | |
| 254 tmp[j] = 0; | |
| 255 return tmp; | |
| 256 } | |
| 257 | |
| 258 static struct chat_connection *find_oscar_chat(struct gaim_connection *gc, int id) { | |
| 259 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; | |
| 260 struct chat_connection *c = NULL; | |
| 261 | |
| 262 while (g) { | |
| 263 c = (struct chat_connection *)g->data; | |
| 264 if (c->id == id) | |
| 265 break; | |
| 266 g = g->next; | |
| 267 c = NULL; | |
| 268 } | |
| 269 | |
| 270 return c; | |
| 271 } | |
| 272 | |
| 273 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
274 aim_conn_t *conn) { |
| 2086 | 275 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
| 276 struct chat_connection *c = NULL; | |
| 277 | |
| 278 while (g) { | |
| 279 c = (struct chat_connection *)g->data; | |
| 280 if (c->conn == conn) | |
| 281 break; | |
| 282 g = g->next; | |
| 283 c = NULL; | |
| 284 } | |
| 285 | |
| 286 return c; | |
| 287 } | |
| 288 | |
| 3630 | 289 /* XXX there must be a better way than this.... -- wtm */ |
| 290 static struct oscar_file_transfer *find_oft_by_conn(struct gaim_connection *gc, | |
| 291 aim_conn_t *conn) { | |
| 292 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
| 293 struct oscar_file_transfer *f = NULL; | |
| 294 | |
| 295 while (g) { | |
| 296 f = (struct oscar_file_transfer *)g->data; | |
| 297 if (f->conn == conn) | |
| 298 break; | |
| 299 g = g->next; | |
| 300 f = NULL; | |
| 301 } | |
| 302 | |
| 303 return f; | |
| 304 } | |
| 305 | |
| 306 static struct oscar_file_transfer *find_oft_by_xfer(struct gaim_connection *gc, | |
| 307 struct file_transfer *xfer) { | |
| 308 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
| 309 struct oscar_file_transfer *f = NULL; | |
| 310 | |
| 311 while (g) { | |
| 312 f = (struct oscar_file_transfer *)g->data; | |
| 313 if (f->xfer == xfer) | |
| 314 break; | |
| 315 g = g->next; | |
| 316 f = NULL; | |
| 317 } | |
| 318 | |
| 319 return f; | |
| 320 } | |
| 321 | |
| 322 static struct oscar_file_transfer *find_oft_by_cookie(struct gaim_connection *gc, | |
| 323 const char *cookie) { | |
| 324 GSList *g = ((struct oscar_data *)gc->proto_data)->file_transfers; | |
| 325 struct oscar_file_transfer *f = NULL; | |
| 326 | |
| 327 while (g) { | |
| 328 f = (struct oscar_file_transfer *)g->data; | |
| 329 if (!strncmp(f->cookie, cookie, 8)) | |
| 330 break; | |
| 331 g = g->next; | |
| 332 f = NULL; | |
| 333 } | |
| 334 | |
| 335 return f; | |
| 336 } | |
| 337 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
338 static int gaim_parse_auth_resp (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
339 static int gaim_parse_login (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
340 static int gaim_handle_redirect (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
341 static int gaim_info_change (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
342 static int gaim_account_confirm (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
343 static int gaim_parse_oncoming (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
344 static int gaim_parse_offgoing (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
345 static int gaim_parse_incoming_im(aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
346 static int gaim_parse_misses (aim_session_t *, aim_frame_t *, ...); |
| 3212 | 347 static int gaim_parse_clientauto (aim_session_t *, aim_frame_t *, ...); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
348 static int gaim_parse_user_info (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
349 static int gaim_parse_motd (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
350 static int gaim_chatnav_info (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
351 static int gaim_chat_join (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
352 static int gaim_chat_leave (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
353 static int gaim_chat_info_update (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
354 static int gaim_chat_incoming_msg(aim_session_t *, aim_frame_t *, ...); |
| 3694 | 355 static int gaim_email_parseupdate(aim_session_t *, aim_frame_t *, ...); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
356 static int gaim_parse_msgack (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
357 static int gaim_parse_ratechange (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
358 static int gaim_parse_evilnotify (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
359 static int gaim_parse_searcherror(aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
360 static int gaim_parse_searchreply(aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
361 static int gaim_bosrights (aim_session_t *, aim_frame_t *, ...); |
| 3952 | 362 static int conninitdone_admin (aim_session_t *, aim_frame_t *, ...); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
363 static int conninitdone_bos (aim_session_t *, aim_frame_t *, ...); |
| 3952 | 364 static int conninitdone_chatnav (aim_session_t *, aim_frame_t *, ...); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
365 static int conninitdone_chat (aim_session_t *, aim_frame_t *, ...); |
| 3694 | 366 static int conninitdone_email (aim_session_t *, aim_frame_t *, ...); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
367 static int gaim_parse_msgerr (aim_session_t *, aim_frame_t *, ...); |
| 3595 | 368 static int gaim_parse_mtn (aim_session_t *, aim_frame_t *, ...); |
| 2993 | 369 static int gaim_parse_locaterights(aim_session_t *, aim_frame_t *, ...); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
370 static int gaim_parse_buddyrights(aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
371 static int gaim_parse_locerr (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
372 static int gaim_icbm_param_info (aim_session_t *, aim_frame_t *, ...); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
373 static int gaim_parse_genericerr (aim_session_t *, aim_frame_t *, ...); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
374 static int gaim_memrequest (aim_session_t *, aim_frame_t *, ...); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
375 static int gaim_selfinfo (aim_session_t *, aim_frame_t *, ...); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
376 static int gaim_offlinemsg (aim_session_t *, aim_frame_t *, ...); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
377 static int gaim_offlinemsgdone (aim_session_t *, aim_frame_t *, ...); |
| 4151 | 378 static int gaim_icqsimpleinfo (aim_session_t *, aim_frame_t *, ...); |
| 379 static int gaim_icqallinfo (aim_session_t *, aim_frame_t *, ...); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
380 static int gaim_popup (aim_session_t *, aim_frame_t *, ...); |
| 4230 | 381 #ifndef NOSSI |
| 2991 | 382 static int gaim_ssi_parserights (aim_session_t *, aim_frame_t *, ...); |
| 383 static int gaim_ssi_parselist (aim_session_t *, aim_frame_t *, ...); | |
| 4230 | 384 static int gaim_ssi_parseack (aim_session_t *, aim_frame_t *, ...); |
| 385 static int gaim_ssi_authgiven (aim_session_t *, aim_frame_t *, ...); | |
| 386 static int gaim_ssi_authrequest (aim_session_t *, aim_frame_t *, ...); | |
| 387 static int gaim_ssi_authreply (aim_session_t *, aim_frame_t *, ...); | |
| 388 static int gaim_ssi_gotadded (aim_session_t *, aim_frame_t *, ...); | |
| 389 #endif | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
390 |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
391 static int gaim_directim_initiate(aim_session_t *, aim_frame_t *, ...); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
392 static int gaim_directim_incoming(aim_session_t *, aim_frame_t *, ...); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
393 static int gaim_directim_typing (aim_session_t *, aim_frame_t *, ...); |
| 2993 | 394 static int gaim_update_ui (aim_session_t *, aim_frame_t *, ...); |
| 2086 | 395 |
| 3630 | 396 static int oscar_file_transfer_do(aim_session_t *, aim_frame_t *, ...); |
| 397 static void oscar_file_transfer_disconnect(aim_session_t *, | |
| 398 aim_conn_t *); | |
| 3771 | 399 static void oscar_file_transfer_cancel(struct gaim_connection *, |
| 3630 | 400 struct file_transfer *); |
| 401 static int oscar_sendfile_request(aim_session_t *sess, | |
| 402 struct oscar_file_transfer *oft); | |
| 3752 | 403 static int oscar_sendfile_timeout(aim_session_t *sess, aim_frame_t *fr, ...); |
| 3630 | 404 |
| 4151 | 405 static fu32_t check_encoding(const char *utf8); |
| 406 static fu32_t parse_encoding(const char *enc); | |
| 407 | |
| 2086 | 408 static char *msgerrreason[] = { |
| 4056 | 409 N_("Invalid error"), |
| 410 N_("Invalid SNAC"), | |
| 411 N_("Rate to host"), | |
| 412 N_("Rate to client"), | |
| 413 N_("Not logged in"), | |
| 414 N_("Service unavailable"), | |
| 415 N_("Service not defined"), | |
| 416 N_("Obsolete SNAC"), | |
| 417 N_("Not supported by host"), | |
| 418 N_("Not supported by client"), | |
| 419 N_("Refused by client"), | |
| 420 N_("Reply too big"), | |
| 421 N_("Responses lost"), | |
| 422 N_("Request denied"), | |
| 423 N_("Busted SNAC payload"), | |
| 424 N_("Insufficient rights"), | |
| 425 N_("In local permit/deny"), | |
| 426 N_("Too evil (sender)"), | |
| 427 N_("Too evil (receiver)"), | |
| 428 N_("User temporarily unavailable"), | |
| 429 N_("No match"), | |
| 430 N_("List overflow"), | |
| 431 N_("Request ambiguous"), | |
| 432 N_("Queue full"), | |
| 433 N_("Not while on AOL") | |
| 2086 | 434 }; |
| 435 static int msgerrreasonlen = 25; | |
| 436 | |
| 3952 | 437 /* |
| 438 * This is called to clean up whenever a file transfer is no longer in progress, | |
| 439 * whether because it finished sucessfully, it was canceled, or there was an error. | |
| 440 */ | |
| 441 static void oscar_file_transfer_disconnect(aim_session_t *sess, aim_conn_t *conn) { | |
| 3630 | 442 struct gaim_connection *gc = sess->aux_data; |
| 443 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 444 struct oscar_file_transfer *oft = find_oft_by_conn(gc, | |
| 445 conn); | |
| 446 | |
| 447 od->file_transfers = g_slist_remove(od->file_transfers, oft); | |
| 448 | |
| 449 if (oft->watcher) { | |
| 450 gaim_input_remove(oft->watcher); | |
| 451 oft->watcher = 0; | |
| 452 } | |
| 453 | |
| 454 aim_conn_kill(sess, &conn); | |
| 455 | |
| 456 g_free(oft->sn); | |
| 457 g_free(oft); | |
| 458 } | |
| 459 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
460 static void gaim_directim_disconnect(aim_session_t *sess, aim_conn_t *conn) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
461 struct gaim_connection *gc = sess->aux_data; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
462 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
463 struct gaim_conversation *cnv; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
464 struct direct_im *dim; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
465 char *sn; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
466 char buf[256]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
467 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
468 sn = g_strdup(aim_directim_getsn(conn)); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
469 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
470 debug_printf("%s disconnected Direct IM.\n", sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
471 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
472 dim = find_direct_im(od, sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
473 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
474 gaim_input_remove(dim->watcher); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
475 |
| 3008 | 476 if (dim->connected) |
| 477 g_snprintf(buf, sizeof buf, _("Direct IM with %s closed"), sn); | |
| 478 else | |
| 479 g_snprintf(buf, sizeof buf, _("Direct IM with %s failed"), sn); | |
| 480 | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
481 if ((cnv = gaim_find_conversation(sn))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
482 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
483 |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
484 gaim_conversation_update_progress(cnv, 100); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
485 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
486 g_free(dim); /* I guess? I don't see it anywhere else... -- mid */ |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
487 g_free(sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
488 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
489 return; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
490 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
491 |
| 2086 | 492 static void oscar_callback(gpointer data, gint source, |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
493 GaimInputCondition condition) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
494 aim_conn_t *conn = (aim_conn_t *)data; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
495 aim_session_t *sess = aim_conn_getsess(conn); |
| 2086 | 496 struct gaim_connection *gc = sess ? sess->aux_data : NULL; |
| 497 struct oscar_data *odata; | |
| 498 | |
| 499 if (!gc) { | |
| 500 /* gc is null. we return, else we seg SIGSEG on next line. */ | |
| 501 debug_printf("oscar callback for closed connection (1).\n"); | |
| 502 return; | |
| 503 } | |
| 504 | |
| 505 odata = (struct oscar_data *)gc->proto_data; | |
| 506 | |
| 507 if (!g_slist_find(connections, gc)) { | |
| 508 /* oh boy. this is probably bad. i guess the only thing we | |
| 509 * can really do is return? */ | |
| 510 debug_printf("oscar callback for closed connection (2).\n"); | |
| 511 return; | |
| 512 } | |
| 513 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
514 if (condition & GAIM_INPUT_READ) { |
| 2086 | 515 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { |
| 516 debug_printf("got information on rendezvous\n"); | |
| 517 if (aim_handlerendconnect(odata->sess, conn) < 0) { | |
| 4236 | 518 debug_printf("connection error (rend)\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
519 aim_conn_kill(odata->sess, &conn); |
| 2086 | 520 } |
| 521 } else { | |
| 522 if (aim_get_command(odata->sess, conn) >= 0) { | |
| 523 aim_rxdispatch(odata->sess); | |
| 524 if (odata->killme) | |
| 525 signoff(gc); | |
| 526 } else { | |
| 527 if ((conn->type == AIM_CONN_TYPE_BOS) || | |
| 528 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { | |
| 4236 | 529 debug_printf("major connection error\n"); |
| 3074 | 530 hide_login_progress_error(gc, _("Disconnected.")); |
| 2086 | 531 signoff(gc); |
| 532 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
| 533 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
| 534 char buf[BUF_LONG]; | |
| 535 debug_printf("disconnected from chat room %s\n", c->name); | |
| 536 c->conn = NULL; | |
| 537 if (c->inpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
538 gaim_input_remove(c->inpa); |
| 2086 | 539 c->inpa = 0; |
| 540 c->fd = -1; | |
| 541 aim_conn_kill(odata->sess, &conn); | |
| 3574 | 542 snprintf(buf, sizeof(buf), _("You have been disconnected from chat room %s."), c->name); |
| 3427 | 543 do_error_dialog(buf, NULL, GAIM_ERROR); |
| 2086 | 544 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { |
| 545 if (odata->cnpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
546 gaim_input_remove(odata->cnpa); |
| 2086 | 547 odata->cnpa = 0; |
| 548 debug_printf("removing chatnav input watcher\n"); | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
549 while (odata->create_rooms) { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
550 struct create_room *cr = odata->create_rooms->data; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
551 g_free(cr->name); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
552 odata->create_rooms = |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
553 g_slist_remove(odata->create_rooms, cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
554 g_free(cr); |
| 3427 | 555 do_error_dialog(_("Chat is currently unavailable"), NULL, GAIM_ERROR); |
| 2086 | 556 } |
| 557 aim_conn_kill(odata->sess, &conn); | |
| 558 } else if (conn->type == AIM_CONN_TYPE_AUTH) { | |
| 559 if (odata->paspa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
560 gaim_input_remove(odata->paspa); |
| 2086 | 561 odata->paspa = 0; |
| 562 debug_printf("removing authconn input watcher\n"); | |
| 563 aim_conn_kill(odata->sess, &conn); | |
| 3694 | 564 } else if (conn->type == AIM_CONN_TYPE_EMAIL) { |
| 565 if (odata->emlpa > 0) | |
| 566 gaim_input_remove(odata->emlpa); | |
| 567 odata->emlpa = 0; | |
| 568 debug_printf("removing email input watcher\n"); | |
| 569 aim_conn_kill(odata->sess, &conn); | |
| 2086 | 570 } else if (conn->type == AIM_CONN_TYPE_RENDEZVOUS) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
571 if (conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
572 gaim_directim_disconnect(odata->sess, conn); |
| 3630 | 573 else if (conn->subtype == AIM_CONN_SUBTYPE_OFT_SENDFILE) { |
| 574 struct oscar_file_transfer *oft = find_oft_by_conn(gc, conn); | |
| 575 if (oft) { | |
| 576 transfer_abort(oft->xfer, _("Buddy canceled transfer")); | |
| 577 } | |
| 578 oscar_file_transfer_disconnect(odata->sess, conn); | |
| 579 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
580 else { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
581 debug_printf("No handler for rendezvous disconnect (%d).\n", |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
582 source); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
583 } |
| 2086 | 584 aim_conn_kill(odata->sess, &conn); |
| 585 } else { | |
| 4194 | 586 debug_printf("holy crap! generic connection error! %hu\n", |
| 2086 | 587 conn->type); |
| 588 aim_conn_kill(odata->sess, &conn); | |
| 589 } | |
| 590 } | |
| 591 } | |
| 592 } | |
| 593 } | |
| 594 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
595 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) { |
| 2086 | 596 char *s = g_strdup_vprintf(format, va); |
| 597 char buf[256]; | |
| 598 char *t; | |
| 599 struct gaim_connection *gc = sess->aux_data; | |
| 600 | |
| 601 g_snprintf(buf, sizeof(buf), "%s %d: ", gc->username, level); | |
| 602 t = g_strconcat(buf, s, NULL); | |
| 603 debug_printf(t); | |
| 604 if (t[strlen(t)-1] != '\n') | |
| 605 debug_printf("\n"); | |
| 606 g_free(t); | |
| 607 g_free(s); | |
| 608 } | |
| 609 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
610 static void oscar_login_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 611 { |
| 612 struct gaim_connection *gc = data; | |
| 613 struct oscar_data *odata; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
614 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
615 aim_conn_t *conn; |
| 2086 | 616 |
| 617 if (!g_slist_find(connections, gc)) { | |
| 618 close(source); | |
| 619 return; | |
| 620 } | |
| 621 | |
| 622 odata = gc->proto_data; | |
| 623 sess = odata->sess; | |
| 624 conn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
| 4366 | 625 |
| 626 conn->fd = source; | |
| 2086 | 627 |
| 628 if (source < 0) { | |
| 629 hide_login_progress(gc, _("Couldn't connect to host")); | |
| 630 signoff(gc); | |
| 631 return; | |
| 632 } | |
| 633 | |
| 634 aim_conn_completeconnect(sess, conn); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
635 gc->inpa = gaim_input_add(conn->fd, GAIM_INPUT_READ, |
| 2086 | 636 oscar_callback, conn); |
| 4236 | 637 debug_printf("Password sent, waiting for response\n"); |
| 2086 | 638 } |
| 639 | |
| 640 static void oscar_login(struct aim_user *user) { | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
641 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
642 aim_conn_t *conn; |
| 2086 | 643 char buf[256]; |
| 644 struct gaim_connection *gc = new_gaim_conn(user); | |
| 645 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); | |
| 4366 | 646 int rc; |
| 2086 | 647 |
|
2589
4e149a0b9665
[gaim-migrate @ 2602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2507
diff
changeset
|
648 if (isdigit(*user->username)) { |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
649 odata->icq = TRUE; |
| 3064 | 650 gc->password[8] = 0; |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
651 } else { |
|
2918
4df759d607f3
[gaim-migrate @ 2931]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2916
diff
changeset
|
652 gc->flags |= OPT_CONN_HTML; |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
653 gc->flags |= OPT_CONN_AUTO_RESP; |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
654 } |
| 3600 | 655 odata->supports_tn = g_hash_table_new(g_str_hash, g_str_equal); |
| 2086 | 656 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
657 sess = g_new0(aim_session_t, 1); |
| 2086 | 658 |
| 659 aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0); | |
| 660 aim_setdebuggingcb(sess, oscar_debug); | |
| 661 | |
| 662 /* we need an immediate queue because we don't use a while-loop to | |
| 663 * see if things need to be sent. */ | |
| 664 aim_tx_setenqueue(sess, AIM_TX_IMMEDIATE, NULL); | |
| 665 odata->sess = sess; | |
| 666 sess->aux_data = gc; | |
| 667 | |
| 668 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
| 669 if (conn == NULL) { | |
| 4236 | 670 debug_printf("internal connection error\n"); |
| 2086 | 671 hide_login_progress(gc, _("Unable to login to AIM")); |
| 672 signoff(gc); | |
| 673 return; | |
| 674 } | |
| 675 | |
| 676 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
| 677 set_login_progress(gc, 2, buf); | |
| 678 | |
| 679 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
| 680 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
| 681 | |
| 682 conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 4366 | 683 rc = proxy_connect(user->proto_opt[USEROPT_AUTH][0] ? |
| 2086 | 684 user->proto_opt[USEROPT_AUTH] : FAIM_LOGIN_SERVER, |
| 685 user->proto_opt[USEROPT_AUTHPORT][0] ? | |
| 686 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
| 687 oscar_login_connect, gc); | |
| 4366 | 688 if (rc < 0) { |
| 2086 | 689 hide_login_progress(gc, _("Couldn't connect to host")); |
| 690 signoff(gc); | |
| 691 return; | |
| 692 } | |
| 693 aim_request_login(sess, conn, gc->username); | |
| 694 } | |
| 695 | |
| 696 static void oscar_close(struct gaim_connection *gc) { | |
| 697 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 698 | |
| 699 while (odata->oscar_chats) { | |
| 700 struct chat_connection *n = odata->oscar_chats->data; | |
| 701 if (n->inpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
702 gaim_input_remove(n->inpa); |
| 2086 | 703 g_free(n->name); |
| 704 g_free(n->show); | |
| 705 odata->oscar_chats = g_slist_remove(odata->oscar_chats, n); | |
| 706 g_free(n); | |
| 707 } | |
| 708 while (odata->direct_ims) { | |
| 709 struct direct_im *n = odata->direct_ims->data; | |
| 710 if (n->watcher > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
711 gaim_input_remove(n->watcher); |
| 2086 | 712 odata->direct_ims = g_slist_remove(odata->direct_ims, n); |
| 713 g_free(n); | |
| 714 } | |
| 3630 | 715 while (odata->file_transfers) { |
| 716 struct oscar_file_transfer *n = odata->file_transfers->data; | |
| 717 if (n->watcher > 0) | |
| 718 gaim_input_remove(n->watcher); | |
| 719 odata->file_transfers = g_slist_remove(odata->file_transfers, n); | |
| 720 g_free(n); | |
| 721 } | |
| 2086 | 722 while (odata->hasicons) { |
| 723 struct icon_req *n = odata->hasicons->data; | |
| 724 g_free(n->user); | |
| 725 odata->hasicons = g_slist_remove(odata->hasicons, n); | |
| 726 g_free(n); | |
| 727 } | |
| 3600 | 728 g_hash_table_destroy(odata->supports_tn); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
729 while (odata->evilhack) { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
730 g_free(odata->evilhack->data); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
731 odata->evilhack = g_slist_remove(odata->evilhack, odata->evilhack->data); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
732 } |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
733 while (odata->create_rooms) { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
734 struct create_room *cr = odata->create_rooms->data; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
735 g_free(cr->name); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
736 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
737 g_free(cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
738 } |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
739 if (odata->email) |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
740 g_free(odata->email); |
|
2754
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
741 if (odata->newp) |
|
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
742 g_free(odata->newp); |
|
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
743 if (odata->oldp) |
|
642413968b03
[gaim-migrate @ 2767]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2742
diff
changeset
|
744 g_free(odata->oldp); |
| 2086 | 745 if (gc->inpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
746 gaim_input_remove(gc->inpa); |
| 2086 | 747 if (odata->cnpa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
748 gaim_input_remove(odata->cnpa); |
| 2086 | 749 if (odata->paspa > 0) |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
750 gaim_input_remove(odata->paspa); |
| 3694 | 751 if (odata->emlpa > 0) |
| 752 gaim_input_remove(odata->emlpa); | |
| 2086 | 753 aim_session_kill(odata->sess); |
| 754 g_free(odata->sess); | |
| 755 odata->sess = NULL; | |
| 756 g_free(gc->proto_data); | |
| 757 gc->proto_data = NULL; | |
| 4236 | 758 debug_printf("Signed off.\n"); |
| 2086 | 759 } |
| 760 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
761 static void oscar_bos_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 2086 | 762 struct gaim_connection *gc = data; |
| 763 struct oscar_data *odata; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
764 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
765 aim_conn_t *bosconn; |
| 2086 | 766 |
| 767 if (!g_slist_find(connections, gc)) { | |
| 768 close(source); | |
| 769 return; | |
| 770 } | |
| 771 | |
| 772 odata = gc->proto_data; | |
| 773 sess = odata->sess; | |
| 4366 | 774 bosconn = odata->conn; |
| 775 bosconn->fd = source; | |
| 2086 | 776 |
| 777 if (source < 0) { | |
| 778 hide_login_progress(gc, _("Could Not Connect")); | |
| 779 signoff(gc); | |
| 780 return; | |
| 781 } | |
| 782 | |
| 783 aim_conn_completeconnect(sess, bosconn); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
784 gc->inpa = gaim_input_add(bosconn->fd, GAIM_INPUT_READ, |
| 2086 | 785 oscar_callback, bosconn); |
| 786 set_login_progress(gc, 4, _("Connection established, cookie sent")); | |
| 787 } | |
| 788 | |
| 3630 | 789 static void oscar_ask_send_file(struct gaim_connection *gc, char *destsn) { |
| 790 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 3752 | 791 |
| 792 struct oscar_file_transfer *oft = g_new0(struct oscar_file_transfer, | |
| 793 1); | |
| 794 | |
| 795 oft->type = OFT_SENDFILE_OUT; | |
| 796 oft->sn = g_strdup(destsn); | |
| 797 | |
| 798 od->file_transfers = g_slist_append(od->file_transfers, oft); | |
| 799 | |
| 800 oft->xfer = transfer_out_add(gc, oft->sn); | |
| 3630 | 801 } |
| 802 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
803 static int gaim_parse_auth_resp(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 804 va_list ap; |
| 2704 | 805 struct aim_authresp_info *info; |
| 4366 | 806 int i, rc; char *host; int port; |
| 2086 | 807 struct aim_user *user; |
| 2704 | 808 aim_conn_t *bosconn; |
| 2086 | 809 |
| 810 struct gaim_connection *gc = sess->aux_data; | |
| 811 struct oscar_data *od = gc->proto_data; | |
| 812 user = gc->user; | |
| 813 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
| 814 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
| 815 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
816 va_start(ap, fr); |
| 2704 | 817 info = va_arg(ap, struct aim_authresp_info *); |
| 2086 | 818 va_end(ap); |
| 819 | |
| 2704 | 820 debug_printf("inside auth_resp (Screen name: %s)\n", info->sn); |
| 821 | |
| 4293 | 822 if (info->errorcode || !info->bosip || !info->cookielen || !info->cookie) { |
| 4056 | 823 char buf[256]; |
| 2704 | 824 switch (info->errorcode) { |
| 2086 | 825 case 0x05: |
| 826 /* Incorrect nick/password */ | |
| 827 hide_login_progress(gc, _("Incorrect nickname or password.")); | |
| 828 plugin_event(event_error, (void *)980, 0, 0, 0); | |
| 829 break; | |
| 830 case 0x11: | |
| 831 /* Suspended account */ | |
| 832 hide_login_progress(gc, _("Your account is currently suspended.")); | |
| 833 break; | |
| 3498 | 834 case 0x14: |
| 835 /* service temporarily unavailable */ | |
| 836 hide_login_progress(gc, _("The AOL Instant Messenger service is temporarily unavailable.")); | |
| 837 break; | |
| 2086 | 838 case 0x18: |
| 839 /* connecting too frequently */ | |
| 840 hide_login_progress(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.")); | |
| 841 plugin_event(event_error, (void *)983, 0, 0, 0); | |
| 842 break; | |
| 843 case 0x1c: | |
| 844 /* client too old */ | |
| 4056 | 845 g_snprintf(buf, sizeof(buf), _("The client version you are using is too old. Please upgrade at %s"), WEBSITE); |
| 846 hide_login_progress(gc, buf); | |
| 2086 | 847 plugin_event(event_error, (void *)989, 0, 0, 0); |
| 848 break; | |
| 849 default: | |
| 850 hide_login_progress(gc, _("Authentication Failed")); | |
| 851 break; | |
| 852 } | |
| 4194 | 853 debug_printf("Login Error Code 0x%04hx\n", info->errorcode); |
| 2704 | 854 debug_printf("Error URL: %s\n", info->errorurl); |
| 2086 | 855 od->killme = TRUE; |
| 856 return 1; | |
| 857 } | |
| 858 | |
| 859 | |
| 4194 | 860 debug_printf("Reg status: %hu\n", info->regstatus); |
| 2704 | 861 if (info->email) { |
| 862 debug_printf("Email: %s\n", info->email); | |
| 2086 | 863 } else { |
| 864 debug_printf("Email is NULL\n"); | |
| 865 } | |
| 2704 | 866 debug_printf("BOSIP: %s\n", info->bosip); |
| 2086 | 867 debug_printf("Closing auth connection...\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
868 aim_conn_kill(sess, &fr->conn); |
| 2086 | 869 |
| 870 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, NULL); | |
| 871 if (bosconn == NULL) { | |
| 872 hide_login_progress(gc, _("Internal Error")); | |
| 873 od->killme = TRUE; | |
| 874 return 0; | |
| 875 } | |
| 876 | |
| 2675 | 877 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_bos, 0); |
| 2086 | 878 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); |
| 879 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
| 880 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
| 2993 | 881 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_RIGHTSINFO, gaim_parse_locaterights, 0); |
| 2086 | 882 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); |
| 883 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
| 884 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
| 885 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
| 886 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
| 887 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
| 3212 | 888 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_CLIENTAUTORESP, gaim_parse_clientauto, 0); |
| 2086 | 889 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); |
| 890 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
| 891 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, AIM_CB_LOK_ERROR, gaim_parse_searcherror, 0); | |
| 892 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOK, 0x0003, gaim_parse_searchreply, 0); | |
| 893 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
| 3595 | 894 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MTN, gaim_parse_mtn, 0); |
| 2086 | 895 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); |
| 896 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
| 897 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
898 aim_conn_addhandler(sess, bosconn, 0x0004, 0x0005, gaim_icbm_param_info, 0); |
| 2086 | 899 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0001, gaim_parse_genericerr, 0); |
| 900 aim_conn_addhandler(sess, bosconn, 0x0003, 0x0001, gaim_parse_genericerr, 0); | |
| 901 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0001, gaim_parse_genericerr, 0); | |
| 902 aim_conn_addhandler(sess, bosconn, 0x0001, 0x001f, gaim_memrequest, 0); | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
903 aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0); |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
904 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
905 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
906 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0); |
| 4151 | 907 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_SIMPLEINFO, gaim_icqsimpleinfo, 0); |
| 908 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALLINFO, gaim_icqallinfo, 0); | |
| 4230 | 909 #ifndef NOSSI |
| 2991 | 910 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RIGHTSINFO, gaim_ssi_parserights, 0); |
| 911 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_LIST, gaim_ssi_parselist, 0); | |
| 912 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_NOLIST, gaim_ssi_parselist, 0); | |
| 4230 | 913 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_SRVACK, gaim_ssi_parseack, 0); |
| 914 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTH, gaim_ssi_authgiven, 0); | |
| 915 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREQ, gaim_ssi_authrequest, 0); | |
| 916 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_RECVAUTHREP, gaim_ssi_authreply, 0); | |
| 917 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SSI, AIM_CB_SSI_ADDED, gaim_ssi_gotadded, 0); | |
| 918 #endif | |
| 3752 | 919 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_MSGTIMEOUT, oscar_sendfile_timeout, 0); |
| 2086 | 920 |
| 921 ((struct oscar_data *)gc->proto_data)->conn = bosconn; | |
| 2704 | 922 for (i = 0; i < (int)strlen(info->bosip); i++) { |
| 923 if (info->bosip[i] == ':') { | |
| 924 port = atoi(&(info->bosip[i+1])); | |
| 2086 | 925 break; |
| 926 } | |
| 927 } | |
| 2704 | 928 host = g_strndup(info->bosip, i); |
| 2086 | 929 bosconn->status |= AIM_CONN_STATUS_INPROGRESS; |
| 4366 | 930 rc = proxy_connect(host, port, oscar_bos_connect, gc); |
| 2086 | 931 g_free(host); |
| 4366 | 932 if (rc < 0) { |
| 2086 | 933 hide_login_progress(gc, _("Could Not Connect")); |
| 934 od->killme = TRUE; | |
| 935 return 0; | |
| 936 } | |
| 4293 | 937 aim_sendcookie(sess, bosconn, info->cookielen, info->cookie); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
938 gaim_input_remove(gc->inpa); |
| 2704 | 939 |
| 2086 | 940 return 1; |
| 941 } | |
| 942 | |
| 943 struct pieceofcrap { | |
| 944 struct gaim_connection *gc; | |
| 945 unsigned long offset; | |
| 946 unsigned long len; | |
| 947 char *modname; | |
| 948 int fd; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
949 aim_conn_t *conn; |
| 2086 | 950 unsigned int inpa; |
| 951 }; | |
| 952 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
953 static void damn_you(gpointer data, gint source, GaimInputCondition c) |
| 2086 | 954 { |
| 955 struct pieceofcrap *pos = data; | |
| 956 struct oscar_data *od = pos->gc->proto_data; | |
| 957 char in = '\0'; | |
| 958 int x = 0; | |
| 959 unsigned char m[17]; | |
| 960 | |
| 961 while (read(pos->fd, &in, 1) == 1) { | |
| 962 if (in == '\n') | |
| 963 x++; | |
| 964 else if (in != '\r') | |
| 965 x = 0; | |
| 966 if (x == 2) | |
| 967 break; | |
| 968 in = '\0'; | |
| 969 } | |
| 970 if (in != '\n') { | |
| 4056 | 971 char buf[256]; |
| 972 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
| 973 "this is fixed. Check %s for updates."), WEBSITE); | |
| 3427 | 974 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
| 4056 | 975 buf, GAIM_WARNING); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
976 gaim_input_remove(pos->inpa); |
| 2086 | 977 close(pos->fd); |
| 978 g_free(pos); | |
| 979 return; | |
| 980 } | |
| 981 read(pos->fd, m, 16); | |
| 982 m[16] = '\0'; | |
| 983 debug_printf("Sending hash: "); | |
| 984 for (x = 0; x < 16; x++) | |
| 4194 | 985 debug_printf("%02hhx ", (unsigned char)m[x]); |
| 2086 | 986 debug_printf("\n"); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
987 gaim_input_remove(pos->inpa); |
| 2086 | 988 close(pos->fd); |
| 989 aim_sendmemblock(od->sess, pos->conn, 0, 16, m, AIM_SENDMEMBLOCK_FLAG_ISHASH); | |
| 990 g_free(pos); | |
| 991 } | |
| 992 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
993 static void straight_to_hell(gpointer data, gint source, GaimInputCondition cond) { |
| 2086 | 994 struct pieceofcrap *pos = data; |
| 995 char buf[BUF_LONG]; | |
| 996 | |
| 4366 | 997 pos->fd = source; |
| 998 | |
| 2086 | 999 if (source < 0) { |
| 4056 | 1000 char buf[256]; |
| 1001 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " | |
| 1002 "this is fixed. Check %s for updates."), WEBSITE); | |
| 3427 | 1003 do_error_dialog(_("Gaim was Unable to get a valid AIM login hash."), |
| 4056 | 1004 buf, GAIM_WARNING); |
| 2086 | 1005 if (pos->modname) |
| 1006 g_free(pos->modname); | |
| 1007 g_free(pos); | |
| 1008 return; | |
| 1009 } | |
| 1010 | |
| 1011 g_snprintf(buf, sizeof(buf), "GET " AIMHASHDATA | |
| 1012 "?offset=%ld&len=%ld&modname=%s HTTP/1.0\n\n", | |
| 1013 pos->offset, pos->len, pos->modname ? pos->modname : ""); | |
| 1014 write(pos->fd, buf, strlen(buf)); | |
| 1015 if (pos->modname) | |
| 1016 g_free(pos->modname); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1017 pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); |
| 2086 | 1018 return; |
| 1019 } | |
| 1020 | |
| 1021 /* size of icbmui.ocm, the largest module in AIM 3.5 */ | |
| 1022 #define AIM_MAX_FILE_SIZE 98304 | |
| 1023 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1024 int gaim_memrequest(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 1025 va_list ap; |
| 1026 struct pieceofcrap *pos; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1027 fu32_t offset, len; |
| 2086 | 1028 char *modname; |
| 1029 int fd; | |
| 1030 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1031 va_start(ap, fr); |
| 4200 | 1032 offset = va_arg(ap, fu32_t); |
| 1033 len = va_arg(ap, fu32_t); | |
| 2086 | 1034 modname = va_arg(ap, char *); |
| 1035 va_end(ap); | |
| 1036 | |
| 4194 | 1037 debug_printf("offset: %lu, len: %lu, file: %s\n", offset, len, (modname ? modname : "aim.exe")); |
| 2086 | 1038 if (len == 0) { |
| 1039 debug_printf("len is 0, hashing NULL\n"); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1040 aim_sendmemblock(sess, fr->conn, offset, len, NULL, |
| 2086 | 1041 AIM_SENDMEMBLOCK_FLAG_ISREQUEST); |
| 1042 return 1; | |
| 1043 } | |
| 1044 /* uncomment this when you're convinced it's right. remember, it's been wrong before. | |
| 1045 if (offset > AIM_MAX_FILE_SIZE || len > AIM_MAX_FILE_SIZE) { | |
| 1046 char *buf; | |
| 1047 int i = 8; | |
| 1048 if (modname) | |
| 1049 i += strlen(modname); | |
| 1050 buf = g_malloc(i); | |
| 1051 i = 0; | |
| 1052 if (modname) { | |
| 1053 memcpy(buf, modname, strlen(modname)); | |
| 1054 i += strlen(modname); | |
| 1055 } | |
| 1056 buf[i++] = offset & 0xff; | |
| 1057 buf[i++] = (offset >> 8) & 0xff; | |
| 1058 buf[i++] = (offset >> 16) & 0xff; | |
| 1059 buf[i++] = (offset >> 24) & 0xff; | |
| 1060 buf[i++] = len & 0xff; | |
| 1061 buf[i++] = (len >> 8) & 0xff; | |
| 1062 buf[i++] = (len >> 16) & 0xff; | |
| 1063 buf[i++] = (len >> 24) & 0xff; | |
| 1064 debug_printf("len + offset is invalid, hashing request\n"); | |
| 1065 aim_sendmemblock(sess, command->conn, offset, i, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST); | |
| 1066 g_free(buf); | |
| 1067 return 1; | |
| 1068 } | |
| 1069 */ | |
| 1070 | |
| 1071 pos = g_new0(struct pieceofcrap, 1); | |
| 1072 pos->gc = sess->aux_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1073 pos->conn = fr->conn; |
| 2086 | 1074 |
| 1075 pos->offset = offset; | |
| 1076 pos->len = len; | |
| 1077 pos->modname = modname ? g_strdup(modname) : NULL; | |
| 1078 | |
| 1079 fd = proxy_connect("gaim.sourceforge.net", 80, straight_to_hell, pos); | |
| 1080 if (fd < 0) { | |
| 4056 | 1081 char buf[256]; |
| 2086 | 1082 if (pos->modname) |
| 1083 g_free(pos->modname); | |
| 1084 g_free(pos); | |
| 4056 | 1085 g_snprintf(buf, sizeof(buf), _("You may be disconnected shortly. You may want to use TOC until " |
| 1086 "this is fixed. Check %s for updates."), WEBSITE); | |
| 3427 | 1087 do_error_dialog(_("Gaim was Unable to get valid login hash."), |
| 4056 | 1088 buf, GAIM_WARNING); |
| 2086 | 1089 } |
| 1090 | |
| 1091 return 1; | |
| 1092 } | |
| 1093 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1094 static int gaim_parse_login(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 1095 char *key; |
| 1096 va_list ap; | |
| 1097 struct gaim_connection *gc = sess->aux_data; | |
| 3458 | 1098 struct oscar_data *odata = gc->proto_data; |
| 2086 | 1099 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1100 va_start(ap, fr); |
| 2086 | 1101 key = va_arg(ap, char *); |
| 1102 va_end(ap); | |
| 1103 | |
| 3458 | 1104 if (odata->icq) { |
| 1105 struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD; | |
| 1106 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
| 1107 } else { | |
| 1108 #if 0 | |
| 1109 struct client_info_s info = {"gaim", 4, 1, 2010, "us", "en", 0x0004, 0x0000, 0x04b}; | |
| 1110 #endif | |
| 1111 struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD; | |
| 1112 aim_send_login(sess, fr->conn, gc->username, gc->password, &info, key); | |
| 1113 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1114 |
| 2086 | 1115 return 1; |
| 1116 } | |
| 1117 | |
| 2675 | 1118 static int conninitdone_chat(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2647 | 1119 struct gaim_connection *gc = sess->aux_data; |
| 1120 struct chat_connection *chatcon; | |
| 1121 static int id = 1; | |
| 1122 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1123 aim_conn_addhandler(sess, fr->conn, 0x000e, 0x0001, gaim_parse_genericerr, 0); |
| 2675 | 1124 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
| 1125 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
| 1126 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
| 1127 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
| 1128 | |
| 2672 | 1129 aim_clientready(sess, fr->conn); |
| 2675 | 1130 |
| 2647 | 1131 chatcon = find_oscar_chat_by_conn(gc, fr->conn); |
| 1132 chatcon->id = id; | |
| 1133 chatcon->cnv = serv_got_joined_chat(gc, id++, chatcon->show); | |
| 1134 | |
| 1135 return 1; | |
| 1136 } | |
| 1137 | |
| 2675 | 1138 static int conninitdone_chatnav(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1139 | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1140 aim_conn_addhandler(sess, fr->conn, 0x000d, 0x0001, gaim_parse_genericerr, 0); |
| 2647 | 1141 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
| 2675 | 1142 |
| 1143 aim_clientready(sess, fr->conn); | |
| 1144 | |
| 1145 aim_chatnav_reqrights(sess, fr->conn); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1146 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1147 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1148 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1149 |
| 3694 | 1150 static int conninitdone_email(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1151 | |
| 1152 aim_conn_addhandler(sess, fr->conn, 0x0018, 0x0001, gaim_parse_genericerr, 0); | |
| 1153 aim_conn_addhandler(sess, fr->conn, AIM_CB_FAM_EML, AIM_CB_EML_MAILSTATUS, gaim_email_parseupdate, 0); | |
| 1154 | |
| 1155 aim_email_sendcookies(sess, fr->conn); | |
| 1156 aim_email_activate(sess, fr->conn); | |
| 1157 aim_clientready(sess, fr->conn); | |
| 1158 | |
| 1159 return 1; | |
| 1160 } | |
| 1161 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1162 static void oscar_chatnav_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 2086 | 1163 struct gaim_connection *gc = data; |
| 1164 struct oscar_data *odata; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1165 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1166 aim_conn_t *tstconn; |
| 2086 | 1167 |
| 1168 if (!g_slist_find(connections, gc)) { | |
| 1169 close(source); | |
| 1170 return; | |
| 1171 } | |
| 1172 | |
| 1173 odata = gc->proto_data; | |
| 1174 sess = odata->sess; | |
| 1175 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_CHATNAV); | |
| 4366 | 1176 tstconn->fd = source; |
| 2086 | 1177 |
| 1178 if (source < 0) { | |
| 1179 aim_conn_kill(sess, &tstconn); | |
| 1180 debug_printf("unable to connect to chatnav server\n"); | |
| 1181 return; | |
| 1182 } | |
| 1183 | |
| 1184 aim_conn_completeconnect(sess, tstconn); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1185 odata->cnpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1186 oscar_callback, tstconn); |
| 2086 | 1187 debug_printf("chatnav: connected\n"); |
| 1188 } | |
| 1189 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1190 static void oscar_auth_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1191 { |
| 1192 struct gaim_connection *gc = data; | |
| 1193 struct oscar_data *odata; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1194 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1195 aim_conn_t *tstconn; |
| 2086 | 1196 |
| 1197 if (!g_slist_find(connections, gc)) { | |
| 1198 close(source); | |
| 1199 return; | |
| 1200 } | |
| 1201 | |
| 1202 odata = gc->proto_data; | |
| 1203 sess = odata->sess; | |
| 1204 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_AUTH); | |
| 4366 | 1205 tstconn->fd = source; |
| 2086 | 1206 |
| 1207 if (source < 0) { | |
| 1208 aim_conn_kill(sess, &tstconn); | |
| 1209 debug_printf("unable to connect to authorizer\n"); | |
| 1210 return; | |
| 1211 } | |
| 1212 | |
| 1213 aim_conn_completeconnect(sess, tstconn); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1214 odata->paspa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, |
| 2086 | 1215 oscar_callback, tstconn); |
| 1216 debug_printf("chatnav: connected\n"); | |
| 1217 } | |
| 1218 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1219 static void oscar_chat_connect(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1220 { |
| 1221 struct chat_connection *ccon = data; | |
| 1222 struct gaim_connection *gc = ccon->gc; | |
| 1223 struct oscar_data *odata; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1224 aim_session_t *sess; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1225 aim_conn_t *tstconn; |
| 2086 | 1226 |
| 1227 if (!g_slist_find(connections, gc)) { | |
| 1228 close(source); | |
| 1229 g_free(ccon->show); | |
| 1230 g_free(ccon->name); | |
| 1231 g_free(ccon); | |
| 1232 return; | |
| 1233 } | |
| 1234 | |
| 1235 odata = gc->proto_data; | |
| 1236 sess = odata->sess; | |
| 1237 tstconn = ccon->conn; | |
| 4366 | 1238 tstconn->fd = source; |
| 2086 | 1239 |
| 1240 if (source < 0) { | |
| 1241 aim_conn_kill(sess, &tstconn); | |
| 1242 g_free(ccon->show); | |
| 1243 g_free(ccon->name); | |
| 1244 g_free(ccon); | |
| 1245 return; | |
| 1246 } | |
| 1247 | |
| 1248 aim_conn_completeconnect(sess, ccon->conn); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1249 ccon->inpa = gaim_input_add(tstconn->fd, |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1250 GAIM_INPUT_READ, |
| 2086 | 1251 oscar_callback, tstconn); |
| 1252 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); | |
| 1253 } | |
| 1254 | |
| 3694 | 1255 static void oscar_email_connect(gpointer data, gint source, GaimInputCondition cond) { |
| 1256 struct gaim_connection *gc = data; | |
| 1257 struct oscar_data *odata; | |
| 1258 aim_session_t *sess; | |
| 1259 aim_conn_t *tstconn; | |
| 1260 | |
| 1261 if (!g_slist_find(connections, gc)) { | |
| 1262 close(source); | |
| 1263 return; | |
| 1264 } | |
| 1265 | |
| 1266 odata = gc->proto_data; | |
| 1267 sess = odata->sess; | |
| 1268 tstconn = aim_getconn_type_all(sess, AIM_CONN_TYPE_EMAIL); | |
| 4366 | 1269 tstconn->fd = source; |
| 3694 | 1270 |
| 1271 if (source < 0) { | |
| 1272 aim_conn_kill(sess, &tstconn); | |
| 1273 debug_printf("unable to connect to email server\n"); | |
| 1274 return; | |
| 1275 } | |
| 1276 | |
| 1277 aim_conn_completeconnect(sess, tstconn); | |
| 1278 odata->emlpa = gaim_input_add(tstconn->fd, GAIM_INPUT_READ, oscar_callback, tstconn); | |
| 1279 debug_printf("email: connected\n"); | |
| 1280 } | |
| 1281 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1282 /* Hrmph. I don't know how to make this look better. --mid */ |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1283 static int gaim_handle_redirect(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 1284 va_list ap; |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1285 struct aim_redirect_data *redir; |
| 2086 | 1286 struct gaim_connection *gc = sess->aux_data; |
| 1287 struct aim_user *user = gc->user; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1288 aim_conn_t *tstconn; |
| 4366 | 1289 int i, rc; |
| 2086 | 1290 char *host; |
| 1291 int port; | |
| 1292 | |
| 1293 port = user->proto_opt[USEROPT_AUTHPORT][0] ? | |
| 1294 atoi(user->proto_opt[USEROPT_AUTHPORT]) : FAIM_LOGIN_PORT, | |
| 1295 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1296 va_start(ap, fr); |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1297 redir = va_arg(ap, struct aim_redirect_data *); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1298 va_end(ap); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1299 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1300 for (i = 0; i < (int)strlen(redir->ip); i++) { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1301 if (redir->ip[i] == ':') { |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1302 port = atoi(&(redir->ip[i+1])); |
| 2086 | 1303 break; |
| 1304 } | |
| 1305 } | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1306 host = g_strndup(redir->ip, i); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1307 |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1308 switch(redir->group) { |
| 2086 | 1309 case 0x7: /* Authorizer */ |
| 1310 debug_printf("Reconnecting with authorizor...\n"); | |
| 1311 tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, NULL); | |
| 1312 if (tstconn == NULL) { | |
| 1313 debug_printf("unable to reconnect with authorizer\n"); | |
| 1314 g_free(host); | |
| 1315 return 1; | |
| 1316 } | |
| 2675 | 1317 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_admin, 0); |
| 2086 | 1318 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0003, gaim_info_change, 0); |
| 1319 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0005, gaim_info_change, 0); | |
| 1320 aim_conn_addhandler(sess, tstconn, 0x0007, 0x0007, gaim_account_confirm, 0); | |
| 1321 | |
| 1322 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 4366 | 1323 rc = proxy_connect(host, port, oscar_auth_connect, gc); |
| 1324 if (rc < 0) { | |
| 2086 | 1325 aim_conn_kill(sess, &tstconn); |
| 1326 debug_printf("unable to reconnect with authorizer\n"); | |
| 1327 g_free(host); | |
| 1328 return 1; | |
| 1329 } | |
| 4293 | 1330 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 1331 break; |
| 1332 | |
| 2086 | 1333 case 0xd: /* ChatNav */ |
| 1334 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, NULL); | |
| 1335 if (tstconn == NULL) { | |
| 1336 debug_printf("unable to connect to chatnav server\n"); | |
| 1337 g_free(host); | |
| 1338 return 1; | |
| 1339 } | |
| 2675 | 1340 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chatnav, 0); |
| 2086 | 1341 |
| 1342 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 4366 | 1343 rc = proxy_connect(host, port, oscar_chatnav_connect, gc); |
| 1344 if (rc < 0) { | |
| 2086 | 1345 aim_conn_kill(sess, &tstconn); |
| 1346 debug_printf("unable to connect to chatnav server\n"); | |
| 1347 g_free(host); | |
| 1348 return 1; | |
| 1349 } | |
| 4293 | 1350 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 1351 break; |
| 1352 | |
| 1353 case 0xe: { /* Chat */ | |
| 2086 | 1354 struct chat_connection *ccon; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1355 |
| 2086 | 1356 tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, NULL); |
| 1357 if (tstconn == NULL) { | |
| 1358 debug_printf("unable to connect to chat server\n"); | |
| 1359 g_free(host); | |
| 1360 return 1; | |
| 1361 } | |
| 1362 | |
| 2675 | 1363 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_chat, 0); |
| 1364 | |
| 2086 | 1365 ccon = g_new0(struct chat_connection, 1); |
| 1366 ccon->conn = tstconn; | |
| 1367 ccon->gc = gc; | |
| 1368 ccon->fd = -1; | |
|
2821
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1369 ccon->name = g_strdup(redir->chat.room); |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1370 ccon->exchange = redir->chat.exchange; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1371 ccon->instance = redir->chat.instance; |
|
9467e4ee81be
[gaim-migrate @ 2834]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
1372 ccon->show = extract_name(redir->chat.room); |
| 2086 | 1373 |
| 1374 ccon->conn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 4366 | 1375 rc = proxy_connect(host, port, oscar_chat_connect, ccon); |
| 1376 if (rc < 0) { | |
| 2086 | 1377 aim_conn_kill(sess, &tstconn); |
| 1378 debug_printf("unable to connect to chat server\n"); | |
| 1379 g_free(host); | |
| 1380 g_free(ccon->show); | |
| 1381 g_free(ccon->name); | |
| 1382 g_free(ccon); | |
| 1383 return 1; | |
| 1384 } | |
| 4293 | 1385 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 4194 | 1386 debug_printf("Connected to chat room %s exchange %hu\n", ccon->name, ccon->exchange); |
| 1387 } break; | |
| 3694 | 1388 |
| 1389 case 0x0018: { /* email */ | |
| 1390 if (!(tstconn = aim_newconn(sess, AIM_CONN_TYPE_EMAIL, NULL))) { | |
| 1391 debug_printf("unable to connect to email server\n"); | |
| 1392 g_free(host); | |
| 1393 return 1; | |
| 1394 } | |
| 1395 aim_conn_addhandler(sess, tstconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_CONNINITDONE, conninitdone_email, 0); | |
| 1396 | |
| 1397 tstconn->status |= AIM_CONN_STATUS_INPROGRESS; | |
| 4366 | 1398 rc = proxy_connect(host, port, oscar_email_connect, gc); |
| 1399 if (rc < 0) { | |
| 3694 | 1400 aim_conn_kill(sess, &tstconn); |
| 1401 debug_printf("unable to connect to email server\n"); | |
| 1402 g_free(host); | |
| 1403 return 1; | |
| 1404 } | |
| 4293 | 1405 aim_sendcookie(sess, tstconn, redir->cookielen, redir->cookie); |
| 3694 | 1406 } break; |
| 1407 | |
| 2086 | 1408 default: /* huh? */ |
| 4194 | 1409 debug_printf("got redirect for unknown service 0x%04hx\n", redir->group); |
| 2086 | 1410 break; |
| 1411 } | |
| 1412 | |
| 1413 g_free(host); | |
| 1414 return 1; | |
| 1415 } | |
| 1416 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1417 static int gaim_parse_oncoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 1418 struct gaim_connection *gc = sess->aux_data; |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1419 struct oscar_data *od = gc->proto_data; |
| 2993 | 1420 aim_userinfo_t *info; |
| 1421 time_t time_idle = 0, signon = 0; | |
| 1422 int type = 0; | |
| 1423 int caps = 0; | |
| 2086 | 1424 va_list ap; |
| 4194 | 1425 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1426 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1427 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 1428 va_end(ap); |
| 1429 | |
| 2993 | 1430 if (info->present & AIM_USERINFO_PRESENT_CAPABILITIES) |
| 1431 caps = info->capabilities; | |
| 3267 | 1432 if (info->flags & AIM_FLAG_ACTIVEBUDDY) |
| 1433 type |= UC_AB; | |
| 1434 | |
| 1435 if ((!od->icq) && (info->present & AIM_USERINFO_PRESENT_FLAGS)) { | |
| 1436 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
| 1437 type |= UC_UNCONFIRMED; | |
| 1438 if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
| 1439 type |= UC_ADMIN; | |
| 1440 if (info->flags & AIM_FLAG_AOL) | |
| 1441 type |= UC_AOL; | |
| 1442 if (info->flags & AIM_FLAG_FREE) | |
| 1443 type |= UC_NORMAL; | |
| 1444 if (info->flags & AIM_FLAG_AWAY) | |
| 1445 type |= UC_UNAVAILABLE; | |
| 1446 if (info->flags & AIM_FLAG_WIRELESS) | |
| 1447 type |= UC_WIRELESS; | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
1448 } |
| 2993 | 1449 if (info->present & AIM_USERINFO_PRESENT_ICQEXTSTATUS) { |
| 3595 | 1450 type = (info->icqinfo.status << 16); |
| 3013 | 1451 if (!(info->icqinfo.status & AIM_ICQ_STATE_CHAT) && |
| 1452 (info->icqinfo.status != AIM_ICQ_STATE_NORMAL)) { | |
| 2993 | 1453 type |= UC_UNAVAILABLE; |
| 3013 | 1454 } |
| 2993 | 1455 } |
| 1456 | |
| 1457 if (caps & AIM_CAPS_ICQ) | |
| 1458 caps ^= AIM_CAPS_ICQ; | |
| 1459 | |
| 1460 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
| 2086 | 1461 time(&time_idle); |
| 1462 time_idle -= info->idletime*60; | |
| 2993 | 1463 } |
| 1464 | |
| 1465 if (info->present & AIM_USERINFO_PRESENT_SESSIONLEN) | |
| 1466 signon = time(NULL) - info->sessionlen; | |
| 2086 | 1467 |
| 4269 | 1468 if (!aim_sncmp(gc->username, info->sn)) |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1469 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", info->sn); |
|
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
1470 |
| 2993 | 1471 serv_got_update(gc, info->sn, 1, info->warnlevel/10, signon, |
|
2713
34ddcb44a4d2
[gaim-migrate @ 2726]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1472 time_idle, type, caps); |
| 2086 | 1473 |
| 1474 return 1; | |
| 1475 } | |
| 1476 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1477 static int gaim_parse_offgoing(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1478 aim_userinfo_t *info; |
| 2086 | 1479 va_list ap; |
| 1480 struct gaim_connection *gc = sess->aux_data; | |
| 1481 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1482 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1483 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 1484 va_end(ap); |
| 1485 | |
| 1486 serv_got_update(gc, info->sn, 0, 0, 0, 0, 0, 0); | |
| 1487 | |
| 1488 return 1; | |
| 1489 } | |
| 1490 | |
| 3730 | 1491 static void cancel_direct_im(struct ask_direct *d) { |
| 2086 | 1492 debug_printf("Freeing DirectIM prompts.\n"); |
| 1493 | |
| 1494 g_free(d->sn); | |
| 1495 g_free(d); | |
| 1496 } | |
| 1497 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1498 static void oscar_directim_callback(gpointer data, gint source, GaimInputCondition condition) { |
| 2086 | 1499 struct direct_im *dim = data; |
| 1500 struct gaim_connection *gc = dim->gc; | |
| 1501 struct oscar_data *od = gc->proto_data; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1502 struct gaim_conversation *cnv; |
| 2086 | 1503 char buf[256]; |
| 3008 | 1504 struct sockaddr name; |
| 1505 socklen_t name_len = 1; | |
| 1506 | |
| 2086 | 1507 if (!g_slist_find(connections, gc)) { |
| 1508 g_free(dim); | |
| 1509 return; | |
| 1510 } | |
| 1511 | |
| 1512 if (source < 0) { | |
| 1513 g_free(dim); | |
| 1514 return; | |
| 1515 } | |
| 1516 | |
| 4366 | 1517 dim->conn->fd = source; |
| 2086 | 1518 aim_conn_completeconnect(od->sess, dim->conn); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1519 if (!(cnv = gaim_find_conversation(dim->name))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1520 cnv = gaim_conversation_new(GAIM_CONV_IM, dim->name); |
| 3008 | 1521 |
| 1522 /* This is the best way to see if we're connected or not */ | |
| 1523 if (getpeername(source, &name, &name_len) == 0) { | |
| 1524 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), dim->name); | |
| 1525 dim->connected = TRUE; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
1526 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
| 3008 | 1527 } |
| 2086 | 1528 od->direct_ims = g_slist_append(od->direct_ims, dim); |
| 3008 | 1529 |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1530 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
| 3008 | 1531 oscar_callback, dim->conn); |
| 2086 | 1532 } |
| 1533 | |
| 3952 | 1534 /* |
| 1535 * This is called every time we are finished sending a file and the receiving buddy | |
| 1536 * has sent back an acknowledgement; we start the next file or tear down the | |
| 1537 * connection as appropriate. | |
| 1538 */ | |
| 3630 | 1539 static int oscar_sendfile_out_done(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1540 struct gaim_connection *gc = sess->aux_data; | |
| 1541 va_list ap; | |
| 1542 aim_conn_t *conn; | |
| 1543 const char *cook; | |
| 1544 struct oscar_file_transfer *oft; | |
| 1545 | |
| 1546 va_start(ap, fr); | |
| 1547 conn = va_arg(ap, aim_conn_t *); | |
| 1548 cook = va_arg(ap, const char *); | |
| 1549 va_end(ap); | |
| 1550 | |
| 1551 oft = find_oft_by_cookie(gc, cook); | |
| 1552 if (oft->filesdone == oft->totfiles) | |
| 1553 oscar_file_transfer_disconnect(sess, conn); | |
| 1554 else | |
| 1555 /* Send header for next file */ | |
| 1556 oscar_sendfile_request(sess, oft); | |
| 1557 | |
| 1558 return 0; | |
| 1559 } | |
| 1560 | |
| 1561 /* Called once for each file before sending the raw data. */ | |
| 1562 static int oscar_sendfile_request(aim_session_t *sess, | |
| 1563 struct oscar_file_transfer *oft) { | |
| 1564 char *name; | |
| 1565 int size; | |
| 1566 | |
| 1567 transfer_get_file_info(oft->xfer, &size, &name); | |
| 3952 | 1568 /* AAA convert the name to UCS-2 if necessary, and pass the encoding to the call below */ |
| 3630 | 1569 aim_oft_sendfile_request(sess, oft->conn, name, oft->filesdone, |
| 1570 oft->totfiles, size, oft->totsize); | |
| 1571 | |
| 1572 return 0; | |
| 1573 } | |
| 1574 | |
| 3952 | 1575 /* |
| 1576 * This is called when sending a file and a direct connection has been set up with | |
| 1577 * the buddy; we can now transmit the appropriate headers describing the transfer. | |
| 1578 */ | |
| 3630 | 1579 static int oscar_sendfile_accepted(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1580 struct gaim_connection *gc = sess->aux_data; | |
| 1581 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 1582 struct oscar_file_transfer *oft; | |
| 1583 va_list ap; | |
| 1584 aim_conn_t *conn, *listenerconn; | |
| 3752 | 1585 |
| 3630 | 1586 va_start(ap, fr); |
| 1587 conn = va_arg(ap, aim_conn_t *); | |
| 1588 listenerconn = va_arg(ap, aim_conn_t *); | |
| 1589 va_end(ap); | |
| 1590 | |
| 1591 oft = find_oft_by_conn(gc, listenerconn); | |
| 1592 oft->conn = conn; | |
| 1593 /* Stop watching listener conn; watch transfer conn instead */ | |
| 1594 gaim_input_remove(oft->watcher); | |
| 1595 aim_conn_kill(sess, &listenerconn); | |
| 1596 | |
| 1597 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, | |
| 3771 | 1598 AIM_CB_OFT_SENDFILEFILESEND, |
| 3630 | 1599 oscar_file_transfer_do, |
| 1600 0); | |
| 1601 aim_conn_addhandler(sess, conn, | |
| 1602 AIM_CB_FAM_OFT, | |
| 3771 | 1603 AIM_CB_OFT_SENDFILECOMPLETE, |
| 3630 | 1604 oscar_sendfile_out_done, |
| 1605 0); | |
| 1606 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
| 1607 oscar_callback, oft->conn); | |
| 1608 | |
| 1609 oscar_sendfile_request(sess, oft); | |
| 1610 | |
| 1611 return 0; | |
| 1612 } | |
| 1613 | |
| 3952 | 1614 /* |
| 1615 * This is called when we requested to send a file to a buddy, but he or she didn't | |
| 1616 * respond; we need to clean up. | |
| 1617 */ | |
| 3752 | 1618 static int oscar_sendfile_timeout(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 1619 struct gaim_connection *gc = sess->aux_data; | |
| 1620 va_list ap; | |
| 1621 struct oscar_file_transfer *oft; | |
| 1622 char *cookie; | |
| 1623 aim_conn_t *bosconn; | |
| 1624 | |
| 1625 va_start(ap, fr); | |
| 1626 bosconn = va_arg(ap, aim_conn_t *); | |
| 1627 cookie = va_arg(ap, char *); | |
| 1628 va_end(ap); | |
| 1629 | |
| 1630 if ((oft = find_oft_by_cookie(gc, cookie))) { | |
| 3630 | 1631 aim_canceltransfer(sess, bosconn, oft->cookie, |
| 1632 oft->sn, AIM_CAPS_SENDFILE); | |
| 1633 | |
| 1634 transfer_abort(oft->xfer, _("Transfer timed out")); | |
| 1635 oscar_file_transfer_disconnect(sess, oft->conn); | |
| 1636 } | |
| 3752 | 1637 |
| 1638 return 1; /* success */ | |
| 3630 | 1639 } |
| 1640 | |
| 1641 /* Called once at the beginning of an outgoing transfer session. */ | |
| 3771 | 1642 static void oscar_file_transfer_out(struct gaim_connection *gc, |
| 3630 | 1643 struct file_transfer *xfer, const char *name, int totfiles, |
| 1644 int totsize) { | |
| 1645 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 1646 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 1647 | |
| 1648 oft->xfer = xfer; | |
| 1649 oft->totsize = totsize; | |
| 1650 oft->totfiles = totfiles; | |
| 1651 oft->filesdone = 0; | |
| 1652 | |
| 1653 oft->conn = aim_sendfile_initiate(od->sess, oft->sn, | |
| 1654 name, totfiles, oft->totsize, oft->cookie); | |
| 1655 if (!oft->conn) { | |
| 1656 do_error_dialog(_("Couldn't open listener to send file"), | |
| 1657 _("File transfer aborted"), | |
| 1658 GAIM_ERROR); | |
| 1659 return; | |
| 1660 } | |
| 3752 | 1661 |
| 3630 | 1662 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, |
| 3771 | 1663 AIM_CB_OFT_SENDFILEINITIATE, |
| 3630 | 1664 oscar_sendfile_accepted, |
| 1665 0); | |
| 1666 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
| 1667 oscar_callback, oft->conn); | |
| 1668 } | |
| 1669 | |
| 3952 | 1670 /* |
| 1671 * This is called after a chunk of data has been sent out or received; it is used | |
| 1672 * to update the checksum. | |
| 1673 */ | |
| 3771 | 1674 static void oscar_file_transfer_data_chunk(struct gaim_connection *gc, |
| 3630 | 1675 struct file_transfer *xfer, const char *buf, int len) |
| 1676 { | |
| 1677 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 1678 aim_session_t *sess = aim_conn_getsess(oft->conn); | |
| 1679 | |
| 1680 if (oft->type == OFT_SENDFILE_IN) | |
| 1681 aim_update_checksum(sess, oft->conn, buf, len); | |
| 1682 } | |
| 1683 | |
| 3952 | 1684 /* Called once at the beginning of an incoming transfer session. */ |
| 3771 | 1685 static void oscar_file_transfer_in(struct gaim_connection *gc, |
| 3630 | 1686 struct file_transfer *xfer, int offset) { |
| 1687 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 1688 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 1689 | |
| 1690 oft->xfer = xfer; | |
| 1691 oft->conn = aim_accepttransfer(od->sess, od->conn, oft->sn, | |
| 1692 oft->cookie, oft->ip, | |
| 1693 oft->port, | |
| 1694 AIM_CAPS_SENDFILE); | |
| 1695 if (!oft->conn) { | |
| 3952 | 1696 /* XXX implement reverse connections for receiving from behind a firewall */ |
| 3630 | 1697 char *buf = g_strdup_printf("Couldn't connect to remote host"); |
| 1698 do_error_dialog(buf, NULL, GAIM_ERROR); | |
| 1699 g_free(buf); | |
| 1700 return; | |
| 1701 } | |
| 1702 | |
| 1703 aim_conn_addhandler(od->sess, oft->conn, AIM_CB_FAM_OFT, | |
| 3771 | 1704 AIM_CB_OFT_SENDFILEFILEREQ, oscar_file_transfer_do, |
| 3630 | 1705 0); |
| 1706 | |
| 1707 oft->watcher = gaim_input_add(oft->conn->fd, GAIM_INPUT_READ, | |
| 1708 oscar_callback, oft->conn); | |
| 1709 } | |
| 1710 | |
| 3952 | 1711 /* |
| 1712 * This is called when the user began a file transfer, but subsequently canceled. | |
| 1713 */ | |
| 1714 static void oscar_file_transfer_cancel(struct gaim_connection *gc, struct file_transfer *xfer) { | |
| 3630 | 1715 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 1716 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 1717 | |
| 1718 if (oft->type == OFT_SENDFILE_IN) | |
| 1719 aim_denytransfer(od->sess, oft->sn, oft->cookie, | |
| 1720 AIM_TRANSFER_DENY_DECLINE); | |
| 1721 | |
| 1722 od->file_transfers = g_slist_remove(od->file_transfers, oft); | |
| 1723 aim_conn_kill(od->sess, &oft->conn); | |
| 1724 g_free(oft->sn); | |
| 1725 g_free(oft); | |
| 1726 } | |
| 1727 | |
| 4244 | 1728 static void accept_direct_im(struct ask_direct *d) { |
| 2086 | 1729 struct gaim_connection *gc = d->gc; |
| 4244 | 1730 struct oscar_data *od; |
| 2086 | 1731 struct direct_im *dim; |
| 2945 | 1732 char *host; int port = 4443; |
| 4366 | 1733 int i, rc; |
| 2086 | 1734 |
| 4244 | 1735 if (!g_slist_find(connections, gc)) { |
| 1736 cancel_direct_im(d); | |
| 1737 return; | |
| 1738 } | |
| 1739 | |
| 1740 od = (struct oscar_data *)gc->proto_data; | |
| 2086 | 1741 debug_printf("Accepted DirectIM.\n"); |
| 1742 | |
| 1743 dim = find_direct_im(od, d->sn); | |
| 1744 if (dim) { | |
| 3730 | 1745 cancel_direct_im(d); /* 40 */ |
| 4244 | 1746 return; |
| 2086 | 1747 } |
| 1748 dim = g_new0(struct direct_im, 1); | |
| 1749 dim->gc = d->gc; | |
| 1750 g_snprintf(dim->name, sizeof dim->name, "%s", d->sn); | |
| 1751 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1752 dim->conn = aim_directim_connect(od->sess, d->sn, NULL, d->cookie); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1753 if (!dim->conn) { |
| 2086 | 1754 g_free(dim); |
| 3730 | 1755 cancel_direct_im(d); |
| 4244 | 1756 return; |
| 2086 | 1757 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1758 |
| 2086 | 1759 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, |
| 1760 gaim_directim_incoming, 0); | |
| 1761 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
| 1762 gaim_directim_typing, 0); | |
| 3033 | 1763 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
| 2993 | 1764 gaim_update_ui, 0); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1765 for (i = 0; i < (int)strlen(d->ip); i++) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1766 if (d->ip[i] == ':') { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1767 port = atoi(&(d->ip[i+1])); |
| 2086 | 1768 break; |
| 1769 } | |
| 1770 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1771 host = g_strndup(d->ip, i); |
| 2086 | 1772 dim->conn->status |= AIM_CONN_STATUS_INPROGRESS; |
| 4366 | 1773 rc = proxy_connect(host, port, oscar_directim_callback, dim); |
| 2086 | 1774 g_free(host); |
| 4366 | 1775 if (rc < 0) { |
| 2086 | 1776 aim_conn_kill(od->sess, &dim->conn); |
| 1777 g_free(dim); | |
| 3730 | 1778 cancel_direct_im(d); |
| 4244 | 1779 return; |
| 2086 | 1780 } |
| 1781 | |
| 3730 | 1782 cancel_direct_im(d); |
| 2086 | 1783 |
| 4244 | 1784 return; |
| 2086 | 1785 } |
| 1786 | |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1787 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
| 3642 | 1788 char *tmp; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1789 struct gaim_connection *gc = sess->aux_data; |
| 3600 | 1790 struct oscar_data *od = gc->proto_data; |
|
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1791 int flags = 0; |
| 3659 | 1792 int convlen; |
| 1793 GError *err = NULL; | |
|
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1794 |
|
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1795 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
|
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2249
diff
changeset
|
1796 flags |= IM_FLAG_AWAY; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1797 |
| 4380 | 1798 if ((args->icbmflags & AIM_IMFLAGS_HASICON) && (args->iconlen) && (args->iconsum) && (args->iconstamp)) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1799 struct icon_req *ir = NULL; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1800 GSList *h = od->hasicons; |
| 4121 | 1801 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1802 debug_printf("%s has an icon\n", userinfo->sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1803 while (h) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1804 ir = h->data; |
| 4269 | 1805 if (!aim_sncmp(userinfo->sn, ir->user)) |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1806 break; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1807 h = h->next; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1808 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1809 if (!h) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1810 ir = g_new0(struct icon_req, 1); |
| 4269 | 1811 ir->user = g_strdup(normalize(userinfo->sn)); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1812 od->hasicons = g_slist_append(od->hasicons, ir); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1813 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1814 if ((args->iconlen != ir->length) || |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1815 (args->iconsum != ir->checksum) || |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1816 (args->iconstamp != ir->timestamp)) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1817 ir->request = TRUE; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1818 ir->length = args->iconlen; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1819 ir->checksum = args->iconsum; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1820 ir->timestamp = args->iconstamp; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1821 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1822 |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1823 if (gc->user->iconfile[0] && (args->icbmflags & AIM_IMFLAGS_BUDDYREQ)) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1824 FILE *file; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1825 struct stat st; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1826 |
|
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1827 if (!stat(gc->user->iconfile, &st)) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1828 char *buf = g_malloc(st.st_size); |
|
2248
cef6d4e81aec
[gaim-migrate @ 2258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2246
diff
changeset
|
1829 file = fopen(gc->user->iconfile, "r"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1830 if (file) { |
|
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1831 int len = fread(buf, 1, st.st_size, file); |
| 4194 | 1832 debug_printf("Sending buddy icon to %s (%d bytes, %lu reported)\n", |
|
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1833 userinfo->sn, len, st.st_size); |
|
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
1834 aim_send_icon(sess, userinfo->sn, buf, st.st_size, |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1835 st.st_mtime, aim_iconsum(buf, st.st_size)); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1836 fclose(file); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1837 } else |
|
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1838 debug_printf("Can't open buddy icon file!\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1839 g_free(buf); |
|
2336
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1840 } else |
|
c6c5eaf69188
[gaim-migrate @ 2349]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2315
diff
changeset
|
1841 debug_printf("Can't stat buddy icon file!\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1842 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1843 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1844 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { |
| 3722 | 1845 /* This message is marked as UNICODE, so we have to |
| 1846 * convert it to utf-8 before handing it to the gaim core. | |
| 1847 * This conversion should *never* fail, if it does it | |
| 1848 * means that either the incoming ICBM is corrupted or | |
| 1849 * there is something we don't understand about it. */ | |
| 1850 /* For the record, AIM Unicode is big-endian UCS-2 */ | |
| 4121 | 1851 |
| 1852 if (!args->msg || !args->msglen) | |
| 1853 return 1; | |
| 1854 | |
| 3659 | 1855 tmp = g_convert(args->msg, args->msglen, "UTF-8", "UCS-2BE", NULL, &convlen, &err); |
| 1856 if (err) { | |
| 1857 debug_printf("Unicode IM conversion: %s\n", err->message); | |
| 1858 tmp = strdup(_("(There was an error receiving this message)")); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1859 } |
| 3722 | 1860 } else { |
| 3850 | 1861 /* This will get executed for both AIM_IMFLAGS_ISO_8859_1 and |
| 3722 | 1862 * unflagged messages, which are ASCII. That's OK because |
| 1863 * ASCII is a strict subset of ISO-8859-1; this should | |
| 1864 * help with compatibility with old, broken versions of | |
| 1865 * gaim (everything before 0.60) and other broken clients | |
| 1866 * that will happily send ISO-8859-1 without marking it as | |
| 1867 * such */ | |
| 3850 | 1868 if (args->icbmflags & AIM_IMFLAGS_ISO_8859_1) { |
| 4194 | 1869 debug_printf("Received ISO-8859-1 IM\n"); |
| 3850 | 1870 } |
| 4121 | 1871 |
| 1872 if (!args->msg || !args->msglen) | |
| 1873 return 1; | |
| 1874 | |
| 3659 | 1875 tmp = g_convert(args->msg, args->msglen, "UTF-8", "ISO-8859-1", NULL, &convlen, &err); |
| 1876 if (err) { | |
| 1877 debug_printf("ISO-8859-1 IM conversion: %s\n", err->message); | |
| 1878 tmp = strdup(_("(There was an error receiving this message)")); | |
| 1879 } | |
| 3642 | 1880 } |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1881 |
| 3850 | 1882 if (args->icbmflags & AIM_IMFLAGS_CUSTOMCHARSET) { |
| 4194 | 1883 debug_printf("Custom character set: %hu %hu\n", args->charset, args->charsubset); |
| 3850 | 1884 } |
| 1885 | |
| 3595 | 1886 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) { |
| 3600 | 1887 char *who = normalize(userinfo->sn); |
| 1888 if (!g_hash_table_lookup(od->supports_tn, who)) | |
| 1889 g_hash_table_insert(od->supports_tn, who, who); | |
| 3595 | 1890 } |
| 1891 | |
| 4333 | 1892 /* strip_linefeed(tmp); */ |
|
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2833
diff
changeset
|
1893 serv_got_im(gc, userinfo->sn, tmp, flags, time(NULL), -1); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1894 g_free(tmp); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1895 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1896 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1897 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1898 |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
1899 static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1900 struct gaim_connection *gc = sess->aux_data; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1901 |
| 4121 | 1902 if (!args) |
| 1903 return 0; | |
| 4194 | 1904 |
| 1905 debug_printf("rendezvous status %hu (%s)\n", args->status, userinfo->sn); | |
| 1906 | |
| 3630 | 1907 if (args->status == AIM_RENDEZVOUS_CANCEL) { |
| 1908 struct oscar_file_transfer *oft; | |
| 4121 | 1909 if (!args->cookie) |
| 1910 return 1; | |
| 3630 | 1911 oft = find_oft_by_cookie(gc, args->cookie); |
| 1912 if (oft) { | |
| 1913 transfer_abort(oft->xfer, _("Buddy canceled transfer")); | |
| 1914 oscar_file_transfer_disconnect(sess, oft->conn); | |
| 1915 } | |
| 1916 return 0; | |
| 1917 } | |
| 1918 else if (args->status == AIM_RENDEZVOUS_ACCEPT) { | |
| 1919 /* The user accepted our transfer request, but we don't | |
| 1920 * really need to do anything yet. | |
| 1921 * -- wtm | |
| 1922 */ | |
| 1923 return 0; | |
| 1924 } | |
| 1925 else if (args->status != AIM_RENDEZVOUS_PROPOSE) { | |
| 3752 | 1926 debug_printf("unknown rendezvous status\n"); |
| 2869 | 1927 return 1; |
| 3630 | 1928 } |
| 2869 | 1929 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1930 if (args->reqclass & AIM_CAPS_CHAT) { |
| 4121 | 1931 char *name; |
| 4120 | 1932 int *exch; |
| 4121 | 1933 GList *m = NULL; |
| 4120 | 1934 |
| 4121 | 1935 if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange || !args->msg) |
| 1936 return 1; | |
| 1937 name = extract_name(args->info.chat.roominfo.name); | |
| 4120 | 1938 exch = g_new0(int, 1); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1939 m = g_list_append(m, g_strdup(name ? name : args->info.chat.roominfo.name)); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1940 *exch = args->info.chat.roominfo.exchange; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1941 m = g_list_append(m, exch); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1942 serv_got_chat_invite(gc, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1943 name ? name : args->info.chat.roominfo.name, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1944 userinfo->sn, |
| 2869 | 1945 (char *)args->msg, |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1946 m); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1947 if (name) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1948 g_free(name); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
1949 } else if (args->reqclass & AIM_CAPS_SENDFILE) { |
| 3630 | 1950 struct oscar_file_transfer *oft; |
| 3752 | 1951 struct oscar_data *od = gc->proto_data; |
| 4358 | 1952 char *tmp; |
| 3752 | 1953 |
| 4121 | 1954 if (!args->cookie || !args->verifiedip || !args->port || |
| 1955 !args->info.sendfile.filename || !args->info.sendfile.totsize || | |
| 4342 | 1956 !args->info.sendfile.totfiles || !args->reqclass) |
| 4121 | 1957 return 1; |
| 3752 | 1958 if ((oft = find_oft_by_cookie(sess->aux_data, args->cookie))) |
| 1959 { | |
| 1960 /* This is a request for a reverse connection, | |
| 1961 * which is used by newer clients when for some | |
| 1962 * reason they are unable to connect to our listener | |
| 1963 * (e.g. they are behind a firewall). | |
| 1964 */ | |
| 1965 if (oft->type != OFT_SENDFILE_OUT) | |
| 1966 return -1; | |
| 1967 | |
| 1968 /* It seems that Trillian sends some weird | |
| 1969 * packets. Sanity check. | |
| 1970 */ | |
| 1971 if (!args->verifiedip) | |
| 1972 return -1; | |
| 1973 | |
| 1974 /* This connection isn't used for anything, since | |
| 1975 * we're using a reverse connection instead. | |
| 3630 | 1976 */ |
| 3752 | 1977 gaim_input_remove(oft->watcher); |
| 1978 aim_conn_kill(sess, &oft->conn); | |
| 1979 | |
| 4194 | 1980 debug_printf("sendfile: doing reverse connection to %s:%hu\n", args->verifiedip, args->port); |
| 3752 | 1981 |
| 1982 oft->conn = aim_accepttransfer(sess, od->conn, | |
| 1983 userinfo->sn, | |
| 1984 args->cookie, args->verifiedip, | |
| 1985 args->port, | |
| 1986 AIM_CAPS_SENDFILE); | |
| 1987 | |
| 1988 /* XXX: this is a bit of a hack: ideally | |
| 1989 * we should wait on GAIM_INPUT_WRITE. -- wtm | |
| 1990 */ | |
| 1991 aim_conn_completeconnect(sess, oft->conn); | |
| 1992 | |
| 1993 oscar_sendfile_request(sess, oft); | |
| 1994 | |
| 1995 aim_conn_addhandler(sess, oft->conn, | |
| 1996 AIM_CB_FAM_OFT, | |
| 3771 | 1997 AIM_CB_OFT_SENDFILECOMPLETE, |
| 3752 | 1998 oscar_sendfile_out_done, |
| 1999 0); | |
| 2000 aim_conn_addhandler(sess, oft->conn, | |
| 2001 AIM_CB_FAM_OFT, | |
| 3771 | 2002 AIM_CB_OFT_SENDFILEFILESEND, |
| 3752 | 2003 oscar_file_transfer_do, |
| 2004 0); | |
| 2005 oft->watcher = gaim_input_add(oft->conn->fd, | |
| 2006 GAIM_INPUT_READ, oscar_callback, | |
| 2007 oft->conn); | |
| 2008 return 0; | |
| 3630 | 2009 } |
| 2010 | |
| 3952 | 2011 /* Someone wants to send a file (or files) to us */ |
| 3630 | 2012 debug_printf("%s (%s) requests to send a file to %s\n", |
| 2013 userinfo->sn, args->verifiedip, gc->username); | |
| 3752 | 2014 |
| 2015 oft = g_new0(struct oscar_file_transfer, 1); | |
| 3630 | 2016 |
| 2017 oft->type = OFT_SENDFILE_IN; | |
| 2018 oft->sn = g_strdup(userinfo->sn); | |
| 2019 strncpy(oft->ip, args->verifiedip, sizeof(oft->ip)); | |
| 2020 oft->port = args->port; | |
| 2021 memcpy(oft->cookie, args->cookie, 8); | |
| 2022 | |
| 3752 | 2023 od->file_transfers = g_slist_append(od->file_transfers, oft); |
| 3630 | 2024 |
| 4358 | 2025 /* last char of the ft req is a star, they are sending us a |
| 2026 * directory -- remove the star and trailing slash so we dont save | |
| 2027 * directories that look like 'dirname\*' -- arl */ | |
| 2028 tmp = strrchr(args->info.sendfile.filename, '\\'); | |
| 2029 if (tmp && (tmp[1] == '*')) { | |
| 2030 tmp[0] = '\0'; | |
| 4355 | 2031 } |
| 2032 | |
| 3630 | 2033 oft->xfer = transfer_in_add(gc, userinfo->sn, |
| 2034 args->info.sendfile.filename, | |
| 2035 args->info.sendfile.totsize, | |
| 2036 args->info.sendfile.totfiles, | |
| 2037 args->msg); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2038 } else if (args->reqclass & AIM_CAPS_GETFILE) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2039 } else if (args->reqclass & AIM_CAPS_VOICE) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2040 } else if (args->reqclass & AIM_CAPS_BUDDYICON) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2041 set_icon_data(gc, normalize(userinfo->sn), args->info.icon.icon, |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2042 args->info.icon.length); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2043 } else if (args->reqclass & AIM_CAPS_IMIMAGE) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2044 struct ask_direct *d = g_new0(struct ask_direct, 1); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2045 char buf[256]; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2046 |
| 4212 | 2047 if (!args->verifiedip) { |
| 2048 debug_printf("directim kill blocked (%s)\n", userinfo->sn); | |
| 2049 return 1; | |
| 2050 } | |
| 2051 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2052 debug_printf("%s received direct im request from %s (%s)\n", |
| 2869 | 2053 gc->username, userinfo->sn, args->verifiedip); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2054 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2055 d->gc = gc; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2056 d->sn = g_strdup(userinfo->sn); |
| 2869 | 2057 strncpy(d->ip, args->verifiedip, sizeof(d->ip)); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2058 memcpy(d->cookie, args->cookie, 8); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2059 g_snprintf(buf, sizeof buf, "%s has just asked to directly connect to %s.", |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2060 userinfo->sn, gc->username); |
| 4249 | 2061 do_ask_dialog(buf, _("This requires a direct connection between the two computers and is necessary for IM Images. Because your IP address will be revealed, this may be considered a privacy risk."), d, _("Connect"), accept_direct_im, _("Cancel"), cancel_direct_im, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2062 } else { |
| 4194 | 2063 debug_printf("Unknown reqclass %hu\n", args->reqclass); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2064 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2065 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2066 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2067 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2068 |
| 3453 | 2069 /* |
| 4230 | 2070 * Authorization Functions |
| 2071 * Most of these are callbacks from dialogs. They're used by both | |
| 2072 * methods of authorization (SSI and old-school channel 4 ICBM) | |
| 3453 | 2073 */ |
| 4269 | 2074 /* When you ask other people for authorization */ |
| 4337 | 2075 static void gaim_auth_request(struct name_data *data, char *msg) { |
| 4230 | 2076 struct gaim_connection *gc = data->gc; |
| 4244 | 2077 |
| 2078 if (g_slist_find(connections, gc)) { | |
| 2079 struct oscar_data *od = gc->proto_data; | |
| 4349 | 2080 struct buddy *buddy = find_buddy(gc->user, data->name); |
| 2081 struct group *group = find_group_by_buddy(buddy); | |
| 4244 | 2082 if (buddy && group) { |
| 2083 debug_printf("ssi: adding buddy %s to group %s\n", buddy->name, group->name); | |
| 4337 | 2084 aim_ssi_sendauthrequest(od->sess, od->conn, data->name, msg ? msg : _("Please authorize me so I can add you to my buddy list.")); |
| 4269 | 2085 if (!aim_ssi_itemlist_finditem(od->sess->ssi.local, group->name, buddy->name, AIM_SSI_TYPE_BUDDY)) |
| 2086 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 1); | |
| 4244 | 2087 } |
| 4230 | 2088 } |
| 4337 | 2089 } |
| 2090 | |
| 2091 static void gaim_auth_request_msgprompt(struct name_data *data) { | |
| 2092 do_prompt_dialog(_("Authorization Request Message:"), _("Please authorize me!"), data, gaim_auth_request, gaim_free_name_data); | |
| 4230 | 2093 } |
| 2094 | |
| 2095 static void gaim_auth_dontrequest(struct name_data *data) { | |
| 4244 | 2096 struct gaim_connection *gc = data->gc; |
| 2097 | |
| 2098 if (g_slist_find(connections, gc)) { | |
| 2099 /* struct oscar_data *od = gc->proto_data; */ | |
| 2100 /* XXX - Take the buddy out of our buddy list */ | |
| 2101 } | |
| 2102 | |
| 4230 | 2103 gaim_free_name_data(data); |
| 2104 } | |
| 2105 | |
| 4269 | 2106 static void gaim_auth_sendrequest(struct gaim_connection *gc, char *name) { |
| 2107 struct name_data *data = g_new(struct name_data, 1); | |
| 2108 struct buddy *buddy; | |
| 2109 gchar *dialog_msg, *nombre; | |
| 2110 | |
| 4349 | 2111 buddy = find_buddy(gc->user, name); |
| 4269 | 2112 if (buddy && (get_buddy_alias_only(buddy))) |
| 2113 nombre = g_strdup_printf("%s (%s)", name, get_buddy_alias_only(buddy)); | |
| 2114 else | |
| 2115 nombre = g_strdup(name); | |
| 2116 | |
| 2117 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); | |
| 2118 data->gc = gc; | |
| 2119 data->name = g_strdup(name); | |
| 2120 data->nick = NULL; | |
| 4337 | 2121 do_ask_dialog(_("Request Authorization"), dialog_msg, data, _("Request Authorization"), gaim_auth_request_msgprompt, _("Cancel"), gaim_auth_dontrequest, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 4269 | 2122 |
| 2123 g_free(dialog_msg); | |
| 2124 g_free(nombre); | |
| 2125 } | |
| 2126 | |
| 4230 | 2127 /* When other people ask you for authorization */ |
| 2128 static void gaim_auth_grant(struct name_data *data) { | |
| 2129 struct gaim_connection *gc = data->gc; | |
| 4244 | 2130 |
| 2131 if (g_slist_find(connections, gc)) { | |
| 2132 struct oscar_data *od = gc->proto_data; | |
| 4236 | 2133 #ifdef NOSSI |
| 4244 | 2134 struct buddy *buddy; |
| 2135 gchar message; | |
| 2136 message = 0; | |
| 4349 | 2137 buddy = find_buddy(gc->user, data->name); |
| 4244 | 2138 aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHGRANTED, &message); |
| 2139 show_got_added(gc, NULL, data->name, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL); | |
| 4230 | 2140 #else |
| 4244 | 2141 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x01, NULL); |
| 4230 | 2142 #endif |
| 4244 | 2143 } |
| 2144 | |
| 4230 | 2145 gaim_free_name_data(data); |
| 3141 | 2146 } |
| 2147 | |
| 4230 | 2148 /* When other people ask you for authorization */ |
| 4337 | 2149 static void gaim_auth_dontgrant(struct name_data *data, char *msg) { |
| 4230 | 2150 struct gaim_connection *gc = data->gc; |
| 4244 | 2151 |
| 2152 if (g_slist_find(connections, gc)) { | |
| 2153 struct oscar_data *od = gc->proto_data; | |
| 4230 | 2154 #ifdef NOSSI |
| 4337 | 2155 aim_send_im_ch4(od->sess, data->name, AIM_ICQMSG_AUTHDENIED, msg ? msg : _("No reason given.")); |
| 4230 | 2156 #else |
| 4337 | 2157 aim_ssi_sendauthreply(od->sess, od->conn, data->name, 0x00, msg ? msg : _("No reason given.")); |
| 4230 | 2158 #endif |
| 4244 | 2159 } |
| 4337 | 2160 } |
| 2161 | |
| 2162 static void gaim_auth_dontgrant_msgprompt(struct name_data *data) { | |
| 2163 do_prompt_dialog(_("Authorization Denied Message:"), _("No reason given."), data, gaim_auth_dontgrant, gaim_free_name_data); | |
| 3141 | 2164 } |
| 2165 | |
| 4230 | 2166 /* When someone sends you contacts */ |
| 2167 static void gaim_icq_contactadd(struct name_data *data) { | |
| 2168 struct gaim_connection *gc = data->gc; | |
| 4244 | 2169 |
| 2170 if (g_slist_find(connections, gc)) { | |
| 2171 show_add_buddy(gc, data->name, NULL, data->nick); | |
| 2172 } | |
| 2173 | |
| 4230 | 2174 gaim_free_name_data(data); |
| 3453 | 2175 } |
| 2176 | |
| 4075 | 2177 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) { |
| 3141 | 2178 struct gaim_connection *gc = sess->aux_data; |
| 4076 | 2179 gchar **msg1, **msg2; |
| 2180 GError *err = NULL; | |
| 2181 int i; | |
| 2182 | |
| 4121 | 2183 if (!args->type || !args->msg || !args->uin) |
| 2184 return 1; | |
| 4194 | 2185 |
| 2186 debug_printf("Received a channel 4 message of type 0x%02hhx.\n", args->type); | |
| 4076 | 2187 |
| 2188 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ | |
| 4173 | 2189 msg1 = g_strsplit(args->msg, "\376", 0); |
| 4194 | 2190 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* XXX - 10 is a guess */ |
| 4076 | 2191 for (i=0; msg1[i]; i++) { |
| 2192 strip_linefeed(msg1[i]); | |
| 2193 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); | |
| 2194 if (err) | |
| 2195 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n"); | |
| 2196 } | |
| 2197 msg2[i] = NULL; | |
| 2198 | |
| 3952 | 2199 switch (args->type) { |
| 4173 | 2200 case 0x01: { /* MacICQ message or basic offline message */ |
| 4076 | 2201 if (i >= 1) { |
| 2202 gchar *uin = g_strdup_printf("%lu", args->uin); | |
| 2203 if (t) { /* This is an offline message */ | |
| 2204 /* I think this timestamp is in UTC, or something */ | |
| 2205 serv_got_im(gc, uin, msg2[0], 0, t, -1); | |
| 2206 } else { /* This is a message from MacICQ/Miranda */ | |
| 2207 serv_got_im(gc, uin, msg2[0], 0, time(NULL), -1); | |
| 2208 } | |
| 2209 g_free(uin); | |
| 4075 | 2210 } |
| 3316 | 2211 } break; |
| 2212 | |
| 4173 | 2213 case 0x04: { /* Someone sent you a URL */ |
| 4076 | 2214 if (i >= 2) { |
| 2215 gchar *uin = g_strdup_printf("%lu", args->uin); | |
| 2216 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); | |
| 3453 | 2217 serv_got_im(gc, uin, message, 0, time(NULL), -1); |
| 2218 g_free(uin); | |
| 2219 g_free(message); | |
| 2220 } | |
| 2221 } break; | |
| 2222 | |
| 4173 | 2223 case 0x06: { /* Someone requested authorization */ |
| 4076 | 2224 if (i >= 6) { |
| 4230 | 2225 struct name_data *data = g_new(struct name_data, 1); |
| 4337 | 2226 gchar *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason:\n%s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); |
| 4076 | 2227 debug_printf("Received an authorization request from UIN %lu\n", args->uin); |
| 2228 data->gc = gc; | |
| 4230 | 2229 data->name = g_strdup_printf("%lu", args->uin); |
| 2230 data->nick = NULL; | |
| 4337 | 2231 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 4076 | 2232 g_free(dialog_msg); |
| 2233 } | |
| 3141 | 2234 } break; |
| 2235 | |
| 4173 | 2236 case 0x07: { /* Someone has denied you authorization */ |
| 4076 | 2237 if (i >= 1) { |
| 4194 | 2238 gchar *dialog_msg = g_strdup_printf(_("The user %lu has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given.")); |
| 4230 | 2239 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_INFO); |
| 4076 | 2240 g_free(dialog_msg); |
| 2241 } | |
| 3141 | 2242 } break; |
| 2243 | |
| 4173 | 2244 case 0x08: { /* Someone has granted you authorization */ |
| 4194 | 2245 gchar *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); |
| 3427 | 2246 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); |
| 3141 | 2247 g_free(dialog_msg); |
| 2248 } break; | |
| 2249 | |
| 4333 | 2250 case 0x09: { /* Message from the Godly ICQ server itself, I think */ |
| 2251 if (i >= 5) { | |
| 2252 gchar *dialog_msg = g_strdup_printf(_("You have received a special message\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); | |
| 2253 do_error_dialog("ICQ Server Message", dialog_msg, GAIM_INFO); | |
| 2254 g_free(dialog_msg); | |
| 2255 } | |
| 2256 } break; | |
| 2257 | |
| 4173 | 2258 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ |
| 4076 | 2259 if (i >= 6) { |
| 4194 | 2260 gchar *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); |
| 4076 | 2261 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO); |
| 2262 g_free(dialog_msg); | |
| 2263 } | |
| 4075 | 2264 } break; |
| 2265 | |
| 4173 | 2266 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */ |
| 4076 | 2267 if (i >= 6) { |
| 4308 | 2268 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]); |
| 4076 | 2269 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO); |
| 2270 g_free(dialog_msg); | |
| 2271 } | |
| 4075 | 2272 } break; |
| 2273 | |
| 4173 | 2274 case 0x12: { |
| 3141 | 2275 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ |
| 4173 | 2276 /* Someone added you to their contact list? */ |
| 3141 | 2277 } break; |
| 2278 | |
| 4173 | 2279 case 0x13: { /* Someone has sent you some ICQ contacts */ |
| 3453 | 2280 int i, num; |
| 2281 gchar **text; | |
| 4173 | 2282 text = g_strsplit(args->msg, "\376", 0); |
| 3453 | 2283 if (text) { |
| 2284 num = 0; | |
| 2285 for (i=0; i<strlen(text[0]); i++) | |
| 2286 num = num*10 + text[0][i]-48; | |
| 2287 for (i=0; i<num; i++) { | |
| 4230 | 2288 struct name_data *data = g_new(struct name_data, 1); |
| 3730 | 2289 gchar *message = g_strdup_printf(_("ICQ user %lu has sent you a contact: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); |
| 3453 | 2290 data->gc = gc; |
| 4230 | 2291 data->name = g_strdup(text[i*2+2]); |
| 3453 | 2292 data->nick = g_strdup(text[i*2+1]); |
| 4249 | 2293 do_ask_dialog(message, _("Do you want to add this contact to your Buddy List?"), data, _("Add"), gaim_icq_contactadd, _("Decline"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 3453 | 2294 g_free(message); |
| 2295 } | |
| 2296 g_strfreev(text); | |
| 2297 } | |
| 2298 } break; | |
| 2299 | |
| 4173 | 2300 case 0x1a: { /* Someone has sent you a greeting card or requested contacts? */ |
| 3453 | 2301 /* This is boring and silly. */ |
| 2302 } break; | |
| 2303 | |
| 3141 | 2304 default: { |
| 4194 | 2305 debug_printf("Received a channel 4 message of unknown type (type 0x%02hhx).\n", args->type); |
| 3141 | 2306 } break; |
| 2307 } | |
| 2308 | |
| 4076 | 2309 g_strfreev(msg1); |
| 2310 g_strfreev(msg2); | |
| 2311 | |
| 3141 | 2312 return 1; |
| 2313 } | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2314 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2315 static int gaim_parse_incoming_im(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4200 | 2316 fu16_t channel; |
| 2317 int ret = 0; | |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2318 aim_userinfo_t *userinfo; |
| 2086 | 2319 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2320 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2321 va_start(ap, fr); |
| 4200 | 2322 channel = (fu16_t)va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2323 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 2324 |
| 3141 | 2325 switch (channel) { |
| 2326 case 1: { /* standard message */ | |
| 2327 struct aim_incomingim_ch1_args *args; | |
| 2328 args = va_arg(ap, struct aim_incomingim_ch1_args *); | |
| 2329 ret = incomingim_chan1(sess, fr->conn, userinfo, args); | |
| 2330 } break; | |
| 2331 | |
| 2332 case 2: { /* rendevous */ | |
| 2333 struct aim_incomingim_ch2_args *args; | |
| 2334 args = va_arg(ap, struct aim_incomingim_ch2_args *); | |
| 2335 ret = incomingim_chan2(sess, fr->conn, userinfo, args); | |
| 2336 } break; | |
| 2337 | |
| 2338 case 4: { /* ICQ */ | |
| 2339 struct aim_incomingim_ch4_args *args; | |
| 2340 args = va_arg(ap, struct aim_incomingim_ch4_args *); | |
| 4075 | 2341 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0); |
| 3141 | 2342 } break; |
| 2343 | |
| 2344 default: { | |
| 4194 | 2345 debug_printf("ICBM received on unsupported channel (channel 0x%04hx).", channel); |
| 3141 | 2346 } break; |
| 2086 | 2347 } |
| 2348 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2349 va_end(ap); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2350 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2351 return ret; |
| 2086 | 2352 } |
| 2353 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2354 static int gaim_parse_misses(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2355 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2356 fu16_t chan, nummissed, reason; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2357 aim_userinfo_t *userinfo; |
| 2086 | 2358 char buf[1024]; |
| 2359 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2360 va_start(ap, fr); |
| 4200 | 2361 chan = (fu16_t)va_arg(ap, unsigned int); |
| 2362 userinfo = va_arg(ap, aim_userinfo_t *); | |
| 2363 nummissed = (fu16_t)va_arg(ap, unsigned int); | |
| 2364 reason = (fu16_t)va_arg(ap, unsigned int); | |
| 2086 | 2365 va_end(ap); |
| 2366 | |
| 2367 switch(reason) { | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2368 case 0: |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2369 /* Invalid (0) */ |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2370 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2371 sizeof(buf), |
| 4276 | 2372 ngettext( |
| 2373 "You missed %hu message from %s because it was invalid.", | |
| 2374 "You missed %hu messages from %s because they were invalid.", | |
| 2375 nummissed), | |
| 4282 | 2376 nummissed, |
| 2377 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2378 break; |
| 2086 | 2379 case 1: |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2380 /* Message too large */ |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2381 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2382 sizeof(buf), |
| 4276 | 2383 ngettext( |
| 2384 "You missed %hu message from %s because it was too large.", | |
| 2385 "You missed %hu messages from %s because they were too large.", | |
| 2386 nummissed), | |
| 4282 | 2387 nummissed, |
| 2388 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2389 break; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2390 case 2: |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2391 /* Rate exceeded */ |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2392 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2393 sizeof(buf), |
| 4276 | 2394 ngettext( |
| 2395 "You missed %hu message from %s because the rate limit has been exceeded.", | |
| 2396 "You missed %hu messages from %s because the rate limit has been exceeded.", | |
| 2397 nummissed), | |
| 4282 | 2398 nummissed, |
| 2399 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2400 break; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2401 case 3: |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2402 /* Evil Sender */ |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2403 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2404 sizeof(buf), |
| 4276 | 2405 ngettext( |
| 2406 "You missed %hu message from %s because he/she was too evil.", | |
| 2407 "You missed %hu messages from %s because he/she was too evil.", | |
| 2408 nummissed), | |
| 4282 | 2409 nummissed, |
| 2410 userinfo->sn); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2411 break; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2412 case 4: |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2413 /* Evil Receiver */ |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2414 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2415 sizeof(buf), |
| 4276 | 2416 ngettext( |
| 2417 "You missed %hu message from %s because you are too evil.", | |
| 2418 "You missed %hu messages from %s because you are too evil.", | |
| 2419 nummissed), | |
| 4282 | 2420 nummissed, |
| 2421 userinfo->sn); | |
| 2086 | 2422 break; |
| 2423 default: | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2424 g_snprintf(buf, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2425 sizeof(buf), |
| 4276 | 2426 ngettext( |
| 2427 "You missed %hu message from %s for an unknown reason.", | |
| 2428 "You missed %hu messages from %s for an unknown reason.", | |
| 2429 nummissed), | |
| 4282 | 2430 nummissed, |
| 2431 userinfo->sn); | |
| 2086 | 2432 break; |
| 2433 } | |
| 3427 | 2434 do_error_dialog(buf, NULL, GAIM_ERROR); |
| 2086 | 2435 |
| 2436 return 1; | |
| 2437 } | |
| 2438 | |
| 3212 | 2439 static char *gaim_icq_status(int state) { |
| 2440 /* Make a cute little string that shows the status of the dude or dudet */ | |
| 2441 if (state & AIM_ICQ_STATE_CHAT) | |
| 4342 | 2442 return g_strdup_printf(_("Free For Chat")); |
| 3212 | 2443 else if (state & AIM_ICQ_STATE_DND) |
| 4342 | 2444 return g_strdup_printf(_("Do Not Disturb")); |
| 3212 | 2445 else if (state & AIM_ICQ_STATE_OUT) |
| 4342 | 2446 return g_strdup_printf(_("Not Available")); |
| 3212 | 2447 else if (state & AIM_ICQ_STATE_BUSY) |
| 4342 | 2448 return g_strdup_printf(_("Occupied")); |
| 3212 | 2449 else if (state & AIM_ICQ_STATE_AWAY) |
| 4342 | 2450 return g_strdup_printf(_("Away")); |
| 3212 | 2451 else if (state & AIM_ICQ_STATE_WEBAWARE) |
| 4342 | 2452 return g_strdup_printf(_("Web Aware")); |
| 3212 | 2453 else if (state & AIM_ICQ_STATE_INVISIBLE) |
| 4342 | 2454 return g_strdup_printf(_("Invisible")); |
| 3212 | 2455 else |
| 4342 | 2456 return g_strdup_printf(_("Online")); |
| 3212 | 2457 } |
| 2458 | |
| 4194 | 2459 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
| 3630 | 2460 struct gaim_connection *gc = sess->aux_data; |
| 2461 | |
| 2462 switch (reason) { | |
| 4151 | 2463 case 3: { /* Decline sendfile. */ |
| 2464 struct oscar_file_transfer *oft = find_oft_by_cookie(gc, cookie); | |
| 3630 | 2465 |
| 2466 if (oft) { | |
| 4151 | 2467 char *buf = g_strdup_printf(_("%s has declined to receive a file from %s.\n"), |
| 3630 | 2468 who, gc->username); |
| 2469 transfer_abort(oft->xfer, buf); | |
| 2470 g_free(buf); | |
| 2471 oscar_file_transfer_disconnect(sess, oft->conn); | |
| 2472 } | |
| 4151 | 2473 } break; |
| 2474 | |
| 2475 default: { | |
| 4194 | 2476 debug_printf("Received an unknown rendezvous client auto-response from %s. Type 0x%04hx\n", who, reason); |
| 4151 | 2477 } |
| 3630 | 2478 |
| 2479 } | |
| 2480 | |
| 2481 return 0; | |
| 2482 } | |
| 2483 | |
| 4194 | 2484 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
| 4151 | 2485 struct gaim_connection *gc = sess->aux_data; |
| 2486 | |
| 2487 switch(reason) { | |
| 2488 case 0x0003: { /* Reply from an ICQ status message request */ | |
| 2489 char *status_msg = gaim_icq_status(state); | |
| 2490 char *dialog_msg, **splitmsg; | |
| 2491 struct oscar_data *od = gc->proto_data; | |
| 2492 GSList *l = od->evilhack; | |
| 2493 gboolean evilhack = FALSE; | |
| 2494 | |
| 2495 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | |
| 2496 splitmsg = g_strsplit(msg, "\r\n", 0); | |
| 2497 | |
| 2498 /* If who is in od->evilhack, then we're just getting the away message, otherwise this | |
| 2499 * will just get appended to the info box (which is already showing). */ | |
| 2500 while (l) { | |
| 2501 char *x = l->data; | |
| 2502 if (!strcmp(x, normalize(who))) { | |
| 2503 evilhack = TRUE; | |
| 2504 g_free(x); | |
| 2505 od->evilhack = g_slist_remove(od->evilhack, x); | |
| 2506 break; | |
| 2507 } | |
| 2508 l = l->next; | |
| 2509 } | |
| 2510 | |
| 2511 if (evilhack) | |
| 4344 | 2512 dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, status_msg, g_strjoinv("<BR>", splitmsg)); |
| 4151 | 2513 else |
| 4344 | 2514 dialog_msg = g_strdup_printf(_("<B>Status:</B> %s<HR>%s"), status_msg, g_strjoinv("<BR>", splitmsg)); |
| 4151 | 2515 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
| 2516 | |
| 2517 g_free(status_msg); | |
| 2518 g_free(dialog_msg); | |
| 2519 g_strfreev(splitmsg); | |
| 2520 } break; | |
| 2521 | |
| 2522 default: { | |
| 4194 | 2523 debug_printf("Received an unknown client auto-response from %s. Type 0x%04hx\n", who, reason); |
| 4151 | 2524 } break; |
| 2525 } /* end of switch */ | |
| 2526 | |
| 2527 return 0; | |
| 2528 } | |
| 2529 | |
| 3212 | 2530 static int gaim_parse_clientauto(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2531 va_list ap; | |
| 2532 fu16_t chan, reason; | |
| 2533 char *who; | |
| 2534 | |
| 2535 va_start(ap, fr); | |
| 4200 | 2536 chan = (fu16_t)va_arg(ap, unsigned int); |
| 3212 | 2537 who = va_arg(ap, char *); |
| 4200 | 2538 reason = (fu16_t)va_arg(ap, unsigned int); |
| 3212 | 2539 |
| 3952 | 2540 if (chan == 0x0002) { /* File transfer declined */ |
| 3630 | 2541 char *cookie = va_arg(ap, char *); |
| 4151 | 2542 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
| 3952 | 2543 } else if (chan == 0x0004) { /* ICQ message */ |
| 4200 | 2544 fu32_t state = 0; |
| 4151 | 2545 char *msg = NULL; |
| 2546 if (reason == 0x0003) { | |
| 4200 | 2547 state = va_arg(ap, fu32_t); |
| 4151 | 2548 msg = va_arg(ap, char *); |
| 2549 } | |
| 2550 return gaim_parse_clientauto_ch4(sess, who, reason, state, msg); | |
| 2551 } | |
| 3952 | 2552 |
| 3212 | 2553 va_end(ap); |
| 2554 | |
| 2555 return 1; | |
| 2556 } | |
| 2557 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2558 static int gaim_parse_genericerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2559 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2560 fu16_t reason; |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2561 char *m; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2562 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2563 va_start(ap, fr); |
| 4199 | 2564 reason = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 2565 va_end(ap); |
| 2566 | |
| 4194 | 2567 debug_printf("snac threw error (reason 0x%04hx: %s)\n", reason, |
| 2086 | 2568 (reason < msgerrreasonlen) ? msgerrreason[reason] : "unknown"); |
| 2569 | |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2570 m = g_strdup_printf(_("SNAC threw error: %s\n"), |
| 4056 | 2571 reason < msgerrreasonlen ? gettext(msgerrreason[reason]) : _("Unknown error")); |
| 3427 | 2572 do_error_dialog(m, NULL, GAIM_ERROR); |
|
2865
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2573 g_free(m); |
|
88dc3623a2ae
[gaim-migrate @ 2878]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2864
diff
changeset
|
2574 |
| 2086 | 2575 return 1; |
| 2576 } | |
| 2577 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2578 static int gaim_parse_msgerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2579 va_list ap; |
| 3752 | 2580 char *data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2581 fu16_t reason; |
| 2086 | 2582 char buf[1024]; |
| 3752 | 2583 struct gaim_connection *gc = sess->aux_data; |
| 2584 struct oscar_file_transfer *oft; | |
| 2585 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2586 va_start(ap, fr); |
| 4199 | 2587 reason = (fu16_t) va_arg(ap, unsigned int); |
| 3752 | 2588 data = va_arg(ap, char *); |
| 2086 | 2589 va_end(ap); |
| 2590 | |
| 3752 | 2591 /* If this was a file transfer request, data is a cookie. */ |
| 2592 if ((oft = find_oft_by_cookie(gc, data))) { | |
| 3630 | 2593 transfer_abort(oft->xfer, |
| 4342 | 2594 (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given.")); |
| 3630 | 2595 |
| 2596 oscar_file_transfer_disconnect(sess, oft->conn); | |
| 2597 return 1; | |
| 2598 } | |
| 2599 | |
| 3752 | 2600 /* Data is assumed to be the destination sn. */ |
| 2601 snprintf(buf, sizeof(buf), _("Your message to %s did not get sent:"), data); | |
| 4342 | 2602 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
| 2086 | 2603 |
| 2604 return 1; | |
| 2605 } | |
| 2606 | |
| 3595 | 2607 static int gaim_parse_mtn(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2608 struct gaim_connection *gc = sess->aux_data; | |
| 2609 va_list ap; | |
| 2610 fu16_t type1, type2; | |
| 2611 char *sn; | |
| 2612 | |
| 2613 va_start(ap, fr); | |
| 4199 | 2614 type1 = (fu16_t) va_arg(ap, unsigned int); |
| 3595 | 2615 sn = va_arg(ap, char *); |
| 4199 | 2616 type2 = (fu16_t) va_arg(ap, unsigned int); |
| 3595 | 2617 va_end(ap); |
| 2618 | |
| 4194 | 2619 debug_printf("Received an mtn from %s. Type1 is 0x%04hx and type2 is 0x%04hx.\n", sn, type1, type2); |
| 3595 | 2620 |
| 2621 switch (type2) { | |
| 2622 case 0x0000: { /* Text has been cleared */ | |
| 2623 serv_got_typing_stopped(gc, sn); | |
| 2624 } break; | |
| 2625 | |
| 2626 case 0x0001: { /* Paused typing */ | |
| 3768 | 2627 serv_got_typing(gc, sn, 0, TYPED); |
| 3595 | 2628 } break; |
| 2629 | |
| 2630 case 0x0002: { /* Typing */ | |
| 3768 | 2631 serv_got_typing(gc, sn, 0, TYPING); |
| 3595 | 2632 } break; |
| 2633 | |
| 2634 default: { | |
| 2635 printf("Received unknown typing notification type.\n"); | |
| 2636 } break; | |
| 2637 } | |
| 2638 | |
| 2639 return 1; | |
| 2640 } | |
| 2641 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2642 static int gaim_parse_locerr(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2643 va_list ap; |
| 2644 char *destn; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2645 fu16_t reason; |
| 2086 | 2646 char buf[1024]; |
| 2647 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2648 va_start(ap, fr); |
| 4199 | 2649 reason = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 2650 destn = va_arg(ap, char *); |
| 2651 va_end(ap); | |
| 2652 | |
| 3574 | 2653 snprintf(buf, sizeof(buf), _("User information for %s unavailable:"), destn); |
| 4342 | 2654 do_error_dialog(buf, (reason < msgerrreasonlen) ? gettext(msgerrreason[reason]) : _("No reason given."), GAIM_ERROR); |
| 2086 | 2655 |
| 2656 return 1; | |
| 2657 } | |
| 2658 | |
| 2659 static char *images(int flags) { | |
| 2660 static char buf[1024]; | |
| 3101 | 2661 g_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s", |
| 2679 | 2662 (flags & AIM_FLAG_ACTIVEBUDDY) ? "<IMG SRC=\"ab_icon.gif\">" : "", |
| 2086 | 2663 (flags & AIM_FLAG_UNCONFIRMED) ? "<IMG SRC=\"dt_icon.gif\">" : "", |
| 2664 (flags & AIM_FLAG_AOL) ? "<IMG SRC=\"aol_icon.gif\">" : "", | |
| 3101 | 2665 (flags & AIM_FLAG_ICQ) ? "<IMG SRC=\"icq_icon.gif\">" : "", |
| 2086 | 2666 (flags & AIM_FLAG_ADMINISTRATOR) ? "<IMG SRC=\"admin_icon.gif\">" : "", |
| 3079 | 2667 (flags & AIM_FLAG_FREE) ? "<IMG SRC=\"free_icon.gif\">" : "", |
| 2668 (flags & AIM_FLAG_WIRELESS) ? "<IMG SRC=\"wireless_icon.gif\">" : ""); | |
| 2086 | 2669 return buf; |
| 2670 } | |
| 2671 | |
| 3101 | 2672 |
| 2920 | 2673 /* XXX This is horribly copied from ../../buddy.c. */ |
| 2674 static char *caps_string(guint caps) | |
| 2675 { | |
| 2676 static char buf[512], *tmp; | |
| 2677 int count = 0, i = 0; | |
| 2678 guint bit = 1; | |
| 2679 while (bit <= 0x10000) { | |
| 2680 if (bit & caps) { | |
| 2681 switch (bit) { | |
| 2682 case 0x1: | |
| 2683 tmp = _("Buddy Icon"); | |
| 2684 break; | |
| 2685 case 0x2: | |
| 2686 tmp = _("Voice"); | |
| 2687 break; | |
| 2688 case 0x4: | |
| 2689 tmp = _("IM Image"); | |
| 2690 break; | |
| 2691 case 0x8: | |
| 2692 tmp = _("Chat"); | |
| 2693 break; | |
| 2694 case 0x10: | |
| 2695 tmp = _("Get File"); | |
| 2696 break; | |
| 2697 case 0x20: | |
| 2698 tmp = _("Send File"); | |
| 2699 break; | |
| 2700 case 0x40: | |
| 2701 case 0x200: | |
| 2702 tmp = _("Games"); | |
| 2703 break; | |
| 2704 case 0x80: | |
| 2705 tmp = _("Stocks"); | |
| 2706 break; | |
| 2707 case 0x100: | |
| 2708 tmp = _("Send Buddy List"); | |
| 2709 break; | |
| 2710 case 0x400: | |
| 2711 tmp = _("EveryBuddy Bug"); | |
| 2712 break; | |
| 2713 case 0x800: | |
| 2714 tmp = _("AP User"); | |
| 2715 break; | |
| 2716 case 0x1000: | |
| 2717 tmp = _("ICQ RTF"); | |
| 2718 break; | |
| 2719 case 0x2000: | |
| 2720 tmp = _("Nihilist"); | |
| 2721 break; | |
| 2722 case 0x4000: | |
| 2723 tmp = _("ICQ Server Relay"); | |
| 2724 break; | |
| 2725 case 0x8000: | |
| 2726 tmp = _("ICQ Unknown"); | |
| 2727 break; | |
| 2728 case 0x10000: | |
| 2729 tmp = _("Trillian Encryption"); | |
| 2730 break; | |
| 2731 default: | |
| 2732 tmp = NULL; | |
| 2733 break; | |
| 2734 } | |
| 2735 if (tmp) | |
| 2736 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
| 2737 tmp); | |
| 2738 count++; | |
| 2739 } | |
| 2740 bit <<= 1; | |
| 2741 } | |
| 2742 return buf; | |
| 2743 } | |
| 2744 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2745 static int gaim_parse_user_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2746 aim_userinfo_t *info; |
| 4151 | 2747 char *text_enc = NULL, *text = NULL, *utf8 = NULL; |
| 2748 int text_len; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2749 fu16_t infotype; |
| 4151 | 2750 fu32_t flags; |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2751 char header[BUF_LONG]; |
| 2086 | 2752 struct gaim_connection *gc = sess->aux_data; |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2753 struct oscar_data *od = gc->proto_data; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2754 GSList *l = od->evilhack; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2755 gboolean evilhack = FALSE; |
| 2086 | 2756 va_list ap; |
| 2993 | 2757 gchar *membersince = NULL, *onlinesince = NULL, *idle = NULL; |
| 2086 | 2758 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2759 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2760 info = va_arg(ap, aim_userinfo_t *); |
| 4199 | 2761 infotype = (fu16_t) va_arg(ap, unsigned int); |
| 4151 | 2762 text_enc = va_arg(ap, char *); |
| 2763 text = va_arg(ap, char *); | |
| 2764 text_len = va_arg(ap, int); | |
| 2086 | 2765 va_end(ap); |
| 2766 | |
| 4151 | 2767 if (text_len > 0) { |
| 2768 flags = parse_encoding (text_enc); | |
| 2769 switch (flags) { | |
| 2770 case 0: | |
| 4159 | 2771 utf8 = g_strndup(text, text_len); |
| 4151 | 2772 break; |
| 4166 | 2773 case AIM_IMFLAGS_ISO_8859_1: |
| 2774 utf8 = g_convert(text, text_len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); | |
| 2775 break; | |
| 4151 | 2776 case AIM_IMFLAGS_UNICODE: |
| 2777 utf8 = g_convert(text, text_len, "UTF-8", "UCS-2BE", NULL, NULL, NULL); | |
| 2778 break; | |
| 2779 default: | |
| 4152 | 2780 utf8 = g_strdup(_("<I>Unable to display information because it was sent in an unknown encoding.</I>")); |
| 4194 | 2781 debug_printf("Encountered an unknown encoding while parsing userinfo\n"); |
| 4151 | 2782 } |
| 2783 } | |
| 2784 | |
| 2993 | 2785 if (info->present & AIM_USERINFO_PRESENT_ONLINESINCE) { |
| 2786 onlinesince = g_strdup_printf("Online Since : <B>%s</B><BR>\n", | |
| 2787 asctime(localtime(&info->onlinesince))); | |
| 2788 } | |
| 2789 | |
| 2790 if (info->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { | |
| 2791 membersince = g_strdup_printf("Member Since : <B>%s</B><BR>\n", | |
| 2792 asctime(localtime(&info->membersince))); | |
| 2793 } | |
| 2794 | |
| 2795 if (info->present & AIM_USERINFO_PRESENT_IDLE) { | |
| 4426 | 2796 gchar *itime = sec_to_text(info->idletime*60); |
| 2797 idle = g_strdup_printf("Idle : <B>%s</B>", itime); | |
| 2798 g_free(itime); | |
| 2993 | 2799 } else |
| 2800 idle = g_strdup("Idle: <B>Active</B>"); | |
| 2801 | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2802 g_snprintf(header, sizeof header, |
| 2086 | 2803 _("Username : <B>%s</B> %s <BR>\n" |
| 2993 | 2804 "Warning Level : <B>%d %%</B><BR>\n" |
| 2086 | 2805 "%s" |
| 2993 | 2806 "%s" |
| 4344 | 2807 "%s\n" |
| 3952 | 2808 "<HR>\n"), |
| 2086 | 2809 info->sn, images(info->flags), |
| 2810 info->warnlevel/10, | |
| 2993 | 2811 onlinesince ? onlinesince : "", |
| 2812 membersince ? membersince : "", | |
| 2813 idle ? idle : ""); | |
| 2814 | |
| 2815 g_free(onlinesince); | |
| 2816 g_free(membersince); | |
| 2817 g_free(idle); | |
|
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
2818 |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2819 while (l) { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2820 char *x = l->data; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2821 if (!strcmp(x, normalize(info->sn))) { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2822 evilhack = TRUE; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2823 g_free(x); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2824 od->evilhack = g_slist_remove(od->evilhack, x); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2825 break; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2826 } |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2827 l = l->next; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2828 } |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2829 |
| 2920 | 2830 if (infotype == AIM_GETINFO_AWAYMESSAGE) { |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2831 if (evilhack) { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2832 g_show_info_text(gc, info->sn, 2, |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2833 header, |
| 4151 | 2834 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
| 4207 | 2835 _("<i>User has no away message</i>"), NULL); |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2836 } else { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2837 g_show_info_text(gc, info->sn, 0, |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2838 header, |
| 4151 | 2839 (utf8 && *utf8) ? away_subs(utf8, gc->username) : NULL, |
| 4344 | 2840 (utf8 && *utf8) ? "<HR>" : NULL, |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2841 NULL); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2842 } |
| 2920 | 2843 } else if (infotype == AIM_GETINFO_CAPABILITIES) { |
| 2844 g_show_info_text(gc, info->sn, 2, | |
| 2845 header, | |
| 2846 "<i>", _("Client Capabilities: "), | |
| 2847 caps_string(info->capabilities), | |
| 2848 "</i>", | |
| 2849 NULL); | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2850 } else { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2851 g_show_info_text(gc, info->sn, 1, |
| 4151 | 2852 (utf8 && *utf8) ? away_subs(utf8, gc->username) : |
| 2853 _("<i>No Information Provided</i>"), | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2854 NULL); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
2855 } |
| 2086 | 2856 |
| 4151 | 2857 g_free(utf8); |
| 2858 | |
| 2086 | 2859 return 1; |
| 2860 } | |
| 2861 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2862 static int gaim_parse_motd(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2863 char *msg; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2864 fu16_t id; |
| 2086 | 2865 va_list ap; |
| 2866 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2867 va_start(ap, fr); |
| 4199 | 2868 id = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 2869 msg = va_arg(ap, char *); |
| 2870 va_end(ap); | |
| 2871 | |
| 4194 | 2872 debug_printf("MOTD: %s (%hu)\n", msg ? msg : "Unknown", id); |
|
2092
59b0377d18aa
[gaim-migrate @ 2102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
2873 if (id < 4) |
| 3427 | 2874 do_error_dialog(_("Your AIM connection may be lost."), NULL, GAIM_WARNING); |
| 2086 | 2875 |
| 2876 return 1; | |
| 2877 } | |
| 2878 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2879 static int gaim_chatnav_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2880 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2881 fu16_t type; |
| 2086 | 2882 struct gaim_connection *gc = sess->aux_data; |
| 2883 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 2884 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2885 va_start(ap, fr); |
| 4199 | 2886 type = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 2887 |
| 2888 switch(type) { | |
| 2889 case 0x0002: { | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2890 fu8_t maxrooms; |
| 2086 | 2891 struct aim_chat_exchangeinfo *exchanges; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2892 int exchangecount, i; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2893 |
| 4199 | 2894 maxrooms = (fu8_t) va_arg(ap, unsigned int); |
| 2086 | 2895 exchangecount = va_arg(ap, int); |
| 2896 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
| 2897 | |
| 2898 debug_printf("chat info: Chat Rights:\n"); | |
| 4194 | 2899 debug_printf("chat info: \tMax Concurrent Rooms: %hhd\n", maxrooms); |
| 2086 | 2900 debug_printf("chat info: \tExchange List: (%d total)\n", exchangecount); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2901 for (i = 0; i < exchangecount; i++) |
| 4194 | 2902 debug_printf("chat info: \t\t%hu %s\n", exchanges[i].number, exchanges[i].name ? exchanges[i].name : ""); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2903 while (odata->create_rooms) { |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2904 struct create_room *cr = odata->create_rooms->data; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2905 debug_printf("creating room %s\n", cr->name); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2906 aim_chatnav_createroom(sess, fr->conn, cr->name, cr->exchange); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2907 g_free(cr->name); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2908 odata->create_rooms = g_slist_remove(odata->create_rooms, cr); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
2909 g_free(cr); |
| 2086 | 2910 } |
| 2911 } | |
| 2912 break; | |
| 2913 case 0x0008: { | |
| 2914 char *fqcn, *name, *ck; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2915 fu16_t instance, flags, maxmsglen, maxoccupancy, unknown, exchange; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2916 fu8_t createperms; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2917 fu32_t createtime; |
| 2086 | 2918 |
| 2919 fqcn = va_arg(ap, char *); | |
| 4200 | 2920 instance = (fu16_t)va_arg(ap, unsigned int); |
| 2921 exchange = (fu16_t)va_arg(ap, unsigned int); | |
| 2922 flags = (fu16_t)va_arg(ap, unsigned int); | |
| 2923 createtime = va_arg(ap, fu32_t); | |
| 2924 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
| 2925 maxoccupancy = (fu16_t)va_arg(ap, unsigned int); | |
| 2926 createperms = (fu8_t)va_arg(ap, unsigned int); | |
| 2927 unknown = (fu16_t)va_arg(ap, unsigned int); | |
| 2928 name = va_arg(ap, char *); | |
| 2929 ck = va_arg(ap, char *); | |
| 4194 | 2930 |
| 2931 debug_printf("created room: %s %hu %hu %hu %lu %hu %hu %hhu %hu %s %s\n", | |
| 2086 | 2932 fqcn, |
| 2933 exchange, instance, flags, | |
| 2934 createtime, | |
| 2935 maxmsglen, maxoccupancy, createperms, unknown, | |
| 2936 name, ck); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2937 aim_chat_join(odata->sess, odata->conn, exchange, ck, instance); |
| 2086 | 2938 } |
| 2939 break; | |
| 2940 default: | |
| 4194 | 2941 debug_printf("chatnav info: unknown type (%04hx)\n", type); |
| 2086 | 2942 break; |
| 2943 } | |
| 4194 | 2944 |
| 2945 va_end(ap); | |
| 2946 | |
| 2086 | 2947 return 1; |
| 2948 } | |
| 2949 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2950 static int gaim_chat_join(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2951 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2952 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2953 aim_userinfo_t *info; |
| 2086 | 2954 struct gaim_connection *g = sess->aux_data; |
| 2955 | |
| 2956 struct chat_connection *c = NULL; | |
| 2957 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2958 va_start(ap, fr); |
| 2086 | 2959 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2960 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 2961 va_end(ap); |
| 2962 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2963 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 2964 if (!c) |
| 2965 return 1; | |
| 2966 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2967 for (i = 0; i < count; i++) |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
2968 gaim_chat_add_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
| 2086 | 2969 |
| 2970 return 1; | |
| 2971 } | |
| 2972 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2973 static int gaim_chat_leave(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 2974 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2975 int count, i; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2976 aim_userinfo_t *info; |
| 2086 | 2977 struct gaim_connection *g = sess->aux_data; |
| 2978 | |
| 2979 struct chat_connection *c = NULL; | |
| 2980 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2981 va_start(ap, fr); |
| 2086 | 2982 count = va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2983 info = va_arg(ap, aim_userinfo_t *); |
| 2086 | 2984 va_end(ap); |
| 2985 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2986 c = find_oscar_chat_by_conn(g, fr->conn); |
| 2086 | 2987 if (!c) |
| 2988 return 1; | |
| 2989 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2990 for (i = 0; i < count; i++) |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
2991 gaim_chat_remove_user(GAIM_CHAT(c->cnv), info[i].sn, NULL); |
| 2086 | 2992 |
| 2993 return 1; | |
| 2994 } | |
| 2995 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
2996 static int gaim_chat_info_update(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2997 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
2998 aim_userinfo_t *userinfo; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2999 struct aim_chat_roominfo *roominfo; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3000 char *roomname; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3001 int usercount; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3002 char *roomdesc; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3003 fu16_t unknown_c9, unknown_d2, unknown_d5, maxmsglen, maxvisiblemsglen; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3004 fu32_t creationtime; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3005 struct gaim_connection *gc = sess->aux_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3006 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
|
3007 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3008 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3009 roominfo = va_arg(ap, struct aim_chat_roominfo *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3010 roomname = va_arg(ap, char *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3011 usercount= va_arg(ap, int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3012 userinfo = va_arg(ap, aim_userinfo_t *); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3013 roomdesc = va_arg(ap, char *); |
| 4200 | 3014 unknown_c9 = (fu16_t)va_arg(ap, unsigned int); |
| 3015 creationtime = va_arg(ap, fu32_t); | |
| 3016 maxmsglen = (fu16_t)va_arg(ap, unsigned int); | |
| 3017 unknown_d2 = (fu16_t)va_arg(ap, unsigned int); | |
| 3018 unknown_d5 = (fu16_t)va_arg(ap, unsigned int); | |
| 3019 maxvisiblemsglen = (fu16_t)va_arg(ap, unsigned int); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3020 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3021 |
| 4194 | 3022 debug_printf("inside chat_info_update (maxmsglen = %hu, maxvislen = %hu)\n", |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3023 maxmsglen, maxvisiblemsglen); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3024 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3025 ccon->maxlen = maxmsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3026 ccon->maxvis = maxvisiblemsglen; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3027 |
| 2086 | 3028 return 1; |
| 3029 } | |
| 3030 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3031 static int gaim_chat_incoming_msg(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4269 | 3032 struct gaim_connection *gc = sess->aux_data; |
| 2086 | 3033 va_list ap; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3034 aim_userinfo_t *info; |
| 2086 | 3035 char *msg; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3036 struct chat_connection *ccon = find_oscar_chat_by_conn(gc, fr->conn); |
| 2086 | 3037 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3038 va_start(ap, fr); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3039 info = va_arg(ap, aim_userinfo_t *); |
| 4194 | 3040 msg = va_arg(ap, char *); |
| 3041 va_end(ap); | |
| 2086 | 3042 |
| 4269 | 3043 serv_got_chat_in(gc, ccon->id, info->sn, 0, msg, time((time_t)NULL)); |
| 2086 | 3044 |
| 3045 return 1; | |
| 3046 } | |
| 3047 | |
| 3694 | 3048 static int gaim_email_parseupdate(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 3049 va_list ap; | |
| 3050 struct gaim_connection *gc = sess->aux_data; | |
| 3051 struct aim_emailinfo *emailinfo; | |
| 3725 | 3052 int havenewmail; |
| 3694 | 3053 |
| 3054 va_start(ap, fr); | |
| 3055 emailinfo = va_arg(ap, struct aim_emailinfo *); | |
| 3725 | 3056 havenewmail = va_arg(ap, int); |
| 3694 | 3057 va_end(ap); |
| 3058 | |
| 3725 | 3059 if (emailinfo) { |
| 4269 | 3060 debug_printf("Got email info. domain is %s, webmail is %s, new email: %hhu, number new: %hu, flag is %hu, havenewmail is %d\n", emailinfo->domain, emailinfo->url, emailinfo->unread, emailinfo->nummsgs, emailinfo->flag, havenewmail); |
| 3725 | 3061 if (emailinfo->unread) { |
| 3062 if (havenewmail) | |
| 3063 connection_has_mail(gc, emailinfo->nummsgs ? emailinfo->nummsgs : -1, NULL, NULL, emailinfo->url); | |
| 3064 } else | |
| 3694 | 3065 connection_has_mail(gc, 0, NULL, NULL, emailinfo->url); |
| 3066 } | |
| 3067 | |
| 3068 return 1; | |
| 3069 } | |
| 3070 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3071 /* |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3072 * 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
|
3073 */ |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3074 static int gaim_parse_msgack(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 3075 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3076 fu16_t type; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3077 char *sn; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3078 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3079 va_start(ap, fr); |
| 4199 | 3080 type = (fu16_t) va_arg(ap, unsigned int); |
| 2086 | 3081 sn = va_arg(ap, char *); |
| 3082 va_end(ap); | |
| 3083 | |
| 3084 debug_printf("Sent message to %s.\n", sn); | |
| 3085 | |
| 3086 return 1; | |
| 3087 } | |
| 3088 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3089 static int gaim_parse_ratechange(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3090 static const char *codes[5] = { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3091 "invalid", |
| 4194 | 3092 "change", |
| 3093 "warning", | |
| 3094 "limit", | |
| 3095 "limit cleared", | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3096 }; |
| 2086 | 3097 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3098 fu16_t code, rateclass; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3099 fu32_t windowsize, clear, alert, limit, disconnect, currentavg, maxavg; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3100 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3101 va_start(ap, fr); |
| 4200 | 3102 code = (fu16_t)va_arg(ap, unsigned int); |
| 3103 rateclass= (fu16_t)va_arg(ap, unsigned int); | |
| 3104 windowsize = va_arg(ap, fu32_t); | |
| 3105 clear = va_arg(ap, fu32_t); | |
| 3106 alert = va_arg(ap, fu32_t); | |
| 3107 limit = va_arg(ap, fu32_t); | |
| 3108 disconnect = va_arg(ap, fu32_t); | |
| 3109 currentavg = va_arg(ap, fu32_t); | |
| 3110 maxavg = va_arg(ap, fu32_t); | |
| 2086 | 3111 va_end(ap); |
| 3112 | |
| 4194 | 3113 debug_printf("rate %s (param ID 0x%04hx): curavg = %lu, maxavg = %lu, alert at %lu, " |
| 3114 "clear warning at %lu, limit at %lu, disconnect at %lu (window size = %lu)\n", | |
| 2086 | 3115 (code < 5) ? codes[code] : codes[0], |
| 3116 rateclass, | |
| 3117 currentavg, maxavg, | |
| 3118 alert, clear, | |
| 3119 limit, disconnect, | |
| 3120 windowsize); | |
| 3121 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3122 /* XXX fix these values */ |
| 2086 | 3123 if (code == AIM_RATE_CODE_CHANGE) { |
| 3124 if (currentavg >= clear) | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3125 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 3126 } else if (code == AIM_RATE_CODE_WARNING) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3127 aim_conn_setlatency(fr->conn, windowsize/4); |
|
2909
48ec70928d7f
[gaim-migrate @ 2922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2906
diff
changeset
|
3128 } else if (code == AIM_RATE_CODE_LIMIT) { |
| 3427 | 3129 do_error_dialog(_("Rate limiting error."), |
| 3130 _("The last message was not sent because you are over the rate limit. " | |
| 3131 "Please wait 10 seconds and try again."), GAIM_ERROR); | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3132 aim_conn_setlatency(fr->conn, windowsize/2); |
| 2086 | 3133 } else if (code == AIM_RATE_CODE_CLEARLIMIT) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3134 aim_conn_setlatency(fr->conn, 0); |
| 2086 | 3135 } |
| 3136 | |
| 3137 return 1; | |
| 3138 } | |
| 3139 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3140 static int gaim_parse_evilnotify(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 3141 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3142 fu16_t newevil; |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3143 aim_userinfo_t *userinfo; |
| 2086 | 3144 struct gaim_connection *gc = sess->aux_data; |
| 3145 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3146 va_start(ap, fr); |
| 4199 | 3147 newevil = (fu16_t) va_arg(ap, unsigned int); |
|
2421
95b4ec08abec
[gaim-migrate @ 2434]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2411
diff
changeset
|
3148 userinfo = va_arg(ap, aim_userinfo_t *); |
| 2086 | 3149 va_end(ap); |
| 3150 | |
| 3151 serv_got_eviled(gc, (userinfo && userinfo->sn[0]) ? userinfo->sn : NULL, newevil / 10); | |
| 3152 | |
| 3153 return 1; | |
| 3154 } | |
| 3155 | |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3156 static int gaim_selfinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3157 va_list ap; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3158 aim_userinfo_t *info; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3159 struct gaim_connection *gc = sess->aux_data; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3160 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3161 va_start(ap, fr); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3162 info = va_arg(ap, aim_userinfo_t *); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3163 va_end(ap); |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3164 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3165 gc->evil = info->warnlevel/10; |
|
2698
e80f4b4f840f
[gaim-migrate @ 2711]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2689
diff
changeset
|
3166 /* gc->correction_time = (info->onlinesince - gc->login_time); */ |
|
2507
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3167 |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3168 return 1; |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3169 } |
|
1069b0940237
[gaim-migrate @ 2520]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
3170 |
| 2675 | 3171 static int conninitdone_bos(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3172 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3173 aim_reqpersonalinfo(sess, fr->conn); |
| 4230 | 3174 |
| 3175 #ifndef NOSSI | |
| 3176 debug_printf("ssi: requesting ssi list\n"); | |
| 3177 aim_ssi_reqrights(sess, fr->conn); | |
| 3178 aim_ssi_reqdata(sess, fr->conn, sess->ssi.timestamp, sess->ssi.numitems); | |
| 3179 #endif | |
| 3180 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3181 aim_bos_reqlocaterights(sess, fr->conn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3182 aim_bos_reqbuddyrights(sess, fr->conn); |
|
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
3183 aim_reqicbmparams(sess); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3184 aim_bos_reqrights(sess, fr->conn); |
| 4230 | 3185 |
| 3186 #ifdef NOSSI | |
| 3187 aim_bos_setgroupperm(sess, fr->conn, AIM_FLAG_ALLUSERS); | |
| 3188 aim_bos_setprivacyflags(sess, fr->conn, AIM_PRIVFLAGS_ALLOWIDLE | AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
| 3189 #endif | |
| 2086 | 3190 |
| 3191 return 1; | |
| 3192 } | |
| 3193 | |
| 2675 | 3194 static int conninitdone_admin(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2647 | 3195 struct gaim_connection *gc = sess->aux_data; |
| 3196 struct oscar_data *od = gc->proto_data; | |
| 3197 | |
| 2672 | 3198 aim_clientready(sess, fr->conn); |
| 2675 | 3199 debug_printf("connected to admin\n"); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3200 |
| 2647 | 3201 if (od->chpass) { |
| 3202 debug_printf("changing password\n"); | |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3203 aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp); |
| 2647 | 3204 g_free(od->oldp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3205 od->oldp = NULL; |
| 2647 | 3206 g_free(od->newp); |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3207 od->newp = NULL; |
| 2647 | 3208 od->chpass = FALSE; |
| 3209 } | |
| 2979 | 3210 if (od->setnick) { |
| 3211 debug_printf("formatting screenname\n"); | |
| 3212 aim_admin_setnick(sess, fr->conn, od->newsn); | |
| 3213 g_free(od->newsn); | |
| 3214 od->newsn = NULL; | |
| 3215 od->setnick = FALSE; | |
| 3216 } | |
| 2647 | 3217 if (od->conf) { |
| 3218 debug_printf("confirming account\n"); | |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3219 aim_admin_reqconfirm(sess, fr->conn); |
| 2647 | 3220 od->conf = FALSE; |
| 3221 } | |
| 3222 if (od->reqemail) { | |
| 3223 debug_printf("requesting email\n"); | |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3224 aim_admin_getinfo(sess, fr->conn, 0x0011); |
| 2647 | 3225 od->reqemail = FALSE; |
| 3226 } | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3227 if (od->setemail) { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3228 debug_printf("setting email\n"); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3229 aim_admin_setemail(sess, fr->conn, od->email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3230 g_free(od->email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3231 od->setemail = FALSE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3232 } |
| 2647 | 3233 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3234 return 1; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3235 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3236 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3237 static int gaim_icbm_param_info(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3238 struct aim_icbmparameters *params; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3239 va_list ap; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3240 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3241 va_start(ap, fr); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3242 params = va_arg(ap, struct aim_icbmparameters *); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3243 va_end(ap); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3244 |
| 4194 | 3245 /* XXX - evidently this crashes on solaris. i have no clue why |
| 3246 debug_printf("ICBM Parameters: maxchannel = %hu, default flags = 0x%08lx, max msg len = %hu, " | |
| 3247 "max sender evil = %f, max receiver evil = %f, min msg interval = %lu\n", | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3248 params->maxchan, params->flags, params->maxmsglen, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3249 ((float)params->maxsenderwarn)/10.0, ((float)params->maxrecverwarn)/10.0, |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3250 params->minmsginterval); |
|
2427
5bc3b39fc0a5
[gaim-migrate @ 2440]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2421
diff
changeset
|
3251 */ |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3252 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3253 /* Maybe senderwarn and recverwarn should be user preferences... */ |
| 3595 | 3254 params->flags = 0x0000000b; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3255 params->maxmsglen = 8000; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3256 params->minmsginterval = 0; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3257 |
|
2673
81d658e6ac1e
[gaim-migrate @ 2686]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2672
diff
changeset
|
3258 aim_seticbmparam(sess, params); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3259 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3260 return 1; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3261 } |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3262 |
| 2993 | 3263 static int gaim_parse_locaterights(aim_session_t *sess, aim_frame_t *fr, ...) |
| 3264 { | |
| 3265 va_list ap; | |
| 3266 fu16_t maxsiglen; | |
| 3267 struct gaim_connection *gc = sess->aux_data; | |
| 3268 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 4151 | 3269 char *unicode; |
| 3270 int unicode_len; | |
| 3271 fu32_t flags; | |
| 2993 | 3272 |
| 3273 va_start(ap, fr); | |
| 4199 | 3274 maxsiglen = (fu16_t) va_arg(ap, int); |
| 2993 | 3275 va_end(ap); |
| 3276 | |
| 3277 debug_printf("locate rights: max sig len = %d\n", maxsiglen); | |
| 3278 | |
| 3279 odata->rights.maxsiglen = odata->rights.maxawaymsglen = (guint)maxsiglen; | |
| 3280 | |
| 3458 | 3281 if (odata->icq) |
| 4151 | 3282 aim_bos_setprofile(sess, fr->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
| 3283 else { | |
| 3284 flags = check_encoding (gc->user->user_info); | |
| 3285 | |
| 3286 if (flags == 0) { | |
| 3287 aim_bos_setprofile(sess, fr->conn, "us-ascii", gc->user->user_info, | |
| 3288 strlen(gc->user->user_info), NULL, NULL, 0, caps_aim); | |
| 3289 } else { | |
| 3290 unicode = g_convert (gc->user->user_info, strlen(gc->user->user_info), | |
| 3291 "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
| 3292 aim_bos_setprofile(sess, fr->conn, "unicode-2-0", unicode, unicode_len, | |
| 3293 NULL, NULL, 0, caps_aim); | |
| 3294 g_free(unicode); | |
| 3295 } | |
| 3296 } | |
| 2993 | 3297 |
| 3298 return 1; | |
| 3299 } | |
| 3300 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3301 static int gaim_parse_buddyrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
3302 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3303 fu16_t maxbuddies, maxwatchers; |
| 2993 | 3304 struct gaim_connection *gc = sess->aux_data; |
| 3305 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3306 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3307 va_start(ap, fr); |
| 4199 | 3308 maxbuddies = (fu16_t) va_arg(ap, unsigned int); |
| 3309 maxwatchers = (fu16_t) va_arg(ap, unsigned int); | |
| 2086 | 3310 va_end(ap); |
| 3311 | |
| 4194 | 3312 debug_printf("buddy list rights: Max buddies = %hu / Max watchers = %hu\n", maxbuddies, maxwatchers); |
| 2086 | 3313 |
| 2993 | 3314 odata->rights.maxbuddies = (guint)maxbuddies; |
| 3315 odata->rights.maxwatchers = (guint)maxwatchers; | |
| 3316 | |
| 2086 | 3317 return 1; |
| 3318 } | |
| 3319 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3320 static int gaim_bosrights(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3321 fu16_t maxpermits, maxdenies; |
| 2086 | 3322 va_list ap; |
| 2993 | 3323 struct gaim_connection *gc = sess->aux_data; |
| 3324 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 2086 | 3325 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3326 va_start(ap, fr); |
| 4199 | 3327 maxpermits = (fu16_t) va_arg(ap, unsigned int); |
| 3328 maxdenies = (fu16_t) va_arg(ap, unsigned int); | |
| 2086 | 3329 va_end(ap); |
| 3330 | |
| 4194 | 3331 debug_printf("BOS rights: Max permit = %hu / Max deny = %hu\n", maxpermits, maxdenies); |
| 2086 | 3332 |
| 2993 | 3333 odata->rights.maxpermits = (guint)maxpermits; |
| 3334 odata->rights.maxdenies = (guint)maxdenies; | |
| 3335 | |
| 3336 account_online(gc); | |
| 3337 serv_finish_login(gc); | |
| 3338 | |
| 3339 debug_printf("buddy list loaded\n"); | |
| 3340 | |
| 2672 | 3341 aim_clientready(sess, fr->conn); |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3342 |
| 4230 | 3343 /* AAA - Should call aim_bos_setidle with 0x0000 */ |
| 3344 | |
| 3345 /* AAA - Should only call reqofflinemsgs when using ICQ? */ | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3346 aim_icq_reqofflinemsgs(sess); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3347 |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3348 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_CHATNAV); |
| 4102 | 3349 if (sess->authinfo->email) |
| 3350 aim_reqservice(sess, fr->conn, AIM_CONN_TYPE_EMAIL); | |
| 2086 | 3351 |
| 3352 return 1; | |
| 3353 } | |
| 3354 | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3355 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3356 va_list ap; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3357 struct aim_icq_offlinemsg *msg; |
| 4075 | 3358 struct aim_incomingim_ch4_args args; |
| 3359 time_t t; | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3360 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3361 va_start(ap, fr); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3362 msg = va_arg(ap, struct aim_icq_offlinemsg *); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3363 va_end(ap); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3364 |
| 4075 | 3365 debug_printf("Received offline message. Converting to channel 4 ICBM...\n"); |
| 3366 args.uin = msg->sender; | |
| 3367 args.type = msg->type; | |
| 4173 | 3368 args.flags = msg->flags; |
| 4076 | 3369 args.msglen = msg->msglen; |
| 4075 | 3370 args.msg = msg->msg; |
| 3371 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); | |
| 3372 incomingim_chan4(sess, fr->conn, NULL, &args, t); | |
|
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3373 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3374 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3375 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3376 |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3377 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3378 { |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3379 aim_icq_ackofflinemsgs(sess); |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3380 return 1; |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3381 } |
|
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2704
diff
changeset
|
3382 |
| 4151 | 3383 static int gaim_icqsimpleinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3384 { |
|
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2768
diff
changeset
|
3385 struct gaim_connection *gc = sess->aux_data; |
| 3212 | 3386 struct buddy *budlight; |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3387 va_list ap; |
| 4151 | 3388 struct aim_icq_info *info; |
| 3389 gchar *buf, *tmp; | |
| 3390 gchar who[16]; | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3391 |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3392 va_start(ap, fr); |
| 4151 | 3393 info = va_arg(ap, struct aim_icq_info *); |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3394 va_end(ap); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3395 |
| 4151 | 3396 g_snprintf(who, sizeof(who), "%lu", info->uin); |
| 3397 buf = g_strdup_printf("<b>UIN:</b> %s<br>", who); | |
| 3398 if (info->nick) { | |
| 3399 tmp = buf; | |
| 3400 buf = g_strconcat(tmp, "<b>Nick:</b> ", info->nick, "<br>\n", NULL); | |
| 3401 g_free(tmp); | |
| 4386 | 3402 serv_got_alias(gc, who, info->nick); |
| 4151 | 3403 } |
| 3404 if (info->first) { | |
| 3405 tmp = buf; | |
| 3406 buf = g_strconcat(tmp, "<b>First Name:</b> ", info->first, "<br>\n", NULL); | |
| 3407 g_free(tmp); | |
| 3408 } | |
| 3409 if (info->last) { | |
| 3410 tmp = buf; | |
| 3411 buf = g_strconcat(tmp, "<b>Last Name:</b> ", info->last, "<br>\n", NULL); | |
| 3412 g_free(tmp); | |
| 3413 } | |
| 3414 if (info->email) { | |
| 3415 tmp = buf; | |
| 3416 buf = g_strconcat(tmp, "<b>Email Address:</b> ", info->email, "<br>\n", NULL); | |
| 3417 g_free(tmp); | |
| 3418 } | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3419 |
| 3212 | 3420 /* If the contact is away, then we also want to get their status message |
| 3421 * and show it in the same window as info. g_show_info_text gets the status | |
| 3422 * message if the third arg is 0 (this seems really gross to me). The | |
| 3423 * parse-icq-status-message function knows if it is putting it's message in | |
| 3424 * an info window because the name will _not_ be in od->evilhack. For getting | |
| 3425 * only the away message the contact's UIN is put in od->evilhack. */ | |
| 4349 | 3426 if ((budlight = find_buddy(gc->user, who))) { |
| 3595 | 3427 if ((budlight->uc >> 16) & (AIM_ICQ_STATE_AWAY || AIM_ICQ_STATE_DND || AIM_ICQ_STATE_OUT || AIM_ICQ_STATE_BUSY || AIM_ICQ_STATE_CHAT)) { |
| 3270 | 3428 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
| 3429 g_show_info_text(gc, who, 0, buf, NULL); | |
| 3430 else { | |
| 3595 | 3431 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
| 4344 | 3432 g_show_info_text(gc, who, 2, buf, "<B>Status:</B> ", state_msg, "<HR>\n<I>Remote client does not support sending status messages.</I><BR>\n", NULL); |
| 3270 | 3433 free(state_msg); |
| 3434 } | |
| 3435 } else { | |
| 3595 | 3436 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
| 3270 | 3437 g_show_info_text(gc, who, 2, buf, "<B>Status:</B> ", state_msg, NULL); |
| 3212 | 3438 free(state_msg); |
| 3439 } | |
| 3270 | 3440 } else |
| 3441 g_show_info_text(gc, who, 2, buf, NULL); | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3442 |
| 4151 | 3443 g_free(buf); |
| 3444 | |
| 3445 return 1; | |
| 3446 } | |
| 3447 | |
| 3448 static int gaim_icqallinfo(aim_session_t *sess, aim_frame_t *fr, ...) | |
| 3449 { | |
| 3450 struct gaim_connection *gc = sess->aux_data; | |
| 3451 va_list ap; | |
| 3452 struct aim_icq_info *info; | |
| 3453 gchar *buf, *tmp; | |
| 3454 gchar who[16]; | |
| 3455 | |
| 3456 va_start(ap, fr); | |
| 3457 info = va_arg(ap, struct aim_icq_info *); | |
| 3458 va_end(ap); | |
| 3459 | |
| 3460 g_snprintf(who, sizeof(who), "%lu", info->uin); | |
| 3461 buf = g_strdup_printf("<b>UIN:</b> %s<br>", who); | |
| 3462 if (info->nick) { | |
| 3463 tmp = buf; | |
| 3464 buf = g_strconcat(tmp, "<b>Nick:</b> ", info->nick, "<br>\n", NULL); | |
| 3465 g_free(tmp); | |
| 4386 | 3466 serv_got_alias(gc, who, info->nick); |
| 4151 | 3467 } |
| 3468 if (info->first) { | |
| 3469 tmp = buf; | |
| 3470 buf = g_strconcat(tmp, "<b>First Name:</b> ", info->first, "<br>\n", NULL); | |
| 3471 g_free(tmp); | |
| 3472 } | |
| 3473 if (info->last) { | |
| 3474 tmp = buf; | |
| 3475 buf = g_strconcat(tmp, "<b>Last Name:</b> ", info->last, "<br>\n", NULL); | |
| 3476 g_free(tmp); | |
| 3477 } | |
| 3478 if (info->email) { | |
| 3479 tmp = buf; | |
| 3480 buf = g_strconcat(tmp, "<b>Email Address:</b> ", info->email, "<br>\n", NULL); | |
| 3481 g_free(tmp); | |
| 3482 } | |
| 3483 if (info->personalwebpage) { | |
| 3484 tmp = buf; | |
| 3485 buf = g_strconcat(tmp, "<b>Personal Webpage:</b> ", info->personalwebpage, "<br>\n", NULL); | |
| 3486 g_free(tmp); | |
| 3487 } | |
| 3488 if (info->info) { | |
| 3489 tmp = buf; | |
| 4344 | 3490 buf = g_strconcat(tmp, "<br><b>Additional Information:</b><br>", info->info, "<hr>\n", NULL); |
| 4151 | 3491 g_free(tmp); |
| 3492 } | |
| 3493 if (info->homecity && info->homestate && info->homeaddr && info->homezip) { | |
| 3494 tmp = buf; | |
| 3495 buf = g_strconcat(tmp, "<br><b>Home Address:</b><br>\n", info->homeaddr, "<br>\n", info->homecity, ", ", info->homestate, " ", info->homezip, "<hr>\n", NULL); | |
| 3496 g_free(tmp); | |
| 3497 } | |
| 3498 | |
| 3499 g_show_info_text(gc, who, 2, buf, NULL); | |
| 3500 g_free(buf); | |
| 3501 | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3502 return 1; |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3503 } |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3504 |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3505 static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...) |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3506 { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3507 char *msg, *url; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3508 fu16_t wid, hei, delay; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3509 va_list ap; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3510 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3511 va_start(ap, fr); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3512 msg = va_arg(ap, char *); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3513 url = va_arg(ap, char *); |
| 4199 | 3514 wid = (fu16_t) va_arg(ap, int); |
| 3515 hei = (fu16_t) va_arg(ap, int); | |
| 3516 delay = (fu16_t) va_arg(ap, int); | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3517 va_end(ap); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3518 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3519 serv_got_popup(msg, url, wid, hei); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3520 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3521 return 1; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3522 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
3523 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3524 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 3525 va_list ap; |
| 3526 char *address, *SNs; | |
| 3527 int i, num; | |
| 3528 char *buf; | |
| 3529 int at = 0, len; | |
| 3530 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3531 va_start(ap, fr); |
| 2086 | 3532 address = va_arg(ap, char *); |
| 3533 num = va_arg(ap, int); | |
| 3534 SNs = va_arg(ap, char *); | |
| 3535 va_end(ap); | |
| 3536 | |
| 3537 len = num * (MAXSNLEN + 1) + 1024; | |
| 3538 buf = g_malloc(len); | |
| 3539 at += g_snprintf(buf + at, len - at, "<B>%s has the following screen names:</B><BR>", address); | |
| 3540 for (i = 0; i < num; i++) | |
| 3541 at += g_snprintf(buf + at, len - at, "%s<BR>", &SNs[i * (MAXSNLEN + 1)]); | |
| 3212 | 3542 g_show_info_text(NULL, NULL, 2, buf, NULL); |
| 2086 | 3543 g_free(buf); |
| 3544 | |
| 3545 return 1; | |
| 3546 } | |
| 3547 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3548 static int gaim_parse_searcherror(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 3549 va_list ap; |
| 3550 char *address; | |
| 3551 char buf[BUF_LONG]; | |
| 3552 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3553 va_start(ap, fr); |
| 2086 | 3554 address = va_arg(ap, char *); |
| 3555 va_end(ap); | |
| 3556 | |
| 3557 g_snprintf(buf, sizeof(buf), "No results found for email address %s", address); | |
| 3427 | 3558 do_error_dialog(buf, NULL, GAIM_ERROR); |
| 2086 | 3559 |
| 3560 return 1; | |
| 3561 } | |
| 3562 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3563 static int gaim_account_confirm(aim_session_t *sess, aim_frame_t *fr, ...) { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3564 fu16_t status; |
| 2086 | 3565 va_list ap; |
| 3566 char msg[256]; | |
| 3567 struct gaim_connection *gc = sess->aux_data; | |
| 3568 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3569 va_start(ap, fr); |
| 4199 | 3570 status = (fu16_t) va_arg(ap, unsigned int); /* status code of confirmation request */ |
| 2086 | 3571 va_end(ap); |
| 3572 | |
| 3573 debug_printf("account confirmation returned status 0x%04x (%s)\n", status, | |
| 3912 | 3574 status ? "unknown" : "email sent"); |
| 3575 if (!status) { | |
| 2086 | 3576 g_snprintf(msg, sizeof(msg), "You should receive an email asking to confirm %s.", |
| 3577 gc->username); | |
| 4056 | 3578 do_error_dialog(_("Account Confirmation Requested"), msg, GAIM_INFO); |
| 2086 | 3579 } |
| 3580 | |
| 3581 return 1; | |
| 3582 } | |
| 3583 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3584 static int gaim_info_change(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 3912 | 3585 struct gaim_connection *gc = sess->aux_data; |
| 2086 | 3586 va_list ap; |
| 3912 | 3587 fu16_t perms, err; |
| 3588 char *url, *sn, *email; | |
| 3589 int change; | |
| 2086 | 3590 |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3591 va_start(ap, fr); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
3592 change = va_arg(ap, int); |
| 4199 | 3593 perms = (fu16_t) va_arg(ap, unsigned int); |
| 3594 err = (fu16_t) va_arg(ap, unsigned int); | |
| 3912 | 3595 url = va_arg(ap, char *); |
| 3596 sn = va_arg(ap, char *); | |
| 3597 email = va_arg(ap, char *); | |
| 2086 | 3598 va_end(ap); |
| 3599 | |
| 3912 | 3600 debug_printf("account info: because of %s, perms=0x%04x, err=0x%04x, url=%s, sn=%s, email=%s\n", |
| 3601 change ? "change" : "request", perms, err, url, sn, email); | |
| 3602 | |
| 3603 if (err && url) { | |
| 3604 char *dialog_msg; | |
| 3605 char *dialog_top = g_strdup_printf(_("Error Changing Account Info")); | |
| 3606 switch (err) { | |
| 3607 case 0x0001: { | |
| 3608 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name differs from the original."), err); | |
| 3609 } break; | |
| 3610 case 0x0006: { | |
| 3611 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name ends in a space."), err); | |
| 3612 } break; | |
| 3613 case 0x000b: { | |
| 3614 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to format screen name because the requested screen name is too long."), err); | |
| 3615 } break; | |
| 3616 case 0x001d: { | |
| 3617 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); | |
| 3618 } break; | |
| 3619 case 0x0021: { | |
| 3620 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); | |
| 3621 } break; | |
| 3622 case 0x0023: { | |
| 3623 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unable to change email address because the given address is invalid."), err); | |
| 3624 } break; | |
| 3625 default: { | |
| 3626 dialog_msg = g_strdup_printf(_("Error 0x%04x: Unknown error."), err); | |
| 3627 } break; | |
| 3628 } | |
| 3629 do_error_dialog(dialog_top, dialog_msg, GAIM_ERROR); | |
| 3630 g_free(dialog_top); | |
| 3631 g_free(dialog_msg); | |
| 3632 return 1; | |
| 3633 } | |
| 3634 | |
| 3635 if (sn) { | |
| 3636 char *dialog_msg = g_strdup_printf(_("Your screen name is currently formated as follows:\n%s"), sn); | |
| 4056 | 3637 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
| 3912 | 3638 g_free(dialog_msg); |
| 3639 } | |
| 3640 | |
| 3641 if (email) { | |
| 3642 char *dialog_msg = g_strdup_printf(_("The email address for %s is %s"), gc->username, email); | |
| 4056 | 3643 do_error_dialog(_("Account Info"), dialog_msg, GAIM_INFO); |
| 3912 | 3644 g_free(dialog_msg); |
| 2086 | 3645 } |
| 3646 | |
| 3647 return 1; | |
| 3648 } | |
| 3649 | |
| 3650 static void oscar_keepalive(struct gaim_connection *gc) { | |
| 3651 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 3652 aim_flap_nop(odata->sess, odata->conn); | |
| 3653 } | |
| 3654 | |
| 3001 | 3655 static int oscar_send_typing(struct gaim_connection *gc, char *name, int typing) { |
| 2993 | 3656 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 3657 struct direct_im *dim = find_direct_im(odata, name); | |
| 3595 | 3658 if (dim) |
| 3659 aim_send_typing(odata->sess, dim->conn, typing); | |
| 3660 else { | |
| 4269 | 3661 if (g_hash_table_lookup(odata->supports_tn, normalize(name))) { |
| 3596 | 3662 if (typing == TYPING) |
| 3595 | 3663 aim_mtn_send(odata->sess, 0x0001, name, 0x0002); |
| 3596 | 3664 else if (typing == TYPED) |
| 3665 aim_mtn_send(odata->sess, 0x0001, name, 0x0001); | |
| 3595 | 3666 else |
| 3667 aim_mtn_send(odata->sess, 0x0001, name, 0x0000); | |
| 3668 } | |
| 3669 } | |
| 2993 | 3670 return 0; |
| 3671 } | |
| 3048 | 3672 static void oscar_ask_direct_im(struct gaim_connection *gc, char *name); |
| 2993 | 3673 |
| 3033 | 3674 static int oscar_send_im(struct gaim_connection *gc, char *name, char *message, int len, int imflags) { |
| 2086 | 3675 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 3676 struct direct_im *dim = find_direct_im(odata, name); | |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3677 int ret = 0; |
| 3659 | 3678 GError *err = NULL; |
| 3458 | 3679 |
| 2086 | 3680 if (dim) { |
| 3009 | 3681 if (dim->connected) { /* If we're not connected yet, send through server */ |
| 3952 | 3682 /* AAA - The last parameter below is the encoding. Let Paco-Paco do something with it. */ |
| 3683 ret = aim_send_im_direct(odata->sess, dim->conn, message, len == -1 ? strlen(message) : len, 0); | |
| 3009 | 3684 if (ret == 0) |
| 3685 return 1; | |
| 3686 else return ret; | |
| 3687 } | |
| 3008 | 3688 debug_printf("Direct IM pending, but not connected; sending through server\n"); |
| 3044 | 3689 } else if (len != -1) { |
| 3690 /* Trying to send an IM image outside of a direct connection. */ | |
| 3691 oscar_ask_direct_im(gc, name); | |
| 3692 return -ENOTCONN; | |
| 3693 } | |
| 3008 | 3694 if (imflags & IM_FLAG_AWAY) { |
| 3695 ret = aim_send_im(odata->sess, name, AIM_IMFLAGS_AWAY, message); | |
| 2086 | 3696 } else { |
| 3008 | 3697 struct aim_sendimext_args args; |
| 3698 GSList *h = odata->hasicons; | |
| 3699 struct icon_req *ir = NULL; | |
| 3700 char *who = normalize(name); | |
| 3701 struct stat st; | |
| 4151 | 3702 int len; |
| 4269 | 3703 |
| 3008 | 3704 args.flags = AIM_IMFLAGS_ACK | AIM_IMFLAGS_CUSTOMFEATURES; |
| 3705 if (odata->icq) | |
| 3706 args.flags |= AIM_IMFLAGS_OFFLINE; | |
| 4269 | 3707 |
| 3008 | 3708 args.features = gaim_features; |
| 3709 args.featureslen = sizeof(gaim_features); | |
| 4269 | 3710 |
| 3008 | 3711 while (h) { |
| 3712 ir = h->data; | |
| 3713 if (ir->request && !strcmp(who, ir->user)) | |
| 3714 break; | |
| 3715 h = h->next; | |
| 2086 | 3716 } |
| 3008 | 3717 if (h) { |
| 3718 ir->request = FALSE; | |
| 3719 args.flags |= AIM_IMFLAGS_BUDDYREQ; | |
| 3720 debug_printf("sending buddy icon request with message\n"); | |
| 3721 } | |
| 4269 | 3722 |
| 3008 | 3723 if (gc->user->iconfile[0] && !stat(gc->user->iconfile, &st)) { |
| 3724 FILE *file = fopen(gc->user->iconfile, "r"); | |
| 3725 if (file) { | |
| 3726 char *buf = g_malloc(st.st_size); | |
| 3727 fread(buf, 1, st.st_size, file); | |
| 4269 | 3728 |
| 3008 | 3729 args.iconlen = st.st_size; |
| 3730 args.iconsum = aim_iconsum(buf, st.st_size); | |
| 3731 args.iconstamp = st.st_mtime; | |
| 3732 | |
| 3733 args.flags |= AIM_IMFLAGS_HASICON; | |
| 3734 debug_printf("Claiming to have an icon.\n"); | |
| 3735 | |
| 3736 fclose(file); | |
| 3737 g_free(buf); | |
| 2086 | 3738 } |
| 3739 } | |
| 4269 | 3740 |
| 3008 | 3741 args.destsn = name; |
| 4269 | 3742 |
| 3642 | 3743 len = strlen(message); |
| 4151 | 3744 args.flags |= check_encoding(message); |
| 3642 | 3745 if (args.flags & AIM_IMFLAGS_UNICODE) { |
| 4194 | 3746 debug_printf("Sending Unicode IM\n"); |
| 3659 | 3747 args.msg = g_convert(message, len, "UCS-2BE", "UTF-8", NULL, &len, &err); |
| 3748 if (err) { | |
| 3749 debug_printf("Error converting a unicode message: %s\n", err->message); | |
| 3750 debug_printf("This really shouldn't happen!\n"); | |
| 3751 /* We really shouldn't try to send the | |
| 3752 * IM now, but I'm not sure what to do */ | |
| 3753 } | |
| 3850 | 3754 } else if (args.flags & AIM_IMFLAGS_ISO_8859_1) { |
| 4194 | 3755 debug_printf("Sending ISO-8859-1 IM\n"); |
| 3659 | 3756 args.msg = g_convert(message, len, "ISO-8859-1", "UTF-8", NULL, &len, &err); |
| 3757 if (err) { | |
| 3758 debug_printf("conversion error: %s\n", err->message); | |
| 3642 | 3759 debug_printf("Someone tell Ethan his 8859-1 detection is wrong\n"); |
| 3760 args.flags ^= AIM_IMFLAGS_ISO_8859_1 | AIM_IMFLAGS_UNICODE; | |
| 3761 len = strlen(message); | |
| 3659 | 3762 args.msg = g_convert(message, len, "UCS-2BE", "UTF8", NULL, &len, &err); |
| 3763 if (err) { | |
| 4194 | 3764 debug_printf("Error in unicode fallback: %s\n", err->message); |
| 3659 | 3765 } |
| 3642 | 3766 } |
| 3767 } else { | |
| 3768 args.msg = message; | |
| 3769 } | |
| 3770 args.msglen = len; | |
| 4269 | 3771 |
| 3008 | 3772 ret = aim_send_im_ext(odata->sess, &args); |
| 2086 | 3773 } |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3774 if (ret >= 0) |
|
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3775 return 1; |
|
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2297
diff
changeset
|
3776 return ret; |
| 2086 | 3777 } |
| 3778 | |
| 3779 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
| 3780 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
|
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3781 if (odata->icq) |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3782 aim_icq_getsimpleinfo(odata->sess, name); |
|
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2734
diff
changeset
|
3783 else |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3784 /* people want the away message on the top, so we get the away message |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3785 * first and then get the regular info, since it's too difficult to |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3786 * insert in the middle. i hate people. */ |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3787 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3788 } |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3789 |
| 3212 | 3790 static void oscar_get_away(struct gaim_connection *g, char *who) { |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
3791 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 3212 | 3792 if (odata->icq) { |
| 4349 | 3793 struct buddy *budlight = find_buddy(g->user, who); |
| 3212 | 3794 if (budlight) |
| 3595 | 3795 if ((budlight->uc & 0xffff0000) >> 16) |
| 3212 | 3796 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
| 3595 | 3797 aim_send_im_ch2_geticqmessage(odata->sess, who, (budlight->uc & 0xffff0000) >> 16); |
| 3212 | 3798 else |
| 3799 debug_printf("Error: Remote client does not support retrieval of status messages.\n"); | |
| 3800 else | |
| 3801 debug_printf("Error: The user %s has no status message, therefore not requesting.\n", who); | |
| 3802 else | |
| 3803 debug_printf("Error: Could not find %s in local contact list, therefore unable to request status message.\n", who); | |
| 3804 } else | |
| 3805 aim_getinfo(odata->sess, odata->conn, who, AIM_GETINFO_GENERALINFO); | |
| 2086 | 3806 } |
| 3807 | |
| 2920 | 3808 static void oscar_get_caps(struct gaim_connection *g, char *name) { |
| 3809 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
| 3810 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_CAPABILITIES); | |
| 3811 } | |
| 3812 | |
| 3466 | 3813 static void oscar_set_dir(struct gaim_connection *g, const char *first, const char *middle, const char *last, |
| 3814 const char *maiden, const char *city, const char *state, const char *country, int web) { | |
| 4230 | 3815 /* AAA: some of these things are wrong, but i'm lazy */ |
| 2086 | 3816 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 3817 aim_setdirectoryinfo(odata->sess, odata->conn, first, middle, last, | |
| 3818 maiden, NULL, NULL, city, state, NULL, 0, web); | |
| 3819 } | |
| 3820 | |
| 3821 | |
| 3822 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
| 3823 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
| 3824 aim_bos_setidle(odata->sess, odata->conn, time); | |
| 3825 } | |
| 3826 | |
| 3827 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
| 3828 struct oscar_data *odata = (struct oscar_data *)g->proto_data; | |
| 4151 | 3829 gchar *inforeal, *unicode; |
| 3830 fu32_t flags; | |
| 3831 int unicode_len; | |
| 2993 | 3832 |
| 3833 if (odata->rights.maxsiglen == 0) | |
| 3427 | 3834 do_error_dialog(_("Unable to set AIM profile."), |
| 3835 _("You have probably requested to set your profile before the login procedure completed. " | |
| 3836 "Your profile remains unset; try setting it again when you are fully connected."), GAIM_ERROR); | |
| 2993 | 3837 |
| 3838 if (strlen(info) > odata->rights.maxsiglen) { | |
| 3839 gchar *errstr; | |
| 3840 | |
| 3427 | 3841 errstr = g_strdup_printf(_("The maximum profile length of %d bytes has been exceeded. " |
| 3842 "Gaim has truncated and set it."), odata->rights.maxsiglen); | |
| 3843 do_error_dialog("Profile too long.", errstr, GAIM_WARNING); | |
| 2993 | 3844 |
| 3845 g_free(errstr); | |
| 3846 } | |
| 3847 | |
| 3848 inforeal = g_strndup(info, odata->rights.maxsiglen); | |
| 3849 | |
| 3458 | 3850 if (odata->icq) |
| 4151 | 3851 aim_bos_setprofile(odata->sess, odata->conn, NULL, NULL, 0, NULL, NULL, 0, caps_icq); |
| 3852 else { | |
| 3853 flags = check_encoding(inforeal); | |
| 3854 | |
| 3855 if (flags == 0) { | |
| 3856 aim_bos_setprofile(odata->sess, odata->conn, "us-ascii", inforeal, strlen (inforeal), | |
| 3857 NULL, NULL, 0, caps_aim); | |
| 3858 } else { | |
| 3859 unicode = g_convert (inforeal, strlen(inforeal), "UCS-2BE", "UTF-8", NULL, | |
| 3860 &unicode_len, NULL); | |
| 3861 aim_bos_setprofile(odata->sess, odata->conn, "unicode-2-0", unicode, unicode_len, | |
| 3862 NULL, NULL, 0, caps_aim); | |
| 3863 g_free(unicode); | |
| 3864 } | |
| 3865 } | |
| 2993 | 3866 g_free(inforeal); |
| 3867 | |
| 3868 return; | |
| 2086 | 3869 } |
| 3870 | |
| 2993 | 3871 static void oscar_set_away_aim(struct gaim_connection *gc, struct oscar_data *od, const char *message) |
| 3872 { | |
| 4151 | 3873 fu32_t flags; |
| 3874 char *unicode; | |
| 3875 int unicode_len; | |
| 2993 | 3876 |
| 3877 if (od->rights.maxawaymsglen == 0) | |
| 3427 | 3878 do_error_dialog(_("Unable to set AIM away message."), |
| 3879 _("You have probably requested to set your away message before the login procedure completed. " | |
| 3880 "You remain in a \"present\" state; try setting it again when you are fully connected."), GAIM_ERROR); | |
| 3881 | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3882 if (gc->away) { |
| 2993 | 3883 g_free(gc->away); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3884 gc->away = NULL; |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3885 } |
| 2993 | 3886 |
| 3887 if (!message) { | |
| 4151 | 3888 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, NULL, "", 0, caps_aim); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3889 return; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3890 } |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3891 |
| 2993 | 3892 if (strlen(message) > od->rights.maxawaymsglen) { |
| 3893 gchar *errstr; | |
| 3894 | |
| 3427 | 3895 errstr = g_strdup_printf(_("The away message length of %d bytes has been exceeded. " |
| 3896 "Gaim has truncated it and set you away."), od->rights.maxawaymsglen); | |
| 3897 do_error_dialog("Away message too long.", errstr, GAIM_WARNING); | |
| 2993 | 3898 g_free(errstr); |
| 3899 } | |
| 3900 | |
| 3901 gc->away = g_strndup(message, od->rights.maxawaymsglen); | |
| 4151 | 3902 flags = check_encoding(message); |
| 3903 | |
| 3904 if (flags == 0) { | |
| 3905 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "us-ascii", gc->away, strlen(gc->away), | |
| 3906 caps_aim); | |
| 3907 } else { | |
| 3908 unicode = g_convert(message, strlen(message), "UCS-2BE", "UTF-8", NULL, &unicode_len, NULL); | |
| 3909 aim_bos_setprofile(od->sess, od->conn, NULL, NULL, 0, "unicode-2-0", unicode, unicode_len, | |
| 3910 caps_aim); | |
| 3911 g_free(unicode); | |
| 3912 } | |
| 2993 | 3913 |
| 3914 return; | |
| 3915 } | |
| 3916 | |
| 3917 static void oscar_set_away_icq(struct gaim_connection *gc, struct oscar_data *od, const char *state, const char *message) | |
| 3918 { | |
| 3919 | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3920 if (gc->away) { |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3921 g_free(gc->away); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3922 gc->away = NULL; |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3923 } |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3924 |
| 4342 | 3925 if (strcmp(state, _("Invisible"))) { |
| 4349 | 3926 if (aim_ssi_getpermdeny(od->sess->ssi.local) != gc->user->permdeny) |
| 3927 aim_ssi_setpermdeny(od->sess, od->conn, gc->user->permdeny, | |
| 3928 0xffffffff); | |
| 3929 gc->user->permdeny = 4; | |
| 4342 | 3930 } else { |
| 3931 if (aim_ssi_getpermdeny(od->sess->ssi.local) != 0x03) | |
| 3932 aim_ssi_setpermdeny(od->sess, od->conn, 0x03, 0xffffffff); | |
| 4349 | 3933 gc->user->permdeny = 3; |
| 4342 | 3934 } |
| 3935 | |
| 3936 if (!strcmp(state, _("Online"))) | |
|
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
3937 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
| 4342 | 3938 else if (!strcmp(state, _("Away"))) { |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3939 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3940 gc->away = g_strdup(""); |
| 4342 | 3941 } else if (!strcmp(state, _("Do Not Disturb"))) { |
| 3212 | 3942 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_DND | AIM_ICQ_STATE_BUSY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3943 gc->away = g_strdup(""); |
| 4342 | 3944 } else if (!strcmp(state, _("Not Available"))) { |
| 3101 | 3945 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3946 gc->away = g_strdup(""); |
| 4342 | 3947 } else if (!strcmp(state, _("Occupied"))) { |
| 3212 | 3948 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_AWAY | AIM_ICQ_STATE_BUSY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3949 gc->away = g_strdup(""); |
| 4342 | 3950 } else if (!strcmp(state, _("Free For Chat"))) { |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3951 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_CHAT); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3952 gc->away = g_strdup(""); |
| 4342 | 3953 } else if (!strcmp(state, _("Invisible"))) { |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
3954 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_INVISIBLE); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3955 gc->away = g_strdup(""); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3956 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
| 2998 | 3957 if (message) { |
| 3101 | 3958 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_OUT | AIM_ICQ_STATE_AWAY); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4102
diff
changeset
|
3959 gc->away = g_strdup(""); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3960 } else { |
|
2866
6d62d4520460
[gaim-migrate @ 2879]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2865
diff
changeset
|
3961 aim_setextstatus(od->sess, od->conn, AIM_ICQ_STATE_NORMAL); |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
3962 } |
| 2086 | 3963 } |
| 2993 | 3964 |
| 3965 return; | |
| 3966 } | |
| 3967 | |
| 3968 static void oscar_set_away(struct gaim_connection *gc, char *state, char *message) | |
| 3969 { | |
| 3970 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 3971 | |
| 3972 if (od->icq) | |
| 3973 oscar_set_away_icq(gc, od, state, message); | |
| 3974 else | |
| 3975 oscar_set_away_aim(gc, od, message); | |
| 3976 | |
| 3977 return; | |
| 2086 | 3978 } |
| 3979 | |
| 4230 | 3980 static void oscar_warn(struct gaim_connection *gc, char *name, int anon) { |
| 3981 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; | |
| 2113 | 3982 aim_send_warning(odata->sess, odata->conn, name, anon ? AIM_WARN_ANON : 0); |
| 2086 | 3983 } |
| 3984 | |
| 4230 | 3985 static void oscar_dir_search(struct gaim_connection *gc, const char *first, const char *middle, const char *last, |
| 3466 | 3986 const char *maiden, const char *city, const char *state, const char *country, const char *email) { |
| 4230 | 3987 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 2086 | 3988 if (strlen(email)) |
| 3989 aim_usersearch_address(odata->sess, odata->conn, email); | |
| 3990 } | |
| 3991 | |
| 4230 | 3992 static void oscar_add_buddy(struct gaim_connection *gc, const char *name) { |
| 3993 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 3994 #ifdef NOSSI | |
| 3995 aim_add_buddy(od->sess, od->conn, name); | |
| 3996 #else | |
| 3997 if ((od->sess->ssi.received_data) && !(aim_ssi_itemlist_exists(od->sess->ssi.local, name))) { | |
| 4349 | 3998 struct buddy *buddy = find_buddy(gc->user, name); |
| 3999 struct group *group = find_group_by_buddy(buddy); | |
| 4230 | 4000 if (buddy && group) { |
| 4001 debug_printf("ssi: adding buddy %s to group %s\n", name, group->name); | |
| 4002 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 0); | |
| 4003 } | |
| 4004 } | |
| 4005 #endif | |
| 4006 } | |
| 4007 | |
| 4008 static void oscar_add_buddies(struct gaim_connection *gc, GList *buddies) { | |
| 4009 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4010 #ifdef NOSSI | |
| 4011 char buf[MSG_LEN]; | |
| 4012 int n=0; | |
| 4013 while (buddies) { | |
| 4014 if (n > MSG_LEN - 18) { | |
| 4015 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
| 4016 n = 0; | |
| 3092 | 4017 } |
| 4230 | 4018 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); |
| 4019 buddies = buddies->next; | |
| 4020 } | |
| 4021 aim_bos_setbuddylist(od->sess, od->conn, buf); | |
| 4022 #else | |
| 4023 if (od->sess->ssi.received_data) { | |
| 4024 while (buddies) { | |
| 4349 | 4025 struct buddy *buddy = find_buddy(gc->user, (const char *)buddies->data); |
| 4026 struct group *group = find_group_by_buddy(buddy); | |
| 4230 | 4027 if (buddy && group) { |
| 4028 debug_printf("ssi: adding buddy %s to group %s\n", (const char *)buddies->data, group->name); | |
| 4029 aim_ssi_addbuddy(od->sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 0); | |
| 4030 } | |
| 4031 buddies = buddies->next; | |
| 4032 } | |
| 4033 } | |
| 4034 #endif | |
| 4035 } | |
| 4036 | |
| 4037 static void oscar_remove_buddy(struct gaim_connection *gc, char *name, char *group) { | |
| 4038 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4039 #ifdef NOSSI | |
| 4040 aim_remove_buddy(od->sess, od->conn, name); | |
| 4041 #else | |
| 4042 if (od->sess->ssi.received_data) { | |
| 4043 debug_printf("ssi: deleting buddy %s from group %s\n", name, group); | |
| 4044 aim_ssi_delbuddy(od->sess, od->conn, name, group); | |
| 4045 } | |
| 4046 #endif | |
| 4047 } | |
| 4048 | |
| 4049 static void oscar_remove_buddies(struct gaim_connection *gc, GList *buddies, const char *group) { | |
| 4050 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4051 #ifdef NOSSI | |
| 4052 GList *cur; | |
| 4053 for (cur=buddies; cur; cur=cur->next) | |
| 4054 aim_remove_buddy(od->sess, od->conn, cur->data); | |
| 4055 #else | |
| 4056 if (od->sess->ssi.received_data) { | |
| 3092 | 4057 while (buddies) { |
| 4230 | 4058 debug_printf("ssi: deleting buddy %s from group %s\n", (char *)buddies->data, group); |
| 4059 aim_ssi_delbuddy(od->sess, od->conn, buddies->data, group); | |
| 3092 | 4060 buddies = buddies->next; |
| 4061 } | |
| 4230 | 4062 } |
| 4063 #endif | |
| 4064 } | |
| 4065 | |
| 4066 #ifndef NOSSI | |
| 4269 | 4067 static void oscar_move_buddy(struct gaim_connection *gc, const char *name, const char *old_group, const char *new_group) { |
| 4068 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4303 | 4069 if (od->sess->ssi.received_data && strcmp(old_group, new_group)) { |
| 4269 | 4070 debug_printf("ssi: moving buddy %s from group %s to group %s\n", name, old_group, new_group); |
| 4071 aim_ssi_movebuddy(od->sess, od->conn, old_group, new_group, name); | |
| 4072 } | |
| 4073 } | |
| 4074 | |
| 4075 static void oscar_alias_buddy(struct gaim_connection *gc, const char *name, const char *alias) { | |
| 4076 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4077 if (od->sess->ssi.received_data) { | |
| 4078 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, name); | |
| 4079 if (gname) { | |
| 4080 debug_printf("ssi: changing the alias for buddy %s to %s\n", name, alias); | |
| 4081 aim_ssi_aliasbuddy(od->sess, od->conn, gname, name, alias); | |
| 4082 } | |
| 4083 } | |
| 4084 } | |
| 4085 | |
| 4230 | 4086 static void oscar_rename_group(struct gaim_connection *g, const char *old_group, const char *new_group, GList *members) { |
| 4087 struct oscar_data *od = (struct oscar_data *)g->proto_data; | |
| 4088 | |
| 4089 if (od->sess->ssi.received_data) { | |
| 4090 if (aim_ssi_itemlist_finditem(od->sess->ssi.local, new_group, NULL, AIM_SSI_TYPE_GROUP)) { | |
| 4091 oscar_remove_buddies(g, members, old_group); | |
| 4092 oscar_add_buddies(g, members); | |
| 4093 debug_printf("ssi: moved all buddies from group %s to %s\n", old_group, new_group); | |
| 4094 } else { | |
| 4095 aim_ssi_rename_group(od->sess, od->conn, old_group, new_group); | |
| 4096 debug_printf("ssi: renamed group %s to %s\n", old_group, new_group); | |
| 2995 | 4097 } |
| 4098 } | |
| 4099 } | |
| 4100 | |
| 2991 | 4101 static int gaim_ssi_parserights(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4230 | 4102 struct gaim_connection *gc = sess->aux_data; |
| 4103 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4104 int numtypes, i; | |
| 4105 fu16_t *maxitems; | |
| 2991 | 4106 va_list ap; |
| 4107 | |
| 4108 va_start(ap, fr); | |
| 4230 | 4109 numtypes = va_arg(ap, int); |
| 4110 maxitems = va_arg(ap, fu16_t *); | |
| 2991 | 4111 va_end(ap); |
| 4112 | |
| 4230 | 4113 debug_printf("ssi rights:"); |
| 4114 for (i=0; i<numtypes; i++) | |
| 4317 | 4115 debug_printf(" max type 0x%04x = %hx, ", i, maxitems[i]); |
| 4116 debug_printf("\n"); | |
| 4230 | 4117 |
| 4118 if (numtypes >= 0) | |
| 4119 od->rights.maxbuddies = maxitems[0]; | |
| 4120 if (numtypes >= 1) | |
| 4121 od->rights.maxgroups = maxitems[1]; | |
| 4122 if (numtypes >= 2) | |
| 4123 od->rights.maxpermits = maxitems[2]; | |
| 4124 if (numtypes >= 3) | |
| 4125 od->rights.maxdenies = maxitems[3]; | |
| 2991 | 4126 |
| 4127 return 1; | |
| 4128 } | |
| 4129 | |
| 4130 static int gaim_ssi_parselist(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4131 struct gaim_connection *gc = sess->aux_data; | |
| 4230 | 4132 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 2995 | 4133 struct aim_ssi_item *curitem; |
| 2991 | 4134 int tmp; |
| 4230 | 4135 /* AAA - use these? |
| 4136 va_list ap; | |
| 4137 | |
| 4138 va_start(ap, fr); | |
| 4139 fmtver = (fu16_t)va_arg(ap, int); | |
| 4140 numitems = (fu16_t)va_arg(ap, int); | |
| 4141 items = va_arg(ap, struct aim_ssi_item); | |
| 4142 timestamp = va_arg(ap, fu32_t); | |
| 4143 va_end(ap); */ | |
| 2991 | 4144 |
| 4145 debug_printf("ssi: syncing local list and server list\n"); | |
| 4146 | |
| 4147 /* Clean the buddy list */ | |
| 4443 | 4148 /* aim_ssi_cleanlist(sess, fr->conn); */ |
| 2991 | 4149 |
| 4150 /* Add from server list to local list */ | |
| 4151 tmp = 0; | |
| 4230 | 4152 for (curitem=sess->ssi.local; curitem; curitem=curitem->next) { |
| 2991 | 4153 switch (curitem->type) { |
| 4230 | 4154 case 0x0000: { /* Buddy */ |
| 4251 | 4155 if (curitem->name) { |
| 4292 | 4156 char *gname = aim_ssi_itemlist_findparentname(sess->ssi.local, curitem->name); |
| 4282 | 4157 char *alias = aim_ssi_getalias(sess->ssi.local, gname, curitem->name); |
| 4349 | 4158 struct buddy *buddy = find_buddy(gc->user, curitem->name); |
| 4282 | 4159 if (buddy) { |
| 4292 | 4160 /* Get server stored alias */ |
| 4282 | 4161 if (alias) |
| 4162 strcpy(buddy->alias, alias); | |
| 4163 } else { | |
| 4251 | 4164 debug_printf("ssi: adding buddy %s to group %s to local list\n", curitem->name, gname); |
| 4349 | 4165 add_buddy(gc->user, (gname ? gname : "orphans"), curitem->name, alias); |
| 4251 | 4166 tmp++; |
| 4167 } | |
| 4282 | 4168 free(alias); |
| 2991 | 4169 } |
| 4230 | 4170 } break; |
| 4171 | |
| 4172 case 0x0001: { /* Group */ | |
| 4282 | 4173 /* Shouldn't add empty groups */ |
| 4230 | 4174 } break; |
| 4175 | |
| 4176 case 0x0002: { /* Permit buddy */ | |
| 2991 | 4177 if (curitem->name) { |
| 4230 | 4178 /* if (!find_permdeny_by_name(gc->permit, curitem->name)) { AAA */ |
| 2991 | 4179 GSList *list; |
| 4349 | 4180 for (list=gc->user->permit; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 4181 if (!list) { |
| 2995 | 4182 debug_printf("ssi: adding permit buddy %s to local list\n", curitem->name); |
| 4349 | 4183 gaim_privacy_permit_add(gc->user, curitem->name); |
| 2991 | 4184 build_allow_list(); |
| 4185 tmp++; | |
| 4186 } | |
| 4187 } | |
| 4230 | 4188 } break; |
| 4189 | |
| 4190 case 0x0003: { /* Deny buddy */ | |
| 2991 | 4191 if (curitem->name) { |
| 4192 GSList *list; | |
| 4349 | 4193 for (list=gc->user->deny; (list && aim_sncmp(curitem->name, list->data)); list=list->next); |
| 2991 | 4194 if (!list) { |
| 2995 | 4195 debug_printf("ssi: adding deny buddy %s to local list\n", curitem->name); |
| 4349 | 4196 gaim_privacy_deny_add(gc->user, curitem->name); |
| 2991 | 4197 build_block_list(); |
| 4198 tmp++; | |
| 4199 } | |
| 4200 } | |
| 4230 | 4201 } break; |
| 4202 | |
| 4203 case 0x0004: { /* Permit/deny setting */ | |
| 2991 | 4204 if (curitem->data) { |
| 4205 fu8_t permdeny; | |
| 4349 | 4206 if ((permdeny = aim_ssi_getpermdeny(sess->ssi.local)) && (permdeny != gc->user->permdeny)) { |
| 4207 debug_printf("ssi: changing permdeny from %d to %hhu\n", gc->user->permdeny, permdeny); | |
| 4208 gc->user->permdeny = permdeny; | |
| 4209 if (od->icq && gc->user->permdeny == 0x03) { | |
| 4342 | 4210 serv_set_away(gc, "Invisible", ""); |
| 4211 } | |
| 2995 | 4212 tmp++; |
| 2991 | 4213 } |
| 4214 } | |
| 4230 | 4215 } break; |
| 4216 | |
| 4217 case 0x0005: { /* Presence setting */ | |
| 3109 | 4218 /* We don't want to change Gaim's setting because it applies to all accounts */ |
| 4230 | 4219 } break; |
| 2991 | 4220 } /* End of switch on curitem->type */ |
| 4221 } /* End of for loop */ | |
| 4230 | 4222 |
| 4223 /* If changes were made, then flush buddy list to file */ | |
| 2991 | 4224 if (tmp) |
| 4349 | 4225 gaim_blist_save(); |
| 2991 | 4226 |
| 4227 /* Add from local list to server list */ | |
| 4228 if (gc) { | |
| 3017 | 4229 GSList *cur; |
| 4230 | |
| 2991 | 4231 /* Buddies */ |
| 4349 | 4232 for (cur=groups; cur; cur=g_slist_next(cur)) { |
| 4299 | 4233 GSList *curb; |
| 4234 struct group *group = cur->data; | |
| 4235 for (curb=group->members; curb; curb=curb->next) { | |
| 4236 struct buddy *buddy = curb->data; | |
| 4349 | 4237 if(buddy->user == gc->user) { |
| 4238 if (aim_ssi_itemlist_exists(sess->ssi.local, buddy->name)) { | |
| 4239 /* Store local alias on server */ | |
| 4240 char *alias = aim_ssi_getalias(sess->ssi.local, group->name, buddy->name); | |
| 4241 if (!alias && buddy->alias[0]) | |
| 4242 aim_ssi_aliasbuddy(sess, od->conn, group->name, buddy->name, buddy->alias); | |
| 4243 free(alias); | |
| 4244 } else { | |
| 4245 debug_printf("ssi: adding buddy %s from local list to server list\n", buddy->name); | |
| 4246 aim_ssi_addbuddy(sess, od->conn, buddy->name, group->name, get_buddy_alias_only(buddy), NULL, NULL, 0); | |
| 4247 } | |
| 4230 | 4248 } |
| 4292 | 4249 } |
| 2991 | 4250 } |
| 4251 | |
| 4252 /* Permit list */ | |
| 4349 | 4253 if (gc->user->permit) { |
| 4254 for (cur=gc->user->permit; cur; cur=cur->next) | |
| 4230 | 4255 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_PERMIT)) { |
| 4256 debug_printf("ssi: adding permit %s from local list to server list\n", (char *)cur->data); | |
| 4292 | 4257 aim_ssi_addpermit(sess, od->conn, cur->data); |
| 4230 | 4258 } |
| 2991 | 4259 } |
| 4260 | |
| 4261 /* Deny list */ | |
| 4349 | 4262 if (gc->user->deny) { |
| 4263 for (cur=gc->user->deny; cur; cur=cur->next) | |
| 4230 | 4264 if (!aim_ssi_itemlist_finditem(sess->ssi.local, NULL, cur->data, AIM_SSI_TYPE_DENY)) { |
| 4265 debug_printf("ssi: adding deny %s from local list to server list\n", (char *)cur->data); | |
| 4292 | 4266 aim_ssi_adddeny(sess, od->conn, cur->data); |
| 4230 | 4267 } |
| 2991 | 4268 } |
| 3109 | 4269 |
| 4270 /* Presence settings (idle time visibility) */ | |
| 4230 | 4271 if ((tmp = aim_ssi_getpresence(sess->ssi.local)) != 0xFFFFFFFF) |
| 3109 | 4272 if (report_idle && !(tmp & 0x400)) |
| 4273 aim_ssi_setpresence(sess, fr->conn, tmp | 0x400); | |
| 3210 | 4274 |
| 4275 /* Check for maximum number of buddies */ | |
| 4349 | 4276 for (cur=groups, tmp=0; cur; cur=g_slist_next(cur)) { |
| 3214 | 4277 struct group* gr = (struct group*)cur->data; |
| 4349 | 4278 GSList *buds = gr->members; |
| 4279 while(buds) { | |
| 4280 struct buddy *b = buds->data; | |
| 4281 if(b->user == gc->user) | |
| 4282 tmp++; | |
| 4283 buds = buds->next; | |
| 4284 } | |
| 3214 | 4285 } |
| 4230 | 4286 if (tmp > od->rights.maxbuddies) { |
| 3210 | 4287 char *dialog_msg = g_strdup_printf(_("The maximum number of buddies allowed in your buddy list is %d, and you have %d." |
| 4288 " Until you are below the limit, some buddies will not show up as online."), | |
| 4230 | 4289 od->rights.maxbuddies, tmp); |
| 3427 | 4290 do_error_dialog("Maximum buddy list length exceeded.", dialog_msg, GAIM_WARNING); |
| 3210 | 4291 g_free(dialog_msg); |
| 4292 } | |
| 3214 | 4293 |
| 3210 | 4294 } /* end if (gc) */ |
| 3092 | 4295 |
| 4342 | 4296 /* Activate SSI */ |
| 4297 /* Sending the enable causes other people to be able to see you, and you to see them */ | |
| 4298 /* Make sure your privacy setting/invisibility is set how you want it before this! */ | |
| 4299 debug_printf("ssi: activating server-stored buddy list\n"); | |
| 4300 aim_ssi_enable(sess, fr->conn); | |
| 4301 | |
| 2991 | 4302 return 1; |
| 2086 | 4303 } |
| 4230 | 4304 |
| 4305 static int gaim_ssi_parseack(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4306 struct gaim_connection *gc = sess->aux_data; | |
| 4307 va_list ap; | |
| 4308 struct aim_ssi_tmp *retval; | |
| 4309 | |
| 4310 va_start(ap, fr); | |
| 4311 retval = va_arg(ap, struct aim_ssi_tmp *); | |
| 4312 va_end(ap); | |
| 4313 | |
| 4314 while (retval) { | |
| 4315 debug_printf("ssi: status is 0x%04hx for a 0x%04hx action with name %s\n", retval->ack, retval->action, retval->item ? retval->item->name : "no item"); | |
| 4316 | |
| 4317 if (retval->ack != 0xffff) | |
| 4318 switch (retval->ack) { | |
| 4319 case 0x0000: { /* added successfully */ | |
| 4320 } break; | |
| 4321 | |
| 4322 case 0x000e: { /* contact requires authorization */ | |
| 4269 | 4323 if (retval->action == AIM_CB_SSI_ADD) |
| 4324 gaim_auth_sendrequest(gc, retval->name); | |
| 4230 | 4325 } break; |
| 4326 | |
| 4327 default: { /* La la la */ | |
| 4328 debug_printf("ssi: Action 0x%04hx was unsuccessful with error 0x%04hx\n", retval->action, retval->ack); | |
| 4329 /* Should remove buddy from local list and give an error message? */ | |
| 4330 } break; | |
| 4331 } | |
| 4332 | |
| 4333 retval = retval->next; | |
| 4334 } | |
| 4335 | |
| 4336 return 1; | |
| 4337 } | |
| 4338 | |
| 4339 static int gaim_ssi_authgiven(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4340 struct gaim_connection *gc = sess->aux_data; | |
| 4341 va_list ap; | |
| 4342 char *sn, *msg; | |
| 4236 | 4343 gchar *dialog_msg, *nombre; |
| 4230 | 4344 struct name_data *data; |
| 4236 | 4345 struct buddy *buddy; |
| 4230 | 4346 |
| 4347 va_start(ap, fr); | |
| 4348 sn = va_arg(ap, char *); | |
| 4349 msg = va_arg(ap, char *); | |
| 4350 va_end(ap); | |
| 4351 | |
| 4352 debug_printf("ssi: %s has given you permission to add him to your buddy list\n", sn); | |
| 4353 | |
| 4349 | 4354 buddy = find_buddy(gc->user, sn); |
| 4236 | 4355 if (buddy && (get_buddy_alias_only(buddy))) |
| 4356 nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy)); | |
| 4357 else | |
| 4358 nombre = g_strdup(sn); | |
| 4359 | |
| 4360 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 | 4361 data = g_new(struct name_data, 1); |
| 4362 data->gc = gc; | |
| 4363 data->name = g_strdup(sn); | |
| 4364 data->nick = NULL; | |
| 4249 | 4365 do_ask_dialog(_("Authorization Given"), dialog_msg, data, _("Yes"), gaim_icq_contactadd, _("No"), gaim_free_name_data, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 4236 | 4366 |
| 4230 | 4367 g_free(dialog_msg); |
| 4236 | 4368 g_free(nombre); |
| 4230 | 4369 |
| 4370 return 1; | |
| 4371 } | |
| 4372 | |
| 4373 static int gaim_ssi_authrequest(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4374 struct gaim_connection *gc = sess->aux_data; | |
| 4375 va_list ap; | |
| 4376 char *sn, *msg; | |
| 4236 | 4377 gchar *dialog_msg, *nombre; |
| 4230 | 4378 struct name_data *data; |
| 4236 | 4379 struct buddy *buddy; |
| 4230 | 4380 |
| 4381 va_start(ap, fr); | |
| 4382 sn = va_arg(ap, char *); | |
| 4383 msg = va_arg(ap, char *); | |
| 4384 va_end(ap); | |
| 4385 | |
| 4386 debug_printf("ssi: received authorization request from %s\n", sn); | |
| 4387 | |
| 4349 | 4388 buddy = find_buddy(gc->user, sn); |
| 4236 | 4389 if (buddy && (get_buddy_alias_only(buddy))) |
| 4390 nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy)); | |
| 4391 else | |
| 4392 nombre = g_strdup(sn); | |
| 4393 | |
| 4337 | 4394 dialog_msg = g_strdup_printf(_("The user %s wants to add you to their buddy list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
| 4230 | 4395 data = g_new(struct name_data, 1); |
| 4396 data->gc = gc; | |
| 4397 data->name = g_strdup(sn); | |
| 4398 data->nick = NULL; | |
| 4337 | 4399 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_auth_grant, _("Deny"), gaim_auth_dontgrant_msgprompt, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 4236 | 4400 |
| 4230 | 4401 g_free(dialog_msg); |
| 4236 | 4402 g_free(nombre); |
| 4230 | 4403 |
| 4404 return 1; | |
| 4405 } | |
| 4406 | |
| 4407 static int gaim_ssi_authreply(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4236 | 4408 struct gaim_connection *gc = sess->aux_data; |
| 4230 | 4409 va_list ap; |
| 4410 char *sn, *msg; | |
| 4236 | 4411 gchar *dialog_msg, *nombre; |
| 4230 | 4412 fu8_t reply; |
| 4236 | 4413 struct buddy *buddy; |
| 4230 | 4414 |
| 4415 va_start(ap, fr); | |
| 4416 sn = va_arg(ap, char *); | |
| 4417 reply = (fu8_t)va_arg(ap, int); | |
| 4418 msg = va_arg(ap, char *); | |
| 4419 va_end(ap); | |
| 4420 | |
| 4236 | 4421 debug_printf("ssi: received authorization reply from %s. Reply is 0x%04hhx\n", sn, reply); |
| 4422 | |
| 4349 | 4423 buddy = find_buddy(gc->user, sn); |
| 4236 | 4424 if (buddy && (get_buddy_alias_only(buddy))) |
| 4425 nombre = g_strdup_printf("%s (%s)", sn, get_buddy_alias_only(buddy)); | |
| 4426 else | |
| 4427 nombre = g_strdup(sn); | |
| 4428 | |
| 4230 | 4429 if (reply) { |
| 4430 /* Granted */ | |
| 4236 | 4431 dialog_msg = g_strdup_printf(_("The user %s has granted your request to add them to your contact list."), nombre); |
| 4230 | 4432 do_error_dialog(_("Authorization Granted"), dialog_msg, GAIM_INFO); |
| 4433 } else { | |
| 4434 /* Denied */ | |
| 4236 | 4435 dialog_msg = g_strdup_printf(_("The user %s has denied your request to add them to your contact list for the following reason:\n%s"), nombre, msg ? msg : _("No reason given.")); |
| 4230 | 4436 do_error_dialog(_("Authorization Denied"), dialog_msg, GAIM_INFO); |
| 4437 } | |
| 4438 g_free(dialog_msg); | |
| 4236 | 4439 g_free(nombre); |
| 4230 | 4440 |
| 4441 return 1; | |
| 4442 } | |
| 4443 | |
| 4444 static int gaim_ssi_gotadded(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4445 struct gaim_connection *gc = sess->aux_data; | |
| 4446 va_list ap; | |
| 4447 char *sn; | |
| 4236 | 4448 struct buddy *buddy; |
| 4230 | 4449 |
| 4450 va_start(ap, fr); | |
| 4451 sn = va_arg(ap, char *); | |
| 4452 va_end(ap); | |
| 4453 | |
| 4349 | 4454 buddy = find_buddy(gc->user, sn); |
| 4230 | 4455 debug_printf("ssi: %s added you to their buddy list\n", sn); |
| 4236 | 4456 show_got_added(gc, NULL, sn, (buddy ? get_buddy_alias_only(buddy) : NULL), NULL); |
| 4230 | 4457 |
| 4458 return 1; | |
| 4459 } | |
| 4269 | 4460 #endif |
| 2086 | 4461 |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4462 static GList *oscar_chat_info(struct gaim_connection *gc) { |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4463 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4464 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4465 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4466 pce = g_new0(struct proto_chat_entry, 1); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4467 pce->label = _("Join what group:"); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4468 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4469 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4470 pce = g_new0(struct proto_chat_entry, 1); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4471 pce->label = _("Exchange:"); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4472 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4473 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4474 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4475 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4476 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4477 return m; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4478 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4479 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4480 static void oscar_join_chat(struct gaim_connection *g, GList *data) { |
| 2086 | 4481 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4482 aim_conn_t *cur; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4483 char *name; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4484 int *exchange; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4485 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4486 if (!data || !data->next) |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4487 return; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4488 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4489 name = data->data; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4490 exchange = data->next->data; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4491 |
| 2086 | 4492 debug_printf("Attempting to join chat room %s.\n", name); |
| 4493 if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { | |
| 4494 debug_printf("chatnav exists, creating room\n"); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
4495 aim_chatnav_createroom(odata->sess, cur, name, *exchange); |
| 2086 | 4496 } else { |
| 4497 /* this gets tricky */ | |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4498 struct create_room *cr = g_new0(struct create_room, 1); |
| 2086 | 4499 debug_printf("chatnav does not exist, opening chatnav\n"); |
|
2822
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4500 cr->exchange = *exchange; |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4501 cr->name = g_strdup(name); |
|
744df95bf123
[gaim-migrate @ 2835]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2821
diff
changeset
|
4502 odata->create_rooms = g_slist_append(odata->create_rooms, cr); |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
4503 aim_reqservice(odata->sess, odata->conn, AIM_CONN_TYPE_CHATNAV); |
| 2086 | 4504 } |
| 4505 } | |
| 4506 | |
| 3466 | 4507 static void oscar_chat_invite(struct gaim_connection *g, int id, const char *message, const char *name) { |
| 2086 | 4508 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 4509 struct chat_connection *ccon = find_oscar_chat(g, id); | |
| 4510 | |
| 4511 if (!ccon) | |
| 4512 return; | |
| 4513 | |
| 4514 aim_chat_invite(odata->sess, odata->conn, name, message ? message : "", | |
| 4515 ccon->exchange, ccon->name, 0x0); | |
| 4516 } | |
| 4517 | |
| 4518 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
| 4519 struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL; | |
| 4520 GSList *bcs = g->buddy_chats; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4521 struct gaim_conversation *b = NULL; |
| 2086 | 4522 struct chat_connection *c = NULL; |
| 4523 int count = 0; | |
| 4524 | |
| 4525 while (bcs) { | |
| 4526 count++; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4527 b = (struct gaim_conversation *)bcs->data; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4528 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
| 2086 | 4529 break; |
| 4530 bcs = bcs->next; | |
| 4531 b = NULL; | |
| 4532 } | |
| 4533 | |
| 4534 if (!b) | |
| 4535 return; | |
| 4536 | |
| 4537 debug_printf("Attempting to leave room %s (currently in %d rooms)\n", b->name, count); | |
| 4538 | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4539 c = find_oscar_chat(g, gaim_chat_get_id(GAIM_CHAT(b))); |
| 2086 | 4540 if (c != NULL) { |
| 4541 if (odata) | |
| 4542 odata->oscar_chats = g_slist_remove(odata->oscar_chats, c); | |
| 4543 if (c->inpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4544 gaim_input_remove(c->inpa); |
| 2086 | 4545 if (g && odata->sess) |
| 4546 aim_conn_kill(odata->sess, &c->conn); | |
| 4547 g_free(c->name); | |
| 4548 g_free(c->show); | |
| 4549 g_free(c); | |
| 4550 } | |
| 4551 /* we do this because with Oscar it doesn't tell us we left */ | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4552 serv_got_chat_left(g, gaim_chat_get_id(GAIM_CHAT(b))); |
| 2086 | 4553 } |
| 4554 | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4555 static int oscar_chat_send(struct gaim_connection *g, int id, char *message) { |
| 2086 | 4556 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 4557 GSList *bcs = g->buddy_chats; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4558 struct gaim_conversation *b = NULL; |
| 2086 | 4559 struct chat_connection *c = NULL; |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4560 char *buf, *buf2; |
| 2086 | 4561 int i, j; |
| 4562 | |
| 4563 while (bcs) { | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4564 b = (struct gaim_conversation *)bcs->data; |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4565 if (id == gaim_chat_get_id(GAIM_CHAT(b))) |
| 2086 | 4566 break; |
| 4567 bcs = bcs->next; | |
| 4568 b = NULL; | |
| 4569 } | |
| 4570 if (!b) | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4571 return -EINVAL; |
| 2086 | 4572 |
| 4573 bcs = odata->oscar_chats; | |
| 4574 while (bcs) { | |
| 4575 c = (struct chat_connection *)bcs->data; | |
| 4576 if (b == c->cnv) | |
| 4577 break; | |
| 4578 bcs = bcs->next; | |
| 4579 c = NULL; | |
| 4580 } | |
| 4581 if (!c) | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4582 return -EINVAL; |
| 2086 | 4583 |
| 4584 buf = g_malloc(strlen(message) * 4 + 1); | |
| 4585 for (i = 0, j = 0; i < strlen(message); i++) { | |
| 4586 if (message[i] == '\n') { | |
| 4587 buf[j++] = '<'; | |
| 4588 buf[j++] = 'B'; | |
| 4589 buf[j++] = 'R'; | |
| 4590 buf[j++] = '>'; | |
| 4591 } else { | |
| 4592 buf[j++] = message[i]; | |
| 4593 } | |
| 4594 } | |
| 4595 buf[j] = '\0'; | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4596 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4597 if (strlen(buf) > c->maxlen) |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4598 return -E2BIG; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4599 |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4600 buf2 = strip_html(buf); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4601 if (strlen(buf2) > c->maxvis) { |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4602 g_free(buf2); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4603 return -E2BIG; |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4604 } |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4605 g_free(buf2); |
|
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4606 |
| 2086 | 4607 aim_chat_send_im(odata->sess, c->conn, 0, buf, strlen(buf)); |
| 4608 g_free(buf); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
4609 return 0; |
| 2086 | 4610 } |
| 4611 | |
| 4612 static char **oscar_list_icon(int uc) { | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4613 if (uc == 0) |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4614 return (char **)icon_online_xpm; |
| 3595 | 4615 if (uc & 0xffff0000) { |
| 4616 uc >>= 16; | |
| 3101 | 4617 if (uc & AIM_ICQ_STATE_INVISIBLE) |
| 4618 return icon_offline_xpm; | |
| 4619 if (uc & AIM_ICQ_STATE_CHAT) | |
| 4620 return icon_ffc_xpm; | |
| 3212 | 4621 if (uc & AIM_ICQ_STATE_DND) |
| 4622 return icon_dnd_xpm; | |
| 4623 if (uc & AIM_ICQ_STATE_OUT) | |
| 4624 return icon_na_xpm; | |
| 3101 | 4625 if (uc & AIM_ICQ_STATE_BUSY) |
| 4626 return icon_occ_xpm; | |
| 4627 if (uc & AIM_ICQ_STATE_AWAY) | |
| 4628 return icon_away_xpm; | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4629 return icon_online_xpm; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
4630 } |
| 3101 | 4631 if (uc & UC_UNAVAILABLE) |
| 4632 return (char **)away_icon_xpm; | |
| 3079 | 4633 if (uc & UC_WIRELESS) |
| 4634 return (char **)wireless_icon_xpm; | |
| 2689 | 4635 if (uc & UC_AB) |
| 2679 | 4636 return (char **)ab_xpm; |
| 2086 | 4637 if (uc & UC_AOL) |
| 4638 return (char **)aol_icon_xpm; | |
| 4639 if (uc & UC_ADMIN) | |
| 4640 return (char **)admin_icon_xpm; | |
| 4641 if (uc & UC_UNCONFIRMED) | |
| 4642 return (char **)dt_icon_xpm; | |
|
2297
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
4643 if (uc & UC_NORMAL) |
|
a0f6ead876ca
[gaim-migrate @ 2307]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2288
diff
changeset
|
4644 return (char **)free_icon_xpm; |
| 2086 | 4645 return NULL; |
| 4646 } | |
| 4647 | |
| 3952 | 4648 /* |
| 4649 * This is called after the raw data for a file has been transferred (whether | |
| 4650 * we are sending or receiving), but there are other files remaining. | |
| 4651 */ | |
| 3771 | 4652 void oscar_file_transfer_nextfile(struct gaim_connection *gc, |
| 3630 | 4653 struct file_transfer *xfer) { |
| 4654 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 4655 aim_conn_t *conn = oft->conn; | |
| 4656 aim_session_t *sess = aim_conn_getsess(conn); | |
| 4657 | |
| 4658 oft->filesdone++; | |
| 4659 oft->watcher = gaim_input_add(conn->fd, GAIM_INPUT_READ, | |
| 4660 oscar_callback, conn); | |
| 4661 | |
| 4662 /* If this is an incoming sendfile transfer, we send an OK | |
| 4663 * message to the sender; if this is an outgoing sendfile, we | |
| 4664 * will get an OK from the receiver that will be handled in | |
| 4665 * oscar_sendfile_out_done(), so we don't need to do anything | |
| 4666 * yet. | |
| 4667 */ | |
| 4668 | |
| 4669 if (oft->type == OFT_SENDFILE_IN) | |
| 4670 aim_oft_end(sess, conn); | |
| 4671 } | |
| 4672 | |
| 3952 | 4673 /* |
| 4674 * This is called after the raw data for a file has been transferred (whether | |
| 4675 * we are sending or receiving), and it is the last file in the set, so we | |
| 4676 * can tear down the connection. | |
| 4677 */ | |
| 3771 | 4678 void oscar_file_transfer_done(struct gaim_connection *gc, |
| 3630 | 4679 struct file_transfer *xfer) { |
| 4680 struct oscar_file_transfer *oft = find_oft_by_xfer(gc, xfer); | |
| 4681 aim_conn_t *conn = oft->conn; | |
| 4682 aim_session_t *sess = aim_conn_getsess(conn); | |
| 4683 | |
| 4684 oft->filesdone++; | |
| 4685 if (oft->type == OFT_SENDFILE_IN) { | |
| 4686 aim_oft_end(sess, conn); | |
| 4687 oscar_file_transfer_disconnect(sess, conn); | |
| 4688 } | |
| 4689 else if (oft->type == OFT_SENDFILE_OUT) { | |
| 4690 /* Wait for response before closing connection. */ | |
| 4691 oft->watcher = gaim_input_add(conn->fd, GAIM_INPUT_READ, | |
| 4692 oscar_callback, conn); | |
| 4693 } | |
| 4694 } | |
| 4695 | |
| 3952 | 4696 /* |
| 4697 * This is called when there is raw data ready to be sent or received; all the | |
| 4698 * protocol details have been taken care of. | |
| 4699 */ | |
| 3630 | 4700 static int oscar_file_transfer_do(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 4701 struct gaim_connection *gc = sess->aux_data; | |
| 4702 va_list ap; | |
| 4703 aim_conn_t *conn; | |
| 4704 struct oscar_file_transfer *oft; | |
| 3771 | 4705 struct aim_fileheader_t *fh; |
| 3752 | 4706 int err; |
| 3630 | 4707 |
| 4708 va_start(ap, fr); | |
| 4709 conn = va_arg(ap, aim_conn_t *); | |
| 3771 | 4710 fh = va_arg(ap, struct aim_fileheader_t *); |
| 4711 va_end(ap); | |
| 3630 | 4712 |
| 4713 oft = find_oft_by_conn(gc, conn); | |
| 4714 | |
| 4715 /* Don't use the regular input handler for the raw data. */ | |
| 4716 gaim_input_remove(oft->watcher); | |
| 4717 oft->watcher = 0; | |
| 4718 | |
| 4719 if (oft->type == OFT_SENDFILE_IN) { | |
| 3952 | 4720 /* AAA convert fh->name from UCS-2 to UTF-8 if (fh->nencode == 0x0002) */ |
| 4721 err = transfer_in_do(oft->xfer, conn->fd, fh->name, fh->size); | |
| 3630 | 4722 } |
| 4723 else { | |
| 3771 | 4724 err = transfer_out_do(oft->xfer, conn->fd, fh->nrecvd); |
| 3630 | 4725 } |
| 4726 | |
| 3752 | 4727 if (err) { |
| 4728 /* There was an error; cancel the transfer. */ | |
| 4729 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4730 aim_conn_t *bosconn = od->conn; | |
| 4731 aim_canceltransfer(sess, bosconn, oft->cookie, | |
| 4732 oft->sn, AIM_CAPS_SENDFILE); | |
| 4733 oscar_file_transfer_disconnect(sess, oft->conn); | |
| 4734 } | |
| 4735 | |
| 3630 | 4736 return 0; |
| 4737 } | |
| 4738 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4739 static int gaim_directim_initiate(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4740 va_list ap; |
| 4741 struct gaim_connection *gc = sess->aux_data; | |
| 4742 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4743 aim_conn_t *newconn, *listenerconn; |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4744 struct gaim_conversation *cnv; |
| 2086 | 4745 struct direct_im *dim; |
| 4746 char buf[256]; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4747 char *sn; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4748 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4749 va_start(ap, fr); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4750 newconn = va_arg(ap, aim_conn_t *); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4751 listenerconn = va_arg(ap, aim_conn_t *); |
| 2086 | 4752 va_end(ap); |
| 4753 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4754 aim_conn_close(listenerconn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4755 aim_conn_kill(sess, &listenerconn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4756 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4757 sn = g_strdup(aim_directim_getsn(newconn)); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4758 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4759 debug_printf("DirectIM: initiate success to %s\n", sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4760 dim = find_direct_im(od, sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4761 |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4762 if (!(cnv = gaim_find_conversation(sn))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4763 cnv = gaim_conversation_new(GAIM_CONV_IM, sn); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4764 gaim_input_remove(dim->watcher); |
| 2086 | 4765 dim->conn = newconn; |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4766 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
| 2086 | 4767 oscar_callback, dim->conn); |
| 3008 | 4768 dim->connected = TRUE; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4769 g_snprintf(buf, sizeof buf, _("Direct IM with %s established"), sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4770 g_free(sn); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4771 gaim_conversation_write(cnv, NULL, buf, -1, WFLAG_SYSTEM, time(NULL)); |
| 2086 | 4772 |
| 4773 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, | |
| 4774 gaim_directim_incoming, 0); | |
| 4775 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, | |
| 4776 gaim_directim_typing, 0); | |
| 3033 | 4777 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER, |
| 2993 | 4778 gaim_update_ui, 0); |
| 4779 return 1; | |
| 4780 } | |
| 4781 | |
| 4782 static int gaim_update_ui(aim_session_t *sess, aim_frame_t *fr, ...) { | |
| 4783 va_list ap; | |
| 4784 char *sn; | |
| 4785 double percent; | |
| 4786 struct gaim_connection *gc = sess->aux_data; | |
| 4787 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4788 struct gaim_conversation *c; |
| 2993 | 4789 struct direct_im *dim; |
| 4790 | |
| 4791 va_start(ap, fr); | |
| 4792 sn = va_arg(ap, char *); | |
| 4793 percent = va_arg(ap, double); | |
| 4794 va_end(ap); | |
| 4795 | |
| 2994 | 4796 if (!(dim = find_direct_im(od, sn))) |
| 4797 return 1; | |
| 3059 | 4798 if (dim->watcher) { |
| 4799 gaim_input_remove(dim->watcher); /* Otherwise, the callback will callback */ | |
| 4800 dim->watcher = 0; | |
| 4801 } | |
| 3044 | 4802 while (gtk_events_pending()) |
| 4803 gtk_main_iteration(); | |
| 4804 | |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4805 if ((c = gaim_find_conversation(sn))) |
|
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4358
diff
changeset
|
4806 gaim_conversation_update_progress(c, percent); |
| 2993 | 4807 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
| 4808 oscar_callback, dim->conn); | |
| 2086 | 4809 |
| 4810 return 1; | |
| 4811 } | |
| 4812 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4813 static int gaim_directim_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4814 va_list ap; |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4815 char *msg, *sn; |
| 3952 | 4816 int len, encoding; |
| 2086 | 4817 struct gaim_connection *gc = sess->aux_data; |
| 4818 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4819 va_start(ap, fr); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4820 sn = va_arg(ap, char *); |
| 2086 | 4821 msg = va_arg(ap, char *); |
| 2993 | 4822 len = va_arg(ap, int); |
| 3952 | 4823 encoding = va_arg(ap, int); |
| 2086 | 4824 va_end(ap); |
| 4825 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4826 debug_printf("Got DirectIM message from %s\n", sn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4827 |
| 3952 | 4828 /* AAA - I imagine Paco-Paco will want to do some voodoo with the encoding here */ |
| 2993 | 4829 serv_got_im(gc, sn, msg, 0, time(NULL), len); |
| 2086 | 4830 |
| 4831 return 1; | |
| 4832 } | |
| 4833 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4834 static int gaim_directim_typing(aim_session_t *sess, aim_frame_t *fr, ...) { |
| 2086 | 4835 va_list ap; |
| 4836 char *sn; | |
| 2993 | 4837 int typing; |
| 4838 struct gaim_connection *gc = sess->aux_data; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4839 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
4840 va_start(ap, fr); |
| 2086 | 4841 sn = va_arg(ap, char *); |
| 2993 | 4842 typing = va_arg(ap, int); |
| 2086 | 4843 va_end(ap); |
| 4844 | |
| 2993 | 4845 if (typing) { |
| 4846 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
| 4847 debug_printf("ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
| 4342 | 4848 serv_got_typing(gc, sn, 0, TYPING); |
| 2993 | 4849 } else |
| 4342 | 4850 serv_got_typing_stopped(gc, sn); |
| 2086 | 4851 return 1; |
| 4852 } | |
| 4853 | |
| 4854 struct ask_do_dir_im { | |
| 4855 char *who; | |
| 4856 struct gaim_connection *gc; | |
| 4857 }; | |
| 4858 | |
| 3730 | 4859 static void oscar_cancel_direct_im(struct ask_do_dir_im *data) { |
| 2086 | 4860 g_free(data); |
| 4861 } | |
| 4862 | |
| 3730 | 4863 static void oscar_direct_im(struct ask_do_dir_im *data) { |
| 2086 | 4864 struct gaim_connection *gc = data->gc; |
| 4244 | 4865 struct oscar_data *od; |
| 2086 | 4866 struct direct_im *dim; |
| 4867 | |
| 4244 | 4868 if (!g_slist_find(connections, gc)) { |
| 4869 g_free(data); | |
| 4870 return; | |
| 4871 } | |
| 4872 | |
| 4873 od = (struct oscar_data *)gc->proto_data; | |
| 4874 | |
| 2086 | 4875 dim = find_direct_im(od, data->who); |
| 4876 if (dim) { | |
| 3008 | 4877 if (!(dim->connected)) { /* We'll free the old, unconnected dim, and start over */ |
| 4878 od->direct_ims = g_slist_remove(od->direct_ims, dim); | |
| 4879 gaim_input_remove(dim->watcher); | |
| 4880 g_free(dim); | |
| 4881 debug_printf("Gave up on old direct IM, trying again\n"); | |
| 4882 } else { | |
| 3427 | 4883 do_error_dialog("DirectIM already open.", NULL, GAIM_ERROR); |
| 4244 | 4884 g_free(data); |
| 3008 | 4885 return; |
| 4886 } | |
| 2086 | 4887 } |
| 4888 dim = g_new0(struct direct_im, 1); | |
| 4889 dim->gc = gc; | |
| 4890 g_snprintf(dim->name, sizeof dim->name, "%s", data->who); | |
| 4891 | |
|
2717
03bf072c6238
[gaim-migrate @ 2730]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2713
diff
changeset
|
4892 dim->conn = aim_directim_initiate(od->sess, data->who); |
| 2086 | 4893 if (dim->conn != NULL) { |
| 4894 od->direct_ims = g_slist_append(od->direct_ims, dim); | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
4895 dim->watcher = gaim_input_add(dim->conn->fd, GAIM_INPUT_READ, |
| 2086 | 4896 oscar_callback, dim->conn); |
| 4897 aim_conn_addhandler(od->sess, dim->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, | |
| 4898 gaim_directim_initiate, 0); | |
| 4899 } else { | |
| 3427 | 4900 do_error_dialog(_("Unable to open Direct IM"), NULL, GAIM_ERROR); |
| 2086 | 4901 g_free(dim); |
| 4902 } | |
| 4244 | 4903 |
| 4904 g_free(data); | |
| 2086 | 4905 } |
| 4906 | |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4907 static void oscar_ask_direct_im(struct gaim_connection *gc, gchar *who) { |
| 2086 | 4908 char buf[BUF_LONG]; |
| 4909 struct ask_do_dir_im *data = g_new0(struct ask_do_dir_im, 1); | |
| 4910 data->who = who; | |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
4911 data->gc = gc; |
| 3730 | 4912 g_snprintf(buf, sizeof(buf), _("You have selected to open a Direct IM connection with %s."), who); |
| 4249 | 4913 do_ask_dialog(buf, _("Because this reveals your IP address, it may be considered a privacy risk. Do you wish to continue?"), data, _("Connect"), oscar_direct_im, _("Cancel"), oscar_cancel_direct_im, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
| 2086 | 4914 } |
| 4915 | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4916 static void oscar_get_away_msg(struct gaim_connection *gc, char *who) { |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4917 struct oscar_data *od = gc->proto_data; |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4918 od->evilhack = g_slist_append(od->evilhack, g_strdup(normalize(who))); |
| 3212 | 4919 if (od->icq) { |
| 4349 | 4920 struct buddy *budlight = find_buddy(gc->user, who); |
| 3212 | 4921 if (budlight) |
| 3595 | 4922 if ((budlight->uc >> 16) & (AIM_ICQ_STATE_AWAY || AIM_ICQ_STATE_DND || AIM_ICQ_STATE_OUT || AIM_ICQ_STATE_BUSY || AIM_ICQ_STATE_CHAT)) |
| 3212 | 4923 if (budlight->caps & AIM_CAPS_ICQSERVERRELAY) |
| 3595 | 4924 aim_send_im_ch2_geticqmessage(od->sess, who, (budlight->uc & 0xffff0000) >> 16); |
| 3212 | 4925 else { |
| 3595 | 4926 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
| 4344 | 4927 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR><I>Remote client does not support sending status messages.</I><BR>"), who, state_msg); |
| 3212 | 4928 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
| 4929 free(state_msg); | |
| 4930 free(dialog_msg); | |
| 4931 } | |
| 4932 else { | |
| 3595 | 4933 char *state_msg = gaim_icq_status((budlight->uc & 0xffff0000) >> 16); |
| 4344 | 4934 char *dialog_msg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR><I>User has no status message.</I><BR>"), who, state_msg); |
| 3212 | 4935 g_show_info_text(gc, who, 2, dialog_msg, NULL); |
| 4936 free(state_msg); | |
| 4937 free(dialog_msg); | |
| 4938 } | |
| 4939 else | |
| 3427 | 4940 do_error_dialog("Could not find contact in local list, therefore unable to request status message.\n", NULL, GAIM_ERROR); |
| 3212 | 4941 } else |
| 4942 oscar_get_info(gc, who); | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4943 } |
|
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
4944 |
| 2086 | 4945 static void oscar_set_permit_deny(struct gaim_connection *gc) { |
| 4946 struct oscar_data *od = (struct oscar_data *)gc->proto_data; | |
| 4230 | 4947 #ifdef NOSSI |
| 4948 GSList *list, *g; | |
| 4949 char buf[MAXMSGLEN]; | |
| 4950 int at; | |
| 4951 | |
| 4349 | 4952 switch(gc->user->permdeny) { |
| 4230 | 4953 case 1: |
| 4954 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gc->username); | |
| 4955 break; | |
| 4956 case 2: | |
| 4957 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gc->username); | |
| 4958 break; | |
| 4959 case 3: | |
| 4960 list = gc->permit; | |
| 4961 at = 0; | |
| 4962 while (list) { | |
| 4963 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
| 4964 list = list->next; | |
| 4965 } | |
| 4966 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); | |
| 4967 break; | |
| 4968 case 4: | |
| 4969 list = gc->deny; | |
| 4970 at = 0; | |
| 4971 while (list) { | |
| 4972 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", (char *)list->data); | |
| 4973 list = list->next; | |
| 4974 } | |
| 4975 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, buf); | |
| 4976 break; | |
| 4977 case 5: | |
| 4349 | 4978 g = groups; |
| 4230 | 4979 at = 0; |
| 4980 while (g) { | |
| 4349 | 4981 list = ((struct group *)g->data)->members; |
| 2995 | 4982 while (list) { |
| 4349 | 4983 struct buddy *b = list->data; |
| 4984 if(b->user == gc->user) | |
| 4985 at += g_snprintf(buf + at, sizeof(buf) - at, "%s&", b->name); | |
| 2995 | 4986 list = list->next; |
| 4987 } | |
| 4230 | 4988 g = g->next; |
| 4349 | 4989 } |
| 4230 | 4990 aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf); |
| 4991 break; | |
| 4992 default: | |
| 4993 break; | |
| 2086 | 4994 } |
| 4230 | 4995 signoff_blocked(gc); |
| 4996 #else | |
| 4997 if (od->sess->ssi.received_data) | |
| 4349 | 4998 aim_ssi_setpermdeny(od->sess, od->conn, gc->user->permdeny, 0xffffffff); |
| 4230 | 4999 #endif |
| 2086 | 5000 } |
| 5001 | |
| 4349 | 5002 static void oscar_add_permit(struct gaim_connection *gc, const char *who) { |
| 4269 | 5003 #ifdef NOSSI |
| 4349 | 5004 if (gc->user->permdeny == 3) |
| 4269 | 5005 oscar_set_permit_deny(gc); |
| 5006 #else | |
| 2991 | 5007 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 4230 | 5008 debug_printf("ssi: About to add a permit\n"); |
| 5009 if (od->sess->ssi.received_data) | |
| 5010 aim_ssi_addpermit(od->sess, od->conn, who); | |
| 5011 #endif | |
| 2086 | 5012 } |
| 5013 | |
| 4349 | 5014 static void oscar_add_deny(struct gaim_connection *gc, const char *who) { |
| 4269 | 5015 #ifdef NOSSI |
| 4349 | 5016 if (gc->user->permdeny == 4) |
| 4269 | 5017 oscar_set_permit_deny(gc); |
| 5018 #else | |
| 2991 | 5019 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 4230 | 5020 debug_printf("ssi: About to add a deny\n"); |
| 5021 if (od->sess->ssi.received_data) | |
| 5022 aim_ssi_adddeny(od->sess, od->conn, who); | |
| 5023 #endif | |
| 2086 | 5024 } |
| 5025 | |
| 4349 | 5026 static void oscar_rem_permit(struct gaim_connection *gc, const char *who) { |
| 4269 | 5027 #ifdef NOSSI |
| 4349 | 5028 if (gc->user->permdeny == 3) |
| 4269 | 5029 oscar_set_permit_deny(gc); |
| 5030 #else | |
| 2991 | 5031 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 4230 | 5032 debug_printf("ssi: About to delete a permit\n"); |
| 5033 if (od->sess->ssi.received_data) | |
| 5034 aim_ssi_delpermit(od->sess, od->conn, who); | |
| 5035 #endif | |
| 2086 | 5036 } |
| 5037 | |
| 4349 | 5038 static void oscar_rem_deny(struct gaim_connection *gc, const char *who) { |
| 4269 | 5039 #ifdef NOSSI |
| 4349 | 5040 if (gc->user->permdeny == 4) |
| 4269 | 5041 oscar_set_permit_deny(gc); |
| 5042 #else | |
| 2991 | 5043 struct oscar_data *od = (struct oscar_data *)gc->proto_data; |
| 4230 | 5044 debug_printf("ssi: About to delete a deny\n"); |
| 5045 if (od->sess->ssi.received_data) | |
| 5046 aim_ssi_deldeny(od->sess, od->conn, who); | |
| 5047 #endif | |
| 2086 | 5048 } |
| 5049 | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5050 static GList *oscar_away_states(struct gaim_connection *gc) |
| 2086 | 5051 { |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5052 struct oscar_data *od = gc->proto_data; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5053 GList *m = NULL; |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5054 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5055 if (!od->icq) |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5056 return g_list_append(m, GAIM_AWAY_CUSTOM); |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5057 |
| 4333 | 5058 m = g_list_append(m, _("Online")); |
| 5059 m = g_list_append(m, _("Away")); | |
| 5060 m = g_list_append(m, _("Do Not Disturb")); | |
| 5061 m = g_list_append(m, _("Not Available")); | |
| 5062 m = g_list_append(m, _("Occupied")); | |
| 5063 m = g_list_append(m, _("Free For Chat")); | |
| 5064 m = g_list_append(m, _("Invisible")); | |
| 5065 | |
| 5066 return m; | |
| 5067 } | |
| 5068 | |
| 5069 static GList *oscar_buddy_menu(struct gaim_connection *gc, char *who) { | |
| 5070 struct oscar_data *od = gc->proto_data; | |
| 5071 GList *m = NULL; | |
| 5072 struct proto_buddy_menu *pbm; | |
| 5073 | |
| 5074 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5075 pbm->label = _("Get Info"); | |
| 5076 pbm->callback = oscar_get_info; | |
| 5077 pbm->gc = gc; | |
| 5078 m = g_list_append(m, pbm); | |
| 5079 | |
| 5080 if (od->icq) { | |
| 5081 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5082 pbm->label = _("Get Status Msg"); | |
| 5083 pbm->callback = oscar_get_away_msg; | |
| 5084 pbm->gc = gc; | |
| 5085 m = g_list_append(m, pbm); | |
| 5086 } else { | |
| 4356 | 5087 struct buddy *b = find_buddy(gc->user, who); |
| 5088 | |
| 5089 if (!b || (b->uc & UC_UNAVAILABLE)) { | |
| 5090 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5091 pbm->label = _("Get Away Msg"); | |
| 5092 pbm->callback = oscar_get_away_msg; | |
| 5093 pbm->gc = gc; | |
| 5094 m = g_list_append(m, pbm); | |
| 5095 } | |
| 4333 | 5096 |
| 5097 if (aim_sncmp(gc->username, who)) { | |
| 5098 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5099 pbm->label = _("Direct IM"); | |
| 5100 pbm->callback = oscar_ask_direct_im; | |
| 5101 pbm->gc = gc; | |
| 5102 m = g_list_append(m, pbm); | |
| 5103 | |
| 5104 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5105 pbm->label = _("Send File"); | |
| 5106 pbm->callback = oscar_ask_send_file; | |
| 5107 pbm->gc = gc; | |
| 5108 m = g_list_append(m, pbm); | |
| 5109 } | |
| 5110 } | |
| 5111 | |
| 5112 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5113 pbm->label = _("Get Capabilities"); | |
| 5114 pbm->callback = oscar_get_caps; | |
| 5115 pbm->gc = gc; | |
| 5116 m = g_list_append(m, pbm); | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5117 |
|
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2432
diff
changeset
|
5118 return m; |
| 2086 | 5119 } |
| 5120 | |
| 4333 | 5121 static GList *oscar_edit_buddy_menu(struct gaim_connection *gc, char *who) |
| 5122 { | |
| 5123 struct oscar_data *od = gc->proto_data; | |
| 5124 GList *m = NULL; | |
| 5125 struct proto_buddy_menu *pbm; | |
| 5126 | |
| 5127 if (od->icq) { | |
| 5128 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5129 pbm->label = _("Get Info"); | |
| 5130 pbm->callback = oscar_get_info; | |
| 5131 pbm->gc = gc; | |
| 5132 m = g_list_append(m, pbm); | |
| 5133 } | |
| 5134 | |
| 5135 if (od->sess->ssi.received_data) { | |
| 5136 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, who); | |
| 5137 if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, who)) { | |
| 5138 pbm = g_new0(struct proto_buddy_menu, 1); | |
| 5139 pbm->label = _("Re-request Authorization"); | |
| 5140 pbm->callback = gaim_auth_sendrequest; | |
| 5141 pbm->gc = gc; | |
| 5142 m = g_list_append(m, pbm); | |
| 5143 } | |
| 5144 } | |
| 5145 | |
| 5146 return m; | |
| 5147 } | |
| 5148 | |
| 5149 static void oscar_format_screenname(struct gaim_connection *gc, char *nick) { | |
| 5150 struct oscar_data *od = gc->proto_data; | |
| 5151 if (!aim_sncmp(gc->username, nick)) { | |
| 5152 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
| 5153 od->setnick = TRUE; | |
| 5154 od->newsn = g_strdup(nick); | |
| 5155 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 5156 } else { | |
| 5157 aim_admin_setnick(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), nick); | |
| 5158 } | |
| 5159 } else { | |
| 5160 do_error_dialog(_("The new formatting is invalid."), | |
| 5161 _("Screenname formatting can change only capitalization and whitespace."), GAIM_ERROR); | |
| 5162 } | |
| 5163 } | |
| 5164 | |
| 5165 static void oscar_show_format_screenname(struct gaim_connection *gc) | |
| 5166 { | |
| 5167 do_prompt_dialog(_("New screenname formatting:"), gc->displayname, gc, oscar_format_screenname, NULL); | |
| 5168 } | |
| 5169 | |
| 5170 static void oscar_confirm_account(struct gaim_connection *gc) | |
| 5171 { | |
| 5172 struct oscar_data *od = gc->proto_data; | |
| 5173 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
| 5174 | |
| 5175 if (conn) { | |
| 5176 aim_admin_reqconfirm(od->sess, conn); | |
| 5177 } else { | |
| 5178 od->conf = TRUE; | |
| 5179 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 5180 } | |
| 5181 } | |
| 5182 | |
| 5183 static void oscar_show_email(struct gaim_connection *gc) | |
| 5184 { | |
| 5185 struct oscar_data *od = gc->proto_data; | |
| 5186 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); | |
| 5187 | |
| 5188 if (conn) { | |
| 5189 aim_admin_getinfo(od->sess, conn, 0x11); | |
| 5190 } else { | |
| 5191 od->reqemail = TRUE; | |
| 5192 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); | |
| 5193 } | |
| 5194 } | |
| 5195 | |
|
2768
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5196 static void oscar_change_email(struct gaim_connection *gc, char *email) |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5197 { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5198 struct oscar_data *od = gc->proto_data; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5199 aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5200 |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5201 if (conn) { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5202 aim_admin_setemail(od->sess, conn, email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5203 } else { |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5204 od->setemail = TRUE; |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5205 od->email = g_strdup(email); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5206 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5207 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5208 } |
|
8a918df1a5ed
[gaim-migrate @ 2781]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2762
diff
changeset
|
5209 |
| 4333 | 5210 static void oscar_show_change_email(struct gaim_connection *gc) |
| 5211 { | |
| 5212 do_prompt_dialog(_("Change Address To: "), NULL, gc, oscar_change_email, NULL); | |
| 5213 } | |
| 5214 | |
| 5215 static void oscar_show_awaitingauth(struct gaim_connection *gc) | |
| 5216 { | |
| 2979 | 5217 struct oscar_data *od = gc->proto_data; |
| 4333 | 5218 gchar *nombre, *text, *tmp; |
| 5219 GSList *curg, *curb; | |
| 5220 int num=0; | |
| 5221 | |
| 5222 text = g_strdup(_("You are awaiting authorization from the following buddies:<BR>")); | |
| 5223 | |
| 4349 | 5224 for (curg=groups; curg; curg=g_slist_next(curg)) { |
| 4333 | 5225 struct group *group = curg->data; |
| 5226 for (curb=group->members; curb; curb=g_slist_next(curb)) { | |
| 5227 struct buddy *buddy = curb->data; | |
| 4349 | 5228 if (buddy->user == gc->user && aim_ssi_waitingforauth(od->sess->ssi.local, group->name, buddy->name)) { |
| 4333 | 5229 if (get_buddy_alias_only(buddy)) |
| 5230 nombre = g_strdup_printf(" %s (%s)", buddy->name, get_buddy_alias_only(buddy)); | |
| 5231 else | |
| 4337 | 5232 nombre = g_strdup_printf(" %s", buddy->name); |
| 4333 | 5233 tmp = g_strdup_printf("%s<BR>%s", text, nombre); |
| 5234 g_free(text); | |
| 5235 text = tmp; | |
| 5236 g_free(nombre); | |
| 5237 num++; | |
| 5238 } | |
| 2979 | 5239 } |
| 4333 | 5240 } |
| 5241 | |
| 5242 if (!num) { | |
| 5243 tmp = g_strdup_printf("%s<BR>%s", text, _("<i>you are not waiting for authorization</i>")); | |
| 5244 g_free(text); | |
| 5245 text = tmp; | |
| 2979 | 5246 } |
| 4333 | 5247 |
| 5248 tmp = g_strdup_printf(_("%s<BR><BR>You can re-request authorization from these buddies by right-clicking on them in the \"Edit Buddies\" pane and selecting \"Re-request authorization.\""), text); | |
| 5249 g_free(text); | |
| 5250 text = tmp; | |
| 5251 g_show_info_text(gc, gc->username, 2, text, NULL); | |
| 5252 g_free(text); | |
| 2979 | 5253 } |
| 5254 | |
| 4333 | 5255 static void oscar_show_chpassurl(struct gaim_connection *gc) |
| 5256 { | |
| 5257 struct oscar_data *od = gc->proto_data; | |
| 5258 open_url(NULL, od->sess->authinfo->chpassurl); | |
| 5259 } | |
| 5260 | |
| 5261 static GList *oscar_actions(struct gaim_connection *gc) | |
| 2086 | 5262 { |
| 5263 struct oscar_data *od = gc->proto_data; | |
| 4333 | 5264 struct proto_actions_menu *pam; |
| 5265 GList *m = NULL; | |
| 5266 | |
| 5267 pam = g_new0(struct proto_actions_menu, 1); | |
| 5268 pam->label = _("Set User Info"); | |
| 5269 pam->callback = show_set_info; | |
| 5270 pam->gc = gc; | |
| 5271 m = g_list_append(m, pam); | |
| 5272 | |
| 5273 if (od->sess->authinfo->regstatus == 0x0003) { | |
| 5274 /* AIM actions */ | |
| 5275 m = g_list_append(m, NULL); | |
| 5276 | |
| 5277 pam = g_new0(struct proto_actions_menu, 1); | |
| 5278 pam->label = _("Change Password"); | |
| 5279 pam->callback = show_change_passwd; | |
| 5280 pam->gc = gc; | |
| 5281 m = g_list_append(m, pam); | |
| 5282 | |
| 5283 pam = g_new0(struct proto_actions_menu, 1); | |
| 5284 pam->label = _("Format Screenname"); | |
| 5285 pam->callback = oscar_show_format_screenname; | |
| 5286 pam->gc = gc; | |
| 5287 m = g_list_append(m, pam); | |
| 5288 | |
| 5289 pam = g_new0(struct proto_actions_menu, 1); | |
| 5290 pam->label = _("Confirm Account"); | |
| 5291 pam->callback = oscar_confirm_account; | |
| 5292 pam->gc = gc; | |
| 5293 m = g_list_append(m, pam); | |
| 5294 | |
| 5295 pam = g_new0(struct proto_actions_menu, 1); | |
| 5296 pam->label = _("Display Current Registered Address"); | |
| 5297 pam->callback = oscar_show_email; | |
| 5298 pam->gc = gc; | |
| 5299 m = g_list_append(m, pam); | |
| 5300 | |
| 5301 pam = g_new0(struct proto_actions_menu, 1); | |
| 5302 pam->label = _("Change Current Registered Address"); | |
| 5303 pam->callback = oscar_show_change_email; | |
| 5304 pam->gc = gc; | |
| 5305 m = g_list_append(m, pam); | |
| 5306 } else if (od->sess->authinfo->chpassurl) { | |
| 5307 pam = g_new0(struct proto_actions_menu, 1); | |
| 5308 pam->label = _("Change Password"); | |
| 5309 pam->callback = oscar_show_chpassurl; | |
| 5310 pam->gc = gc; | |
| 5311 m = g_list_append(m, pam); | |
| 2086 | 5312 } |
| 4333 | 5313 |
| 5314 m = g_list_append(m, NULL); | |
| 5315 | |
| 5316 pam = g_new0(struct proto_actions_menu, 1); | |
| 5317 pam->label = _("Show Buddies Awaiting Authorization"); | |
| 5318 pam->callback = oscar_show_awaitingauth; | |
| 5319 pam->gc = gc; | |
| 5320 m = g_list_append(m, pam); | |
| 5321 | |
| 2086 | 5322 m = g_list_append(m, NULL); |
| 4333 | 5323 |
| 5324 pam = g_new0(struct proto_actions_menu, 1); | |
| 5325 pam->label = _("Search for Buddy by Email"); | |
| 5326 pam->callback = show_find_email; | |
| 5327 pam->gc = gc; | |
| 5328 m = g_list_append(m, pam); | |
| 5329 | |
| 4336 | 5330 /* pam = g_new0(struct proto_actions_menu, 1); |
| 4333 | 5331 pam->label = _("Search for Buddy by Information"); |
| 5332 pam->callback = show_find_info; | |
| 5333 pam->gc = gc; | |
| 4336 | 5334 m = g_list_append(m, pam); */ |
| 2086 | 5335 |
| 5336 return m; | |
| 5337 } | |
| 5338 | |
| 3466 | 5339 static void oscar_change_passwd(struct gaim_connection *gc, const char *old, const char *new) |
| 2086 | 5340 { |
| 5341 struct oscar_data *od = gc->proto_data; | |
| 5342 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH)) { | |
| 5343 od->chpass = TRUE; | |
| 5344 od->oldp = g_strdup(old); | |
| 5345 od->newp = g_strdup(new); | |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5346 aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH); |
| 2086 | 5347 } else { |
|
2703
441b84ab7f4e
[gaim-migrate @ 2716]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2698
diff
changeset
|
5348 aim_admin_changepasswd(od->sess, aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH), |
| 2086 | 5349 new, old); |
| 5350 } | |
| 5351 } | |
| 5352 | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5353 static void oscar_convo_closed(struct gaim_connection *gc, char *who) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5354 { |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5355 struct oscar_data *od = gc->proto_data; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5356 struct direct_im *dim = find_direct_im(od, who); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5357 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5358 if (!dim) |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5359 return; |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5360 |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5361 od->direct_ims = g_slist_remove(od->direct_ims, dim); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5362 gaim_input_remove(dim->watcher); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5363 aim_conn_kill(od->sess, &dim->conn); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5364 g_free(dim); |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5365 } |
|
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5366 |
| 4151 | 5367 static fu32_t check_encoding(const char *utf8) |
| 5368 { | |
| 5369 int i = 0; | |
| 5370 fu32_t encodingflag = 0; | |
| 5371 | |
| 5372 /* Determine how we can send this message. Per the | |
| 5373 * warnings elsewhere in this file, these little | |
| 5374 * checks determine the simplest encoding we can use | |
| 5375 * for a given message send using it. */ | |
| 5376 while (utf8[i]) { | |
| 5377 if ((unsigned char)utf8[i] > 0x7f) { | |
| 5378 /* not ASCII! */ | |
| 5379 encodingflag = AIM_IMFLAGS_ISO_8859_1; | |
| 5380 break; | |
| 5381 } | |
| 5382 i++; | |
| 5383 } | |
| 5384 while (utf8[i]) { | |
| 5385 /* ISO-8859-1 is 0x00-0xbf in the first byte | |
| 5386 * followed by 0xc0-0xc3 in the second */ | |
| 5387 if ((unsigned char)utf8[i] < 0x80) { | |
| 5388 i++; | |
| 5389 continue; | |
| 5390 } else if (((unsigned char)utf8[i] & 0xfc) == 0xc0 && | |
| 5391 ((unsigned char)utf8[i + 1] & 0xc0) == 0x80) { | |
| 5392 i += 2; | |
| 5393 continue; | |
| 5394 } | |
| 5395 encodingflag = AIM_IMFLAGS_UNICODE; | |
| 5396 break; | |
| 5397 } | |
| 5398 | |
| 5399 return encodingflag; | |
| 5400 } | |
| 5401 | |
| 5402 static fu32_t parse_encoding(const char *enc) | |
| 5403 { | |
| 5404 char *charset; | |
| 5405 | |
| 5406 /* If anything goes wrong, fall back on ASCII and print a message */ | |
| 5407 charset = strstr(enc, "charset="); | |
| 5408 if (charset == NULL) { | |
| 5409 debug_printf("No charset specified for info, assuming ASCII\n"); | |
| 5410 return 0; | |
| 5411 } | |
| 5412 charset += 8; | |
| 5413 if (!strcmp(charset, "\"us-ascii\"")) { | |
| 5414 return 0; | |
| 4166 | 5415 } else if (!strcmp(charset, "\"iso-8859-1\"")) { |
| 5416 return AIM_IMFLAGS_ISO_8859_1; | |
| 4151 | 5417 } else if (!strcmp(charset, "\"unicode-2-0\"")) { |
| 5418 return AIM_IMFLAGS_UNICODE; | |
| 5419 } else { | |
| 5420 debug_printf("Unrecognized character set '%s', using ASCII\n", charset); | |
| 5421 return 0; | |
| 5422 } | |
| 5423 } | |
| 3035 | 5424 |
| 3630 | 5425 G_MODULE_EXPORT void oscar_init(struct prpl *ret) { |
| 3572 | 5426 struct proto_user_opt *puo; |
| 2086 | 5427 ret->protocol = PROTO_OSCAR; |
| 3694 | 5428 ret->options = OPT_PROTO_MAIL_CHECK | OPT_PROTO_BUDDY_ICON | OPT_PROTO_IM_IMAGE; |
| 3858 | 5429 ret->name = g_strdup("AIM/ICQ"); |
| 2086 | 5430 ret->list_icon = oscar_list_icon; |
| 5431 ret->away_states = oscar_away_states; | |
| 5432 ret->actions = oscar_actions; | |
| 5433 ret->buddy_menu = oscar_buddy_menu; | |
| 3456 | 5434 ret->edit_buddy_menu = oscar_edit_buddy_menu; |
| 2086 | 5435 ret->login = oscar_login; |
| 5436 ret->close = oscar_close; | |
| 5437 ret->send_im = oscar_send_im; | |
| 2993 | 5438 ret->send_typing = oscar_send_typing; |
| 2086 | 5439 ret->set_info = oscar_set_info; |
| 5440 ret->get_info = oscar_get_info; | |
| 5441 ret->set_away = oscar_set_away; | |
|
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2789
diff
changeset
|
5442 ret->get_away = oscar_get_away; |
| 2086 | 5443 ret->set_dir = oscar_set_dir; |
| 5444 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
| 5445 ret->dir_search = oscar_dir_search; | |
| 5446 ret->set_idle = oscar_set_idle; | |
| 5447 ret->change_passwd = oscar_change_passwd; | |
| 5448 ret->add_buddy = oscar_add_buddy; | |
| 5449 ret->add_buddies = oscar_add_buddies; | |
| 4269 | 5450 ret->remove_buddy = oscar_remove_buddy; |
| 5451 ret->remove_buddies = oscar_remove_buddies; | |
| 4230 | 5452 #ifndef NOSSI |
| 3140 | 5453 ret->group_buddy = oscar_move_buddy; |
| 4269 | 5454 ret->alias_buddy = oscar_alias_buddy; |
| 3348 | 5455 ret->rename_group = oscar_rename_group; |
| 4230 | 5456 #endif |
| 4269 | 5457 ret->add_permit = oscar_add_permit; |
| 5458 ret->add_deny = oscar_add_deny; | |
| 5459 ret->rem_permit = oscar_rem_permit; | |
| 5460 ret->rem_deny = oscar_rem_deny; | |
| 5461 ret->set_permit_deny = oscar_set_permit_deny; | |
| 3771 | 5462 ret->file_transfer_cancel = oscar_file_transfer_cancel; |
| 5463 ret->file_transfer_in = oscar_file_transfer_in; | |
| 5464 ret->file_transfer_out = oscar_file_transfer_out; | |
| 5465 ret->file_transfer_data_chunk = oscar_file_transfer_data_chunk; | |
| 5466 ret->file_transfer_nextfile = oscar_file_transfer_nextfile; | |
| 5467 ret->file_transfer_done = oscar_file_transfer_done; | |
| 2086 | 5468 ret->warn = oscar_warn; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2197
diff
changeset
|
5469 ret->chat_info = oscar_chat_info; |
| 2086 | 5470 ret->join_chat = oscar_join_chat; |
| 5471 ret->chat_invite = oscar_chat_invite; | |
| 5472 ret->chat_leave = oscar_chat_leave; | |
| 5473 ret->chat_whisper = NULL; | |
| 5474 ret->chat_send = oscar_chat_send; | |
| 5475 ret->keepalive = oscar_keepalive; | |
|
2246
933346315b9b
[gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2235
diff
changeset
|
5476 ret->convo_closed = oscar_convo_closed; |
| 2086 | 5477 |
| 3572 | 5478 puo = g_new0(struct proto_user_opt, 1); |
| 5479 puo->label = g_strdup("Auth Host:"); | |
| 5480 puo->def = g_strdup("login.oscar.aol.com"); | |
| 5481 puo->pos = USEROPT_AUTH; | |
| 5482 ret->user_opts = g_list_append(ret->user_opts, puo); | |
| 5483 | |
| 5484 puo = g_new0(struct proto_user_opt, 1); | |
| 5485 puo->label = g_strdup("Auth Port:"); | |
| 5486 puo->def = g_strdup("5190"); | |
| 5487 puo->pos = USEROPT_AUTHPORT; | |
| 5488 ret->user_opts = g_list_append(ret->user_opts, puo); | |
| 5489 | |
| 2086 | 5490 my_protocol = ret; |
| 5491 } | |
| 5492 | |
| 5493 #ifndef STATIC | |
| 5494 | |
| 3630 | 5495 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
| 2086 | 5496 { |
| 3572 | 5497 oscar_init(prpl); |
| 5498 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
| 2086 | 5499 } |
| 5500 | |
| 5501 #endif |
