2019-08-14 14:54:46 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
#ifndef CORE_SQUAWK_H
|
|
|
|
#define CORE_SQUAWK_H
|
|
|
|
|
2019-09-17 15:16:09 +00:00
|
|
|
#include <QObject>
|
2019-03-30 20:13:13 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QMap>
|
2019-10-16 19:38:35 +00:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
2019-03-31 21:05:09 +00:00
|
|
|
#include <deque>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
#include "account.h"
|
2020-04-03 22:28:15 +00:00
|
|
|
#include "shared/enums.h"
|
|
|
|
#include "shared/message.h"
|
|
|
|
#include "shared/global.h"
|
2023-02-20 18:12:32 +00:00
|
|
|
#include "shared/info.h"
|
2022-08-19 21:28:59 +00:00
|
|
|
#include "shared/clientinfo.h"
|
2022-08-22 20:29:43 +00:00
|
|
|
|
|
|
|
#include <core/components/clientcache.h>
|
|
|
|
#include <core/components/networkaccess.h>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
2020-04-10 22:15:08 +00:00
|
|
|
#ifdef WITH_KWALLET
|
2020-04-09 22:48:08 +00:00
|
|
|
#include "passwordStorageEngines/kwallet.h"
|
2020-04-10 22:15:08 +00:00
|
|
|
#endif
|
2020-04-09 22:48:08 +00:00
|
|
|
|
2024-10-27 17:31:47 +00:00
|
|
|
namespace Core {
|
|
|
|
class Squawk : public QObject {
|
2019-03-29 14:54:34 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Squawk(QObject* parent = 0);
|
|
|
|
~Squawk();
|
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
signals:
|
2019-04-02 21:58:43 +00:00
|
|
|
void quit();
|
2020-04-04 16:40:32 +00:00
|
|
|
void ready();
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
void newAccount(const QMap<QString, QVariant>&);
|
2019-05-24 14:46:34 +00:00
|
|
|
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
2019-05-29 15:05:54 +00:00
|
|
|
void removeAccount(const QString& account);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-04-03 21:23:51 +00:00
|
|
|
void addGroup(const QString& account, const QString& name);
|
|
|
|
void removeGroup(const QString& account, const QString& name);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-04-07 20:14:15 +00:00
|
|
|
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
2019-04-06 10:14:32 +00:00
|
|
|
void removeContact(const QString& account, const QString& jid);
|
|
|
|
void removeContact(const QString& account, const QString& jid, const QString& group);
|
2019-04-07 20:14:15 +00:00
|
|
|
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removePresence(const QString& account, const QString& jid, const QString& name);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
void stateChanged(Shared::Availability state);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-04-11 14:58:59 +00:00
|
|
|
void accountMessage(const QString& account, const Shared::Message& data);
|
2020-08-21 20:57:48 +00:00
|
|
|
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-07-11 08:51:52 +00:00
|
|
|
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
|
|
|
void changeRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
|
|
|
void removeRoom(const QString& account, const QString jid);
|
2019-09-01 19:46:12 +00:00
|
|
|
void addRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void changeRoomParticipant(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removeRoomParticipant(const QString& account, const QString& jid, const QString& name);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
|
|
|
void fileError(const std::list<Shared::MessageInfo> msgs, const QString& error, bool up);
|
|
|
|
void fileProgress(const std::list<Shared::MessageInfo> msgs, qreal value, bool up);
|
|
|
|
void fileDownloadComplete(const std::list<Shared::MessageInfo> msgs, const QString& path);
|
2021-10-15 16:20:31 +00:00
|
|
|
void fileUploadComplete(const std::list<Shared::MessageInfo> msgs, const QString& url, const QString& path);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2023-02-20 18:12:32 +00:00
|
|
|
void responseInfo(const Shared::Info& info);
|
2020-03-25 15:28:36 +00:00
|
|
|
void changeMessage(const QString& account, const QString& jid, const QString& id, const QMap<QString, QVariant>& data);
|
2022-04-14 08:13:27 +00:00
|
|
|
void requestPassword(const QString& account, bool authernticationError);
|
2019-03-30 20:13:13 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void start();
|
2019-04-02 21:58:43 +00:00
|
|
|
void stop();
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-03-30 20:13:13 +00:00
|
|
|
void newAccountRequest(const QMap<QString, QVariant>& map);
|
2019-05-24 14:46:34 +00:00
|
|
|
void modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map);
|
2019-05-29 15:05:54 +00:00
|
|
|
void removeAccountRequest(const QString& name);
|
2019-03-31 21:05:09 +00:00
|
|
|
void connectAccount(const QString& account);
|
|
|
|
void disconnectAccount(const QString& account);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
void changeState(Shared::Availability state);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-04-11 14:58:59 +00:00
|
|
|
void sendMessage(const QString& account, const Shared::Message& data);
|
2022-03-28 20:25:33 +00:00
|
|
|
void replaceMessage(const QString& account, const QString& originalId, const Shared::Message& data);
|
2021-05-22 22:03:14 +00:00
|
|
|
void resendMessage(const QString& account, const QString& jid, const QString& id);
|
2019-05-15 17:36:37 +00:00
|
|
|
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-06-12 17:18:18 +00:00
|
|
|
void subscribeContact(const QString& account, const QString& jid, const QString& reason);
|
|
|
|
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
2019-09-28 14:30:16 +00:00
|
|
|
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
|
|
|
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
2019-06-14 16:36:04 +00:00
|
|
|
void removeContactRequest(const QString& account, const QString& jid);
|
2019-10-01 08:47:40 +00:00
|
|
|
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
2019-06-15 15:29:15 +00:00
|
|
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
2023-11-05 01:12:15 +00:00
|
|
|
void setContactEncryption(const QString& account, const QString& jid, Shared::EncryptionProtocol value);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
2019-08-29 14:19:35 +00:00
|
|
|
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
|
|
|
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
2019-09-04 16:38:52 +00:00
|
|
|
void addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
2019-09-03 20:28:58 +00:00
|
|
|
void removeRoomRequest(const QString& account, const QString& jid);
|
2021-04-18 12:49:20 +00:00
|
|
|
|
|
|
|
void fileDownloadRequest(const QString& url);
|
|
|
|
|
2023-02-20 18:12:32 +00:00
|
|
|
void requestInfo(const QString& account, const QString& jid);
|
|
|
|
void updateInfo(const QString& account, const Shared::Info& info);
|
2020-04-07 20:33:03 +00:00
|
|
|
void responsePassword(const QString& account, const QString& password);
|
2021-04-28 20:26:19 +00:00
|
|
|
void onLocalPathInvalid(const QString& path);
|
2022-02-19 18:31:49 +00:00
|
|
|
void changeDownloadsPath(const QString& path);
|
2019-03-30 20:13:13 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
private:
|
2019-03-30 20:13:13 +00:00
|
|
|
typedef std::deque<Account*> Accounts;
|
2019-03-31 21:05:09 +00:00
|
|
|
typedef std::map<QString, Account*> AccountsMap;
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
Accounts accounts;
|
2019-03-31 21:05:09 +00:00
|
|
|
AccountsMap amap;
|
2019-04-07 20:14:15 +00:00
|
|
|
Shared::Availability state;
|
2019-09-17 15:16:09 +00:00
|
|
|
NetworkAccess network;
|
2021-10-06 14:52:20 +00:00
|
|
|
bool isInitialized;
|
2022-08-22 20:29:43 +00:00
|
|
|
ClientCache clientCache;
|
2020-04-10 22:15:08 +00:00
|
|
|
|
|
|
|
#ifdef WITH_KWALLET
|
2020-04-09 22:48:08 +00:00
|
|
|
PSE::KWallet kwallet;
|
2020-04-10 22:15:08 +00:00
|
|
|
#endif
|
2019-03-31 21:05:09 +00:00
|
|
|
|
|
|
|
private slots:
|
2020-04-04 16:40:32 +00:00
|
|
|
void addAccount(
|
|
|
|
const QString& login,
|
|
|
|
const QString& server,
|
|
|
|
const QString& password,
|
|
|
|
const QString& name,
|
|
|
|
const QString& resource,
|
2022-04-12 20:33:10 +00:00
|
|
|
bool active,
|
2020-04-04 16:40:32 +00:00
|
|
|
Shared::AccountPassword passwordType
|
|
|
|
);
|
|
|
|
|
2020-04-03 22:28:15 +00:00
|
|
|
void onAccountConnectionStateChanged(Shared::ConnectionState state);
|
|
|
|
void onAccountAvailabilityChanged(Shared::Availability state);
|
2019-10-16 19:38:35 +00:00
|
|
|
void onAccountChanged(const QMap<QString, QVariant>& data);
|
2019-04-03 21:23:51 +00:00
|
|
|
void onAccountAddGroup(const QString& name);
|
2019-05-24 14:46:34 +00:00
|
|
|
void onAccountError(const QString& text);
|
2019-04-03 21:23:51 +00:00
|
|
|
void onAccountRemoveGroup(const QString& name);
|
2019-04-07 20:14:15 +00:00
|
|
|
void onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
2019-04-06 10:14:32 +00:00
|
|
|
void onAccountRemoveContact(const QString& jid);
|
|
|
|
void onAccountRemoveContact(const QString& jid, const QString& group);
|
2019-04-07 20:14:15 +00:00
|
|
|
void onAccountChangeContact(const QString& jid, const QMap<QString, QVariant>& data);
|
2019-04-07 14:02:41 +00:00
|
|
|
void onAccountAddPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void onAccountRemovePresence(const QString& jid, const QString& name);
|
2019-04-11 14:58:59 +00:00
|
|
|
void onAccountMessage(const Shared::Message& data);
|
2020-08-21 20:57:48 +00:00
|
|
|
void onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last);
|
2019-07-11 08:51:52 +00:00
|
|
|
void onAccountAddRoom(const QString jid, const QMap<QString, QVariant>& data);
|
|
|
|
void onAccountChangeRoom(const QString jid, const QMap<QString, QVariant>& data);
|
|
|
|
void onAccountRemoveRoom(const QString jid);
|
2019-09-01 19:46:12 +00:00
|
|
|
void onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data);
|
|
|
|
void onAccountChangeRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data);
|
|
|
|
void onAccountRemoveRoomPresence(const QString& jid, const QString& nick);
|
2020-03-25 15:28:36 +00:00
|
|
|
void onAccountChangeMessage(const QString& jid, const QString& id, const QMap<QString, QVariant>& data);
|
2022-04-12 20:33:10 +00:00
|
|
|
void onAccountNeedPassword();
|
2020-04-04 16:40:32 +00:00
|
|
|
|
2021-04-18 12:49:20 +00:00
|
|
|
void onAccountUploadFileError(const QString& jid, const QString id, const QString& errorText);
|
|
|
|
|
2020-04-09 22:48:08 +00:00
|
|
|
void onWalletOpened(bool success);
|
|
|
|
void onWalletRejectPassword(const QString& login);
|
2022-08-22 20:29:43 +00:00
|
|
|
|
2022-08-24 22:41:06 +00:00
|
|
|
void onAccountInfoDiscovered(const QString& address, const QString& node, const std::set<Shared::Identity>& identities, const std::set<QString>& features);
|
2020-04-09 22:48:08 +00:00
|
|
|
|
2020-04-04 16:40:32 +00:00
|
|
|
private:
|
|
|
|
void readSettings();
|
2020-04-07 20:33:03 +00:00
|
|
|
|
|
|
|
static const quint64 passwordHash = 0x08d054225ac4871d;
|
2019-03-29 14:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CORE_SQUAWK_H
|