tizen 2.4 release
[framework/convergence/service/service-plugin-client.git] / include / plugin_message.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 #ifndef __TIZEN_SOCIAL_LIBSERVICE_PLUGIN_MESSAGE_H__
18 #define __TIZEN_SOCIAL_LIBSERVICE_PLUGIN_MESSAGE_H__
19
20 #include <stdint.h>
21 #include <stdbool.h>
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27
28 typedef enum
29 {
30         PLUGIN_MESSAGE_TYPE_FUNCTION = 1,
31         PLUGIN_MESSAGE_TYPE_CALLBACK = 2,
32 } plugin_message_type_e;
33
34 /*
35 #define PLUGIN_DATA_TYPE_INT            'i'
36 #define PLUGIN_DATA_TYPE_LONG           'l'
37 */
38
39 // INT/LONG -> NUM (64bit)
40 #define PLUGIN_DATA_TYPE_NUM            'n'
41 #define PLUGIN_DATA_TYPE_STRING         's'
42 #define PLUGIN_DATA_TYPE_BOOL           'b'
43 #define PLUGIN_DATA_TYPE_ARRAY          'a'
44 #define PLUGIN_DATA_TYPE_UNKNOWN        'u'
45
46 typedef char plugin_data_type;
47
48
49 /*
50 typedef enum
51 {
52         PM_TYPE_FALSE = 0,
53         PM_TYPE_TRUE = 1,
54 } pmbool_type_e;
55 */
56
57 typedef long long int pmnumber;
58 typedef char *pmstring;
59 typedef bool pmbool;
60
61 typedef enum
62 {
63         PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
64         PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
65         PLUGIN_MESSAGE_ELEMENT_PARAMETER_MANDATORY,
66         PLUGIN_MESSAGE_ELEMENT_PARAMETER_OPTIONAL,
67         PLUGIN_MESSAGE_ELEMENT_REQUEST_ID,
68         PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
69         PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
70         PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
71 } plugin_message_element_e;
72
73 typedef struct _plugin_message_s *plugin_message_h;
74
75 typedef struct _plugin_message_array_s *plugin_message_array_h;
76
77
78 int plugin_message_create(plugin_message_h *message);
79
80 void plugin_message_destroy(plugin_message_h message);
81
82 int plugin_message_set_value_number(plugin_message_h message, plugin_message_element_e field, pmnumber value);
83
84 int plugin_message_get_value_number(plugin_message_h message, plugin_message_element_e field, pmnumber *value);
85
86 int plugin_message_set_value_string(plugin_message_h message, plugin_message_element_e field, const char *value);
87
88 int plugin_message_get_value_string(plugin_message_h message, plugin_message_element_e field, char **value);
89
90 int plugin_message_set_value_bool(plugin_message_h message, plugin_message_element_e field, bool value);
91
92 int plugin_message_get_value_bool(plugin_message_h message, plugin_message_element_e field, bool *value);
93
94
95 int plugin_message_set_param_number(plugin_message_h message, int param_index, pmnumber value);
96
97 int plugin_message_get_param_number(plugin_message_h message, int param_index, pmnumber *value);
98
99 int plugin_message_set_param_string(plugin_message_h message, int param_index, const char *value);
100
101 int plugin_message_get_param_string(plugin_message_h message, int param_index, char **value);
102
103 int plugin_message_set_param_bool(plugin_message_h message, int param_index, bool value);
104
105 int plugin_message_get_param_bool(plugin_message_h message, int param_index, bool *value);
106
107 int plugin_message_set_param_array(plugin_message_h message, int param_index, plugin_message_array_h value);
108
109 int plugin_message_get_param_array(plugin_message_h message, int param_index, plugin_message_array_h *value);
110
111
112 int plugin_message_set_opt_param_number(plugin_message_h message, int param_index, pmnumber value);
113
114 int plugin_message_get_opt_param_number(plugin_message_h message, int param_index, pmnumber *value);
115
116 int plugin_message_set_opt_param_string(plugin_message_h message, int param_index, const char *value);
117
118 int plugin_message_get_opt_param_string(plugin_message_h message, int param_index, char **value);
119
120 int plugin_message_set_opt_param_bool(plugin_message_h message, int param_index, bool value);
121
122 int plugin_message_get_opt_param_bool(plugin_message_h message, int param_index, bool *value);
123
124 int plugin_message_set_opt_param_array(plugin_message_h message, int param_index, plugin_message_array_h value);
125
126 int plugin_message_get_opt_param_array(plugin_message_h message, int param_index, plugin_message_array_h *value);
127
128
129 int plugin_message_serialize(plugin_message_h message, char **data);
130
131 int plugin_message_deserialize(const char *data, plugin_message_h *message);
132
133
134 int plugin_message_array_create(const plugin_data_type *type_string, plugin_message_array_h *array);
135
136 void plugin_message_array_destroy(plugin_message_array_h array);
137
138 int plugin_message_array_add_element(plugin_message_array_h array, ...);
139
140 int plugin_message_array_get_element(plugin_message_array_h array, int idx, ...);
141
142 #ifdef __cplusplus
143 }
144 #endif
145
146 #endif /* __TIZEN_SOCIAL_LIBSERVICE_PLUGIN_MESSAGE_H__ */