Commit d1ade407 authored by Alexandre Savard's avatar Alexandre Savard

#8320: add dbus signal for stun failure

parent b7589008
......@@ -447,6 +447,16 @@
<signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
</signal>
<signal name="stunStatusFailure" tp:name-for_bindings="stunStatusFailure">
<arg type="s" name="reason">
</arg>
</signal>
<signal name="stunStatusSuccess" tp:name-for_bindings="stunStatusSuccess">
<arg type="s" name="message">
</arg>
</signal>
<signal name="errorAlert" tp:name-for-bindings="errorAlert">
<arg type="i" name="code">
</arg>
......
......@@ -48,6 +48,7 @@
#include "dbus/dbusmanager.h"
#include "dbus/callmanager.h"
#include "dbus/configurationmanager.h"
#include "im/instant_messaging.h"
......@@ -1236,8 +1237,15 @@ pj_bool_t stun_sock_on_status_cb(pj_stun_sock *stun_sock UNUSED, pj_stun_sock_op
pj_bool_t reschedule = PJ_TRUE;
if(status != PJ_SUCCESS) {
// Signal the client on failure
Manager::instance().getDbusManager()->getConfigurationManager()->stunStatusFailure(pj_stun_sock_op_name(op));
ERROR("Error STUN session failed because %s failed", pj_stun_sock_op_name(op));
}
else {
Manager::instance().getDbusManager()->getConfigurationManager()->stunStatusSuccess("");
}
// Signal the client on success or failure
return reschedule;
}
......
......@@ -446,6 +446,16 @@
<signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
</signal>
<signal name="stunStatusFailure" tp:name-for_bindings="stunStatusFailure">
<arg type="s" name="reason">
</arg>
</signal>
<signal name="stunStatusSuccess" tp:name-for_bindings="stunStatusSuccess">
<arg type="s" name="message">
</arg>
</signal>
<signal name="errorAlert" tp:name-for-bindings="errorAlert">
<arg type="i" name="code">
</arg>
......
......@@ -432,6 +432,17 @@ accounts_changed_cb(DBusGProxy *proxy UNUSED, void *foo UNUSED)
statusicon_set_tooltip();
}
static void
stun_status_failure_cb(DBusGProxy *proxy UNUSED, const gchar *reason, void *foo UNUSED)
{
ERROR("Error: Stun status failure: %s failed", reason);
}
static void
stun_status_success_cb(DBusGProxy *proxy UNUSED, const gchar *message UNUSED, void *foo UNUSED)
{
}
static void
transfer_succeeded_cb(DBusGProxy *proxy UNUSED, void *foo UNUSED)
{
......@@ -612,43 +623,98 @@ gboolean dbus_connect_session_manager(DBusGConnection *connection)
gboolean dbus_connect(GError **error)
{
const char *dbus_message_bus_name = "org.sflphone.SFLphone";
const char *dbus_object_instance = "/org/sflphone/SFLphone/Instance";
const char *dbus_interface = "org.sflphone.SFLphone.Instance";
const char *callmanager_object_instance = "/org/sflphone/SFLphone/CallManager";
const char *callmanager_interface = "org.sflphone.SFLphone.CallManager";
const char *configurationmanager_object_instance = "/org/sflphone/SFLphone/ConfigurationManager";
const char *configurationmanager_interface = "org.sflphone.SFLphone.ConfigurationManager";
g_type_init();
DBusGConnection *connection = dbus_g_bus_get(DBUS_BUS_SESSION, error);
if (connection == NULL) {
ERROR("DBUS: Error, could not establish connection with session bus");
return FALSE;
}
/* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
DEBUG("Connect to message bus: %s", dbus_message_bus_name);
DEBUG(" object instance: %s", dbus_object_instance);
DEBUG(" dbus interface: %s", dbus_interface);
instance_proxy = dbus_g_proxy_new_for_name(connection,
"org.sflphone.SFLphone", "/org/sflphone/SFLphone/Instance",
"org.sflphone.SFLphone.Instance");
instance_proxy = dbus_g_proxy_new_for_name(connection, dbus_message_bus_name, dbus_object_instance, dbus_interface);
if (instance_proxy == NULL) {
ERROR("Failed to get proxy to Instance");
ERROR("Error: Failed to connect to %s", dbus_message_bus_name);
return FALSE;
}
DEBUG("DBus connected to Instance");
DEBUG("Connect to object instance: %s", callmanager_object_instance);
DEBUG(" dbus interface: %s", callmanager_interface);
call_proxy = dbus_g_proxy_new_for_name(connection, "org.sflphone.SFLphone",
"/org/sflphone/SFLphone/CallManager",
"org.sflphone.SFLphone.CallManager");
g_assert(call_proxy != NULL);
call_proxy = dbus_g_proxy_new_for_name(connection, dbus_message_bus_name, callmanager_object_instance, callmanager_interface);
if (call_proxy == NULL) {
ERROR("Error: Failed to connect to %s", callmanager_object_instance);
return FALSE;
}
DEBUG("DBus connected to CallManager");
/* STRING STRING STRING Marshaller */
/* Incoming call */
config_proxy = dbus_g_proxy_new_for_name(connection, dbus_message_bus_name, configurationmanager_object_instance, configurationmanager_interface);
if (config_proxy == NULL) {
ERROR("Error: Failed to connect to %s", configurationmanager_object_instance);
return FALSE;
}
/* Register INT Marshaller */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__INT,
G_TYPE_NONE, G_TYPE_INT, G_TYPE_INVALID);
/* Register STRING STRING STRING Marshaller */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING_STRING, G_TYPE_NONE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
/* Register STRING STRING INT Marshaller */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING_INT, G_TYPE_NONE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
/* Register STRING STRING Marshaller */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_INVALID);
/* Register STRING INT Marshaller */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_INT,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
/* Register STRING DOUBLE Marshaller */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_DOUBLE, G_TYPE_NONE, G_TYPE_STRING,
G_TYPE_DOUBLE, G_TYPE_INVALID);
/* Register STRING Marshaller */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
/* Register STRING STRING BOOL Marshaller */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING_BOOL, G_TYPE_NONE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
/* Register STRING Marshaller */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
DEBUG("Adding callmanager Dbus signals");
/* Incoming call */
dbus_g_proxy_add_signal(call_proxy, "newCallCreated", G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "newCallCreated",
G_CALLBACK(new_call_created_cb), NULL, NULL);
dbus_g_proxy_add_signal(call_proxy, "incomingCall", G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "incomingCall",
......@@ -659,17 +725,11 @@ gboolean dbus_connect(GError **error)
dbus_g_proxy_connect_signal(call_proxy, "zrtpNegotiationFailed",
G_CALLBACK(zrtp_negotiation_failed_cb), NULL, NULL);
/* Register a marshaller for STRING,STRING */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "callStateChanged", G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "callStateChanged",
G_CALLBACK(call_state_cb), NULL, NULL);
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_INT,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "voiceMailNotify", G_TYPE_STRING,
G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "voiceMailNotify",
......@@ -680,9 +740,6 @@ gboolean dbus_connect(GError **error)
dbus_g_proxy_connect_signal(call_proxy, "incomingMessage",
G_CALLBACK(incoming_message_cb), NULL, NULL);
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_DOUBLE, G_TYPE_NONE, G_TYPE_STRING,
G_TYPE_DOUBLE, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "volumeChanged", G_TYPE_STRING,
G_TYPE_DOUBLE, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "volumeChanged",
......@@ -697,9 +754,6 @@ gboolean dbus_connect(GError **error)
G_CALLBACK(transfer_failed_cb), NULL, NULL);
/* Conference related callback */
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "conferenceChanged", G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "conferenceChanged",
......@@ -720,12 +774,12 @@ gboolean dbus_connect(GError **error)
G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "recordPlaybackFilepath",
G_CALLBACK(record_playback_filepath_cb), NULL, NULL);
dbus_g_proxy_add_signal(call_proxy, "recordPlaybackStopped", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "recordPlaybackStopped",
G_CALLBACK(record_playback_stopped_cb), NULL, NULL);
/* Security related callbacks */
dbus_g_proxy_add_signal(call_proxy, "secureSdesOn", G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "secureSdesOn",
......@@ -736,10 +790,6 @@ gboolean dbus_connect(GError **error)
dbus_g_proxy_connect_signal(call_proxy, "secureSdesOff",
G_CALLBACK(secure_sdes_off_cb), NULL, NULL);
/* Register a marshaller for STRING,STRING,BOOL */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING_BOOL, G_TYPE_NONE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "showSAS", G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "showSAS",
......@@ -750,48 +800,43 @@ gboolean dbus_connect(GError **error)
dbus_g_proxy_connect_signal(call_proxy, "secureZrtpOn",
G_CALLBACK(secure_zrtp_on_cb), NULL, NULL);
/* Register a marshaller for STRING*/
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "secureZrtpOff", G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "secureZrtpOff",
G_CALLBACK(secure_zrtp_off_cb), NULL, NULL);
dbus_g_proxy_add_signal(call_proxy, "zrtpNotSuppOther", G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "zrtpNotSuppOther",
G_CALLBACK(zrtp_not_supported_cb), NULL, NULL);
dbus_g_proxy_add_signal(call_proxy, "confirmGoClear", G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "confirmGoClear",
G_CALLBACK(confirm_go_clear_cb), NULL, NULL);
/* VOID STRING STRING INT */
dbus_g_object_register_marshaller(
g_cclosure_user_marshal_VOID__STRING_STRING_INT, G_TYPE_NONE,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(call_proxy, "sipCallStateChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal(call_proxy, "sipCallStateChanged",
G_CALLBACK(sip_call_state_cb), NULL, NULL);
config_proxy = dbus_g_proxy_new_for_name(connection,
"org.sflphone.SFLphone",
"/org/sflphone/SFLphone/ConfigurationManager",
"org.sflphone.SFLphone.ConfigurationManager");
g_assert(config_proxy != NULL);
DEBUG("DBus connected to ConfigurationManager");
DEBUG("Adding configurationmanager Dbus signals");
dbus_g_proxy_add_signal(config_proxy, "accountsChanged", G_TYPE_INVALID);
dbus_g_proxy_connect_signal(config_proxy, "accountsChanged",
G_CALLBACK(accounts_changed_cb), NULL, NULL);
dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__INT,
G_TYPE_NONE, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(config_proxy, "errorAlert", G_TYPE_INT,
G_TYPE_INVALID);
dbus_g_proxy_add_signal(config_proxy, "stunStatusFailure", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(config_proxy, "stunStatusFailure",
G_CALLBACK(stun_status_failure_cb), NULL, NULL);
dbus_g_proxy_add_signal(config_proxy, "stunStatusSuccess", G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(config_proxy, "stunStatusSuccess",
G_CALLBACK(stun_status_success_cb), NULL, NULL);
dbus_g_proxy_add_signal(config_proxy, "errorAlert", G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(config_proxy, "errorAlert",
G_CALLBACK(error_alert), NULL, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment