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