use pkgconfig to improve pkg dependency mgmt.
[platform/framework/native/appwidget-service.git] / inc / FShell_AppWidgetContext.h
1 //
2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file        FShell_AppWidgetContext.h
19  * @brief       This is the header file for the _AppWidgetContext class.
20  *
21  * This header file contains the declarations of the _AppWidgetContext class.
22  */
23
24 #ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
25 #define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_
26
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"
33
34 namespace Tizen { namespace Base  { namespace Collection
35 {
36 class HashMap;
37 }}}
38
39 namespace Tizen { namespace Shell  { namespace App
40 {
41
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[];
54
55 extern const int UPDATE_PERIOD_MSEC_MIN;
56
57
58 class _AppWidgetPopupContext;
59
60 /**
61  * @class       _AppWidgetContext
62  * @brief       Context of a AppWidget provider and it's AppWidgetFrame
63  */
64 class _AppWidgetContext
65         : public Tizen::Base::Runtime::ITimerEventListener
66         , public _IAppWidgetRemoteBufferEventListener
67         , public Tizen::Base::Object
68 {
69 public:
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);
72
73         // handle dynamic box
74         void OnAdded(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);
79
80         // dynamic box state
81         void OnForeground(void);
82         void OnBackground(void);
83
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;
88
89         // handle drop view
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;
96
97         _AppContext* GetAppContext(void) const;
98         void OnDisconnected(void);
99
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;
109
110 private:
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);
116
117         virtual void OnTouchEventReceived(buffer_event event, double timestamp, double x, double y);
118         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
119
120         void SetWidth(int width);
121         void SetHeight(int height);
122         int GetPeriod(void) const;
123
124         int GetClientId(void) const;
125         bool IsForeground(void) const;
126         long long GetLastUpdatedTime(void) const;
127         bool IsUpdatePeriodExpired(void) const;
128
129 private:
130         struct PendingTouchEvent
131         {
132                 PendingTouchEvent(int eventType, double timeStamp, double       x, double       y)
133                  : eventType(eventType), timeStamp(timeStamp), x(x), y(y) {  }
134
135                 int eventType;
136                 double  timeStamp;
137                 double  x;
138                 double  y;
139         };
140
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;
146
147         int __width;
148         int __height;
149         const int __priority;
150         const int __updateMillis;
151
152         int __ipcClientId;
153         bool __isForeground;
154         mutable bool __isRemoteBufferProxyCreated;
155         long long __lastUpdatedTime;
156         bool __hasPendingRequest;
157         Tizen::Base::String __pendingArgument;
158         Tizen::Base::Runtime::Timer __updateTimer;
159
160         _AppContext* __pAppContext;
161         _AppWidgetPopupContext* __pAppWidgetPopup;
162         _AppWidgetRemoteBuffer* __pAppWidgetRemoteBuffer;
163
164         Tizen::Base::Collection::ArrayListT<PendingTouchEvent*>* __pPendingTouchEventList;
165 };      // class _AppWidgetContext
166
167 static const RequestId  LOCAL_EVENT_REQUEST_UPDATE = 0;
168
169 }}} // Tizen::Shell::App
170
171 #endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_H_