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