2 * Copyright 2013 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.
24 #include "mf-widget.h"
26 #include "mf-fs-util.h"
27 #include "mf-launch.h"
30 #include "mf-resource.h"
32 int mf_share_mode_get(Eina_List * selected_list)
34 mf_retvm_if(selected_list == NULL, -1, "selected_list is NULL");
35 int file_mode = SHARE_FILE_MODE_NORMAL;
38 GString *pNode = NULL;
41 EINA_LIST_FOREACH(selected_list, l, pNode) {
43 char *file_path = pNode->str;
44 if (ecore_file_is_dir(file_path)) {
48 fsFileType category = FILE_TYPE_NONE;
50 mf_file_attr_get_file_category(file_path, &category);
51 if (category == FILE_TYPE_IMAGE) {
53 if (image_count > 1) {
54 file_mode = file_mode | SHARE_FILE_MODE_MULTI_IMAGE;
56 file_mode = file_mode | SHARE_FILE_MODE_IMAGE;
58 } else if (category == FILE_TYPE_VIDEO) {
60 if (video_count > 1) {
61 file_mode = file_mode | SHARE_FILE_MODE_MULTI_VIDEO;
63 file_mode = file_mode | SHARE_FILE_MODE_VIDEO;
66 file_mode = file_mode | SHARE_FILE_MODE_OTHERS;
72 static int __mf_share_get_selected_files(void *data, gchar ** selected_files, Eina_List * selected_list)
75 struct appdata *ap = (struct appdata *)data;
76 mf_retvm_if(ap == NULL, -1, "ap is NULL");
77 mf_retvm_if(selected_list == NULL, 0, "selected_list is NULL");
78 mf_retvm_if(selected_files == NULL, -1, "selected_files is NULL");
82 GString *pNode = NULL;
83 gchar *message = NULL;
85 EINA_LIST_FOREACH(ap->mf_FileRecordList.selected_files, l, pNode) {
87 if (!ecore_file_is_dir(pNode->str) && mf_drm_is_drm_file(pNode->str) == 0) {
88 if (mf_drm_is_converted_fl(pNode->str) == 0) {
89 message = g_strconcat(GET_STR(MF_POPUP_MESSAGE_SEND_FAIL1), "<br>", ecore_file_file_get(pNode->str),
90 GET_STR(MF_POPUP_MESSAGE_SEND_FAIL2), NULL);
91 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message,
92 NULL, NULL, NULL, NULL, NULL);
96 if (*selected_files != NULL) {
97 g_free(*selected_files);
98 *selected_files = NULL;
103 } else if (ecore_file_is_dir(pNode->str)) {
104 message = GET_STR(MF_POPUP_MESSAGE_SEND_FAIL3);
105 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
107 if (*selected_files != NULL) {
108 g_free(*selected_files);
109 *selected_files = NULL;
115 if (*selected_files == NULL) {
116 *selected_files = g_strconcat(pNode->str, NULL);
119 gchar *temp = *selected_files;
120 if (ap->mf_Status.more == MORE_SENDVIABLUETOOTH
122 *selected_files = g_strconcat(*selected_files, "?", pNode->str, NULL);
126 *selected_files = g_strconcat(*selected_files, "\n", pNode->str, NULL);
138 void mf_share_launch_multi_file(void *data)
141 struct appdata *ap = (struct appdata *)data;
143 gchar *myFilenames = NULL;
144 int number_of_files = 0;
145 char count_arg[20] = { 0, };
146 const char *message = NULL;
148 number_of_files = __mf_share_get_selected_files(ap, &myFilenames, ap->mf_FileRecordList.selected_files);
149 if (number_of_files < 0) {
152 } else if (number_of_files == 0) {
153 message = GET_SYS_STR(MF_LABEL_NOTHING_SELECTED);
154 ap->mf_MainWindow.pNormalPopup = mf_popup_create_popup(ap, POPMODE_TEXT, NULL, message, NULL, NULL, NULL, NULL, NULL);
158 snprintf(count_arg, sizeof(count_arg), "%d", number_of_files);
159 if (ap->mf_Status.more == MORE_SENDVIABLUETOOTH) {
160 mf_debug("::::::::::Send via bluetooth:::::::::::::");
161 mf_launch_load_ug(ap, myFilenames, MF_LOAD_UG_BLUETOOTH, count_arg);
162 } else if (ap->mf_Status.more == MORE_SENDVIAEMAIL) {
163 mf_debug("::::::::::Send via email::::::::::::: files is [%s]", myFilenames);
164 mf_launch_load_ug(ap, myFilenames, MF_LOAD_UG_EMAIL, count_arg);
165 } else if (ap->mf_Status.more == MORE_SENDVIAMESSAGE) {
166 mf_debug("::::::::::Send via message::::::::::::: files is [%s]", myFilenames);
167 mf_launch_load_ug(ap, myFilenames, MF_LOAD_UG_MESSAGE, count_arg);