bb23514dacb276370378cb538cea18c229e8f4a2
[platform/core/connectivity/stc-manager.git] / include / stc-manager.h
1 /*
2  * Copyright (c) 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 #ifndef __STC_MANAGER_H__
18 #define __STC_MANAGER_H__
19
20 #include "stc-error.h"
21 #include "stc-manager-util.h"
22
23 #define NET_RELEASE_AGENT "/usr/bin/net-cls-release"
24 #define NET_CLS_SUBSYS "net_cls"
25
26 #define STC_BACKGROUND_APP_SUFFIX "_BACKGROUND"
27 #define STC_BACKGROUND_APP_ID "BACKGROUND"
28 #define STC_TOTAL_DATACALL "TOTAL_DATACALL"
29 #define STC_TOTAL_WIFI "TOTAL_WIFI"
30 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
31 #define STC_TOTAL_IPV4 "TOTAL_IPV4"
32 #define STC_TOTAL_IPV6 "TOTAL_IPV6"
33
34 #define STC_DEBUG_LOG (stc_util_get_debuglog())
35
36 typedef enum {
37         STC_CANCEL = 0,    /**< cancel */
38         STC_CONTINUE = 1,  /**< continue */
39 } stc_cb_ret_e;
40
41 typedef enum {
42         STC_CMD_NONE,
43         STC_CMD_SET_FOREGRD,
44         STC_CMD_SET_BACKGRD,
45         STC_CMD_SET_APP_LAUNCHED,
46         STC_CMD_SET_SERVICE_LAUNCHED,
47         STC_CMD_SET_TERMINATED,
48         STC_CMD_MAX_ELEM
49 } stc_cmd_type_e;
50
51 /**
52  * @brief Monitored application types
53  */
54 typedef enum {
55         STC_APP_TYPE_NONE,
56         STC_APP_TYPE_READY,
57         STC_APP_TYPE_GUI,
58         STC_APP_TYPE_SERVICE,
59         STC_APP_TYPE_GROUP,
60         STC_APP_TYPE_WATCH,
61         STC_APP_TYPE_WIDGET,
62         STC_APP_TYPE_MAX,
63 } stc_app_type_e;
64
65 /**
66  * @brief State of the statisticsed process
67  */
68 typedef enum {
69         STC_APP_STATE_UNKNOWN = 0,
70         STC_APP_STATE_FOREGROUND = 1 << 1,  /** < foreground state */
71         STC_APP_STATE_BACKGROUND = 1 << 2,  /** < background state */
72         STC_APP_STATE_LAST_ELEM = 1 << 3
73 } stc_app_state_e;
74
75 /**
76  * @brief Network restriction states
77  */
78 typedef enum {
79         STC_RESTRICTION_UNKNOWN,
80         STC_RESTRICTION_ACTIVATED,  /** < restriction has been activated */
81         STC_RESTRICTION_REMOVED,    /** < restriction has been removed */
82         STC_RESTRICTION_EXCLUDED,   /** < restriction has been excluded */
83         STC_RESTRICTION_LAST_ELEM
84 } stc_restriction_state_e;
85
86 /**
87  * @brief Network restriction types
88  */
89 typedef enum {
90         STC_RSTN_TYPE_UNKNOWN,
91         STC_RSTN_TYPE_EXCLUDED,  /**< exclusion */
92         STC_RSTN_TYPE_BLOCKED,    /**< block */
93         STC_RSTN_TYPE_LAST_ELEM
94 } stc_rstn_type_e;
95
96 /**
97  * @brief Network interface types
98  */
99 typedef enum {
100         STC_IFACE_UNKNOWN,    /**< undefined iface */
101         STC_IFACE_DATACALL,   /**< mobile data */
102         STC_IFACE_WIFI,       /**< wifi data */
103         STC_IFACE_WIRED,      /**< wired interface */
104         STC_IFACE_BLUETOOTH,  /**< bluetooth interface */
105         STC_IFACE_IPV4,       /**< ipv4 interface */
106         STC_IFACE_IPV6,       /**< ipv6 interface */
107         STC_IFACE_ALL,        /**< enumerate all network interface types */
108         STC_IFACE_LAST_ELEM
109 } stc_iface_type_e;
110
111 /**
112  * @brief Network roaming type
113  */
114 typedef enum {
115         STC_ROAMING_UNKNOWN,   /**< can't define roaming - roaming unknown */
116         STC_ROAMING_ENABLE,    /**< in roaming */
117         STC_ROAMING_DISABLE,   /**< not in roaming */
118         STC_ROAMING_LAST_ELEM,
119 } stc_roaming_type_e;
120
121 /**
122  * @brief Hardware network protocol types
123  */
124 typedef enum {
125         STC_PROTOCOL_NONE,                /**< Network unknown */
126         STC_PROTOCOL_DATACALL_NOSVC,      /**< Network no service */
127         STC_PROTOCOL_DATACALL_EMERGENCY,  /**< Network emergency */
128         STC_PROTOCOL_DATACALL_SEARCH,     /**< Network search 1900 */
129         STC_PROTOCOL_DATACALL_2G,         /**< Network 2G */
130         STC_PROTOCOL_DATACALL_2_5G,       /**< Network 2.5G */
131         STC_PROTOCOL_DATACALL_2_5G_EDGE,  /**< Network EDGE */
132         STC_PROTOCOL_DATACALL_3G,         /**< Network UMTS */
133         STC_PROTOCOL_DATACALL_HSDPA,      /**< Network HSDPA */
134         STC_PROTOCOL_DATACALL_LTE,        /**< Network LTE */
135         STC_PROTOCOL_MAX_ELEM
136 } stc_hw_net_protocol_type_e;
137
138 /**
139  * @desc Description of the boolean option for enabling/disabling
140  *     network interfaces and enabling/disabling some behaviar
141  */
142 typedef enum {
143         STC_DB_OPTION_UNDEF,
144         STC_DB_OPTION_ENABLE,
145         STC_DB_OPTION_DISABLE
146 } stc_option_state_e;
147
148 /**
149  * @desc Set of the options.
150  * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
151  * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
152  * datausage_timer - set period of the updating data from the kernel,
153  *     0 to leave option as is
154  * datacall_logging - enable/disable datacall_logging,
155  *     STC_DB_OPTION_UNDEF to leave option as is
156  */
157 typedef struct {
158         stc_option_state_e wifi;
159         stc_option_state_e datacall;
160         time_t datausage_timer;
161         stc_option_state_e datacall_logging;
162 } stc_options_s;
163
164 /**
165  * @brief datausage in bytes
166  */
167 typedef struct {
168         int64_t in_bytes;  /**< incoming bytes */
169         int64_t out_bytes;  /**< outgoing bytes */
170 } stc_data_counter_s;
171
172 typedef struct {
173         GMainLoop *main_loop;
174
175         gpointer statistics_obj;
176         gpointer restriction_obj;
177         gpointer manager_obj;
178
179         GDBusObjectManagerServer *obj_mgr;
180         GDBusConnection *connection;
181         guint gdbus_owner_id;
182
183         void *system; /* stc_system_s */
184         struct counter_arg *carg;
185 } stc_s;
186
187 stc_s *stc_get_manager(void);
188 void stc_stop_manager(void);
189
190 #endif /* __STC_MANAGER__ */