Mercurial > pidgin
comparison libpurple/protocols/jabber/jabber.c @ 26470:4f14455a86d2
propagate from branch 'im.pidgin.pidgin' (head f25348fdce436002d7d508f074aaa70fd9491f01)
to branch 'im.pidgin.cpw.darkrain42.xmpp.iq-handlers' (head 33f84ea59a9e7afb3a03806268589ea49622326a)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 03 Apr 2009 16:45:38 +0000 |
parents | ae41d8e827e3 da651b0f40a1 |
children | 8399b545925c |
comparison
equal
deleted
inserted
replaced
26469:00870e5f2e90 | 26470:4f14455a86d2 |
---|---|
57 #include "si.h" | 57 #include "si.h" |
58 #include "xdata.h" | 58 #include "xdata.h" |
59 #include "pep.h" | 59 #include "pep.h" |
60 #include "adhoccommands.h" | 60 #include "adhoccommands.h" |
61 | 61 |
62 #include "jingle/jingle.h" | |
63 #include "jingle/rtp.h" | |
62 | 64 |
63 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) | 65 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) |
64 | 66 |
65 static PurplePlugin *my_protocol = NULL; | 67 static PurplePlugin *my_protocol = NULL; |
66 GList *jabber_features = NULL; | 68 GList *jabber_features = NULL; |
717 js->next_id = g_random_int(); | 719 js->next_id = g_random_int(); |
718 js->write_buffer = purple_circ_buffer_new(512); | 720 js->write_buffer = purple_circ_buffer_new(512); |
719 js->old_length = 0; | 721 js->old_length = 0; |
720 js->keepalive_timeout = -1; | 722 js->keepalive_timeout = -1; |
721 js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user ? js->user->domain : NULL); | 723 js->certificate_CN = g_strdup(connect_server[0] ? connect_server : js->user ? js->user->domain : NULL); |
724 js->sessions = NULL; | |
725 js->stun_ip = NULL; | |
726 js->stun_port = 0; | |
727 js->stun_query = NULL; | |
722 | 728 |
723 if(!js->user) { | 729 if(!js->user) { |
724 purple_connection_error_reason (gc, | 730 purple_connection_error_reason (gc, |
725 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | 731 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
726 _("Invalid XMPP ID")); | 732 _("Invalid XMPP ID")); |
1212 my_jb->subscription |= JABBER_SUB_BOTH; | 1218 my_jb->subscription |= JABBER_SUB_BOTH; |
1213 | 1219 |
1214 server = connect_server[0] ? connect_server : js->user->domain; | 1220 server = connect_server[0] ? connect_server : js->user->domain; |
1215 js->certificate_CN = g_strdup(server); | 1221 js->certificate_CN = g_strdup(server); |
1216 | 1222 |
1223 js->stun_ip = NULL; | |
1224 js->stun_port = 0; | |
1225 js->stun_query = NULL; | |
1226 | |
1217 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | 1227 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
1218 | 1228 |
1219 if(purple_account_get_bool(account, "old_ssl", FALSE)) { | 1229 if(purple_account_get_bool(account, "old_ssl", FALSE)) { |
1220 if(purple_ssl_is_supported()) { | 1230 if(purple_ssl_is_supported()) { |
1221 js->gsc = purple_ssl_connect(account, server, | 1231 js->gsc = purple_ssl_connect(account, server, |
1312 } | 1322 } |
1313 | 1323 |
1314 void jabber_close(PurpleConnection *gc) | 1324 void jabber_close(PurpleConnection *gc) |
1315 { | 1325 { |
1316 JabberStream *js = gc->proto_data; | 1326 JabberStream *js = gc->proto_data; |
1327 | |
1328 /* Close all of the open Jingle sessions on this stream */ | |
1329 jingle_terminate_sessions(js); | |
1317 | 1330 |
1318 /* Don't perform any actions on the ssl connection | 1331 /* Don't perform any actions on the ssl connection |
1319 * if we were forcibly disconnected because it will crash | 1332 * if we were forcibly disconnected because it will crash |
1320 * on some SSL backends. | 1333 * on some SSL backends. |
1321 */ | 1334 */ |
1414 purple_timeout_remove(js->keepalive_timeout); | 1427 purple_timeout_remove(js->keepalive_timeout); |
1415 | 1428 |
1416 g_free(js->srv_rec); | 1429 g_free(js->srv_rec); |
1417 js->srv_rec = NULL; | 1430 js->srv_rec = NULL; |
1418 | 1431 |
1432 g_free(js->stun_ip); | |
1433 js->stun_ip = NULL; | |
1434 | |
1435 /* cancel DNS query for STUN, if one is ongoing */ | |
1436 if (js->stun_query) { | |
1437 purple_dnsquery_destroy(js->stun_query); | |
1438 js->stun_query = NULL; | |
1439 } | |
1440 | |
1419 g_free(js); | 1441 g_free(js); |
1420 | 1442 |
1421 gc->proto_data = NULL; | 1443 gc->proto_data = NULL; |
1422 } | 1444 } |
1423 | 1445 |
2588 gboolean jabber_offline_message(const PurpleBuddy *buddy) | 2610 gboolean jabber_offline_message(const PurpleBuddy *buddy) |
2589 { | 2611 { |
2590 return TRUE; | 2612 return TRUE; |
2591 } | 2613 } |
2592 | 2614 |
2615 gboolean | |
2616 jabber_initiate_media(PurpleConnection *gc, const char *who, | |
2617 PurpleMediaSessionType type) | |
2618 { | |
2619 #ifdef USE_VV | |
2620 JabberStream *js = (JabberStream *) gc->proto_data; | |
2621 JabberBuddy *jb; | |
2622 | |
2623 if (!js) { | |
2624 purple_debug_error("jabber", | |
2625 "jabber_initiate_media: NULL stream\n"); | |
2626 return FALSE; | |
2627 } | |
2628 | |
2629 jb = jabber_buddy_find(js, who, FALSE); | |
2630 | |
2631 if (!jb) { | |
2632 purple_debug_error("jabber", "Could not find buddy\n"); | |
2633 return FALSE; | |
2634 } | |
2635 | |
2636 if (type & PURPLE_MEDIA_AUDIO && | |
2637 !jabber_buddy_has_capability(jb, | |
2638 JINGLE_APP_RTP_SUPPORT_AUDIO) && | |
2639 jabber_buddy_has_capability(jb, GOOGLE_VOICE_CAP)) | |
2640 return jabber_google_session_initiate(gc->proto_data, who, type); | |
2641 else | |
2642 return jingle_rtp_initiate_media(gc->proto_data, who, type); | |
2643 #else | |
2644 return FALSE; | |
2645 #endif | |
2646 } | |
2647 | |
2648 PurpleMediaCaps jabber_get_media_caps(PurpleConnection *gc, const char *who) | |
2649 { | |
2650 #ifdef USE_VV | |
2651 JabberStream *js = (JabberStream *) gc->proto_data; | |
2652 JabberBuddy *jb; | |
2653 PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; | |
2654 | |
2655 if (!js) { | |
2656 purple_debug_info("jabber", | |
2657 "jabber_can_do_media: NULL stream\n"); | |
2658 return FALSE; | |
2659 } | |
2660 | |
2661 jb = jabber_buddy_find(js, who, FALSE); | |
2662 | |
2663 if (!jb) { | |
2664 purple_debug_error("jabber", "Could not find buddy\n"); | |
2665 return FALSE; | |
2666 } | |
2667 | |
2668 if (jabber_buddy_has_capability(jb, JINGLE_APP_RTP_SUPPORT_AUDIO)) | |
2669 caps |= PURPLE_MEDIA_CAPS_AUDIO | | |
2670 PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION; | |
2671 if (jabber_buddy_has_capability(jb, JINGLE_APP_RTP_SUPPORT_VIDEO)) | |
2672 caps |= PURPLE_MEDIA_CAPS_VIDEO | | |
2673 PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION; | |
2674 if (caps & PURPLE_MEDIA_CAPS_AUDIO && caps & PURPLE_MEDIA_CAPS_VIDEO) | |
2675 caps |= PURPLE_MEDIA_CAPS_AUDIO_VIDEO; | |
2676 if (caps != PURPLE_MEDIA_CAPS_NONE) { | |
2677 if (!jabber_buddy_has_capability(jb, | |
2678 JINGLE_TRANSPORT_ICEUDP) && | |
2679 !jabber_buddy_has_capability(jb, | |
2680 JINGLE_TRANSPORT_RAWUDP)) { | |
2681 purple_debug_info("jingle-rtp", "Buddy doesn't " | |
2682 "support the same transport types\n"); | |
2683 caps = PURPLE_MEDIA_CAPS_NONE; | |
2684 } else | |
2685 caps |= PURPLE_MEDIA_CAPS_MODIFY_SESSION | | |
2686 PURPLE_MEDIA_CAPS_CHANGE_DIRECTION; | |
2687 } | |
2688 if (jabber_buddy_has_capability(jb, GOOGLE_VOICE_CAP)) | |
2689 caps |= PURPLE_MEDIA_CAPS_AUDIO; | |
2690 | |
2691 return caps; | |
2692 #else | |
2693 return PURPLE_MEDIA_CAPS_NONE; | |
2694 #endif | |
2695 } | |
2696 | |
2593 void jabber_register_commands(void) | 2697 void jabber_register_commands(void) |
2594 { | 2698 { |
2595 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, | 2699 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL, |
2596 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, | 2700 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY, |
2597 "prpl-jabber", jabber_cmd_chat_config, | 2701 "prpl-jabber", jabber_cmd_chat_config, |