right trim txt item string
authorHyoyoung Chang <hyoyoung.chang@samsung.com>
Sat, 23 Oct 2010 06:51:38 +0000 (15:51 +0900)
committerHyoyoung Chang <hyoyoung.chang@samsung.com>
Sat, 23 Oct 2010 06:51:38 +0000 (15:51 +0900)
CMakeLists.txt
debian/control
src/common.h
src/storage.c
src/xcnphandler.c

index 5cdec93..90aabde 100755 (executable)
@@ -11,7 +11,7 @@ SET(SRCS src/cbhm_main.c
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED eina elementary appcore-efl appcore-common x11 ecore-x utilX)
+pkg_check_modules(pkgs REQUIRED elementary appcore-efl appcore-common x11 ecore-x utilX)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index bc89196..84b0a92 100755 (executable)
@@ -2,7 +2,7 @@ Source: cbhm
 Section: devel
 Priority: extra
 Maintainer: Hyoyoung Chang <hyoyoung.chang@samsung.com>
-Build-Depends: debhelper (>= 5), libeina-dev, libelm-dev, libappcore-efl-dev, libappcore-common-dev, libx11-dev, libecore-dev, libslp-utilx-dev, x11-xserver-utils-ex
+Build-Depends: debhelper (>= 5), libelm-dev, libappcore-efl-dev, libappcore-common-dev, libx11-dev, libecore-dev, libslp-utilx-dev, x11-xserver-utils-ex
 Standards-Version: 0.1.1
 
 Package: cbhm
index 719a674..8359299 100644 (file)
@@ -32,6 +32,7 @@
 struct appdata;
 
 #define HISTORY_QUEUE_MAX_TXT_ITEMS 5
+#define HISTORY_QUEUE_TXT_ITEM_SIZE (4 * 1024) // 4Kilo 
 #define HISTORY_QUEUE_MAX_IMG_ITEMS 10
 
 #endif // _common_h_
index 55de30d..11c32dc 100644 (file)
@@ -4,7 +4,7 @@
 #define STORAGE_FILEPATH "/opt/var/.savecbh"
 #define STORAGE_MAX_ITEMS HISTORY_QUEUE_MAX_TXT_ITEMS
 #define HEADER_ITEM_SIZE (sizeof(int)) 
-#define BODY_ITEM_SIZE (4 * 1024) // 4Kilo 
+#define BODY_ITEM_SIZE HISTORY_QUEUE_TXT_ITEM_SIZE
 #define STORAGE_HEADER_SIZE (STORAGE_MAX_ITEMS * HEADER_ITEM_SIZE)
 #define STORAGE_BODY_SIZE (STORAGE_MAX_ITEMS * BODY_ITEM_SIZE) 
 #define TOTAL_STORAGE_SIZE (STORAGE_HEADER_SIZE+STORAGE_BODY_SIZE)
index b85e0c9..3da17dd 100755 (executable)
@@ -115,13 +115,16 @@ int add_to_storage_buffer(void *data, char *src, int len)
        if (len <= 0)
                return -1;
 
+       // FIXME: replace magic number to a define
        if (g_lastest_content == NULL)
-               g_lastest_content = malloc(sizeof(char)*(4*1024));
+               g_lastest_content = malloc(sizeof(char)*(HISTORY_QUEUE_TXT_ITEM_SIZE));
        if (g_history_pos >= HISTORY_QUEUE_MAX_TXT_ITEMS)
                g_history_pos = 0;
 
        // FIXME: remove g_lasteset_content
-       strcpy(g_lastest_content, src);
+       //strcpy(g_lastest_content, src);
+       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();
 
@@ -182,6 +185,8 @@ int get_selection_content(void *data)
        unsigned char *cbbuf;
        struct appdata *ad = data;
        const char *unesc;
+       size_t unesc_len = 0;
+       int i;
 
        XGetWindowProperty(g_disp, g_evtwin, atomCBOut, 0, 0, False,
                                           AnyPropertyType, &cbtype, &cbformat, &cbitems, &cbsize, &cbbuf);
@@ -208,6 +213,28 @@ int get_selection_content(void *data)
        XDeleteProperty(g_disp, g_evtwin, atomCBOut);
 
        unesc = clipdrawer_get_plain_string_from_escaped(cbbuf);
+       if (unesc != NULL)
+               unesc_len = strlen(unesc);
+       else
+               unesc_len = 0;
+
+       fprintf(stderr, "## unesc len = %d\n", unesc_len);
+
+       // FIXME: invent more clever way to right trim the string
+       for (i = unesc_len-1; i > 0; i--)
+       {
+               fprintf(stderr, "## unesc[%d] = 0x%x\n", i, unesc[i]);
+               if (unesc[i] >= 0x01 && unesc[i] <= 0x1F)
+                       continue;
+               else
+               {
+                       unesc_len = i+1;
+                       break;
+               }
+       }
+       
+       fprintf(stderr, "## unesc len = %d\n", unesc_len);
+
 //     add_to_storage_buffer(ad, cbbuf, cbitems);
 //     DTRACE("len = %ld, data = %s\n", cbitems, cbbuf);
 
@@ -221,8 +248,8 @@ int get_selection_content(void *data)
                clipdrawer_add_image_item(unesc);
        }
        else
-               add_to_storage_buffer(ad, unesc, strlen(unesc));
-       DTRACE("len = %ld, data = %s\n", strlen(unesc), unesc);
+               add_to_storage_buffer(ad, unesc, unesc_len);
+       DTRACE("len = %ld, data = %s\n", unesc_len, unesc);
        free(unesc);
 
        DTRACE("\n");