[Prevent] Logically dead code
[platform/core/telephony/telephony-daemon.git] / src / monitor.c
1 /*
2  * telephony-daemon
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Ja-young Gu <jygu@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <stdio.h>
22 #include <string.h>
23 #include <pthread.h>
24 #include <unistd.h>
25 #include <stdlib.h>
26 #include <time.h>
27 #include <dlfcn.h>
28 #include <getopt.h>
29
30 #include <glib.h>
31 #include <glib-object.h>
32
33 #include <tcore.h>
34 #include <plugin.h>
35 #include <server.h>
36 #include <hal.h>
37 #include <queue.h>
38 #include <storage.h>
39 #include <communicator.h>
40 #include <user_request.h>
41
42 #include "monitor.h"
43
44 /* Hacking TcoreQueue */
45 struct tcore_queue_type {
46         TcorePlugin *plugin;
47         GQueue *gq;
48 };
49
50 static void _monitor_plugin(Server *s)
51 {
52         GSList *list;
53         TcorePlugin *p;
54         char *str;
55
56         msg("-- Plugins --");
57
58         list = tcore_server_ref_plugins(s);
59         if (list == NULL)
60                 return;
61
62         do {
63                 p = list->data;
64
65                 msg("Name: [%s]", tcore_plugin_get_description(p)->name);
66
67                 str = tcore_plugin_get_filename(p);
68                 msg(" - file: %s", str);
69                 if (str)
70                         free(str);
71
72                 msg(" - addr: %p", p);
73                 msg(" - userdata: %p", tcore_plugin_ref_user_data(p));
74                 msg("");
75
76
77                 list = list->next;
78         } while (list);
79 }
80
81 static void _monitor_storage(Server *s)
82 {
83         GSList *list;
84         Storage *strg;
85
86         msg("-- Storages --");
87
88         list = tcore_server_ref_storages(s);
89         if (list == NULL)
90                 return;
91
92         do {
93                 strg = list->data;
94
95                 msg("Name: [%s]", tcore_storage_ref_name(strg));
96                 msg(" - addr: %p", strg);
97                 msg("");
98
99                 list = list->next;
100         } while (list);
101 }
102
103 static void _monitor_communicator(Server *s)
104 {
105         GSList *list;
106         Communicator *comm;
107
108         msg("-- Communicators --");
109
110         list = tcore_server_ref_communicators(s);
111         if (list == NULL)
112                 return;
113
114         do {
115                 comm = list->data;
116
117                 msg("Name: [%s]", tcore_communicator_ref_name(comm));
118                 msg(" - addr: %p", comm);
119                 msg(" - parent_plugin: %p", tcore_communicator_ref_plugin(comm));
120                 msg(" - userdata: %p", tcore_communicator_ref_user_data(comm));
121                 msg("");
122
123                 list = list->next;
124         } while (list);
125 }
126
127 static void _monitor_modems(Server *s)
128 {
129         GSList *list;
130         TcorePlugin *p;
131
132         msg("-- Modems --");
133
134         list = tcore_server_ref_plugins(s);
135         if (list == NULL)
136                 return;
137
138         for (; list != NULL; list = g_slist_next(list)) {
139                 p = list->data;
140                 if (p == NULL)
141                         continue;
142
143                 tcore_server_print_modems(p);
144         }
145 }
146
147 void monitor_server_state(Server *s)
148 {
149         _monitor_plugin(s);
150         _monitor_storage(s);
151         _monitor_communicator(s);
152         _monitor_modems(s);
153 }