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.
17 #include <Elementary.h>
18 #include <app_service.h>
19 #include "gl-ext-exec.h"
22 #include "gl-db-handler.h"
26 #define GL_APP_PKG_VIDEOPLAYER "org.tizen.video-player"
28 #define GL_ARGV_VIDEO_LIST_TYPE "video_list_type"
29 #define GL_ARGV_VIDEO_ALL_FOLDER_VIDEO "all_folder_video"
30 #define GL_ARGV_VIDEO_FOLDER "folder"
32 #define GL_ARGV_VIDEO_ORDER_TYPE "order_type"
33 #define GL_ARGV_VIDEO_ORDER_DATE_DESC "date_desc"
34 #define GL_ARGV_VIDEO_START_POS "start_pos_time"
36 #define GL_ARGV_VIDEO_LAUNCH_APP "launching_application"
37 #define GL_ARGV_VIDEO_LAUNCH_GALLERY "gallery"
39 #define GL_ARGV_LAUNCH_TYPE "launch-type"
40 #define GL_ARGV_LAUNCH_SEND "send"
41 #define GL_ARGV_LAUNCH_FT_WITH_CONTACT "ft-with-contact"
43 #define GL_ARGV_FT_FILE "file"
44 #define GL_ARGV_PATH "path"
45 #define GL_ARGV_FT_CONTACT "contact"
47 #define GL_SEPERATOR_EMOLINK GL_SEPERATOR_BT
48 #define GL_SEPERATOR_FT ';'
51 //refer to imageviewer
53 _gl_ext_launch_video_player(void *data, service_h service)
55 GL_CHECK_VAL(service, -1);
56 GL_CHECK_VAL(data, -1);
57 gl_item *gitem = (gl_item *)data;
58 GL_CHECK_VAL(gitem->ad, -1);
59 gl_appdata *ad = (gl_appdata *)gitem->ad;
60 GL_CHECK_VAL(gitem->item, -1);
61 GL_CHECK_VAL(gitem->item->uuid, -1);
62 GL_CHECK_VAL(gitem->item->file_url, -1);
64 const char *video_path = gitem->item->file_url;
66 gl_cluster *cur_cluster = ad->albuminfo.current_album;
67 if (cur_cluster && cur_cluster->cluster)
69 gl_dbg("Album: %s", cur_cluster->cluster->display_name);
70 if (!g_strcmp0(cur_cluster->cluster->uuid, GL_ALBUM_ALL_ID))
73 service_add_extra_data(service,
74 GL_ARGV_VIDEO_LIST_TYPE,
75 GL_ARGV_VIDEO_ALL_FOLDER_VIDEO);
76 service_add_extra_data(service,
77 GL_ARGV_VIDEO_ORDER_TYPE,
78 GL_ARGV_VIDEO_ORDER_DATE_DESC);
79 service_add_extra_data(service,
80 GL_ARGV_VIDEO_LAUNCH_APP,
81 GL_ARGV_VIDEO_LAUNCH_GALLERY);
83 else if (cur_cluster->cluster->type == MINFO_PHONE ||
84 cur_cluster->cluster->type == MINFO_MMC)
87 service_add_extra_data(service,
88 GL_ARGV_VIDEO_LIST_TYPE,
89 GL_ARGV_VIDEO_FOLDER);
90 service_add_extra_data(service,
91 GL_ARGV_VIDEO_ORDER_TYPE,
92 GL_ARGV_VIDEO_ORDER_DATE_DESC);
93 service_add_extra_data(service,
94 GL_ARGV_VIDEO_LAUNCH_APP,
95 GL_ARGV_VIDEO_LAUNCH_GALLERY);
99 gl_dbgE("Wrong type!");
104 /* Fixme: return or not? */
105 gl_dbgE("Invalid current album, return?");
108 service_add_extra_data(service, GL_ARGV_PATH, video_path);
109 service_set_operation(service, SERVICE_OPERATION_VIEW);
110 service_set_package(service, GL_APP_PKG_VIDEOPLAYER);
111 if (service_send_launch_request(service, NULL, NULL) == SERVICE_ERROR_NONE)
118 _gl_ext_compose_exec_cmd(void *data, gl_ext_app_type type,
119 char *path, char **pkg_name)
121 GL_CHECK_VAL(data, -1);
122 gl_dbg("type:%d, path:%s", type, path);
126 case GL_APP_VIDEOPLAYER:
127 GL_CHECK_VAL(path, -1);
128 *pkg_name = GL_APP_PKG_VIDEOPLAYER;
138 gl_ext_exec(void *data, gl_ext_app_type type)
140 GL_CHECK_VAL(data, GL_LAUNCH_FAIL);
141 gl_item *gitem = (gl_item *)data;
142 GL_CHECK_VAL(gitem->ad, GL_LAUNCH_FAIL);
143 gl_appdata *ad = (gl_appdata *)gitem->ad;
144 GL_CHECK_VAL(gitem->item, GL_LAUNCH_FAIL);
145 GL_CHECK_VAL(gitem->item->file_url, GL_LAUNCH_FAIL);
146 char *path = gitem->item->file_url;
147 service_h service = NULL;
148 char *pkg_name = NULL;
150 if (ad->uginfo.app_called_by_me)
152 gl_dbg("APP launched, return.");
153 return GL_LAUNCH_FAIL;
156 _gl_ext_compose_exec_cmd(ad, type, path, &pkg_name);
157 GL_CHECK_VAL(gitem->item->file_url, GL_LAUNCH_FAIL);
159 service_create(&service);
160 GL_CHECK_VAL(service, GL_LAUNCH_FAIL);
163 if (type == GL_APP_VIDEOPLAYER) {
165 service_destroy(service);
166 return GL_LAUNCH_FAIL;
168 if (_gl_ext_launch_video_player(data, service) != 0) {
169 service_destroy(service);
170 return GL_LAUNCH_FAIL;
173 service_set_operation(service, SERVICE_OPERATION_DEFAULT);
174 service_set_package(service, pkg_name);
175 ret = service_send_launch_request(service, NULL, NULL);
176 if (ret != SERVICE_ERROR_NONE) {
177 service_destroy(service);
178 gl_dbgE("service_send_launch_request failed[%d]!", ret);
179 return GL_LAUNCH_FAIL;
183 ret = service_destroy(service);
184 if (ret != SERVICE_ERROR_NONE) {
185 ad->uginfo.app_called_by_me = true;
186 return GL_LAUNCH_SUCCESS;
188 return GL_LAUNCH_FAIL;