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