3a312fb767b8e2748cb429105b18c6d2f984edbc
[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-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_app_state_e state;
36         stc_data_counter_s data_usage;
37         stc_data_counter_s counter;
38         GHashTable *processes;  /**< applications instances */
39         char mac[MAC_ADDRESS_LEN+1]; /**< application mac address */
40 } stc_app_value_s;
41
42 void stc_monitor_app_update_counter(stc_app_value_s *value,
43                                  classid_bytes_context_s *context);
44
45 void stc_monitor_app_update_iface_counter(classid_bytes_context_s *context);
46
47 gboolean stc_monitor_app_flush_stats_to_db(gpointer user_data);
48
49 stc_error_e stc_monitor_app_add(uint32_t classid,
50                                 const char *app_id,
51                                 const char *pkg_id,
52                                 const stc_app_value_s value);
53
54 void stc_monitor_app_add_by_iface(const char *app_id);
55
56 void stc_monitor_app_add_monitor(gpointer key,
57                                 gpointer value, gpointer data);
58
59 void stc_monitor_app_add_by_connection(stc_connection_s *conn);
60
61 void stc_monitor_app_add_accept(gpointer key,
62                                 gpointer value, gpointer data);
63
64 stc_error_e stc_monitor_app_remove(uint32_t classid, const char *app_id);
65
66 void stc_monitor_app_remove_monitor(gpointer key,
67                                 gpointer value, gpointer data);
68
69 void stc_monitor_app_remove_by_connection(stc_connection_s *conn);
70
71 void stc_monitor_app_remove_accept(gpointer key,
72                                 gpointer value, gpointer data);
73
74 gboolean stc_monitor_app_lookup(uint32_t classid);
75
76 GHashTable *stc_monitor_apps_init(void);
77
78 #endif /* __STC_MONITOR_APP_H__ */