Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5e1357c1 authored by Ilya Bizyaev's avatar Ilya Bizyaev 📱

Fix Android build of gloox-extensions

Android NDK does not include multiple string functions like
stol(), stoi(), to_string() etc. As we have now decided to
switch to QXmpp in the future, we no longer have to care
about Qt includes in src/gloox-extensions, so using
QString conversion methods as a workaround.
parent 128cc2fb
......@@ -33,6 +33,7 @@
#include <gloox/gloox.h>
#include <gloox/base64.h>
#include <gloox/sha.h>
#include <QString>
using namespace gloox;
......@@ -69,7 +70,7 @@ BitsOfBinaryData::BitsOfBinaryData(const Tag* tag)
if (tag->hasAttribute("max-age")) {
try {
// conversion can cause invalid_argument / out_of_range exception
m_maxAge = std::stol(tag->findAttribute("max-age"));
m_maxAge = QString::fromStdString(tag->findAttribute("max-age")).toLong();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......
......@@ -40,6 +40,7 @@
#include <fstream>
#include <sys/stat.h>
#include <QString>
using namespace gloox;
......@@ -110,8 +111,8 @@ void HttpUploadManager::tryAddFileStoreService(const JID &jid,
try {
// get max file size for uploads from form data
unsigned long maxFileSize = std::stoul(
form->field("max-file-size")->value());
unsigned long maxFileSize = QString::fromStdString(
form->field("max-file-size")->value()).toULong();
// register new upload service
addUploadService(jid, maxFileSize);
......
......@@ -31,6 +31,7 @@
#include "httpuploadrequest.h"
#include "gloox-extensions.h"
#include <gloox/tag.h>
#include <QString>
using namespace gloox;
......@@ -61,7 +62,7 @@ HttpUploadRequest::HttpUploadRequest(const Tag *tag) : gloox::StanzaExtension(EX
m_contentType = tag->findAttribute("contentType");
try {
// conversion can cause invalid_argument / out_of_range exception
m_size = std::stoul(tag->findAttribute("size"));
m_size = QString::fromStdString(tag->findAttribute("size")).toULong();
m_valid = true;
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
......@@ -86,7 +87,7 @@ Tag* HttpUploadRequest::tag() const
{
Tag *tag = new Tag("request", XMLNS, XMLNS_HTTPUPLOAD);
tag->addAttribute("filename", m_filename);
tag->addAttribute("size", std::to_string(m_size));
tag->addAttribute("size", QString::number(m_size).toStdString());
if (!m_contentType.empty())
tag->addAttribute("content-type", m_contentType);
......
......@@ -31,6 +31,7 @@
#include "jinglefile.h"
#include "gloox-extensions.h"
#include <gloox/util.h>
#include <QString>
using namespace gloox;
using namespace gloox::Jingle;
......@@ -62,7 +63,7 @@ File::File(const Tag* tag)
if (tag->hasChild("size")) {
try {
// conversion can cause invalid_argument / out_of_range exception
m_size = std::stol(tag->findChild("size")->cdata());
m_size = QString::fromStdString(tag->findChild("size")->cdata()).toLong();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......@@ -75,7 +76,7 @@ File::File(const Tag* tag)
if (range->hasAttribute("offset")) {
try {
// conversion can cause invalid_argument / out_of_range exception
m_offset = std::stol(tag->findAttribute("offset"));
m_offset = QString::fromStdString(tag->findAttribute("offset")).toLong();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......@@ -85,7 +86,7 @@ File::File(const Tag* tag)
if (range->hasAttribute("length")) {
try {
// conversion can cause invalid_argument / out_of_range exception
m_length = std::stol(tag->findAttribute("length"));
m_length = QString::fromStdString(tag->findAttribute("length")).toLong();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......
......@@ -35,6 +35,7 @@
//FIXME: remove
#include <iostream>
#include <QString>
using namespace gloox;
......@@ -79,8 +80,8 @@ Reference::Reference(const Tag* tag)
if (tag->hasAttribute("begin") && tag->hasAttribute("end")) {
try {
// conversion can cause invalid_argument / out_of_range exception
m_begin = std::stoi(tag->findAttribute("start"));
m_end = std::stoi(tag->findAttribute("end"));
m_begin = QString::fromStdString(tag->findAttribute("start")).toInt();
m_end = QString::fromStdString(tag->findAttribute("end")).toInt();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......
......@@ -30,6 +30,7 @@
#include "thumb.h"
#include "gloox-extensions.h"
#include <QString>
using namespace gloox;
using namespace gloox::Jingle;
......@@ -53,8 +54,8 @@ Thumb::Thumb(const Tag* tag)
m_mediaType = tag->findAttribute("media-type");
try {
// conversion can cause invalid_argument / out_of_range exception
m_width = std::stoul(tag->findAttribute("width"));
m_height = std::stoul(tag->findAttribute("height"));
m_width = QString::fromStdString(tag->findAttribute("width")).toULong();
m_height = QString::fromStdString(tag->findAttribute("height")).toULong();
} catch (std::invalid_argument &e) {
// Couldn't parse size: input probably doesn't contain valid number
} catch (std::out_of_range &e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment