[STC Manager] Support set/get for total data usage(Tx + Rx) in restriction.
[platform/core/connectivity/stc-manager.git] / src / database / include / table-statistics.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 __TABLE_STATISTICS_H__
18 #define __TABLE_STATISTICS_H__
19
20 typedef struct {
21         char *app_id;
22         char *ifname;
23         char *imsi;
24         stc_iface_type_e iftype;
25         stc_db_tm_interval_s *interval;
26         stc_data_counter_s cnt;
27         stc_roaming_type_e roaming;
28         stc_hw_net_protocol_type_e hw_net_protocol_type;
29         stc_app_state_e ground;
30 } table_statistics_info;
31
32 typedef struct {
33         unsigned char version;
34         char *app_id;
35         char *imsi;
36         stc_iface_type_e iftype;
37         stc_db_tm_interval_s *interval;
38         stc_db_connection_period_type connection_state;
39 } table_statistics_reset_rule;
40
41 typedef struct {
42         unsigned char version;
43         time_t from;
44         time_t to;
45         stc_iface_type_e iftype;
46         int granularity;
47 } table_statistics_select_rule;
48
49 typedef stc_cb_ret_e
50 (*table_statistics_info_cb)(const table_statistics_info *info, void *user_data);
51
52 stc_error_e table_statistics_reset_first_n_entries(int num);
53
54 stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule);
55
56 stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rule,
57                                          table_statistics_info_cb info_cb,
58                                          void *user_data);
59
60 stc_error_e table_statistics_per_app(const char *app_id,
61                                      table_statistics_select_rule *rule,
62                                      table_statistics_info_cb info_cb,
63                                      void *user_data);
64
65 stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
66                                     stc_db_app_stats *stat,
67                                     time_t last_touch_time);
68
69 stc_error_e table_statistics_prepare(sqlite3 *db);
70
71 void table_statistics_finalize(void);
72
73 #endif /*__TABLE_STATISTICS_H__ */