report-json-serializer: app and top serializers
[apps/native/ttsd-worker-task.git] / src / appinfo-provider.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 __APPINFO_PROVIDER_H_
18 #define __APPINFO_PROVIDER_H_
19
20 #include "report.h"
21 #include <stdbool.h>
22
23 /**
24  * @brief Iterator used to obtain all running apps.
25  */
26 typedef struct app_info_iterator app_info_iterator_t;
27
28 /**
29  * @brief Go to next element of iterator.
30  * @param[in] iter Iterator struct.
31  */
32 bool app_info_iterator_next(app_info_iterator_t *iter);
33
34 /**
35  * @brief Gets app id from iterator.
36  * @param[in] iter Iterator struct.
37  */
38 const char *app_info_iterator_get_app_id(app_info_iterator_t *iter);
39
40 /**
41  * @brief Gets pid of app from iterator.
42  * @param[in] iter Iterator struct.
43  */
44 int app_info_iterator_get_pid(app_info_iterator_t *iter);
45
46 /**
47  * @brief Frees resource used by iterator.
48  * @param[in] iter Iterator struct.
49  */
50 void app_info_iterator_free(app_info_iterator_t *iter);
51
52 /**
53  * @brief Returns list of running Tizen applications.
54  *
55  * @return app_info_iterator, NULL when no apps are running or on error.
56  *
57  * @remark function is thread safe
58  * @remark returned value should be released with @app_info_iterator_free
59  */
60 app_info_iterator_t *app_info_provider_get_running_applications();
61
62 /**
63  * @brief Searches Tizen applications main process id.
64  *
65  * @return pid (>0) on success, -1 if app_id was not found
66  *
67  * @remark function is thread safe
68  * @remark app_provide_init should be called beforehead
69  */
70 int app_info_provider_find_main_pid(const char *app_id);
71
72 /**
73  * @brief Searches for Tizen application app_id with given pid.
74  *
75  * @return app_id, NULL on if pid was not found or not owned by any Tizen application
76  *
77  * @remark function is thread safe
78  * @remark app_provide_init should be called beforehead
79  * @remark the returned value should be released with @free
80  */
81 char *app_info_provider_find_app_id(int pid);
82
83 /**
84  * @brief Initializes app provider internals
85  *
86  * @return 0 on success, other value on error.
87  */
88 int app_provider_init();
89
90 /**
91  * @brief Shutdowns app provider internals
92  */
93 void app_provider_shutdown();
94
95 #endif