This commit is contained in:
Mike Blumenkrantz 2016-02-19 14:05:42 -05:00
parent 33f735be17
commit 40616fb203
3 changed files with 116 additions and 54 deletions

View File

@ -171,6 +171,18 @@ group { name: "e/modules/wireless/wifi"; nomouse;
public message(Msg_Type:type, id, ...) {
if ((type == MSG_INT_SET) && (id == 1)) {
new state = getarg(2), signl = getarg(3);
if (state <= 1) {
set_state(PART:"wifi_1", "default", 0.0);
set_state(PART:"wifi_2", "default", 0.0);
set_state(PART:"wifi_3", "default", 0.0);
set_state(PART:"led", "default", 0.0);
}
if (state == 1) {
run_program(PROGRAM:"connecting");
run_program(PROGRAM:"connecting_wifi");
return;
}
stop_programs_on(PART:"led");
if (signl <= 14) {
set_state(PART:"wifi_1", "default", 0.0);
set_state(PART:"wifi_2", "default", 0.0);
@ -206,12 +218,7 @@ group { name: "e/modules/wireless/wifi"; nomouse;
set_state(PART:"wifi_2", "visible", 0.0);
set_state(PART:"wifi_3", "visible", 0.0);
}
if ((state == 1)) {
set_state(PART:"led", "default", 0.0);
run_program(PROGRAM:"connecting");
return;
}
else if ((state == 2)) { set_state(PART:"led", "connected", 0.0); }
if ((state == 2)) { set_state(PART:"led", "connected", 0.0); }
else if ((state == 3)) { set_state(PART:"led", "online", 0.0); }
else { set_state(PART:"led", "default", 0.0); }
}
@ -400,19 +407,42 @@ group { name: "e/modules/wireless/wifi"; nomouse;
}
}
}
programs {
program { name: "connecting";
action: STATE_SET "connected" 0.0;
target: "led";
in: 0.3 0.0;
after: "connecting2";
program { "connecting_wifi";
action: STATE_SET "default";
targets: "wifi_1" "wifi_2" "wifi_3";
sequence {
action: STATE_SET "partly";
target: "wifi_1";
transition: LINEAR 0.085;
action: STATE_SET "visible";
target: "wifi_1";
transition: LINEAR 0.085;
action: STATE_SET "partly";
target: "wifi_2";
transition: LINEAR 0.085;
action: STATE_SET "visible";
target: "wifi_2";
transition: LINEAR 0.085;
action: STATE_SET "partly";
target: "wifi_3";
transition: LINEAR 0.085;
action: STATE_SET "visible";
target: "wifi_3";
transition: LINEAR 0.085;
after: "connecting_wifi";
}
}
program { name: "connecting2";
action: STATE_SET "default" 0.0;
program { "connecting";
action: STATE_SET "connected";
target: "led";
in: 0.3 0.0;
after: "connecting";
sequence {
action: STATE_SET "default";
target: "led";
in: 0.3 0.0;
after: "connecting";
}
}
target_group: "clips" "clip_exclam" "clip_wifi";
program {

View File

@ -40,11 +40,11 @@ typedef enum
typedef enum
{
CONNMAN_SERVICE_TYPE_NONE = -1, /* All non-supported types */
CONNMAN_SERVICE_TYPE_ETHERNET,
CONNMAN_SERVICE_TYPE_WIFI,
CONNMAN_SERVICE_TYPE_BLUETOOTH,
CONNMAN_SERVICE_TYPE_CELLULAR,
CONNMAN_SERVICE_TYPE_LAST,
CONNMAN_SERVICE_TYPE_ETHERNET = 0,
CONNMAN_SERVICE_TYPE_WIFI = 1,
CONNMAN_SERVICE_TYPE_BLUETOOTH = 2,
CONNMAN_SERVICE_TYPE_CELLULAR = 3,
CONNMAN_SERVICE_TYPE_LAST = 4,
} Connman_Service_Type;
typedef struct Connman_Technology
@ -139,6 +139,22 @@ static Connman_Technology connman_technology[CONNMAN_SERVICE_TYPE_LAST];
/* connman -> wireless */
static Eina_Hash *connman_services_map[CONNMAN_SERVICE_TYPE_LAST];
static inline Eina_Bool
_connman_service_is_connected(const Connman_Service *cs)
{
return (cs->state >= CONNMAN_STATE_ASSOCIATION) && (cs->state <= CONNMAN_STATE_ONLINE);
}
static void
_eldbus_proxy_del(Eldbus_Proxy *proxy)
{
Eldbus_Object *obj;
obj = eldbus_proxy_object_get(proxy);
eldbus_proxy_unref(proxy);
eldbus_object_unref(obj);
}
static void
_connman_service_connect_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
{
@ -227,21 +243,23 @@ _connman_service_convert(Connman_Service *cs)
}
static void
_connman_update_current_network(Connman_Service *cs)
_connman_update_current_network(Connman_Service *cs, Connman_Service_Type type)
{
if (connman_current_service[cs->type] != cs)
if (connman_current_service[type] != cs)
{
E_FREE(connman_current_connection[cs->type]);
E_FREE(connman_current_connection[type]);
if (cs)
connman_current_connection[cs->type] = E_NEW(Wireless_Connection, 1);
connman_current_connection[type] = E_NEW(Wireless_Connection, 1);
}
connman_current_service[cs->type] = cs;
connman_current_service[type] = cs;
if (cs)
{
connman_current_connection[cs->type]->wn = eina_hash_find(connman_services_map[cs->type], &cs);
memcpy(&connman_current_connection[cs->type]->method,
connman_current_connection[type]->wn = eina_hash_find(connman_services_map[type], &cs);
memcpy(&connman_current_connection[type]->method,
&cs->method, sizeof(Wireless_Connection) - sizeof(void*));
}
else
connman_current_connection[type] = NULL;
wireless_wifi_current_networks_set(connman_current_connection);
}
@ -252,6 +270,7 @@ _connman_update_networks(Connman_Service_Type type)
Connman_Service *cs;
Wireless_Network *wn;
Eina_Hash *map;
Connman_Service *services[CONNMAN_SERVICE_TYPE_LAST] = {NULL};
map = connman_services_map[type];
connman_services_map[type] = eina_hash_pointer_new(free);
@ -261,12 +280,12 @@ _connman_update_networks(Connman_Service_Type type)
wn = _connman_service_convert(cs);
eina_hash_add(connman_services_map[type], &cs, wn);
eina_array_push(arr, wn);
if (connman_current_service[type] && (cs->state == CONNMAN_STATE_ONLINE))
connman_current_service[type] = cs;
if (connman_current_service[type] && _connman_service_is_connected(cs))
services[type] = cs;
}
memcpy(&connman_current_service, services, CONNMAN_SERVICE_TYPE_LAST * sizeof(void*));
arr = wireless_wifi_networks_set(arr);
if (connman_current_service[type])
_connman_update_current_network(connman_current_service[type]);
_connman_update_current_network(connman_current_service[type], type);
eina_hash_free(map);
eina_array_free(arr);
}
@ -332,8 +351,6 @@ str_to_security(const char *s)
static void
_connman_service_free(Connman_Service *cs)
{
Eldbus_Object *obj;
if (!cs) return;
if (cs->pending.connect)
@ -361,10 +378,8 @@ _connman_service_free(Connman_Service *cs)
eina_stringshare_del(cs->name);
eina_stringshare_del(cs->path);
eldbus_signal_handler_del(cs->handler);
obj = eldbus_proxy_object_get(cs->proxy);
DBG("service free %p || proxy %p", cs, cs->proxy);
eldbus_proxy_unref(cs->proxy);
eldbus_object_unref(obj);
_eldbus_proxy_del(cs->proxy);
connman_services_list[cs->type] = eina_inlist_remove(connman_services_list[cs->type], EINA_INLIST_GET(cs));
free(cs);
@ -479,8 +494,8 @@ _connman_service_prop_dict_changed(Connman_Service *cs, Eldbus_Message_Iter *pro
if (eldbus_message_iter_arguments_get(dict, "sv", &name, &var))
_connman_service_parse_prop_changed(cs, name, var);
}
if (cs->state == CONNMAN_STATE_ONLINE)
_connman_update_current_network(cs);
if (_connman_service_is_connected(cs))
_connman_update_current_network(cs, cs->type);
}
static void
@ -492,8 +507,8 @@ _connman_service_property(void *data, const Eldbus_Message *msg)
if (eldbus_message_arguments_get(msg, "sv", &name, &var))
_connman_service_parse_prop_changed(cs, name, var);
if (cs->state == CONNMAN_STATE_ONLINE)
_connman_update_current_network(cs);
if (_connman_service_is_connected(cs))
_connman_update_current_network(cs, cs->type);
}
static Connman_Service *
@ -557,7 +572,7 @@ _connman_technology_parse_prop_changed(Connman_Technology *ct, const char *name,
eldbus_message_iter_arguments_get(value, "b", &str);
ct->tethering_passwd = eina_stringshare_add(str);
}
return EINA_FALSE;
return ret;
}
static void
@ -645,6 +660,8 @@ _connman_manager_getservices(void *data EINA_UNUSED, const Eldbus_Message *msg,
Eina_Bool update[CONNMAN_SERVICE_TYPE_LAST] = {0};
pending_getservices = NULL;
for (i = 0; i < CONNMAN_SERVICE_TYPE_LAST; i++)
eina_hash_free_buckets(connman_services[i]);
if (eldbus_message_error_get(msg, &name, &text))
{
ERR("Could not get services. %s: %s", name, text);
@ -785,7 +802,7 @@ _connman_manager_event_services(void *data EINA_UNUSED, const Eldbus_Message *ms
cs = eina_hash_find(connman_services[i], path);
if (!cs) continue;
_connman_service_prop_dict_changed(cs, array);
update[cs->type] = 1;
found = update[cs->type] = 1;
DBG("Changed service: %p %s", cs, path);
break;
}
@ -1093,7 +1110,6 @@ _connman_start(void)
static void
_connman_end(Eina_Bool killed)
{
Eldbus_Object *obj;
int i;
if (!proxy_manager) return;
@ -1103,9 +1119,7 @@ _connman_end(Eina_Bool killed)
{
E_FREE_FUNC(connman_services[i], eina_hash_free);
if (!connman_technology[i].proxy) continue;
obj = eldbus_proxy_object_get(connman_technology[i].proxy);
E_FREE_FUNC(connman_technology[i].proxy, eldbus_proxy_unref);
eldbus_object_unref(obj);
E_FREE_FUNC(connman_technology[i].proxy, _eldbus_proxy_del);
}
E_FREE_FUNC(pending_getservices, eldbus_pending_cancel);
E_FREE_FUNC(pending_getproperties_manager, eldbus_pending_cancel);
@ -1114,8 +1128,7 @@ _connman_end(Eina_Bool killed)
else
E_FREE_LIST(signal_handlers, eldbus_signal_handler_del);
obj = eldbus_proxy_object_get(proxy_manager);
E_FREE_FUNC(proxy_manager, eldbus_proxy_unref);
E_FREE_FUNC(proxy_manager, _eldbus_proxy_del);
E_FREE_FUNC(agent_iface, eldbus_service_object_unregister);
}

View File

@ -47,11 +47,24 @@ static Eina_List *instances;
static Eina_List *wireless_auth_pending;
static Wireless_Auth_Popup *wireless_auth_popup;
#undef DBG
#undef INF
#undef WRN
#undef ERR
#define DBG(...) EINA_LOG_DOM_DBG(_wireless_gadget_log_dom, __VA_ARGS__)
#define INF(...) EINA_LOG_DOM_INFO(_wireless_gadget_log_dom, __VA_ARGS__)
#define WRN(...) EINA_LOG_DOM_WARN(_wireless_gadget_log_dom, __VA_ARGS__)
#define ERR(...) EINA_LOG_DOM_ERR(_wireless_gadget_log_dom, __VA_ARGS__)
static int _wireless_gadget_log_dom = -1;
static void
_wifi_icon_signal(Evas_Object *icon, int state, int strength)
{
Edje_Message_Int_Set *msg;
DBG("icon msg: %d %d%%", state, strength);
msg = alloca(sizeof(Edje_Message_Int_Set) + sizeof(int));
msg->count = 2;
msg->val[0] = state;
@ -74,6 +87,7 @@ _wifi_icon_init(Evas_Object *icon, Wireless_Network *wn)
if (!wn)
{
elm_object_signal_emit(icon, "e,state,default", "e");
elm_object_signal_emit(icon, "e,state,unsecured", "e");
return;
}
if (wn->state == WIRELESS_NETWORK_STATE_FAILURE)
@ -228,7 +242,7 @@ _wireless_gadget_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, v
e_comp_object_util_autoclose(inst->popup.popup, NULL, _wireless_popup_key, NULL);
zone = e_zone_current_get();
evas_object_resize(inst->popup.popup, zone->w / 5, zone->h / 4);
evas_object_resize(inst->popup.popup, zone->w / 5, zone->h / 3);
evas_object_show(inst->popup.popup);
evas_object_event_callback_add(inst->popup.popup, EVAS_CALLBACK_DEL, _wireless_popup_del, inst);
}
@ -317,6 +331,10 @@ wireless_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void
evas_object_hide(inst->popup.popup);
evas_object_del(inst->popup.popup);
free(inst);
if (instances) return;
eina_log_domain_unregister(_wireless_gadget_log_dom);
_wireless_gadget_log_dom = -1;
}
static void
@ -348,6 +366,7 @@ _wireless_gadget_refresh(Instance *inst)
elm_object_tooltip_content_cb_set(g, tooltip_cb[type], inst, NULL);
evas_object_event_callback_add(g, EVAS_CALLBACK_MOUSE_DOWN, _wireless_gadget_mouse_down, inst);
}
DBG("Updating icon for %d", type);
_wifi_icon_init(inst->icon[type], wireless_current[type] ? wireless_current[type]->wn : NULL);
evas_object_hide(inst->icon[type]);
avail++;
@ -362,6 +381,7 @@ _wireless_gadget_refresh(Instance *inst)
/* only show ethernet if it's connected or there's no wifi available */
if ((!inst->icon[WIRELESS_SERVICE_TYPE_WIFI]) ||
(wireless_current[type] &&
wireless_current[type]->wn &&
(wireless_current[type]->wn->state == WIRELESS_NETWORK_STATE_ONLINE)))
{
elm_box_pack_end(inst->box, inst->icon[type]);
@ -387,6 +407,8 @@ wireless_create(Evas_Object *parent, int *id, Z_Gadget_Site_Orient orient)
Evas_Object *g;
Instance *inst;
if (!instances)
_wireless_gadget_log_dom = eina_log_domain_register("wireless", EINA_COLOR_CYAN);
inst = E_NEW(Instance, 1);
inst->orient = orient;
inst->popup.type = inst->tooltip.type = -1;
@ -418,6 +440,7 @@ EINTERN void
wireless_gadget_init(void)
{
z_gadget_type_add("Wireless", wireless_create);
}
EINTERN void
@ -477,11 +500,7 @@ wireless_wifi_current_networks_set(Wireless_Connection **current)
}
}
}
for (type = 0; type < WIRELESS_SERVICE_TYPE_LAST; type++)
{
if (inst->icon[type] && wireless_current[type])
_wifi_icon_init(inst->icon[type], wireless_current[type]->wn);
}
_wireless_gadget_refresh(inst);
type = inst->tooltip.type;
if (type < 0) continue;
if (prev[type] &&