2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FShell_AppWidgetContext.h
19 * @brief This is the header file for the _AppWidgetContext class.
21 * This header file contains the declarations of the _AppWidgetContext class.
24 #ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
25 #define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
27 #include <provider_buffer.h>
28 #include <FAppTypes.h>
29 #include <FBaseRtTimer.h>
30 #include <FBaseColArrayListT.h>
31 #include "FShell_AppContext.h"
32 #include "FShell_AppWidgetRemoteBuffer.h"
34 namespace Tizen { namespace Base { namespace Collection
39 namespace Tizen { namespace Shell { namespace App
42 extern const wchar_t ARG_KEY_INSTANCE_ID[];
43 extern const wchar_t ARG_KEY_PROVIDER_NAME[];
44 extern const wchar_t ARG_KEY_USER_INFO[];
45 extern const wchar_t ARG_KEY_X[];
46 extern const wchar_t ARG_KEY_Y[];
47 extern const wchar_t ARG_KEY_WIDTH[];
48 extern const wchar_t ARG_KEY_HEIGHT[];
49 extern const wchar_t ARG_KEY_POPUP_WIDTH[];
50 extern const wchar_t ARG_KEY_POPUP_HEIGHT[];
51 extern const wchar_t ARG_KEY_ARGUMENT[];
52 extern const wchar_t ARG_KEY_EVENT_TYPE[];
53 extern const wchar_t ARG_KEY_TIME_STAMP[];
55 extern const int UPDATE_PERIOD_MSEC_MIN;
58 class _AppWidgetPopupContext;
61 * @class _AppWidgetContext
62 * @brief Context of a AppWidget provider and it's AppWidgetFrame
64 class _AppWidgetContext
65 : public Tizen::Base::Runtime::ITimerEventListener
66 , public _IAppWidgetRemoteBufferEventListener
67 , public Tizen::Base::Object
70 _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& instanceId, const Tizen::Base::String& providerId, int width, int height, const Tizen::Base::String& userInfo, int period, int priority);
71 virtual ~_AppWidgetContext(void);
75 void OnUpdate(const Tizen::Base::String& argument);
76 result OnUpdateAsync(_AppContext* pAppContext, const Tizen::Base::String& argument);
77 void OnResize(int width, int height);
78 result OnRemoved(bool isTriggeredByViewer = true);
81 void OnForeground(void);
82 void OnBackground(void);
84 // handle request from dynamic box
85 int AcquireRemoteBuffer(int w, int h) const;
86 result SyncRemoteBuffer(int width, int height);
87 result SendAccessStatus(int accessStatus) const;
90 void OnPopupCreated(double x, double y, int width, int height);
91 void OnPopupDestoyed(void);
92 int AcquireRemoteBufferForPD(int w, int h) const;
93 result SyncRemoteBufferForPD(void) const;
94 _AppWidgetPopupContext* GetAppWidgetPopup(void) const;
95 Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) const;
97 _AppContext* GetAppContext(void) const;
98 void OnDisconnected(void);
100 Tizen::Base::String GetAppId(void) const;
101 Tizen::Base::String GetProviderName(void) const;
102 Tizen::Base::String GetUserInfo(void) const;
103 Tizen::Base::String GetProviderId(void) const;
104 Tizen::Base::String GetInstanceId(void) const;
105 int GetWidth(void) const;
106 int GetHeight(void) const;
107 int GetPriority(void) const;
108 bool IsActive(void) const;
111 result SendAddRequest(int width, int height) const;
112 result SendUpdateRequest(int width, int height, const Tizen::Base::String& argument) const;
113 result SendResizeRequest(int width, int height) const;
114 result SendRemoveRequest(void) const;
115 void SendPendingTouchEvent(void);
117 virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y);
118 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
120 void SetWidth(int width);
121 void SetHeight(int height);
122 int GetPeriod(void) const;
124 int GetClientId(void) const;
125 bool IsForeground(void) const;
126 long long GetLastUpdatedTime(void) const;
127 bool IsUpdatePeriodExpired(void) const;
130 struct PendingTouchEvent
132 PendingTouchEvent(int eventType, double timeStamp, double x, double y)
133 : eventType(eventType), timeStamp(timeStamp), x(x), y(y) { }
141 const Tizen::Base::String __instanceId;
142 const Tizen::Base::String __providerId;
143 const Tizen::Base::String __appId;
144 const Tizen::Base::String __providerName;
145 const Tizen::Base::String __userInfo;
149 const int __priority;
150 const int __updateMillis;
154 mutable bool __isRemoteBufferProxyCreated;
155 long long __lastUpdatedTime;
156 bool __hasPendingRequest;
157 Tizen::Base::String __pendingArgument;
158 Tizen::Base::Runtime::Timer __updateTimer;
160 _AppContext* __pAppContext;
161 _AppWidgetPopupContext* __pAppWidgetPopup;
162 _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer;
164 Tizen::Base::Collection::ArrayListT<PendingTouchEvent*>* __pPendingTouchEventList;
165 }; // class _AppWidgetContext
167 static const RequestId LOCAL_EVENT_REQUEST_UPDATE = 0;
169 }}} // Tizen::Shell::App
171 #endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_