annotate plugins/icq/gaim_icq.c @ 1713:14caa7df478c

[gaim-migrate @ 1723] fun stuff committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 13 Apr 2001 23:18:02 +0000
parents 4c3bcc579e71
children 1e0613d9526b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include "icq.h" /* well, we're doing ICQ, right? */
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 #include "multi.h" /* needed for gaim_connection */
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #include "prpl.h" /* needed for prpl */
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 #include "gaim.h" /* needed for every other damn thing */
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 struct icq_data {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 ICQLINK *link;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 int cur_status;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 };
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 static struct gaim_connection *find_gaim_conn_by_icq_link(ICQLINK *link) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 GSList *c = connections;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 struct gaim_connection *gc = NULL;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 struct icq_data *id;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 while (c) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 gc = (struct gaim_connection *)c->data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 if (gc->protocol == PROTO_ICQ) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 if (id->link == link)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 break;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 gc = NULL;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 c = c->next;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 return gc;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 static char *icq_name() {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 return "ICQ";
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 static void icq_do_log(ICQLINK *link, time_t time, unsigned char level, const char *log) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 debug_printf("ICQ debug %d: %s", level, log);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 static void icq_online(ICQLINK *link) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 debug_printf("%s is now online.\n", gc->username);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 serv_finish_login(gc);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 icq_ChangeStatus(id->link, STATUS_ONLINE);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 static void icq_logged_off(ICQLINK *link) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 hide_login_progress(gc, "Unable to connect");
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 signoff(gc);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 return;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 icq_Login(link, STATUS_ONLINE);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 id->cur_status = STATUS_ONLINE;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 static void icq_msg_incoming(ICQLINK *link, unsigned long uin, unsigned char hour, unsigned char minute,
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 unsigned char day, unsigned char month, unsigned short year, const char *data) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 g_snprintf(buf, sizeof buf, "%lu", uin);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 serv_got_im(gc, buf, tmp, 0);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 g_free(tmp);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 unsigned long ip, unsigned short port, unsigned long real_ip,
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 unsigned char tcp_flags) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 static void icq_user_offline(ICQLINK *link, unsigned long uin) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 return FALSE;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
1498
0ef6603d986e [gaim-migrate @ 1508]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1496
diff changeset
166 static void icq_set_timeout(long interval) {
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 static void icq_url_incoming(struct icq_link *link, unsigned long uin, unsigned char hour,
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 unsigned char minute, unsigned char day, unsigned char month,
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 unsigned short year, const char *url, const char *descr) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 g_snprintf(buf, 256, "%lu", uin);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 serv_got_im(gc, buf, msg, 0);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 g_free(msg);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 static void icq_wrong_passwd(struct icq_link *link) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 hide_login_progress(gc, "Invalid password.");
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 signoff(gc);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 static void icq_invalid_uin(struct icq_link *link) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 hide_login_progress(gc, "Invalid UIN.");
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 signoff(gc);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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);
1336
f3303fc05572 [gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1335
diff changeset
222 serv_got_im(gc, who, what, 0);
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);
1336
f3303fc05572 [gaim-migrate @ 1346]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1335
diff changeset
234 serv_got_im(gc, who, what, 0);
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 static void icq_login(struct aim_user *user) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 struct gaim_connection *gc = new_gaim_conn(user);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 icq_LogLevel = ICQ_LOG_MESSAGE;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 link->icq_Logged = icq_online;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 link->icq_Disconnected = icq_logged_off;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 link->icq_RecvMessage = icq_msg_incoming;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 link->icq_UserOnline = icq_user_online;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 link->icq_UserOffline = icq_user_offline;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 link->icq_WrongPassword = icq_wrong_passwd;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 link->icq_InvalidUIN = icq_invalid_uin;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 icq_UnsetProxy(link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 hide_login_progress(gc, "Unable to connect");
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 signoff(gc);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 return;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 icq_Login(link, STATUS_ONLINE);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 id->cur_status = STATUS_ONLINE;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 set_login_progress(gc, 0, "Connecting...");
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 static void icq_close(struct gaim_connection *gc) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 icq_Logout(id->link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 static struct prpl *my_protocol = NULL;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 static void icq_send_msg(struct gaim_connection *gc, char *who, char *msg, int away) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 static void icq_keepalive(struct gaim_connection *gc) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 icq_KeepAlive(id->link);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 static void icq_add_buddy(struct gaim_connection *gc, char *who) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 icq_ContactAdd(id->link, atol(who));
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 icq_ContactSetVis(id->link, atol(who), TRUE);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 static void icq_add_buddies(struct gaim_connection *gc, GList *whos) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 while (whos) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 icq_ContactAdd(id->link, atol(whos->data));
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 icq_ContactSetVis(id->link, atol(whos->data), TRUE);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 whos = whos->next;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 static void icq_rem_buddy(struct gaim_connection *gc, char *who) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 icq_ContactRemove(id->link, atol(who));
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 struct icq_data *id = (struct icq_data *)gc->proto_data;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 static void icq_init(struct prpl *ret) {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 ret->protocol = PROTO_ICQ;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 ret->login = icq_login;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 ret->close = icq_close;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 ret->send_im = icq_send_msg;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 ret->add_buddy = icq_add_buddy;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 ret->add_buddies = icq_add_buddies;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 ret->set_away = icq_set_away;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 ret->keepalive = icq_keepalive;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 my_protocol = ret;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 return NULL;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 void gaim_plugin_remove() {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 struct prpl *p = find_prpl(PROTO_ICQ);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 if (p == my_protocol)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 unload_protocol(p);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 char *name() {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 return "ICQ";
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 char *description() {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508 return "Allows gaim to use the ICQ protocol";
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 }