annotate src/protocols/toc/toc.c @ 9454:b6feee45f33d

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