Mercurial > pidgin.yaz
annotate plugins/icq/gaim_icq.c @ 1783:950a3e2be27d
[gaim-migrate @ 1793]
Who knows if it'll be called this or not. Might as well go ahead
and change the version numbers anyway.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Mon, 30 Apr 2001 18:52:47 +0000 |
parents | 896432d66303 |
children | a02584b98823 |
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); | |
1772
896432d66303
[gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1766
diff
changeset
|
102 /*gc->options |= OPT_USR_KEEPALV; this is always-on now */ |
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); |
1766
a247305b835f
[gaim-migrate @ 1776]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
128 serv_got_im(gc, buf, tmp, 0, time((time_t)NULL)); |
1152 | 129 g_free(tmp); |
130 } | |
131 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
132 static void icq_user_online(ICQLINK *link, unsigned long uin, unsigned long st, |
1152 | 133 unsigned long ip, unsigned short port, unsigned long real_ip, |
134 unsigned char tcp_flags) { | |
135 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
|
136 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
137 char buf[256]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
138 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
139 g_snprintf(buf, sizeof buf, "%lu", uin); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
140 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); |
1496
d33bf6548543
[gaim-migrate @ 1506]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1493
diff
changeset
|
141 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
1152 | 142 } |
143 | |
144 static void icq_user_offline(ICQLINK *link, unsigned long uin) { | |
145 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
146 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); | |
147 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); | |
148 } | |
149 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
150 static void icq_user_status(ICQLINK *link, unsigned long uin, unsigned long st) { |
1152 | 151 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
|
152 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
153 char buf[256]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
154 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
155 g_snprintf(buf, sizeof buf, "%lu", uin); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
156 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
157 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); |
1152 | 158 } |
159 | |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
160 static gint icq_set_timeout_cb() { |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
161 icq_HandleTimeout(); |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
162 ack_timer = 0; |
1152 | 163 return FALSE; |
164 } | |
165 | |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
166 static void icq_set_timeout(long interval) { |
1152 | 167 debug_printf("icq_SetTimeout: %ld\n", interval); |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
168 if (interval > 0 && ack_timer == 0) |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
169 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
|
170 else if (ack_timer > 0) { |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
171 gtk_timeout_remove(ack_timer); |
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
172 ack_timer = 0; |
1152 | 173 } |
174 } | |
175 | |
176 static void icq_url_incoming(struct icq_link *link, unsigned long uin, unsigned char hour, | |
177 unsigned char minute, unsigned char day, unsigned char month, | |
178 unsigned short year, const char *url, const char *descr) { | |
179 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
|
180 char *msg = g_malloc(BUF_LONG), buf[256]; |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
181 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); |
1152 | 182 g_snprintf(buf, 256, "%lu", uin); |
1766
a247305b835f
[gaim-migrate @ 1776]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
183 serv_got_im(gc, buf, msg, 0, time((time_t)NULL)); |
1152 | 184 g_free(msg); |
185 } | |
186 | |
187 static void icq_wrong_passwd(struct icq_link *link) { | |
188 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
189 hide_login_progress(gc, "Invalid password."); | |
190 signoff(gc); | |
191 } | |
192 | |
193 static void icq_invalid_uin(struct icq_link *link) { | |
194 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); | |
195 hide_login_progress(gc, "Invalid UIN."); | |
196 signoff(gc); | |
197 } | |
198 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
199 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
|
200 const char *first, const char *last, const char *email, char auth) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
201 char buf[16 * 1024]; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
202 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
203 g_snprintf(buf, sizeof buf, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
204 "<B>UIN:</B> %lu<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
205 "<B>Nick:</B> %s<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
206 "<B>Name:</B> %s %s<BR>" |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
207 "<B>Email:</B> %s\n", |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
208 uin, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
209 nick, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
210 first, last, |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
211 email); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
212 g_show_info_text(buf); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
213 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
214 |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
215 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
|
216 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
|
217 const char *email, const char *msg) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
218 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
219 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
|
220 char *what = g_malloc(BUF_LONG); |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
221 g_snprintf(what, BUF_LONG, "%s", msg); |
1766
a247305b835f
[gaim-migrate @ 1776]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
222 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
|
223 g_free(who); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
224 g_free(what); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
225 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
226 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
227 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
|
228 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
|
229 const char *email, const char *msg) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
230 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
231 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
|
232 char *what = g_malloc(BUF_LONG); |
7bb7eca3fa14
[gaim-migrate @ 1497]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
233 g_snprintf(what, BUF_LONG, "%s", msg); |
1766
a247305b835f
[gaim-migrate @ 1776]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1765
diff
changeset
|
234 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
|
235 g_free(who); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
236 g_free(what); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
237 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
238 |
1698
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
239 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
|
240 if (type == ICQ_NOTIFY_FAILED) |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
241 do_error_dialog("Failure in sending packet", "ICQ error"); |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
242 return; |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
243 } |
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
244 |
1152 | 245 static void icq_login(struct aim_user *user) { |
246 struct gaim_connection *gc = new_gaim_conn(user); | |
247 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
|
248 ICQLINK *link; |
1543
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
249 char ps[9]; |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
250 |
1152 | 251 icq_LogLevel = ICQ_LOG_MESSAGE; |
252 | |
1543
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
253 g_snprintf(ps, sizeof(ps), "%s", user->password); |
352f05feb0d1
[gaim-migrate @ 1553]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1531
diff
changeset
|
254 link = id->link = icq_ICQLINKNew(atol(user->username), ps, |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
255 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
|
256 TRUE); |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
257 |
1152 | 258 link->icq_Logged = icq_online; |
259 link->icq_Disconnected = icq_logged_off; | |
260 link->icq_RecvMessage = icq_msg_incoming; | |
261 link->icq_RecvURL = icq_url_incoming; | |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
262 link->icq_RecvWebPager = icq_web_pager; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
263 link->icq_RecvMailExpress = icq_mail_express; |
1152 | 264 link->icq_UserOnline = icq_user_online; |
265 link->icq_UserOffline = icq_user_offline; | |
266 link->icq_UserStatusUpdate = icq_user_status; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
267 link->icq_InfoReply = icq_info_reply; |
1152 | 268 link->icq_WrongPassword = icq_wrong_passwd; |
269 link->icq_InvalidUIN = icq_invalid_uin; | |
270 link->icq_Log = icq_do_log; | |
1698
4c3bcc579e71
[gaim-migrate @ 1708]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1543
diff
changeset
|
271 link->icq_RequestNotify = icq_req_not; |
1152 | 272 |
1493
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
273 icq_ContactClear(id->link); |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
274 if (bud_list_cache_exists(gc)) |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
275 do_import(NULL, gc); |
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
276 |
1152 | 277 icq_UnsetProxy(link); |
278 | |
279 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { | |
280 hide_login_progress(gc, "Unable to connect"); | |
281 signoff(gc); | |
282 return; | |
283 } | |
284 | |
285 icq_Login(link, STATUS_ONLINE); | |
286 id->cur_status = STATUS_ONLINE; | |
287 | |
288 set_login_progress(gc, 0, "Connecting..."); | |
289 } | |
290 | |
291 static void icq_close(struct gaim_connection *gc) { | |
292 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
293 | |
294 icq_Logout(id->link); | |
295 icq_Disconnect(id->link); | |
1309
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1232
diff
changeset
|
296 icq_ICQLINKDelete(id->link); |
0a766047b4fd
[gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1232
diff
changeset
|
297 g_free(id); |
1152 | 298 } |
299 | |
300 static struct prpl *my_protocol = NULL; | |
301 | |
302 static void icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) { | |
303 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
304 if (!away && (strlen(msg) > 0)) |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
305 icq_SendMessage(id->link, atol(who), msg, ICQ_SEND_BESTWAY); |
1152 | 306 } |
307 | |
308 static void icq_keepalive(struct gaim_connection *gc) { | |
309 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
310 icq_KeepAlive(id->link); | |
311 } | |
312 | |
313 static void icq_add_buddy(struct gaim_connection *gc, char *who) { | |
314 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
315 icq_ContactAdd(id->link, atol(who)); | |
316 icq_ContactSetVis(id->link, atol(who), TRUE); | |
317 } | |
318 | |
319 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) { | |
320 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
321 while (whos) { | |
322 icq_ContactAdd(id->link, atol(whos->data)); | |
323 icq_ContactSetVis(id->link, atol(whos->data), TRUE); | |
324 whos = whos->next; | |
325 } | |
326 } | |
327 | |
328 static void icq_rem_buddy(struct gaim_connection *gc, char *who) { | |
329 struct icq_data *id = (struct icq_data *)gc->proto_data; | |
330 icq_ContactRemove(id->link, atol(who)); | |
331 } | |
332 | |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
333 static void icq_set_away(struct gaim_connection *gc, char *state, char *msg) { |
1152 | 334 struct icq_data *id = (struct icq_data *)gc->proto_data; |
335 | |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
336 if (gc->away) |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
337 gc->away = NULL; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
338 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
339 if (!strcmp(state, "Online")) |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
340 icq_ChangeStatus(id->link, STATUS_ONLINE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
341 else if (!strcmp(state, "Away")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
342 icq_ChangeStatus(id->link, STATUS_AWAY); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
343 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
344 } else if (!strcmp(state, "Do Not Disturb")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
345 icq_ChangeStatus(id->link, STATUS_DND); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
346 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
347 } else if (!strcmp(state, "Not Available")) { |
1152 | 348 icq_ChangeStatus(id->link, STATUS_NA); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
349 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
350 } else if (!strcmp(state, "Occupied")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
351 icq_ChangeStatus(id->link, STATUS_OCCUPIED); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
352 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
353 } else if (!strcmp(state, "Free For Chat")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
354 icq_ChangeStatus(id->link, STATUS_FREE_CHAT); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
355 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
356 } else if (!strcmp(state, "Invisible")) { |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
357 icq_ChangeStatus(id->link, STATUS_INVISIBLE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
358 gc->away = ""; |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
359 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) { |
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
360 if (msg) { |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
361 icq_ChangeStatus(id->link, STATUS_NA); |
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 { |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
364 icq_ChangeStatus(id->link, STATUS_ONLINE); |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1402
diff
changeset
|
365 } |
1402
65f4a0325022
[gaim-migrate @ 1412]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1401
diff
changeset
|
366 } |
1152 | 367 } |
368 | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
369 static char **icq_list_icon(int uc) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
370 guint status; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
371 if (uc == UC_NORMAL) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
372 return icon_online_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
373 status = uc >> 5; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
374 if (status & STATUS_NA) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
375 return icon_na_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
376 if (status & STATUS_DND) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
377 return icon_dnd_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
378 if (status & STATUS_OCCUPIED) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
379 return icon_occ_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
380 if (status & STATUS_AWAY) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
381 return icon_away_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
382 if (status & STATUS_FREE_CHAT) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
383 return icon_ffc_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
384 if (status & STATUS_INVISIBLE) |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
385 return NULL; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
386 return icon_online_xpm; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
387 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
388 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
389 static void icq_get_info(struct gaim_connection *gc, char *who) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
390 struct icq_data *id = (struct icq_data *)gc->proto_data; |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
391 icq_SendInfoReq(id->link, atol(who)); |
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 |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
394 static void icq_info(GtkObject *obj, char *who) { |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
395 serv_get_info(gtk_object_get_user_data(obj), 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 |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
398 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
|
399 GtkWidget *button; |
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 button = gtk_menu_item_new_with_label(_("Get Info")); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
402 gtk_signal_connect(GTK_OBJECT(button), "activate", |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
403 GTK_SIGNAL_FUNC(icq_info), who); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
404 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
405 gtk_menu_append(GTK_MENU(menu), button); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
406 gtk_widget_show(button); |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
407 } |
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
408 |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
409 static void icq_print_option(GtkEntry *entry, struct aim_user *user) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
410 int entrynum; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
411 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
412 entrynum = (int) gtk_object_get_user_data(GTK_OBJECT(entry)); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
413 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
414 if (entrynum == USEROPT_NICK) |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
415 g_snprintf(user->proto_opt[USEROPT_NICK], |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
416 sizeof(user->proto_opt[USEROPT_NICK]), |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
417 "%s", gtk_entry_get_text(entry)); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
418 } |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
419 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
420 static void icq_user_opts(GtkWidget *book, struct aim_user *user) { |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
421 GtkWidget *vbox; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
422 GtkWidget *hbox; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
423 GtkWidget *label; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
424 GtkWidget *entry; |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
425 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
426 vbox = gtk_vbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
427 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
428 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
429 gtk_label_new("ICQ Options")); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
430 gtk_widget_show(vbox); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
431 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
432 hbox = gtk_hbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
433 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
434 gtk_widget_show(hbox); |
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 label = gtk_label_new("Nick"); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
437 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
438 gtk_widget_show(label); |
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 entry = gtk_entry_new(); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
441 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
442 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)USEROPT_NICK); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
443 gtk_signal_connect(GTK_OBJECT(entry), "changed", |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
444 GTK_SIGNAL_FUNC(icq_print_option), user); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
445 if (user->proto_opt[USEROPT_NICK][0]) |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
446 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
|
447 else |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
448 gtk_entry_set_text(GTK_ENTRY(entry), "gaim user"); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
449 gtk_widget_show(entry); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
450 |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
451 hbox = gtk_hbox_new(FALSE, 5); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
452 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
453 gtk_widget_show(hbox); |
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 |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
456 static GList *icq_away_states() { |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
457 GList *m = NULL; |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
458 |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
459 m = g_list_append(m, "Online"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
460 m = g_list_append(m, "Away"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
461 m = g_list_append(m, "Do Not Disturb"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
462 m = g_list_append(m, "Not Available"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
463 m = g_list_append(m, "Occupied"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
464 m = g_list_append(m, "Free For Chat"); |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
465 m = g_list_append(m, "Invisible"); |
1432
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
466 |
4c510ca3563f
[gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
467 return m; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
468 } |
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
469 |
1152 | 470 static void icq_init(struct prpl *ret) { |
471 ret->protocol = PROTO_ICQ; | |
472 ret->name = icq_name; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
473 ret->list_icon = icq_list_icon; |
1401
bf041349b11e
[gaim-migrate @ 1411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1374
diff
changeset
|
474 ret->away_states = icq_away_states; |
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1498
diff
changeset
|
475 ret->buddy_menu = icq_buddy_menu; |
1336
f3303fc05572
[gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1335
diff
changeset
|
476 ret->user_opts = icq_user_opts; |
1152 | 477 ret->login = icq_login; |
478 ret->close = icq_close; | |
479 ret->send_im = icq_send_msg; | |
480 ret->add_buddy = icq_add_buddy; | |
481 ret->add_buddies = icq_add_buddies; | |
482 ret->remove_buddy = icq_rem_buddy; | |
1220
16ea7a3fdbb6
[gaim-migrate @ 1230]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1167
diff
changeset
|
483 ret->get_info = icq_get_info; |
1152 | 484 ret->set_away = icq_set_away; |
485 ret->keepalive = icq_keepalive; | |
486 | |
487 my_protocol = ret; | |
488 } | |
489 | |
490 char *gaim_plugin_init(GModule *handle) { | |
1493
e12fa57b9ef9
[gaim-migrate @ 1503]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1487
diff
changeset
|
491 icq_SocketNotify = icq_sock_notify; |
1498
0ef6603d986e
[gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1496
diff
changeset
|
492 icq_SetTimeout = icq_set_timeout; |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1433
diff
changeset
|
493 load_protocol(icq_init, sizeof(struct prpl)); |
1152 | 494 return NULL; |
495 } | |
496 | |
497 void gaim_plugin_remove() { | |
498 struct prpl *p = find_prpl(PROTO_ICQ); | |
499 if (p == my_protocol) | |
500 unload_protocol(p); | |
501 } | |
502 | |
503 char *name() { | |
504 return "ICQ"; | |
505 } | |
506 | |
507 char *description() { | |
508 return "Allows gaim to use the ICQ protocol"; | |
509 } |