comp-manager: Add new method to store ref count of applications
[platform/core/api/multi-device-group.git] / src / companion-manager / include / comp_context.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
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
18 #ifndef __COMP_CONTEXT_H__
19 #define __COMP_CONTEXT_H__
20
21 #include <glib.h>
22 #include <comp_log.h>
23 #include <unistd.h>
24 #include <gio/gio.h>
25 #include <companion_gdbus.h>
26 #include <sys/types.h>
27 #include <sqlite3.h>
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 typedef struct {
35         GMainLoop *main_loop;
36         //GDBusConnection *connection;
37         int ref_count;
38
39         // resource list
40         GList *resource_list[COMP_RESOURCE_TYPE_MAX];
41
42         char *device_uuid;
43         bool mot_me; /**< Indicator whether mot local comp-manager */
44         GList *grp_list;
45         GList *pairwise_list;
46
47         //sqlite3 db
48         sqlite3 *db;
49 } comp_context_t;
50
51 typedef struct {
52         char *conn_name;
53         int conn_id;
54         GDBusConnection *connection;
55 } comp_conn_destroy_data;
56
57 int comp_context_create();
58 int comp_context_destroy();
59 void comp_context_mutex_lock();
60 void comp_context_mutex_unlock();
61
62 comp_context_t *comp_context_get_context();
63
64 #ifdef __cplusplus
65 }
66 #endif
67 #endif /* __COMP_CONTEXT_H__ */