4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Junsuk Oh <junsuk77.oh@samsung.com>,
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include "pkgmgrinfo_basic.h"
26 #include "pkgmgrinfo_private.h"
27 #include <openssl/md5.h>
29 #define HASH_LEN MD5_DIGEST_LENGTH * 2
32 static void __ps_free_category(category_x *category)
36 FREE_AND_NULL(category->name);
37 FREE_AND_NULL(category);
40 static void __ps_free_privilege(privilege_x *privilege)
42 if (privilege == NULL)
44 FREE_AND_NULL(privilege->text);
45 FREE_AND_NULL(privilege);
48 static void __ps_free_privileges(privileges_x *privileges)
50 if (privileges == NULL)
53 if (privileges->privilege) {
54 privilege_x *privilege = privileges->privilege;
55 privilege_x *tmp = NULL;
56 while(privilege != NULL) {
57 tmp = privilege->next;
58 __ps_free_privilege(privilege);
62 FREE_AND_NULL(privileges);
65 static void __ps_free_metadata(metadata_x *metadata)
69 FREE_AND_NULL(metadata->key);
70 FREE_AND_NULL(metadata->value);
71 FREE_AND_NULL(metadata);
74 static void __ps_free_permission(permission_x *permission)
76 if (permission == NULL)
78 FREE_AND_NULL(permission->type);
79 FREE_AND_NULL(permission->value);
80 FREE_AND_NULL(permission);
83 static void __ps_free_icon(icon_x *icon)
87 FREE_AND_NULL(icon->text);
88 FREE_AND_NULL(icon->lang);
89 FREE_AND_NULL(icon->name);
90 FREE_AND_NULL(icon->section);
91 FREE_AND_NULL(icon->size);
92 FREE_AND_NULL(icon->resolution);
96 static void __ps_free_image(image_x *image)
100 FREE_AND_NULL(image->text);
101 FREE_AND_NULL(image->lang);
102 FREE_AND_NULL(image->name);
103 FREE_AND_NULL(image->section);
104 FREE_AND_NULL(image);
107 static void __ps_free_operation(operation_x *operation)
109 if (operation == NULL)
111 FREE_AND_NULL(operation->text);
112 FREE_AND_NULL(operation);
115 static void __ps_free_uri(uri_x *uri)
119 FREE_AND_NULL(uri->text);
123 static void __ps_free_mime(mime_x *mime)
127 FREE_AND_NULL(mime->text);
131 static void __ps_free_subapp(subapp_x *subapp)
135 FREE_AND_NULL(subapp->text);
136 FREE_AND_NULL(subapp);
139 static void __ps_free_condition(condition_x *condition)
141 if (condition == NULL)
143 FREE_AND_NULL(condition->text);
144 FREE_AND_NULL(condition->name);
145 FREE_AND_NULL(condition);
148 static void __ps_free_notification(notification_x *notification)
150 if (notification == NULL)
152 FREE_AND_NULL(notification->text);
153 FREE_AND_NULL(notification->name);
154 FREE_AND_NULL(notification);
157 static void __ps_free_compatibility(compatibility_x *compatibility)
159 if (compatibility == NULL)
161 FREE_AND_NULL(compatibility->text);
162 FREE_AND_NULL(compatibility->name);
163 FREE_AND_NULL(compatibility);
166 static void __ps_free_allowed(allowed_x *allowed)
170 FREE_AND_NULL(allowed->name);
171 FREE_AND_NULL(allowed->text);
172 FREE_AND_NULL(allowed);
175 static void __ps_free_request(request_x *request)
179 FREE_AND_NULL(request->text);
180 FREE_AND_NULL(request);
183 static void __ps_free_datacontrol(datacontrol_x *datacontrol)
185 if (datacontrol == NULL)
187 FREE_AND_NULL(datacontrol->providerid);
188 FREE_AND_NULL(datacontrol->access);
189 FREE_AND_NULL(datacontrol->type);
190 FREE_AND_NULL(datacontrol);
193 static void __ps_free_launchconditions(launchconditions_x *launchconditions)
195 if (launchconditions == NULL)
197 FREE_AND_NULL(launchconditions->text);
199 if (launchconditions->condition) {
200 condition_x *condition = launchconditions->condition;
201 condition_x *tmp = NULL;
202 while(condition != NULL) {
203 tmp = condition->next;
204 __ps_free_condition(condition);
208 FREE_AND_NULL(launchconditions);
211 static void __ps_free_appsvc(appsvc_x *appsvc)
215 FREE_AND_NULL(appsvc->text);
217 if (appsvc->operation) {
218 operation_x *operation = appsvc->operation;
219 operation_x *tmp = NULL;
220 while(operation != NULL) {
221 tmp = operation->next;
222 __ps_free_operation(operation);
228 uri_x *uri = appsvc->uri;
238 mime_x *mime = appsvc->mime;
240 while(mime != NULL) {
242 __ps_free_mime(mime);
247 if (appsvc->subapp) {
248 subapp_x *subapp = appsvc->subapp;
249 subapp_x *tmp = NULL;
250 while(subapp != NULL) {
252 __ps_free_subapp(subapp);
256 FREE_AND_NULL(appsvc);
259 static void __ps_free_deviceprofile(deviceprofile_x *deviceprofile)
264 static void __ps_free_define(define_x *define)
268 FREE_AND_NULL(define->path);
270 if (define->request) {
271 request_x *request = define->request;
272 request_x *tmp = NULL;
273 while(request != NULL) {
275 __ps_free_request(request);
280 if (define->allowed) {
281 allowed_x *allowed = define->allowed;
282 allowed_x *tmp = NULL;
283 while(allowed != NULL) {
285 __ps_free_allowed(allowed);
289 FREE_AND_NULL(define);
292 static void __ps_free_datashare(datashare_x *datashare)
294 if (datashare == NULL)
297 if (datashare->define) {
298 define_x *define = datashare->define;
299 define_x *tmp = NULL;
300 while(define != NULL) {
302 __ps_free_define(define);
307 if (datashare->request) {
308 request_x *request = datashare->request;
309 request_x *tmp = NULL;
310 while(request != NULL) {
312 __ps_free_request(request);
316 FREE_AND_NULL(datashare);
319 static void __ps_free_label(label_x *label)
323 FREE_AND_NULL(label->name);
324 FREE_AND_NULL(label->text);
325 FREE_AND_NULL(label->lang);
326 FREE_AND_NULL(label);
329 static void __ps_free_author(author_x *author)
333 FREE_AND_NULL(author->email);
334 FREE_AND_NULL(author->text);
335 FREE_AND_NULL(author->href);
336 FREE_AND_NULL(author->lang);
337 FREE_AND_NULL(author);
340 static void __ps_free_description(description_x *description)
342 if (description == NULL)
344 FREE_AND_NULL(description->name);
345 FREE_AND_NULL(description->text);
346 FREE_AND_NULL(description->lang);
347 FREE_AND_NULL(description);
350 static void __ps_free_license(license_x *license)
354 FREE_AND_NULL(license->text);
355 FREE_AND_NULL(license->lang);
356 FREE_AND_NULL(license);
359 static void __ps_free_uiapplication(uiapplication_x *uiapplication)
361 if (uiapplication == NULL)
363 FREE_AND_NULL(uiapplication->exec);
364 FREE_AND_NULL(uiapplication->ambient_support);
365 FREE_AND_NULL(uiapplication->appid);
366 FREE_AND_NULL(uiapplication->nodisplay);
367 FREE_AND_NULL(uiapplication->multiple);
368 FREE_AND_NULL(uiapplication->type);
369 FREE_AND_NULL(uiapplication->categories);
370 FREE_AND_NULL(uiapplication->extraid);
371 FREE_AND_NULL(uiapplication->taskmanage);
372 FREE_AND_NULL(uiapplication->enabled);
373 FREE_AND_NULL(uiapplication->hwacceleration);
374 FREE_AND_NULL(uiapplication->screenreader);
375 FREE_AND_NULL(uiapplication->mainapp);
376 FREE_AND_NULL(uiapplication->recentimage);
377 FREE_AND_NULL(uiapplication->package);
378 FREE_AND_NULL(uiapplication->launchcondition);
379 FREE_AND_NULL(uiapplication->multi_instance);
380 FREE_AND_NULL(uiapplication->multi_instance_mainid);
381 FREE_AND_NULL(uiapplication->multi_window);
382 FREE_AND_NULL(uiapplication->support_disable);
383 FREE_AND_NULL(uiapplication->ui_gadget);
384 FREE_AND_NULL(uiapplication->removable);
385 FREE_AND_NULL(uiapplication->support_mode);
386 FREE_AND_NULL(uiapplication->support_feature);
387 FREE_AND_NULL(uiapplication->satui_label);
388 FREE_AND_NULL(uiapplication->package_type);
389 FREE_AND_NULL(uiapplication->package_system);
390 FREE_AND_NULL(uiapplication->package_installed_time);
393 if (uiapplication->label) {
394 label_x *label = uiapplication->label;
396 while(label != NULL) {
398 __ps_free_label(label);
403 if (uiapplication->icon) {
404 icon_x *icon = uiapplication->icon;
406 while(icon != NULL) {
408 __ps_free_icon(icon);
413 if (uiapplication->image) {
414 image_x *image = uiapplication->image;
416 while(image != NULL) {
418 __ps_free_image(image);
422 /*Free LaunchConditions*/
423 if (uiapplication->launchconditions) {
424 launchconditions_x *launchconditions = uiapplication->launchconditions;
425 launchconditions_x *tmp = NULL;
426 while(launchconditions != NULL) {
427 tmp = launchconditions->next;
428 __ps_free_launchconditions(launchconditions);
429 launchconditions = tmp;
432 /*Free Notification*/
433 if (uiapplication->notification) {
434 notification_x *notification = uiapplication->notification;
435 notification_x *tmp = NULL;
436 while(notification != NULL) {
437 tmp = notification->next;
438 __ps_free_notification(notification);
443 if (uiapplication->datashare) {
444 datashare_x *datashare = uiapplication->datashare;
445 datashare_x *tmp = NULL;
446 while(datashare != NULL) {
447 tmp = datashare->next;
448 __ps_free_datashare(datashare);
453 if (uiapplication->appsvc) {
454 appsvc_x *appsvc = uiapplication->appsvc;
455 appsvc_x *tmp = NULL;
456 while(appsvc != NULL) {
458 __ps_free_appsvc(appsvc);
463 if (uiapplication->category) {
464 category_x *category = uiapplication->category;
465 category_x *tmp = NULL;
466 while(category != NULL) {
467 tmp = category->next;
468 __ps_free_category(category);
473 if (uiapplication->metadata) {
474 metadata_x *metadata = uiapplication->metadata;
475 metadata_x *tmp = NULL;
476 while(metadata != NULL) {
477 tmp = metadata->next;
478 __ps_free_metadata(metadata);
483 if (uiapplication->permission) {
484 permission_x *permission = uiapplication->permission;
485 permission_x *tmp = NULL;
486 while(permission != NULL) {
487 tmp = permission->next;
488 __ps_free_permission(permission);
494 if (uiapplication->datacontrol) {
495 datacontrol_x *datacontrol = uiapplication->datacontrol;
496 datacontrol_x *tmp = NULL;
497 while(datacontrol != NULL) {
498 tmp = datacontrol->next;
499 __ps_free_datacontrol(datacontrol);
504 /* _PRODUCT_LAUNCHING_ENHANCED_ START */
505 FREE_AND_NULL(uiapplication->indicatordisplay);
506 FREE_AND_NULL(uiapplication->portraitimg);
507 FREE_AND_NULL(uiapplication->landscapeimg);
508 FREE_AND_NULL(uiapplication->effectimage_type);
509 /* _PRODUCT_LAUNCHING_ENHANCED_ END */
510 FREE_AND_NULL(uiapplication->guestmode_visibility);
511 FREE_AND_NULL(uiapplication->app_component);
512 FREE_AND_NULL(uiapplication->permission_type);
513 FREE_AND_NULL(uiapplication->component_type);
514 FREE_AND_NULL(uiapplication->preload);
515 FREE_AND_NULL(uiapplication->submode);
516 FREE_AND_NULL(uiapplication->submode_mainid);
517 FREE_AND_NULL(uiapplication->installed_storage);
518 FREE_AND_NULL(uiapplication->process_pool);
519 FREE_AND_NULL(uiapplication->autorestart);
520 FREE_AND_NULL(uiapplication->onboot);
522 FREE_AND_NULL(uiapplication);
525 static void __ps_free_font(font_x *font)
529 FREE_AND_NULL(font->name);
530 FREE_AND_NULL(font->text);
534 static void __ps_free_theme(theme_x *theme)
538 FREE_AND_NULL(theme->name);
539 FREE_AND_NULL(theme->text);
540 FREE_AND_NULL(theme);
543 static void __ps_free_daemon(daemon_x *daemon)
547 FREE_AND_NULL(daemon->name);
548 FREE_AND_NULL(daemon->text);
549 FREE_AND_NULL(daemon);
552 static void __ps_free_ime(ime_x *ime)
556 FREE_AND_NULL(ime->name);
557 FREE_AND_NULL(ime->text);
561 API void _pkgmgrinfo_basic_free_manifest_x(manifest_x *mfx)
565 FREE_AND_NULL(mfx->ns);
566 FREE_AND_NULL(mfx->package);
567 FREE_AND_NULL(mfx->version);
568 FREE_AND_NULL(mfx->installlocation);
569 FREE_AND_NULL(mfx->preload);
570 FREE_AND_NULL(mfx->readonly);
571 FREE_AND_NULL(mfx->removable);
572 FREE_AND_NULL(mfx->update);
573 FREE_AND_NULL(mfx->system);
574 FREE_AND_NULL(mfx->hash);
575 FREE_AND_NULL(mfx->type);
576 FREE_AND_NULL(mfx->package_size);
577 FREE_AND_NULL(mfx->package_total_size);
578 FREE_AND_NULL(mfx->package_data_size);
579 FREE_AND_NULL(mfx->installed_time);
580 FREE_AND_NULL(mfx->installed_storage);
581 FREE_AND_NULL(mfx->storeclient_id);
582 FREE_AND_NULL(mfx->mainapp_id);
583 FREE_AND_NULL(mfx->package_url);
584 FREE_AND_NULL(mfx->root_path);
585 FREE_AND_NULL(mfx->csc_path);
586 FREE_AND_NULL(mfx->appsetting);
587 FREE_AND_NULL(mfx->nodisplay_setting);
588 FREE_AND_NULL(mfx->support_disable);
589 FREE_AND_NULL(mfx->mother_package);
590 FREE_AND_NULL(mfx->support_mode);
591 FREE_AND_NULL(mfx->groupid);
592 FREE_AND_NULL(mfx->support_reset);
593 FREE_AND_NULL(mfx->use_reset);
597 icon_x *icon = mfx->icon;
599 while(icon != NULL) {
601 __ps_free_icon(icon);
607 label_x *label = mfx->label;
609 while(label != NULL) {
611 __ps_free_label(label);
617 author_x *author = mfx->author;
618 author_x *tmp = NULL;
619 while(author != NULL) {
621 __ps_free_author(author);
626 if (mfx->description) {
627 description_x *description = mfx->description;
628 description_x *tmp = NULL;
629 while(description != NULL) {
630 tmp = description->next;
631 __ps_free_description(description);
637 license_x *license = mfx->license;
638 license_x *tmp = NULL;
639 while(license != NULL) {
641 __ps_free_license(license);
646 if (mfx->privileges) {
647 privileges_x *privileges = mfx->privileges;
648 privileges_x *tmp = NULL;
649 while(privileges != NULL) {
650 tmp = privileges->next;
651 __ps_free_privileges(privileges);
655 /*Free UiApplication*/
656 if (mfx->uiapplication) {
657 uiapplication_x *uiapplication = mfx->uiapplication;
658 uiapplication_x *tmp = NULL;
659 while(uiapplication != NULL) {
660 tmp = uiapplication->next;
661 __ps_free_uiapplication(uiapplication);
667 daemon_x *daemon = mfx->daemon;
668 daemon_x *tmp = NULL;
669 while(daemon != NULL) {
671 __ps_free_daemon(daemon);
677 theme_x *theme = mfx->theme;
679 while(theme != NULL) {
681 __ps_free_theme(theme);
687 font_x *font = mfx->font;
689 while(font != NULL) {
691 __ps_free_font(font);
697 ime_x *ime = mfx->ime;
705 /*Free Compatibility*/
706 if (mfx->compatibility) {
707 compatibility_x *compatibility = mfx->compatibility;
708 compatibility_x *tmp = NULL;
709 while(compatibility != NULL) {
710 tmp = compatibility->next;
711 __ps_free_compatibility(compatibility);
715 /*Free DeviceProfile*/
716 if (mfx->deviceprofile) {
717 deviceprofile_x *deviceprofile = mfx->deviceprofile;
718 deviceprofile_x *tmp = NULL;
719 while(deviceprofile != NULL) {
720 tmp = deviceprofile->next;
721 __ps_free_deviceprofile(deviceprofile);
729 API char* pkgmgrinfo_basic_generate_hash_for_file( const char *file)
732 unsigned char c[MD5_DIGEST_LENGTH] = {0};
738 unsigned char data[1024];
740 FILE *inFile = fopen (file, "rb");
742 if (inFile == NULL) {
743 _LOGD("@Error while opening the file: %s",strerror(errno));
747 MD5_Init (&mdContext);
749 while ((bytes = fread (data, 1, 1024, inFile)) != 0)
750 MD5_Update (&mdContext, data, bytes);
752 MD5_Final (c,&mdContext);
754 hash = (char*)malloc(HASH_LEN + 1);
756 _LOGE("Malloc failed!!");
759 memset(hash,'\0',HASH_LEN + 1);
761 for(index = 0; index < MD5_DIGEST_LENGTH; index++) {
762 sprintf(temp,"%02x",c[index]);
763 strncat(hash,temp,strlen(temp));