[ROLLBACK] Rollback to Jan. 27.
authorDaniel Juyung Seo <juyung.seo@samsung.com>
Wed, 2 Feb 2011 05:32:42 +0000 (14:32 +0900)
committerDaniel Juyung Seo <juyung.seo@samsung.com>
Wed, 2 Feb 2011 05:32:42 +0000 (14:32 +0900)
data/themes/cbhmdrawer.edc
data/themes/extstyles.edc
src/clipdrawer.c
src/clipdrawer.h
src/storage.c
src/storage.h
src/xcnphandler.c

index ead6d88..86227a7 100644 (file)
@@ -65,8 +65,8 @@ collections
                                description
                                {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.005 0.033; to: "background"; }
-                                       rel2 { relative: 0.995 0.954; to: "background"; }
+                                       rel1 { relative: 0.005 0.035; to: "background"; }
+                                       rel2 { relative: 0.995 0.88; to: "background"; }
                                }
                        }
 
@@ -80,8 +80,8 @@ collections
                                description 
                                {
                                        state: "default" 0.0;
-                                       rel1 { relative: 0.0 0.92; to: "background";}
-                                       rel2 { relative: 1.0 1.00; to: "background";}
+                                       rel1 { relative: 0.0 0.89; to: "background";}
+                                       rel2 { relative: 1.0 0.99; to: "background";}
                                        color: 0 0 0 0;
                                }
                        }
@@ -97,7 +97,7 @@ collections
                                        state: "default" 0.0;
                                        rel1 { relative: 0.0 0.0; to: "background/close";}
                                        rel2 { relative: 1.0 1.0; to: "background/close";}
-                                       align: 0.5 0.4;
+                                       align: 0.5 0.5;
                                        min: 18 12;
                                        max: 18 12;
                                        image
index 0e899c7..1ba56e7 100644 (file)
@@ -299,7 +299,7 @@ group
                                state: "default" 0.0;
                                rel1.to: "elm.swallow.icon";
                                rel2.to: "elm.swallow.icon";
-                               align: 1.0 0.0;
+                               align: 0.95 0.01;
                                min: 46 40;
                                max: 46 40;
                                color:  0 0 0 0;
