Merge "Added logic to monitor and restrict data usage per interface" into tizen
[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_TOTAL_DATACALL "TOTAL_DATACALL"
28 #define STC_TOTAL_WIFI "TOTAL_WIFI"
29 #define STC_TOTAL_BLUETOOTH "TOTAL_BLUETOOTH"
30
31 typedef enum {
32         STC_CANCEL = 0,    /**< cancel */
33         STC_CONTINUE = 1,  /**< continue */
34 } stc_cb_ret_e;
35
36 /**
37  * @brief Monitored application types
38  */
39 typedef enum {
40         STC_APP_TYPE_NONE,
41         STC_APP_TYPE_READY,
42         STC_APP_TYPE_GUI,
43         STC_APP_TYPE_SERVICE,
44         STC_APP_TYPE_GROUP,
45         STC_APP_TYPE_WATCH,
46         STC_APP_TYPE_WIDGET,
47         STC_APP_TYPE_MAX,
48 } stc_app_type_e;
49
50 /**
51  * @brief State of the statisticsed process
52  */
53 typedef enum {
54         STC_APP_STATE_UNKNOWN = 0,
55         STC_APP_STATE_FOREGROUND = 1 << 1,  /** < foreground state */
56         STC_APP_STATE_BACKGROUND = 1 << 2,  /** < background state */
57         STC_APP_STATE_LAST_ELEM = 1 << 3
58 } stc_app_state_e;
59
60 /**
61  * @brief Network restriction states
62  */
63 typedef enum {
64         STC_RESTRICTION_UNKNOWN,
65         STC_RESTRICTION_ACTIVATED,  /** < restriction has been activated */
66         STC_RESTRICTION_REMOVED,    /** < restriction has been removed */
67         STC_RESTRICTION_EXCLUDED,   /** < restriction has been excluded */
68         STC_RESTRICTION_LAST_ELEM
69 } stc_restriction_state_e;
70
71 /**
72  * @brief Network interface types
73  */
74 typedef enum {
75         STC_IFACE_UNKNOWN,    /**< undefined iface */
76         STC_IFACE_DATACALL,   /**< mobile data */
77         STC_IFACE_WIFI,       /**< wifi data */
78         STC_IFACE_WIRED,      /**< wired interface */
79         STC_IFACE_BLUETOOTH,  /**< bluetooth interface */
80         STC_IFACE_ALL,        /**< enumerate all network interface types */
81         STC_IFACE_LAST_ELEM
82 } stc_iface_type_e;
83
84 /**
85  * @brief Network roaming type
86  */
87 typedef enum {
88         STC_ROAMING_UNKNOWN,   /**< can't define roaming - roaming unknown */
89         STC_ROAMING_ENABLE,    /**< in roaming */
90         STC_ROAMING_DISABLE,   /**< not in roaming */
91         STC_ROAMING_LAST_ELEM,
92 } stc_roaming_type_e;
93
94 /**
95  * @brief Hardware network protocol types
96  */
97 typedef enum {
98         STC_PROTOCOL_NONE,                /**< Network unknown */
99         STC_PROTOCOL_DATACALL_NOSVC,      /**< Network no service */
100         STC_PROTOCOL_DATACALL_EMERGENCY,  /**< Network emergency */
101         STC_PROTOCOL_DATACALL_SEARCH,     /**< Network search 1900 */
102         STC_PROTOCOL_DATACALL_2G,         /**< Network 2G */
103         STC_PROTOCOL_DATACALL_2_5G,       /**< Network 2.5G */
104         STC_PROTOCOL_DATACALL_2_5G_EDGE,  /**< Network EDGE */
105         STC_PROTOCOL_DATACALL_3G,         /**< Network UMTS */
106         STC_PROTOCOL_DATACALL_HSDPA,      /**< Network HSDPA */
107         STC_PROTOCOL_DATACALL_LTE,        /**< Network LTE */
108         STC_PROTOCOL_MAX_ELEM
109 } stc_hw_net_protocol_type_e;
110
111 /**
112  * @desc Description of the boolean option for enabling/disabling
113  *     network interfaces and enabling/disabling some behaviar
114  */
115 typedef enum {
116         STC_DB_OPTION_UNDEF,
117         STC_DB_OPTION_ENABLE,
118         STC_DB_OPTION_DISABLE
119 } stc_option_state_e;
120
121 /**
122  * @desc Set of the options.
123  * version - contains structure version
124  * wifi - enable/disable wifi, STC_DB_OPTION_UNDEF to leave option as is
125  * datacall - enable/disable datacall, STC_DB_OPTION_UNDEF to leave option as is
126  * datausage_timer - set period of the updating data from the kernel,
127  *     0 to leave option as is
128  * datacall_logging - enable/disable datacall_logging,
129  *     STC_DB_OPTION_UNDEF to leave option as is
130  */
131 typedef struct {
132         unsigned char version;
133         stc_option_state_e wifi;
134         stc_option_state_e datacall;
135         time_t datausage_timer;
136         stc_option_state_e datacall_logging;
137 } stc_options_s;
138
139 /**
140  * @brief datausage in bytes
141  */
142 typedef struct {
143         int64_t in_bytes;  /**< incoming bytes */
144         int64_t out_bytes;  /**< outgoing bytes */
145 } stc_data_counter_s;
146
147 typedef struct {
148         GMainLoop *main_loop;
149
150         gpointer statistics_obj;
151         gpointer restriction_obj;
152
153         GDBusObjectManagerServer *obj_mgr;
154         GDBusConnection *connection;
155         guint gdbus_owner_id;
156
157         void *system; /* stc_system_s */
158         struct counter_arg *carg;
159 } stc_s;
160
161 stc_s *stc_get_manager(void);
162
163 #endif /* __STC_MANAGER__ */