Mercurial > pidgin.yaz
annotate plugins/icq/gaim_icq.c @ 1764:1e0613d9526b
[gaim-migrate @ 1774]
I decided to do the time stamp w/ messages thing that Eric put in the TODO list.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 27 Apr 2001 23:26:19 +0000 |
parents | 4c3bcc579e71 |
children | 2aab66c7a007 |
rev | line source |
---|---|
1152 | 1 #include <gtk/gtk.h> |
1167
5d1ded9f88b7
[gaim-migrate @ 1177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1153
diff
changeset
|
2 #include <string.h> |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
3 #include <stdlib.h> |
1152 | 4 #include "icq.h" /* well, we're doing ICQ, right? */ |
5 #include "multi.h" /* needed for gaim_connection */ | |
6 #include "prpl.h" /* needed for prpl */ | |
7 #include "gaim.h" /* needed for every other damn thing */ | |
8 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
9 #include "pixmaps/gnomeicu-online.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
10 #include "pixmaps/gnomeicu-away.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
11 #include "pixmaps/gnomeicu-dnd.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
12 #include "pixmaps/gnomeicu-na.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
13 #include "pixmaps/gnomeicu-occ.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
14 #include "pixmaps/gnomeicu-ffc.xpm" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
15 |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
16 #define USEROPT_NICK 0 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
17 |
1152 | 18 struct icq_data { |
19 ICQLINK *link; | |
20 int cur_status; | |
21 }; | |
22 | |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
23 static guint ack_timer = 0; |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
24 |
1152 | 25 static struct gaim_connection *find_gaim_conn_by_icq_link(ICQLINK *link) { |
26 GSList *c = connections; | |
27 struct gaim_connection *gc = NULL; | |
28 struct icq_data *id; | |
29 | |
30 while (c) { | |
31 gc = (struct gaim_connection *)c->data; | |
32 if (gc->protocol == PROTO_ICQ) { | |
33 id = (struct icq_data *)gc->proto_data; | |
34 if (id->link == link) | |
35 break; | |
36 } | |
37 gc = NULL; | |
38 c = c->next; | |
39 } | |
40 | |
41 return gc; | |
42 } | |
43 | |
44 static char *icq_name() { | |
45 return "ICQ"; | |
46 } | |
47 | |
48 static void icq_do_log(ICQLINK *link, time_t time, unsigned char level, const char *log) { | |
49 debug_printf("ICQ debug %d: %s", level, log); | |
50 } | |
51 | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
52 GList *sockets = NULL; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
53 struct gaim_sock { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
54 int socket; |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
55 int type; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
56 gint inpa; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
57 }; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
58 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
59 static void gaim_icq_handler(gpointer data, gint source, GdkInputCondition cond) { |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
60 if (cond & GDK_INPUT_READ) |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
61 icq_HandleReadySocket(source, ICQ_SOCKET_READ); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
62 if (cond & GDK_INPUT_WRITE) |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
63 icq_HandleReadySocket(source, ICQ_SOCKET_WRITE); |
1152 | 64 } |
65 | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
66 static void icq_sock_notify(int socket, int type, int status) { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
67 struct gaim_sock *gs; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
68 if (status) { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
69 GdkInputCondition cond; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
70 if (type == ICQ_SOCKET_READ) |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
71 cond = GDK_INPUT_READ; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
72 else |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
73 cond = GDK_INPUT_WRITE; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
74 gs = g_new0(struct gaim_sock, 1); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
75 gs->socket = socket; |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
76 gs->type = type; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
77 gs->inpa = gdk_input_add(socket, cond, gaim_icq_handler, NULL); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
78 sockets = g_list_append(sockets, gs); |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
79 debug_printf("Adding socket notifier: %d %d (%d)\n", socket, type, gs->inpa); |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
80 } else { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
81 GList *m = sockets; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
82 while (m) { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
83 gs = m->data; |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
84 if ((gs->socket == socket) && (gs->type == type)) |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
85 break; |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
86 m = g_list_next(m); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
87 } |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
88 if (m) { |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
89 gdk_input_remove(gs->inpa); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
90 sockets = g_list_remove(sockets, gs); |
1531
e06dcc3025a9
[gaim-migrate @ 1541]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
91 debug_printf("Removing socket notifier: %d %d (%d)\n", socket, type, gs->inpa); |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
92 g_free(gs); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
93 } |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
94 } |
1152 | 95 } |
96 | |
97 static void icq_online(ICQLINK *link) { | |
98 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
99 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
100 debug_printf("%s is now online.\n", gc->username); | |
101 account_online(gc); | |
1153
3063e6743913
[gaim-migrate @ 1163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1152
diff
changeset
|
102 gc->options |= OPT_USR_KEEPALV; |
1152 | 103 serv_finish_login(gc); |
104 | |
105 icq_ChangeStatus(id->link, STATUS_ONLINE); | |
106 } | |
107 | |
108 static void icq_logged_off(ICQLINK *link) { | |
109 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
110 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
111 | |
112 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
113 hide_login_progress(gc, "Unable to connect"); | |
114 signoff(gc); | |
115 return; | |
116 } | |
117 | |
118 icq_Login(link, STATUS_ONLINE); | |
119 id->cur_status = STATUS_ONLINE; | |
120 } | |
121 | |
122 static void icq_msg_incoming(ICQLINK *link, unsigned long uin, unsigned char hour, unsigned char minute, | |
123 unsigned char day, unsigned char month, unsigned short year, const char *data) { | |
124 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
1487
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
125 char buf[256], *tmp = g_malloc(BUF_LONG); |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
126 g_snprintf(tmp, BUF_LONG, "%s", data); |
1152 | 127 g_snprintf(buf, sizeof buf, "%lu", uin); |
1764 | 128 /* FIXME EWIC */ |
129 serv_got_im(gc, buf, tmp, 0, time((time_t)NULL)); | |
1152 | 130 g_free(tmp); |
131 } | |
132 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
133 static void icq_user_online(ICQLINK *link, unsigned long uin, unsigned long st, |
1152 | 134 unsigned long ip, unsigned short port, unsigned long real_ip, |
135 unsigned char tcp_flags) { | |
136 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
137 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
138 char buf[256]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
139 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
140 g_snprintf(buf, sizeof buf, "%lu", uin); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
141 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); |
1496
d33bf6548543
[gaim-migrate @ 1506]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1493
diff
changeset
|
142 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
1152 | 143 } |
144 | |
145 static void icq_user_offline(ICQLINK *link, unsigned long uin) { | |
146 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
147 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); | |
148 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); | |
149 } | |
150 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
151 static void icq_user_status(ICQLINK *link, unsigned long uin, unsigned long st) { |
1152 | 152 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
153 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
154 char buf[256]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
155 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
156 g_snprintf(buf, sizeof buf, "%lu", uin); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
157 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
158 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
1152 | 159 } |
160 | |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
161 static gint icq_set_timeout_cb() { |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
162 icq_HandleTimeout(); |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
163 ack_timer = 0; |
1152 | 164 return FALSE; |
165 } | |
166 | |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
167 static void icq_set_timeout(long interval) { |
1152 | 168 debug_printf("icq_SetTimeout: %ld\n", interval); |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
169 if (interval > 0 && ack_timer == 0) |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
170 ack_timer = gtk_timeout_add(interval * 1000, (GtkFunction)icq_set_timeout_cb, NULL); |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
171 else if (ack_timer > 0) { |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
172 gtk_timeout_remove(ack_timer); |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
173 ack_timer = 0; |
1152 | 174 } |
175 } | |
176 | |
177 static void icq_url_incoming(struct icq_link *link, unsigned long uin, unsigned char hour, | |
178 unsigned char minute, unsigned char day, unsigned char month, | |
179 unsigned short year, const char *url, const char *descr) { | |
180 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
1487
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
181 char *msg = g_malloc(BUF_LONG), buf[256]; |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
182 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); |
1152 | 183 g_snprintf(buf, 256, "%lu", uin); |
1764 | 184 /* FIXME EWIC */ |
185 serv_got_im(gc, buf, msg, 0, time((time_t)NULL)); | |
1152 | 186 g_free(msg); |
187 } | |
188 | |
189 static void icq_wrong_passwd(struct icq_link *link) { | |
190 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
191 hide_login_progress(gc, "Invalid password."); | |
192 signoff(gc); | |
193 } | |
194 | |
195 static void icq_invalid_uin(struct icq_link *link) { | |
196 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
197 hide_login_progress(gc, "Invalid UIN."); | |
198 signoff(gc); | |
199 } | |
200 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
201 static void icq_info_reply(struct icq_link *link, unsigned long uin, const char *nick, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
202 const char *first, const char *last, const char *email, char auth) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
203 char buf[16 * 1024]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
204 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
205 g_snprintf(buf, sizeof buf, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
206 "<B>UIN:</B> %lu<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
207 "<B>Nick:</B> %s<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
208 "<B>Name:</B> %s %s<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
209 "<B>Email:</B> %s\n", |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
210 uin, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
211 nick, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
212 first, last, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
213 email); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
214 g_show_info_text(buf); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
215 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
216 |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
217 static void icq_web_pager(struct icq_link *link, unsigned char hour, unsigned char minute, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
218 unsigned char day, unsigned char month, unsigned short year, const char *nick, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
219 const char *email, const char *msg) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
220 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
221 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email); |
1487
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
222 char *what = g_malloc(BUF_LONG); |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
223 g_snprintf(what, BUF_LONG, "%s", msg); |
1764 | 224 /* FIXME EWIC */ |
225 serv_got_im(gc, who, what, 0, time((time_t)NULL)); | |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
226 g_free(who); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
227 g_free(what); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
228 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
229 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
230 static void icq_mail_express(struct icq_link *link, unsigned char hour, unsigned char minute, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
231 unsigned char day, unsigned char month, unsigned short year, const char *nick, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
232 const char *email, const char *msg) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
233 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
234 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email); |
1487
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
235 char *what = g_malloc(BUF_LONG); |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
236 g_snprintf(what, BUF_LONG, "%s", msg); |
1764 | 237 /* FIXME EWIC */ |
238 serv_got_im(gc, who, what, 0, time((time_t)NULL)); | |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
239 g_free(who); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
240 g_free(what); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
241 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
242 |
1698
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
243 static void icq_req_not(struct icq_link *link, unsigned long id, int type, int arg, void *data) { |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
244 if (type == ICQ_NOTIFY_FAILED) |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
245 do_error_dialog("Failure in sending packet", "ICQ error"); |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
246 return; |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
247 } |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
248 |
1152 | 249 static void icq_login(struct aim_user *user) { |
250 struct gaim_connection *gc = new_gaim_conn(user); | |
251 struct icq_data *id = gc->proto_data = g_new0(struct icq_data, 1); | |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
252 ICQLINK *link; |
1543
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
253 char ps[9]; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
254 |
1152 | 255 icq_LogLevel = ICQ_LOG_MESSAGE; |
256 | |
1543
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
257 g_snprintf(ps, sizeof(ps), "%s", user->password); |
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
258 link = id->link = icq_ICQLINKNew(atol(user->username), ps, |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
259 user->proto_opt[USEROPT_NICK][0] ? user->proto_opt[USEROPT_NICK] : "gaim user", |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
260 TRUE); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
261 |
1152 | 262 link->icq_Logged = icq_online; |
263 link->icq_Disconnected = icq_logged_off; | |
264 link->icq_RecvMessage = icq_msg_incoming; | |
265 link->icq_RecvURL = icq_url_incoming; | |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
266 link->icq_RecvWebPager = icq_web_pager; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
267 link->icq_RecvMailExpress = icq_mail_express; |
1152 | 268 link->icq_UserOnline = icq_user_online; |
269 link->icq_UserOffline = icq_user_offline; | |
270 link->icq_UserStatusUpdate = icq_user_status; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
271 link->icq_InfoReply = icq_info_reply; |
1152 | 272 link->icq_WrongPassword = icq_wrong_passwd; |
273 link->icq_InvalidUIN = icq_invalid_uin; | |
274 link->icq_Log = icq_do_log; | |
1698
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
275 link->icq_RequestNotify = icq_req_not; |
1152 | 276 |
1493
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
277 icq_ContactClear(id->link); |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
278 if (bud_list_cache_exists(gc)) |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
279 do_import(NULL, gc); |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
280 |
1152 | 281 icq_UnsetProxy(link); |
282 | |
283 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
284 hide_login_progress(gc, "Unable to connect"); | |
285 signoff(gc); | |
286 return; | |
287 } | |
288 | |
289 icq_Login(link, STATUS_ONLINE); | |
290 id->cur_status = STATUS_ONLINE; | |
291 | |
292 set_login_progress(gc, 0, "Connecting..."); | |
293 } | |
294 | |
295 static void icq_close(struct gaim_connection *gc) { | |
296 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
297 | |
298 icq_Logout(id->link); | |
299 icq_Disconnect(id->link); | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1232
diff
changeset
|
300 icq_ICQLINKDelete(id->link); |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1232
diff
changeset
|
301 g_free(id); |
1152 | 302 } |
303 | |
304 static struct prpl *my_protocol = NULL; | |
305 | |
306 static void icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) { | |
307 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
308 if (!away && (strlen(msg) > 0)) |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
309 icq_SendMessage(id->link, atol(who), msg, ICQ_SEND_BESTWAY); |
1152 | 310 } |
311 | |
312 static void icq_keepalive(struct gaim_connection *gc) { | |
313 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
314 icq_KeepAlive(id->link); | |
315 } | |
316 | |
317 static void icq_add_buddy(struct gaim_connection *gc, char *who) { | |
318 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
319 icq_ContactAdd(id->link, atol(who)); | |
320 icq_ContactSetVis(id->link, atol(who), TRUE); | |
321 } | |
322 | |
323 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) { | |
324 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
325 while (whos) { | |
326 icq_ContactAdd(id->link, atol(whos->data)); | |
327 icq_ContactSetVis(id->link, atol(whos->data), TRUE); | |
328 whos = whos->next; | |
329 } | |
330 } | |
331 | |
332 static void icq_rem_buddy(struct gaim_connection *gc, char *who) { | |
333 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
334 icq_ContactRemove(id->link, atol(who)); | |
335 } | |
336 | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
337 static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { |
1152 | 338 struct icq_data *id = (struct icq_data *)gc->proto_data; |
339 | |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
340 if (gc->away) |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
341 gc->away = NULL; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
342 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
343 if (!strcmp(state, "Online")) |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
344 icq_ChangeStatus(id->link, STATUS_ONLINE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
345 else if (!strcmp(state, "Away")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
346 icq_ChangeStatus(id->link, STATUS_AWAY); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
347 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
348 } else if (!strcmp(state, "Do Not Disturb")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
349 icq_ChangeStatus(id->link, STATUS_DND); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
350 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
351 } else if (!strcmp(state, "Not Available")) { |
1152 | 352 icq_ChangeStatus(id->link, STATUS_NA); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
353 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
354 } else if (!strcmp(state, "Occupied")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
355 icq_ChangeStatus(id->link, STATUS_OCCUPIED); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
356 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
357 } else if (!strcmp(state, "Free For Chat")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
358 icq_ChangeStatus(id->link, STATUS_FREE_CHAT); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
359 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
360 } else if (!strcmp(state, "Invisible")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
361 icq_ChangeStatus(id->link, STATUS_INVISIBLE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
362 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
363 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
364 if (msg) { |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
365 icq_ChangeStatus(id->link, STATUS_NA); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
366 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
367 } else { |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
368 icq_ChangeStatus(id->link, STATUS_ONLINE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
369 } |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
370 } |
1152 | 371 } |
372 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
373 static char **icq_list_icon(int uc) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
374 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
375 if (uc == UC_NORMAL) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
376 return icon_online_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
377 status = uc >> 5; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
378 if (status & STATUS_NA) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
379 return icon_na_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
380 if (status & STATUS_DND) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
381 return icon_dnd_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
382 if (status & STATUS_OCCUPIED) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
383 return icon_occ_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
384 if (status & STATUS_AWAY) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
385 return icon_away_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
386 if (status & STATUS_FREE_CHAT) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
387 return icon_ffc_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
388 if (status & STATUS_INVISIBLE) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
389 return NULL; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
390 return icon_online_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
391 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
392 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
393 static void icq_get_info(struct gaim_connection *gc, char *who) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
394 struct icq_data *id = (struct icq_data *)gc->proto_data; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
395 icq_SendInfoReq(id->link, atol(who)); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
396 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
397 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
398 static void icq_info(GtkObject *obj, char *who) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
399 serv_get_info(gtk_object_get_user_data(obj), who); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
400 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
401 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
402 static void icq_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) { |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
403 GtkWidget *button; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
404 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
405 button = gtk_menu_item_new_with_label(_("Get Info")); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
406 gtk_signal_connect(GTK_OBJECT(button), "activate", |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
407 GTK_SIGNAL_FUNC(icq_info), who); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
408 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
409 gtk_menu_append(GTK_MENU(menu), button); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
410 gtk_widget_show(button); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
411 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
412 |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
413 static void icq_print_option(GtkEntry *entry, struct aim_user *user) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
414 int entrynum; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
415 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
416 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
417 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
418 if (entrynum == USEROPT_NICK) |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
419 g_snprintf(user->proto_opt[USEROPT_NICK], |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
420 sizeof(user->proto_opt[USEROPT_NICK]), |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
421 "%s", gtk_entry_get_text(entry)); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
422 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
423 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
424 static void icq_user_opts(GtkWidget *book, struct aim_user *user) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
425 GtkWidget *vbox; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
426 GtkWidget *hbox; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
427 GtkWidget *label; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
428 GtkWidget *entry; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
429 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
430 vbox = gtk_vbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
431 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
432 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
433 gtk_label_new("ICQ Options")); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
434 gtk_widget_show(vbox); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
435 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
436 hbox = gtk_hbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
437 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
438 gtk_widget_show(hbox); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
439 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
440 label = gtk_label_new("Nick"); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
441 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
442 gtk_widget_show(label); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
443 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
444 entry = gtk_entry_new(); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
445 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
446 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_NICK); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
447 gtk_signal_connect(GTK_OBJECT(entry), "changed", |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
448 GTK_SIGNAL_FUNC(icq_print_option), user); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
449 if (user->proto_opt[USEROPT_NICK][0]) |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
450 gtk_entry_set_text(GTK_ENTRY(entry), user->proto_opt[USEROPT_NICK]); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
451 else |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
452 gtk_entry_set_text(GTK_ENTRY(entry), "gaim user"); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
453 gtk_widget_show(entry); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
454 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
455 hbox = gtk_hbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
456 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
457 gtk_widget_show(hbox); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
458 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
459 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
460 static GList *icq_away_states() { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
461 GList *m = NULL; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
462 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
463 m = g_list_append(m, "Online"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
464 m = g_list_append(m, "Away"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
465 m = g_list_append(m, "Do Not Disturb"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
466 m = g_list_append(m, "Not Available"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
467 m = g_list_append(m, "Occupied"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
468 m = g_list_append(m, "Free For Chat"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
469 m = g_list_append(m, "Invisible"); |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
470 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
471 return m; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
472 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
473 |
1152 | 474 static void icq_init(struct prpl *ret) { |
475 ret->protocol = PROTO_ICQ; | |
476 ret->name = icq_name; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
477 ret->list_icon = icq_list_icon; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
478 ret->away_states = icq_away_states; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
479 ret->buddy_menu = icq_buddy_menu; |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
480 ret->user_opts = icq_user_opts; |
1152 | 481 ret->login = icq_login; |
482 ret->close = icq_close; | |
483 ret->send_im = icq_send_msg; | |
484 ret->add_buddy = icq_add_buddy; | |
485 ret->add_buddies = icq_add_buddies; | |
486 ret->remove_buddy = icq_rem_buddy; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
487 ret->get_info = icq_get_info; |
1152 | 488 ret->set_away = icq_set_away; |
489 ret->keepalive = icq_keepalive; | |
490 | |
491 my_protocol = ret; | |
492 } | |
493 | |
494 char *gaim_plugin_init(GModule *handle) { | |
1493
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
495 icq_SocketNotify = icq_sock_notify; |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
496 icq_SetTimeout = icq_set_timeout; |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1433
diff
changeset
|
497 load_protocol(icq_init, sizeof(struct prpl)); |
1152 | 498 return NULL; |
499 } | |
500 | |
501 void gaim_plugin_remove() { | |
502 struct prpl *p = find_prpl(PROTO_ICQ); | |
503 if (p == my_protocol) | |
504 unload_protocol(p); | |
505 } | |
506 | |
507 char *name() { | |
508 return "ICQ"; | |
509 } | |
510 | |
511 char *description() { | |
512 return "Allows gaim to use the ICQ protocol"; | |
513 } |