* @brief This is the implementation for the _AppWidgetContext class.
*/
-#include <stdlib.h>
+#include <provider.h>
#include <unique_ptr.h>
-#include "provider_buffer.h"
-
#include <FBase.h>
#include <FBaseSysLog.h>
+#include <FSysSystemTime.h>
+#include <FAppApp.h>
#include <FBase_StringConverter.h>
-
-#include <FApp_AppControlManager.h>
-
+#include <FApp_AppManagerImpl.h>
+#include "FShell_AppWidgetManagerImpl.h"
#include "FShell_AppWidgetManagerService.h"
#include "FShell_AppWidgetPopupContext.h"
-#include "FShell_AppWidgetContextBase.h"
#include "FShell_AppWidgetContext.h"
-
+#include "FShell_AppWidgetContextHelper.h"
+#include "FShell_AppWidgetRemoteBuffer.h"
namespace Tizen { namespace Shell { namespace App
{
+using namespace std;
using namespace Tizen::App;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
-
-
-const char APPWIDGET_ON_ADD[] = "http://tizen.org/appcontrol/appwidget/add";
-const char APPWIDGET_ON_REMOVE[] = "http://tizen.org/appcontrol/appwidget/remove";
-const char APPWIDGET_ON_UPDATE[] = "http://tizen.org/appcontrol/appwidget/update";
-const char APPWIDGET_ON_RESIZE[] = "http://tizen.org/appcontrol/appwidget/resize";
-const char APPWIDGET_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidget/touch";
-
-const int DEFAULT_LIFE_DURATION_MSEC = 30000;//30sec
-const int UPDATE_PERIOD_MSEC_MIN = 1800000;//30min
-
-_AppWidgetContext::_AppWidgetContext(const String& info, const String& providerId, const String& instanceId, int width, int height, int period, int priority)
- :_AppWidgetContextBase(TYPE_LB, info, providerId, instanceId, width, height, priority)
- ,__pAppWidgetPopup(null)
- ,__updateMillis(period)
- ,__pPendingTouchEventList(null)
+using namespace Tizen::System;
+
+const wchar_t ARG_KEY_INSTANCE_ID[] = L"_InstanceId";
+const wchar_t ARG_KEY_PROVIDER_NAME[] = L"_ProviderName";
+const wchar_t ARG_KEY_USER_INFO[] = L"_UserInfo";
+const wchar_t ARG_KEY_X[] = L"_X";
+const wchar_t ARG_KEY_Y[] = L"_Y";
+const wchar_t ARG_KEY_WIDTH[] = L"_Width";
+const wchar_t ARG_KEY_HEIGHT[] = L"_Height";
+const wchar_t ARG_KEY_POPUP_WIDTH[] = L"_PopupWidth";
+const wchar_t ARG_KEY_POPUP_HEIGHT[] = L"_PopupHeight";
+const wchar_t ARG_KEY_ARGUMENT[] = L"_Argument";
+const wchar_t ARG_KEY_EVENT_TYPE[] = L"_EventType";
+const wchar_t ARG_KEY_TIME_STAMP[] = L"_TimeStamp";
+
+const wchar_t APPWIDGET_ON_ADD[] = L"http://tizen.org/appcontrol/appwidget/add";
+const wchar_t APPWIDGET_ON_REMOVE[] = L"http://tizen.org/appcontrol/appwidget/remove";
+const wchar_t APPWIDGET_ON_UPDATE[] = L"http://tizen.org/appcontrol/appwidget/update";
+const wchar_t APPWIDGET_ON_RESIZE[] = L"http://tizen.org/appcontrol/appwidget/resize";
+const wchar_t APPWIDGET_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidget/touch";
+
+const int UPDATE_PERIOD_MSEC_MIN = 1800000; // 30min
+
+
+_AppWidgetContext::_AppWidgetContext(_AppContext* pAppContext, const String& instanceId, const String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period, int priority)
+ :__instanceId(instanceId)
+ ,__providerId(providerId)
+ ,__appId(_AppWidgetHelper::ExtractAppId(providerId))
+ ,__providerName(_AppWidgetHelper::ExtractProviderName(providerId))
+ ,__userInfo(userInfo)
+ ,__width(width)
+ ,__height(height)
+ ,__priority(priority)
+ ,__updateMillis( (period > UPDATE_PERIOD_MSEC_MIN) ? period : UPDATE_PERIOD_MSEC_MIN )
+ ,__ipcClientId(-1)
+ ,__isForeground(true)
+ ,__isRemoteBufferProxyCreated(false)
+ ,__lastUpdatedTime(0)
+ ,__hasPendingRequest(false)
+ ,__pAppContext(pAppContext)
+ ,__pAppWidgetPopup(null)
+ ,__pAppWidgetRemoteBuffer(null)
+ ,__pPendingTouchEventList(null)
{
-// __lifeDurationTimer.Construct(*this);//, true);
-// __lifeDurationTimer.Start(DEFAULT_LIFE_DURATION_MSEC );
+ SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d), period(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority, __updateMillis);
- __updateMillis = (__updateMillis > UPDATE_PERIOD_MSEC_MIN) ? __updateMillis : UPDATE_PERIOD_MSEC_MIN;
- SysLog(NID_SHELL, "period(%d)", __updateMillis);
- if( __updateMillis > 0)
+ // for updating period
+ if (__updateMillis > 0)
{
- __updateTimer.Construct(*this);//, false);
- __updateTimer.StartAsRepeatable(__updateMillis);
+ SystemTime::GetTicks(this->__lastUpdatedTime);
+
+ result r = __updateTimer.Construct(*this);
+ SysTryReturnVoidResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "");
+
+ r = __updateTimer.StartAsRepeatable(__updateMillis);
+ SysTryReturnVoidResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "");
}
- __pPendingTouchEventList = new ArrayListT<PendingTouchEvent*>();
+ __pPendingTouchEventList = new (nothrow) ArrayListT<PendingTouchEvent*>();
+ SysTryReturnVoidResult(NID_SHELL, __pPendingTouchEventList, E_OUT_OF_MEMORY, "");
__pPendingTouchEventList->Construct();
+
+ __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(providerId, instanceId, TYPE_LB, this);
+ SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, "");
}
-_AppWidgetContext::~_AppWidgetContext()
+_AppWidgetContext::~_AppWidgetContext(void)
{
- SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
-// __lifeDurationTimer.Cancel();
+ SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight(), GetPriority());
+
__updateTimer.Cancel();
if (__pAppWidgetPopup)
{
SysLog(NID_SHELL, "Destroying dangling AppWidgetPopup instance..");
- __pAppWidgetPopup->OnPopupDestoyed();
delete __pAppWidgetPopup;
}
-
- if( __pPendingTouchEventList )
+ if (__pPendingTouchEventList)
{
- for( int i = 0; i < __pPendingTouchEventList->GetCount(); i++)
+ for (int i = 0; i < __pPendingTouchEventList->GetCount(); i++)
{
PendingTouchEvent* pTouchEvent = null;
__pPendingTouchEventList->GetAt(i, pTouchEvent);
__pPendingTouchEventList->RemoveAll();
delete __pPendingTouchEventList;
}
+
+ if (__pAppWidgetRemoteBuffer)
+ {
+ delete __pAppWidgetRemoteBuffer;
+ }
+}
+
+_AppContext*
+_AppWidgetContext::GetAppContext(void) const
+{
+ return __pAppContext;
}
_AppWidgetPopupContext*
-_AppWidgetContext::GetAppWidgetPopup() const
+_AppWidgetContext::GetAppWidgetPopup(void) const
{
return __pAppWidgetPopup;
}
void
_AppWidgetContext::OnAdded(void)
{
- SendAddRequest(__width, __height);
+ SendAddRequest(GetWidth(), GetHeight());
}
-void
-_AppWidgetContext::OnRemoved()
+result
+_AppWidgetContext::OnRemoved(bool isTriggeredByViewer)
{
- SendRemoveRequest();
+ if (isTriggeredByViewer)
+ {
+ return SendRemoveRequest();
+ }
+ else
+ {
+ std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(GetProviderId()));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
+
+ int ret = provider_send_deleted(providerId.get(), id.get());
+ SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_send_deleted.");
+ }
+ return E_SUCCESS;
}
void
_AppWidgetContext::OnUpdate(const String& argument)
{
- SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+ SysLog(NID_SHELL, "argument(%ls)", argument.GetPointer());
+ ClearLastResult();
+
+ if (this->IsForeground())
+ {
+ result r = this->SendUpdateRequest(GetWidth(), GetHeight(), argument);
+ SysTryLog(NID_SHELL, !IsFailed(r), "Failed to execute SendUpdateRequest.");
+
+ SystemTime::GetTicks(this->__lastUpdatedTime);
+ SysLog(NID_SHELL, "The last updated time is %lld.", this->__lastUpdatedTime);
+
+ __hasPendingRequest = false;
+ __pendingArgument.Clear();
+ }
+ else
+ {
+ // Queueing the pointer of background context.
+ if (!argument.IsEmpty())
+ {
+ __pendingArgument = argument;
+ }
+
+ __hasPendingRequest = true;
+ SysLog(NID_SHELL, "Update is requested but the %ls is background.", (this->GetProviderId()).GetPointer());
+ }
+}
+
+result
+_AppWidgetContext::OnUpdateAsync(_AppContext* pAppContext, const String& argument)
+{
+ ArrayList* pArray = new (std::nothrow) ArrayList();
+ SysTryReturnResult(NID_SHELL, pArray, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ pArray->Construct();
+ pArray->Add(pAppContext);
+ pArray->Add(this);
+ pArray->Add(new String(argument));
- SendUpdateRequest(__width, __height, argument);
+ result r = Tizen::App::App::GetInstance()->SendUserEvent(LOCAL_EVENT_REQUEST_UPDATE, pArray);
+ SysTryLog(NID_SHELL, !IsFailed(r), "[%s] Propagated.", GetErrorMessage(r));
+ SysLog(NID_SHELL, "UserEvent(%d) is sent for '%ls.%ls'.", LOCAL_EVENT_REQUEST_UPDATE, GetAppId().GetPointer(), GetProviderName().GetPointer() );
+
+ return E_SUCCESS;
}
void
_AppWidgetContext::OnResize(int width, int height)
{
- SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+ SysSecureLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight(), GetPriority());
- __width = width;
- __height = height;
- SendResizeRequest(__width, __height);
+ SetWidth(width);
+ SetHeight(height);
+
+ SendResizeRequest(width, height);
}
void
-_AppWidgetContext::OnForeground()
+_AppWidgetContext::OnForeground(void)
{
- SysLog(NID_SHELL, "");
+ if (IsForeground())
+ {
+ SysLog(NID_SHELL, "%ls is already foreground.", (this->GetAppId()).GetPointer());
+ return;
+ }
+
__isForeground = true;
- __updateTimer.Cancel();
- __updateTimer.StartAsRepeatable(__updateMillis);
+ if (__hasPendingRequest == true)
+ {
+ SysLog(NID_SHELL, "There is pending request.");
+ OnUpdateAsync(__pAppContext, __pendingArgument);
+ }
+ else
+ {
+ if (IsUpdatePeriodExpired() == true)
+ {
+ SysLog(NID_SHELL, "The period is expired.");
+ OnUpdateAsync(__pAppContext, L"");
+ }
+ }
+}
+
+bool
+_AppWidgetContext::IsUpdatePeriodExpired(void) const
+{
+ if (this->GetPeriod() <= 0)
+ {
+ return false;
+ }
+
+ long long currentTicks = 0;
+ SystemTime::GetTicks(currentTicks);
+
+ SysLog(NID_SHELL, "current[%lld] - last updated time[%lld] = [%lld], period[%d]",
+ currentTicks, this->GetLastUpdatedTime(), currentTicks - this->GetLastUpdatedTime(), this->GetPeriod());
+
+ bool isPeriodExpired = (currentTicks - this->GetLastUpdatedTime()) >= (this->GetPeriod());
+ return isPeriodExpired;
}
void
-_AppWidgetContext::OnBackground()
+_AppWidgetContext::OnBackground(void)
{
- SysLog(NID_SHELL, "");
+ if (!IsForeground())
+ {
+ SysLog(NID_SHELL, "%ls is already background.", (this->GetAppId()).GetPointer());
+ return;
+ }
+
+ SysLog(NID_SHELL, "OnBackground");
__isForeground = false;
- __updateTimer.Cancel();
}
void
_AppWidgetContext::OnPopupCreated(double x, double y, int width, int height)
{
- __pAppWidgetPopup = new (std::nothrow) _AppWidgetPopupContext(__userInfo, __providerId, __instanceId, width, height, __priority, this);
- __pAppWidgetPopup->SetIpcClientId(__ipcClientId);
- __pAppWidgetPopup->OnPopupCreated(x, y, width, height);
+ __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(this);
+ SysTryReturnVoidResult(NID_SHELL, __pAppWidgetPopup, E_OUT_OF_MEMORY, "");
-// __lifeDurationTimer.Cancel();
+ __pAppWidgetPopup->OnPopupCreated(x, y, width, height);
}
void
_AppWidgetContext::OnPopupDestoyed(void)
{
SysLog(NID_SHELL, "");
+
if (__pAppWidgetPopup)
{
- __pAppWidgetPopup->OnPopupDestoyed();
delete __pAppWidgetPopup;
__pAppWidgetPopup = null;
}
-// RestartLifeDurationTimer();
}
result
-_AppWidgetContext::SendAddRequest(int width, int height)
+_AppWidgetContext::SendAddRequest(int width, int height) const
{
- std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
- return SendRequestToApp( __appId, APPWIDGET_ON_ADD, pArgs.get());
+ return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_ADD, pArgs.release());
}
result
-_AppWidgetContext::SendUpdateRequest(int width, int height, const String& argument)
+_AppWidgetContext::SendUpdateRequest(int width, int height, const String& argument) const
{
- std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+ 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( __appId, APPWIDGET_ON_UPDATE, pArgs.get());
+ return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_UPDATE, pArgs.release());
}
result
-_AppWidgetContext::SendResizeRequest(int width, int height)
+_AppWidgetContext::SendResizeRequest(int width, int height) const
{
- std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
- return SendRequestToApp( __appId, APPWIDGET_ON_RESIZE, pArgs.get());
+ return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_RESIZE, pArgs.release());
}
result
-_AppWidgetContext::SendRemoveRequest()
+_AppWidgetContext::SendRemoveRequest(void) const
{
- std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN());
- return SendRequestToApp( __appId, APPWIDGET_ON_REMOVE, pArgs.get());
+ return __pAppContext->SendRequestToApp(GetAppId(), APPWIDGET_ON_REMOVE, pArgs.release());
}
void
_AppWidgetContext::SendPendingTouchEvent(void)
{
- for(int i =0; i< __pPendingTouchEventList->GetCount(); i++)
+ for (int i =0; i< __pPendingTouchEventList->GetCount(); i++)
{
PendingTouchEvent* pTouchEvent = null;
__pPendingTouchEventList->GetAt(i, pTouchEvent);
- AppWidgetManagerService::GetInstance()->SendTouchEvent(__ipcClientId, __instanceId, pTouchEvent->eventType, pTouchEvent->timeStamp, pTouchEvent->x, pTouchEvent->y);
+ AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), pTouchEvent->eventType, pTouchEvent->timeStamp, pTouchEvent->x, pTouchEvent->y);
delete pTouchEvent;
}
__pPendingTouchEventList->RemoveAll();
}
-result
-_AppWidgetContext::SendTouchEvent(buffer_event eventType, double timeStamp, double x, double y)
+void
+_AppWidgetContext::OnTouchEventReceived(buffer_event event, double timestamp, double x, double y)
{
- if( HasValidClientId() && IsRunning() )
+ if (__pAppContext->GetConnectionState() == CONNECTION_STATE_CONNECTED && __isRemoteBufferProxyCreated)
{
- SysAssert(IsSharedMemCreated() == true);
- SysLog(NID_SHELL, "send IPC message");
- AppWidgetManagerService::GetInstance()->SendTouchEvent(__ipcClientId, __instanceId, eventType, timeStamp, x, y);
+ SysLog(NID_SHELL, "%d, %f, %f", event, x, y);
+ AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), event, timestamp, x, y);
}
else
{
- SysLog(NID_SHELL, "request to start AppControl");
- __pPendingTouchEventList->Add(new PendingTouchEvent(eventType, timeStamp, x, y));
+ __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(event, timestamp, x, y));
- //
- std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgs() );
+ if( _AppManagerImpl::GetInstance()->IsRunning(this->GetAppId() ) == false ||
+ ( __pAppContext->GetConnectionState() == CONNECTION_STATE_CONNECTED && __isRemoteBufferProxyCreated == false))
+ {
+ SysLog(NID_SHELL, "request to start AppControl");
+ std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
- 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)));
+ // TODO: consider to remove these unused args.
+ pArgs->Add(new (nothrow) String(ARG_KEY_EVENT_TYPE), new (nothrow) String(Integer::ToString(event)));
+ 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( __appId, APPWIDGET_ON_TOUCH, pArgs.get());
+ _AppWidgetRequestHelper::SendAppControlRequest(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get());
+ }
}
+}
+
+result
+_AppWidgetContext::SyncRemoteBuffer(int width, int height)
+{
+ std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(GetProviderId()));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
+ std::unique_ptr<char[]> content_info(_StringConverter::CopyToCharArrayN(GetUserInfo()));
+
+ int ret = provider_send_updated(providerId.get(), id.get(), width, height, GetPriority(), content_info.get(), null);
+ SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
+
+ SendPendingTouchEvent();
+ SysLog(NID_SHELL, "Done");
return E_SUCCESS;
}
result
-_AppWidgetContext::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
+_AppWidgetContext::SyncRemoteBufferForPD(void) const
{
- result r = _AppWidgetContextBase::SendRequestToApp(appId, operation, pArgs);
-// RestartLifeDurationTimer();
+ _AppWidgetPopupContext* pPopupContext = GetAppWidgetPopup();
+ SysSecureTryReturnResult(NID_SHELL, pPopupContext , E_SYSTEM, "pPopupContext is null for (%ls)", GetProviderId().GetPointer());
- return r;
+ return pPopupContext->SyncRemoteBuffer();
}
result
-_AppWidgetContext::RequestUpdateRemote(int width, int height)
+_AppWidgetContext::SendAccessStatus(int accessStatus) const
{
- /*if( GetAppWidgetPopup() != null)
- {
- SysLog(NID_SHELL, "AppWidgetPopup is appeared, so appWidget doesn't need to update");
- return E_SUCCESS;
- }*/
- std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
- std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
- std::unique_ptr<char[]> content_info(_StringConverter::CopyToCharArrayN(__userInfo));
-
- int ret = provider_send_updated(packageName.get(), id.get(), width, height, __priority, content_info.get(), null);
- SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
+ std::unique_ptr<char[]> providerId(_StringConverter::CopyToCharArrayN(GetProviderId()));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
+
+ int ret = provider_send_access_status(providerId.get(), id.get(), accessStatus);
+ SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_access_status");
- SendPendingTouchEvent();
- SysLog(NID_SHELL, "Done");
return E_SUCCESS;
}
Tizen::Base::Collection::HashMap*
-_AppWidgetContext::CreateRequestArgs(void)
+_AppWidgetContext::CreateRequestArgsN(void) const
{
- 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(__instanceId));
- pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__providerName));
- pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__userInfo));
- pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__width)));
- pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__height)));
+
+ 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;
}
+int
+_AppWidgetContext::GetPeriod(void) const
+{
+ return __updateMillis;
+}
+
+long long
+_AppWidgetContext::GetLastUpdatedTime(void) const
+{
+ return __lastUpdatedTime;
+}
-//void
-//_AppWidgetContext::RestartLifeDurationTimer()
-//{
-// __lifeDurationTimer.Cancel();
-// __lifeDurationTimer.Start(DEFAULT_LIFE_DURATION_MSEC);
-// SysLog(NID_SHELL, "lifeDuration timer restarted (%d)msec", DEFAULT_LIFE_DURATION_MSEC);
-//}
+int
+_AppWidgetContext::GetClientId(void) const
+{
+ return GetAppContext()->GetClientId();
+}
+
+int
+_AppWidgetContext::GetWidth(void) const
+{
+ return __width;
+}
+
+void
+_AppWidgetContext::SetWidth(int width)
+{
+ __width = width;
+}
+
+int
+_AppWidgetContext::GetHeight(void) const
+{
+ return __height;
+}
+
+void
+_AppWidgetContext::SetHeight(int height)
+{
+ __height = height;
+}
+
+String
+_AppWidgetContext::GetProviderId(void) const
+{
+ return __providerId;
+}
+
+/*void
+_AppWidgetContext::SetProviderId(const String& providerId)
+{
+ __providerId = providerId;
+}*/
+
+String
+_AppWidgetContext::GetAppId(void) const
+{
+ return __appId;
+}
+
+int
+_AppWidgetContext::GetPriority(void) const
+{
+ return __priority;
+}
+
+/*void
+_AppWidgetContext::SetPriority(int priority)
+{
+ __priority = priority;
+}*/
+
+String
+_AppWidgetContext::GetProviderName(void) const
+{
+ return __providerName;
+}
+
+bool
+_AppWidgetContext::IsForeground(void) const
+{
+ return __isForeground;
+}
+
+String
+_AppWidgetContext::GetUserInfo(void) const
+{
+ return __userInfo;
+}
+
+/*void
+_AppWidgetContext::SetUserInfo(const String& userInfo)
+{
+ __userInfo = userInfo;
+}*/
+
+String
+_AppWidgetContext::GetInstanceId(void) const
+{
+ return __instanceId;
+}
void
_AppWidgetContext::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
{
-// if( &timer == &__lifeDurationTimer)
-// {
-// SysLog(NID_SHELL, "lifeDuration timer is expired, so terminating appWidget app(%ls)..", __providerId.GetPointer() );
-//
-//// ReleaseSharedMem();
-// AppManager::GetInstance()->TerminateApplication(__appId);
-//
-// }
-// else
- if( &timer == &__updateTimer)
+ if (&timer == &__updateTimer)
{
- SysLog(NID_SHELL, "update timer is expired for appWidget app(%ls)..", __providerId.GetPointer() );
+ SysLog(NID_SHELL, "update timer is expired for appWidget app(%ls).", GetProviderId().GetPointer());
OnUpdate(L"");
}
}
+void
+_AppWidgetContext::OnDisconnected(void)
+{
+ SysSecureLog(NID_SHELL, "%ls, %ls", GetInstanceId().GetPointer(), GetProviderId().GetPointer());
+
+ __isRemoteBufferProxyCreated = false;
+ if (GetAppWidgetPopup())
+ {
+ OnPopupDestoyed();
+ }
+}
+
+int
+_AppWidgetContext::AcquireRemoteBuffer(int w, int h) const
+{
+ int id = __pAppWidgetRemoteBuffer->Acquire(w, h);
+ if (id != -1)
+ {
+ __isRemoteBufferProxyCreated = true;
+ }
+ return id;
+}
+
+int
+_AppWidgetContext::AcquireRemoteBufferForPD(int w, int h) const
+{
+ _AppWidgetPopupContext* pPopupContext = GetAppWidgetPopup();
+ SysSecureTryReturnResult(NID_SHELL, pPopupContext , E_SYSTEM, "pPopupContext is null for (%ls)", GetProviderId().GetPointer());
-} } } // Tizen::Shell::App {
+ int bufferId = pPopupContext->AcquireRemoteBuffer(w, h);
+ SysSecureTryReturnResult(NID_SHELL, bufferId != -1, E_SYSTEM, "Failed to AcquireRemoteBuffer for (%ls)", GetProviderId().GetPointer());
+
+ return bufferId;
+}
+}}} // Tizen::Shell::App