Mercurial > pidgin
annotate src/protocols/toc/toc.c @ 7132:d17a587efeb3
[gaim-migrate @ 7699]
new blist parser code, and some tweaks to the account code to make my next commit possible. the other parser code can get moved over to this model to make things cleaner, but i'm too lazy to do it now.
committer: Tailor Script <tailor@pidgin.im>
| author | Nathan Walp <nwalp@pidgin.im> |
|---|---|
| date | Fri, 03 Oct 2003 21:49:11 +0000 |
| parents | bf630f7dfdcd |
| children | 1930e3d00ecd |
| 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" |
| 2086 | 27 #include "prpl.h" |
| 28 #include "multi.h" | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
29 #include "notify.h" |
| 2086 | 30 #include "proxy.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 */ | |
| 312 ret = (char *)malloc((j+1) * sizeof(char)); | |
| 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); | |
| 439 free(escaped); | |
| 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; |
| 2086 | 594 struct toc_data *tdt = (struct toc_data *)gc->proto_data; |
| 595 struct sflap_hdr *hdr; | |
| 596 struct signon so; | |
| 597 char buf[8 * 1024], *c; | |
| 598 char snd[BUF_LEN * 2]; | |
| 599 | |
| 5605 | 600 const char *username = gaim_account_get_username(gc->account); |
| 601 char *password; | |
| 602 | |
| 2086 | 603 /* there's data waiting to be read, so read it. */ |
| 604 if (wait_reply(gc, buf, 8 * 1024) <= 0) { | |
| 5605 | 605 gaim_connection_error(gc, _("Connection Closed")); |
| 2086 | 606 return; |
| 607 } | |
| 608 | |
| 609 if (tdt->state == STATE_FLAPON) { | |
| 610 hdr = (struct sflap_hdr *)buf; | |
| 611 if (hdr->type != TYPE_SIGNON) | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
612 gaim_debug(GAIM_DEBUG_ERROR, "toc", "hdr->type != TYPE_SIGNON\n"); |
| 2086 | 613 else |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
614 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
615 "TOC sends Client FLAP SIGNON\n"); |
| 2086 | 616 tdt->seqno = ntohs(hdr->seqno); |
| 617 tdt->state = STATE_SIGNON_REQUEST; | |
| 618 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
619 gaim_debug(GAIM_DEBUG_INFO, "toc", "Client sends TOC FLAP SIGNON\n"); |
| 5605 | 620 g_snprintf(so.username, sizeof(so.username), "%s", username); |
| 2086 | 621 so.ver = htonl(1); |
| 622 so.tag = htons(1); | |
| 623 so.namelen = htons(strlen(so.username)); | |
| 624 if (sflap_send(gc, (char *)&so, ntohs(so.namelen) + 8, TYPE_SIGNON) < 0) { | |
| 5605 | 625 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 626 return; |
| 627 } | |
| 628 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
629 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
630 "Client sends TOC \"toc_signon\" message\n"); |
|
2853
f0633f458a1c
[gaim-migrate @ 2866]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
631 /* i hate icq. */ |
| 5605 | 632 if (username[0] >= '0' && username[0] <= '9') |
| 633 password = g_strndup(gaim_account_get_password(gc->account), 8); | |
| 634 else | |
| 635 password = g_strdup(gaim_account_get_password(gc->account)); | |
| 2086 | 636 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
637 AUTH_HOST, AUTH_PORT, gaim_normalize(username), |
| 5605 | 638 roast_password(password), LANGUAGE, REVISION); |
| 639 g_free(password); | |
| 2086 | 640 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 5605 | 641 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 642 return; |
| 643 } | |
| 644 | |
| 5605 | 645 gaim_connection_update_progress(gc, _("Waiting for reply..."), 3, TOC_CONNECT_STEPS); |
| 2086 | 646 return; |
| 647 } | |
| 648 | |
| 649 if (tdt->state == STATE_SIGNON_REQUEST) { | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
650 gaim_debug(GAIM_DEBUG_INFO, "toc", "TOC sends client SIGN_ON reply\n"); |
| 4793 | 651 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
|
652 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
653 "Didn't get SIGN_ON! buf was: %s\n", |
| 2086 | 654 buf + sizeof(struct sflap_hdr)); |
| 4793 | 655 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
|
656 strtok(buf + sizeof(struct sflap_hdr), ":"); |
| 5605 | 657 gaim_connection_error(gc, show_error_message()); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
658 } else |
| 6623 | 659 gaim_connection_error(gc, _("Authentication failed")); |
| 2086 | 660 return; |
| 661 } | |
| 662 /* 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
|
663 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
664 "TOC version: %s\n", buf + sizeof(struct sflap_hdr) + 8); |
| 2086 | 665 |
| 666 /* we used to check for the CONFIG here, but we'll wait until we've sent our | |
| 667 * version of the config and then the toc_init_done message. we'll come back to | |
| 668 * the callback in a better state if we get CONFIG anyway */ | |
| 669 | |
| 670 tdt->state = STATE_ONLINE; | |
| 671 | |
| 5605 | 672 gaim_connection_set_state(gc, GAIM_CONNECTED); |
| 2086 | 673 serv_finish_login(gc); |
| 674 | |
| 675 /* Client sends TOC toc_init_done message */ | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
676 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
677 "Client sends TOC toc_init_done message\n"); |
| 2086 | 678 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 679 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 680 | |
| 681 /* | |
| 682 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
| 683 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
| 684 */ | |
| 685 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | |
| 686 sflap_send(gc, snd, -1, TYPE_DATA); | |
| 687 | |
| 688 return; | |
| 689 } | |
| 690 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
691 gaim_debug(GAIM_DEBUG_INFO, "toc", "S: %s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
692 buf + sizeof(struct sflap_hdr)); |
| 2086 | 693 |
| 694 c = strtok(buf + sizeof(struct sflap_hdr), ":"); /* Ditch the first part */ | |
| 695 | |
| 4793 | 696 if (!g_ascii_strcasecmp(c, "SIGN_ON")) { |
| 2086 | 697 /* we should only get here after a PAUSE */ |
| 698 if (tdt->state != STATE_PAUSE) | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
699 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
700 "got SIGN_ON but not PAUSE!\n"); |
| 2086 | 701 else { |
| 702 tdt->state = STATE_ONLINE; | |
| 703 g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"", | |
| 5605 | 704 AUTH_HOST, AUTH_PORT, |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
705 gaim_normalize(gaim_account_get_username(gc->account)), |
| 5605 | 706 roast_password(gaim_account_get_password(gc->account)), |
| 707 LANGUAGE, REVISION); | |
| 2086 | 708 if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) { |
| 5605 | 709 gaim_connection_error(gc, _("Disconnected.")); |
| 2086 | 710 return; |
| 711 } | |
| 712 g_snprintf(snd, sizeof snd, "toc_init_done"); | |
| 713 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
714 gaim_notify_info(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
715 _("TOC has come back from its pause. You may " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
716 "now send messages again."), NULL); |
| 2086 | 717 } |
| 4793 | 718 } else if (!g_ascii_strcasecmp(c, "CONFIG")) { |
| 2086 | 719 c = strtok(NULL, ":"); |
|
7117
943085b0ff8b
[gaim-migrate @ 7684]
Christian Hammond <chipx86@chipx86.com>
parents:
7107
diff
changeset
|
720 gaim_blist_parse_toc_buddy_list(gc->account, c); |
| 4793 | 721 } else if (!g_ascii_strcasecmp(c, "NICK")) { |
| 2086 | 722 /* ignore NICK so that things get imported/exported properly |
| 723 c = strtok(NULL, ":"); | |
| 724 g_snprintf(gc->username, sizeof(gc->username), "%s", c); | |
| 725 */ | |
| 4793 | 726 } else if (!g_ascii_strcasecmp(c, "IM_IN")) { |
| 2086 | 727 char *away, *message; |
| 728 int a = 0; | |
| 729 | |
| 730 c = strtok(NULL, ":"); | |
| 731 away = strtok(NULL, ":"); | |
| 732 | |
| 733 message = away; | |
| 734 while (*message && (*message != ':')) | |
| 735 message++; | |
| 736 message++; | |
| 737 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
738 a = (away && (*away == 'T')) ? GAIM_CONV_IM_AUTO_RESP : 0; |
| 2086 | 739 |
| 6982 | 740 serv_got_im(gc, c, message, a, time(NULL)); |
| 4793 | 741 } else if (!g_ascii_strcasecmp(c, "UPDATE_BUDDY")) { |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
742 char *l, *uc, *tmp; |
| 2086 | 743 int logged, evil, idle, type = 0; |
| 744 time_t signon, time_idle; | |
| 745 | |
| 746 c = strtok(NULL, ":"); /* name */ | |
| 747 l = strtok(NULL, ":"); /* online */ | |
| 748 sscanf(strtok(NULL, ":"), "%d", &evil); | |
| 749 sscanf(strtok(NULL, ":"), "%ld", &signon); | |
| 750 sscanf(strtok(NULL, ":"), "%d", &idle); | |
| 751 uc = strtok(NULL, ":"); | |
| 752 | |
| 753 logged = (l && (*l == 'T')) ? 1 : 0; | |
| 754 | |
| 755 if (uc[0] == 'A') | |
| 756 type |= UC_AOL; | |
| 757 switch (uc[1]) { | |
| 758 case 'A': | |
| 759 type |= UC_ADMIN; | |
| 760 break; | |
| 761 case 'U': | |
| 762 type |= UC_UNCONFIRMED; | |
| 763 break; | |
| 764 case 'O': | |
| 765 type |= UC_NORMAL; | |
| 766 break; | |
| 3083 | 767 case 'C': |
| 768 type |= UC_WIRELESS; | |
| 769 break; | |
| 2086 | 770 default: |
| 771 break; | |
| 772 } | |
| 773 if (uc[2] == 'U') | |
| 774 type |= UC_UNAVAILABLE; | |
| 775 | |
| 776 if (idle) { | |
| 777 time(&time_idle); | |
| 778 time_idle -= idle * 60; | |
| 779 } else | |
| 780 time_idle = 0; | |
| 781 | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
782 tmp = g_strdup(gaim_normalize(gaim_account_get_username(gc->account))); |
|
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
783 if (!strcmp(tmp, gaim_normalize(c))) |
| 5605 | 784 gaim_connection_set_display_name(gc, c); |
|
2305
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
785 g_free(tmp); |
|
0371b905baef
[gaim-migrate @ 2315]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
786 |
| 4732 | 787 serv_got_update(gc, c, logged, evil, signon, time_idle, type); |
| 4793 | 788 } else if (!g_ascii_strcasecmp(c, "ERROR")) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
789 gaim_notify_error(gc, NULL, show_error_message(), NULL); |
| 4793 | 790 } else if (!g_ascii_strcasecmp(c, "EVILED")) { |
| 2086 | 791 int lev; |
| 792 char *name; | |
| 793 | |
| 794 sscanf(strtok(NULL, ":"), "%d", &lev); | |
| 795 name = strtok(NULL, ":"); | |
| 796 | |
| 797 serv_got_eviled(gc, name, lev); | |
| 4793 | 798 } else if (!g_ascii_strcasecmp(c, "CHAT_JOIN")) { |
| 2086 | 799 char *name; |
| 800 int id; | |
| 801 | |
| 802 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 803 name = strtok(NULL, ":"); | |
| 804 | |
| 805 serv_got_joined_chat(gc, id, name); | |
| 4793 | 806 } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { |
| 2086 | 807 int id, w; |
| 808 char *m, *who, *whisper; | |
| 809 | |
| 810 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 811 who = strtok(NULL, ":"); | |
| 812 whisper = strtok(NULL, ":"); | |
| 813 m = whisper; | |
| 814 while (*m && (*m != ':')) | |
| 815 m++; | |
| 816 m++; | |
| 817 | |
| 818 w = (whisper && (*whisper == 'T')) ? 1 : 0; | |
| 819 | |
| 820 serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); | |
| 4793 | 821 } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { |
| 2086 | 822 int id; |
| 823 char *in, *buddy; | |
| 824 GSList *bcs = gc->buddy_chats; | |
| 5679 | 825 GaimConversation *b = NULL; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
826 GaimConvChat *chat; |
| 2086 | 827 |
| 828 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 829 in = strtok(NULL, ":"); | |
| 830 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
831 chat = GAIM_CONV_CHAT(b); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
832 |
| 2086 | 833 while (bcs) { |
| 5679 | 834 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
835 if (id == gaim_conv_chat_get_id(chat)) |
| 2086 | 836 break; |
| 837 bcs = bcs->next; | |
| 838 b = NULL; | |
| 839 } | |
| 840 | |
| 841 if (!b) | |
| 842 return; | |
| 843 | |
| 844 if (in && (*in == 'T')) | |
| 845 while ((buddy = strtok(NULL, ":")) != NULL) | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
846 gaim_conv_chat_add_user(chat, buddy, NULL); |
| 2086 | 847 else |
| 848 while ((buddy = strtok(NULL, ":")) != NULL) | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
849 gaim_conv_chat_remove_user(chat, buddy, NULL); |
| 4793 | 850 } else if (!g_ascii_strcasecmp(c, "CHAT_INVITE")) { |
| 2086 | 851 char *name, *who, *message; |
| 5234 | 852 int id; |
| 853 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, | |
| 854 g_free, g_free); | |
| 2086 | 855 |
| 856 name = strtok(NULL, ":"); | |
| 5234 | 857 sscanf(strtok(NULL, ":"), "%d", &id); |
| 2086 | 858 who = strtok(NULL, ":"); |
| 859 message = strtok(NULL, ":"); | |
| 860 | |
| 5234 | 861 g_hash_table_replace(components, g_strdup("id"), g_strdup_printf("%d", id)); |
| 862 | |
| 863 serv_got_chat_invite(gc, name, who, message, components); | |
| 4793 | 864 } else if (!g_ascii_strcasecmp(c, "CHAT_LEFT")) { |
| 2086 | 865 GSList *bcs = gc->buddy_chats; |
| 5679 | 866 GaimConversation *b = NULL; |
| 2086 | 867 int id; |
| 868 | |
| 869 sscanf(strtok(NULL, ":"), "%d", &id); | |
| 870 | |
| 871 while (bcs) { | |
| 5679 | 872 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
873 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 874 break; |
| 875 b = NULL; | |
| 876 bcs = bcs->next; | |
| 877 } | |
| 878 | |
| 879 if (!b) | |
| 880 return; | |
| 881 | |
| 882 if (b->window) { | |
| 883 char error_buf[BUF_LONG]; | |
| 4491 | 884 gaim_conversation_set_account(b, NULL); |
| 2086 | 885 g_snprintf(error_buf, sizeof error_buf, _("You have been disconnected" |
| 886 " from chat room %s."), b->name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
887 gaim_notify_error(gc, NULL, error_buf, NULL); |
| 2086 | 888 } else |
| 889 serv_got_chat_left(gc, id); | |
| 4793 | 890 } else if (!g_ascii_strcasecmp(c, "GOTO_URL")) { |
| 2086 | 891 char *name, *url, tmp[256]; |
| 892 | |
| 893 name = strtok(NULL, ":"); | |
| 894 url = strtok(NULL, ":"); | |
| 895 | |
| 4597 | 896 g_snprintf(tmp, sizeof(tmp), "http://%s:%d/%s", tdt->toc_ip, |
| 5605 | 897 gaim_account_get_int(gc->account, "port", TOC_PORT), |
| 2086 | 898 url); |
|
7094
2343c3aa1dec
[gaim-migrate @ 7659]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
899 gaim_url_fetch(tmp, FALSE, NULL, FALSE, toc_got_info, gc); |
| 4793 | 900 } else if (!g_ascii_strcasecmp(c, "DIR_STATUS")) { |
| 901 } else if (!g_ascii_strcasecmp(c, "ADMIN_NICK_STATUS")) { | |
| 902 } else if (!g_ascii_strcasecmp(c, "ADMIN_PASSWD_STATUS")) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
903 gaim_notify_info(gc, NULL, _("Password Change Successful"), NULL); |
| 4793 | 904 } else if (!g_ascii_strcasecmp(c, "PAUSE")) { |
| 2086 | 905 tdt->state = STATE_PAUSE; |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
906 gaim_notify_warning(gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
907 _("TOC has sent a PAUSE command."), |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
908 _("When this happens, TOC ignores any messages " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
909 "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
|
910 " message. Gaim will prevent anything from " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
911 "going through. This is only temporary, please " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
912 "be patient.")); |
| 4793 | 913 } else if (!g_ascii_strcasecmp(c, "RVOUS_PROPOSE")) { |
| 6867 | 914 #if 0 |
| 2086 | 915 char *user, *uuid, *cookie; |
| 916 int seq; | |
| 3159 | 917 char *rip, *pip, *vip, *trillian = NULL; |
| 2086 | 918 int port; |
| 3126 | 919 |
| 2086 | 920 user = strtok(NULL, ":"); |
| 921 uuid = strtok(NULL, ":"); | |
| 922 cookie = strtok(NULL, ":"); | |
| 923 sscanf(strtok(NULL, ":"), "%d", &seq); | |
| 924 rip = strtok(NULL, ":"); | |
| 925 pip = strtok(NULL, ":"); | |
| 926 vip = strtok(NULL, ":"); | |
| 927 sscanf(strtok(NULL, ":"), "%d", &port); | |
| 928 | |
| 929 if (!strcmp(uuid, FILE_SEND_UID)) { | |
| 930 /* they want us to get a file */ | |
| 931 int unk[4], i; | |
| 932 char *messages[4], *tmp, *name; | |
| 933 int subtype, files, totalsize = 0; | |
| 934 struct ft_request *ft; | |
| 935 | |
| 936 for (i = 0; i < 4; i++) { | |
| 3126 | 937 trillian = strtok(NULL, ":"); |
| 938 sscanf(trillian, "%d", &unk[i]); | |
| 2086 | 939 if (unk[i] == 10001) |
| 940 break; | |
| 3126 | 941 /* Trillian likes to send an empty token as a message, rather than |
| 942 no message at all. */ | |
| 943 if (*(trillian + strlen(trillian) +1) != ':') | |
| 944 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 945 } |
| 3126 | 946 |
| 2086 | 947 frombase64(strtok(NULL, ":"), &tmp, NULL); |
| 948 | |
| 949 subtype = tmp[1]; | |
| 950 files = tmp[3]; | |
| 951 | |
| 952 totalsize |= (tmp[4] << 24) & 0xff000000; | |
| 953 totalsize |= (tmp[5] << 16) & 0x00ff0000; | |
| 954 totalsize |= (tmp[6] << 8) & 0x0000ff00; | |
| 955 totalsize |= (tmp[7] << 0) & 0x000000ff; | |
| 956 | |
| 957 if (!totalsize) { | |
| 958 g_free(tmp); | |
| 959 for (i--; i >= 0; i--) | |
| 960 g_free(messages[i]); | |
| 961 return; | |
| 962 } | |
| 963 | |
| 964 name = tmp + 8; | |
| 965 | |
| 966 ft = g_new0(struct ft_request, 1); | |
| 967 ft->cookie = g_strdup(cookie); | |
| 968 ft->ip = g_strdup(pip); | |
| 969 ft->port = port; | |
| 970 if (i) | |
| 971 ft->message = g_strdup(messages[0]); | |
| 972 else | |
| 973 ft->message = NULL; | |
| 974 ft->filename = g_strdup(name); | |
| 975 ft->user = g_strdup(user); | |
| 976 ft->size = totalsize; | |
| 977 ft->files = files; | |
| 978 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_SEND_UID); | |
| 979 ft->gc = gc; | |
| 980 | |
| 981 g_free(tmp); | |
| 982 for (i--; i >= 0; i--) | |
| 983 g_free(messages[i]); | |
| 984 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
985 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
986 "English translation of RVOUS_PROPOSE: %s requests " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
987 "Send File (i.e. send a file to you); %s:%d " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
988 "(verified_ip:port), %d files at total size of " |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
989 "%d bytes.\n", user, vip, port, files, totalsize); |
| 2086 | 990 accept_file_dialog(ft); |
| 991 } else if (!strcmp(uuid, FILE_GET_UID)) { | |
| 992 /* they want us to send a file */ | |
| 993 int unk[4], i; | |
| 994 char *messages[4], *tmp; | |
| 995 struct ft_request *ft; | |
| 996 | |
| 997 for (i = 0; i < 4; i++) { | |
| 998 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 999 if (unk[i] == 10001) | |
| 1000 break; | |
| 3126 | 1001 /* Trillian likes to send an empty token as a message, rather than |
| 1002 no message at all. */ | |
| 1003 if (*(trillian + strlen(trillian) +1) != ':') | |
| 1004 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 2086 | 1005 } |
| 1006 frombase64(strtok(NULL, ":"), &tmp, NULL); | |
| 1007 | |
| 1008 ft = g_new0(struct ft_request, 1); | |
| 1009 ft->cookie = g_strdup(cookie); | |
| 1010 ft->ip = g_strdup(pip); | |
| 1011 ft->port = port; | |
| 1012 if (i) | |
| 1013 ft->message = g_strdup(messages[0]); | |
| 1014 else | |
| 1015 ft->message = NULL; | |
| 1016 ft->user = g_strdup(user); | |
| 1017 g_snprintf(ft->UID, sizeof(ft->UID), "%s", FILE_GET_UID); | |
| 1018 ft->gc = gc; | |
| 1019 | |
| 1020 g_free(tmp); | |
| 1021 for (i--; i >= 0; i--) | |
| 1022 g_free(messages[i]); | |
| 1023 | |
| 1024 accept_file_dialog(ft); | |
| 1025 } else if (!strcmp(uuid, VOICE_UID)) { | |
| 1026 /* oh goody. voice over ip. fun stuff. */ | |
| 1027 } else if (!strcmp(uuid, B_ICON_UID)) { | |
| 1028 int unk[4], i; | |
| 1029 char *messages[4]; | |
| 1030 struct buddy_icon *icon; | |
| 1031 | |
| 1032 for (i = 0; i < 4; i++) { | |
| 1033 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 1034 if (unk[i] == 10001) | |
| 1035 break; | |
| 1036 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 1037 } | |
| 1038 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
| 1039 | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1040 gaim_debug(GAIM_DEBUG_MISC, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1041 "received icon of length %d\n", icon->len); |
| 2086 | 1042 g_free(icon); |
| 1043 for (i--; i >= 0; i--) | |
| 1044 g_free(messages[i]); | |
| 1045 } else if (!strcmp(uuid, IMAGE_UID)) { | |
| 1046 /* aka Direct IM */ | |
| 1047 } else { | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1048 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1049 "Don't know what to do with RVOUS UUID %s\n", uuid); |
| 2086 | 1050 /* do we have to do anything here? i think it just times out */ |
| 1051 } | |
| 6867 | 1052 #endif |
| 2086 | 1053 } else { |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1054 gaim_debug(GAIM_DEBUG_ERROR, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1055 "don't know what to do with %s\n", c); |
| 2086 | 1056 } |
| 1057 } | |
| 1058 | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1059 static int toc_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags flags) |
| 2086 | 1060 { |
| 6061 | 1061 char *buf1, *buf2; |
| 2086 | 1062 |
| 6855 | 1063 #if 1 |
| 1064 /* This is the old, non-i18n way */ | |
| 6061 | 1065 buf1 = escape_text(message); |
| 1066 if (strlen(buf1) + 52 > MSG_LEN) { | |
| 1067 g_free(buf1); | |
|
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
1068 return -E2BIG; |
|
2136
73253b36c3cb
[gaim-migrate @ 2146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
1069 } |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1070 buf2 = g_strdup_printf("toc_send_im %s \"%s\"%s", gaim_normalize(name), buf1, |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1071 ((flags & GAIM_CONV_IM_AUTO_RESP) ? " auto" : "")); |
| 6061 | 1072 g_free(buf1); |
| 6855 | 1073 #else |
| 1074 /* This doesn't work yet. See the comments below for details */ | |
| 1075 buf1 = gaim_strreplace(message, "\"", "\\\""); | |
| 1076 | |
| 1077 /* | |
| 1078 * We still need to determine what encoding should be used and send the | |
| 1079 * message in that encoding. This should be done the same as in | |
| 1080 * oscar_encoding_check() in oscar.c. There is no encoding flag sent | |
| 1081 * along with the message--the TOC to OSCAR proxy server must just | |
| 1082 * use a lil' algorithm to determine what the actual encoding is. | |
| 1083 * | |
| 1084 * After that, you need to convert buf1 to that encoding, and keep track | |
| 1085 * of the length of the resulting string. Then you need to make sure | |
| 1086 * that length is passed to sflap_send(). | |
| 1087 */ | |
| 1088 | |
| 6982 | 1089 if (strlen(buf1) + 52 > MSG_LEN) { |
| 6855 | 1090 g_free(buf1); |
| 1091 return -E2BIG; | |
| 1092 } | |
| 1093 | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1094 buf2 = g_strdup_printf("toc2_send_im_enc %s F U en \"%s\" %s", gaim_normalize(name), buf1, |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1095 ((flags & GAIM_CONV_IM_AUTO_RESP) ? "auto" : "")); |
| 6855 | 1096 g_free(buf1); |
| 1097 #endif | |
| 1098 | |
| 6061 | 1099 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1100 g_free(buf2); | |
| 1101 | |
|
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2281
diff
changeset
|
1102 return 1; |
| 2086 | 1103 } |
| 1104 | |
| 5605 | 1105 static void toc_set_config(GaimConnection *gc) |
| 2086 | 1106 { |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1107 char *buf = g_malloc(MSG_LEN), snd[BUF_LEN * 2]; |
| 4491 | 1108 toc_build_config(gc->account, buf, MSG_LEN - strlen("toc_set_config \\{\\}"), FALSE); |
| 2086 | 1109 g_snprintf(snd, MSG_LEN, "toc_set_config {%s}", buf); |
| 1110 sflap_send(gc, snd, -1, TYPE_DATA); | |
|
2281
cc462108c101
[gaim-migrate @ 2291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1111 g_free(buf); |
| 2086 | 1112 } |
| 1113 | |
| 5605 | 1114 static void toc_get_info(GaimConnection *g, const char *name) |
| 2086 | 1115 { |
| 1116 char buf[BUF_LEN * 2]; | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1117 g_snprintf(buf, MSG_LEN, "toc_get_info %s", gaim_normalize(name)); |
| 2086 | 1118 sflap_send(g, buf, -1, TYPE_DATA); |
| 1119 } | |
| 1120 | |
| 5605 | 1121 static void toc_get_dir(GaimConnection *g, const char *name) |
| 2086 | 1122 { |
| 1123 char buf[BUF_LEN * 2]; | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1124 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", gaim_normalize(name)); |
| 2086 | 1125 sflap_send(g, buf, -1, TYPE_DATA); |
| 1126 } | |
| 1127 | |
| 5605 | 1128 static void toc_set_dir(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1129 const char *maiden, const char *city, const char *state, const char *country, int web) |
| 2086 | 1130 { |
| 6059 | 1131 char *buf3, buf2[BUF_LEN * 4], buf[BUF_LEN]; |
| 2086 | 1132 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
| 1133 middle, last, maiden, city, state, country, (web == 1) ? "Y" : ""); | |
| 6059 | 1134 buf3 = escape_text(buf2); |
| 1135 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf3); | |
| 1136 g_free(buf3); | |
| 2086 | 1137 sflap_send(g, buf, -1, TYPE_DATA); |
| 1138 } | |
| 1139 | |
| 5605 | 1140 static void toc_dir_search(GaimConnection *g, const char *first, const char *middle, const char *last, |
| 3466 | 1141 const char *maiden, const char *city, const char *state, const char *country, const char *email) |
| 2086 | 1142 { |
| 1143 char buf[BUF_LONG]; | |
| 1144 g_snprintf(buf, sizeof(buf) / 2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, | |
| 1145 last, maiden, city, state, country, email); | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1146 gaim_debug(GAIM_DEBUG_INFO, "toc", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1147 "Searching for: %s,%s,%s,%s,%s,%s,%s\n", |
|
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1148 first, middle, last, maiden, |
| 2086 | 1149 city, state, country); |
| 1150 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1151 } | |
| 1152 | |
| 6059 | 1153 static void toc_set_away(GaimConnection *g, const char *state, const char *message) |
| 2086 | 1154 { |
| 1155 char buf[BUF_LEN * 2]; | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1156 if (g->away) { |
| 2086 | 1157 g_free (g->away); |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1158 g->away = NULL; |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1159 } |
| 2086 | 1160 if (message) { |
| 6059 | 1161 char *tmp; |
| 1162 g->away = g_strdup(message); | |
| 1163 tmp = escape_text(message); | |
| 3188 | 1164 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", tmp); |
| 1165 g_free(tmp); | |
| 2086 | 1166 } else |
| 1167 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
| 1168 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1169 } | |
| 1170 | |
| 5954 | 1171 static void toc_set_info(GaimConnection *g, const char *info) |
| 2086 | 1172 { |
| 6059 | 1173 char buf[BUF_LEN * 2], *buf2; |
| 1174 buf2 = escape_text(info); | |
| 2086 | 1175 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", buf2); |
| 6059 | 1176 g_free(buf2); |
| 2086 | 1177 sflap_send(g, buf, -1, TYPE_DATA); |
| 1178 } | |
| 1179 | |
| 5605 | 1180 static void toc_change_passwd(GaimConnection *g, const char *orig, const char *new) |
| 2086 | 1181 { |
| 1182 char buf[BUF_LEN * 2]; | |
| 1183 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
| 6306 | 1184 sflap_send(g, buf, -1, TYPE_DATA); |
| 2086 | 1185 } |
| 1186 | |
|
6787
faa491042c66
[gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1187 static void toc_add_buddy(GaimConnection *g, const char *name, GaimGroup *group) |
| 2086 | 1188 { |
| 1189 char buf[BUF_LEN * 2]; | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1190 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", gaim_normalize(name)); |
| 2086 | 1191 sflap_send(g, buf, -1, TYPE_DATA); |
| 1192 toc_set_config(g); | |
| 1193 } | |
| 1194 | |
| 5605 | 1195 static void toc_add_buddies(GaimConnection *g, GList *buddies) |
| 2086 | 1196 { |
| 1197 char buf[BUF_LEN * 2]; | |
| 1198 int n; | |
| 1199 | |
| 1200 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 1201 while (buddies) { | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1202 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { |
| 2086 | 1203 sflap_send(g, buf, -1, TYPE_DATA); |
| 1204 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 1205 } | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1206 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); |
| 2086 | 1207 buddies = buddies->next; |
| 1208 } | |
| 1209 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1210 } | |
| 1211 | |
| 6059 | 1212 static void toc_remove_buddy(GaimConnection *g, const char *name, const char *group) |
| 2086 | 1213 { |
| 1214 char buf[BUF_LEN * 2]; | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1215 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", gaim_normalize(name)); |
| 2086 | 1216 sflap_send(g, buf, -1, TYPE_DATA); |
| 1217 toc_set_config(g); | |
| 1218 } | |
| 1219 | |
| 5605 | 1220 static void toc_remove_buddies(GaimConnection *g, GList *buddies, const char *group) |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1221 { |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1222 char buf[BUF_LEN * 2]; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1223 int n; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1224 |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1225 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1226 while (buddies) { |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1227 if (strlen(gaim_normalize(buddies->data)) + n + 32 > MSG_LEN) { |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1228 sflap_send(g, buf, -1, TYPE_DATA); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1229 n = g_snprintf(buf, sizeof(buf), "toc_remove_buddy"); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1230 } |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1231 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", gaim_normalize(buddies->data)); |
|
2334
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1232 buddies = buddies->next; |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1233 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1234 sflap_send(g, buf, -1, TYPE_DATA); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1235 toc_set_config(g); |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1236 } |
|
b53cd5b63a99
[gaim-migrate @ 2347]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2309
diff
changeset
|
1237 |
| 5605 | 1238 static void toc_set_idle(GaimConnection *g, int time) |
| 2086 | 1239 { |
| 1240 char buf[BUF_LEN * 2]; | |
| 1241 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
| 1242 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1243 } | |
| 1244 | |
| 6059 | 1245 static void toc_warn(GaimConnection *g, const char *name, int anon) |
| 2086 | 1246 { |
| 1247 char send[BUF_LEN * 2]; | |
| 1248 g_snprintf(send, 255, "toc_evil %s %s", name, ((anon) ? "anon" : "norm")); | |
| 1249 sflap_send(g, send, -1, TYPE_DATA); | |
| 1250 } | |
| 1251 | |
| 5605 | 1252 static GList *toc_chat_info(GaimConnection *gc) |
| 2086 | 1253 { |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1254 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1255 struct proto_chat_entry *pce; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1256 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1257 pce = g_new0(struct proto_chat_entry, 1); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1258 pce->label = _("Join what group:"); |
| 5234 | 1259 pce->identifier = "room"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1260 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1261 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1262 pce = g_new0(struct proto_chat_entry, 1); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1263 pce->label = _("Exchange:"); |
| 5234 | 1264 pce->identifier = "exchange"; |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1265 pce->is_int = TRUE; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1266 pce->min = 4; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1267 pce->max = 20; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1268 m = g_list_append(m, pce); |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1269 |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1270 return m; |
| 2086 | 1271 } |
| 1272 | |
| 5605 | 1273 static void toc_join_chat(GaimConnection *g, GHashTable *data) |
| 2086 | 1274 { |
| 1275 char buf[BUF_LONG]; | |
| 5234 | 1276 char *name, *exchange; |
| 1277 char *id; | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1278 |
| 5234 | 1279 name = g_hash_table_lookup(data, "room"); |
| 1280 exchange = g_hash_table_lookup(data, "exchange"); | |
| 1281 id = g_hash_table_lookup(data, "id"); | |
| 1282 | |
| 1283 if (id) { | |
| 1284 g_snprintf(buf, 255, "toc_chat_accept %d", atoi(id)); | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1285 } else { |
| 5234 | 1286 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
|
1287 } |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1288 |
| 2086 | 1289 sflap_send(g, buf, -1, TYPE_DATA); |
| 1290 } | |
| 1291 | |
| 5605 | 1292 static void toc_chat_invite(GaimConnection *g, int id, const char *message, const char *name) |
| 2086 | 1293 { |
| 1294 char buf[BUF_LONG]; | |
|
2719
9747583279d1
[gaim-migrate @ 2732]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
1295 g_snprintf(buf, sizeof(buf) / 2, "toc_chat_invite %d \"%s\" %s", id, |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1296 message ? message : "", gaim_normalize(name)); |
| 2086 | 1297 sflap_send(g, buf, -1, TYPE_DATA); |
| 1298 } | |
| 1299 | |
| 5605 | 1300 static void toc_chat_leave(GaimConnection *g, int id) |
| 2086 | 1301 { |
| 1302 GSList *bcs = g->buddy_chats; | |
| 5679 | 1303 GaimConversation *b = NULL; |
| 2086 | 1304 char buf[BUF_LEN * 2]; |
| 1305 | |
| 1306 while (bcs) { | |
| 5679 | 1307 b = (GaimConversation *)bcs->data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7117
diff
changeset
|
1308 if (id == gaim_conv_chat_get_id(GAIM_CONV_CHAT(b))) |
| 2086 | 1309 break; |
| 1310 b = NULL; | |
| 1311 bcs = bcs->next; | |
| 1312 } | |
| 1313 | |
| 1314 if (!b) | |
| 1315 return; /* can this happen? */ | |
| 1316 | |
| 4491 | 1317 if (gaim_conversation_get_account(b) == NULL) { |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1318 /* TOC already kicked us out of this room */ |
| 2086 | 1319 serv_got_chat_left(g, id); |
|
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
1320 } |
| 2086 | 1321 else { |
| 1322 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
| 1323 sflap_send(g, buf, -1, TYPE_DATA); | |
| 1324 } | |
| 1325 } | |
| 1326 | |
| 6059 | 1327 static void toc_chat_whisper(GaimConnection *g, int id, const char *who, const char *message) |
| 2086 | 1328 { |
| 6059 | 1329 char *buf1, *buf2; |
| 1330 buf1 = escape_text(message); | |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1331 buf2 = g_strdup_printf("toc_chat_whisper %d %s \"%s\"", id, gaim_normalize(who), buf1); |
| 6059 | 1332 g_free(buf1); |
| 2086 | 1333 sflap_send(g, buf2, -1, TYPE_DATA); |
| 6059 | 1334 g_free(buf2); |
| 2086 | 1335 } |
| 1336 | |
| 6059 | 1337 static int toc_chat_send(GaimConnection *g, int id, const char *message) |
| 2086 | 1338 { |
| 6059 | 1339 char *buf1, *buf2; |
| 1340 buf1 = escape_text(message); | |
| 1341 if (strlen(buf1) > 2000) { | |
| 1342 g_free(buf1); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1343 return -E2BIG; |
| 6059 | 1344 } |
| 1345 buf2 = g_strdup_printf("toc_chat_send %d \"%s\"", id, buf1); | |
| 1346 g_free(buf1); | |
| 1347 sflap_send(g, buf2, -1, TYPE_DATA); | |
| 1348 g_free(buf2); | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1349 return 0; |
| 2086 | 1350 } |
| 1351 | |
| 5605 | 1352 static void toc_keepalive(GaimConnection *gc) |
| 2086 | 1353 { |
| 1354 sflap_send(gc, "", 0, TYPE_KEEPALIVE); | |
| 1355 } | |
| 1356 | |
| 6695 | 1357 static const char *toc_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2086 | 1358 { |
| 5971 | 1359 if (!b || (b && b->name && b->name[0] == '+')) { |
| 6695 | 1360 if (a != NULL && isdigit(*gaim_account_get_username(a))) |
| 5971 | 1361 return "icq"; |
| 1362 else | |
| 1363 return "aim"; | |
| 1364 } | |
| 1365 | |
| 1366 if (b && b->name && isdigit(b->name[0])) | |
| 1367 return "icq"; | |
| 4687 | 1368 return "aim"; |
| 1369 } | |
| 4916 | 1370 |
| 6695 | 1371 static void toc_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne) |
| 4916 | 1372 { |
| 1373 char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 1374 int i = 0; | |
| 1375 | |
| 5971 | 1376 if (!GAIM_BUDDY_IS_ONLINE(b)) { |
| 4916 | 1377 *se = "offline"; |
| 1378 return; | |
| 1379 } else { | |
| 1380 if (b->uc & UC_UNAVAILABLE) | |
| 1381 emblems[i++] = "away"; | |
| 1382 if (b->uc & UC_AOL) | |
| 1383 emblems[i++] = "aol"; | |
| 1384 if (b->uc & UC_ADMIN) | |
| 1385 emblems[i++] = "admin"; | |
| 1386 if (b->uc & UC_WIRELESS) | |
| 1387 emblems[i++] = "wireless"; | |
| 1388 } | |
| 1389 *se = emblems[0]; | |
| 1390 *sw = emblems[1]; | |
| 1391 *nw = emblems[2]; | |
| 1392 *ne = emblems[3]; | |
| 1393 } | |
| 2086 | 1394 |
| 5605 | 1395 static GList *toc_buddy_menu(GaimConnection *gc, const char *who) |
| 2086 | 1396 { |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1397 GList *m = NULL; |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1398 struct proto_buddy_menu *pbm; |
| 2086 | 1399 |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1400 pbm = g_new0(struct proto_buddy_menu, 1); |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1401 pbm->label = _("Get Dir Info"); |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1402 pbm->callback = toc_get_dir; |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1403 pbm->gc = gc; |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1404 m = g_list_append(m, pbm); |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1405 |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1406 return m; |
| 2086 | 1407 } |
| 1408 | |
| 5605 | 1409 static void toc_add_permit(GaimConnection *gc, const char *who) |
| 2086 | 1410 { |
| 1411 char buf2[BUF_LEN * 2]; | |
| 5605 | 1412 if (gc->account->perm_deny != 3) |
| 2086 | 1413 return; |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1414 g_snprintf(buf2, sizeof(buf2), "toc_add_permit %s", gaim_normalize(who)); |
| 2086 | 1415 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1416 toc_set_config(gc); | |
| 1417 } | |
| 1418 | |
| 5605 | 1419 static void toc_add_deny(GaimConnection *gc, const char *who) |
| 2086 | 1420 { |
| 1421 char buf2[BUF_LEN * 2]; | |
| 5605 | 1422 if (gc->account->perm_deny != 4) |
| 2086 | 1423 return; |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1424 g_snprintf(buf2, sizeof(buf2), "toc_add_deny %s", gaim_normalize(who)); |
| 2086 | 1425 sflap_send(gc, buf2, -1, TYPE_DATA); |
| 1426 toc_set_config(gc); | |
| 1427 } | |
| 1428 | |
| 5605 | 1429 static void toc_set_permit_deny(GaimConnection *gc) |
| 2086 | 1430 { |
| 1431 char buf2[BUF_LEN * 2]; | |
| 1432 GSList *list; | |
| 1433 int at; | |
| 1434 | |
| 5605 | 1435 switch (gc->account->perm_deny) { |
| 2086 | 1436 case 1: |
| 1437 /* permit all, deny none. to get here reliably we need to have been in permit | |
| 1438 * mode, and send an empty toc_add_deny message, which will switch us to deny none */ | |
| 1439 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1440 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1441 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1442 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1443 break; | |
| 1444 case 2: | |
| 1445 /* deny all, permit none. to get here reliably we need to have been in deny | |
| 1446 * mode, and send an empty toc_add_permit message, which will switch us to permit none */ | |
| 1447 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1448 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1449 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1450 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1451 break; | |
| 1452 case 3: | |
| 1453 /* permit some. we want to switch to deny mode first, then send the toc_add_permit | |
| 1454 * message, which will clear and set our permit list. toc sucks. */ | |
| 1455 g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1456 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1457 | |
| 1458 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 4491 | 1459 list = gc->account->permit; |
| 2086 | 1460 while (list) { |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1461 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); |
| 2086 | 1462 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1463 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1464 at = g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1465 } | |
| 1466 list = list->next; | |
| 1467 } | |
| 1468 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1469 break; | |
| 1470 case 4: | |
| 1471 /* deny some. we want to switch to permit mode first, then send the toc_add_deny | |
| 1472 * message, which will clear and set our deny list. toc sucks. */ | |
| 1473 g_snprintf(buf2, sizeof(buf2), "toc_add_permit "); | |
| 1474 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1475 | |
| 1476 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 4491 | 1477 list = gc->account->deny; |
| 2086 | 1478 while (list) { |
|
7107
9220c7490cd1
[gaim-migrate @ 7672]
Christian Hammond <chipx86@chipx86.com>
parents:
7095
diff
changeset
|
1479 at += g_snprintf(buf2 + at, sizeof(buf2) - at, "%s ", gaim_normalize(list->data)); |
| 2086 | 1480 if (at > MSG_LEN + 32) { /* from out my ass comes greatness */ |
| 1481 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1482 at = g_snprintf(buf2, sizeof(buf2), "toc_add_deny "); | |
| 1483 } | |
| 1484 list = list->next; | |
| 1485 } | |
| 1486 sflap_send(gc, buf2, -1, TYPE_DATA); | |
| 1487 break; | |
| 1488 default: | |
| 1489 break; | |
| 1490 } | |
| 1491 toc_set_config(gc); | |
| 1492 } | |
| 1493 | |
| 5605 | 1494 static void toc_rem_permit(GaimConnection *gc, const char *who) |
| 2086 | 1495 { |
| 5605 | 1496 if (gc->account->perm_deny != 3) |
| 2086 | 1497 return; |
| 1498 toc_set_permit_deny(gc); | |
| 1499 } | |
| 1500 | |
| 5605 | 1501 static void toc_rem_deny(GaimConnection *gc, const char *who) |
| 2086 | 1502 { |
| 5605 | 1503 if (gc->account->perm_deny != 4) |
| 2086 | 1504 return; |
| 1505 toc_set_permit_deny(gc); | |
| 1506 } | |
| 1507 | |
| 5605 | 1508 static GList *toc_away_states(GaimConnection *gc) |
| 2086 | 1509 { |
| 1510 return g_list_append(NULL, GAIM_AWAY_CUSTOM); | |
| 1511 } | |
| 1512 | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1513 static void |
|
7067
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1514 show_set_info(GaimConnection *gc) |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1515 { |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1516 gaim_account_request_change_user_info(gaim_connection_get_account(gc)); |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1517 } |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1518 |
|
71e0da45abe6
[gaim-migrate @ 7631]
Christian Hammond <chipx86@chipx86.com>
parents:
7063
diff
changeset
|
1519 static void |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1520 change_pass(GaimConnection *gc) |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1521 { |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1522 gaim_account_request_change_password(gaim_connection_get_account(gc)); |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1523 } |
|
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1524 |
| 5605 | 1525 static GList *toc_actions(GaimConnection *gc) |
| 2086 | 1526 { |
| 1527 GList *m = NULL; | |
| 4333 | 1528 struct proto_actions_menu *pam; |
| 2086 | 1529 |
| 4333 | 1530 pam = g_new0(struct proto_actions_menu, 1); |
| 1531 pam->label = _("Set User Info"); | |
| 1532 pam->callback = show_set_info; | |
| 1533 pam->gc = gc; | |
| 1534 m = g_list_append(m, pam); | |
| 1535 | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1536 #if 0 |
| 4333 | 1537 pam = g_new0(struct proto_actions_menu, 1); |
| 1538 pam->label = _("Set Dir Info"); | |
| 1539 pam->callback = show_set_dir; | |
| 1540 pam->gc = gc; | |
| 1541 m = g_list_append(m, pam); | |
|
7080
fc9c74cfb306
[gaim-migrate @ 7645]
Christian Hammond <chipx86@chipx86.com>
parents:
7067
diff
changeset
|
1542 #endif |
| 4333 | 1543 |
| 1544 pam = g_new0(struct proto_actions_menu, 1); | |
| 1545 pam->label = _("Change Password"); | |
|
7063
7fdac700deb1
[gaim-migrate @ 7627]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
1546 pam->callback = change_pass; |
| 4333 | 1547 pam->gc = gc; |
| 1548 m = g_list_append(m, pam); | |
| 2086 | 1549 |
| 1550 return m; | |
| 1551 } | |
| 1552 | |
| 6867 | 1553 #if 0 |
| 2086 | 1554 /********* |
| 1555 * RVOUS ACTIONS | |
| 1556 ********/ | |
| 1557 | |
| 1558 struct file_header { | |
| 1559 char magic[4]; /* 0 */ | |
| 1560 short hdrlen; /* 4 */ | |
| 1561 short hdrtype; /* 6 */ | |
| 1562 char bcookie[8]; /* 8 */ | |
| 1563 short encrypt; /* 16 */ | |
| 1564 short compress; /* 18 */ | |
| 1565 short totfiles; /* 20 */ | |
| 1566 short filesleft; /* 22 */ | |
| 1567 short totparts; /* 24 */ | |
| 1568 short partsleft; /* 26 */ | |
| 1569 long totsize; /* 28 */ | |
| 1570 long size; /* 32 */ | |
| 1571 long modtime; /* 36 */ | |
| 1572 long checksum; /* 40 */ | |
| 1573 long rfrcsum; /* 44 */ | |
| 1574 long rfsize; /* 48 */ | |
| 1575 long cretime; /* 52 */ | |
| 1576 long rfcsum; /* 56 */ | |
| 1577 long nrecvd; /* 60 */ | |
| 1578 long recvcsum; /* 64 */ | |
| 1579 char idstring[32]; /* 68 */ | |
| 1580 char flags; /* 100 */ | |
| 1581 char lnameoffset; /* 101 */ | |
| 1582 char lsizeoffset; /* 102 */ | |
| 1583 char dummy[69]; /* 103 */ | |
| 1584 char macfileinfo[16]; /* 172 */ | |
| 1585 short nencode; /* 188 */ | |
| 1586 short nlanguage; /* 190 */ | |
| 1587 char name[64]; /* 192 */ | |
| 1588 /* 256 */ | |
| 1589 }; | |
| 1590 | |
| 1591 struct file_transfer { | |
| 1592 struct file_header hdr; | |
| 1593 | |
| 5605 | 1594 GaimConnection *gc; |
| 2086 | 1595 |
| 1596 char *user; | |
| 1597 char *cookie; | |
| 1598 char *ip; | |
| 1599 int port; | |
| 1600 long size; | |
| 1601 struct stat st; | |
| 1602 | |
| 1603 GtkWidget *window; | |
| 1604 int files; | |
| 1605 char *filename; | |
| 1606 FILE *file; | |
| 1607 int recvsize; | |
| 1608 | |
| 1609 gint inpa; | |
| 1610 }; | |
| 1611 | |
| 1612 static void debug_header(struct file_transfer *ft) { | |
| 1613 struct file_header *f = (struct file_header *)ft; | |
|
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1614 gaim_debug(GAIM_DEBUG_MISC, "toc", "FT HEADER:\n" |
| 2086 | 1615 "\t%s %d 0x%04x\n" |
| 1616 "\t%s %d %d\n" | |
|
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1617 "\t%d %d %d %d %d %d\n" |
|
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4115
diff
changeset
|
1618 "\t%d %d %d %d %d %d %d %d\n" |
| 2086 | 1619 "\t%s\n" |
| 1620 "\t0x%02x, 0x%02x, 0x%02x\n" | |
| 1621 "\t%s %s\n" | |
| 1622 "\t%d %d\n" | |
| 1623 "\t%s\n", | |
| 1624 f->magic, ntohs(f->hdrlen), f->hdrtype, | |
| 1625 f->bcookie, ntohs(f->encrypt), ntohs(f->compress), | |
| 1626 ntohs(f->totfiles), ntohs(f->filesleft), ntohs(f->totparts), | |
| 1627 ntohs(f->partsleft), ntohl(f->totsize), ntohl(f->size), | |
| 1628 ntohl(f->modtime), ntohl(f->checksum), ntohl(f->rfrcsum), ntohl(f->rfsize), | |
| 1629 ntohl(f->cretime), ntohl(f->rfcsum), ntohl(f->nrecvd), | |
| 1630 ntohl(f->recvcsum), | |
| 1631 f->idstring, | |
| 1632 f->flags, f->lnameoffset, f->lsizeoffset, | |
| 1633 f->dummy, f->macfileinfo, | |
| 1634 ntohs(f->nencode), ntohs(f->nlanguage), | |
| 1635 f->name); | |
| 1636 } | |
| 1637 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1638 static void toc_send_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1639 { |
| 1640 char buf[BUF_LONG]; | |
| 1641 int rt, i; | |
| 1642 | |
| 1643 struct file_transfer *ft = data; | |
| 1644 | |
| 1645 if (ft->hdr.hdrtype != 0x202) { | |
| 1646 char *buf; | |
| 1647 frombase64(ft->cookie, &buf, NULL); | |
| 1648 | |
| 3630 | 1649 toc_read(source, ft, 8); |
| 1650 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1651 debug_header(ft); |
| 1652 | |
| 1653 ft->hdr.hdrtype = 0x202; | |
| 1654 memcpy(ft->hdr.bcookie, buf, 8); | |
| 1655 g_free(buf); | |
| 1656 ft->hdr.encrypt = 0; ft->hdr.compress = 0; | |
| 1657 debug_header(ft); | |
| 3630 | 1658 toc_write(source, ft, 256); |
| 2086 | 1659 |
| 1660 if (ft->files == 1) { | |
| 1661 ft->file = fopen(ft->filename, "w"); | |
| 1662 if (!ft->file) { | |
| 4115 | 1663 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
|
1664 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1665 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1666 gaim_input_remove(ft->inpa); |
| 3630 | 1667 toc_soc_close(source); |
| 2086 | 1668 g_free(ft->filename); |
| 1669 g_free(ft->user); | |
| 1670 g_free(ft->ip); | |
| 1671 g_free(ft->cookie); | |
| 1672 g_free(ft); | |
| 1673 } | |
| 1674 } else { | |
| 1675 buf = g_strdup_printf("%s/%s", ft->filename, ft->hdr.name); | |
| 1676 ft->file = fopen(buf, "w"); | |
| 1677 g_free(buf); | |
| 1678 if (!ft->file) { | |
| 1679 buf = g_strdup_printf("Could not open %s/%s for writing!", ft->filename, | |
| 1680 ft->hdr.name); | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1681 gaim_notify_error(ft->gc, NULL, buf, strerror(errno)); |
| 2086 | 1682 g_free(buf); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1683 gaim_input_remove(ft->inpa); |
| 3630 | 1684 toc_soc_close(source); |
| 2086 | 1685 g_free(ft->filename); |
| 1686 g_free(ft->user); | |
| 1687 g_free(ft->ip); | |
| 1688 g_free(ft->cookie); | |
| 1689 g_free(ft); | |
| 1690 } | |
| 1691 } | |
| 1692 | |
| 1693 return; | |
| 1694 } | |
| 1695 | |
| 3630 | 1696 rt = toc_read(source, buf, MIN(ntohl(ft->hdr.size) - ft->recvsize, 1024)); |
| 2086 | 1697 if (rt < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1698 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1699 _("File transfer failed; other side probably " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1700 "canceled."), NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1701 gaim_input_remove(ft->inpa); |
| 3630 | 1702 toc_soc_close(source); |
| 2086 | 1703 g_free(ft->user); |
| 1704 g_free(ft->ip); | |
| 1705 g_free(ft->cookie); | |
| 1706 if (ft->file) | |
| 1707 fclose(ft->file); | |
| 1708 g_free(ft); | |
| 1709 return; | |
| 1710 } | |
| 1711 ft->recvsize += rt; | |
| 1712 for (i = 0; i < rt; i++) | |
| 1713 fprintf(ft->file, "%c", buf[i]); | |
| 1714 | |
| 1715 if (ft->recvsize == ntohl(ft->hdr.size)) { | |
| 1716 ft->hdr.hdrtype = htons(0x0204); | |
| 1717 ft->hdr.filesleft = htons(ntohs(ft->hdr.filesleft) - 1); | |
| 1718 ft->hdr.partsleft = htons(ntohs(ft->hdr.partsleft) - 1); | |
| 1719 ft->hdr.recvcsum = ft->hdr.checksum; /* uh... */ | |
| 1720 ft->hdr.nrecvd = htons(ntohs(ft->hdr.nrecvd) + 1); | |
| 1721 ft->hdr.flags = 0; | |
| 3630 | 1722 toc_write(source, ft, 256); |
| 2086 | 1723 debug_header(ft); |
| 1724 ft->recvsize = 0; | |
| 1725 fclose(ft->file); | |
| 1726 if (ft->hdr.filesleft == 0) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1727 gaim_input_remove(ft->inpa); |
| 3630 | 1728 toc_soc_close(source); |
| 2086 | 1729 g_free(ft->filename); |
| 1730 g_free(ft->user); | |
| 1731 g_free(ft->ip); | |
| 1732 g_free(ft->cookie); | |
| 1733 g_free(ft); | |
| 1734 } | |
| 1735 } | |
| 1736 } | |
| 1737 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1738 static void toc_send_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 1739 { |
| 1740 struct file_transfer *ft = data; | |
| 1741 | |
| 1742 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1743 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1744 _("Could not connect for transfer."), NULL); |
| 2086 | 1745 g_free(ft->filename); |
| 1746 g_free(ft->cookie); | |
| 1747 g_free(ft->user); | |
| 1748 g_free(ft->ip); | |
| 1749 g_free(ft); | |
| 1750 return; | |
| 1751 } | |
| 1752 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1753 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_send_file_callback, ft); |
| 2086 | 1754 } |
| 1755 | |
| 1756 static void toc_send_file(gpointer a, struct file_transfer *old_ft) | |
| 1757 { | |
| 1758 struct file_transfer *ft; | |
| 1759 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 1760 GaimAccount *account; |
| 2086 | 1761 char buf[BUF_LEN * 2]; |
| 1762 | |
| 5966 | 1763 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 1764 return; |
| 1765 ft = g_new0(struct file_transfer, 1); | |
| 1766 if (old_ft->files == 1) | |
| 1767 ft->filename = g_strdup(dirname); | |
| 1768 else | |
| 4793 | 1769 ft->filename = g_path_get_dirname(dirname); |
| 2086 | 1770 ft->cookie = g_strdup(old_ft->cookie); |
| 1771 ft->user = g_strdup(old_ft->user); | |
| 1772 ft->ip = g_strdup(old_ft->ip); | |
| 1773 ft->files = old_ft->files; | |
| 1774 ft->port = old_ft->port; | |
| 1775 ft->gc = old_ft->gc; | |
| 4491 | 1776 account = ft->gc->account; |
| 2086 | 1777 gtk_widget_destroy(old_ft->window); |
| 1778 | |
| 1779 g_snprintf(buf, sizeof(buf), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_SEND_UID); | |
| 1780 sflap_send(ft->gc, buf, -1, TYPE_DATA); | |
| 1781 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1782 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
|
1783 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1784 _("Could not connect for transfer."), NULL); |
| 2086 | 1785 g_free(ft->filename); |
| 1786 g_free(ft->cookie); | |
| 1787 g_free(ft->user); | |
| 1788 g_free(ft->ip); | |
| 1789 g_free(ft); | |
| 1790 return; | |
| 1791 } | |
| 1792 } | |
| 1793 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1794 static void toc_get_file_callback(gpointer data, gint source, GaimInputCondition cond) |
| 2086 | 1795 { |
| 1796 char buf[BUF_LONG]; | |
| 1797 | |
| 1798 struct file_transfer *ft = data; | |
| 1799 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1800 if (cond & GAIM_INPUT_WRITE) { |
| 2086 | 1801 int remain = MIN(ntohl(ft->hdr.totsize) - ft->recvsize, 1024); |
| 1802 int i; | |
| 1803 for (i = 0; i < remain; i++) | |
| 1804 fscanf(ft->file, "%c", &buf[i]); | |
| 3630 | 1805 toc_write(source, buf, remain); |
| 2086 | 1806 ft->recvsize += remain; |
| 1807 if (ft->recvsize == ntohl(ft->hdr.totsize)) { | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1808 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1809 ft->inpa = gaim_input_add(source, GAIM_INPUT_READ, |
| 2086 | 1810 toc_get_file_callback, ft); |
| 1811 } | |
| 1812 return; | |
| 1813 } | |
| 1814 | |
| 1815 if (ft->hdr.hdrtype == htons(0x1108)) { | |
| 1816 struct tm *fortime; | |
| 1817 struct stat st; | |
| 4793 | 1818 char *basename; |
| 2086 | 1819 |
| 3630 | 1820 toc_read(source, ft, 8); |
| 1821 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1822 debug_header(ft); |
| 1823 | |
| 1824 stat(ft->filename, &st); | |
| 1825 fortime = localtime(&st.st_mtime); | |
| 4793 | 1826 basename = g_path_get_basename(ft->filename); |
| 2086 | 1827 g_snprintf(buf, sizeof(buf), "%2d/%2d/%4d %2d:%2d %8ld %s\r\n", |
| 1828 fortime->tm_mon + 1, fortime->tm_mday, fortime->tm_year + 1900, | |
| 1829 fortime->tm_hour + 1, fortime->tm_min + 1, (long)st.st_size, | |
| 4793 | 1830 basename); |
| 3630 | 1831 toc_write(source, buf, ntohl(ft->hdr.size)); |
| 4793 | 1832 g_free(basename); |
| 2086 | 1833 return; |
| 1834 } | |
| 1835 | |
| 1836 if (ft->hdr.hdrtype == htons(0x1209)) { | |
| 3630 | 1837 toc_read(source, ft, 8); |
| 1838 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1839 debug_header(ft); |
| 1840 return; | |
| 1841 } | |
| 1842 | |
| 1843 if (ft->hdr.hdrtype == htons(0x120b)) { | |
| 3630 | 1844 toc_read(source, ft, 8); |
| 1845 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1846 debug_header(ft); |
| 1847 | |
| 1848 if (ft->hdr.hdrtype != htons(0x120c)) { | |
| 1849 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
|
1850 gaim_notify_error(ft->gc, NULL, buf, NULL); |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1851 gaim_input_remove(ft->inpa); |
| 3630 | 1852 toc_soc_close(source); |
| 2086 | 1853 g_free(ft->filename); |
| 1854 g_free(ft->user); | |
| 1855 g_free(ft->ip); | |
| 1856 g_free(ft->cookie); | |
| 1857 if (ft->file) | |
| 1858 fclose(ft->file); | |
| 1859 g_free(ft); | |
| 1860 return; | |
| 1861 } | |
| 1862 | |
| 1863 ft->hdr.hdrtype = 0x0101; | |
| 1864 ft->hdr.totfiles = htons(1); ft->hdr.filesleft = htons(1); | |
| 1865 ft->hdr.flags = 0x20; | |
| 3630 | 1866 toc_write(source, ft, 256); |
| 2086 | 1867 return; |
| 1868 } | |
| 1869 | |
| 1870 if (ft->hdr.hdrtype == 0x0101) { | |
| 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 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1875 gaim_input_remove(ft->inpa); |
|
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1876 ft->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, |
| 2086 | 1877 toc_get_file_callback, ft); |
| 1878 return; | |
| 1879 } | |
| 1880 | |
| 1881 if (ft->hdr.hdrtype == 0x0202) { | |
| 3630 | 1882 toc_read(source, ft, 8); |
| 1883 toc_read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | |
| 2086 | 1884 debug_header(ft); |
| 1885 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1886 gaim_input_remove(ft->inpa); |
| 3630 | 1887 toc_soc_close(source); |
| 2086 | 1888 g_free(ft->filename); |
| 1889 g_free(ft->user); | |
| 1890 g_free(ft->ip); | |
| 1891 g_free(ft->cookie); | |
| 1892 if (ft->file) | |
| 1893 fclose(ft->file); | |
| 1894 g_free(ft); | |
| 1895 return; | |
| 1896 } | |
| 1897 } | |
| 1898 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1899 static void toc_get_file_connect(gpointer data, gint src, GaimInputCondition cond) |
| 2086 | 1900 { |
| 1901 struct file_transfer *ft = data; | |
| 1902 struct file_header *hdr; | |
| 1903 char *buf; | |
| 4793 | 1904 char *basename; |
| 2086 | 1905 |
| 1906 if (src == -1) { | |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1907 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1908 _("Could not connect for transfer!"), NULL); |
| 2086 | 1909 fclose(ft->file); |
| 1910 g_free(ft->filename); | |
| 1911 g_free(ft->cookie); | |
| 1912 g_free(ft->user); | |
| 1913 g_free(ft->ip); | |
| 1914 g_free(ft); | |
| 1915 return; | |
| 1916 } | |
| 1917 | |
| 1918 hdr = (struct file_header *)ft; | |
| 1919 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | |
| 1920 hdr->hdrlen = htons(256); | |
| 1921 hdr->hdrtype = htons(0x1108); | |
| 1922 frombase64(ft->cookie, &buf, NULL); | |
| 1923 g_snprintf(hdr->bcookie, 8, "%s", buf); | |
| 1924 g_free(buf); | |
| 1925 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | |
| 1926 hdr->totparts = htons(1); hdr->partsleft = htons(1); | |
| 1927 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | |
| 1928 /* size = strlen("mm/dd/yyyy hh:mm sizesize 'name'\r\n") */ | |
| 4793 | 1929 basename = g_path_get_basename(ft->filename); |
| 1930 hdr->size = htonl(28 + strlen(basename)); /* size of listing.txt */ | |
| 1931 g_free(basename); | |
| 2086 | 1932 hdr->modtime = htonl(ft->st.st_mtime); |
| 1933 hdr->checksum = htonl(0x89f70000); /* uh... */ | |
| 1934 g_snprintf(hdr->idstring, 32, "OFT_Windows ICBMFT V1.1 32"); | |
| 1935 hdr->flags = 0x02; | |
| 1936 hdr->lnameoffset = 0x1A; | |
| 1937 hdr->lsizeoffset = 0x10; | |
| 1938 g_snprintf(hdr->name, 64, "listing.txt"); | |
| 3630 | 1939 if (toc_write(src, hdr, 256) < 0) { |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1940 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1941 _("Could not write file header. The file will " |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1942 "not be transferred."), NULL); |
| 2086 | 1943 fclose(ft->file); |
| 1944 g_free(ft->filename); | |
| 1945 g_free(ft->cookie); | |
| 1946 g_free(ft->user); | |
| 1947 g_free(ft->ip); | |
| 1948 g_free(ft); | |
| 1949 return; | |
| 1950 } | |
| 1951 | |
|
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1952 ft->inpa = gaim_input_add(src, GAIM_INPUT_READ, toc_get_file_callback, ft); |
| 2086 | 1953 } |
| 1954 | |
| 1955 static void toc_get_file(gpointer a, struct file_transfer *old_ft) | |
| 1956 { | |
| 1957 struct file_transfer *ft; | |
| 1958 const char *dirname = gtk_file_selection_get_filename(GTK_FILE_SELECTION(old_ft->window)); | |
| 5605 | 1959 GaimAccount *account; |
| 2086 | 1960 char *buf, buf2[BUF_LEN * 2]; |
| 1961 | |
| 5966 | 1962 if (gaim_gtk_check_if_dir(dirname, GTK_FILE_SELECTION(old_ft->window))) |
| 2086 | 1963 return; |
| 1964 ft = g_new0(struct file_transfer, 1); | |
| 1965 ft->filename = g_strdup(dirname); | |
| 1966 ft->file = fopen(ft->filename, "r"); | |
| 1967 if (!ft->file) { | |
| 3427 | 1968 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
|
1969 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 1970 g_free(buf); |
| 1971 g_free(ft->filename); | |
| 1972 g_free(ft); | |
| 1973 return; | |
| 1974 } | |
| 1975 if (stat(dirname, &ft->st)) { | |
| 3427 | 1976 buf = g_strdup_printf("Unable to examine %s.", dirname); |
|
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1977 gaim_notify_error(ft->gc, NULL, buf, NULL); |
| 2086 | 1978 g_free(buf); |
| 1979 g_free(ft->filename); | |
| 1980 g_free(ft); | |
| 1981 return; | |
| 1982 } | |
| 1983 ft->cookie = g_strdup(old_ft->cookie); | |
| 1984 ft->user = g_strdup(old_ft->user); | |
| 1985 ft->ip = g_strdup(old_ft->ip); | |
| 1986 ft->port = old_ft->port; | |
| 1987 ft->gc = old_ft->gc; | |
| 4491 | 1988 account = ft->gc->account; |
| 2086 | 1989 gtk_widget_destroy(old_ft->window); |
| 1990 | |
| 1991 g_snprintf(buf2, sizeof(buf2), "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILE_GET_UID); | |
| 1992 sflap_send(ft->gc, buf2, -1, TYPE_DATA); | |
| 1993 | |
|
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
1994 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
|
1995 gaim_notify_error(ft->gc, NULL, |
|
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1996 _("Could not connect for transfer."), NULL); |
| 2086 | 1997 fclose(ft->file); |
| 1998 g_free(ft->filename); | |
| 1999 g_free(ft->cookie); | |
| 2000 g_free(ft->user); | |
| 2001 g_free(ft->ip); | |
| 2002 g_free(ft); | |
| 2003 return; | |
| 2004 } | |
| 2005 } | |
| 2006 | |
| 2007 static void cancel_callback(gpointer a, struct file_transfer *ft) { | |
| 2008 gtk_widget_destroy(ft->window); | |
| 2009 if (a == ft->window) { | |
| 2010 g_free(ft->cookie); | |
| 2011 g_free(ft->user); | |
| 2012 g_free(ft->ip); | |
| 2013 g_free(ft); | |
| 2014 } | |
| 2015 } | |
| 2016 | |
| 3867 | 2017 static void toc_reject_ft(struct ft_request *ft) { |
| 2018 g_free(ft->user); | |
| 2019 g_free(ft->filename); | |
| 2020 g_free(ft->ip); | |
| 2021 g_free(ft->cookie); | |
| 2022 if (ft->message) | |
| 2023 g_free(ft->message); | |
| 2024 g_free(ft); | |
| 2025 } | |
| 2026 | |
| 2027 | |
| 3730 | 2028 static void toc_accept_ft(struct ft_request *fr) { |
| 5605 | 2029 if(g_list_find(gaim_connections_get_all(), fr->gc)) { |
| 4249 | 2030 GtkWidget *window; |
| 2031 char buf[BUF_LEN]; | |
| 2086 | 2032 |
| 4249 | 2033 struct file_transfer *ft = g_new0(struct file_transfer, 1); |
| 2034 ft->gc = fr->gc; | |
| 2035 ft->user = g_strdup(fr->user); | |
| 2036 ft->cookie = g_strdup(fr->cookie); | |
| 2037 ft->ip = g_strdup(fr->ip); | |
| 2038 ft->port = fr->port; | |
| 2039 ft->files = fr->files; | |
| 2086 | 2040 |
| 4249 | 2041 ft->window = window = gtk_file_selection_new(_("Gaim - Save As...")); |
| 2042 g_snprintf(buf, sizeof(buf), "%s/%s", gaim_home_dir(), fr->filename ? fr->filename : ""); | |
| 2043 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
| 4635 | 2044 g_signal_connect(G_OBJECT(window), "destroy", |
| 2045 G_CALLBACK(cancel_callback), ft); | |
| 2046 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
| 2047 "clicked", G_CALLBACK(cancel_callback), ft); | |
| 2086 | 2048 |
| 4249 | 2049 if (!strcmp(fr->UID, FILE_SEND_UID)) |
| 4635 | 2050 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2051 "clicked", G_CALLBACK(toc_send_file), ft); | |
| 4249 | 2052 else |
| 4635 | 2053 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
| 2054 "clicked", G_CALLBACK(toc_get_file), ft); | |
| 2086 | 2055 |
| 4249 | 2056 gtk_widget_show(window); |
| 2057 } | |
| 2058 | |
| 3867 | 2059 toc_reject_ft(fr); |
| 2086 | 2060 } |
| 2061 | |
| 2062 static void accept_file_dialog(struct ft_request *ft) { | |
| 2063 char buf[BUF_LONG]; | |
| 2064 if (!strcmp(ft->UID, FILE_SEND_UID)) { | |
| 2065 /* holy crap. who the fuck would transfer gigabytes through AIM?! */ | |
| 2066 static char *sizes[4] = { "bytes", "KB", "MB", "GB" }; | |
| 2067 float size = ft->size; | |
| 2068 int index = 0; | |
| 2069 while ((index < 4) && (size > 1024)) { | |
| 2070 size /= 1024; | |
| 2071 index++; | |
| 2072 } | |
| 6500 | 2073 g_snprintf(buf, sizeof(buf), |
| 4276 | 2074 ngettext( |
| 2075 "%s requests %s to accept %d file: %s (%.2f %s)%s%s", | |
| 2076 "%s requests %s to accept %d files: %s (%.2f %s)%s%s", | |
| 2077 ft->files), | |
| 5605 | 2078 ft->user, gaim_account_get_username(ft->gc->account), ft->files, |
| 2086 | 2079 ft->filename, size, sizes[index], (ft->message) ? "\n" : "", |
| 2080 (ft->message) ? ft->message : ""); | |
| 2081 } else { | |
| 2082 g_snprintf(buf, sizeof(buf), _("%s requests you to send them a file"), ft->user); | |
| 2083 } | |
|
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2084 |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2085 gaim_request_accept_cancel(ft->gc, NULL, buf, NULL, 0, ft, |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2086 G_CALLBACK(toc_accept_ft), |
|
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2087 G_CALLBACK(toc_reject_ft)); |
| 2086 | 2088 } |
| 6867 | 2089 #endif |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2090 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2091 static GaimPluginProtocolInfo prpl_info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2092 { |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2093 GAIM_PROTO_TOC, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2094 OPT_PROTO_CORRECT_TIME, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2095 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2096 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2097 toc_list_icon, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2098 toc_list_emblems, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2099 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2100 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2101 toc_away_states, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2102 toc_actions, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2103 toc_buddy_menu, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2104 toc_chat_info, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2105 toc_login, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2106 toc_close, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2107 toc_send_im, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2108 toc_set_info, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2109 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2110 toc_get_info, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2111 toc_set_away, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2112 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2113 toc_set_dir, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2114 toc_get_dir, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2115 toc_dir_search, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2116 toc_set_idle, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2117 toc_change_passwd, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2118 toc_add_buddy, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2119 toc_add_buddies, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2120 toc_remove_buddy, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2121 toc_remove_buddies, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2122 toc_add_permit, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2123 toc_add_deny, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2124 toc_rem_permit, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2125 toc_rem_deny, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2126 toc_set_permit_deny, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2127 toc_warn, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2128 toc_join_chat, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2129 toc_chat_invite, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2130 toc_chat_leave, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2131 toc_chat_whisper, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2132 toc_chat_send, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2133 toc_keepalive, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2134 NULL, |
|
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 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2137 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2138 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2139 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2140 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2141 NULL, |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2142 NULL |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2143 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2144 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2145 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2146 { |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2147 2, /**< api_version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2148 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2149 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2150 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2151 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2152 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2153 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2154 "prpl-toc", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2155 "TOC", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2156 VERSION, /**< version */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2157 /** summary */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2158 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2159 /** description */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2160 N_("TOC Protocol Plugin"), |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2161 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
2162 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2163 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2164 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2165 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2166 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2167 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2168 NULL, /**< ui_info */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2169 &prpl_info /**< extra_info */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2170 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2171 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2172 static void |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2173 init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2174 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2175 GaimAccountOption *option; |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2176 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2177 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
|
2178 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2179 option); |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2180 |
|
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
2181 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
|
2182 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5605
diff
changeset
|
2183 option); |
|
5205
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 my_protocol = plugin; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2186 } |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
2187 |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2188 GAIM_INIT_PLUGIN(toc, init_plugin, info); |
