diff --git a/src/libclient/CMakeLists.txt b/src/libclient/CMakeLists.txt index 3ef0f17f..bfedfba4 100644 --- a/src/libclient/CMakeLists.txt +++ b/src/libclient/CMakeLists.txt @@ -238,6 +238,7 @@ endif() set(LIBCLIENT_SOURCES # data objects uri.cpp + vcard.cpp # models contactmodel.cpp diff --git a/src/libclient/callbackshandler.cpp b/src/libclient/callbackshandler.cpp index a63b8387..e6b03d75 100644 --- a/src/libclient/callbackshandler.cpp +++ b/src/libclient/callbackshandler.cpp @@ -42,7 +42,7 @@ #ifdef ENABLE_LIBWRAP // For the debugMessageReceived connection that queues const std::string refs // when not using dbus -Q_DECLARE_METATYPE(std::string); +Q_DECLARE_METATYPE(std::string) #endif namespace lrc { diff --git a/src/libclient/callparticipantsmodel.cpp b/src/libclient/callparticipantsmodel.cpp index 74139316..3ae412ab 100644 --- a/src/libclient/callparticipantsmodel.cpp +++ b/src/libclient/callparticipantsmodel.cpp @@ -101,7 +101,7 @@ CallParticipants::removeParticipant(int index) { { std::lock_guard lk(participantsMtx_); - auto it = participants_.begin() + index; + auto it = std::next(participants_.begin(), index); participants_.erase(it); } Q_EMIT linked_.participantRemoved(callId_, idx_); @@ -115,7 +115,7 @@ CallParticipants::addParticipant(const ParticipantInfos& participant) std::lock_guard lk(participantsMtx_); auto it = participants_.find(participant.sinkId); if (it == participants_.end()) { - participants_.insert(participants_.begin() + idx_, participant.sinkId, participant); + participants_.insert(std::next(participants_.begin(), idx_), participant.sinkId, participant); added = true; } else { if (participant == (*it)) @@ -179,7 +179,7 @@ CallParticipants::toQJsonObject(uint index) const return {}; QJsonObject ret; - const auto& participant = participants_.begin() + index; + const auto& participant = std::next(participants_.begin(), index); ret[ParticipantsInfosStrings::URI] = participant->uri; ret[ParticipantsInfosStrings::DEVICE] = participant->device; diff --git a/src/libclient/vcard.cpp b/src/libclient/vcard.cpp new file mode 100644 index 00000000..5271486c --- /dev/null +++ b/src/libclient/vcard.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018-2022 Savoir-faire Linux Inc. + * Author: Sébastien Blin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "vcard.h" + +namespace lrc { +namespace vCard { +namespace utils { + +QHash +toHashMap(const QByteArray& content) +{ + // TODO without Qt + QHash vCard; + QByteArray previousKey, previousValue; + const QList lines = content.split('\n'); + + Q_FOREACH (const QByteArray& property, lines) { + // Ignore empty lines + if (property.size()) { + // Some properties are over multiple lines + if (property[0] == ' ' && previousKey.size()) { + previousValue += property.right(property.size() - 1); + } + + // Do not use split, URIs can have : in them + const int dblptPos = property.indexOf(':'); + const QByteArray k(property.left(dblptPos)), + v(property.right(property.size() - dblptPos - 1)); + vCard[k] = v; + } + } + return vCard; +} + +} // namespace utils +} // namespace vCard +} // namespace lrc diff --git a/src/libclient/vcard.h b/src/libclient/vcard.h index 8d1a603e..ebf932bf 100644 --- a/src/libclient/vcard.h +++ b/src/libclient/vcard.h @@ -79,31 +79,8 @@ namespace utils { * @param content payload * @return the vCard representation */ -static QHash -toHashMap(const QByteArray& content) -{ - // TODO without Qt - QHash vCard; - QByteArray previousKey, previousValue; - const QList lines = content.split('\n'); +QHash toHashMap(const QByteArray& content); - Q_FOREACH (const QByteArray& property, lines) { - // Ignore empty lines - if (property.size()) { - // Some properties are over multiple lines - if (property[0] == ' ' && previousKey.size()) { - previousValue += property.right(property.size() - 1); - } - - // Do not use split, URIs can have : in them - const int dblptPos = property.indexOf(':'); - const QByteArray k(property.left(dblptPos)), - v(property.right(property.size() - dblptPos - 1)); - vCard[k] = v; - } - } - return vCard; -} } // namespace utils } // namespace vCard } // namespace lrc