Mercurial > pidgin
annotate src/protocols/icq/gaim_icq.c @ 9166:1e51236d825e
[gaim-migrate @ 9951]
This removes some stuff for im image that isn't used anymore.
Basicly one of the things I did when i brought it back, was to make it so
the host widget doesn't have to do any special handling for its imhtml to
support <img id="###"> tags. And while this goal was achieved in 0.78,
there's still code all over the place that checks flags that aren't used
and iterates over lists that will always be empty. This doesn't remove all
of it, but removes some of it anyway.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Wed, 02 Jun 2004 05:08:49 +0000 |
parents | ef881489396e |
children | 7a8aa87164ae |
rev | line source |
---|---|
2086 | 1 #include <string.h> |
2 #include <stdlib.h> | |
3 #include "icq.h" /* well, we're doing ICQ, right? */ | |
4608 | 4 #include "gaim.h" /* needed for every other damn thing */ |
2086 | 5 #include "multi.h" /* needed for gaim_connection */ |
6 #include "prpl.h" /* needed for prpl */ | |
7 #include "proxy.h" | |
8 | |
9 #define USEROPT_NICK 0 | |
10 | |
4249 | 11 static struct prpl *my_protocol = NULL; |
12 | |
2086 | 13 struct icq_data { |
14 icq_Link *link; | |
15 int cur_status; | |
2515
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
16 gboolean connected; |
2086 | 17 }; |
18 | |
19 static guint ack_timer = 0; | |
20 | |
21 static void icq_do_log(icq_Link *link, time_t time, unsigned char level, const char *log) { | |
22 debug_printf("ICQ debug %d: %s", level, log); | |
23 } | |
24 | |
25 GList *sockets = NULL; | |
26 struct gaim_sock { | |
27 int socket; | |
28 int type; | |
29 gint inpa; | |
30 }; | |
31 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
32 static void gaim_icq_handler(gpointer data, gint source, GaimInputCondition cond) { |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
33 if (cond & GAIM_INPUT_READ) |
2086 | 34 icq_HandleReadySocket(source, ICQ_SOCKET_READ); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
35 if (cond & GAIM_INPUT_WRITE) |
2086 | 36 icq_HandleReadySocket(source, ICQ_SOCKET_WRITE); |
37 } | |
38 | |
39 static void icq_sock_notify(int socket, int type, int status) { | |
40 struct gaim_sock *gs = NULL; | |
41 if (status) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
42 GaimInputCondition cond; |
2086 | 43 if (type == ICQ_SOCKET_READ) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
44 cond = GAIM_INPUT_READ; |
2086 | 45 else |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
46 cond = GAIM_INPUT_WRITE; |
2086 | 47 gs = g_new0(struct gaim_sock, 1); |
48 gs->socket = socket; | |
49 gs->type = type; | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
50 gs->inpa = gaim_input_add(socket, cond, gaim_icq_handler, NULL); |
2086 | 51 sockets = g_list_append(sockets, gs); |
52 debug_printf("Adding socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
53 } else { | |
54 GList *m = sockets; | |
55 while (m) { | |
56 gs = m->data; | |
57 if ((gs->socket == socket) && (gs->type == type)) | |
58 break; | |
59 m = g_list_next(m); | |
60 } | |
61 if (m) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
62 gaim_input_remove(gs->inpa); |
2086 | 63 sockets = g_list_remove(sockets, gs); |
64 debug_printf("Removing socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
65 g_free(gs); | |
66 } | |
67 } | |
68 } | |
69 | |
70 static void icq_online(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
71 struct gaim_connection *gc = link->icq_UserData; |
2086 | 72 struct icq_data *id = (struct icq_data *)gc->proto_data; |
73 debug_printf("%s is now online.\n", gc->username); | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
74 if (!id->connected) { |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
75 account_online(gc); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
76 serv_finish_login(gc); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
77 icq_ChangeStatus(id->link, STATUS_ONLINE); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
78 id->connected = TRUE; |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
79 } |
2086 | 80 } |
81 | |
82 static void icq_logged_off(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
83 struct gaim_connection *gc = link->icq_UserData; |
2086 | 84 struct icq_data *id = (struct icq_data *)gc->proto_data; |
85 | |
2515
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
86 if (!id->connected) { |
6106 | 87 gaim_connection_error(gc, "Unable to connect"); |
2515
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
88 signoff(gc); |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
89 return; |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
90 } |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
91 |
2086 | 92 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { |
6106 | 93 gaim_connection_error(gc, "Unable to connect"); |
2086 | 94 signoff(gc); |
95 return; | |
96 } | |
97 | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
98 icq_Login(link, id->cur_status); |
2086 | 99 } |
100 | |
101 static void icq_msg_incoming(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
102 unsigned char day, unsigned char month, unsigned short year, const char *data) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
103 struct gaim_connection *gc = link->icq_UserData; |
2086 | 104 char buf[256], *tmp = g_malloc(BUF_LONG); |
105 g_snprintf(tmp, BUF_LONG, "%s", data); | |
106 g_snprintf(buf, sizeof buf, "%lu", uin); | |
107 strip_linefeed(tmp); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
108 serv_got_im(gc, buf, tmp, 0, time(NULL), -1); |
2086 | 109 g_free(tmp); |
110 } | |
111 | |
112 static void icq_user_online(icq_Link *link, unsigned long uin, unsigned long st, | |
113 unsigned long ip, unsigned short port, unsigned long real_ip, | |
114 unsigned char tcp_flags) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
115 struct gaim_connection *gc = link->icq_UserData; |
2086 | 116 guint status; |
117 char buf[256]; | |
118 | |
119 g_snprintf(buf, sizeof buf, "%lu", uin); | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
120 status = (st == STATUS_ONLINE) ? 0 : UC_UNAVAILABLE | (st << 1); |
4732 | 121 serv_got_update(gc, buf, 1, 0, 0, 0, status); |
2086 | 122 } |
123 | |
124 static void icq_user_offline(icq_Link *link, unsigned long uin) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
125 struct gaim_connection *gc = link->icq_UserData; |
2086 | 126 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); |
4732 | 127 serv_got_update(gc, buf, 0, 0, 0, 0, 0); |
2086 | 128 } |
129 | |
130 static void icq_user_status(icq_Link *link, unsigned long uin, unsigned long st) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
131 struct gaim_connection *gc = link->icq_UserData; |
2086 | 132 guint status; |
133 char buf[256]; | |
134 | |
135 g_snprintf(buf, sizeof buf, "%lu", uin); | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
136 status = (st == STATUS_ONLINE) ? 0 : UC_UNAVAILABLE | (st << 1); |
4732 | 137 serv_got_update(gc, buf, 1, 0, 0, 0, status); |
2086 | 138 } |
139 | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
140 static gboolean icq_set_timeout_cb(gpointer data) { |
2086 | 141 icq_HandleTimeout(); |
142 ack_timer = 0; | |
143 return FALSE; | |
144 } | |
145 | |
146 static void icq_set_timeout(long interval) { | |
147 debug_printf("icq_SetTimeout: %ld\n", interval); | |
148 if (interval > 0 && ack_timer == 0) | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
6623
diff
changeset
|
149 ack_timer = gaim_timeout_add(interval * 1000, icq_set_timeout_cb, NULL); |
2086 | 150 else if (ack_timer > 0) { |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
151 gaim_timeout_remove(ack_timer); |
2086 | 152 ack_timer = 0; |
153 } | |
154 } | |
155 | |
156 static void icq_url_incoming(icq_Link *link, unsigned long uin, unsigned char hour, | |
157 unsigned char minute, unsigned char day, unsigned char month, | |
158 unsigned short year, const char *url, const char *descr) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
159 struct gaim_connection *gc = link->icq_UserData; |
2086 | 160 char *msg = g_malloc(BUF_LONG), buf[256]; |
161 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); | |
162 g_snprintf(buf, 256, "%lu", uin); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
163 serv_got_im(gc, buf, msg, 0, time(NULL), -1); |
2086 | 164 g_free(msg); |
165 } | |
166 | |
167 static void icq_wrong_passwd(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
168 struct gaim_connection *gc = link->icq_UserData; |
6106 | 169 gaim_connection_error(gc, "Invalid password."); |
2086 | 170 signoff(gc); |
171 } | |
172 | |
173 static void icq_invalid_uin(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
174 struct gaim_connection *gc = link->icq_UserData; |
6106 | 175 gaim_connection_error(gc, "Invalid UIN."); |
2086 | 176 signoff(gc); |
177 } | |
178 | |
179 static void icq_info_reply(icq_Link *link, unsigned long uin, const char *nick, | |
180 const char *first, const char *last, const char *email, char auth) { | |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
181 struct gaim_connection *gc = link->icq_UserData; |
2086 | 182 char buf[16 * 1024]; |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
183 char who[16]; |
2086 | 184 |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
185 g_snprintf(who, sizeof who, "%lu", uin); |
2086 | 186 g_snprintf(buf, sizeof buf, |
187 "<B>UIN:</B> %lu<BR>" | |
188 "<B>Nick:</B> %s<BR>" | |
189 "<B>Name:</B> %s %s<BR>" | |
190 "<B>Email:</B> %s\n", | |
191 uin, | |
192 nick, | |
193 first, last, | |
194 email); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
195 g_show_info_text(gc, who, 2, buf, NULL); |
2086 | 196 } |
197 | |
198 static void icq_web_pager(icq_Link *link, unsigned char hour, unsigned char minute, | |
199 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
200 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
201 struct gaim_connection *gc = link->icq_UserData; |
2086 | 202 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email); |
203 char *what = g_malloc(BUF_LONG); | |
204 g_snprintf(what, BUF_LONG, "%s", msg); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
205 serv_got_im(gc, who, what, 0, time(NULL), -1); |
2086 | 206 g_free(who); |
207 g_free(what); | |
208 } | |
209 | |
210 static void icq_mail_express(icq_Link *link, unsigned char hour, unsigned char minute, | |
211 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
212 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
213 struct gaim_connection *gc = link->icq_UserData; |
2086 | 214 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email); |
215 char *what = g_malloc(BUF_LONG); | |
216 g_snprintf(what, BUF_LONG, "%s", msg); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
217 serv_got_im(gc, who, what, 0, time(NULL), -1); |
2086 | 218 g_free(who); |
219 g_free(what); | |
220 } | |
221 | |
222 static void icq_req_not(icq_Link *link, unsigned long id, int type, int arg, void *data) { | |
223 if (type == ICQ_NOTIFY_FAILED) | |
3427 | 224 do_error_dialog(_("Gaim encountered an error communicating with the ICQ server."), NULL, GAIM_ERROR); |
2086 | 225 return; |
226 } | |
227 | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
228 static void icq_recv_add(icq_Link *link, unsigned long id, unsigned char hour, unsigned char minute, |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
229 unsigned char day, unsigned char month, unsigned short year, const char *nick, |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
230 const char *first, const char *last, const char *email) |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
231 { |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
232 char uin[16]; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
233 g_snprintf(uin, sizeof(uin), "%ld", id); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
234 show_got_added(link->icq_UserData, NULL, uin, nick, NULL); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
235 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
236 |
2086 | 237 struct icq_auth { |
238 icq_Link *link; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
239 char *nick; |
2086 | 240 unsigned long uin; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
241 struct gaim_connection *gc; |
2086 | 242 }; |
243 | |
3730 | 244 static void icq_den_auth(struct icq_auth *iq) |
2086 | 245 { |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
246 g_free(iq->nick); |
2086 | 247 g_free(iq); |
248 } | |
249 | |
3730 | 250 static void icq_add_after_auth(struct icq_auth *iq) |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
251 { |
4249 | 252 if (g_slist_find(connections, iq->gc)) { |
253 char uin[16]; | |
254 g_snprintf(uin, sizeof(uin), "%ld", iq->uin); | |
255 show_add_buddy(iq->gc, uin, NULL, iq->nick); | |
256 } | |
3730 | 257 icq_den_auth(iq); |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
258 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
259 |
3730 | 260 static void icq_acc_auth(struct icq_auth *iq) |
2086 | 261 { |
4249 | 262 if (g_slist_find(connections, iq->gc)) { |
263 char msg[1024]; | |
264 char uin[16]; | |
265 struct icq_auth *iqnew; | |
266 | |
267 icq_SendAuthMsg(iq->link, iq->uin); | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
268 |
4249 | 269 g_snprintf(uin, sizeof(uin), "%ld", iq->uin); |
4687 | 270 if (gaim_find_buddy(iq->gc->account, uin)) |
4249 | 271 return; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
272 |
4249 | 273 iqnew = g_memdup(iq, sizeof(struct icq_auth)); |
274 iqnew->nick = g_strdup(iq->nick); | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
275 |
4249 | 276 g_snprintf(msg, sizeof(msg), "Add %ld to your buddy list?", iq->uin); |
277 do_ask_dialog(msg, NULL, iqnew, _("Add"), icq_add_after_auth, _("Cancel"), icq_den_auth, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); | |
278 } | |
279 | |
3730 | 280 icq_den_auth(iq); |
2086 | 281 } |
282 | |
283 static void icq_auth_req(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
284 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
285 const char *first, const char *last, const char *email, const char *reason) | |
286 { | |
287 char msg[8192]; | |
288 struct icq_auth *iq = g_new0(struct icq_auth, 1); | |
289 iq->link = link; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
290 iq->nick = g_strdup(nick); |
2086 | 291 iq->uin = uin; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
292 iq->gc = link->icq_UserData; |
2086 | 293 |
4834 | 294 g_snprintf(msg, sizeof(msg), _("The user %s (%s%s%s%s%s) wants you to authorize them."), |
2086 | 295 nick, first ? first : "", first && last ? " " : "", last ? last : "", |
296 (first || last) && email ? ", " : "", email ? email : ""); | |
4249 | 297 do_ask_dialog(msg, NULL, iq, _("Authorize"), icq_acc_auth, _("Deny"), icq_den_auth, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2086 | 298 } |
299 | |
4491 | 300 static void icq_login(struct gaim_account *account) { |
301 struct gaim_connection *gc = new_gaim_conn(account); | |
2086 | 302 struct icq_data *id = gc->proto_data = g_new0(struct icq_data, 1); |
4634 | 303 struct gaim_proxy_info *gpi = account->gpi; |
2086 | 304 icq_Link *link; |
305 char ps[9]; | |
306 | |
4634 | 307 if(!gpi) |
308 gpi = &global_proxy_info; | |
309 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
310 gc->checkbox = _("Send message through server"); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
311 |
2086 | 312 icq_LogLevel = ICQ_LOG_MESSAGE; |
313 | |
4491 | 314 g_snprintf(ps, sizeof(ps), "%s", account->password); |
315 link = id->link = icq_ICQLINKNew(atol(account->username), ps, | |
316 account->proto_opt[USEROPT_NICK][0] ? account->proto_opt[USEROPT_NICK] : "gaim user", | |
2086 | 317 TRUE); |
4491 | 318 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", account->proto_opt[USEROPT_NICK]); |
2086 | 319 |
320 link->icq_Logged = icq_online; | |
321 link->icq_Disconnected = icq_logged_off; | |
322 link->icq_RecvMessage = icq_msg_incoming; | |
323 link->icq_RecvURL = icq_url_incoming; | |
324 link->icq_RecvWebPager = icq_web_pager; | |
325 link->icq_RecvMailExpress = icq_mail_express; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
326 link->icq_RecvAdded = icq_recv_add; |
2086 | 327 link->icq_RecvAuthReq = icq_auth_req; |
328 link->icq_UserOnline = icq_user_online; | |
329 link->icq_UserOffline = icq_user_offline; | |
330 link->icq_UserStatusUpdate = icq_user_status; | |
331 link->icq_InfoReply = icq_info_reply; | |
332 link->icq_WrongPassword = icq_wrong_passwd; | |
333 link->icq_InvalidUIN = icq_invalid_uin; | |
334 link->icq_Log = icq_do_log; | |
335 link->icq_RequestNotify = icq_req_not; | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
336 link->icq_UserData = gc; |
2086 | 337 |
4634 | 338 if (gpi->proxytype == PROXY_SOCKS5) |
339 icq_SetProxy(link, gpi->proxyhost, gpi->proxyport, gpi->proxyuser[0], gpi->proxyuser, gpi->proxypass); | |
2086 | 340 |
341 icq_ContactClear(id->link); | |
342 | |
343 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
6623 | 344 gaim_connection_error(gc, _("Unable to connect.")); |
2086 | 345 signoff(gc); |
346 return; | |
347 } | |
348 | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
349 id->cur_status = STATUS_ONLINE; |
2086 | 350 icq_Login(link, STATUS_ONLINE); |
351 | |
6106 | 352 gaim_connection_update_progress(gc, _("Connecting..."), 0, 2); |
2086 | 353 } |
354 | |
355 static void icq_close(struct gaim_connection *gc) { | |
356 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
357 | |
358 icq_Logout(id->link); | |
359 icq_Disconnect(id->link); | |
360 icq_ICQLINKDelete(id->link); | |
361 g_free(id); | |
362 } | |
363 | |
5136 | 364 static int icq_send_msg(struct gaim_connection *gc, const char *who, const char *msg, int len, int flags) { |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
365 if (!(flags & IM_FLAG_AWAY) && (strlen(msg) > 0)) { |
2086 | 366 struct icq_data *id = (struct icq_data *)gc->proto_data; |
367 long w = atol(who); | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
368 icq_SendMessage(id->link, w, msg, |
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
369 (flags & IM_FLAG_CHECKBOX) ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY); |
2086 | 370 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
371 return 1; |
2086 | 372 } |
373 | |
374 static void icq_keepalive(struct gaim_connection *gc) { | |
375 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
376 icq_KeepAlive(id->link); | |
377 } | |
378 | |
3466 | 379 static void icq_add_buddy(struct gaim_connection *gc, const char *who) { |
2086 | 380 struct icq_data *id = (struct icq_data *)gc->proto_data; |
381 icq_ContactAdd(id->link, atol(who)); | |
382 icq_ContactSetVis(id->link, atol(who), TRUE); | |
383 } | |
384 | |
385 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) { | |
386 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
387 while (whos) { | |
388 icq_ContactAdd(id->link, atol(whos->data)); | |
389 icq_ContactSetVis(id->link, atol(whos->data), TRUE); | |
390 whos = whos->next; | |
391 } | |
392 } | |
393 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
394 static void icq_rem_buddy(struct gaim_connection *gc, char *who, char *group) { |
2086 | 395 struct icq_data *id = (struct icq_data *)gc->proto_data; |
396 icq_ContactRemove(id->link, atol(who)); | |
397 } | |
398 | |
399 static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { | |
400 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
401 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
402 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
403 g_free(gc->away); |
2086 | 404 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
405 } |
2086 | 406 |
407 if (!strcmp(state, "Online")) | |
408 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
409 else if (!strcmp(state, "Away")) { | |
410 icq_ChangeStatus(id->link, STATUS_AWAY); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
411 gc->away = g_strdup(""); |
2086 | 412 } else if (!strcmp(state, "Do Not Disturb")) { |
413 icq_ChangeStatus(id->link, STATUS_DND); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
414 gc->away = g_strdup(""); |
2086 | 415 } else if (!strcmp(state, "Not Available")) { |
416 icq_ChangeStatus(id->link, STATUS_NA); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
417 gc->away = g_strdup(""); |
2086 | 418 } else if (!strcmp(state, "Occupied")) { |
419 icq_ChangeStatus(id->link, STATUS_OCCUPIED); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
420 gc->away = g_strdup(""); |
2086 | 421 } else if (!strcmp(state, "Free For Chat")) { |
422 icq_ChangeStatus(id->link, STATUS_FREE_CHAT); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
423 gc->away = g_strdup(""); |
2086 | 424 } else if (!strcmp(state, "Invisible")) { |
425 icq_ChangeStatus(id->link, STATUS_INVISIBLE); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
426 gc->away = g_strdup(""); |
2086 | 427 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
428 if (msg) { | |
429 icq_ChangeStatus(id->link, STATUS_NA); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
430 gc->away = g_strdup(""); |
2086 | 431 } else { |
432 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
433 } | |
434 } | |
435 } | |
436 | |
4687 | 437 static const char *icq_list_icon(struct gaim_account *a, struct buddy *b) { |
438 return "icq"; | |
439 } | |
440 | |
441 /* guint status; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
442 if (uc == 0) |
2086 | 443 return icon_online_xpm; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
444 status = uc >> 1; |
2086 | 445 if (status & STATUS_NA) |
446 return icon_na_xpm; | |
447 if (status & STATUS_DND) | |
448 return icon_dnd_xpm; | |
449 if (status & STATUS_OCCUPIED) | |
450 return icon_occ_xpm; | |
451 if (status & STATUS_AWAY) | |
452 return icon_away_xpm; | |
453 if (status & STATUS_FREE_CHAT) | |
454 return icon_ffc_xpm; | |
455 if (status & STATUS_INVISIBLE) | |
456 return NULL; | |
457 return icon_online_xpm; | |
4687 | 458 }*/ |
2086 | 459 |
5136 | 460 static void icq_get_info(struct gaim_connection *gc, const char *who) { |
2086 | 461 struct icq_data *id = (struct icq_data *)gc->proto_data; |
462 icq_SendInfoReq(id->link, atol(who)); | |
463 } | |
464 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
465 static GList *icq_away_states(struct gaim_connection *gc) { |
2086 | 466 GList *m = NULL; |
467 | |
468 m = g_list_append(m, "Online"); | |
469 m = g_list_append(m, "Away"); | |
470 m = g_list_append(m, "Do Not Disturb"); | |
471 m = g_list_append(m, "Not Available"); | |
472 m = g_list_append(m, "Occupied"); | |
473 m = g_list_append(m, "Free For Chat"); | |
474 m = g_list_append(m, "Invisible"); | |
475 | |
476 return m; | |
477 } | |
478 | |
479 void icq_init(struct prpl *ret) { | |
3572 | 480 struct proto_user_opt *puo; |
2086 | 481 ret->protocol = PROTO_ICQ; |
3572 | 482 ret->name = g_strdup("ICQ"); |
2086 | 483 ret->list_icon = icq_list_icon; |
484 ret->away_states = icq_away_states; | |
4732 | 485 ret->buddy_menu = NULL; |
2086 | 486 ret->login = icq_login; |
487 ret->close = icq_close; | |
488 ret->send_im = icq_send_msg; | |
489 ret->add_buddy = icq_add_buddy; | |
490 ret->add_buddies = icq_add_buddies; | |
491 ret->remove_buddy = icq_rem_buddy; | |
492 ret->get_info = icq_get_info; | |
493 ret->set_away = icq_set_away; | |
494 ret->keepalive = icq_keepalive; | |
495 | |
3572 | 496 puo = g_new0(struct proto_user_opt, 1); |
4115 | 497 puo->label = g_strdup(_("Nick:")); |
498 puo->def = g_strdup(_("Gaim User")); | |
3572 | 499 puo->pos = USEROPT_NICK; |
500 ret->user_opts = g_list_append(ret->user_opts, puo); | |
501 | |
2086 | 502 my_protocol = ret; |
503 | |
504 icq_SocketNotify = icq_sock_notify; | |
505 icq_SetTimeout = icq_set_timeout; | |
506 } | |
507 | |
508 #ifndef STATIC | |
509 | |
3867 | 510 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 511 { |
3572 | 512 icq_init(prpl); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
513 prpl->plug->desc.api_version = GAIM_PLUGIN_API_VERSION; |
2086 | 514 } |
515 #endif |