2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "stc-manager.h"
22 #define MAX_DB_RETRY_COUNT 20
23 #define MAX_USLEEP_TIMEOUT 500000
24 #define SQLITE_BUSY_TIMEOUT 500000
25 #define MAX_IFACE_LENGTH 32
28 * @brief Commulative structure for holding stc storage information
31 stc_data_counter_s cnt;
32 // stc_db_net_restrictions rst;
38 } stc_db_tm_interval_s;
41 STC_DB_CON_PERIOD_UNKNOWN, /**< Undefined period */
42 STC_DB_CON_PERIOD_LAST_RECEIVED_DATA, /**< Last received data */
43 STC_DB_CON_PERIOD_LAST_SENT_DATA, /**< Last sent data */
44 STC_DB_CON_PERIOD_TOTAL_RECEIVED_DATA, /**< Total received data */
45 STC_DB_CON_PERIOD_TOTAL_SENT_DATA, /**< Total sent data */
46 STC_DB_CON_PERIOD_LAST_ELEM
47 } stc_db_connection_period_type;
50 * General structure containing information for storing
51 * app_id - package name as unique application identifier
52 * snd_count - sent bytes
53 * rcv_count - received bytes
54 * pid - process identifier
55 * ifindex - network interface index, iftype holds in key @see stc_iface_type
56 * is_roaming - is traffic consumed at roaming, @see stc_roaming_type
60 unsigned int snd_count;
61 unsigned int rcv_count;
62 unsigned int delta_snd;
63 unsigned int delta_rcv;
65 #ifndef CONFIG_DATAUSAGE_NFACCT
69 stc_roaming_type_e is_roaming;
71 /* foreground/background state is here,
72 * not in classid_iftype_key, it means
73 * we'll not able to handle simultaneously
74 * counter per one application for background and
75 * foreground within one counting cycle,
76 * so every time application goes to background/foreground
77 * we'll request its counter update */
78 stc_app_state_e ground;
84 /* pointer to telephony's imsi */
86 char ifname[MAX_IFACE_LENGTH];
87 } stc_db_classid_iftype_key;
90 * @desc This funciton init db oversize erase timer.
92 stc_error_e stc_init_db_guard(void);
95 * @desc This funciton deinit db oversize erase timer.
97 void stc_deinit_db_guard(void);
100 * @desc This funciton initializes storage module.
102 gboolean stc_db_initialize(void);
105 * @desc This funciton deinitializes storage module.
107 gboolean stc_db_deinitialize(void);
109 #endif /* _STC_DB_H_ */