tizen 2.4 release
[apps/home/ug-setting-notification-efl.git] / ug-setting-notification-efl / src / pkgmgr-setting-info.c
1 /*
2  * Copyright (c) 2009 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18
19 #include <package_manager.h>
20 #include <pkgmgr-info.h>
21 #include "pkgmgr-setting-info.h"
22
23 int apps_sort_cb(const void *d1, const void *d2)
24 {
25         item_info_s *tmp1 = (item_info_s *) d1;
26         item_info_s *tmp2 = (item_info_s *) d2;
27
28         if (NULL == tmp1 || NULL == tmp1->name) return 1;
29         else if (NULL == tmp2 || NULL == tmp2->name) return -1;
30
31         return strcmp(tmp1->name, tmp2->name);
32 }
33
34 HAPI char *get_app_icon(char *appid)
35 {
36         pkgmgrinfo_appinfo_h appinfo_h = NULL;
37         char *tmp = NULL;
38         char *name = NULL;
39
40 //      retv_if(0 > pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo_h), NULL);
41 //      goto_if(PMINFO_R_OK != pkgmgrinfo_appinfo_get_icon(appinfo_h, &tmp), ERROR);
42
43         pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo_h);
44         pkgmgrinfo_appinfo_get_icon(appinfo_h, &tmp);
45
46         if (tmp) {
47                 name = strdup(tmp);
48                 goto_if(NULL == name, ERROR);
49         } 
50
51         pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
52         return name;
53
54 ERROR:
55                 pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
56                 return NULL;
57         
58 }
59
60
61 HAPI char *get_app_name(const char *appid)
62 {
63         pkgmgrinfo_appinfo_h appinfo_h = NULL;
64         char *tmp = NULL;
65         char *name = NULL;
66
67 //      retv_if(0 > pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo_h), NULL);
68 //      goto_if(PMINFO_R_OK != pkgmgrinfo_appinfo_get_label(appinfo_h, &tmp), ERROR);
69
70         pkgmgrinfo_appinfo_get_appinfo(appid, &appinfo_h);
71         pkgmgrinfo_appinfo_get_label(appinfo_h, &tmp);
72
73         if (tmp) {
74                 name = strdup(tmp);
75                 goto_if(NULL == name, ERROR);
76         }
77
78         pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
79         return name;
80
81 ERROR:
82         pkgmgrinfo_appinfo_destroy_appinfo(appinfo_h);
83         return NULL;
84 }