namespace Tizen { namespace Shell
{
-
using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
using namespace Tizen::Security;
using namespace Tizen::Graphics;
-
-namespace
-{
-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 char APPWIDGET_POPUP_ON_CREATE[] = "http://tizen.org/appcontrol/appwidgetpopup/create";
-const char APPWIDGET_POPUP_ON_DESTROY[] = "http://tizen.org/appcontrol/appwidgetpopup/destroy";
-const char APPWIDGET_POPUP_ON_TOUCH[] = "http://tizen.org/appcontrol/appwidgetpopup/touch";
-const char APPWIDGET_POPUP_PREFIX[] = "http://tizen.org/appcontrol/appwidgetpopup";
-
-const String ARG_KEY_INSTANCE_ID = L"_InstanceId";
-const String ARG_KEY_PROVIDER_NAME = L"_ProviderName";
-const String ARG_KEY_USER_INFO = L"_UserInfo";
-const String ARG_KEY_X = L"_X";
-const String ARG_KEY_Y = L"_Y";
-const String ARG_KEY_WIDTH = L"_Width";
-const String ARG_KEY_HEIGHT = L"_Height";
-const String ARG_KEY_POPUP_WIDTH = L"_PopupWidth";
-const String ARG_KEY_POPUP_HEIGHT = L"_PopupHeight";
-const String ARG_KEY_ARGUMENT = L"_Argument";
-const String ARG_KEY_EVENT_TYPE = L"_EventType";
-const String ARG_KEY_TIME_STAMP = L"_TimeStamp";
-
-}
+extern const wchar_t APPWIDGET_ON_ADD[] = L"http://tizen.org/appcontrol/appwidget/add";
+extern const wchar_t APPWIDGET_ON_REMOVE[] = L"http://tizen.org/appcontrol/appwidget/remove";
+extern const wchar_t APPWIDGET_ON_UPDATE[] = L"http://tizen.org/appcontrol/appwidget/update";
+extern const wchar_t APPWIDGET_ON_RESIZE[] = L"http://tizen.org/appcontrol/appwidget/resize";
+extern const wchar_t APPWIDGET_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidget/touch";
+extern const wchar_t APPWIDGET_POPUP_ON_CREATE[] = L"http://tizen.org/appcontrol/appwidgetpopup/create";
+extern const wchar_t APPWIDGET_POPUP_ON_DESTROY[] = L"http://tizen.org/appcontrol/appwidgetpopup/destroy";
+extern const wchar_t APPWIDGET_POPUP_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidgetpopup/touch";
+extern const wchar_t APPWIDGET_POPUP_PREFIX[] = L"http://tizen.org/appcontrol/appwidgetpopup";
+extern const wchar_t INVALID_INSTANCE[] = L"file://invalid instance id";
+
+extern const String ARG_KEY_INSTANCE_ID = L"_InstanceId";
+extern const String ARG_KEY_PROVIDER_NAME = L"_ProviderName";
+extern const String ARG_KEY_USER_INFO = L"_UserInfo";
+extern const String ARG_KEY_X = L"_X";
+extern const String ARG_KEY_Y = L"_Y";
+extern const String ARG_KEY_WIDTH = L"_Width";
+extern const String ARG_KEY_HEIGHT = L"_Height";
+extern const String ARG_KEY_POPUP_WIDTH = L"_PopupWidth";
+extern const String ARG_KEY_POPUP_HEIGHT = L"_PopupHeight";
+extern const String ARG_KEY_ARGUMENT = L"_Argument";
+extern const String ARG_KEY_EVENT_TYPE = L"_EventType";
+extern const String ARG_KEY_TIME_STAMP = L"_TimeStamp";
_AppWidgetProviderManagerImpl::_AppWidgetProviderManagerImpl()
:__pAppWidgetFactory(null)
SysLog(NID_SHELL, "");
}
-
_AppWidgetProviderManagerImpl*
_AppWidgetProviderManagerImpl::GetInstance()
{
__pAppWidgetManagerImpl = new (nothrow)_AppWidgetProviderManagerImpl;
SysTryReturn(NID_SHELL, __pAppWidgetManagerImpl, null, E_OUT_OF_MEMORY, "Allocating new _AppWidgetManagerProxy failed.");
+ _AppWidgetManagerProxy::GetInstance();
+
result r = __pAppWidgetManagerImpl->Construct();
SysTryReturn(NID_SHELL, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r));
}
_AppWidgetProviderManagerImpl::SetAppWidgetProviderFactory(IAppWidgetProviderFactory& factory)
{
result r = ValidateApplicationAttribute();
- SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "The application's attribute does not meet the condition to provide AppWidget. 'LifeDuration' and 'UseUi' attribute should be specified in application manifest." );
+ if (IsFailed(r))
+ {
+ SysLog(NID_SHELL, "The application's attribute does not meet the condition to provide AppWidget. 'LifeDuration' and 'UseUi' attribute should be specified in application manifest and it's not allowed that declaring 'AUTO_RESTART' attribute for AppWidget.");
+
+ r = SendResult(INVALID_INSTANCE, false);
+ SysTryLog(NID_SHELL, !IsFailed(r), "Because the context for this dynamic box is removed, POLLRDHUP occurs.");
+
+ SysAssertf(false, "The application's attribute does not meet the condition to provide Dynamic Box.");
+ }
+
+ SysLog(NID_SHELL, "enter");
__pAppWidgetFactory = &factory;
return E_SUCCESS;
_AppWidgetProviderManagerImpl::SetAppWidgetPopupProviderFactory(IAppWidgetPopupProviderFactory& factory)
{
result r = ValidateApplicationAttribute();
- SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "The application's attribute does not meet the condition to provide AppWidget. 'LifeDuration' and 'UseUi' attribute should be specified in application manifest.");
+ if (IsFailed(r))
+ {
+ SysLog(NID_SHELL, "The application's attribute does not meet the condition to provide AppWidget. 'LifeDuration' and 'UseUi' attribute should be specified in application manifest and it's not allowed that declaring 'AUTO_RESTART' attribute for AppWidget.");
+
+ r = SendResult(INVALID_INSTANCE, false);
+ SysTryLog(NID_SHELL, !IsFailed(r), "Because the context for this dynamic box is removed, POLLRDHUP occurs.");
+
+ SysAssertf(false, "The application's attribute does not meet the condition to provide Dynamic Box.");
+ }
__pAppWidgetPopupProviderFactory = &factory;
return E_SUCCESS;
return contains;
}
-void
-_AppWidgetProviderManagerImpl::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUri, const String* pMimeType, const IMap* pArgs)
+result
+_AppWidgetProviderManagerImpl::CreateAppWidget(const String& instanceId, const String& operationId, const IMap* pArgs)
{
- SysAssertf( pArgs, "[E_SYSTEN] pArgs should not be null.");
- SysAssertf( pArgs->GetCount() > 0, "[E_SYSTEN] pArgs should have one more key-values.");
+ const String* pName = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_PROVIDER_NAME));
+ SysTryReturnResult(NID_SHELL, pName, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_PROVIDER_NAME.GetPointer() );
- SysLog(NID_SHELL, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount());
+ const String* pParam = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_USER_INFO));
+ SysTryReturnResult(NID_SHELL, pParam, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_USER_INFO.GetPointer() );
- const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
- SysTryReturnVoidResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() );
+ SysSecureLog(NID_SHELL, "id(%ls), name(%ls), param(%ls)", instanceId.GetPointer(), pName->GetPointer(), pParam->GetPointer());
- const String* pName = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_PROVIDER_NAME));
- SysTryReturnVoidResult(NID_SHELL, pName, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_PROVIDER_NAME.GetPointer() );
+ SysLog(NID_SHELL, "no appwidget instance, creating..");
- const String* pParam = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_USER_INFO));
- SysTryReturnVoidResult(NID_SHELL, pParam, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_USER_INFO.GetPointer() );
+ int width = 0;
+ const String* pValue = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_WIDTH));
+ SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_WIDTH.GetPointer() );
+ Integer::Parse(*pValue, width);
- SysSecureLog(NID_SHELL, "id(%ls), name(%ls), param(%ls)", pInstanceId->GetPointer(), pName->GetPointer(), pParam->GetPointer());
+ int height = 0;
+ pValue = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_HEIGHT));
+ SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_HEIGHT.GetPointer() );
+ Integer::Parse(*pValue, height);
- if(this->ContainsAppWidget(*pInstanceId) == false)
+ this->CreateAppWidget(*pName, instanceId, width, height, *pParam);
+
+ if(operationId == APPWIDGET_ON_RESIZE)
{
- SysLog(NID_SHELL, "no appwidget instance, creating..");
+ SysLog(NID_SHELL, "operation is resize, but appwidget is already recreated with new size, so OnSize won't be called.");
+ }
- int width = 0;
- const String* pValue = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_WIDTH));
- SysTryReturnVoidResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_WIDTH.GetPointer() );
- Integer::Parse(*pValue, width);
+ return E_SUCCESS;
+}
- int height = 0;
- pValue = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_HEIGHT));
- SysTryReturnVoidResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_HEIGHT.GetPointer() );
- Integer::Parse(*pValue, height);
+// entry point for AppControl Request
+void
+_AppWidgetProviderManagerImpl::OnAppControlRequestReceived(RequestId reqId, const String& operationId, const String* pUri, const String* pMimeType, const IMap* pArgs)
+{
+ SysAssertf( pArgs, "[E_SYSTEN] pArgs should not be null.");
+ SysAssertf( pArgs->GetCount() > 0, "[E_SYSTEN] pArgs should have one more key-values.");
- this->CreateAppWidget( *pName, *pInstanceId, width, height, *pParam);
+ SysLog(NID_SHELL, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount());
- if(operationId == APPWIDGET_ON_RESIZE)
- {
- SysLog(NID_SHELL, "operation is resize, but appwidget is already recreated with new size, so OnSize won't be called.");
- return;
- }
+ HandleRequest(operationId, pArgs);
+
+ SysLog(NID_SHELL, "Exit");
+}
+
+result
+_AppWidgetProviderManagerImpl::HandleRequest(const String& operationId, const IMap* pArgs)
+{
+ const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
+ SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to execute GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer());
+
+ if (this->ContainsAppWidget(*pInstanceId) == false)
+ {
+ SysLog(NID_SHELL, "CreateAppWidget with appcontrol");
+ result r = CreateAppWidget(*pInstanceId, operationId, pArgs);
+ SysTryReturnResult(NID_SHELL, !IsFailed(r), E_FAILURE, "Failed to execute CreateAppWidget.");
}
if(operationId.StartsWith(APPWIDGET_POPUP_PREFIX, 0) == true)
{
- SysTryReturnVoidResult(NID_SHELL, __pAppWidgetPopupProviderFactory, E_FAILURE, "[E_FAILURE] __pAppWidgetPopupProviderFactory is null");
+ SysTryReturnResult(NID_SHELL, __pAppWidgetPopupProviderFactory, E_FAILURE, "__pAppWidgetPopupProviderFactory is null");
HandleAppWidgetPopupRequest(operationId, pArgs);
}
else
{
- SysTryReturnVoidResult(NID_SHELL, __pAppWidgetFactory, E_FAILURE, "[E_FAILURE] __pAppWidgetFactory is null");
HandleAppWidgetRequest(operationId, pArgs);
}
- SysLog(NID_SHELL, "Exit");
+
+ return E_SUCCESS;
}
result
-_AppWidgetProviderManagerImpl::HandleAppWidgetRequest(const String& operationId, const IMap* pArgs)
+_AppWidgetProviderManagerImpl::HandleAppWidgetRequest(const String& operationId, const IMap* pArgs, bool isConnected)
{
+ SysTryReturnResult(NID_SHELL, __pAppWidgetFactory, E_FAILURE, "[E_FAILURE] __pAppWidgetFactory is null");
+
if( pArgs == null || pArgs->GetCount() < 3)
{
SysAssertf(pArgs, "[E_SYSTEN] pArgs should not be null.");
SysLog(NID_SHELL, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount());
const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
- SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "[E_FAILURE] pId is null.");
+ SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "pId is null.");
+
+ result r = E_SUCCESS;
+
+ if (isConnected)
+ {
+ if(this->ContainsAppWidget(*pInstanceId) == false)
+ {
+ SysLog(NID_SHELL, "CreateAppWidget with ipc");
+ r = CreateAppWidget(*pInstanceId, operationId, pArgs);
+ SysTryReturnResult(NID_SHELL, !IsFailed(r), E_FAILURE, "[E_FAILURE] Failed to execute CreateAppWidget.");
+ }
+ }
if (operationId == APPWIDGET_ON_RESIZE)
{
SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_HEIGHT.GetPointer() );
Integer::Parse(*pValue, height);
- this->ResizeAppWidget(*pInstanceId, width, height);
+ r = this->ResizeAppWidget(*pInstanceId, width, height);
+ SysTryReturnResult(NID_SHELL, !IsFailed(r), E_FAILURE, "Failed to execute ResizeAppWidget.");
}
else if (operationId == APPWIDGET_ON_UPDATE)
{
pValue = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_ARGUMENT));
SysTryReturnResult(NID_SHELL, pValue, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_ARGUMENT.GetPointer() );
- this->UpdateAppWidget(*pInstanceId, width, height, *pValue);
+ r = this->UpdateAppWidget(*pInstanceId, width, height, *pValue);
+ SysTryReturnResult(NID_SHELL, !IsFailed(r), E_FAILURE, "Failed to execute UpdateAppWidget.");
}
else if (operationId == APPWIDGET_ON_REMOVE)
{
- this->RemoveAppWidget(*pInstanceId, true);
+ r = this->RemoveAppWidget(*pInstanceId, true);
+ SysTryReturnResult(NID_SHELL, !IsFailed(r), E_FAILURE, "Failed to execute RemoveAppWidget.");
}
else if (operationId == APPWIDGET_ON_TOUCH)
{
SysLog(NID_SHELL, "[APPWIDGET_ON_TOUCH] touch events will be delivered after provider is initialized");
}
+
+ SendResult(*pInstanceId, true);
+
SysLog(NID_SHELL, "Exit");
return E_SUCCESS;
}
_AppWidgetManagerProxy* pProxy = _AppWidgetManagerProxy::GetInstance();
SysTryReturnResult(NID_SHELL, pProxy, E_SYSTEM, "Failed to get proxy instance!");
- result r = pProxy->RequestSyncSharedMemory(instanceId, width, height);
-
- return r;
+ return pProxy->RequestSyncSharedMemory(instanceId, width, height);
}
result
int lifeDuration = 0;
r = Integer::Parse(lifeDurationValue, lifeDuration);
SysTryReturnResult(NID_SHELL, !IsFailed(r), E_INVALID_OPERATION, "Failed to parse %ls attribute for the ServiceApp in package information.", LIFE_DURATION_KEY );
-// SysTryReturnResult(NID_SHELL, lifeDuration <= LIFE_DURATION_MIN, E_INVALID_OPERATION, "%ls attribute value should be less than '%d' to be an application that providing AppWidget, but value is %d", LIFE_DURATION_KEY, LIFE_DURATION_MIN, lifeDuration );
+ //SysTryReturnResult(NID_SHELL, lifeDuration <= LIFE_DURATION_MIN, E_INVALID_OPERATION, "%ls attribute value should be less than '%d' to be an application that providing AppWidget, but value is %d", LIFE_DURATION_KEY, LIFE_DURATION_MIN, lifeDuration );
// AutoRestart
- /*r = pInfo->GetValue(AUTO_RESTART_KEY, pFeature);
+ r = pInfo->GetValue(AUTO_RESTART_KEY, pFeature);
if (!IsFailed(r))
{
String autoRestart = pFeature->GetValue();
autoRestart.ToLowerCase();
SysTryReturnResult(NID_SHELL, autoRestart != "true", E_INVALID_OPERATION, "It's not allowed that declaring 'AUTO_RESTART' attribute for AppWidget.");
- }*/
+ }
_DeleteCollectionMapValue<String, _AppFeatureInfoImpl>(*pInfo);
#include <FAppIAppControlProviderEventListener.h>
#include <FApp_IAppEventListener.h>
-
namespace Tizen { namespace Shell {
class AppWidgetFrame;
class _IAppWidgetTouchEventListener;
class _AppWidgetManagerProxy;
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_ON_ADD[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_ON_REMOVE[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_ON_UPDATE[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_ON_RESIZE[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_ON_TOUCH[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_POPUP_ON_CREATE[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_POPUP_ON_DESTROY[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_POPUP_ON_TOUCH[];
+_OSP_EXPORT_ extern const wchar_t APPWIDGET_POPUP_PREFIX[];
+
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_INSTANCE_ID;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_PROVIDER_NAME;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_USER_INFO;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_X;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_Y;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_WIDTH;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_HEIGHT;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_POPUP_WIDTH;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_POPUP_HEIGHT;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_ARGUMENT;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_EVENT_TYPE;
+_OSP_EXPORT_ extern const Tizen::Base::String ARG_KEY_TIME_STAMP;
class _OSP_EXPORT_ _AppWidgetProviderManagerImpl
- : public Tizen::App::IAppControlProviderEventListener
+ : public Tizen::Base::Object
+ , public Tizen::App::IAppControlProviderEventListener
, public Tizen::App::_IAppEventListener
- , public Tizen::Base::Object
{
public:
static _AppWidgetProviderManagerImpl* GetInstance();
result ForwardTouchEvent(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y);
result ForwardTouchEventForPD(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y);
+ result HandleRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
+ result HandleAppWidgetRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs, bool isConnected = false);
+
// helper
-// static result ExtractAppIdAndProviderName(const Tizen::Base::String& providerId, Tizen::App::AppId& appId, Tizen::Base::String& providerName);
static result ValidateApplicationAttribute(void);
- void TerminateAppIfInvalidState();
-
private:
_AppWidgetProviderManagerImpl();
virtual ~_AppWidgetProviderManagerImpl();
result Construct();
+ result CreateAppWidget(const Tizen::Base::String& instanceId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
result CreateAppWidget(const Tizen::Base::String& name, const Tizen::Base::String& instanceId, int width, int height, const Tizen::Base::String& userInfo);
result UpdateAppWidget(const Tizen::Base::String& instanceId, int width, int height, const Tizen::Base::String& argument);
result ResizeAppWidget(const Tizen::Base::String& instanceId, int width, int height);
virtual void OnAppControlRequestReceived(RequestId reqId, const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData);
- result HandleAppWidgetRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
result HandleAppWidgetPopupRequest(const Tizen::Base::String& operationId, const Tizen::Base::Collection::IMap* pArgs);
static result CheckCertificate(const Tizen::App::AppId& localAppId, const Tizen::App::AppId& remoteAppId);