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