LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
appmonitor.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2011-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 APPMONITOR_H_
23 #define APPMONITOR_H_
24 
25 #include "externalapp.h"
26 #include "webosapp.h"
27 #include "blacklist.h"
28 
29 #include <QObject>
30 #include <QPointer>
31 #include <QList>
32 #include <QUuid>
33 #include <QBitArray>
34 
36 class LaunchPoint;
37 
38 namespace DimensionsSystemInterface
39 {
40 
41 namespace AppMonitorSignalType
42 {
43  enum Enum
44  {
45  INVALID, //or not applicable
49  };
50 }
51 
52 class AppMonitor : public QObject
53 {
54  Q_OBJECT
55 
56 public:
57 
58  static AppMonitor * appMonitor();
59  AppMonitor();
60  virtual ~AppMonitor();
61 
62  bool completedScan() const;
63  QList<QUuid> allAppUids() const;
64  QList<QPointer<ExternalApp> > allApps() const;
65  ExternalApp * appByUid(const QUuid& appUid) const;
66  WebOSApp * webosAppByAppId(const QString& appId) const;
67 
68  bool isAppRemovable(const QUuid& appUid);
69 
70  static QString webosAppLaunchPointTitle(const QString& appId,const QString& launchPointId);
71  static QString webosAppTitle(const QString& appId);
72  static QString webosAppVersion(const QString& appId);
73  static QString webosAppCategory(const QString& appId);
74  static bool webosAppNonRemovableSystemApp(const QString& appId);
75  static bool webosAppPlatformApp(const QString& appId);
76  static bool webosAppUserInstalledApp(const QString& appId);
77  static bool webosAppRemovableOrHideable(const QString& appId);
78 
79  QString pageDesignatorForWebOSApp(const QString& appId);
80  QString pageNameFromDesignator(const QString& designator);
81  QList<QString> auxPageDesignators() const;
82 
83  static QString appIdFromLaunchpointId(const QString& launchpointId);
84 
85 public Q_SLOTS:
86 
87  // These are the primary interface to AppMan,AppInstaller... which are modified to emit signals compatible with these slots.
88  // const'd the parameter in order to isolate the sender (AppMan for the most part); e.g. if AppMan wants to index the appdescriptor in any
89  // way by keying to some appdescr. variable, then it would have to know that I won't mess with any of the variables in here (or anywhere the signal that
90  // sends the appdescr. ptr is sent)
91 
92  virtual void slotInitialScanStart();
93  virtual void slotInitialScanEnd();
94 
95  virtual void slotScanFoundApp(const ApplicationDescription * pAppdescriptor);
96  virtual void slotScanFoundAuxiliaryLaunchPoint(const ApplicationDescription * p_appDesc,
97  const LaunchPoint * p_launchPoint);
98 
99  virtual void slotAppBeingRemoved(const ApplicationDescription * pAppdescriptor);
100  virtual void slotAppBeingRemoved(WebOSApp * p_webOSapp);
101 
102  virtual void slotAppUpdated(const ApplicationDescription * pAppdescriptor);
103 
104  //these are for ApplicationManager; since they're more or less stricly for AppMan, they don't need to be slots and I could just have AppMan call here directly
105  // but this will be more convenient, ESPECIALLY if something changes with AppMan or the rest of the sys outside
106  virtual void slotLaunchPointAdded(const LaunchPoint*,QBitArray reasons);
107  virtual void slotLaunchPointUpdated(const LaunchPoint*,QBitArray reasons);
108  virtual void slotLaunchPointRemoved(const LaunchPoint*,QBitArray reasons);
109 
110 Q_SIGNALS:
111 
112  //USE THESE SIGNALS ONLY INTERNALLY TO DIMENSIONS! THESE ARE RE-SIGNALS OF EXTERNAL EVENTS BUT ARE NOT INTENDED TO BE
113  // USED 'BACKWARDS'/UPSTREAM (I.E. BACK INTO THE SYSTEM). USING THESE TO SYNCHRONIZE OR TRIGGER EXTERNAL EVENTS IS STRONGLY
114  // DISCOURAGED! YOU'VE BEEN WARNED.
115 
116  //signalFullScanCompleted called after each full scan completes (AppMan)
117  void signalFullScanCompleted(bool initialScan=false);
118 
119  //signalNewApp is called *after* the ExternalApp object has been created and in the proper list(s)
121  // note: signalNewAdditionalLaunchPointForApp will not get signaled for the main/default launch point. That is assumed in signalNewApp
123 
124  //signalRemovedApp is called *before* the ExternalApp object is removed and discarded from the proper list(s)
126  // and this one is *after*...
128 
129  void signalAppAuxiliaryIconRemove(const QUuid& appUid,const QString& launchpointId,
131 
133 
134 protected:
135 
136  // return false if app no longer exists (rescan failed)
137  virtual bool rescanWebOSApp(WebOSApp& webOSApp);
138  virtual WebOSApp * pointerToWebOSApp(const QString& appId) const; //TODO: NAMING
139  virtual ExternalApp * find(const QUuid& uid) const;
140 
141  virtual WebOSApp * newPendingWebOSApp(const ApplicationDescription * pAppdescriptor);
142  virtual WebOSApp * newWebOSApp(const ApplicationDescription * pAppdescriptor);
143 
144  virtual IconBase * createAppIcon(const QString& mainIconFile,const QString& label);
145 
146  virtual void remove(ExternalApp * p_eapp);
147 
148  virtual void loadDesignatorKeywordMapping(const QString& mapFile);
149 
150 protected:
151 
152  static QPointer<AppMonitor> s_qp_mainInstance;
153 
156 
157  typedef QMap<QUuid,QPointer<ExternalApp> > AppMap;
158  typedef AppMap::iterator AppMapIter;
159  typedef AppMap::const_iterator AppMapConstIter;
161 
162  typedef QMap<QString,QPointer<WebOSApp> > WebOSAppMap;
163  typedef WebOSAppMap::iterator WebOSAppMapIter;
164  typedef WebOSAppMap::const_iterator WebOSAppMapConstIter;
166 
168  QMap<QString,QString> m_pageDesignatorByKeyword;
169  QList<QString> m_auxDesignatorList; //everything besides "favorites" (or actually, the name in Page::PageDesignator_Favorites)
170  QMap<QString,QString> m_designatorToNameMap;
171 };
172 
173 }
174 
175 #endif /* APPMONITOR_H_ */