17016a06a01e0bac6d03b7b36aaa85c422552e4d
[platform/core/connectivity/stc-manager.git] / src / monitor / include / stc-monitor-app.h
1 /*
2  * Copyright (c) 2017 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_MONITOR_APP_H__
18 #define __STC_MONITOR_APP_H__
19
20 #include <glib.h>
21
22 #include "stc-error.h"
23 #include "stc-manager.h"
24 #include "stc-monitor-context.h"
25 #include "stc-default-connection.h"
26
27 #define MAC_ADDRESS_LEN 18
28 #define SUBSCRIBERID_NONE "none_subid"
29
30 typedef struct {
31         uint32_t classid;  /**< classid for a package */
32         gchar *pkg_id;  /**< package id */
33         gchar *app_id;  /**< application id */
34         stc_app_type_e type;  /**< type of application */
35         stc_data_counter_s data_usage;
36         stc_data_counter_s counter;
37         GHashTable *processes;  /**< applications instances */
38         char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */
39 } stc_app_value_s;
40
41 void stc_monitor_app_update_counter(stc_app_value_s *value,
42                                  classid_bytes_context_s *context);
43
44 void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context);
45
46 gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data);
47
48 stc_error_e stc_monitor_app_add(uint32_t classid,
49                                 const char *app_id,
50                                 const char *pkg_id,
51                                 const stc_app_value_s value);
52
53 void stc_monitor_app_add_by_iface(const char *app_id);
54
55 void stc_monitor_app_add_monitor(gpointer key,
56                                 gpointer value, gpointer data);
57
58 void stc_monitor_app_add_by_connection(default_connection_s *conn);
59
60 stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id);
61
62 void stc_monitor_app_remove_monitor(gpointer key,
63                                 gpointer value, gpointer data);
64
65 void stc_monitor_app_remove_by_connection(default_connection_s *conn);
66
67 GHashTable *stc_monitor_apps_init(void);
68
69 #endif /* __STC_MONITOR_APP_H__ */