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 SQUAWK_H
|
|
|
|
#define SQUAWK_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QCloseEvent>
|
2019-06-18 15:08:03 +00:00
|
|
|
#include <QtDBus/QDBusInterface>
|
2019-03-30 20:13:13 +00:00
|
|
|
#include <deque>
|
2019-04-02 15:46:18 +00:00
|
|
|
#include <map>
|
2019-09-12 20:54:44 +00:00
|
|
|
#include <set>
|
2019-05-15 17:36:37 +00:00
|
|
|
#include <list>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
2019-09-04 16:38:52 +00:00
|
|
|
#include "widgets/accounts.h"
|
2019-08-23 09:51:33 +00:00
|
|
|
#include "widgets/chat.h"
|
2019-08-28 11:40:55 +00:00
|
|
|
#include "widgets/room.h"
|
2019-09-04 16:38:52 +00:00
|
|
|
#include "widgets/newcontact.h"
|
|
|
|
#include "widgets/joinconference.h"
|
2019-03-31 21:05:09 +00:00
|
|
|
#include "models/roster.h"
|
2019-11-02 20:50:25 +00:00
|
|
|
#include "widgets/vcard/vcard.h"
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2019-11-02 20:50:25 +00:00
|
|
|
#include "global.h"
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class Squawk;
|
|
|
|
}
|
|
|
|
|
|
|
|
class Squawk : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit Squawk(QWidget *parent = nullptr);
|
|
|
|
~Squawk() override;
|
2019-03-30 20:13:13 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void newAccountRequest(const QMap<QString, QVariant>&);
|
2019-05-24 14:46:34 +00:00
|
|
|
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
|
2019-05-29 15:05:54 +00:00
|
|
|
void removeAccountRequest(const QString&);
|
2019-03-31 21:05:09 +00:00
|
|
|
void connectAccount(const QString&);
|
|
|
|
void disconnectAccount(const QString&);
|
2019-04-07 20:14:15 +00:00
|
|
|
void changeState(int state);
|
2019-04-11 14:58:59 +00:00
|
|
|
void sendMessage(const QString& account, const Shared::Message& data);
|
2019-09-23 12:09:15 +00:00
|
|
|
void sendMessage(const QString& account, const Shared::Message& data, const QString& path);
|
2019-05-15 17:36:37 +00:00
|
|
|
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
|
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-06-14 16:36:04 +00:00
|
|
|
void removeContactRequest(const QString& account, const QString& jid);
|
2019-06-15 15:29:15 +00:00
|
|
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
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-10-01 08:47:40 +00:00
|
|
|
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
|
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);
|
2019-09-12 20:54:44 +00:00
|
|
|
void fileLocalPathRequest(const QString& messageId, const QString& url);
|
2019-09-17 15:16:09 +00:00
|
|
|
void downloadFileRequest(const QString& messageId, const QString& url);
|
2019-10-22 15:13:56 +00:00
|
|
|
void requestVCard(const QString& account, const QString& jid);
|
2019-10-23 14:49:56 +00:00
|
|
|
void uploadVCard(const QString& account, const Shared::VCard& card);
|
2019-03-30 20:13:13 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void newAccount(const QMap<QString, QVariant>& account);
|
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);
|
2019-04-03 21:23:51 +00:00
|
|
|
void addGroup(const QString& account, const QString& name);
|
|
|
|
void removeGroup(const QString& account, const QString& name);
|
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, const QString& group);
|
|
|
|
void removeContact(const QString& account, const QString& jid);
|
2019-04-07 20:14:15 +00:00
|
|
|
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
|
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);
|
2019-04-07 20:14:15 +00:00
|
|
|
void stateChanged(int state);
|
2019-04-11 14:58:59 +00:00
|
|
|
void accountMessage(const QString& account, const Shared::Message& data);
|
2019-05-15 17:36:37 +00:00
|
|
|
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
|
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-02 11:17:28 +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);
|
2019-09-12 20:54:44 +00:00
|
|
|
void fileLocalPathResponse(const QString& messageId, const QString& path);
|
2019-09-18 13:27:47 +00:00
|
|
|
void downloadFileError(const QString& messageId, const QString& error);
|
2019-09-17 15:16:09 +00:00
|
|
|
void downloadFileProgress(const QString& messageId, qreal value);
|
2019-10-22 15:13:56 +00:00
|
|
|
void responseVCard(const QString& jid, const Shared::VCard& card);
|
2019-03-30 20:13:13 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
private:
|
2019-04-09 15:04:08 +00:00
|
|
|
typedef std::map<Models::Roster::ElId, Conversation*> Conversations;
|
2019-03-29 14:54:34 +00:00
|
|
|
QScopedPointer<Ui::Squawk> m_ui;
|
|
|
|
|
|
|
|
Accounts* accounts;
|
2019-03-31 21:05:09 +00:00
|
|
|
Models::Roster rosterModel;
|
2019-04-09 15:04:08 +00:00
|
|
|
Conversations conversations;
|
2019-06-12 17:18:18 +00:00
|
|
|
QMenu* contextMenu;
|
2019-06-18 15:08:03 +00:00
|
|
|
QDBusInterface dbus;
|
2019-09-12 20:54:44 +00:00
|
|
|
std::map<QString, std::set<Models::Roster::ElId>> requestedFiles;
|
2019-10-22 15:13:56 +00:00
|
|
|
std::map<QString, VCard*> vCards;
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent * event) override;
|
2019-06-18 15:08:03 +00:00
|
|
|
void notify(const QString& account, const Shared::Message& msg);
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onAccounts();
|
2019-06-15 15:29:15 +00:00
|
|
|
void onNewContact();
|
2019-09-04 16:38:52 +00:00
|
|
|
void onNewConference();
|
2019-06-15 15:29:15 +00:00
|
|
|
void onNewContactAccepted();
|
2019-09-04 16:38:52 +00:00
|
|
|
void onJoinConferenceAccepted();
|
2019-06-15 15:29:15 +00:00
|
|
|
void onAccountsSizeChanged(unsigned int size);
|
2019-03-29 14:54:34 +00:00
|
|
|
void onAccountsClosed(QObject* parent = 0);
|
2019-04-09 15:04:08 +00:00
|
|
|
void onConversationClosed(QObject* parent = 0);
|
2019-10-22 15:13:56 +00:00
|
|
|
void onVCardClosed();
|
2019-10-23 14:49:56 +00:00
|
|
|
void onVCardSave(const Shared::VCard& card, const QString& account);
|
2019-10-22 15:13:56 +00:00
|
|
|
void onActivateVCard(const QString& account, const QString& jid, bool edition = false);
|
2019-03-31 21:05:09 +00:00
|
|
|
void onComboboxActivated(int index);
|
2019-04-09 15:04:08 +00:00
|
|
|
void onRosterItemDoubleClicked(const QModelIndex& item);
|
2019-04-11 14:58:59 +00:00
|
|
|
void onConversationMessage(const Shared::Message& msg);
|
2019-09-23 12:09:15 +00:00
|
|
|
void onConversationMessage(const Shared::Message& msg, const QString& path);
|
2019-05-15 17:36:37 +00:00
|
|
|
void onConversationRequestArchive(const QString& before);
|
2019-06-12 17:18:18 +00:00
|
|
|
void onRosterContextMenu(const QPoint& point);
|
2019-06-18 15:08:03 +00:00
|
|
|
void onConversationShown();
|
2019-09-12 20:54:44 +00:00
|
|
|
void onConversationRequestLocalFile(const QString& messageId, const QString& url);
|
|
|
|
void onConversationDownloadFile(const QString& messageId, const QString& url);
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SQUAWK_H
|