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