comparison src/protocols/icq/gaim_icq.c @ 2138:cfa83a1b3d49

[gaim-migrate @ 2148] hopefully fixes any problems we might have with icq. also makes it so we can receive messages from people whose names are longer than 64 characters. this should be arbitrary. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Wed, 08 Aug 2001 20:09:57 +0000
parents 18722ae5b882
children cff133e0ec0c
comparison
equal deleted inserted replaced
2137:18722ae5b882 2138:cfa83a1b3d49
21 int cur_status; 21 int cur_status;
22 GSList *thru_serv; 22 GSList *thru_serv;
23 }; 23 };
24 24
25 static guint ack_timer = 0; 25 static guint ack_timer = 0;
26
27 static struct gaim_connection *find_gaim_conn_by_icq_link(icq_Link *link) {
28 GSList *c = connections;
29 struct gaim_connection *gc = NULL;
30 struct icq_data *id;
31
32 while (c) {
33 gc = (struct gaim_connection *)c->data;
34 if (gc->protocol == PROTO_ICQ) {
35 id = (struct icq_data *)gc->proto_data;
36 if (id->link == link)
37 break;
38 }
39 gc = NULL;
40 c = c->next;
41 }
42
43 return gc;
44 }
45 26
46 static char *icq_name() { 27 static char *icq_name() {
47 return "ICQ"; 28 return "ICQ";
48 } 29 }
49 30
95 } 76 }
96 } 77 }
97 } 78 }
98 79
99 static void icq_online(icq_Link *link) { 80 static void icq_online(icq_Link *link) {
100 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 81 struct gaim_connection *gc = link->icq_UserData;
101 struct icq_data *id = (struct icq_data *)gc->proto_data; 82 struct icq_data *id = (struct icq_data *)gc->proto_data;
102 debug_printf("%s is now online.\n", gc->username); 83 debug_printf("%s is now online.\n", gc->username);
103 account_online(gc); 84 account_online(gc);
104 /*gc->options |= OPT_USR_KEEPALV; this is always-on now */ 85 /*gc->options |= OPT_USR_KEEPALV; this is always-on now */
105 serv_finish_login(gc); 86 serv_finish_login(gc);
106 87
107 icq_ChangeStatus(id->link, STATUS_ONLINE); 88 icq_ChangeStatus(id->link, STATUS_ONLINE);
108 } 89 }
109 90
110 static void icq_logged_off(icq_Link *link) { 91 static void icq_logged_off(icq_Link *link) {
111 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 92 struct gaim_connection *gc = link->icq_UserData;
112 struct icq_data *id = (struct icq_data *)gc->proto_data; 93 struct icq_data *id = (struct icq_data *)gc->proto_data;
113 94
114 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) { 95 if (icq_Connect(link, "icq.mirabilis.com", 4000) < 1) {
115 hide_login_progress(gc, "Unable to connect"); 96 hide_login_progress(gc, "Unable to connect");
116 signoff(gc); 97 signoff(gc);
135 g_free(text2); 116 g_free(text2);
136 } 117 }
137 118
138 static void icq_msg_incoming(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute, 119 static void icq_msg_incoming(icq_Link *link, unsigned long uin, unsigned char hour, unsigned char minute,
139 unsigned char day, unsigned char month, unsigned short year, const char *data) { 120 unsigned char day, unsigned char month, unsigned short year, const char *data) {
140 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 121 struct gaim_connection *gc = link->icq_UserData;
141 char buf[256], *tmp = g_malloc(BUF_LONG); 122 char buf[256], *tmp = g_malloc(BUF_LONG);
142 g_snprintf(tmp, BUF_LONG, "%s", data); 123 g_snprintf(tmp, BUF_LONG, "%s", data);
143 g_snprintf(buf, sizeof buf, "%lu", uin); 124 g_snprintf(buf, sizeof buf, "%lu", uin);
144 strip_linefeed(tmp); 125 strip_linefeed(tmp);
145 serv_got_im(gc, buf, tmp, 0, time((time_t)NULL)); 126 serv_got_im(gc, buf, tmp, 0, time((time_t)NULL));
147 } 128 }
148 129
149 static void icq_user_online(icq_Link *link, unsigned long uin, unsigned long st, 130 static void icq_user_online(icq_Link *link, unsigned long uin, unsigned long st,
150 unsigned long ip, unsigned short port, unsigned long real_ip, 131 unsigned long ip, unsigned short port, unsigned long real_ip,
151 unsigned char tcp_flags) { 132 unsigned char tcp_flags) {
152 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 133 struct gaim_connection *gc = link->icq_UserData;
153 guint status; 134 guint status;
154 char buf[256]; 135 char buf[256];
155 136
156 g_snprintf(buf, sizeof buf, "%lu", uin); 137 g_snprintf(buf, sizeof buf, "%lu", uin);
157 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); 138 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5);
158 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0); 139 serv_got_update(gc, buf, 1, 0, 0, 0, status, 0);
159 } 140 }
160 141
161 static void icq_user_offline(icq_Link *link, unsigned long uin) { 142 static void icq_user_offline(icq_Link *link, unsigned long uin) {
162 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 143 struct gaim_connection *gc = link->icq_UserData;
163 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin); 144 char buf[256]; g_snprintf(buf, sizeof buf, "%lu", uin);
164 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); 145 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0);
165 } 146 }
166 147
167 static void icq_user_status(icq_Link *link, unsigned long uin, unsigned long st) { 148 static void icq_user_status(icq_Link *link, unsigned long uin, unsigned long st) {
168 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 149 struct gaim_connection *gc = link->icq_UserData;
169 guint status; 150 guint status;
170 char buf[256]; 151 char buf[256];
171 152
172 g_snprintf(buf, sizeof buf, "%lu", uin); 153 g_snprintf(buf, sizeof buf, "%lu", uin);
173 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5); 154 status = (st == STATUS_ONLINE) ? UC_NORMAL : UC_UNAVAILABLE | (st << 5);
191 } 172 }
192 173
193 static void icq_url_incoming(icq_Link *link, unsigned long uin, unsigned char hour, 174 static void icq_url_incoming(icq_Link *link, unsigned long uin, unsigned char hour,
194 unsigned char minute, unsigned char day, unsigned char month, 175 unsigned char minute, unsigned char day, unsigned char month,
195 unsigned short year, const char *url, const char *descr) { 176 unsigned short year, const char *url, const char *descr) {
196 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 177 struct gaim_connection *gc = link->icq_UserData;
197 char *msg = g_malloc(BUF_LONG), buf[256]; 178 char *msg = g_malloc(BUF_LONG), buf[256];
198 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr); 179 g_snprintf(msg, BUF_LONG, "<A HREF=\"%s\">%s</A>", url, descr);
199 g_snprintf(buf, 256, "%lu", uin); 180 g_snprintf(buf, 256, "%lu", uin);
200 serv_got_im(gc, buf, msg, 0, time((time_t)NULL)); 181 serv_got_im(gc, buf, msg, 0, time((time_t)NULL));
201 g_free(msg); 182 g_free(msg);
202 } 183 }
203 184
204 static void icq_wrong_passwd(icq_Link *link) { 185 static void icq_wrong_passwd(icq_Link *link) {
205 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 186 struct gaim_connection *gc = link->icq_UserData;
206 hide_login_progress(gc, "Invalid password."); 187 hide_login_progress(gc, "Invalid password.");
207 signoff(gc); 188 signoff(gc);
208 } 189 }
209 190
210 static void icq_invalid_uin(icq_Link *link) { 191 static void icq_invalid_uin(icq_Link *link) {
211 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 192 struct gaim_connection *gc = link->icq_UserData;
212 hide_login_progress(gc, "Invalid UIN."); 193 hide_login_progress(gc, "Invalid UIN.");
213 signoff(gc); 194 signoff(gc);
214 } 195 }
215 196
216 static void icq_info_reply(icq_Link *link, unsigned long uin, const char *nick, 197 static void icq_info_reply(icq_Link *link, unsigned long uin, const char *nick,
230 } 211 }
231 212
232 static void icq_web_pager(icq_Link *link, unsigned char hour, unsigned char minute, 213 static void icq_web_pager(icq_Link *link, unsigned char hour, unsigned char minute,
233 unsigned char day, unsigned char month, unsigned short year, const char *nick, 214 unsigned char day, unsigned char month, unsigned short year, const char *nick,
234 const char *email, const char *msg) { 215 const char *email, const char *msg) {
235 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 216 struct gaim_connection *gc = link->icq_UserData;
236 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email); 217 char *who = g_strdup_printf("ICQ Web Pager: %s (%s)", nick, email);
237 char *what = g_malloc(BUF_LONG); 218 char *what = g_malloc(BUF_LONG);
238 g_snprintf(what, BUF_LONG, "%s", msg); 219 g_snprintf(what, BUF_LONG, "%s", msg);
239 serv_got_im(gc, who, what, 0, time((time_t)NULL)); 220 serv_got_im(gc, who, what, 0, time((time_t)NULL));
240 g_free(who); 221 g_free(who);
242 } 223 }
243 224
244 static void icq_mail_express(icq_Link *link, unsigned char hour, unsigned char minute, 225 static void icq_mail_express(icq_Link *link, unsigned char hour, unsigned char minute,
245 unsigned char day, unsigned char month, unsigned short year, const char *nick, 226 unsigned char day, unsigned char month, unsigned short year, const char *nick,
246 const char *email, const char *msg) { 227 const char *email, const char *msg) {
247 struct gaim_connection *gc = find_gaim_conn_by_icq_link(link); 228 struct gaim_connection *gc = link->icq_UserData;
248 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email); 229 char *who = g_strdup_printf("ICQ Mail Express: %s (%s)", nick, email);
249 char *what = g_malloc(BUF_LONG); 230 char *what = g_malloc(BUF_LONG);
250 g_snprintf(what, BUF_LONG, "%s", msg); 231 g_snprintf(what, BUF_LONG, "%s", msg);
251 serv_got_im(gc, who, what, 0, time((time_t)NULL)); 232 serv_got_im(gc, who, what, 0, time((time_t)NULL));
252 g_free(who); 233 g_free(who);
315 link->icq_InfoReply = icq_info_reply; 296 link->icq_InfoReply = icq_info_reply;
316 link->icq_WrongPassword = icq_wrong_passwd; 297 link->icq_WrongPassword = icq_wrong_passwd;
317 link->icq_InvalidUIN = icq_invalid_uin; 298 link->icq_InvalidUIN = icq_invalid_uin;
318 link->icq_Log = icq_do_log; 299 link->icq_Log = icq_do_log;
319 link->icq_RequestNotify = icq_req_not; 300 link->icq_RequestNotify = icq_req_not;
301 link->icq_UserData = gc;
320 302
321 if (proxytype == PROXY_SOCKS5) 303 if (proxytype == PROXY_SOCKS5)
322 icq_SetProxy(link, proxyhost, proxyport, proxyuser[0], proxyuser, proxypass); 304 icq_SetProxy(link, proxyhost, proxyport, proxyuser[0], proxyuser, proxypass);
323 305
324 icq_ContactClear(id->link); 306 icq_ContactClear(id->link);