[cbhm] copy&paste error in webkit
[framework/uifw/cbhm.git] / src / cbhm.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  */
17
18 #ifndef _CBHM_H_
19 #define _CBHM_H_
20
21 #include <Elementary.h>
22 #include <Ecore_X.h>
23
24 #if !defined(PACKAGE)
25 #  define PACKAGE "CBHM"
26 #endif
27
28 #if !defined(APPNAME)
29 #  define APPNAME "Clipboard History Manager"
30 #endif
31
32 #if !defined(LOCALEDIR)
33 #  define LOCALEDIR "/usr/share/locale"
34 #endif
35
36 #define CBHM_MAGIC 0xad960009
37
38 typedef struct _TargetHandler TargetHandler;
39 typedef struct _AppData AppData;
40 typedef struct _ClipdrawerData ClipdrawerData;
41 typedef struct _CNP_ITEM CNP_ITEM;
42 typedef struct _XHandlerData XHandlerData;
43 typedef struct _SCaptureData SCaptureData;
44 typedef struct _StorageData StorageData;
45 typedef char *(*text_converter_func)(AppData *ad, int type_index, const char *str);
46
47 #include "clipdrawer.h"
48 #include "item_manager.h"
49 #include "xhandler.h"
50 #include "xconverter.h"
51 #include "scrcapture.h"
52 #include "storage.h"
53
54 struct _TargetHandler {
55         Ecore_X_Atom *atom;
56         char **name;
57         int atom_cnt;
58         text_converter_func convert_for_entry;
59         text_converter_func convert_to_target[ATOM_INDEX_MAX];
60 };
61
62 struct _AppData {
63         int magic;
64         Ecore_X_Display *x_disp;
65         Ecore_X_Window x_root_win;
66         Ecore_X_Window x_event_win;
67         Ecore_X_Window x_active_win;
68         Eina_List *item_list;
69
70         Eina_Bool (*draw_item_add)(AppData *ad, CNP_ITEM *item);
71         Eina_Bool (*draw_item_del)(AppData *ad, CNP_ITEM *item);
72         Eina_Bool (*storage_item_add)(AppData *ad, CNP_ITEM *item);
73         Eina_Bool (*storage_item_del)(AppData *ad, CNP_ITEM *item);
74 //      CNP_ITEM *(*storage_item_load)(AppData *ad, int index);
75
76         ClipdrawerData *clipdrawer;
77         XHandlerData *xhandler;
78         SCaptureData *screencapture;
79         StorageData *storage;
80
81         CNP_ITEM *clip_selected_item;
82         TargetHandler targetAtoms[ATOM_INDEX_MAX];
83 };
84
85 void *d_malloc(char *func, int line, size_t size);
86 void *d_calloc(char *func, int line, size_t n, size_t size);
87 void d_free(char *func, int line, void *m);
88
89 #define DEBUG
90
91 #ifdef DEBUG
92 #define DTRACE(fmt, args...) \
93 {do { fprintf(stderr, "[%s:%04d] " fmt, __func__,__LINE__, ##args); } while (0); }
94 #define DMSG(fmt, args...) printf("[%s] " fmt, __func__, ## args )
95 #define CALLED() printf("called %s, %s\n", __FILE__, __func__);
96 #define DTIME(fmt, args...) \
97 {do { struct timeval tv1; gettimeofday(&tv1, NULL); double t1=tv1.tv_sec+(tv1.tv_usec/1000000.0); fprintf(stderr, "[CBHM][time=%lf:%s:%04d] " fmt, t1, __func__, __LINE__, ##args); } while (0); }
98 #ifdef MEM_DEBUG
99 #define MALLOC(size) d_malloc(__func__, __LINE__, size)
100 #define CALLOC(n, size) d_calloc(__func__, __LINE__, n, size)
101 #define FREE(p) d_free(__func__, __LINE__, p)
102 #else
103 #define MALLOC(size) malloc(size)
104 #define CALLOC(n, size) calloc(n, size)
105 #define FREE(p) free(p)
106 #endif
107 #else
108 #define DMSG(fmt, args...)
109 #define CALLED()
110 #define DTIME(fmt, args...)
111 #define MALLOC(size) malloc(size)
112 #define CALLOC(n, size) calloc(n, size)
113 #define FREE(p) free(p)
114 #endif
115
116 #endif // _CBHM_H_