adopt dbus cynara check
[platform/core/telephony/tel-plugin-dbus_tapi.git] / src / dtapi_common.h
1 /*
2  * tel-plugin-dbus-tapi
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #ifndef __COMMON_H__
22 #define __COMMON_H__
23
24 #include <glib.h>
25 #include <gio/gio.h>
26
27 #include "type/sim.h"
28
29 #include "generated-code.h"
30
31 #define AC_MANAGER              "telephony_framework::api_manager"
32 #define AC_CALL                 "telephony_framework::api_call"
33 #define AC_MODEM                "telephony_framework::api_modem"
34 #define AC_NETWORK              "telephony_framework::api_network"
35 #define AC_PHONEBOOK            "telephony_framework::api_phonebook"
36 #define AC_SAP                  "telephony_framework::api_sap"
37 #define AC_SAT                  "telephony_framework::api_sat"
38 #define AC_SIM                  "telephony_framework::api_sim"
39 #define AC_SMS                  "telephony_framework::api_sms"
40 #define AC_SS                   "telephony_framework::api_ss"
41
42 #define MY_DBUS_PATH            "/org/tizen/telephony"
43 #define MY_DBUS_SERVICE "org.tizen.telephony"
44
45 enum dbus_tapi_sim_slot_id {
46         SIM_SLOT_PRIMARY,
47         SIM_SLOT_SECONDARY,
48         SIM_SLOT_TERTIARY
49 };
50
51 struct cached_data{
52         char *cp_name;
53         gpointer cached_sat_main_menu;
54 };
55
56 struct custom_data {
57         TcorePlugin *plugin;
58         Communicator *comm;
59         Server *server;
60
61         GHashTable *objects;
62         GDBusObjectManagerServer *manager;
63         TelephonyManager *mgr;
64         enum tel_sim_status sim1_status;
65         enum tel_sim_status sim2_status;
66         int valid_sim_count;
67         GSList *cached_data;
68
69         gboolean name_acquired;
70         guint owner_id;
71 };
72
73 struct dbus_request_info {
74         void *interface_object;
75         GDBusMethodInvocation *invocation;
76 };
77
78 #define DEFAULT_MSG_REQ_FAILED "Request failed"
79
80 #define GET_CP_NAME(invocation) dbus_plugin_get_cp_name_by_object_path(g_dbus_method_invocation_get_object_path(invocation))
81 #define MAKE_UR(ctx, object, invocation) dbus_plugin_macro_user_request_new(ctx, object, invocation)
82 #define FAIL_RESPONSE(ivc, msg) g_dbus_method_invocation_return_error (ivc, \
83         G_DBUS_ERROR, G_DBUS_ERROR_FAILED, msg);
84
85 gboolean dtapi_init(TcorePlugin *p);
86 void dtapi_deinit(TcorePlugin *p);
87
88 char *dbus_plugin_get_cp_name_by_object_path(const char *object_path);
89 UserRequest *dbus_plugin_macro_user_request_new(struct custom_data *ctx, void *object, GDBusMethodInvocation *invocation);
90
91 gboolean dbus_plugin_util_load_xml(char *docname, char *groupname, void **i_doc, void **i_root_node);
92 void dbus_plugin_util_unload_xml(void **i_doc, void **i_root_node);
93
94 void dtapi_dispatch_request(struct custom_data *ctx,
95         void *object, GDBusMethodInvocation *invocation,
96         enum tcore_request_command req_command,
97         void *req_data, unsigned int req_data_len);
98 TReturn dtapi_dispatch_request_ex(struct custom_data *ctx,
99         void *object, GDBusMethodInvocation *invocation,
100         enum tcore_request_command req_command,
101         void *req_data, unsigned int req_data_len);
102
103 gboolean dbus_plugin_setup_network_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
104 gboolean dbus_plugin_network_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
105 gboolean dbus_plugin_network_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
106
107 gboolean dbus_plugin_setup_sap_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
108 gboolean dbus_plugin_sap_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
109 gboolean dbus_plugin_sap_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
110
111 gboolean dbus_plugin_setup_phonebook_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
112 gboolean dbus_plugin_phonebook_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
113 gboolean dbus_plugin_phonebook_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
114
115 gboolean dbus_plugin_setup_sim_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
116 gboolean dbus_plugin_sim_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
117 gboolean dbus_plugin_sim_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
118
119 gboolean dbus_plugin_setup_sat_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
120 gboolean dbus_plugin_sat_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
121 gboolean dbus_plugin_sat_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
122
123 gboolean dbus_plugin_setup_sms_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
124 gboolean dbus_plugin_sms_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
125 gboolean dbus_plugin_sms_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
126
127 gboolean dbus_plugin_setup_call_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
128 gboolean dbus_plugin_call_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
129 gboolean dbus_plugin_call_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
130
131 gboolean dbus_plugin_setup_ss_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
132 gboolean dbus_plugin_ss_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
133 gboolean dbus_plugin_ss_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
134
135 gboolean dbus_plugin_setup_modem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
136 gboolean dbus_plugin_modem_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
137 gboolean dbus_plugin_modem_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
138
139 gboolean dbus_plugin_setup_oem_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx);
140 gboolean dbus_plugin_oem_response(struct custom_data *ctx, UserRequest *ur, struct dbus_request_info *dbus_info, enum tcore_response_command command, unsigned int data_len, const void *data);
141 gboolean dbus_plugin_oem_notification(struct custom_data *ctx, CoreObject *source, TelephonyObjectSkeleton *object, enum tcore_notification_command command, unsigned int data_len, const void *data);
142
143 enum dbus_tapi_sim_slot_id get_sim_slot_id_by_cp_name(const char *cp_name);
144
145 #endif /* __COMMON_H__ */