Release version 1.7.0
[platform/core/appfw/data-provider-master.git] / include / service_common.h
1 /*
2  * Copyright 2016  Samsung Electronics Co., Ltd
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 #include <gio/gio.h>
18 #include <notification.h>
19 #include <badge.h>
20 #include <shortcut.h>
21 #include <stdlib.h>
22
23 #ifndef SERVICE_COMMON_H_
24 #define SERVICE_COMMON_H_
25
26 #define NORMAL_UID_BASE 5000
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 typedef enum {
33         NOTIFICATION_SERVICE = 0,
34         SHORTCUT_SERVICE,
35         BADGE_SERVICE,
36 } service_type;
37
38 enum service_common_error {
39         SERVICE_COMMON_ERROR_NONE = 0,
40         SERVICE_COMMON_ERROR_INVALID_PARAMETER = -1,
41         SERVICE_COMMON_ERROR_ALREADY_STARTED = -2,
42         SERVICE_COMMON_ERROR_FAULT = -3,
43         SERVICE_COMMON_ERROR_PERMISSION_DENIED = -4,
44         SERVICE_COMMON_ERROR_IO_ERROR = -5,
45         SERVICE_COMMON_ERROR_OUT_OF_MEMORY = -6,
46         SERVICE_COMMON_ERROR_NOT_EXIST = -7,
47         SERVICE_COMMON_ERROR_ALREADY_EXIST = -8,
48 };
49
50 typedef struct monitoring_info {
51         int watcher_id;
52         char *bus_name;
53         uid_t uid;
54 } monitoring_info_s;
55
56 int send_notify(GVariant *body, char *cmd, GHashTable **monitoring_hash, char *interface_name, uid_t uid);
57 bool is_existed_busname(const char *sender_name);
58 int send_event_notify_by_busname(GVariant *body, char *cmd, char *busname, char *interface_name);
59 int service_register(GVariant *parameters, GVariant **reply_body, const gchar *sender,
60         GBusNameAppearedCallback name_appeared_handler,
61         GBusNameVanishedCallback name_vanished_handler,
62         GHashTable **monitoring_hash,
63         uid_t uid);
64 int service_unregister(GVariant *parameters, GVariant **reply_body, const gchar *sender, GHashTable **monitoring_hash, uid_t uid);
65 int delete_monitoring_list(GHashTable **monitoring_hash, const char *sender, uid_t uid);
66 GDBusConnection *service_common_get_connection();
67 int service_common_register_dbus_interface(char *introspection_xml, GDBusInterfaceVTable interface_vtable);
68 uid_t get_sender_uid(const char *sender_name);
69 pid_t get_sender_pid(const char *sender_name);
70 void free_monitoring_list(gpointer data);
71 void service_common_init(void);
72 void service_common_set_connection(GDBusConnection *conn);
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif //SERVICE_COMMON_H_