minor code cleanup
authorYoung Ik Cho <youngik.cho@samsung.com>
Tue, 15 Oct 2013 01:46:02 +0000 (10:46 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Tue, 15 Oct 2013 09:12:53 +0000 (18:12 +0900)
Change-Id: Ib33e872ae6651a276b4d1cf1d547e7c3e0d11b1d
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
packaging/osp-appfw.spec
src/app/FApp_AppControlImpl.cpp
src/app/FApp_AppControlManager.cpp
src/app/FApp_AppControlRegistry.cpp
src/app/FApp_AppManagerImpl.cpp
src/app/FApp_Aul.cpp
src/app/inc/FApp_AppControlImpl.h
src/app/inc/FApp_AppControlManager.h
src/app/inc/FApp_Types.h
src/server/app/FApp_AulServer.cpp [changed mode: 0755->0644]
src/server/inc/FApp_AulServer.h [changed mode: 0755->0644]

index 9518ba0..3221bd0 100644 (file)
@@ -99,7 +99,6 @@ The App Framework library of OSP
 
 %package devel
 Summary:    The App Framework library of OSP (Development)
-Group:      TO_BE/FILLED_IN
 Requires:   %{name} = %{version}-%{release}
 Requires: boost-devel
 Requires: pkgconfig(pkgmgr-info)
@@ -108,8 +107,7 @@ Requires: pkgconfig(pkgmgr-info)
 The  App Framework library of OSP (DEV)
 
 %package internal-devel
-Summary:    osp app framework internel (Internal)
-Group:      TO_BE/FILLED_IN
+Summary:    OSP app framework internal (Internal)
 Requires:   %{name} = %{version}-%{release}
 Requires:   %{name}-devel
 
@@ -118,7 +116,6 @@ The App Framework library of OSP (Internal-DEV)
 
 %package debug
 Summary:    The App Framework library of OSP (Development)
-Group:      TO_BE/FILLED_IN
 Requires:   %{name} = %{version}-%{release}
 
 %description debug
index 7c22057..2411fd4 100644 (file)
@@ -56,8 +56,8 @@ using namespace Tizen::Io;
 namespace
 {
 
-static const int _REQ_ID_INVALID = -1;
 const wchar_t ACTL_IMPLICIT_PLUGIN[] = L"libosp-ac-implicit.so";
+const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
 
 }
 
@@ -66,9 +66,9 @@ namespace Tizen { namespace App
 
 _AppControlImpl::_AppControlImpl(const AppControl& value)
        : _appControl(value)
-       , _reqId(_REQ_ID_INVALID)
+       , _reqId(APPCONTROL_REQUEST_ID_INVALID)
        , _property(_APPCONTROL_PROPERTY_NONE)
-       , _processId(_REQ_ID_INVALID)
+       , _processId(APPCONTROL_REQUEST_ID_INVALID)
 {
        __appControlResponseEventList.Construct();
 }
@@ -105,7 +105,13 @@ _AppControlImpl::CreateN(const String& path, const String& aId, const String& oI
        SysTryReturn(NID_APP, !path.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Path is empty.");
        SysTryReturn(NID_APP, !aId.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] Provider Id is empty.");
 
-       const AppId& actualAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(aId);
+       String actualAppId = aId;
+       if (aId.StartsWith(TIZEN_ALIAS_APPID_PREFIX, 0))
+       {
+               // little bit of performance tweak
+               actualAppId = _AppControlRegistry::GetInstance()->GetAliasAppId(aId);
+       }
+
        const bool isInstalled = _Aul::IsInstalled(actualAppId);
        SysTryReturn(NID_APP, isInstalled, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] %ls not installed.", actualAppId.GetPointer());
 
@@ -125,18 +131,6 @@ _AppControlImpl::CreateN(const String& path, const String& aId, const String& oI
 }
 
 
-const _AppControlImpl*
-_AppControlImpl::GetInstance(const AppControl& ac)
-{
-       return ac.__pAppControlImpl;
-}
-
-_AppControlImpl*
-_AppControlImpl::GetInstance(AppControl& ac)
-{
-       return ac.__pAppControlImpl;
-}
-
 _IAppControlPluginProvider*
 _AppControlImpl::GetAppControlPluginProvider(const String& path)
 {
@@ -173,25 +167,7 @@ _AppControlImpl::FindAndStart(const String& operationId, const String* pUriPatte
 
        if (pDataType)
        {
-               String mimeType = *pDataType;
-
-               if ((*pDataType)[0] == L'.')
-               {
-                       SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
-
-#if 0
-                       String ext;
-                       pDataType->SubString(1, ext);
-
-                       result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
-
-                       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
-
-                       pMimeType = &mimeType;
-
-                       SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
-#endif
-               }
+               const String& mimeType = _AppControlManager::GetMimeTypeFromDataType(*pDataType);
 
                _AppMessageImpl::SetMime(pBundle.get(), mimeType);
        }
@@ -209,7 +185,7 @@ result
 _AppControlImpl::StartImplicit(const _AppMessageImpl& msg, IEventListener* pListener, bool isLegacy)
 {
        SysLog(NID_APP, "Enter");
-       int req = _REQ_ID_INVALID;
+       int req = APPCONTROL_REQUEST_ID_INVALID;
 
        _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(ACTL_IMPLICIT_PLUGIN);
        if (pProvider == null)
@@ -275,7 +251,7 @@ _AppControlImpl::Start(const IList* pDataList, IAppControlEventListener* pListen
        _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
        SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
 
-       int req = _REQ_ID_INVALID;
+       int req = APPCONTROL_REQUEST_ID_INVALID;
 
        _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
        if (pProvider == null)
@@ -321,7 +297,7 @@ _AppControlImpl::Start(const String* pUriData, const String* pMimeType, const IM
        _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
        SysTryReturnResult(NID_APP, pInfo == null, E_IN_PROGRESS, "Request ID %d is already in progress.", _reqId);
 
-       int req = _REQ_ID_INVALID;
+       int req = APPCONTROL_REQUEST_ID_INVALID;
        result r = E_SUCCESS;
 
        _IAppControlPluginProvider* pProvider = GetAppControlPluginProvider(_path);
@@ -406,7 +382,14 @@ _AppControlImpl::InvokeStartAppControl(_IAppControlPluginProvider* pProvider, in
 result
 _AppControlImpl::InvokeStartAppControl(_IAppControlPluginProvider* pProvider, int req, const String& appId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
 {
-       _AppMessageImpl msg(appId, oId, pUri, pMime, pMap);
+       String data;
+
+       if (pMime)
+       {
+               data = _AppControlManager::GetMimeTypeFromDataType(*pMime);
+       }
+
+       _AppMessageImpl msg(appId, oId, pUri, &data, pMap);
 
        return InvokeStartAppControl(pProvider, req, appId, msg);
 }
@@ -475,7 +458,7 @@ _AppControlImpl::Stop(void)
 
        result (*pStop)(int req) = null;
 
-       if (_reqId != _REQ_ID_INVALID)
+       if (_reqId != APPCONTROL_REQUEST_ID_INVALID)
        {
                _InProcessInfo* pInfo = _AppControlManager::GetInstance()->__inAppManager.FindItem(_reqId);
                SysTryReturnResult(NID_APP, pInfo != null, E_INVALID_OPERATION, "Request ID %d is not found.", _reqId);
@@ -487,7 +470,7 @@ _AppControlImpl::Stop(void)
 
                _AppControlManager::GetInstance()->__inAppManager.RemoveItem(_reqId);
 
-               _reqId = _REQ_ID_INVALID;
+               _reqId = APPCONTROL_REQUEST_ID_INVALID;
        }
        else
        {
@@ -505,7 +488,7 @@ _AppControlImpl::Stop(void)
 }
 
 String
-_AppControlImpl::GetAppName(void)
+_AppControlImpl::GetAppName(void) const
 {
        if (_appName.IsEmpty())
        {
@@ -521,7 +504,7 @@ _AppControlImpl::GetAppName(void)
                {
                        SysLog(NID_APP, "PackageInfo of appId(%ls) exists", appId.GetPointer());
                        const String& name = pInfo->GetAppName();
-                       if (name == L"_AppControl")
+                       if (name == String(SUBMODE_NAME))
                        {
                                // workaround for special case: requery with actual appId
                                const PackageId& packageId = _PackageManagerImpl::GetPackageIdByAppId(appId);
@@ -554,23 +537,6 @@ _AppControlImpl::GetAppName(void)
        return _appName;
 }
 
-String
-_AppControlImpl::GetAppId(void) const
-{
-       return _appId;
-}
-
-const String&
-_AppControlImpl::GetAppControlProviderId(void) const
-{
-       return _appId;
-}
-
-const String&
-_AppControlImpl::GetOperationId(void) const
-{
-       return _opId;
-}
 
 IList*
 _AppControlImpl::GetCategoryListN(void) const
index 9ff5cbc..c40f5d4 100644 (file)
@@ -143,6 +143,30 @@ _AppControlManager::GetMimeFromExt(const String& ext, String& out)
        return E_SUCCESS;
 }
 
+
+String
+_AppControlManager::GetMimeTypeFromDataType(const String& data)
+{
+       // Data type is either MIME type or .[extension]
+
+       if (data.IsEmpty() || data[0] != L'.')
+       {
+               return data;
+       }
+
+       // .[extension]
+       String ext;
+       data.SubString(1, ext);
+
+       String res;
+       result r = _AppControlManager::GetMimeFromExt(ext, res);
+       SysTryReturn(NID_APP, !IsFailed(r), L"", r, "[%s] MIME type conversion failed for %ls.", GetErrorMessage(r), ext.GetPointer());
+
+       SysLog(NID_APP, "Conversion from %ls into %ls.", data.GetPointer(), res.GetPointer());
+       return res;
+}
+
+
 void
 _AppControlManager::OnAppControlEventReceivedN(int reqId, _AppArg* pAppArg, int res)
 {
@@ -351,15 +375,6 @@ _AppControlManager::OnAppControlPluginEventReceivedN(int reqId, int res, const A
                SysLogException(NID_APP, E_SYSTEM, "Invalid AppControl listener.");
        }
 
-#if 0
-       // [FIXME] following logic is not needed.
-       // call TerminateAppControl
-       if (pInfo->pProvider)
-       {
-               pInfo->pProvider->StopAppControlPlugin(pInfo->reqId);
-               SysLog(NID_APP, "AppControl stopped for req %d.", pInfo->reqId);
-       }
-#endif
 
        // remove from list and unload dll
        __inAppManager.RemoveItem(reqId);
@@ -624,7 +639,7 @@ _AppControlManager::LaunchApp(const AppId& appId, _AppArg* pArg, int req)
        String tempId;
        actualAppId.SubString(0, 10, tempId);
        tempId += L'.';
-       tempId += L"_AppControl";
+       tempId += String(SUBMODE_NAME);
 
        // [INFO] Ugly solution for submode support
        pArg->UpdateAppId(tempId);
@@ -754,7 +769,7 @@ _AppControlManager::Launch(const AppId& appId, _AppArg* pArg, AppSvcResFn pCb, v
        if ((!(type & _APP_TYPE_SERVICE_APP)) && _IsDefaultApplication(tempId, appId))
        {
                tempId += L'.';
-               tempId += L"_AppControl";
+               tempId += String(SUBMODE_NAME);
 
                // [INFO] Ugly solution for submode support
                pArg->UpdateAppId(tempId);
index a4c7c03..2775ba4 100644 (file)
@@ -52,12 +52,9 @@ const wchar_t ACTL_DEFAULT_FILE[] = L"/usr/etc/app-control-info.ini";
 const wchar_t ACTL_LEGACY_FILE[] = L"/usr/etc/app-control-alias.ini";
 const wchar_t ACTL_DEFAULT_PLUGIN[] = L"libosp-ac-platform.so";
 
-const wchar_t TIZEN_ALIAS_APPID_PREFIX[] = L"tizen.";
-
 const String ACTL_REGISTRY_PATH = L"Path";
 const String ACTL_REGISTRY_ALIAS_PROVIDER = L"PROVIDER_ALIAS";
 
-const int PKG_APPID_LEN = 256;
 const int REG_VALUE_BUFFER_LEN = 256;
 
 }
index 5c95d58..1931781 100644 (file)
@@ -214,21 +214,7 @@ _AppManagerImpl::FindAppControlsN(const String* pOperationId, const String* pCat
 
        if (pDataType)
        {
-               if ((*pDataType)[0] == L'.')
-               {
-                       SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
-
-                       String ext;
-                       pDataType->SubString(1, ext);
-
-                       result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
-
-                       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
-
-                       pMimeType = &mimeType;
-
-                       SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
-               }
+               mimeType = _AppControlManager::GetMimeTypeFromDataType(*pDataType);
        }
 
        if (pUriScheme)
@@ -295,25 +281,7 @@ _AppManagerImpl::StartAppControl(const String* pOperationId, const String* pCate
 
        if (pDataType)
        {
-               String mimeType = *pDataType;
-
-               if ((*pDataType)[0] == L'.')
-               {
-                       SysLog(NID_APP, "Extension to MIME conversion for %ls", pDataType->GetPointer());
-
-#if 0
-                       String ext;
-                       pDataType->SubString(1, ext);
-
-                       result r = _AppControlManager::GetMimeFromExt(ext, mimeType);
-
-                       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] MIME type conversion failure for %ls.", GetErrorMessage(r), ext.GetPointer());
-
-                       pMimeType = &mimeType;
-
-                       SysLog(NID_APP, "Conversion : %ls -> %ls.", pDataType->GetPointer(), pMimeType->GetPointer());
-#endif
-               }
+               const String& mimeType = _AppControlManager::GetMimeTypeFromDataType(*pDataType);
 
                _AppMessageImpl::SetMime(pBundle.get(), mimeType);
        }
index 104b4e0..d5cf730 100644 (file)
@@ -288,7 +288,7 @@ _Aul::GetRealAppId(const AppId& appId)
        String temp;
        // [INFO] ugly code for submode callee
        appId.SubString(11, temp);
-       if (temp == L"_AppControl")
+       if (temp == String(SUBMODE_NAME))
        {
                String id;
                appId.SubString(0, 10, id);
index 98ea6f7..8d9e59e 100644 (file)
@@ -71,12 +71,18 @@ public:
        /**
         * Internal GetImpl() method.
         */
-       static const _AppControlImpl* GetInstance(const AppControl& ac);
+       static const _AppControlImpl* GetInstance(const AppControl& ac)
+       {
+               return ac.__pAppControlImpl;
+       }
 
        /**
         * Internal GetImpl() method.
         */
-       static _AppControlImpl* GetInstance(AppControl& ac);
+       static _AppControlImpl* GetInstance(AppControl& ac)
+       {
+               return ac.__pAppControlImpl;
+       }
 
        /**
         * Starts the resolved application control. @n
@@ -136,28 +142,37 @@ public:
         *
         * @return              The name of the application providing this %_AppControlImpl instance
         */
-       Tizen::Base::String GetAppName(void);
+       Tizen::Base::String GetAppName(void) const;
 
        /**
         * Gets the associated application ID. @n
         *
         * @return              The application control ID
         */
-       Tizen::Base::String GetAppId(void) const;
+       Tizen::Base::String GetAppId(void) const
+       {
+               return _appId;
+       }
 
        /**
         * Gets the associated application control provider ID. @n
         *
         * @return              The application control provider ID
         */
-       const Tizen::Base::String& GetAppControlProviderId(void) const;
+       const Tizen::Base::String& GetAppControlProviderId(void) const
+       {
+               return _appId;
+       }
 
        /**
         * Gets the associated operation ID. @n
         *
         * @return              The operation ID
         */
-       const Tizen::Base::String& GetOperationId(void) const;
+       const Tizen::Base::String& GetOperationId(void) const
+       {
+               return _opId;
+       }
 
        /**
         * Returns the associated application control categories.
@@ -230,7 +245,7 @@ public:
 
        virtual void OnAppControlResponseEventReceivedN(const Tizen::Base::Runtime::IEventArg* arg);
 private:
-       _AppControlImpl(const AppControl& value);
+       explicit _AppControlImpl(const AppControl& value);
 
        /**
         * This is the default constructor for this class.
@@ -262,7 +277,7 @@ protected:
        Tizen::Base::String _path;
        Tizen::Base::String _appId;
        Tizen::Base::String _opId;
-       Tizen::Base::String _appName;
+       mutable Tizen::Base::String _appName;
        int     _reqId;
        int     _property;
        int _processId;
index c651314..1976db8 100644 (file)
@@ -159,6 +159,8 @@ public:
 
        result SendAppControlStartResponse(int req, const char* pValue, const char* pOp);
 
+       _OSP_LOCAL_ static Tizen::Base::String GetMimeTypeFromDataType(const Tizen::Base::String& dataType);
+
        static result GetMimeFromExt(const Tizen::Base::String& ext, Tizen::Base::String& out);
 
        void RemoveLaunchRequest(int req);
index 8245989..cc12c86 100644 (file)
@@ -104,6 +104,7 @@ const int APPSVC_OSP_RES_FAIL = -13;
 const int APPSVC_OSP_RES_TERMINATE = -14;
 
 const int LAUNCH_ARG_META_COUNT = 3;
+const int APPCONTROL_REQUEST_ID_INVALID = -1;
 
 _OSP_LOCAL_ extern const wchar_t LEGACY_LAUNCH_REASON_NORMAL[];
 _OSP_LOCAL_ extern const wchar_t LEGACY_LAUNCH_REASON_CONDITIONAL[];
@@ -111,6 +112,7 @@ _OSP_LOCAL_ extern const wchar_t LEGACY_OPERATION_MAIN[];
 _OSP_LOCAL_ extern const wchar_t TIZEN_OPERATION_MAIN[];
 _OSP_EXPORT_ extern const wchar_t TIZEN_OPERATION_PICK[];
 _OSP_LOCAL_ extern const char TIZEN_NOTIFICATION_DATA[];
+_OSP_LOCAL_ extern const char SUBMODE_NAME[];
 
 _OSP_EXPORT_ extern const char IPC_SERVER_NAME[];
 _OSP_EXPORT_ extern const char CONDITION_MANAGER_IPC_NAME[];
old mode 100755 (executable)
new mode 100644 (file)
index fd37fc9..33bd171
 #include "FApp_AulServer.h"
 #include "FApp_TemplateUtil.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int aul_listen_app_dead_signal(int (* func)(int, void*), void* data);
-#ifdef __cplusplus
-}
-#endif
 
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
@@ -159,6 +152,35 @@ _AulServer::IsRunning(const String& packageName)
 }
 
 
+result
+_AulServer::Launch(const String& appId)
+{
+       std::unique_ptr<char[]> pPackageName(_StringConverter::CopyToCharArrayN(appId));
+
+       int ret = aul_launch_app(pPackageName.get(), NULL);
+       if (ret < 0)
+       {
+               result r = E_SYSTEM;
+               switch (ret)
+               {
+               case AUL_R_EILLACC:
+                       r = E_ILLEGAL_ACCESS;
+                       break;
+               case AUL_R_EINVAL:
+                       r = E_MAX_EXCEEDED;
+                       break;
+               default:
+                       break;
+               }
+
+               SysLogException(NID_APP, r, "[%s] Error occurred.", GetErrorMessage(r));
+               return r;
+       }
+
+       return E_SUCCESS;
+}
+
+
 void
 _AulServer::SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData)
 {
@@ -355,294 +377,4 @@ _AulServer::ClearUserPreferenceForAppControlResolution(const AppId& appId)
        return E_SUCCESS;
 }
 
-result
-_AulServer::_DesktopFile::MakePath(const AppId& appId, const String* pExeName, char* path, int size)
-{
-       SysTryReturnResult(NID_APP, path != null, E_INVALID_ARG, "");
-
-       char packageName[MAX_SLP_PACKAGE_ID] = {0, };
-       result r = E_SUCCESS;
-       _PackageManagerImpl* pPackageManagerImpl = _PackageManagerImpl::GetInstance();
-       SysTryReturnResult(NID_APP, pPackageManagerImpl, E_INVALID_STATE, "Invalid package manager instance.");
-
-       r = pPackageManagerImpl->GetPackageName(appId, pExeName, packageName, MAX_SLP_PACKAGE_ID);
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "%s", GetErrorMessage(r));
-
-       snprintf(path, size, _DESKTOP_FILE_PATH_FORMAT, _DESKTOP_FILE_PATH, packageName);
-
-       return r;
-}
-
-result
-_AulServer::_DesktopFile::UpdateService(const AppId& appId, const char* value)
-{
-       char path[FILENAME_MAX] = {0, };
-       MakePath(appId, null, path, FILENAME_MAX);
-
-       return UpdateField(path, _X_TIZEN_SVC, value);
-}
-
-
-result
-_AulServer::_DesktopFile::RemoveService(const AppId& appId, const char* operationOnlyValue)
-{
-       char path[FILENAME_MAX] = {0, };
-       MakePath(appId, null, path, FILENAME_MAX);
-
-       return UpdateField(path, _X_TIZEN_SVC, operationOnlyValue, true);
-}
-
-
-//
-// Update value of specified field.
-// currently only "x-slp-svc" field is supported.
-//
-#define BUFFER_SIZE 1024
-result
-_AulServer::_DesktopFile::UpdateField(const char* path, const char* fieldName, const char* value, bool isRemove)
-{
-       SysTryReturnResult(NID_APP, path != null, E_INVALID_ARG, "path should not be null.");
-       SysTryReturnResult(NID_APP, fieldName != null, E_INVALID_ARG, "fieldName should not be null.");
-       SysTryReturnResult(NID_APP, value != null, E_INVALID_ARG, "value should not be null.");
-
-       FILE* fp = fopen(path, "r+");
-       SysTryReturnResult(NID_APP, fp != null, E_SYSTEM, "falied to open '%s' due to %s", path, strerror(errno));
-
-       char buffer[BUFFER_SIZE] = {0, };
-       bool found = false;
-       int len = 0;
-       int pos = 0;
-       int foundpos = 0;
-       result r = E_SUCCESS;
-       int remains = 0;
-
-       ArrayListT<char*> buffers;
-       buffers.Construct();
-
-       char* pCurrent = null;
-
-       while (fgets(buffer, BUFFER_SIZE, fp) != NULL)
-       {
-               len = strlen(buffer);
-               SysTryCatch(NID_APP, len < BUFFER_SIZE, , r = E_INVALID_ARG, "strlen returns invalid value. (%d)", len );
-
-               if (found)
-               {
-                       pCurrent = new (std::nothrow) char[len + 1];
-                       SysTryCatch(NID_APP, pCurrent != null, , r = E_OUT_OF_MEMORY, "failed to allocate mem pCurrent");
-
-                       strncpy(pCurrent, buffer, len);
-                       buffers.Add(pCurrent);
-               }
-               else
-               {
-                       if (strncmp(buffer, fieldName, len) == 0)
-                       {
-                               int fieldNameLen = strlen(fieldName);
-                               SysTryCatch(NID_APP, len > fieldNameLen, , E_INVALID_ARG, "[E_INVALID_ARG] fieldName(%s)", fieldName);
-
-                               pCurrent = UpdateServiceValueN(buffer + fieldNameLen, value, isRemove);
-                               SysTryCatch(NID_APP, pCurrent != null, , r = GetLastResult(), "[%s] UpdateServiceValue failed", GetErrorMessage(GetLastResult()));
-
-                               buffers.Add(pCurrent);
-
-                               foundpos = pos;
-                               found = true;
-                       }
-               }
-
-               pos += len;
-       }
-
-       if (found)
-       {
-               fsetpos(fp, (fpos_t*) &foundpos);
-
-               remains = buffers.GetCount();   // prevent infinite loop
-               while (buffers.GetCount() > 0 && remains-- > 0)
-               {
-                       pCurrent = null;
-                       buffers.GetAt(0, pCurrent);
-                       buffers.RemoveAt(0);
-                       SysTryCatch(NID_APP, pCurrent != null, , r = E_INVALID_STATE, "");
-
-                       fputs(pCurrent, fp);
-                       len = strlen(pCurrent);
-                       pos += len;
-                       delete[] pCurrent;
-               }
-
-               int ret = truncate(path, pos);
-               SysTryLog(NID_APP, ret == 0, "Truncate failure (%s).", strerror(errno));
-       }
-       else
-       {
-               char svctext[_MAX_TIZEN_SVC_DESC_LEN] = {0, };
-               snprintf(svctext, _MAX_TIZEN_SVC_DESC_LEN, "%s=%s\n", fieldName, value);
-               fputs(svctext, fp);
-       }
-       fclose(fp);
-
-       return E_SUCCESS;
-
-CATCH:
-
-       remains = buffers.GetCount();   // prevent infinite loop
-       while (buffers.GetCount() > 0 && remains-- > 0)
-       {
-               pCurrent = null;
-               buffers.GetAt(0, pCurrent);
-               buffers.RemoveAt(0);
-               if (pCurrent != null)
-               {
-                       delete[] pCurrent;
-               }
-       }
-
-       fclose(fp);
-
-       return r;
-}
-
-//
-//     Tizen service string example
-//     X-TIZEN-SVC= http://tizen.org/appcontrol/operation/pick|NULL|image/jpge; http://tizen.org/appcontrol/operation/pick|NULL|video/mp4; http://tizen.org/appcontrol/operation/pick|NULL|NULL; http://tizen.org/appcontrol/operation/pview|NULL|NULL
-//
-char*
-_AulServer::_DesktopFile::UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove)
-{
-       SysTryReturn(NID_APP, buffer != null, null, E_INVALID_ARG, "");
-       SysTryReturn(NID_APP, newValue != null, null, E_INVALID_ARG, "");
-
-       SysLog(NID_APP, "current(%s), new(%s), isRemove(%s)", buffer, newValue, (isRemove) ? "true" : "false");
-
-       String buf(buffer);
-       bool found = false;
-
-       const String& servicePattern(L"([A-Za-z&=:/\\.\\-]*);?");
-
-       ArrayList services;
-       String resultString;
-
-       Utility::RegularExpression regex;
-       result r = regex.Construct(servicePattern);
-       SysTryReturn(NID_APP, !IsFailed(r), null, r, "");
-
-       String newOperation;
-       String newUrl;
-       String newMimeType;
-       String newService(newValue);
-
-       if (isRemove == false)
-       {
-               ParseService(newService, newOperation, newUrl, newMimeType);
-       }
-       else
-       {
-               newOperation = newValue;
-       }
-
-       services.Construct();
-
-       while (regex.Consume(buf, &services) == true)
-       {
-               String* pCurrentService = (String*) services.GetAt(1);
-               services.RemoveAll(false);
-
-               String operation;
-               String url;
-               String mimeType;
-
-               ParseService(*pCurrentService, operation, url, mimeType);
-
-               if (operation == newOperation)
-               {
-                       if (isRemove == true)
-                       {
-                               SysLog(NID_APP, "opreration '%ls' will be removed", operation.GetPointer());
-                       }
-                       else
-                       {
-                               SysAssertf(found == false, "It's assumed that service doesn't have duplicated operation in tizen desktop file. But it isn't, so now we have to check this case.");
-                               // replace operation.
-                               if (found == false) // ( if duplicated operation is already exist, It will be keeped.
-                               {
-                                       // update value
-                                       AppendServiceValueToString(resultString, newService);
-                                       SysLog(NID_APP, "opreration '%ls;%ls;%ls' will be updated to ;%ls;%ls", operation.GetPointer(), url.GetPointer(), mimeType.GetPointer(), newUrl.GetPointer(), mimeType.GetPointer());
-                               }
-                       }
-                       found = true;
-               }
-               else
-               {
-                       // add not specified service.
-                       AppendServiceValueToString(resultString, *pCurrentService);
-               }
-
-               delete pCurrentService;
-       }
-
-       if (found == false && isRemove == false)
-       {
-               AppendServiceValueToString(resultString, newService);
-               SysLog(NID_APP, "opreration '%ls;%ls;%ls' will be added", newOperation.GetPointer(), newUrl.GetPointer(), newMimeType.GetPointer());
-       }
-
-       SysLog(NID_APP, "updated string is '%ls'", resultString.GetPointer());
-       return _StringConverter::CopyToCharArrayN(resultString);
-}
-
-
-void
-_AulServer::_DesktopFile::AppendServiceValueToString(String& serviceString, const String& newVaue)
-{
-       if (serviceString.GetLength() > 0)
-       {
-               serviceString += ";";
-       }
-
-       serviceString += newVaue;
-}
-
-
-result
-_AulServer::_DesktopFile::ParseService(const String& service, String& operation, String& url, String& mimeType)
-{
-       SysLog(NID_APP, "service(%ls)", service.GetPointer());
-
-       const String& serviceDetailPattern(L"([A-Za-z&=/\\.\\-]*):(.*://[A-Za-z&=/\\.\\-]*|[A-Za-z&=/\\.\\-]*):([A-Za-z&=/\\.\\-]*)");
-
-       Utility::RegularExpression regexDetail;
-       result r = regexDetail.Construct(serviceDetailPattern);
-       SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] RegularExpression::Construct(L\"%ls\") failed.", GetErrorMessage(r), serviceDetailPattern.GetPointer());
-
-       ArrayList matchedItems;
-       matchedItems.Construct();
-       regexDetail.Match(service, true, &matchedItems);
-
-       int matchedCount = matchedItems.GetCount();
-       SysTryLog(NID_APP, matchedCount == 4, "It's assumed that x-slp-svc value always have operation:url:mime in tizen desktop file. But it isn't or our parser is invalid. so now we have to check this case. %d", matchedItems.GetCount());
-
-       if (matchedCount > 1)
-       {
-               operation = *(String*) matchedItems.GetAt(1);
-       }
-
-       if (matchedCount > 2)
-       {
-               url = *(String*) matchedItems.GetAt(2);
-       }
-
-       if (matchedCount > 3)
-       {
-               mimeType = *(String*) matchedItems.GetAt(3);
-       }
-
-       SysLog(NID_APP, "matched(%d) : (%ls;%ls;%ls)", matchedItems.GetCount(), operation.GetPointer(), url.GetPointer(), mimeType.GetPointer());
-       matchedItems.RemoveAll(true);
-
-       return E_SUCCESS;
-}
-
 } } // Tizen::App
old mode 100755 (executable)
new mode 100644 (file)
index 22c34dc..ccda307
@@ -49,6 +49,8 @@ public:
 
        static bool IsRunning(const Tizen::Base::String& packageName);
 
+       static result Launch(const Tizen::Base::String& appId);
+
        static void SetOnAppTerminatedCb(int (* pf_app_dead_handler)(int pid, void* pData), void* pData);
 
        static result SetOomAdj(int pid, int adj);
@@ -64,55 +66,6 @@ public:
        static result ClearUserPreferenceForAppControlResolution(const AppId& appId);
 
 public:
-       /**
-        * This is static helper class for desktop file.
-        */
-       class _DesktopFile
-       {
-       public:
-               /**
-                * Updates the service value
-                * @param[in]   appId                   The application's ID to be executed
-                * @param[in]   value                   value to be added or updated.
-                *
-                * @remark              If operations is new, it will be appended.
-                *              but, if same operation is already exist, 'url' and 'mimeType' will be updated.
-                */
-               static result UpdateService(const AppId& appId, const char* value);
-
-               /**
-                * Removes the service value by operation
-                * @param[in]   appId   The application's ID to be executed
-                * @param[in]   operationOnlyValue      operationId of service to be removed
-                */
-               static result RemoveService(const AppId& appId, const char* operationOnlyValue);
-
-       private:
-               /**
-                * Updates value of specified field
-                */
-               static result UpdateField(const char* path, const char* key, const char* value, bool isRemove = false);
-
-               /**
-                * Makes desktop file path from appId (retrives appName using _PackageMamagerImpl)
-                */
-               static result MakePath(const AppId& appId, const Tizen::Base::String* pExeName, char* path, int size);
-
-               /**
-                * Update service value of input buffer with specified value
-                */
-               static char* UpdateServiceValueN(char* buffer, const char* newValue, bool isRemove = false);
-
-               /**
-                * Extracts each informations from one service string.
-                */
-               static result ParseService(const Tizen::Base::String& service, Tizen::Base::String& operation, Tizen::Base::String& url, Tizen::Base::String& mimeType);
-
-               static void AppendServiceValueToString(Tizen::Base::String& string, const Tizen::Base::String& newVaue);
-
-               friend class UTs_AulServer;
-       }; // _DesktopFile
-
        friend class UTs_AulServer;
 }; // _AulServer