webappmanager
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SysMgrWebBridge.h
Go to the documentation of this file.
1 
2 #ifndef SysMgrWebBridge_h
3 #define SysMgrWebBridge_h
4 
5 #include "ProcessBase.h"
6 
7 #include <QtWebKit>
8 #include <QPointer>
9 
10 #include <palmimedefines.h>
11 #include <QWebPage>
12 #include <QWebFrame>
13 
14 typedef QMap<QString, QVariant> StringVariantMap;
15 class WebAppBase;
16 class PalmSystem;
17 
18 class SysMgrWebPage : public QWebPage {
19  Q_OBJECT
20 
21  public:
22  SysMgrWebPage(QObject* parent = 0);
23  virtual ~SysMgrWebPage() { };
24 
25  QWebPage* createWindow(WebWindowType);
26 
38  const QRect requestedGeometry() const;
39 
40  protected:
41  virtual bool acceptNavigationRequest(QWebFrame*, const QNetworkRequest&, NavigationType);
42  virtual void javaScriptConsoleMessage(const QString&, int lineNumber, const QString& sourceID);
43 
44  protected Q_SLOTS:
45  void setRequestedGeometry(const QRect&);
46 
47  private:
52  QRect m_requestedGeometry;
53 };
54 
55 
56 class SysMgrWebBridge : public QObject,
57  public ProcessBase {
58  Q_OBJECT
59 
60  public:
61  SysMgrWebBridge(bool viewable);
62  SysMgrWebBridge(bool viewable, QUrl);
63  virtual ~SysMgrWebBridge();
64 
65  SysMgrWebPage* page() const { return m_page; }
66  int progress() const { return m_progress; }
67  QUrl url() const { return m_page->mainFrame()->url(); }
68  bool relaunch(const char* args, const char* launchingAppId, const char* launchingProcId);
69  void setArgs(const char*);
70  void cut();
71  void copy();
72  void paste();
73  void selectAll();
74  void setName(const char*);
75  bool isShuttingDown() { return m_isShuttingDown; }
76  QString name() { return m_name; }
77  void setStageReadyPending(bool pending) { m_stageReadyPending = pending; }
78  bool stageReadyPending() const { return m_stageReadyPending; }
79  void addNewContentRequestId(const QString);
80  void removeNewContentRequestId(const QString);
81  int activityId();
82  void setActivityId(int id) { m_activityId = id; }
83 
84  void setComposingText(const char*);
85  void commitComposingText();
86  void commitText(const char*);
87  void performEditorAction(PalmIME::FieldAction);
88  void removeInputFocus();
89 
90  const StringVariantMap& stageArguments() const { return m_stageArgs; }
95  const QRect requestedGeometry() const;
96 
97  void inspect() { }
98 
100 
101  WebAppBase* getClient(void) { return m_client; }
102  void setClient(WebAppBase* client) { m_client = client; }
103 
104  void load()
105  {
106  if (m_page)
107  m_page->mainFrame()->load(m_url);
108  }
109  const char* getIdentifier();
110 
111  private:
112  virtual void explicitEditorFocused(bool, const PalmIME::EditorState&);
113  virtual void manualEditorFocused(bool, const PalmIME::EditorState&);
114  virtual void manualFocusEnabled(bool);
115 
116  void closePageSoon();
117 
118  Q_SIGNALS:
119  void signalResizedContents(const QSize&);
120  void signalGeometryChanged(const QRect&);
121  void signalInvalidateRect(const QRect&);
122  void signalLinkClicked(const QUrl&);
123  void signalTitleChanged(const QString&);
124  void signalUrlChanged(const QUrl&);
125  void signalViewportChanged(const QWebPage::ViewportAttributes&);
126 
127  protected Q_SLOTS:
128  void slotLoadProgress(int progress);
129  void slotLoadStarted();
130  void slotLoadFinished(bool ok);
132  void slotSetupPage(const QUrl&);
134  void slotMicroFocusChanged();
135 
136  private:
137  SysMgrWebPage* m_page;
138  WebAppBase* m_client;
139  int m_progress;
140  bool m_viewable;
141  QString m_args;
142  StringVariantMap m_stageArgs;
143  QString m_name;
144  bool m_isShuttingDown;
145  bool m_stageReadyPending;
146  QSet<QString> m_newContentRequestIds;
147  int m_activityId;
148  QUrl m_url;
149  std::string m_identifier;
150  bool m_launchedAtBoot;
151 
152  PalmIME::EditorState m_explicitEditorState;
153  PalmIME::EditorState m_manualEditorState;
154  bool m_manualFocusEnabled;
155 
156  bool m_inRelaunch;
157 
158  QPointer<PalmSystem> m_jsObj;
159 
160  QString m_bufferedRelaunchArgs;
161  QString m_bufferedRelaunchLaunchingAppId;
162  QString m_bufferedRelaunchLaunchingProcId;
163 
164  void commonSetup();
165  void setupStageArgs(const QUrl);
166  void setupStageArgs(const char* url);
167  void addPalmSystemObject();
168 
169  friend class WebAppBase;
170 };
171 
172 #endif