LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SystemService.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@@@ */
18 
19 
20 
21 
22 #ifndef SYSTEMSERVICE_H
23 #define SYSTEMSERVICE_H
24 
25 #include "Common.h"
26 
27 #include <string>
28 
29 #include <lunaservice.h>
30 #include <QTimer>
31 #include <QObject>
32 
33 struct json_object;
34 
35 class SystemService : public QObject
36 {
37  Q_OBJECT
38 
39 public:
40 
41  typedef struct __ActiveModalDialogInfo {
45  std::string m_activeDialogApp;
46  std::string m_activeDialogCaller;
47  std::string m_returnValueToPost;
49 
50  static SystemService* instance();
51 
52  static void buildSubscriptionModalId(std::string& caller, std::string& launchApp);
53  static void resetModalDialogInfo();
54  static void setActiveModalBeingLaunched();
55  static void setActiveModalBeingRemoved();
56  static void setActiveModalInfo();
57  static bool isModalActive();
58  static std::string getStrFromJSON(json_object *root, const char *id);
59  static std::string getModalWindowSubscriptionId();
60  static std::string getModalDismissReturnValue();
61  static bool initiateAppLaunch(LSHandle* lshandle, LSMessage *message, std::string& callerId, const char *messageStr, void *user_data, const char *modalId, bool isHeadless);
62  static json_object* buildParamsForAppLaunch(std::string params, std::string& launchId, bool& success, std::string& errMsg);
63  static void saveLauncherAndCallerInfo(std::string& caller, std::string& launchedApp);
64  static void setReturnValueToPost(const std::string& retValue);
65  static bool isParentPdk();
66  static void setParentAppPdk(bool isSdk);
67 
69 
70  void init();
71 
72  bool brickMode() const { return m_brickMode; }
73  LSHandle* serviceHandle() const { return m_service; }
74 
75  void postForegroundApplicationChange(const std::string& name,const std::string& menuname, const std::string& id);
76  void postApplicationHasBeenTerminated(const std::string& title, const std::string& menuname, const std::string& id);
77 
78  void postLockStatus(bool locked);
79  void postDeviceLockMode();
81 
82  void shutdownDevice();
83 
84  void enterMSM();
85 
86  void vibrate(const char* soundClass);
87 
88  void postLaunchModalResult(bool timedOut = false);
89  void postDismissModalResult(bool timedOut = false);
90  void postAppRestoredNeeded();
91 
92  void postMessageToSystemUI(const char* jsonStr);
93  void postMessageToSystemUIResponses(const char* jsonStr);
94 
95  void postSystemStatus();
96 
99  void notifyTouchToShareCanTap(bool val) { Q_EMIT signalTouchToShareCanTap(val); }
100  void notifyTouchToShareAppUrlTransfered(const std::string& str) { Q_EMIT signalTouchToShareAppUrlTransfered(str); }
103 
104  bool showCardLoadingAnimation() const { return m_cardLoadingAnimation; }
105  void setShowCardLoadingAnimation(bool val) { m_cardLoadingAnimation = val; }
106 
107 private Q_SLOTS:
108 
109  void postBootFinished();
110  void postDockModeStatus(bool enabled);
111  void slotModalWindowAdded();
112  void slotModalWindowRemoved();
113  void slotModalDialogTimerFired();
114 
115 Q_SIGNALS:
116 
118 
119  void signalEnterBrickMode(bool mediaSync);
120  void signalExitBrickMode();
121  void signalBrickModeFailed();
122 
124 
125  void signalDeviceUnlocked();
126  void signalCancelPinEntry();
127 
128  void signalTouchToShareCanTap(bool);
129  void signalTouchToShareAppUrlTransfered(const std::string&);
132 
133 private:
134 
135  SystemService();
136 
137  void startService();
138  void stopService();
139 
140  static bool msmAvailCallback(LSHandle* handle, LSMessage* message, void* ctxt);
141  static bool msmProgressCallback(LSHandle* handle, LSMessage* message, void* ctxt);
142  static bool msmEntryCallback(LSHandle* handle, LSMessage* message, void* ctxt);
143  static bool msmFsckingCallback(LSHandle* handle, LSMessage* message, void* ctxt);
144  static bool msmPartitionAvailCallback(LSHandle* handle, LSMessage* message, void* ctxt);
145  static bool telephonyServiceUpCallback(LSHandle* handle, LSMessage* message, void* ctxt);
146  static bool telephonyEventsCallback(LSHandle* handle, LSMessage* message, void* ctxt);
147  static bool touchToShareCanTapStatusCallback(LSHandle* handle, LSMessage* message, void* ctxt);
148 
149  static void initModalTimerInfo();
150 
151  bool msmAvail(LSMessage* message);
152  bool msmProgress(LSMessage* message);
153  bool msmEntry(LSMessage* message);
154  bool msmFscking(LSMessage* message);
155  bool msmPartitionAvail(LSMessage* message);
156  bool touchToShareCanTapStatus(LSHandle* handle, LSMessage* message, void* ctxt);
157  void postNovacomStatus();
158 
159 private:
160  LSHandle* m_service;
161  LSMessageToken m_storageDaemonToken;
162  bool m_brickMode;
163  bool m_msmExitClean;
164  bool m_fscking;
165  bool m_cardLoadingAnimation;
166  static ActiveModalDialogInfo sActiveModalInfo;
167  static std::string sTempCaller;
168  static std::string sTempLaunchApp;
169  static std::string sModalWindowSubscriptionId;
170  static QTimer sModalLauchCheckTimer;
171  static int sModalWindowIndex;
172  static bool sIsParentPdkApp;
173 };
174 
175 
176 
177 #endif /* SYSTEMSERVICE_H */