From: Magnus H. <leg...@us...> - 2008-10-29 23:50:50
|
Update of /cvsroot/emacs-jabber/tox In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv30223 Modified Files: jabber-tox.el tox-marshal.list tox-session.c tox-session.xml Log Message: New signal: state-changed. Untested so far... Index: jabber-tox.el =================================================================== RCS file: /cvsroot/emacs-jabber/tox/jabber-tox.el,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- jabber-tox.el 23 Oct 2008 22:09:14 -0000 1.20 +++ jabber-tox.el 29 Oct 2008 23:50:35 -0000 1.21 @@ -111,6 +111,14 @@ (fsm-send-sync fsm (cons :new-native-candidate components))))) + ;; And we also want to know about state changes. + (dbus-register-signal :session tox-name tox-session tox-session-interface + "StateChanged" + (lexical-let ((fsm fsm)) + (lambda (state direction) + (fsm-send-sync + fsm + (list :state-changed state direction))))) (fsm-debug-output "Waiting") state-data)) Index: tox-session.xml =================================================================== RCS file: /cvsroot/emacs-jabber/tox/tox-session.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tox-session.xml 20 Mar 2008 12:19:23 -0000 1.2 +++ tox-session.xml 29 Oct 2008 23:50:35 -0000 1.3 @@ -66,5 +66,20 @@ <!-- Argument layout: see SetRemoteCodecs --> </method> + <signal name="StateChanged"> + <!-- state is one of: + 0: disconnected + 1: connecting + 2: connected + --> + <arg name='newstate' type='y'/> + <!-- direction is one of: + 1: send only. + 2: receive only. + 3: send and receive. + --> + <arg name='direction' type='y'/> + </signal> + </interface> </node> Index: tox-marshal.list =================================================================== RCS file: /cvsroot/emacs-jabber/tox/tox-marshal.list,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tox-marshal.list 17 Jan 2008 00:45:22 -0000 1.1 +++ tox-marshal.list 29 Oct 2008 23:50:35 -0000 1.2 @@ -1 +1,2 @@ VOID:BOXED +VOID:UCHAR,UCHAR Index: tox-session.c =================================================================== RCS file: /cvsroot/emacs-jabber/tox/tox-session.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tox-session.c 23 Oct 2008 22:08:50 -0000 1.4 +++ tox-session.c 29 Oct 2008 23:50:35 -0000 1.5 @@ -37,6 +37,7 @@ enum { NEW_NATIVE_CANDIDATE, NATIVE_CANDIDATES_PREPARED, + STATE_CHANGED, LAST_SIGNAL }; @@ -53,6 +54,7 @@ static void tox_session_native_candidates_prepared(FarsightStream *stream, gpointer user_data); static void tox_session_new_native_candidate(FarsightStream *stream, gchar *candidate_id, ToxSession *self); +static void tox_session_state_changed(FarsightStream *stream, gint state, gint direction, ToxSession *self); void tox_session_init(ToxSession *obj) @@ -149,6 +151,18 @@ 1, G_TYPE_VALUE_ARRAY); + signals[STATE_CHANGED] = + g_signal_new("state-changed", + G_OBJECT_CLASS_TYPE(klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, + 0, + NULL, NULL, + tox_marshal_VOID__UCHAR_UCHAR, + G_TYPE_NONE, + 2, + G_TYPE_UCHAR, + G_TYPE_UCHAR); + dbus_g_object_type_install_info(TOX_TYPE_SESSION, &dbus_glib_tox_session_object_info); parent_class = g_type_class_peek_parent (klass); @@ -191,6 +205,8 @@ (GCallback)tox_session_new_native_candidate, (gpointer)self); g_signal_connect(self->priv->stream, "native-candidates-prepared", (GCallback)tox_session_native_candidates_prepared, (gpointer)self); + g_signal_connect(self->priv->stream, "state-changed", + (GCallback)tox_session_state_changed, (gpointer)self); /* but we can't actually do it until we have a pipeline. so, we'll call stream_done when we do. */ break; @@ -703,3 +719,9 @@ return array; } + +static void +tox_session_state_changed(FarsightStream *stream, gint state, gint direction, ToxSession *self) +{ + g_signal_emit(self, signals[STATE_CHANGED], 0, state, direction); +} |