pidgin.vv: db2d4c7a: Use the state-changed signal in GTalk co...
maiku at soc.pidgin.im
maiku at soc.pidgin.im
Tue Jan 13 01:55:50 EST 2009
-----------------------------------------------------------------
Revision: db2d4c7a176b4915d551fee34620b9167f641e1e
Ancestor: c12bd89a902ddd3a7fc9a9c274501f0b44a94593
Author: maiku at soc.pidgin.im
Date: 2009-01-13T06:30:29
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/db2d4c7a176b4915d551fee34620b9167f641e1e
Modified files:
libpurple/protocols/jabber/google.c
ChangeLog:
Use the state-changed signal in GTalk code.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google.c bbb3d08626aedbfaa05998f67c78b7d74140b3f6
+++ libpurple/protocols/jabber/google.c 5adff028af2b3d973574b2c7506ab035ab313ec3
@@ -139,21 +139,6 @@ google_session_send_terminate(GoogleSess
google_session_destroy(session);
}
-static void
-google_session_send_reject(GoogleSession *session)
-{
- xmlnode *sess;
- JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
-
- xmlnode_set_attrib(iq->node, "to", session->remote_jid);
- sess = google_session_create_xmlnode(session, "reject");
- xmlnode_insert_child(iq->node, sess);
-
- jabber_iq_send(iq);
- google_session_destroy(session);
-}
-
-
static void
google_session_candidates_prepared (PurpleMedia *media, gchar *session_id,
gchar *participant, GoogleSession *session)
@@ -254,6 +239,37 @@ google_session_ready(PurpleMedia *media,
}
}
+static void
+google_session_state_changed_cb(PurpleMedia *media,
+ PurpleMediaStateChangedType type,
+ gchar *sid, gchar *name, GoogleSession *session)
+{
+ if (sid == NULL && name == NULL) {
+ if (type == PURPLE_MEDIA_STATE_CHANGED_END) {
+ google_session_destroy(session);
+ } else if (type == PURPLE_MEDIA_STATE_CHANGED_HANGUP) {
+ xmlnode *sess;
+ JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ sess = google_session_create_xmlnode(session, "terminate");
+ xmlnode_insert_child(iq->node, sess);
+
+ jabber_iq_send(iq);
+ } else if (type == PURPLE_MEDIA_STATE_CHANGED_REJECTED) {
+ xmlnode *sess;
+ JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);
+
+ xmlnode_set_attrib(iq->node, "to", session->remote_jid);
+ sess = google_session_create_xmlnode(session, "reject");
+ xmlnode_insert_child(iq->node, sess);
+
+ jabber_iq_send(iq);
+ }
+
+ }
+}
+
PurpleMedia*
jabber_google_session_initiate(JabberStream *js, const gchar *who, PurpleMediaSessionType type)
{
@@ -313,10 +329,8 @@ jabber_google_session_initiate(JabberStr
G_CALLBACK(google_session_ready), session);
g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
G_CALLBACK(google_session_send_accept), session);
- g_signal_connect_swapped(G_OBJECT(session->media), "reject",
- G_CALLBACK(google_session_send_reject), session);
- g_signal_connect_swapped(G_OBJECT(session->media), "hangup",
- G_CALLBACK(google_session_send_terminate), session);
+ g_signal_connect(G_OBJECT(session->media), "state-changed",
+ G_CALLBACK(google_session_state_changed_cb), session);
purple_media_ready(session->media);
if (sessions == NULL)
@@ -377,12 +391,10 @@ google_session_handle_initiate(JabberStr
g_signal_connect_swapped(G_OBJECT(session->media), "accepted",
G_CALLBACK(google_session_send_accept), session);
- g_signal_connect_swapped(G_OBJECT(session->media), "reject",
- G_CALLBACK(google_session_send_reject), session);
- g_signal_connect_swapped(G_OBJECT(session->media), "hangup",
- G_CALLBACK(google_session_send_terminate), session);
g_signal_connect(G_OBJECT(session->media), "candidates-prepared",
G_CALLBACK(google_session_candidates_prepared), session);
+ g_signal_connect(G_OBJECT(session->media), "state-changed",
+ G_CALLBACK(google_session_state_changed_cb), session);
purple_media_ready(session->media);
purple_media_codec_list_free(codecs);
@@ -465,16 +477,12 @@ google_session_handle_reject(JabberStrea
google_session_handle_reject(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
{
purple_media_got_hangup(session->media);
-
- google_session_destroy(session);
}
static void
google_session_handle_terminate(JabberStream *js, GoogleSession *session, xmlnode *packet, xmlnode *sess)
{
purple_media_got_hangup(session->media);
-
- google_session_destroy(session);
}
static void
More information about the Commits
mailing list