e: Port e_msgbus to edbus
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 81980
This commit is contained in:
parent
aba6a0090c
commit
a84987cd60
|
@ -1,39 +1,39 @@
|
|||
#include "e.h"
|
||||
|
||||
/* local subsystem functions */
|
||||
static void _e_msgbus_request_name_cb(void *data,
|
||||
DBusMessage *msg,
|
||||
DBusError *err);
|
||||
static void _e_msgbus_request_name_cb(void *data, const EDBus_Message *msg,
|
||||
EDBus_Pending *pending);
|
||||
|
||||
static DBusMessage *_e_msgbus_core_restart_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_core_shutdown_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static EDBus_Message *_e_msgbus_core_restart_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_core_shutdown_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
|
||||
static DBusMessage *_e_msgbus_module_load_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_module_unload_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_module_enable_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_module_disable_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_module_list_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static EDBus_Message *_e_msgbus_module_load_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_module_unload_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_module_enable_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_module_disable_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_module_list_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
|
||||
static DBusMessage *_e_msgbus_profile_set_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_profile_get_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_profile_list_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_profile_add_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static DBusMessage *_e_msgbus_profile_delete_cb(E_DBus_Object *obj,
|
||||
DBusMessage *msg);
|
||||
static EDBus_Message *_e_msgbus_profile_set_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_profile_get_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_profile_list_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_profile_add_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
static EDBus_Message *_e_msgbus_profile_delete_cb(const EDBus_Service_Interface *iface,
|
||||
const EDBus_Message *msg);
|
||||
|
||||
#define E_MSGBUS_WIN_ACTION_CB_PROTO(NAME) \
|
||||
static DBusMessage *_e_msgbus_window_##NAME##_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
static EDBus_Message *_e_msgbus_window_##NAME##_cb(const EDBus_Service_Interface *iface, \
|
||||
const EDBus_Message *msg)
|
||||
|
||||
E_MSGBUS_WIN_ACTION_CB_PROTO(list);
|
||||
E_MSGBUS_WIN_ACTION_CB_PROTO(close);
|
||||
|
@ -47,165 +47,213 @@ E_MSGBUS_WIN_ACTION_CB_PROTO(unmaximize);
|
|||
/* local subsystem globals */
|
||||
static E_Msgbus_Data *_e_msgbus_data = NULL;
|
||||
|
||||
static const EDBus_Method core_methods[] = {
|
||||
{
|
||||
"Restart", NULL, NULL, _e_msgbus_core_restart_cb, 0
|
||||
},
|
||||
{
|
||||
"Shutdown", NULL, NULL, _e_msgbus_core_shutdown_cb, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Method module_methods[] = {
|
||||
{
|
||||
"Load", EDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_load_cb, 0
|
||||
},
|
||||
{
|
||||
"Unload", EDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_unload_cb, 0
|
||||
},
|
||||
{
|
||||
"Enable", EDBUS_ARGS({"s", "module"}), NULL, _e_msgbus_module_enable_cb, 0
|
||||
},
|
||||
{
|
||||
"Disable", EDBUS_ARGS({"s", "module"}), NULL,
|
||||
_e_msgbus_module_disable_cb, 0
|
||||
},
|
||||
{
|
||||
"List", NULL, EDBUS_ARGS({"a(si)", "array_of_modules"}),
|
||||
_e_msgbus_module_list_cb, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Method profile_methods[] = {
|
||||
{
|
||||
"Set", EDBUS_ARGS({"s", "profile"}), NULL, _e_msgbus_profile_set_cb, 0
|
||||
},
|
||||
{
|
||||
"Get", NULL, EDBUS_ARGS({"s", "profile"}), _e_msgbus_profile_get_cb, 0
|
||||
},
|
||||
{
|
||||
"List", NULL, EDBUS_ARGS({"as", "array_profiles"}),
|
||||
_e_msgbus_profile_list_cb, 0
|
||||
},
|
||||
{
|
||||
"Add", EDBUS_ARGS({"s", "profile"}), NULL,
|
||||
_e_msgbus_profile_add_cb, 0
|
||||
},
|
||||
{
|
||||
"Delete", EDBUS_ARGS({"s", "profile"}), NULL,
|
||||
_e_msgbus_profile_delete_cb, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Method window_methods[] = {
|
||||
{
|
||||
"List", NULL, EDBUS_ARGS({"a(si)", "array_of_window"}),
|
||||
_e_msgbus_window_list_cb, 0
|
||||
},
|
||||
{
|
||||
"Close", EDBUS_ARGS({"i", "window_id"}), NULL, _e_msgbus_window_close_cb, 0
|
||||
},
|
||||
{
|
||||
"Kill", EDBUS_ARGS({"i", "window_id"}), NULL, _e_msgbus_window_kill_cb, 0
|
||||
},
|
||||
{
|
||||
"Focus", EDBUS_ARGS({"i", "window_id"}),
|
||||
NULL, _e_msgbus_window_focus_cb, 0
|
||||
},
|
||||
{
|
||||
"Iconify", EDBUS_ARGS({"i", "window_id"}), NULL,
|
||||
_e_msgbus_window_iconify_cb, 0
|
||||
},
|
||||
{
|
||||
"Uniconify", EDBUS_ARGS({"i", "window_id"}), NULL,
|
||||
_e_msgbus_window_uniconify_cb, 0
|
||||
},
|
||||
{
|
||||
"Maximize", EDBUS_ARGS({"i", "window_id"}), NULL,
|
||||
_e_msgbus_window_maximize_cb, 0
|
||||
},
|
||||
{
|
||||
"Unmaximize", EDBUS_ARGS({"i", "window_id"}), NULL,
|
||||
_e_msgbus_window_unmaximize_cb, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
#define PATH "/org/enlightenment/wm/RemoteObject"
|
||||
|
||||
static const EDBus_Service_Interface_Desc core_desc = {
|
||||
"org.enlightenment.wm.Core", core_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc module_desc = {
|
||||
"org.enlightenment.wm.Module", module_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc profile_desc = {
|
||||
"org.enlightenment.wm.Profile", profile_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc window_desc = {
|
||||
"org.enlightenment.wm.Window", window_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/* externally accessible functions */
|
||||
EINTERN int
|
||||
e_msgbus_init(void)
|
||||
{
|
||||
E_DBus_Interface *iface;
|
||||
|
||||
_e_msgbus_data = E_NEW(E_Msgbus_Data, 1);
|
||||
|
||||
e_dbus_init();
|
||||
#ifdef HAVE_HAL
|
||||
e_hal_init();
|
||||
#endif
|
||||
edbus_init();
|
||||
|
||||
_e_msgbus_data->conn = e_dbus_bus_get(DBUS_BUS_SESSION);
|
||||
_e_msgbus_data->conn = edbus_connection_get(EDBUS_CONNECTION_TYPE_SESSION);
|
||||
if (!_e_msgbus_data->conn)
|
||||
{
|
||||
WRN("Cannot get DBUS_BUS_SESSION");
|
||||
WRN("Cannot get EDBUS_CONNECTION_TYPE_SESSION");
|
||||
return 0;
|
||||
}
|
||||
e_dbus_request_name(_e_msgbus_data->conn, "org.enlightenment.wm.service", 0, _e_msgbus_request_name_cb, NULL);
|
||||
_e_msgbus_data->obj = e_dbus_object_add(_e_msgbus_data->conn, "/org/enlightenment/wm/RemoteObject", NULL);
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Core");
|
||||
if (!iface)
|
||||
{
|
||||
WRN("Cannot add org.enlightenment.wm.Core interface");
|
||||
return 0;
|
||||
}
|
||||
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
|
||||
e_dbus_interface_unref(iface);
|
||||
|
||||
/* Hardcore methods */
|
||||
e_dbus_interface_method_add(iface, "Restart", "", "", _e_msgbus_core_restart_cb);
|
||||
e_dbus_interface_method_add(iface, "Shutdown", "", "", _e_msgbus_core_shutdown_cb);
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Module");
|
||||
if (!iface)
|
||||
{
|
||||
WRN("Cannot add org.enlightenment.wm.Module interface");
|
||||
return 0;
|
||||
}
|
||||
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
|
||||
e_dbus_interface_unref(iface);
|
||||
|
||||
/* Module methods */
|
||||
e_dbus_interface_method_add(iface, "Load", "s", "", _e_msgbus_module_load_cb);
|
||||
e_dbus_interface_method_add(iface, "Unload", "s", "", _e_msgbus_module_unload_cb);
|
||||
e_dbus_interface_method_add(iface, "Enable", "s", "", _e_msgbus_module_enable_cb);
|
||||
e_dbus_interface_method_add(iface, "Disable", "s", "", _e_msgbus_module_disable_cb);
|
||||
e_dbus_interface_method_add(iface, "List", "", "a(si)", _e_msgbus_module_list_cb);
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Profile");
|
||||
if (!iface)
|
||||
{
|
||||
WRN("Cannot add org.enlightenment.wm.Profile interface");
|
||||
return 0;
|
||||
}
|
||||
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
|
||||
e_dbus_interface_unref(iface);
|
||||
|
||||
/* Profile methods */
|
||||
e_dbus_interface_method_add(iface, "Set", "s", "", _e_msgbus_profile_set_cb);
|
||||
e_dbus_interface_method_add(iface, "Get", "", "s", _e_msgbus_profile_get_cb);
|
||||
e_dbus_interface_method_add(iface, "List", "", "as", _e_msgbus_profile_list_cb);
|
||||
e_dbus_interface_method_add(iface, "Add", "s", "", _e_msgbus_profile_add_cb);
|
||||
e_dbus_interface_method_add(iface, "Delete", "s", "", _e_msgbus_profile_delete_cb);
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Window");
|
||||
if (!iface)
|
||||
{
|
||||
WRN("Cannot add org.enlightenment.wm.Window interface");
|
||||
return 0;
|
||||
}
|
||||
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
|
||||
e_dbus_interface_unref(iface);
|
||||
|
||||
/* Profile methods */
|
||||
e_dbus_interface_method_add(iface, "List", "", "a(si)", _e_msgbus_window_list_cb);
|
||||
e_dbus_interface_method_add(iface, "Close", "i", "", _e_msgbus_window_close_cb);
|
||||
e_dbus_interface_method_add(iface, "Kill", "i", "", _e_msgbus_window_kill_cb);
|
||||
e_dbus_interface_method_add(iface, "Focus", "i", "", _e_msgbus_window_focus_cb);
|
||||
e_dbus_interface_method_add(iface, "Iconify", "i", "", _e_msgbus_window_iconify_cb);
|
||||
e_dbus_interface_method_add(iface, "Uniconify", "i", "", _e_msgbus_window_uniconify_cb);
|
||||
e_dbus_interface_method_add(iface, "Maximize", "i", "", _e_msgbus_window_maximize_cb);
|
||||
e_dbus_interface_method_add(iface, "Unmaximize", "i", "", _e_msgbus_window_unmaximize_cb);
|
||||
|
||||
_e_msgbus_data->iface = edbus_service_interface_register(_e_msgbus_data->conn,
|
||||
PATH, &core_desc);
|
||||
edbus_service_interface_register(_e_msgbus_data->conn, PATH, &module_desc);
|
||||
edbus_service_interface_register(_e_msgbus_data->conn, PATH, &profile_desc);
|
||||
edbus_service_interface_register(_e_msgbus_data->conn, PATH, &window_desc);
|
||||
edbus_name_request(_e_msgbus_data->conn, "org.enlightenment.wm.service",
|
||||
0, _e_msgbus_request_name_cb, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EINTERN int
|
||||
e_msgbus_shutdown(void)
|
||||
{
|
||||
if (_e_msgbus_data->obj)
|
||||
{
|
||||
e_dbus_object_free(_e_msgbus_data->obj);
|
||||
}
|
||||
if (_e_msgbus_data->iface)
|
||||
edbus_service_object_unregister(_e_msgbus_data->iface);
|
||||
if (_e_msgbus_data->conn)
|
||||
{
|
||||
e_dbus_connection_close(_e_msgbus_data->conn);
|
||||
edbus_name_release(_e_msgbus_data->conn,
|
||||
"org.enlightenment.wm.service", NULL, NULL);
|
||||
edbus_connection_unref(_e_msgbus_data->conn);
|
||||
}
|
||||
#ifdef HAVE_HAL
|
||||
e_hal_shutdown();
|
||||
#endif
|
||||
e_dbus_shutdown();
|
||||
edbus_shutdown();
|
||||
|
||||
E_FREE(_e_msgbus_data);
|
||||
_e_msgbus_data = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_msgbus_interface_attach(E_DBus_Interface *iface)
|
||||
EAPI EDBus_Service_Interface *
|
||||
e_msgbus_interface_attach(const EDBus_Service_Interface_Desc *desc)
|
||||
{
|
||||
if (!_e_msgbus_data->obj) return;
|
||||
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
e_msgbus_interface_detach(E_DBus_Interface *iface)
|
||||
{
|
||||
if (!_e_msgbus_data->obj) return;
|
||||
e_dbus_object_interface_detach(_e_msgbus_data->obj, iface);
|
||||
if (!_e_msgbus_data->iface)
|
||||
return NULL;
|
||||
return edbus_service_interface_register(_e_msgbus_data->conn, PATH, desc);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_msgbus_request_name_cb(void *data __UNUSED__,
|
||||
DBusMessage *msg __UNUSED__,
|
||||
DBusError *err __UNUSED__)
|
||||
_e_msgbus_request_name_cb(void *data __UNUSED__, const EDBus_Message *msg,
|
||||
EDBus_Pending *pending __UNUSED__)
|
||||
{
|
||||
//TODO Handle Errors
|
||||
unsigned int flag;
|
||||
if (edbus_message_error_get(msg, NULL, NULL))
|
||||
{
|
||||
printf("Error requesting bus name.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "u", &flag))
|
||||
{
|
||||
printf("Error getting arguments on on_name_request\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(flag & EDBUS_NAME_REQUEST_REPLY_PRIMARY_OWNER))
|
||||
{
|
||||
printf("error name already in use\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Core Handlers */
|
||||
static DBusMessage *
|
||||
_e_msgbus_core_restart_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_core_restart_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
e_sys_action_do(E_SYS_RESTART, NULL);
|
||||
return dbus_message_new_method_return(msg);
|
||||
return edbus_message_method_return_new(msg);
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_core_shutdown_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_core_shutdown_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
e_sys_action_do(E_SYS_EXIT, NULL);
|
||||
return dbus_message_new_method_return(msg);
|
||||
return edbus_message_method_return_new(msg);
|
||||
}
|
||||
|
||||
/* Modules Handlers */
|
||||
static DBusMessage *
|
||||
_e_msgbus_module_load_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_module_load_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *module;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &module);
|
||||
if (!edbus_message_arguments_get(msg, "s", &module))
|
||||
return reply;
|
||||
|
||||
if (!e_module_find(module))
|
||||
{
|
||||
|
@ -213,19 +261,19 @@ _e_msgbus_module_load_cb(E_DBus_Object *obj __UNUSED__,
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_module_unload_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_module_unload_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *module;
|
||||
E_Module *m;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &module);
|
||||
if (!edbus_message_arguments_get(msg, "s", &module))
|
||||
return reply;
|
||||
|
||||
if ((m = e_module_find(module)))
|
||||
{
|
||||
|
@ -234,19 +282,19 @@ _e_msgbus_module_unload_cb(E_DBus_Object *obj __UNUSED__,
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_module_enable_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_module_enable_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *module;
|
||||
E_Module *m;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &module);
|
||||
if (!edbus_message_arguments_get(msg, "s", &module))
|
||||
return reply;
|
||||
|
||||
if ((m = e_module_find(module)))
|
||||
{
|
||||
|
@ -254,19 +302,19 @@ _e_msgbus_module_enable_cb(E_DBus_Object *obj __UNUSED__,
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_module_disable_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_module_disable_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *module;
|
||||
E_Module *m;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &module);
|
||||
if (!edbus_message_arguments_get(msg, "s", &module))
|
||||
return reply;
|
||||
|
||||
if ((m = e_module_find(module)))
|
||||
{
|
||||
|
@ -274,51 +322,54 @@ _e_msgbus_module_disable_cb(E_DBus_Object *obj __UNUSED__,
|
|||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_module_list_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_module_list_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Module *mod;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter arr;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
EDBus_Message_Iter *main_iter, *array;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(si)", &arr);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
|
||||
main_iter = edbus_message_iter_get(reply);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(main_iter, reply);
|
||||
|
||||
edbus_message_iter_arguments_append(main_iter, "a(si)", &array);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(array, reply);
|
||||
|
||||
EINA_LIST_FOREACH(e_module_list(), l, mod)
|
||||
{
|
||||
DBusMessageIter sub;
|
||||
EDBus_Message_Iter *s;
|
||||
const char *name;
|
||||
int enabled;
|
||||
|
||||
name = mod->name;
|
||||
enabled = mod->enabled;
|
||||
dbus_message_iter_open_container(&arr, DBUS_TYPE_STRUCT, NULL, &sub);
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &(name));
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(enabled));
|
||||
dbus_message_iter_close_container(&arr, &sub);
|
||||
|
||||
edbus_message_iter_arguments_append(array, "(si)", &s);
|
||||
if (!s) continue;
|
||||
edbus_message_iter_arguments_append(s, "si", name, enabled);
|
||||
edbus_message_iter_container_close(array, s);
|
||||
}
|
||||
dbus_message_iter_close_container(&iter, &arr);
|
||||
edbus_message_iter_container_close(main_iter, array);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
/* Profile Handlers */
|
||||
static DBusMessage *
|
||||
_e_msgbus_profile_set_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_profile_set_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *profile;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &profile);
|
||||
if (!edbus_message_arguments_get(msg, "s", &profile))
|
||||
return reply;
|
||||
|
||||
e_config_save_flush();
|
||||
e_config_profile_set(profile);
|
||||
|
@ -326,123 +377,122 @@ _e_msgbus_profile_set_cb(E_DBus_Object *obj __UNUSED__,
|
|||
e_config_save_block_set(1);
|
||||
e_sys_action_do(E_SYS_RESTART, NULL);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_profile_get_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
DBusMessage *reply;
|
||||
const char *profile;
|
||||
|
||||
profile = e_config_profile_get();
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &profile);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_profile_list_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_profile_get_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
const char *profile;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
|
||||
profile = e_config_profile_get();
|
||||
edbus_message_arguments_append(reply, "s", profile);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
_e_msgbus_profile_list_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
Eina_List *l;
|
||||
const char *name;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter arr;
|
||||
EDBus_Message *reply;
|
||||
EDBus_Message_Iter *array, *main_iter;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &arr);
|
||||
reply = edbus_message_method_return_new(msg);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL);
|
||||
|
||||
main_iter = edbus_message_iter_get(reply);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
|
||||
|
||||
edbus_message_iter_arguments_append(main_iter, "as", &array);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
|
||||
|
||||
EINA_LIST_FOREACH(e_config_profile_list(), l, name)
|
||||
{
|
||||
dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &name);
|
||||
}
|
||||
dbus_message_iter_close_container(&iter, &arr);
|
||||
edbus_message_iter_basic_append(array, 's', name);
|
||||
edbus_message_iter_container_close(main_iter, array);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_profile_add_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_profile_add_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *profile;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &profile);
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "s", &profile))
|
||||
return reply;
|
||||
e_config_profile_add(profile);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
_e_msgbus_profile_delete_cb(E_DBus_Object *obj __UNUSED__,
|
||||
DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_profile_delete_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
char *profile;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
dbus_message_iter_init(msg, &iter);
|
||||
dbus_message_iter_get_basic(&iter, &profile);
|
||||
if (!edbus_message_arguments_get(msg, "s", &profile))
|
||||
return reply;
|
||||
if (!strcmp(e_config_profile_get(), profile))
|
||||
{
|
||||
DBusMessage *ret;
|
||||
|
||||
ret = dbus_message_new_error(msg, "org.enlightenment.DBus.InvalidArgument",
|
||||
"Can't delete active profile");
|
||||
return ret;
|
||||
}
|
||||
return edbus_message_error_new(msg,
|
||||
"org.enlightenment.DBus.InvalidArgument",
|
||||
"Can't delete active profile");
|
||||
e_config_profile_del(profile);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
/* Window handlers */
|
||||
static DBusMessage *
|
||||
_e_msgbus_window_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
_e_msgbus_window_list_cb(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Border *bd;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter arr;
|
||||
EDBus_Message *reply;
|
||||
EDBus_Message_Iter *main_iter, *array;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(si)", &arr);
|
||||
reply = edbus_message_method_return_new(msg);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(reply, NULL);
|
||||
|
||||
main_iter = edbus_message_iter_get(reply);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(main_iter, reply);
|
||||
|
||||
edbus_message_iter_arguments_append(main_iter, "a(si)", &array);
|
||||
EINA_SAFETY_ON_FALSE_RETURN_VAL(array, reply);
|
||||
|
||||
EINA_LIST_FOREACH(e_border_client_list(), l, bd)
|
||||
{
|
||||
DBusMessageIter sub;
|
||||
dbus_message_iter_open_container(&arr, DBUS_TYPE_STRUCT, NULL, &sub);
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &bd->client.icccm.name);
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &bd->client.win);
|
||||
dbus_message_iter_close_container(&arr, &sub);
|
||||
EDBus_Message_Iter *s;
|
||||
|
||||
edbus_message_iter_arguments_append(array, "(si)", &s);
|
||||
if (!s) continue;
|
||||
edbus_message_iter_arguments_append(s, "si", bd->client.icccm.name,
|
||||
bd->client.win);
|
||||
edbus_message_iter_container_close(array, s);
|
||||
}
|
||||
dbus_message_iter_close_container(&iter, &arr);
|
||||
edbus_message_iter_container_close(main_iter, array);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
#define E_MSGBUS_WIN_ACTION_CB_BEGIN(NAME) \
|
||||
static DBusMessage * \
|
||||
_e_msgbus_window_##NAME##_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) \
|
||||
static EDBus_Message * \
|
||||
_e_msgbus_window_##NAME##_cb(const EDBus_Service_Interface *iface __UNUSED__,\
|
||||
const EDBus_Message *msg) \
|
||||
{ \
|
||||
E_Border *bd; \
|
||||
int xwin;\
|
||||
DBusMessageIter iter;\
|
||||
\
|
||||
dbus_message_iter_init(msg, &iter);\
|
||||
dbus_message_iter_get_basic(&iter, &xwin);\
|
||||
if (!edbus_message_arguments_get(msg, "i", &xwin)) \
|
||||
return edbus_message_method_return_new(msg); \
|
||||
bd = e_border_find_by_client_window(xwin);\
|
||||
if (bd)\
|
||||
{
|
||||
|
@ -450,7 +500,7 @@ _e_msgbus_window_##NAME##_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg) \
|
|||
#define E_MSGBUS_WIN_ACTION_CB_END \
|
||||
}\
|
||||
\
|
||||
return dbus_message_new_method_return(msg);\
|
||||
return edbus_message_method_return_new(msg);\
|
||||
}
|
||||
|
||||
E_MSGBUS_WIN_ACTION_CB_BEGIN(close)
|
||||
|
|
|
@ -6,18 +6,17 @@ typedef struct _E_Msgbus_Data E_Msgbus_Data;
|
|||
#ifndef E_MSGBUS_H
|
||||
#define E_MSGBUS_H
|
||||
|
||||
/* This is the dbus subsystem, but e_dbus namespace is taken by e_dbus */
|
||||
/* This is the dbus subsystem, but edbus namespace is taken by edbus */
|
||||
|
||||
struct _E_Msgbus_Data
|
||||
{
|
||||
E_DBus_Connection *conn;
|
||||
E_DBus_Object *obj;
|
||||
EDBus_Connection *conn;
|
||||
EDBus_Service_Interface *iface;
|
||||
};
|
||||
|
||||
EINTERN int e_msgbus_init(void);
|
||||
EINTERN int e_msgbus_shutdown(void);
|
||||
EAPI void e_msgbus_interface_attach(E_DBus_Interface *iface);
|
||||
EAPI void e_msgbus_interface_detach(E_DBus_Interface *iface);
|
||||
EAPI EDBus_Service_Interface *e_msgbus_interface_attach(const EDBus_Service_Interface_Desc *desc);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -25,14 +25,11 @@ e_modapi_init(E_Module *m)
|
|||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||
{
|
||||
E_DBus_Interface* iface;
|
||||
EDBus_Service_Interface* iface;
|
||||
Eina_Array_Iterator iter;
|
||||
size_t i;
|
||||
EINA_ARRAY_ITER_NEXT(ifaces, i, iface, iter)
|
||||
{
|
||||
e_msgbus_interface_detach(iface);
|
||||
e_dbus_interface_unref(iface);
|
||||
}
|
||||
edbus_service_interface_unregister(iface);
|
||||
eina_array_free(ifaces);
|
||||
ifaces = NULL;
|
||||
return 1;
|
||||
|
|
|
@ -10,24 +10,35 @@ static int _log_dom = -1;
|
|||
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
|
||||
|
||||
static DBusMessage*
|
||||
cb_audit_timer_dump(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
cb_audit_timer_dump(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
char *tmp;
|
||||
|
||||
tmp = ecore_timer_dump();
|
||||
if (!tmp) tmp = strdup("Not enable, recompile Ecore with ecore_timer_dump.");
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_append_args(reply, DBUS_TYPE_STRING, &tmp, DBUS_TYPE_INVALID);
|
||||
if (!tmp)
|
||||
edbus_message_arguments_append(reply, "s",
|
||||
"Not enable, recompile Ecore with ecore_timer_dump.");
|
||||
else
|
||||
edbus_message_arguments_append(reply, "s", tmp);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static const EDBus_Method methods[] = {
|
||||
{ "Timers", NULL, EDBUS_ARGS({"s", ""}), cb_audit_timer_dump, 0 },
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc audit = {
|
||||
"org.enlightenment.wm.Audit", methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
void msgbus_audit_init(Eina_Array *ifaces)
|
||||
{
|
||||
E_DBus_Interface *iface;
|
||||
EDBus_Service_Interface *iface;
|
||||
|
||||
if (_log_dom == -1)
|
||||
{
|
||||
|
@ -36,13 +47,7 @@ void msgbus_audit_init(Eina_Array *ifaces)
|
|||
EINA_LOG_ERR("could not register msgbus_audit log domain!");
|
||||
}
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Audit");
|
||||
iface = e_msgbus_interface_attach(&audit);
|
||||
if (iface)
|
||||
{
|
||||
e_dbus_interface_method_add(iface, "Timers", "", "s",
|
||||
cb_audit_timer_dump);
|
||||
e_msgbus_interface_attach(iface);
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,201 +10,229 @@ static int _log_dom = -1;
|
|||
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
|
||||
|
||||
static DBusMessage *
|
||||
cb_virtual_desktops(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
cb_virtual_desktops(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_append_args(reply,
|
||||
DBUS_TYPE_INT32, &(e_config->zone_desks_x_count),
|
||||
DBUS_TYPE_INT32, &(e_config->zone_desks_y_count),
|
||||
DBUS_TYPE_INVALID);
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
edbus_message_arguments_append(reply, "ii", e_config->zone_desks_x_count,
|
||||
e_config->zone_desks_y_count);
|
||||
DBG("GetVirtualCount: %d %d",
|
||||
e_config->zone_desks_x_count, e_config->zone_desks_y_count);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
cb_desktop_show(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
static EDBus_Message *
|
||||
cb_desktop_show(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusError err;
|
||||
int x, y;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
E_Zone *zone;
|
||||
|
||||
dbus_error_init(&err);
|
||||
if (!dbus_message_get_args(msg, &err,
|
||||
DBUS_TYPE_INT32, &x,
|
||||
DBUS_TYPE_INT32, &y,
|
||||
DBUS_TYPE_INVALID))
|
||||
if (!edbus_message_arguments_get(msg, "ii", &x, &y))
|
||||
{
|
||||
ERR("could not get Show arguments: %s: %s", err.name, err.message);
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
else
|
||||
{
|
||||
E_Zone *zone = e_util_zone_current_get(e_manager_current_get());
|
||||
DBG("show desktop %d,%d from zone %p.", x, y, zone);
|
||||
e_zone_desk_flip_to(zone, x, y);
|
||||
ERR("could not get Show arguments");
|
||||
return reply;
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
cb_desktop_show_by_name(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBusError err;
|
||||
const char *name;
|
||||
|
||||
dbus_error_init(&err);
|
||||
if (!dbus_message_get_args(msg, &err,
|
||||
DBUS_TYPE_STRING, &name,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
ERR("could not get Show arguments: %s: %s", err.name, err.message);
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
else if (name)
|
||||
{
|
||||
E_Zone *zone = e_util_zone_current_get(e_manager_current_get());
|
||||
unsigned int i, count;
|
||||
|
||||
DBG("show desktop %s from zone %p.", name, zone);
|
||||
count = zone->desk_x_count * zone->desk_y_count;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
E_Desk *desk = zone->desks[i];
|
||||
if ((desk->name) && (strcmp(desk->name, name) == 0))
|
||||
{
|
||||
DBG("show desktop %s (%d,%d) from zone %p.",
|
||||
name, desk->x, desk->y, zone);
|
||||
e_zone_desk_flip_to(zone, desk->x, desk->y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage *
|
||||
cb_desktop_lock(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBG("desklock requested");
|
||||
e_desklock_show(EINA_FALSE);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
static DBusMessage *
|
||||
cb_desktop_unlock(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBG("deskunlock requested");
|
||||
e_desklock_hide();
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage*
|
||||
cb_desktop_bgadd(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBusError err;
|
||||
int container, zone, desk_x, desk_y;
|
||||
const char *path;
|
||||
|
||||
dbus_error_init(&err);
|
||||
if (!dbus_message_get_args(msg, &err,
|
||||
DBUS_TYPE_INT32, &container,
|
||||
DBUS_TYPE_INT32, &zone,
|
||||
DBUS_TYPE_INT32, &desk_x,
|
||||
DBUS_TYPE_INT32, &desk_y,
|
||||
DBUS_TYPE_STRING, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
ERR("could not get Add arguments: %s: %s", err.name, err.message);
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
else if (path)
|
||||
{
|
||||
DBG("add bg container=%d, zone=%d, pos=%d,%d path=%s",
|
||||
container, zone, desk_x, desk_y, path);
|
||||
e_bg_add(container, zone, desk_x, desk_y, path);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage*
|
||||
cb_desktop_bgdel(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBusError err;
|
||||
int container, zone, desk_x, desk_y;
|
||||
|
||||
dbus_error_init(&err);
|
||||
if (!dbus_message_get_args(msg, &err,
|
||||
DBUS_TYPE_INT32, &container,
|
||||
DBUS_TYPE_INT32, &zone,
|
||||
DBUS_TYPE_INT32, &desk_x,
|
||||
DBUS_TYPE_INT32, &desk_y,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
ERR("could not get Del arguments: %s: %s", err.name, err.message);
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG("del bg container=%d, zone=%d, pos=%d,%d",
|
||||
container, zone, desk_x, desk_y);
|
||||
|
||||
e_bg_del(container, zone, desk_x, desk_y);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
}
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage*
|
||||
cb_desktop_bglist(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
Eina_List *list;
|
||||
E_Config_Desktop_Background *bg;
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter arr;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(iiiis)", &arr);
|
||||
|
||||
EINA_LIST_FOREACH(e_config->desktop_backgrounds, list, bg)
|
||||
{
|
||||
DBusMessageIter sub;
|
||||
|
||||
if (!bg || !bg->file)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG("Background container=%d zone=%d pos=%d,%d path=%s",
|
||||
bg->container, bg->zone, bg->desk_x, bg->desk_y, bg->file);
|
||||
|
||||
dbus_message_iter_open_container(&arr, DBUS_TYPE_STRUCT, NULL, &sub);
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->container));
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->zone));
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->desk_x));
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_INT32, &(bg->desk_y));
|
||||
dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &(bg->file));
|
||||
dbus_message_iter_close_container(&arr, &sub);
|
||||
}
|
||||
dbus_message_iter_close_container(&iter, &arr);
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
DBG("show desktop %d,%d from zone %p.", x, y, zone);
|
||||
e_zone_desk_flip_to(zone, x, y);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_show_by_name(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
const char *name;
|
||||
E_Zone *zone;
|
||||
unsigned int i, count;
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "s", &name))
|
||||
{
|
||||
ERR("could not get Show arguments");
|
||||
return reply;
|
||||
}
|
||||
|
||||
zone = e_util_zone_current_get(e_manager_current_get());
|
||||
DBG("show desktop %s from zone %p.", name, zone);
|
||||
count = zone->desk_x_count * zone->desk_y_count;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
E_Desk *desk = zone->desks[i];
|
||||
if ((desk->name) && (strcmp(desk->name, name) == 0))
|
||||
{
|
||||
DBG("show desktop %s (%d,%d) from zone %p.", name, desk->x,
|
||||
desk->y, zone);
|
||||
e_zone_desk_flip_to(zone, desk->x, desk->y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_lock(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBG("desklock requested");
|
||||
e_desklock_show(EINA_FALSE);
|
||||
|
||||
return edbus_message_method_return_new(msg);
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_unlock(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBG("deskunlock requested");
|
||||
e_desklock_hide();
|
||||
|
||||
return edbus_message_method_return_new(msg);
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_bgadd(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
int container, zone, desk_x, desk_y;
|
||||
const char *path;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "iiiis", &container, &zone, &desk_x,
|
||||
&desk_y, &path))
|
||||
{
|
||||
ERR("could not get Add arguments");
|
||||
return reply;
|
||||
}
|
||||
|
||||
DBG("add bg container=%d, zone=%d, pos=%d,%d path=%s",
|
||||
container, zone, desk_x, desk_y, path);
|
||||
e_bg_add(container, zone, desk_x, desk_y, path);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_bgdel(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
int container, zone, desk_x, desk_y;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
|
||||
if (!edbus_message_arguments_get(msg, "iiii", &container, &zone, &desk_x,
|
||||
&desk_y))
|
||||
{
|
||||
ERR("could not get Del arguments");
|
||||
return reply;
|
||||
}
|
||||
|
||||
DBG("del bg container=%d, zone=%d, pos=%d,%d",
|
||||
container, zone, desk_x, desk_y);
|
||||
e_bg_del(container, zone, desk_x, desk_y);
|
||||
e_bg_update();
|
||||
e_config_save_queue();
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static EDBus_Message *
|
||||
cb_desktop_bglist(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
Eina_List *list;
|
||||
E_Config_Desktop_Background *bg;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
EDBus_Message_Iter *main_iter, *array;
|
||||
|
||||
if (!reply)
|
||||
return NULL;
|
||||
|
||||
main_iter = edbus_message_iter_get(reply);
|
||||
if (!main_iter)
|
||||
return reply;
|
||||
|
||||
if (!edbus_message_iter_arguments_append(main_iter, "a(iiiis)", &array))
|
||||
return reply;
|
||||
|
||||
EINA_LIST_FOREACH(e_config->desktop_backgrounds, list, bg)
|
||||
{
|
||||
EDBus_Message_Iter *s;
|
||||
|
||||
if (!bg || !bg->file)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
DBG("Background container=%d zone=%d pos=%d,%d path=%s",
|
||||
bg->container, bg->zone, bg->desk_x, bg->desk_y, bg->file);
|
||||
edbus_message_iter_arguments_append(array, "(iiiis)", &s);
|
||||
if (!s) continue;
|
||||
edbus_message_iter_arguments_append(s, "iiiis", bg->container, bg->zone,
|
||||
bg->desk_x, bg->desk_y, bg->file);
|
||||
edbus_message_iter_container_close(array, s);
|
||||
}
|
||||
edbus_message_iter_container_close(main_iter, array);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static const EDBus_Method desktop_methods[] = {
|
||||
{
|
||||
"GetVirtualCount", NULL, EDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}),
|
||||
cb_virtual_desktops, 0
|
||||
},
|
||||
{
|
||||
"Show", EDBUS_ARGS({"i", "desk_x"}, {"i", "desk_y"}),
|
||||
NULL, cb_desktop_show, 0
|
||||
},
|
||||
{
|
||||
"ShowByName", EDBUS_ARGS({"s", "desk_name"}), NULL,
|
||||
cb_desktop_show_by_name, 0
|
||||
},
|
||||
{
|
||||
"Lock", NULL, NULL, cb_desktop_lock, 0
|
||||
},
|
||||
{
|
||||
"Unlock", NULL, NULL, cb_desktop_unlock, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Method background_methods[] = {
|
||||
{
|
||||
"Add",
|
||||
EDBUS_ARGS({"i", "container"}, {"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}, {"s", "path"}),
|
||||
NULL, cb_desktop_bgadd, 0
|
||||
},
|
||||
{
|
||||
"Del", EDBUS_ARGS({"i", "container"}, {"i", "zone"}, {"i", "desk_x"}, {"i", "desk_y"}),
|
||||
NULL, cb_desktop_bgdel, 0
|
||||
},
|
||||
{
|
||||
"List", EDBUS_ARGS({"a(iiiis)", "array_of_bg"}), NULL,
|
||||
cb_desktop_bglist, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc desktop = {
|
||||
"org.enlightenment.wm.Desktop", desktop_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc bg = {
|
||||
"org.enlightenment.wm.Desktop.Background", background_methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
void msgbus_desktop_init(Eina_Array *ifaces)
|
||||
{
|
||||
E_DBus_Interface *iface;
|
||||
EDBus_Service_Interface *iface;
|
||||
|
||||
if (_log_dom == -1)
|
||||
{
|
||||
|
@ -212,34 +240,11 @@ void msgbus_desktop_init(Eina_Array *ifaces)
|
|||
if (_log_dom < 0)
|
||||
EINA_LOG_ERR("could not register msgbus_desktop log domain!");
|
||||
}
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Desktop");
|
||||
iface = e_msgbus_interface_attach(&desktop);
|
||||
if (iface)
|
||||
{
|
||||
e_dbus_interface_method_add(iface, "GetVirtualCount", "", "ii",
|
||||
cb_virtual_desktops);
|
||||
e_dbus_interface_method_add(iface, "Show", "ii", "",
|
||||
cb_desktop_show);
|
||||
e_dbus_interface_method_add(iface, "ShowByName", "s", "",
|
||||
cb_desktop_show_by_name);
|
||||
e_dbus_interface_method_add(iface, "Lock", "", "",
|
||||
cb_desktop_lock);
|
||||
e_dbus_interface_method_add(iface, "Unlock", "", "",
|
||||
cb_desktop_unlock);
|
||||
e_msgbus_interface_attach(iface);
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Desktop.Background");
|
||||
eina_array_push(ifaces, iface);
|
||||
iface = NULL;
|
||||
iface = e_msgbus_interface_attach(&bg);
|
||||
if (iface)
|
||||
{
|
||||
e_dbus_interface_method_add(iface, "Add", "iiiis", "",
|
||||
cb_desktop_bgadd);
|
||||
e_dbus_interface_method_add(iface, "Del", "iiii", "",
|
||||
cb_desktop_bgdel);
|
||||
e_dbus_interface_method_add(iface, "List", "", "a(iiiis)",
|
||||
cb_desktop_bglist);
|
||||
e_msgbus_interface_attach(iface);
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
|
|
|
@ -10,34 +10,45 @@ static int _log_dom = -1;
|
|||
#define INF(...) EINA_LOG_DOM_INFO(_log_dom, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
|
||||
|
||||
static DBusMessage *
|
||||
cb_langs(E_DBus_Object *obj __UNUSED__, DBusMessage *message)
|
||||
static EDBus_Message *
|
||||
cb_langs(const EDBus_Service_Interface *iface __UNUSED__,
|
||||
const EDBus_Message *msg)
|
||||
{
|
||||
DBusMessage *reply;
|
||||
DBusMessageIter iter;
|
||||
DBusMessageIter arr;
|
||||
EDBus_Message *reply = edbus_message_method_return_new(msg);
|
||||
EDBus_Message_Iter *main_iter, *array;
|
||||
const Eina_List *l;
|
||||
const char *str;
|
||||
|
||||
reply = dbus_message_new_method_return(message);
|
||||
dbus_message_iter_init_append(reply, &iter);
|
||||
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &arr);
|
||||
if (!reply) return NULL;
|
||||
|
||||
main_iter = edbus_message_iter_get(reply);
|
||||
edbus_message_iter_arguments_append(main_iter, "as", &array);
|
||||
if (!array) return reply;
|
||||
|
||||
EINA_LIST_FOREACH(e_intl_language_list(), l, str)
|
||||
{
|
||||
DBG("language: %s", str);
|
||||
dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &str);
|
||||
DBG("language: %s", str);
|
||||
edbus_message_iter_basic_append(array, 's', str);
|
||||
}
|
||||
|
||||
dbus_message_iter_close_container(&iter, &arr);
|
||||
edbus_message_iter_container_close(main_iter, array);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
static const EDBus_Method methods[] = {
|
||||
{
|
||||
"List", NULL, EDBUS_ARGS({"as", "langs"}), cb_langs, 0
|
||||
},
|
||||
{ NULL, NULL, NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const EDBus_Service_Interface_Desc lang = {
|
||||
"org.enlightenment.wm.Language", methods, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
void msgbus_lang_init(Eina_Array *ifaces)
|
||||
{
|
||||
E_DBus_Interface* iface;
|
||||
|
||||
EDBus_Service_Interface *iface;
|
||||
if (_log_dom == -1)
|
||||
{
|
||||
_log_dom = eina_log_domain_register("msgbus_lang", EINA_COLOR_BLUE);
|
||||
|
@ -45,11 +56,7 @@ void msgbus_lang_init(Eina_Array *ifaces)
|
|||
EINA_LOG_ERR("could not register msgbus_lang log domain!");
|
||||
}
|
||||
|
||||
iface = e_dbus_interface_new("org.enlightenment.wm.Language");
|
||||
iface = e_msgbus_interface_attach(&lang);
|
||||
if (iface)
|
||||
{
|
||||
e_dbus_interface_method_add(iface, "List", "", "as", cb_langs);
|
||||
e_msgbus_interface_attach(iface);
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
eina_array_push(ifaces, iface);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue