src/OspAppWidgetService.cpp
src/OspAppWidgetServiceEntry.cpp
src/FShell_AppWidgetContext.cpp
- src/FShell_AppWidgetContextBase.cpp
+ src/FShell_AppWidgetRemoteBuffer.cpp
src/FShell_AppWidgetManagerService.cpp
src/FShell_AppWidgetManagerStub.cpp
src/FShell_AppWidgetPopupContext.cpp
#define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
#include <provider_buffer.h>
+#include <FAppTypes.h>
#include <FBaseRtTimer.h>
#include <FBaseColArrayListT.h>
-#include "FShell_AppWidgetContextBase.h"
+#include "FShell_AppWidgetRemoteBuffer.h"
namespace Tizen { namespace Base { namespace Collection
{
namespace Tizen { namespace Shell { namespace App
{
-class _AppWidgetPopupContext;
+extern const wchar_t ARG_KEY_INSTANCE_ID[];
+extern const wchar_t ARG_KEY_PROVIDER_NAME[];
+extern const wchar_t ARG_KEY_USER_INFO[];
+extern const wchar_t ARG_KEY_X[];
+extern const wchar_t ARG_KEY_Y[];
+extern const wchar_t ARG_KEY_WIDTH[];
+extern const wchar_t ARG_KEY_HEIGHT[];
+extern const wchar_t ARG_KEY_POPUP_WIDTH[];
+extern const wchar_t ARG_KEY_POPUP_HEIGHT[];
+extern const wchar_t ARG_KEY_ARGUMENT[];
+extern const wchar_t ARG_KEY_EVENT_TYPE[];
+extern const wchar_t ARG_KEY_TIME_STAMP[];
+
extern const int UPDATE_PERIOD_MSEC_MIN;
class _AppWidgetContext;
-
+class _AppWidgetPopupContext;
////////////////////////////////////////////////
// _AppContext
// _AppWidgetContext
////////////////////////////////////////////////
class _AppWidgetContext
- : public _AppWidgetContextBase
- , public Tizen::Base::Runtime::ITimerEventListener
+ : public Tizen::Base::Runtime::ITimerEventListener
+ , public _IAppWidgetRemoteBufferEventListener
+ , public Tizen::Base::Object
{
public:
_AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& name, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority);
virtual ~_AppWidgetContext(void);
+ // handle dynamic box
void OnAdded(void);
void OnUpdate(const Tizen::Base::String& argument);
void OnResize(int width, int height);
result OnRemoved(void);
+ result SendPendingEvent(void);
+ int GetPeriod(void) const;
+ long long GetLastUpdatedTime(void) const;
+ bool IsForeground(void) const;
+ void SetForeground(bool forground);
+ int GetSharedMemId(int w, int h) const;
+ void OnDisconnected(void);
+ virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y);
+ // dynamic box state
bool IsPaused(void) const;
void OnForeground(void);
void OnBackground(void);
- virtual void OnPopupCreated(double x, double y, int width, int height);
- virtual void OnPopupDestoyed(void);
+ // handle drop view
+ void OnPopupCreated(double x, double y, int width, int height);
+ void OnPopupDestoyed(void);
_AppWidgetPopupContext* GetAppWidgetPopup(void) const;
+ result SendPopupRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
- virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y);
- result RequestUpdateRemote(int width, int height);
- result SendPendingEvent(void);
- result SendAccessStatus(int accessStatus);
-
- int GetPeriod(void) const;
- long long GetLastUpdatedTime(void) const;
-
+ // for common
_AppContext* GetAppContext(void) const;
+ result SendAccessStatus(int accessStatus);
+ result RequestUpdateRemote(int width, int height);
+ Tizen::Base::String GetAppId(void) const;
+ Tizen::Base::String GetProviderName(void) const;
+
+ Tizen::Base::String GetUserInfo(void) const;
+ void SetUserInfo(const Tizen::Base::String& userInfo);
+ Tizen::Base::String GetProviderId(void) const;
+ void SetProviderId(const Tizen::Base::String& providerId);
+ Tizen::Base::String GetInstanceId(void) const;
+ void SetInstanceId(const Tizen::Base::String& instanceId);
+ int GetWidth(void) const;
+ void SetWidth(int width);
+ int GetHeight(void) const;
+ void SetHeight(int height);
+ int GetPriority(void) const;
+ void SetPriority(int priority);
private:
result SendAddRequest(int width, int height);
result SendUpdateRequest(int width, int height, const Tizen::Base::String& argument);
result SendResizeRequest(int width, int height);
result SendRemoveRequest(void);
- result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
void SendPendingTouchEvent(void);
result RequestUpdate(const Tizen::Base::String& argument);
+ result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void);
int GetClientId(void) const;
};
private:
- _AppWidgetPopupContext* __pAppWidgetPopup;
- Tizen::Base::Runtime::Timer __updateTimer;
+ mutable bool __isTouchAvailable;
+ bool __hasPendingRequest;
+ bool __isForeground;
+ int __width;
+ int __height;
+ int __priority;
+ int __ipcClientId;
int __updateMillis;
long long __lastUpdatedTime;
- Tizen::Base::Collection::ArrayListT<PendingTouchEvent*>* __pPendingTouchEventList;
+
+ Tizen::Base::String __userInfo;
+ Tizen::Base::String __providerId;
+ Tizen::Base::String __instanceId;
+ Tizen::Base::String __appId;
+ Tizen::Base::String __providerName;
Tizen::Base::String __pendingArgument;
- bool __hasPendingRequest;
+ Tizen::Base::Runtime::Timer __updateTimer;
+
_AppContext* __pAppContext;
+ _AppWidgetPopupContext* __pAppWidgetPopup;
+ _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer;
+ Tizen::Base::Collection::ArrayListT<PendingTouchEvent*>* __pPendingTouchEventList;
Tizen::Base::Collection::ArrayListT<PendingEvent*>* __pPendingEventList;
}; // class _AppWidgetContext
+++ /dev/null
-//
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.1 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// 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 FShell_AppWidgetContextBase.h
- * @brief This is the header file for the _AppWidgetContextBase class.
- *
- * This header file contains the declarations of the _AppWidgetContextBase class.
- */
-
-#ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
-#define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
-
-#include <provider_buffer.h>
-#include <FAppTypes.h>
-
-#define APPWIDGET_PROVIDER_ID_ENABLE true
-
-namespace Tizen { namespace Base { namespace Collection
-{
-class HashMap;
-}}}
-
-namespace Tizen { namespace Shell { namespace App
-{
-
-class _AppWidgetContextBase
- : public Tizen::Base::Object
-{
-public:
- _AppWidgetContextBase(target_type type, const Tizen::Base::String& userInfo, const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, int width, int height, int priority);
- virtual ~_AppWidgetContextBase(void);
- virtual void OnPopupCreated(double x, double y, int width, int height) = 0;
- virtual void OnPopupDestoyed(void) = 0;
- virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y) = 0;
-
- // for buffered appWidget
- int GetSharedMemId(int w, int h);
- result ReleaseSharedMem(void);
-
- Tizen::Base::String GetInstanceId(void) const;
- int GetWidth(void) const;
- int GetHeight(void) const;
- Tizen::Base::String GetProviderId(void) const;
- Tizen::Base::String GetAppId(void) const;
- int GetPriority(void) const;
- Tizen::Base::String GetProviderName(void) const;
-
- void OnDisconnected(void);
- bool IsRemoteBufferCreated(void) const;
-
-protected:
- bool IsSharedMemCreated(void) const;
- virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) = 0;
- result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
- result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
- void SetForeground(bool forground);
- bool IsForeground(void) const;
- Tizen::Base::String GetUserInfo(void) const;
- void SetWidth(int width);
- void SetHeight(int height);
-
-protected:
- bool __isRemoteBufferCreated;
-
-private:
- target_type __type;
- Tizen::Base::String __userInfo;
- Tizen::Base::String __providerId;
- Tizen::Base::String __instanceId;
- int __width;
- int __height;
- int __priority;
- bool __isForeground;
- int __ipcClientId;
- Tizen::Base::String __appId;
- Tizen::Base::String __providerName;
- struct livebox_buffer *__buffer_info;
- void *__buffer;
-
-}; // class _AppWidgetContextBase
-
-extern const Tizen::Base::String ARG_KEY_INSTANCE_ID;
-extern const Tizen::Base::String ARG_KEY_PROVIDER_NAME;
-extern const Tizen::Base::String ARG_KEY_USER_INFO;
-extern const Tizen::Base::String ARG_KEY_X;
-extern const Tizen::Base::String ARG_KEY_Y;
-extern const Tizen::Base::String ARG_KEY_WIDTH;
-extern const Tizen::Base::String ARG_KEY_HEIGHT;
-extern const Tizen::Base::String ARG_KEY_POPUP_WIDTH;
-extern const Tizen::Base::String ARG_KEY_POPUP_HEIGHT;
-extern const Tizen::Base::String ARG_KEY_ARGUMENT;
-extern const Tizen::Base::String ARG_KEY_EVENT_TYPE;
-extern const Tizen::Base::String ARG_KEY_TIME_STAMP;
-
-}}} // Tizen::Shell::App
-
-#endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
#ifndef _FSHELL_INTERNAL_APPWIDGET_POPUP_CONTEXT_H_
#define _FSHELL_INTERNAL_APPWIDGET_POPUP_CONTEXT_H_
-#include "FShell_AppWidgetContextBase.h"
+#include "FShell_AppWidgetRemoteBuffer.h"
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class HashMap;
+}}}
namespace Tizen { namespace Shell { namespace App
{
class _AppWidgetContext;
class _AppWidgetPopupContext
- :public Tizen::Shell::App::_AppWidgetContextBase
+ :public Tizen::Base::Object
+ , public _IAppWidgetRemoteBufferEventListener
{
public:
- _AppWidgetPopupContext(const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent);
+ _AppWidgetPopupContext(_AppWidgetContext* pParent);
virtual ~_AppWidgetPopupContext(void);
// event handler
// request to app
result SendPopupCreateRequest(double x, double y, int width, int height);
result SendPopupDestroyRequest(void);
- virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y);
result RequestUpdateRemote(void);
+ int GetSharedMemId(int w, int h) const;
+
+ virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y);
private:
- virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void);
+ Tizen::Base::Collection::HashMap* CreateRequestArgsN(void);
int GetClientId(void) const;
private:
_AppWidgetContext* __pParent;
+ _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer;
}; // class _AppWidgetPopupContext
--- /dev/null
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FShell_AppWidgetRemoteBuffer.h
+ * @brief This is the header file for the _AppWidgetRemoteBuffer class.
+ *
+ * This header file contains the declarations of the _AppWidgetRemoteBuffer class.
+ */
+
+#ifndef _FSHELL_APPWIDGET_REMOTE_BUFFER_H_
+#define _FSHELL_APPWIDGET_REMOTE_BUFFER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <provider_buffer.h>
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+class _IAppWidgetRemoteBufferEventListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ _IAppWidgetRemoteBufferEventListener(void){}
+ ~_IAppWidgetRemoteBufferEventListener(void){}
+
+ virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y) = 0;
+};
+
+class _AppWidgetRemoteBuffer
+ :public Tizen::Base::Object
+{
+public:
+ _AppWidgetRemoteBuffer(const Tizen::Base::String& providerId, const Tizen::Base::String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener);
+ ~_AppWidgetRemoteBuffer(void);
+
+ int GetSharedMemId(int w, int h);
+
+private:
+ result ReleaseSharedMem(void);
+
+private:
+ target_type __type;
+ Tizen::Base::String __providerId;
+ Tizen::Base::String __instanceId;
+ void* __buffer;
+ struct livebox_buffer* __buffer_info;
+ _IAppWidgetRemoteBufferEventListener* __pListener;
+
+}; // class _AppWidgetRemoteBuffer
+
+}}} // Tizen::Shell::App
+
+#endif // _FSHELL_APPWIDGET_REMOTE_BUFFER_H_
#include <FAppAppManager.h>
#include <FBase_StringConverter.h>
+#include "FShell_AppWidgetManagerImpl.h"
#include "FShell_AppWidgetManagerService.h"
#include "FShell_AppWidgetPopupContext.h"
#include "FShell_AppWidgetContext.h"
#include "FShell_AppWidgetContextHelper.h"
+#include "FShell_AppWidgetRemoteBuffer.h"
namespace Tizen { namespace Shell { namespace App
{
using namespace Tizen::Base::Collection;
using namespace Tizen::System;
-const String APPWIDGET_ON_ADD = L"http://tizen.org/appcontrol/appwidget/add";
-const String APPWIDGET_ON_REMOVE = L"http://tizen.org/appcontrol/appwidget/remove";
-const String APPWIDGET_ON_UPDATE = L"http://tizen.org/appcontrol/appwidget/update";
-const String APPWIDGET_ON_RESIZE = L"http://tizen.org/appcontrol/appwidget/resize";
-const String APPWIDGET_ON_TOUCH = L"http://tizen.org/appcontrol/appwidget/touch";
+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& 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)
+ :__isTouchAvailable(false)
+ ,__hasPendingRequest(false)
+ ,__isForeground(true)
+ ,__width(width)
+ ,__height(height)
+ ,__priority(priority)
+ ,__ipcClientId(-1)
,__updateMillis(period)
,__lastUpdatedTime(0)
- ,__pPendingTouchEventList(null)
- ,__hasPendingRequest(false)
+ ,__userInfo(info)
+ ,__providerId(providerId)
+ ,__instanceId(instanceId)
,__pAppContext(pAppContext)
+ ,__pAppWidgetPopup(null)
+ ,__pAppWidgetRemoteBuffer(null)
+ ,__pPendingTouchEventList(null)
,__pPendingEventList(null)
{
+ _AppWidgetManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
+ SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
+
// for updating period
if (__updateMillis > 0)
{
}
__pPendingTouchEventList = new (nothrow) ArrayListT<PendingTouchEvent*>();
+ SysTryReturnVoidResult(NID_SHELL, __pPendingTouchEventList, E_OUT_OF_MEMORY, "");
__pPendingTouchEventList->Construct();
__pPendingEventList = new (nothrow) ArrayListT<PendingEvent*>();
+ SysTryReturnVoidResult(NID_SHELL, __pPendingEventList, E_OUT_OF_MEMORY, "");
__pPendingEventList->Construct();
+
+ __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(providerId, instanceId, TYPE_LB, this);
+ SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, "");
}
_AppWidgetContext::~_AppWidgetContext(void)
__pPendingEventList->RemoveAll();
delete __pPendingEventList;
}
+
+ if (__pAppWidgetRemoteBuffer)
+ {
+ delete __pAppWidgetRemoteBuffer;
+ }
}
_AppContext*
void
_AppWidgetContext::OnPopupCreated(double x, double y, int width, int height)
{
- __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(GetUserInfo(), GetProviderId(), GetInstanceId(), GetWidth(), GetHeight(), GetPriority(), this);
+ __pAppWidgetPopup = new (nothrow) _AppWidgetPopupContext(this);
+ SysTryReturnVoidResult(NID_SHELL, __pAppWidgetPopup, E_OUT_OF_MEMORY, "");
+
__pAppWidgetPopup->OnPopupCreated(x, y, width, height);
}
__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 (__pAppContext->GetConnectionState() == _AppContext::CONNECTED && IsRemoteBufferCreated())
+ if (__pAppContext->GetConnectionState() == _AppContext::CONNECTED && __isTouchAvailable)
{
- SysAssert(IsSharedMemCreated() == true);
- SysLog(NID_SHELL, "%d, %f, %f", eventType, x, y);
- AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), eventType, timeStamp, x, y);
+ SysLog(NID_SHELL, "%d, %f, %f", event, x, y);
+ AppWidgetManagerService::GetInstance()->SendTouchEvent(GetClientId(), GetInstanceId(), event, timestamp, x, y);
}
else
{
- __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(eventType, timeStamp, x, y));
+ __pPendingTouchEventList->Add(new (nothrow) PendingTouchEvent(event, timestamp, x, y));
if( AppManager::GetInstance()->IsRunning(this->GetAppId() ) == false)
{
std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
// TODO: consider to remove these unused args.
- 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_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(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get());
+ SendRequestToApp(GetAppId(), APPWIDGET_ON_TOUCH, pArgs.get());
}
}
- return E_SUCCESS;
}
result
if ( __pAppContext->GetConnectionState() == _AppContext::NONE || __pAppContext->GetConnectionState() == _AppContext::DISCONNECTED)
{
SysLog(NID_SHELL, "The application is not running.");
- result r = _AppWidgetContextBase::SendRequestToApp(appId, operation, pArgs);
+ result r = _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);
SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r));
__pAppContext->__isWaitingResult = true;
}
result
+_AppWidgetContext::SendPopupRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
+{
+ return _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);;
+}
+
+result
_AppWidgetContext::RequestUpdateRemote(int width, int height)
{
std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(GetProviderId()));
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;
+}
+
+void
+_AppWidgetContext::SetForeground(bool foreground)
+{
+ __isForeground = foreground;
+}
+
+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)
{
}
}
+void
+_AppWidgetContext::OnDisconnected(void)
+{
+ __isTouchAvailable = false;
+}
+
+int
+_AppWidgetContext::GetSharedMemId(int w, int h) const
+{
+ int id = __pAppWidgetRemoteBuffer->GetSharedMemId(w, h);
+ if (id != -1)
+ {
+ __isTouchAvailable = true;
+ }
+ return id;
+}
+
}}} // Tizen::Shell::App
+++ /dev/null
-//
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.1 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// 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 FShell_AppWidgetContextBase.cpp
- * @brief This is the implementation for the _AppWidgetContextBase class.
- */
-
-#include <stdlib.h>
-#include <unique_ptr.h>
-#include <provider.h>
-#include <FBaseColHashMap.h>
-#include <FBaseSysLog.h>
-#include <FBaseRt.h>
-#include <FBase_StringConverter.h>
-#include "FShell_AppWidgetManagerImpl.h"
-#include "FShell_AppWidgetContextBase.h"
-#include "FShell_AppWidgetManagerService.h"
-#include "FShell_AppWidgetContextHelper.h"
-
-// provider/src/fb.c
-struct fb_info {
- char *id;
- int w;
- int h;
- int bufsz;
- void *buffer;
-
- int handle;
-};
-
-// provider/inc/provider_buffer_internal.h
-struct livebox_buffer {
- enum {
- BUFFER_CREATED = 0x00beef00,
- BUFFER_DESTROYED = 0x00dead00,
- } state;
-
- enum target_type type;
-
- union {
- int fd; /* File handle(descriptor) */
- int id; /* SHM handle(id) */
- } handle;
-
- char *pkgname;
- char *id;
- int width;
- int height;
- int pixel_size;
-
- struct fb_info *fb;
-
- int (*handler)(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void *data);
- void *data;
-};
-
-static int AppWidgetHandleBufferEventCallback(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void* data);
-
-namespace Tizen { namespace Shell { namespace App
-{
-
-using namespace Tizen::App;
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-
-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";
-
-_AppWidgetContextBase::_AppWidgetContextBase(target_type type, const String& userInfo, const String& providerId, const String& instanceId, int width, int height, int priority)
- :__type(type)
- ,__userInfo(userInfo)
- ,__providerId(providerId)
- ,__instanceId(instanceId)
- ,__width(width)
- ,__height(height)
- ,__priority(priority)
- ,__isForeground(true)
- ,__buffer_info(null)
- ,__buffer(null)
- ,__isRemoteBufferCreated(false)
-{
- _AppWidgetManagerImpl::ExtractAppIdAndProviderName(providerId, __appId, __providerName);
-
- SysSecureLog(NID_SHELL, "appId(%ls), providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __appId.GetPointer(), __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
-}
-
-_AppWidgetContextBase::~_AppWidgetContextBase(void)
-{
- SysSecureLog(NID_SHELL, "providerId(%ls), instanceId(%ls), width(%d), height(%d), priority(%d)", __providerId.GetPointer(), __instanceId.GetPointer(), __width, __height, __priority);
- ReleaseSharedMem();
-}
-
-bool
-_AppWidgetContextBase::IsSharedMemCreated(void) const
-{
- return ( __buffer_info && __buffer);
-}
-
-int
-_AppWidgetContextBase::GetSharedMemId(int w, int h)
-{
- SysLog(NID_SHELL, "Enter");
-
- bool isResized = (__buffer_info != null) && (__buffer_info->width != w || __buffer_info->height != h);
- if ( isResized )
- {
- ReleaseSharedMem();
- }
-
- if( __buffer_info == null)
- {
- std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
- std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
-
- __buffer_info = provider_buffer_acquire(__type, packageName.get(), id.get(), w, h, sizeof(int), AppWidgetHandleBufferEventCallback, this);
- SysTryReturnResult(NID_SHELL, __buffer_info , -1, "[E_SYSTEM] failed to provider_buffer_acquire");
- SysLog(NID_SHELL, "provider_buffer_acquire successed");
-
- __buffer = provider_buffer_ref(__buffer_info);
- SysTryReturnResult(NID_SHELL, __buffer , -1, "[E_SYSTEM] failed to provider_buffer_ref");
- SysLog(NID_SHELL, "provider_buffer_ref successed");
- }
-
- int bufferId = __buffer_info->fb->handle;
- __isRemoteBufferCreated = true;
-
- SysLog(NID_SHELL, "(%d) Exit", bufferId);
- return bufferId;
-}
-
-
-void
-_AppWidgetContextBase::OnDisconnected(void)
-{
- __isRemoteBufferCreated = false;
-}
-
-bool
-_AppWidgetContextBase::IsRemoteBufferCreated(void) const
-{
- return __isRemoteBufferCreated;
-}
-
-result
-_AppWidgetContextBase::ReleaseSharedMem(void)
-{
- SysLog(NID_SHELL, "Enter");
-
- int ret;
-
- if( __buffer)
- {
- ret = provider_buffer_unref(__buffer);
- __buffer = null;
- SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_buffer_unref");
- SysLog(NID_SHELL, "provider_buffer_unref successed");
- }
-
- if( __buffer_info)
- {
- ret = provider_buffer_release(__buffer_info);
- __buffer_info = null;
- SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_buffer_release");
- SysLog(NID_SHELL, "provider_buffer_release successed");
- }
-
- SysLog(NID_SHELL, "Exit.");
-
- return E_SUCCESS;
-}
-
-result
-_AppWidgetContextBase::SendRequestToApp(const AppId& appId, const String& operation, HashMap* pArgs)
-{
- result r = _AppWidgetRequestHelper::SendAppControlRequest(appId, operation, pArgs);
- SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "Failed to SendRequestToApp");
-
- return r;
-}
-
-String
-_AppWidgetContextBase::GetAppId(void) const
-{
- return __appId;
-}
-
-String
-_AppWidgetContextBase::GetProviderName(void) const
-{
- return __providerName;
-}
-
-String
-_AppWidgetContextBase::GetUserInfo(void) const
-{
- return __userInfo;
-}
-
-void
-_AppWidgetContextBase::SetForeground(bool foreground)
-{
- __isForeground = foreground;
-}
-
-bool
-_AppWidgetContextBase::IsForeground(void) const
-{
- return __isForeground;
-}
-
-int
-_AppWidgetContextBase::GetWidth(void) const
-{
- return __width;
-}
-
-int
-_AppWidgetContextBase::GetHeight(void) const
-{
- return __height;
-}
-
-String
-_AppWidgetContextBase::GetInstanceId(void) const
-{
- return __instanceId;
-}
-
-String
-_AppWidgetContextBase::GetProviderId(void) const
-{
- return __providerId;
-}
-
-int
-_AppWidgetContextBase::GetPriority(void) const
-{
- return __priority;
-}
-
-void
-_AppWidgetContextBase::SetWidth(int width)
-{
- __width = width;
-}
-
-void
-_AppWidgetContextBase::SetHeight(int height)
-{
- __height = height;
-}
-
-}}} // Tizen::Shell::App
-
-////////////////////////////////////////////
-// callback
-////////////////////////////////////////////
-static int AppWidgetHandleBufferEventCallback( struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void* data)
-{
- SysLog(NID_SHELL, "timestamp(%f), x(%f), y(%f)", timestamp, x, y);
-
- Tizen::Shell::App::_AppWidgetContextBase *pAppWidgetBase = static_cast<Tizen::Shell::App::_AppWidgetContextBase*>(data);
- SysTryReturn(NID_SHELL, pAppWidgetBase != null, 0, E_SYSTEM, "[E_SYSTEM] retrieved pAppWidgetBase is null");
-
- if (event == BUFFER_EVENT_ENTER)
- {
- SysLog(NID_SHELL, "BUFFER_EVENT_ENTER");
- }
- else if (event == BUFFER_EVENT_LEAVE)
- {
- SysLog(NID_SHELL, "BUFFER_EVENT_LEAVE");
- }
- else if (event == BUFFER_EVENT_DOWN)
- {
- SysLog(NID_SHELL, "BUFFER_EVENT_DOWN");
- }
- else if (event == BUFFER_EVENT_MOVE)
- {
- SysLog(NID_SHELL, "BUFFER_EVENT_MOVE");
- }
- else if(event == BUFFER_EVENT_UP)
- {
- SysLog(NID_SHELL, "BUFFER_EVENT_UP");
- }
-
- pAppWidgetBase->SendTouchEvent(event, timestamp, x, y);
-
- return 0;
-}
result
_AppWidgetRequestHelper::SendAppControlRequest(const AppId& appId, const String& operation, HashMap* pArgs)
{
- const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
- SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() );
+ const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(String(ARG_KEY_INSTANCE_ID)));
+ SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to get the instance id.");
SysSecureLog(NID_SHELL, "[ac] pInstanceId(%ls), operation(%ls), appId(%ls), arg count(%d)", pInstanceId->GetPointer(), operation.GetPointer(), appId.GetPointer(), pArgs->GetCount());
result
_AppWidgetRequestHelper::SendIpcRequest(const int clientId, const String& operation, HashMap* pArgs)
{
- const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(ARG_KEY_INSTANCE_ID));
- SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to GetValue(%ls)", ARG_KEY_INSTANCE_ID.GetPointer() );
+ const String* pInstanceId = dynamic_cast<const String*>(pArgs->GetValue(String(ARG_KEY_INSTANCE_ID)));
+ SysTryReturnResult(NID_SHELL, pInstanceId, E_FAILURE, "Failed to get the instance id.");
SysSecureLog(NID_SHELL, "[ipc] pInstanceId(%ls), operation(%ls), clientId(%d)", pInstanceId->GetPointer(), operation.GetPointer(), clientId);
AppWidgetManagerService::RequestSharedMemoryIdForPD(const Tizen::App::AppId& appId, const Tizen::Base::String& instanceId, int width, int height, int& shmId)
{
_AppWidgetContext* pAppWidgetContext = this->Find(appId, instanceId);
- SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "[E_SYSTEM] pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , E_SYSTEM, "pAppWidgetContext is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
- _AppWidgetPopupContext* pPd = pAppWidgetContext->GetAppWidgetPopup();
- SysSecureTryReturnResult(NID_SHELL, pPd , E_SYSTEM, "[E_SYSTEM] pPd is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ _AppWidgetPopupContext* pPopupContext = pAppWidgetContext->GetAppWidgetPopup();
+ SysSecureTryReturnResult(NID_SHELL, pPopupContext , E_SYSTEM, "[E_SYSTEM] pPd is null for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
- shmId = pPd->GetSharedMemId(width, height);
- SysSecureTryReturnResult(NID_SHELL, pAppWidgetContext , shmId != -1, "[E_SYSTEM] failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
+ shmId = pPopupContext->GetSharedMemId(width, height);
+ SysSecureTryReturnResult(NID_SHELL, shmId != -1, E_SYSTEM, "Failed to GetSharedMemId for (%ls) (%ls)", appId.GetPointer(), instanceId.GetPointer());
return E_SUCCESS;
}
#include "FShell_AppWidgetManagerService.h"
#include "FShell_AppWidgetContext.h"
#include "FShell_AppWidgetPopupContext.h"
+#include "FShell_AppWidgetContextHelper.h"
+#include "FShell_AppWidgetRemoteBuffer.h"
namespace Tizen { namespace Shell { namespace App
{
+using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
const wchar_t APPWIDGET_POPUP_ON_DESTROY[] = L"http://tizen.org/appcontrol/appwidgetpopup/destroy";
const wchar_t APPWIDGET_POPUP_ON_TOUCH[] = L"http://tizen.org/appcontrol/appwidgetpopup/touch";
-_AppWidgetPopupContext::_AppWidgetPopupContext(const String& info, const String& appId, const String& instanceId, int width, int height, int priority, _AppWidgetContext* pParent)
-:_AppWidgetContextBase(TYPE_PD, info, appId, instanceId, width, height, priority)
+_AppWidgetPopupContext::_AppWidgetPopupContext(_AppWidgetContext* pParent)
+ : __pParent(pParent)
{
- __pParent = pParent;
- SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d)", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight());
+ __pAppWidgetRemoteBuffer = new (nothrow) _AppWidgetRemoteBuffer(__pParent->GetProviderId(), __pParent->GetInstanceId(), TYPE_PD, this);
+ SysTryReturnVoidResult(NID_SHELL, __pAppWidgetRemoteBuffer, E_OUT_OF_MEMORY, "");
+
+ SysLog(NID_SHELL, "The drop view for %ls is constructed.", (__pParent->GetInstanceId()).GetPointer());
}
_AppWidgetPopupContext::~_AppWidgetPopupContext(void)
{
- SysLog(NID_SHELL, "appId(%ls), instanceId(%ls), width(%d), height(%d))", GetProviderId().GetPointer(), GetInstanceId().GetPointer(), GetWidth(), GetHeight());
+ SysLog(NID_SHELL, "The drop view for %ls destructed.", (__pParent->GetInstanceId()).GetPointer());
+
+ if (__pAppWidgetRemoteBuffer)
+ {
+ delete __pAppWidgetRemoteBuffer;
+ }
}
void
pArgs->Add(new String(ARG_KEY_POPUP_WIDTH), new String(Integer::ToString(width)));
pArgs->Add(new String(ARG_KEY_POPUP_HEIGHT), new String(Integer::ToString(height)));
- return SendRequestToApp(GetAppId(), APPWIDGET_POPUP_ON_CREATE, pArgs.get());
+ return __pParent->SendPopupRequestToApp(__pParent->GetAppId(), APPWIDGET_POPUP_ON_CREATE, pArgs.get());
}
result
{
std::unique_ptr<HashMap, AllElementsDeleter> pArgs (CreateRequestArgsN() );
- return SendRequestToApp(GetAppId(), APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
+ return __pParent->SendPopupRequestToApp(__pParent->GetAppId(), APPWIDGET_POPUP_ON_DESTROY, pArgs.get());
}
-result
-_AppWidgetPopupContext::SendTouchEvent(buffer_event event, double timestamp, double x, double y)
+void
+_AppWidgetPopupContext::OnTouchEventReceived(buffer_event event, double timestamp, double x, double y)
{
SysLog(NID_SHELL, "");
- AppWidgetManagerService::GetInstance()->SendTouchEventForPD(GetClientId(), GetInstanceId(), event, timestamp, x, y);
- return E_SUCCESS;
+ AppWidgetManagerService::GetInstance()->SendTouchEventForPD(__pParent->GetAppContext()->GetClientId(), __pParent->GetInstanceId(), event, timestamp, x, y);
}
result
_AppWidgetPopupContext::RequestUpdateRemote(void)
{
- std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(GetProviderId()));
- std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(GetInstanceId()));
+ std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__pParent->GetProviderId()));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__pParent->GetInstanceId()));
int ret = provider_send_desc_updated(packageName.get(), id.get(), null);
SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "[E_SYSTEM] failed to provider_send_updated");
Tizen::Base::Collection::HashMap*
_AppWidgetPopupContext::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_INSTANCE_ID), new String(__pParent->GetInstanceId()));
+ pArgs->Add(new String(ARG_KEY_PROVIDER_NAME), new String(__pParent->GetProviderName()));
+ pArgs->Add(new String(ARG_KEY_USER_INFO), new String(__pParent->GetUserInfo()));
pArgs->Add(new String(ARG_KEY_WIDTH), new String(Integer::ToString(__pParent->GetWidth())));
pArgs->Add(new String(ARG_KEY_HEIGHT), new String(Integer::ToString(__pParent->GetHeight())));
return __pParent->GetAppContext()->GetClientId();
}
+int
+_AppWidgetPopupContext::GetSharedMemId(int w, int h) const
+{
+ return __pAppWidgetRemoteBuffer->GetSharedMemId(w, h);
+}
+
}}} // Tizen::Shell::App
--- /dev/null
+//
+// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.1 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// 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 FShell_AppWidgetRemoteBuffer.cpp
+ * @brief This is the implementation for the _AppWidgetRemoteBuffer class.
+ */
+
+#include <unique_ptr.h>
+#include <provider.h>
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include "FShell_AppWidgetRemoteBuffer.h"
+
+// provider/src/fb.c
+struct fb_info {
+ char *id;
+ int w;
+ int h;
+ int bufsz;
+ void *buffer;
+
+ int handle;
+};
+
+// provider/inc/provider_buffer_internal.h
+struct livebox_buffer {
+ enum {
+ BUFFER_CREATED = 0x00beef00,
+ BUFFER_DESTROYED = 0x00dead00,
+ } state;
+
+ enum target_type type;
+
+ union {
+ int fd; /* File handle(descriptor) */
+ int id; /* SHM handle(id) */
+ } handle;
+
+ char *pkgname;
+ char *id;
+ int width;
+ int height;
+ int pixel_size;
+
+ struct fb_info *fb;
+
+ int (*handler)(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void *data);
+ void *data;
+};
+
+static int AppWidgetHandleBufferEventCallback(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void* data);
+
+namespace Tizen { namespace Shell { namespace App
+{
+
+using namespace std;
+using namespace Tizen::Base;
+
+_AppWidgetRemoteBuffer::_AppWidgetRemoteBuffer(const String& providerId, const String& instanceId, target_type type, _IAppWidgetRemoteBufferEventListener* pListener)
+ :__type(type)
+ ,__providerId(providerId)
+ ,__instanceId(instanceId)
+ ,__buffer(null)
+ ,__buffer_info(null)
+ ,__pListener(pListener)
+{
+ SysLog(NID_SHELL, "_AppWidgetRemoteBuffer is constructed.");
+}
+
+_AppWidgetRemoteBuffer::~_AppWidgetRemoteBuffer(void)
+{
+ ReleaseSharedMem();
+ SysLog(NID_SHELL, "_AppWidgetRemoteBuffer is destructed.");
+}
+
+int
+_AppWidgetRemoteBuffer::GetSharedMemId(int w, int h)
+{
+ SysLog(NID_SHELL, "Enter");
+
+ bool isResized = (__buffer_info != null) && (__buffer_info->width != w || __buffer_info->height != h);
+ if ( isResized )
+ {
+ ReleaseSharedMem();
+ }
+
+ if( __buffer_info == null)
+ {
+ std::unique_ptr<char[]> packageName(_StringConverter::CopyToCharArrayN(__providerId));
+ std::unique_ptr<char[]> id(_StringConverter::CopyToCharArrayN(__instanceId));
+
+ __buffer_info = provider_buffer_acquire(__type, packageName.get(), id.get(), w, h, sizeof(int), AppWidgetHandleBufferEventCallback, __pListener);
+ SysTryReturn(NID_SHELL, __buffer_info, -1, E_SYSTEM, "[E_SYSTEM] Failed to execute provider_buffer_acquire");
+ SysLog(NID_SHELL, "provider_buffer_acquire successed");
+
+ __buffer = provider_buffer_ref(__buffer_info);
+ SysTryReturn(NID_SHELL, __buffer, -1, E_SYSTEM, "[E_SYSTEM] Failed to execute provider_buffer_ref");
+ SysLog(NID_SHELL, "provider_buffer_ref successed");
+ }
+
+ int bufferId = __buffer_info->fb->handle;
+
+ SysLog(NID_SHELL, "(%d) Exit", bufferId);
+ return bufferId;
+}
+
+result
+_AppWidgetRemoteBuffer::ReleaseSharedMem(void)
+{
+ SysLog(NID_SHELL, "Enter");
+
+ int ret;
+
+ if( __buffer)
+ {
+ ret = provider_buffer_unref(__buffer);
+ __buffer = null;
+ SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_buffer_unref");
+ SysLog(NID_SHELL, "provider_buffer_unref successed");
+ }
+
+ if( __buffer_info)
+ {
+ ret = provider_buffer_release(__buffer_info);
+ __buffer_info = null;
+ SysTryReturnResult(NID_SHELL, ret >= 0 , E_SYSTEM, "Failed to execute provider_buffer_release");
+ SysLog(NID_SHELL, "provider_buffer_release successed");
+ }
+
+ SysLog(NID_SHELL, "Exit.");
+
+ return E_SUCCESS;
+}
+
+}}} // Tizen::Shell::App
+
+static int AppWidgetHandleBufferEventCallback(struct livebox_buffer *info, enum buffer_event event, double timestamp, double x, double y, void* data)
+{
+ SysLog(NID_SHELL, "timestamp(%f), x(%f), y(%f)", timestamp, x, y);
+
+ Tizen::Shell::App::_IAppWidgetRemoteBufferEventListener* pListener = static_cast<Tizen::Shell::App::_IAppWidgetRemoteBufferEventListener*>(data);
+ SysTryReturn(NID_SHELL, pListener != null, 0, E_SYSTEM, "[E_SYSTEM] retrieved pAppWidgetContext is null");
+
+ if (event == BUFFER_EVENT_ENTER)
+ {
+ SysLog(NID_SHELL, "BUFFER_EVENT_ENTER");
+ }
+ else if (event == BUFFER_EVENT_LEAVE)
+ {
+ SysLog(NID_SHELL, "BUFFER_EVENT_LEAVE");
+ }
+ else if (event == BUFFER_EVENT_DOWN)
+ {
+ SysLog(NID_SHELL, "BUFFER_EVENT_DOWN");
+ }
+ else if (event == BUFFER_EVENT_MOVE)
+ {
+ SysLog(NID_SHELL, "BUFFER_EVENT_MOVE");
+ }
+ else if(event == BUFFER_EVENT_UP)
+ {
+ SysLog(NID_SHELL, "BUFFER_EVENT_UP");
+ }
+
+ pListener->OnTouchEventReceived(event, timestamp, x, y);
+
+ return 0;
+}