Merge "Return errors to caller" into tizen_5.5
[platform/core/connectivity/stc-manager.git] / unittest / gdbus.h
1 /*
2  * Copyright (c) 2017 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 #ifndef __STC_MGR_GDBUS_H__
17 #define __STC_MGR_GDBUS_H__
18
19 #include <glib.h>
20 #include <gio/gio.h>
21
22 #include "stcmgr.h"
23
24 #define GMAINTIMEOUT 10000
25 #define DBUS_REPLY_TIMEOUT (120 * 1000)
26
27 #define STC_MGR_SERVICE                 "net.stc"
28 #define STC_MGR_STATISTICS_INTERFACE    STC_MGR_SERVICE ".statistics"
29 #define STC_MGR_RESTRICTION_INTERFACE   STC_MGR_SERVICE ".restriction"
30 #define STC_MGR_MANAGER_INTERFACE       STC_MGR_SERVICE ".manager"
31 #define STC_MGR_FIREWALL_INTERFACE      STC_MGR_SERVICE ".firewall"
32
33 #define STC_MGR_STATISTICS_PATH         "/net/stc/statistics"
34 #define STC_MGR_RESTRICTION_PATH        "/net/stc/restriction"
35 #define STC_MGR_MANAGER_PATH            "/net/stc/manager"
36 #define STC_MGR_FIREWALL_PATH           "/net/stc/firewall"
37
38 #define STC_MGR_METHOD_STATISTICS_INIT              "Init"
39 #define STC_MGR_METHOD_STATISTICS_GET_PER_APP_ID    "Get"
40 #define STC_MGR_METHOD_STATISTICS_GET_ALL           "GetAll"
41 #define STC_MGR_METHOD_STATISTICS_GET_TOTAL         "Get"
42 #define STC_MGR_METHOD_STATISTICS_RESET             "Reset"
43
44 #define STC_MGR_METHOD_RESTRICTION_SET              "Set"
45 #define STC_MGR_METHOD_RESTRICTION_GET_STATUS       "GetState"
46 #define STC_MGR_METHOD_RESTRICTION_GET_PER_APP_ID   "Get"
47 #define STC_MGR_METHOD_RESTRICTION_GET_ALL          "GetAll"
48 #define STC_MGR_METHOD_RESTRICTION_UNSET            "Unset"
49 #define STC_MGR_METHOD_RESTRICTION_EXCLUDE          "Exclude"
50
51 #define STC_MGR_METHOD_MANAGER_STOP                 "Stop"
52
53 #define STC_MGR_METHOD_FIREWALL_GET_ALL             "GetAllRule"
54 #define STC_MGR_METHOD_FIREWALL_UPDATE              "UpdateRule"
55 #define STC_MGR_METHOD_FIREWALL_REMOVE              "RemoveRule"
56 #define STC_MGR_METHOD_FIREWALL_ADD                 "AddRule"
57 #define STC_MGR_METHOD_FIREWALL_SET                 "SetChain"
58 #define STC_MGR_METHOD_FIREWALL_UNSET               "UnsetChain"
59 #define STC_MGR_METHOD_FIREWALL_FLUSH               "FlushChain"
60 #define STC_MGR_METHOD_FIREWALL_GET_CHAIN           "GetAllChain"
61 #define STC_MGR_METHOD_FIREWALL_REMOVE_CHAIN        "RemoveChain"
62 #define STC_MGR_METHOD_FIREWALL_ADD_CHAIN           "AddChain"
63 #define STC_MGR_METHOD_FIREWALL_GET_LOCK            "GetLock"
64 #define STC_MGR_METHOD_FIREWALL_LOCK                "Lock"
65 #define STC_MGR_METHOD_FIREWALL_UNLOCK              "Unlock"
66
67 class GDbus {
68 private:
69         GDBusConnection *m_pConnection;
70         GCancellable *m_pCancellable;
71 public:
72         GDbus();
73         ~GDbus();
74         error_e Create(void);
75         error_e Destroy(void);
76         GDBusConnection *GetConnection(void);
77         GCancellable *GetCancellable(void);
78         error_e ConvertErrorStringToEnum(const char *error);
79         GVariant *InvokeMethod(const char *dest, const char *path,
80                 const char *iface_name, const char *method, GVariant *params, error_e *dbus_error);
81         error_e InvokeMethodNonblock(const char *dest, const char *path,
82                 const char *iface_name, const char *method, GVariant *params, int timeout,
83                 GAsyncReadyCallback notify_func, void *user_data);
84 };
85
86 #endif /* __STC_MGR_GDBUS_H__ */