add db column and APIs for app info
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_basic.c
1 #include <stdlib.h>
2
3 #include "pkgmgrinfo_basic.h"
4 #include "pkgmgrinfo_private.h"
5
6 static void __ps_free_metadata(gpointer data)
7 {
8         metadata_x *metadata = (metadata_x *)data;
9         if (metadata == NULL)
10                 return;
11         if (metadata->key)
12                 free((void *)metadata->key);
13         if (metadata->value)
14                 free((void *)metadata->value);
15         free((void*)metadata);
16 }
17
18 static void __ps_free_permission(gpointer data)
19 {
20         permission_x *permission = (permission_x *)data;
21         if (permission == NULL)
22                 return;
23         if (permission->type)
24                 free((void *)permission->type);
25         if (permission->value)
26                 free((void *)permission->value);
27         free((void*)permission);
28 }
29
30 static void __ps_free_icon(gpointer data)
31 {
32         icon_x *icon = (icon_x *)data;
33         if (icon == NULL)
34                 return;
35         if (icon->text)
36                 free((void *)icon->text);
37         if (icon->lang)
38                 free((void *)icon->lang);
39         if (icon->section)
40                 free((void *)icon->section);
41         if (icon->size)
42                 free((void *)icon->size);
43         if (icon->resolution)
44                 free((void *)icon->resolution);
45         if (icon->dpi)
46                 free((void *)icon->dpi);
47         free((void*)icon);
48 }
49
50 static void __ps_free_image(gpointer data)
51 {
52         image_x *image = (image_x *)data;
53         if (image == NULL)
54                 return;
55         if (image->text)
56                 free((void *)image->text);
57         if (image->lang)
58                 free((void *)image->lang);
59         if (image->section)
60                 free((void *)image->section);
61         free((void*)image);
62 }
63
64 static void __ps_free_notification(gpointer data)
65 {
66         notification_x *notification = (notification_x *)data;
67         if (notification == NULL)
68                 return;
69         if (notification->text)
70                 free((void *)notification->text);
71         if (notification->name)
72                 free((void *)notification->name);
73         free((void*)notification);
74 }
75
76 static void __ps_free_compatibility(gpointer data)
77 {
78         compatibility_x *compatibility = (compatibility_x *)data;
79         if (compatibility == NULL)
80                 return;
81         if (compatibility->text)
82                 free((void *)compatibility->text);
83         if (compatibility->name)
84                 free((void *)compatibility->name);
85         free((void*)compatibility);
86 }
87
88 static void __ps_free_datacontrol(gpointer data)
89 {
90         datacontrol_x *datacontrol = (datacontrol_x *)data;
91         if (datacontrol == NULL)
92                 return;
93         if (datacontrol->providerid)
94                 free((void *)datacontrol->providerid);
95         if (datacontrol->access)
96                 free((void *)datacontrol->access);
97         if (datacontrol->type)
98                 free((void *)datacontrol->type);
99         free((void*)datacontrol);
100 }
101
102 static void __ps_free_appcontrol(gpointer data)
103 {
104         appcontrol_x *appcontrol = (appcontrol_x *)data;
105         if (appcontrol == NULL)
106                 return;
107         /*Free Operation*/
108         if (appcontrol->operation)
109                 free((void *)appcontrol->operation);
110         /*Free Uri*/
111         if (appcontrol->uri)
112                 free((void *)appcontrol->uri);
113         /*Free Mime*/
114         if (appcontrol->mime)
115                 free((void *)appcontrol->mime);
116         free((void*)appcontrol);
117 }
118
119 static void __ps_free_define(gpointer data)
120 {
121         define_x *define = (define_x *)data;
122
123         if (define == NULL)
124                 return;
125         if (define->path)
126                 free((void *)define->path);
127         /*Free Request*/
128         g_list_free_full(define->request, free);
129         /*Free Allowed*/
130         g_list_free_full(define->allowed, free);
131         free((void*)define);
132 }
133
134 static void __ps_free_datashare(gpointer data)
135 {
136         datashare_x *datashare = (datashare_x *)data;
137         if (datashare == NULL)
138                 return;
139         /*Free Define*/
140         g_list_free_full(datashare->define, __ps_free_define);
141         /*Free Request*/
142         g_list_free_full(datashare->request, free);
143         free((void*)datashare);
144 }
145
146 static void __ps_free_label(gpointer data)
147 {
148         label_x *label = (label_x *)data;
149         if (label == NULL)
150                 return;
151         if (label->name)
152                 free((void *)label->name);
153         if (label->text)
154                 free((void *)label->text);
155         if (label->lang)
156                 free((void *)label->lang);
157         free((void*)label);
158 }
159
160 static void __ps_free_author(gpointer data)
161 {
162         author_x *author = (author_x *)data;
163         if (author == NULL)
164                 return;
165         if (author->email)
166                 free((void *)author->email);
167         if (author->text)
168                 free((void *)author->text);
169         if (author->href)
170                 free((void *)author->href);
171         if (author->lang)
172                 free((void *)author->lang);
173         free((void*)author);
174 }
175
176 static void __ps_free_description(gpointer data)
177 {
178         description_x *description = (description_x *)data;
179         if (description == NULL)
180                 return;
181         if (description->name)
182                 free((void *)description->name);
183         if (description->text)
184                 free((void *)description->text);
185         if (description->lang)
186                 free((void *)description->lang);
187         free((void*)description);
188 }
189
190 static void __ps_free_license(gpointer data)
191 {
192         license_x *license = (license_x *)data;
193         if (license == NULL)
194                 return;
195         if (license->text)
196                 free((void *)license->text);
197         if (license->lang)
198                 free((void *)license->lang);
199         free((void*)license);
200 }
201
202 static void __ps_free_splashscreen(gpointer data)
203 {
204         splashscreen_x *splashscreen = (splashscreen_x *)data;
205         if (splashscreen == NULL)
206                 return;
207         if (splashscreen->src)
208                 free((void *)splashscreen->src);
209         if (splashscreen->type)
210                 free((void *)splashscreen->type);
211         if (splashscreen->dpi)
212                 free((void *)splashscreen->dpi);
213         if (splashscreen->orientation)
214                 free((void *)splashscreen->orientation);
215         if (splashscreen->indicatordisplay)
216                 free((void *)splashscreen->indicatordisplay);
217         if (splashscreen->operation)
218                 free((void *)splashscreen->operation);
219         if (splashscreen->color_depth)
220                 free((void *)splashscreen->color_depth);
221         free((void *)splashscreen);
222 }
223
224 /* FIXME */
225 static void __ps_free_support_size(gpointer data)
226 {
227         support_size_x *support_size = (support_size_x *)data;
228         if (support_size == NULL)
229                 return;
230         if (support_size->preview)
231                 free((void *)support_size->preview);
232         if (support_size->size)
233                 free((void *)support_size->size);
234         free((void *)support_size);
235 }
236
237 static void __ps_free_privilege(gpointer data)
238 {
239         privilege_x *privilege = (privilege_x *)data;
240         if (privilege->type)
241                 free((void *)privilege->type);
242         if (privilege->value)
243                 free((void *)privilege->value);
244         free((void *)privilege);
245 }
246
247 static void __ps_free_application(gpointer data)
248 {
249         application_x *application = (application_x *)data;
250         if (application == NULL)
251                 return;
252
253         if (application->appid)
254                 free((void *)application->appid);
255         if (application->component)
256                 free((void *)application->component);
257         if (application->exec)
258                 free((void *)application->exec);
259         if (application->nodisplay)
260                 free((void *)application->nodisplay);
261         if (application->type)
262                 free((void *)application->type);
263         if (application->onboot)
264                 free((void *)application->onboot);
265         if (application->multiple)
266                 free((void *)application->multiple);
267         if (application->autorestart)
268                 free((void *)application->autorestart);
269         if (application->taskmanage)
270                 free((void *)application->taskmanage);
271         if (application->enabled)
272                 free((void *)application->enabled);
273         if (application->categories)
274                 free((void *)application->categories);
275         if (application->extraid)
276                 free((void *)application->extraid);
277         if (application->hwacceleration)
278                 free((void *)application->hwacceleration);
279         if (application->screenreader)
280                 free((void *)application->screenreader);
281         if (application->mainapp)
282                 free((void *)application->mainapp);
283         if (application->recentimage)
284                 free((void *)application->recentimage);
285         if (application->launchcondition)
286                 free((void *)application->launchcondition);
287         if (application->indicatordisplay)
288                 free((void *)application->indicatordisplay);
289         if (application->portraitimg)
290                 free((void *)application->portraitimg);
291         if (application->landscapeimg)
292                 free((void *)application->landscapeimg);
293         if (application->guestmode_visibility)
294                 free((void *)application->guestmode_visibility);
295         if (application->permission_type)
296                 free((void *)application->permission_type);
297         if (application->preload)
298                 free((void *)application->preload);
299         if (application->submode)
300                 free((void *)application->submode);
301         if (application->submode_mainid)
302                 free((void *)application->submode_mainid);
303         if (application->process_pool)
304                 free((void *)application->process_pool);
305         if (application->installed_storage)
306                 free((void *)application->installed_storage);
307         if (application->launch_mode)
308                 free((void *)application->launch_mode);
309         if (application->ui_gadget)
310                 free((void *)application->ui_gadget);
311         if (application->component_type)
312                 free((void *)application->component_type);
313         if (application->package)
314                 free((void *)application->package);
315         if (application->support_disable)
316                 free((void *)application->support_disable);
317         if (application->tep_name)
318                 free((void *)application->tep_name);
319         if (application->zip_mount_file)
320                 free((void *)application->zip_mount_file);
321         if (application->root_path)
322                 free((void *)application->root_path);
323         if (application->api_version)
324                 free((void *)application->api_version);
325         if (application->for_all_users)
326                 free((void *)application->for_all_users);
327         if (application->effective_appid)
328                 free((void *)application->effective_appid);
329         if (application->is_disabled)
330                 free((void *)application->is_disabled);
331         if (application->splash_screen_display)
332                 free((void *)application->splash_screen_display);
333         if (application->effectimage_type)
334                 free((void *)application->effectimage_type);
335         if (application->package_type)
336                 free((void *)application->package_type);
337         if (application->ambient_support)
338                 free((void *)application->ambient_support);
339         if (application->alias_appid)
340                 free((void *)application->alias_appid);
341         if (application->external_path)
342                 free((void *)application->external_path);
343         if (application->package_system)
344                 free((void *)application->package_system);
345         if (application->removable)
346                 free((void *)application->removable);
347         if (application->package_installed_time)
348                 free((void *)application->package_installed_time);
349
350         /*Free Label*/
351         g_list_free_full(application->label, __ps_free_label);
352         /*Free Icon*/
353         g_list_free_full(application->icon, __ps_free_icon);
354         /*Free image*/
355         g_list_free_full(application->image, __ps_free_image);
356         /*Free AppControl*/
357         g_list_free_full(application->appcontrol, __ps_free_appcontrol);
358         /*Free Category*/
359         g_list_free_full(application->category, free);
360         /*Free Metadata*/
361         g_list_free_full(application->metadata, __ps_free_metadata);
362         /*Free permission*/
363         g_list_free_full(application->permission, __ps_free_permission);
364         /*Free LaunchConditions*/
365         g_list_free_full(application->launchconditions, free);
366         /*Free Notification*/
367         g_list_free_full(application->notification, __ps_free_notification);
368         /*Free DataShare*/
369         g_list_free_full(application->datashare, __ps_free_datashare);
370         /*Free DataControl*/
371         g_list_free_full(application->datacontrol, __ps_free_datacontrol);
372         /*Free BackgroundCategory*/
373         g_list_free_full(application->background_category, free);
374         /*Free SplashScreen*/
375         g_list_free_full(application->splashscreens, __ps_free_splashscreen);
376         /* FIXME */
377         g_list_free_full(application->support_sizes, __ps_free_support_size);
378
379         free((void *)application);
380 }
381
382 API void pkgmgrinfo_basic_free_application(application_x *application)
383 {
384         __ps_free_application(application);
385 }
386
387 API void pkgmgrinfo_basic_free_package(package_x *package)
388 {
389         if (package == NULL)
390                 return;
391         if (package->for_all_users)
392                 free((void *)package->for_all_users);
393         if (package->ns)
394                 free((void *)package->ns);
395         if (package->package)
396                 free((void *)package->package);
397         if (package->version)
398                 free((void *)package->version);
399         if (package->installlocation)
400                 free((void *)package->installlocation);
401         if (package->preload)
402                 free((void *)package->preload);
403         if (package->readonly)
404                 free((void *)package->readonly);
405         if (package->removable)
406                 free((void *)package->removable);
407         if (package->update)
408                 free((void *)package->update);
409         if (package->system)
410                 free((void *)package->system);
411         if (package->type)
412                 free((void *)package->type);
413         if (package->package_size)
414                 free((void *)package->package_size);
415         if (package->installed_time)
416                 free((void *)package->installed_time);
417         if (package->installed_storage)
418                 free((void *)package->installed_storage);
419         if (package->storeclient_id)
420                 free((void *)package->storeclient_id);
421         if (package->mainapp_id)
422                 free((void *)package->mainapp_id);
423         if (package->package_url)
424                 free((void *)package->package_url);
425         if (package->root_path)
426                 free((void *)package->root_path);
427         if (package->csc_path)
428                 free((void *)package->csc_path);
429         if (package->appsetting)
430                 free((void *)package->appsetting);
431         if (package->nodisplay_setting)
432                 free((void *)package->nodisplay_setting);
433         if (package->api_version)
434                 free((void *)package->api_version);
435         if (package->support_disable)
436                 free((void *)package->support_disable);
437         if (package->tep_name)
438                 free((void *)package->tep_name);
439         if (package->zip_mount_file)
440                 free((void *)package->zip_mount_file);
441         if (package->external_path)
442                 free((void *)package->external_path);
443
444         /*Free Icon*/
445         g_list_free_full(package->icon, __ps_free_icon);
446         /*Free Label*/
447         g_list_free_full(package->label, __ps_free_label);
448         /*Free Author*/
449         g_list_free_full(package->author, __ps_free_author);
450         /*Free Description*/
451         g_list_free_full(package->description, __ps_free_description);
452         /*Free License*/
453         g_list_free_full(package->license, __ps_free_license);
454         /*Free Privileges*/
455         g_list_free_full(package->privileges, __ps_free_privilege);
456         /*Free Application*/
457         g_list_free_full(package->application, __ps_free_application);
458         /*Free Compatibility*/
459         g_list_free_full(package->compatibility, __ps_free_compatibility);
460         /*Free Device profiles*/
461         g_list_free_full(package->deviceprofile, free);
462         free((void*)package);
463         return;
464 }
465