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://www.tizenopensource.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.
22 #include "smartsearch.h"
23 #include "ps_app_interface.h"
24 #include "ps_searcher.h"
25 #include <ui-gadget.h>
26 #include <contacts-ug.h>
27 #include <aul_service.h>
31 #define UG_NAME_LEN 50
33 static void __search_layout_ug_destroy(void *data)
37 struct appdata *ad = (struct appdata *)data;
39 //D. Because the ug will be able to remove the base object, unset the content from the effect layout.
40 elm_object_part_content_unset(ad->effect_layout,
41 (char *)ug_get_layout(ad->detail_ug));
43 evas_object_del(ad->effect_layout);
45 ug_destroy(ad->detail_ug);
48 ad->effect_layout = NULL;
53 static void __search_effect_layout_signal_hide_finished(void *data,
60 __search_layout_ug_destroy(data);
65 static void __search_effect_layout_render_flush_post_cb(void *data, Evas * e,
70 struct appdata *ad = (struct appdata *)data;
75 edje_object_signal_emit(elm_layout_edje_get(ad->effect_layout),
76 "elm,state,show", "");
78 //B.Remove the EVAS_RENDER_FLUSH_POST callback again.
79 evas_event_callback_del(e, EVAS_CALLBACK_RENDER_FLUSH_POST,
80 __search_effect_layout_render_flush_post_cb);
85 static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode,
90 struct appdata *ad = (struct appdata *)priv;
92 Evas_Object *base = (Evas_Object *) ug_get_layout(ug);
97 #ifdef ENABLE_UG_EFFECT
98 if (!ad->effect_layout)
101 elm_object_part_content_set(ad->effect_layout, "elm.swallow.content", base);
102 //B. Add the callback event for the EVAS_RENDER_FLUSH_POST
103 //B. This is one method to not skip the total effect time in creating the ug object.
104 evas_event_callback_add(evas_object_evas_get(ad->effect_layout),
105 EVAS_CALLBACK_RENDER_FLUSH_POST,
106 __search_effect_layout_render_flush_post_cb,
109 evas_object_show(base);
115 static void __search_ug_closed_cb(struct ui_gadget *ug, void *priv)
119 struct appdata *ad = (struct appdata *)priv;
121 #ifdef ENABLE_UG_EFFECT
122 edje_object_signal_emit(elm_layout_edje_get(ad->effect_layout),
123 "elm,state,hide", "");
125 Evas_Object *base = (Evas_Object *) ug_get_layout(ug);
127 evas_object_hide(base);
133 static void __search_create_effect_layout(Evas_Object * parent,
140 //Create the layout then apply the edj
141 Evas_Object *ly = elm_layout_add(ad->win_main);
146 evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
148 elm_win_resize_object_add(ad->win_main, ly);
150 ret = elm_layout_file_set(ly, SEARCH_EDJ, "ug_effect");
152 //Add a signal callback function which will be called after terminating hide effect.
153 edje_object_signal_callback_add(elm_layout_edje_get(ly),
154 "elm,action,hide,finished", "",
155 __search_effect_layout_signal_hide_finished,
158 //store the layout object to refer it at hide effect
159 ad->effect_layout = ly;
161 evas_object_show(ly);
166 void search_launch_contact_view(void *data, void *record_info)
170 struct appdata *ad = (struct appdata *)data;
171 struct search_item_sel *cur_category_mem =
172 (struct search_item_sel *)record_info;
176 struct ui_gadget *ug;
177 struct ug_cbs cbs = { 0, };
179 char buf[10] = { 0, };
182 SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug");
183 __search_layout_ug_destroy(ad);
186 kb = bundle_create();
188 SEARCH_DEBUG_ERROR("contact bundle_create");
192 snprintf(buf, sizeof(buf), "%d", CT_UG_REQUEST_DETAIL);
193 bundle_add(kb, CT_UG_BUNDLE_TYPE, buf);
194 bundle_add(kb, CT_UG_BUNDLE_ID, cur_category_mem->main_id);
196 #ifdef ENABLE_UG_EFFECT
197 __search_create_effect_layout(ad->win_main, ad);
200 cbs.layout_cb = __search_ug_layout_cb;
201 cbs.result_cb = NULL;
202 cbs.destroy_cb = __search_ug_closed_cb;
205 ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, kb, &cbs);
207 SEARCH_DEBUG_ERROR(" ... ug_create: failed !!!");
208 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
218 void search_launch_msg_view(void *data, void *record_info)
222 struct appdata *ad = (struct appdata *)data;
223 struct search_item_sel *cur_category_mem =
224 (struct search_item_sel *)record_info;
231 SEARCH_DEBUG_ERROR("search_launch_msg_view : bundle_create failed");
235 bundle_add(b, "type", "msg_id");
236 bundle_add(b, "msgId", cur_category_mem->main_id);
237 ret = aul_launch_app("org.tizen.message", b);
238 if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){
239 SEARCH_DEBUG_ERROR("msg aul launch app error(%d)", ret);
240 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
248 void search_launch_email_view(void *data, void *record_info)
253 char *token_param = NULL;
257 struct appdata *ad = (struct appdata *)data;
258 struct search_item_sel *cur_category_mem =
259 (struct search_item_sel *)record_info;
265 char livemagazine[2] = { 0, };
266 char temp_path[MAX_LENGTH_PER_PATH] = { 0, };
267 livemagazine[0] = '0';
269 snprintf(temp_path, MAX_LENGTH_PER_PATH - 1, "%s",
270 cur_category_mem->path);
272 token_param = strtok_r(temp_path, " ", &saveptr1);
274 while (token_param != NULL) {
276 bundle_add(b, "ACCOUNT_ID", token_param); //account_id
278 bundle_add(b, "MAIL_ID", token_param); //mail_id
280 bundle_add(b, "MAILBOX", token_param); //mailbox
286 token_param = strtok_r(NULL, " ", &saveptr1);
289 bundle_add(b, "bLiveMagazine", livemagazine);
291 char runType[2] = { 0 };
292 snprintf(runType, sizeof(runType), "%d", 7);
293 bundle_add(b, "RUN_TYPE", runType);
294 ret = aul_launch_app("org.tizen.email", b);
295 if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){
296 SEARCH_DEBUG_ERROR("email aul launch app error(%d)", ret);
297 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
305 void search_launch_image_view(void *data, void *record_info)
309 struct appdata *ad = (struct appdata *)data;
310 struct search_item_sel *cur_category_mem =
311 (struct search_item_sel *)record_info;
314 if (access(cur_category_mem->path, F_OK) != 0) {
315 SEARCH_DEBUG_ERROR("image access error : %s",
316 cur_category_mem->path);
317 search_launch_popup_error(LAUNCH_ERROR_FILE_NOT_FOUND,
320 SEARCH_DEBUG_LOG("cur_category_mem->path : %s",
321 cur_category_mem->path);
324 bd = bundle_create();
327 appsvc_set_operation(bd, APPSVC_OPERATION_VIEW);
328 appsvc_set_uri(bd, cur_category_mem->path);
329 ret = appsvc_run_service(bd, 0, NULL, NULL);
332 search_launch_popup_error(LAUNCH_ERROR_APPSVC,
342 void search_launch_video_view(void *data, void *record_info)
346 struct appdata *ad = (struct appdata *)data;
347 struct search_item_sel *cur_category_mem =
348 (struct search_item_sel *)record_info;
351 if (access(cur_category_mem->path, F_OK) != 0) {
352 SEARCH_DEBUG_ERROR("video access error : %s",
353 cur_category_mem->path);
354 search_launch_popup_error(LAUNCH_ERROR_FILE_NOT_FOUND, ad);
357 bd = bundle_create();
359 appsvc_set_operation(bd, APPSVC_OPERATION_VIEW);
360 appsvc_set_uri(bd, cur_category_mem->path);
361 ret = appsvc_run_service(bd, 0, NULL, NULL);
364 SEARCH_DEBUG_ERROR("video app service error(%d) : %s",
365 ret, cur_category_mem->path);
366 search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad);
375 void search_launch_music_view(void *data, void *record_info)
379 struct appdata *ad = (struct appdata *)data;
380 struct search_item_sel *cur_category_mem =
381 (struct search_item_sel *)record_info;
384 if (access(cur_category_mem->path, F_OK) != 0) {
385 SEARCH_DEBUG_ERROR("music file access error : %s",
386 cur_category_mem->path);
387 search_launch_popup_error(LAUNCH_ERROR_FILE_NOT_FOUND, ad);
389 SEARCH_DEBUG_LOG("cur_category_mem->path : %s",
390 cur_category_mem->path);
393 bd = bundle_create();
396 appsvc_set_operation(bd, APPSVC_OPERATION_VIEW);
397 appsvc_set_uri(bd, cur_category_mem->path);
398 ret = appsvc_run_service(bd, 0, NULL, NULL);
401 SEARCH_DEBUG_ERROR("music app service error(%d) : %s",
402 ret, cur_category_mem->path);
403 search_launch_popup_error(LAUNCH_ERROR_APPSVC,
413 void search_launch_calendar_view(void *data, void *record_info)
417 struct appdata *ad = (struct appdata *)data;
418 struct search_item_sel *cur_category_mem =
419 (struct search_item_sel *)record_info;
420 struct ui_gadget *ug;
421 struct ug_cbs cbs = { 0, };
427 SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug");
429 __search_layout_ug_destroy(ad);
436 bundle_add(b, AUL_K_SERVICE_NAME, "view_event");
437 bundle_add(b, "index", cur_category_mem->main_id);
439 SEARCH_DEBUG_LOG("index : %s", cur_category_mem->main_id);
441 ret = aul_launch_app("org.tizen.efl-calendar", b);
442 if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){
443 SEARCH_DEBUG_ERROR("calendar aul launch app error(%d)", ret);
444 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
452 void search_launch_memo_view(void *data, void *record_info)
456 struct appdata *ad = (struct appdata *)data;
457 struct search_item_sel *cur_category_mem =
458 (struct search_item_sel *)record_info;
459 struct ui_gadget *ug;
460 struct ug_cbs cbs = { 0, };
465 SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug");
467 __search_layout_ug_destroy(ad);
474 bundle_add(b, "index", cur_category_mem->main_id);
476 __search_create_effect_layout(ad->win_main, ad);
478 cbs.layout_cb = __search_ug_layout_cb;
479 cbs.result_cb = NULL;
480 cbs.destroy_cb = __search_ug_closed_cb;
483 ug = ug_create(NULL, "memo-efl", UG_MODE_FULLVIEW, b, &cbs);
485 SEARCH_DEBUG_ERROR("... create_ug_email : failed !!!");
486 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
496 void search_launch_menu_view(void *data, void *record_info)
500 struct appdata *ad = (struct appdata *)data;
501 struct search_item_sel *cur_category_mem =
502 (struct search_item_sel *)record_info;
505 ret = aul_launch_app(cur_category_mem->path, NULL);
507 SEARCH_DEBUG_WARNING("path : %s, ret : %d", cur_category_mem->path, ret);
509 if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){
510 SEARCH_DEBUG_ERROR("menu aul launch app error(%d) : %s", ret,
511 cur_category_mem->path);
512 search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad);
518 static void __search_launch_popup_error_response_cb(void *data,
524 struct appdata *ad = (struct appdata *)data;
526 evas_object_del(ad->ctxpopup);
532 void search_launch_popup_error(int error_type, void *data)
537 struct appdata *ad = (struct appdata *)data;
539 if (error_type >= LAUNCH_ERROR_MAX) {
540 SEARCH_DEBUG_ERROR("wrong error_type : %d", error_type);
544 evas_object_del(ad->ctxpopup);
548 popup = elm_popup_add(ad->win_main);
549 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
553 case LAUNCH_ERROR_FILE_NOT_FOUND:
554 elm_object_text_set(popup,
555 dgettext("sys_string",
556 "IDS_COM_POP_FILE_NOT_FOUND"));
558 case LAUNCH_ERROR_AUL_LAUNCH:
559 /* This Message String enable to be another string in the future */
560 elm_object_text_set(popup,
561 dgettext("sys_string",
562 "IDS_COM_POP_SERVICE_UNAVAILABLE"));
564 case LAUNCH_ERROR_APPSVC:
565 elm_object_text_set(popup,
566 dgettext("sys_string",
567 "IDS_COM_POP_SERVICE_UNAVAILABLE"));
571 btn1 = elm_button_add(popup);
572 elm_object_text_set(btn1,
573 dgettext("sys_string","IDS_COM_SK_OK"));
574 evas_object_smart_callback_add(btn1, "clicked",
575 __search_launch_popup_error_response_cb,
578 elm_object_part_content_set(popup, "button1", btn1);
580 elm_popup_timeout_set(popup, 3.0);
582 evas_object_smart_callback_add(popup, "timeout",
583 __search_launch_popup_error_response_cb,
585 evas_object_smart_callback_add(popup, "block,clicked",
586 __search_launch_popup_error_response_cb,
588 evas_object_show(popup);
590 ad->ctxpopup = popup;