| 66 #include "jingle/jingle.h" |
66 #include "jingle/jingle.h" |
| 67 #include "jingle/rtp.h" |
67 #include "jingle/rtp.h" |
| 68 |
68 |
| 69 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) |
69 #define JABBER_CONNECT_STEPS (js->gsc ? 9 : 5) |
| 70 |
70 |
| 71 static PurplePlugin *my_protocol = NULL; |
71 PurplePlugin *jabber_plugin = NULL; |
| 72 GList *jabber_features = NULL; |
72 GList *jabber_features = NULL; |
| 73 GList *jabber_identities = NULL; |
73 GList *jabber_identities = NULL; |
| 74 GSList *jabber_cmds = NULL; |
74 GSList *jabber_cmds = NULL; |
| 75 |
75 |
| 76 static void jabber_unregister_account_cb(JabberStream *js); |
76 static void jabber_unregister_account_cb(JabberStream *js); |
| 251 |
251 |
| 252 void jabber_process_packet(JabberStream *js, xmlnode **packet) |
252 void jabber_process_packet(JabberStream *js, xmlnode **packet) |
| 253 { |
253 { |
| 254 const char *xmlns; |
254 const char *xmlns; |
| 255 |
255 |
| 256 purple_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, packet); |
256 purple_signal_emit(jabber_plugin, "jabber-receiving-xmlnode", js->gc, packet); |
| 257 |
257 |
| 258 /* if the signal leaves us with a null packet, we're done */ |
258 /* if the signal leaves us with a null packet, we're done */ |
| 259 if(NULL == *packet) |
259 if(NULL == *packet) |
| 260 return; |
260 return; |
| 261 |
261 |
| 405 } |
405 } |
| 406 |
406 |
| 407 /* If we've got a security layer, we need to encode the data, |
407 /* If we've got a security layer, we need to encode the data, |
| 408 * splitting it on the maximum buffer length negotiated */ |
408 * splitting it on the maximum buffer length negotiated */ |
| 409 |
409 |
| 410 purple_signal_emit(my_protocol, "jabber-sending-text", js->gc, &data); |
410 purple_signal_emit(jabber_plugin, "jabber-sending-text", js->gc, &data); |
| 411 if (data == NULL) |
411 if (data == NULL) |
| 412 return; |
412 return; |
| 413 |
413 |
| 414 #ifdef HAVE_CYRUS_SASL |
414 #ifdef HAVE_CYRUS_SASL |
| 415 if (js->sasl_maxbuf>0) { |
415 if (js->sasl_maxbuf>0) { |
| 457 void jabber_send(JabberStream *js, xmlnode *packet) |
457 void jabber_send(JabberStream *js, xmlnode *packet) |
| 458 { |
458 { |
| 459 char *txt; |
459 char *txt; |
| 460 int len; |
460 int len; |
| 461 |
461 |
| 462 purple_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet); |
462 purple_signal_emit(jabber_plugin, "jabber-sending-xmlnode", js->gc, &packet); |
| 463 |
463 |
| 464 /* if we get NULL back, we're done processing */ |
464 /* if we get NULL back, we're done processing */ |
| 465 if(NULL == packet) |
465 if(NULL == packet) |
| 466 return; |
466 return; |
| 467 |
467 |
| 482 void jabber_keepalive(PurpleConnection *gc) |
482 void jabber_keepalive(PurpleConnection *gc) |
| 483 { |
483 { |
| 484 JabberStream *js = gc->proto_data; |
484 JabberStream *js = gc->proto_data; |
| 485 |
485 |
| 486 if (js->keepalive_timeout == -1) { |
486 if (js->keepalive_timeout == -1) { |
| 487 jabber_ping_jid(js, js->user->domain); |
487 jabber_keepalive_ping(js); |
| 488 js->keepalive_timeout = purple_timeout_add_seconds(120, |
488 js->keepalive_timeout = purple_timeout_add_seconds(120, |
| 489 (GSourceFunc)(jabber_keepalive_timeout), gc); |
489 (GSourceFunc)(jabber_keepalive_timeout), gc); |
| 490 } |
490 } |
| 491 } |
491 } |
| 492 |
492 |
| 594 |
594 |
| 595 /* Tell the app that we're doing encryption */ |
595 /* Tell the app that we're doing encryption */ |
| 596 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION); |
596 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING_ENCRYPTION); |
| 597 } |
597 } |
| 598 |
598 |
| 599 static void |
599 static void |
| 600 txt_resolved_cb(GSList *responses, gpointer data) |
600 txt_resolved_cb(GSList *responses, gpointer data) |
| 601 { |
601 { |
| 602 JabberStream *js = data; |
602 JabberStream *js = data; |
| 603 |
603 |
| 604 js->srv_query_data = NULL; |
604 js->srv_query_data = NULL; |
| 607 gchar *tmp; |
607 gchar *tmp; |
| 608 tmp = g_strdup_printf(_("Could not find alternative XMPP connection methods after failing to connect directly.\n")); |
608 tmp = g_strdup_printf(_("Could not find alternative XMPP connection methods after failing to connect directly.\n")); |
| 609 purple_connection_error_reason (js->gc, |
609 purple_connection_error_reason (js->gc, |
| 610 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
610 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
| 611 g_free(tmp); |
611 g_free(tmp); |
| 612 return; |
612 return; |
| 613 } |
613 } |
| 614 |
614 |
| 615 while (responses) { |
615 while (responses) { |
| 616 PurpleTxtResponse *resp = responses->data; |
616 PurpleTxtResponse *resp = responses->data; |
| 617 gchar **token; |
617 gchar **token; |
| 1576 /* cancel DNS query for STUN, if one is ongoing */ |
1576 /* cancel DNS query for STUN, if one is ongoing */ |
| 1577 if (js->stun_query) { |
1577 if (js->stun_query) { |
| 1578 purple_dnsquery_destroy(js->stun_query); |
1578 purple_dnsquery_destroy(js->stun_query); |
| 1579 js->stun_query = NULL; |
1579 js->stun_query = NULL; |
| 1580 } |
1580 } |
| 1581 |
1581 |
| 1582 g_free(js); |
1582 g_free(js); |
| 1583 |
1583 |
| 1584 gc->proto_data = NULL; |
1584 gc->proto_data = NULL; |
| 1585 } |
1585 } |
| 1586 |
1586 |
| 1797 GList *identity; |
1797 GList *identity; |
| 1798 JabberIdentity *ident; |
1798 JabberIdentity *ident; |
| 1799 /* both required according to XEP-0030 */ |
1799 /* both required according to XEP-0030 */ |
| 1800 g_return_if_fail(category != NULL); |
1800 g_return_if_fail(category != NULL); |
| 1801 g_return_if_fail(type != NULL); |
1801 g_return_if_fail(type != NULL); |
| 1802 |
1802 |
| 1803 for(identity = jabber_identities; identity; identity = identity->next) { |
1803 for(identity = jabber_identities; identity; identity = identity->next) { |
| 1804 JabberIdentity *ident = (JabberIdentity*)identity->data; |
1804 JabberIdentity *ident = (JabberIdentity*)identity->data; |
| 1805 if (!strcmp(ident->category, category) && |
1805 if (!strcmp(ident->category, category) && |
| 1806 !strcmp(ident->type, type) && |
1806 !strcmp(ident->type, type) && |
| 1807 ((!ident->lang && !lang) || (ident->lang && lang && !strcmp(ident->lang, lang)))) { |
1807 ((!ident->lang && !lang) || (ident->lang && lang && !strcmp(ident->lang, lang)))) { |
| 1808 return; |
1808 return; |
| 1809 } |
1809 } |
| 1810 } |
1810 } |
| 1811 |
1811 |
| 1812 ident = g_new0(JabberIdentity, 1); |
1812 ident = g_new0(JabberIdentity, 1); |
| 1813 ident->category = g_strdup(category); |
1813 ident->category = g_strdup(category); |
| 1814 ident->type = g_strdup(type); |
1814 ident->type = g_strdup(type); |
| 1951 |
1951 |
| 1952 purple_notify_user_info_add_pair(user_info, label, value); |
1952 purple_notify_user_info_add_pair(user_info, label, value); |
| 1953 g_free(label); |
1953 g_free(label); |
| 1954 g_free(value); |
1954 g_free(value); |
| 1955 g_free(text); |
1955 g_free(text); |
| 1956 |
1956 |
| 1957 /* if the resource is idle, show that */ |
1957 /* if the resource is idle, show that */ |
| 1958 /* only show it if there is more than one resource available for |
1958 /* only show it if there is more than one resource available for |
| 1959 the buddy, since the "general" idleness will be shown anyway, |
1959 the buddy, since the "general" idleness will be shown anyway, |
| 1960 this way we can see see the idleness of lower-priority resources */ |
1960 this way we can see see the idleness of lower-priority resources */ |
| 1961 if (jbr->idle && multiple_resources) { |
1961 if (jbr->idle && multiple_resources) { |
| 1962 gchar *idle_str = |
1962 gchar *idle_str = |
| 1963 purple_str_seconds_to_string(time(NULL) - jbr->idle); |
1963 purple_str_seconds_to_string(time(NULL) - jbr->idle); |
| 1964 label = g_strdup_printf("%s%s", _("Idle"), (res ? res : "")); |
1964 label = g_strdup_printf("%s%s", _("Idle"), (res ? res : "")); |
| 1965 purple_notify_user_info_add_pair(user_info, label, idle_str); |
1965 purple_notify_user_info_add_pair(user_info, label, idle_str); |
| 1966 g_free(idle_str); |
1966 g_free(idle_str); |
| 1967 g_free(label); |
1967 g_free(label); |
| 1990 JabberBuddyResource *jbr = NULL; |
1990 JabberBuddyResource *jbr = NULL; |
| 1991 PurplePresence *presence = purple_buddy_get_presence(b); |
1991 PurplePresence *presence = purple_buddy_get_presence(b); |
| 1992 const char *sub; |
1992 const char *sub; |
| 1993 GList *l; |
1993 GList *l; |
| 1994 const char *mood; |
1994 const char *mood; |
| 1995 gboolean multiple_resources = |
1995 gboolean multiple_resources = |
| 1996 jb->resources && g_list_next(jb->resources); |
1996 jb->resources && g_list_next(jb->resources); |
| 1997 JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); |
1997 JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); |
| 1998 |
1998 |
| 1999 /* resource-specific info for the top resource */ |
1999 /* resource-specific info for the top resource */ |
| 2000 if (top_jbr) { |
2000 if (top_jbr) { |
| 2001 jabber_tooltip_add_resource_text(top_jbr, user_info, |
2001 jabber_tooltip_add_resource_text(top_jbr, user_info, |
| 2002 multiple_resources); |
2002 multiple_resources); |
| 2003 } |
2003 } |
| 2004 |
2004 |
| 2005 for(l=jb->resources; l; l = l->next) { |
2005 for(l=jb->resources; l; l = l->next) { |
| 2006 jbr = l->data; |
2006 jbr = l->data; |
| 2008 if (jbr != top_jbr) { |
2008 if (jbr != top_jbr) { |
| 2009 jabber_tooltip_add_resource_text(jbr, user_info, |
2009 jabber_tooltip_add_resource_text(jbr, user_info, |
| 2010 multiple_resources); |
2010 multiple_resources); |
| 2011 } |
2011 } |
| 2012 } |
2012 } |
| 2013 |
2013 |
| 2014 if (full) { |
2014 if (full) { |
| 2015 PurpleStatus *status; |
2015 PurpleStatus *status; |
| 2016 |
2016 |
| 2017 status = purple_presence_get_active_status(presence); |
2017 status = purple_presence_get_active_status(presence); |
| 2018 mood = purple_status_get_attr_string(status, "mood"); |
2018 mood = purple_status_get_attr_string(status, "mood"); |
| 2913 |
2913 |
| 2914 typedef struct { |
2914 typedef struct { |
| 2915 PurpleAccount *account; |
2915 PurpleAccount *account; |
| 2916 gchar *who; |
2916 gchar *who; |
| 2917 PurpleMediaSessionType type; |
2917 PurpleMediaSessionType type; |
| 2918 |
2918 |
| 2919 } JabberMediaRequest; |
2919 } JabberMediaRequest; |
| 2920 |
2920 |
| 2921 static void |
2921 static void |
| 2922 jabber_media_cancel_cb(JabberMediaRequest *request, |
2922 jabber_media_cancel_cb(JabberMediaRequest *request, |
| 2923 PurpleRequestFields *fields) |
2923 PurpleRequestFields *fields) |
| 2942 g_free(request); |
2942 g_free(request); |
| 2943 } |
2943 } |
| 2944 #endif |
2944 #endif |
| 2945 |
2945 |
| 2946 gboolean |
2946 gboolean |
| 2947 jabber_initiate_media(PurpleAccount *account, const char *who, |
2947 jabber_initiate_media(PurpleAccount *account, const char *who, |
| 2948 PurpleMediaSessionType type) |
2948 PurpleMediaSessionType type) |
| 2949 { |
2949 { |
| 2950 #ifdef USE_VV |
2950 #ifdef USE_VV |
| 2951 JabberStream *js = (JabberStream *) |
2951 JabberStream *js = (JabberStream *) |
| 2952 purple_account_get_connection(account)->proto_data; |
2952 purple_account_get_connection(account)->proto_data; |
| 3326 |
3326 |
| 3327 if (!purple_account_is_connected(account)) |
3327 if (!purple_account_is_connected(account)) |
| 3328 return FALSE; |
3328 return FALSE; |
| 3329 js = gc->proto_data; |
3329 js = gc->proto_data; |
| 3330 |
3330 |
| 3331 if (!(resource = jabber_get_resource(jid)) || |
3331 if (!(resource = jabber_get_resource(jid)) || |
| 3332 !(jb = jabber_buddy_find(js, jid, FALSE)) || |
3332 !(jb = jabber_buddy_find(js, jid, FALSE)) || |
| 3333 !(jbr = jabber_buddy_find_resource(jb, resource))) { |
3333 !(jbr = jabber_buddy_find_resource(jb, resource))) { |
| 3334 g_free(resource); |
3334 g_free(resource); |
| 3335 return FALSE; |
3335 return FALSE; |
| 3336 } |
3336 } |
| 3367 strcmp(ui_type, "web") == 0 || |
3367 strcmp(ui_type, "web") == 0 || |
| 3368 strcmp(ui_type, "bot") == 0) { |
3368 strcmp(ui_type, "bot") == 0) { |
| 3369 type = ui_type; |
3369 type = ui_type; |
| 3370 } |
3370 } |
| 3371 } |
3371 } |
| 3372 my_protocol = plugin; |
3372 jabber_plugin = plugin; |
| 3373 |
3373 |
| 3374 jabber_add_identity("client", type, NULL, PACKAGE); |
3374 jabber_add_identity("client", type, NULL, PACKAGE); |
| 3375 |
3375 |
| 3376 /* initialize jabber_features list */ |
3376 /* initialize jabber_features list */ |
| 3377 jabber_add_feature("jabber:iq:last", 0); |
3377 jabber_add_feature("jabber:iq:last", 0); |