add new features
[framework/osp/appwidget-service.git] / inc / FShell_AppWidgetContextBase.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_AppWidgetContextBase.h
19  * @brief       This is the header file for the _AppWidgetContextBase class.
20  *
21  * This header file contains the declarations of the _AppWidgetContextBase class.
22  */
23
24 #ifndef _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
25 #define _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_
26
27 #include <provider_buffer.h>
28 #include <FAppTypes.h>
29
30 #define APPWIDGET_PROVIDER_ID_ENABLE true
31
32 namespace Tizen { namespace Base  { namespace Collection
33 {
34 class HashMap;
35 }}}
36
37 namespace Tizen { namespace Shell  { namespace App
38 {
39
40 class _AppWidgetContextBase
41         : public Tizen::Base::Object
42 {
43 protected:
44         enum _AppWidgetProviderState
45         {
46                 INVALID = 0,
47                 RUNNING,
48                 SUSPENDED,
49         };
50
51 public:
52         _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);
53         virtual ~_AppWidgetContextBase(void);
54         virtual void OnPopupCreated(double x, double y, int width, int height) = 0;
55         virtual void OnPopupDestoyed(void) = 0;
56         virtual result SendTouchEvent(buffer_event event, double timestamp, double x, double y) = 0;
57         //virtual result SendPendingEvent(void) = 0;
58         virtual void SetIpcClientId(int clientId);
59         int GetClientId(void) const;
60         bool HasValidClientId(void) const;
61         // for buffered appWidget
62         int GetSharedMemId(int w, int h);
63         result ReleaseSharedMem(void);
64         void Suspend(void);
65         Tizen::Base::String GetInstanceId(void) const;
66         int GetWidth(void) const;
67         int GetHeight(void) const;
68         Tizen::Base::String GetProviderId(void) const;
69         Tizen::Base::String GetAppId(void) const;
70         int GetPriority(void) const;
71         Tizen::Base::String GetProviderName(void) const;
72         bool IsRunning(void) const;
73
74 protected:
75         bool IsSharedMemCreated(void) const;
76         virtual Tizen::Base::Collection::HashMap* CreateRequestArgsN(void) = 0;
77         result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
78         result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
79         void SetForeground(bool forground);
80         bool IsForeground(void) const;
81         Tizen::Base::String GetUserInfo(void) const;
82         void SetWidth(int width);
83         void SetHeight(int height);
84
85 private:
86         target_type __type;
87         Tizen::Base::String __userInfo;
88         Tizen::Base::String __providerId;
89         Tizen::Base::String __instanceId;
90         int __width;
91         int __height;
92         int __priority;
93         bool __isForeground;
94         int __ipcClientId;
95         Tizen::Base::String __appId;
96         Tizen::Base::String __providerName;
97         struct livebox_buffer *__buffer_info;
98         void *__buffer;
99         _AppWidgetProviderState __providerState;
100
101 };      // class _AppWidgetContextBase
102
103 class _AppWidgetRequestHelper
104 {
105 public:
106         static result SendRequestToApp(const Tizen::App::AppId& appId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
107         static result SendRequestToApp(const int clientId, const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pArgs);
108
109 };      // class _AppWidgetRequestHelper
110
111 extern const Tizen::Base::String ARG_KEY_INSTANCE_ID;
112 extern const Tizen::Base::String ARG_KEY_PROVIDER_NAME;
113 extern const Tizen::Base::String ARG_KEY_USER_INFO;
114 extern const Tizen::Base::String ARG_KEY_X;
115 extern const Tizen::Base::String ARG_KEY_Y;
116 extern const Tizen::Base::String ARG_KEY_WIDTH;
117 extern const Tizen::Base::String ARG_KEY_HEIGHT;
118 extern const Tizen::Base::String ARG_KEY_POPUP_WIDTH;
119 extern const Tizen::Base::String ARG_KEY_POPUP_HEIGHT;
120 extern const Tizen::Base::String ARG_KEY_ARGUMENT;
121 extern const Tizen::Base::String ARG_KEY_EVENT_TYPE;
122 extern const Tizen::Base::String ARG_KEY_TIME_STAMP;
123
124 }}}      // Tizen::Shell::App
125
126 #endif // _FSHELL_INTERNAL_APPWIDGET_CONTEXT_BASE_H_