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