Integrated management files by CBHM
authorwoochanlee <wc0917.lee@samsung.com>
Mon, 2 Sep 2013 05:33:03 +0000 (14:33 +0900)
committerwoochanlee <wc0917.lee@samsung.com>
Mon, 2 Sep 2013 06:16:17 +0000 (15:16 +0900)
Change-Id: I535b346c7af68f4900f18c989214886cd6b2d300

src/cbhm.h
src/item_manager.c
src/main.c

index 016e239..56a3575 100644 (file)
@@ -47,6 +47,7 @@ typedef struct _StorageData StorageData;
 typedef char *(*text_converter_func)(AppData *ad, int type_index, const char *str);
 
 #define ITEM_CNT_MAX 20
+#define COPIED_DATA_STORAGE_DIR "/opt/var/.cbhm_files"
 
 #include "clipdrawer.h"
 #include "item_manager.h"
index cdccd3e..2839ada 100644 (file)
@@ -36,7 +36,12 @@ static void item_free(CNP_ITEM *item)
                        item->ad->storage_item_del(item->ad, item);
        }
        if (item->data)
+       {
+               if(item->type_index == ATOM_INDEX_IMAGE)
+                       ecore_file_remove(item->data);
+
                FREE(item->data);
+       }
 
        if (item->ad)
        {
@@ -77,6 +82,10 @@ CNP_ITEM *item_add_by_CNP_ITEM(AppData *ad, CNP_ITEM *item)
 
 CNP_ITEM *item_add_by_data(AppData *ad, Ecore_X_Atom type, void *data, int len)
 {
+       char *copied_path = NULL;
+       char *filename = NULL;
+       int size_path=0;
+
        if (!ad || !data)
        {
                DMSG("WRONG PARAMETER in %s\n", __func__);
@@ -87,6 +96,23 @@ CNP_ITEM *item_add_by_data(AppData *ad, Ecore_X_Atom type, void *data, int len)
        if (!item)
                return NULL;
        item->type_index = atom_type_index_get(ad, type);
+
+       if(item->type_index == ATOM_INDEX_IMAGE)
+       {
+               filename = ecore_file_file_get(data);
+               size_path = snprintf(NULL, 0, COPIED_DATA_STORAGE_DIR"/%s", filename) + 1;
+               copied_path = MALLOC(sizeof(char) * size_path);
+
+               if(copied_path)
+                       snprintf(copied_path, size_path, COPIED_DATA_STORAGE_DIR"/%s", filename);
+
+               if(!ecore_file_cp(data, copied_path))
+                       DMSG("ecore_file_cp fail!");
+
+               data = copied_path;
+               len = strlen(copied_path) + 1;
+       }
+
        item->data = data;
        item->len = len;
 
index bc915b3..27c53d9 100644 (file)
@@ -55,6 +55,10 @@ static Eina_Bool setClipboardManager(AppData *ad)
 {
        ad->x_disp = ecore_x_display_get();
        DMSG("x_disp: 0x%x\n", ad->x_disp);
+
+        if(!ecore_file_mkpath(COPIED_DATA_STORAGE_DIR))
+                DMSG("ecore_file_mkpath fail");
+
        if (ad->x_disp)
        {
                Ecore_X_Atom clipboard_manager_atom = XInternAtom(ad->x_disp, ATOM_CLIPBOARD_MANAGER_NAME, False);