refactorng

This commit is contained in:
Blue 2023-11-14 20:23:39 -03:00
parent 00af582287
commit 75554c7451
Signed by: blue
GPG Key ID: 9B203B252A63EE38
30 changed files with 515 additions and 627 deletions

View File

@ -1,52 +0,0 @@
#This file is taken from here https://gitlab.ralph.or.at/causal-rt/causal-cpp/, it was GPLv3 license
#Thank you so much, mr. Ralph Alexander Bariz, I hope you don't mind me using your code
# Try to find LMDB headers and library.
#
# Usage of this module as follows:
#
# find_package(LMDB)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# LMDB_ROOT_DIR Set this variable to the root installation of
# LMDB if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# LMDB_FOUND System has LMDB library/headers.
# LMDB_LIBRARIES The LMDB library.
# LMDB_INCLUDE_DIRS The location of LMDB headers.
find_path(LMDB_ROOT_DIR
NAMES include/lmdb.h
)
find_library(LMDB_LIBRARIES
NAMES liblmdb.a liblmdb.so liblmdb.so.a liblmdb.dll.a # We want lmdb to be static, if possible
HINTS ${LMDB_ROOT_DIR}/lib
)
add_library(lmdb UNKNOWN IMPORTED)
set_target_properties(lmdb PROPERTIES
IMPORTED_LOCATION ${LMDB_LIBRARIES}
)
find_path(LMDB_INCLUDE_DIRS
NAMES lmdb.h
HINTS ${LMDB_ROOT_DIR}/include
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LMDB DEFAULT_MSG
LMDB_LIBRARIES
LMDB_INCLUDE_DIRS
)
mark_as_advanced(
LMDB_ROOT_DIR
LMDB_LIBRARIES
LMDB_INCLUDE_DIRS
)

View File

@ -1,15 +0,0 @@
find_path(Signal_INCLUDE_DIR NAMES signal/signal_protocol.h)
find_library(Signal_LIBRARY signal-protocol-c)
mark_as_advanced(Signal_INCLUDE_DIR Signal_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Signal REQUIRED_VARS Signal_LIBRARY Signal_INCLUDE_DIR)
if (Signal_FOUND AND NOT TARGET Signal::Signal)
add_library(Signal::Signal UNKNOWN IMPORTED)
set_target_properties(Signal::Signal PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${Signal_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Signal_INCLUDE_DIR}"
)
endif ()

View File

@ -207,7 +207,6 @@ unsigned int Core::Archive::addElements(const std::list<Shared::Message>& messag
++success;
}
txn.commit();
return success;
}
@ -315,7 +314,8 @@ bool Core::Archive::setAvatar(const QByteArray& data, AvatarInfo& newInfo, bool
avatars->removeRecord(res, txn);
txn.commit();
return true;
} else {
}
QString currentPath = db.getPath();
bool needToRemoveOld = false;
QCryptographicHash hash(QCryptographicHash::Sha1);
@ -339,7 +339,15 @@ bool Core::Archive::setAvatar(const QByteArray& data, AvatarInfo& newInfo, bool
QMimeType type = mimedb.mimeTypeForData(data);
QString ext = type.preferredSuffix();
QFile newAvatar(currentPath + "/" + res + "." + ext);
if (newAvatar.open(QFile::WriteOnly)) {
if (!newAvatar.open(QFile::WriteOnly)) {
qDebug() << "Can't change avatar: cant open file to write" << newAvatar.fileName() << "rolling back to the previous state";
if (needToRemoveOld) {
QFile oldAvatar(currentPath + "/" + res + "." + oldInfo.type + ".bak");
oldAvatar.rename(currentPath + "/" + res + "." + oldInfo.type);
}
return false;
}
newAvatar.write(data);
newAvatar.close();
@ -363,15 +371,6 @@ bool Core::Archive::setAvatar(const QByteArray& data, AvatarInfo& newInfo, bool
oldAvatar.remove();
}
return true;
} else {
qDebug() << "Can't change avatar: cant open file to write" << newAvatar.fileName() << "rolling back to the previous state";
if (needToRemoveOld) {
QFile oldAvatar(currentPath + "/" + res + "." + oldInfo.type + ".bak");
oldAvatar.rename(currentPath + "/" + res + "." + oldInfo.type);
}
return false;
}
}
}
bool Core::Archive::readAvatarInfo(Core::Archive::AvatarInfo& target, const QString& resource) const {

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_ARCHIVE_H
#define CORE_ARCHIVE_H
#pragma once
#include <QObject>
#include <QCryptographicHash>
@ -101,5 +100,3 @@ private:
QDataStream& operator << (QDataStream &out, const Core::Archive::AvatarInfo& info);
QDataStream& operator >> (QDataStream &in, Core::Archive::AvatarInfo& info);
#endif // CORE_ARCHIVE_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "clientcache.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_CLIENTCACHE_H
#define CORE_CLIENTCACHE_H
#pragma once
#include <map>
#include <set>
@ -60,6 +61,3 @@ private:
};
}
#endif // CORE_CLIENTCACHE_H

