Mercurial > pidgin.yaz
comparison libpurple/protocols/simple/simple.c @ 15823:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | af92b284664a |
comparison
equal
deleted
inserted
replaced
15822:84b0f9b23ede | 15823:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file simple.c | 2 * @file simple.c |
3 * | 3 * |
4 * gaim | 4 * purple |
5 * | 5 * |
6 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de> | 6 * Copyright (C) 2005 Thomas Butter <butter@uni-mannheim.de> |
7 * | 7 * |
8 * *** | 8 * *** |
9 * Thanks to Google's Summer of Code Program and the helpful mentors | 9 * Thanks to Google's Summer of Code Program and the helpful mentors |
60 rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, | 60 rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, |
61 rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, | 61 rand() & 0xFFFF, rand() & 0xFFFF, rand() & 0xFFFF, |
62 rand() & 0xFFFF, rand() & 0xFFFF); | 62 rand() & 0xFFFF, rand() & 0xFFFF); |
63 } | 63 } |
64 | 64 |
65 static const char *simple_list_icon(GaimAccount *a, GaimBuddy *b) { | 65 static const char *simple_list_icon(PurpleAccount *a, PurpleBuddy *b) { |
66 return "simple"; | 66 return "simple"; |
67 } | 67 } |
68 | 68 |
69 static void simple_keep_alive(GaimConnection *gc) { | 69 static void simple_keep_alive(PurpleConnection *gc) { |
70 struct simple_account_data *sip = gc->proto_data; | 70 struct simple_account_data *sip = gc->proto_data; |
71 if(sip->udp) { /* in case of UDP send a packet only with a 0 byte to | 71 if(sip->udp) { /* in case of UDP send a packet only with a 0 byte to |
72 remain in the NAT table */ | 72 remain in the NAT table */ |
73 gchar buf[2] = {0, 0}; | 73 gchar buf[2] = {0, 0}; |
74 gaim_debug_info("simple", "sending keep alive\n"); | 74 purple_debug_info("simple", "sending keep alive\n"); |
75 sendto(sip->fd, buf, 1, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)); | 75 sendto(sip->fd, buf, 1, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)); |
76 } | 76 } |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
82 | 82 |
83 static void send_publish(struct simple_account_data *sip); | 83 static void send_publish(struct simple_account_data *sip); |
84 | 84 |
85 static void do_notifies(struct simple_account_data *sip) { | 85 static void do_notifies(struct simple_account_data *sip) { |
86 GSList *tmp = sip->watcher; | 86 GSList *tmp = sip->watcher; |
87 gaim_debug_info("simple", "do_notifies()\n"); | 87 purple_debug_info("simple", "do_notifies()\n"); |
88 if((sip->republish != -1) || sip->republish < time(NULL)) { | 88 if((sip->republish != -1) || sip->republish < time(NULL)) { |
89 if(gaim_account_get_bool(sip->account, "dopublish", TRUE)) { | 89 if(purple_account_get_bool(sip->account, "dopublish", TRUE)) { |
90 send_publish(sip); | 90 send_publish(sip); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 while(tmp) { | 94 while(tmp) { |
95 gaim_debug_info("simple", "notifying %s\n", ((struct simple_watcher*)tmp->data)->name); | 95 purple_debug_info("simple", "notifying %s\n", ((struct simple_watcher*)tmp->data)->name); |
96 send_notify(sip, tmp->data); | 96 send_notify(sip, tmp->data); |
97 tmp = tmp->next; | 97 tmp = tmp->next; |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 static void simple_set_status(GaimAccount *account, GaimStatus *status) { | 101 static void simple_set_status(PurpleAccount *account, PurpleStatus *status) { |
102 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(gaim_status_get_type(status)); | 102 PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_type(status)); |
103 struct simple_account_data *sip = NULL; | 103 struct simple_account_data *sip = NULL; |
104 | 104 |
105 if (!gaim_status_is_active(status)) | 105 if (!purple_status_is_active(status)) |
106 return; | 106 return; |
107 | 107 |
108 if (account->gc) | 108 if (account->gc) |
109 sip = account->gc->proto_data; | 109 sip = account->gc->proto_data; |
110 | 110 |
111 if (sip) | 111 if (sip) |
112 { | 112 { |
113 g_free(sip->status); | 113 g_free(sip->status); |
114 if (primitive == GAIM_STATUS_AVAILABLE) | 114 if (primitive == PURPLE_STATUS_AVAILABLE) |
115 sip->status = g_strdup("available"); | 115 sip->status = g_strdup("available"); |
116 else | 116 else |
117 sip->status = g_strdup("busy"); | 117 sip->status = g_strdup("busy"); |
118 | 118 |
119 do_notifies(sip); | 119 do_notifies(sip); |
174 } | 174 } |
175 | 175 |
176 static void connection_remove(struct simple_account_data *sip, int fd) { | 176 static void connection_remove(struct simple_account_data *sip, int fd) { |
177 struct sip_connection *conn = connection_find(sip, fd); | 177 struct sip_connection *conn = connection_find(sip, fd); |
178 sip->openconns = g_slist_remove(sip->openconns, conn); | 178 sip->openconns = g_slist_remove(sip->openconns, conn); |
179 if(conn->inputhandler) gaim_input_remove(conn->inputhandler); | 179 if(conn->inputhandler) purple_input_remove(conn->inputhandler); |
180 g_free(conn->inbuf); | 180 g_free(conn->inbuf); |
181 g_free(conn); | 181 g_free(conn); |
182 } | 182 } |
183 | 183 |
184 static void connection_free_all(struct simple_account_data *sip) { | 184 static void connection_free_all(struct simple_account_data *sip) { |
189 connection_remove(sip, ret->fd); | 189 connection_remove(sip, ret->fd); |
190 entry = sip->openconns; | 190 entry = sip->openconns; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 static void simple_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | 194 static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
195 { | 195 { |
196 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; | 196 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; |
197 struct simple_buddy *b; | 197 struct simple_buddy *b; |
198 if(strncmp("sip:", buddy->name, 4)) { | 198 if(strncmp("sip:", buddy->name, 4)) { |
199 gchar *buf = g_strdup_printf("sip:%s", buddy->name); | 199 gchar *buf = g_strdup_printf("sip:%s", buddy->name); |
200 gaim_blist_rename_buddy(buddy, buf); | 200 purple_blist_rename_buddy(buddy, buf); |
201 g_free(buf); | 201 g_free(buf); |
202 } | 202 } |
203 if(!g_hash_table_lookup(sip->buddies, buddy->name)) { | 203 if(!g_hash_table_lookup(sip->buddies, buddy->name)) { |
204 b = g_new0(struct simple_buddy, 1); | 204 b = g_new0(struct simple_buddy, 1); |
205 gaim_debug_info("simple", "simple_add_buddy %s\n", buddy->name); | 205 purple_debug_info("simple", "simple_add_buddy %s\n", buddy->name); |
206 b->name = g_strdup(buddy->name); | 206 b->name = g_strdup(buddy->name); |
207 g_hash_table_insert(sip->buddies, b->name, b); | 207 g_hash_table_insert(sip->buddies, b->name, b); |
208 } else { | 208 } else { |
209 gaim_debug_info("simple", "buddy %s already in internal list\n", buddy->name); | 209 purple_debug_info("simple", "buddy %s already in internal list\n", buddy->name); |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 static void simple_get_buddies(GaimConnection *gc) { | 213 static void simple_get_buddies(PurpleConnection *gc) { |
214 GaimBlistNode *gnode, *cnode, *bnode; | 214 PurpleBlistNode *gnode, *cnode, *bnode; |
215 | 215 |
216 gaim_debug_info("simple", "simple_get_buddies\n"); | 216 purple_debug_info("simple", "simple_get_buddies\n"); |
217 | 217 |
218 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | 218 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
219 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; | 219 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue; |
220 for(cnode = gnode->child; cnode; cnode = cnode->next) { | 220 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
221 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) continue; | 221 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) continue; |
222 for(bnode = cnode->child; bnode; bnode = bnode->next) { | 222 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
223 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; | 223 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) continue; |
224 if(((GaimBuddy*)bnode)->account == gc->account) | 224 if(((PurpleBuddy*)bnode)->account == gc->account) |
225 simple_add_buddy(gc, (GaimBuddy*)bnode, (GaimGroup *)gnode); | 225 simple_add_buddy(gc, (PurpleBuddy*)bnode, (PurpleGroup *)gnode); |
226 } | 226 } |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 static void simple_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | 231 static void simple_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
232 { | 232 { |
233 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; | 233 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; |
234 struct simple_buddy *b = g_hash_table_lookup(sip->buddies, buddy->name); | 234 struct simple_buddy *b = g_hash_table_lookup(sip->buddies, buddy->name); |
235 g_hash_table_remove(sip->buddies, buddy->name); | 235 g_hash_table_remove(sip->buddies, buddy->name); |
236 g_free(b->name); | 236 g_free(b->name); |
237 g_free(b); | 237 g_free(b); |
238 } | 238 } |
239 | 239 |
240 static GList *simple_status_types(GaimAccount *acc) { | 240 static GList *simple_status_types(PurpleAccount *acc) { |
241 GaimStatusType *type; | 241 PurpleStatusType *type; |
242 GList *types = NULL; | 242 GList *types = NULL; |
243 | 243 |
244 type = gaim_status_type_new_with_attrs( | 244 type = purple_status_type_new_with_attrs( |
245 GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, | 245 PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
246 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), | 246 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), |
247 NULL); | 247 NULL); |
248 types = g_list_append(types, type); | 248 types = g_list_append(types, type); |
249 | 249 |
250 type = gaim_status_type_new_full( | 250 type = purple_status_type_new_full( |
251 GAIM_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE); | 251 PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE, TRUE, FALSE); |
252 types = g_list_append(types, type); | 252 types = g_list_append(types, type); |
253 | 253 |
254 return types; | 254 return types; |
255 } | 255 } |
256 | 256 |
261 gchar *ret; | 261 gchar *ret; |
262 gchar *tmp; | 262 gchar *tmp; |
263 const char *authdomain; | 263 const char *authdomain; |
264 const char *authuser; | 264 const char *authuser; |
265 | 265 |
266 authdomain = gaim_account_get_string(sip->account, "authdomain", ""); | 266 authdomain = purple_account_get_string(sip->account, "authdomain", ""); |
267 authuser = gaim_account_get_string(sip->account, "authuser", sip->username); | 267 authuser = purple_account_get_string(sip->account, "authuser", sip->username); |
268 | 268 |
269 if(!authuser || strlen(authuser) < 1) { | 269 if(!authuser || strlen(authuser) < 1) { |
270 authuser = sip->username; | 270 authuser = sip->username; |
271 } | 271 } |
272 | 272 |
273 if(auth->type == 1) { /* Digest */ | 273 if(auth->type == 1) { /* Digest */ |
274 sprintf(noncecount, "%08d", auth->nc++); | 274 sprintf(noncecount, "%08d", auth->nc++); |
275 response = gaim_cipher_http_digest_calculate_response( | 275 response = purple_cipher_http_digest_calculate_response( |
276 "md5", method, target, NULL, NULL, | 276 "md5", method, target, NULL, NULL, |
277 auth->nonce, noncecount, NULL, auth->digest_session_key); | 277 auth->nonce, noncecount, NULL, auth->digest_session_key); |
278 gaim_debug(GAIM_DEBUG_MISC, "simple", "response %s\n", response); | 278 purple_debug(PURPLE_DEBUG_MISC, "simple", "response %s\n", response); |
279 | 279 |
280 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n", authuser, auth->realm, auth->nonce, target, noncecount, response); | 280 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n", authuser, auth->realm, auth->nonce, target, noncecount, response); |
281 g_free(response); | 281 g_free(response); |
282 return ret; | 282 return ret; |
283 } else if(auth->type == 2) { /* NTLM */ | 283 } else if(auth->type == 2) { /* NTLM */ |
284 if(auth->nc == 3 && auth->nonce) { | 284 if(auth->nc == 3 && auth->nonce) { |
285 /* TODO: Don't hardcode "gaim" as the hostname */ | 285 /* TODO: Don't hardcode "purple" as the hostname */ |
286 ret = gaim_ntlm_gen_type3(authuser, sip->password, "gaim", authdomain, (const guint8 *)auth->nonce, &auth->flags); | 286 ret = purple_ntlm_gen_type3(authuser, sip->password, "purple", authdomain, (const guint8 *)auth->nonce, &auth->flags); |
287 tmp = g_strdup_printf("NTLM qop=\"auth\", opaque=\"%s\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"%s\"\r\n", auth->opaque, auth->realm, auth->target, ret); | 287 tmp = g_strdup_printf("NTLM qop=\"auth\", opaque=\"%s\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"%s\"\r\n", auth->opaque, auth->realm, auth->target, ret); |
288 g_free(ret); | 288 g_free(ret); |
289 return tmp; | 289 return tmp; |
290 } | 290 } |
291 tmp = g_strdup_printf("NTLM qop=\"auth\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"\"\r\n", auth->realm, auth->target); | 291 tmp = g_strdup_printf("NTLM qop=\"auth\", realm=\"%s\", targetname=\"%s\", gssapi-data=\"\"\r\n", auth->realm, auth->target); |
292 return tmp; | 292 return tmp; |
293 } | 293 } |
294 | 294 |
295 sprintf(noncecount, "%08d", auth->nc++); | 295 sprintf(noncecount, "%08d", auth->nc++); |
296 response = gaim_cipher_http_digest_calculate_response( | 296 response = purple_cipher_http_digest_calculate_response( |
297 "md5", method, target, NULL, NULL, | 297 "md5", method, target, NULL, NULL, |
298 auth->nonce, noncecount, NULL, auth->digest_session_key); | 298 auth->nonce, noncecount, NULL, auth->digest_session_key); |
299 gaim_debug(GAIM_DEBUG_MISC, "simple", "response %s\n", response); | 299 purple_debug(PURPLE_DEBUG_MISC, "simple", "response %s\n", response); |
300 | 300 |
301 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n", authuser, auth->realm, auth->nonce, target, noncecount, response); | 301 ret = g_strdup_printf("Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", nc=\"%s\", response=\"%s\"\r\n", authuser, auth->realm, auth->nonce, target, noncecount, response); |
302 g_free(response); | 302 g_free(response); |
303 return ret; | 303 return ret; |
304 } | 304 } |
324 int i = 0; | 324 int i = 0; |
325 const char *authuser; | 325 const char *authuser; |
326 char *tmp; | 326 char *tmp; |
327 gchar **parts; | 327 gchar **parts; |
328 | 328 |
329 authuser = gaim_account_get_string(sip->account, "authuser", sip->username); | 329 authuser = purple_account_get_string(sip->account, "authuser", sip->username); |
330 | 330 |
331 if(!authuser || strlen(authuser) < 1) { | 331 if(!authuser || strlen(authuser) < 1) { |
332 authuser = sip->username; | 332 authuser = sip->username; |
333 } | 333 } |
334 | 334 |
335 if(!hdr) { | 335 if(!hdr) { |
336 gaim_debug_error("simple", "fill_auth: hdr==NULL\n"); | 336 purple_debug_error("simple", "fill_auth: hdr==NULL\n"); |
337 return; | 337 return; |
338 } | 338 } |
339 | 339 |
340 if(!g_strncasecmp(hdr, "NTLM", 4)) { | 340 if(!g_strncasecmp(hdr, "NTLM", 4)) { |
341 gaim_debug_info("simple", "found NTLM\n"); | 341 purple_debug_info("simple", "found NTLM\n"); |
342 auth->type = 2; | 342 auth->type = 2; |
343 parts = g_strsplit(hdr+5, "\", ", 0); | 343 parts = g_strsplit(hdr+5, "\", ", 0); |
344 i = 0; | 344 i = 0; |
345 while(parts[i]) { | 345 while(parts[i]) { |
346 gaim_debug_info("simple", "parts[i] %s\n", parts[i]); | 346 purple_debug_info("simple", "parts[i] %s\n", parts[i]); |
347 if((tmp = parse_attribute("gssapi-data=\"", parts[i]))) { | 347 if((tmp = parse_attribute("gssapi-data=\"", parts[i]))) { |
348 auth->nonce = g_memdup(gaim_ntlm_parse_type2(tmp, &auth->flags), 8); | 348 auth->nonce = g_memdup(purple_ntlm_parse_type2(tmp, &auth->flags), 8); |
349 g_free(tmp); | 349 g_free(tmp); |
350 } | 350 } |
351 if((tmp = parse_attribute("targetname=\"", | 351 if((tmp = parse_attribute("targetname=\"", |
352 parts[i]))) { | 352 parts[i]))) { |
353 auth->target = tmp; | 353 auth->target = tmp; |
382 } | 382 } |
383 i++; | 383 i++; |
384 } | 384 } |
385 g_strfreev(parts); | 385 g_strfreev(parts); |
386 | 386 |
387 gaim_debug(GAIM_DEBUG_MISC, "simple", "nonce: %s realm: %s\n", auth->nonce ? auth->nonce : "(null)", auth->realm ? auth->realm : "(null)"); | 387 purple_debug(PURPLE_DEBUG_MISC, "simple", "nonce: %s realm: %s\n", auth->nonce ? auth->nonce : "(null)", auth->realm ? auth->realm : "(null)"); |
388 if(auth->realm) { | 388 if(auth->realm) { |
389 auth->digest_session_key = gaim_cipher_http_digest_calculate_session_key( | 389 auth->digest_session_key = purple_cipher_http_digest_calculate_session_key( |
390 "md5", authuser, auth->realm, sip->password, auth->nonce, NULL); | 390 "md5", authuser, auth->realm, sip->password, auth->nonce, NULL); |
391 | 391 |
392 auth->nc = 1; | 392 auth->nc = 1; |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 static void simple_canwrite_cb(gpointer data, gint source, GaimInputCondition cond) { | 396 static void simple_canwrite_cb(gpointer data, gint source, PurpleInputCondition cond) { |
397 GaimConnection *gc = data; | 397 PurpleConnection *gc = data; |
398 struct simple_account_data *sip = gc->proto_data; | 398 struct simple_account_data *sip = gc->proto_data; |
399 gsize max_write; | 399 gsize max_write; |
400 gssize written; | 400 gssize written; |
401 | 401 |
402 max_write = gaim_circ_buffer_get_max_read(sip->txbuf); | 402 max_write = purple_circ_buffer_get_max_read(sip->txbuf); |
403 | 403 |
404 if(max_write == 0) { | 404 if(max_write == 0) { |
405 gaim_input_remove(sip->tx_handler); | 405 purple_input_remove(sip->tx_handler); |
406 sip->tx_handler = 0; | 406 sip->tx_handler = 0; |
407 return; | 407 return; |
408 } | 408 } |
409 | 409 |
410 written = write(sip->fd, sip->txbuf->outptr, max_write); | 410 written = write(sip->fd, sip->txbuf->outptr, max_write); |
411 | 411 |
412 if(written < 0 && errno == EAGAIN) | 412 if(written < 0 && errno == EAGAIN) |
413 written = 0; | 413 written = 0; |
414 else if(written <= 0) { | 414 else if(written <= 0) { |
415 /*TODO: do we really want to disconnect on a failure to write?*/ | 415 /*TODO: do we really want to disconnect on a failure to write?*/ |
416 gaim_connection_error(gc, _("Could not write")); | 416 purple_connection_error(gc, _("Could not write")); |
417 return; | 417 return; |
418 } | 418 } |
419 | 419 |
420 gaim_circ_buffer_mark_read(sip->txbuf, written); | 420 purple_circ_buffer_mark_read(sip->txbuf, written); |
421 } | 421 } |
422 | 422 |
423 static void simple_input_cb(gpointer data, gint source, GaimInputCondition cond); | 423 static void simple_input_cb(gpointer data, gint source, PurpleInputCondition cond); |
424 | 424 |
425 static void send_later_cb(gpointer data, gint source, const gchar *error) { | 425 static void send_later_cb(gpointer data, gint source, const gchar *error) { |
426 GaimConnection *gc = data; | 426 PurpleConnection *gc = data; |
427 struct simple_account_data *sip; | 427 struct simple_account_data *sip; |
428 struct sip_connection *conn; | 428 struct sip_connection *conn; |
429 | 429 |
430 if (!GAIM_CONNECTION_IS_VALID(gc)) | 430 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
431 { | 431 { |
432 if (source >= 0) | 432 if (source >= 0) |
433 close(source); | 433 close(source); |
434 return; | 434 return; |
435 } | 435 } |
436 | 436 |
437 if(source < 0) { | 437 if(source < 0) { |
438 gaim_connection_error(gc, _("Could not connect")); | 438 purple_connection_error(gc, _("Could not connect")); |
439 return; | 439 return; |
440 } | 440 } |
441 | 441 |
442 sip = gc->proto_data; | 442 sip = gc->proto_data; |
443 sip->fd = source; | 443 sip->fd = source; |
444 sip->connecting = FALSE; | 444 sip->connecting = FALSE; |
445 | 445 |
446 simple_canwrite_cb(gc, sip->fd, GAIM_INPUT_WRITE); | 446 simple_canwrite_cb(gc, sip->fd, PURPLE_INPUT_WRITE); |
447 | 447 |
448 /* If there is more to write now, we need to register a handler */ | 448 /* If there is more to write now, we need to register a handler */ |
449 if(sip->txbuf->bufused > 0) | 449 if(sip->txbuf->bufused > 0) |
450 sip->tx_handler = gaim_input_add(sip->fd, GAIM_INPUT_WRITE, | 450 sip->tx_handler = purple_input_add(sip->fd, PURPLE_INPUT_WRITE, |
451 simple_canwrite_cb, gc); | 451 simple_canwrite_cb, gc); |
452 | 452 |
453 conn = connection_create(sip, source); | 453 conn = connection_create(sip, source); |
454 conn->inputhandler = gaim_input_add(sip->fd, GAIM_INPUT_READ, simple_input_cb, gc); | 454 conn->inputhandler = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_input_cb, gc); |
455 } | 455 } |
456 | 456 |
457 | 457 |
458 static void sendlater(GaimConnection *gc, const char *buf) { | 458 static void sendlater(PurpleConnection *gc, const char *buf) { |
459 struct simple_account_data *sip = gc->proto_data; | 459 struct simple_account_data *sip = gc->proto_data; |
460 | 460 |
461 if(!sip->connecting) { | 461 if(!sip->connecting) { |
462 gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); | 462 purple_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); |
463 if (gaim_proxy_connect(gc, sip->account, sip->realhostname, sip->realport, send_later_cb, gc) == NULL) { | 463 if (purple_proxy_connect(gc, sip->account, sip->realhostname, sip->realport, send_later_cb, gc) == NULL) { |
464 gaim_connection_error(gc, _("Couldn't create socket")); | 464 purple_connection_error(gc, _("Couldn't create socket")); |
465 } | 465 } |
466 sip->connecting = TRUE; | 466 sip->connecting = TRUE; |
467 } | 467 } |
468 | 468 |
469 if(gaim_circ_buffer_get_max_read(sip->txbuf) > 0) | 469 if(purple_circ_buffer_get_max_read(sip->txbuf) > 0) |
470 gaim_circ_buffer_append(sip->txbuf, "\r\n", 2); | 470 purple_circ_buffer_append(sip->txbuf, "\r\n", 2); |
471 | 471 |
472 gaim_circ_buffer_append(sip->txbuf, buf, strlen(buf)); | 472 purple_circ_buffer_append(sip->txbuf, buf, strlen(buf)); |
473 } | 473 } |
474 | 474 |
475 static void sendout_pkt(GaimConnection *gc, const char *buf) { | 475 static void sendout_pkt(PurpleConnection *gc, const char *buf) { |
476 struct simple_account_data *sip = gc->proto_data; | 476 struct simple_account_data *sip = gc->proto_data; |
477 time_t currtime = time(NULL); | 477 time_t currtime = time(NULL); |
478 int writelen = strlen(buf); | 478 int writelen = strlen(buf); |
479 | 479 |
480 gaim_debug(GAIM_DEBUG_MISC, "simple", "\n\nsending - %s\n######\n%s\n######\n\n", ctime(&currtime), buf); | 480 purple_debug(PURPLE_DEBUG_MISC, "simple", "\n\nsending - %s\n######\n%s\n######\n\n", ctime(&currtime), buf); |
481 if(sip->udp) { | 481 if(sip->udp) { |
482 if(sendto(sip->fd, buf, writelen, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)) < writelen) { | 482 if(sendto(sip->fd, buf, writelen, 0, (struct sockaddr*)&sip->serveraddr, sizeof(struct sockaddr_in)) < writelen) { |
483 gaim_debug_info("simple", "could not send packet\n"); | 483 purple_debug_info("simple", "could not send packet\n"); |
484 } | 484 } |
485 } else { | 485 } else { |
486 int ret; | 486 int ret; |
487 if(sip->fd < 0) { | 487 if(sip->fd < 0) { |
488 sendlater(gc, buf); | 488 sendlater(gc, buf); |
502 return; | 502 return; |
503 } | 503 } |
504 | 504 |
505 if (ret < writelen) { | 505 if (ret < writelen) { |
506 if(!sip->tx_handler) | 506 if(!sip->tx_handler) |
507 sip->tx_handler = gaim_input_add(sip->fd, | 507 sip->tx_handler = purple_input_add(sip->fd, |
508 GAIM_INPUT_WRITE, simple_canwrite_cb, | 508 PURPLE_INPUT_WRITE, simple_canwrite_cb, |
509 gc); | 509 gc); |
510 | 510 |
511 /* XXX: is it OK to do this? You might get part of a request sent | 511 /* XXX: is it OK to do this? You might get part of a request sent |
512 with part of another. */ | 512 with part of another. */ |
513 if(sip->txbuf->bufused > 0) | 513 if(sip->txbuf->bufused > 0) |
514 gaim_circ_buffer_append(sip->txbuf, "\r\n", 2); | 514 purple_circ_buffer_append(sip->txbuf, "\r\n", 2); |
515 | 515 |
516 gaim_circ_buffer_append(sip->txbuf, buf + ret, | 516 purple_circ_buffer_append(sip->txbuf, buf + ret, |
517 writelen - ret); | 517 writelen - ret); |
518 } | 518 } |
519 } | 519 } |
520 } | 520 } |
521 | 521 |
522 static int simple_send_raw(GaimConnection *gc, const char *buf, int len) | 522 static int simple_send_raw(PurpleConnection *gc, const char *buf, int len) |
523 { | 523 { |
524 sendout_pkt(gc, buf); | 524 sendout_pkt(gc, buf); |
525 return len; | 525 return len; |
526 } | 526 } |
527 | 527 |
540 g_string_append_printf(outstr, "\r\n%s", msg->body ? msg->body : ""); | 540 g_string_append_printf(outstr, "\r\n%s", msg->body ? msg->body : ""); |
541 sendout_pkt(sip->gc, outstr->str); | 541 sendout_pkt(sip->gc, outstr->str); |
542 g_string_free(outstr, TRUE); | 542 g_string_free(outstr, TRUE); |
543 } | 543 } |
544 | 544 |
545 static void send_sip_response(GaimConnection *gc, struct sipmsg *msg, int code, | 545 static void send_sip_response(PurpleConnection *gc, struct sipmsg *msg, int code, |
546 const char *text, const char *body) { | 546 const char *text, const char *body) { |
547 GSList *tmp = msg->headers; | 547 GSList *tmp = msg->headers; |
548 gchar *name; | 548 gchar *name; |
549 gchar *value; | 549 gchar *value; |
550 GString *outstr = g_string_new(""); | 550 GString *outstr = g_string_new(""); |
602 } | 602 } |
603 | 603 |
604 return NULL; | 604 return NULL; |
605 } | 605 } |
606 | 606 |
607 static void send_sip_request(GaimConnection *gc, const gchar *method, | 607 static void send_sip_request(PurpleConnection *gc, const gchar *method, |
608 const gchar *url, const gchar *to, const gchar *addheaders, | 608 const gchar *url, const gchar *to, const gchar *addheaders, |
609 const gchar *body, struct sip_dialog *dialog, TransCallback tc) { | 609 const gchar *body, struct sip_dialog *dialog, TransCallback tc) { |
610 struct simple_account_data *sip = gc->proto_data; | 610 struct simple_account_data *sip = gc->proto_data; |
611 char *callid = dialog ? g_strdup(dialog->callid) : gencallid(); | 611 char *callid = dialog ? g_strdup(dialog->callid) : gencallid(); |
612 char *auth = NULL; | 612 char *auth = NULL; |
626 if(addheaders) addh = addheaders; | 626 if(addheaders) addh = addheaders; |
627 if(sip->registrar.type && !strcmp(method, "REGISTER")) { | 627 if(sip->registrar.type && !strcmp(method, "REGISTER")) { |
628 buf = auth_header(sip, &sip->registrar, method, url); | 628 buf = auth_header(sip, &sip->registrar, method, url); |
629 auth = g_strdup_printf("Authorization: %s", buf); | 629 auth = g_strdup_printf("Authorization: %s", buf); |
630 g_free(buf); | 630 g_free(buf); |
631 gaim_debug(GAIM_DEBUG_MISC, "simple", "header %s", auth); | 631 purple_debug(PURPLE_DEBUG_MISC, "simple", "header %s", auth); |
632 } | 632 } |
633 | 633 |
634 if(sip->proxy.type && strcmp(method, "REGISTER")) { | 634 if(sip->proxy.type && strcmp(method, "REGISTER")) { |
635 buf = auth_header(sip, &sip->proxy, method, url); | 635 buf = auth_header(sip, &sip->proxy, method, url); |
636 auth = g_strdup_printf("Proxy-Authorization: %s", buf); | 636 auth = g_strdup_printf("Proxy-Authorization: %s", buf); |
637 g_free(buf); | 637 g_free(buf); |
638 gaim_debug(GAIM_DEBUG_MISC, "simple", "header %s", auth); | 638 purple_debug(PURPLE_DEBUG_MISC, "simple", "header %s", auth); |
639 } | 639 } |
640 | 640 |
641 if (!dialog) | 641 if (!dialog) |
642 tag = gentag(); | 642 tag = gentag(); |
643 | 643 |
646 /* Don't know what epid is, but LCS wants it */ | 646 /* Don't know what epid is, but LCS wants it */ |
647 "From: <sip:%s@%s>;tag=%s;epid=1234567890\r\n" | 647 "From: <sip:%s@%s>;tag=%s;epid=1234567890\r\n" |
648 "To: <%s>%s%s\r\n" | 648 "To: <%s>%s%s\r\n" |
649 "Max-Forwards: 10\r\n" | 649 "Max-Forwards: 10\r\n" |
650 "CSeq: %d %s\r\n" | 650 "CSeq: %d %s\r\n" |
651 "User-Agent: Gaim/" VERSION "\r\n" | 651 "User-Agent: Purple/" VERSION "\r\n" |
652 "Call-ID: %s\r\n" | 652 "Call-ID: %s\r\n" |
653 "%s%s" | 653 "%s%s" |
654 "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n%s", | 654 "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n%s", |
655 method, | 655 method, |
656 url, | 656 url, |
657 sip->udp ? "UDP" : "TCP", | 657 sip->udp ? "UDP" : "TCP", |
658 gaim_network_get_my_ip(-1), | 658 purple_network_get_my_ip(-1), |
659 sip->listenport, | 659 sip->listenport, |
660 branch, | 660 branch, |
661 sip->username, | 661 sip->username, |
662 sip->servername, | 662 sip->servername, |
663 dialog ? dialog->ourtag : tag, | 663 dialog ? dialog->ourtag : tag, |
685 | 685 |
686 g_free(buf); | 686 g_free(buf); |
687 } | 687 } |
688 | 688 |
689 static char *get_contact(struct simple_account_data *sip) { | 689 static char *get_contact(struct simple_account_data *sip) { |
690 return g_strdup_printf("<sip:%s@%s:%d;transport=%s>;methods=\"MESSAGE, SUBSCRIBE, NOTIFY\"", sip->username, gaim_network_get_my_ip(-1), sip->listenport, sip->udp ? "udp" : "tcp"); | 690 return g_strdup_printf("<sip:%s@%s:%d;transport=%s>;methods=\"MESSAGE, SUBSCRIBE, NOTIFY\"", sip->username, purple_network_get_my_ip(-1), sip->listenport, sip->udp ? "udp" : "tcp"); |
691 } | 691 } |
692 | 692 |
693 static void do_register_exp(struct simple_account_data *sip, int expire) { | 693 static void do_register_exp(struct simple_account_data *sip, int expire) { |
694 char *uri = g_strdup_printf("sip:%s", sip->servername); | 694 char *uri = g_strdup_printf("sip:%s", sip->servername); |
695 char *to = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); | 695 char *to = g_strdup_printf("sip:%s@%s", sip->username, sip->servername); |
720 static gchar *parse_from(const gchar *hdr) { | 720 static gchar *parse_from(const gchar *hdr) { |
721 gchar *from; | 721 gchar *from; |
722 const gchar *tmp, *tmp2 = hdr; | 722 const gchar *tmp, *tmp2 = hdr; |
723 | 723 |
724 if(!hdr) return NULL; | 724 if(!hdr) return NULL; |
725 gaim_debug_info("simple", "parsing address out of %s\n", hdr); | 725 purple_debug_info("simple", "parsing address out of %s\n", hdr); |
726 tmp = strchr(hdr, '<'); | 726 tmp = strchr(hdr, '<'); |
727 | 727 |
728 /* i hate the different SIP UA behaviours... */ | 728 /* i hate the different SIP UA behaviours... */ |
729 if(tmp) { /* sip address in <...> */ | 729 if(tmp) { /* sip address in <...> */ |
730 tmp2 = tmp + 1; | 730 tmp2 = tmp + 1; |
731 tmp = strchr(tmp2, '>'); | 731 tmp = strchr(tmp2, '>'); |
732 if(tmp) { | 732 if(tmp) { |
733 from = g_strndup(tmp2, tmp - tmp2); | 733 from = g_strndup(tmp2, tmp - tmp2); |
734 } else { | 734 } else { |
735 gaim_debug_info("simple", "found < without > in From\n"); | 735 purple_debug_info("simple", "found < without > in From\n"); |
736 return NULL; | 736 return NULL; |
737 } | 737 } |
738 } else { | 738 } else { |
739 tmp = strchr(tmp2, ';'); | 739 tmp = strchr(tmp2, ';'); |
740 if(tmp) { | 740 if(tmp) { |
741 from = g_strndup(tmp2, tmp - tmp2); | 741 from = g_strndup(tmp2, tmp - tmp2); |
742 } else { | 742 } else { |
743 from = g_strdup(tmp2); | 743 from = g_strdup(tmp2); |
744 } | 744 } |
745 } | 745 } |
746 gaim_debug_info("simple", "got %s\n", from); | 746 purple_debug_info("simple", "got %s\n", from); |
747 return from; | 747 return from; |
748 } | 748 } |
749 | 749 |
750 static gboolean process_subscribe_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { | 750 static gboolean process_subscribe_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
751 gchar *to; | 751 gchar *to; |
756 | 756 |
757 to = parse_from(sipmsg_find_header(tc->msg, "To")); /* cant be NULL since it is our own msg */ | 757 to = parse_from(sipmsg_find_header(tc->msg, "To")); /* cant be NULL since it is our own msg */ |
758 | 758 |
759 /* we can not subscribe -> user is offline (TODO unknown status?) */ | 759 /* we can not subscribe -> user is offline (TODO unknown status?) */ |
760 | 760 |
761 gaim_prpl_got_user_status(sip->account, to, "offline", NULL); | 761 purple_prpl_got_user_status(sip->account, to, "offline", NULL); |
762 g_free(to); | 762 g_free(to); |
763 return TRUE; | 763 return TRUE; |
764 } | 764 } |
765 | 765 |
766 static void simple_subscribe(struct simple_account_data *sip, struct simple_buddy *buddy) { | 766 static void simple_subscribe(struct simple_account_data *sip, struct simple_buddy *buddy) { |
793 | 793 |
794 static gboolean simple_add_lcs_contacts(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { | 794 static gboolean simple_add_lcs_contacts(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
795 gchar *tmp; | 795 gchar *tmp; |
796 xmlnode *item, *group, *isc; | 796 xmlnode *item, *group, *isc; |
797 const char *name_group; | 797 const char *name_group; |
798 GaimBuddy *b; | 798 PurpleBuddy *b; |
799 GaimGroup *g = NULL; | 799 PurpleGroup *g = NULL; |
800 struct simple_buddy *bs; | 800 struct simple_buddy *bs; |
801 int len = msg->bodylen; | 801 int len = msg->bodylen; |
802 | 802 |
803 | 803 |
804 tmp = sipmsg_find_header(msg, "Event"); | 804 tmp = sipmsg_find_header(msg, "Event"); |
805 if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ | 805 if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ |
806 | 806 |
807 gaim_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len); | 807 purple_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len); |
808 /*Convert the contact from XML to Gaim Buddies*/ | 808 /*Convert the contact from XML to Purple Buddies*/ |
809 isc = xmlnode_from_str(msg->body, len); | 809 isc = xmlnode_from_str(msg->body, len); |
810 | 810 |
811 /* ToDo. Find for all groups */ | 811 /* ToDo. Find for all groups */ |
812 if ((group = xmlnode_get_child(isc, "group"))) { | 812 if ((group = xmlnode_get_child(isc, "group"))) { |
813 name_group = xmlnode_get_attrib(group, "name"); | 813 name_group = xmlnode_get_attrib(group, "name"); |
814 gaim_debug_info("simple", "name_group->%s\n", name_group); | 814 purple_debug_info("simple", "name_group->%s\n", name_group); |
815 g = gaim_find_group(name_group); | 815 g = purple_find_group(name_group); |
816 if(!g) | 816 if(!g) |
817 g = gaim_group_new(name_group); | 817 g = purple_group_new(name_group); |
818 } | 818 } |
819 | 819 |
820 if (!g) { | 820 if (!g) { |
821 g = gaim_find_group("Buddies"); | 821 g = purple_find_group("Buddies"); |
822 if(!g) | 822 if(!g) |
823 g = gaim_group_new("Buddies"); | 823 g = purple_group_new("Buddies"); |
824 } | 824 } |
825 | 825 |
826 for(item = xmlnode_get_child(isc, "contact"); item; item = xmlnode_get_next_twin(item)) | 826 for(item = xmlnode_get_child(isc, "contact"); item; item = xmlnode_get_next_twin(item)) |
827 { | 827 { |
828 const char *uri, *name, *groups; | 828 const char *uri, *name, *groups; |
829 char *buddy_name; | 829 char *buddy_name; |
830 uri = xmlnode_get_attrib(item, "uri"); | 830 uri = xmlnode_get_attrib(item, "uri"); |
831 name = xmlnode_get_attrib(item, "name"); | 831 name = xmlnode_get_attrib(item, "name"); |
832 groups = xmlnode_get_attrib(item, "groups"); | 832 groups = xmlnode_get_attrib(item, "groups"); |
833 gaim_debug_info("simple", "URI->%s\n", uri); | 833 purple_debug_info("simple", "URI->%s\n", uri); |
834 | 834 |
835 buddy_name = g_strdup_printf("sip:%s", uri); | 835 buddy_name = g_strdup_printf("sip:%s", uri); |
836 | 836 |
837 b = gaim_find_buddy(sip->account, buddy_name); | 837 b = purple_find_buddy(sip->account, buddy_name); |
838 if(!b){ | 838 if(!b){ |
839 b = gaim_buddy_new(sip->account, buddy_name, uri); | 839 b = purple_buddy_new(sip->account, buddy_name, uri); |
840 } | 840 } |
841 g_free(buddy_name); | 841 g_free(buddy_name); |
842 | 842 |
843 gaim_blist_add_buddy(b, NULL, g, NULL); | 843 purple_blist_add_buddy(b, NULL, g, NULL); |
844 gaim_blist_alias_buddy(b, uri); | 844 purple_blist_alias_buddy(b, uri); |
845 bs = g_new0(struct simple_buddy, 1); | 845 bs = g_new0(struct simple_buddy, 1); |
846 bs->name = g_strdup(b->name); | 846 bs->name = g_strdup(b->name); |
847 g_hash_table_insert(sip->buddies, bs->name, bs); | 847 g_hash_table_insert(sip->buddies, bs->name, bs); |
848 } | 848 } |
849 xmlnode_free(isc); | 849 xmlnode_free(isc); |
869 } | 869 } |
870 | 870 |
871 | 871 |
872 static void simple_buddy_resub(char *name, struct simple_buddy *buddy, struct simple_account_data *sip) { | 872 static void simple_buddy_resub(char *name, struct simple_buddy *buddy, struct simple_account_data *sip) { |
873 time_t curtime = time(NULL); | 873 time_t curtime = time(NULL); |
874 gaim_debug_info("simple", "buddy resub\n"); | 874 purple_debug_info("simple", "buddy resub\n"); |
875 if(buddy->resubscribe < curtime) { | 875 if(buddy->resubscribe < curtime) { |
876 gaim_debug(GAIM_DEBUG_MISC, "simple", "simple_buddy_resub %s\n", name); | 876 purple_debug(PURPLE_DEBUG_MISC, "simple", "simple_buddy_resub %s\n", name); |
877 simple_subscribe(sip, buddy); | 877 simple_subscribe(sip, buddy); |
878 } | 878 } |
879 } | 879 } |
880 | 880 |
881 static gboolean resend_timeout(struct simple_account_data *sip) { | 881 static gboolean resend_timeout(struct simple_account_data *sip) { |
882 GSList *tmp = sip->transactions; | 882 GSList *tmp = sip->transactions; |
883 time_t currtime = time(NULL); | 883 time_t currtime = time(NULL); |
884 while(tmp) { | 884 while(tmp) { |
885 struct transaction *trans = tmp->data; | 885 struct transaction *trans = tmp->data; |
886 tmp = tmp->next; | 886 tmp = tmp->next; |
887 gaim_debug_info("simple", "have open transaction age: %d\n", currtime- trans->time); | 887 purple_debug_info("simple", "have open transaction age: %d\n", currtime- trans->time); |
888 if((currtime - trans->time > 5) && trans->retries >= 1) { | 888 if((currtime - trans->time > 5) && trans->retries >= 1) { |
889 /* TODO 408 */ | 889 /* TODO 408 */ |
890 } else { | 890 } else { |
891 if((currtime - trans->time > 2) && trans->retries == 0) { | 891 if((currtime - trans->time > 2) && trans->retries == 0) { |
892 trans->retries++; | 892 trans->retries++; |
938 send_sip_request(sip->gc, "MESSAGE", fullto, fullto, hdr, msg, NULL, NULL); | 938 send_sip_request(sip->gc, "MESSAGE", fullto, fullto, hdr, msg, NULL, NULL); |
939 g_free(hdr); | 939 g_free(hdr); |
940 g_free(fullto); | 940 g_free(fullto); |
941 } | 941 } |
942 | 942 |
943 static int simple_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags) { | 943 static int simple_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) { |
944 struct simple_account_data *sip = gc->proto_data; | 944 struct simple_account_data *sip = gc->proto_data; |
945 char *to = g_strdup(who); | 945 char *to = g_strdup(who); |
946 char *text = gaim_unescape_html(what); | 946 char *text = purple_unescape_html(what); |
947 simple_send_message(sip, to, text, NULL); | 947 simple_send_message(sip, to, text, NULL); |
948 g_free(to); | 948 g_free(to); |
949 g_free(text); | 949 g_free(text); |
950 return 1; | 950 return 1; |
951 } | 951 } |
957 | 957 |
958 from = parse_from(sipmsg_find_header(msg, "From")); | 958 from = parse_from(sipmsg_find_header(msg, "From")); |
959 | 959 |
960 if(!from) return; | 960 if(!from) return; |
961 | 961 |
962 gaim_debug(GAIM_DEBUG_MISC, "simple", "got message from %s: %s\n", from, msg->body); | 962 purple_debug(PURPLE_DEBUG_MISC, "simple", "got message from %s: %s\n", from, msg->body); |
963 | 963 |
964 contenttype = sipmsg_find_header(msg, "Content-Type"); | 964 contenttype = sipmsg_find_header(msg, "Content-Type"); |
965 if(!contenttype || !strncmp(contenttype, "text/plain", 10) || !strncmp(contenttype, "text/html", 9)) { | 965 if(!contenttype || !strncmp(contenttype, "text/plain", 10) || !strncmp(contenttype, "text/html", 9)) { |
966 serv_got_im(sip->gc, from, msg->body, 0, time(NULL)); | 966 serv_got_im(sip->gc, from, msg->body, 0, time(NULL)); |
967 send_sip_response(sip->gc, msg, 200, "OK", NULL); | 967 send_sip_response(sip->gc, msg, 200, "OK", NULL); |
971 xmlnode *isc = xmlnode_from_str(msg->body, msg->bodylen); | 971 xmlnode *isc = xmlnode_from_str(msg->body, msg->bodylen); |
972 xmlnode *state; | 972 xmlnode *state; |
973 gchar *statedata; | 973 gchar *statedata; |
974 | 974 |
975 if(!isc) { | 975 if(!isc) { |
976 gaim_debug_info("simple", "process_incoming_message: can not parse iscomposing\n"); | 976 purple_debug_info("simple", "process_incoming_message: can not parse iscomposing\n"); |
977 return; | 977 return; |
978 } | 978 } |
979 | 979 |
980 state = xmlnode_get_child(isc, "state"); | 980 state = xmlnode_get_child(isc, "state"); |
981 | 981 |
982 if(!state) { | 982 if(!state) { |
983 gaim_debug_info("simple", "process_incoming_message: no state found\n"); | 983 purple_debug_info("simple", "process_incoming_message: no state found\n"); |
984 xmlnode_free(isc); | 984 xmlnode_free(isc); |
985 return; | 985 return; |
986 } | 986 } |
987 | 987 |
988 statedata = xmlnode_get_data(state); | 988 statedata = xmlnode_get_data(state); |
989 if(statedata) { | 989 if(statedata) { |
990 if(strstr(statedata, "active")) serv_got_typing(sip->gc, from, 0, GAIM_TYPING); | 990 if(strstr(statedata, "active")) serv_got_typing(sip->gc, from, 0, PURPLE_TYPING); |
991 else serv_got_typing_stopped(sip->gc, from); | 991 else serv_got_typing_stopped(sip->gc, from); |
992 | 992 |
993 g_free(statedata); | 993 g_free(statedata); |
994 } | 994 } |
995 xmlnode_free(isc); | 995 xmlnode_free(isc); |
996 send_sip_response(sip->gc, msg, 200, "OK", NULL); | 996 send_sip_response(sip->gc, msg, 200, "OK", NULL); |
997 found = TRUE; | 997 found = TRUE; |
998 } | 998 } |
999 if(!found) { | 999 if(!found) { |
1000 gaim_debug_info("simple", "got unknown mime-type"); | 1000 purple_debug_info("simple", "got unknown mime-type"); |
1001 send_sip_response(sip->gc, msg, 415, "Unsupported media type", NULL); | 1001 send_sip_response(sip->gc, msg, 415, "Unsupported media type", NULL); |
1002 } | 1002 } |
1003 g_free(from); | 1003 g_free(from); |
1004 } | 1004 } |
1005 | 1005 |
1006 | 1006 |
1007 gboolean process_register_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { | 1007 gboolean process_register_response(struct simple_account_data *sip, struct sipmsg *msg, struct transaction *tc) { |
1008 gchar *tmp; | 1008 gchar *tmp; |
1009 gaim_debug(GAIM_DEBUG_MISC, "simple", "in process register response response: %d\n", msg->response); | 1009 purple_debug(PURPLE_DEBUG_MISC, "simple", "in process register response response: %d\n", msg->response); |
1010 switch (msg->response) { | 1010 switch (msg->response) { |
1011 case 200: | 1011 case 200: |
1012 if(sip->registerstatus < 3) { /* registered */ | 1012 if(sip->registerstatus < 3) { /* registered */ |
1013 if(gaim_account_get_bool(sip->account, "dopublish", TRUE)) { | 1013 if(purple_account_get_bool(sip->account, "dopublish", TRUE)) { |
1014 send_publish(sip); | 1014 send_publish(sip); |
1015 } | 1015 } |
1016 } | 1016 } |
1017 sip->registerstatus = 3; | 1017 sip->registerstatus = 3; |
1018 gaim_connection_set_state(sip->gc, GAIM_CONNECTED); | 1018 purple_connection_set_state(sip->gc, PURPLE_CONNECTED); |
1019 | 1019 |
1020 /* get buddies from blist */ | 1020 /* get buddies from blist */ |
1021 simple_get_buddies(sip->gc); | 1021 simple_get_buddies(sip->gc); |
1022 | 1022 |
1023 subscribe_timeout(sip); | 1023 subscribe_timeout(sip); |
1027 } | 1027 } |
1028 | 1028 |
1029 break; | 1029 break; |
1030 case 401: | 1030 case 401: |
1031 if(sip->registerstatus != 2) { | 1031 if(sip->registerstatus != 2) { |
1032 gaim_debug_info("simple", "REGISTER retries %d\n", sip->registrar.retries); | 1032 purple_debug_info("simple", "REGISTER retries %d\n", sip->registrar.retries); |
1033 if(sip->registrar.retries > 3) { | 1033 if(sip->registrar.retries > 3) { |
1034 sip->gc->wants_to_die = TRUE; | 1034 sip->gc->wants_to_die = TRUE; |
1035 gaim_connection_error(sip->gc, _("Incorrect password.")); | 1035 purple_connection_error(sip->gc, _("Incorrect password.")); |
1036 return TRUE; | 1036 return TRUE; |
1037 } | 1037 } |
1038 tmp = sipmsg_find_header(msg, "WWW-Authenticate"); | 1038 tmp = sipmsg_find_header(msg, "WWW-Authenticate"); |
1039 fill_auth(sip, tmp, &sip->registrar); | 1039 fill_auth(sip, tmp, &sip->registrar); |
1040 sip->registerstatus = 2; | 1040 sip->registerstatus = 2; |
1058 if(!from) return; | 1058 if(!from) return; |
1059 | 1059 |
1060 pidf = xmlnode_from_str(msg->body, msg->bodylen); | 1060 pidf = xmlnode_from_str(msg->body, msg->bodylen); |
1061 | 1061 |
1062 if(!pidf) { | 1062 if(!pidf) { |
1063 gaim_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); | 1063 purple_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); |
1064 return; | 1064 return; |
1065 } | 1065 } |
1066 | 1066 |
1067 if ((tuple = xmlnode_get_child(pidf, "tuple"))) | 1067 if ((tuple = xmlnode_get_child(pidf, "tuple"))) |
1068 if ((status = xmlnode_get_child(tuple, "status"))) | 1068 if ((status = xmlnode_get_child(tuple, "status"))) |
1069 basicstatus = xmlnode_get_child(status, "basic"); | 1069 basicstatus = xmlnode_get_child(status, "basic"); |
1070 | 1070 |
1071 if(!basicstatus) { | 1071 if(!basicstatus) { |
1072 gaim_debug_info("simple", "process_incoming_notify: no basic found\n"); | 1072 purple_debug_info("simple", "process_incoming_notify: no basic found\n"); |
1073 xmlnode_free(pidf); | 1073 xmlnode_free(pidf); |
1074 return; | 1074 return; |
1075 } | 1075 } |
1076 | 1076 |
1077 tmp2 = xmlnode_get_data(basicstatus); | 1077 tmp2 = xmlnode_get_data(basicstatus); |
1078 | 1078 |
1079 if(!tmp2) { | 1079 if(!tmp2) { |
1080 gaim_debug_info("simple", "process_incoming_notify: no basic data found\n"); | 1080 purple_debug_info("simple", "process_incoming_notify: no basic data found\n"); |
1081 xmlnode_free(pidf); | 1081 xmlnode_free(pidf); |
1082 return; | 1082 return; |
1083 } | 1083 } |
1084 | 1084 |
1085 if(strstr(tmp2, "open")) { | 1085 if(strstr(tmp2, "open")) { |
1086 isonline = TRUE; | 1086 isonline = TRUE; |
1087 } | 1087 } |
1088 | 1088 |
1089 g_free(tmp2); | 1089 g_free(tmp2); |
1090 | 1090 |
1091 if(isonline) gaim_prpl_got_user_status(sip->account, from, "available", NULL); | 1091 if(isonline) purple_prpl_got_user_status(sip->account, from, "available", NULL); |
1092 else gaim_prpl_got_user_status(sip->account, from, "offline", NULL); | 1092 else purple_prpl_got_user_status(sip->account, from, "offline", NULL); |
1093 | 1093 |
1094 xmlnode_free(pidf); | 1094 xmlnode_free(pidf); |
1095 | 1095 |
1096 g_free(from); | 1096 g_free(from); |
1097 send_sip_response(sip->gc, msg, 200, "OK", NULL); | 1097 send_sip_response(sip->gc, msg, 200, "OK", NULL); |
1098 } | 1098 } |
1099 | 1099 |
1100 static unsigned int simple_typing(GaimConnection *gc, const char *name, GaimTypingState state) { | 1100 static unsigned int simple_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) { |
1101 struct simple_account_data *sip = gc->proto_data; | 1101 struct simple_account_data *sip = gc->proto_data; |
1102 | 1102 |
1103 gchar *xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | 1103 gchar *xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
1104 "<isComposing xmlns=\"urn:ietf:params:xml:ns:im-iscomposing\"\n" | 1104 "<isComposing xmlns=\"urn:ietf:params:xml:ns:im-iscomposing\"\n" |
1105 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" | 1105 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" |
1107 "<state>%s</state>\n" | 1107 "<state>%s</state>\n" |
1108 "<contenttype>text/plain</contenttype>\n" | 1108 "<contenttype>text/plain</contenttype>\n" |
1109 "<refresh>60</refresh>\n" | 1109 "<refresh>60</refresh>\n" |
1110 "</isComposing>"; | 1110 "</isComposing>"; |
1111 gchar *recv = g_strdup(name); | 1111 gchar *recv = g_strdup(name); |
1112 if(state == GAIM_TYPING) { | 1112 if(state == PURPLE_TYPING) { |
1113 gchar *msg = g_strdup_printf(xml, "active"); | 1113 gchar *msg = g_strdup_printf(xml, "active"); |
1114 simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); | 1114 simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); |
1115 g_free(msg); | 1115 g_free(msg); |
1116 } else /* TODO: Only if (state == GAIM_TYPED) ? */ { | 1116 } else /* TODO: Only if (state == PURPLE_TYPED) ? */ { |
1117 gchar *msg = g_strdup_printf(xml, "idle"); | 1117 gchar *msg = g_strdup_printf(xml, "idle"); |
1118 simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); | 1118 simple_send_message(sip, recv, msg, "application/im-iscomposing+xml"); |
1119 g_free(msg); | 1119 g_free(msg); |
1120 } | 1120 } |
1121 g_free(recv); | 1121 g_free(recv); |
1122 /* | 1122 /* |
1123 * TODO: Is this right? It will cause the core to call | 1123 * TODO: Is this right? It will cause the core to call |
1124 * serv_send_typing(gc, who, GAIM_TYPING) once every second | 1124 * serv_send_typing(gc, who, PURPLE_TYPING) once every second |
1125 * until the user stops typing. If that's not desired, | 1125 * until the user stops typing. If that's not desired, |
1126 * then return 0 instead. | 1126 * then return 0 instead. |
1127 */ | 1127 */ |
1128 return 1; | 1128 return 1; |
1129 } | 1129 } |
1222 ourtag = gentag(); | 1222 ourtag = gentag(); |
1223 } | 1223 } |
1224 if(!watcher) { /* new subscription */ | 1224 if(!watcher) { /* new subscription */ |
1225 gchar *acceptheader = sipmsg_find_header(msg, "Accept"); | 1225 gchar *acceptheader = sipmsg_find_header(msg, "Accept"); |
1226 gboolean needsxpidf = FALSE; | 1226 gboolean needsxpidf = FALSE; |
1227 if(!gaim_privacy_check(sip->account, from)) { | 1227 if(!purple_privacy_check(sip->account, from)) { |
1228 send_sip_response(sip->gc, msg, 202, "Ok", NULL); | 1228 send_sip_response(sip->gc, msg, 202, "Ok", NULL); |
1229 goto privend; | 1229 goto privend; |
1230 } | 1230 } |
1231 if(acceptheader) { | 1231 if(acceptheader) { |
1232 gchar *tmp = acceptheader; | 1232 gchar *tmp = acceptheader; |
1263 watcher->expire = time(NULL) + 600; | 1263 watcher->expire = time(NULL) + 600; |
1264 sipmsg_remove_header(msg, "Contact"); | 1264 sipmsg_remove_header(msg, "Contact"); |
1265 tmp = get_contact(sip); | 1265 tmp = get_contact(sip); |
1266 sipmsg_add_header(msg, "Contact", tmp); | 1266 sipmsg_add_header(msg, "Contact", tmp); |
1267 g_free(tmp); | 1267 g_free(tmp); |
1268 gaim_debug_info("simple", "got subscribe: name %s ourtag %s theirtag %s callid %s\n", watcher->name, watcher->dialog.ourtag, watcher->dialog.theirtag, watcher->dialog.callid); | 1268 purple_debug_info("simple", "got subscribe: name %s ourtag %s theirtag %s callid %s\n", watcher->name, watcher->dialog.ourtag, watcher->dialog.theirtag, watcher->dialog.callid); |
1269 send_sip_response(sip->gc, msg, 200, "Ok", NULL); | 1269 send_sip_response(sip->gc, msg, 200, "Ok", NULL); |
1270 send_notify(sip, watcher); | 1270 send_notify(sip, watcher); |
1271 privend: | 1271 privend: |
1272 g_free(from); | 1272 g_free(from); |
1273 g_free(theirtag); | 1273 g_free(theirtag); |
1313 sendout_pkt(sip->gc, resend); | 1313 sendout_pkt(sip->gc, resend); |
1314 g_free(resend); | 1314 g_free(resend); |
1315 } else { | 1315 } else { |
1316 if(msg->response == 100) { | 1316 if(msg->response == 100) { |
1317 /* ignore provisional response */ | 1317 /* ignore provisional response */ |
1318 gaim_debug_info("simple", "got trying response\n"); | 1318 purple_debug_info("simple", "got trying response\n"); |
1319 } else { | 1319 } else { |
1320 sip->proxy.retries = 0; | 1320 sip->proxy.retries = 0; |
1321 if(!strcmp(trans->msg->method, "REGISTER")) { | 1321 if(!strcmp(trans->msg->method, "REGISTER")) { |
1322 if(msg->response == 401) sip->registrar.retries++; | 1322 if(msg->response == 401) sip->registrar.retries++; |
1323 else sip->registrar.retries = 0; | 1323 else sip->registrar.retries = 0; |
1348 transactions_remove(sip, trans); | 1348 transactions_remove(sip, trans); |
1349 } | 1349 } |
1350 } | 1350 } |
1351 found = TRUE; | 1351 found = TRUE; |
1352 } else { | 1352 } else { |
1353 gaim_debug(GAIM_DEBUG_MISC, "simple", "received response to unknown transaction"); | 1353 purple_debug(PURPLE_DEBUG_MISC, "simple", "received response to unknown transaction"); |
1354 } | 1354 } |
1355 } | 1355 } |
1356 if(!found) { | 1356 if(!found) { |
1357 gaim_debug(GAIM_DEBUG_MISC, "simple", "received a unknown sip message with method %s and response %d\n", msg->method, msg->response); | 1357 purple_debug(PURPLE_DEBUG_MISC, "simple", "received a unknown sip message with method %s and response %d\n", msg->method, msg->response); |
1358 } | 1358 } |
1359 } | 1359 } |
1360 | 1360 |
1361 static void process_input(struct simple_account_data *sip, struct sip_connection *conn) | 1361 static void process_input(struct simple_account_data *sip, struct sip_connection *conn) |
1362 { | 1362 { |
1378 /* Received a full Header? */ | 1378 /* Received a full Header? */ |
1379 if((cur = strstr(conn->inbuf, "\r\n\r\n")) != NULL) { | 1379 if((cur = strstr(conn->inbuf, "\r\n\r\n")) != NULL) { |
1380 time_t currtime = time(NULL); | 1380 time_t currtime = time(NULL); |
1381 cur += 2; | 1381 cur += 2; |
1382 cur[0] = '\0'; | 1382 cur[0] = '\0'; |
1383 gaim_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), conn->inbuf); | 1383 purple_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), conn->inbuf); |
1384 msg = sipmsg_parse_header(conn->inbuf); | 1384 msg = sipmsg_parse_header(conn->inbuf); |
1385 cur[0] = '\r'; | 1385 cur[0] = '\r'; |
1386 cur += 2; | 1386 cur += 2; |
1387 restlen = conn->inbufused - (cur - conn->inbuf); | 1387 restlen = conn->inbufused - (cur - conn->inbuf); |
1388 if(restlen >= msg->bodylen) { | 1388 if(restlen >= msg->bodylen) { |
1395 conn->inbufused = strlen(conn->inbuf); | 1395 conn->inbufused = strlen(conn->inbuf); |
1396 } else { | 1396 } else { |
1397 sipmsg_free(msg); | 1397 sipmsg_free(msg); |
1398 return; | 1398 return; |
1399 } | 1399 } |
1400 gaim_debug(GAIM_DEBUG_MISC, "simple", "in process response response: %d\n", msg->response); | 1400 purple_debug(PURPLE_DEBUG_MISC, "simple", "in process response response: %d\n", msg->response); |
1401 process_input_message(sip, msg); | 1401 process_input_message(sip, msg); |
1402 } else { | 1402 } else { |
1403 gaim_debug(GAIM_DEBUG_MISC, "simple", "received a incomplete sip msg: %s\n", conn->inbuf); | 1403 purple_debug(PURPLE_DEBUG_MISC, "simple", "received a incomplete sip msg: %s\n", conn->inbuf); |
1404 } | 1404 } |
1405 } | 1405 } |
1406 | 1406 |
1407 static void simple_udp_process(gpointer data, gint source, GaimInputCondition con) { | 1407 static void simple_udp_process(gpointer data, gint source, PurpleInputCondition con) { |
1408 GaimConnection *gc = data; | 1408 PurpleConnection *gc = data; |
1409 struct simple_account_data *sip = gc->proto_data; | 1409 struct simple_account_data *sip = gc->proto_data; |
1410 struct sipmsg *msg; | 1410 struct sipmsg *msg; |
1411 int len; | 1411 int len; |
1412 time_t currtime; | 1412 time_t currtime; |
1413 | 1413 |
1414 static char buffer[65536]; | 1414 static char buffer[65536]; |
1415 if((len = recv(source, buffer, sizeof(buffer) - 1, 0)) > 0) { | 1415 if((len = recv(source, buffer, sizeof(buffer) - 1, 0)) > 0) { |
1416 buffer[len] = '\0'; | 1416 buffer[len] = '\0'; |
1417 gaim_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), buffer); | 1417 purple_debug_info("simple", "\n\nreceived - %s\n######\n%s\n#######\n\n", ctime(&currtime), buffer); |
1418 msg = sipmsg_parse_msg(buffer); | 1418 msg = sipmsg_parse_msg(buffer); |
1419 if(msg) process_input_message(sip, msg); | 1419 if(msg) process_input_message(sip, msg); |
1420 } | 1420 } |
1421 } | 1421 } |
1422 | 1422 |
1423 static void simple_input_cb(gpointer data, gint source, GaimInputCondition cond) | 1423 static void simple_input_cb(gpointer data, gint source, PurpleInputCondition cond) |
1424 { | 1424 { |
1425 GaimConnection *gc = data; | 1425 PurpleConnection *gc = data; |
1426 struct simple_account_data *sip = gc->proto_data; | 1426 struct simple_account_data *sip = gc->proto_data; |
1427 int len; | 1427 int len; |
1428 struct sip_connection *conn = connection_find(sip, source); | 1428 struct sip_connection *conn = connection_find(sip, source); |
1429 if(!conn) { | 1429 if(!conn) { |
1430 gaim_debug_error("simple", "Connection not found!\n"); | 1430 purple_debug_error("simple", "Connection not found!\n"); |
1431 return; | 1431 return; |
1432 } | 1432 } |
1433 | 1433 |
1434 if(conn->inbuflen < conn->inbufused + SIMPLE_BUF_INC) { | 1434 if(conn->inbuflen < conn->inbufused + SIMPLE_BUF_INC) { |
1435 conn->inbuflen += SIMPLE_BUF_INC; | 1435 conn->inbuflen += SIMPLE_BUF_INC; |
1439 len = read(source, conn->inbuf + conn->inbufused, SIMPLE_BUF_INC - 1); | 1439 len = read(source, conn->inbuf + conn->inbufused, SIMPLE_BUF_INC - 1); |
1440 | 1440 |
1441 if(len < 0 && errno == EAGAIN) | 1441 if(len < 0 && errno == EAGAIN) |
1442 return; | 1442 return; |
1443 else if(len <= 0) { | 1443 else if(len <= 0) { |
1444 gaim_debug_info("simple", "simple_input_cb: read error\n"); | 1444 purple_debug_info("simple", "simple_input_cb: read error\n"); |
1445 connection_remove(sip, source); | 1445 connection_remove(sip, source); |
1446 if(sip->fd == source) sip->fd = -1; | 1446 if(sip->fd == source) sip->fd = -1; |
1447 return; | 1447 return; |
1448 } | 1448 } |
1449 | 1449 |
1452 | 1452 |
1453 process_input(sip, conn); | 1453 process_input(sip, conn); |
1454 } | 1454 } |
1455 | 1455 |
1456 /* Callback for new connections on incoming TCP port */ | 1456 /* Callback for new connections on incoming TCP port */ |
1457 static void simple_newconn_cb(gpointer data, gint source, GaimInputCondition cond) { | 1457 static void simple_newconn_cb(gpointer data, gint source, PurpleInputCondition cond) { |
1458 GaimConnection *gc = data; | 1458 PurpleConnection *gc = data; |
1459 struct simple_account_data *sip = gc->proto_data; | 1459 struct simple_account_data *sip = gc->proto_data; |
1460 struct sip_connection *conn; | 1460 struct sip_connection *conn; |
1461 | 1461 |
1462 int newfd = accept(source, NULL, NULL); | 1462 int newfd = accept(source, NULL, NULL); |
1463 | 1463 |
1464 conn = connection_create(sip, newfd); | 1464 conn = connection_create(sip, newfd); |
1465 | 1465 |
1466 conn->inputhandler = gaim_input_add(newfd, GAIM_INPUT_READ, simple_input_cb, gc); | 1466 conn->inputhandler = purple_input_add(newfd, PURPLE_INPUT_READ, simple_input_cb, gc); |
1467 } | 1467 } |
1468 | 1468 |
1469 static void login_cb(gpointer data, gint source, const gchar *error_message) { | 1469 static void login_cb(gpointer data, gint source, const gchar *error_message) { |
1470 GaimConnection *gc = data; | 1470 PurpleConnection *gc = data; |
1471 struct simple_account_data *sip; | 1471 struct simple_account_data *sip; |
1472 struct sip_connection *conn; | 1472 struct sip_connection *conn; |
1473 | 1473 |
1474 if (!GAIM_CONNECTION_IS_VALID(gc)) | 1474 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
1475 { | 1475 { |
1476 if (source >= 0) | 1476 if (source >= 0) |
1477 close(source); | 1477 close(source); |
1478 return; | 1478 return; |
1479 } | 1479 } |
1480 | 1480 |
1481 if(source < 0) { | 1481 if(source < 0) { |
1482 gaim_connection_error(gc, _("Could not connect")); | 1482 purple_connection_error(gc, _("Could not connect")); |
1483 return; | 1483 return; |
1484 } | 1484 } |
1485 | 1485 |
1486 sip = gc->proto_data; | 1486 sip = gc->proto_data; |
1487 sip->fd = source; | 1487 sip->fd = source; |
1488 | 1488 |
1489 conn = connection_create(sip, source); | 1489 conn = connection_create(sip, source); |
1490 | 1490 |
1491 sip->registertimeout = gaim_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); | 1491 sip->registertimeout = purple_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); |
1492 | 1492 |
1493 do_register(sip); | 1493 do_register(sip); |
1494 | 1494 |
1495 conn->inputhandler = gaim_input_add(sip->fd, GAIM_INPUT_READ, simple_input_cb, gc); | 1495 conn->inputhandler = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_input_cb, gc); |
1496 } | 1496 } |
1497 | 1497 |
1498 static guint simple_ht_hash_nick(const char *nick) { | 1498 static guint simple_ht_hash_nick(const char *nick) { |
1499 char *lc = g_utf8_strdown(nick, -1); | 1499 char *lc = g_utf8_strdown(nick, -1); |
1500 guint bucket = g_str_hash(lc); | 1500 guint bucket = g_str_hash(lc); |
1502 | 1502 |
1503 return bucket; | 1503 return bucket; |
1504 } | 1504 } |
1505 | 1505 |
1506 static gboolean simple_ht_equals_nick(const char *nick1, const char *nick2) { | 1506 static gboolean simple_ht_equals_nick(const char *nick1, const char *nick2) { |
1507 return (gaim_utf8_strcasecmp(nick1, nick2) == 0); | 1507 return (purple_utf8_strcasecmp(nick1, nick2) == 0); |
1508 } | 1508 } |
1509 | 1509 |
1510 static void simple_udp_host_resolved_listen_cb(int listenfd, gpointer data) { | 1510 static void simple_udp_host_resolved_listen_cb(int listenfd, gpointer data) { |
1511 struct simple_account_data *sip = (struct simple_account_data*) data; | 1511 struct simple_account_data *sip = (struct simple_account_data*) data; |
1512 | 1512 |
1513 sip->listen_data = NULL; | 1513 sip->listen_data = NULL; |
1514 | 1514 |
1515 if(listenfd == -1) { | 1515 if(listenfd == -1) { |
1516 gaim_connection_error(sip->gc, _("Could not create listen socket")); | 1516 purple_connection_error(sip->gc, _("Could not create listen socket")); |
1517 return; | 1517 return; |
1518 } | 1518 } |
1519 | 1519 |
1520 sip->fd = listenfd; | 1520 sip->fd = listenfd; |
1521 | 1521 |
1522 sip->listenport = gaim_network_get_port_from_fd(sip->fd); | 1522 sip->listenport = purple_network_get_port_from_fd(sip->fd); |
1523 sip->listenfd = sip->fd; | 1523 sip->listenfd = sip->fd; |
1524 | 1524 |
1525 sip->listenpa = gaim_input_add(sip->fd, GAIM_INPUT_READ, simple_udp_process, sip->gc); | 1525 sip->listenpa = purple_input_add(sip->fd, PURPLE_INPUT_READ, simple_udp_process, sip->gc); |
1526 | 1526 |
1527 sip->resendtimeout = gaim_timeout_add(2500, (GSourceFunc) resend_timeout, sip); | 1527 sip->resendtimeout = purple_timeout_add(2500, (GSourceFunc) resend_timeout, sip); |
1528 sip->registertimeout = gaim_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); | 1528 sip->registertimeout = purple_timeout_add((rand()%100)+10*1000, (GSourceFunc)subscribe_timeout, sip); |
1529 do_register(sip); | 1529 do_register(sip); |
1530 } | 1530 } |
1531 | 1531 |
1532 static void simple_udp_host_resolved(GSList *hosts, gpointer data, const char *error_message) { | 1532 static void simple_udp_host_resolved(GSList *hosts, gpointer data, const char *error_message) { |
1533 struct simple_account_data *sip = (struct simple_account_data*) data; | 1533 struct simple_account_data *sip = (struct simple_account_data*) data; |
1534 int addr_size; | 1534 int addr_size; |
1535 | 1535 |
1536 sip->query_data = NULL; | 1536 sip->query_data = NULL; |
1537 | 1537 |
1538 if (!hosts || !hosts->data) { | 1538 if (!hosts || !hosts->data) { |
1539 gaim_connection_error(sip->gc, _("Couldn't resolve host")); | 1539 purple_connection_error(sip->gc, _("Couldn't resolve host")); |
1540 return; | 1540 return; |
1541 } | 1541 } |
1542 | 1542 |
1543 addr_size = GPOINTER_TO_INT(hosts->data); | 1543 addr_size = GPOINTER_TO_INT(hosts->data); |
1544 hosts = g_slist_remove(hosts, hosts->data); | 1544 hosts = g_slist_remove(hosts, hosts->data); |
1550 g_free(hosts->data); | 1550 g_free(hosts->data); |
1551 hosts = g_slist_remove(hosts, hosts->data); | 1551 hosts = g_slist_remove(hosts, hosts->data); |
1552 } | 1552 } |
1553 | 1553 |
1554 /* create socket for incoming connections */ | 1554 /* create socket for incoming connections */ |
1555 sip->listen_data = gaim_network_listen_range(5060, 5160, SOCK_DGRAM, | 1555 sip->listen_data = purple_network_listen_range(5060, 5160, SOCK_DGRAM, |
1556 simple_udp_host_resolved_listen_cb, sip); | 1556 simple_udp_host_resolved_listen_cb, sip); |
1557 if (sip->listen_data == NULL) { | 1557 if (sip->listen_data == NULL) { |
1558 gaim_connection_error(sip->gc, _("Could not create listen socket")); | 1558 purple_connection_error(sip->gc, _("Could not create listen socket")); |
1559 return; | 1559 return; |
1560 } | 1560 } |
1561 } | 1561 } |
1562 | 1562 |
1563 static void | 1563 static void |
1566 | 1566 |
1567 sip->listen_data = NULL; | 1567 sip->listen_data = NULL; |
1568 | 1568 |
1569 sip->listenfd = listenfd; | 1569 sip->listenfd = listenfd; |
1570 if(sip->listenfd == -1) { | 1570 if(sip->listenfd == -1) { |
1571 gaim_connection_error(sip->gc, _("Could not create listen socket")); | 1571 purple_connection_error(sip->gc, _("Could not create listen socket")); |
1572 return; | 1572 return; |
1573 } | 1573 } |
1574 | 1574 |
1575 gaim_debug_info("simple", "listenfd: %d\n", sip->listenfd); | 1575 purple_debug_info("simple", "listenfd: %d\n", sip->listenfd); |
1576 sip->listenport = gaim_network_get_port_from_fd(sip->listenfd); | 1576 sip->listenport = purple_network_get_port_from_fd(sip->listenfd); |
1577 sip->listenpa = gaim_input_add(sip->listenfd, GAIM_INPUT_READ, | 1577 sip->listenpa = purple_input_add(sip->listenfd, PURPLE_INPUT_READ, |
1578 simple_newconn_cb, sip->gc); | 1578 simple_newconn_cb, sip->gc); |
1579 gaim_debug_info("simple", "connecting to %s port %d\n", | 1579 purple_debug_info("simple", "connecting to %s port %d\n", |
1580 sip->realhostname, sip->realport); | 1580 sip->realhostname, sip->realport); |
1581 /* open tcp connection to the server */ | 1581 /* open tcp connection to the server */ |
1582 if (gaim_proxy_connect(sip->gc, sip->account, sip->realhostname, | 1582 if (purple_proxy_connect(sip->gc, sip->account, sip->realhostname, |
1583 sip->realport, login_cb, sip->gc) == NULL) { | 1583 sip->realport, login_cb, sip->gc) == NULL) { |
1584 gaim_connection_error(sip->gc, _("Couldn't create socket")); | 1584 purple_connection_error(sip->gc, _("Couldn't create socket")); |
1585 } | 1585 } |
1586 } | 1586 } |
1587 | 1587 |
1588 static void srvresolved(GaimSrvResponse *resp, int results, gpointer data) { | 1588 static void srvresolved(PurpleSrvResponse *resp, int results, gpointer data) { |
1589 struct simple_account_data *sip; | 1589 struct simple_account_data *sip; |
1590 gchar *hostname; | 1590 gchar *hostname; |
1591 int port; | 1591 int port; |
1592 | 1592 |
1593 sip = data; | 1593 sip = data; |
1594 sip->srv_query_data = NULL; | 1594 sip->srv_query_data = NULL; |
1595 | 1595 |
1596 port = gaim_account_get_int(sip->account, "port", 0); | 1596 port = purple_account_get_int(sip->account, "port", 0); |
1597 | 1597 |
1598 /* find the host to connect to */ | 1598 /* find the host to connect to */ |
1599 if(results) { | 1599 if(results) { |
1600 hostname = g_strdup(resp->hostname); | 1600 hostname = g_strdup(resp->hostname); |
1601 if(!port) | 1601 if(!port) |
1602 port = resp->port; | 1602 port = resp->port; |
1603 g_free(resp); | 1603 g_free(resp); |
1604 } else { | 1604 } else { |
1605 if(!gaim_account_get_bool(sip->account, "useproxy", FALSE)) { | 1605 if(!purple_account_get_bool(sip->account, "useproxy", FALSE)) { |
1606 hostname = g_strdup(sip->servername); | 1606 hostname = g_strdup(sip->servername); |
1607 } else { | 1607 } else { |
1608 hostname = g_strdup(gaim_account_get_string(sip->account, "proxy", sip->servername)); | 1608 hostname = g_strdup(purple_account_get_string(sip->account, "proxy", sip->servername)); |
1609 } | 1609 } |
1610 } | 1610 } |
1611 | 1611 |
1612 sip->realhostname = hostname; | 1612 sip->realhostname = hostname; |
1613 sip->realport = port; | 1613 sip->realport = port; |
1614 if(!sip->realport) sip->realport = 5060; | 1614 if(!sip->realport) sip->realport = 5060; |
1615 | 1615 |
1616 /* TCP case */ | 1616 /* TCP case */ |
1617 if(!sip->udp) { | 1617 if(!sip->udp) { |
1618 /* create socket for incoming connections */ | 1618 /* create socket for incoming connections */ |
1619 sip->listen_data = gaim_network_listen_range(5060, 5160, SOCK_STREAM, | 1619 sip->listen_data = purple_network_listen_range(5060, 5160, SOCK_STREAM, |
1620 simple_tcp_connect_listen_cb, sip); | 1620 simple_tcp_connect_listen_cb, sip); |
1621 if (sip->listen_data == NULL) { | 1621 if (sip->listen_data == NULL) { |
1622 gaim_connection_error(sip->gc, _("Could not create listen socket")); | 1622 purple_connection_error(sip->gc, _("Could not create listen socket")); |
1623 return; | 1623 return; |
1624 } | 1624 } |
1625 } else { /* UDP */ | 1625 } else { /* UDP */ |
1626 gaim_debug_info("simple", "using udp with server %s and port %d\n", hostname, port); | 1626 purple_debug_info("simple", "using udp with server %s and port %d\n", hostname, port); |
1627 | 1627 |
1628 sip->query_data = gaim_dnsquery_a(hostname, port, simple_udp_host_resolved, sip); | 1628 sip->query_data = purple_dnsquery_a(hostname, port, simple_udp_host_resolved, sip); |
1629 if (sip->query_data == NULL) { | 1629 if (sip->query_data == NULL) { |
1630 gaim_connection_error(sip->gc, _("Could not resolve hostname")); | 1630 purple_connection_error(sip->gc, _("Could not resolve hostname")); |
1631 } | 1631 } |
1632 } | 1632 } |
1633 } | 1633 } |
1634 | 1634 |
1635 static void simple_login(GaimAccount *account) | 1635 static void simple_login(PurpleAccount *account) |
1636 { | 1636 { |
1637 GaimConnection *gc; | 1637 PurpleConnection *gc; |
1638 struct simple_account_data *sip; | 1638 struct simple_account_data *sip; |
1639 gchar **userserver; | 1639 gchar **userserver; |
1640 gchar *hosttoconnect; | 1640 gchar *hosttoconnect; |
1641 | 1641 |
1642 const char *username = gaim_account_get_username(account); | 1642 const char *username = purple_account_get_username(account); |
1643 gc = gaim_account_get_connection(account); | 1643 gc = purple_account_get_connection(account); |
1644 | 1644 |
1645 if (strpbrk(username, " \t\v\r\n") != NULL) { | 1645 if (strpbrk(username, " \t\v\r\n") != NULL) { |
1646 gc->wants_to_die = TRUE; | 1646 gc->wants_to_die = TRUE; |
1647 gaim_connection_error(gc, _("SIP screen names may not contain whitespaces or @ symbols")); | 1647 purple_connection_error(gc, _("SIP screen names may not contain whitespaces or @ symbols")); |
1648 return; | 1648 return; |
1649 } | 1649 } |
1650 | 1650 |
1651 gc->proto_data = sip = g_new0(struct simple_account_data, 1); | 1651 gc->proto_data = sip = g_new0(struct simple_account_data, 1); |
1652 sip->gc = gc; | 1652 sip->gc = gc; |
1653 sip->account = account; | 1653 sip->account = account; |
1654 sip->registerexpire = 900; | 1654 sip->registerexpire = 900; |
1655 sip->udp = gaim_account_get_bool(account, "udp", FALSE); | 1655 sip->udp = purple_account_get_bool(account, "udp", FALSE); |
1656 /* TODO: is there a good default grow size? */ | 1656 /* TODO: is there a good default grow size? */ |
1657 if(!sip->udp) | 1657 if(!sip->udp) |
1658 sip->txbuf = gaim_circ_buffer_new(0); | 1658 sip->txbuf = purple_circ_buffer_new(0); |
1659 | 1659 |
1660 userserver = g_strsplit(username, "@", 2); | 1660 userserver = g_strsplit(username, "@", 2); |
1661 gaim_connection_set_display_name(gc, userserver[0]); | 1661 purple_connection_set_display_name(gc, userserver[0]); |
1662 sip->username = g_strdup(userserver[0]); | 1662 sip->username = g_strdup(userserver[0]); |
1663 sip->servername = g_strdup(userserver[1]); | 1663 sip->servername = g_strdup(userserver[1]); |
1664 sip->password = g_strdup(gaim_connection_get_password(gc)); | 1664 sip->password = g_strdup(purple_connection_get_password(gc)); |
1665 g_strfreev(userserver); | 1665 g_strfreev(userserver); |
1666 | 1666 |
1667 sip->buddies = g_hash_table_new((GHashFunc)simple_ht_hash_nick, (GEqualFunc)simple_ht_equals_nick); | 1667 sip->buddies = g_hash_table_new((GHashFunc)simple_ht_hash_nick, (GEqualFunc)simple_ht_equals_nick); |
1668 | 1668 |
1669 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); | 1669 purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
1670 | 1670 |
1671 /* TODO: Set the status correctly. */ | 1671 /* TODO: Set the status correctly. */ |
1672 sip->status = g_strdup("available"); | 1672 sip->status = g_strdup("available"); |
1673 | 1673 |
1674 if(!gaim_account_get_bool(account, "useproxy", FALSE)) { | 1674 if(!purple_account_get_bool(account, "useproxy", FALSE)) { |
1675 hosttoconnect = g_strdup(sip->servername); | 1675 hosttoconnect = g_strdup(sip->servername); |
1676 } else { | 1676 } else { |
1677 hosttoconnect = g_strdup(gaim_account_get_string(account, "proxy", sip->servername)); | 1677 hosttoconnect = g_strdup(purple_account_get_string(account, "proxy", sip->servername)); |
1678 } | 1678 } |
1679 | 1679 |
1680 sip->srv_query_data = gaim_srv_resolve("sip", | 1680 sip->srv_query_data = purple_srv_resolve("sip", |
1681 sip->udp ? "udp" : "tcp", hosttoconnect, srvresolved, sip); | 1681 sip->udp ? "udp" : "tcp", hosttoconnect, srvresolved, sip); |
1682 g_free(hosttoconnect); | 1682 g_free(hosttoconnect); |
1683 } | 1683 } |
1684 | 1684 |
1685 static void simple_close(GaimConnection *gc) | 1685 static void simple_close(PurpleConnection *gc) |
1686 { | 1686 { |
1687 struct simple_account_data *sip = gc->proto_data; | 1687 struct simple_account_data *sip = gc->proto_data; |
1688 | 1688 |
1689 if(sip) { | 1689 if(sip) { |
1690 /* unregister */ | 1690 /* unregister */ |
1691 do_register_exp(sip, 0); | 1691 do_register_exp(sip, 0); |
1692 connection_free_all(sip); | 1692 connection_free_all(sip); |
1693 | 1693 |
1694 if (sip->query_data != NULL) | 1694 if (sip->query_data != NULL) |
1695 gaim_dnsquery_destroy(sip->query_data); | 1695 purple_dnsquery_destroy(sip->query_data); |
1696 | 1696 |
1697 if (sip->srv_query_data != NULL) | 1697 if (sip->srv_query_data != NULL) |
1698 gaim_srv_cancel(sip->srv_query_data); | 1698 purple_srv_cancel(sip->srv_query_data); |
1699 | 1699 |
1700 if (sip->listen_data != NULL) | 1700 if (sip->listen_data != NULL) |
1701 gaim_network_listen_cancel(sip->listen_data); | 1701 purple_network_listen_cancel(sip->listen_data); |
1702 | 1702 |
1703 g_free(sip->servername); | 1703 g_free(sip->servername); |
1704 g_free(sip->username); | 1704 g_free(sip->username); |
1705 g_free(sip->password); | 1705 g_free(sip->password); |
1706 g_free(sip->registrar.nonce); | 1706 g_free(sip->registrar.nonce); |
1712 g_free(sip->proxy.opaque); | 1712 g_free(sip->proxy.opaque); |
1713 g_free(sip->proxy.target); | 1713 g_free(sip->proxy.target); |
1714 g_free(sip->proxy.realm); | 1714 g_free(sip->proxy.realm); |
1715 g_free(sip->proxy.digest_session_key); | 1715 g_free(sip->proxy.digest_session_key); |
1716 if(sip->txbuf) | 1716 if(sip->txbuf) |
1717 gaim_circ_buffer_destroy(sip->txbuf); | 1717 purple_circ_buffer_destroy(sip->txbuf); |
1718 g_free(sip->realhostname); | 1718 g_free(sip->realhostname); |
1719 if(sip->listenpa) gaim_input_remove(sip->listenpa); | 1719 if(sip->listenpa) purple_input_remove(sip->listenpa); |
1720 if(sip->tx_handler) gaim_input_remove(sip->tx_handler); | 1720 if(sip->tx_handler) purple_input_remove(sip->tx_handler); |
1721 if(sip->resendtimeout) gaim_timeout_remove(sip->resendtimeout); | 1721 if(sip->resendtimeout) purple_timeout_remove(sip->resendtimeout); |
1722 if(sip->registertimeout) gaim_timeout_remove(sip->registertimeout); | 1722 if(sip->registertimeout) purple_timeout_remove(sip->registertimeout); |
1723 } | 1723 } |
1724 g_free(gc->proto_data); | 1724 g_free(gc->proto_data); |
1725 gc->proto_data = NULL; | 1725 gc->proto_data = NULL; |
1726 } | 1726 } |
1727 | 1727 |
1728 /* not needed since privacy is checked for every subscribe */ | 1728 /* not needed since privacy is checked for every subscribe */ |
1729 static void dummy_add_deny(GaimConnection *gc, const char *name) { | 1729 static void dummy_add_deny(PurpleConnection *gc, const char *name) { |
1730 } | 1730 } |
1731 | 1731 |
1732 static void dummy_permit_deny(GaimConnection *gc) { | 1732 static void dummy_permit_deny(PurpleConnection *gc) { |
1733 } | 1733 } |
1734 | 1734 |
1735 static GaimPluginProtocolInfo prpl_info = | 1735 static PurplePluginProtocolInfo prpl_info = |
1736 { | 1736 { |
1737 0, | 1737 0, |
1738 NULL, /* user_splits */ | 1738 NULL, /* user_splits */ |
1739 NULL, /* protocol_options */ | 1739 NULL, /* protocol_options */ |
1740 NO_BUDDY_ICONS, /* icon_spec */ | 1740 NO_BUDDY_ICONS, /* icon_spec */ |
1797 simple_send_raw, /* send_raw */ | 1797 simple_send_raw, /* send_raw */ |
1798 NULL, /* roomlist_room_serialize */ | 1798 NULL, /* roomlist_room_serialize */ |
1799 }; | 1799 }; |
1800 | 1800 |
1801 | 1801 |
1802 static GaimPluginInfo info = | 1802 static PurplePluginInfo info = |
1803 { | 1803 { |
1804 GAIM_PLUGIN_MAGIC, | 1804 PURPLE_PLUGIN_MAGIC, |
1805 GAIM_MAJOR_VERSION, | 1805 PURPLE_MAJOR_VERSION, |
1806 GAIM_MINOR_VERSION, | 1806 PURPLE_MINOR_VERSION, |
1807 GAIM_PLUGIN_PROTOCOL, /**< type */ | 1807 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
1808 NULL, /**< ui_requirement */ | 1808 NULL, /**< ui_requirement */ |
1809 0, /**< flags */ | 1809 0, /**< flags */ |
1810 NULL, /**< dependencies */ | 1810 NULL, /**< dependencies */ |
1811 GAIM_PRIORITY_DEFAULT, /**< priority */ | 1811 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
1812 | 1812 |
1813 "prpl-simple", /**< id */ | 1813 "prpl-simple", /**< id */ |
1814 "SIMPLE", /**< name */ | 1814 "SIMPLE", /**< name */ |
1815 VERSION, /**< version */ | 1815 VERSION, /**< version */ |
1816 N_("SIP/SIMPLE Protocol Plugin"), /** summary */ | 1816 N_("SIP/SIMPLE Protocol Plugin"), /** summary */ |
1817 N_("The SIP/SIMPLE Protocol Plugin"), /** description */ | 1817 N_("The SIP/SIMPLE Protocol Plugin"), /** description */ |
1818 "Thomas Butter <butter@uni-mannheim.de>", /**< author */ | 1818 "Thomas Butter <butter@uni-mannheim.de>", /**< author */ |
1819 GAIM_WEBSITE, /**< homepage */ | 1819 PURPLE_WEBSITE, /**< homepage */ |
1820 | 1820 |
1821 NULL, /**< load */ | 1821 NULL, /**< load */ |
1822 NULL, /**< unload */ | 1822 NULL, /**< unload */ |
1823 NULL, /**< destroy */ | 1823 NULL, /**< destroy */ |
1824 | 1824 |
1826 &prpl_info, /**< extra_info */ | 1826 &prpl_info, /**< extra_info */ |
1827 NULL, | 1827 NULL, |
1828 NULL | 1828 NULL |
1829 }; | 1829 }; |
1830 | 1830 |
1831 static void _init_plugin(GaimPlugin *plugin) | 1831 static void _init_plugin(PurplePlugin *plugin) |
1832 { | 1832 { |
1833 GaimAccountUserSplit *split; | 1833 PurpleAccountUserSplit *split; |
1834 GaimAccountOption *option; | 1834 PurpleAccountOption *option; |
1835 | 1835 |
1836 split = gaim_account_user_split_new(_("Server"), "", '@'); | 1836 split = purple_account_user_split_new(_("Server"), "", '@'); |
1837 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); | 1837 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
1838 | 1838 |
1839 option = gaim_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "dopublish", TRUE); | 1839 option = purple_account_option_bool_new(_("Publish status (note: everyone may watch you)"), "dopublish", TRUE); |
1840 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1840 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1841 | 1841 |
1842 option = gaim_account_option_int_new(_("Connect port"), "port", 0); | 1842 option = purple_account_option_int_new(_("Connect port"), "port", 0); |
1843 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1843 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1844 | 1844 |
1845 option = gaim_account_option_bool_new(_("Use UDP"), "udp", FALSE); | 1845 option = purple_account_option_bool_new(_("Use UDP"), "udp", FALSE); |
1846 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1846 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1847 option = gaim_account_option_bool_new(_("Use proxy"), "useproxy", FALSE); | 1847 option = purple_account_option_bool_new(_("Use proxy"), "useproxy", FALSE); |
1848 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1848 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1849 option = gaim_account_option_string_new(_("Proxy"), "proxy", ""); | 1849 option = purple_account_option_string_new(_("Proxy"), "proxy", ""); |
1850 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1850 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1851 option = gaim_account_option_string_new(_("Auth User"), "authuser", ""); | 1851 option = purple_account_option_string_new(_("Auth User"), "authuser", ""); |
1852 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1852 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1853 option = gaim_account_option_string_new(_("Auth Domain"), "authdomain", ""); | 1853 option = purple_account_option_string_new(_("Auth Domain"), "authdomain", ""); |
1854 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | 1854 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
1855 } | 1855 } |
1856 | 1856 |
1857 GAIM_INIT_PLUGIN(simple, _init_plugin, info); | 1857 PURPLE_INIT_PLUGIN(simple, _init_plugin, info); |