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.
20 #include <ui-gadget.h>
31 #include "mp-ug-launch.h"
32 #include "mp-define.h"
36 #include "mp-player-debug.h"
37 #include "mp-play-view.h"
38 #include "mp-widget.h"
40 #ifdef MP_SOUND_PLAYER
41 #include "sp-view-manager.h"
43 #include "mp-common.h"
44 #include "mp-group-view.h"
45 #include "mp-view-manager.h"
48 #define UG_EMAIL_NAME "email-composer-efl"
49 #define UG_BT_NAME "setting-bluetooth-efl"
50 #define UG_MUSIC_INFO "music-info-efl"
51 #define UG_MSG_NAME "msg-composer-efl"
52 #ifdef MP_FEATURE_WIFI_SHARE
53 #define UG_FTM_NAME "fileshare-efl"
55 #define UG_MUSIC_SETTINGS "setting-music-player-efl"
57 #define MP_UG_INFO_PATH "path"
58 #define MP_UG_INFO_ALBUMART "albumart"
59 #define MP_UG_INFO_ARTIST "artist"
60 #define MP_UG_INFO_ID "id"
61 #define MP_UG_INFO_DESTROY "destroy"
62 #define MP_UG_INFO_BACK "back"
63 #define MP_UG_INFO_LOAD "load"
64 #define MP_UG_INFO_ALBUMART_CLICKED "albumart_clicked"
65 #define MP_UG_INFO_MEDIA_SVC_HANDLE "media_service_handle"
68 #define CT_UG_REQUEST_SAVE_RINGTONE 42
69 #define CT_UG_BUNDLE_TYPE "type"
70 #define CT_UG_BUNDLE_PATH "ct_path"
71 #define UG_CONTACTS_LIST "contacts-list-efl"
74 _mp_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
77 Evas_Object *base, *win;
82 base = ug_get_layout(ug);
86 win = ug_get_window();
90 case UG_MODE_FULLVIEW:
91 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
92 elm_win_resize_object_add(win, base);
93 evas_object_show(base);
104 _mp_ug_destroy(struct appdata *ad)
115 _mp_ug_destroy_cb(ui_gadget_h ug, void *priv)
121 struct appdata *ad = priv;
128 _mp_ug_create_ug(struct appdata *ad, ui_gadget_h parent, const char *name, enum ug_mode mode, service_h service,
134 ui_gadget_h ug = NULL;
136 ug = ug_create(parent, name, mode, service, cbs);
140 ERROR_TRACE("unable to create ug %s", name);
141 mp_widget_text_popup(ad, GET_SYS_STR("IDS_COM_BODY_APPLICATION_NOT_INSTALLED"));
148 mp_ug_email_attatch_file(const char *filepath, void *user_data)
151 struct appdata *ad = NULL;
152 service_h service = NULL;
153 struct ug_cbs cbs = { 0, };
156 mp_retvm_if(filepath == NULL, -1, "file path is NULL");
157 mp_retvm_if(user_data == NULL, -1, "appdata is NULL");
159 ad = (struct appdata *)user_data;
160 MP_CHECK_VAL(ad, -1);
164 ERROR_TRACE("Destory previous ui-gadget first !!!!");
167 option = UG_OPT_INDICATOR_ENABLE;
169 UG_INIT_EFL(ad->win_main, option);
171 if(service_create(&service) != SERVICE_ERROR_NONE)
173 ERROR_TRACE("Error: service_create");
177 service_add_extra_data(service, "RUN_TYPE", "5");
178 service_add_extra_data(service, "ATTACHMENT", filepath);
180 cbs.priv = user_data;
181 cbs.layout_cb = _mp_ug_layout_cb;
182 cbs.result_cb = NULL;
183 cbs.destroy_cb = _mp_ug_destroy_cb;
186 ad->ug = _mp_ug_create_ug(ad, NULL, UG_EMAIL_NAME, UG_MODE_FULLVIEW, service, &cbs);
188 service_destroy(service);
194 mp_ug_message_attatch_file(const char *filepath, void *user_data)
197 struct appdata *ad = NULL;
198 service_h service = NULL;
199 struct ug_cbs cbs = { 0, };
202 mp_retvm_if(filepath == NULL, -1, "file path is NULL");
203 mp_retvm_if(user_data == NULL, -1, "appdata is NULL");
205 ad = (struct appdata *)user_data;
206 MP_CHECK_VAL(ad, -1);
210 ERROR_TRACE("Destory previous ui-gadget first !!!!");
213 option = UG_OPT_INDICATOR_ENABLE;
215 UG_INIT_EFL(ad->win_main, option);
217 if(service_create(&service) != SERVICE_ERROR_NONE)
219 ERROR_TRACE("Error: service_create");
222 service_add_extra_data(service, "ATTACHFILE", filepath);
224 cbs.priv = user_data;
225 cbs.layout_cb = _mp_ug_layout_cb;
226 cbs.result_cb = NULL;
227 cbs.destroy_cb = _mp_ug_destroy_cb;
229 ad->ug = _mp_ug_create_ug(ad, NULL, UG_MSG_NAME, UG_MODE_FULLVIEW, service, &cbs);
230 service_destroy(service);
235 mp_ug_bt_attatch_file(const char *filepath, int count, void *user_data)
238 struct appdata *ad = NULL;
239 service_h service = NULL;
240 struct ug_cbs cbs = { 0, };
242 char *file_count = NULL;
244 mp_retvm_if(filepath == NULL, -1, "file path is NULL");
245 mp_retvm_if(user_data == NULL, -1, "appdata is NULL");
250 ERROR_TRACE("Destory previous ui-gadget first !!!!");
254 option = UG_OPT_INDICATOR_ENABLE;
256 UG_INIT_EFL(ad->win_main, option);
258 file_count = g_strdup_printf("%d", count);
260 if(service_create(&service) != SERVICE_ERROR_NONE)
262 ERROR_TRACE("Error: service_create");
265 service_add_extra_data(service, "launch-type", "send");
266 service_add_extra_data(service, "filecount", file_count);
267 service_add_extra_data(service, "files", filepath);
269 cbs.priv = user_data;
270 cbs.layout_cb = _mp_ug_layout_cb;
271 cbs.result_cb = NULL;
272 cbs.destroy_cb = _mp_ug_destroy_cb;
274 ad->ug = _mp_ug_create_ug(ad, NULL, UG_BT_NAME, UG_MODE_FULLVIEW, service, &cbs);
276 service_destroy(service);
281 #ifdef MP_FEATURE_WIFI_SHARE
283 mp_ug_wifi_attatch_file(const char *filepath, int count, void *user_data)
286 struct appdata *ad = NULL;
287 service_h service = NULL;
288 struct ug_cbs cbs = { 0, };
290 char *file_count = NULL;
292 mp_retvm_if(filepath == NULL, -1, "file path is NULL");
293 mp_retvm_if(user_data == NULL, -1, "appdata is NULL");
298 ERROR_TRACE("Destory previous ui-gadget first !!!!");
301 option = UG_OPT_INDICATOR_ENABLE;
302 UG_INIT_EFL(ad->win_main, option);
303 file_count = g_strdup_printf("%d", count);
304 if(service_create(&service) != SERVICE_ERROR_NONE)
306 ERROR_TRACE("Error: service_create");
309 service_add_extra_data(service, "filecount", file_count);
310 service_add_extra_data(service, "files", filepath);
311 cbs.priv = user_data;
312 cbs.layout_cb = _mp_ug_layout_cb;
313 cbs.result_cb = NULL;
314 cbs.destroy_cb = _mp_ug_destroy_cb;
315 ad->ug = _mp_ug_create_ug(ad, NULL, UG_FTM_NAME, UG_MODE_FULLVIEW, service, &cbs);
316 service_destroy(service);
323 mp_ug_contact_user_sel(const char *filepath, void *user_data)
326 struct appdata *ad = NULL;
327 service_h service = NULL;
328 struct ug_cbs cbs = { 0, };
331 mp_retvm_if(filepath == NULL, -1, "file path is NULL");
332 mp_retvm_if(user_data == NULL, -1, "appdata is NULL");
337 ERROR_TRACE("Destory previous ui-gadget first !!!!");
341 option = UG_OPT_INDICATOR_ENABLE;
343 UG_INIT_EFL(ad->win_main, option);
345 if(service_create(&service) != SERVICE_ERROR_NONE)
347 ERROR_TRACE("Error: service_create");
353 snprintf(buf, sizeof(buf), "%d", CT_UG_REQUEST_SAVE_RINGTONE);
354 service_add_extra_data(service, CT_UG_BUNDLE_TYPE, buf);
355 service_add_extra_data(service, CT_UG_BUNDLE_PATH, filepath);
358 cbs.layout_cb = _mp_ug_layout_cb;
359 cbs.result_cb = NULL;
360 cbs.destroy_cb = _mp_ug_destroy_cb;
362 ad->ug = _mp_ug_create_ug(ad, NULL, UG_CONTACTS_LIST, UG_MODE_FULLVIEW, service, &cbs);
364 service_destroy(service);
371 mp_ug_send_message(struct appdata *ad, mp_ug_message_t message)
374 ui_gadget_h ug = NULL;
378 service_h service = NULL;
380 if(service_create(&service) != SERVICE_ERROR_NONE)
382 ERROR_TRACE("Error: service_create");
389 case MP_UG_MESSAGE_DEL:
391 service_add_extra_data(service, MP_UG_INFO_DESTROY, MP_UG_INFO_DESTROY);
393 case MP_UG_MESSAGE_BACK:
395 service_add_extra_data(service, MP_UG_INFO_BACK, MP_UG_INFO_BACK);
397 case MP_UG_MESSAGE_LOAD:
400 service_add_extra_data(service, MP_UG_INFO_LOAD, MP_UG_INFO_LOAD);
401 music_list_item *item = mp_play_list_get_current_item(ad->playing_list);
402 MP_CHECK_EXCEP(item);
404 service_add_extra_data(service, MP_UG_INFO_PATH, item->filename);
405 service_add_extra_data(service, MP_UG_INFO_ALBUMART, item->albumart);
406 service_add_extra_data(service, MP_UG_INFO_ARTIST, item->artist);
408 id = g_strdup(item->key_id);
410 service_add_extra_data(service, MP_UG_INFO_ID, id);
414 service_destroy(service);
417 ug_send_message(ug, service);
421 service_destroy(service);
426 mp_ug_destory_all(struct appdata *ad)
429 // ad->info_ug should not be destoryed!!
436 mp_ug_active(struct appdata *ad)