LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ApplicationDescription.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 #ifndef APPLICATIONDESCRIPTION_H
20 #define APPLICATIONDESCRIPTION_H
21 
22 #include "Common.h"
23 
24 #include <string>
25 #include <stdint.h>
26 #include <set>
27 #include <list>
28 
29 #include "LaunchPoint.h"
30 #include "KeywordMap.h"
31 #include "CmdResourceHandlers.h"
32 #include <ApplicationDescriptionBase.h>
33 
34 struct json_object;
35 struct ApplicationStatus;
36 
38 {
39  Q_OBJECT
40 public:
41 
42  SysmgrBuiltinLaunchHelper(const std::string& args)
44 
45  void launch()
46  {
48  }
49  void launch(const std::string& overrideArgs)
50  {
51  Q_EMIT signalEntry(std::string(overrideArgs));
52  }
53  void launchNoArgs()
54  {
55  Q_EMIT signalEntry(std::string(""));
56  }
57 
58  Q_SIGNALS:
59  void signalEntry(const std::string& argsAsStringEncodedJson);
60 public:
61 
63 };
64 
66 {
67 public:
68 
69  enum Status {
74  };
75 
83  };
84 
87 
88  static ApplicationDescription* fromFile(const std::string& filePath, const std::string& folderPath);
89  static ApplicationDescription* fromJsonString(const char* jsonStr);
90  static ApplicationDescription* fromApplicationStatus(const ApplicationStatus& appStatus, bool isUpdating);
91  static ApplicationDescription* fromNativeDockApp(const std::string& id, const std::string& title,
92  const std::string& version, const std::string& splashIcon,
93  const std::string& splashBackgroundName, const std::string& miniicon,
94  const std::string& vendor, const std::string& vendorUrl,
95  const std::string& appmenu);
96  static std::string versionFromFile(const std::string& filePath, const std::string& folderPath);
97 
98  const std::string& menuName() const { return m_appmenuName; }
99  const std::string& category() const { return m_category; }
100  std::list<std::string> keywords() const { return m_keywords.allKeywords(); }
101  const std::string& version() const { return m_version; }
102  bool hasTransparentWindows() const { return m_hasTransparentWindows; }
103  bool isRemovable() const { return m_isRemovable; }
104  bool handlesRelaunch() const { return m_handlesRelaunch; }
105  bool isUserHideable() const { return m_isUserHideable; }
106  bool isVisible() const { return m_isVisible; }
107  const std::string& folderPath() const { return m_folderPath; }
108  Type type() const { return m_type; }
109  Status status() const { return m_status; }
110  int progress() const { return m_progress; }
111  const std::string& attributes() const { return m_attributes; }
112  bool hasAccounts() const { return m_hasAccounts; }
113 
114  bool dockModeStatus() const { return m_dockMode; }
115  const std::string& dockModeTitle() const { return m_dockModeTitle; }
116 
117  const std::string& miniIconUrl() const {return m_miniIconName;}
118  const std::string& vendorName() const {return m_vendorName;}
119  const std::string& vendorUrl() const { return m_vendorUrl;}
120  uint64_t appSize() const {return m_appSize;}
121  void setAppSize(const uint64_t& s) { m_appSize = s;}
122  uint32_t blockSize() const { return m_fsBlockSize; }
123  void setBlockSize(uint32_t s) { m_fsBlockSize = s;}
124 
125  unsigned int runtimeMemoryRequired() const {return m_runtimeMemoryRequired;}
126 
127  QPixmap miniIcon() const;
128 
129  const std::string& splashIconName() const {
130  return m_splashIconName;
131  }
132  const std::string &splashBackgroundName() const {
133  return m_splashBackgroundName;
134  }
135 
136  const bool launchInNewGroup() const {
137  return m_launchInNewGroup;
138  }
139 
140  const std::list<ResourceHandler>& mimeTypes() const;
141  const std::list<RedirectHandler>& redirectTypes() const;
142 
143  const LaunchPointList& launchPoints() const;
144  void launchPoints(LaunchPointList& launchPointList); //copy version of launchPoints(). Useful for add/remove of stuff from the list
145 
146  void addLaunchPoint(LaunchPoint* lp);
147  const LaunchPoint* findLaunchPoint(const std::string& lpId);
148  const LaunchPoint* getDefaultLaunchPoint() const;
149  void removeLaunchPoint(const LaunchPoint* lp);
150 
151  // NOTE: it is the callers responsibility to json_object_put the return value
152  json_object* toJSON() const;
153 
154  std::string toString() const;
155 
156  bool canExecute() const { return !m_executionLock; }
157  void executionLock(bool xp=true) { m_executionLock = xp;}
158 
159  bool isRemoveFlagged() const { return m_flaggedForRemoval;}
160  void flagForRemoval(bool rf=true) { m_flaggedForRemoval = rf;}
161  bool setRemovable(bool v=true);
162  bool setVisible(bool v=true);
163  void setVersion(const std::string& version) { m_version = version; }
164 
165  uint32_t hardwareFeaturesNeeded() const { return m_hardwareFeaturesNeeded; }
166 
167  // NOTE: only applications which reside in ROM (/usr/palm/applications)
168  // should set this flag to true
169  void setUserHideable(bool hideable) { m_isUserHideable = hideable; }
170 
171  void setStatus(Status newStatus) { m_status = newStatus; }
172 
173  void setHasAccounts(bool hasAccounts) { m_hasAccounts = hasAccounts; }
174 
175  bool tapToShareSupported() const { return m_tapToShareSupported; }
176 
177  bool operator==(const ApplicationDescription& cmp) const;
178  bool operator!=(const ApplicationDescription& cmp) const;
179 
180  bool strictCompare(const ApplicationDescription& cmp) const;
181 
182  void update(const ApplicationStatus& appStatus, bool isUpdating);
183  int update(const ApplicationDescription& appDesc);
184 
185  bool doesMatchKeywordExact(const gchar* keyword) const;
186  bool doesMatchKeywordPartial(const gchar* keyword) const;
187 
188  void getAppDescriptionString(std::string &descString) const;
189 
190  void startSysmgrBuiltIn(const std::string& jsonArgsString) const;
191  void startSysmgrBuiltIn() const;
192  void startSysmgrBuiltInNoArgs() const;
193 
194  bool initSysmgrBuiltIn(QObject * pReceiver,const std::string& entrypt,const std::string& args);
195 
196  void dbgSetProgressManually(int progv) { m_progress = progv; }
197 
198  bool securityChecksVerified();
199 
200 private:
201 
202  class MimeRegInfo {
203  public:
204  MimeRegInfo() : stream(false) {}
205  //FIXME: don't need this anymore; originally intended to have it handle deep copies from pointers but now it's just the same as the default copy constr.
206  MimeRegInfo(const MimeRegInfo& c) {
207  mimeType = c.mimeType;
208  extension = c.extension;
209  urlPattern = c.urlPattern;
210  scheme = c.scheme;
211  stream = c.stream;
212  }
213  MimeRegInfo& operator=(const MimeRegInfo& c) {
214  if (this == &c)
215  return *this;
216  mimeType = c.mimeType;
217  extension = c.extension;
218  urlPattern = c.urlPattern;
219  scheme = c.scheme;
220  stream = c.stream;
221  return *this;
222  }
223  std::string mimeType;
224  std::string extension;
225  std::string urlPattern;
226  std::string scheme;
227  bool stream;
228  };
229 
230  static int utilExtractMimeTypes(struct json_object * jsonMimeTypeArray,std::vector<MimeRegInfo>& extractedMimeTypes);
231 
232  std::string m_category;
233  std::string m_version;
234  std::list<ResourceHandler> m_mimeTypes;
235  std::list<RedirectHandler> m_redirectTypes;
236  LaunchPointList m_launchPoints;
237  std::string m_splashIconName;
238  std::string m_splashBackgroundName;
239  std::string m_miniIconName;
240  bool m_hasTransparentWindows;
241  std::string m_folderPath;
242  bool m_executionLock;
243  bool m_flaggedForRemoval;
244  bool m_isRemovable;
245  bool m_isUserHideable;
246  int m_progress;
247  bool m_isVisible;
248  uint32_t m_hardwareFeaturesNeeded;
249  Type m_type;
250  Status m_status;
251  bool m_hasAccounts;
252  bool m_launchInNewGroup;
253  bool m_tapToShareSupported;
254  bool m_handlesRelaunch;
255 
256  // Dock Mode parameters
257  bool m_dockMode;
258  std::string m_dockModeTitle;
259 
260  std::string m_attributes;
261 
262  std::string m_vendorName;
263  std::string m_vendorUrl;
264  uint64_t m_appSize;
265  uint32_t m_fsBlockSize;
266 
267  unsigned int m_runtimeMemoryRequired; // Amount (in MB) of RAM the application expects to use during runtime
268  std::string m_appmenuName;
269  KeywordMap m_keywords;
270  std::string m_universalSearchJsonStr;
271  std::string m_servicesJsonStr;
272  std::string m_accountsJsonStr;
273 
274  // if type == SysmgrBuiltin
275 
276  SysmgrBuiltinLaunchHelper * m_pBuiltin_launcher;
277  void updateSysmgrBuiltinWithLocalization();
278 };
279 
280 
281 #endif /* APPLICATIONDESCRIPTION_H */