index 0c63154..b6be718 100644 (file)
@@ -12,8 +12,8 @@ static const char *g_images_path[] = {
 #define N_IMAGES (1)
 
 #define GRID_ITEM_SPACE_W 6
-#define GRID_ITEM_SINGLE_W 185
-#define GRID_ITEM_SINGLE_H 161
+#define GRID_ITEM_SINGLE_W 187
+#define GRID_ITEM_SINGLE_H 151
 #define GRID_ITEM_W (GRID_ITEM_SINGLE_W+(GRID_ITEM_SPACE_W*2))
 #define GRID_ITEM_H (GRID_ITEM_SINGLE_H)
 #define GRID_IMAGE_LIMIT_W 91
@@ -48,9 +48,9 @@ int clipdrawer_update_contents(void *data)
                if (pos < 0)
                        pos = pos+HISTORY_QUEUE_MAX_ITEMS;
 
-               if (clipdrawer_get_item_data(ad, pos) != NULL && strlen(clipdrawer_get_item_data(ad, pos)) > 0)
+               if (get_item_contents_by_pos(pos) != NULL && strlen(get_item_contents_by_pos(pos)) > 0)
                {
-                       unesc = clipdrawer_get_plain_string_from_escaped(clipdrawer_get_item_data(ad, pos));
+                       unesc = clipdrawer_get_plain_string_from_escaped(get_item_contents_by_pos(pos));
                        unesc = unesc ? unesc : "";
                        elm_list_item_append(ad->txtlist, unesc, NULL, NULL, NULL, ad);
                        free(unesc);
@@ -203,7 +203,6 @@ Evas_Object* _grid_icon_get(const void *data, Evas_Object *obj, const char *part
                        eina_strbuf_replace_all(strent, " absize=240x180 ", " absize=52x39 ");
                        if (strcnt > 100)
                                eina_strbuf_append(strent, "...");
-                       eina_strbuf_prepend(strent, "<font_size=18>");
 
                        elm_scrolled_entry_entry_set(ientry, eina_strbuf_string_get(strent));
                        elm_scrolled_entry_editable_set(ientry, EINA_FALSE);
@@ -331,6 +330,8 @@ static void _grid_click_paste(void *data, Evas_Object *obj, void *event_info)
        sgobj = elm_gengrid_selected_item_get(ad->hig);
        griditem_t *ti = NULL;
        ti = elm_gengrid_item_data_get(sgobj);
+
+       fprintf(stderr, "## grid_click_paste = 0x%x\n", event_info);
 }
 
 void _grid_del(const void *data, Evas_Object *obj)
@@ -343,36 +344,6 @@ void _grid_del(const void *data, Evas_Object *obj)
        free(ti);
 }
 
-char* clipdrawer_get_item_data(void *data, int pos)
-{
-       struct appdata *ad = data;
-       griditem_t *ti = NULL;
-       griditem_t *newgi = NULL;
-       int count = 0;
-
-       if (pos < 0 || pos > ad->hicount)
-               return NULL;
-
-       Elm_Gengrid_Item *item = elm_gengrid_first_item_get(ad->hig);
-       while (item)    
-       {
-               ti = elm_gengrid_item_data_get(item);
-               if (count == pos)
-               {
-                       if (!ti)
-                               break;
-                       if (ti->itype == GI_TEXT)
-                               return (char*)eina_strbuf_string_get(ti->istrdata);
-                       else
-                               return ti->ipathdata;
-               }
-               count++;
-               item = elm_gengrid_item_next_get(item);      
-       }
-
-       return NULL;
-}
-
 // FIXME: how to remove calling g_get_main_appdata()? 
 //        it's mainly used at 'clipdrawer_image_item'
 int clipdrawer_add_item(char *idata, int type)
@@ -410,6 +381,7 @@ int clipdrawer_add_item(char *idata, int type)
                        }
                        item = elm_gengrid_item_next_get(item);      
                }
+
                newgi->ipathdata = eina_stringshare_add(idata);
        }
 
@@ -522,7 +494,7 @@ int clipdrawer_create_view(void *data)
 
        // for debug
        // at starting, showing app view
-       clipdrawer_activate_view(ad);
+//     clipdrawer_activate_view(ad);
 
 //     clipdrawer_anim_show_effect(ad);
 
@@ -574,10 +546,12 @@ Eina_Bool anim_pos_calc_cb(void *data)
                case HIDE_ANIM:
                        deltay = (int)((anim_endy-anim_starty)*posprop);
                        evas_object_move(ad->win_main, 0, anim_starty+deltay);
+                       //fprintf(stderr, "## cur pos y = %d\n", anim_starty+deltay);
                        break;
                case SHOW_ANIM:
                        deltay = (int)((anim_starty-anim_endy)*posprop);
                        evas_object_move(ad->win_main, 0, anim_starty-deltay);
+                       //fprintf(stderr, "## cur pos y = %d\n", anim_starty-deltay);
                        break;
                default:
                        return EINA_FALSE;
