LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pagerestore.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 PAGERESTORE_H_
23 #define PAGERESTORE_H_
24 
25 #include <QObject>
26 #include <QPointer>
27 #include <QVariant>
28 #include <QList>
29 #include <QUuid>
30 #include <QVariantMap>
31 #include <QMap>
32 #include <QString>
33 #include <QPair>
34 
35 #include "safefileops.h"
36 
37 class DimensionsUI;
38 class Page;
39 class ReorderablePage;
40 
41 namespace DimensionsSystemInterface
42 {
43 
44 namespace PageRestoreMSaveFileSelector
45 {
46  enum Enum
47  {
49  Any,
52  };
53 }
54 
55 namespace QuickLaunchRestoreSaveFileSelector
56 {
57  enum Enum
58  {
60  Any,
63  };
64 }
65 
67 {
68 public:
70  WebOSAppRestoreObject(const QUuid& appuid,const QString& appid,const QString& launchpointid,quint32 pos)
71  : m_valid(true) , appUid(appuid) , appId(appid) , launchpointId(launchpointid) , positionInSaveFile(pos) {}
72 
73  bool m_valid;
74  QUuid appUid;
75  QString appId;
76  QString launchpointId;
78 };
79 
80 static QMap<QString,QPair<QString,quint32> > s_positionsAsStoredOnDiskMap;
81 //
82 
83 class PageRestore : public QObject
84 {
85  Q_OBJECT
86 public:
87  PageRestore();
88  virtual ~PageRestore();
89 
90  //return the current set of app uids based on the apps stored in the settings file
91  // the uids are looked up in the AppMonitor
92  static QList<QVariantMap> restoreLauncher(const QString& masterSaveFilepath);
93  static QVariantMap restoreQuickLaunch(const QString& quicklaunchSaveFilepath);
94 
95  static QVariantMap restorePage(const QString& pageSaveFilepath);
96  static QString pageSaveFilepathFromPageTag(const QVariantMap& pageTag);
97 
99  static QString selectMasterFile(const QList<QString>& masterFileList,
101  QVariant selectValue = QVariant());
102  static QList<QString> scanForSavedMasterFiles();
103  static QVariantMap masterFileStat(const QString& filePath);
104  static QList<QVariantMap> processMasterFile(const QString& masterFilepath);
105 
106  static bool masterfileSaveSysVersion(const QVariantMap& masterFileHeader,quint32& r_saveSysVersion);
107  static bool masterfileTimeStamp(const QVariantMap& masterFileHeader,quint64& r_timeStamp);
108  static bool masterfileSimpleName(const QVariantMap& masterFileHeader,QString& r_simpleName);
109  static bool masterfileNumPages(const QVariantMap& masterFileHeader,quint32& r_numPages);
110 
111  static bool isMasterFileCompatibleWithCurrentSaveSysVersion(const QVariantMap& masterFileHeader);
112 
114  static QString selectQuicklaunchFile(const QList<QString>& quickLaunchFileList,
116  QVariant selectValue = QVariant());
117  static QList<QString> scanForSavedQuicklaunchFiles();
118  static QVariantMap quicklaunchFileStat(const QString& filepath);
119  static QVariantMap processQuicklaunchFile(const QString& filepath);
120 
121  static bool quicklaunchFileTimeStamp(const QVariantMap& quicklaunchFileHeader,quint64& r_timeStamp);
122  static bool quicklaunchFileSimpleName(const QVariantMap& quicklaunchFileHeader,QString& r_simpleName);
123  static bool quicklaunchFileSaveSysVersion(const QVariantMap& quicklaunchFileHeader,quint32& r_saveSysVersion);
124  static bool isQuicklaunchFileCompatibleWithCurrentSaveSysVersion(const QVariantMap& quicklaunchFileHeader);
125 
126  static bool convertLegacyJsonQuicklaunchConfig(const QString& sourceFilepath,const QString& destinationFilepath=QString());
127  static QList<QPair<QString,QList<QString> > > loadStaticLegacyLauncherConfig(const QString& sourceFilePath);
128 
129  static QPair<QString,quint32> itemPositionAsStoredOnDisk(const QString& webOsAppId);
130  //
131 protected:
132 
133  static QList<WebOSAppRestoreObject> restoreReorderablePage(QSettings& savedSettingsObj,const QString& pageUid);
134 
135 };
136 
137 } //end namespace
138 
139 Q_DECLARE_METATYPE (QUuid)
140 Q_DECLARE_METATYPE (QList<QUuid>)
141 Q_DECLARE_METATYPE (DimensionsSystemInterface::WebOSAppRestoreObject)
142 Q_DECLARE_METATYPE (QList<DimensionsSystemInterface::WebOSAppRestoreObject>)
143 
144 #endif /* PAGERESTORE_H_ */