webappmanager
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WebAppBase.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-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@@@ */
27 #ifndef WebAppBase_h
28 #define WebAppBase_h
29 
30 #include "SysMgrWebBridge.h"
31 
32 #include <QObject>
33 
34 #include <lunaservice.h>
35 #include <palmimedefines.h>
36 
38 
42 class WebAppBase : public QObject {
43 
44  Q_OBJECT
45 
46  public:
54  WebAppBase();
55 
78  virtual ~WebAppBase();
79 
103  virtual void attach(SysMgrWebBridge*);
104 
118  virtual SysMgrWebBridge* detach();
119 
120  virtual void thawFromCache() { }
121  virtual void freezeInCache() { }
122  bool inCache() const { return m_inCache; }
123  void markInCache(bool inCache) { m_inCache = inCache; }
124 
125  void setKeepAlive(bool keepAlive) { m_keepAlive = keepAlive; }
126  bool keepAlive() { return m_keepAlive; }
127 
128  SysMgrWebBridge* page() const { return m_page; }
129 
130  virtual bool isWindowed() const { return false; }
131  virtual bool isCardApp() const { return false; }
132  virtual bool isChildApp() const { return false; }
133  virtual bool isDashboardApp() const { return false; }
134  virtual bool isAlertApp() const { return false; }
135 
136  void relaunch(const char* args, const char* launchingAppId, const char* launchingProcId);
137  virtual void stagePreparing();
138  virtual void stageReady();
139 
149  QString appId() const { return m_appId; }
150  QString processId() const { return m_processId; }
151  QString url() const { return m_url; }
152 
153  ApplicationDescription* getAppDescription() { return m_appDesc; }
155 
156  void setManualEditorFocusEnabled(bool);
157  virtual void setManualEditorFocus(bool focused, const PalmIME::EditorState&);
158  virtual void setExplicitEditorFocus(bool focused, const PalmIME::EditorState & editorState);
159 
160  virtual void suspendAppRendering() { }
161  virtual void resumeAppRendering() { }
162  virtual void resizeWebPage(uint32_t width, uint32_t height);
163 
164  protected:
165  virtual int getKey() const { return 0; }
166  virtual void focus() { }
167  virtual void unfocus() { }
168  virtual void close();
169  virtual void windowSize(int& width, int& height) { width = 0; height = 0; }
170  virtual void screenSize(int& width, int& height);
171  virtual void resizedContents(int contentsWidth, int contentsHeight);
172  virtual void zoomedContents(double scaleFactor, int contentsWidth, int contentsHeight,
173  int newScrollOffsetX, int newScrollOffsetY);
174  virtual void scrolledContents(int newContentsX, int newContentsY);
175  virtual void uriChanged(const char* url);
176  virtual void titleChanged(const char* title);
177  virtual void statusMessage(const char* msg);
178  virtual void dispatchFailedLoad(const char* domain, int errorCode,
179  const char* failingURL, const char* localizedDescription);
180  virtual void loadFinished() { }
181  virtual void editorFocusChanged(bool focused, const PalmIME::EditorState& state) { }
182 
190  virtual void autoCapEnabled(bool enabled) { }
191 
197  void createActivity();
198 
204  void destroyActivity();
205  void focusActivity();
206 
212  void blurActivity();
213 
227  void cleanResources();
228 
229  void setAppId(const QString& appId) { m_appId = appId; }
230 
231  protected Q_SLOTS:
232  virtual void uriChanged(const QUrl&);
233 
234  private:
235  // app description
236 
237  SysMgrWebBridge* m_page;
238  bool m_inCache;
239  bool m_keepAlive;
240 
241  QString m_appId;
242  QString m_processId;
243  QString m_url;
244 
245  ApplicationDescription* m_appDesc;
246 
247  LSMessageToken m_activityManagerToken;
248 
249  friend class PalmSystem;
250  friend class SysMgrWebBridge;
251 };
252 
253 #endif