forked from enlightenment/enlightenment
e: Port wizard to edbus
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 81982
This commit is contained in:
parent
b8dbc2fa0e
commit
e3787e1b41
|
@ -1,7 +1,7 @@
|
|||
/* Setup if we need connman? */
|
||||
#include "e_wizard.h"
|
||||
#ifdef HAVE_ECONNMAN
|
||||
#include <E_DBus.h>
|
||||
#include <EDBus.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
|
@ -38,10 +38,19 @@ _recommend_connman(E_Wizard_Page *pg)
|
|||
e_wizard_button_next_enable_set(1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ECONNMAN
|
||||
static DBusPendingCall *pending_connman;
|
||||
static EDBus_Connection *conn;
|
||||
static EDBus_Pending *pending_connman;
|
||||
static Ecore_Timer *connman_timeout = NULL;
|
||||
|
||||
static Eina_Bool
|
||||
clean_dbus(void *data)
|
||||
{
|
||||
EDBus_Connection *conn2 = data;
|
||||
edbus_connection_unref(conn2);
|
||||
edbus_shutdown();
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_connman_fail(void *data)
|
||||
{
|
||||
|
@ -65,18 +74,24 @@ _connman_fail(void *data)
|
|||
e_config_save_queue();
|
||||
if (pending_connman)
|
||||
{
|
||||
dbus_pending_call_cancel(pending_connman);
|
||||
edbus_pending_cancel(pending_connman);
|
||||
pending_connman = NULL;
|
||||
}
|
||||
if (conn)
|
||||
{
|
||||
ecore_idler_add(clean_dbus, conn);
|
||||
conn = NULL;
|
||||
}
|
||||
connman_timeout = NULL;
|
||||
_recommend_connman(pg);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_check_connman_owner(void *data, DBusMessage *msg,
|
||||
DBusError *err __UNUSED__)
|
||||
_check_connman_owner(void *data, const EDBus_Message *msg,
|
||||
EDBus_Pending *pending __UNUSED__)
|
||||
{
|
||||
const char *id;
|
||||
pending_connman = NULL;
|
||||
|
||||
if (connman_timeout)
|
||||
|
@ -85,17 +100,27 @@ _check_connman_owner(void *data, DBusMessage *msg,
|
|||
connman_timeout = NULL;
|
||||
}
|
||||
|
||||
if (!msg)
|
||||
{
|
||||
_connman_fail(data);
|
||||
return;
|
||||
}
|
||||
if (edbus_message_error_get(msg, NULL, NULL))
|
||||
goto fail;
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "s", &id))
|
||||
goto fail;
|
||||
|
||||
if (id[0] != ':')
|
||||
goto fail;
|
||||
|
||||
e_wizard_button_next_enable_set(1);
|
||||
e_wizard_next();
|
||||
if (conn)
|
||||
{
|
||||
ecore_idler_add(clean_dbus, conn);
|
||||
conn = NULL;
|
||||
}
|
||||
fail:
|
||||
_connman_fail(data);
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
|
||||
EAPI int
|
||||
wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UNUSED__, Eina_Bool *need_xdg_icons __UNUSED__)
|
||||
{
|
||||
|
@ -112,18 +137,18 @@ EAPI int
|
|||
wizard_page_show(E_Wizard_Page *pg)
|
||||
{
|
||||
int have_connman = 0;
|
||||
#ifdef HAVE_ECONNMAN
|
||||
E_DBus_Connection *c;
|
||||
|
||||
c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
|
||||
if (c)
|
||||
#ifdef HAVE_ECONNMAN
|
||||
edbus_init();
|
||||
conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SYSTEM);
|
||||
#endif
|
||||
if (conn)
|
||||
{
|
||||
if (pending_connman)
|
||||
dbus_pending_call_cancel(pending_connman);
|
||||
edbus_pending_cancel(pending_connman);
|
||||
|
||||
pending_connman = e_dbus_name_has_owner(c, "net.connman",
|
||||
_check_connman_owner,
|
||||
pg);
|
||||
pending_connman = edbus_name_owner_get(conn, "net.connman",
|
||||
_check_connman_owner, pg);
|
||||
if (pending_connman)
|
||||
{
|
||||
if (connman_timeout) ecore_timer_del(connman_timeout);
|
||||
|
@ -132,12 +157,12 @@ wizard_page_show(E_Wizard_Page *pg)
|
|||
e_wizard_button_next_enable_set(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!have_connman)
|
||||
{
|
||||
E_Config_Module *em;
|
||||
Eina_List *l;
|
||||
|
||||
edbus_shutdown();
|
||||
EINA_LIST_FOREACH(e_config->modules, l, em)
|
||||
{
|
||||
if (!em->name) continue;
|
||||
|
@ -160,10 +185,9 @@ wizard_page_show(E_Wizard_Page *pg)
|
|||
EAPI int
|
||||
wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
|
||||
{
|
||||
#ifdef HAVE_ECONNMAN
|
||||
if (pending_connman)
|
||||
{
|
||||
dbus_pending_call_cancel(pending_connman);
|
||||
edbus_pending_cancel(pending_connman);
|
||||
pending_connman = NULL;
|
||||
}
|
||||
if (connman_timeout)
|
||||
|
@ -171,7 +195,6 @@ wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
|
|||
ecore_timer_del(connman_timeout);
|
||||
connman_timeout = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue