Update for user preference for AppControl resolution
authorJaesung Ku <jaesung.ku@samsung.com>
Fri, 21 Jun 2013 03:07:53 +0000 (12:07 +0900)
committerJaesung Ku <jaesung.ku@samsung.com>
Fri, 21 Jun 2013 03:07:53 +0000 (12:07 +0900)
Change-Id: I64c31505b8540f9d493325a836fb27b54bff819e
Signed-off-by: Jaesung Ku <jaesung.ku@samsung.com>
inc/FAppAppManager.h
src/app/FAppAppManager.cpp [changed mode: 0644->0755]
src/app/FApp_AppManagerImpl.cpp [changed mode: 0644->0755]
src/app/FApp_AppManagerProxy.cpp [changed mode: 0644->0755]
src/app/inc/FApp_AppManagerImpl.h [changed mode: 0644->0755]
src/app/inc/FApp_AppManagerIpcMessage.h [changed mode: 0644->0755]
src/app/inc/FApp_AppManagerProxy.h [changed mode: 0644->0755]
src/app/inc/FApp_IAppManager.h [changed mode: 0644->0755]
src/server/app/FApp_AulServer.cpp
src/server/inc/FApp_AulServer.h

index a0e84e1..6e3dd36 100755 (executable)
@@ -711,6 +711,42 @@ public:
         */
        result GetActiveApp(AppId& appId);
 
+       /**
+        * Checks whether the specified application is declared as preferred application for any AppControl resolution
+        *
+        * @since         2.2
+        * @privlevel      platform
+        * @privilege     %http://tizen.org/privilege/appmanager.setting
+        *
+        * @return        @c true if the application is running, @n
+        *           else @c false
+        * @param[in]    appId                         Application ID
+        * @exception    E_SUCCESS                   The method is successful.
+        * @exception    E_SYSTEM                    The method cannot proceed due to a severe system error.
+        * @exception    E_APP_NOT_INSTALLED    The specified application is not installed.
+        * @exception    E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @remarks      The specific error code can be accessed using the GetLastResult() method.
+        * @remarks      For more information on AppControl resolution, see <a href="../org.tizen.native.appprogramming/html/guide/app/app_controls.htm">Application Controls</a>.
+        */
+       bool IsUserPreferredAppForAppControlResolution(const AppId& appId) const;           
+
+       /**
+        * Clear user preference for all AppControl resolutions on the specified application.
+        *
+        * @since         2.2
+        * @privlevel      platform
+        * @privilege     %http://tizen.org/privilege/appmanager.setting
+        *
+        * @return        An error code
+        * @param[in]    appId                         The preferred application's ID
+        * @exception    E_SUCCESS                   The method is successful. 
+        * @exception    E_SYSTEM                    The method cannot proceed due to a severe system error.
+        * @exception    E_APP_NOT_INSTALLED    The specified application is not installed.
+        * @exception    E_PRIVILEGE_DENIED       The application does not have the privilege to call this method.
+        * @remarks      For more information on AppControl resolution, see <a href="../org.tizen.native.appprogramming/html/guide/app/app_controls.htm">Application Controls</a>.
+        */
+       result ClearUserPreferenceForAppControlResolution(const AppId& appId);
+
 private:
        /**
         * This default constructor is intentionally declared as private to implement the %Singleton semantic.
old mode 100644 (file)
new mode 100755 (executable)
index 63ead16..719256c
@@ -370,4 +370,22 @@ AppManager::GetActiveApp(AppId& appId)
        return __pAppManagerImpl->GetActiveApp(appId);
 }
 
+bool 
+AppManager::IsUserPreferredAppForAppControlResolution(const AppId& appId) const
+{
+       SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
+       SysTryReturn(NID_APP, _Aul::IsInstalled(appId) == true, false, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
+
+       return __pAppManagerImpl->IsUserPreferredAppForAppControlResolution(appId);
+}
+
+result 
+AppManager::ClearUserPreferenceForAppControlResolution(const AppId& appId)
+{
+       SysAssertf(__pAppManagerImpl != null, "Not constructed properly by platform.");
+       SysTryReturnResult(NID_APP, _Aul::IsInstalled(appId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", appId.GetPointer());
+
+       return __pAppManagerImpl->ClearUserPreferenceForAppControlResolution(appId);
+}
+
 }} // Tizen::App
old mode 100644 (file)
new mode 100755 (executable)
index 624196d..99f3f56
@@ -1245,4 +1245,22 @@ _AppManagerImpl::GetActiveApp(AppId& appId)
        return E_SUCCESS;
 }
 
+bool 
+_AppManagerImpl::IsUserPreferredAppForAppControlResolution(const AppId& appId) const
+{
+       _IAppManager* pMgr = _AppManagerProxy::GetService();
+       SysTryReturn(NID_APP, pMgr, false, E_SYSTEM, "Failed to _AppManagerProxy::GetService().");
+
+       return pMgr->IsUserPreferredAppForAppControlResolution(appId);
+}
+
+result 
+_AppManagerImpl::ClearUserPreferenceForAppControlResolution(const AppId& appId)
+{
+       _IAppManager* pMgr = _AppManagerProxy::GetService();
+       SysTryReturnResult(NID_APP, pMgr, E_SYSTEM, "Failed to _AppManagerProxy::GetService().");
+
+       return pMgr->ClearUserPreferenceForAppControlResolution(appId);
+}
+
 }} // Tizen::App
old mode 100644 (file)
new mode 100755 (executable)
index e7023ee..56e76af
@@ -250,5 +250,33 @@ _AppManagerProxy::RemoveEventListener(int clientId)
        return E_SUCCESS;
 }
 
+bool 
+_AppManagerProxy::IsUserPreferredAppForAppControlResolution(const AppId& appId)
+{
+       SysLog(NID_APP, "begin.");
+       bool isUserPreferredApp = false;
+       result response = E_SUCCESS;
+       
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_IsUserPreferredAppForAppControlResolution(appId, &isUserPreferredApp, &response));
+       result r = __pIpcClient->SendRequest(*pMsg.get());
+       SysTryReturn(NID_APP, !IsFailed(r), false, r, "SendRequest is failed.");
+
+       SetLastResult(response);
+       SysLog(NID_APP, "end.");        
+       return isUserPreferredApp;
+}
+
+result 
+_AppManagerProxy::ClearUserPreferenceForAppControlResolution(const AppId& appId)
+{
+       SysLog(NID_APP, "begin.");
+       result response = E_SUCCESS;
+       std::auto_ptr<IPC::Message> pMsg (new (std::nothrow) AppManager_ClearUserPreferenceForAppControlResolution(appId, &response));
+       result r = __pIpcClient->SendRequest(*pMsg.get());
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed.");
+
+       SysLog(NID_APP, "end.");
+       return response;
+}
 
 } } // Tizen::App
old mode 100644 (file)
new mode 100755 (executable)
index 37f87e8..ef49d07
@@ -378,6 +378,10 @@ public:
 
        void FireActiveAppEvent(unsigned int xid, int pid, char* pAppName);
 
+       bool IsUserPreferredAppForAppControlResolution(const AppId& appId) const;
+
+       result ClearUserPreferenceForAppControlResolution(const AppId& appId);
+
 private:
        _OSP_LOCAL_ _AppManagerImpl(void);
 
old mode 100644 (file)
new mode 100755 (executable)
index 3d46fdc..fa0ac1a
@@ -34,6 +34,8 @@
 IPC_MESSAGE_CONTROL2(AppManager_LaunchApplication, Tizen::App::AppId, int)
 IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_TerminateApplication, Tizen::App::AppId, result)
 IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_IsRunning, Tizen::App::AppId, bool)
+IPC_SYNC_MESSAGE_CONTROL1_2(AppManager_IsUserPreferredAppForAppControlResolution, Tizen::App::AppId, bool, result)
+IPC_SYNC_MESSAGE_CONTROL1_1(AppManager_ClearUserPreferenceForAppControlResolution, Tizen::App::AppId, result)
 IPC_SYNC_MESSAGE_CONTROL0_2(AppManager_GetRunningAppList, Tizen::Base::Collection::ArrayList, result)
 IPC_MESSAGE_CONTROL4(AppManager_RegisterApplication, Tizen::App::AppId, Tizen::Base::String, int, int)
 IPC_MESSAGE_CONTROL1(AppManager_UnregisterApplication, int)
old mode 100644 (file)
new mode 100755 (executable)
index f16c8ec..6408dbc
@@ -67,6 +67,10 @@ public:
 
        virtual result UnregisterApplication(int pid);
 
+       virtual bool IsUserPreferredAppForAppControlResolution(const AppId& appId);
+       
+       virtual result ClearUserPreferenceForAppControlResolution(const AppId& appId);
+
        static _IAppManager* GetService(void);
 
        static void SetService(_IAppManager* pAppManager);
old mode 100644 (file)
new mode 100755 (executable)
index 5cb0a21..5108c76
@@ -49,6 +49,9 @@ public:
        virtual result InitEventListener(_IAppManagerServiceEventListener* pListener) = 0;
        virtual result AddEventListener(int clientId) = 0;//, _IAppManagerServiceEventListener* pListener) = 0;
        virtual result RemoveEventListener(int clientId) = 0;//, _IAppManagerServiceEventListener* pListener) = 0;
+
+       virtual bool IsUserPreferredAppForAppControlResolution(const AppId& appId) = 0;
+       virtual result ClearUserPreferenceForAppControlResolution(const AppId& appId) = 0;
 };
 
 }} // Tizen::App
index e8f1388..868505e 100755 (executable)
@@ -350,6 +350,30 @@ int _AulServer::CreateProcess(const AppId& appId)
 
 }
 
+bool
+_AulServer::IsUserPreferredAppForAppControlResolution(const AppId& appId)
+{
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+
+       int ret = appsvc_is_defapp(pAppId.get());
+       SysTryReturn(NID_APP, ret == 1, false, E_SUCCESS,"%ls is not an UserPreferredAppForAppControlResolution. ret(%d)", appId.GetPointer(), ret);
+       
+       SysLog(NID_APP, "%ls is an UserPreferredAppForAppControlResolution.", appId.GetPointer());      
+       return true;
+}
+
+result
+_AulServer::ClearUserPreferenceForAppControlResolution(const AppId& appId)
+{
+       std::unique_ptr<char[]> pAppId(_StringConverter::CopyToCharArrayN(appId));
+
+       int ret_aul = appsvc_unset_defapp(pAppId.get());
+       SysTryReturnResult(NID_APP, ret_aul == APPSVC_RET_OK, E_SYSTEM, "Fail to clear UserPreferredAppForAppControlResolution of %ls. ret_aul(%d)", appId.GetPointer(), ret_aul);
+
+       SysLog(NID_APP, "Succeed to clear UserPreferredAppForAppControlResolution of %ls.", appId.GetPointer());
+       return E_SUCCESS;
+}
+
 result
 _AulServer::_DesktopFile::MakePath(const AppId& appId, const String* pExeName, char* path, int size)
 {
index b958296..ab22aea 100755 (executable)
@@ -61,6 +61,10 @@ public:
 
        static int CreateProcess(const Tizen::Base::String& appId);
 
+       static bool IsUserPreferredAppForAppControlResolution(const AppId& appId);
+       
+       static result ClearUserPreferenceForAppControlResolution(const AppId& appId);
+
 public:
        /**
         * This is static helper class for desktop file.