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