Fixed prevent issues
authorkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 26 Jun 2013 07:08:31 +0000 (16:08 +0900)
committerkyeongwoo.lee <kyeongwoo.lee@samsung.com>
Wed, 26 Jun 2013 07:26:59 +0000 (16:26 +0900)
Change-Id: Ib8358adadd410f18d095fe654ab157de0a733e61

src/FShell_AppWidgetContext.cpp
src/FShell_AppWidgetManagerService.cpp
src/OspAppWidgetService.cpp

index c36a171230f95c11352f8e026d98929af412f91e..e6c4c14b36fe0571ac8b8ff8702c7bb86d757baa 100644 (file)
@@ -39,6 +39,7 @@
 namespace Tizen { namespace Shell  { namespace App
 {
 
+using namespace std;
 using namespace Tizen::App;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
@@ -74,10 +75,10 @@ _AppWidgetContext::_AppWidgetContext(AppContext* pAppContext, const String& info
                __updateTimer.StartAsRepeatable(__updateMillis);
        }
 
-       __pPendingTouchEventList = new ArrayListT<PendingTouchEvent*>();
+       __pPendingTouchEventList = new (nothrow) ArrayListT<PendingTouchEvent*>();
        __pPendingTouchEventList->Construct();
 
-       __pPendingEventList = new ArrayListT<PendingEvent*>();
+       __pPendingEventList = new (nothrow) ArrayListT<PendingEvent*>();
        __pPendingEventList->Construct();
 }
 
@@ -260,7 +261,7 @@ _AppWidgetContext::IsPaused(void) const
 void
 _AppWidgetContext::OnPopupCreated(double x, double y, int width, int height)
 {
-       __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(GetUserInfo(), GetProviderId(), GetInstanceId(), GetWidth(), GetHeight(), GetPriority(), this);
+       __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(GetUserInfo(), GetProviderId(), GetInstanceId(), GetWidth(), GetHeight(), GetPriority(), this);
        __pAppWidgetPopup->SetIpcClientId(GetClientId());
        __pAppWidgetPopup->OnPopupCreated(x, y, width, height);
 }
@@ -291,7 +292,7 @@ _AppWidgetContext::SendUpdateRequest(int width, int height, const String& argume
 {
        std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
 
-       pArgs->Add(new String(ARG_KEY_ARGUMENT), new String(argument));
+       pArgs->Add(new (nothrow) String(ARG_KEY_ARGUMENT), new (nothrow) String(argument));
 
        return SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release());
 }
@@ -327,7 +328,7 @@ _AppWidgetContext::SendPendingEvent(void)
                r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg);
 
                result r1 = __pPendingEventList->RemoveAt(0);
-               SysTryLog(NID_SHELL, !IsFailed(r1), "Failed to execute remove context.");
+               SysTryLog(NID_SHELL, !IsFailed(r1), "Failed to remove the context.");
                delete pEvent;
 
                SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed.");
@@ -365,7 +366,7 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub
        }
        else
        {
-               __pPendingTouchEventList->Add(new PendingTouchEvent(eventType, timeStamp, x, y));
+               __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(eventType, timeStamp, x, y));
 
                if( AppManager::GetInstance()->IsRunning(this->GetAppId() ) == false)
                {
@@ -373,10 +374,10 @@ _AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, doub
                        std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
 
                        // TODO: consider to remove these unused args.
-                       pArgs->Add(new String(ARG_KEY_EVENT_TYPE), new String(Integer::ToString(eventType)));
-                       pArgs->Add(new String(ARG_KEY_TIME_STAMP), new String(Double::ToString(timeStamp)));
-                       pArgs->Add(new String(ARG_KEY_X), new String(Double::ToString(x)));
-                       pArgs->Add(new String(ARG_KEY_Y), new String(Double::ToString(y)));
+                       pArgs->Add(new (nothrow) String(ARG_KEY_EVENT_TYPE), new (nothrow) String(Integer::ToString(eventType)));
+                       pArgs->Add(new (nothrow) String(ARG_KEY_TIME_STAMP), new (nothrow) String(Double::ToString(timeStamp)));
+                       pArgs->Add(new (nothrow) String(ARG_KEY_X), new (nothrow) String(Double::ToString(x)));
+                       pArgs->Add(new (nothrow) String(ARG_KEY_Y), new (nothrow) String(Double::ToString(y)));
 
                        return SendRequestToApp(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get());
                }
