Refactoring structures for monitoring and restrictions
[platform/core/connectivity/stc-manager.git] / src / monitor / include / stc-monitor.h
index ee2213f..8fa8bc9 100755 (executable)
 #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
 
-/* 1 day */
-#define EXCNS_TIMER_INTERVAL 86400
+#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 */
-} 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 *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_restriction_state_e rst_state;
-       int64_t data_limit;
-       int64_t data_warn_limit;
-       int64_t data_counter;
-       gboolean data_limit_reached;
-       gboolean warn_limit_crossed_notified;
-       gboolean rstn_limit_crossed_notified;
-} stc_rstn_value_s;
+int stc_monitor_get_contr_sock(void);
 
-/**
- * @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;
-       GHashTable *excns_hash;  /**< exception hash table */
-       guint excns_timer_id;
-       guint background_state;
-} stc_system_s;
+time_t stc_monitor_get_last_month_ts(void);
 
-/**
- * @brief initializes stc monitor module
- */
-stc_error_e stc_monitor_init(void);
+void stc_monitor_set_last_month_ts(time_t time);
 
-/**
- * @brief deinitializes stc monitor module
- */
-stc_error_e stc_monitor_deinit(void);
+time_t stc_monitor_get_last_week_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_week_ts(time_t time);
 
-/**
- * @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);
+time_t stc_monitor_get_last_day_ts(void);
 
-/**
- * @brief removes associated process from respective application
- */
-stc_error_e stc_monitor_process_remove(pid_t pid);
+void stc_monitor_set_last_day_ts(time_t time);
 
-/**
- * @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);
+void stc_monitor_set_rstns_updated(gboolean value);
+
+gboolean stc_monitor_get_rstns_updated(void);
+
+void stc_monitor_set_apps_updated(gboolean value);
 
-void stc_monitor_update_rstn_by_default_connection(void *default_connection);
+gboolean stc_monitor_get_apps_updated(void);
 
-stc_error_e stc_monitor_rstns_tree_add(const table_restrictions_info *info);
+void stc_monitor_set_background_state(gboolean value);
 
-stc_error_e stc_monitor_rstns_tree_remove(const table_restrictions_info *info);
+gboolean stc_monitor_get_background_state(void);
 
-stc_error_e stc_monitor_check_excn_by_app_id(char *app_id);
+void stc_monitor_update_by_default_connection(void *data);
 
-int stc_monitor_get_counter_socket(void);
+stc_error_e stc_monitor_check_excn_by_cmdline(char *cmdline);
 
 #endif /* __STC_MONITOR_H__ */