View File

@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtWidgets/QApplication>
#include <QtCore/QDir>
@ -129,9 +128,9 @@ void Core::NetworkAccess::onDownloadError(QNetworkReply::NetworkError code) {
void Core::NetworkAccess::onDownloadSSLError(const QList<QSslError>& errors) {
qDebug() << "DEBUG: DOWNLOAD SSL ERRORS";
for (const QSslError& err : errors) {
for (const QSslError& err : errors)
qDebug() << err.errorString();
}
QNetworkReply* rpl = static_cast<QNetworkReply*>(sender());
QString url = rpl->url().toString();
std::map<QString, Transfer*>::const_iterator itr = downloads.find(url);

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_NETWORKACCESS_H
#define CORE_NETWORKACCESS_H
#pragma once
#include <QObject>
#include <QNetworkAccessManager>
@ -36,8 +35,7 @@
namespace Core {
//TODO Need to describe how to get rid of records when file is no longer reachable;
class NetworkAccess : public QObject
{
class NetworkAccess : public QObject {
Q_OBJECT
struct Transfer;
public:
@ -100,5 +98,3 @@ private:
};
}
#endif // CORE_NETWORKACCESS_H

View File

@ -193,10 +193,9 @@ Core::UrlStorage::UrlInfo::~UrlInfo() {}
bool Core::UrlStorage::UrlInfo::addMessage(const QString& acc, const QString& jid, const QString& id) {
for (const Shared::MessageInfo& info : messages) {
if (info.account == acc && info.jid == jid && info.messageId == id) {
if (info.account == acc && info.jid == jid && info.messageId == id)
return false;
}
}
messages.emplace_back(acc, jid, id);
return true;
}

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_URLSTORAGE_H
#define CORE_URLSTORAGE_H
#pragma once
#include <QString>
#include <QDataStream>
@ -93,5 +92,3 @@ public:
QDataStream& operator >> (QDataStream &in, Core::UrlStorage::UrlInfo& info);
QDataStream& operator << (QDataStream &out, const Core::UrlStorage::UrlInfo& info);
#endif // CORE_URLSTORAGE_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "cardinternal.h"

View File

@ -1,22 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
#ifndef CORE_DELAYMANAGER_CARDINTERNAL_H
#define CORE_DELAYMANAGER_CARDINTERNAL_H
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QString>
@ -33,5 +33,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_CARDINTERNAL_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "contact.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_CONTACT_H
#define CORE_DELAYMANAGER_CONTACT_H
#pragma once
#include <QString>
@ -35,5 +36,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_CONTACT_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "info.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_INFO_H
#define CORE_DELAYMANAGER_INFO_H
#pragma once
#include "job.h"
@ -52,5 +53,3 @@ private:
}
}
#endif // CORE_DELAYMANAGER_INFO_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "infoforuser.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_INFOFORUSER_H
#define CORE_DELAYMANAGER_INFOFORUSER_H
#pragma once
#include "contact.h"
#include "info.h"
@ -31,5 +32,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_INFOFORUSER_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "job.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_JOB_H
#define CORE_DELAYMANAGER_JOB_H
#pragma once
#include <stdint.h>
@ -51,5 +52,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_JOB_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "owncardinternal.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_OWNCARDINTERNAL_H
#define CORE_DELAYMANAGER_OWNCARDINTERNAL_H
#pragma once
#include "job.h"
@ -33,5 +34,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_OWNCARDINTERNAL_H

View File

@ -1,18 +1,20 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#include "owninfoforuser.h"

View File

@ -1,21 +1,22 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 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 <http://www.gnu.org/licenses/>.
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 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 <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_DELAYMANAGER_OWNINFOFORUSER_H
#define CORE_DELAYMANAGER_OWNINFOFORUSER_H
#pragma once
#include "contact.h"
#include "info.h"
@ -31,5 +32,3 @@ public:
}
}
#endif // CORE_DELAYMANAGER_OWNINFOFORUSER_H

