Skip to content
Snippets Groups Projects
Commit 16cd6197 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Implement NameOwnerChanged signal callback

parent 6435cce9
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ DBusGConnection * connection; ...@@ -39,6 +39,7 @@ DBusGConnection * connection;
DBusGProxy * callManagerProxy; DBusGProxy * callManagerProxy;
DBusGProxy * configurationManagerProxy; DBusGProxy * configurationManagerProxy;
DBusGProxy * instanceProxy; DBusGProxy * instanceProxy;
DBusGProxy * nameOwnerProxy;
static void static void
incoming_call_cb (DBusGProxy *proxy UNUSED, incoming_call_cb (DBusGProxy *proxy UNUSED,
...@@ -172,18 +173,32 @@ error_alert(DBusGProxy *proxy UNUSED, ...@@ -172,18 +173,32 @@ error_alert(DBusGProxy *proxy UNUSED,
sflphone_throw_exception( errCode ); sflphone_throw_exception( errCode );
} }
static void nameOwnerChanged(DBusGProxy *proxy, char *name, char *old_owner, char *new_owner, gpointer data )
{
g_print("******************************************************************\n");
g_print("Owner name of the service %s changed from %s to %s\n", name, old_owner, new_owner);
g_print("******************************************************************\n");
if (strcmp(name, "org.sflphone.SFLphone")!=0) return;
}
gboolean gboolean
dbus_connect () dbus_connect ()
{ {
GError *error = NULL; GError *error = NULL;
connection = NULL; connection = NULL;
instanceProxy = NULL;
nameOwnerProxy = NULL;
g_type_init (); g_type_init ();
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL) if (error)
{ {
g_printerr ("Failed to open connection to bus: %s\n", g_printerr ("Failed to open connection to bus: %s\n",
error->message); error->message);
...@@ -191,6 +206,25 @@ dbus_connect () ...@@ -191,6 +206,25 @@ dbus_connect ()
return FALSE; return FALSE;
} }
nameOwnerProxy = dbus_g_proxy_new_for_name_owner( connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS,
&error);
if( nameOwnerProxy==NULL)
{
g_printerr ("Failed to get proxy to NameOwner\n");
return FALSE;
}
dbus_g_proxy_add_signal( nameOwnerProxy, "NameOwnerChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (nameOwnerProxy, "NameOwnerChanged",
G_CALLBACK (nameOwnerChanged), NULL, NULL);
/* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
instanceProxy = dbus_g_proxy_new_for_name_owner (connection, instanceProxy = dbus_g_proxy_new_for_name_owner (connection,
...@@ -198,7 +232,7 @@ dbus_connect () ...@@ -198,7 +232,7 @@ dbus_connect ()
"/org/sflphone/SFLphone/Instance", "/org/sflphone/SFLphone/Instance",
"org.sflphone.SFLphone.Instance", "org.sflphone.SFLphone.Instance",
&error); &error);
if (!instanceProxy) if (instanceProxy==NULL)
{ {
g_printerr ("Failed to get proxy to Instance\n"); g_printerr ("Failed to get proxy to Instance\n");
return FALSE; return FALSE;
...@@ -212,7 +246,7 @@ dbus_connect () ...@@ -212,7 +246,7 @@ dbus_connect ()
"/org/sflphone/SFLphone/CallManager", "/org/sflphone/SFLphone/CallManager",
"org.sflphone.SFLphone.CallManager", "org.sflphone.SFLphone.CallManager",
&error); &error);
if (!callManagerProxy) if (callManagerProxy==NULL)
{ {
g_printerr ("Failed to get proxy to CallManagers\n"); g_printerr ("Failed to get proxy to CallManagers\n");
return FALSE; return FALSE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment