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_AppWidgetRemoteBuffer.h"
33 namespace Tizen { namespace Base { namespace Collection
38 namespace Tizen { namespace Shell { namespace App
41 extern const wchar_t ARG_KEY_INSTANCE_ID[];
42 extern const wchar_t ARG_KEY_PROVIDER_NAME[];
43 extern const wchar_t ARG_KEY_USER_INFO[];
44 extern const wchar_t ARG_KEY_X[];
45 extern const wchar_t ARG_KEY_Y[];
46 extern const wchar_t ARG_KEY_WIDTH[];
47 extern const wchar_t ARG_KEY_HEIGHT[];
48 extern const wchar_t ARG_KEY_POPUP_WIDTH[];
49 extern const wchar_t ARG_KEY_POPUP_HEIGHT[];
50 extern const wchar_t ARG_KEY_ARGUMENT[];
51 extern const wchar_t ARG_KEY_EVENT_TYPE[];
52 extern const wchar_t ARG_KEY_TIME_STAMP[];
54 extern const int UPDATE_PERIOD_MSEC_MIN;
55 class _AppWidgetContext;
56 class _AppWidgetPopupContext;
60 CONNECTION_STATE_NONE = 0,
61 CONNECTION_STATE_CONNECTING,
62 CONNECTION_STATE_CONNECTED,
63 CONNECTION_STATE_DISCONNECTED
66 ////////////////////////////////////////////////
68 ////////////////////////////////////////////////
70 :public Tizen::Base::Object
77 _ConnectionState GetConnectionState(void) const;
78 void SetConnectionState(_ConnectionState state);
79 int GetClientId(void) const;
80 void SetClientId(int clientId);
81 void SetWaitingStatus(bool status);
82 bool GetWaitingStatus(void) const;
85 bool __isWaitingResult;
87 _ConnectionState __connectionState;
88 Tizen::Base::Collection::ArrayListT<_AppWidgetContext*> __appWidetContextList;
91 ////////////////////////////////////////////////
93 ////////////////////////////////////////////////
94 class _AppWidgetContext
95 : public Tizen::Base::Runtime::ITimerEventListener
96 , public _IAppWidgetRemoteBufferEventListener
97 , public Tizen::Base::Object
100 _AppWidgetContext(_AppContext* pAppContext, const Tizen::Base::String& userInfo, const Tizen::Base::String& appId, const Tizen::Base::String& instanceId, int width, int height, int period, int priority);
101 virtual ~_AppWidgetContext(void);
103 // handle dynamic box
105 void OnUpdate(const Tizen::Base::String& argument);
106 void OnResize(int width, int height);
107 result OnRemoved(void);
108 virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y);
111 void OnForeground(void);
112 void OnBackground(void);
114 // handle request from dynamic box
115 int AcquireRemoteBuffer(int w, int h) const;
116 result SyncRemoteBuffer(int width, int height);
117 result SendAccessStatus(int accessStatus) const;
120 void OnPopupCreated(double x, double y, int width, int height);
121 void OnPopupDestoyed(void);
122 _AppWidgetPopupContext* GetAppWidgetPopup(void) const;
123 result SendPopupRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs) const;
124 Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) const;
126 _AppContext* GetAppContext(void) const;
127 void OnDisconnected(void);
128 result SendPendingEvent(void);
130 Tizen::Base::String GetAppId(void) const;
131 Tizen::Base::String GetProviderName(void) const;
132 Tizen::Base::String GetUserInfo(void) const;
133 Tizen::Base::String GetProviderId(void) const;
134 Tizen::Base::String GetInstanceId(void) const;
135 int GetWidth(void) const;
136 int GetHeight(void) const;
137 int GetPriority(void) const;
139 // void SetUserInfo(const Tizen::Base::String& userInfo);
140 // void SetProviderId(const Tizen::Base::String& providerId);
141 // void SetInstanceId(const Tizen::Base::String& instanceId);
142 // void SetPriority(int priority);
145 result SendAddRequest(int width, int height);
146 result SendUpdateRequest(int width, int height, const Tizen::Base::String& argument);
147 result SendResizeRequest(int width, int height);
148 result SendRemoveRequest(void);
149 void SendPendingTouchEvent(void);
150 result RequestUpdate(const Tizen::Base::String& argument);
151 result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
153 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
155 void SetForeground(bool forground);
156 void SetWidth(int width);
157 void SetHeight(int height);
158 int GetPeriod(void) const;
160 int GetClientId(void) const;
161 bool IsForeground(void) const;
162 long long GetLastUpdatedTime(void) const;
165 struct PendingTouchEvent
167 PendingTouchEvent(int eventType, double timeStamp, double x, double y)
168 : eventType(eventType), timeStamp(timeStamp), x(x), y(y) { }
178 PendingEvent(const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap)
179 : operation(operation), pArg(pHashMap) { }
181 Tizen::Base::String operation;
182 Tizen::Base::Collection::HashMap* pArg;
185 mutable bool __isRemoteBufferProxyCreated;
186 bool __hasPendingRequest;
193 long long __lastUpdatedTime;
195 Tizen::Base::String __userInfo;
196 Tizen::Base::String __providerId;
197 Tizen::Base::String __instanceId;
198 Tizen::Base::String __appId;
199 Tizen::Base::String __providerName;
200 Tizen::Base::String __pendingArgument;
201 Tizen::Base::Runtime::Timer __updateTimer;
203 _AppContext* __pAppContext;
204 _AppWidgetPopupContext* __pAppWidgetPopup;
205 _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer;
207 Tizen::Base::Collection::ArrayListT<PendingTouchEvent*>* __pPendingTouchEventList;
208 Tizen::Base::Collection::ArrayListT<PendingEvent*>* __pPendingEventList;
210 }; // class _AppWidgetContext
212 }}} // Tizen::Shell::App
214 #endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_