LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WebAppMgrProxy.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef WEBAPPMGRPROXY_H
23 #define WEBAPPMGRPROXY_H
24 
25 #include "Common.h"
26 
27 #include <PIpcChannelListener.h>
28 #include <queue>
29 #include "IpcClientHost.h"
30 #include "Event.h"
31 #include "CustomEvents.h"
32 #include <NewContentIndicatorEvent.h>
33 #include <BannerMessageEvent.h>
34 #include "ActiveCallBannerEvent.h"
35 
36 class PIpcChannel;
37 class PIpcBuffer;
38 class PIpcMessage;
39 class SysMgrKeyEvent;
40 class HostWindowData;
41 
43 {
44  Q_OBJECT
45 
46 public:
47  static void setAppToLaunchUponConnection(char* app);
48  static WebAppMgrProxy* connectWebAppMgr(int pid, PIpcChannel* channel);
49 
50  static WebAppMgrProxy* instance();
51 
52  bool connected();
53  void onDisconnected();
54 
55  virtual ~WebAppMgrProxy();
56 
57  void sendAsyncMessage(PIpcMessage* msg);
58  PIpcChannel* getIpcChannel() const;
59  void sendQueuedMessages();
60 
61  void closeWindow(Window* w);
62  void launchUrl(const char* url, WindowType::Type winType=WindowType::Type_Card,
63  const char* appDesc="", const char* procId="",
64  const char* params="", const char* launchingAppId="",
65  const char* launchingProcId="");
66  void relaunchApp(const char* procId, const char* params, const char* launchingAppId,
67  const char* launchingProcId);
68 
69  std::string appLaunch(const std::string& appId,
70  const std::string& params,
71  const std::string& launchingAppId,
72  const std::string& launchingProcId,
73  std::string& errMsg);
74 
75  std::string appLaunchModal(const std::string& appId,
76  const std::string& params,
77  const std::string& launchingAppId,
78  const std::string& launchingProcId,
79  std::string& errMsg,
80  bool isHeadless,
81  bool isParentTypePdk);
82 
83  std::string launchBootTimeApp(const char* appId);
84 
85  std::string launchNativeApp(const ApplicationDescription* desc,
86  const std::string& params,
87  const std::string& launchingAppId,
88  const std::string& launchingProcId,
89  std::string& errMsg );
90 
91  void inputEvent(Window* win, Event* e);
92  void inputQKeyEvent(Window* win, QKeyEvent* event);
93  void focusEvent(Window* win, bool focused);
94  void resizeEvent(Window* win, int newWidth, int newHeight, bool resizeBuffer=false);
95  void uiDimensionsChanged(int width, int height);
96 
97  void setOrientation(OrientationEvent::Orientation orient);
98  OrientationEvent::Orientation orientation() const { return m_orientation; }
99 
100  void setGlobalProperties(int key);
101 
102  void inspect(const char* procId);
103  void clearWebkitCache();
104  void setJavascriptFlags(const char* flags);
105  void enableDebugger(bool enable);
106  void performLowMemoryActions(const bool allowExpensive = false);
107  void postShutdownEvent();
108  void notifyCompassEnabled(bool enabled);
109  void serviceRequestHandler_listRunningApps(bool includeSysApps);
110 
111  void emitCopy(Window *win);
112  void emitCut(Window *win);
113  void emitPaste(Window *win);
114  void emitSelectAll(Window *win);
115 
116  void suspendWebKitProcess();
117  void resumeWebKitProcess();
118 
119  // publicizing this because I need to call it from IpcClientHost
120  void onReturnedInputEvent(const SysMgrKeyEvent& event);
121 
122 Q_SIGNALS:
123 
124  void signalKeyEventRejected(const SysMgrKeyEvent& event);
126  void signalLowMemoryActionsRequested (bool allowExpensive);
127 
128 private:
129 
130  virtual void onMessageReceived(const PIpcMessage& msg);
131 
132  void onPrepareAddWindow(int key, int type, int width, int height);
133  void onPrepareAddWindowWithMetaData(int key, int metaDataKey, int type, int width, int height);
134  void onPasteToActiveWindow();
135  void onBootupFinished();
136  void onNewContentEvent(const NewContentIndicatorEventWrapper &wrapper);
137  void onBannerMessageEvent(const BannerMessageEventWrapper &wrapper);
138  void onEnableDockMode(bool enable);
139  void onCancelVibrations();
140  void onActiveCallBannerEvent(const ActiveCallBannerEventWrapper &wrapper);
141  void onAddPhoneActiveCallBanner(uint32_t ipcHandle,const std::string& iconFile,const std::string& message,uint32_t startTime);
142  void onRemovePhoneActiveCallBanner(uint32_t ipcHandle);
143  void onUpdatePhoneActiveCallBanner(uint32_t ipcHandle,const std::string& iconFile,const std::string& message,uint32_t resetTime);
144  void onApplyLaunchFeedback(int cx, int cy);
145  void onListOfRunningAppsResponse(const std::string& runnigAppsJsonArray);
146  void onAppLaunchPreventedUnderLowMemory();
147  void onLowMemoryActionsRequested(bool allowExpensive);
148  void onModalDismissPreCreate(int errorCode);
149 
150  Window* createWindowForWebApp(WindowType::Type winType, HostWindowData* data);
151 
152  static void webKitDiedCallback(GPid pid, gint status, gpointer data);
153  void webKitDied(GPid pid, gint status);
154 
155 private:
156 
157  WebAppMgrProxy();
158  void clientConnected(int pid, PIpcChannel* channel);
159 
161  WebAppMgrProxy& operator=(const WebAppMgrProxy&);
162 
163 private:
164  std::queue<PIpcMessage*> m_discMsgQueue; // for queueing outgoing messages while not connected
165  OrientationEvent::Orientation m_orientation;
166 
167  PIpcBuffer* m_ipcImgDragBuffer;
168  QPixmap* m_dragPixmap;
169 };
170 
171 
172 #endif /* WEBAPPMGRPROXY_H */