removed redundant code
authorYoung Ik Cho <youngik.cho@samsung.com>
Wed, 23 Oct 2013 10:17:29 +0000 (19:17 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Wed, 23 Oct 2013 10:17:29 +0000 (19:17 +0900)
Change-Id: If3f9687ee42378daa1218ecaebdcb29794347e91
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_Aul.cpp
src/app/inc/FApp_AppControlManager.h
src/app/inc/FApp_Aul.h

index b51f12c..899c9ea 100644 (file)
@@ -447,44 +447,23 @@ _AppControlImpl::GetAppName(void) const
        if (_appName.IsEmpty())
        {
                AppId appId = GetAppId();
-               AppId aliasAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(appId);
+               const AppId& aliasAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(appId);
                if (!aliasAppId.IsEmpty())
                {
                        appId = aliasAppId;
                }
 
+               appId = _Aul::GetRealAppId(appId);
+
                std::unique_ptr<PackageAppInfo> pInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(appId));
                if (pInfo.get())
                {
-                       SysLog(NID_APP, "PackageInfo of appId(%ls) exists", appId.GetPointer());
-                       const String& name = pInfo->GetAppName();
-                       if (name == String(SUBMODE_NAME))
-                       {
-                               // workaround for special case: requery with actual appId
-                               const PackageId& packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
-                               const String& defaultName = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(packageId);
-
-                               const String& convertedAppId = packageId + L'.' + defaultName;
-
-                               std::unique_ptr<PackageAppInfo> pNewInfo(_PackageManagerImpl::GetInstance()->GetPackageAppInfoN(convertedAppId));
-
-                               if (pNewInfo.get())
-                               {
-                                       _appName = pNewInfo->GetAppDisplayName();
-                               }
-                               else
-                               {
-                                       SysLog(NID_APP, "No default applicaiton information, possible database error.");
-                               }
-                       }
-                       else
-                       {
-                               _appName = pInfo->GetAppDisplayName();
-                       }
+                       SysLog(NID_APP, "PackageInfo of [%ls] exists.", appId.GetPointer());
+                       _appName = pInfo->GetAppDisplayName();
                }
                else
                {
-                       SysLog(NID_APP, "PackageInfo of appId(%ls) does not exist", appId.GetPointer());
+                       SysLog(NID_APP, "PackageInfo of [%ls] does not exist.", appId.GetPointer());
                }
        }
 
index ee295bf..c2b933d 100644 (file)
@@ -582,36 +582,14 @@ _AppControlManager::LaunchPkg(_AppMessageImpl& msg, AppSvcResFn pCb, void* data)
 
 
 result
-_AppControlManager::LaunchPkg(const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data)
-{
-       _AppMessageImpl msg;
-
-       return LaunchPkg(msg, pkg_name, op, mime, uri, pCb, data);
-}
-
-result
-_AppControlManager::LaunchAppWithCondition(const AppId& appId, const String& condition, IList* pArrayArgs)
-{
-       result r = E_SUCCESS;
-       _AppArg * pArg = new (std::nothrow) _AppArg();
-       SysTryCatch(NID_APP, pArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
-
-       r = pArg->ConstructForAppLaunchCondition(condition, pArrayArgs);
-       SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] ConstructForAppLaunchCondition(%ls, .. ) fails", GetErrorMessage(r), condition.GetPointer());
-
-       r = _AppControlManager::LaunchApp(appId, pArg);
-CATCH:
-       delete pArg;
-       return r;
-}
-
-result
 _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
 {
        SysTryReturnResult(NID_APP, pArg != null, E_INVALID_ARG, "Invalid launch argument");
        SysLog(NID_APP, "App: %ls.", appId.GetPointer());
 
        String actualAppId = appId;
+#if 0
+       // This logic is only for very old legacy code to support "pkgid" launch and should be removed
        if (appId.GetLength() == 10)
        {
                const String& name = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(appId);
@@ -622,6 +600,7 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
                        actualAppId.Append(name);
                }
        }
+#endif
 
        pArg->UpdateRequestId(req);
 
index d5cf730..6abde09 100644 (file)
@@ -30,6 +30,7 @@
 #include <bundle.h>
 #include <appsvc/appsvc.h>
 #include <vconf.h>
+#include <pkgmgr-info.h>
 
 #include <FBaseObject.h>
 #include <FBaseString.h>
@@ -282,27 +283,43 @@ _Aul::IsInstalled(const AppId& appId)
 }
 
 
+String
+_Aul::GetMainAppId(const char* appid)
+{
+       pkgmgrinfo_appinfo_h handle = NULL;
+       int ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+       {
+               return String();
+       }
+
+       char* mainid = NULL;
+       ret = pkgmgrinfo_appinfo_get_submode_mainid(handle, &mainid);
+       SysTryLog(NID_APP, ret == PMINFO_R_OK, "Cannot get main id for %s.", appid);
+
+       const String tmp = String(mainid);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return tmp;
+}
+
+
 AppId
 _Aul::GetRealAppId(const AppId& appId)
 {
        String temp;
-       // [INFO] ugly code for submode callee
        appId.SubString(11, temp);
        if (temp == String(SUBMODE_NAME))
        {
-               String id;
-               appId.SubString(0, 10, id);
-               const String& name = _PackageManagerImpl::GetInstance()->GetDefaultAppExecutableName(id);
-
-               const String retVal = id + L'.' + name;
-               SysLog(NID_APP, "Converted caller Id is %ls", retVal.GetPointer());
-
-               return retVal;
-       }
-       else
-       {
-               return appId;
+               std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+               const String& main = GetMainAppId(pAppId.get());
+               if (!main.IsEmpty())
+               {
+                       SysLog(NID_APP, "main Id is %ls", main.GetPointer());
+                       return main;
+               }
        }
+
+       return appId;
 }
 
 } } // Tizen::App
index 1976db8..e3cf44b 100644 (file)
@@ -139,11 +139,6 @@ public:
        int Launch(const _AppMessageImpl& msg, AppSvcResFn pCb, void* pData, int req = -1);
 
        /**
-        * Launch with pkgname.(osp-app-service : AppService.cpp)
-        */
-       result LaunchPkg(const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
-
-       /**
         * Launch with pkgname.(osp-uifw : FUiCtrl_EditCopyPasteManager.cpp)
         */
        result LaunchPkg(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
@@ -155,8 +150,6 @@ public:
 
        int Launch(_AppMessageImpl& msg, const char* pkg_name, const char* op, const char* mime, const char* uri, AppSvcResFn pCb, void* data);
        
-       result LaunchAppWithCondition(const AppId& appId, const Tizen::Base::String& condition, Tizen::Base::Collection::IList* pArgs);
-
        result SendAppControlStartResponse(int req, const char* pValue, const char* pOp);
 
        _OSP_LOCAL_ static Tizen::Base::String GetMimeTypeFromDataType(const Tizen::Base::String& dataType);
index 08133c2..39abc37 100644 (file)
@@ -60,6 +60,8 @@ public:
 
        static bool IsInstalled(const AppId& appId);
 
+       _OSP_LOCAL_ static Tizen::Base::String GetMainAppId(const char* appid);
+
        _OSP_LOCAL_ static AppId GetRealAppId(const AppId& appId);
 
 public: