2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
17 #include "cst-debug.h"
19 #include "cst-common.h"
20 #include "cst-reject-msg.h"
21 #include "cst-widget.h"
24 #include <msg_types.h>
28 #define CST_CT_UG_CONTACTS_LIST "contacts-list-efl"
29 #define CST_CT_UG_REQUEST_SELECT_NUMBER 12
30 #define CST_CT_UG_BUNDLE_TYPE "type"
31 #define CST_CT_UG_BUNDLE_RESULT_NUMBER_ID "num_id"
32 #define CST_CT_UG_BUNDLE_RESULT_PERSON_ID "person_id"
35 #define UG_MODULE_API __attribute__ ((visibility("default")))
38 UG_MODULE_API char *cst_reject_msg_get(int index)
40 ENTER(cst_reject_msg_get);
41 bindtextdomain(UGNAME, CST_LOCALE);
43 char *message = _cst_get_reject_message(index);
47 void _cst_vconf_get_bool(const char *in_key, int *boolval)
49 if ((vconf_get_bool(in_key, boolval)) < 0) {
50 DBG("vconf get error : %s", in_key);
54 void _cst_vconf_get_int(const char *in_key, int *intval)
56 if ((vconf_get_int(in_key, intval)) < 0) {
57 DBG("vconf get error : %s", in_key);
61 char *_cst_vconf_get_str(const char *in_key)
64 result = vconf_get_str(in_key);
66 DBG("vconf get error : %s", in_key);
72 void _cst_vconf_set_bool(const char *in_key, const int boolval)
74 if (vconf_set_bool(in_key, boolval) < 0) {
75 DBG("vconf set error : %s", in_key);
77 DBG("vconf set : %d(%s)", boolval, in_key);
81 void _cst_vconf_set_int(const char *in_key, const int intval)
83 if (vconf_set_int(in_key, intval) < 0) {
84 DBG("vconf set error : %s", in_key);
86 DBG("vconf set : %d(%s)", intval, in_key);
90 void _cst_vconf_set_str(const char *in_key, const char *strval)
92 if (vconf_set_str(in_key, strval) < 0) {
93 DBG("vconf set error : %s", in_key);
95 DBG("vconf set : %s(%s)", strval, in_key);
99 Eina_Bool _cst_check_flight_mode(void)
101 ENTER(_cst_check_flight_mode);
102 int flight_mode = EINA_FALSE;
104 _cst_vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &flight_mode);
108 Eina_Bool _cst_check_sim_status(void)
110 ENTER(_cst_check_sim_status);
111 int sim_status = VCONFKEY_TELEPHONY_SIM_UNKNOWN;
112 Eina_Bool sim_avail = EINA_FALSE;
114 _cst_vconf_get_int(VCONFKEY_TELEPHONY_SIM_SLOT, &sim_status);
115 if (sim_status == VCONFKEY_TELEPHONY_SIM_INSERTED) {
116 sim_avail = EINA_TRUE;
121 int _cst_parse_bundle(service_h service)
123 int type = CST_UG_REQ_NONE;
127 service_get_extra_data(service, CST_UG_BUNDLE_TYPE, &val);
131 DBG("Bundle type = %d", type);
137 static void __cst_contact_list_view_ug_destroy_cb(ui_gadget_h ug, void *priv)
139 ENTER(__cst_contact_list_view_ug_destroy_cb);
145 static void __cst_contact_list_view_ug_result_cb(ui_gadget_h ug, service_h service, void *priv)
147 ENTER(__cst_contact_list_view_ug_result_cb);
148 CstUgData_t *ugd = (CstUgData_t *)priv;
154 char *displayname = NULL;
155 contacts_record_h numbers_record = NULL;
156 contacts_record_h contacts_record = NULL;
158 service_get_extra_data(service, CST_CT_UG_BUNDLE_RESULT_NUMBER_ID, &temp_p);
159 number_id = atoi(temp_p);
161 service_get_extra_data(service, CST_CT_UG_BUNDLE_RESULT_PERSON_ID, &temp_p);
162 person_id = atoi(temp_p);
164 if (contacts_connect2() != CONTACTS_ERROR_NONE) {
165 DBG("contacts_connect2 failed");
166 ugd->popup = _cst_create_error_popup(ugd->nf, CST_ERROR_UNKNOWN);
167 evas_object_show(ugd->popup);
171 DBG("number_id = %d, person_id = %d", number_id, person_id);
173 /* get and set number */
174 if (contacts_db_get_record(_contacts_number._uri, number_id, &numbers_record) != CONTACTS_ERROR_NONE) {
175 DBG("contacts_db_get_record for number failed");
176 ugd->popup = _cst_create_error_popup(ugd->nf, CST_ERROR_SELECT_VALID_ENTRY);
177 evas_object_show(ugd->popup);
179 if (contacts_record_get_str_p(numbers_record, _contacts_number.number, (char**)&number) == CONTACTS_ERROR_NONE) {
180 DBG("number = %s", number);
182 if (ugd->dg_entry_contact_number) {
183 elm_entry_entry_set(ugd->dg_entry_contact_number, number);
185 elm_entry_entry_set(ugd->dg_entry, number);
189 contacts_record_destroy(numbers_record, true);
191 /* get and set display name if needed */
192 if (ugd->dg_entry_contact_name) {
193 if (contacts_db_get_record(_contacts_person._uri, person_id, &contacts_record) != CONTACTS_ERROR_NONE) {
194 DBG("contacts_db_get_record for display name failed");
195 ugd->popup = _cst_create_error_popup(ugd->nf, CST_ERROR_SELECT_VALID_ENTRY);
196 evas_object_show(ugd->popup);
198 if (contacts_record_get_str_p(contacts_record, _contacts_person.display_name, (char**)&displayname) == CONTACTS_ERROR_NONE) {
199 DBG("displayname = %s", displayname);
201 elm_entry_entry_set(ugd->dg_entry_contact_name, displayname);
204 contacts_record_destroy(contacts_record, true);
207 if (contacts_disconnect2() != CONTACTS_ERROR_NONE) {
208 DBG("contacts_disconnect2 failed");
212 static void __cst_contact_list_view_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
214 ENTER(__cst_contact_list_view_ug_layout_cb);
215 Evas_Object *base = ug_get_layout(ug);
217 ret_if(NULL == base);
219 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
220 elm_win_resize_object_add(ug_get_window(), base);
221 evas_object_show(base);
224 static ui_gadget_h __cst_invoke_contact_uigadget(void *data)
226 ENTER(__cst_invoke_contact_uigadget);
228 struct ug_cbs cbs = {0, };
230 retv_if(NULL == data, NULL);
231 CstUgData_t *ugd = (CstUgData_t *)data;
233 service_h service = NULL;
235 service_create(&service);
237 retv_if(NULL == service, NULL);
239 service_set_operation(service, SERVICE_OPERATION_CREATE_CONTENT);
241 snprintf(buf, sizeof(buf), "%d", CST_CT_UG_REQUEST_SELECT_NUMBER);
243 service_add_extra_data(service, CST_CT_UG_BUNDLE_TYPE, buf);
245 cbs.layout_cb = __cst_contact_list_view_ug_layout_cb;
246 cbs.result_cb = __cst_contact_list_view_ug_result_cb;
247 cbs.destroy_cb = __cst_contact_list_view_ug_destroy_cb;
248 cbs.priv = (void *)ugd;
250 ug = ug_create((ui_gadget_h)ugd->ug, CST_CT_UG_CONTACTS_LIST, UG_MODE_FULLVIEW, service, &cbs);
252 service_destroy(service);
257 void _cst_on_click_ime_contact_btn(void *data, Evas_Object *obj, void *event_info)
259 ENTER(_cst_on_click_ime_contact_btn);
260 ret_if(NULL == data);
261 CstUgData_t *ugd = (CstUgData_t *)data;
263 __cst_invoke_contact_uigadget(ugd);
266 Eina_Bool _cst_naviframe_item_pop_cb(void *data)
268 CstUgData_t *ugd = (CstUgData_t *)data;
269 elm_naviframe_item_pop(ugd->nf);
271 ugd->back_button = _cst_get_navifr_prev_btn(ugd->nf);
273 return ECORE_CALLBACK_CANCEL;