summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-05-26 13:20:55 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-05-27 07:53:48 +0200
commit4aca087c7cb9ffe831b277a62ad3e993c3b2ca58 (patch)
treea5495bc107e5a86bc324e49c72f641ff376d5d03 /desktop
parent79e247d657ec400ce851c8b14500448113ee6013 (diff)
support the json key value data upload for crash report on client side
Change-Id: I93f77f9363c016e0cc5a3e3c867de9f426e5bdf0
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/minidump/minidump_upload.cxx46
1 files changed, 32 insertions, 14 deletions
diff --git a/desktop/source/minidump/minidump_upload.cxx b/desktop/source/minidump/minidump_upload.cxx
index d75453a80f90..7447d833a970 100644
--- a/desktop/source/minidump/minidump_upload.cxx
+++ b/desktop/source/minidump/minidump_upload.cxx
@@ -12,6 +12,7 @@
#include <memory>
#include <iostream>
#include <fstream>
+#include <sstream>
#include <curl/curl.h>
@@ -62,13 +63,32 @@ void getProperty(const std::string& key, std::string& value,
}
}
+std::string generate_json(const std::map<std::string, std::string>& parameters)
+{
+ std::ostringstream stream;
+ stream << "{\n";
+ bool first = true;
+ for (auto itr = parameters.begin(), itrEnd = parameters.end(); itr != itrEnd; ++itr)
+ {
+ if (!first)
+ {
+ stream << ",\n";
+ first = false;
+ }
+ stream << "\"" << itr->first << "\": \"" << itr->second << "\"";
+ }
+ stream << "\n}";
+
+ return stream.str();
+}
+
bool uploadContent(std::map<std::string, std::string>& parameters)
{
CURL* curl = curl_easy_init();
if (!curl)
return false;
- std::string proxy, proxy_user_pwd, ca_certificate_file, file, url;
+ std::string proxy, proxy_user_pwd, ca_certificate_file, file, url, version;
getProperty("Proxy", proxy, parameters);
getProperty("ProxyUserPW", proxy_user_pwd, parameters);
@@ -76,6 +96,7 @@ bool uploadContent(std::map<std::string, std::string>& parameters)
getProperty("DumpFile", file, parameters);
getProperty("URL", url, parameters);
+ getProperty("Version", version, parameters);
if (url.empty())
return false;
@@ -92,13 +113,16 @@ bool uploadContent(std::map<std::string, std::string>& parameters)
curl_httppost* formpost = nullptr;
curl_httppost* lastptr = nullptr;
- for (auto itr = parameters.begin(), itEnd = parameters.end(); itr != itEnd; ++itr)
- {
- curl_formadd(&formpost, &lastptr,
- CURLFORM_COPYNAME, itr->first.c_str(),
- CURLFORM_COPYCONTENTS, itr->second.c_str(),
- CURLFORM_END);
- }
+ std::string additional_data = generate_json(parameters);
+ curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "AdditionalData",
+ CURLFORM_COPYCONTENTS, additional_data.c_str(),
+ CURLFORM_END);
+
+ curl_formadd(&formpost, &lastptr,
+ CURLFORM_COPYNAME, "Version",
+ CURLFORM_COPYCONTENTS, version.c_str(),
+ CURLFORM_END);
std::string response_body;
long response_code;
@@ -172,12 +196,6 @@ bool readConfig(char** argv)
return false;
}
- if (parameters.find("ProductName") == parameters.end())
- {
- std::cerr << "ini file needs to contain a ket ProductName!";
- return false;
- }
-
uploadContent(parameters);
return true;