N_SE-34899: fix rare timing issue for register app launch
authorYoung Ik Cho <youngik.cho@samsung.com>
Wed, 8 May 2013 10:29:47 +0000 (19:29 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Wed, 8 May 2013 10:29:47 +0000 (19:29 +0900)
Change-Id: Iec4bee0b681ab700daeccad3ba4640ae84e4898b
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/FApp_AppManagerImpl.cpp
src/app/FApp_ConditionManagerProxy.cpp
src/app/FApp_ImeAppImpl.cpp [deleted file]
src/app/FApp_ImeAppImpl.h [deleted file]

index 6c57624..3bde180 100755 (executable)
@@ -290,11 +290,31 @@ _AppManagerImpl::GetConditionManagerProxy(void)
 {
        if (__pConditionManager == null)
        {
+               const int MAX_TRY_COUNT = 5;
+               const int TRY_SLEEP_TIME = 250;
+
                __pConditionManager = new (std::nothrow) _ConditionManagerProxy;
                SysAssert(__pConditionManager != null);
 
-               result r = __pConditionManager->Construct();
-               SysAssertf(r == E_SUCCESS, "__pConditionManager->Construct() faliied [%s].", GetErrorMessage(r));
+               int count = 0;
+               while (true)
+               {
+                       result r = __pConditionManager->Construct();
+                       if (r == E_SUCCESS)
+                       {
+                               SysLog(NID_APP, "Succeeded in connecting condition manager.");
+                               break;
+                       }
+
+                       if (count >= MAX_TRY_COUNT)
+                       {
+                               SysLog(NID_APP, "Failed to connecting condition manager.");
+                               break;
+                       }
+
+                       count++;
+                       Thread::Sleep(TRY_SLEEP_TIME);
+               }
        }
 
        return __pConditionManager;
index 7a941d2..98c6aac 100644 (file)
@@ -22,6 +22,8 @@
 #include <new>
 #include <memory>
 
+#include <unique_ptr.h>
+
 #include <FBaseErrors.h>
 
 #include <FBaseSysLog.h>
@@ -33,6 +35,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
 
 namespace Tizen { namespace App
 {
@@ -51,11 +54,13 @@ _ConditionManagerProxy::~_ConditionManagerProxy(void)
 result
 _ConditionManagerProxy::Construct()
 {
-       __pIpcClient = new (std::nothrow) Tizen::Io::_IpcClient();
-       SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
+       std::unique_ptr<_IpcClient> pIpcClient(new (std::nothrow) _IpcClient());
+       SysTryReturnResult(NID_APP, pIpcClient.get() != null, E_OUT_OF_MEMORY, "_IpcClient creation failed.");
+
+       result r = pIpcClient->Construct("osp.app.ipcserver.conditionmanager");
+       SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%%s] _IpcClient constructing faliied.", GetErrorMessage(r));
 
-       result r = __pIpcClient->Construct("osp.app.ipcserver.conditionmanager");
-       SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing faliied [%s].", GetErrorMessage(r));
+       __pIpcClient = pIpcClient.release();
 
        return E_SUCCESS;
 }
diff --git a/src/app/FApp_ImeAppImpl.cpp b/src/app/FApp_ImeAppImpl.cpp
deleted file mode 100644 (file)
index 9f1fd05..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file       FApp_ImeAppImpl.cpp
- * @brief      This is the implementation for the _ImeAppImpl class.
- */
-
-#include <cstdio>
-#include <cstring>
-#include <unistd.h>
-#include <dlog.h>
-#include <dlfcn.h>
-
-#define Uses_SCIM_HELPER
-#define Uses_SCIM_TYPES
-#define Uses_SCIM_CONFIG_BASE
-#undef null
-#include <scim.h>
-#define null 0
-
-#include <FAppAppRegistry.h>
-#include <FBaseColArrayList.h>
-#include <FUiCtrlFrame.h>
-
-#include <FBaseSysLog.h>
-#include <FUi_ControlManager.h>
-#include <FUi_ControlImplManager.h>
-#include <FUi_KeyEventManager.h>
-#include <FUi_WindowImpl.h>
-#include <FUi_EcoreEvasMgr.h>
-#include <FUi_EcoreEvas.h>
-#include <FSys_PowerManagerImpl.h>
-
-#include "FApp_AppFrame.h"
-#include "FApp_AppInfo.h"
-#include "FApp_AppImpl.h"
-#include "FApp_ImeAppImpl.h"
-#include "FAppPkg_PackageManagerImpl.h"
-
-//#include "FUiIme_ScimDataConverter.h"
-
-using namespace Tizen::App;
-using namespace Tizen::App::Package;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Ui;
-using namespace Tizen::Ui::Controls;
-using namespace Tizen::Ui::Ime;
-using namespace Tizen::System;
-using namespace Tizen::Graphics;
-
-
-const char GLINFO_FILE_PATH[] = "info/webservice.info";
-
-
-namespace Tizen { namespace App
-{
-
-_ImeAppImpl* _ImeAppImpl::__pImeAppImpl = null;
-
-
-_ImeAppImpl::_ImeAppImpl(UiApp* pUiApp)
-       : _UiAppImpl(pUiApp)
-       , __pAppImpl(_AppImpl::GetInstance())
-       , __appUiState(APP_UI_STATE_BACKGROUND)
-       , __pUiApp(pUiApp)
-{
-       __pImeAppImpl = this;
-       SysTryReturnVoidResult(NID_APP, __pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
-}
-
-
-_ImeAppImpl::~_ImeAppImpl(void)
-{
-       __pImeAppImpl = null;
-}
-
-
-bool
-_ImeAppImpl::OnCreate(void)
-{
-       SysLog(NID_APP, "Platform creation event.");
-
-       _AppInfo::SetAppState(INITIALIZING);
-
-       return true;
-}
-
-
-void
-_ImeAppImpl::OnService(service_s* service)
-{
-}
-
-
-void
-_ImeAppImpl::OnTerminate(void)
-{
-       SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
-
-       if (OnImeAppImplTerminating() != true)
-       {
-               SysLog(NID_APP, "[E_SYSTEM] The Termination of application failed.");
-       }
-}
-
-
-void
-_ImeAppImpl::OnResume(void)
-{
-       SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
-
-       if (_AppInfo::GetAppState() == RUNNING)
-       {
-               OnForeground();
-       }
-}
-
-
-void
-_ImeAppImpl::OnPause(void)
-{
-       SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
-
-       if (_AppInfo::GetAppState() == RUNNING)
-       {
-               OnBackground();
-       }
-}
-
-
-void
-_ImeAppImpl::OnDeviceOrientationChanged(app_device_orientation_e orientation)
-{
-       SysLog(NID_APP, "System device orientation event.");
-
-       _ControlImplManager* pControlImplManager = _ControlImplManager::GetInstance();
-       if (pControlImplManager == null)
-       {
-               SysLog(NID_APP, "Device orientation event arrived too early.");
-               return;
-       }
-
-       pControlImplManager->OnScreenRotated(orientation);
-}
-
-
-long
-_ImeAppImpl::OnWindowHandleRequest(void)
-{
-       const _EcoreEvas* const pEvas = GetEcoreEvasMgr()->GetEcoreEvas();
-       return (pEvas) ? static_cast<long>(pEvas->GetXWindow()) : -1;
-}
-
-
-bool
-_ImeAppImpl::OnAppInitializing(void)
-{
-       // [FIXME] Temporary code for enabling opengl
-
-       // to reduce package manager overhead, _AppInfo::GetAppRootPath() is not used
-
-       if (faccessat(_AppInfo::GetAppRootDirFd(), GLINFO_FILE_PATH, F_OK, 0) == 0)
-       {
-               SysLog(NID_APP, "Setting opengl engine for WEB_SERVICE privilege.");
-               elm_config_preferred_engine_set("opengl_x11");
-       }
-
-       // Do Ui related initializing for UiApp
-       result r = InitializeUiFramework();
-       if (IsFailed(r))
-       {
-               SysLogException(NID_APP, E_SYSTEM, "Getting resolution information failure. Application may not be installed correctly.");
-               _Process::Exit(-1);
-       }
-
-       _KeyEventManager::GetInstance()->AddKeyEventListener(*this);
-
-       SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed.");
-       return __pUiApp->OnAppInitializing(*(AppRegistry::GetInstance()));
-}
-
-
-bool
-_ImeAppImpl::OnAppInitialized(void)
-{
-       SysTryReturn(NID_APP, __pUiApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting UiApp instance failed.");
-
-       __pUiApp->OnAppInitialized();
-       return true;
-}
-
-
-bool
-_ImeAppImpl::OnImeAppImplTerminating(void)
-{
-       bool result = false;
-
-       if (_AppInfo::GetAppState() != TERMINATED)
-       {
-               result = __pUiApp->OnAppTerminating(*(AppRegistry::GetInstance()), __pAppImpl->IsForcedTermination());
-               _AppInfo::SetAppState(TERMINATED);
-       }
-
-       // Do Ui related finalizing for UiApp
-       FinalizeUiFramework();
-
-       return result;
-}
-
-
-void
-_ImeAppImpl::OnForeground(void)
-{
-       result r = E_SUCCESS;
-
-       __appUiState = APP_UI_STATE_FOREGROUND;
-       __pUiApp->OnForeground();
-
-       r = _PowerManagerImpl::OnForeground();
-
-       SysTryLog(NID_APP, !IsFailed(r), "Failed to send foreground event to powermanager");
-}
-
-
-void
-_ImeAppImpl::OnBackground(void)
-{
-       result r = E_SUCCESS;
-
-       __appUiState = APP_UI_STATE_BACKGROUND;
-       __pUiApp->OnBackground();
-
-       r = _PowerManagerImpl::OnBackground();
-
-       SysTryLog(NID_APP, !IsFailed(r), "Failed to send background event to powermanager");
-}
-
-
-AppUiState
-_ImeAppImpl::GetAppUiState(void) const
-{
-       return __appUiState;
-}
-
-
-_ImeAppImpl*
-_ImeAppImpl::GetInstance(void)
-{
-       return __pImeAppImpl;
-}
-
-
-UiApp*
-_ImeAppImpl::GetUiAppInstance(void)
-{
-       return __pUiApp;
-}
-
-
-} } //Tizen::App
-/*
-#define MAX_BUFFER 100
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif // __cplusplus
-
-extern int OspImeInfo(char* uuid, char* name, char* language) __attribute__((weak));
-
-unsigned int _OSP_EXPORT_
-scim_helper_module_number_of_helpers (void)
-{
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_number_of_helpers");
-       return 1;
-}
-
-bool _OSP_EXPORT_
-scim_helper_module_get_helper_info (unsigned int idx, scim::HelperInfo& info)
-{
-       char uuid[MAX_BUFFER];
-       char name[MAX_BUFFER];
-       memset(uuid, '\0', MAX_BUFFER);
-       memset(name, '\0', MAX_BUFFER);
-
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info enter");
-
-       if (dlsym(null, "OspImeInfo") != null)
-       {
-               LOG(LOG_DEBUG, "IME", "IME : OspImeInfo found");
-               OspImeInfo(uuid, name, null);
-       }
-
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info 2 %ls %ls", uuid, name);
-
-       if (strlen(uuid) == 0)
-       {
-               LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no uuid return");
-               strncpy(uuid, "723191f0-cfb3-11e1-9ea3-e811323afc30", strlen("723191f0-cfb3-11e1-9ea3-e811323afc30"));
-       }
-
-       if (strlen(name) == 0)
-       {
-               LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no name return");
-               strncpy(name, "Keyboard", strlen("Keyboard"));
-       }
-
-       String Uuid(uuid);
-       String Name(name);
-
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_info %ls %ls", Uuid.GetPointer(), Name.GetPointer());
-
-       Tizen::Ui::Ime::_ScimDataConverter dataConverter;
-       scim::String scimUuid;
-       scim::String scimName;
-
-       dataConverter.ConvertString(Uuid, scimUuid);
-       dataConverter.ConvertString(Name, scimName);
-
-       if (idx == 0)
-       {
-               info = scim::HelperInfo(scimUuid, scimName, "", "",
-                                                               scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | scim::SCIM_HELPER_AUTO_RESTART);
-               return true;
-       }
-
-       return false;
-}
-
-scim::String _OSP_EXPORT_
-scim_helper_module_get_helper_language (unsigned int idx)
-{
-       // get ImeApplicationInfo
-       char uuid[MAX_BUFFER];
-       char language[MAX_BUFFER];
-       memset(uuid, '\0', MAX_BUFFER);
-       memset(language, '\0', MAX_BUFFER);
-
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_language enter");
-
-       if (dlsym(null, "OspImeInfo") != null)
-       {
-               LOG(LOG_DEBUG, "IME", "IME : OspImeInfo found");
-               OspImeInfo(uuid, null, language);
-       }
-
-       if (strlen(language) == 0)
-       {
-               LOG(LOG_DEBUG, "IME", "IME : OspImeInfo no language return");
-               strncpy(language, "fr_FR", strlen("fr_FR"));
-       }
-
-       String Language(language);
-
-       LOG(LOG_DEBUG, "IME", "IME : scim_helper_module_get_helper_language %ls", Language.GetPointer());
-
-       // convert String
-       Tizen::Ui::Ime::_ScimDataConverter dataConverter;
-       scim::String scimLanguage;
-
-       dataConverter.ConvertString(Language, scimLanguage);
-
-       return scimLanguage;
-}
-
-void _OSP_EXPORT_
-scim_module_init (void)
-{
-       LOG(LOG_DEBUG, "IME", "IME : scim_module_init");
-}
-
-void _OSP_EXPORT_
-scim_module_exit (void)
-{
-       LOG(LOG_DEBUG, "IME", "IME : scim_module_exit");
-}
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus
-*/
diff --git a/src/app/FApp_ImeAppImpl.h b/src/app/FApp_ImeAppImpl.h
deleted file mode 100644 (file)
index 931b679..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-//
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file       FApp_ImeAppImpl.h
- * @brief      This is the header file for the %_ImeAppImpl class.
- */
-
-#ifndef _FAPP_INTERNAL_IME_APP_IMPL_H_
-#define _FAPP_INTERNAL_IME_APP_IMPL_H_
-
-#include <app.h>
-
-#include <FAppUiApp.h>
-#include <FBaseRtIEventListener.h>
-
-#include "FApp_UiAppImpl.h"
-
-namespace Tizen { namespace Base { namespace Collection { class IList; } } }
-namespace Tizen { namespace Ui {namespace Controls { class Frame; } } }
-
-namespace Tizen { namespace App
-{
-
-class IAppFrame;
-class _AppFrame;
-
-/**
- * @class      _ImeAppImpl
- * @brief      This class is the Impl class of a IME application.
- * @since 2.1
- *
- * This class is the Impl class of a IME application.
- */
-class _ImeAppImpl
-       : public Tizen::App::_UiAppImpl
-{
-public:
-       /**
-       * Returns the _ImeAppImpl's instance pointer.
-       *
-       * @since 2.1
-       * @return       A pointer to the %_ImeAppImpl instance, @n
-       *                       else @c null if it fails
-       */
-       static _ImeAppImpl* GetInstance(void);
-
-       /**
-       * Returns the UiApp's instance pointer.
-       *
-       * @since 2.1
-       * @return       A pointer to the %UiApp instance, @n
-       *                       else @c null if it fails
-       */
-       UiApp* GetUiAppInstance(void);
-
-       /**
-        * Called when the application is started
-        *
-        * @since 2.1
-        * @return      @c true if the method is successful, @n
-        *              else @c false
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       virtual bool OnCreate(void);
-
-       /**
-        * Called when other application send the launch request to the application
-        *
-        * @since 2.1
-        * @param[in]   service The handle to the service
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       virtual void OnService(service_s* service);
-
-       /**
-        * Called when the application is completely obscured by another application and becomes invisible
-        *
-        * @since 2.1
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       virtual void OnPause(void);
-
-       /**
-        * Called when the application becomes visible
-        *
-        * @since 2.1
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       virtual void OnResume(void);
-
-       /**
-        * Called once after the main loop of application exits
-        *
-        * @since 2.1
-        * @param[in]   user_data       The user data passed from the callback registration function
-        * @remarks     This is a system dependent callback function
-        */
-       virtual void OnTerminate(void);
-
-       /**
-        * Called when an orintation event occurs.
-        *
-        * @since 2.1
-        * @param[in]   orientation     The information about the orientation event
-        */
-       virtual void OnDeviceOrientationChanged(app_device_orientation_e orientation);
-
-       /**
-        * Called when the application's state changes to Tizen::App::AppState::INITIALIZING. @n
-        *
-        * @since 2.1
-        * @return      @c true if the method is successful, @n
-        *              else @c false
-        */
-       virtual bool OnAppInitializing(void);
-
-       /**
-        * Called when the application's INITIALIZING state is finished
-        *
-        * @since 2.1
-        * @return      @c true if the method is successful, @n
-        *                      else @c false
-        */
-       virtual bool OnAppInitialized(void);
-
-
-       /**
-        * Called when the internal window handle is required.
-        *
-        * @since 2.1
-        */
-       virtual long OnWindowHandleRequest(void);
-
-       /**
-        * Called when the application's state change to Tizen::App::AppState::TERMINATING. @n
-        *
-        * @since 2.1
-        * @param[in]   forcedTermination       @c true if the application terminate by system or other application, else @c false.
-        * @return      @c true if the method is successful, @n
-        *              else @c false
-        */
-       bool OnImeAppImplTerminating(void);
-
-private:
-       /**
-        * This is the default constructor for this class.
-        *
-        * @since 2.1
-        */
-       _ImeAppImpl(void);
-
-       /**
-        * This is the constructor for this class.
-        *
-        * @since 2.1
-        */
-       _ImeAppImpl(UiApp* pUiApp);
-
-       /**
-        * This is the copy constructor for the this class.
-        */
-       _ImeAppImpl(const _ImeAppImpl& source);
-
-       /**
-        * This is the assignment operator for this class.
-        */
-       _ImeAppImpl& operator =(const _ImeAppImpl& source);
-
-       /**
-        * This is the destructor for this class.
-        *
-        * @since 2.1
-        */
-       virtual ~_ImeAppImpl(void);
-
-       /**
-        * Gets the UI state of the IME application.
-        *
-        * @since 2.1
-        * @return      The UI state of the IME application
-        */
-       AppUiState GetAppUiState(void) const;
-
-       void OnForeground(void);
-
-       void OnBackground(void);
-
-private:
-       static _ImeAppImpl* __pImeAppImpl;
-
-       _AppImpl* __pAppImpl;
-
-       AppUiState __appUiState;
-
-       UiApp* __pUiApp;
-
-       friend class UiApp;
-}; //_ImeAppImpl
-
-} } //Tizen::App
-
-#endif // _FAPP_INTERNAL_IME_APP_IMPL_H_