Debian Codegraph @

src/search/mainnet.h

raw symbols SCIP
1 // Copyright (C) 2014 Sacha Refshauge
2
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 3.0.
6
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 3.0 for more details.
11
12 // A copy of the GPL 3.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
14
15 // Official GIT repository and contact information can be found at
16 // http://github.com/xsacha/Sachesi
17
18 #pragma once
19
20 #include <QtNetwork>
21 #include <QObject>
22 #include "apps.h"
23 #include "splitter.h"
24 #include "downloadinfo.h"
25
26 #ifdef BLACKBERRY
27 class InstallNet;
28 #else
29 #include "installer.h"
30 #endif
31
32 enum SplitType {
33 SplittingIdle = 0,
34 SplittingAuto = 1,
35 CreatingAuto = 2,
36 ExtractingImage = 3,
37 ExtractingApps = 4,
38 FetchingCap = 5,
39 };
40
41 class MainNet : public QObject {
42 Q_OBJECT
43 Q_PROPERTY(QString softwareRelease MEMBER _softwareRelease NOTIFY softwareReleaseChanged) // from reverse lookup
44 Q_PROPERTY(QString updateMessage MEMBER _updateMessage NOTIFY updateMessageChanged)
45 Q_PROPERTY(QQmlListProperty<Apps> updateAppList READ updateAppList NOTIFY updateMessageChanged)
46 Q_PROPERTY(int updateAppCount READ updateAppCount NOTIFY updateMessageChanged)
47 Q_PROPERTY(int updateCheckedCount READ updateCheckedCount NOTIFY updateCheckedCountChanged)
48 Q_PROPERTY(int updateAppNeededCount READ updateAppNeededCount NOTIFY updateMessageChanged)
49 Q_PROPERTY(int updateCheckedNeededCount READ updateCheckedNeededCount NOTIFY updateCheckedCountChanged)
50 Q_PROPERTY(QString error MEMBER _error NOTIFY errorChanged)
51 Q_PROPERTY(QString multiscanVersion MEMBER _multiscanVersion NOTIFY updateMessageChanged)
52 Q_PROPERTY(bool hasBootAccess READ hasBootAccess CONSTANT)
53 Q_PROPERTY(bool multiscan MEMBER _multiscan WRITE setMultiscan NOTIFY multiscanChanged)
54 Q_PROPERTY(int scanning MEMBER _scanning WRITE setScanning NOTIFY scanningChanged)
55 Q_PROPERTY(int maxId MEMBER _maxId NOTIFY maxIdChanged)
56 Q_PROPERTY(int splitting MEMBER _splitting NOTIFY splittingChanged)
57 Q_PROPERTY(int splitProgress MEMBER _splitProgress WRITE setSplitProgress NOTIFY splitProgressChanged)
58
59 public:
60 MainNet(InstallNet* installer = nullptr, QObject* parent = 0);
61 ~MainNet();
62 Q_INVOKABLE void updateDetailRequest(QString delta, QString carrier, QString country, int device, int variant, int mode/*, int server, int version*/);
63 Q_INVOKABLE void downloadLinks(int downloadDevice = 0);
64 Q_INVOKABLE void splitAutoloader(QUrl, int options);
65 Q_INVOKABLE void combineAutoloader(QList<QUrl> selectedFiles);
66 Q_INVOKABLE void extractImage(int type, int options);
67 Q_INVOKABLE void grabLinks(int downloadDevice);
68 Q_INVOKABLE void abortSplit();
69 void splitConnectStart();
70
71 Q_INVOKABLE QString nameFromVariant(unsigned int device, unsigned int variant);
72 Q_INVOKABLE QString hwidFromVariant(unsigned int device, unsigned int variant);
73 Q_INVOKABLE unsigned int variantCount(unsigned int device);
74 bool hasBootAccess() const { return
75 #ifdef BOOTLOADER_ACCESS
76 true;
77 #else
78 false;
79 #endif
80 }
81 void setMultiscan(const bool &multiscan);
82 void setScanning(const int &scanning);
83 QQmlListProperty<Apps> updateAppList() {
84 return QQmlListProperty<Apps>(this, _updateAppList);
85 }
86
87 int updateAppCount() const { return _updateAppList.count(); }
88 int updateAppNeededCount() const {
89 int count = 0;
90 foreach (Apps* app, _updateAppList) {
91 if (app->isAvailable() && !app->isInstalled())
92 count++;
93 }
94 return count;
95 }
96 int updateCheckedCount() const {
97 int checked = 0;
98 foreach (Apps* app, _updateAppList)
99 if (app->isMarked())
100 checked++;
101 return checked;
102 }
103 int updateCheckedNeededCount() const {
104 int checked = 0;
105 foreach (Apps* app, _updateAppList)
106 if (app->isMarked() && (app->isAvailable() && !app->isInstalled()))
107 checked++;
108 return checked;
109 }
110 DownloadInfo* currentDownload;
111 public slots:
112 void setSplitProgress(const int &progress);
113 void newDeviceConnected();
114 signals:
115 void softwareReleaseChanged();
116 void updateMessageChanged();
117 void updateCheckedCountChanged();
118 void errorChanged();
119 void multiscanChanged();
120 void scanningChanged();
121 void hasBootAccessChanged();
122 void maxIdChanged();
123 void splittingChanged();
124 void splitProgressChanged();
125 private slots:
126 void serverReply();
127 void showFirmwareData(QByteArray data, QString variant);
128 void serverError(QNetworkReply::NetworkError error);
129 void cancelSplit();
130 // Blackberry
131 void extractImageSlot(const QStringList& selectedFiles);
132
133 private:
134 // Utils:
135 InstallNet* _i;
136 void verifyLink(QString url, QString type);
137 QString convertLinks(QString prepend);
138 QString fixVariantName(QString name, QString replace, int type);
139 void fixApps();
140 QString NPCFromLocale(int country, int carrier);
141
142 QThread* splitThread;
143 Splitter* splitter;
144 QNetworkAccessManager *manager;
145 QList<Apps*> _updateAppList;
146 QString _updateMessage;
147 QString _softwareRelease;
148 QString _versionRelease;
149 QString _error;
150 QString _multiscanVersion;
151 bool _multiscan;
152 int _scanning;
153 QFile _currentFile;
154 int _maxId, _dlBytes, _dlTotal;
155 int _splitting, _splitProgress;
156 int _options;
157 int _type;
158 int _downloadDevice;
159 };