Mercurial > pidgin
annotate src/protocols/toc/toc.c @ 14122:dabbcb9b013d
[gaim-migrate @ 16759]
This initializes threads for glib and dbus, because under some
circumstances multithreaded libraries are causing dbus badness
(namely, gnome-vfs). This fix doesn't really belong in Gaim, but in
the interest of expedience (we don't want to wait for upstream
libraries to get their initializations all worked around to make
things safe) the fix goes here. Note that all Gaim frontends will
have to initialize glib threads if other threaded libraries which
interact with glib or dbus or what-have-you come into play.
committer: Tailor Script <tailor@pidgin.im>
| author | Ethan Blanton <elb@pidgin.im> |
|---|---|
| date | Mon, 14 Aug 2006 21:46:17 +0000 |
| parents | 54147aa1ffe6 |
| children |
| rev | line source |
|---|---|
| 2086 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or modify | |
| 7 * it under the terms of the GNU General Public License as published by | |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 * | |
| 20 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 #include "internal.h" |
| 3630 | 22 |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
23 #include "account.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 #include "accountopt.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
25 #include "conversation.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
27 #include "notify.h" |
| 10744 | 28 #include "privacy.h" |
| 2086 | 29 #include "proxy.h" |
| 9058 | 30 #include "prpl.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
31 #include "request.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
32 #include "util.h" |
| 9954 | 33 #include "version.h" |
| 2086 | 34 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
35 static GaimPlugin *my_protocol = NULL; |
| 4249 | 36 |
| 2086 | 37 #define REVISION "penguin" |
| 38 | |
| 39 #define TYPE_SIGNON 1 | |
| 40 #define TYPE_DATA 2 | |
| 41 #define TYPE_ERROR 3 | |
| 42 #define TYPE_SIGNOFF 4 | |
| 43 #define TYPE_KEEPALIVE 5 | |
| 44 | |
| 45 #define FLAPON "FLAPON\r\n\r\n" | |
| 46 #define ROAST "Tic/Toc" | |
| 47 | |
| 48 #define TOC_HOST "toc.oscar.aol.com" | |
| 49 #define TOC_PORT 9898 | |
| 50 #define AUTH_HOST "login.oscar.aol.com" | |
| 51 #define AUTH_PORT 5190 | |
| 52 #define LANGUAGE "english" | |
| 53 | |
| 54 #define STATE_OFFLINE 0 | |
| 55 #define STATE_FLAPON 1 | |
| 56 #define STATE_SIGNON_REQUEST 2 | |
| 57 #define STATE_ONLINE 3 | |
| 58 #define STATE_PAUSE 4 | |
| 59 | |
| 60 #define VOICE_UID "09461341-4C7F-11D1-8222-444553540000" | |
| 61 #define FILE_SEND_UID "09461343-4C7F-11D1-8222-444553540000" | |
| 62 #define IMAGE_UID "09461345-4C7F-11D1-8222-444553540000" | |
| 63 #define B_ICON_UID "09461346-4C7F-11D1-8222-444553540000" | |
| 64 #define STOCKS_UID "09461347-4C7F-11D1-8222-444553540000" | |
| 65 #define FILE_GET_UID "09461348-4C7F-11D1-8222-444553540000" | |
| 66 #define GAMES_UID "0946134a-4C7F-11D1-8222-444553540000" | |
| 67 | |
| 10011 | 68 #define UC_UNAVAILABLE 0x01 |
| 6500 | 69 #define UC_AOL 0x02 |
| 70 #define UC_ADMIN 0x04 | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
71 #define UC_UNCONFIRMED 0x08 |
| 6500 | 72 #define UC_NORMAL 0x10 |
| 73 #define UC_WIRELESS 0x20 | |
|
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2453
diff
changeset
|
74 |
| 2086 | 75 struct ft_request { |
| 5605 | 76 GaimConnection *gc; |
| 6500 | 77 char *user; |
| 2086 | 78 char UID[2048]; |
| 6500 | 79 char *cookie; |
| 80 char *ip; | |
| 81 int port; | |
| 82 char *message; | |
| 83 char *filename; | |
| 2086 | 84 int files; |
| 6500 | 85 int size; |
| 2086 | 86 }; |
| 87 | |
| 88 struct buddy_icon { | |
| 89 guint32 hash; | |
| 90 guint32 len; | |
| 91 time_t time; | |
| 92 void *data; | |
| 93 }; | |
| 94 | |
| 95 struct toc_data { | |
| 96 int toc_fd; | |
| 4597 | 97 char toc_ip[20]; |
| 2086 | 98 int seqno; |
| 99 int state; | |
| 100 }; | |
| 101 | |
| 102 struct sflap_hdr { | |
| 103 unsigned char ast; | |
| 104 unsigned char type; | |
| 105 unsigned short seqno; | |
| 106 unsigned short len; | |
| 107 }; | |
| 108 | |
| 109 struct signon { | |
| 110 unsigned int ver; | |
| 111 unsigned short tag; | |
| 112 unsigned short namelen; | |
| 113 char username[80]; | |
| 114 }; | |
| 115 | |
| 116 /* constants to identify proto_opts */ | |
| 117 #define USEROPT_AUTH 0 | |
| 118 #define USEROPT_AUTHPORT 1 | |
| 119 | |
| 9140 | 120 #define TOC_CONNECT_STEPS 3 |
| 5605 | 121 |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
122 static void toc_login_callback(gpointer, gint, GaimInputCondition); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
123 static void toc_callback(gpointer, gint, GaimInputCondition); |
| 2086 | 124 |
| 125 /* ok. this function used to take username/password, and return 0 on success. | |
| 126 * now, it takes username/password, and returns NULL on error or a new gaim_connection | |
| 127 * on success. */ | |
| 11837 | 128 static void toc_login(GaimAccount *account) |
| 2086 | 129 { |
| 5605 | 130 GaimConnection *gc; |
| 2086 | 131 struct toc_data *tdt; |
| 132 char buf[80]; | |
| 133 | |
| 5605 | 134 gc = gaim_account_get_connection(account); |
| 2086 | 135 gc->proto_data = tdt = g_new0(struct toc_data, 1); |
| 6622 | 136 gc->flags |= GAIM_CONNECTION_HTML; |
| 137 gc->flags |= GAIM_CONNECTION_AUTO_RESP; | |
| 2086 | 138 |
| 4834 | 139 g_snprintf(buf, sizeof buf, _("Looking up %s"), |
| 5605 | 140 gaim_account_get_string(account, "server", TOC_HOST)); |
| 9140 | 141 gaim_connection_update_progress(gc, buf, 0, TOC_CONNECT_STEPS); |
| 2086 | 142 |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
143 gaim_debug(GAIM_DEBUG_INFO, "toc", "Client connects to TOC\n"); |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
144 if (gaim_proxy_connect(account, |
| 5605 | 145 gaim_account_get_string(account, "server", TOC_HOST), |
| 146 gaim_account_get_int(account, "port", TOC_PORT), | |
| 4491 | 147 toc_login_callback, gc) != 0 || !account->gc) { |
| 6321 | 148 g_snprintf(buf, sizeof(buf), _("Connect to %s failed"), |
| 5605 | 149 gaim_account_get_string(account, "server", TOC_HOST)); |
| 150 gaim_connection_error(gc, buf); | |
| 2086 | 151 return; |
| 152 } | |
| 153 } | |
| 154 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
155 static void toc_login_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 156 { |
| 5605 | 157 GaimConnection *gc = data; |
| 2086 | 158 struct toc_data *tdt; |
| 159 char buf[80]; | |
| 4597 | 160 struct sockaddr_in name; |
| 161 socklen_t namelen; | |
| 2086 | 162 |
| 14119 | 163 if (!GAIM_CONNECTION_IS_VALID(gc)) { |
| 164 if (source >= 0) | |
| 165 close(source); | |
| 2086 | 166 return; |
| 167 } | |
| 168 | |
| 169 tdt = gc->proto_data; | |
| 170 | |
| 171 if (source == -1) { | |
| 172 /* we didn't successfully connect. tdt->toc_fd is valid here */ | |
| 6321 | 173 gaim_connection_error(gc, _("Unable to connect.")); |
| 2086 | 174 return; |
| 175 } | |
| 4452 | 176 tdt->toc_fd = source; |
| 2086 | 177 |
| 4597 | 178 /* |
| 179 * Copy the IP that we're connected to. We need this because "GOTO_URL"'s | |
| 180 * should open on the exact server we're connected to. toc.oscar.aol.com | |
| 181 * doesn't work because that hostname resolves to multiple IP addresses. | |
| 182 */ | |
| 183 if (getpeername(tdt->toc_fd, (struct sockaddr *)&name, &namelen) == 0) | |
| 184 strncpy(tdt->toc_ip, inet_ntoa(name.sin_addr), sizeof(tdt->toc_ip)); | |
| 185 else | |
| 5605 | 186 strncpy(tdt->toc_ip, gaim_account_get_string(gc->account, "server", TOC_HOST), sizeof(tdt->toc_ip)); |
| 4597 | 187 |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
188 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
189 "Client sends \"FLAPON\\r\\n\\r\\n\"\n"); |
| 9134 | 190 if (write(tdt->toc_fd, FLAPON, strlen(FLAPON)) < 0) { |
| 6321 | 191 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 192 return; |
| 193 } | |
| 194 tdt->state = STATE_FLAPON; | |
| 195 | |
| 196 /* i know a lot of people like to look at gaim to see how TOC works. so i'll comment | |
| 197 * on what this does. it's really simple. when there's data ready to be read from the | |
| 198 * toc_fd file descriptor, toc_callback is called, with gc passed as its data arg. */ | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
199 gc->inpa = gaim_input_add(tdt->toc_fd, GAIM_INPUT_READ, toc_callback, gc); |
| 2086 | 200 |
| 5605 | 201 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gaim_account_get_username(gc->account)); |
| 9140 | 202 gaim_connection_update_progress(gc, buf, 1, TOC_CONNECT_STEPS); |
| 2086 | 203 } |
| 204 | |
| 5605 | 205 static void toc_close(GaimConnection *gc) |
| 2086 | 206 { |
| 207 if (gc->inpa > 0) | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
208 gaim_input_remove(gc->inpa); |
| 2086 | 209 gc->inpa = 0; |
| 9134 | 210 close(((struct toc_data *)gc->proto_data)->toc_fd); |
| 2086 | 211 g_free(gc->proto_data); |
| 212 } | |
| 213 | |
| 5605 | 214 static void toc_build_config(GaimAccount *account, char *s, int len, gboolean show) |
| 4687 | 215 { |
| 6695 | 216 GaimBlistNode *gnode, *cnode, *bnode; |
| 217 GaimGroup *g; | |
| 218 GaimBuddy *b; | |
| 4687 | 219 GSList *plist = account->permit; |
| 220 GSList *dlist = account->deny; | |
| 221 | |
| 222 int pos = 0; | |
| 223 | |
| 5605 | 224 if (!account->perm_deny) |
| 225 account->perm_deny = 1; | |
| 4687 | 226 |
| 5605 | 227 pos += g_snprintf(&s[pos], len - pos, "m %d\n", account->perm_deny); |
| 4785 | 228 for(gnode = gaim_get_blist()->root; gnode && len > pos; gnode = gnode->next) { |
| 6695 | 229 g = (GaimGroup *)gnode; |
| 4785 | 230 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
| 231 continue; | |
| 4687 | 232 if(gaim_group_on_account(g, account)) { |
| 233 pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name); | |
| 6695 | 234 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 235 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 4785 | 236 continue; |
| 6695 | 237 for(bnode = gnode->child; bnode && len > pos; bnode = bnode->next) { |
| 238 b = (GaimBuddy *)bnode; | |
| 239 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 240 continue; | |
| 241 if(b->account == account) { | |
| 242 pos += g_snprintf(&s[pos], len - pos, "b %s%s%s\n", | |
| 243 b->name, | |
| 244 (show && b->alias) ? ":" : "", | |
| 245 (show && b->alias) ? b->alias : ""); | |
| 246 } | |
| 4687 | 247 } |
| 248 } | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 while (len > pos && plist) { | |
| 253 pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data); | |
| 254 plist = plist->next; | |
| 255 } | |
| 256 | |
| 257 while (len > pos && dlist) { | |
| 258 pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data); | |
| 259 dlist = dlist->next; | |
| 260 } | |
| 261 } | |
| 262 | |
| 6306 | 263 char *escape_message(const char *msg) |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
264 { |
| 6306 | 265 char *ret; |
| 266 int i, j; | |
| 267 | |
| 268 if (!msg) | |
| 269 return NULL; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
270 |
| 6306 | 271 /* Calculate the length after escaping */ |
| 272 for (i=0, j=0; msg[i]; i++) | |
| 273 switch (msg[i]) { | |
| 274 case '$': | |
| 275 case '[': | |
| 276 case ']': | |
| 277 case '(': | |
| 278 case ')': | |
| 279 j++; | |
| 280 default: | |
| 281 j++; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
282 } |
| 6306 | 283 |
| 284 /* Allocate a string */ | |
| 7606 | 285 ret = (char *)g_malloc((j+1) * sizeof(char)); |
| 6306 | 286 |
| 287 /* Copy the string */ | |
| 288 for (i=0, j=0; msg[i]; i++) | |
| 289 switch (msg[i]) { | |
| 290 case '$': | |
| 291 case '[': | |
| 292 case ']': | |
| 293 case '(': | |
| 294 case ')': | |
| 295 ret[j++] = '\\'; | |
| 296 default: | |
| 297 ret[j++] = msg[i]; | |
| 298 } | |
| 299 ret[j] = '\0'; | |
| 300 | |
| 301 return ret; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
302 } |
|
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
303 |
| 6059 | 304 /* |
| 305 * Duplicates the input string, replacing each \n with a <BR>, and | |
| 306 * escaping a few other characters. | |
| 307 */ | |
| 308 char *escape_text(const char *msg) | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
309 { |
| 6059 | 310 char *ret; |
| 311 int i, j; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
312 |
| 6059 | 313 if (!msg) |
| 314 return NULL; | |
| 315 | |
| 316 /* Calculate the length after escaping */ | |
| 6306 | 317 for (i=0, j=0; msg[i]; i++) |
| 6059 | 318 switch (msg[i]) { |
| 6306 | 319 case '\n': |
| 320 j += 4; | |
| 321 break; | |
| 322 case '{': | |
| 323 case '}': | |
| 324 case '\\': | |
| 325 case '"': | |
| 326 j += 1; | |
| 327 default: | |
| 328 j += 1; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
329 } |
| 6059 | 330 |
| 331 /* Allocate a string */ | |
| 332 ret = (char *)malloc((j+1) * sizeof(char)); | |
| 333 | |
| 334 /* Copy the string */ | |
| 6306 | 335 for (i=0, j=0; msg[i]; i++) |
| 6059 | 336 switch (msg[i]) { |
| 6306 | 337 case '\n': |
| 338 ret[j++] = '<'; | |
| 339 ret[j++] = 'B'; | |
| 340 ret[j++] = 'R'; | |
| 341 ret[j++] = '>'; | |
| 342 break; | |
| 343 case '{': | |
| 344 case '}': | |
| 345 case '\\': | |
| 346 case '"': | |
| 347 ret[j++] = '\\'; | |
| 348 default: | |
| 349 ret[j++] = msg[i]; | |
| 6059 | 350 } |
| 351 ret[j] = '\0'; | |
| 352 | |
| 353 return ret; | |
|
2371
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
354 } |
|
db02399a9ad7
[gaim-migrate @ 2384]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2343
diff
changeset
|
355 |
| 6306 | 356 static int sflap_send(GaimConnection *gc, const char *buf, int olen, int type) |
| 2086 | 357 { |
| 6306 | 358 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 2086 | 359 int len; |
| 360 int slen = 0; | |
| 6306 | 361 int ret; |
| 2086 | 362 struct sflap_hdr hdr; |
| 6306 | 363 char *escaped, *obuf; |
| 2086 | 364 |
| 365 if (tdt->state == STATE_PAUSE) | |
| 366 /* TOC has given us the PAUSE message; sending could cause a disconnect | |
| 367 * so we just return here like everything went through fine */ | |
| 368 return 0; | |
| 369 | |
| 6306 | 370 if (olen < 0) { |
| 371 escaped = escape_message(buf); | |
| 6500 | 372 len = strlen(escaped); |
| 6306 | 373 } else { |
| 374 escaped = g_memdup(buf, olen); | |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
375 len = olen; |
| 6306 | 376 } |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
377 |
| 6306 | 378 /* |
| 379 * One _last_ 2048 check here! This shouldn't ever | |
| 380 * get hit though, hopefully. If it gets hit on an IM | |
| 381 * It'll lose the last " and the message won't go through, | |
| 382 * but this'll stop a segfault. | |
| 383 */ | |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
384 if (len > MSG_LEN) { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
385 gaim_debug(GAIM_DEBUG_WARNING, "toc", "message too long, truncating\n"); |
| 6306 | 386 escaped[MSG_LEN - 1] = '\0'; |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
387 len = MSG_LEN; |
| 2086 | 388 } |
| 389 | |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
390 if (olen < 0) |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
391 gaim_debug(GAIM_DEBUG_INFO, "toc", "C: %s\n", escaped); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
392 |
| 2086 | 393 hdr.ast = '*'; |
| 394 hdr.type = type; | |
| 395 hdr.seqno = htons(tdt->seqno++ & 0xffff); | |
| 396 hdr.len = htons(len + (type == TYPE_SIGNON ? 0 : 1)); | |
| 397 | |
| 6306 | 398 obuf = (char *)malloc((sizeof(hdr)+len+1) * sizeof(char)); |
| 2086 | 399 memcpy(obuf, &hdr, sizeof(hdr)); |
| 400 slen += sizeof(hdr); | |
| 6306 | 401 |
| 402 memcpy(&obuf[slen], escaped, len); | |
| 2086 | 403 slen += len; |
| 6306 | 404 |
| 2086 | 405 if (type != TYPE_SIGNON) { |
| 406 obuf[slen] = '\0'; | |
| 407 slen += 1; | |
| 408 } | |
| 409 | |
| 9134 | 410 ret = write(tdt->toc_fd, obuf, slen); |
| 6306 | 411 free(obuf); |
| 7606 | 412 g_free(escaped); |
| 6306 | 413 |
| 414 return ret; | |
| 2086 | 415 } |
| 416 | |
| 5605 | 417 static int wait_reply(GaimConnection *gc, char *buffer, size_t buflen) |
| 2086 | 418 { |
| 419 struct toc_data *tdt = (struct toc_data *)gc->proto_data; | |
| 420 struct sflap_hdr *hdr; | |
| 421 int ret; | |
| 422 | |
| 9134 | 423 if (read(tdt->toc_fd, buffer, sizeof(struct sflap_hdr)) < 0) { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
424 gaim_debug(GAIM_DEBUG_ERROR, "toc", "Couldn't read flap header\n"); |
| 2086 | 425 return -1; |
| 426 } | |
| 427 | |
| 428 hdr = (struct sflap_hdr *)buffer; | |
| 429 | |
| 430 if (buflen < ntohs(hdr->len)) { | |
| 431 /* fake like there's a read error */ | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
432 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
433 "buffer too small (have %d, need %d)\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
434 buflen, ntohs(hdr->len)); |
| 2086 | 435 return -1; |
| 436 } | |
| 437 | |
| 438 if (ntohs(hdr->len) > 0) { | |
| 439 int count = 0; | |
| 440 ret = 0; | |
| 441 do { | |
| 442 count += ret; | |
| 9134 | 443 ret = read(tdt->toc_fd, |
| 2086 | 444 buffer + sizeof(struct sflap_hdr) + count, ntohs(hdr->len) - count); |
| 445 } while (count + ret < ntohs(hdr->len) && ret > 0); | |
| 446 buffer[sizeof(struct sflap_hdr) + count + ret] = '\0'; | |
| 447 return ret; | |
| 448 } else | |
| 449 return 0; | |
| 450 } | |
| 451 | |
| 5605 | 452 static unsigned char *roast_password(const char *pass) |
| 2086 | 453 { |
| 454 /* Trivial "encryption" */ | |
| 455 static unsigned char rp[256]; | |
| 456 static char *roast = ROAST; | |
| 457 int pos = 2; | |
| 458 int x; | |
| 459 strcpy(rp, "0x"); | |
| 460 for (x = 0; (x < 150) && pass[x]; x++) | |
| 461 pos += sprintf(&rp[pos], "%02x", pass[x] ^ roast[x % strlen(roast)]); | |
| 462 rp[pos] = '\0'; | |
| 463 return rp; | |
| 464 } | |
| 465 | |
|
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
466 static void toc_got_info(void *data, const char *url_text, size_t len) |
| 2086 | 467 { |
| 468 if (!url_text) | |
| 469 return; | |
| 470 | |
|
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
471 gaim_notify_formatted(data, NULL, _("Buddy Information"), NULL, |
|
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
472 url_text, NULL, NULL); |
| 2086 | 473 } |
| 474 | |
|
2453
b72143059ad4
[gaim-migrate @ 2466]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
475 static char *show_error_message() |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
476 { |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
477 int no = atoi(strtok(NULL, ":")); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
478 char *w = strtok(NULL, ":"); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
479 static char buf[256]; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
480 |
| 6500 | 481 switch(no) { |
| 482 case 69: | |
| 483 g_snprintf(buf, sizeof(buf), _("Unable to write file %s."), w); | |
| 484 break; | |
| 485 case 169: | |
| 486 g_snprintf(buf, sizeof(buf), _("Unable to read file %s."), w); | |
| 487 break; | |
| 488 case 269: | |
| 489 g_snprintf(buf, sizeof(buf), _("Message too long, last %s bytes truncated."), w); | |
| 490 break; | |
| 491 case 901: | |
| 492 g_snprintf(buf, sizeof(buf), _("%s not currently logged in."), w); | |
| 493 break; | |
| 494 case 902: | |
| 495 g_snprintf(buf, sizeof(buf), _("Warning of %s not allowed."), w); | |
| 496 break; | |
| 497 case 903: | |
| 498 g_snprintf(buf, sizeof(buf), _("A message has been dropped, you are exceeding the server speed limit.")); | |
| 499 break; | |
| 500 case 950: | |
| 501 g_snprintf(buf, sizeof(buf), _("Chat in %s is not available."), w); | |
| 502 break; | |
| 503 case 960: | |
| 504 g_snprintf(buf, sizeof(buf), _("You are sending messages too fast to %s."), w); | |
| 505 break; | |
| 506 case 961: | |
| 507 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was too big."), w); | |
| 508 break; | |
| 509 case 962: | |
| 510 g_snprintf(buf, sizeof(buf), _("You missed an IM from %s because it was sent too fast."), w); | |
| 511 break; | |
| 512 case 970: | |
| 513 g_snprintf(buf, sizeof(buf), _("Failure.")); | |
| 514 break; | |
| 515 case 971: | |
| 516 g_snprintf(buf, sizeof(buf), _("Too many matches.")); | |
| 517 break; | |
| 518 case 972: | |
| 519 g_snprintf(buf, sizeof(buf), _("Need more qualifiers.")); | |
| 520 break; | |
| 521 case 973: | |
| 522 g_snprintf(buf, sizeof(buf), _("Dir service temporarily unavailable.")); | |
| 523 break; | |
| 524 case 974: | |
|
13545
cfc2f7fcb3dd
[gaim-migrate @ 15922]
Richard Laager <rlaager@wiktel.com>
parents:
13296
diff
changeset
|
525 g_snprintf(buf, sizeof(buf), _("E-mail lookup restricted.")); |
| 6500 | 526 break; |
| 527 case 975: | |
| 528 g_snprintf(buf, sizeof(buf), _("Keyword ignored.")); | |
| 529 break; | |
| 530 case 976: | |
| 531 g_snprintf(buf, sizeof(buf), _("No keywords.")); | |
| 532 break; | |
| 533 case 977: | |
| 534 g_snprintf(buf, sizeof(buf), _("User has no directory information.")); | |
| 535 /* g_snprintf(buf, sizeof(buf), _("Language not supported.")); */ | |
| 536 break; | |
| 537 case 978: | |
| 538 g_snprintf(buf, sizeof(buf), _("Country not supported.")); | |
| 539 break; | |
| 540 case 979: | |
| 541 g_snprintf(buf, sizeof(buf), _("Failure unknown: %s."), w); | |
| 542 break; | |
| 543 case 980: | |
| 544 g_snprintf(buf, sizeof(buf), _("Incorrect nickname or password.")); | |
| 545 break; | |
| 546 case 981: | |
| 547 g_snprintf(buf, sizeof(buf), _("The service is temporarily unavailable.")); | |
| 548 break; | |
| 549 case 982: | |
| 550 g_snprintf(buf, sizeof(buf), _("Your warning level is currently too high to log in.")); | |
| 551 break; | |
| 552 case 983: | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
553 g_snprintf(buf, sizeof(buf), _("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.")); |
| 6500 | 554 break; |
| 555 g_snprintf(buf, sizeof(buf), _("An unknown signon error has occurred: %s."), w); | |
| 556 break; | |
| 557 default: | |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
558 g_snprintf(buf, sizeof(buf), _("An unknown error, %d, has occurred. Info: %s"), no, w); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
559 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
560 |
| 6500 | 561 return buf; |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
562 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
563 |
| 10744 | 564 static void |
| 565 parse_toc_buddy_list(GaimAccount *account, char *config) | |
| 566 { | |
| 567 char *c; | |
| 568 char current[256]; | |
| 569 GList *buddies = NULL; | |
| 570 | |
| 571 if (config == NULL) | |
| 572 return; | |
| 573 | |
| 574 /* skip "CONFIG:" (if it exists) */ | |
| 575 c = strncmp(config + 6 /* sizeof(struct sflap_hdr) */ , "CONFIG:", strlen("CONFIG:")) ? | |
| 576 strtok(config, "\n") : | |
| 577 strtok(config + 6 /* sizeof(struct sflap_hdr) */ + strlen("CONFIG:"), "\n"); | |
| 578 do { | |
| 579 if (c == NULL) | |
| 580 break; | |
| 581 if (*c == 'g') { | |
| 582 char *utf8 = NULL; | |
| 583 utf8 = gaim_utf8_try_convert(c + 2); | |
| 584 if (utf8 == NULL) { | |
| 585 g_strlcpy(current, _("Invalid Groupname"), sizeof(current)); | |
| 586 } else { | |
| 587 g_strlcpy(current, utf8, sizeof(current)); | |
| 588 g_free(utf8); | |
| 589 } | |
| 590 if (!gaim_find_group(current)) { | |
| 591 GaimGroup *g = gaim_group_new(current); | |
| 592 gaim_blist_add_group(g, NULL); | |
| 593 } | |
| 594 } else if (*c == 'b') { /*&& !gaim_find_buddy(user, c + 2)) {*/ | |
| 595 char nm[80], sw[388], *a, *utf8 = NULL; | |
| 596 | |
| 597 if ((a = strchr(c + 2, ':')) != NULL) { | |
| 598 *a++ = '\0'; /* nul the : */ | |
| 599 } | |
| 600 | |
| 601 g_strlcpy(nm, c + 2, sizeof(nm)); | |
| 602 if (a) { | |
| 603 utf8 = gaim_utf8_try_convert(a); | |
| 604 if (utf8 == NULL) { | |
| 605 gaim_debug(GAIM_DEBUG_ERROR, "toc blist", | |
| 606 "Failed to convert alias for " | |
| 607 "'%s' to UTF-8\n", nm); | |
| 608 } | |
| 609 } | |
| 610 if (utf8 == NULL) { | |
| 611 sw[0] = '\0'; | |
| 612 } else { | |
| 613 /* This can leave a partial sequence at the end, | |
| 614 * but who cares? */ | |
| 615 g_strlcpy(sw, utf8, sizeof(sw)); | |
| 616 g_free(utf8); | |
| 617 } | |
| 618 | |
| 619 if (!gaim_find_buddy(account, nm)) { | |
| 620 GaimBuddy *b = gaim_buddy_new(account, nm, sw); | |
| 621 GaimGroup *g = gaim_find_group(current); | |
| 622 gaim_blist_add_buddy(b, NULL, g, NULL); | |
| 623 buddies = g_list_append(buddies, b); | |
| 624 } | |
| 625 } else if (*c == 'p') { | |
| 626 gaim_privacy_permit_add(account, c + 2, TRUE); | |
| 627 } else if (*c == 'd') { | |
| 628 gaim_privacy_deny_add(account, c + 2, TRUE); | |
| 629 } else if (!strncmp("toc", c, 3)) { | |
| 630 sscanf(c + strlen(c) - 1, "%d", &account->perm_deny); | |
| 631 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | |
| 632 "permdeny: %d\n", account->perm_deny); | |
| 633 if (account->perm_deny == 0) | |
| 634 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | |
| 635 } else if (*c == 'm') { | |
| 636 sscanf(c + 2, "%d", &account->perm_deny); | |
| 637 gaim_debug(GAIM_DEBUG_MISC, "toc blist", | |
| 638 "permdeny: %d\n", account->perm_deny); | |
| 639 if (account->perm_deny == 0) | |
| 640 account->perm_deny = GAIM_PRIVACY_ALLOW_ALL; | |
| 641 } | |
| 642 } while ((c = strtok(NULL, "\n"))); | |
| 643 | |
| 644 if (account->gc) { | |
| 645 if (buddies != NULL) { | |
| 11643 | 646 gaim_account_add_buddies(account, buddies); |
| 10744 | 647 g_list_free(buddies); |
| 648 } | |
| 649 serv_set_permit_deny(account->gc); | |
| 650 } | |
| 651 g_list_free(buddies); | |
| 652 } | |
| 653 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
654 static void toc_callback(gpointer data, gint source, GaimInputCondition condition) |
| 2086 | 655 { |
| 5605 | 656 GaimConnection *gc = (GaimConnection *)data; |
| 9058 | 657 GaimAccount *account = gaim_connection_get_account(gc); |
| 2086 | 658 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 659 struct sflap_hdr *hdr; | |
| 660 struct signon so; | |
| 661 char buf[8 * 1024], *c; | |
| 662 char snd[BUF_LEN * 2]; | |
| 9058 | 663 const char *username = gaim_account_get_username(account); |
| 5605 | 664 char *password; |
| 9285 | 665 GaimBuddy *buddy; |
| 5605 | 666 |
| 2086 | 667 /* there's data waiting to be read, so read it. */ |
| 668 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | |
| 5605 | 669 gaim_connection_error(gc, _("Connection Closed")); |
| 2086 | 670 return; |
| 671 } | |
| 672 | |
| 673 if (tdt->state == STATE_FLAPON) { | |
| 674 hdr = (struct sflap_hdr *)buf; | |
| 675 if (hdr->type != TYPE_SIGNON) | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
676 gaim_debug(GAIM_DEBUG_ERROR, "toc", "hdr->type != TYPE_SIGNON\n"); |
| 2086 | 677 else |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
678 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
679 "TOC sends Client FLAP SIGNON\n"); |
| 2086 | 680 tdt->seqno = ntohs(hdr->seqno); |
| 681 tdt->state = STATE_SIGNON_REQUEST; | |
| 682 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
683 gaim_debug(GAIM_DEBUG_INFO, "toc", "Client sends TOC FLAP SIGNON\n"); |
| 5605 | 684 g_snprintf(so.username, sizeof(so.username), "%s", username); |
| 2086 | 685 so.ver = htonl(1); |
| 686 so.tag = htons(1); | |
| 687 so.namelen = htons(strlen(so.username)); | |
| 688 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | |
| 5605 | 689 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 690 return; |
| 691 } | |
| 692 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
693 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
694 "Client sends TOC \"toc_signon\" message\n"); |
|
2853
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
695 /* i hate icq. */ |
| 5605 | 696 if (username[0] >= '0' && username[0] <= '9') |
| 10744 | 697 password = g_strndup(gaim_connection_get_password(gc), 8); |
| 5605 | 698 else |
| 10744 | 699 password = g_strdup(gaim_connection_get_password(gc)); |
| 2086 | 700 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
| 10011 | 701 AUTH_HOST, AUTH_PORT, gaim_normalize(account, username), |
| 5605 | 702 roast_password(password), LANGUAGE, REVISION); |
| 703 g_free(password); | |
| 2086 | 704 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 5605 | 705 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 706 return; |
| 707 } | |
| 708 | |
| 9140 | 709 gaim_connection_update_progress(gc, _("Waiting for reply..."), 2, TOC_CONNECT_STEPS); |
| 2086 | 710 return; |
| 711 } | |
| 712 | |
| 713 if (tdt->state == STATE_SIGNON_REQUEST) { | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
714 gaim_debug(GAIM_DEBUG_INFO, "toc", "TOC sends client SIGN_ON reply\n"); |
| 4793 | 715 if (g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "SIGN_ON", strlen("SIGN_ON"))) { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
716 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
717 "Didn't get SIGN_ON! buf was: %s\n", |
| 2086 | 718 buf + sizeof(struct sflap_hdr)); |
| 4793 | 719 if (!g_ascii_strncasecmp(buf + sizeof(struct sflap_hdr), "ERROR", 5)) { |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
720 strtok(buf + sizeof(struct sflap_hdr), ":"); |
| 5605 | 721 gaim_connection_error(gc, show_error_message()); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
722 } else |
| 6623 | 723 gaim_connection_error(gc, _("Authentication failed")); |
| 2086 | 724 return; |
| 725 } | |
| 726 /* we're supposed to check that it's really TOC v1 here but we know it is ;) */ | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
727 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
728 "TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
| 2086 | 729 |
| 730 /* we used to check for the CONFIG here, but we'll wait until we've sent our | |
| 731 * version of the config and then the toc_init_done message. we'll come back to | |
| 732 * the callback in a better state if we get CONFIG anyway */ | |
| 733 | |
| 734 tdt->state = STATE_ONLINE; | |
| 735 | |
| 5605 | 736 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 2086 | 737 |
| 9058 | 738 /* |
| 739 * Add me to my buddy list so that we know the time when | |
| 740 * the server thinks I signed on. | |
| 741 */ | |
| 9285 | 742 buddy = gaim_buddy_new(account, username, NULL); |
| 743 /* XXX - Pick a group to add to */ | |
| 744 /* gaim_blist_add(buddy, NULL, g, NULL); */ | |
| 11643 | 745 gaim_account_add_buddy(gc, buddy); |
| 9058 | 746 |
| 2086 | 747 /* Client sends TOC toc_init_done message */ |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
748 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
749 "Client sends TOC toc_init_done message\n"); |
| 2086 | 750 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 751 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 752 | |
| 753 /* | |
| 754 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
| 755 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
| 756 */ | |
| 757 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | |
| 758 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 759 | |
| 760 return; | |
| 761 } | |
| 762 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
763 gaim_debug(GAIM_DEBUG_INFO, "toc", "S: %s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
764 buf + sizeof(struct sflap_hdr)); |
| 2086 | 765 |
| 766 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | |
| 767 | |
| 4793 | 768 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
| 2086 | 769 /* we should only get here after a PAUSE */ |
| 770 if (tdt->state != STATE_PAUSE) | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
771 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
772 "got SIGN_ON but not PAUSE!\n"); |
| 2086 | 773 else { |
| 774 tdt->state = STATE_ONLINE; | |
| 775 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | |
| 5605 | 776 AUTH_HOST, AUTH_PORT, |
| 10011 | 777 gaim_normalize(account, gaim_account_get_username(account)), |
| 10744 | 778 roast_password(gaim_connection_get_password(gc)), |
| 5605 | 779 LANGUAGE, REVISION); |
| 2086 | 780 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 5605 | 781 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 782 return; |
| 783 } | |
| 784 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
| 785 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
786 gaim_notify_info(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
787 _("TOC has come back from its pause. You may " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
788 "now send messages again."), NULL); |
| 2086 | 789 } |
| 4793 | 790 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 2086 | 791 c = strtok(NULL, ":"); |
| 10744 | 792 parse_toc_buddy_list(account, c); |
| 4793 | 793 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
| 2086 | 794 /* ignore NICK so that things get imported/exported properly |
| 795 c = strtok(NULL, ":"); | |
| 796 g_snprintf(gc->username, sizeof(gc->username), "%s", c); | |
| 797 */ | |
| 4793 | 798 } else if (!g_ascii_strcasecmp(c, "IM_IN")) { |
| 2086 | 799 char *away, *message; |
| 800 int a = 0; | |
| 801 | |
| 802 c = strtok(NULL, ":"); | |
| 803 away = strtok(NULL, ":"); | |
| 804 | |
| 805 message = away; | |
| 806 while (*message && (*message != ':')) | |
| 807 message++; | |
| 808 message++; | |
| 809 | |
| 12216 | 810 a = (away && (*away == 'T')) ? GAIM_MESSAGE_AUTO_RESP : 0; |
| 2086 | 811 |
| 6982 | 812 serv_got_im(gc, c, message, a, time(NULL)); |
| 4793 | 813 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
814 char *l, *uc, *tmp; |
| 9927 | 815 gboolean logged_in; |
| 816 int evil, idle, type = 0; | |
| 2086 | 817 time_t signon, time_idle; |
| 818 | |
| 819 c = strtok(NULL, ":"); /* name */ | |
| 820 l = strtok(NULL, ":"); /* online */ | |
| 821 sscanf(strtok(NULL, ":"), "%d", &evil); | |
| 822 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
| 823 sscanf(strtok(NULL, ":"), "%d", &idle); | |
| 824 uc = strtok(NULL, ":"); | |
| 825 | |
| 9927 | 826 logged_in = (l && (*l == 'T')) ? TRUE : FALSE; |
| 2086 | 827 |
| 828 if (uc[0] == 'A') | |
| 829 type |= UC_AOL; | |
| 830 switch (uc[1]) { | |
| 831 case 'A': | |
| 832 type |= UC_ADMIN; | |
| 833 break; | |
| 834 case 'U': | |
| 835 type |= UC_UNCONFIRMED; | |
| 836 break; | |
| 837 case 'O': | |
| 838 type |= UC_NORMAL; | |
| 839 break; | |
| 3083 | 840 case 'C': |
| 841 type |= UC_WIRELESS; | |
| 842 break; | |
| 2086 | 843 default: |
| 844 break; | |
| 845 } | |
| 846 if (uc[2] == 'U') | |
| 847 type |= UC_UNAVAILABLE; | |
| 848 | |
| 849 if (idle) { | |
| 850 time(&time_idle); | |
| 851 time_idle -= idle * 60; | |
| 852 } else | |
| 853 time_idle = 0; | |
| 854 | |
| 9058 | 855 /* |
| 856 * If we have info for ourselves then set our display name, warning | |
| 857 * level and official time of login. | |
| 858 */ | |
| 10011 | 859 tmp = g_strdup(gaim_normalize(account, gaim_account_get_username(gc->account))); |
| 860 if (!strcmp(tmp, gaim_normalize(account, c))) { | |
| 5605 | 861 gaim_connection_set_display_name(gc, c); |
| 10011 | 862 /* XXX - What should the second parameter be here? */ |
| 11257 | 863 /* gaim_prpl_got_account_warning_level(account, NULL, evil);*/ |
| 10870 | 864 gaim_prpl_got_account_login_time(account, signon); |
| 9058 | 865 } |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
866 g_free(tmp); |
|
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
867 |
| 10011 | 868 gaim_prpl_got_user_status(account, c, (logged_in ? "online" : "offline"), NULL); |
| 869 gaim_prpl_got_user_login_time(account, c, signon); | |
| 870 if (time_idle > 0) | |
| 871 gaim_prpl_got_user_idle(account, c, TRUE, time_idle); | |
| 872 else | |
| 873 gaim_prpl_got_user_idle(account, c, FALSE, 0); | |
| 4793 | 874 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
875 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
| 4793 | 876 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 2086 | 877 int lev; |
| 878 char *name; | |
| 879 | |
| 880 sscanf(strtok(NULL, ":"), "%d", &lev); | |
| 881 name = strtok(NULL, ":"); | |
| 882 | |
| 11257 | 883 /* gaim_prpl_got_account_warning_level(account, name, lev); */ |
| 4793 | 884 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
| 2086 | 885 char *name; |
| 886 int id; | |
| 887 | |
| 888 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 889 name = strtok(NULL, ":"); | |
| 890 | |
| 891 serv_got_joined_chat(gc, id, name); | |
| 4793 | 892 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
| 9584 | 893 int id; |
| 12216 | 894 GaimMessageFlags flags; |
| 2086 | 895 char *m, *who, *whisper; |
| 896 | |
| 897 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 898 who = strtok(NULL, ":"); | |
| 899 whisper = strtok(NULL, ":"); | |
| 900 m = whisper; | |
| 901 while (*m && (*m != ':')) | |
| 902 m++; | |
| 903 m++; | |
| 904 | |
| 12216 | 905 flags = (whisper && (*whisper == 'T')) ? GAIM_MESSAGE_WHISPER : 0; |
| 2086 | 906 |
| 9584 | 907 serv_got_chat_in(gc, id, who, flags, m, time((time_t)NULL)); |
| 4793 | 908 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 2086 | 909 int id; |
| 910 char *in, *buddy; | |
| 911 GSList *bcs = gc->buddy_chats; | |
| 5679 | 912 GaimConversation *b = NULL; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
913 GaimConvChat *chat; |
| 2086 | 914 |
| 915 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 916 in = strtok(NULL, ":"); | |
| 917 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
918 chat = GAIM_CONV_CHAT(b); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
919 |
| 2086 | 920 while (bcs) { |
| 5679 | 921 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
922 if (id == gaim_conv_chat_get_id(chat)) |
| 2086 | 923 break; |
| 924 bcs = bcs->next; | |
| 925 b = NULL; | |
| 926 } | |
| 927 | |
| 928 if (!b) | |
| 929 return; | |
| 930 | |
| 931 if (in && (*in == 'T')) | |
| 932 while ((buddy = strtok(NULL, ":")) != NULL) | |
| 9846 | 933 gaim_conv_chat_add_user(chat, buddy, NULL, GAIM_CBFLAGS_NONE, TRUE); |
| 2086 | 934 else |
| 935 while ((buddy = strtok(NULL, ":")) != NULL) | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
936 gaim_conv_chat_remove_user(chat, buddy, NULL); |
| 4793 | 937 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
| 2086 | 938 char *name, *who, *message; |
| 5234 | 939 int id; |
| 940 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 941 g_free, g_free); | |
| 2086 | 942 |
| 943 name = strtok(NULL, ":"); | |
| 5234 | 944 sscanf(strtok(NULL, ":"), "%d", &id); |
| 2086 | 945 who = strtok(NULL, ":"); |
| 946 message = strtok(NULL, ":"); | |
| 947 | |
| 5234 | 948 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); |
| 949 | |
| 950 serv_got_chat_invite(gc, name, who, message, components); | |
| 4793 | 951 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
| 2086 | 952 GSList *bcs = gc->buddy_chats; |
| 5679 | 953 GaimConversation *b = NULL; |
| 2086 | 954 int id; |
| 955 | |
| 956 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 957 | |
| 958 while (bcs) { | |
| 5679 | 959 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
960 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 961 break; |
| 962 b = NULL; | |
| 963 bcs = bcs->next; | |
| 964 } | |
| 965 | |
| 966 if (!b) | |
| 967 return; | |
| 968 | |
| 969 if (b->window) { | |
| 970 char error_buf[BUF_LONG]; | |
| 4491 | 971 gaim_conversation_set_account(b, NULL); |
| 2086 | 972 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 973 " from chat room %s."), b->name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
974 gaim_notify_error(gc, NULL, error_buf, NULL); |
| 2086 | 975 } else |
| 976 serv_got_chat_left(gc, id); | |
| 4793 | 977 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 2086 | 978 char *name, *url, tmp[256]; |
| 979 | |
| 980 name = strtok(NULL, ":"); | |
| 981 url = strtok(NULL, ":"); | |
| 982 | |
| 4597 | 983 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 5605 | 984 gaim_account_get_int(gc->account, "port", TOC_PORT), |
| 2086 | 985 url); |
|
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
986 gaim_url_fetch(tmp, FALSE, NULL, FALSE, toc_got_info, gc); |
| 4793 | 987 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 988 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | |
| 989 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
990 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
| 4793 | 991 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 2086 | 992 tdt->state = STATE_PAUSE; |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
993 gaim_notify_warning(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
994 _("TOC has sent a PAUSE command."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
995 _("When this happens, TOC ignores any messages " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
996 "sent to it, and may kick you off if you send a" |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
997 " message. Gaim will prevent anything from " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
998 "going through. This is only temporary, please " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
999 "be patient.")); |
| 4793 | 1000 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 6867 | 1001 #if 0 |
| 2086 | 1002 char *user, *uuid, *cookie; |
| 1003 int seq; | |
| 3159 | 1004 char *rip, *pip, *vip, *trillian = NULL; |
| 2086 | 1005 int port; |
| 3126 | 1006 |
| 2086 | 1007 user = strtok(NULL, ":"); |
| 1008 uuid = strtok(NULL, ":"); | |
| 1009 cookie = strtok(NULL, ":"); | |
| 1010 sscanf(strtok(NULL, ":"), "%d", &seq); | |
| 1011 rip = strtok(NULL, ":"); | |
| 1012 pip = strtok(NULL, ":"); | |
| 1013 vip = strtok(NULL, ":"); | |
| 1014 sscanf(strtok(NULL, ":"), "%d", &port); | |
| 1015 | |
| 1016 if (!strcmp(uuid, FILE_SEND_UID)) { | |
| 1017 /* they want us to get a file */ | |
| 1018 int unk[4], i; | |
| 1019 char *messages[4], *tmp, *name; | |
| 1020 int subtype, files, totalsize = 0; | |
| 1021 struct ft_request *ft; | |
| 1022 | |
| 1023 for (i = 0; i < 4; i++) { | |
| 3126 | 1024 trillian = strtok(NULL, ":"); |
| 1025 sscanf(trillian, "%d", &unk[i]); | |
| 2086 | 1026 if (unk[i] == 10001) |
| 1027 break; | |
| 3126 | 1028 /* Trillian likes to send an empty token as a message, rather than |
| 1029 no message at all. */ | |
| 1030 if (*(trillian + strlen(trillian) +1) != ':') | |
| 1031 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 1032 } |
| 3126 | 1033 |
| 2086 | 1034 frombase64(strtok(NULL, ":"), &tmp, NULL); |
| 1035 | |
| 1036 subtype = tmp[1]; | |
| 1037 files = tmp[3]; | |
| 1038 | |
| 1039 totalsize |= (tmp[4] << 24) & 0xff000000; | |
| 1040 totalsize |= (tmp[5] << 16) & 0x00ff0000; | |
| 1041 totalsize |= (tmp[6] << 8) & 0x0000ff00; | |
| 1042 totalsize |= (tmp[7] << 0) & 0x000000ff; | |
| 1043 | |
| 1044 if (!totalsize) { | |
| 1045 g_free(tmp); | |
| 1046 for (i--; i >= 0; i--) | |
| 1047 g_free(messages[i]); | |
| 1048 return; | |
| 1049 } | |
| 1050 | |
| 1051 name = tmp + 8; | |
| 1052 | |
| 1053 ft = g_new0(struct ft_request, 1); | |
| 1054 ft->cookie = g_strdup(cookie); | |
| 1055 ft->ip = g_strdup(pip); | |
| 1056 ft->port = port; | |
| 1057 if (i) | |
| 1058 ft->message = g_strdup(messages[0]); | |
| 1059 else | |
| 1060 ft->message = NULL; | |
| 1061 ft->filename = g_strdup(name); | |
| 1062 ft->user = g_strdup(user); | |
| 1063 ft->size = totalsize; | |
| 1064 ft->files = files; | |
| 1065 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_SEND_UID); | |
| 1066 ft->gc = gc; | |
| 1067 | |
| 1068 g_free(tmp); | |
| 1069 for (i--; i >= 0; i--) | |
| 1070 g_free(messages[i]); | |
| 1071 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1072 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1073 "English translation of RVOUS_PROPOSE: %s requests " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1074 "Send File (i.e. send a file to you); %s:%d " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1075 "(verified_ip:port), %d files at total size of " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1076 "%d bytes.\n", user, vip, port, files, totalsize); |
| 2086 | 1077 accept_file_dialog(ft); |
| 1078 } else if (!strcmp(uuid, FILE_GET_UID)) { | |
| 1079 /* they want us to send a file */ | |
| 1080 int unk[4], i; | |
| 1081 char *messages[4], *tmp; | |
| 1082 struct ft_request *ft; | |
| 1083 | |
| 1084 for (i = 0; i < 4; i++) { | |
| 1085 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 1086 if (unk[i] == 10001) | |
| 1087 break; | |
| 3126 | 1088 /* Trillian likes to send an empty token as a message, rather than |
| 1089 no message at all. */ | |
| 1090 if (*(trillian + strlen(trillian) +1) != ':') | |
| 1091 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 1092 } |
| 1093 frombase64(strtok(NULL, ":"), &tmp, NULL); | |
| 1094 | |
| 1095 ft = g_new0(struct ft_request, 1); | |
| 1096 ft->cookie = g_strdup(cookie); | |
| 1097 ft->ip = g_strdup(pip); | |
| 1098 ft->port = port; | |
| 1099 if (i) | |
| 1100 ft->message = g_strdup(messages[0]); | |
| 1101 else | |
| 1102 ft->message = NULL; | |
| 1103 ft->user = g_strdup(user); | |
| 1104 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_GET_UID); | |
| 1105 ft->gc = gc; | |
| 1106 | |
| 1107 g_free(tmp); | |
| 1108 for (i--; i >= 0; i--) | |
| 1109 g_free(messages[i]); | |
| 1110 | |
| 1111 accept_file_dialog(ft); | |
| 1112 } else if (!strcmp(uuid, VOICE_UID)) { | |
| 1113 /* oh goody. voice over ip. fun stuff. */ | |
| 1114 } else if (!strcmp(uuid, B_ICON_UID)) { | |
| 1115 int unk[4], i; | |
| 1116 char *messages[4]; | |
| 1117 struct buddy_icon *icon; | |
| 1118 | |
| 1119 for (i = 0; i < 4; i++) { | |
| 1120 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 1121 if (unk[i] == 10001) | |
| 1122 break; | |
| 1123 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 1124 } | |
| 1125 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
| 1126 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1127 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1128 "received icon of length %d\n", icon->len); |
| 2086 | 1129 g_free(icon); |
| 1130 for (i--; i >= 0; i--) | |
| 1131 g_free(messages[i]); | |
| 1132 } else if (!strcmp(uuid, IMAGE_UID)) { | |
| 1133 /* aka Direct IM */ | |
| 1134 } else { | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1135 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1136 "Don't know what to do with RVOUS UUID %s\n", uuid); |
| 2086 | 1137 /* do we have to do anything here? i think it just times out */ |
| 1138 } | |
| 6867 | 1139 #endif |
| 2086 | 1140 } else { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1141 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1142 "don't know what to do with %s\n", c); |
| 2086 | 1143 } |
| 1144 } | |
| 1145 | |
| 12216 | 1146 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags flags) |
| 2086 | 1147 { |
| 6061 | 1148 char *buf1, *buf2; |
| 2086 | 1149 |
| 6855 | 1150 #if 1 |
| 1151 /* This is the old, non-i18n way */ | |
| 6061 | 1152 buf1 = escape_text(message); |
| 1153 if (strlen(buf1) + 52 > MSG_LEN) { | |
| 1154 g_free(buf1); | |
|
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1155 return -E2BIG; |
|
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1156 } |
| 7261 | 1157 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(gc->account, name), buf1, |
| 12216 | 1158 ((flags & GAIM_MESSAGE_AUTO_RESP) ? " auto" : "")); |
| 6061 | 1159 g_free(buf1); |
| 6855 | 1160 #else |
| 1161 /* This doesn't work yet. See the comments below for details */ | |
| 1162 buf1 = gaim_strreplace(message, "\"", "\\\""); | |
| 1163 | |
| 1164 /* | |
| 1165 * We still need to determine what encoding should be used and send the | |
| 1166 * message in that encoding. This should be done the same as in | |
| 1167 * oscar_encoding_check() in oscar.c. There is no encoding flag sent | |
| 1168 * along with the message--the TOC to OSCAR proxy server must just | |
| 1169 * use a lil' algorithm to determine what the actual encoding is. | |
| 1170 * | |
| 1171 * After that, you need to convert buf1 to that encoding, and keep track | |
| 1172 * of the length of the resulting string. Then you need to make sure | |
| 1173 * that length is passed to sflap_send(). | |
| 1174 */ | |
| 1175 | |
| 6982 | 1176 if (strlen(buf1) + 52 > MSG_LEN) { |
| 6855 | 1177 g_free(buf1); |
| 1178 return -E2BIG; | |
| 1179 } | |
| 1180 | |
| 7261 | 1181 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(gc->account, name), buf1, |
| 12216 | 1182 ((flags & GAIM_MESSAGE_AUTO_RESP) ? "auto" : "")); |
| 6855 | 1183 g_free(buf1); |
| 1184 #endif | |
| 1185 | |
| 6061 | 1186 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1187 g_free(buf2); | |
| 1188 | |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2281
diff
changeset
|
1189 return 1; |
| 2086 | 1190 } |
| 1191 | |
| 5605 | 1192 static void toc_set_config(GaimConnection *gc) |
| 2086 | 1193 { |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1194 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 4491 | 1195 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 2086 | 1196 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 1197 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1198 g_free(buf); |
| 2086 | 1199 } |
| 1200 | |
| 7261 | 1201 static void toc_get_info(GaimConnection *gc, const char *name) |
| 2086 | 1202 { |
| 1203 char buf[BUF_LEN * 2]; | |
| 7261 | 1204 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(gc->account, name)); |
| 1205 sflap_send(gc, buf, -1, TYPE_DATA); | |
| 2086 | 1206 } |
| 1207 | |
| 8950 | 1208 /* Should be implemented as an Account Action? */ |
| 9030 | 1209 static void toc_get_dir(GaimBlistNode *node, gpointer data) |
| 2086 | 1210 { |
| 9030 | 1211 GaimBuddy *buddy; |
| 1212 GaimConnection *gc; | |
| 2086 | 1213 char buf[BUF_LEN * 2]; |
| 9030 | 1214 |
| 1215 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
| 1216 | |
| 1217 buddy = (GaimBuddy *) node; | |
| 9058 | 1218 gc = gaim_account_get_connection(buddy->account); |
| 9030 | 1219 |
| 1220 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", | |
| 1221 gaim_normalize(buddy->account, buddy->name)); | |
| 7261 | 1222 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1223 } |
| 1224 | |
| 8950 | 1225 #if 0 |
| 1226 /* Should be implemented as an Account Action */ | |
| 5605 | 1227 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1228 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 2086 | 1229 { |
| 6059 | 1230 char *buf3, buf2[BUF_LEN * 4], buf[BUF_LEN]; |
| 2086 | 1231 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 1232 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | |
| 6059 | 1233 buf3 = escape_text(buf2); |
| 1234 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf3); | |
| 1235 g_free(buf3); | |
| 2086 | 1236 sflap_send(g, buf, -1, TYPE_DATA); |
| 1237 } | |
| 8950 | 1238 #endif |
| 2086 | 1239 |
| 8950 | 1240 #if 0 |
| 1241 /* Should be implemented as an Account Action */ | |
| 5605 | 1242 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1243 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
| 2086 | 1244 { |
| 1245 char buf[BUF_LONG]; | |
| 1246 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | |
| 1247 last, maiden, city, state, country, email); | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1248 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1249 "Searching for: %s,%s,%s,%s,%s,%s,%s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1250 first, middle, last, maiden, |
| 2086 | 1251 city, state, country); |
| 1252 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1253 } | |
| 8950 | 1254 #endif |
| 2086 | 1255 |
| 10401 | 1256 static void toc_set_status(GaimAccount *account, GaimStatus *status) |
| 2086 | 1257 { |
| 10401 | 1258 #if 0 /* do we care about TOC any more? */ |
| 2086 | 1259 char buf[BUF_LEN * 2]; |
| 10011 | 1260 if (gc->away) { |
| 1261 g_free(gc->away); | |
| 1262 gc->away = NULL; | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1263 } |
| 2086 | 1264 if (message) { |
| 6059 | 1265 char *tmp; |
| 10011 | 1266 gc->away = g_strdup(message); |
| 6059 | 1267 tmp = escape_text(message); |
| 3188 | 1268 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", tmp); |
| 1269 g_free(tmp); | |
| 2086 | 1270 } else |
| 1271 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
| 1272 sflap_send(g, buf, -1, TYPE_DATA); | |
| 10401 | 1273 #endif |
| 2086 | 1274 } |
| 1275 | |
| 5954 | 1276 static void toc_set_info(GaimConnection *g, const char *info) |
| 2086 | 1277 { |
| 6059 | 1278 char buf[BUF_LEN * 2], *buf2; |
| 1279 buf2 = escape_text(info); | |
| 2086 | 1280 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); |
| 6059 | 1281 g_free(buf2); |
| 2086 | 1282 sflap_send(g, buf, -1, TYPE_DATA); |
| 1283 } | |
| 1284 | |
| 5605 | 1285 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) |
| 2086 | 1286 { |
| 1287 char buf[BUF_LEN * 2]; | |
| 1288 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
| 6306 | 1289 sflap_send(g, buf, -1, TYPE_DATA); |
| 2086 | 1290 } |
| 1291 | |
| 7261 | 1292 static void |
| 9285 | 1293 toc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2086 | 1294 { |
| 1295 char buf[BUF_LEN * 2]; | |
| 9285 | 1296 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(gc->account, buddy->name)); |
| 7261 | 1297 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1298 toc_set_config(gc); | |
| 2086 | 1299 } |
| 1300 | |
| 9285 | 1301 static void toc_add_buddies(GaimConnection *gc, GList *buddies, GList *groups) |
| 2086 | 1302 { |
| 1303 char buf[BUF_LEN * 2]; | |
| 1304 int n; | |
| 9285 | 1305 GList *cur; |
| 2086 | 1306 |
| 1307 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 9285 | 1308 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1309 GaimBuddy *buddy = cur->data; | |
| 1310 | |
| 1311 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | |
| 7261 | 1312 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1313 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
| 1314 } | |
| 9285 | 1315 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name)); |
| 2086 | 1316 } |
| 7261 | 1317 sflap_send(gc, buf, -1, TYPE_DATA); |
| 2086 | 1318 } |
| 1319 | |
| 9285 | 1320 static void toc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2086 | 1321 { |
| 1322 char buf[BUF_LEN * 2]; | |
| 9285 | 1323 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(gc->account, buddy->name)); |
| 7261 | 1324 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1325 toc_set_config(gc); | |
| 2086 | 1326 } |
| 1327 | |
| 9285 | 1328 static void toc_remove_buddies(GaimConnection *gc, GList *buddies, GList *groups) |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1329 { |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1330 char buf[BUF_LEN * 2]; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1331 int n; |
| 9285 | 1332 GList *cur; |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1333 |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1334 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
| 9285 | 1335 for (cur = buddies; cur != NULL; cur = cur->next) { |
| 1336 GaimBuddy *buddy = cur->data; | |
| 1337 | |
| 1338 if (strlen(gaim_normalize(gc->account, buddy->name)) + n + 32 > MSG_LEN) { | |
| 7261 | 1339 sflap_send(gc, buf, -1, TYPE_DATA); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1340 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1341 } |
| 9285 | 1342 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(gc->account, buddy->name)); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1343 } |
| 7261 | 1344 sflap_send(gc, buf, -1, TYPE_DATA); |
| 1345 toc_set_config(gc); | |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1346 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1347 |
| 5605 | 1348 static void toc_set_idle(GaimConnection *g, int time) |
| 2086 | 1349 { |
| 1350 char buf[BUF_LEN * 2]; | |
| 1351 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
| 1352 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1353 } | |
| 1354 | |
| 6059 | 1355 static void toc_warn(GaimConnection *g, const char *name, int anon) |
| 2086 | 1356 { |
| 1357 char send[BUF_LEN * 2]; | |
| 1358 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | |
| 1359 sflap_send(g, send, -1, TYPE_DATA); | |
| 1360 } | |
| 1361 | |
| 5605 | 1362 static GList *toc_chat_info(GaimConnection *gc) |
| 2086 | 1363 { |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1364 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1365 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1366 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1367 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 1368 pce->label = _("_Group:"); |
| 5234 | 1369 pce->identifier = "room"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1370 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1371 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1372 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 1373 pce->label = _("_Exchange:"); |
| 5234 | 1374 pce->identifier = "exchange"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1375 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1376 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1377 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1378 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1379 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1380 return m; |
| 2086 | 1381 } |
| 1382 | |
| 9754 | 1383 GHashTable *toc_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
| 1384 { | |
| 1385 GHashTable *defaults; | |
| 1386 | |
| 1387 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 1388 | |
| 1389 if (chat_name != NULL) | |
| 1390 g_hash_table_insert(defaults, "room", g_strdup(chat_name)); | |
| 1391 | |
| 1392 return defaults; | |
| 1393 } | |
| 1394 | |
| 5605 | 1395 static void toc_join_chat(GaimConnection *g, GHashTable *data) |
| 2086 | 1396 { |
| 1397 char buf[BUF_LONG]; | |
| 5234 | 1398 char *name, *exchange; |
| 1399 char *id; | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1400 |
| 5234 | 1401 name = g_hash_table_lookup(data, "room"); |
| 1402 exchange = g_hash_table_lookup(data, "exchange"); | |
| 1403 id = g_hash_table_lookup(data, "id"); | |
| 1404 | |
| 1405 if (id) { | |
| 1406 g_snprintf(buf, 255, "toc_chat_accept %d", atoi(id)); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1407 } else { |
| 5234 | 1408 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_join %d \"%s\"", atoi(exchange), name); |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1409 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1410 |
| 2086 | 1411 sflap_send(g, buf, -1, TYPE_DATA); |
| 1412 } | |
| 1413 | |
| 7261 | 1414 static void toc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
| 2086 | 1415 { |
| 1416 char buf[BUF_LONG]; | |
|
2719
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1417 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
| 7261 | 1418 message ? message : "", gaim_normalize(gc->account, name)); |
| 1419 sflap_send(gc, buf, -1, TYPE_DATA); | |
| 2086 | 1420 } |
| 1421 | |
| 5605 | 1422 static void toc_chat_leave(GaimConnection *g, int id) |
| 2086 | 1423 { |
| 1424 GSList *bcs = g->buddy_chats; | |
| 5679 | 1425 GaimConversation *b = NULL; |
| 2086 | 1426 char buf[BUF_LEN * 2]; |
| 1427 | |
| 1428 while (bcs) { | |
| 5679 | 1429 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1430 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 1431 break; |
| 1432 b = NULL; | |
| 1433 bcs = bcs->next; | |
| 1434 } | |
| 1435 | |
| 1436 if (!b) | |
| 1437 return; /* can this happen? */ | |
| 1438 | |
| 4491 | 1439 if (gaim_conversation_get_account(b) == NULL) { |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1440 /* TOC already kicked us out of this room */ |
| 2086 | 1441 serv_got_chat_left(g, id); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1442 } |
| 2086 | 1443 else { |
| 1444 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
| 1445 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1446 } | |
| 1447 } | |
| 1448 | |
| 7261 | 1449 static void toc_chat_whisper(GaimConnection *gc, int id, const char *who, const char *message) |
| 2086 | 1450 { |
| 6059 | 1451 char *buf1, *buf2; |
| 1452 buf1 = escape_text(message); | |
| 7261 | 1453 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(gc->account, who), buf1); |
| 6059 | 1454 g_free(buf1); |
| 7261 | 1455 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 6059 | 1456 g_free(buf2); |
| 2086 | 1457 } |
| 1458 | |
| 12216 | 1459 static int toc_chat_send(GaimConnection *g, int id, const char *message, GaimMessageFlags flags) |
| 2086 | 1460 { |
| 6059 | 1461 char *buf1, *buf2; |
| 1462 buf1 = escape_text(message); | |
| 1463 if (strlen(buf1) > 2000) { | |
| 1464 g_free(buf1); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1465 return -E2BIG; |
| 6059 | 1466 } |
| 1467 buf2 = g_strdup_printf("toc_chat_send %d \"%s\"", id, buf1); | |
| 1468 g_free(buf1); | |
| 1469 sflap_send(g, buf2, -1, TYPE_DATA); | |
| 1470 g_free(buf2); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1471 return 0; |
| 2086 | 1472 } |
| 1473 | |
| 5605 | 1474 static void toc_keepalive(GaimConnection *gc) |
| 2086 | 1475 { |
| 1476 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | |
| 1477 } | |
| 1478 | |
| 11153 | 1479 static const char * |
| 1480 toc_normalize(const GaimAccount *account, const char *str) | |
| 1481 { | |
| 1482 static char buf[BUF_LEN]; | |
| 1483 char *tmp1, *tmp2; | |
| 1484 int i, j; | |
| 1485 | |
| 1486 g_return_val_if_fail(str != NULL, NULL); | |
| 1487 | |
| 1488 strncpy(buf, str, BUF_LEN); | |
| 1489 for (i=0, j=0; buf[j]; i++, j++) | |
| 1490 { | |
| 1491 while (buf[j] == ' ') | |
| 1492 j++; | |
| 1493 buf[i] = buf[j]; | |
| 1494 } | |
| 1495 buf[i] = '\0'; | |
| 1496 | |
| 1497 tmp1 = g_utf8_strdown(buf, -1); | |
| 1498 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT); | |
| 1499 g_snprintf(buf, sizeof(buf), "%s", tmp2); | |
| 1500 g_free(tmp2); | |
| 1501 g_free(tmp1); | |
| 1502 | |
| 1503 return buf; | |
| 1504 } | |
| 1505 | |
| 6695 | 1506 static const char *toc_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 1507 { |
| 5971 | 1508 if (!b || (b && b->name && b->name[0] == '+')) { |
| 6695 | 1509 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
| 5971 | 1510 return "icq"; |
| 1511 else | |
| 1512 return "aim"; | |
| 1513 } | |
| 1514 | |
| 1515 if (b && b->name && isdigit(b->name[0])) | |
| 1516 return "icq"; | |
| 4687 | 1517 return "aim"; |
| 1518 } | |
| 4916 | 1519 |
| 9972 | 1520 static void toc_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
| 4916 | 1521 { |
| 1522 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 1523 int i = 0; | |
| 1524 | |
| 5971 | 1525 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
| 4916 | 1526 *se = "offline"; |
| 1527 return; | |
| 1528 } else { | |
| 1529 if (b->uc & UC_UNAVAILABLE) | |
| 1530 emblems[i++] = "away"; | |
| 1531 if (b->uc & UC_AOL) | |
| 1532 emblems[i++] = "aol"; | |
| 1533 if (b->uc & UC_ADMIN) | |
| 1534 emblems[i++] = "admin"; | |
| 1535 if (b->uc & UC_WIRELESS) | |
| 1536 emblems[i++] = "wireless"; | |
| 1537 } | |
| 1538 *se = emblems[0]; | |
| 1539 *sw = emblems[1]; | |
| 1540 *nw = emblems[2]; | |
| 1541 *ne = emblems[3]; | |
| 1542 } | |
| 2086 | 1543 |
| 9030 | 1544 static GList *toc_blist_node_menu(GaimBlistNode *node) |
| 2086 | 1545 { |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1546 GList *m = NULL; |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12650
diff
changeset
|
1547 GaimMenuAction *act; |
| 2086 | 1548 |
| 9030 | 1549 if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
|
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12650
diff
changeset
|
1550 act = gaim_menu_action_new(_("Get Dir Info"), |
|
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12650
diff
changeset
|
1551 toc_get_dir, NULL, NULL); |
| 9030 | 1552 m = g_list_append(m, act); |
| 1553 } | |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1554 |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1555 return m; |
| 2086 | 1556 } |
| 1557 | |
| 5605 | 1558 static void toc_add_permit(GaimConnection *gc, const char *who) |
| 2086 | 1559 { |
| 1560 char buf2[BUF_LEN * 2]; | |
| 5605 | 1561 if (gc->account->perm_deny != 3) |
| 2086 | 1562 return; |
| 7261 | 1563 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(gc->account, who)); |
| 2086 | 1564 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1565 toc_set_config(gc); | |
| 1566 } | |
| 1567 | |
| 5605 | 1568 static void toc_add_deny(GaimConnection *gc, const char *who) |
| 2086 | 1569 { |
| 1570 char buf2[BUF_LEN * 2]; | |
| 5605 | 1571 if (gc->account->perm_deny != 4) |
| 2086 | 1572 return; |
| 7261 | 1573 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(gc->account, who)); |
| 2086 | 1574 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1575 toc_set_config(gc); | |
| 1576 } | |
| 1577 | |
| 5605 | 1578 static void toc_set_permit_deny(GaimConnection *gc) |
| 2086 | 1579 { |
| 1580 char buf2[BUF_LEN * 2]; | |
| 1581 GSList *list; | |
| 1582 int at; | |
| 1583 | |
| 5605 | 1584 switch (gc->account->perm_deny) { |
| 2086 | 1585 case 1: |
| 1586 /* permit all, deny none. to get here reliably we need to have been in permit | |
| 1587 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | |
| 1588 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1589 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1590 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1591 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1592 break; | |
| 1593 case 2: | |
| 1594 /* deny all, permit none. to get here reliably we need to have been in deny | |
| 1595 * mode, and send an empty toc_add_permit message, which will switch us to permit none */ | |
| 1596 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1597 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1598 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1599 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1600 break; | |
| 1601 case 3: | |
| 1602 /* permit some. we want to switch to deny mode first, then send the toc_add_permit | |
| 1603 * message, which will clear and set our permit list. toc sucks. */ | |
| 1604 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1605 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1606 | |
| 1607 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 4491 | 1608 list = gc->account->permit; |
| 2086 | 1609 while (list) { |
| 7261 | 1610 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
| 2086 | 1611 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1612 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1613 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1614 } | |
| 1615 list = list->next; | |
| 1616 } | |
| 1617 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1618 break; | |
| 1619 case 4: | |
| 1620 /* deny some. we want to switch to permit mode first, then send the toc_add_deny | |
| 1621 * message, which will clear and set our deny list. toc sucks. */ | |
| 1622 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1623 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1624 | |
| 1625 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 4491 | 1626 list = gc->account->deny; |
| 2086 | 1627 while (list) { |
| 7261 | 1628 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(gc->account, list->data)); |
| 2086 | 1629 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1630 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1631 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1632 } | |
| 1633 list = list->next; | |
| 1634 } | |
| 1635 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1636 break; | |
| 1637 default: | |
| 1638 break; | |
| 1639 } | |
| 1640 toc_set_config(gc); | |
| 1641 } | |
| 1642 | |
| 5605 | 1643 static void toc_rem_permit(GaimConnection *gc, const char *who) |
| 2086 | 1644 { |
| 5605 | 1645 if (gc->account->perm_deny != 3) |
| 2086 | 1646 return; |
| 1647 toc_set_permit_deny(gc); | |
| 1648 } | |
| 1649 | |
| 5605 | 1650 static void toc_rem_deny(GaimConnection *gc, const char *who) |
| 2086 | 1651 { |
| 5605 | 1652 if (gc->account->perm_deny != 4) |
| 2086 | 1653 return; |
| 1654 toc_set_permit_deny(gc); | |
| 1655 } | |
| 1656 | |
| 10401 | 1657 static GList *toc_away_states(GaimAccount *account) |
| 2086 | 1658 { |
| 10401 | 1659 #if 0 /* do we care about TOC any more? */ |
| 2086 | 1660 return g_list_append(NULL, GAIM_AWAY_CUSTOM); |
| 10401 | 1661 #else |
| 1662 return NULL; | |
| 1663 #endif | |
| 2086 | 1664 } |
| 1665 | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1666 static void |
| 9015 | 1667 show_set_info(GaimPluginAction *action) |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1668 { |
| 9015 | 1669 GaimConnection *gc = (GaimConnection *) action->context; |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1670 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1671 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1672 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1673 static void |
| 9015 | 1674 change_pass(GaimPluginAction *action) |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1675 { |
| 9015 | 1676 GaimConnection *gc = (GaimConnection *) action->context; |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1677 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1678 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1679 |
| 9015 | 1680 static GList *toc_actions(GaimPlugin *plugin, gpointer context) |
| 2086 | 1681 { |
| 1682 GList *m = NULL; | |
| 9015 | 1683 GaimPluginAction *act; |
| 2086 | 1684 |
| 9015 | 1685 act = gaim_plugin_action_new(_("Set User Info"), |
| 1686 show_set_info); | |
| 1687 m = g_list_append(m, act); | |
| 4333 | 1688 |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1689 #if 0 |
| 9015 | 1690 act = gaim_plugin_action_new(_("Set Dir Info"), |
| 1691 show_set_dir); | |
| 1692 m = g_list_append(m, act); | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1693 #endif |
| 4333 | 1694 |
| 9015 | 1695 act = gaim_plugin_action_new(_("Change Password"), |
| 1696 change_pass); | |
| 1697 m = g_list_append(m, act); | |
| 2086 | 1698 |
| 1699 return m; | |
| 1700 } | |
| 1701 | |
| 6867 | 1702 #if 0 |
| 2086 | 1703 /********* |
| 1704 * RVOUS ACTIONS | |
| 1705 ********/ | |
| 1706 | |
| 1707 struct file_header { | |
| 1708 char magic[4]; /* 0 */ | |
| 1709 short hdrlen; /* 4 */ | |
| 1710 short hdrtype; /* 6 */ | |
| 1711 char bcookie[8]; /* 8 */ | |
| 1712 short encrypt; /* 16 */ | |
| 1713 short compress; /* 18 */ | |
| 1714 short totfiles; /* 20 */ | |
| 1715 short filesleft; /* 22 */ | |
| 1716 short totparts; /* 24 */ | |
| 1717 short partsleft; /* 26 */ | |
| 1718 long totsize; /* 28 */ | |
| 1719 long size; /* 32 */ | |
| 1720 long modtime; /* 36 */ | |
| 1721 long checksum; /* 40 */ | |
| 1722 long rfrcsum; /* 44 */ | |
| 1723 long rfsize; /* 48 */ | |
| 1724 long cretime; /* 52 */ | |
| 1725 long rfcsum; /* 56 */ | |
| 1726 long nrecvd; /* 60 */ | |
| 1727 long recvcsum; /* 64 */ | |
| 1728 char idstring[32]; /* 68 */ | |
| 1729 char flags; /* 100 */ | |
| 1730 char lnameoffset; /* 101 */ | |
| 1731 char lsizeoffset; /* 102 */ | |
| 1732 char dummy[69]; /* 103 */ | |
| 1733 char macfileinfo[16]; /* 172 */ | |
| 1734 short nencode; /* 188 */ | |
| 1735 short nlanguage; /* 190 */ | |
| 1736 char name[64]; /* 192 */ | |
| 1737 /* 256 */ | |
| 1738 }; | |
| 1739 | |
| 1740 struct file_transfer { | |
| 1741 struct file_header hdr; | |
| 1742 | |
| 5605 | 1743 GaimConnection *gc; |
| 2086 | 1744 |
| 1745 char *user; | |
| 1746 char *cookie; | |
| 1747 char *ip; | |
| 1748 int port; | |
| 1749 long size; | |
| 1750 struct stat st; | |
| 1751 | |
| 1752 GtkWidget *window; | |
| 1753 int files; | |
| 1754 char *filename; | |
| 1755 FILE *file; | |
| 1756 int recvsize; | |
| 1757 | |
| 1758 gint inpa; | |
| 1759 }; | |
| 1760 | |
| 1761 static void debug_header(struct file_transfer *ft) { | |
| 1762 struct file_header *f = (struct file_header *)ft; | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1763 gaim_debug(GAIM_DEBUG_MISC, "toc", "FT HEADER:\n" |
| 2086 | 1764 "\t%s %d 0x%04x\n" |
| 1765 "\t%s %d %d\n" | |
|
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1766 "\t%d %d %d %d %d %d\n" |
|
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1767 "\t%d %d %d %d %d %d %d %d\n" |
| 2086 | 1768 "\t%s\n" |
| 1769 "\t0x%02x, 0x%02x, 0x%02x\n" | |
| 1770 "\t%s %s\n" | |
| 1771 "\t%d %d\n" | |
| 1772 "\t%s\n", | |
| 1773 f->magic, ntohs(f->hdrlen), f->hdrtype, | |
| 1774 f->bcookie, ntohs(f->encrypt), ntohs(f->compress), | |
| 1775 ntohs(f->totfiles), ntohs(f->filesleft), ntohs(f->totparts), | |
| 1776 ntohs(f->partsleft), ntohl(f->totsize), ntohl(f->size), | |
| 1777 ntohl(f->modtime), ntohl(f->checksum), ntohl(f->rfrcsum), ntohl(f->rfsize), | |
| 1778 ntohl(f->cretime), ntohl(f->rfcsum), ntohl(f->nrecvd), | |
| 1779 ntohl(f->recvcsum), | |
| 1780 f->idstring, | |
| 1781 f->flags, f->lnameoffset, f->lsizeoffset, | |
| 1782 f->dummy, f->macfileinfo, | |
| 1783 ntohs(f->nencode), ntohs(f->nlanguage), | |
| 1784 f->name); | |
| 1785 } | |
| 1786 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1787 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1788 { |
| 1789 char buf[BUF_LONG]; | |
| 1790 int rt, i; | |
| 1791 | |
| 1792 struct file_transfer *ft = data; | |
| 1793 | |
| 1794 if (ft->hdr.hdrtype != 0x202) { | |
| 1795 char *buf; | |
| 1796 frombase64(ft->cookie, &buf, NULL); | |
| 1797 | |
| 9134 | 1798 read(source, ft, 8); |
| 1799 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1800 debug_header(ft); |
| 1801 | |
| 1802 ft->hdr.hdrtype = 0x202; | |
| 1803 memcpy(ft->hdr.bcookie, buf, 8); | |
| 1804 g_free(buf); | |
| 1805 ft->hdr.encrypt = 0; ft->hdr.compress = 0; | |
| 1806 debug_header(ft); | |
| 9134 | 1807 write(source, ft, 256); |
| 2086 | 1808 |
| 1809 if (ft->files == 1) { | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1810 ft->file = g_fopen(ft->filename, "w"); |
| 2086 | 1811 if (!ft->file) { |
| 4115 | 1812 buf = g_strdup_printf(_("Could not open %s for writing!"), ft->filename); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1813 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1814 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1815 gaim_input_remove(ft->inpa); |
| 9134 | 1816 close(source); |
| 2086 | 1817 g_free(ft->filename); |
| 1818 g_free(ft->user); | |
| 1819 g_free(ft->ip); | |
| 1820 g_free(ft->cookie); | |
| 1821 g_free(ft); | |
| 1822 } | |
| 1823 } else { | |
| 1824 buf = g_strdup_printf("%s/%s", ft->filename, ft->hdr.name); | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1825 ft->file = g_fopen(buf, "w"); |
| 2086 | 1826 g_free(buf); |
| 1827 if (!ft->file) { | |
| 1828 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | |
| 1829 ft->hdr.name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1830 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1831 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1832 gaim_input_remove(ft->inpa); |
| 9134 | 1833 close(source); |
| 2086 | 1834 g_free(ft->filename); |
| 1835 g_free(ft->user); | |
| 1836 g_free(ft->ip); | |
| 1837 g_free(ft->cookie); | |
| 1838 g_free(ft); | |
| 1839 } | |
| 1840 } | |
| 1841 | |
| 1842 return; | |
| 1843 } | |
| 1844 | |
| 9134 | 1845 rt = read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
| 2086 | 1846 if (rt < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1847 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1848 _("File transfer failed; other side probably " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1849 "canceled."), NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1850 gaim_input_remove(ft->inpa); |
| 9134 | 1851 close(source); |
| 2086 | 1852 g_free(ft->user); |
| 1853 g_free(ft->ip); | |
| 1854 g_free(ft->cookie); | |
| 1855 if (ft->file) | |
| 1856 fclose(ft->file); | |
| 1857 g_free(ft); | |
| 1858 return; | |
| 1859 } | |
| 1860 ft->recvsize += rt; | |
| 1861 for (i = 0; i < rt; i++) | |
| 1862 fprintf(ft->file, "%c", buf[i]); | |
| 1863 | |
| 1864 if (ft->recvsize == ntohl(ft->hdr.size)) { | |
| 1865 ft->hdr.hdrtype = htons(0x0204); | |
| 1866 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | |
| 1867 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | |
| 1868 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | |
| 1869 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | |
| 1870 ft->hdr.flags = 0; | |
| 9134 | 1871 write(source, ft, 256); |
| 2086 | 1872 debug_header(ft); |
| 1873 ft->recvsize = 0; | |
| 1874 fclose(ft->file); | |
| 1875 if (ft->hdr.filesleft == 0) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1876 gaim_input_remove(ft->inpa); |
| 9134 | 1877 close(source); |
| 2086 | 1878 g_free(ft->filename); |
| 1879 g_free(ft->user); | |
| 1880 g_free(ft->ip); | |
| 1881 g_free(ft->cookie); | |
| 1882 g_free(ft); | |
| 1883 } | |
| 1884 } | |
| 1885 } | |
| 1886 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1887 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 1888 { |
| 1889 struct file_transfer *ft = data; | |
| 1890 | |
| 1891 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1892 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1893 _("Could not connect for transfer."), NULL); |
| 2086 | 1894 g_free(ft->filename); |
| 1895 g_free(ft->cookie); | |
| 1896 g_free(ft->user); | |
| 1897 g_free(ft->ip); | |
| 1898 g_free(ft); | |
| 1899 return; | |
| 1900 } | |
| 1901 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1902 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); |
| 2086 | 1903 } |
| 1904 | |
| 1905 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | |
| 1906 { | |
| 1907 struct file_transfer *ft; | |
| 1908 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 1909 GaimAccount *account; |
| 2086 | 1910 char buf[BUF_LEN * 2]; |
| 1911 | |
| 5966 | 1912 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 1913 return; |
| 1914 ft = g_new0(struct file_transfer, 1); | |
| 1915 if (old_ft->files == 1) | |
| 1916 ft->filename = g_strdup(dirname); | |
| 1917 else | |
| 4793 | 1918 ft->filename = g_path_get_dirname(dirname); |
| 2086 | 1919 ft->cookie = g_strdup(old_ft->cookie); |
| 1920 ft->user = g_strdup(old_ft->user); | |
| 1921 ft->ip = g_strdup(old_ft->ip); | |
| 1922 ft->files = old_ft->files; | |
| 1923 ft->port = old_ft->port; | |
| 1924 ft->gc = old_ft->gc; | |
| 4491 | 1925 account = ft->gc->account; |
| 2086 | 1926 gtk_widget_destroy(old_ft->window); |
| 1927 | |
| 1928 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | |
| 1929 sflap_send(ft->gc, buf, -1, TYPE_DATA); | |
| 1930 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1931 if (gaim_proxy_connect(account, ft->ip, ft->port, toc_send_file_connect, ft) != 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1932 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1933 _("Could not connect for transfer."), NULL); |
| 2086 | 1934 g_free(ft->filename); |
| 1935 g_free(ft->cookie); | |
| 1936 g_free(ft->user); | |
| 1937 g_free(ft->ip); | |
| 1938 g_free(ft); | |
| 1939 return; | |
| 1940 } | |
| 1941 } | |
| 1942 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1943 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1944 { |
| 1945 char buf[BUF_LONG]; | |
| 1946 | |
| 1947 struct file_transfer *ft = data; | |
| 1948 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1949 if (cond & GAIM_INPUT_WRITE) { |
| 2086 | 1950 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
| 1951 int i; | |
| 1952 for (i = 0; i < remain; i++) | |
| 1953 fscanf(ft->file, "%c", &buf[i]); | |
| 9134 | 1954 write(source, buf, remain); |
| 2086 | 1955 ft->recvsize += remain; |
| 1956 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1957 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1958 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, |
| 2086 | 1959 toc_get_file_callback, ft); |
| 1960 } | |
| 1961 return; | |
| 1962 } | |
| 1963 | |
| 1964 if (ft->hdr.hdrtype == htons(0x1108)) { | |
| 1965 struct tm *fortime; | |
| 1966 struct stat st; | |
| 4793 | 1967 char *basename; |
| 2086 | 1968 |
| 9134 | 1969 read(source, ft, 8); |
| 1970 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1971 debug_header(ft); |
| 1972 | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1973 g_stat(ft->filename, &st); |
| 2086 | 1974 fortime = localtime(&st.st_mtime); |
| 4793 | 1975 basename = g_path_get_basename(ft->filename); |
| 2086 | 1976 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
| 1977 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | |
| 1978 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | |
| 4793 | 1979 basename); |
| 9134 | 1980 write(source, buf, ntohl(ft->hdr.size)); |
| 4793 | 1981 g_free(basename); |
| 2086 | 1982 return; |
| 1983 } | |
| 1984 | |
| 1985 if (ft->hdr.hdrtype == htons(0x1209)) { | |
| 9134 | 1986 read(source, ft, 8); |
| 1987 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1988 debug_header(ft); |
| 1989 return; | |
| 1990 } | |
| 1991 | |
| 1992 if (ft->hdr.hdrtype == htons(0x120b)) { | |
| 9134 | 1993 read(source, ft, 8); |
| 1994 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1995 debug_header(ft); |
| 1996 | |
| 1997 if (ft->hdr.hdrtype != htons(0x120c)) { | |
| 1998 g_snprintf(buf, sizeof(buf), "%s decided to cancel the transfer", ft->user); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1999 gaim_notify_error(ft->gc, NULL, buf, NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2000 gaim_input_remove(ft->inpa); |
| 9134 | 2001 close(source); |
| 2086 | 2002 g_free(ft->filename); |
| 2003 g_free(ft->user); | |
| 2004 g_free(ft->ip); | |
| 2005 g_free(ft->cookie); | |
| 2006 if (ft->file) | |
| 2007 fclose(ft->file); | |
| 2008 g_free(ft); | |
| 2009 return; | |
| 2010 } | |
| 2011 | |
| 2012 ft->hdr.hdrtype = 0x0101; | |
| 2013 ft->hdr.totfiles = htons(1); ft->hdr.filesleft = htons(1); | |
| 2014 ft->hdr.flags = 0x20; | |
| 9134 | 2015 write(source, ft, 256); |
| 2086 | 2016 return; |
| 2017 } | |
| 2018 | |
| 2019 if (ft->hdr.hdrtype == 0x0101) { | |
| 9134 | 2020 read(source, ft, 8); |
| 2021 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 2022 debug_header(ft); |
| 2023 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2024 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2025 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, |
| 2086 | 2026 toc_get_file_callback, ft); |
| 2027 return; | |
| 2028 } | |
| 2029 | |
| 2030 if (ft->hdr.hdrtype == 0x0202) { | |
| 9134 | 2031 read(source, ft, 8); |
| 2032 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 2033 debug_header(ft); |
| 2034 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2035 gaim_input_remove(ft->inpa); |
| 9134 | 2036 close(source); |
| 2086 | 2037 g_free(ft->filename); |
| 2038 g_free(ft->user); | |
| 2039 g_free(ft->ip); | |
| 2040 g_free(ft->cookie); | |
| 2041 if (ft->file) | |
| 2042 fclose(ft->file); | |
| 2043 g_free(ft); | |
| 2044 return; | |
| 2045 } | |
| 2046 } | |
| 2047 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2048 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 2049 { |
| 2050 struct file_transfer *ft = data; | |
| 2051 struct file_header *hdr; | |
| 2052 char *buf; | |
| 4793 | 2053 char *basename; |
| 2086 | 2054 |
| 2055 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2056 gaim_notify_error(ft->gc, NULL, |
| 7981 | 2057 _("Could not connect for transfer."), NULL); |
| 2086 | 2058 fclose(ft->file); |
| 2059 g_free(ft->filename); | |
| 2060 g_free(ft->cookie); | |
| 2061 g_free(ft->user); | |
| 2062 g_free(ft->ip); | |
| 2063 g_free(ft); | |
| 2064 return; | |
| 2065 } | |
| 2066 | |
| 2067 hdr = (struct file_header *)ft; | |
| 2068 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | |
| 2069 hdr->hdrlen = htons(256); | |
| 2070 hdr->hdrtype = htons(0x1108); | |
| 2071 frombase64(ft->cookie, &buf, NULL); | |
| 2072 g_snprintf(hdr->bcookie, 8, "%s", buf); | |
| 2073 g_free(buf); | |
| 2074 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | |
| 2075 hdr->totparts = htons(1); hdr->partsleft = htons(1); | |
| 2076 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | |
| 2077 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | |
| 4793 | 2078 basename = g_path_get_basename(ft->filename); |
| 2079 hdr->size = htonl(28 + strlen(basename)); /* size of listing.txt */ | |
| 2080 g_free(basename); | |
| 2086 | 2081 hdr->modtime = htonl(ft->st.st_mtime); |
| 2082 hdr->checksum = htonl(0x89f70000); /* uh... */ | |
| 2083 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); | |
| 2084 hdr->flags = 0x02; | |
| 2085 hdr->lnameoffset = 0x1A; | |
| 2086 hdr->lsizeoffset = 0x10; | |
| 2087 g_snprintf(hdr->name, 64, "listing.txt"); | |
| 9134 | 2088 if (write(src, hdr, 256) < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2089 gaim_notify_error(ft->gc, NULL, |
|
10816
c94f40ffcafb
[gaim-migrate @ 12471]
Luke Schierer <lschiere@pidgin.im>
parents:
10812
diff
changeset
|
2090 _("Could not write file header. The file will " |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2091 "not be transferred."), NULL); |
| 2086 | 2092 fclose(ft->file); |
| 2093 g_free(ft->filename); | |
| 2094 g_free(ft->cookie); | |
| 2095 g_free(ft->user); | |
| 2096 g_free(ft->ip); | |
| 2097 g_free(ft); | |
| 2098 return; | |
| 2099 } | |
| 2100 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
2101 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); |
| 2086 | 2102 } |
| 2103 | |
| 2104 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | |
| 2105 { | |
| 2106 struct file_transfer *ft; | |
| 2107 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 2108 GaimAccount *account; |
| 2086 | 2109 char *buf, buf2[BUF_LEN * 2]; |
| 2110 | |
| 5966 | 2111 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 2112 return; |
| 2113 ft = g_new0(struct file_transfer, 1); | |
| 2114 ft->filename = g_strdup(dirname); | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
2115 ft->file = g_fopen(ft->filename, "r"); |
| 2086 | 2116 if (!ft->file) { |
| 3427 | 2117 buf = g_strdup_printf("Unable to open %s for transfer.", ft->filename); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2118 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 2119 g_free(buf); |
| 2120 g_free(ft->filename); | |
| 2121 g_free(ft); | |
| 2122 return; | |
| 2123 } | |
|
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
2124 if (g_stat(dirname, &ft->st)) { |
| 3427 | 2125 buf = g_strdup_printf("Unable to examine %s.", dirname); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2126 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 2127 g_free(buf); |
| 2128 g_free(ft->filename); | |
| 2129 g_free(ft); | |
| 2130 return; | |
| 2131 } | |
| 2132 ft->cookie = g_strdup(old_ft->cookie); | |
| 2133 ft->user = g_strdup(old_ft->user); | |
| 2134 ft->ip = g_strdup(old_ft->ip); | |
| 2135 ft->port = old_ft->port; | |
| 2136 ft->gc = old_ft->gc; | |
| 4491 | 2137 account = ft->gc->account; |
| 2086 | 2138 gtk_widget_destroy(old_ft->window); |
| 2139 | |
| 2140 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | |
| 2141 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | |
| 2142 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
2143 if (gaim_proxy_connect(account, ft->ip, ft->port, toc_get_file_connect, ft) < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2144 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
2145 _("Could not connect for transfer."), NULL); |
| 2086 | 2146 fclose(ft->file); |
| 2147 g_free(ft->filename); | |
| 2148 g_free(ft->cookie); | |
| 2149 g_free(ft->user); | |
| 2150 g_free(ft->ip); | |
| 2151 g_free(ft); | |
| 2152 return; | |
| 2153 } | |
| 2154 } | |
| 2155 | |
| 2156 static void cancel_callback(gpointer a, struct file_transfer *ft) { | |
| 2157 gtk_widget_destroy(ft->window); | |
| 2158 if (a == ft->window) { | |
| 2159 g_free(ft->cookie); | |
| 2160 g_free(ft->user); | |
| 2161 g_free(ft->ip); | |
| 2162 g_free(ft); | |
| 2163 } | |
| 2164 } | |
| 2165 | |
| 3867 | 2166 static void toc_reject_ft(struct ft_request *ft) { |
| 2167 g_free(ft->user); | |
| 2168 g_free(ft->filename); | |
| 2169 g_free(ft->ip); | |
| 2170 g_free(ft->cookie); | |
| 2171 if (ft->message) | |
| 2172 g_free(ft->message); | |
| 2173 g_free(ft); | |
| 2174 } | |
| 2175 | |
| 2176 | |
| 3730 | 2177 static void toc_accept_ft(struct ft_request *fr) { |
| 5605 | 2178 if(g_list_find(gaim_connections_get_all(), fr->gc)) { |
| 4249 | 2179 GtkWidget *window; |
| 2180 char buf[BUF_LEN]; | |
| 2086 | 2181 |
| 4249 | 2182 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
| 2183 ft->gc = fr->gc; | |
| 2184 ft->user = g_strdup(fr->user); | |
| 2185 ft->cookie = g_strdup(fr->cookie); | |
| 2186 ft->ip = g_strdup(fr->ip); | |
| 2187 ft->port = fr->port; | |
| 2188 ft->files = fr->files; | |
| 2086 | 2189 |
| 4249 | 2190 ft->window = window = gtk_file_selection_new(_("Gaim - Save As...")); |
| 2191 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | |
| 2192 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
| 4635 | 2193 g_signal_connect(G_OBJECT(window), "destroy", |
| 2194 G_CALLBACK(cancel_callback), ft); | |
| 2195 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
| 2196 "clicked", G_CALLBACK(cancel_callback), ft); | |
| 2086 | 2197 |
| 4249 | 2198 if (!strcmp(fr->UID, FILE_SEND_UID)) |
| 4635 | 2199 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2200 "clicked", G_CALLBACK(toc_send_file), ft); | |
| 4249 | 2201 else |
| 4635 | 2202 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2203 "clicked", G_CALLBACK(toc_get_file), ft); | |
| 2086 | 2204 |
| 4249 | 2205 gtk_widget_show(window); |
| 2206 } | |
| 2207 | |
| 3867 | 2208 toc_reject_ft(fr); |
| 2086 | 2209 } |
| 2210 | |
| 2211 static void accept_file_dialog(struct ft_request *ft) { | |
| 2212 char buf[BUF_LONG]; | |
| 2213 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
| 2214 /* holy crap. who the fuck would transfer gigabytes through AIM?! */ | |
| 2215 static char *sizes[4] = { "bytes", "KB", "MB", "GB" }; | |
| 2216 float size = ft->size; | |
| 2217 int index = 0; | |
| 2218 while ((index < 4) && (size > 1024)) { | |
| 2219 size /= 1024; | |
| 2220 index++; | |
| 2221 } | |
| 6500 | 2222 g_snprintf(buf, sizeof(buf), |
| 4276 | 2223 ngettext( |
| 2224 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | |
| 2225 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | |
| 2226 ft->files), | |
| 5605 | 2227 ft->user, gaim_account_get_username(ft->gc->account), ft->files, |
| 2086 | 2228 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
| 2229 (ft->message) ? ft->message : ""); | |
| 2230 } else { | |
| 2231 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | |
| 2232 } | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2233 |
| 9948 | 2234 gaim_request_accept_cancel(ft->gc, NULL, buf, NULL, |
| 9970 | 2235 GAIM_DEFAULT_ACTION_NONE, ft, |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2236 G_CALLBACK(toc_accept_ft), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2237 G_CALLBACK(toc_reject_ft)); |
| 2086 | 2238 } |
| 6867 | 2239 #endif |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2240 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2241 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2242 { |
| 9058 | 2243 0, |
| 9475 | 2244 NULL, /* user_splits */ |
| 2245 NULL, /* protocol_options */ | |
| 2246 NO_BUDDY_ICONS, /* icon_spec */ | |
| 2247 toc_list_icon, /* list_icon */ | |
| 2248 toc_list_emblems, /* list_emblems */ | |
| 2249 NULL, /* status_text */ | |
| 2250 NULL, /* tooltip_text */ | |
| 2251 toc_away_states, /* away_states */ | |
| 2252 toc_blist_node_menu, /* blist_node_menu */ | |
| 2253 toc_chat_info, /* chat_info */ | |
| 9754 | 2254 toc_chat_info_defaults, /* chat_info_defaults */ |
| 9475 | 2255 toc_login, /* login */ |
| 2256 toc_close, /* close */ | |
| 2257 toc_send_im, /* send_im */ | |
| 2258 toc_set_info, /* set_info */ | |
| 2259 NULL, /* send_typing */ | |
| 2260 toc_get_info, /* get_info */ | |
| 10401 | 2261 toc_set_status, /* set_away */ |
| 9475 | 2262 toc_set_idle, /* set_idle */ |
| 2263 toc_change_passwd, /* change_passwd */ | |
| 2264 toc_add_buddy, /* add_buddy */ | |
| 2265 toc_add_buddies, /* add_buddies */ | |
| 2266 toc_remove_buddy, /* remove_buddy */ | |
| 2267 toc_remove_buddies, /* remove_buddies */ | |
| 2268 toc_add_permit, /* add_permit */ | |
| 2269 toc_add_deny, /* add_deny */ | |
| 2270 toc_rem_permit, /* rem_permit */ | |
| 2271 toc_rem_deny, /* rem_deny */ | |
| 2272 toc_set_permit_deny, /* set_permit_deny */ | |
| 2273 toc_join_chat, /* join_chat */ | |
| 2274 NULL, /* reject_chat */ | |
| 9917 | 2275 NULL, /* get_chat_name */ |
| 9475 | 2276 toc_chat_invite, /* chat_invite */ |
| 2277 toc_chat_leave, /* chat_leave */ | |
| 2278 toc_chat_whisper, /* chat_whisper */ | |
| 2279 toc_chat_send, /* chat_send */ | |
| 2280 toc_keepalive, /* keepalive */ | |
| 2281 NULL, /* register_user */ | |
| 2282 NULL, /* get_cb_info */ | |
| 2283 NULL, /* get_cb_away */ | |
| 2284 NULL, /* alias_buddy */ | |
| 2285 NULL, /* group_buddy */ | |
| 2286 NULL, /* rename_group */ | |
| 2287 NULL, /* buddy_free */ | |
| 2288 NULL, /* convo_closed */ | |
| 11153 | 2289 toc_normalize, /* normalize */ |
| 9475 | 2290 NULL, /* set_buddy_icon */ |
| 2291 NULL, /* remove_group */ | |
| 2292 NULL, /* get_cb_real_name */ | |
| 2293 NULL, /* set_chat_topic */ | |
| 2294 NULL, /* find_blist_chat */ | |
| 2295 NULL, /* roomlist_get_list */ | |
| 2296 NULL, /* roomlist_cancel */ | |
| 2297 NULL, /* roomlist_expand_category */ | |
| 2298 NULL, /* can_receive_file */ | |
|
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2299 NULL, /* send_file */ |
| 12650 | 2300 NULL, /* new_xfer */ |
| 2301 NULL, /* offline_message */ | |
| 2302 NULL, /* whiteboard_prpl_ops */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2303 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2304 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2305 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2306 { |
| 9954 | 2307 GAIM_PLUGIN_MAGIC, |
| 2308 GAIM_MAJOR_VERSION, | |
| 2309 GAIM_MINOR_VERSION, | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2310 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2311 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2312 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2313 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2314 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2315 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2316 "prpl-toc", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2317 "TOC", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2318 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2319 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2320 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2321 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2322 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2323 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
2324 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2325 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2326 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2327 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2328 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2329 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2330 NULL, /**< ui_info */ |
| 8993 | 2331 &prpl_info, /**< extra_info */ |
| 2332 NULL, | |
| 9015 | 2333 toc_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2334 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2335 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2336 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2337 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2338 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2339 GaimAccountOption *option; |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2340 |
|
13705
2f7b356812bc
[gaim-migrate @ 16108]
Richard Laager <rlaager@wiktel.com>
parents:
13545
diff
changeset
|
2341 option = gaim_account_option_string_new(_("Server"), "server", TOC_HOST); |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2342 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2343 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2344 |
|
13705
2f7b356812bc
[gaim-migrate @ 16108]
Richard Laager <rlaager@wiktel.com>
parents:
13545
diff
changeset
|
2345 option = gaim_account_option_int_new(_("Port"), "port", TOC_PORT); |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2346 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2347 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2348 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2349 my_protocol = plugin; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2350 } |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2351 |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2352 GAIM_INIT_PLUGIN(toc, init_plugin, info); |
