summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-04-05 20:54:08 +0200
committerTannin <devnull@localhost>2014-04-05 20:54:08 +0200
commit739c3424e7c058f972a2648f2231e6a10c59662d (patch)
treef0a9e40c8b30692aed30ca9f2e2599f0ec9db625 /src
parentcabed9b268c9f095d5e3b98a6797b0bcdcd38b1f (diff)
- loot integration now displays the report
- fixes to the previous merge - bugfix: cli loot didn't handle non-ascii characters correctly
Diffstat (limited to 'src')
-rw-r--r--src/ModOrganizer.pro3
-rw-r--r--src/downloadlist.cpp2
-rw-r--r--src/downloadmanager.cpp38
-rw-r--r--src/downloadmanager.h7
-rw-r--r--src/mainwindow.cpp79
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/nexusinterface.cpp5
-rw-r--r--src/organizer.pro2
-rw-r--r--src/version.rc4
9 files changed, 85 insertions, 57 deletions
diff --git a/src/ModOrganizer.pro b/src/ModOrganizer.pro
index 62de3f66..4624ffec 100644
--- a/src/ModOrganizer.pro
+++ b/src/ModOrganizer.pro
@@ -13,13 +13,12 @@ SUBDIRS = bsatk \
nxmhandler \
BossDummy \
pythonRunner \
- boss_modified \
esptk \
loot_cli
plugins.depends = pythonRunner
hookdll.depends = shared
-organizer.depends = shared uibase plugins boss_modified
+organizer.depends = shared uibase plugins loot_cli
CONFIG(debug, debug|release) {
DESTDIR = outputd
diff --git a/src/downloadlist.cpp b/src/downloadlist.cpp
index 5248382b..e42f7fd4 100644
--- a/src/downloadlist.cpp
+++ b/src/downloadlist.cpp
@@ -82,7 +82,7 @@ QVariant DownloadList::data(const QModelIndex &index, int role) const
text += tr("Information missing, please select \"Query Info\" from the context menu to re-retrieve.");
} else {
const MOBase::ModRepositoryFileInfo *info = m_Manager->getFileInfo(index.row());
- return QString("%1 (ID %2) %3").arg(info.m_ModName).arg(m_Manager->getModID(index.row())).arg(info.m_Version);
+ return QString("%1 (ID %2) %3").arg(info->modName).arg(m_Manager->getModID(index.row())).arg(info->version.canonicalString());
}
return text;
} else {
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 8c127511..19470825 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -106,10 +106,13 @@ DownloadManager::DownloadInfo *DownloadManager::DownloadInfo::createFromMeta(con
info->m_Urls = metaFile.value("url", "").toString().split(";");
info->m_Tries = 0;
info->m_TaskProgressId = TaskProgressManager::instance().getId();
+ int modID = metaFile.value("modID", 0).toInt();
+ int fileID = metaFile.value("fileID", 0).toInt();
+ info->m_FileInfo = new ModRepositoryFileInfo(modID, fileID);
info->m_FileInfo->name = metaFile.value("name", "").toString();
info->m_FileInfo->modName = metaFile.value("modName", "").toString();
- info->m_FileInfo->modID = metaFile.value("modID", 0).toInt();
- info->m_FileInfo->fileID = metaFile.value("fileID", 0).toInt();
+ info->m_FileInfo->modID = modID;
+ info->m_FileInfo->fileID = fileID;
info->m_FileInfo->description = metaFile.value("description").toString();
info->m_FileInfo->version.parse(metaFile.value("version", "0").toString());
info->m_FileInfo->newestVersion.parse(metaFile.value("newestVersion", "0").toString());
@@ -309,7 +312,8 @@ void DownloadManager::refreshList()
}
-bool DownloadManager::addDownload(const QStringList &URLs, const ModRepositoryFileInfo *fileInfo)
+bool DownloadManager::addDownload(const QStringList &URLs,
+ int modID, int fileID, const ModRepositoryFileInfo *fileInfo)
{
QString fileName = QFileInfo(URLs.first()).fileName();
if (fileName.isEmpty()) {
@@ -317,7 +321,7 @@ bool DownloadManager::addDownload(const QStringList &URLs, const ModRepositoryFi
}
QNetworkRequest request(URLs.first());
- return addDownload(m_NexusInterface->getAccessManager()->get(request), URLs, fileName, fileInfo);
+ return addDownload(m_NexusInterface->getAccessManager()->get(request), URLs, fileName, modID, fileID, fileInfo);
}
@@ -328,11 +332,12 @@ bool DownloadManager::addDownload(QNetworkReply *reply, const ModRepositoryFileI
fileName = "unknown";
}
- return addDownload(reply, QStringList(reply->url().toString()), fileName, fileInfo);
+ return addDownload(reply, QStringList(reply->url().toString()), fileName, fileInfo->modID, fileInfo->fileID, fileInfo);
}
-bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs, const QString &fileName, const ModRepositoryFileInfo *fileInfo)
+bool DownloadManager::addDownload(QNetworkReply *reply, const QStringList &URLs, const QString &fileName,
+ int modID, int fileID, const ModRepositoryFileInfo *fileInfo)
{
// download invoked from an already open network reply (i.e. download link in the browser)
DownloadInfo *newDownload = DownloadInfo::createNew(fileInfo, URLs);
@@ -409,7 +414,7 @@ void DownloadManager::startDownload(QNetworkReply *reply, DownloadInfo *newDownl
if (!resume) {
newDownload->m_PreResumeSize = newDownload->m_Output.size();
- removePending(newDownload->m_ModID, newDownload->m_FileID);
+ removePending(newDownload-> m_ModID, newDownload->m_FileID);
emit aboutToUpdate();
@@ -916,6 +921,7 @@ DownloadManager::DownloadInfo *DownloadManager::findDownload(QObject *reply, int
void DownloadManager::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
+qDebug("progress: %ldd / %ldd", bytesReceived, bytesTotal);
if (bytesTotal == 0) {
return;
}
@@ -961,7 +967,7 @@ void DownloadManager::createMetaFile(DownloadInfo *info)
metaFile.setValue("modName", info->m_FileInfo->modName);
metaFile.setValue("version", info->m_FileInfo->version.canonicalString());
metaFile.setValue("newestVersion", info->m_FileInfo->newestVersion.canonicalString());
- metaFile.setValue("fileTime", info->m_FileInfo->m_FileTime);
+ metaFile.setValue("fileTime", info->m_FileInfo->fileTime);
metaFile.setValue("fileCategory", info->m_FileInfo->fileCategory);
metaFile.setValue("category", info->m_FileInfo->categoryID);
metaFile.setValue("repository", info->m_FileInfo->repository);
@@ -1061,8 +1067,8 @@ void DownloadManager::nxmFilesAvailable(int, QVariant userData, QVariant resultD
(fileNameVariant == info->m_FileName) || (fileNameVariant == alternativeLocalName)) {
info->m_FileInfo->name = fileInfo["name"].toString();
info->m_FileInfo->version.parse(fileInfo["version"].toString());
- if (info->m_FileInfo->version.isEmpty()) {
- info->m_FileInfo->version = info->m_NexusInfo.m_NewestVersion;
+ if (!info->m_FileInfo->version.isValid()) {
+ info->m_FileInfo->version = info->m_FileInfo->newestVersion;
}
info->m_FileInfo->fileCategory = convertFileCategory(fileInfo["category_id"].toInt());
info->m_FileInfo->fileTime = matchDate(fileInfo["date"].toString());
@@ -1117,10 +1123,10 @@ void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant userD
QVariantMap result = resultData.toMap();
info->name = result["name"].toString();
- qDebug("file info received for %s", qPrintable(info.m_Name));
+ qDebug("file info received for %s", qPrintable(info->name));
info->version.parse(result["version"].toString());
- if (info.m_Version.isEmpty()) {
- info.m_Version = info.m_NewestVersion;
+ if (!info->version.isValid()) {
+ info->version = info->newestVersion;
}
info->fileName = result["uri"].toString();
info->fileCategory = result["category_id"].toInt();
@@ -1132,7 +1138,7 @@ void DownloadManager::nxmFileInfoAvailable(int modID, int fileID, QVariant userD
info->fileID = fileID;
QObject *test = info;
- m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(info)));
+ m_RequestIDs.insert(m_NexusInterface->requestDownloadURL(modID, fileID, this, qVariantFromValue(test)));
}
@@ -1180,7 +1186,7 @@ bool DownloadManager::ServerByPreference(const std::map<QString, int> &preferred
int DownloadManager::startDownloadURLs(const QStringList &urls)
{
- addDownload(urls, NULL);
+ addDownload(urls, -1, -1, nullptr);
return m_ActiveDownloads.size() - 1;
}
@@ -1233,7 +1239,7 @@ void DownloadManager::nxmDownloadURLsAvailable(int modID, int fileID, QVariant u
URLs.append(server.toMap()["URI"].toString());
}
- addDownload(URLs, info);
+ addDownload(URLs, modID, fileID, info);
}
diff --git a/src/downloadmanager.h b/src/downloadmanager.h
index 4e8467ee..27b5c526 100644
--- a/src/downloadmanager.h
+++ b/src/downloadmanager.h
@@ -72,12 +72,13 @@ private:
QTime m_StartTime;
qint64 m_PreResumeSize;
int m_Progress;
+ int m_ModID;
+ int m_FileID;
DownloadState m_State;
int m_CurrentUrl;
QStringList m_Urls;
qint64 m_ResumePos;
qint64 m_TotalSize;
-
QDateTime m_Created; // used as a cache in DownloadManager::getFileTime, may not be valid elsewhere
int m_Tries;
@@ -177,7 +178,7 @@ public:
* @param fileInfo information previously retrieved from the nexus network
* @return true if the download was started, false if it wasn't. The latter currently only happens if there is a duplicate and the user decides not to download again
**/
- bool addDownload(QNetworkReply *reply, const QStringList &URLs, const QString &fileName, const MOBase::ModRepositoryFileInfo *fileInfo);
+ bool addDownload(QNetworkReply *reply, const QStringList &URLs, const QString &fileName, int modID, int fileID = 0, const MOBase::ModRepositoryFileInfo *fileInfo = new MOBase::ModRepositoryFileInfo());
/**
* @brief start a download using a nxm-link
@@ -428,7 +429,7 @@ private:
* @param fileInfo information previously retrieved from the mod page
* @return true if the download was started, false if it wasn't. The latter currently only happens if there is a duplicate and the user decides not to download again
**/
- bool addDownload(const QStringList &URLs, const MOBase::ModRepositoryFileInfo *fileInfo);
+ bool addDownload(const QStringList &URLs, int modID, int fileID, const MOBase::ModRepositoryFileInfo *fileInfo);
// important: the caller has to lock the list-mutex, otherwise the DownloadInfo-pointer might get invalidated at any time
DownloadInfo *findDownload(QObject *reply, int *index = NULL) const;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8f07aa20..362a7c4c 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -4288,7 +4288,7 @@ void MainWindow::downloadRequestedNXM(const QString &url)
void MainWindow::downloadRequested(QNetworkReply *reply, int modID, const QString &fileName)
{
try {
- if (m_DownloadManager.addDownload(reply, QStringList(), fileName, new ModRepositoryFileInfo(modID))) {
+ if (m_DownloadManager.addDownload(reply, QStringList(), fileName, modID, 0, new ModRepositoryFileInfo(modID))) {
MessageDialog::showMessage(tr("Download started"), this);
}
} catch (const std::exception &e) {
@@ -5290,8 +5290,34 @@ std::string MainWindow::readFromPipe(HANDLE stdOutRead)
return result;
}
+void MainWindow::processLOOTOut(const std::string &lootOut, std::string &reportURL, std::string &errorMessages, QProgressDialog &dialog)
+{
+ std::vector<std::string> lines;
+ boost::split(lines, lootOut, boost::is_any_of("\r\n"));
+ foreach (const std::string &line, lines) {
+ if (line.length() > 0) {
+ size_t progidx = line.find("[progress]");
+ size_t reportidx = line.find("[report]");
+ size_t erroridx = line.find("[error]");
+ if (progidx != std::string::npos) {
+ dialog.setLabelText(line.substr(progidx + 11).c_str());
+ } else if (reportidx != std::string::npos) {
+ reportURL = line.substr(reportidx + 9);
+ } else if (erroridx != std::string::npos) {
+ qWarning("%s", line.c_str());
+ errorMessages.append(boost::algorithm::trim_copy(line.substr(erroridx + 8)) + "\n");
+ } else {
+ qDebug("%s", line.c_str());
+ }
+ }
+ }
+}
+
void MainWindow::on_bossButton_clicked()
{
+ std::string reportURL;
+ std::string errorMessages;
+
try {
this->setEnabled(false);
ON_BLOCK_EXIT([&] () { this->setEnabled(true); });
@@ -5308,11 +5334,11 @@ void MainWindow::on_bossButton_clicked()
HANDLE stdOutRead = INVALID_HANDLE_VALUE;
createStdoutPipe(&stdOutRead, &stdOutWrite);
- HANDLE loot = startBinary(QFileInfo(qApp->applicationDirPath() + "/lootcli.exe"),
+ HANDLE loot = startBinary(QFileInfo(qApp->applicationDirPath() + "/loot/lootcli.exe"),
parameters.join(" "),
m_CurrentProfile->getName(),
m_Settings.logLevel(),
- qApp->applicationDirPath(),
+ qApp->applicationDirPath() + "/loot",
true,
stdOutWrite);
@@ -5327,38 +5353,37 @@ void MainWindow::on_bossButton_clicked()
::TerminateProcess(loot, 1);
}
std::string lootOut = readFromPipe(stdOutRead);
- std::vector<std::string> lines;
- boost::split(lines, lootOut, boost::is_any_of("\r\n"));
- foreach (const std::string &line, lines) {
- if (line.length() > 0) {
- size_t progidx = line.find("[progress]");
- size_t reportidx = line.find("[report]");
- if (progidx != std::string::npos) {
- dialog.setLabelText(line.substr(progidx + 11).c_str());
- } else if (reportidx != std::string::npos) {
- qDebug("report at %s", line.substr(reportidx + 9).c_str());
- } else {
- qDebug("%s", line.c_str());
- }
- }
- }
+ processLOOTOut(lootOut, reportURL, errorMessages, dialog);
}
std::string remainder = readFromPipe(stdOutRead).c_str();
if (remainder.length() > 0) {
- qDebug("%s", remainder.c_str());
+ processLOOTOut(remainder, reportURL, errorMessages, dialog);
}
+ }
+ } catch (const std::exception &e) {
+ reportError(tr("failed to run boss: %1").arg(e.what()));
+ }
- refreshESPList();
+ if (errorMessages.length() > 0) {
+ QMessageBox *warn = new QMessageBox(QMessageBox::Warning, tr("Errors occured"), errorMessages.c_str(), QMessageBox::Ok, this);
+ warn->setModal(false);
+ warn->show();
+ }
- if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) {
- QFile::remove(m_CurrentProfile->getLoadOrderFileName());
- }
+ if (reportURL.length() > 0) {
+ m_IntegratedBrowser.setWindowTitle("LOOT Report");
+ QString report(reportURL.c_str());
+ if (QFile::exists(report)) {
+ m_IntegratedBrowser.openUrl(QUrl::fromLocalFile(report));
+ } else {
+ qWarning("report file missing");
}
+ }
- dialog.hide();
- } catch (const std::exception &e) {
- reportError(tr("failed to run boss: %1").arg(e.what()));
- ui->bossButton->setEnabled(false);
+ refreshESPList();
+
+ if (GameInfo::instance().getLoadOrderMechanism() == GameInfo::TYPE_FILETIME) {
+ QFile::remove(m_CurrentProfile->getLoadOrderFileName());
}
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 6d4b0230..2af84be4 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -158,6 +158,7 @@ public:
void createStdoutPipe(HANDLE *stdOutRead, HANDLE *stdOutWrite);
std::string readFromPipe(HANDLE stdOutRead);
+ void processLOOTOut(const std::string &lootOut, std::string &reportURL, std::string &errorMessages, QProgressDialog &dialog);
public slots:
void displayColumnSelection(const QPoint &pos);
@@ -384,6 +385,7 @@ private:
QString m_CurrentLanguage;
std::vector<QTranslator*> m_Translators;
+ PreviewGenerator m_PreviewGenerator;
BrowserDialog m_IntegratedBrowser;
QFileSystemWatcher m_SavesWatcher;
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index ba2d5754..57c8819d 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -161,8 +161,6 @@ NexusInterface::NexusInterface()
void NexusInterface::cleanup()
{
- delete NexusInterface::s_Instance;
- NexusInterface::s_Instance = NULL;
}
@@ -178,9 +176,6 @@ NXMAccessManager *NexusInterface::getAccessManager()
NexusInterface *NexusInterface::instance()
{
static NexusInterface s_Instance;
-/* if (s_Instance == NULL) {
- s_Instance = new NexusInterface;
- }*/
return &s_Instance;
}
diff --git a/src/organizer.pro b/src/organizer.pro
index d93cd51f..8875ec05 100644
--- a/src/organizer.pro
+++ b/src/organizer.pro
@@ -157,7 +157,7 @@ HEADERS += \
../esptk/espexceptions.h \
browserview.h \
browserdialog.h \
- persistentcookiejar.h
+ persistentcookiejar.h \
noeditdelegate.h \
previewgenerator.h \
previewdialog.h \
diff --git a/src/version.rc b/src/version.rc
index 33c25b1c..f76ac8dc 100644
--- a/src/version.rc
+++ b/src/version.rc
@@ -1,7 +1,7 @@
#include "Winver.h"
-#define VER_FILEVERSION 1,1,3,0
-#define VER_FILEVERSION_STR "1,1,3,0\0"
+#define VER_FILEVERSION 1,2,0,0
+#define VER_FILEVERSION_STR "1,2,0,0\0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION VER_FILEVERSION