Support localized/multi-resolution app icons
[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->name)
40                 free((void *)icon->name);
41         if (icon->section)
42                 free((void *)icon->section);
43         if (icon->size)
44                 free((void *)icon->size);
45         if (icon->resolution)
46                 free((void *)icon->resolution);
47         if (icon->dpi)
48                 free((void *)icon->dpi);
49         free((void*)icon);
50 }
51
52 static void __ps_free_image(gpointer data)
53 {
54         image_x *image = (image_x *)data;
55         if (image == NULL)
56                 return;
57         if (image->text)
58                 free((void *)image->text);
59         if (image->lang)
60                 free((void *)image->lang);
61         if (image->name)
62                 free((void *)image->name);
63         if (image->section)
64                 free((void *)image->section);
65         free((void*)image);
66 }
67
68 static void __ps_free_notification(gpointer data)
69 {
70         notification_x *notification = (notification_x *)data;
71         if (notification == NULL)
72                 return;
73         if (notification->text)
74                 free((void *)notification->text);
75         if (notification->name)
76                 free((void *)notification->name);
77         free((void*)notification);
78 }
79
80 static void __ps_free_compatibility(gpointer data)
81 {
82         compatibility_x *compatibility = (compatibility_x *)data;
83         if (compatibility == NULL)
84                 return;
85         if (compatibility->text)
86                 free((void *)compatibility->text);
87         if (compatibility->name)
88                 free((void *)compatibility->name);
89         free((void*)compatibility);
90 }
91
92 static void __ps_free_datacontrol(gpointer data)
93 {
94         datacontrol_x *datacontrol = (datacontrol_x *)data;
95         if (datacontrol == NULL)
96                 return;
97         if (datacontrol->providerid)
98                 free((void *)datacontrol->providerid);
99         if (datacontrol->access)
100                 free((void *)datacontrol->access);
101         if (datacontrol->type)
102                 free((void *)datacontrol->type);
103         free((void*)datacontrol);
104 }
105
106 static void __ps_free_appcontrol(gpointer data)
107 {
108         appcontrol_x *appcontrol = (appcontrol_x *)data;
109         if (appcontrol == NULL)
110                 return;
111         /*Free Operation*/
112         if (appcontrol->operation)
113                 free((void *)appcontrol->operation);
114         /*Free Uri*/
115         if (appcontrol->uri)
116                 free((void *)appcontrol->uri);
117         /*Free Mime*/
118         if (appcontrol->mime)
119                 free((void *)appcontrol->mime);
120         free((void*)appcontrol);
121 }
122
123 static void __ps_free_define(gpointer data)
124 {
125         define_x *define = (define_x *)data;
126
127         if (define == NULL)
128                 return;
129         if (define->path)
130                 free((void *)define->path);
131         /*Free Request*/
132         g_list_free_full(define->request, free);
133         /*Free Allowed*/
134         g_list_free_full(define->allowed, free);
135         free((void*)define);
136 }
137
138 static void __ps_free_datashare(gpointer data)
139 {
140         datashare_x *datashare = (datashare_x *)data;
141         if (datashare == NULL)
142                 return;
143         /*Free Define*/
144         g_list_free_full(datashare->define, __ps_free_define);
145         /*Free Request*/
146         g_list_free_full(datashare->request, free);
147         free((void*)datashare);
148 }
149
150 static void __ps_free_label(gpointer data)
151 {
152         label_x *label = (label_x *)data;
153         if (label == NULL)
154                 return;
155         if (label->name)
156                 free((void *)label->name);
157         if (label->text)
158                 free((void *)label->text);
159         if (label->lang)
160                 free((void *)label->lang);
161         free((void*)label);
162 }
163
164 static void __ps_free_author(gpointer data)
165 {
166         author_x *author = (author_x *)data;
167         if (author == NULL)
168                 return;
169         if (author->email)
170                 free((void *)author->email);
171         if (author->text)
172                 free((void *)author->text);
173         if (author->href)
174                 free((void *)author->href);
175         if (author->lang)
176                 free((void *)author->lang);
177         free((void*)author);
178 }
179
180 static void __ps_free_description(gpointer data)
181 {
182         description_x *description = (description_x *)data;
183         if (description == NULL)
184                 return;
185         if (description->name)
186                 free((void *)description->name);
187         if (description->text)
188                 free((void *)description->text);
189         if (description->lang)
190                 free((void *)description->lang);
191         free((void*)description);
192 }
193
194 static void __ps_free_license(gpointer data)
195 {
196         license_x *license = (license_x *)data;
197         if (license == NULL)
198                 return;
199         if (license->text)
200                 free((void *)license->text);
201         if (license->lang)
202                 free((void *)license->lang);
203         free((void*)license);
204 }
205
206 static void __ps_free_application(gpointer data)
207 {
208         application_x *application = (application_x *)data;
209         if (application == NULL)
210                 return;
211
212         if (application->appid)
213                 free((void *)application->appid);
214         if (application->component)
215                 free((void *)application->component);
216         if (application->exec)
217                 free((void *)application->exec);
218         if (application->nodisplay)
219                 free((void *)application->nodisplay);
220         if (application->type)
221                 free((void *)application->type);
222         if (application->onboot)
223                 free((void *)application->onboot);
224         if (application->multiple)
225                 free((void *)application->multiple);
226         if (application->autorestart)
227                 free((void *)application->autorestart);
228         if (application->taskmanage)
229                 free((void *)application->taskmanage);
230         if (application->enabled)
231                 free((void *)application->enabled);
232         if (application->categories)
233                 free((void *)application->categories);
234         if (application->extraid)
235                 free((void *)application->extraid);
236         if (application->hwacceleration)
237                 free((void *)application->hwacceleration);
238         if (application->screenreader)
239                 free((void *)application->screenreader);
240         if (application->mainapp)
241                 free((void *)application->mainapp);
242         if (application->recentimage)
243                 free((void *)application->recentimage);
244         if (application->launchcondition)
245                 free((void *)application->launchcondition);
246         if (application->indicatordisplay)
247                 free((void *)application->indicatordisplay);
248         if (application->portraitimg)
249                 free((void *)application->portraitimg);
250         if (application->landscapeimg)
251                 free((void *)application->landscapeimg);
252         if (application->guestmode_visibility)
253                 free((void *)application->guestmode_visibility);
254         if (application->permission_type)
255                 free((void *)application->permission_type);
256         if (application->preload)
257                 free((void *)application->preload);
258         if (application->submode)
259                 free((void *)application->submode);
260         if (application->submode_mainid)
261                 free((void *)application->submode_mainid);
262         if (application->process_pool)
263                 free((void *)application->process_pool);
264         if (application->installed_storage)
265                 free((void *)application->installed_storage);
266         if (application->launch_mode)
267                 free((void *)application->launch_mode);
268         if (application->ui_gadget)
269                 free((void *)application->ui_gadget);
270         if (application->component_type)
271                 free((void *)application->component_type);
272         if (application->package)
273                 free((void *)application->package);
274         if (application->support_disable)
275                 free((void *)application->support_disable);
276
277         /*Free Label*/
278         g_list_free_full(application->label, __ps_free_label);
279         /*Free Icon*/
280         g_list_free_full(application->icon, __ps_free_icon);
281         /*Free image*/
282         g_list_free_full(application->image, __ps_free_image);
283         /*Free AppControl*/
284         g_list_free_full(application->appcontrol, __ps_free_appcontrol);
285         /*Free Category*/
286         g_list_free_full(application->category, free);
287         /*Free Metadata*/
288         g_list_free_full(application->metadata, __ps_free_metadata);
289         /*Free permission*/
290         g_list_free_full(application->permission, __ps_free_permission);
291         /*Free LaunchConditions*/
292         g_list_free_full(application->launchconditions, free);
293         /*Free Notification*/
294         g_list_free_full(application->notification, __ps_free_notification);
295         /*Free DataShare*/
296         g_list_free_full(application->datashare, __ps_free_datashare);
297         /*Free DataControl*/
298         g_list_free_full(application->datacontrol, __ps_free_datacontrol);
299         /*Free BackgroundCategory*/
300         g_list_free_full(application->background_category, free);
301         free((void *)application);
302 }
303
304 API void pkgmgrinfo_basic_free_application(application_x *application)
305 {
306         __ps_free_application(application);
307 }
308
309 API void pkgmgrinfo_basic_free_package(package_x *package)
310 {
311         if (package == NULL)
312                 return;
313         if (package->for_all_users)
314                 free((void *)package->for_all_users);
315         if (package->ns)
316                 free((void *)package->ns);
317         if (package->package)
318                 free((void *)package->package);
319         if (package->version)
320                 free((void *)package->version);
321         if (package->installlocation)
322                 free((void *)package->installlocation);
323         if (package->preload)
324                 free((void *)package->preload);
325         if (package->readonly)
326                 free((void *)package->readonly);
327         if (package->removable)
328                 free((void *)package->removable);
329         if (package->update)
330                 free((void *)package->update);
331         if (package->system)
332                 free((void *)package->system);
333         if (package->type)
334                 free((void *)package->type);
335         if (package->package_size)
336                 free((void *)package->package_size);
337         if (package->installed_time)
338                 free((void *)package->installed_time);
339         if (package->installed_storage)
340                 free((void *)package->installed_storage);
341         if (package->storeclient_id)
342                 free((void *)package->storeclient_id);
343         if (package->mainapp_id)
344                 free((void *)package->mainapp_id);
345         if (package->package_url)
346                 free((void *)package->package_url);
347         if (package->root_path)
348                 free((void *)package->root_path);
349         if (package->csc_path)
350                 free((void *)package->csc_path);
351         if (package->appsetting)
352                 free((void *)package->appsetting);
353         if (package->nodisplay_setting)
354                 free((void *)package->nodisplay_setting);
355         if (package->api_version)
356                 free((void *)package->api_version);
357         if (package->support_disable)
358                 free((void *)package->support_disable);
359         if (package->tep_name)
360                 free((void *)package->tep_name);
361
362         /*Free Icon*/
363         g_list_free_full(package->icon, __ps_free_icon);
364         /*Free Label*/
365         g_list_free_full(package->label, __ps_free_label);
366         /*Free Author*/
367         g_list_free_full(package->author, __ps_free_author);
368         /*Free Description*/
369         g_list_free_full(package->description, __ps_free_description);
370         /*Free License*/
371         g_list_free_full(package->license, __ps_free_license);
372         /*Free Privileges*/
373         g_list_free_full(package->privileges, free);
374         /*Free Application*/
375         g_list_free_full(package->application, __ps_free_application);
376         /*Free Compatibility*/
377         g_list_free_full(package->compatibility, __ps_free_compatibility);
378         /*Free Device profiles*/
379         g_list_free_full(package->deviceprofile, free);
380         free((void*)package);
381         return;
382 }
383