ecrustified

SVN revision: 61874
devs/princeamd/enlightenment-0.17-elive
Mike Blumenkrantz 12 years ago
parent 0694881640
commit 25f274114a
  1. 220
      src/bin/e_msgbus.c

@ -1,22 +1,36 @@
#include "e.h"
/* local subsystem functions */
static void _e_msgbus_request_name_cb(void *data, DBusMessage *msg, DBusError *err);
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 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 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 void _e_msgbus_request_name_cb(void *data,
DBusMessage *msg,
DBusError *err);
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 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 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);
/* local subsystem globals */
static E_Msgbus_Data *_e_msgbus_data = NULL;
@ -37,8 +51,8 @@ e_msgbus_init(void)
_e_msgbus_data->conn = e_dbus_bus_get(DBUS_BUS_SESSION);
if (!_e_msgbus_data->conn)
{
printf("WARNING: Cannot get DBUS_BUS_SESSION\n");
return 0;
printf("WARNING: Cannot get DBUS_BUS_SESSION\n");
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);
@ -46,21 +60,21 @@ e_msgbus_init(void)
iface = e_dbus_interface_new("org.enlightenment.wm.Core");
if (!iface)
{
printf("WARNING: Cannot add org.enlightenment.wm.Core interface\n");
return 0;
printf("WARNING: Cannot add org.enlightenment.wm.Core interface\n");
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)
{
printf("WARNING: Cannot add org.enlightenment.wm.Module interface\n");
return 0;
printf("WARNING: Cannot add org.enlightenment.wm.Module interface\n");
return 0;
}
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
e_dbus_interface_unref(iface);
@ -75,8 +89,8 @@ e_msgbus_init(void)
iface = e_dbus_interface_new("org.enlightenment.wm.Profile");
if (!iface)
{
printf("WARNING: Cannot add org.enlightenment.wm.Profile interface\n");
return 0;
printf("WARNING: Cannot add org.enlightenment.wm.Profile interface\n");
return 0;
}
e_dbus_object_interface_attach(_e_msgbus_data->obj, iface);
e_dbus_interface_unref(iface);
@ -87,7 +101,7 @@ e_msgbus_init(void)
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);
return 1;
}
@ -127,103 +141,114 @@ e_msgbus_interface_detach(E_DBus_Interface *iface)
}
static void
_e_msgbus_request_name_cb(void *data __UNUSED__, DBusMessage *msg __UNUSED__, DBusError *err __UNUSED__)
_e_msgbus_request_name_cb(void *data __UNUSED__,
DBusMessage *msg __UNUSED__,
DBusError *err __UNUSED__)
{
//TODO Handle Errors
}
/* Core Handlers */
static DBusMessage*
_e_msgbus_core_restart_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_core_restart_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
e_sys_action_do(E_SYS_RESTART, NULL);
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_core_shutdown_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_core_shutdown_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
e_sys_action_do(E_SYS_EXIT, NULL);
return dbus_message_new_method_return(msg);
}
/* Modules Handlers */
static DBusMessage*
_e_msgbus_module_load_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_module_load_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *module;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &module);
if (!e_module_find(module))
if (!e_module_find(module))
{
e_module_new(module);
e_config_save_queue();
e_module_new(module);
e_config_save_queue();
}
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_module_unload_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_module_unload_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *module;
char *module;
E_Module *m;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &module);
if ((m = e_module_find(module)))
if ((m = e_module_find(module)))
{
e_module_disable(m);
e_object_del(E_OBJECT(m));
e_config_save_queue();
e_module_disable(m);
e_object_del(E_OBJECT(m));
e_config_save_queue();
}
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_module_enable_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_module_enable_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *module;
char *module;
E_Module *m;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &module);
if ((m = e_module_find(module))) {
e_module_enable(m);
e_config_save_queue();
}
if ((m = e_module_find(module)))
{
e_module_enable(m);
e_config_save_queue();
}
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_module_disable_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_module_disable_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *module;
char *module;
E_Module *m;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &module);
if ((m = e_module_find(module))) {
e_module_disable(m);
e_config_save_queue();
}
if ((m = e_module_find(module)))
{
e_module_disable(m);
e_config_save_queue();
}
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_module_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_module_list_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
Eina_List *l;
E_Module *mod;
@ -237,16 +262,16 @@ _e_msgbus_module_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
EINA_LIST_FOREACH(e_module_list(), l, mod)
{
DBusMessageIter sub;
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);
DBusMessageIter sub;
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);
}
dbus_message_iter_close_container(&iter, &arr);
@ -254,11 +279,12 @@ _e_msgbus_module_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
}
/* Profile Handlers */
static DBusMessage*
_e_msgbus_profile_set_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_profile_set_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *profile;
char *profile;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &profile);
@ -272,8 +298,9 @@ _e_msgbus_profile_set_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_profile_get_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_profile_get_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
DBusMessage *reply;
@ -288,8 +315,9 @@ _e_msgbus_profile_get_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
return reply;
}
static DBusMessage*
_e_msgbus_profile_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_profile_list_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
Eina_List *l;
const char *name;
@ -303,18 +331,19 @@ _e_msgbus_profile_list_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
EINA_LIST_FOREACH(e_config_profile_list(), l, name)
{
dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &name);
dbus_message_iter_append_basic(&arr, DBUS_TYPE_STRING, &name);
}
dbus_message_iter_close_container(&iter, &arr);
return reply;
}
static DBusMessage*
_e_msgbus_profile_add_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_profile_add_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *profile;
char *profile;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &profile);
@ -322,26 +351,27 @@ _e_msgbus_profile_add_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
e_config_profile_add(profile);
return dbus_message_new_method_return(msg);
}
static DBusMessage*
_e_msgbus_profile_delete_cb(E_DBus_Object *obj __UNUSED__, DBusMessage *msg)
static DBusMessage *
_e_msgbus_profile_delete_cb(E_DBus_Object *obj __UNUSED__,
DBusMessage *msg)
{
DBusMessageIter iter;
char *profile;
char *profile;
dbus_message_iter_init(msg, &iter);
dbus_message_iter_get_basic(&iter, &profile);
if (!strcmp(e_config_profile_get(), profile))
{
DBusMessage *ret;
DBusMessage *ret;
ret = dbus_message_new_error(msg, "org.enlightenment.DBus.InvalidArgument",
"Can't delete active profile");
return ret;
ret = dbus_message_new_error(msg, "org.enlightenment.DBus.InvalidArgument",
"Can't delete active profile");
return ret;
}
e_config_profile_del(profile);
return dbus_message_new_method_return(msg);
}

Loading…
Cancel
Save