}
}
+static void
+_e_info_client_cb_module_list_get(const Eldbus_Message *msg)
+{
+ const char *errname = NULL, *errtext = NULL;
+ Eldbus_Message_Iter *module_array = NULL;
+ Eldbus_Message_Iter *inner_module_array = NULL;
+ Eina_Stringshare *module_name = NULL;
+ int count = 0;
+ int onoff = 0;
+
+ // check error
+ EINA_SAFETY_ON_TRUE_GOTO(eldbus_message_error_get(msg, &errname, &errtext), err);
+
+ // get arguments
+ EINA_SAFETY_ON_FALSE_GOTO(eldbus_message_arguments_get(msg, "ia(si)", &count, &module_array), err);
+ printf("============< print module list >===========\n");
+ printf("module count : %d\n", count);
+ while (eldbus_message_iter_get_and_next(module_array, 'r', &inner_module_array))
+ {
+ EINA_SAFETY_ON_FALSE_GOTO(
+ eldbus_message_iter_arguments_get(inner_module_array, "si", &module_name, &onoff),
+ err);
+ printf("module [ %30s ]\t:\t%s\n", module_name, onoff?"enabled":"disabled");
+ }
+ goto finish;
+
+err:
+ if (errname || errtext)
+ printf("errname : %s, errmsg : %s\n", errname, errtext);
+ else
+ printf("Error occurred in _e_info_client_cb_module_list_get\n");
+
+finish:
+ return;
+}
+
+static void
+_e_info_client_cb_module_load(const Eldbus_Message *msg)
+{
+ const char *errname = NULL, *errtext = NULL;
+ const char *result = NULL;
+
+ EINA_SAFETY_ON_TRUE_GOTO(eldbus_message_error_get(msg, &errname, &errtext), err);
+
+ EINA_SAFETY_ON_FALSE_GOTO(eldbus_message_arguments_get(msg, "s", &result), err);
+
+ printf("%s\n", result);
+ goto finish;
+
+err:
+ if (errname || errtext)
+ printf("errname : %s, errmsg : %s\n", errname, errtext);
+ else
+ printf("Error occurred in _e_info_client_cb_module_load\n");
+
+finish:
+ return;
+}
+
+static void
+_e_info_client_cb_module_unload(const Eldbus_Message *msg)
+{
+ const char *errname = NULL, *errtext = NULL;
+ const char *result = NULL;
+
+ EINA_SAFETY_ON_TRUE_GOTO(eldbus_message_error_get(msg, &errname, &errtext), err);
+
+ EINA_SAFETY_ON_FALSE_GOTO(eldbus_message_arguments_get(msg, "s", &result), err);
+
+ printf("%s\n", result);
+ goto finish;
+
+err:
+ if (errname || errtext)
+ printf("errname : %s, errmsg : %s\n", errname, errtext);
+ else
+ printf("Error occurred in _e_info_client_cb_module_unload\n");
+
+finish:
+ return;
+}
+
+static void
+_e_info_client_proc_module(int argc, char **argv)
+{
+ const char *program = argv[0];
+ const char *command = argv[2];
+ const char *module_name = argv[3];
+
+ EINA_SAFETY_ON_FALSE_GOTO(((argc >= 3) && (argc <= 4)), usage);
+
+ if (strncmp(command, "list", strlen(command)) == 0)
+ {
+ if (argc != 3)
+ goto usage;
+
+ _e_info_client_eldbus_message("module_list_get", _e_info_client_cb_module_list_get);
+ goto finish;
+ }
+ else if (strncmp(command, "load", strlen(command)) == 0)
+ {
+ if (argc != 4)
+ goto usage;
+
+ _e_info_client_eldbus_message_with_args("module_load",
+ _e_info_client_cb_module_load,
+ "s",
+ module_name);
+ goto finish;
+ }
+ else if (strncmp(command, "unload", strlen(command)) == 0)
+ {
+ if (argc != 4)
+ goto usage;
+
+ _e_info_client_eldbus_message_with_args("module_unload",
+ _e_info_client_cb_module_unload,
+ "s",
+ module_name);
+ goto finish;
+ }
+
+usage:
+ printf("Usage : %s -module <command> [<module_name>]\n\n", program);
+ printf("Commands:\n"
+ "list : Print the current modules list loaded\n"
+ "load <module_name> : Load module with the given name\n"
+ "unload <module_name> : Unload module with the given name\n\n");
+ printf("Example:\n"
+ "%s -module load e-mod-tizen-effect\n"
+ "%s -module unload e-mod-tizen-effect\n", program, program);
+finish:
+ return;
+}
+
static struct
{
const char *option;
WININFO_USAGE,
"displaying information about windows",
_e_info_client_proc_wininfo
+ },
+ {
+ "module",
+ "[list], [load <module_name>], [unload <module_name>]",
+ "manage modules on enlightenment",
+ _e_info_client_proc_module
}
};
return reply;
}
+static Eldbus_Message *
+_e_info_server_cb_module_list_get(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eina_List *module_list = NULL, *l = NULL;
+ E_Module *mod = NULL;
+ Eldbus_Message *reply = NULL;
+ Eldbus_Message_Iter *iter = NULL, *module_array = NULL;
+ Eldbus_Message_Iter *inner_module_array = NULL;
+
+ module_list = e_module_list();
+ if (module_list == NULL)
+ {
+ ERR("cannot get module list");
+ return eldbus_message_error_new(msg, FAIL_TO_GET_PROPERTY,
+ "module list: e_module_list() returns NULL");
+ }
+
+ // init message
+ reply = eldbus_message_method_return_new(msg);
+ iter = eldbus_message_iter_get(reply);
+
+ // get module count
+ eldbus_message_iter_basic_append(iter, 'i', eina_list_count(module_list));
+
+ // get module list
+ eldbus_message_iter_arguments_append(iter, "a(si)", &module_array);
+ EINA_LIST_FOREACH(module_list, l, mod)
+ {
+ char module_name[128] = {0};
+ int isonoff = 0;
+ snprintf(module_name, sizeof(module_name), "%s", mod->name);
+ isonoff = e_module_enabled_get(mod);
+ eldbus_message_iter_arguments_append(module_array, "(si)", &inner_module_array);
+ eldbus_message_iter_arguments_append(inner_module_array, "si", module_name, isonoff);
+ eldbus_message_iter_container_close(module_array, inner_module_array);
+ }
+ eldbus_message_iter_container_close(iter, module_array);
+
+ return reply;
+}
+
+static Eldbus_Message *
+_e_info_server_cb_module_load(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply = NULL;
+ E_Module *module = NULL;
+ const char *module_name = NULL;
+ char msg_to_client[128] = {0};
+ int res = 0;
+
+ if (eldbus_message_arguments_get(msg, "s", &module_name) == EINA_FALSE || module_name == NULL)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "module load: an attempt to get arguments from method call message failed");
+ }
+
+ // find module & enable
+ module = e_module_find(module_name);
+ if (module == NULL)
+ {
+ module = e_module_new(module_name);
+ }
+ if (module == NULL || module->error)
+ {
+ snprintf(msg_to_client, sizeof(msg_to_client), "module load: cannot find module name : %s", module_name);
+ if(module != NULL)
+ e_object_del(E_OBJECT(module));
+ }
+ else
+ {
+ if (e_module_enabled_get(module))
+ {
+ snprintf(msg_to_client, sizeof(msg_to_client), "enlightenment module[ %s ] is already loaded", module_name);
+ }
+ else
+ {
+ res = e_module_enable(module);
+ snprintf(msg_to_client, sizeof(msg_to_client), "enlightenment module[ %s ] load %s", module_name, res?"succeed":"failed");
+ }
+ }
+
+ // return message to client
+ reply = eldbus_message_method_return_new(msg);
+ eldbus_message_arguments_append(reply, "s", msg_to_client);
+
+ return reply;
+}
+
+static Eldbus_Message *
+_e_info_server_cb_module_unload(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+ Eldbus_Message *reply = NULL;
+ E_Module *module = NULL;
+ const char *module_name = NULL;
+ char msg_to_client[128] = {0};
+ int res = 0;
+
+ if (eldbus_message_arguments_get(msg, "s", &module_name) == EINA_FALSE || module_name == NULL)
+ {
+ return eldbus_message_error_new(msg, GET_CALL_MSG_ARG_ERR,
+ "module unload: an attempt to get arguments from method call message failed");
+ }
+
+ module = e_module_find(module_name);
+ if (module == NULL)
+ {
+ snprintf(msg_to_client, sizeof(msg_to_client), "module unload: cannot find module name : %s", module_name);
+ goto finish;
+ }
+ else
+ {
+ if (e_module_enabled_get(module))
+ {
+ res = e_module_disable(module);
+ snprintf(msg_to_client, sizeof(msg_to_client), "enlightenment module[ %s ] unload %s", module_name, res?"succeed":"failed");
+ }
+ else
+ {
+ snprintf(msg_to_client, sizeof(msg_to_client), "enlightenment module[ %s ] is already unloaded", module_name);
+ }
+ goto finish;
+ }
+
+finish:
+ // return message to client
+ reply = eldbus_message_method_return_new(msg);
+ eldbus_message_arguments_append(reply, "s", msg_to_client);
+
+ return reply;
+}
+
//{ "method_name", arguments_from_client, return_values_to_client, _method_cb, ELDBUS_METHOD_FLAG },
static const Eldbus_Method methods[] = {
{ "get_window_info", NULL, ELDBUS_ARGS({"iiiisa("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
{ "wininfo_hints", ELDBUS_ARGS({"it", "mode, window"}), ELDBUS_ARGS({"as", "window hints"}), _e_info_server_cb_wininfo_hints, 0 },
{ "wininfo_shape", ELDBUS_ARGS({"t", "window"}), ELDBUS_ARGS({"ia(iiii)ia(iiii)", "window shape"}), _e_info_server_cb_wininfo_shape, 0 },
{ "get_version", NULL, ELDBUS_ARGS({"ss", "version of E20"}), _e_info_server_cb_version_get, 0 },
+ { "module_list_get", NULL, ELDBUS_ARGS({"ia(si)", "module list"}), _e_info_server_cb_module_list_get, 0 },
+ { "module_load", ELDBUS_ARGS({"s", "target module"}), ELDBUS_ARGS({"s", "load result"}), _e_info_server_cb_module_load, 0 },
+ { "module_unload", ELDBUS_ARGS({"s", "target module"}), ELDBUS_ARGS({"s", "unload result"}), _e_info_server_cb_module_unload, 0 },
{ NULL, NULL, NULL, NULL, 0 }
};