Mercurial > pidgin
annotate src/protocols/icq/gaim_icq.c @ 4687:283fb289c510
[gaim-migrate @ 4998]
This is a new buddy list.
Lots of things about it just Don't Work. I probably already know about those
things, and you'd just be wasting my time in submitting a bug report about it.
I decided that instead of getting it to all work perfectly before committing,
that I'd get it in cvs, and slowly fix it with regular commits. That way, it's
easier to keep track of things, and other developers can help. Plus, I'm getting
pissed off at the buddy list and want it to die. It's kinda boring, and doing nothing
but the buddy list for such a long time has just gotten me very bitter.
After 0.60 is released later this week, Gaim will resume being fun. This week is
going to be very stressful, though, I'm sure.
Things you ought to know about this buddy list:
- It crashes
- It leaks
- There's no way to edit the buddy list, or access offline buddies
- Most of the menus and buttons and whatnot just plain ol' don't work.
- Status icons are only implemented for AIM.
That's mostly just because I'm lazy. As such, you may want to be wary of updating this.
If you do decide to update this, you may want to learn "cvs update -D yesterday" as well :)
All the art there is just placeholder art.
You probably won't really have as many problems as it sounds like you will from reading this.
This message is extra-negative to stress that I don't want to be bothered with complaints about
something not working about it :). I'll repeat: If something doesn't work, I probably already
know about it.
If you want to actually help with something, I'd be delighted to have it. IM me.
-s.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 10 Mar 2003 05:30:31 +0000 |
parents | d19872836812 |
children | e19f91053ad0 |
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 | |
3579 | 9 #include "pixmaps/protocols/icq/gnomeicu-online.xpm" |
10 #include "pixmaps/protocols/icq/gnomeicu-away.xpm" | |
11 #include "pixmaps/protocols/icq/gnomeicu-dnd.xpm" | |
12 #include "pixmaps/protocols/icq/gnomeicu-na.xpm" | |
13 #include "pixmaps/protocols/icq/gnomeicu-occ.xpm" | |
14 #include "pixmaps/protocols/icq/gnomeicu-ffc.xpm" | |
2086 | 15 |
16 #define USEROPT_NICK 0 | |
17 | |
4249 | 18 static struct prpl *my_protocol = NULL; |
19 | |
2086 | 20 struct icq_data { |
21 icq_Link *link; | |
22 int cur_status; | |
2515
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
23 gboolean connected; |
2086 | 24 }; |
25 | |
26 static guint ack_timer = 0; | |
27 | |
28 static void icq_do_log(icq_Link *link, time_t time, unsigned char level, const char *log) { | |
29 debug_printf("ICQ debug %d: %s", level, log); | |
30 } | |
31 | |
32 GList *sockets = NULL; | |
33 struct gaim_sock { | |
34 int socket; | |
35 int type; | |
36 gint inpa; | |
37 }; | |
38 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
39 static void gaim_icq_handler(gpointer data, gint source, GaimInputCondition cond) { |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
40 if (cond & GAIM_INPUT_READ) |
2086 | 41 icq_HandleReadySocket(source, ICQ_SOCKET_READ); |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
42 if (cond & GAIM_INPUT_WRITE) |
2086 | 43 icq_HandleReadySocket(source, ICQ_SOCKET_WRITE); |
44 } | |
45 | |
46 static void icq_sock_notify(int socket, int type, int status) { | |
47 struct gaim_sock *gs = NULL; | |
48 if (status) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
49 GaimInputCondition cond; |
2086 | 50 if (type == ICQ_SOCKET_READ) |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
51 cond = GAIM_INPUT_READ; |
2086 | 52 else |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
53 cond = GAIM_INPUT_WRITE; |
2086 | 54 gs = g_new0(struct gaim_sock, 1); |
55 gs->socket = socket; | |
56 gs->type = type; | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
57 gs->inpa = gaim_input_add(socket, cond, gaim_icq_handler, NULL); |
2086 | 58 sockets = g_list_append(sockets, gs); |
59 debug_printf("Adding socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
60 } else { | |
61 GList *m = sockets; | |
62 while (m) { | |
63 gs = m->data; | |
64 if ((gs->socket == socket) && (gs->type == type)) | |
65 break; | |
66 m = g_list_next(m); | |
67 } | |
68 if (m) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
69 gaim_input_remove(gs->inpa); |
2086 | 70 sockets = g_list_remove(sockets, gs); |
71 debug_printf("Removing socket notifier: %d %d (%d)\n", socket, type, gs->inpa); | |
72 g_free(gs); | |
73 } | |
74 } | |
75 } | |
76 | |
77 static void icq_online(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
78 struct gaim_connection *gc = link->icq_UserData; |
2086 | 79 struct icq_data *id = (struct icq_data *)gc->proto_data; |
80 debug_printf("%s is now online.\n", gc->username); | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
81 if (!id->connected) { |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
82 account_online(gc); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
83 serv_finish_login(gc); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
84 icq_ChangeStatus(id->link, STATUS_ONLINE); |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
85 id->connected = TRUE; |
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
86 } |
2086 | 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 | |
2515
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
93 if (!id->connected) { |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
94 hide_login_progress(gc, "Unable to connect"); |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
95 signoff(gc); |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
96 return; |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
97 } |
3ec36a342496
[gaim-migrate @ 2528]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
98 |
2086 | 99 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { |
100 hide_login_progress(gc, "Unable to connect"); | |
101 signoff(gc); | |
102 return; | |
103 } | |
104 | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
105 icq_Login(link, id->cur_status); |
2086 | 106 } |
107 | |
108 static void icq_msg_incoming(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
109 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
|
110 struct gaim_connection *gc = link->icq_UserData; |
2086 | 111 char buf[256], *tmp = g_malloc(BUF_LONG); |
112 g_snprintf(tmp, BUF_LONG, "%s", data); | |
113 g_snprintf(buf, sizeof buf, "%lu", uin); | |
114 strip_linefeed(tmp); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
115 serv_got_im(gc, buf, tmp, 0, time(NULL), -1); |
2086 | 116 g_free(tmp); |
117 } | |
118 | |
119 static void icq_user_online(icq_Link *link, unsigned long uin, unsigned long st, | |
120 unsigned long ip, unsigned short port, unsigned long real_ip, | |
121 unsigned char tcp_flags) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
122 struct gaim_connection *gc = link->icq_UserData; |
2086 | 123 guint status; |
124 char buf[256]; | |
125 | |
126 g_snprintf(buf, sizeof buf, "%lu", uin); | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
127 status = (st == STATUS_ONLINE) ? 0 : UC_UNAVAILABLE | (st << 1); |
2086 | 128 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
129 } | |
130 | |
131 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
|
132 struct gaim_connection *gc = link->icq_UserData; |
2086 | 133 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); |
134 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); | |
135 } | |
136 | |
137 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
|
138 struct gaim_connection *gc = link->icq_UserData; |
2086 | 139 guint status; |
140 char buf[256]; | |
141 | |
142 g_snprintf(buf, sizeof buf, "%lu", uin); | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
143 status = (st == STATUS_ONLINE) ? 0 : UC_UNAVAILABLE | (st << 1); |
2086 | 144 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
145 } | |
146 | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
147 static gboolean icq_set_timeout_cb(gpointer data) { |
2086 | 148 icq_HandleTimeout(); |
149 ack_timer = 0; | |
150 return FALSE; | |
151 } | |
152 | |
153 static void icq_set_timeout(long interval) { | |
154 debug_printf("icq_SetTimeout: %ld\n", interval); | |
155 if (interval > 0 && ack_timer == 0) | |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
156 ack_timer = g_timeout_add(interval * 1000, icq_set_timeout_cb, NULL); |
2086 | 157 else if (ack_timer > 0) { |
2130
50c7a704ee56
[gaim-migrate @ 2140]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
158 g_source_remove(ack_timer); |
2086 | 159 ack_timer = 0; |
160 } | |
161 } | |
162 | |
163 static void icq_url_incoming(icq_Link *link, unsigned long uin, unsigned char hour, | |
164 unsigned char minute, unsigned char day, unsigned char month, | |
165 unsigned short year, const char *url, const char *descr) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
166 struct gaim_connection *gc = link->icq_UserData; |
2086 | 167 char *msg = g_malloc(BUF_LONG), buf[256]; |
168 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); | |
169 g_snprintf(buf, 256, "%lu", uin); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
170 serv_got_im(gc, buf, msg, 0, time(NULL), -1); |
2086 | 171 g_free(msg); |
172 } | |
173 | |
174 static void icq_wrong_passwd(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
175 struct gaim_connection *gc = link->icq_UserData; |
2086 | 176 hide_login_progress(gc, "Invalid password."); |
177 signoff(gc); | |
178 } | |
179 | |
180 static void icq_invalid_uin(icq_Link *link) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
181 struct gaim_connection *gc = link->icq_UserData; |
2086 | 182 hide_login_progress(gc, "Invalid UIN."); |
183 signoff(gc); | |
184 } | |
185 | |
186 static void icq_info_reply(icq_Link *link, unsigned long uin, const char *nick, | |
187 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
|
188 struct gaim_connection *gc = link->icq_UserData; |
2086 | 189 char buf[16 * 1024]; |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
190 char who[16]; |
2086 | 191 |
2773
a0fd8f91e294
[gaim-migrate @ 2786]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
192 g_snprintf(who, sizeof who, "%lu", uin); |
2086 | 193 g_snprintf(buf, sizeof buf, |
194 "<B>UIN:</B> %lu<BR>" | |
195 "<B>Nick:</B> %s<BR>" | |
196 "<B>Name:</B> %s %s<BR>" | |
197 "<B>Email:</B> %s\n", | |
198 uin, | |
199 nick, | |
200 first, last, | |
201 email); | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
202 g_show_info_text(gc, who, 2, buf, NULL); |
2086 | 203 } |
204 | |
205 static void icq_web_pager(icq_Link *link, unsigned char hour, unsigned char minute, | |
206 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
207 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
208 struct gaim_connection *gc = link->icq_UserData; |
2086 | 209 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email); |
210 char *what = g_malloc(BUF_LONG); | |
211 g_snprintf(what, BUF_LONG, "%s", msg); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
212 serv_got_im(gc, who, what, 0, time(NULL), -1); |
2086 | 213 g_free(who); |
214 g_free(what); | |
215 } | |
216 | |
217 static void icq_mail_express(icq_Link *link, unsigned char hour, unsigned char minute, | |
218 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
219 const char *email, const char *msg) { | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
220 struct gaim_connection *gc = link->icq_UserData; |
2086 | 221 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email); |
222 char *what = g_malloc(BUF_LONG); | |
223 g_snprintf(what, BUF_LONG, "%s", msg); | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
224 serv_got_im(gc, who, what, 0, time(NULL), -1); |
2086 | 225 g_free(who); |
226 g_free(what); | |
227 } | |
228 | |
229 static void icq_req_not(icq_Link *link, unsigned long id, int type, int arg, void *data) { | |
230 if (type == ICQ_NOTIFY_FAILED) | |
3427 | 231 do_error_dialog(_("Gaim encountered an error communicating with the ICQ server."), NULL, GAIM_ERROR); |
2086 | 232 return; |
233 } | |
234 | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
235 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
|
236 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
|
237 const char *first, const char *last, const char *email) |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
238 { |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
239 char uin[16]; |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
240 g_snprintf(uin, sizeof(uin), "%ld", id); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
241 show_got_added(link->icq_UserData, NULL, uin, nick, NULL); |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
242 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
243 |
2086 | 244 struct icq_auth { |
245 icq_Link *link; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
246 char *nick; |
2086 | 247 unsigned long uin; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
248 struct gaim_connection *gc; |
2086 | 249 }; |
250 | |
3730 | 251 static void icq_den_auth(struct icq_auth *iq) |
2086 | 252 { |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
253 g_free(iq->nick); |
2086 | 254 g_free(iq); |
255 } | |
256 | |
3730 | 257 static void icq_add_after_auth(struct icq_auth *iq) |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
258 { |
4249 | 259 if (g_slist_find(connections, iq->gc)) { |
260 char uin[16]; | |
261 g_snprintf(uin, sizeof(uin), "%ld", iq->uin); | |
262 show_add_buddy(iq->gc, uin, NULL, iq->nick); | |
263 } | |
3730 | 264 icq_den_auth(iq); |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
265 } |
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
266 |
3730 | 267 static void icq_acc_auth(struct icq_auth *iq) |
2086 | 268 { |
4249 | 269 if (g_slist_find(connections, iq->gc)) { |
270 char msg[1024]; | |
271 char uin[16]; | |
272 struct icq_auth *iqnew; | |
273 | |
274 icq_SendAuthMsg(iq->link, iq->uin); | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
275 |
4249 | 276 g_snprintf(uin, sizeof(uin), "%ld", iq->uin); |
4687 | 277 if (gaim_find_buddy(iq->gc->account, uin)) |
4249 | 278 return; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
279 |
4249 | 280 iqnew = g_memdup(iq, sizeof(struct icq_auth)); |
281 iqnew->nick = g_strdup(iq->nick); | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
282 |
4249 | 283 g_snprintf(msg, sizeof(msg), "Add %ld to your buddy list?", iq->uin); |
284 do_ask_dialog(msg, NULL, iqnew, _("Add"), icq_add_after_auth, _("Cancel"), icq_den_auth, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); | |
285 } | |
286 | |
3730 | 287 icq_den_auth(iq); |
2086 | 288 } |
289 | |
290 static void icq_auth_req(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
291 unsigned char day, unsigned char month, unsigned short year, const char *nick, | |
292 const char *first, const char *last, const char *email, const char *reason) | |
293 { | |
294 char msg[8192]; | |
295 struct icq_auth *iq = g_new0(struct icq_auth, 1); | |
296 iq->link = link; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
297 iq->nick = g_strdup(nick); |
2086 | 298 iq->uin = uin; |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
299 iq->gc = link->icq_UserData; |
2086 | 300 |
301 g_snprintf(msg, sizeof(msg), "The user %s (%s%s%s%s%s) wants you to authorize them.", | |
302 nick, first ? first : "", first && last ? " " : "", last ? last : "", | |
303 (first || last) && email ? ", " : "", email ? email : ""); | |
4249 | 304 do_ask_dialog(msg, NULL, iq, _("Authorize"), icq_acc_auth, _("Deny"), icq_den_auth, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2086 | 305 } |
306 | |
4491 | 307 static void icq_login(struct gaim_account *account) { |
308 struct gaim_connection *gc = new_gaim_conn(account); | |
2086 | 309 struct icq_data *id = gc->proto_data = g_new0(struct icq_data, 1); |
4634 | 310 struct gaim_proxy_info *gpi = account->gpi; |
2086 | 311 icq_Link *link; |
312 char ps[9]; | |
313 | |
4634 | 314 if(!gpi) |
315 gpi = &global_proxy_info; | |
316 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
317 gc->checkbox = _("Send message through server"); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
318 |
2086 | 319 icq_LogLevel = ICQ_LOG_MESSAGE; |
320 | |
4491 | 321 g_snprintf(ps, sizeof(ps), "%s", account->password); |
322 link = id->link = icq_ICQLINKNew(atol(account->username), ps, | |
323 account->proto_opt[USEROPT_NICK][0] ? account->proto_opt[USEROPT_NICK] : "gaim user", | |
2086 | 324 TRUE); |
4491 | 325 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", account->proto_opt[USEROPT_NICK]); |
2086 | 326 |
327 link->icq_Logged = icq_online; | |
328 link->icq_Disconnected = icq_logged_off; | |
329 link->icq_RecvMessage = icq_msg_incoming; | |
330 link->icq_RecvURL = icq_url_incoming; | |
331 link->icq_RecvWebPager = icq_web_pager; | |
332 link->icq_RecvMailExpress = icq_mail_express; | |
2582
5efa8077107f
[gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2516
diff
changeset
|
333 link->icq_RecvAdded = icq_recv_add; |
2086 | 334 link->icq_RecvAuthReq = icq_auth_req; |
335 link->icq_UserOnline = icq_user_online; | |
336 link->icq_UserOffline = icq_user_offline; | |
337 link->icq_UserStatusUpdate = icq_user_status; | |
338 link->icq_InfoReply = icq_info_reply; | |
339 link->icq_WrongPassword = icq_wrong_passwd; | |
340 link->icq_InvalidUIN = icq_invalid_uin; | |
341 link->icq_Log = icq_do_log; | |
342 link->icq_RequestNotify = icq_req_not; | |
2138
cfa83a1b3d49
[gaim-migrate @ 2148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2137
diff
changeset
|
343 link->icq_UserData = gc; |
2086 | 344 |
4634 | 345 if (gpi->proxytype == PROXY_SOCKS5) |
346 icq_SetProxy(link, gpi->proxyhost, gpi->proxyport, gpi->proxyuser[0], gpi->proxyuser, gpi->proxypass); | |
2086 | 347 |
348 icq_ContactClear(id->link); | |
349 | |
350 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
351 hide_login_progress(gc, "Unable to connect"); | |
352 signoff(gc); | |
353 return; | |
354 } | |
355 | |
2516
d379814be59e
[gaim-migrate @ 2529]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2515
diff
changeset
|
356 id->cur_status = STATUS_ONLINE; |
2086 | 357 icq_Login(link, STATUS_ONLINE); |
358 | |
359 set_login_progress(gc, 0, "Connecting..."); | |
360 } | |
361 | |
362 static void icq_close(struct gaim_connection *gc) { | |
363 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
364 | |
365 icq_Logout(id->link); | |
366 icq_Disconnect(id->link); | |
367 icq_ICQLINKDelete(id->link); | |
368 g_free(id); | |
369 } | |
370 | |
3033 | 371 static int icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int len, int flags) { |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
372 if (!(flags & IM_FLAG_AWAY) && (strlen(msg) > 0)) { |
2086 | 373 struct icq_data *id = (struct icq_data *)gc->proto_data; |
374 long w = atol(who); | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
375 icq_SendMessage(id->link, w, msg, |
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
376 (flags & IM_FLAG_CHECKBOX) ? ICQ_SEND_THRUSERVER : ICQ_SEND_BESTWAY); |
2086 | 377 } |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
378 return 1; |
2086 | 379 } |
380 | |
381 static void icq_keepalive(struct gaim_connection *gc) { | |
382 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
383 icq_KeepAlive(id->link); | |
384 } | |
385 | |
3466 | 386 static void icq_add_buddy(struct gaim_connection *gc, const char *who) { |
2086 | 387 struct icq_data *id = (struct icq_data *)gc->proto_data; |
388 icq_ContactAdd(id->link, atol(who)); | |
389 icq_ContactSetVis(id->link, atol(who), TRUE); | |
390 } | |
391 | |
392 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) { | |
393 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
394 while (whos) { | |
395 icq_ContactAdd(id->link, atol(whos->data)); | |
396 icq_ContactSetVis(id->link, atol(whos->data), TRUE); | |
397 whos = whos->next; | |
398 } | |
399 } | |
400 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
401 static void icq_rem_buddy(struct gaim_connection *gc, char *who, char *group) { |
2086 | 402 struct icq_data *id = (struct icq_data *)gc->proto_data; |
403 icq_ContactRemove(id->link, atol(who)); | |
404 } | |
405 | |
406 static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { | |
407 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
408 | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
409 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
410 g_free(gc->away); |
2086 | 411 gc->away = NULL; |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
412 } |
2086 | 413 |
414 if (!strcmp(state, "Online")) | |
415 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
416 else if (!strcmp(state, "Away")) { | |
417 icq_ChangeStatus(id->link, STATUS_AWAY); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
418 gc->away = g_strdup(""); |
2086 | 419 } else if (!strcmp(state, "Do Not Disturb")) { |
420 icq_ChangeStatus(id->link, STATUS_DND); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
421 gc->away = g_strdup(""); |
2086 | 422 } else if (!strcmp(state, "Not Available")) { |
423 icq_ChangeStatus(id->link, STATUS_NA); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
424 gc->away = g_strdup(""); |
2086 | 425 } else if (!strcmp(state, "Occupied")) { |
426 icq_ChangeStatus(id->link, STATUS_OCCUPIED); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
427 gc->away = g_strdup(""); |
2086 | 428 } else if (!strcmp(state, "Free For Chat")) { |
429 icq_ChangeStatus(id->link, STATUS_FREE_CHAT); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
430 gc->away = g_strdup(""); |
2086 | 431 } else if (!strcmp(state, "Invisible")) { |
432 icq_ChangeStatus(id->link, STATUS_INVISIBLE); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
433 gc->away = g_strdup(""); |
2086 | 434 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
435 if (msg) { | |
436 icq_ChangeStatus(id->link, STATUS_NA); | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
437 gc->away = g_strdup(""); |
2086 | 438 } else { |
439 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
440 } | |
441 } | |
442 } | |
443 | |
4687 | 444 static const char *icq_list_icon(struct gaim_account *a, struct buddy *b) { |
445 return "icq"; | |
446 } | |
447 | |
448 /* guint status; | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
449 if (uc == 0) |
2086 | 450 return icon_online_xpm; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
451 status = uc >> 1; |
2086 | 452 if (status & STATUS_NA) |
453 return icon_na_xpm; | |
454 if (status & STATUS_DND) | |
455 return icon_dnd_xpm; | |
456 if (status & STATUS_OCCUPIED) | |
457 return icon_occ_xpm; | |
458 if (status & STATUS_AWAY) | |
459 return icon_away_xpm; | |
460 if (status & STATUS_FREE_CHAT) | |
461 return icon_ffc_xpm; | |
462 if (status & STATUS_INVISIBLE) | |
463 return NULL; | |
464 return icon_online_xpm; | |
4687 | 465 }*/ |
2086 | 466 |
467 static void icq_get_info(struct gaim_connection *gc, char *who) { | |
468 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
469 icq_SendInfoReq(id->link, atol(who)); | |
470 } | |
471 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
472 static void icq_info(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
473 serv_get_info(gc, who); |
2086 | 474 } |
475 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
476 static GList *icq_buddy_menu(struct gaim_connection *gc, char *who) { |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
477 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
478 struct proto_buddy_menu *pbm; |
2086 | 479 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
480 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
481 pbm->label = _("Get Info"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
482 pbm->callback = icq_info; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
483 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
484 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
485 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
486 return m; |
2086 | 487 } |
488 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2382
diff
changeset
|
489 static GList *icq_away_states(struct gaim_connection *gc) { |
2086 | 490 GList *m = NULL; |
491 | |
492 m = g_list_append(m, "Online"); | |
493 m = g_list_append(m, "Away"); | |
494 m = g_list_append(m, "Do Not Disturb"); | |
495 m = g_list_append(m, "Not Available"); | |
496 m = g_list_append(m, "Occupied"); | |
497 m = g_list_append(m, "Free For Chat"); | |
498 m = g_list_append(m, "Invisible"); | |
499 | |
500 return m; | |
501 } | |
502 | |
503 void icq_init(struct prpl *ret) { | |
3572 | 504 struct proto_user_opt *puo; |
2086 | 505 ret->protocol = PROTO_ICQ; |
3572 | 506 ret->name = g_strdup("ICQ"); |
2086 | 507 ret->list_icon = icq_list_icon; |
508 ret->away_states = icq_away_states; | |
509 ret->buddy_menu = icq_buddy_menu; | |
510 ret->login = icq_login; | |
511 ret->close = icq_close; | |
512 ret->send_im = icq_send_msg; | |
513 ret->add_buddy = icq_add_buddy; | |
514 ret->add_buddies = icq_add_buddies; | |
515 ret->remove_buddy = icq_rem_buddy; | |
516 ret->get_info = icq_get_info; | |
517 ret->set_away = icq_set_away; | |
518 ret->keepalive = icq_keepalive; | |
519 | |
3572 | 520 puo = g_new0(struct proto_user_opt, 1); |
4115 | 521 puo->label = g_strdup(_("Nick:")); |
522 puo->def = g_strdup(_("Gaim User")); | |
3572 | 523 puo->pos = USEROPT_NICK; |
524 ret->user_opts = g_list_append(ret->user_opts, puo); | |
525 | |
2086 | 526 my_protocol = ret; |
527 | |
528 icq_SocketNotify = icq_sock_notify; | |
529 icq_SetTimeout = icq_set_timeout; | |
530 } | |
531 | |
532 #ifndef STATIC | |
533 | |
3867 | 534 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 535 { |
3572 | 536 icq_init(prpl); |
537 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 538 } |
539 #endif |