Add external_path column and change function related with it
[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_application(gpointer data)
238 {
239         application_x *application = (application_x *)data;
240         if (application == NULL)
241                 return;
242
243         if (application->appid)
244                 free((void *)application->appid);
245         if (application->component)
246                 free((void *)application->component);
247         if (application->exec)
248                 free((void *)application->exec);
249         if (application->nodisplay)
250                 free((void *)application->nodisplay);
251         if (application->type)
252                 free((void *)application->type);
253         if (application->onboot)
254                 free((void *)application->onboot);
255         if (application->multiple)
256                 free((void *)application->multiple);
257         if (application->autorestart)
258                 free((void *)application->autorestart);
259         if (application->taskmanage)
260                 free((void *)application->taskmanage);
261         if (application->enabled)
262                 free((void *)application->enabled);
263         if (application->categories)
264                 free((void *)application->categories);
265         if (application->extraid)
266                 free((void *)application->extraid);
267         if (application->hwacceleration)
268                 free((void *)application->hwacceleration);
269         if (application->screenreader)
270                 free((void *)application->screenreader);
271         if (application->mainapp)
272                 free((void *)application->mainapp);
273         if (application->recentimage)
274                 free((void *)application->recentimage);
275         if (application->launchcondition)
276                 free((void *)application->launchcondition);
277         if (application->indicatordisplay)
278                 free((void *)application->indicatordisplay);
279         if (application->portraitimg)
280                 free((void *)application->portraitimg);
281         if (application->landscapeimg)
282                 free((void *)application->landscapeimg);
283         if (application->guestmode_visibility)
284                 free((void *)application->guestmode_visibility);
285         if (application->permission_type)
286                 free((void *)application->permission_type);
287         if (application->preload)
288                 free((void *)application->preload);
289         if (application->submode)
290                 free((void *)application->submode);
291         if (application->submode_mainid)
292                 free((void *)application->submode_mainid);
293         if (application->process_pool)
294                 free((void *)application->process_pool);
295         if (application->installed_storage)
296                 free((void *)application->installed_storage);
297         if (application->launch_mode)
298                 free((void *)application->launch_mode);
299         if (application->ui_gadget)
300                 free((void *)application->ui_gadget);
301         if (application->component_type)
302                 free((void *)application->component_type);
303         if (application->package)
304                 free((void *)application->package);
305         if (application->support_disable)
306                 free((void *)application->support_disable);
307         if (application->tep_name)
308                 free((void *)application->tep_name);
309         if (application->zip_mount_file)
310                 free((void *)application->zip_mount_file);
311         if (application->root_path)
312                 free((void *)application->root_path);
313         if (application->api_version)
314                 free((void *)application->api_version);
315         if (application->for_all_users)
316                 free((void *)application->for_all_users);
317         if (application->effective_appid)
318                 free((void *)application->effective_appid);
319         if (application->is_disabled)
320                 free((void *)application->is_disabled);
321         if (application->splash_screen_display)
322                 free((void *)application->splash_screen_display);
323         if (application->effectimage_type)
324                 free((void *)application->effectimage_type);
325         if (application->package_type)
326                 free((void *)application->package_type);
327         if (application->ambient_support)
328                 free((void *)application->ambient_support);
329         if (application->alias_appid)
330                 free((void *)application->alias_appid);
331         if (application->external_path)
332                 free((void *)application->external_path);
333
334         /*Free Label*/
335         g_list_free_full(application->label, __ps_free_label);
336         /*Free Icon*/
337         g_list_free_full(application->icon, __ps_free_icon);
338         /*Free image*/
339         g_list_free_full(application->image, __ps_free_image);
340         /*Free AppControl*/
341         g_list_free_full(application->appcontrol, __ps_free_appcontrol);
342         /*Free Category*/
343         g_list_free_full(application->category, free);
344         /*Free Metadata*/
345         g_list_free_full(application->metadata, __ps_free_metadata);
346         /*Free permission*/
347         g_list_free_full(application->permission, __ps_free_permission);
348         /*Free LaunchConditions*/
349         g_list_free_full(application->launchconditions, free);
350         /*Free Notification*/
351         g_list_free_full(application->notification, __ps_free_notification);
352         /*Free DataShare*/
353         g_list_free_full(application->datashare, __ps_free_datashare);
354         /*Free DataControl*/
355         g_list_free_full(application->datacontrol, __ps_free_datacontrol);
356         /*Free BackgroundCategory*/
357         g_list_free_full(application->background_category, free);
358         /*Free SplashScreen*/
359         g_list_free_full(application->splashscreens, __ps_free_splashscreen);
360         /* FIXME */
361         g_list_free_full(application->support_sizes, __ps_free_support_size);
362
363         free((void *)application);
364 }
365
366 API void pkgmgrinfo_basic_free_application(application_x *application)
367 {
368         __ps_free_application(application);
369 }
370
371 API void pkgmgrinfo_basic_free_package(package_x *package)
372 {
373         if (package == NULL)
374                 return;
375         if (package->for_all_users)
376                 free((void *)package->for_all_users);
377         if (package->ns)
378                 free((void *)package->ns);
379         if (package->package)
380                 free((void *)package->package);
381         if (package->version)
382                 free((void *)package->version);
383         if (package->installlocation)
384                 free((void *)package->installlocation);
385         if (package->preload)
386                 free((void *)package->preload);
387         if (package->readonly)
388                 free((void *)package->readonly);
389         if (package->removable)
390                 free((void *)package->removable);
391         if (package->update)
392                 free((void *)package->update);
393         if (package->system)
394                 free((void *)package->system);
395         if (package->type)
396                 free((void *)package->type);
397         if (package->package_size)
398                 free((void *)package->package_size);
399         if (package->installed_time)
400                 free((void *)package->installed_time);
401         if (package->installed_storage)
402                 free((void *)package->installed_storage);
403         if (package->storeclient_id)
404                 free((void *)package->storeclient_id);
405         if (package->mainapp_id)
406                 free((void *)package->mainapp_id);
407         if (package->package_url)
408                 free((void *)package->package_url);
409         if (package->root_path)
410                 free((void *)package->root_path);
411         if (package->csc_path)
412                 free((void *)package->csc_path);
413         if (package->appsetting)
414                 free((void *)package->appsetting);
415         if (package->nodisplay_setting)
416                 free((void *)package->nodisplay_setting);
417         if (package->api_version)
418                 free((void *)package->api_version);
419         if (package->support_disable)
420                 free((void *)package->support_disable);
421         if (package->tep_name)
422                 free((void *)package->tep_name);
423         if (package->zip_mount_file)
424                 free((void *)package->zip_mount_file);
425         if (package->external_path)
426                 free((void *)package->external_path);
427
428         /*Free Icon*/
429         g_list_free_full(package->icon, __ps_free_icon);
430         /*Free Label*/
431         g_list_free_full(package->label, __ps_free_label);
432         /*Free Author*/
433         g_list_free_full(package->author, __ps_free_author);
434         /*Free Description*/
435         g_list_free_full(package->description, __ps_free_description);
436         /*Free License*/
437         g_list_free_full(package->license, __ps_free_license);
438         /*Free Privileges*/
439         g_list_free_full(package->privileges, free);
440         /*Free Application*/
441         g_list_free_full(package->application, __ps_free_application);
442         /*Free Compatibility*/
443         g_list_free_full(package->compatibility, __ps_free_compatibility);
444         /*Free Device profiles*/
445         g_list_free_full(package->deviceprofile, free);
446         free((void*)package);
447         return;
448 }
449