static char* WINLAYOUT_CONFIG = "window_layout.dat";
static char* GUI_CONFIG = "gui_config.xml";
static char* CAMERA_RECORD = "camera_record.camera";
+
static char* DEFAULT_CONFIG_DIR = "/Data/DefaultConfig/";
return QStandardPaths::writableLocation(loc_type);
}
+QString PathInfo::GetTempDirPath(void)
+{
+ QStandardPaths::StandardLocation loc_type;
+ loc_type = QStandardPaths::TempLocation;
+
+ return QStandardPaths::writableLocation(loc_type);
+}
+
+
+QString PathInfo::GetAppTmpPath(void)
+{
+ return GetLocalAppDirPath() + "/Tmp/";
+}
+
QString PathInfo::GetConfigDirPath(void)
{
if (BUILDMODE_RELEASE)
#include <QDesktopServices>
#include <QUrl>
#include <QDomDocument>
+#include <QDir>
#include <Qt5Utility/QXmlExt.h>
#include "BuildInfo.h"
#include "DownloadManager.h"
#include "AppVersion.h"
+#include "PathInfo.h"
+
+#include "../../Lib/Qt5Utility/ExtCmdRunner.h"
+
+
static const char* PROJECT_URL = "https://osdn.jp/projects/qtgeoviewer/";
static const char* RELEASE_RSS = "https://osdn.jp/projects/qtgeoviewer/releases/rss";
bool QGVAboutDlg::GetVersionTextFromWeb(QString& version)
{
- QByteArray ba;
- if (!DownloadReleaseRSS(ba))
+ if (!DownloadReleaseRSS())
return false;
- QString src(ba);
+ QFile file(GetTmpPath());
+ if (!file.open(QIODevice::ReadOnly))
+ return false;
QDomDocument xml;
- xml.setContent(src);
+ xml.setContent(&file);
+
+ bool suc = ReadXmlBuf(xml, version);
+ file.close();
+ return suc;
+}
+
+bool QGVAboutDlg::ReadXmlBuf(QDomDocument& xml, QString& version)
+{
QXML_ELEM_FOREACH(n_rss, xml)
{
QXML_ELEM_FOREACH(n_channel, n_rss)
return false;
}
-bool QGVAboutDlg::DownloadReleaseRSS(QByteArray& buf)
+QString QGVAboutDlg::GetTmpPath(void)
+{
+ QString dst = PathInfo::GetAppTmpPath();
+ dst = QDir::toNativeSeparators(dst);
+ dst += "version.xml";
+ return dst;
+}
+
+bool QGVAboutDlg::DownloadReleaseRSS(void)
{
- DownloadManager manager;
- manager.downloadToBuf(QUrl(RELEASE_RSS), &buf);
+ QString url = RELEASE_RSS;
+ QString dst = GetTmpPath();
- manager.WaitWhileDownloading();
+ QString tmp_dir = PathInfo::GetAppTmpPath();
+ if (!QDir().exists(tmp_dir))
+ QDir().mkpath(tmp_dir);
- if (manager.currentState() == DownloadManager::DownloadFail)
- return false;
+ if (QFile(dst).exists())
+ QFile::remove(dst);
- return true;
-}
+ ExtCmdRunner runner;
+ runner.cmd = PathInfo::GetWebDownloaderPath();
+ runner.args = "";
+ runner.args += url;
+ runner.args += " ";
+ runner.args += dst;
+
+ runner.Execute2(ShellExecMode::Wait);
+
+ if (!QFile(dst).exists())
+ return false;
-bool QGVAboutDlg::ParseVersion(QString& line, QString& version)
-{
return true;
}
#include "AppVersion.h"
+class QDomDocument;
+
class QGVAboutDlg : public QDialog
{
Q_OBJECT
bool GetVersionFromWeb(AppVersion& version, QString& vs);
bool GetVersionTextFromWeb(QString& version);
bool VersionTextToVal(QString& version);
- bool DownloadReleaseRSS(QByteArray& buf);
- bool ParseVersion(QString& line, QString& version);
+ bool DownloadReleaseRSS(void);
void ShowProjectPage(void);
+ QString GetTmpPath(void);
+
+ bool ReadXmlBuf(QDomDocument& xml, QString& version);
+
private slots:
void on_buttonBox_accepted();