Release version 0.28.2
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_basic.c
1 #include <stdlib.h>
2
3 #include "pkgmgrinfo_basic.h"
4
5 #ifndef API
6 #define API __attribute__ ((visibility("default")))
7 #endif
8
9 static void __ps_free_metadata(gpointer data)
10 {
11         metadata_x *metadata = (metadata_x *)data;
12
13         if (metadata == NULL)
14                 return;
15         if (metadata->key)
16                 free((void *)metadata->key);
17         if (metadata->value)
18                 free((void *)metadata->value);
19         free((void *)metadata);
20 }
21
22 static void __ps_free_permission(gpointer data)
23 {
24         permission_x *permission = (permission_x *)data;
25
26         if (permission == NULL)
27                 return;
28         if (permission->type)
29                 free((void *)permission->type);
30         if (permission->value)
31                 free((void *)permission->value);
32         free((void *)permission);
33 }
34
35 static void __ps_free_icon(gpointer data)
36 {
37         icon_x *icon = (icon_x *)data;
38
39         if (icon == NULL)
40                 return;
41         if (icon->text)
42                 free((void *)icon->text);
43         if (icon->lang)
44                 free((void *)icon->lang);
45         if (icon->section)
46                 free((void *)icon->section);
47         if (icon->size)
48                 free((void *)icon->size);
49         if (icon->resolution)
50                 free((void *)icon->resolution);
51         if (icon->dpi)
52                 free((void *)icon->dpi);
53         free((void *)icon);
54 }
55
56 static void __ps_free_image(gpointer data)
57 {
58         image_x *image = (image_x *)data;
59
60         if (image == NULL)
61                 return;
62         if (image->text)
63                 free((void *)image->text);
64         if (image->lang)
65                 free((void *)image->lang);
66         if (image->section)
67                 free((void *)image->section);
68         free((void *)image);
69 }
70
71 static void __ps_free_notification(gpointer data)
72 {
73         notification_x *notification = (notification_x *)data;
74
75         if (notification == NULL)
76                 return;
77         if (notification->text)
78                 free((void *)notification->text);
79         if (notification->name)
80                 free((void *)notification->name);
81         free((void *)notification);
82 }
83
84 static void __ps_free_compatibility(gpointer data)
85 {
86         compatibility_x *compatibility = (compatibility_x *)data;
87
88         if (compatibility == NULL)
89                 return;
90         if (compatibility->text)
91                 free((void *)compatibility->text);
92         if (compatibility->name)
93                 free((void *)compatibility->name);
94         free((void *)compatibility);
95 }
96
97 static void __ps_free_plugin_info(gpointer data)
98 {
99         plugin_x *plugin = (plugin_x *)data;
100
101         if (plugin == NULL)
102                 return;
103         if (plugin->pkgid)
104                 free((void *)plugin->pkgid);
105         if (plugin->appid)
106                 free((void *)plugin->appid);
107         if (plugin->plugin_type)
108                 free((void *)plugin->plugin_type);
109         if (plugin->plugin_name)
110                 free((void *)plugin->plugin_name);
111         free((void *)plugin);
112 }
113
114 static void __ps_free_res_allowed_packages(gpointer data)
115 {
116         res_allowed_package_x *allowed_package = (res_allowed_package_x *)data;
117
118         if (allowed_package == NULL)
119                 return;
120         g_list_free_full(allowed_package->required_privileges, free);
121         free((void *)allowed_package->allowed_package);
122         free((void *)allowed_package);
123 }
124
125 static void __ps_free_appcontrol(gpointer data)
126 {
127         appcontrol_x *appcontrol = (appcontrol_x *)data;
128
129         if (appcontrol == NULL)
130                 return;
131         /*Free Operation*/
132         if (appcontrol->operation)
133                 free((void *)appcontrol->operation);
134         /*Free Uri*/
135         if (appcontrol->uri)
136                 free((void *)appcontrol->uri);
137         /*Free Mime*/
138         if (appcontrol->mime)
139                 free((void *)appcontrol->mime);
140         /*Free Visibility*/
141         if (appcontrol->visibility)
142                 free((void *)appcontrol->visibility);
143         /*Free Id*/
144         if (appcontrol->id)
145                 free((void *)appcontrol->id);
146         /*Free Privileges*/
147         if (appcontrol->privileges)
148                 g_list_free_full(appcontrol->privileges, free);
149         free((void *)appcontrol);
150 }
151
152 static void __ps_free_define(gpointer data)
153 {
154         define_x *define = (define_x *)data;
155
156         if (define == NULL)
157                 return;
158         if (define->path)
159                 free((void *)define->path);
160         /*Free Request*/
161         g_list_free_full(define->request, free);
162         /*Free Allowed*/
163         g_list_free_full(define->allowed, free);
164         free((void *)define);
165 }
166
167 static void __ps_free_datashare(gpointer data)
168 {
169         datashare_x *datashare = (datashare_x *)data;
170
171         if (datashare == NULL)
172                 return;
173         /*Free Define*/
174         g_list_free_full(datashare->define, __ps_free_define);
175         /*Free Request*/
176         g_list_free_full(datashare->request, free);
177         free((void *)datashare);
178 }
179
180 static void __ps_free_label(gpointer data)
181 {
182         label_x *label = (label_x *)data;
183
184         if (label == NULL)
185                 return;
186         if (label->name)
187                 free((void *)label->name);
188         if (label->text)
189                 free((void *)label->text);
190         if (label->lang)
191                 free((void *)label->lang);
192         free((void *)label);
193 }
194
195 static void __ps_free_author(gpointer data)
196 {
197         author_x *author = (author_x *)data;
198
199         if (author == NULL)
200                 return;
201         if (author->email)
202                 free((void *)author->email);
203         if (author->text)
204                 free((void *)author->text);
205         if (author->href)
206                 free((void *)author->href);
207         if (author->lang)
208                 free((void *)author->lang);
209         free((void *)author);
210 }
211
212 static void __ps_free_description(gpointer data)
213 {
214         description_x *description = (description_x *)data;
215
216         if (description == NULL)
217                 return;
218         if (description->name)
219                 free((void *)description->name);
220         if (description->text)
221                 free((void *)description->text);
222         if (description->lang)
223                 free((void *)description->lang);
224         free((void *)description);
225 }
226
227 static void __ps_free_license(gpointer data)
228 {
229         license_x *license = (license_x *)data;
230
231         if (license == NULL)
232                 return;
233         if (license->text)
234                 free((void *)license->text);
235         if (license->lang)
236                 free((void *)license->lang);
237         free((void *)license);
238 }
239
240 static void __ps_free_splashscreen(gpointer data)
241 {
242         splashscreen_x *splashscreen = (splashscreen_x *)data;
243
244         if (splashscreen == NULL)
245                 return;
246         if (splashscreen->src)
247                 free((void *)splashscreen->src);
248         if (splashscreen->type)
249                 free((void *)splashscreen->type);
250         if (splashscreen->dpi)
251                 free((void *)splashscreen->dpi);
252         if (splashscreen->orientation)
253                 free((void *)splashscreen->orientation);
254         if (splashscreen->indicatordisplay)
255                 free((void *)splashscreen->indicatordisplay);
256         if (splashscreen->operation)
257                 free((void *)splashscreen->operation);
258         if (splashscreen->color_depth)
259                 free((void *)splashscreen->color_depth);
260         free((void *)splashscreen);
261 }
262
263 static void __ps_free_privilege(gpointer data)
264 {
265         privilege_x *privilege = (privilege_x *)data;
266
267         if (privilege == NULL)
268                 return;
269         if (privilege->type)
270                 free((void *)privilege->type);
271         if (privilege->value)
272                 free((void *)privilege->value);
273         free((void *)privilege);
274 }
275
276 static void __ps_free_appdefined_privilege(gpointer data)
277 {
278         appdefined_privilege_x *privilege = (appdefined_privilege_x *)data;
279
280         if (privilege == NULL)
281                 return;
282         if (privilege->type)
283                 free((void *)privilege->type);
284         if (privilege->value)
285                 free((void *)privilege->value);
286         if (privilege->license)
287                 free((void *)privilege->license);
288         free((void *)privilege);
289 }
290
291 static void __ps_free_datacontrol(gpointer data)
292 {
293         datacontrol_x *datacontrol = (datacontrol_x *)data;
294
295         if (datacontrol == NULL)
296                 return;
297         if (datacontrol->providerid)
298                 free((void *)datacontrol->providerid);
299         if (datacontrol->access)
300                 free((void *)datacontrol->access);
301         if (datacontrol->type)
302                 free((void *)datacontrol->type);
303         if (datacontrol->trusted)
304                 free((void *)datacontrol->trusted);
305         if (datacontrol->privileges)
306                 g_list_free_full(datacontrol->privileges, free);
307         free((void *)datacontrol);
308 }
309
310 static void __ps_free_dependency(gpointer data)
311 {
312         dependency_x *dependency = (dependency_x *)data;
313
314         if (dependency == NULL)
315                 return;
316         if (dependency->pkgid)
317                 free((void *)dependency->pkgid);
318         if (dependency->depends_on)
319                 free((void *)dependency->depends_on);
320         if (dependency->type)
321                 free((void *)dependency->type);
322         if (dependency->required_version)
323                 free((void *)dependency->required_version);
324         free((void *)dependency);
325 }
326
327 static void __ps_free_res_control(gpointer data)
328 {
329         res_control_x *res_control = (res_control_x *)data;
330
331         if (res_control == NULL)
332                 return;
333         free((void *)res_control->res_type);
334         free((void *)res_control->min_res_version);
335         free((void *)res_control->max_res_version);
336         free((void *)res_control->auto_close);
337         free((void *)res_control);
338 }
339
340 static void __ps_free_application(gpointer data)
341 {
342         application_x *application = (application_x *)data;
343
344         if (application == NULL)
345                 return;
346
347         if (application->appid)
348                 free((void *)application->appid);
349         if (application->component)
350                 free((void *)application->component);
351         if (application->exec)
352                 free((void *)application->exec);
353         if (application->nodisplay)
354                 free((void *)application->nodisplay);
355         if (application->type)
356                 free((void *)application->type);
357         if (application->onboot)
358                 free((void *)application->onboot);
359         if (application->multiple)
360                 free((void *)application->multiple);
361         if (application->autorestart)
362                 free((void *)application->autorestart);
363         if (application->taskmanage)
364                 free((void *)application->taskmanage);
365         if (application->categories)
366                 free((void *)application->categories);
367         if (application->extraid)
368                 free((void *)application->extraid);
369         if (application->hwacceleration)
370                 free((void *)application->hwacceleration);
371         if (application->screenreader)
372                 free((void *)application->screenreader);
373         if (application->mainapp)
374                 free((void *)application->mainapp);
375         if (application->recentimage)
376                 free((void *)application->recentimage);
377         if (application->launchcondition)
378                 free((void *)application->launchcondition);
379         if (application->indicatordisplay)
380                 free((void *)application->indicatordisplay);
381         if (application->portraitimg)
382                 free((void *)application->portraitimg);
383         if (application->landscapeimg)
384                 free((void *)application->landscapeimg);
385         if (application->guestmode_visibility)
386                 free((void *)application->guestmode_visibility);
387         if (application->permission_type)
388                 free((void *)application->permission_type);
389         if (application->preload)
390                 free((void *)application->preload);
391         if (application->submode)
392                 free((void *)application->submode);
393         if (application->submode_mainid)
394                 free((void *)application->submode_mainid);
395         if (application->process_pool)
396                 free((void *)application->process_pool);
397         if (application->installed_storage)
398                 free((void *)application->installed_storage);
399         if (application->launch_mode)
400                 free((void *)application->launch_mode);
401         if (application->ui_gadget)
402                 free((void *)application->ui_gadget);
403         if (application->component_type)
404                 free((void *)application->component_type);
405         if (application->package)
406                 free((void *)application->package);
407         if (application->support_disable)
408                 free((void *)application->support_disable);
409         if (application->tep_name)
410                 free((void *)application->tep_name);
411         if (application->zip_mount_file)
412                 free((void *)application->zip_mount_file);
413         if (application->root_path)
414                 free((void *)application->root_path);
415         if (application->api_version)
416                 free((void *)application->api_version);
417         if (application->for_all_users)
418                 free((void *)application->for_all_users);
419         if (application->effective_appid)
420                 free((void *)application->effective_appid);
421         if (application->is_disabled)
422                 free((void *)application->is_disabled);
423         if (application->splash_screen_display)
424                 free((void *)application->splash_screen_display);
425         if (application->effectimage_type)
426                 free((void *)application->effectimage_type);
427         if (application->package_type)
428                 free((void *)application->package_type);
429         if (application->support_ambient)
430                 free((void *)application->support_ambient);
431         if (application->alias_appid)
432                 free((void *)application->alias_appid);
433         if (application->external_path)
434                 free((void *)application->external_path);
435         if (application->package_system)
436                 free((void *)application->package_system);
437         if (application->removable)
438                 free((void *)application->removable);
439         if (application->package_installed_time)
440                 free((void *)application->package_installed_time);
441         if (application->support_mode)
442                 free((void *)application->support_mode);
443         if (application->setup_appid)
444                 free((void *)application->setup_appid);
445         if (application->locale)
446                 free((void *)application->locale);
447         if (application->light_user_switch_mode)
448                 free((void *)application->light_user_switch_mode);
449
450         /*Free Label*/
451         g_list_free_full(application->label, __ps_free_label);
452         /*Free Icon*/
453         g_list_free_full(application->icon, __ps_free_icon);
454         /*Free image*/
455         g_list_free_full(application->image, __ps_free_image);
456         /*Free AppControl*/
457         g_list_free_full(application->appcontrol, __ps_free_appcontrol);
458         /*Free Category*/
459         g_list_free_full(application->category, free);
460         /*Free Metadata*/
461         g_list_free_full(application->metadata, __ps_free_metadata);
462         /*Free permission*/
463         g_list_free_full(application->permission, __ps_free_permission);
464         /*Free LaunchConditions*/
465         g_list_free_full(application->launchconditions, free);
466         /*Free Notification*/
467         g_list_free_full(application->notification, __ps_free_notification);
468         /*Free DataShare*/
469         g_list_free_full(application->datashare, __ps_free_datashare);
470         /*Free DataControl*/
471         g_list_free_full(application->datacontrol, __ps_free_datacontrol);
472         /*Free BackgroundCategory*/
473         g_list_free_full(application->background_category, free);
474         /*Free SplashScreen*/
475         g_list_free_full(application->splashscreens, __ps_free_splashscreen);
476         /*Free ResControl*/
477         g_list_free_full(application->res_control, __ps_free_res_control);
478
479         free((void *)application);
480 }
481
482 API void pkgmgrinfo_basic_free_application(application_x *application)
483 {
484         __ps_free_application(application);
485 }
486
487 API void pkgmgrinfo_basic_free_dependency(dependency_x *dependency)
488 {
489         __ps_free_dependency(dependency);
490 }
491
492 API void pkgmgrinfo_basic_free_package(package_x *package)
493 {
494         if (package == NULL)
495                 return;
496         if (package->for_all_users)
497                 free((void *)package->for_all_users);
498         if (package->ns)
499                 free((void *)package->ns);
500         if (package->package)
501                 free((void *)package->package);
502         if (package->version)
503                 free((void *)package->version);
504         if (package->installlocation)
505                 free((void *)package->installlocation);
506         if (package->preload)
507                 free((void *)package->preload);
508         if (package->readonly)
509                 free((void *)package->readonly);
510         if (package->removable)
511                 free((void *)package->removable);
512         if (package->update)
513                 free((void *)package->update);
514         if (package->system)
515                 free((void *)package->system);
516         if (package->type)
517                 free((void *)package->type);
518         if (package->package_size)
519                 free((void *)package->package_size);
520         if (package->installed_time)
521                 free((void *)package->installed_time);
522         if (package->installed_storage)
523                 free((void *)package->installed_storage);
524         if (package->storeclient_id)
525                 free((void *)package->storeclient_id);
526         if (package->mainapp_id)
527                 free((void *)package->mainapp_id);
528         if (package->package_url)
529                 free((void *)package->package_url);
530         if (package->root_path)
531                 free((void *)package->root_path);
532         if (package->csc_path)
533                 free((void *)package->csc_path);
534         if (package->appsetting)
535                 free((void *)package->appsetting);
536         if (package->nodisplay_setting)
537                 free((void *)package->nodisplay_setting);
538         if (package->api_version)
539                 free((void *)package->api_version);
540         if (package->support_disable)
541                 free((void *)package->support_disable);
542         if (package->tep_name)
543                 free((void *)package->tep_name);
544         if (package->zip_mount_file)
545                 free((void *)package->zip_mount_file);
546         if (package->external_path)
547                 free((void *)package->external_path);
548         if (package->support_mode)
549                 free((void *)package->support_mode);
550         if (package->use_system_certs)
551                 free((void *)package->use_system_certs);
552         if (package->locale)
553                 free((void *)package->locale);
554         if (package->res_type)
555                 free((void *)package->res_type);
556         if (package->res_version)
557                 free((void *)package->res_version);
558         if (package->lib)
559                 free((void *)package->lib);
560         if (package->is_disabled)
561                 free((void *)package->is_disabled);
562         if (package->light_user_switch_mode)
563                 free((void *)package->light_user_switch_mode);
564
565         /*Free Icon*/
566         g_list_free_full(package->icon, __ps_free_icon);
567         /*Free Label*/
568         g_list_free_full(package->label, __ps_free_label);
569         /*Free Author*/
570         g_list_free_full(package->author, __ps_free_author);
571         /*Free Description*/
572         g_list_free_full(package->description, __ps_free_description);
573         /*Free License*/
574         g_list_free_full(package->license, __ps_free_license);
575         /*Free Privileges*/
576         g_list_free_full(package->privileges, __ps_free_privilege);
577         /*Free AppDefined Privileges*/
578         g_list_free_full(package->appdefined_privileges,
579                 __ps_free_appdefined_privilege);
580         /*Free Providing AppDefined Privileges*/
581         g_list_free_full(package->provides_appdefined_privileges,
582                 __ps_free_appdefined_privilege);
583         /*Free Application*/
584         g_list_free_full(package->application, __ps_free_application);
585         /*Free Compatibility*/
586         g_list_free_full(package->compatibility, __ps_free_compatibility);
587         /*Free Device profiles*/
588         g_list_free_full(package->deviceprofile, free);
589         /*Free Dependencies*/
590         g_list_free_full(package->dependencies, __ps_free_dependency);
591         /*Free Plugin execution history*/
592         g_list_free_full(package->plugin, __ps_free_plugin_info);
593         /*Free resource allowed packages*/
594         g_list_free_full(package->res_allowed_packages, __ps_free_res_allowed_packages);
595         /*Free Metadata*/
596         g_list_free_full(package->metadata, __ps_free_metadata);
597         free((void *)package);
598 }