View File

@ -19,6 +19,10 @@
#include "messagehandler.h"
#include "core/account.h"
static const QMap<QString, QVariant> statePending({{"state", static_cast<uint8_t>(Shared::Message::State::pending)}});
static const QMap<QString, QVariant> stateDelivered({{"state", static_cast<uint8_t>(Shared::Message::State::delivered)}});
static const QMap<QString, QVariant> stateSent({{"state", static_cast<uint8_t>(Shared::Message::State::sent)}});
Core::MessageHandler::MessageHandler(Core::Account* account):
QObject(),
acc(account),
@ -85,28 +89,16 @@ void Core::MessageHandler::onMessageReceived(const QXmppMessage& msg) {
}
bool Core::MessageHandler::handlePendingMessageError(const QString& id, const QString& errorText) {
std::tuple<bool, QString, QString> ids = getOriginalPendingMessageId(id);
if (std::get<0>(ids)) {
QString id = std::get<1>(ids);
QString jid = std::get<2>(ids);
RosterItem* ri = acc->rh->getRosterItem(jid);
QMap<QString, QVariant> cData = {
{"state", static_cast<uint>(Shared::Message::State::error)},
return adjustPendingMessage(id, {
{"state", static_cast<uint8_t>(Shared::Message::State::error)},
{"errorText", errorText}
};
if (ri != nullptr)
ri->changeMessage(id, cData);
emit acc->changeMessage(jid, id, cData);
return true;
}
return false;
}, true);
}
bool Core::MessageHandler::handleChatMessage(const QXmppMessage& msg, bool outgoing, bool forwarded, bool guessing) {
if (msg.body().size() != 0 || msg.outOfBandUrl().size() > 0) {
if (msg.body().isEmpty() && msg.outOfBandUrl().isEmpty())
return false;
Shared::Message sMsg(Shared::Message::chat);
initializeMessage(sMsg, msg, outgoing, forwarded, guessing);
QString jid = sMsg.getPenPalJid();
@ -135,13 +127,12 @@ bool Core::MessageHandler::handleChatMessage(const QXmppMessage& msg, bool outgo
}
return true;
}
return false;
}
bool Core::MessageHandler::handleGroupMessage(const QXmppMessage& msg, bool outgoing, bool forwarded, bool guessing) {
const QString& body(msg.body());
if (body.size() != 0) {
if (body.isEmpty())
return false;
Shared::Message sMsg(Shared::Message::groupChat);
initializeMessage(sMsg, msg, outgoing, forwarded, guessing);
@ -150,12 +141,10 @@ bool Core::MessageHandler::handleGroupMessage(const QXmppMessage& msg, bool outg
if (cnt == 0)
return false;
std::tuple<bool, QString, QString> ids = getOriginalPendingMessageId(msg.id());
if (std::get<0>(ids)) {
QMap<QString, QVariant> cData = {{"state", static_cast<uint>(Shared::Message::State::delivered)}};
cnt->changeMessage(std::get<1>(ids), cData);
emit acc->changeMessage(std::get<2>(ids), std::get<1>(ids), cData);
} else {
bool result = adjustPendingMessage(msg.id(), stateDelivered, true);
if (result) //then it was an echo of my own sent message, nothing else needs to be done
return result;
QString oId = msg.replaceId();
if (oId.size() > 0) {
QMap<QString, QVariant> cData = {
@ -167,20 +156,13 @@ bool Core::MessageHandler::handleGroupMessage(const QXmppMessage& msg, bool outg
} else {
cnt->appendMessageToArchive(sMsg);
QDateTime minAgo = QDateTime::currentDateTimeUtc().addSecs(-60);
if (sMsg.getTime() > minAgo) { //otherwise it's considered a delayed delivery, most probably MUC history receipt
if (sMsg.getTime() > minAgo) //otherwise it's considered a delayed delivery, most probably MUC history initial fetch
emit acc->message(sMsg);
} else {
//qDebug() << "Delayed delivery: ";
}
}
}
return true;
}
return false;
}
void Core::MessageHandler::initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing, bool forwarded, bool guessing) const {
const QDateTime& time(source.stamp());
QString id;
@ -254,45 +236,31 @@ void Core::MessageHandler::onCarbonMessageSent(const QXmppMessage& msg) {
}
#endif
std::tuple<bool, QString, QString> Core::MessageHandler::getOriginalPendingMessageId(const QString& id, bool clear) {
std::tuple<bool, QString, QString> result({false, "", ""});
std::optional<Shared::MessageInfo> Core::MessageHandler::getOriginalPendingMessageId(const QString& id, bool clear) {
std::map<QString, QString>::const_iterator itr = pendingStateMessages.find(id);
if (itr != pendingStateMessages.end()) {
std::get<0>(result) = true;
std::get<2>(result) = itr->second;
Shared::MessageInfo info(acc->name, itr->second, itr->first);
std::map<QString, QString>::const_iterator itrC = pendingCorrectionMessages.find(id);
if (itrC != pendingCorrectionMessages.end()) {
if (itrC->second.size() > 0)
std::get<1>(result) = itrC->second;
else
std::get<1>(result) = itr->first;
info.jid = itrC->second;
if (clear)
pendingCorrectionMessages.erase(itrC);
} else {
std::get<1>(result) = itr->first;
}
if (clear)
pendingStateMessages.erase(itr);
return info;
}
return result;
return std::nullopt;
}
void Core::MessageHandler::onReceiptReceived(const QString& jid, const QString& id) {
SHARED_UNUSED(jid);
std::tuple<bool, QString, QString> ids = getOriginalPendingMessageId(id);
if (std::get<0>(ids)) {
QMap<QString, QVariant> cData = {{"state", static_cast<uint>(Shared::Message::State::delivered)}};
RosterItem* ri = acc->rh->getRosterItem(std::get<2>(ids));
if (ri != nullptr)
ri->changeMessage(std::get<1>(ids), cData);
emit acc->changeMessage(std::get<2>(ids), std::get<1>(ids), cData);
}
adjustPendingMessage(id, {{"state", static_cast<uint>(Shared::Message::State::delivered)}}, true);
}
void Core::MessageHandler::sendMessage(const Shared::Message& data, bool newMessage, QString originalId) {
@ -386,19 +354,8 @@ std::pair<Shared::Message::State, QString> Core::MessageHandler::scheduleSending
bool success = acc->client.sendPacket(*encrypted.get());
if (success) {
qDebug() << "Successfully sent an encrypted message";
std::tuple<bool, QString, QString> ids = getOriginalPendingMessageId(id, false);
if (std::get<0>(ids)) {
QString id = std::get<1>(ids);
QString jid = std::get<2>(ids);
RosterItem* ri = acc->rh->getRosterItem(jid);
QMap<QString, QVariant> cData = {{"state", static_cast<uint>(Shared::Message::State::sent)}};
if (ri != nullptr)
ri->changeMessage(id, cData);
emit acc->changeMessage(jid, id, cData);
} else {
if (!adjustPendingMessage(id, stateSent, false))
qDebug() << "Encrypted message has been successfully sent, but it couldn't be found to update the sate";
}
} else {
qDebug() << "Couldn't sent an encrypted message";
handlePendingMessageError(id, "Error sending successfully encrypted message");
@ -425,6 +382,19 @@ std::pair<Shared::Message::State, QString> Core::MessageHandler::scheduleSending
}
}
bool Core::MessageHandler::adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final) {
std::optional<Shared::MessageInfo> info = getOriginalPendingMessageId(messageId, final);
if (info) {
RosterItem* ri = acc->rh->getRosterItem(info->jid);
if (ri != nullptr)
ri->changeMessage(info->messageId, data);
emit acc->changeMessage(info->jid, info->messageId, data);
return true;
}
return false;
}
QMap<QString, QVariant> Core::MessageHandler::getChanges(Shared::Message& data, const QDateTime& time, bool newMessage, const QString& originalId) const {
QMap<QString, QVariant> changes;
@ -481,7 +451,12 @@ QXmppMessage Core::MessageHandler::createPacket(const Shared::Message& data, con
}
void Core::MessageHandler::prepareUpload(const Shared::Message& data, bool newMessage) {
if (acc->state == Shared::ConnectionState::connected) {
if (acc->state != Shared::ConnectionState::connected) {
handleUploadError(data.getPenPalJid(), data.getId(), "Account is offline or reconnecting");
qDebug() << "An attempt to send message with not connected account " << acc->name << ", skipping";
return;
}
QString jid = data.getPenPalJid();
QString id = data.getId();
RosterItem* ri = acc->rh->getRosterItem(jid);
@ -489,24 +464,31 @@ void Core::MessageHandler::prepareUpload(const Shared::Message& data, bool newMe
qDebug() << "An attempt to initialize upload in" << acc->name << "for pal" << jid << "but the object for this pal wasn't found, something went terrebly wrong, skipping send";
return;
}
QString path = data.getAttachPath();
QString url = acc->network->getFileRemoteUrl(path);
if (url.size() != 0) {
sendMessageWithLocalUploadedFile(data, url, newMessage);
} else {
if (url.size() != 0)
return sendMessageWithLocalUploadedFile(data, url, newMessage);
pendingStateMessages.insert(std::make_pair(id, jid));
if (newMessage) {
ri->appendMessageToArchive(data);
} else {
QMap<QString, QVariant> changes({
{"state", (uint)Shared::Message::State::pending}
});
ri->changeMessage(id, changes);
emit acc->changeMessage(jid, id, changes);
ri->changeMessage(id, statePending);
emit acc->changeMessage(jid, id, statePending);
}
//this checks if the file is already uploading, and if so it subscribes to it's success, so, i need to do stuff only if the network knows nothing of this file
if (!acc->network->checkAndAddToUploading(acc->getName(), jid, id, path)) {
if (acc->um->serviceFound()) {
//this checks if the file is already uploading, and if so it subscribes to it's success,
//So, I need to do stuff only if the network knows nothing of this file
if (acc->network->checkAndAddToUploading(acc->getName(), jid, id, path))
return;
if (!acc->um->serviceFound()) {
handleUploadError(jid, id, "Your server doesn't support file upload service, or it's prohibited for your account");
qDebug() << "Requested upload slot in account" << acc->name << "for file" << path << "but upload manager didn't discover any upload services";
return;
}
QFileInfo file(path);
if (file.exists() && file.isReadable()) {
pendingStateMessages.insert(std::make_pair(id, jid));
@ -517,16 +499,6 @@ void Core::MessageHandler::prepareUpload(const Shared::Message& data, bool newMe
handleUploadError(jid, id, "Uploading file no longer exists or your system user has no permission to read it");
qDebug() << "Requested upload slot in account" << acc->name << "for file" << path << "but the file doesn't exist or is not readable";
}
} else {
handleUploadError(jid, id, "Your server doesn't support file upload service, or it's prohibited for your account");
qDebug() << "Requested upload slot in account" << acc->name << "for file" << path << "but upload manager didn't discover any upload services";
}
}
}
} else {
handleUploadError(data.getPenPalJid(), data.getId(), "Account is offline or reconnecting");
qDebug() << "An attempt to send message with not connected account " << acc->name << ", skipping";
}
}
void Core::MessageHandler::onUploadSlotReceived(const QXmppHttpUploadSlotIq& slot) {
@ -565,7 +537,9 @@ void Core::MessageHandler::onDownloadFileComplete(const std::list<Shared::Messag
{"attachPath", path}
};
for (const Shared::MessageInfo& info : msgs) {
if (info.account == acc->getName()) {
if (info.account != acc->getName())
continue;
RosterItem* cnt = acc->rh->getRosterItem(info.jid);
if (cnt != nullptr) {
bool changed = cnt->changeMessage(info.messageId, cData);
@ -573,16 +547,15 @@ void Core::MessageHandler::onDownloadFileComplete(const std::list<Shared::Messag
emit acc->changeMessage(info.jid, info.messageId, cData);
}
}
}
}
void Core::MessageHandler::onLoadFileError(const std::list<Shared::MessageInfo>& msgs, const QString& text, bool up) {
if (up) {
for (const Shared::MessageInfo& info : msgs) {
if (!up)
return;
for (const Shared::MessageInfo& info : msgs)
if (info.account == acc->getName())
handleUploadError(info.jid, info.messageId, text);
}
}
}
void Core::MessageHandler::handleUploadError(const QString& jid, const QString& messageId, const QString& errorText) {
@ -597,7 +570,9 @@ void Core::MessageHandler::handleUploadError(const QString& jid, const QString&
void Core::MessageHandler::onUploadFileComplete(const std::list<Shared::MessageInfo>& msgs, const QString& url, const QString& path) {
for (const Shared::MessageInfo& info : msgs) {
if (info.account == acc->getName()) {
if (info.account != acc->getName())
continue;
RosterItem* ri = acc->rh->getRosterItem(info.jid);
if (ri != nullptr) {
Shared::Message msg = ri->getMessage(info.messageId);
@ -607,7 +582,6 @@ void Core::MessageHandler::onUploadFileComplete(const std::list<Shared::MessageI
qDebug() << "A signal received about complete upload to" << acc->name << "for pal" << info.jid << "but the object for this pal wasn't found, something went terrebly wrong, skipping send";
}
}
}
}
void Core::MessageHandler::sendMessageWithLocalUploadedFile(Shared::Message msg, const QString& url, bool newMessage) {
@ -654,7 +628,7 @@ void Core::MessageHandler::resendMessage(const QString& jid, const QString& id)
try {
Shared::Message msg = cnt->getMessage(id);
if (msg.getState() == Shared::Message::State::error) {
if (msg.getEdited()){
if (msg.getEdited()) {
QString originalId = msg.getId();
msg.generateRandomId();
sendMessage(msg, false, originalId);

View File

@ -23,6 +23,7 @@
#include <deque>
#include <map>
#include <functional>
#include <optional>
#include <QXmppMessage.h>
#include <QXmppHttpUploadIq.h>
@ -71,9 +72,10 @@ private:
void handleUploadError(const QString& jid, const QString& messageId, const QString& errorText);
QXmppMessage createPacket(const Shared::Message& data, const QDateTime& time, const QString& originalId) const;
QMap<QString, QVariant> getChanges(Shared::Message& data, const QDateTime& time, bool newMessage, const QString& originalId) const;
std::tuple<bool, QString, QString> getOriginalPendingMessageId(const QString& id, bool clear = true);
std::optional<Shared::MessageInfo> getOriginalPendingMessageId(const QString& id, bool clear = true);
bool handlePendingMessageError(const QString& id, const QString& errorText);
std::pair<Shared::Message::State, QString> scheduleSending(const Shared::Message& message, const QDateTime& sendTime, const QString& originalId);
bool adjustPendingMessage(const QString& messageId, const QMap<QString, QVariant>& data, bool final);
private:
Account* acc;

View File

@ -54,22 +54,20 @@ QXmppTask<QXmppOmemoStorage::OmemoData> Core::OmemoHandler::allData() {
OmemoData data;
data.ownDevice = ownDevice;
// LMDBAL::Transaction txn = db.beginReadOnlyTransaction(); TODO need to enable transaction after fixing LMDBAL
std::map<uint32_t, QByteArray> pkeys = preKeyPairs->readAll();
for (const std::pair<const uint32_t, QByteArray>& pair : pkeys) {
LMDBAL::Transaction txn = db.beginReadOnlyTransaction();
std::map<uint32_t, QByteArray> pkeys = preKeyPairs->readAll(txn);
for (const std::pair<const uint32_t, QByteArray>& pair : pkeys)
data.preKeyPairs.insert(pair.first, pair.second);
}
std::map<uint32_t, SignedPreKeyPair> spre = signedPreKeyPairs->readAll();
std::map<uint32_t, SignedPreKeyPair> spre = signedPreKeyPairs->readAll(txn);
for (const std::pair<const uint32_t, SignedPreKeyPair>& pair : spre) {
QXmppOmemoStorage::SignedPreKeyPair qxpair = {pair.second.first, pair.second.second};
data.signedPreKeyPairs.insert(pair.first, qxpair);
}
std::map<QString, QHash<uint32_t, Device>> devs = devices->readAll();
for (const std::pair<const QString, QHash<uint32_t, Device>>& pair : devs) {
std::map<QString, QHash<uint32_t, Device>> devs = devices->readAll(txn);
for (const std::pair<const QString, QHash<uint32_t, Device>>& pair : devs)
data.devices.insert(pair.first, pair.second);
}
return Core::makeReadyTask(std::move(data));
}

View File

@ -60,7 +60,6 @@ void Core::RosterHandler::clear() {
conferences.clear();
}
void Core::RosterHandler::onRosterReceived() {
QStringList bj = acc->rm->getRosterBareJids();
for (int i = 0; i < bj.size(); ++i) {
@ -260,7 +259,6 @@ void Core::RosterHandler::onTrustChanged(const QString& jid, const Shared::Trust
emit acc->changeContact(jid, {{"trust", QVariant::fromValue(trust)}});
}
void Core::RosterHandler::addToGroup(const QString& jid, const QString& group) {
std::map<QString, std::set<QString>>::iterator gItr = groups.find(group);
if (gItr == groups.end()) {
@ -288,7 +286,7 @@ void Core::RosterHandler::removeFromGroup(const QString& jid, const QString& gro
}
}
Core::RosterItem * Core::RosterHandler::getRosterItem(const QString& jid) {
Core::RosterItem* Core::RosterHandler::getRosterItem(const QString& jid) {
RosterItem* item = nullptr;
QString lcJid = jid.toLower();
std::map<QString, Contact*>::const_iterator citr = contacts.find(lcJid);
@ -302,7 +300,7 @@ Core::RosterItem * Core::RosterHandler::getRosterItem(const QString& jid) {
return item;
}
Core::Conference * Core::RosterHandler::getConference(const QString& jid) {
Core::Conference* Core::RosterHandler::getConference(const QString& jid) {
Conference* item = 0;
std::map<QString, Conference*>::const_iterator coitr = conferences.find(jid.toLower());
if (coitr != conferences.end())
@ -311,7 +309,7 @@ Core::Conference * Core::RosterHandler::getConference(const QString& jid) {
return item;
}
Core::Contact * Core::RosterHandler::getContact(const QString& jid) {
Core::Contact* Core::RosterHandler::getContact(const QString& jid) {
Contact* item = 0;
std::map<QString, Contact*>::const_iterator citr = contacts.find(jid.toLower());
if (citr != contacts.end())
@ -320,7 +318,7 @@ Core::Contact * Core::RosterHandler::getContact(const QString& jid) {
return item;
}
Core::Contact * Core::RosterHandler::addOutOfRosterContact(const QString& jid) {
Core::Contact* Core::RosterHandler::addOutOfRosterContact(const QString& jid) {
QString lcJid = jid.toLower();
Contact* cnt = new Contact(lcJid, acc->name);
contacts.insert(std::make_pair(lcJid, cnt));
@ -446,9 +444,9 @@ void Core::RosterHandler::clearConferences() {
void Core::RosterHandler::removeRoomRequest(const QString& jid) {
QString lcJid = jid.toLower();
std::map<QString, Conference*>::const_iterator itr = conferences.find(lcJid);
if (itr == conferences.end()) {
if (itr == conferences.end())
qDebug() << "An attempt to remove non existing room" << lcJid << "from account" << acc->name << ", skipping";
}
itr->second->deleteLater();
conferences.erase(itr);
emit acc->removeRoom(lcJid);

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CORE_ROSTERHANDLER_H
#define CORE_ROSTERHANDLER_H
#pragma once
#include <QObject>
#include <QSet>
@ -27,6 +26,7 @@
#include <list>
#include <map>
#include <set>
#include <optional>
#include <QXmppBookmarkSet.h>
#include <QXmppMucManager.h>
@ -45,8 +45,7 @@ namespace Core {
class Account;
class RosterHandler : public QObject
{
class RosterHandler : public QObject {
Q_OBJECT
public:
RosterHandler(Account* account);
@ -119,5 +118,3 @@ private:
};
}
#endif // CORE_ROSTERHANDLER_H

View File

@ -16,16 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_MESSAGEINFO_H
#define SHARED_MESSAGEINFO_H
#pragma once
#include <QString>
namespace Shared {
/**
* @todo write docs
*/
struct MessageInfo {
MessageInfo();
MessageInfo(const QString& acc, const QString& j, const QString& id);
@ -39,5 +34,3 @@ struct MessageInfo {
};
}
#endif // SHARED_MESSAGEINFO_H