Mercurial > pidgin
annotate src/protocols/icq/gaim_icq.c @ 2501:227cc42ffa6e
[gaim-migrate @ 2514]
i should have hidden something ultra-secret in this.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 14 Oct 2001 11:36:36 +0000 |
parents | 569ae9f2bb89 |
children | 3ec36a342496 |
rev | line source |
---|---|
2086 | 1 #include <string.h> |
2 #include <stdlib.h> | |
3 #include "icq.h" /* well, we're doing ICQ, right? */ | |
4 #include "multi.h" /* needed for gaim_connection */ | |
5 #include "prpl.h" /* needed for prpl */ | |
6 #include "gaim.h" /* needed for every other damn thing */ | |
7 #include "proxy.h" | |
8 | |
9 #include "pixmaps/gnomeicu-online.xpm" | |
10 #include "pixmaps/gnomeicu-away.xpm" | |
11 #include "pixmaps/gnomeicu-dnd.xpm" | |
12 #include "pixmaps/gnomeicu-na.xpm" | |
13 #include "pixmaps/gnomeicu-occ.xpm" | |
14 #include "pixmaps/gnomeicu-ffc.xpm" | |
15 | |
16 #define USEROPT_NICK 0 | |
17 | |
18 struct icq_data { | |
19 icq_Link *link; | |
20 int cur_status; | |
21 }; | |
22 | |
23 static guint ack_timer = 0; | |
24 | |
25 static char *icq_name() { | |
26 return "ICQ"; | |
27 } | |
28 | |
29 static void icq_do_log(icq_Link *link, time_t time, unsigned char level, const char *log) { | |
30 debug_printf("ICQ debug %d: %s", level, log); | |
31 } | |
32 | |
33 GList *sockets = NULL; | |
34 struct gaim_sock { | |
35 int socket; | |
36 int type; | |
37 gint inpa; | |
38 }; | |
39 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
40 static void gaim_icq_handler(gpointer data, gint source, GaimInputCondition cond) { |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
41 if (cond & GAIM_INPUT_READ) |
2086 | 42 icq_HandleReadySocket(source, ICQ_SOCKET_READ); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
43 if (cond & GAIM_INPUT_WRITE) |
2086 | 44 icq_HandleReadySocket(source, ICQ_SOCKET_WRITE); |
45 } | |
46 | |
47 static void icq_sock_notify(int socket, int type, int status) { | |
48 struct gaim_sock *gs = NULL; | |
49 if (status) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
50 GaimInputCondition cond; |
2086 | 51 if (type == ICQ_SOCKET_READ) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
52 cond = GAIM_INPUT_READ; |
2086 | 53 else |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
54 cond = GAIM_INPUT_WRITE; |
2086 | 55 gs = g_new0(struct gaim_sock, 1); |
56 gs->socket = socket; | |
57 gs->type = type; | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
58 gs->inpa = gaim_input_add(socket, cond, gaim_icq_handler, NULL); |
2086 | 59 sockets = g_list_append(sockets, gs); |
60 debug_printf("Adding socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
61 } else { | |
62 GList *m = sockets; | |
63 while (m) { | |
64 gs = m->data; | |
65 if ((gs->socket == socket) && (gs->type == type)) | |
66 break; | |
67 m = g_list_next(m); | |
68 } | |
69 if (m) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
70 gaim_input_remove(gs->inpa); |
2086 | 71 sockets = g_list_remove(sockets, gs); |
72 debug_printf("Removing socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
73 g_free(gs); | |
74 } | |
75 } | |
76 } | |
77 | |
78 static void icq_online(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
79 struct gaim_connection *gc = link->icq_UserData; |
2086 | 80 struct icq_data *id = (struct icq_data *)gc->proto_data; |
81 debug_printf("%s is now online.\n", gc->username); | |
82 account_online(gc); | |
83 /*gc->options |= OPT_USR_KEEPALV; this is always-on now */ | |
84 serv_finish_login(gc); | |
85 | |
86 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
87 } | |
88 | |
89 static void icq_logged_off(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
90 struct gaim_connection *gc = link->icq_UserData; |
2086 | 91 struct icq_data *id = (struct icq_data *)gc->proto_data; |
92 | |
93 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
94 hide_login_progress(gc, "Unable to connect"); | |
95 signoff(gc); | |
96 return; | |
97 } | |
98 | |
99 icq_Login(link, STATUS_ONLINE); | |
100 id->cur_status = STATUS_ONLINE; | |
101 } | |
102 | |
103 void strip_linefeed(gchar *text) | |
104 { | |
105 int i, j; | |
106 gchar *text2 = g_malloc(strlen(text) + 1); | |
107 | |
108 for (i = 0, j = 0; text[i]; i++) | |
109 if (text[i] != '\r') | |
110 text2[j++] = text[i]; | |
111 text2[j] = '\0'; | |
112 | |
113 strcpy(text, text2); | |
114 g_free(text2); | |
115 } | |
116 | |
117 static void icq_msg_incoming(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
118 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
|
119 struct gaim_connection *gc = link->icq_UserData; |
2086 | 120 char buf[256], *tmp = g_malloc(BUF_LONG); |
121 g_snprintf(tmp, BUF_LONG, "%s", data); | |
122 g_snprintf(buf, sizeof buf, "%lu", uin); | |
123 strip_linefeed(tmp); | |
124 serv_got_im(gc, buf, tmp, 0, time((time_t)NULL)); | |
125 g_free(tmp); | |
126 } | |
127 | |
128 static void icq_user_online(icq_Link *link, unsigned long uin, unsigned long st, | |
129 unsigned long ip, unsigned short port, unsigned long real_ip, | |
130 unsigned char tcp_flags) { | |
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); |
2086 | 137 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
138 } | |
139 | |
140 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
|
141 struct gaim_connection *gc = link->icq_UserData; |
2086 | 142 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); |
143 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); | |
144 } | |
145 | |
146 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
|
147 struct gaim_connection *gc = link->icq_UserData; |
2086 | 148 guint status; |
149 char buf[256]; | |
150 | |
151 g_snprintf(buf, sizeof buf, "%lu", uin); | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
152 status = (st == STATUS_ONLINE) ? 0 : UC_UNAVAILABLE | (st << 1); |
2086 | 153 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
154 } | |
155 | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
156 static gboolean icq_set_timeout_cb(gpointer data) { |
2086 | 157 icq_HandleTimeout(); |
158 ack_timer = 0; | |
159 return FALSE; | |
160 } | |
161 | |
162 static void icq_set_timeout(long interval) { | |
163 debug_printf("icq_SetTimeout: %ld\n", interval); | |
164 if (interval > 0 && ack_timer == 0) | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
165 ack_timer = g_timeout_add(interval * 1000, icq_set_timeout_cb, NULL); |
2086 | 166 else if (ack_timer > 0) { |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
167 g_source_remove(ack_timer); |
2086 | 168 ack_timer = 0; |
169 } | |
170 } | |
171 | |
172 static void icq_url_incoming(icq_Link *link, unsigned long uin, unsigned char hour, | |
173 unsigned char minute, unsigned char day, unsigned char month, | |
174 unsigned short year, const char *url, const char *descr) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
175 struct gaim_connection *gc = link->icq_UserData; |
2086 | 176 char *msg = g_malloc(BUF_LONG), buf[256]; |
177 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); | |
178 g_snprintf(buf, 256, "%lu", uin); | |
179 serv_got_im(gc, buf, msg, 0, time((time_t)NULL)); | |
180 g_free(msg); | |
181 } | |
182 | |
183 static void icq_wrong_passwd(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
184 struct gaim_connection *gc = link->icq_UserData; |
2086 | 185 hide_login_progress(gc, "Invalid password."); |
186 signoff(gc); | |
187 } | |
188 | |
189 static void icq_invalid_uin(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
190 struct gaim_connection *gc = link->icq_UserData; |
2086 | 191 hide_login_progress(gc, "Invalid UIN."); |
192 signoff(gc); | |
193 } | |
194 | |
195 static void icq_info_reply(icq_Link *link, unsigned long uin, const char *nick, | |
196 const char *first, const char *last, const char *email, char auth) { | |
197 char buf[16 * 1024]; | |
198 | |
199 g_snprintf(buf, sizeof buf, | |
200 "<B>UIN:</B> %lu<BR>" | |
201 "<B>Nick:</B> %s<BR>" | |
202 "<B>Name:</B> %s %s<BR>" | |
203 "<B>Email:</B> %s\n", | |
204 uin, | |
205 nick, | |
206 first, last, | |
207 email); | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2130
diff
changeset
|
208 g_show_info_text(buf, NULL); |
2086 | 209 } |
210 | |
211 static void icq_web_pager(icq_Link *link, unsigned char hour, unsigned char minute, | |
212 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
213 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
214 struct gaim_connection *gc = link->icq_UserData; |
2086 | 215 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email); |
216 char *what = g_malloc(BUF_LONG); | |
217 g_snprintf(what, BUF_LONG, "%s", msg); | |
218 serv_got_im(gc, who, what, 0, time((time_t)NULL)); | |
219 g_free(who); | |
220 g_free(what); | |
221 } | |
222 | |
223 static void icq_mail_express(icq_Link *link, unsigned char hour, unsigned char minute, | |
224 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
225 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
226 struct gaim_connection *gc = link->icq_UserData; |
2086 | 227 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email); |
228 char *what = g_malloc(BUF_LONG); | |
229 g_snprintf(what, BUF_LONG, "%s", msg); | |
230 serv_got_im(gc, who, what, 0, time((time_t)NULL)); | |
231 g_free(who); | |
232 g_free(what); | |
233 } | |
234 | |
235 static void icq_req_not(icq_Link *link, unsigned long id, int type, int arg, void *data) { | |
236 if (type == ICQ_NOTIFY_FAILED) | |
237 do_error_dialog("Failure in sending packet", "ICQ error"); | |
238 return; | |
239 } | |
240 | |
241 struct icq_auth { | |
242 icq_Link *link; | |
243 unsigned long uin; | |
244 }; | |
245 | |
246 static void icq_den_auth(gpointer x, struct icq_auth *iq) | |
247 { | |
248 g_free(iq); | |
249 } | |
250 | |
251 static void icq_acc_auth(gpointer x, struct icq_auth *iq) | |
252 { | |
253 icq_SendAuthMsg(iq->link, iq->uin); | |
254 } | |
255 | |
256 static void icq_auth_req(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
257 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
258 const char *first, const char *last, const char *email, const char *reason) | |
259 { | |
260 char msg[8192]; | |
261 struct icq_auth *iq = g_new0(struct icq_auth, 1); | |
262 iq->link = link; | |
263 iq->uin = uin; | |
264 | |
265 g_snprintf(msg, sizeof(msg), "The user %s (%s%s%s%s%s) wants you to authorize them.", | |
266 nick, first ? first : "", first && last ? " " : "", last ? last : "", | |
267 (first || last) && email ? ", " : "", email ? email : ""); | |
268 do_ask_dialog(msg, iq, icq_acc_auth, icq_den_auth); | |
269 } | |
270 | |
271 static void icq_login(struct aim_user *user) { | |
272 struct gaim_connection *gc = new_gaim_conn(user); | |
273 struct icq_data *id = gc->proto_data = g_new0(struct icq_data, 1); | |
274 icq_Link *link; | |
275 char ps[9]; | |
276 | |
277 icq_LogLevel = ICQ_LOG_MESSAGE; | |
278 | |
279 g_snprintf(ps, sizeof(ps), "%s", user->password); | |
280 link = id->link = icq_ICQLINKNew(atol(user->username), ps, | |
281 user->proto_opt[USEROPT_NICK][0] ? user->proto_opt[USEROPT_NICK] : "gaim user", | |
282 TRUE); | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
283 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", user->proto_opt[USEROPT_NICK]); |
2086 | 284 |
285 link->icq_Logged = icq_online; | |
286 link->icq_Disconnected = icq_logged_off; | |
287 link->icq_RecvMessage = icq_msg_incoming; | |
288 link->icq_RecvURL = icq_url_incoming; | |
289 link->icq_RecvWebPager = icq_web_pager; | |
290 link->icq_RecvMailExpress = icq_mail_express; | |
291 link->icq_RecvAuthReq = icq_auth_req; | |
292 link->icq_UserOnline = icq_user_online; | |
293 link->icq_UserOffline = icq_user_offline; | |
294 link->icq_UserStatusUpdate = icq_user_status; | |
295 link->icq_InfoReply = icq_info_reply; | |
296 link->icq_WrongPassword = icq_wrong_passwd; | |
297 link->icq_InvalidUIN = icq_invalid_uin; | |
298 link->icq_Log = icq_do_log; | |
299 link->icq_RequestNotify = icq_req_not; | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
300 link->icq_UserData = gc; |
2086 | 301 |
302 if (proxytype == PROXY_SOCKS5) | |
303 icq_SetProxy(link, proxyhost, proxyport, proxyuser[0], proxyuser, proxypass); | |
304 | |
305 icq_ContactClear(id->link); | |
306 if (bud_list_cache_exists(gc)) | |
2382
569ae9f2bb89
[gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2303
diff
changeset
|
307 do_import(gc, NULL); |
2086 | 308 |
309 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
310 hide_login_progress(gc, "Unable to connect"); | |
311 signoff(gc); | |
312 return; | |
313 } | |
314 | |
315 icq_Login(link, STATUS_ONLINE); | |
316 id->cur_status = STATUS_ONLINE; | |
317 | |
318 set_login_progress(gc, 0, "Connecting..."); | |
319 } | |
320 | |
321 static void icq_close(struct gaim_connection *gc) { | |
322 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
323 | |
324 icq_Logout(id->link); | |
325 icq_Disconnect(id->link); | |
326 icq_ICQLINKDelete(id->link); | |
327 g_free(id); | |
328 } | |
329 | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
330 static int icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int flags) { |
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
331 if (!(flags & IM_FLAG_AWAY) && (strlen(msg) > 0)) { |
2086 | 332 struct icq_data *id = (struct icq_data *)gc->proto_data; |
333 long w = atol(who); | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
334 icq_SendMessage(id->link, w, msg, |
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
335 (flags & IM_FLAG_CHECKBOX) ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY); |
2086 | 336 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
337 return 1; |
2086 | 338 } |
339 | |
340 static void icq_keepalive(struct gaim_connection *gc) { | |
341 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
342 icq_KeepAlive(id->link); | |
343 } | |
344 | |
345 static void icq_add_buddy(struct gaim_connection *gc, char *who) { | |
346 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
347 icq_ContactAdd(id->link, atol(who)); | |
348 icq_ContactSetVis(id->link, atol(who), TRUE); | |
349 } | |
350 | |
351 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) { | |
352 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
353 while (whos) { | |
354 icq_ContactAdd(id->link, atol(whos->data)); | |
355 icq_ContactSetVis(id->link, atol(whos->data), TRUE); | |
356 whos = whos->next; | |
357 } | |
358 } | |
359 | |
360 static void icq_rem_buddy(struct gaim_connection *gc, char *who) { | |
361 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
362 icq_ContactRemove(id->link, atol(who)); | |
363 } | |
364 | |
365 static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { | |
366 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
367 | |
368 if (gc->away) | |
369 gc->away = NULL; | |
370 | |
371 if (!strcmp(state, "Online")) | |
372 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
373 else if (!strcmp(state, "Away")) { | |
374 icq_ChangeStatus(id->link, STATUS_AWAY); | |
375 gc->away = ""; | |
376 } else if (!strcmp(state, "Do Not Disturb")) { | |
377 icq_ChangeStatus(id->link, STATUS_DND); | |
378 gc->away = ""; | |
379 } else if (!strcmp(state, "Not Available")) { | |
380 icq_ChangeStatus(id->link, STATUS_NA); | |
381 gc->away = ""; | |
382 } else if (!strcmp(state, "Occupied")) { | |
383 icq_ChangeStatus(id->link, STATUS_OCCUPIED); | |
384 gc->away = ""; | |
385 } else if (!strcmp(state, "Free For Chat")) { | |
386 icq_ChangeStatus(id->link, STATUS_FREE_CHAT); | |
387 gc->away = ""; | |
388 } else if (!strcmp(state, "Invisible")) { | |
389 icq_ChangeStatus(id->link, STATUS_INVISIBLE); | |
390 gc->away = ""; | |
391 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { | |
392 if (msg) { | |
393 icq_ChangeStatus(id->link, STATUS_NA); | |
394 gc->away = ""; | |
395 } else { | |
396 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
397 } | |
398 } | |
399 } | |
400 | |
401 static char **icq_list_icon(int uc) { | |
402 guint status; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
403 if (uc == 0) |
2086 | 404 return icon_online_xpm; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
405 status = uc >> 1; |
2086 | 406 if (status & STATUS_NA) |
407 return icon_na_xpm; | |
408 if (status & STATUS_DND) | |
409 return icon_dnd_xpm; | |
410 if (status & STATUS_OCCUPIED) | |
411 return icon_occ_xpm; | |
412 if (status & STATUS_AWAY) | |
413 return icon_away_xpm; | |
414 if (status & STATUS_FREE_CHAT) | |
415 return icon_ffc_xpm; | |
416 if (status & STATUS_INVISIBLE) | |
417 return NULL; | |
418 return icon_online_xpm; | |
419 } | |
420 | |
421 static void icq_get_info(struct gaim_connection *gc, char *who) { | |
422 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
423 icq_SendInfoReq(id->link, atol(who)); | |
424 } | |
425 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
426 static void icq_info(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
427 serv_get_info(gc, who); |
2086 | 428 } |
429 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
430 static GList *icq_buddy_menu(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
431 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
432 struct proto_buddy_menu *pbm; |
2086 | 433 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
434 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
435 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
436 pbm->callback = icq_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
437 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
438 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
439 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
440 return m; |
2086 | 441 } |
442 | |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
443 static GList *icq_user_opts() { |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
444 GList *m = NULL; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
445 struct proto_user_opt *puo; |
2086 | 446 |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
447 puo = g_new0(struct proto_user_opt, 1); |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
448 puo->label = "Nick:"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
449 puo->def = "Gaim User"; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
450 puo->pos = USEROPT_NICK; |
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
451 m = g_list_append(m, puo); |
2086 | 452 |
2154
cff133e0ec0c
[gaim-migrate @ 2164]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2138
diff
changeset
|
453 return m; |
2086 | 454 } |
455 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
456 static GList *icq_away_states(struct gaim_connection *gc) { |
2086 | 457 GList *m = NULL; |
458 | |
459 m = g_list_append(m, "Online"); | |
460 m = g_list_append(m, "Away"); | |
461 m = g_list_append(m, "Do Not Disturb"); | |
462 m = g_list_append(m, "Not Available"); | |
463 m = g_list_append(m, "Occupied"); | |
464 m = g_list_append(m, "Free For Chat"); | |
465 m = g_list_append(m, "Invisible"); | |
466 | |
467 return m; | |
468 } | |
469 | |
470 static struct prpl *my_protocol = NULL; | |
471 | |
472 void icq_init(struct prpl *ret) { | |
473 ret->protocol = PROTO_ICQ; | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
474 ret->checkbox = "Send message through server"; |
2086 | 475 ret->name = icq_name; |
476 ret->list_icon = icq_list_icon; | |
477 ret->away_states = icq_away_states; | |
478 ret->buddy_menu = icq_buddy_menu; | |
479 ret->user_opts = icq_user_opts; | |
480 ret->login = icq_login; | |
481 ret->close = icq_close; | |
482 ret->send_im = icq_send_msg; | |
483 ret->add_buddy = icq_add_buddy; | |
484 ret->add_buddies = icq_add_buddies; | |
485 ret->remove_buddy = icq_rem_buddy; | |
486 ret->get_info = icq_get_info; | |
487 ret->set_away = icq_set_away; | |
488 ret->keepalive = icq_keepalive; | |
489 | |
490 my_protocol = ret; | |
491 | |
492 icq_SocketNotify = icq_sock_notify; | |
493 icq_SetTimeout = icq_set_timeout; | |
494 } | |
495 | |
496 #ifndef STATIC | |
497 | |
498 char *gaim_plugin_init(GModule *handle) | |
499 { | |
500 load_protocol(icq_init, sizeof(struct prpl)); | |
501 return NULL; | |
502 } | |
503 | |
504 void gaim_plugin_remove() | |
505 { | |
506 struct prpl *p = find_prpl(PROTO_ICQ); | |
507 if (p == my_protocol) | |
508 unload_protocol(p); | |
509 } | |
510 | |
511 char *name() | |
512 { | |
513 return "ICQ"; | |
514 } | |
515 | |
516 char *description() | |
517 { | |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2154
diff
changeset
|
518 return PRPL_DESC("ICQ"); |
2086 | 519 } |
520 | |
521 #endif |