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