Add 3.0 APIs and sync APIs same as 2.4
[platform/core/convergence/service-adaptor.git] / common / sal_ipc.h
1 /*
2  * Service Adaptor IPC
3  *
4  * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Yongjin Kim <youth.kim@samsung.com>
7  *          Jinhyeong Ahn <jinh.ahn@samsung.com>
8  *          Jiwon Kim <jiwon177.kim@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24 #ifndef __TIZEN_CONVERGENCE_SAL_IPC_H__
25 #define __TIZEN_CONVERGENCE_SAL_IPC_H__
26
27 #ifndef API
28 #define API __attribute__ ((visibility("default")))
29 #endif
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 #include <glib.h>
37 #include <gio/gio.h>
38
39 #define SAL_IPC_STR(x)  (x==NULL)?"":x
40
41 /**
42  * Service Adaptor D-Bus server bus name.
43  */
44 #define SERVICE_ADAPTOR_BUS_NAME "org.tizen.serviceadaptor.client"
45
46 /**
47  * Service Adaptor D-Bus server object path.
48  */
49 #define SERVICE_ADAPTOR_OBJECT_PATH "/org/tizen/serviceadaptor/client"
50
51 /**
52  * Service Adaptor D-Bus interface.
53  */
54 #define SERVICE_ADAPTOR_INTERFACE "org.tizen.serviceadaptor.client.interface"
55
56 /**
57  * struct for dbus.
58  */
59 #define service_adaptor_connect_req_s_type_length 1
60 #define service_adaptor_connect_req_s_type \
61         "(" \
62         "s" /* char *uri */ \
63         ")"
64
65 #define service_adaptor_connect_res_s_type_length 1
66 #define service_adaptor_connect_res_s_type \
67         "(" \
68         "a(s)" /* char **uri */ \
69         ")"
70
71 #define service_adaptor_disconnect_s_type_length 1
72 #define service_adaptor_disconnect_s_type \
73         "(" \
74         "s" /* char *uri */ \
75         ")"
76
77 #define service_plugin_create_s_type_length 1
78 #define service_plugin_create_s_type \
79         "(" \
80         "s" /* char *uri */ \
81         ")"
82
83 #define service_plugin_destroy_s_type_length 1
84 #define service_plugin_destroy_s_type \
85         "(" \
86         "s" /* char *uri */ \
87         ")"
88
89 #define service_auth_oauth1_s_type_length 2
90 #define service_auth_oauth1_s_type \
91         "(" \
92         "s" /* char *access_token */ \
93         "s" /* char *operation */ \
94         ")"
95
96 #define service_auth_oauth1_req_s_type_length 2
97 #define service_auth_oauth1_req_s_type \
98         "(" \
99         "s" /* char *uri */ \
100         service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
101         ")"
102
103 #define service_auth_oauth1_res_s_type_length 1
104 #define service_auth_oauth1_res_s_type \
105         "(" \
106         service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
107         ")"
108
109 #define service_storage_cloud_file_s_type_length 6
110 #define service_storage_cloud_file_s_type \
111         "(" \
112         "b" /* bool is_dir */ \
113         "s" /* char *dir_path */ \
114         "s" /* char *local_path */ \
115         "s" /* char *cloud_path */ \
116         "t" /* uint64 size */ \
117         "s" /* char *operation */ \
118         ")"
119
120 #define service_storage_cloud_file_req_s_type_length 2
121 #define service_storage_cloud_file_req_s_type \
122         "(" \
123         "s" /* char *uri */ \
124         service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
125         ")"
126
127 #define service_storage_cloud_file_res_s_type_length 2
128 #define service_storage_cloud_file_res_s_type \
129         "(" \
130         service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
131         "a" service_storage_cloud_file_s_type /* GList *files */  \
132         ")"
133
134 /**
135  * array of structures
136  */
137 #define plugin_list_type                                "a(s)"
138 #define file_list_type                                  "a" service_storage_cloud_file_s_type
139
140 /**
141  * append error code to the type
142  */
143 #define RETURN_LENGTH                                   2
144
145 /**
146  * DBus APIs
147  */
148 #define DBUS_SERVICE_ADAPTOR                            "dbus_00"
149 #define DBUS_SERVICE_PLUGIN                             "dbus_01"
150 #define DBUS_SERVICE_AUTH                               "dbus_02"
151 #define DBUS_SERVICE_STORAGE                            "dbus_03"
152 #define DBUS_NAME_LENGTH                                7
153
154 #define DBUS_SERVICE_ADAPTOR_CONNECT_METHOD             DBUS_SERVICE_ADAPTOR "_service_adaptor_connect"
155 #define DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD          DBUS_SERVICE_ADAPTOR "_service_adaptor_disconnect"
156
157 #define DBUS_SERVICE_PLUGIN_CREATE_METHOD               DBUS_SERVICE_PLUGIN "_service_plugin_create"
158 #define DBUS_SERVICE_PLUGIN_DESTROY_METHOD              DBUS_SERVICE_PLUGIN "_service_plugin_destroy"
159
160 #define DBUS_SERVICE_AUTH_OAUTH1_METHOD                 DBUS_SERVICE_AUTH "_service_auth_oauth1"
161
162 #define DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD          DBUS_SERVICE_STORAGE "_service_storage_cloud_file"
163
164 #define DBUS_SERVICE_ADAPTOR_NOTIFY_SIGNAL              DBUS_SERVICE_ADAPTOR "_service_adaptor_signal_notify"
165
166 typedef struct _ipc_reply_data_s
167 {
168         GDBusMethodInvocation *invocation;
169         char *type;
170 } ipc_reply_data_s;
171 typedef struct _ipc_reply_data_s *ipc_reply_data_h;
172
173 char *ipc_insure_g_variant_dup_string(GVariant *string);
174 void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str);
175 char *ipc_make_return_type(const char *type);
176 void ipc_create_error_msg(int code, char **ipc_msg);
177 void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info);
178 void ipc_destroy_variant_info(GVariant **var_info, int size);
179 void ipc_free_reply_data(ipc_reply_data_h reply);
180
181 #ifdef __cplusplus
182 }
183 #endif
184
185 #endif /* __TIZEN_CONVERGENCE_SAL_IPC_H__ */