@@ -630,6 +604,8 @@ void _change_gengrid_paste_textonly_mode(void *data)
 {
        struct appdata *ad = data;
 
+       fprintf(stderr, "## _change_gengrid_paste_textonly_mode = %d\n", clipdrawer_paste_textonly_get(ad));
+
        Elm_Gengrid_Item *item;
        griditem_t *ti = NULL;
 
@@ -642,6 +618,8 @@ void _change_gengrid_paste_textonly_mode(void *data)
                        ti = elm_gengrid_item_data_get(item);
                        if ((ti->itype == GI_IMAGE) && (ti->ilayout))
                        {
+                               fprintf(stderr, "## sig to hide delbtn\n");
+
                                edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,hide,delbtn", "elm");
                                Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(ad->hig));
                                evas_object_color_set(rect, 0, 0, 0, 200);
@@ -658,8 +636,12 @@ void _change_gengrid_paste_textonly_mode(void *data)
                while (item)    
                {
                        ti = elm_gengrid_item_data_get(item);
+                       fprintf(stderr, "## itype = %d\n", ti->itype);
+                       fprintf(stderr, "## ilayout = 0x%x\n", ti->ilayout);
                        if ((ti->itype == GI_IMAGE) && (ti->ilayout))
                        {
+                               fprintf(stderr, "## sig to show delbtn\n");
+
                                edje_object_signal_emit(elm_layout_edje_get(ti->ilayout), "elm,state,show,delbtn", "elm");
                                Evas_Object *rect = elm_layout_content_unset(ti->ilayout, "elm.swallow.cover");
                                evas_object_hide(rect);
index 3a5399e..7f8ce7d 100644 (file)
@@ -24,7 +24,6 @@ void clipdrawer_lower_view(void *data);
 
 const char* clipdrawer_get_plain_string_from_escaped(char *escstr);
 
-char *clipdrawer_get_item_data(void *data, int pos);
 int clipdrawer_add_item(char *idata, int type);
 
 void clipdrawer_paste_textonly_set(void *data, Eina_Bool textonly);
index e654522..1d15d90 100644 (file)
@@ -1,5 +1,4 @@
 #include "common.h"
-#include "cbhm_main.h"
 #include "storage.h"
 
 /*
 #define STORAGE_BODY_SIZE (STORAGE_MAX_ITEMS * BODY_ITEM_SIZE) 
 #define TOTAL_STORAGE_SIZE (STORAGE_HEADER_SIZE+STORAGE_BODY_SIZE)
 
-#define GET_HEADER_ADDR_BY_POSITION(pos) (STORAGE_HEADER_SIZE+pos*(HEADER_ITEM_SIZE+BODY_ITEM_SIZE))
-#define GET_BODY_ADDR_BY_POSITION(pos) (GET_HEADER_ADDR_BY_POSITION(pos)+HEADER_ITEM_SIZE)
+#define GET_ITEM_ADDR_BY_POSITION(map, pos) (map+STORAGE_HEADER_SIZE+pos*BODY_ITEM_SIZE)
 
-static FILE *g_storage_file = NULL;
+static int g_storage_fd = 0;
 static unsigned int g_storage_serial_number = 0;
+static char *g_map = NULL;
 
-int init_storage(void *data)
+int init_storage()
 {
-       struct appdata *ad = data;
-
        int i;
        int result = 0;
 
-       if (g_storage_file)
+       if (g_storage_fd != 0)
                return 1;
 
-       g_storage_file = fopen(STORAGE_FILEPATH, "r+");
-       if (!g_storage_file)
-       {  // making data savefile
-               g_storage_file = fopen(STORAGE_FILEPATH, "w+");
-
-               if (!g_storage_file)
-               {
-                       close_storage(ad);
-                       DTRACE("Error : failed openning file for writing\n");
-                       return -1;
-               }
-
-               result = fseek(g_storage_file, TOTAL_STORAGE_SIZE-1, SEEK_SET);
-               if (!result) 
-               {
-                       close_storage(ad);
-                       DTRACE("Error : failed moving file position to file's end\n");
-                       return -1;
-               }
-
-               result = fputc(0, g_storage_file);
-               if (result == EOF)
-               {
+       g_storage_fd = open(STORAGE_FILEPATH, O_RDWR | O_CREAT, (mode_t)0600);
+       if (g_storage_fd == -1)
+       {
+               g_storage_fd = 0;
+               close_storage();
+               DTRACE("Error : failed openning file for writing\n");
+               return -1;
+       }
+
+    result = lseek(g_storage_fd, TOTAL_STORAGE_SIZE-1, SEEK_SET);
+    if (result == -1) 
+       {
+               close_storage();
+               DTRACE("Error : failed moving file position to file's end\n");
+               return -1;
+    }
+    
+    result = write(g_storage_fd, "", 1);
+    if (result != 1) 
+       {
+               close_storage();
                DTRACE("Error : failed writing to file's end\n");
                return -1;
-               }
+    }
+
+       g_map = mmap(0, TOTAL_STORAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, g_storage_fd, 0);
+       if (g_map == MAP_FAILED)
+       {
+               close_storage();
+               DTRACE("Error : failed mmapping the file\n");
+               return -1;
        }
 
+       // FIXME : do not unconditionaly initialize, maybe old data can be
+       // at here
+       int *header = g_map;
+       for (i = 0; i < STORAGE_MAX_ITEMS; i++)
+       {
+               char d = 0;
+               header[i] = 0;
+               memcpy(GET_ITEM_ADDR_BY_POSITION(g_map, i), &d, 1);
+       }
        DTRACE("Success : storage init is done\n");
 
        g_storage_serial_number = 0;
@@ -70,61 +81,82 @@ int init_storage(void *data)
        return 0;
 }
 
-int sync_storage(void *data)
+int sync_storage()
 {
-//     struct appdata *ad = data;
-
-       if (!g_storage_file)
+       if (g_map == NULL)
        {
-               DTRACE("g_storage_file is null\n");
+               DTRACE("g_map is null\n");
                return -1;
        }
-       fsync(g_storage_file);
+       msync(g_map, TOTAL_STORAGE_SIZE, MS_ASYNC);
 
        return 0;
 }
 
-unsigned int get_storage_serial_code(void *data)
+int get_total_storage_size()
 {
-//     struct appdata *ad = data;
+       return TOTAL_STORAGE_SIZE;
+}
 
+unsigned int get_storage_serial_code()
+{
        return g_storage_serial_number;
 }
 
-int adding_item_to_storage(void *data, int pos, char *idata)
+int adding_item_to_storage(int pos, char *data)
 {
-//     struct appdata *ad = data;
+       int *header = get_storage_start_addr();
 
-       if (!g_storage_file)
+       if (g_map == NULL)
        {
-               DTRACE("g_storage_file is null\n");
+               DTRACE("g_map is null");
                return -1;
        }
-
-       int result;
-       result = fseek(g_storage_file, GET_HEADER_ADDR_BY_POSITION(pos), SEEK_SET);
-       // FIXME : replace from fprintf to fwrite
-       fprintf(g_storage_file, "%d", strlen(idata));
-       fprintf(g_storage_file, "%s", idata);
-       
+       // saving relative addr at header
+       header[pos] = STORAGE_HEADER_SIZE+pos*BODY_ITEM_SIZE; 
+       memcpy(GET_ITEM_ADDR_BY_POSITION(g_map, pos), data, BODY_ITEM_SIZE);
        g_storage_serial_number++;
        return 0;
 }
 
-int get_item_counts(void *data)
+char *get_storage_start_addr()
+{
+       return g_map;
+}
+
+int get_item_counts()
 {
-       struct appdata *ad = data;
+       int i, count;
+       int *header = get_storage_start_addr();
 
-       return ad->hicount;
+       count = 0;
+       for (i = 0; i < STORAGE_MAX_ITEMS; i++)
+       {
+               if (header[i] != 0)
+                       count++;
+       }
+       return count;
+}
+
+char *get_item_contents_by_pos(int pos)
+{
+       if (g_map == NULL)
+       {
+               DTRACE("g_map is null");
+               return NULL;
+       }
+       return GET_ITEM_ADDR_BY_POSITION(g_map, pos);
 }
 
-int close_storage(void *data)
+int close_storage()
 {
-       struct appdata *ad = data;
+       if (g_map)
+               munmap(g_map, TOTAL_STORAGE_SIZE);
+       g_map = NULL;
 
-       if (g_storage_file)
-               fclose(g_storage_file);
-       g_storage_file = NULL;
+       if (g_storage_fd)
+               close(g_storage_fd);
+       g_storage_fd = 0;
        g_storage_serial_number = 0;
 
        return 0;
index 26bf145..2b25985 100644 (file)
@@ -6,12 +6,14 @@
 #include <fcntl.h>
 #include <sys/mman.h>
 
-int init_storage(void *data);
-int sync_storage(void *data);
-unsigned int get_storage_serial_code(void *data);
-int adding_item_to_storage(void *data, int pos, char *idata);
-int get_item_counts(void *data);
-int close_storage(void *data);
+int init_storage();
+int sync_storage();
+unsigned int get_storage_serial_code();
+int adding_item_to_storage(int pos, char *data);
+char *get_storage_start_addr();
+int get_item_counts();
+char *get_item_contents_by_pos(int pos);
+int close_storage();
 
 int check_regular_file(char *path);
 
index a43bec2..c80a3dc 100755 (executable)
@@ -3,7 +3,6 @@
 #include "xcnphandler.h"
 #include "storage.h"
 #include "clipdrawer.h"
-#include "scrcapture.h"
 
 static Ecore_Event_Handler *xsel_clear_handler = NULL;
 static Ecore_Event_Handler *xsel_request_handler = NULL;
@@ -116,21 +115,20 @@ int add_to_storage_buffer(void *data, char *src, int len)
        if (len <= 0)
                return -1;
 
-//     if (g_lastest_content == NULL)
-//             g_lastest_content = malloc(sizeof(char)*(HISTORY_QUEUE_ITEM_SIZE));
+       if (g_lastest_content == NULL)
+               g_lastest_content = malloc(sizeof(char)*(HISTORY_QUEUE_ITEM_SIZE));
        if (g_history_pos >= HISTORY_QUEUE_MAX_ITEMS)
                g_history_pos = 0;
 
        // FIXME: remove g_lasteset_content
        //strcpy(g_lastest_content, src);
-//     memcpy(g_lastest_content, src, len);
-//     g_lastest_content[len] = '\0';
-       g_lastest_content = src;
-       adding_item_to_storage(ad, g_history_pos, g_lastest_content);
+       memcpy(g_lastest_content, src, len);
+       g_lastest_content[len] = '\0';
+       adding_item_to_storage(g_history_pos, g_lastest_content);
        increment_current_history_position();
 
        int nserial = 0;
-       nserial = get_storage_serial_code(ad);
+       nserial = get_storage_serial_code();
        Atom atomCbhmSerial = XInternAtom(g_disp, "CBHM_SERIAL_NUMBER", False);
        XChangeProperty(g_disp, g_evtwin, atomCbhmSerial, XA_INTEGER,
                                        32, PropModeReplace,
@@ -140,10 +138,8 @@ int add_to_storage_buffer(void *data, char *src, int len)
        return 0;
 }
 
-int print_storage_buffer(void *data)
+int print_storage_buffer()
 {
-       struct appdata *ad = data;
-
        int pos;
        int i = 0;
        for (i = 0; i < HISTORY_QUEUE_MAX_ITEMS; i++)
@@ -151,8 +147,7 @@ int print_storage_buffer(void *data)
                pos = get_current_history_position()+i;
                if (pos > HISTORY_QUEUE_MAX_ITEMS-1)
                        pos = pos-HISTORY_QUEUE_MAX_ITEMS;
-               DTRACE("%d: %s\n", i, 
-                          clipdrawer_get_item_data(ad, pos) != NULL ? clipdrawer_get_item_data(ad, pos) : "NULL");
+               DTRACE("%d: %s\n", i, get_item_contents_by_pos(pos) != NULL ? get_item_contents_by_pos(pos) : "NULL");
        }
 }
 
@@ -269,12 +264,12 @@ int get_selection_content(void *data)
                check_regular_file(cbbuf+7))
        {
                DTRACE("clipdrawer add path = %s\n", cbbuf+7);
-               clipdrawer_add_item(ad, cbbuf+7, GI_IMAGE);
+               clipdrawer_add_item(cbbuf+7, GI_IMAGE);
        }
        else
        {
                add_to_storage_buffer(ad, cbbuf, unesc_len);
-               clipdrawer_add_item(ad, cbbuf, GI_TEXT);
+               clipdrawer_add_item(cbbuf, GI_TEXT);
        }
        DTRACE("len = %ld, data = %s\n", unesc_len, cbbuf);
 #endif
@@ -300,7 +295,7 @@ int get_selection_content(void *data)
 #endif
 
        DTRACE("\n");
-       print_storage_buffer(ad);
+       print_storage_buffer();
        DTRACE("\n");
 
        XFree(cbbuf);
@@ -420,7 +415,7 @@ static int _cbhm_init(void *data)
 
        _set_cbhmwin_prop();
     _init_atoms();
-       init_storage(ad);
+       init_storage();
 
        DTRACE("_cbhm_init ok\n");
 
@@ -433,9 +428,7 @@ static int _cbhm_init(void *data)
 
 static void _cbhm_fini()
 {
-       struct appdata *ad = g_get_main_appdata();
-
-       close_storage(ad);
+       close_storage();
 
        return;
 }
@@ -530,7 +523,7 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
 
        if (strcmp("get count", ev->data.b) == 0)
        {
-               int icount = get_item_counts(ad);
+               int icount = get_item_counts();
                char countbuf[10];
                DTRACE("## cbhm count : %d\n", icount);
                sprintf(countbuf, "%d", icount);
@@ -557,12 +550,12 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
                        // FIXME : handle with correct atom
                        sprintf(atomname, "CBHM_c%d", num);
                        cbhm_atoms[0] = XInternAtom(g_disp, atomname, False);
-                       if (clipdrawer_get_item_data(ad, num) != NULL)
+                       if (get_item_contents_by_pos(num) != NULL)
                        {
                                XChangeProperty(g_disp, reqwin, cbhm_atoms[0], atomUTF8String, 
                                                                8, PropModeReplace, 
-                                                               (unsigned char *) clipdrawer_get_item_data(ad, num), 
-                                                               (int) strlen(clipdrawer_get_item_data(ad, num)));
+                                                               (unsigned char *) get_item_contents_by_pos(num), 
+                                                               (int) strlen(get_item_contents_by_pos(num)));
                        }
                }
        }
@@ -575,12 +568,12 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
                        DTRACE("## %d -> %d\n", i, pos);
                        sprintf(atomname, "CBHM_c%d", i);
                        cbhm_atoms[i] = XInternAtom(g_disp, atomname, False);
-                       if (clipdrawer_get_item_data(ad, pos) != NULL)
+                       if (get_item_contents_by_pos(pos) != NULL)
                        {
                                XChangeProperty(g_disp, reqwin, cbhm_atoms[i], atomUTF8String, 
                                                                8, PropModeReplace, 
-                                                               (unsigned char *) clipdrawer_get_item_data(ad, pos),
-                                                               (int) strlen(clipdrawer_get_item_data(ad, pos)));
+                                                               (unsigned char *) get_item_contents_by_pos(pos) , 
+                                                               (int) strlen(get_item_contents_by_pos(pos)));
                        }
                        pos--;
                        if (pos < 0)
@@ -589,7 +582,6 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
        }
        else if (strcmp("get raw", ev->data.b) == 0)
        {
-/*
                if (get_storage_start_addr != NULL)
                {
                        XChangeProperty(g_disp, reqwin, atomCBHM_cRAW, atomUTF8String, 
@@ -597,7 +589,6 @@ static int _xclient_msg_cb(void *data, int ev_type, void *event)
                                                        (unsigned char *) get_storage_start_addr(),
                                                        (int) get_total_storage_size());
                }
-*/
        }
        else if (strncmp("show", ev->data.b, 4) == 0)
        {