Initialize Tizen 2.3
[framework/uifw/elementary.git] / src / modules / ctxpopup_copypasteUI / cbhm_helper.c
1 #include "cbhm_helper.h"
2
3 #ifdef HAVE_ELEMENTARY_X
4 #include <X11/Xlib.h>
5 #include <X11/Xatom.h>
6 #define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
7 #define ATOM_CBHM_MSG "CBHM_MSG"
8 #define ATOM_CBHM_COUNT_GET "CBHM_cCOUNT"
9 #define ATOM_CBHM_TEXT_COUNT_GET "CBHM_TEXT_cCOUNT"
10 #define ATOM_CBHM_IMAGE_COUNT_GET "CBHM_IMAGE_cCOUNT"
11 #define ATOM_CBHM_SERIAL_NUMBER "CBHM_SERIAL_NUMBER"
12 #define MSG_CBHM_COUNT_GET "get count"
13 #define ATOM_CBHM_ERROR "CBHM_ERROR"
14 #define ATOM_CBHM_ITEM "CBHM_ITEM"
15 #endif
16
17 #ifdef HAVE_ELEMENTARY_X
18 Ecore_X_Window
19 _cbhm_window_get()
20 {
21    Ecore_X_Atom x_atom_cbhm = ecore_x_atom_get(ATOM_CBHM_WINDOW_NAME);
22    Ecore_X_Window x_cbhm_win = 0;
23    unsigned char *buf = NULL;
24    int num = 0;
25    int ret = ecore_x_window_prop_property_get(0, x_atom_cbhm, XA_WINDOW, 0, &buf, &num);
26    DMSG("ret: %d, num: %d\n", ret, num);
27    if (ret && num)
28      memcpy(&x_cbhm_win, buf, sizeof(Ecore_X_Window));
29    if (buf)
30      free(buf);
31    return x_cbhm_win;
32 }
33 #endif
34
35 Eina_Bool
36 _cbhm_msg_send(Evas_Object *obj, char *msg)
37 {
38 #ifdef HAVE_ELEMENTARY_X
39    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
40    Ecore_X_Atom x_atom_cbhm_msg = ecore_x_atom_get(ATOM_CBHM_MSG);
41    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
42    Ecore_X_Window xwin = ecore_evas_software_x11_window_get(ee);
43    if (!xwin)
44      {
45         xwin = ecore_evas_gl_x11_window_get(ee);
46         if (!xwin)
47           {
48              DMSG("ERROR: can't get x window\n");
49              return EINA_FALSE;
50           }
51      }
52
53    DMSG("x_cbhm: 0x%x\n", x_cbhm_win);
54    if (!x_cbhm_win || !x_atom_cbhm_msg)
55      return EINA_FALSE;
56
57    XClientMessageEvent m;
58    memset(&m, 0, sizeof(m));
59    m.type = ClientMessage;
60    m.display = ecore_x_display_get();
61    m.window = xwin;
62    m.message_type = x_atom_cbhm_msg;
63    m.format = 8;
64    snprintf(m.data.b, 20, "%s", msg);
65
66    XSendEvent(ecore_x_display_get(), x_cbhm_win, False, NoEventMask, (XEvent*)&m);
67
68    ecore_x_sync();
69    return EINA_TRUE;
70 #else
71    return EINA_FALSE;
72 #endif
73 }
74
75 #ifdef HAVE_ELEMENTARY_X
76 void *
77 _cbhm_reply_get(Ecore_X_Window xwin, Ecore_X_Atom property, Ecore_X_Atom *x_data_type, int *num)
78 {
79    unsigned char *data = NULL;
80    if (x_data_type)
81      *x_data_type = 0;
82    if (!property)
83       return NULL;
84    ecore_x_sync();
85    if (num)
86      *num = 0;
87
88    long unsigned int num_ret = 0, bytes = 0;
89    int ret = 0, size_ret;
90    unsigned int i;
91    unsigned char *prop_ret;
92    Ecore_X_Atom type_ret;
93    ret = XGetWindowProperty(ecore_x_display_get(), xwin, property, 0, LONG_MAX,
94                             False, ecore_x_window_prop_any_type(), (Atom *)&type_ret, &size_ret,
95                             &num_ret, &bytes, &prop_ret);
96    if (ret != Success)
97      return NULL;
98    if (!num_ret)
99      {
100         XFree(prop_ret);
101         return NULL;
102      }
103
104    if (!(data = malloc(num_ret * size_ret / 8)))
105      {
106         XFree(prop_ret);
107         return NULL;
108      }
109
110    switch (size_ret) {
111       case 8:
112         for (i = 0; i < num_ret; i++)
113           (data)[i] = prop_ret[i];
114         break;
115
116       case 16:
117         for (i = 0; i < num_ret; i++)
118           ((unsigned short *)data)[i] = ((unsigned short *)prop_ret)[i];
119         break;
120
121       case 32:
122         for (i = 0; i < num_ret; i++)
123           ((unsigned int *)data)[i] = ((unsigned long *)prop_ret)[i];
124         break;
125      }
126
127    XFree(prop_ret);
128
129    if (num)
130      *num = num_ret;
131    if (x_data_type)
132      *x_data_type = type_ret;
133
134    return data;
135 }
136 #endif
137
138 int
139 _cbhm_item_count_get(Evas_Object *obj __UNUSED__, int atom_index)
140 {
141 #ifdef HAVE_ELEMENTARY_X
142    char *ret, count;
143    Ecore_X_Atom x_atom_cbhm_count_get = 0;
144
145    if (atom_index == ATOM_INDEX_CBHM_COUNT_ALL)
146      x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
147    else if (atom_index == ATOM_INDEX_CBHM_COUNT_TEXT)
148      x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_TEXT_COUNT_GET);
149    else if (atom_index == ATOM_INDEX_CBHM_COUNT_IMAGE)
150      x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_IMAGE_COUNT_GET);
151
152    Ecore_X_Window cbhm_xwin = _cbhm_window_get();
153    DMSG("x_win: 0x%x, x_atom: %d\n", cbhm_xwin, x_atom_cbhm_count_get);
154    ret = _cbhm_reply_get(cbhm_xwin, x_atom_cbhm_count_get, NULL, NULL);
155    if (ret)
156      {
157         count = atoi(ret);
158         DMSG("count: %d\n", count);
159         free(ret);
160         return count;
161      }
162    DMSG("ret: 0x%x\n", ret);
163 #endif
164    return -1;
165 }
166 /*
167 int
168 _cbhm_item_count_get(Evas_Object *obj)
169 {
170 #ifdef HAVE_ELEMENTARY_X
171    char *ret, count;
172    if(_cbhm_msg_send(obj, MSG_CBHM_COUNT_GET))
173      {
174         DMSG("message send success\n");
175         Ecore_X_Atom x_atom_cbhm_count_get = ecore_x_atom_get(ATOM_CBHM_COUNT_GET);
176         Ecore_X_Window xwin = ecore_evas_software_x11_window_get(
177            ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
178         DMSG("x_win: 0x%x, x_atom: %d\n", xwin, x_atom_cbhm_count_get);
179         ret = _cbhm_reply_get(xwin, x_atom_cbhm_count_get, NULL, NULL);
180         if (ret)
181           {
182              count = atoi(ret);
183              DMSG("count: %d\n", count);
184              free(ret);
185              return count;
186           }
187         DMSG("ret: 0x%x\n", ret);
188      }
189 #endif
190    return -1;
191 }
192 */
193
194 #ifdef HAVE_ELEMENTARY_X
195 Eina_Bool
196 _cbhm_item_get(Evas_Object *obj __UNUSED__, int idx, Ecore_X_Atom *data_type, char **buf)
197 #else
198 Eina_Bool
199 _cbhm_item_get(Evas_Object *obj, int idx, void *data_type, char **buf)
200 #endif
201
202 {
203    if (buf)
204      *buf = NULL;
205    if (data_type)
206      *(int *)data_type = 0;
207
208 #ifdef HAVE_ELEMENTARY_X
209    Ecore_X_Window cbhm_xwin = _cbhm_window_get();
210    char send_buf[20];
211    char *ret;
212
213    snprintf(send_buf, 20, "CBHM_ITEM%d", idx);
214    Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(send_buf);
215    Ecore_X_Atom x_atom_item_type = 0;
216
217    DMSG("x_win: 0x%x, x_atom: %d\n", cbhm_xwin, x_atom_cbhm_item);
218    ret = _cbhm_reply_get(cbhm_xwin, x_atom_cbhm_item, &x_atom_item_type, NULL);
219    if (ret)
220      {
221         DMSG("data_type: %d, buf: %s\n", x_atom_item_type, ret);
222         if (buf)
223           *buf = ret;
224         else
225           free(ret);
226
227         if (data_type)
228           *data_type = x_atom_item_type;
229
230         Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
231         if (x_atom_item_type == x_atom_cbhm_error)
232           return EINA_FALSE;
233      }
234    DMSG("ret: 0x%x\n", ret);
235 /*
236    Ecore_X_Window xwin = ecore_evas_software_x11_window_get(
237       ecore_evas_ecore_evas_get(evas_object_evas_get(obj)));
238    char send_buf[20];
239    char *ret;
240
241    snprintf(send_buf, 20, "GET_ITEM%d", idx);
242    if (_cbhm_msg_send(obj, send_buf))
243      {
244         DMSG("message send success\n");
245         Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(ATOM_CBHM_ITEM);
246         Ecore_X_Atom x_atom_item_type = 0;
247
248         DMSG("x_win: 0x%x, x_atom: %d\n", xwin, x_atom_cbhm_item);
249         ret = _cbhm_reply_get(xwin, x_atom_cbhm_item, &x_atom_item_type, NULL);
250         if (ret)
251           {
252              DMSG("data_type: %d, buf: %s\n", x_atom_item_type, ret);
253              if (buf)
254                *buf = ret;
255              else
256                free(ret);
257              if (data_type)
258                *data_type = x_atom_item_type;
259
260              Ecore_X_Atom x_atom_cbhm_error = ecore_x_atom_get(ATOM_CBHM_ERROR);
261              if (x_atom_item_type == x_atom_cbhm_error)
262                return EINA_FALSE;
263           }
264         DMSG("ret: 0x%x\n", ret);
265      }
266 */
267 #endif
268    return EINA_FALSE;
269 }
270
271 #ifdef HAVE_ELEMENTARY_X
272 Eina_Bool
273 _cbhm_item_set(Evas_Object *obj, Ecore_X_Atom data_type, char *item_data)
274 {
275    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
276    Ecore_X_Atom x_atom_cbhm_item = ecore_x_atom_get(ATOM_CBHM_ITEM);
277    ecore_x_window_prop_property_set(x_cbhm_win, x_atom_cbhm_item, data_type, 8, item_data, strlen(item_data) + 1);
278    ecore_x_sync();
279    if (_cbhm_msg_send(obj, "SET_ITEM"))
280      {
281         DMSG("message send success\n");
282         return EINA_TRUE;
283      }
284    return EINA_FALSE;
285 }
286 #endif
287
288 unsigned int
289 _cbhm_serial_number_get()
290 {
291    unsigned int senum = 0;
292 #ifdef HAVE_ELEMENTARY_X
293    unsigned char *buf = NULL;
294    Ecore_X_Atom x_atom_cbhm_SN = ecore_x_atom_get(ATOM_CBHM_SERIAL_NUMBER);
295    Ecore_X_Window x_cbhm_win = _cbhm_window_get();
296    buf = _cbhm_reply_get(x_cbhm_win, x_atom_cbhm_SN, NULL, NULL);
297    if (buf)
298      {
299         memcpy(&senum, buf, sizeof(senum));
300         free(buf);
301      }
302 #endif
303    return senum;
304 }
305
306 //////////////////////////////////////////////////////////////////////////////
307 // old elm_cbmh_helper                                                      //
308 //////////////////////////////////////////////////////////////////////////////
309 //#include <Elementary.h>
310 //#include "elm_priv.h"
311 //
312 //#ifdef HAVE_ELEMENTARY_X
313 //#include <X11/Xlib.h>
314 //#include <X11/Xatom.h>
315 //#endif
316 //
317 ///**
318 // * @defgroup CBHM_helper CBHM_helper
319 // * @ingroup Elementary
320 // *
321 // * retrieving date from Clipboard History Manager
322 // * CBHM_helper supports to get CBHM's contents
323 // */
324 //
325 //
326 //#define ATOM_CLIPBOARD_NAME "CLIPBOARD"
327 //#define ATOM_CLIPBOARD_MANGER_NAME "CLIPBOARD_MANAGER"
328 //#define CLIPBOARD_MANAGER_WINDOW_TITLE_STRING "X11_CLIPBOARD_HISTORY_MANAGER"
329 //#define ATOM_CBHM_WINDOW_NAME "CBHM_XWIN"
330 //
331 //#ifdef HAVE_ELEMENTARY_X
332 //static Ecore_X_Display *cbhm_disp = NULL;
333 //static Ecore_X_Window cbhm_win = None;
334 //static Ecore_X_Window self_win = None;
335 //#endif
336 //static Eina_Bool init_flag = EINA_FALSE;
337 //
338 //void _get_clipboard_window();
339 //unsigned int _get_cbhm_serial_number();
340 //void _search_clipboard_window(Ecore_X_Window w);
341 //int _send_clipboard_events(char *cmd);
342 //#ifdef HAVE_ELEMENTARY_X
343 //int _get_clipboard_data(Atom datom, char **datomptr);
344 //#endif
345 //
346 //void _get_clipboard_window()
347 //{
348 //#ifdef HAVE_ELEMENTARY_X
349 //   Atom actual_type;
350 //   int actual_format;
351 //   unsigned long nitems, bytes_after;
352 //   unsigned char *prop_return = NULL;
353 //   Atom atomCbhmWin = XInternAtom(cbhm_disp, ATOM_CBHM_WINDOW_NAME, False);
354 //   if(Success ==
355 //      XGetWindowProperty(cbhm_disp, DefaultRootWindow(cbhm_disp), atomCbhmWin,
356 //                         0, sizeof(Ecore_X_Window), False, XA_WINDOW,
357 //                         &actual_type, &actual_format, &nitems, &bytes_after, &prop_return) &&
358 //      prop_return)
359 //     {
360 //        cbhm_win = *(Ecore_X_Window*)prop_return;
361 //        XFree(prop_return);
362 //        fprintf(stderr, "## find clipboard history manager at root\n");
363 //     }
364 //#endif
365 //}
366 //
367 //unsigned int _get_cbhm_serial_number()
368 //{
369 //   unsigned int senum = 0;
370 //#ifdef HAVE_ELEMENTARY_X
371 //   Atom actual_type;
372 //   int actual_format;
373 //   unsigned long nitems, bytes_after;
374 //   unsigned char *prop_return = NULL;
375 //   Atom atomCbhmSN = XInternAtom(cbhm_disp, "CBHM_SERIAL_NUMBER", False);
376 //
377 //   // FIXME : is it really needed?
378 //   XSync(cbhm_disp, EINA_FALSE);
379 //
380 //   if(Success ==
381 //      XGetWindowProperty(cbhm_disp, cbhm_win, atomCbhmSN,
382 //                         0, sizeof(Ecore_X_Window), False, XA_INTEGER,
383 //                         &actual_type, &actual_format, &nitems, &bytes_after, &prop_return) &&
384 //      prop_return)
385 //     {
386 //        senum = *(unsigned int*)prop_return;
387 //        XFree(prop_return);
388 //     }
389 //   fprintf(stderr, "## chbm_serial = %d\n", senum);
390 //#endif
391 //   return senum;
392 //}
393 //
394 //void _search_clipboard_window(Ecore_X_Window w)
395 //{
396 //#ifdef HAVE_ELEMENTARY_X
397 //   // Get the PID for the current Window.
398 //   Atom atomWMName = XInternAtom(cbhm_disp, "_NET_WM_NAME", False);
399 //   Atom atomUTF8String = XInternAtom(cbhm_disp, "UTF8_STRING", False);
400 //   Atom type;
401 //   int format;
402 //   unsigned long nitems;
403 //   unsigned long bytes_after;
404 //   unsigned long nsize = 0;
405 //   unsigned char *propName = 0;
406 //   if(Success ==
407 //      XGetWindowProperty(cbhm_disp, w, atomWMName, 0, (long)nsize, False,
408 //                         atomUTF8String, &type, &format, &nitems, &bytes_after, &propName))
409 //
410 //     {
411 //        if(propName != 0)
412 //          {
413 //             if (strcmp((const char *)CLIPBOARD_MANAGER_WINDOW_TITLE_STRING,(const char *)propName) == 0)
414 //               cbhm_win = w;
415 //             XFree(propName);
416 //          }
417 //     }
418 //
419 //   // Recurse into child windows.
420 //   Window wroot;
421 //   Window wparent;
422 //   Window *wchild;
423 //   unsigned nchildren;
424 //   int i;
425 //   if(0 != XQueryTree(cbhm_disp, w, &wroot, &wparent, &wchild, &nchildren))
426 //     {
427 //        for(i = 0; i < nchildren; i++)
428 //          _search_clipboard_window(wchild[i]);
429 //        XFree(wchild);
430 //     }
431 //#endif
432 //}
433 //
434 //int _send_clipboard_events(char *cmd)
435 //{
436 //   if (cmd == NULL)
437 //     return -1;
438 //
439 //#ifdef HAVE_ELEMENTARY_X
440 //   Atom atomCBHM_MSG = XInternAtom(cbhm_disp, "CBHM_MSG", False);
441 //
442 //   XClientMessageEvent m;
443 //   memset(&m, 0, sizeof(m));
444 //   m.type = ClientMessage;
445 //   m.display = cbhm_disp;
446 //   m.window = self_win;
447 //   m.message_type = atomCBHM_MSG;
448 //   m.format = 8;
449 //   sprintf(m.data.b, "%s", cmd);
450 //
451 //   XSendEvent(cbhm_disp, cbhm_win, False, NoEventMask, (XEvent*)&m);
452 //#endif
453 //   return 0;
454 //}
455 //
456 //#ifdef HAVE_ELEMENTARY_X
457 //int _get_clipboard_data(Atom datom, char **datomptr)
458 //{
459 //   // Atom atomUTF8String = XInternAtom(cbhm_disp, "UTF8_STRING", False);
460 //   Atom type;
461 //   int format;
462 //   unsigned long nitems;
463 //   unsigned long nsize;
464 //   unsigned char *propname = NULL;
465 //
466 //   // FIXME : is it really needed?
467 //   XSync(cbhm_disp, EINA_FALSE);
468 //
469 //   if (Success ==
470 //       XGetWindowProperty(cbhm_disp, self_win, datom, 0, 0, False,
471 //                          AnyPropertyType, &type, &format, &nitems, &nsize, &propname))
472 //     {
473 //        XFree(propname);
474 //     }
475 //   else
476 //     return -1;
477 //
478 //   /*
479 //      fprintf(stderr, "## format = %d\n", format);
480 //      fprintf(stderr, "## nsize = %d\n", nsize);
481 //    */
482 //
483 //   if (format != 8)
484 //     return -1;
485 //
486 //   if (Success ==
487 //       XGetWindowProperty(cbhm_disp, self_win, datom, 0, (long)nsize, False,
488 //                          AnyPropertyType, &type, &format, &nitems, &nsize, &propname))
489 //     {
490 //        if (nsize != 0)
491 //          {
492 //             XGetWindowProperty(cbhm_disp, self_win, datom, 0, (long)nsize, False,
493 //                                AnyPropertyType, &type, &format, &nitems, &nsize, &propname);
494 //          }
495 //
496 //        if(propname != NULL)
497 //          {
498 //             //                       fprintf(stderr, "## get data(0x%x) : %s\n", propname, propname);
499 //             //                       fprintf(stderr, "## after nsize = %d\n", nsize);
500 //             *datomptr = (char*)propname;
501 //             //                       XFree(propName);
502 //          }
503 //
504 //        XDeleteProperty(cbhm_disp, self_win, datom);
505 //        XFlush(cbhm_disp);
506 //     }
507 //
508 //   if (propname != NULL)
509 //     return 0;
510 //
511 //   *datomptr = NULL;
512 //   return -1;
513 //}
514 //#endif
515 //
516 //void free_clipboard_data(char *dptr)
517 //{
518 //#ifdef HAVE_ELEMENTARY_X
519 //   XFree(dptr);
520 //   return;
521 //#endif
522 //}
523 //
524 //
525 ///**
526 // * initalizing CBHM_helper
527 // *
528 // * @param self The self window object which receive events
529 // * @return return TRUE or FALSE if it cannot be created
530 // *
531 // * @ingroup CBHM_helper
532 // */
533 //EAPI Eina_Bool
534 //elm_cbhm_helper_init(Evas_Object *self)
535 //{
536 //   init_flag = EINA_FALSE;
537 //
538 //#ifdef HAVE_ELEMENTARY_X
539 //   cbhm_disp = ecore_x_display_get();
540 //   if (cbhm_disp == NULL)
541 //     return init_flag;
542 //   if (cbhm_win == None)
543 //     _get_clipboard_window();
544 //   if (cbhm_win == None)
545 //     _search_clipboard_window(DefaultRootWindow(cbhm_disp));
546 //   if (self_win == None)
547 //     self_win = ecore_evas_software_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(self)));
548 //
549 //   if (cbhm_disp && cbhm_win && self_win)
550 //     init_flag = EINA_TRUE;
551 //#endif
552 //   return init_flag;
553 //}
554 //
555 ///**
556 // * getting serial number of CBHM
557 // *
558 // * @return return serial number of clipboard history manager
559 // *
560 // * @ingroup CBHM_helper
561 // */
562 //EAPI unsigned int
563 //elm_cbhm_get_serial_number()
564 //{
565 //   if (init_flag == EINA_FALSE)
566 //     return 0;
567 //
568 //   unsigned int num = 0;
569 //   num = _get_cbhm_serial_number();
570 //   return num;
571 //}
572 //
573 ///**
574 // * getting count of CBHM's contents
575 // *
576 // * @return return count of history contents
577 // *
578 // * @ingroup CBHM_helper
579 // */
580 //EAPI int
581 //elm_cbhm_get_count()
582 //{
583 //   if (init_flag == EINA_FALSE)
584 //     return -1;
585 //
586 //   char *retptr = NULL;
587 //   int count = 0;
588 //
589 //   _send_clipboard_events("get count");
590 //
591 //#ifdef HAVE_ELEMENTARY_X
592 //   Atom atomCBHM_cCOUNT = XInternAtom(cbhm_disp, "CBHM_cCOUNT", False);
593 //
594 //   _get_clipboard_data(atomCBHM_cCOUNT, &retptr);
595 //#endif
596 //
597 //   if (retptr != NULL)
598 //     {
599 //        fprintf(stderr, "## c get retptr : %s\n", retptr);
600 //        count = atoi(retptr);
601 //
602 //        free_clipboard_data(retptr);
603 //        retptr = NULL;
604 //     }
605 //
606 //   return count;
607 //}
608 //
609 ///**
610 // * getting raw data of CBHM's contents
611 // *
612 // * @return return raw data of history contents
613 // *
614 // * @ingroup CBHM_helper
615 // */
616 //EAPI int
617 //elm_cbhm_get_raw_data()
618 //{
619 //   if (init_flag == EINA_FALSE)
620 //     return -1;
621 //
622 //   char *retptr = NULL;
623 //
624 //   _send_clipboard_events("get raw");
625 //
626 //#ifdef HAVE_ELEMENTARY_X
627 //   Atom atomCBHM_cRAW = XInternAtom(cbhm_disp, "CBHM_cRAW", False);
628 //
629 //   _get_clipboard_data(atomCBHM_cRAW, &retptr);
630 //#endif
631 //
632 //   if (retptr != NULL)
633 //     {
634 //        free_clipboard_data(retptr);
635 //        retptr = NULL;
636 //     }
637 //
638 //   return 0;
639 //}
640 //
641 ///**
642 // * sending raw command to CBHM
643 // *
644 // * @return void
645 // *
646 // * @ingroup CBHM_helper
647 // */
648 //EAPI void
649 //elm_cbhm_send_raw_data(char *cmd)
650 //{
651 //   if (init_flag == EINA_FALSE)
652 //     return;
653 //
654 //   if (cmd == NULL)
655 //     return;
656 //
657 //   _send_clipboard_events(cmd);
658 //   fprintf(stderr, "## cbhm - send raw cmd = %s\n", cmd);
659 //
660 //   return;
661 //}
662 //
663 ///**
664 // * getting data by history position of CBHM's contents
665 // * 0 is current content.
666 // *
667 // * @return return data pointer of position of history contents
668 // *
669 // * @ingroup CBHM_helper
670 // */
671 //EAPI int
672 //elm_cbhm_get_data_by_position(int pos, char **dataptr)
673 //{
674 //   if (init_flag == EINA_FALSE)
675 //     return -1;
676 //
677 //   char reqbuf[16];
678 //   int ret = 0;
679 //   sprintf(reqbuf, "get #%d", pos);
680 //
681 //   _send_clipboard_events(reqbuf);
682 //
683 //   sprintf(reqbuf, "CBHM_c%d", pos);
684 //
685 //#ifdef HAVE_ELEMENTARY_X
686 //   Atom atomCBHM_cPOS = XInternAtom(cbhm_disp, reqbuf, False);
687 //
688 //   ret = _get_clipboard_data(atomCBHM_cPOS, dataptr);
689 //#endif
690 //
691 //   if (ret >= 0 && *dataptr != NULL)
692 //     {
693 //        //            fprintf(stderr, "## d get retptr : %s\n", *dataptr);
694 //        //            fprintf(stderr, "## dptr = 0x%x\n", *dataptr);
695 //
696 //        return 0;
697 //     }
698 //
699 //   return -1;
700 //}
701 //
702 ///**
703 // * free data by history position of CBHM's contents
704 // *
705 // * @return None
706 // *
707 // * @ingroup CBHM_helper
708 // */
709 //EAPI void
710 //elm_cbhm_free_data(char *dptr)
711 //{
712 //   if (dptr != NULL)
713 //     free_clipboard_data(dptr);
714 //}