From e1d7b913812ae11025f6890ee4dd54a0f9e4794c Mon Sep 17 00:00:00 2001
From: Akira Ohgaki <akiraohgaki@gmail.com>
Date: Wed, 5 Oct 2016 00:38:24 +0900
Subject: [PATCH] Get metadata

---
 src/handlers/xdgurl.cpp | 17 +++++++++++------
 src/handlers/xdgurl.h   |  3 ++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/handlers/xdgurl.cpp b/src/handlers/xdgurl.cpp
index a4eb420..6dc8fcf 100644
--- a/src/handlers/xdgurl.cpp
+++ b/src/handlers/xdgurl.cpp
@@ -16,7 +16,7 @@ namespace Handlers {
 XdgUrl::XdgUrl(const QString &xdgUrl, Core::Config *appConfig, Core::Config *userConfig, Core::Network *asyncNetwork, QObject *parent) :
     QObject(parent), _xdgUrl(xdgUrl), _appConfig(appConfig), _userConfig(userConfig), _asyncNetwork(asyncNetwork)
 {
-    _meta = _parse();
+    _metadata = _parse();
     _destinations = _importDestinations();
     _archiveTypes = _importArchiveTypes();
 }
@@ -210,27 +210,32 @@ QString XdgUrl::getXdgUrl()
     return _xdgUrl;
 }
 
+QString XdgUrl::getMetadata()
+{
+    return Utility::Json::convertObjToStr(_metadata);
+}
+
 bool XdgUrl::isValid()
 {
     bool isValid = true;
 
-    if (_meta["scheme"].toString() != "xdg" && _meta["scheme"].toString() != "xdgs") {
+    if (_metadata["scheme"].toString() != "xdg" && _metadata["scheme"].toString() != "xdgs") {
         isValid = false;
     }
 
-    if (_meta["command"].toString() != "download" && _meta["command"].toString() != "install") {
+    if (_metadata["command"].toString() != "download" && _metadata["command"].toString() != "install") {
         isValid = false;
     }
 
-    if (!QUrl(_meta["url"].toString()).isValid()) {
+    if (!QUrl(_metadata["url"].toString()).isValid()) {
         isValid = false;
     }
 
-    if (!_destinations.contains(_meta["type"].toString())) {
+    if (!_destinations.contains(_metadata["type"].toString())) {
         isValid = false;
     }
 
-    if (_meta["filename"].toString().isEmpty()) {
+    if (_metadata["filename"].toString().isEmpty()) {
         isValid = false;
     }
 
diff --git a/src/handlers/xdgurl.h b/src/handlers/xdgurl.h
index 619e2ae..d1c0cdf 100644
--- a/src/handlers/xdgurl.h
+++ b/src/handlers/xdgurl.h
@@ -23,7 +23,7 @@ private:
     Core::Config *_userConfig;
     Core::Network *_asyncNetwork;
 
-    QJsonObject _meta;
+    QJsonObject _metadata;
     QJsonObject _destinations;
     QJsonObject _archiveTypes;
 
@@ -44,6 +44,7 @@ private slots:
 
 public slots:
     QString getXdgUrl();
+    QString getMetadata();
     bool isValid();
     bool process();
 
-- 
GitLab