2011-08-15 02:21:12 -07:00
|
|
|
/* Setup if we need connman? */
|
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
2011-11-14 12:58:12 -08:00
|
|
|
#ifdef HAVE_ECONNMAN
|
2012-09-03 14:57:16 -07:00
|
|
|
#include <E_DBus.h>
|
2011-08-15 02:21:12 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
_recommend_connman(E_Wizard_Page *pg)
|
|
|
|
{
|
|
|
|
Evas_Object *o, *of, *ob;
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
o = e_widget_list_add(pg->evas, 1, 0);
|
|
|
|
e_wizard_title_set(_("Network Management"));
|
|
|
|
|
2012-11-26 03:30:16 -08:00
|
|
|
#ifdef HAVE_ECONNMAN
|
2012-06-28 06:12:13 -07:00
|
|
|
of = e_widget_framelist_add(pg->evas,
|
2011-08-15 02:21:12 -07:00
|
|
|
_("Connman network service not found"), 0);
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
ob = e_widget_label_add
|
2012-06-28 06:12:13 -07:00
|
|
|
(pg->evas, _("Install Connman for network management support"));
|
2012-11-26 03:30:16 -08:00
|
|
|
#else
|
|
|
|
of = e_widget_framelist_add(pg->evas,
|
|
|
|
_("Connman support disabled"), 0);
|
|
|
|
|
|
|
|
ob = e_widget_label_add
|
|
|
|
(pg->evas, _("Install/Enable Connman for network management support"));
|
|
|
|
#endif
|
2011-08-15 02:21:12 -07:00
|
|
|
e_widget_framelist_object_append(of, ob);
|
|
|
|
evas_object_show(ob);
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
e_widget_list_object_append(o, of, 0, 0, 0.5);
|
|
|
|
evas_object_show(ob);
|
|
|
|
evas_object_show(of);
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
e_wizard_page_show(o);
|
2011-08-30 17:05:44 -07:00
|
|
|
// pg->data = o;
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
e_wizard_button_next_enable_set(1);
|
|
|
|
}
|
|
|
|
|
2011-10-16 08:24:47 -07:00
|
|
|
#ifdef HAVE_ECONNMAN
|
2012-09-03 14:57:16 -07:00
|
|
|
static DBusPendingCall *pending_connman;
|
|
|
|
static Ecore_Timer *connman_timeout = NULL;
|
2011-08-15 02:21:12 -07:00
|
|
|
|
|
|
|
static Eina_Bool
|
2012-09-03 14:57:16 -07:00
|
|
|
_connman_fail(void *data)
|
2011-08-15 02:21:12 -07:00
|
|
|
{
|
|
|
|
E_Wizard_Page *pg = data;
|
|
|
|
E_Config_Module *em;
|
|
|
|
Eina_List *l;
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
|
|
|
{
|
|
|
|
if (!em->name) continue;
|
|
|
|
if (!strcmp(em->name, "connman"))
|
|
|
|
{
|
|
|
|
e_config->modules = eina_list_remove_list
|
2012-06-28 06:12:13 -07:00
|
|
|
(e_config->modules, l);
|
2011-08-15 02:21:12 -07:00
|
|
|
if (em->name) eina_stringshare_del(em->name);
|
|
|
|
free(em);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-09-03 14:57:16 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
e_config_save_queue();
|
2012-09-03 14:57:16 -07:00
|
|
|
if (pending_connman)
|
2011-08-15 02:21:12 -07:00
|
|
|
{
|
2012-09-03 14:57:16 -07:00
|
|
|
dbus_pending_call_cancel(pending_connman);
|
|
|
|
pending_connman = NULL;
|
2011-08-15 02:21:12 -07:00
|
|
|
}
|
2012-09-03 14:57:16 -07:00
|
|
|
connman_timeout = NULL;
|
2011-08-15 02:21:12 -07:00
|
|
|
_recommend_connman(pg);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2012-09-03 14:57:16 -07:00
|
|
|
static void
|
2012-09-15 14:46:38 -07:00
|
|
|
_check_connman_owner(void *data, DBusMessage *msg,
|
|
|
|
DBusError *err __UNUSED__)
|
2012-09-03 14:57:16 -07:00
|
|
|
{
|
|
|
|
pending_connman = NULL;
|
|
|
|
|
|
|
|
if (connman_timeout)
|
|
|
|
{
|
|
|
|
ecore_timer_del(connman_timeout);
|
|
|
|
connman_timeout = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msg)
|
|
|
|
{
|
|
|
|
_connman_fail(data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e_wizard_button_next_enable_set(1);
|
|
|
|
e_wizard_next();
|
|
|
|
}
|
2011-10-16 08:24:47 -07:00
|
|
|
#endif
|
2011-08-15 02:21:12 -07:00
|
|
|
|
|
|
|
EAPI int
|
|
|
|
wizard_page_init(E_Wizard_Page *pg __UNUSED__)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
wizard_page_shutdown(E_Wizard_Page *pg __UNUSED__)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
wizard_page_show(E_Wizard_Page *pg)
|
|
|
|
{
|
2011-10-16 08:24:47 -07:00
|
|
|
int have_connman = 0;
|
2012-11-26 03:30:16 -08:00
|
|
|
#ifdef HAVE_ECONNMAN
|
2011-08-15 02:21:12 -07:00
|
|
|
E_DBus_Connection *c;
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
c = e_dbus_bus_get(DBUS_BUS_SYSTEM);
|
|
|
|
if (c)
|
|
|
|
{
|
2012-09-03 14:57:16 -07:00
|
|
|
if (pending_connman)
|
|
|
|
dbus_pending_call_cancel(pending_connman);
|
|
|
|
|
|
|
|
pending_connman = e_dbus_name_has_owner(c, "net.connman",
|
|
|
|
_check_connman_owner,
|
|
|
|
pg);
|
|
|
|
if (pending_connman)
|
2011-08-15 02:21:12 -07:00
|
|
|
{
|
|
|
|
if (connman_timeout) ecore_timer_del(connman_timeout);
|
2012-09-03 14:57:16 -07:00
|
|
|
connman_timeout = ecore_timer_add(2.0, _connman_fail, pg);
|
2011-10-16 08:24:47 -07:00
|
|
|
have_connman = 1;
|
2011-08-15 02:21:12 -07:00
|
|
|
e_wizard_button_next_enable_set(0);
|
|
|
|
}
|
|
|
|
}
|
2012-11-26 03:30:16 -08:00
|
|
|
#endif
|
2011-10-16 08:24:47 -07:00
|
|
|
if (!have_connman)
|
2011-08-15 02:21:12 -07:00
|
|
|
{
|
|
|
|
E_Config_Module *em;
|
|
|
|
Eina_List *l;
|
2012-06-28 06:12:13 -07:00
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
|
|
|
{
|
|
|
|
if (!em->name) continue;
|
|
|
|
if (!strcmp(em->name, "connman"))
|
|
|
|
{
|
|
|
|
e_config->modules = eina_list_remove_list
|
2012-06-28 06:12:13 -07:00
|
|
|
(e_config->modules, l);
|
2011-08-15 02:21:12 -07:00
|
|
|
if (em->name) eina_stringshare_del(em->name);
|
|
|
|
free(em);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e_config_save_queue();
|
|
|
|
_recommend_connman(pg);
|
|
|
|
}
|
|
|
|
e_wizard_title_set(_("Checking to see if Connman exists"));
|
|
|
|
return 1; /* 1 == show ui, and wait for user, 0 == just continue */
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
wizard_page_hide(E_Wizard_Page *pg __UNUSED__)
|
|
|
|
{
|
2012-09-03 14:57:16 -07:00
|
|
|
#ifdef HAVE_ECONNMAN
|
|
|
|
if (pending_connman)
|
2011-08-15 02:21:12 -07:00
|
|
|
{
|
2012-09-03 14:57:16 -07:00
|
|
|
dbus_pending_call_cancel(pending_connman);
|
|
|
|
pending_connman = NULL;
|
2011-08-15 02:21:12 -07:00
|
|
|
}
|
|
|
|
if (connman_timeout)
|
|
|
|
{
|
|
|
|
ecore_timer_del(connman_timeout);
|
|
|
|
connman_timeout = NULL;
|
|
|
|
}
|
2012-09-03 14:57:16 -07:00
|
|
|
#endif
|
|
|
|
|
2011-08-15 02:21:12 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
wizard_page_apply(E_Wizard_Page *pg __UNUSED__)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2012-06-28 06:12:13 -07:00
|
|
|
|