diff --git a/meson.build b/meson.build index c316a18..c46bfb9 100644 --- a/meson.build +++ b/meson.build @@ -13,18 +13,28 @@ evas = dependency('evas') edje = dependency('edje') eina = dependency('eina') -# Get Enlightenment module API version -e_version = enlightenment.version().split('.') -e_major = e_version[0] -e_minor = e_version[1] +# Get Enlightenment version and module architecture +e_version = enlightenment.version() + +# Detect system ABI (gnu, musl, etc.) +cc = meson.get_compiler('c') +if cc.has_header('features.h') + # GNU libc systems + system_abi = 'gnu' +else + # Try to detect from system - fallback to 'unknown' + system_abi = 'unknown' +endif # Installation paths module_name = 'iwd' -module_arch = '@0@-@1@-@2@.@3@'.format( +# Format: --- +# Example: linux-gnu-x86_64-0.27.1 +module_arch = '@0@-@1@-@2@-@3@'.format( host_machine.system(), + system_abi, host_machine.cpu_family(), - e_major, - e_minor + e_version ) dir_module = join_paths(get_option('libdir'), 'enlightenment', 'modules', module_name) diff --git a/metadata/layout.conf b/metadata/layout.conf new file mode 100644 index 0000000..7a111f5 --- /dev/null +++ b/metadata/layout.conf @@ -0,0 +1,2 @@ +masters = gentoo +repo-name = x-eiwd diff --git a/packaging/gentoo/eiwd-0.1.0.ebuild b/packaging/gentoo/eiwd-0.1.0.ebuild index 45e8ee0..b5433d1 100644 --- a/packaging/gentoo/eiwd-0.1.0.ebuild +++ b/packaging/gentoo/eiwd-0.1.0.ebuild @@ -6,14 +6,16 @@ EAPI=8 inherit meson DESCRIPTION="Enlightenment Wi-Fi module using iwd backend" -HOMEPAGE="https://github.com/yourusername/eiwd" -SRC_URI="https://github.com/yourusername/eiwd/archive/v${PV}.tar.gz -> ${P}.tar.gz" +HOMEPAGE="https://git.nemunai.re/nemunaire/eiwd" +SRC_URI="https://git.nemunai.re/nemunaire/eiwd/archive/v${PV}.tar.gz -> ${P}.tar.gz" -LICENSE="BSD" # Adjust based on chosen license +LICENSE="BSD" SLOT="0" KEYWORDS="~amd64 ~x86 ~arm64" IUSE="nls" +S="${WORKDIR}/${PN}" + RDEPEND=" >=x11-wm/enlightenment-0.25.0 >=dev-libs/efl-1.26.0 diff --git a/packaging/profiles/repo_name b/packaging/profiles/repo_name new file mode 100644 index 0000000..6506ebe --- /dev/null +++ b/packaging/profiles/repo_name @@ -0,0 +1 @@ +x-eiwd diff --git a/src/e_mod_gadget.c b/src/e_mod_gadget.c index a8c07a0..78ff615 100644 --- a/src/e_mod_gadget.c +++ b/src/e_mod_gadget.c @@ -63,21 +63,8 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) inst = E_NEW(Instance, 1); if (!inst) return NULL; - /* Create gadcon client */ - gcc = e_gadcon_client_new(gc, name, id, style, NULL); - if (!gcc) - { - E_FREE(inst); - return NULL; - } - - gcc->data = inst; - inst->gcc = gcc; - - /* Create icon */ - o = edje_object_add(gcc->gadcon->evas); - inst->icon = o; - inst->gadget = o; + /* Create edje object */ + o = edje_object_add(gc->evas); /* Load theme */ char theme_path[PATH_MAX]; @@ -91,18 +78,26 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) evas_object_color_set(o, 100, 150, 200, 255); } - evas_object_resize(o, 16, 16); evas_object_show(o); + /* Pass the object directly to e_gadcon_client_new */ + gcc = e_gadcon_client_new(gc, name, id, style, o); + if (!gcc) + { + evas_object_del(o); + E_FREE(inst); + return NULL; + } + + gcc->data = inst; + inst->gcc = gcc; + inst->icon = o; + inst->gadget = o; + /* Add mouse event handler */ evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _gadget_mouse_down_cb, inst); - /* Set gadcon object */ - e_gadcon_client_min_size_set(gcc, 16, 16); - e_gadcon_client_aspect_set(gcc, 16, 16); - e_gadcon_client_show(gcc); - /* Get first available device */ Eina_List *devices = iwd_devices_get(); if (devices && eina_list_count(devices) > 0) @@ -164,8 +159,21 @@ _gc_shutdown(E_Gadcon_Client *gcc) static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient EINA_UNUSED) { - e_gadcon_client_aspect_set(gcc, 16, 16); - e_gadcon_client_min_size_set(gcc, 16, 16); + Instance *inst; + Evas_Coord mw, mh; + + inst = gcc->data; + if (!inst || !inst->icon) return; + + mw = 0; + mh = 0; + edje_object_size_min_get(inst->icon, &mw, &mh); + if ((mw < 1) || (mh < 1)) + edje_object_size_min_calc(inst->icon, &mw, &mh); + if (mw < 4) mw = 4; + if (mh < 4) mh = 4; + e_gadcon_client_aspect_set(gcc, mw, mh); + e_gadcon_client_min_size_set(gcc, mw, mh); } /* Gadcon label */ @@ -194,25 +202,30 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas) { /* Fallback to simple colored box */ evas_object_color_set(o, 100, 150, 200, 255); + evas_object_resize(o, 16, 16); } } else { /* Fallback if module not initialized yet */ evas_object_color_set(o, 100, 150, 200, 255); + evas_object_resize(o, 16, 16); } - evas_object_resize(o, 16, 16); + evas_object_show(o); return o; } /* Generate new ID */ static const char * -_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED) +_gc_id_new(const E_Gadcon_Client_Class *client_class) { - static char buf[32]; - snprintf(buf, sizeof(buf), "%s.%d", _gc_class.name, rand()); + static char buf[128]; + Mod *mod = iwd_mod; + + snprintf(buf, sizeof(buf), "%s.%d", client_class->name, + mod ? eina_list_count(mod->instances) + 1 : 1); return buf; } @@ -225,19 +238,36 @@ _gadget_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Instance *inst = data; Evas_Event_Mouse_Down *ev = event_info; - if (!inst) return; + if (!inst) + { + e_util_dialog_show("Debug", "Instance is NULL!"); + return; + } if (ev->button == 1) /* Left click */ { + INF("Gadget clicked - popup=%p device=%p", inst->popup, inst->device); + if (inst->popup) { /* Close popup */ + INF("Closing popup"); iwd_popup_del(inst); } else { /* Open popup */ + INF("Opening popup"); iwd_popup_new(inst); + + /* Debug: Check if popup was created */ + if (!inst->popup) + { + ERR("Failed to create popup!"); + e_util_dialog_show("IWD Debug", + "Popup creation failed.
" + "Check if iwd is running and wireless device exists."); + } } } } diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 4dd0605..cf4bbff 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -87,13 +87,15 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED) /* Shutdown gadget */ e_iwd_gadget_shutdown(); - /* Shutdown D-Bus and iwd subsystems */ - iwd_agent_shutdown(); - iwd_dbus_shutdown(); + /* Shutdown iwd subsystems (must happen before D-Bus shutdown) */ iwd_network_shutdown(); iwd_device_shutdown(); iwd_state_shutdown(); + /* Shutdown D-Bus (this frees all proxies and handlers) */ + iwd_agent_shutdown(); + iwd_dbus_shutdown(); + /* Free configuration */ _iwd_config_free(); e_iwd_config_shutdown(); diff --git a/src/e_mod_popup.c b/src/e_mod_popup.c index ecd2410..bbada58 100644 --- a/src/e_mod_popup.c +++ b/src/e_mod_popup.c @@ -18,16 +18,31 @@ iwd_popup_new(Instance *inst) IWD_Network *net; Eina_List *l; - if (!inst) return; - if (inst->popup) return; + if (!inst) + { + ERR("iwd_popup_new: inst is NULL"); + return; + } - DBG("Creating popup"); + if (inst->popup) + { + DBG("Popup already exists"); + return; + } + + INF("Creating popup for instance %p", inst); /* Create popup */ popup = e_gadcon_popup_new(inst->gcc, 0); - if (!popup) return; + if (!popup) + { + ERR("e_gadcon_popup_new failed!"); + e_util_dialog_show("IWD Error", "Failed to create gadcon popup"); + return; + } inst->popup = (void *)popup; + INF("Popup created: %p", popup); /* Create main box */ box = elm_box_add(e_comp->elm); diff --git a/src/iwd/iwd_agent.c b/src/iwd/iwd_agent.c index 15cd654..653f5b4 100644 --- a/src/iwd/iwd_agent.c +++ b/src/iwd/iwd_agent.c @@ -66,6 +66,12 @@ iwd_agent_init(void) return EINA_FALSE; } + /* Initialize fields */ + iwd_agent->manager_obj = NULL; + iwd_agent->pending_network_path = NULL; + iwd_agent->pending_passphrase = NULL; + iwd_agent->pending_msg = NULL; + /* Register D-Bus service interface */ iwd_agent->iface = eldbus_service_interface_register(conn, IWD_AGENT_PATH, &agent_desc); if (!iwd_agent->iface) @@ -76,11 +82,11 @@ iwd_agent_init(void) return EINA_FALSE; } - /* Register agent with iwd */ - obj = eldbus_object_get(conn, IWD_SERVICE, IWD_MANAGER_PATH); + /* Register agent with iwd daemon (AgentManager is at /net/connman/iwd) */ + obj = eldbus_object_get(conn, IWD_SERVICE, IWD_DAEMON_PATH); if (!obj) { - ERR("Failed to get iwd manager object"); + ERR("Failed to get iwd daemon object"); eldbus_service_interface_unregister(iwd_agent->iface); E_FREE(iwd_agent); iwd_agent = NULL; @@ -98,11 +104,12 @@ iwd_agent_init(void) return EINA_FALSE; } + /* Store object reference to keep it alive during async call */ + iwd_agent->manager_obj = obj; + eldbus_proxy_call(proxy, "RegisterAgent", _agent_register_cb, NULL, -1, "o", IWD_AGENT_PATH); - eldbus_object_unref(obj); - - INF("Agent initialized"); + INF("Agent initialization started"); return EINA_TRUE; } @@ -119,6 +126,9 @@ iwd_agent_shutdown(void) if (iwd_agent->iface) eldbus_service_interface_unregister(iwd_agent->iface); + if (iwd_agent->manager_obj) + eldbus_object_unref(iwd_agent->manager_obj); + eina_stringshare_del(iwd_agent->pending_network_path); eina_stringshare_del(iwd_agent->pending_passphrase); @@ -216,7 +226,7 @@ _agent_unregister(void) conn = iwd_dbus_conn_get(); if (!conn) return; - obj = eldbus_object_get(conn, IWD_SERVICE, IWD_MANAGER_PATH); + obj = eldbus_object_get(conn, IWD_SERVICE, IWD_DAEMON_PATH); if (!obj) return; proxy = eldbus_proxy_get(obj, IWD_AGENT_MANAGER_INTERFACE); diff --git a/src/iwd/iwd_agent.h b/src/iwd/iwd_agent.h index 37df935..455f943 100644 --- a/src/iwd/iwd_agent.h +++ b/src/iwd/iwd_agent.h @@ -10,6 +10,7 @@ typedef struct _IWD_Agent { Eldbus_Service_Interface *iface; + Eldbus_Object *manager_obj; /* Keep reference to prevent call cancellation */ const char *pending_network_path; const char *pending_passphrase; const Eldbus_Message *pending_msg; /* Stored message to reply to */ diff --git a/src/iwd/iwd_dbus.c b/src/iwd/iwd_dbus.c index e5166bd..b19f3a0 100644 --- a/src/iwd/iwd_dbus.c +++ b/src/iwd/iwd_dbus.c @@ -157,24 +157,17 @@ _iwd_dbus_disconnect(void) DBG("Disconnecting from iwd daemon"); - if (iwd_dbus->interfaces_added) - { - eldbus_signal_handler_del(iwd_dbus->interfaces_added); - iwd_dbus->interfaces_added = NULL; - } - - if (iwd_dbus->interfaces_removed) - { - eldbus_signal_handler_del(iwd_dbus->interfaces_removed); - iwd_dbus->interfaces_removed = NULL; - } - + /* Unref the object first - this will clean up associated signal handlers */ if (iwd_dbus->manager_obj) { eldbus_object_unref(iwd_dbus->manager_obj); iwd_dbus->manager_obj = NULL; } + /* Clear handler pointers (they're already freed by object unref) */ + iwd_dbus->interfaces_added = NULL; + iwd_dbus->interfaces_removed = NULL; + iwd_dbus->connected = EINA_FALSE; } diff --git a/src/iwd/iwd_dbus.h b/src/iwd/iwd_dbus.h index 638e138..0078350 100644 --- a/src/iwd/iwd_dbus.h +++ b/src/iwd/iwd_dbus.h @@ -7,6 +7,7 @@ /* iwd D-Bus service and interfaces */ #define IWD_SERVICE "net.connman.iwd" #define IWD_MANAGER_PATH "/" +#define IWD_DAEMON_PATH "/net/connman/iwd" #define IWD_MANAGER_INTERFACE "net.connman.iwd.Manager" #define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter" #define IWD_DEVICE_INTERFACE "net.connman.iwd.Device"