2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <Elementary.h>
23 #include <tzsh_quickpanel_service.h>
26 #include "quickpanel-ui.h"
27 #include "quickpanel_def.h"
31 #include "setting_utils.h"
32 #include "settings_view_all.h"
33 #include "settings_view_featured.h"
36 E_DBus_Signal_Handler *hdl_activity;
37 E_DBus_Signal_Handler *hdl_editing;
43 static void _handler_activity(void *data, DBusMessage *msg)
49 QP_Module_Setting *mod = NULL;
50 retif(data == NULL || msg == NULL, , "Invalid parameter!");
52 dbus_error_init(&err);
53 ret = dbus_message_get_args(msg, &err,
54 DBUS_TYPE_STRING, &module,
55 DBUS_TYPE_STRING, &command,
57 retif(ret == 0, , "dbus_message_get_args error");
58 retif(module == NULL, , "Failed to get module");
59 retif(command == NULL, , "Failed to get command");
61 if (dbus_error_is_set(&err)) {
62 ERR("Dbus err: %s", err.message);
63 dbus_error_free(&err);
67 mod = quickpanel_settings_module_get_by_name(module);
69 DBG("module:%s, command:%s", module, command);
70 if (mod->handler_ipc != NULL) {
71 if (mod->is_loaded == EINA_TRUE && mod->loader != NULL) {
72 mod->handler_ipc(command, mod);
74 ERR("module:%s isn't loaded");
77 ERR("module:%s don't have IPC handler");
80 ERR("failed to lookup module:%s", module);
84 static void _handler_editing(void *data, DBusMessage *msg)
87 int ret = 0, is_error = 0;
93 gchar **order_split = NULL;
94 Eina_List *list_active = NULL;
95 QP_Module_Setting *mod = NULL;
96 retif(data == NULL || msg == NULL, , "Invalid parameter!");
98 dbus_error_init(&err);
99 ret = dbus_message_get_args(msg, &err,
100 DBUS_TYPE_STRING, &key,
101 DBUS_TYPE_STRING, &order,
102 DBUS_TYPE_INT32, &num_featured,
104 retif(ret == 0, , "dbus_message_get_args error");
105 retif(key == NULL, , "Failed to get key");
106 retif(order == NULL, , "Failed to get value");
108 if (dbus_error_is_set(&err)) {
109 ERR("dbus err: %s", err.message);
110 dbus_error_free(&err);
114 if (strcmp(key, "quicksetting_order") == 0) {
115 DBG("order:%s %d", order, num_featured);
116 if (quickpanel_settings_featured_list_validation_check(order) == 1) {
117 order_split = g_strsplit(order, ",", 0);
118 if (order_split != NULL) {
119 order_count = g_strv_length(order_split);
120 DBG("count of quicksettings:%d", order_count);
122 for (i = 0; i < order_count; i++) {
123 mod = quickpanel_settings_module_get_by_name(order_split[i]);
124 if (mod != NULL && mod->init != NULL) {
125 list_active = eina_list_append (list_active, mod);
127 ERR("failed to get quicksetting:%s", order_split[i]);
133 if (list_active != NULL) {
134 quickpanel_setting_view_featured_reload(list_active, num_featured);
135 quickpanel_setting_view_all_reload(list_active);
136 quickpanel_setting_save_list_to_file(list_active, num_featured);
137 eina_list_free(list_active);
140 g_strfreev(order_split);
143 ERR("setting order validation check failed, igonore this signal");
148 static void _settings_ipc_init(void *data)
150 struct appdata *ad = data;
151 retif(ad == NULL, , "Invalid parameter!");
152 retif(ad->dbus_connection == NULL, , "Invalid parameter!");
154 s_info.hdl_activity =
155 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
158 QS_DBUS_SIG_ACTIVITY,
159 _handler_activity, ad);
160 msgif(s_info.hdl_activity == NULL, "fail to add size signal");
163 e_dbus_signal_handler_add(ad->dbus_connection, NULL,
167 _handler_editing, ad);
168 msgif(s_info.hdl_editing == NULL, "fail to add size signal");
171 static void _settings_ipc_fini(void *data)
173 struct appdata *ad = data;
174 retif(ad == NULL, , "Invalid parameter!");
175 retif(ad->dbus_connection == NULL, , "Invalid parameter!");
177 if (s_info.hdl_activity != NULL) {
178 e_dbus_signal_handler_del(ad->dbus_connection,
179 s_info.hdl_activity);
180 s_info.hdl_activity = NULL;
183 if (s_info.hdl_editing != NULL) {
184 e_dbus_signal_handler_del(ad->dbus_connection,
186 s_info.hdl_editing = NULL;
190 /*****************************************************************************
194 *****************************************************************************/
195 HAPI int quickpanel_settings_ipc_init(void *data)
197 _settings_ipc_init(data);
202 HAPI int quickpanel_settings_ipc_fini(void *data)
204 _settings_ipc_fini(data);