Mercurial > pidgin
comparison libpurple/protocols/bonjour/jabber.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 71b017348c39 |
children | 7ade887fd3f6 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * gaim - Bonjour Protocol Plugin | 2 * purple - Bonjour Protocol Plugin |
3 * | 3 * |
4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | 6 * source distribution. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
44 #include "jabber.h" | 44 #include "jabber.h" |
45 #include "bonjour.h" | 45 #include "bonjour.h" |
46 #include "buddy.h" | 46 #include "buddy.h" |
47 | 47 |
48 static gint | 48 static gint |
49 _connect_to_buddy(GaimBuddy *gb) | 49 _connect_to_buddy(PurpleBuddy *gb) |
50 { | 50 { |
51 gint socket_fd; | 51 gint socket_fd; |
52 gint retorno = 0; | 52 gint retorno = 0; |
53 struct sockaddr_in buddy_address; | 53 struct sockaddr_in buddy_address; |
54 | 54 |
60 inet_aton(((BonjourBuddy*)(gb->proto_data))->ip, &(buddy_address.sin_addr)); | 60 inet_aton(((BonjourBuddy*)(gb->proto_data))->ip, &(buddy_address.sin_addr)); |
61 memset(&(buddy_address.sin_zero), '\0', 8); | 61 memset(&(buddy_address.sin_zero), '\0', 8); |
62 | 62 |
63 retorno = connect(socket_fd, (struct sockaddr*)&buddy_address, sizeof(struct sockaddr)); | 63 retorno = connect(socket_fd, (struct sockaddr*)&buddy_address, sizeof(struct sockaddr)); |
64 if (retorno == -1) { | 64 if (retorno == -1) { |
65 gaim_debug_warning("bonjour", "connect error: %s\n", strerror(errno)); | 65 purple_debug_warning("bonjour", "connect error: %s\n", strerror(errno)); |
66 } | 66 } |
67 fcntl(socket_fd, F_SETFL, O_NONBLOCK); | 67 fcntl(socket_fd, F_SETFL, O_NONBLOCK); |
68 | 68 |
69 return socket_fd; | 69 return socket_fd; |
70 } | 70 } |
71 | 71 |
72 #if 0 /* this isn't used anywhere... */ | 72 #if 0 /* this isn't used anywhere... */ |
73 static const char * | 73 static const char * |
74 _font_size_gaim_to_ichat(int size) | 74 _font_size_purple_to_ichat(int size) |
75 { | 75 { |
76 switch (size) { | 76 switch (size) { |
77 case 1: | 77 case 1: |
78 return "8"; | 78 return "8"; |
79 case 2: | 79 case 2: |
93 return "12"; | 93 return "12"; |
94 } | 94 } |
95 #endif | 95 #endif |
96 | 96 |
97 static const char * | 97 static const char * |
98 _font_size_ichat_to_gaim(int size) | 98 _font_size_ichat_to_purple(int size) |
99 { | 99 { |
100 if (size > 24) { | 100 if (size > 24) { |
101 return "7"; | 101 return "7"; |
102 } else if (size >= 21) { | 102 } else if (size >= 21) { |
103 return "6"; | 103 return "6"; |
112 } | 112 } |
113 | 113 |
114 return "1"; | 114 return "1"; |
115 } | 115 } |
116 static void | 116 static void |
117 _jabber_parse_and_write_message_to_ui(char *message, GaimConnection *connection, GaimBuddy *gb) | 117 _jabber_parse_and_write_message_to_ui(char *message, PurpleConnection *connection, PurpleBuddy *gb) |
118 { | 118 { |
119 xmlnode *body_node = NULL; | 119 xmlnode *body_node = NULL; |
120 char *body = NULL; | 120 char *body = NULL; |
121 xmlnode *html_node = NULL; | 121 xmlnode *html_node = NULL; |
122 gboolean isHTML = FALSE; | 122 gboolean isHTML = FALSE; |
161 font_face = xmlnode_get_attrib(html_body_font_node, "face"); | 161 font_face = xmlnode_get_attrib(html_body_font_node, "face"); |
162 /* The absolute iChat font sizes should be converted to 1..7 range */ | 162 /* The absolute iChat font sizes should be converted to 1..7 range */ |
163 font_size = xmlnode_get_attrib(html_body_font_node, "ABSZ"); | 163 font_size = xmlnode_get_attrib(html_body_font_node, "ABSZ"); |
164 if (font_size != NULL) | 164 if (font_size != NULL) |
165 { | 165 { |
166 font_size = _font_size_ichat_to_gaim(atoi(font_size)); | 166 font_size = _font_size_ichat_to_purple(atoi(font_size)); |
167 } | 167 } |
168 font_color = xmlnode_get_attrib(html_body_font_node, "color"); | 168 font_color = xmlnode_get_attrib(html_body_font_node, "color"); |
169 html_body = xmlnode_get_data(html_body_font_node); | 169 html_body = xmlnode_get_data(html_body_font_node); |
170 if (html_body == NULL) | 170 if (html_body == NULL) |
171 { | 171 { |
172 /* This is the kind of formated messages that Gaim creates */ | 172 /* This is the kind of formated messages that Purple creates */ |
173 html_body = xmlnode_to_str(html_body_font_node, &garbage); | 173 html_body = xmlnode_to_str(html_body_font_node, &garbage); |
174 } | 174 } |
175 } else { | 175 } else { |
176 isHTML = FALSE; | 176 isHTML = FALSE; |
177 } | 177 } |
218 g_free(html_body); | 218 g_free(html_body); |
219 } | 219 } |
220 | 220 |
221 struct _check_buddy_by_address_t { | 221 struct _check_buddy_by_address_t { |
222 char *address; | 222 char *address; |
223 GaimBuddy **gb; | 223 PurpleBuddy **gb; |
224 BonjourJabber *bj; | 224 BonjourJabber *bj; |
225 }; | 225 }; |
226 | 226 |
227 static void | 227 static void |
228 _check_buddy_by_address(gpointer key, gpointer value, gpointer data) | 228 _check_buddy_by_address(gpointer key, gpointer value, gpointer data) |
229 { | 229 { |
230 GaimBuddy *gb = (GaimBuddy*)value; | 230 PurpleBuddy *gb = (PurpleBuddy*)value; |
231 BonjourBuddy *bb; | 231 BonjourBuddy *bb; |
232 struct _check_buddy_by_address_t *cbba; | 232 struct _check_buddy_by_address_t *cbba; |
233 | 233 |
234 gb = value; | 234 gb = value; |
235 cbba = data; | 235 cbba = data; |
236 | 236 |
237 /* | 237 /* |
238 * If the current GaimBuddy's data is not null and the GaimBuddy's account | 238 * If the current PurpleBuddy's data is not null and the PurpleBuddy's account |
239 * is the same as the account requesting the check then continue to determine | 239 * is the same as the account requesting the check then continue to determine |
240 * whether the buddies IP matches the target IP. | 240 * whether the buddies IP matches the target IP. |
241 */ | 241 */ |
242 if (cbba->bj->account == gb->account) | 242 if (cbba->bj->account == gb->account) |
243 { | 243 { |
262 total_message_length += partial_message_length; | 262 total_message_length += partial_message_length; |
263 } | 263 } |
264 | 264 |
265 if (partial_message_length == -1) | 265 if (partial_message_length == -1) |
266 { | 266 { |
267 gaim_debug_warning("bonjour", "receive error: %s\n", strerror(errno)); | 267 purple_debug_warning("bonjour", "receive error: %s\n", strerror(errno)); |
268 if (total_message_length == 0) { | 268 if (total_message_length == 0) { |
269 return -1; | 269 return -1; |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 *message = data->str; | 273 *message = data->str; |
274 g_string_free(data, FALSE); | 274 g_string_free(data, FALSE); |
275 if (total_message_length != 0) | 275 if (total_message_length != 0) |
276 gaim_debug_info("bonjour", "Receive: -%s- %d bytes\n", *message, total_message_length); | 276 purple_debug_info("bonjour", "Receive: -%s- %d bytes\n", *message, total_message_length); |
277 | 277 |
278 return total_message_length; | 278 return total_message_length; |
279 } | 279 } |
280 | 280 |
281 static gint | 281 static gint |
297 | 297 |
298 return strlen(message); | 298 return strlen(message); |
299 } | 299 } |
300 | 300 |
301 static void | 301 static void |
302 _client_socket_handler(gpointer data, gint socket, GaimInputCondition condition) | 302 _client_socket_handler(gpointer data, gint socket, PurpleInputCondition condition) |
303 { | 303 { |
304 char *message = NULL; | 304 char *message = NULL; |
305 gint message_length; | 305 gint message_length; |
306 GaimBuddy *gb = (GaimBuddy*)data; | 306 PurpleBuddy *gb = (PurpleBuddy*)data; |
307 GaimAccount *account = gb->account; | 307 PurpleAccount *account = gb->account; |
308 GaimConversation *conversation; | 308 PurpleConversation *conversation; |
309 char *closed_conv_message; | 309 char *closed_conv_message; |
310 BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data; | 310 BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data; |
311 gboolean closed_conversation = FALSE; | 311 gboolean closed_conversation = FALSE; |
312 xmlnode *message_node = NULL; | 312 xmlnode *message_node = NULL; |
313 | 313 |
343 else | 343 else |
344 { | 344 { |
345 /* TODO: This needs to be nonblocking! */ | 345 /* TODO: This needs to be nonblocking! */ |
346 if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1) | 346 if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1) |
347 { | 347 { |
348 gaim_debug_error("bonjour", "Unable to start a conversation with %s\n", bb->name); | 348 purple_debug_error("bonjour", "Unable to start a conversation with %s\n", bb->name); |
349 } | 349 } |
350 else | 350 else |
351 { | 351 { |
352 bb->conversation->stream_started = TRUE; | 352 bb->conversation->stream_started = TRUE; |
353 } | 353 } |
357 /* | 357 /* |
358 * Check that this is not the end of the conversation. This is | 358 * Check that this is not the end of the conversation. This is |
359 * using a magic string, but xmlnode won't play nice when just | 359 * using a magic string, but xmlnode won't play nice when just |
360 * parsing an end tag | 360 * parsing an end tag |
361 */ | 361 */ |
362 if (gaim_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) { | 362 if (purple_str_has_prefix(message, STREAM_END) || (closed_conversation == TRUE)) { |
363 /* Close the socket, clear the watcher and free memory */ | 363 /* Close the socket, clear the watcher and free memory */ |
364 if (bb->conversation != NULL) { | 364 if (bb->conversation != NULL) { |
365 close(bb->conversation->socket); | 365 close(bb->conversation->socket); |
366 gaim_input_remove(bb->conversation->watcher_id); | 366 purple_input_remove(bb->conversation->watcher_id); |
367 g_free(bb->conversation->buddy_name); | 367 g_free(bb->conversation->buddy_name); |
368 g_free(bb->conversation); | 368 g_free(bb->conversation); |
369 bb->conversation = NULL; | 369 bb->conversation = NULL; |
370 } | 370 } |
371 | 371 |
372 /* Inform the user that the conversation has been closed */ | 372 /* Inform the user that the conversation has been closed */ |
373 conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, gb->name, account); | 373 conversation = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, gb->name, account); |
374 closed_conv_message = g_strdup_printf(_("%s has closed the conversation."), gb->name); | 374 closed_conv_message = g_strdup_printf(_("%s has closed the conversation."), gb->name); |
375 gaim_conversation_write(conversation, NULL, closed_conv_message, GAIM_MESSAGE_SYSTEM, time(NULL)); | 375 purple_conversation_write(conversation, NULL, closed_conv_message, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
376 g_free(closed_conv_message); | 376 g_free(closed_conv_message); |
377 } else { | 377 } else { |
378 /* Parse the message to get the data and send to the ui */ | 378 /* Parse the message to get the data and send to the ui */ |
379 _jabber_parse_and_write_message_to_ui(message, account->gc, gb); | 379 _jabber_parse_and_write_message_to_ui(message, account->gc, gb); |
380 } | 380 } |
382 if (message_node != NULL) | 382 if (message_node != NULL) |
383 xmlnode_free(message_node); | 383 xmlnode_free(message_node); |
384 } | 384 } |
385 | 385 |
386 static void | 386 static void |
387 _server_socket_handler(gpointer data, int server_socket, GaimInputCondition condition) | 387 _server_socket_handler(gpointer data, int server_socket, PurpleInputCondition condition) |
388 { | 388 { |
389 GaimBuddy *gb = NULL; | 389 PurpleBuddy *gb = NULL; |
390 struct sockaddr_in their_addr; /* connector's address information */ | 390 struct sockaddr_in their_addr; /* connector's address information */ |
391 socklen_t sin_size = sizeof(struct sockaddr); | 391 socklen_t sin_size = sizeof(struct sockaddr); |
392 int client_socket; | 392 int client_socket; |
393 BonjourBuddy *bb = NULL; | 393 BonjourBuddy *bb = NULL; |
394 BonjourJabber *bj = data; | 394 BonjourJabber *bj = data; |
395 char *address_text = NULL; | 395 char *address_text = NULL; |
396 GaimBuddyList *bl = gaim_get_blist(); | 396 PurpleBuddyList *bl = purple_get_blist(); |
397 struct _check_buddy_by_address_t *cbba; | 397 struct _check_buddy_by_address_t *cbba; |
398 | 398 |
399 /* Check that it is a read condition */ | 399 /* Check that it is a read condition */ |
400 if (condition != GAIM_INPUT_READ) { | 400 if (condition != PURPLE_INPUT_READ) { |
401 return; | 401 return; |
402 } | 402 } |
403 | 403 |
404 if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1) | 404 if ((client_socket = accept(server_socket, (struct sockaddr *)&their_addr, &sin_size)) == -1) |
405 { | 405 { |
415 cbba->bj = bj; | 415 cbba->bj = bj; |
416 g_hash_table_foreach(bl->buddies, _check_buddy_by_address, cbba); | 416 g_hash_table_foreach(bl->buddies, _check_buddy_by_address, cbba); |
417 g_free(cbba); | 417 g_free(cbba); |
418 if (gb == NULL) | 418 if (gb == NULL) |
419 { | 419 { |
420 gaim_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n"); | 420 purple_debug_info("bonjour", "We don't like invisible buddies, this is not a superheros comic\n"); |
421 close(client_socket); | 421 close(client_socket); |
422 return; | 422 return; |
423 } | 423 } |
424 bb = (BonjourBuddy*)gb->proto_data; | 424 bb = (BonjourBuddy*)gb->proto_data; |
425 | 425 |
437 send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0); | 437 send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0); |
438 bb->conversation->stream_started = TRUE; | 438 bb->conversation->stream_started = TRUE; |
439 } | 439 } |
440 | 440 |
441 /* Open a watcher for the client socket */ | 441 /* Open a watcher for the client socket */ |
442 bb->conversation->watcher_id = gaim_input_add(client_socket, GAIM_INPUT_READ, | 442 bb->conversation->watcher_id = purple_input_add(client_socket, PURPLE_INPUT_READ, |
443 _client_socket_handler, gb); | 443 _client_socket_handler, gb); |
444 } else { | 444 } else { |
445 close(client_socket); | 445 close(client_socket); |
446 } | 446 } |
447 } | 447 } |
455 gboolean bind_successful; | 455 gboolean bind_successful; |
456 | 456 |
457 /* Open a listening socket for incoming conversations */ | 457 /* Open a listening socket for incoming conversations */ |
458 if ((data->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0) | 458 if ((data->socket = socket(PF_INET, SOCK_STREAM, 0)) < 0) |
459 { | 459 { |
460 gaim_debug_error("bonjour", "Cannot open socket: %s\n", strerror(errno)); | 460 purple_debug_error("bonjour", "Cannot open socket: %s\n", strerror(errno)); |
461 gaim_connection_error(data->account->gc, _("Cannot open socket")); | 461 purple_connection_error(data->account->gc, _("Cannot open socket")); |
462 return -1; | 462 return -1; |
463 } | 463 } |
464 | 464 |
465 /* Make the socket reusable */ | 465 /* Make the socket reusable */ |
466 if (setsockopt(data->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0) | 466 if (setsockopt(data->socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) != 0) |
467 { | 467 { |
468 gaim_debug_error("bonjour", "Error setting socket options: %s\n", strerror(errno)); | 468 purple_debug_error("bonjour", "Error setting socket options: %s\n", strerror(errno)); |
469 gaim_connection_error(data->account->gc, _("Error setting socket options")); | 469 purple_connection_error(data->account->gc, _("Error setting socket options")); |
470 return -1; | 470 return -1; |
471 } | 471 } |
472 | 472 |
473 memset(&my_addr, 0, sizeof(struct sockaddr_in)); | 473 memset(&my_addr, 0, sizeof(struct sockaddr_in)); |
474 my_addr.sin_family = PF_INET; | 474 my_addr.sin_family = PF_INET; |
487 } | 487 } |
488 | 488 |
489 /* On no! We tried 10 ports and could not bind to ANY of them */ | 489 /* On no! We tried 10 ports and could not bind to ANY of them */ |
490 if (!bind_successful) | 490 if (!bind_successful) |
491 { | 491 { |
492 gaim_debug_error("bonjour", "Cannot bind socket: %s\n", strerror(errno)); | 492 purple_debug_error("bonjour", "Cannot bind socket: %s\n", strerror(errno)); |
493 gaim_connection_error(data->account->gc, _("Could not bind socket to port")); | 493 purple_connection_error(data->account->gc, _("Could not bind socket to port")); |
494 return -1; | 494 return -1; |
495 } | 495 } |
496 | 496 |
497 /* Attempt to listen on the bound socket */ | 497 /* Attempt to listen on the bound socket */ |
498 if (listen(data->socket, 10) != 0) | 498 if (listen(data->socket, 10) != 0) |
499 { | 499 { |
500 gaim_debug_error("bonjour", "Cannot listen on socket: %s\n", strerror(errno)); | 500 purple_debug_error("bonjour", "Cannot listen on socket: %s\n", strerror(errno)); |
501 gaim_connection_error(data->account->gc, _("Could not listen on socket")); | 501 purple_connection_error(data->account->gc, _("Could not listen on socket")); |
502 return -1; | 502 return -1; |
503 } | 503 } |
504 | 504 |
505 #if 0 | 505 #if 0 |
506 /* TODO: Why isn't this being used? */ | 506 /* TODO: Why isn't this being used? */ |
507 data->socket = gaim_network_listen(data->port, SOCK_STREAM); | 507 data->socket = purple_network_listen(data->port, SOCK_STREAM); |
508 | 508 |
509 if (data->socket == -1) | 509 if (data->socket == -1) |
510 { | 510 { |
511 gaim_debug_error("bonjour", "No se ha podido crear el socket\n"); | 511 purple_debug_error("bonjour", "No se ha podido crear el socket\n"); |
512 } | 512 } |
513 #endif | 513 #endif |
514 | 514 |
515 /* Open a watcher in the socket we have just opened */ | 515 /* Open a watcher in the socket we have just opened */ |
516 data->watcher_id = gaim_input_add(data->socket, GAIM_INPUT_READ, _server_socket_handler, data); | 516 data->watcher_id = purple_input_add(data->socket, PURPLE_INPUT_READ, _server_socket_handler, data); |
517 | 517 |
518 return data->port; | 518 return data->port; |
519 } | 519 } |
520 | 520 |
521 int | 521 int |
527 xmlnode *message_body_node = NULL; | 527 xmlnode *message_body_node = NULL; |
528 xmlnode *message_html_node = NULL; | 528 xmlnode *message_html_node = NULL; |
529 xmlnode *message_html_body_node = NULL; | 529 xmlnode *message_html_body_node = NULL; |
530 xmlnode *message_html_body_font_node = NULL; | 530 xmlnode *message_html_body_font_node = NULL; |
531 xmlnode *message_x_node = NULL; | 531 xmlnode *message_x_node = NULL; |
532 GaimBuddy *gb = NULL; | 532 PurpleBuddy *gb = NULL; |
533 BonjourBuddy *bb = NULL; | 533 BonjourBuddy *bb = NULL; |
534 GaimConversation *conversation = NULL; | 534 PurpleConversation *conversation = NULL; |
535 char *message_from_ui = NULL; | 535 char *message_from_ui = NULL; |
536 char *stripped_message = NULL; | 536 char *stripped_message = NULL; |
537 gint ret; | 537 gint ret; |
538 | 538 |
539 gb = gaim_find_buddy(data->account, to); | 539 gb = purple_find_buddy(data->account, to); |
540 if (gb == NULL) | 540 if (gb == NULL) |
541 /* You can not send a message to an offline buddy */ | 541 /* You can not send a message to an offline buddy */ |
542 return -10000; | 542 return -10000; |
543 | 543 |
544 bb = (BonjourBuddy *)gb->proto_data; | 544 bb = (BonjourBuddy *)gb->proto_data; |
545 | 545 |
546 /* Enclose the message from the UI within a "font" node */ | 546 /* Enclose the message from the UI within a "font" node */ |
547 message_body_node = xmlnode_new("body"); | 547 message_body_node = xmlnode_new("body"); |
548 stripped_message = gaim_markup_strip_html(body); | 548 stripped_message = purple_markup_strip_html(body); |
549 xmlnode_insert_data(message_body_node, stripped_message, strlen(stripped_message)); | 549 xmlnode_insert_data(message_body_node, stripped_message, strlen(stripped_message)); |
550 g_free(stripped_message); | 550 g_free(stripped_message); |
551 | 551 |
552 message_from_ui = g_strconcat("<font>", body, "</font>", NULL); | 552 message_from_ui = g_strconcat("<font>", body, "</font>", NULL); |
553 message_html_body_font_node = xmlnode_from_str(message_from_ui, strlen(message_from_ui)); | 553 message_html_body_font_node = xmlnode_from_str(message_from_ui, strlen(message_from_ui)); |
580 { | 580 { |
581 bb->conversation = g_new(BonjourJabberConversation, 1); | 581 bb->conversation = g_new(BonjourJabberConversation, 1); |
582 bb->conversation->socket = _connect_to_buddy(gb); | 582 bb->conversation->socket = _connect_to_buddy(gb); |
583 bb->conversation->stream_started = FALSE; | 583 bb->conversation->stream_started = FALSE; |
584 bb->conversation->buddy_name = g_strdup(gb->name); | 584 bb->conversation->buddy_name = g_strdup(gb->name); |
585 bb->conversation->watcher_id = gaim_input_add(bb->conversation->socket, | 585 bb->conversation->watcher_id = purple_input_add(bb->conversation->socket, |
586 GAIM_INPUT_READ, _client_socket_handler, gb); | 586 PURPLE_INPUT_READ, _client_socket_handler, gb); |
587 } | 587 } |
588 | 588 |
589 /* Check if the stream for the conversation has been started */ | 589 /* Check if the stream for the conversation has been started */ |
590 if (bb->conversation->stream_started == FALSE) | 590 if (bb->conversation->stream_started == FALSE) |
591 { | 591 { |
592 /* Start the stream */ | 592 /* Start the stream */ |
593 if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1) | 593 if (send(bb->conversation->socket, DOCTYPE, strlen(DOCTYPE), 0) == -1) |
594 { | 594 { |
595 gaim_debug_error("bonjour", "Unable to start a conversation\n"); | 595 purple_debug_error("bonjour", "Unable to start a conversation\n"); |
596 gaim_debug_warning("bonjour", "send error: %s\n", strerror(errno)); | 596 purple_debug_warning("bonjour", "send error: %s\n", strerror(errno)); |
597 conversation = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, bb->name, data->account); | 597 conversation = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, bb->name, data->account); |
598 gaim_conversation_write(conversation, NULL, | 598 purple_conversation_write(conversation, NULL, |
599 _("Unable to send the message, the conversation couldn't be started."), | 599 _("Unable to send the message, the conversation couldn't be started."), |
600 GAIM_MESSAGE_SYSTEM, time(NULL)); | 600 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
601 close(bb->conversation->socket); | 601 close(bb->conversation->socket); |
602 gaim_input_remove(bb->conversation->watcher_id); | 602 purple_input_remove(bb->conversation->watcher_id); |
603 | 603 |
604 /* Free all the data related to the conversation */ | 604 /* Free all the data related to the conversation */ |
605 g_free(bb->conversation->buddy_name); | 605 g_free(bb->conversation->buddy_name); |
606 g_free(bb->conversation); | 606 g_free(bb->conversation); |
607 bb->conversation = NULL; | 607 bb->conversation = NULL; |
621 | 621 |
622 return 1; | 622 return 1; |
623 } | 623 } |
624 | 624 |
625 void | 625 void |
626 bonjour_jabber_close_conversation(BonjourJabber *data, GaimBuddy *gb) | 626 bonjour_jabber_close_conversation(BonjourJabber *data, PurpleBuddy *gb) |
627 { | 627 { |
628 BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data; | 628 BonjourBuddy *bb = (BonjourBuddy*)gb->proto_data; |
629 | 629 |
630 if (bb->conversation != NULL) | 630 if (bb->conversation != NULL) |
631 { | 631 { |
632 /* Send the end of the stream to the other end of the conversation */ | 632 /* Send the end of the stream to the other end of the conversation */ |
633 send(bb->conversation->socket, STREAM_END, strlen(STREAM_END), 0); | 633 send(bb->conversation->socket, STREAM_END, strlen(STREAM_END), 0); |
634 | 634 |
635 /* Close the socket and remove the watcher */ | 635 /* Close the socket and remove the watcher */ |
636 close(bb->conversation->socket); | 636 close(bb->conversation->socket); |
637 gaim_input_remove(bb->conversation->watcher_id); | 637 purple_input_remove(bb->conversation->watcher_id); |
638 | 638 |
639 /* Free all the data related to the conversation */ | 639 /* Free all the data related to the conversation */ |
640 g_free(bb->conversation->buddy_name); | 640 g_free(bb->conversation->buddy_name); |
641 g_free(bb->conversation); | 641 g_free(bb->conversation); |
642 bb->conversation = NULL; | 642 bb->conversation = NULL; |
644 } | 644 } |
645 | 645 |
646 void | 646 void |
647 bonjour_jabber_stop(BonjourJabber *data) | 647 bonjour_jabber_stop(BonjourJabber *data) |
648 { | 648 { |
649 GaimBuddy *gb = NULL; | 649 PurpleBuddy *gb = NULL; |
650 BonjourBuddy *bb = NULL; | 650 BonjourBuddy *bb = NULL; |
651 GSList *buddies; | 651 GSList *buddies; |
652 GSList *l; | 652 GSList *l; |
653 | 653 |
654 /* Close the server socket and remove all the watcher */ | 654 /* Close the server socket and remove all the watcher */ |
655 close(data->socket); | 655 close(data->socket); |
656 gaim_input_remove(data->watcher_id); | 656 purple_input_remove(data->watcher_id); |
657 | 657 |
658 /* Close all the sockets and remove all the watchers after sending end streams */ | 658 /* Close all the sockets and remove all the watchers after sending end streams */ |
659 if (data->account->gc != NULL) | 659 if (data->account->gc != NULL) |
660 { | 660 { |
661 buddies = gaim_find_buddies(data->account, data->account->username); | 661 buddies = purple_find_buddies(data->account, data->account->username); |
662 for (l = buddies; l; l = l->next) | 662 for (l = buddies; l; l = l->next) |
663 { | 663 { |
664 gb = (GaimBuddy*)l->data; | 664 gb = (PurpleBuddy*)l->data; |
665 bb = (BonjourBuddy*)gb->proto_data; | 665 bb = (BonjourBuddy*)gb->proto_data; |
666 if (bb->conversation != NULL) | 666 if (bb->conversation != NULL) |
667 { | 667 { |
668 send(bb->conversation->socket, STREAM_END, strlen(STREAM_END), 0); | 668 send(bb->conversation->socket, STREAM_END, strlen(STREAM_END), 0); |
669 close(bb->conversation->socket); | 669 close(bb->conversation->socket); |
670 gaim_input_remove(bb->conversation->watcher_id); | 670 purple_input_remove(bb->conversation->watcher_id); |
671 } | 671 } |
672 } | 672 } |
673 g_slist_free(buddies); | 673 g_slist_free(buddies); |
674 } | 674 } |
675 } | 675 } |