libpurple/protocols/jabber/jingle/session.c

branch
soc.2013.gobjectification
changeset 35076
cadfc3f9a7cc
parent 35061
307195f879f3
child 35083
3b6577fd64ee
child 36958
2ab9fcc7ca7c
equal deleted inserted replaced
35075:3a3c90a0ec07 35076:cadfc3f9a7cc
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 */ 23 */
24 24
25 #include "internal.h" 25 #include "internal.h"
26 #include "glibcompat.h"
26 27
27 #include "content.h" 28 #include "content.h"
28 #include "debug.h" 29 #include "debug.h"
29 #include "session.h" 30 #include "session.h"
30 #include "jingle.h" 31 #include "jingle.h"
48 static void jingle_session_class_init (JingleSessionClass *klass); 49 static void jingle_session_class_init (JingleSessionClass *klass);
49 static void jingle_session_init (JingleSession *session); 50 static void jingle_session_init (JingleSession *session);
50 static void jingle_session_finalize (GObject *object); 51 static void jingle_session_finalize (GObject *object);
51 static void jingle_session_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); 52 static void jingle_session_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
52 static void jingle_session_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); 53 static void jingle_session_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
53
54 static GObjectClass *parent_class = NULL;
55 54
56 enum { 55 enum {
57 PROP_0, 56 PROP_0,
58 PROP_SID, 57 PROP_SID,
59 PROP_JS, 58 PROP_JS,
61 PROP_LOCAL_JID, 60 PROP_LOCAL_JID,
62 PROP_IS_INITIATOR, 61 PROP_IS_INITIATOR,
63 PROP_STATE, 62 PROP_STATE,
64 PROP_CONTENTS, 63 PROP_CONTENTS,
65 PROP_PENDING_CONTENTS, 64 PROP_PENDING_CONTENTS,
65 PROP_LAST
66 }; 66 };
67
68 static GObjectClass *parent_class = NULL;
69 static GParamSpec *properties[PROP_LAST];
67 70
68 GType 71 GType
69 jingle_session_get_type() 72 jingle_session_get_type()
70 { 73 {
71 static GType type = 0; 74 static GType type = 0;
96 99
97 gobject_class->finalize = jingle_session_finalize; 100 gobject_class->finalize = jingle_session_finalize;
98 gobject_class->set_property = jingle_session_set_property; 101 gobject_class->set_property = jingle_session_set_property;
99 gobject_class->get_property = jingle_session_get_property; 102 gobject_class->get_property = jingle_session_get_property;
100 103
101 g_object_class_install_property(gobject_class, PROP_SID, 104 properties[PROP_SID] = g_param_spec_string("sid",
102 g_param_spec_string("sid",
103 "Session ID", 105 "Session ID",
104 "The unique session ID of the Jingle Session.", 106 "The unique session ID of the Jingle Session.",
105 NULL, 107 NULL,
106 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 108 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
107 109 g_object_class_install_property(gobject_class, PROP_SID,
108 g_object_class_install_property(gobject_class, PROP_JS, 110 properties[PROP_SID]);
109 g_param_spec_pointer("js", 111
112 properties[PROP_JS] = g_param_spec_pointer("js",
110 "JabberStream", 113 "JabberStream",
111 "The Jabber stream associated with this session.", 114 "The Jabber stream associated with this session.",
112 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 115 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
113 116 g_object_class_install_property(gobject_class, PROP_JS,
114 g_object_class_install_property(gobject_class, PROP_REMOTE_JID, 117 properties[PROP_JS]);
115 g_param_spec_string("remote-jid", 118
119 properties[PROP_REMOTE_JID] = g_param_spec_string("remote-jid",
116 "Remote JID", 120 "Remote JID",
117 "The JID of the remote participant.", 121 "The JID of the remote participant.",
118 NULL, 122 NULL,
119 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 123 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
120 124 g_object_class_install_property(gobject_class, PROP_REMOTE_JID,
121 g_object_class_install_property(gobject_class, PROP_LOCAL_JID, 125 properties[PROP_REMOTE_JID]);
122 g_param_spec_string("local-jid", 126
127 properties[PROP_LOCAL_JID] = g_param_spec_string("local-jid",
123 "Local JID", 128 "Local JID",
124 "The JID of the local participant.", 129 "The JID of the local participant.",
125 NULL, 130 NULL,
126 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 131 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
127 132 g_object_class_install_property(gobject_class, PROP_LOCAL_JID,
128 g_object_class_install_property(gobject_class, PROP_IS_INITIATOR, 133 properties[PROP_LOCAL_JID]);
129 g_param_spec_boolean("is-initiator", 134
135 properties[PROP_IS_INITIATOR] = g_param_spec_boolean("is-initiator",
130 "Is Initiator", 136 "Is Initiator",
131 "Whether or not the local JID is the initiator of the session.", 137 "Whether or not the local JID is the initiator of the session.",
132 FALSE, 138 FALSE,
133 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 139 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
134 140 g_object_class_install_property(gobject_class, PROP_IS_INITIATOR,
135 g_object_class_install_property(gobject_class, PROP_STATE, 141 properties[PROP_IS_INITIATOR]);
136 g_param_spec_boolean("state", 142
143 properties[PROP_STATE] = g_param_spec_boolean("state",
137 "State", 144 "State",
138 "The state of the session (PENDING=FALSE, ACTIVE=TRUE).", 145 "The state of the session (PENDING=FALSE, ACTIVE=TRUE).",
139 FALSE, 146 FALSE,
140 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 147 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
141 148 g_object_class_install_property(gobject_class, PROP_STATE,
142 g_object_class_install_property(gobject_class, PROP_CONTENTS, 149 properties[PROP_STATE]);
143 g_param_spec_pointer("contents", 150
151 properties[PROP_CONTENTS] = g_param_spec_pointer("contents",
144 "Contents", 152 "Contents",
145 "The active contents contained within this session", 153 "The active contents contained within this session",
146 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 154 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
147 155 g_object_class_install_property(gobject_class, PROP_CONTENTS,
148 g_object_class_install_property(gobject_class, PROP_PENDING_CONTENTS, 156 properties[PROP_CONTENTS]);
149 g_param_spec_pointer("pending-contents", 157
158 properties[PROP_PENDING_CONTENTS] = g_param_spec_pointer("pending-contents",
150 "Pending contents", 159 "Pending contents",
151 "The pending contents contained within this session", 160 "The pending contents contained within this session",
152 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 161 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
162 g_object_class_install_property(gobject_class, PROP_PENDING_CONTENTS,
163 properties[PROP_PENDING_CONTENTS]);
153 164
154 g_type_class_add_private(klass, sizeof(JingleSessionPrivate)); 165 g_type_class_add_private(klass, sizeof(JingleSessionPrivate));
155 } 166 }
156 167
157 static void 168 static void
562 { 573 {
563 session->priv->contents = 574 session->priv->contents =
564 g_list_append(session->priv->contents, content); 575 g_list_append(session->priv->contents, content);
565 jingle_content_set_session(content, session); 576 jingle_content_set_session(content, session);
566 577
567 g_object_notify(G_OBJECT(session), "contents"); 578 g_object_notify_by_pspec(G_OBJECT(session), properties[PROP_CONTENTS]);
568 } 579 }
569 580
570 void 581 void
571 jingle_session_remove_content(JingleSession *session, const gchar *name, const gchar *creator) 582 jingle_session_remove_content(JingleSession *session, const gchar *name, const gchar *creator)
572 { 583 {
576 if (content) { 587 if (content) {
577 session->priv->contents = 588 session->priv->contents =
578 g_list_remove(session->priv->contents, content); 589 g_list_remove(session->priv->contents, content);
579 g_object_unref(content); 590 g_object_unref(content);
580 591
581 g_object_notify(G_OBJECT(session), "contents"); 592 g_object_notify_by_pspec(G_OBJECT(session), properties[PROP_CONTENTS]);
582 } 593 }
583 } 594 }
584 595
585 void 596 void
586 jingle_session_add_pending_content(JingleSession *session, JingleContent* content) 597 jingle_session_add_pending_content(JingleSession *session, JingleContent* content)
587 { 598 {
588 session->priv->pending_contents = 599 session->priv->pending_contents =
589 g_list_append(session->priv->pending_contents, content); 600 g_list_append(session->priv->pending_contents, content);
590 jingle_content_set_session(content, session); 601 jingle_content_set_session(content, session);
591 602
592 g_object_notify(G_OBJECT(session), "pending-contents"); 603 g_object_notify_by_pspec(G_OBJECT(session), properties[PROP_PENDING_CONTENTS]);
593 } 604 }
594 605
595 void 606 void
596 jingle_session_remove_pending_content(JingleSession *session, const gchar *name, const gchar *creator) 607 jingle_session_remove_pending_content(JingleSession *session, const gchar *name, const gchar *creator)
597 { 608 {
600 if (content) { 611 if (content) {
601 session->priv->pending_contents = 612 session->priv->pending_contents =
602 g_list_remove(session->priv->pending_contents, content); 613 g_list_remove(session->priv->pending_contents, content);
603 g_object_unref(content); 614 g_object_unref(content);
604 615
605 g_object_notify(G_OBJECT(session), "pending-contents"); 616 g_object_notify_by_pspec(G_OBJECT(session), properties[PROP_PENDING_CONTENTS]);
606 } 617 }
607 } 618 }
608 619
609 void 620 void
610 jingle_session_accept_content(JingleSession *session, const gchar *name, const gchar *creator) 621 jingle_session_accept_content(JingleSession *session, const gchar *name, const gchar *creator)
621 void 632 void
622 jingle_session_accept_session(JingleSession *session) 633 jingle_session_accept_session(JingleSession *session)
623 { 634 {
624 session->priv->state = TRUE; 635 session->priv->state = TRUE;
625 636
626 g_object_notify(G_OBJECT(session), "state"); 637 g_object_notify_by_pspec(G_OBJECT(session), properties[PROP_STATE]);
627 } 638 }
628 639
629 JabberIq * 640 JabberIq *
630 jingle_session_terminate_packet(JingleSession *session, const gchar *reason) 641 jingle_session_terminate_packet(JingleSession *session, const gchar *reason)
631 { 642 {

mercurial