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