squawk/ui/squawk.h

176 lines
8.0 KiB
C
Raw Normal View History

/*
* 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>
#include <QtDBus/QDBusInterface>
#include <QSettings>
#include <QInputDialog>
2019-03-30 20:13:13 +00:00
#include <deque>
2019-04-02 15:46:18 +00:00
#include <map>
#include <set>
#include <list>
2019-03-29 14:54:34 +00:00
2022-04-11 15:45:12 +00:00
#include "widgets/accounts/accounts.h"
#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"
#include "models/roster.h"
#include "widgets/vcard/vcard.h"
2022-01-16 19:54:57 +00:00
#include "widgets/settings/settings.h"
2022-04-03 20:53:46 +00:00
#include "widgets/about.h"
2022-04-11 15:45:12 +00:00
#include "dialogqueue.h"
2021-05-11 17:29:08 +00:00
#include "shared/shared.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>&);
void modifyAccountRequest(const QString&, const QMap<QString, QVariant>&);
2019-05-29 15:05:54 +00:00
void removeAccountRequest(const QString&);
void connectAccount(const QString&);
void disconnectAccount(const QString&);
void changeState(Shared::Availability state);
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);
void resendMessage(const QString& account, const QString& jid, const QString& id);
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
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);
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
void renameContactRequest(const QString& account, const QString& jid, const QString& newName);
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);
void removeRoomRequest(const QString& account, const QString& jid);
void fileDownloadRequest(const QString& url);
void requestVCard(const QString& account, const QString& jid);
void uploadVCard(const QString& account, const Shared::VCard& card);
void responsePassword(const QString& account, const QString& password);
void localPathInvalid(const QString& path);
2022-02-19 18:31:49 +00:00
void changeDownloadsPath(const QString& path);
2019-03-30 20:13:13 +00:00
public slots:
2022-01-25 20:35:55 +00:00
void writeSettings();
void readSettings();
2019-03-30 20:13:13 +00:00
void newAccount(const QMap<QString, QVariant>& account);
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);
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);
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);
void stateChanged(Shared::Availability state);
void accountMessage(const QString& account, const Shared::Message& data);
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last);
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);
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);
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);
void fileUploadComplete(const std::list<Shared::MessageInfo> msgs, const QString& url, const QString& path);
void responseVCard(const QString& jid, const Shared::VCard& card);
void changeMessage(const QString& account, const QString& jid, const QString& id, const QMap<QString, QVariant>& data);
void requestPassword(const QString& account);
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;
2022-01-16 19:54:57 +00:00
Settings* preferences;
2022-04-03 20:53:46 +00:00
About* about;
2022-04-11 15:45:12 +00:00
DialogQueue dialogueQueue;
Models::Roster rosterModel;
2019-04-09 15:04:08 +00:00
Conversations conversations;
QMenu* contextMenu;
QDBusInterface dbus;
std::map<QString, VCard*> vCards;
2020-04-11 20:00:15 +00:00
Conversation* currentConversation;
QModelIndex restoreSelection;
bool needToRestore;
2019-03-29 14:54:34 +00:00
protected:
void closeEvent(QCloseEvent * event) override;
protected slots:
void notify(const QString& account, const Shared::Message& msg);
2019-03-29 14:54:34 +00:00
private slots:
void onAccounts();
2022-01-16 19:54:57 +00:00
void onPreferences();
void onNewContact();
2019-09-04 16:38:52 +00:00
void onNewConference();
void onNewContactAccepted();
2019-09-04 16:38:52 +00:00
void onJoinConferenceAccepted();
void onAccountsSizeChanged(unsigned int size);
2022-01-16 19:54:57 +00:00
void onAccountsClosed();
void onPreferencesClosed();
2019-04-09 15:04:08 +00:00
void onConversationClosed(QObject* parent = 0);
void onVCardClosed();
void onVCardSave(const Shared::VCard& card, const QString& account);
void onActivateVCard(const QString& account, const QString& jid, bool edition = false);
void onComboboxActivated(int index);
2019-04-09 15:04:08 +00:00
void onRosterItemDoubleClicked(const QModelIndex& item);
void onConversationMessage(const Shared::Message& msg);
2022-03-28 20:25:33 +00:00
void onConversationReplaceMessage(const QString& originalId, const Shared::Message& msg);
void onConversationResend(const QString& id);
void onRequestArchive(const QString& account, const QString& jid, const QString& before);
void onRosterContextMenu(const QPoint& point);
void onItemCollepsed(const QModelIndex& index);
2020-04-11 20:00:15 +00:00
void onRosterSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
void onContextAboutToHide();
2022-04-03 20:53:46 +00:00
void onAboutSquawkCalled();
void onAboutSquawkClosed();
void onUnnoticedMessage(const QString& account, const Shared::Message& msg);
private:
2020-04-11 20:00:15 +00:00
void subscribeConversation(Conversation* conv);
2019-03-29 14:54:34 +00:00
};
#endif // SQUAWK_H