@@ -399,7 +400,7 @@ _AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation,
                if (!HasValidClientId() || __pAppContext->__isWaitingResult == true)
                {
                        SysLog(NID_SHELL, "The application is running but IPC is not connected yet.");
-                       __pPendingEventList->Add(new PendingEvent(*new String(operation), pArgs));
+                       __pPendingEventList->Add(new (nothrow) PendingEvent(operation, pArgs));
                }
                else
                {
@@ -446,14 +447,14 @@ _AppWidgetContext::SendAccessStatus(int accessStatus)
 Tizen::Base::Collection::HashMap*
 _AppWidgetContext::CreateRequestArgsN(void)
 {
-       HashMap* pArgs = new (std::nothrow) HashMap(SingleObjectDeleter);
+       HashMap* pArgs = new (nothrow) HashMap(SingleObjectDeleter);
        pArgs->Construct();
 
-       pArgs->Add(new String(ARG_KEY_INSTANCE_ID), new String(GetInstanceId()));
-       pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(GetProviderName()));
-       pArgs->Add(new String(ARG_KEY_USER_INFO), new String(GetUserInfo()));
-       pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(GetWidth())));
-       pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(GetHeight())));
+       pArgs->Add(new (nothrow) String(ARG_KEY_INSTANCE_ID), new (nothrow) String(GetInstanceId()));
+       pArgs->Add(new (nothrow) String(ARG_KEY_PROVIDER_NAME), new (nothrow) String(GetProviderName()));
+       pArgs->Add(new (nothrow) String(ARG_KEY_USER_INFO), new (nothrow) String(GetUserInfo()));
+       pArgs->Add(new (nothrow) String(ARG_KEY_WIDTH), new (nothrow) String(Integer::ToString(GetWidth())));
+       pArgs->Add(new (nothrow) String(ARG_KEY_HEIGHT), new (nothrow) String(Integer::ToString(GetHeight())));
 
        return pArgs;
 }
index d32dd93243cdd0355eaae1da5298a5e8b5a5977f..2261a444f7610b7bfda991045fc306fe8892ba6a 100644 (file)
@@ -758,10 +758,10 @@ AppWidgetManagerService::SendResult(const Tizen::App::AppId& appId, const Tizen:
 
                        while (pAppWidgetContextEnum->MoveNext() == E_SUCCESS)
                        {
-                               _AppWidgetContext* pValue = null;
-                               pAppWidgetContextEnum->GetValue(pValue);
+                               pAppWidgetContextEnum->GetValue(pAppWidgetContext);
+                               SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext, E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
 
-                               if (!pValue->IsRunning())
+                               if (!pAppWidgetContext->IsRunning())
                                {
                                        break;
                                }
index 0820901575565959f4f382c05bc773faa988aefa..286b3e3cbf4ce9d7ed710ca5a0d208f2cfe21f32 100644 (file)
@@ -86,18 +86,27 @@ OspAppWidgetService::OnBatteryLevelChanged(BatteryLevel batteryLevel)
 void
 OspAppWidgetService::OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData)
 {
-       ifoperationId == OPERATION_MAIN)
+       if (operationId == OPERATION_MAIN)
        {
                static bool isServiceCreated = false;
 
-               ifisServiceCreated == false)
+               if (isServiceCreated == false)
                {
                        String key(KEY_NAME);
                        const String* pValue = dynamic_cast<const String*>(pExtraData->GetValue(key));
 
-                       std::unique_ptr<char[]> pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue));
-                       AppWidgetManagerService* pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get());
-                       AppAssertf( pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
+                       AppWidgetManagerService* pSvc = null;
+
+                       if (pValue)
+                       {
+                               std::unique_ptr<char[]> pIdForCoreDaemon(_StringConverter::CopyToCharArrayN(*pValue));
+                               pSvc = AppWidgetManagerService::CreateInstance(pIdForCoreDaemon.get());
+                       }
+                       else
+                       {
+                               pSvc = AppWidgetManagerService::CreateInstance("osp-appwidget-service");
+                       }
+                       AppAssertf(pSvc != null, "AppWidgetManagerService::GetInstance() failed.");
 
                        isServiceCreated = true;
                }