#include <glib.h>
#include "stc-error.h"
#include "stc-manager.h"
-#include "stc-restriction.h"
#include "stc-manager-util.h"
-#include "table-restrictions.h"
+#include "stc-monitor-context.h"
+#include "stc-monitor-app.h"
+#include "stc-monitor-proc.h"
+#include "stc-monitor-rstn.h"
#include "helper-nl.h"
/* 1 seconds */
#define CONTR_TIMER_INTERVAL 1
-#define MAC_ADDRESS_LEN 18
-/**
- * @brief enumeration for data limit types
- */
-typedef enum {
- STC_RSTN_LIMIT_TYPE_DATA_WARN,
- STC_RSTN_LIMIT_TYPE_DATA,
- STC_RSTN_LIMIT_TYPE_MONTHLY,
- STC_RSTN_LIMIT_TYPE_WEEKLY,
- STC_RSTN_LIMIT_TYPE_DAILY,
- STC_RSTN_LIMIT_TYPE_MAX
-} stc_rstn_limit_type_e;
-
-typedef enum {
- STC_RSTN_STATE_INIT = -1,
- STC_RSTN_STATE_UNSET,
- STC_RSTN_STATE_SET,
-} stc_rstn_noti_state_e;
+#ifndef VCONFKEY_STC_BACKGROUND_STATE
+#define VCONFKEY_STC_BACKGROUND_STATE "db/stc/background_state"
+#endif
-/**
- * @brief key for processes tree
- */
-typedef struct {
- stc_app_state_e ground; /**< application state foreground/background */
-} stc_process_value_s;
+#ifndef VCONFKEY_SETAPPL_DATA_RESTRICTION_INT
+#define VCONFKEY_SETAPPL_DATA_RESTRICTION_INT "db/setting/data_restriction"
+#endif
/**
- * @brief value for processes tree
+ * @brief initializes stc monitor module
*/
-typedef struct {
- pid_t pid; /**< process id */
-} stc_process_key_s;
+stc_error_e stc_monitor_init(void);
/**
- * @brief key for apps tree
+ * @brief deinitializes stc monitor module
*/
-typedef struct {
- gchar *pkg_id; /**< package id */
- gchar *app_id; /**< application id */
-} stc_app_key_s;
+stc_error_e stc_monitor_deinit(void);
-/**
- * @brief value for apps tree
- */
-typedef struct {
- uint32_t classid; /**< classid for a package */
- stc_app_type_e type; /**< type of application */
- stc_data_counter_s data_usage;
- stc_data_counter_s counter;
- GTree *processes; /**< applications instances */
- char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */
-} stc_app_value_s;
+GHashTable *stc_monitor_get_system_apps(void);
-/**
- * @brief key for rstn_rules tree
- */
-typedef struct {
- gchar *app_id;
- gchar *ifname;
- gchar *mac;
- gchar *subscriber_id;
- stc_iface_type_e iftype;
- stc_roaming_type_e roaming;
-} stc_rstn_key_s;
+GHashTable *stc_monitor_get_system_rstns(void);
-/**
- * @brief value for rstn_rules tree
- */
-typedef struct {
- uint64_t restriction_id;
- uint32_t classid;
- stc_rstn_state_e rstn_state;
- stc_rstn_type_e rstn_type;
+int stc_monitor_get_contr_sock(void);
- int64_t counter[STC_RSTN_LIMIT_TYPE_MAX];
- int64_t limit[STC_RSTN_LIMIT_TYPE_MAX];
- int32_t limit_exceeded;
- int32_t limit_notified;
+time_t stc_monitor_get_last_month_ts(void);
- int month_start_date;
- time_t month_start_ts;
-} stc_rstn_value_s;
+void stc_monitor_set_last_month_ts(time_t time);
-/**
- * @brief structure to store system info
- */
-typedef struct {
- int contr_sock; /**< socket used for getting kernel counters */
- guint contr_timer_id; /**< timer id for periodically getting kernel counters */
- guint contr_gsource_id;
- stc_data_counter_s du_curr; /**< current data usage */
- GTree *rstns; /**< restriction rules */
- gboolean rstns_tree_updated;
- GTree *apps; /**< monitored applications */
- gboolean apps_tree_updated;
- guint background_state;
- time_t last_month_ts;
- time_t last_week_ts;
- time_t last_day_ts;
- int month_start_date;
-} stc_system_s;
+time_t stc_monitor_get_last_week_ts(void);
-/**
- * @brief initializes stc monitor module
- */
-stc_error_e stc_monitor_init(void);
+void stc_monitor_set_last_week_ts(time_t time);
-/**
- * @brief deinitializes stc monitor module
- */
-stc_error_e stc_monitor_deinit(void);
+time_t stc_monitor_get_last_day_ts(void);
-/**
- * @brief creates an application entry
- */
-stc_error_e stc_monitor_application_add(const stc_app_key_s app_key,
- const stc_app_value_s app_value);
+void stc_monitor_set_last_day_ts(time_t time);
-/**
- * @brief deletes an application entry
- */
-stc_error_e stc_monitor_application_remove(const stc_app_key_s app_key);
+void stc_monitor_set_rstns_updated(gboolean value);
-/**
- * @brief associates process to an application
- */
-stc_error_e stc_monitor_process_add(const stc_app_key_s app_key,
- const stc_process_key_s proc_key,
- const stc_process_value_s proc_value);
+gboolean stc_monitor_get_rstns_updated(void);
-/**
- * @brief removes associated process from respective application
- */
-stc_error_e stc_monitor_process_remove(pid_t pid);
+void stc_monitor_set_apps_updated(gboolean value);
-/**
- * @brief updates process's ground attribute
- */
-stc_error_e stc_monitor_process_update_ground(const stc_app_key_s app_key,
- const stc_process_key_s proc_key,
- stc_app_state_e ground);
+gboolean stc_monitor_get_apps_updated(void);
-void stc_monitor_update_rstn_by_default_connection(void *default_connection);
+void stc_monitor_set_background_state(gboolean value);
-stc_error_e stc_monitor_rstns_tree_add(const table_restrictions_info *info);
+gboolean stc_monitor_get_background_state(void);
-stc_error_e stc_monitor_rstns_tree_remove(const table_restrictions_info *info);
+void stc_monitor_update_by_default_connection(void *data);
stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline);
-int stc_monitor_get_counter_socket(void);
-
#endif /* __STC_MONITOR_H__ */