2 * mainmenu package manager
4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include <pkgmgr-info.h>
30 #include "cluster-home-debug.h"
31 #include "mainmenu-package-manager.h"
37 CMainMenuPackageManager::CMainMenuPackageManager()
39 , m_bListenCbPaused(false)
44 , m_bMMCMounted(false)
50 CMainMenuPackageManager::~CMainMenuPackageManager()
53 //UnregisterEdbusSignalHandler();
56 static void _OnMMCStatusChangedCb(keynode_t * node, void *data)
59 int ret = vconf_get_int("memory/sysman/mmc", &status);
61 CMainMenuPackageManager *pManager = static_cast<CMainMenuPackageManager*>(data);
63 pManager->OnMMCStatusChanged(status);
65 HOME_DBG("memory/sysman/mmc ret[%d] status [%d]", ret, status);
68 void CMainMenuPackageManager::OnMMCStatusChanged(int status)
70 HOME_DBG("BEGIN status[%d]", status);
71 m_bMMCMounted = status;
74 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_unmounted_list(_GetUnmountedAppsInfoCb, this))
76 HOME_ERR("pkgmgrinfo_appinfo_get_unmounted_list return false");
81 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_mounted_list(_GetMountedAppsInfoCb, this))
83 HOME_ERR("pkgmgrinfo_appinfo_get_mounted_list return false");
87 for(auto iter = m_AppInfoCache.begin(); iter != m_AppInfoCache.end(); iter++)
89 BoxDataPtr appInfoData = iter->second;
90 if (appInfoData->IsMMCApp())
92 HOME_DBG("app id [%s]", appInfoData->GetAppId().c_str());
93 m_fAppMoved(appInfoData->GetAppId().c_str());
96 HOME_DBG("END status[%d]", status);
99 int CMainMenuPackageManager::_PkgMgrClientListenCb(uid_t target_uid, int req_id, const char *pkg_type, const char *package, const char *key, const char *val, const void *pmsg, void *data)
101 CMainMenuPackageManager *pManager = static_cast<CMainMenuPackageManager*>(data);
103 pManager->OnClientListenCb( target_uid,req_id, pkg_type, package, key, val, pmsg, data);
109 static void _OnBootingDone(void *data, DBusMessage *msg)
113 ret = vconf_get_int("memory/sysman/mmc", &status);
114 HOME_DBG("memory/sysman/mmc ret[%d] status [%d]", ret, status);
116 CMainMenuPackageManager *pManager = static_cast<CMainMenuPackageManager*>(data);
118 pManager->OnMMCStatusChanged(status);
120 pManager->UnregisterEdbusSignalHandler();
125 bool CMainMenuPackageManager::_RegisterEdbusSignalHandler()
129 HOME_DBG("Register edbus signal handler");
132 while (e_dbus_init() == 0) {
135 HOME_ERR("e_dbus_init failed");
139 m_connEdbus = e_dbus_bus_get(DBUS_BUS_SYSTEM);
140 if (!(m_connEdbus)) {
141 HOME_ERR("e_dbus_bus_get failed");
142 goto edbus_handler_out;
145 m_hEdbus = e_dbus_signal_handler_add(m_connEdbus, NULL, "/Org/Tizen/System/DeviceD/Core",
146 "org.tizen.system.deviced.core", "BootingDone", _OnBootingDone, NULL);
148 HOME_ERR( "edbus_coord_rotation_handler failed");
149 goto edbus_handler_connection_out;
155 edbus_handler_connection_out:
158 e_dbus_connection_close(m_connEdbus);
166 void CMainMenuPackageManager::UnregisterEdbusSignalHandler()
170 if (m_connEdbus && m_hEdbus) {
171 e_dbus_signal_handler_del(m_connEdbus, m_hEdbus);
177 e_dbus_connection_close(m_connEdbus);
185 bool CMainMenuPackageManager::Initialize(const std::function<void(const char*)>& fAppInstalled,
186 const std::function<void(const char*)>& fAppUpdated,
187 const std::function<void(const char*)>& fAppUninstalled,
188 const std::function<void(const char*)>& fAppMoved)
191 m_fAppInstalled = fAppInstalled;
192 m_fAppUpdated = fAppUpdated;
193 m_fAppUninstalled = fAppUninstalled;
194 m_fAppMoved = fAppMoved;
196 if (vconf_notify_key_changed("memory/sysman/mmc", _OnMMCStatusChangedCb, this) != 0)
198 HOME_DBG("Failed to notify memory/sysman/mmc");
201 m_pClient = pkgmgr_client_new(PC_LISTENING);
202 if ( (ret = pkgmgr_client_listen_status( m_pClient, _PkgMgrClientListenCb, this)) != PKGMGR_R_OK)
204 HOME_ERR("pkgmgr_client_listen_status return [%d]", ret);
211 bool CMainMenuPackageManager::Terminate(void)
213 if (pkgmgr_client_free(m_pClient) != PKGMGR_R_OK)
215 HOME_ERR("cannot free pkgmgr_client for listen.");
222 int CMainMenuPackageManager::_PkgMgrAppInfoGetListCb(pkgmgrinfo_appinfo_h handle, void *user_data)
224 std::vector<std::string>* pList = static_cast<std::vector<std::string>*>(user_data);
226 bool bNoDisplay = false;
228 if (PMINFO_R_OK != pkgmgrinfo_appinfo_is_nodisplay(handle, &bNoDisplay)) return 0;
230 HOME_DBG("NoDisplay [%d]", bNoDisplay);
231 if (bNoDisplay == false)
233 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appid(handle, &appid)) return 0;
235 HOME_DBG("app Id [%s]", appid);
237 pList->push_back(appid);
241 HOME_ERR("this package is no display");
244 for(auto iter = pList->begin(); iter != pList->end(); iter++)
246 HOME_ERR("##### [%s]", iter->c_str());
252 int CMainMenuPackageManager::_PkgMgrDeactivatedAppInfoGetListCb(pkgmgrinfo_pkginfo_h handle, void *user_data)
254 std::vector<std::string>* pList = static_cast<std::vector<std::string>*>(user_data);
257 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_mainappid(handle, &sAppId)) return 0;
259 HOME_DBG("Deactivated app Id [%s]", sAppId);
263 pList->push_back(sAppId);
269 int CMainMenuPackageManager::_PkgMgrDeactivatedAppInfoGetCb(pkgmgrinfo_appinfo_h handle, void *user_data)
271 std::vector<std::string>* pList = static_cast<std::vector<std::string>*>(user_data);
277 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_pkgid(handle, &sPkgId))
279 VIEWER_ERR("Failed to get pkgid");
281 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_icon(handle, &sIcon))
283 VIEWER_ERR("Failed to get icon");
285 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_label(handle, &sName))
287 VIEWER_ERR("Failed to get name");
290 // CHECK : is other info needed?
292 VIEWER_DBG("Deactivated pkg info [%s][%s][%s]", sPkgId, sIcon, sName);
296 pList->push_back(sPkgId);
300 pList->push_back(sIcon);
304 pList->push_back(RESDIR"/images/default_app_icon.png");
310 pList->push_back(sName);
316 int CMainMenuPackageManager::_PkgMgrDeactivatedPkgInfoGetCb(pkgmgrinfo_pkginfo_h handle, void *user_data)
318 std::vector<std::string>* pList = static_cast<std::vector<std::string>*>(user_data);
321 char *sPkgType = NULL;
323 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_pkgid(handle, &sPkgId))
325 VIEWER_ERR("Failed to get pkgid");
327 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_get_type(handle, &sPkgType))
329 VIEWER_ERR("Failed to get type");
332 VIEWER_DBG("Deactivated pkg info [%s][%s]", sPkgId, sPkgType);
336 pList->push_back(sPkgType);
342 std::vector<std::string> CMainMenuPackageManager::_GetAppIds(const char* pPackage)
345 std::vector<std::string> list;
346 pkgmgrinfo_pkginfo_h handle = NULL;
347 if (pkgmgrinfo_pkginfo_get_pkginfo(pPackage, &handle) == PMINFO_R_OK )
349 if (pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, _PkgMgrAppInfoGetListCb, &list) != PMINFO_R_OK)
351 HOME_ERR("pkgmgrinfo_appinfo_get_list != PMINFO_R_OK");
355 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
360 HOME_ERR("pkgmgrinfo_pkginfo_get_pkginfo[%s] != PMINFO_R_OK ", pPackage);
363 for(auto iter = list.begin(); iter != list.end(); iter++)
365 HOME_ERR("##### [%s]", iter->c_str());
374 bool CMainMenuPackageManager::StartListenCb()
376 m_bListenCbPaused = false;
378 for(auto iter = m_PkgReqQueue.begin(); iter != m_PkgReqQueue.end(); iter++)
383 m_PkgReqQueue.clear();
387 bool CMainMenuPackageManager::PauseListenCb()
389 m_bListenCbPaused = true;
393 bool CMainMenuPackageManager::_DoPkgJob(shared_ptr<PkgData> data)
395 if ( data->m_eType == REQ_INSTALL || data->m_eType == REQ_UPDATE)
396 data->m_AppIds = _GetAppIds(data->m_strPackage.c_str());
397 HOME_ERR("#Step 3 size[%d]", data->m_AppIds.size());
398 for(auto iter2 = data->m_AppIds.begin(); iter2 != data->m_AppIds.end(); iter2++)
400 std::string strAppId(*iter2);
401 HOME_ERR("appId[%s]", strAppId.c_str());
403 auto iter = m_AppInfoCache.find(strAppId);
405 if (iter != m_AppInfoCache.end())
406 m_AppInfoCache.erase(iter);
408 switch(data->m_eType)
412 BoxDataPtr data(new CMainMenuBoxData);
413 if (_GetAppInfo(strAppId, data))
415 if (data->IsEnabled())
416 m_fAppInstalled(strAppId.c_str());
421 m_fAppUninstalled(strAppId.c_str());
425 BoxDataPtr data(new CMainMenuBoxData);
426 if (_GetAppInfo(strAppId, data))
428 if (data->IsEnabled())
429 m_fAppUpdated(strAppId.c_str());
431 m_fAppUninstalled(strAppId.c_str());
444 int CMainMenuPackageManager::OnClientListenCb(uid_t target_uid,int req_id, const char *pkg_type, const char *package, const char *key, const char *val, const void *pmsg, void *data)
446 HOME_DBG("req_id[%d] pkg_type[%s] package[%s] key[%s] val[%s] pmsg[%s]", req_id, pkg_type, package, key, val, pmsg);
448 std::string strKey(key), strVal(val), strPkg(package);
450 if (strKey.compare("start") == 0 )
452 shared_ptr<PkgData> data(new PkgData);
454 if (strVal.compare("install") == 0) {
455 data->m_eType = REQ_INSTALL;
456 } else if (strVal.compare("update") == 0) {
457 data->m_eType = REQ_UPDATE;
458 } else if (strVal.compare("uninstall") == 0) {
459 data->m_eType = REQ_UNINSTALL;
460 data->m_AppIds = _GetAppIds(package);
462 data->m_eType = REQ_NONE;
463 HOME_ERR("Req Val [%s:%s]", key, val);
466 data->m_nReqId = req_id;
467 data->m_strPackage = strPkg;
469 m_PkgReqList[strPkg] = data;
471 else if (strKey.compare("end") == 0 && strVal.compare("ok") == 0)
474 auto iter = m_PkgReqList.find(strPkg);
475 if (iter != m_PkgReqList.end())
478 shared_ptr<PkgData> data = m_PkgReqList[strPkg];
479 m_PkgReqList.erase(iter);
481 if (m_bListenCbPaused)
483 m_PkgReqQueue.push_back(data);
492 else if (strKey.compare("end") == 0 && strVal.compare("fail") == 0)
494 auto iter = m_PkgReqList.find(strPkg);
495 if (iter != m_PkgReqList.end())
497 m_PkgReqList.erase(iter);
504 bool CMainMenuPackageManager::GetAppInfo(string appId, BoxDataPtr data)
506 auto iter = m_AppInfoCache.find(appId);
508 if (iter != m_AppInfoCache.end())
510 BoxDataPtr appInfoData = iter->second;
512 if (appInfoData->GetName().length() > 0 && appInfoData->GetIconPath().length())
514 data->SetPkgId(appInfoData->GetPkgId());
515 data->SetPkgType(appInfoData->GetPkgType());
517 data->SetIconPath(appInfoData->GetIconPath());
519 data->SetName(appInfoData->GetName());
520 data->SetNoDisplay(appInfoData->IsNoDisplay());
521 data->SetEnabled(appInfoData->IsEnabled());
522 data->SetRemovable(appInfoData->IsRemovable());
523 data->SetMenuLaunch(appInfoData->IsMenuLaunch());
524 data->SetTime(appInfoData->GetTime());
525 data->SetPreloaded(appInfoData->IsPreloaded());
526 data->SetSystem(appInfoData->IsSystem());
527 data->SetSupportDisable(appInfoData->IsSupportDisable());
528 //data->SetBadgeCount(appInfoData->GetBadgeCount());
529 data->SetMMCApp(appInfoData->IsMMCApp());
530 data->SetUnmountedApp(appInfoData->IsUnmountedApp());
532 HOME_ERR("Find a App Info AppId[%s] Name[%s] Icon[%s] enable[%d] system[%d]", appId.c_str(),
533 appInfoData->GetName().c_str(), appInfoData->GetIconPath().c_str(), appInfoData->IsEnabled(), appInfoData->IsSystem());
537 m_AppInfoCache.erase(iter);
540 return _GetAppInfo(appId, data);
543 bool CMainMenuPackageManager::_GetAppInfo(string appId, BoxDataPtr data)
546 pkgmgrinfo_appinfo_h app_handle = NULL;
547 int ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &app_handle);
549 if (PMINFO_R_OK != ret) {
550 HOME_ERR("pkgmgrinfo_appinfo_get_appinfo return [%d]", ret);
554 result = _GetAppInfo(app_handle, data);
556 pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
563 bool CMainMenuPackageManager::GetAppName(string appId, BoxDataPtr data)
565 return _GetAppInfo(appId, data);
568 bool CMainMenuPackageManager::GetDeactivatedAppInfo(std::string appId, BoxDataPtr data)
570 auto iter = m_AppInfoCache.find(appId);
572 if (iter != m_AppInfoCache.end())
574 HOME_DBG("Find a App Info[%s]", appId.c_str());
575 BoxDataPtr appInfoData = iter->second;
577 if (appInfoData->GetName().length() > 0 && appInfoData->GetIconPath().length())
579 data->SetPkgId(appInfoData->GetPkgId());
580 data->SetPkgType(appInfoData->GetPkgType());
582 data->SetIconPath(appInfoData->GetIconPath());
583 data->SetName(appInfoData->GetName());
587 m_AppInfoCache.erase(iter);
590 return _GetDeactivatedAppInfo(appId, data);
593 bool CMainMenuPackageManager::_GetDeactivatedAppInfo(std::string appId, BoxDataPtr data)
595 pkgmgrinfo_appinfo_filter_h handle = NULL;
597 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_create(&handle))
599 HOME_DBG("Failed to create appinfo filter");
603 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, appId.c_str()))
605 HOME_DBG("Failed to add filter");
606 pkgmgrinfo_appinfo_filter_destroy(handle);
611 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_DISABLE, true))
613 HOME_DBG("Failed to add filter");
614 pkgmgrinfo_appinfo_filter_destroy(handle);
619 // TODO: to get app info, create new struct
620 std::vector<std::string> list;
621 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, _PkgMgrDeactivatedAppInfoGetCb, &list))
623 HOME_DBG("Failed to foreach appinfo");
624 pkgmgrinfo_appinfo_filter_destroy(handle);
628 if (list.size() == 3)
630 data->SetPkgId(list[0]);
631 data->SetIconPath(list[1]);
632 data->SetName(list[2]);
634 _GetDeactivatedPkgInfo(list[0], data);
638 HOME_DBG("Failed to get [%s] size[%d]", appId.c_str(), list.size());
639 pkgmgrinfo_appinfo_filter_destroy(handle);
643 //m_AppInfoCache[data->GetAppId()] = data;
645 pkgmgrinfo_appinfo_filter_destroy(handle);
649 bool CMainMenuPackageManager::_GetDeactivatedPkgInfo(std::string pkgId, BoxDataPtr data)
651 pkgmgrinfo_pkginfo_filter_h handle = NULL;
653 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_filter_create(&handle))
655 HOME_DBG("Failed to create pkginfo filter");
661 HOME_DBG("Error: Handle is NULL!");
665 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgId.c_str()))
667 HOME_DBG("Failed to add filter");
668 pkgmgrinfo_pkginfo_filter_destroy(handle);
673 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true))
675 HOME_DBG("Failed to add filter");
676 pkgmgrinfo_pkginfo_filter_destroy(handle);
680 // TODO: to get app info, create new struct
681 std::vector<std::string> list;
682 if (PMINFO_R_OK != pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, _PkgMgrDeactivatedPkgInfoGetCb, &list))
684 HOME_DBG("Failed to foreach pkginfo");
685 pkgmgrinfo_pkginfo_filter_destroy(handle);
689 if (list.size() == 1)
691 data->SetPkgType(list[0]);
695 HOME_DBG("Failed to get [%s] size[%d]", pkgId.c_str(), list.size());
696 pkgmgrinfo_pkginfo_filter_destroy(handle);
700 pkgmgrinfo_pkginfo_filter_destroy(handle);
704 #define METADATA_MENU_LAUNCH_KEY "http://developer.samsung.com/tizen/metadata/menu/launch/operation"
705 #define METADATA_MENU_LAUNCH_VALUE "http://tizen.org/appcontrol/operation/main"
706 static int _app_metadata_list_cb(const char *metadata_name, const char *metadata_value, void *user_data)
708 RETV_IF(NULL == user_data, 0);
710 if (!metadata_name || !metadata_value) return 0;
711 if (!strcmp(metadata_name , METADATA_MENU_LAUNCH_KEY) &&
712 !strcmp(metadata_value, METADATA_MENU_LAUNCH_VALUE))
714 * (bool *) user_data = true;
721 bool CMainMenuPackageManager::_IsMenuLaunch(std::string appId)
723 bool menu_launch = false;
725 pkgmgrinfo_appinfo_filter_h handle = NULL;
726 pkgmgrinfo_appinfo_h app_handle = NULL;
728 RETV_IF(PMINFO_R_OK != pkgmgrinfo_appinfo_filter_create(&handle), NULL);
729 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_ID, appId.c_str())) goto ERROR;
732 pkgmgrinfo_appinfo_filter_destroy(handle);
736 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &app_handle)) goto ERROR;
737 if (PMINFO_R_OK != pkgmgrinfo_appinfo_foreach_metadata(app_handle, _app_metadata_list_cb, &menu_launch)) goto ERROR;
739 pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
740 pkgmgrinfo_appinfo_filter_destroy(handle);
744 if (app_handle) pkgmgrinfo_appinfo_destroy_appinfo(app_handle);
745 if (handle) pkgmgrinfo_appinfo_filter_destroy(handle);
749 bool CMainMenuPackageManager::_GetAppInfo(pkgmgrinfo_appinfo_h app_handle, BoxDataPtr data)
752 char *pkg_type = NULL;
756 bool nodisplay = false;
758 bool is_system = false;
759 bool removable = true;
760 int installed_time = 0;
761 bool is_preload = false;
762 bool is_support_disable = false;
766 ret = pkgmgrinfo_appinfo_get_appid(app_handle, &appid);
767 if (PMINFO_R_OK != ret) {
768 HOME_ERR("pkgmgrinfo_appinfo_get_appid return [%d]", ret);
772 ret = pkgmgrinfo_appinfo_get_pkgid(app_handle, &pkg_id);
773 if (PMINFO_R_OK != ret) {
774 HOME_ERR("pkgmgrinfo_appinfo_get_pkgid return [%d]", ret);
778 ret = pkgmgrinfo_appinfo_get_icon(app_handle, &icon);
779 if (PMINFO_R_OK != ret) {
780 HOME_ERR("pkgmgrinfo_appinfo_get_icon return [%d]", ret);
784 ret = pkgmgrinfo_appinfo_get_label(app_handle, &name);
785 if (PMINFO_R_OK != ret) {
786 HOME_ERR("pkgmgrinfo_appinfo_get_label return [%d]", ret);
791 ret = pkgmgrinfo_appinfo_is_nodisplay(app_handle, &nodisplay);
792 if (PMINFO_R_OK != ret) {
793 HOME_ERR("pkgmgrinfo_appinfo_is_nodisplay return [%d]", ret);
797 ret = pkgmgrinfo_appinfo_is_enabled(app_handle, &enabled);
798 if (PMINFO_R_OK != ret) {
799 HOME_ERR("pkgmgrinfo_appinfo_is_enabled return [%d]", ret);
804 ret = pkgmgrinfo_appinfo_get_pkgtype(app_handle, &pkg_type);
805 if (PMINFO_R_OK != ret) {
806 HOME_ERR("pkgmgrinfo_pkginfo_get_type return [%d]", ret);
809 ret = pkgmgrinfo_appinfo_is_system(app_handle, &is_system);
810 if (PMINFO_R_OK != ret) {
811 HOME_ERR("pkgmgrinfo_pkginfo_is_system return [%d]", ret);
814 ret = pkgmgrinfo_appinfo_is_removable(app_handle, &removable);
815 if (PMINFO_R_OK != ret) {
816 HOME_ERR("pkgmgrinfo_pkginfo_is_removable return [%d]", ret);
820 ret = pkgmgrinfo_appinfo_get_installed_time(app_handle, &installed_time);
821 if (PMINFO_R_OK != ret) {
822 HOME_ERR("pkgmgrinfo_pkginfo_get_installed_time return [%d]", ret);
826 ret = pkgmgrinfo_appinfo_is_preload(app_handle, &is_preload);
827 if (PMINFO_R_OK != ret) {
828 HOME_ERR("pkgmgrinfo_appinfo_is_preload return [%d]", ret);
832 ret = pkgmgrinfo_appinfo_is_support_disable(app_handle, &is_support_disable);
833 if (PMINFO_R_OK != ret) {
834 HOME_ERR("pkgmgrinfo_pkginfo_is_support_disable return [%d]", ret);
840 data->SetPkgId(pkg_id);
842 data->SetPkgType(pkg_type);
846 FILE *fp = fopen(icon, "r");
850 data->SetIconPath(icon);
853 data->SetIconPath(RESDIR"/images/default_app_icon.png");
856 data->SetIconPath(RESDIR"/images/default_app_icon.png");
861 data->SetAppId(appid);
865 data->SetNoDisplay(nodisplay);
867 data->SetEnabled(enabled);
869 data->SetRemovable(removable);;
870 data->SetTime(installed_time);
871 data->SetPreloaded(is_preload);
872 data->SetSystem(is_system);
873 data->SetSupportDisable(is_support_disable);
875 HOME_ERR("AppId[%s] Name[%s] Icon[%s] enable[%d] system[%d]", appid, data->GetName().c_str(), data->GetIconPath().c_str(), enabled, is_system);
877 m_AppInfoCache[data->GetAppId()] = data;
882 HOME_ERR("AppId[%s] failed to get pkginfo", appid);
887 int CMainMenuPackageManager::_GetAllAppsInfoCb(pkgmgrinfo_appinfo_h handle, void *user_data)
889 RETV_IF(NULL == handle, 0);
890 RETV_IF(NULL == user_data, 0);
891 CMainMenuPackageManager* pThis = (CMainMenuPackageManager*)user_data;
892 BoxDataPtr data(new CMainMenuBoxData);
894 pThis->_GetAppInfo(handle, data);
900 int CMainMenuPackageManager::_GetUnmountedAppsInfoCb(pkgmgrinfo_appinfo_h handle, void *user_data)
902 RETV_IF(NULL == handle, 0);
903 RETV_IF(NULL == user_data, 0);
904 CMainMenuPackageManager* pThis = (CMainMenuPackageManager*)user_data;
906 BoxDataPtr data(new CMainMenuBoxData);
909 pThis->_GetAppInfo(handle, data);
911 data->SetIconPath(RESDIR"/images/uninstalled_sd.png");
912 data->SetMMCApp(true);
913 data->SetUnmountedApp(true);
915 HOME_DBG("app id [%s]", data->GetAppId().c_str());
920 int CMainMenuPackageManager::_GetMountedAppsInfoCb(pkgmgrinfo_appinfo_h handle, void *user_data)
922 RETV_IF(NULL == handle, 0);
923 RETV_IF(NULL == user_data, 0);
924 CMainMenuPackageManager* pThis = (CMainMenuPackageManager*)user_data;
926 BoxDataPtr data(new CMainMenuBoxData);
928 pThis->_GetAppInfo(handle, data);
929 data->SetMMCApp(true);
931 HOME_DBG("app id [%s]", data->GetAppId().c_str());
936 bool CMainMenuPackageManager::GetAppIdList(std::vector<std::string>& list)
939 pkgmgrinfo_appinfo_filter_h handle = NULL;
940 HOME_WARN("# BEGIN");
942 if (m_AppInfoCache.size() == 0)
944 RETV_IF(PMINFO_R_OK != pkgmgrinfo_appinfo_filter_create(&handle), false);
945 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, false)) goto ERROR;
946 // if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_DISABLE, false)) goto ERROR;
947 if (PMINFO_R_OK != pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, CMainMenuPackageManager::_GetAllAppsInfoCb, this)) goto ERROR;
950 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_unmounted_list(_GetUnmountedAppsInfoCb, this)) goto ERROR;
952 ret = vconf_get_int("memory/sysman/mmc", &status);
955 if (ret == 0 && status == 1)
956 if (PMINFO_R_OK != pkgmgrinfo_appinfo_get_mounted_list(_GetMountedAppsInfoCb, this)) goto ERROR;
960 for(auto iter = m_AppInfoCache.begin(); iter != m_AppInfoCache.end(); iter++)
962 BoxDataPtr appInfoData = iter->second;
963 if (appInfoData->IsEnabled())
964 list.push_back(appInfoData->GetAppId());
967 std::sort(list.begin(), list.end());
969 pkgmgrinfo_appinfo_filter_destroy(handle);
974 if (handle) pkgmgrinfo_appinfo_filter_destroy(handle);