#include "gl-controlbar.h"
#include "gl-notify.h"
#include "gl-popup.h"
+#include "gl-util.h"
+#include "gl-data-util.h"
+#include "gl-data.h"
+
+static app_control_h g_pServiceShare = NULL;
+static char** g_pShareList = NULL;
+static int g_nShareListSize = 0;
+static bool g_bSharePanelLaunched = FALSE;
+
+static void gl_create_launch_thumbs_share_panel(void* data)
+{
+ if (!data)
+ return;
+ gl_appdata* ad = (gl_appdata*)data;
+
+ char* pOperation = "http://tizen.org/appcontrol/operation/share";
+ int nCounter;
+ int nErr = 0;
+
+ if (g_nShareListSize > 1) {
+ pOperation = "http://tizen.org/appcontrol/operation/multi_share";
+ }
+
+ if (!g_pShareList) {
+ gl_dbgW("[WARNING] Fail to get uri at first.");
+ goto ERROR_EXCEPTION;
+ }
+
+ if (!g_pServiceShare) {
+ nErr = app_control_create(&g_pServiceShare);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("Fail to create ug service handle - [0x%x]",
+ nErr);
+ goto ERROR_EXCEPTION;
+ }
+ }
+
+ nErr = app_control_set_uri(g_pServiceShare, g_pShareList[0]);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("Fail to set uri into ug service handle - [0x%x]",
+ nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ nErr = app_control_set_operation(g_pServiceShare, pOperation);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("app_control_add_extra_data_array().. [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ if (g_nShareListSize >= 1) {
+ nErr = app_control_add_extra_data_array(g_pServiceShare,
+ "http://tizen.org/appcontrol/data/path",
+ (const char
+ **)(&g_pShareList[1]),
+ g_nShareListSize - 1);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgW("[WARNING] app_control_add_extra_data_array() [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+ }
+
+ nErr = app_control_send_launch_request(g_pServiceShare, NULL, NULL);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgW
+ ("[WARNING] app_control_send_launch_request().. [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ g_bSharePanelLaunched = TRUE;
+
+ elm_naviframe_item_pop(ad->maininfo.naviframe);
+
+ return;
+
+ERROR_EXCEPTION:
+ if (g_pServiceShare) {
+ app_control_destroy(g_pServiceShare);
+ g_pServiceShare = NULL;
+ }
+
+ if (g_pShareList) {
+ for (nCounter = 0; nCounter < g_nShareListSize; nCounter++) {
+ if (g_pShareList[nCounter]) {
+ free(g_pShareList[nCounter]);
+ g_pShareList[nCounter] = NULL;
+ }
+ }
+ free(g_pShareList);
+ g_pShareList = NULL;
+ }
+
+}
+
+void gl_launching_thumbs_share_panel(void* data, int cnt)
+{
+ if (!data)
+ return;
+ gl_dbg("");
+ gl_appdata* ad = (gl_appdata*)data;
+
+ int nTotalVideoItem = 0;
+ int nTotalAppendedItem = 0;
+ int nExtraDataSize = 0;
+
+ g_nShareListSize = 0;
+ char** szFileUrlArrayForServiceExtraData = NULL;
+
+ nTotalVideoItem = cnt;
+ gl_dbg("nTotalVideoItem= %d", nTotalVideoItem);
+
+ if (nTotalVideoItem == 0)
+ {
+ gl_dbg("Nothing to share");
+ return;
+ }
+ nExtraDataSize = nTotalVideoItem;
+ if (nExtraDataSize) {
+ szFileUrlArrayForServiceExtraData =
+ (char**)calloc(nExtraDataSize, sizeof(char*));
+
+ /** Store the list so the share panel can be updated later
+ * g_pShareList size needs to bigger than total video size
+ * because first url will be added twice, one for signal share and
+ * one for multiple share.
+ * so g_pShareList alloc size = nExtraDataSize + 1
+ */
+
+ g_pShareList = (char**)calloc((nExtraDataSize + 1), sizeof(char*));
+ }
+
+ /* Extract First URI. */
+ Eina_List* l = NULL;
+ gl_item* gitem = NULL;
+ Eina_List* itemlist = ad->selinfo.elist;
+ EINA_LIST_FOREACH(itemlist, l, gitem) {
+ if (!gitem->item->file_url) {
+ gl_dbgE("file_url is not existed.");
+ continue;
+ }
+ gl_dbg("file url %s", gitem->item->file_url);
+ g_pShareList[0] = strdup(gitem->item->file_url);
+ g_nShareListSize++;
+ break;
+ }
+
+ /* Extract another URI if existing selected items more. */
+ if (nExtraDataSize > 0 && szFileUrlArrayForServiceExtraData) {
+ gitem = NULL;
+ l = NULL;
+ EINA_LIST_FOREACH(itemlist, l, gitem) {
+ if (gitem->item->file_url) {
+ if (nTotalAppendedItem < nExtraDataSize) {
+ szFileUrlArrayForServiceExtraData[nTotalAppendedItem] = gitem->item->file_url;
+ gl_dbg("Appending share item : %s, Total Appended item : %d",
+ (const char**)szFileUrlArrayForServiceExtraData[nTotalAppendedItem],
+ nTotalAppendedItem);
+ nTotalAppendedItem++;
+
+ g_pShareList[g_nShareListSize++] = strdup(gitem->item->file_url);
+ continue;
+ }
+ else
+ {
+ gl_dbgE("Less size is declared");
+ }
+ }
+ else {
+ gl_dbgE("file_url is not existed.");
+ }
+ }
+ }
+
+ gl_create_launch_thumbs_share_panel(data);
+
+ gl_dbg("Launching share panel.");
+/*
+ int nCounter;
+ if (szFileUrlArrayForServiceExtraData) {
+ for (nCounter = 0; nCounter < nExtraDataSize; nCounter++) {
+ if (szFileUrlArrayForServiceExtraData[nCounter]) {
+ free(szFileUrlArrayForServiceExtraData[nCounter]);
+ szFileUrlArrayForServiceExtraData[nCounter] = NULL;
+ }
+ }
+ free(szFileUrlArrayForServiceExtraData);
+ szFileUrlArrayForServiceExtraData = NULL;
+ }*/
+
+ return;
+}
/**
- * Delete the selected media
+ * share the selected media
* @param data : App data
*/
-static void __gl_thumbs_edit_del(void *data)
+static void __gl_thumbs_edit_share(void *data)
{
GL_CHECK(data);
gl_appdata *ad = (gl_appdata *) data;
return;
}
- _gl_popup_create_del(data, GL_POPUP_DEL_FILE,
- _gl_data_selected_list_count,
- gl_del_medias, data);
+ gl_launching_thumbs_share_panel(data, cnt);
+
} else {
- gl_dbgW("Unknow mode!");
+ gl_dbgW("Unknown mode!");
+ }
+}
+
+/**
+ * Delete the selected media
+ * @param data : App data
+ */
+static void __gl_thumbs_edit_del(void* data)
+{
+ GL_CHECK(data);
+ gl_appdata* ad = (gl_appdata*)data;
+ gl_dbg("");
+
+ if (ad->uginfo.ug || ad->uginfo.b_app_called) {
+ gl_dbgW("UG or APP is already loaded!");
+ return;
+ }
+
+ int view_mode = gl_get_view_mode(ad);
+ if (view_mode == GL_VIEW_THUMBS_EDIT) {
+ int cnt = _gl_data_selected_list_count(ad);
+ if (cnt == 0) {
+ gl_dbgW("No thumbs selected!");
+ gl_popup_create_popup(ad, GL_POPUP_NOBUT,
+ GL_STR_NO_FILES_SELECTED);
+ return;
+ }
+
+ _gl_popup_create_del(data, GL_POPUP_DEL_FILE,
+ _gl_data_selected_list_count,
+ gl_del_medias, data);
+ }
+ else {
+ gl_dbgW("Unknown mode!");
}
}
_gl_popup_create_copy_move(data, _gl_data_selected_list_count,
data);
} else {
- gl_dbgW("Unknow mode!");
+ gl_dbgW("Unknown mode!");
}
}
if (_gl_thumbs_get_edit_mode(data) == GL_THUMBS_EDIT_COPY
|| _gl_thumbs_get_edit_mode(data) == GL_THUMBS_EDIT_MOVE) {
__gl_thumbs_edit_copy_move(ad);
+ }
+ else if (_gl_thumbs_get_edit_mode(data) == GL_THUMBS_EDIT_SHARE) {
+ __gl_thumbs_edit_share(ad);
} else {
__gl_thumbs_edit_del(ad);
}
typedef enum _gl_tl_view_t {
GL_TL_VIEW_NORMAL,
GL_TL_VIEW_EDIT,
+ GL_TL_VIEW_SHARE,
GL_TL_VIEW_COPY,
} gl_tl_view_e;
bool check_state;
} _gl_date_item_data;
+static app_control_h g_pServiceShare = NULL;
+static char** g_pShareList = NULL;
+static int g_nShareListSize = 0;
+static bool g_bSharePanelLaunched = FALSE;
+
int _get_count_of_items_on_same_date(gl_media_s * item, Eina_List * list,
char **text, int start_index);
int _gl_time_get_number_of_items_per_row(void *data);
int mode = timeline_d->view_m;
Elm_Object_Item *it = (Elm_Object_Item *) ei;
elm_genlist_item_selected_set(it, EINA_FALSE);
- if (!(mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY)) {
+ if (!(mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY || mode == GL_TL_VIEW_SHARE)) {
gl_dbgE("not edit mode");
return;
}
return layout;
} else if (!g_strcmp0(part, GL_THUMB_CHECKBOX)) {
Evas_Object *ck = NULL;
- if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY) {
+ if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY || mode == GL_TL_VIEW_SHARE) {
ck = elm_check_add(obj);
GL_CHECK_NULL(ck);
return ck;
} else if (!g_strcmp0(part, "elm_image_open_icon_swallow_blocker")) {
Evas_Object *btn1 = NULL;
- if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY) {
+ if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY || mode == GL_TL_VIEW_SHARE) {
btn1 = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_color_set(btn1, 0, 255, 0, 0);
evas_object_propagate_events_set(btn1, EINA_FALSE);
return btn1;
} else if (!g_strcmp0(part, "elm_image_open_icon_swallow")) {
Evas_Object *btn = NULL;
- if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY) {
+ if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY || mode == GL_TL_VIEW_SHARE) {
btn = elm_button_add(obj);
elm_object_style_set(btn, "transparent");
evas_object_show(btn);
if (!g_strcmp0(pPart, "select.all.data.check")) {
Evas_Object *ck = NULL;
- if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY) {
+ if (mode == GL_TL_VIEW_EDIT || mode == GL_TL_VIEW_COPY || mode == GL_TL_VIEW_SHARE) {
ck = elm_check_add(pObject);
GL_CHECK_NULL(ck);
_gl_data_get_items(-1, -1, &list);
_gl_time_finialize_media_data(timeline_d);
if (timeline_d->view_m == GL_TL_VIEW_EDIT
- || timeline_d->view_m == GL_TL_VIEW_COPY) {
+ || timeline_d->view_m == GL_TL_VIEW_COPY
+ || timeline_d->view_m == GL_TL_VIEW_SHARE) {
_gl_time_update_selected_media(timeline_d, list);
}
timeline_d->data_list = list;
__gl_timeline_change_mode(data, GL_TL_VIEW_EDIT);
}
+/**
+ * Create time share view
+ * @param data : App data
+ * @param obj : Context popup object
+ * @param ei : event info
+ */
+
+static void __gl_timeline_share_cb(void* data, Evas_Object* obj, void* ei)
+{
+ GL_CHECK(data);
+ gl_appdata* ad = (gl_appdata*)data;
+ _gl_ctxpopup_del(data);
+ if (ad->uginfo.ug) {
+ /**
+ * Prevent changed to edit view in wrong way.
+ * 1. When invoke imageviewer UG;
+ */
+ gl_dbgW("UG invoked!");
+ return;
+ }
+ __gl_timeline_change_mode(data, GL_TL_VIEW_SHARE);
+}
+
/**
* start time view copy operation
* @param data : App data
/* Delete */
_gl_ctxpopup_append(parent, GL_STR_ID_DELETE,
__gl_timeline_edit_cb, data);
+ /* Share*/
+ _gl_ctxpopup_append(parent, GL_STR_ID_SHARE,
+ __gl_timeline_share_cb, data);
/* Copy to album */
_gl_ctxpopup_append(parent, GL_STR_ID_COPY_TO_ALBUM,
__gl_timeline_copy_cb, data);
return 0;
}
+static void gl_create_launch_share_panel(void* data)
+{
+ if(!data)
+ return;
+ gl_appdata* ad = (gl_appdata*)data;
+
+ char* pOperation = "http://tizen.org/appcontrol/operation/share";
+ int nCounter;
+ int nErr = 0;
+
+ if (g_nShareListSize > 1) {
+ pOperation = "http://tizen.org/appcontrol/operation/multi_share";
+ }
+
+ if (!g_pShareList) {
+ gl_dbgW("[WARNING] Fail to get uri at first.");
+ goto ERROR_EXCEPTION;
+ }
+
+ if (!g_pServiceShare) {
+ nErr = app_control_create(&g_pServiceShare);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("Fail to create ug service handle - [0x%x]",
+ nErr);
+ goto ERROR_EXCEPTION;
+ }
+ }
+
+ nErr = app_control_set_uri(g_pServiceShare, g_pShareList[0]);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("Fail to set uri into ug service handle - [0x%x]",
+ nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ nErr = app_control_set_operation(g_pServiceShare, pOperation);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgE("app_control_add_extra_data_array().. [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ if (g_nShareListSize >= 1) {
+ nErr = app_control_add_extra_data_array(g_pServiceShare,
+ "http://tizen.org/appcontrol/data/path",
+ (const char
+ **)(&g_pShareList[1]),
+ g_nShareListSize - 1);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgW("[WARNING] app_control_add_extra_data_array() [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+ }
+
+ nErr = app_control_send_launch_request(g_pServiceShare, NULL, NULL);
+ if (nErr != APP_CONTROL_ERROR_NONE) {
+ gl_dbgW
+ ("[WARNING] app_control_send_launch_request().. [0x%x]", nErr);
+ goto ERROR_EXCEPTION;
+ }
+
+ g_bSharePanelLaunched = TRUE;
+
+ elm_naviframe_item_pop(ad->maininfo.naviframe);
+
+ return;
+
+ERROR_EXCEPTION:
+ if (g_pServiceShare) {
+ app_control_destroy(g_pServiceShare);
+ g_pServiceShare = NULL;
+ }
+
+ if (g_pShareList) {
+ for (nCounter = 0; nCounter < g_nShareListSize; nCounter++) {
+ if (g_pShareList[nCounter]) {
+ free(g_pShareList[nCounter]);
+ g_pShareList[nCounter] = NULL;
+ }
+ }
+ free(g_pShareList);
+ g_pShareList = NULL;
+ }
+
+}
+
+void gl_launching_share_panel(void* data, int cnt)
+{
+ if(!data)
+ return;
+ gl_dbg("");
+ gl_appdata* ad = (gl_appdata*)data;
+ if(!ad->tlinfo)
+ {
+ gl_dbgE("ad->tlinfo not found");
+ return;
+ }
+ gl_timeline_s* timeline_d = ad->tlinfo;
+ if(!timeline_d->sel_d)
+ {
+ gl_dbgE("sel_d not found");
+ return;
+ }
+
+ int nCounter = 0;
+ int nTotalVideoItem = 0;
+ int nTotalAppendedItem = 0;
+ int nExtraDataSize = 0;
+
+ g_nShareListSize = 0;
+ char** szFileUrlArrayForServiceExtraData = NULL;
+
+ nTotalVideoItem =cnt;
+ gl_dbg("nTotalVideoItem= %d",nTotalVideoItem);
+
+ if (nTotalVideoItem == 0)
+ {
+ gl_dbg("Nothing to share");
+ return;
+ }
+ nExtraDataSize = nTotalVideoItem;
+ if (nExtraDataSize) {
+ szFileUrlArrayForServiceExtraData =
+ (char**)calloc(nExtraDataSize, sizeof(char*));
+
+ /** Store the list so the share panel can be updated later
+ * g_pShareList size needs to bigger than total video size
+ * because first url will be added twice, one for signal share and
+ * one for multiple share.
+ * so g_pShareList alloc size = nExtraDataSize + 1
+ */
+
+ g_pShareList = (char**)calloc((nExtraDataSize + 1), sizeof(char*));
+ }
+
+ Eina_List *l = NULL;
+ char *item = NULL;
+ gl_media_s * gitem=NULL;
+ int i;
+ for(i=0;i<cnt;i++)
+ {
+ item=eina_list_nth(timeline_d->sel_d->sel_list, i);
+ if(!item)
+ {
+ continue;
+ }
+ gl_dbg("list print %s",item);
+ EINA_LIST_FOREACH(timeline_d->data_list, l, gitem) {
+ if(!gitem){
+ continue;}
+ if(!strcmp(item,gitem->uuid))
+ {
+ gl_dbg("file url %s",gitem->file_url);
+ break;
+ }
+ }
+ }
+
+ /* Extract First URI. */
+ for (nCounter = 0; nCounter < nTotalVideoItem; nCounter++) {
+
+ char* szFileUrl = _gl_get_media_url(timeline_d->sel_d->sel_list,nCounter);
+
+ if (szFileUrl) {
+ nCounter++;
+ g_pShareList[0] = strdup(szFileUrl);
+ g_nShareListSize++;
+ break;
+ }
+ else {
+ gl_dbgE("szFileUrl is not existed.");
+ }
+ free(szFileUrl);
+ }
+
+ gl_dbg("nCounter = %d", nCounter);
+
+ /* Extract another URI if existing selected items more. */
+ if (nExtraDataSize > 0 && szFileUrlArrayForServiceExtraData) {
+ for (nCounter = 0; nCounter < nTotalVideoItem; nCounter++) {
+
+ char* szFileUrl = _gl_get_media_url(timeline_d->sel_d->sel_list, nCounter);
+
+ if (szFileUrl) {
+ if (nTotalAppendedItem < nExtraDataSize) {
+ szFileUrlArrayForServiceExtraData[nTotalAppendedItem] = szFileUrl;
+ gl_dbg("Appending share item : %s, Total Appended item : %d",
+ (const char**)szFileUrlArrayForServiceExtraData[nTotalAppendedItem],
+ nTotalAppendedItem);
+ nTotalAppendedItem++;
+
+ g_pShareList[g_nShareListSize++] = strdup(szFileUrl);
+ continue;
+ }
+ else {
+ gl_dbgW("[WARNING] OVERFLOW ALOOCATED MEMORY SIZE.");
+ free(szFileUrl);
+ }
+ }
+ else {
+ gl_dbgE("szFileUrl is not existed.");
+ }
+ }
+ }
+
+ gl_create_launch_share_panel(data);
+
+ gl_dbg("Launching share panel.");
+
+
+ if (szFileUrlArrayForServiceExtraData) {
+ for (nCounter = 0; nCounter < nExtraDataSize; nCounter++) {
+ if (szFileUrlArrayForServiceExtraData[nCounter]) {
+ free(szFileUrlArrayForServiceExtraData[nCounter]);
+ szFileUrlArrayForServiceExtraData[nCounter] = NULL;
+ }
+ }
+ free(szFileUrlArrayForServiceExtraData);
+ szFileUrlArrayForServiceExtraData = NULL;
+ }
+
+ return;
+}
+
/**
* Media delete CB
* @param data : App data
if (ad->tlinfo->view_m == GL_TL_VIEW_COPY) {
gl_dbg("copy operation from time view");
_gl_popup_create_copy_move(data, __gl_timeline_get_sel_cnt, data);
- } else {
+ }
+ else if(ad->tlinfo->view_m == GL_TL_VIEW_SHARE){
+ gl_dbg("share operation from time view");
+ gl_launching_share_panel(data, cnt);
+ }else {
_gl_db_update_lock_always(data, true);
_gl_set_file_op_cbs(data, __gl_timeline_del_op, NULL,
__gl_timeline_update_del_view, cnt);
GL_GFREEIF(ad->tlinfo->sel_d);
break;
case GL_TL_VIEW_EDIT:
+ case GL_TL_VIEW_SHARE:
case GL_TL_VIEW_COPY:
GL_GFREEIF(ad->tlinfo->sel_d);
ad->tlinfo->sel_d = g_new0(gl_sel_s, 1);
GL_CHECK_VAL(ad->tlinfo->sel_d, -1);
_gl_ui_change_navi_title(ad->tlinfo->nf_it, GL_STR_ID_SELECT_ITEM,
false);
- if (GL_TL_VIEW_EDIT == mode || GL_TL_VIEW_COPY == mode) {
+ if (GL_TL_VIEW_EDIT == mode || GL_TL_VIEW_COPY == mode || GL_TL_VIEW_SHARE == mode) {
__gl_timeline_edit_add_btns(data);
}
break;
"");
}
if (ad->tlinfo->view_m == GL_TL_VIEW_EDIT
- || ad->tlinfo->view_m == GL_TL_VIEW_COPY) {
+ || ad->tlinfo->view_m == GL_TL_VIEW_COPY
+ || ad->tlinfo->view_m == GL_TL_VIEW_SHARE) {
elm_object_signal_emit(ad->ctrlinfo.ctrlbar_view_ly,
"elm,selectall,state,visible,bg", "elm");
elm_object_signal_emit(ad->ctrlinfo.ctrlbar_view_ly,
}
return false;
}
+
+/**
+ * Gets if mode is time edit share mode
+ * @param data : App data
+ * @return
+ */
+bool _gl_is_timeline_edit_share_mode(void* data)
+{
+ GL_CHECK_FALSE(data);
+ gl_appdata* ad = (gl_appdata*)data;
+ GL_CHECK_FALSE(ad->tlinfo);
+ if (ad->tlinfo->view_m == GL_TL_VIEW_SHARE) {
+ return true;
+ }
+ return false;
+}