forked from blue/squawk
joining groups on opening them, leaving on closing
This commit is contained in:
parent
023494de0b
commit
a51907b810
@ -1033,3 +1033,25 @@ void Core::Account::onMucNickNameChanged(const QString& nickName)
|
|||||||
{"nick", nickName}
|
{"nick", nickName}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Account::setRoomAutoJoin(const QString& jid, bool joined)
|
||||||
|
{
|
||||||
|
std::map<QString, Conference*>::const_iterator cItr = conferences.find(jid);
|
||||||
|
if (cItr == conferences.end()) {
|
||||||
|
qDebug() << "An attempt to set auto join to the non existing room" << jid << "of the account" << getName() << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cItr->second->setAutoJoin(joined);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Core::Account::setRoomJoined(const QString& jid, bool joined)
|
||||||
|
{
|
||||||
|
std::map<QString, Conference*>::const_iterator cItr = conferences.find(jid);
|
||||||
|
if (cItr == conferences.end()) {
|
||||||
|
qDebug() << "An attempt to set joined to the non existing room" << jid << "of the account" << getName() << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cItr->second->setJoined(joined);
|
||||||
|
}
|
||||||
|
@ -71,6 +71,9 @@ public:
|
|||||||
void removeContactRequest(const QString& jid);
|
void removeContactRequest(const QString& jid);
|
||||||
void addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups);
|
void addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||||
|
|
||||||
|
void setRoomJoined(const QString& jid, bool joined);
|
||||||
|
void setRoomAutoJoin(const QString& jid, bool joined);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectionStateChanged(int);
|
void connectionStateChanged(int);
|
||||||
void availabilityChanged(int);
|
void availabilityChanged(int);
|
||||||
|
@ -419,3 +419,24 @@ void Core::Squawk::onAccountRemoveRoom(const QString jid)
|
|||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeRoom(acc->getName(), jid);
|
emit removeRoom(acc->getName(), jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Squawk::setRoomJoined(const QString& account, const QString& jid, bool joined)
|
||||||
|
{
|
||||||
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
|
if (itr == amap.end()) {
|
||||||
|
qDebug() << "An attempt to set autoJoin to the room" << jid << "of non existing account" << account << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
itr->second->setRoomJoined(jid, joined);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, bool joined)
|
||||||
|
{
|
||||||
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
|
if (itr == amap.end()) {
|
||||||
|
qDebug() << "An attempt to set autoJoin to the room" << jid << "of non existing account" << account << ", skipping";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
itr->second->setRoomAutoJoin(jid, joined);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -74,6 +74,8 @@ public slots:
|
|||||||
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||||
void removeContactRequest(const QString& account, const QString& jid);
|
void removeContactRequest(const QString& account, const QString& jid);
|
||||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||||
|
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||||
|
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::deque<Account*> Accounts;
|
typedef std::deque<Account*> Accounts;
|
||||||
|
3
main.cpp
3
main.cpp
@ -81,6 +81,9 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(&w, SIGNAL(removeContactRequest(const QString&, const QString&)),
|
QObject::connect(&w, SIGNAL(removeContactRequest(const QString&, const QString&)),
|
||||||
squawk, SLOT(removeContactRequest(const QString&, const QString&)));
|
squawk, SLOT(removeContactRequest(const QString&, const QString&)));
|
||||||
|
|
||||||
|
QObject::connect(&w, SIGNAL(setRoomJoined(const QString&, const QString&, bool)), squawk, SLOT(setRoomJoined(const QString&, const QString&, bool)));
|
||||||
|
QObject::connect(&w, SIGNAL(setRoomAutoJoin(const QString&, const QString&, bool)), squawk, SLOT(setRoomAutoJoin(const QString&, const QString&, bool)));
|
||||||
|
|
||||||
QObject::connect(squawk, SIGNAL(newAccount(const QMap<QString, QVariant>&)), &w, SLOT(newAccount(const QMap<QString, QVariant>&)));
|
QObject::connect(squawk, SIGNAL(newAccount(const QMap<QString, QVariant>&)), &w, SLOT(newAccount(const QMap<QString, QVariant>&)));
|
||||||
QObject::connect(squawk, SIGNAL(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
QObject::connect(squawk, SIGNAL(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)),
|
||||||
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
&w, SLOT(addContact(const QString&, const QString&, const QString&, const QMap<QString, QVariant>&)));
|
||||||
|
@ -247,6 +247,10 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
|
|||||||
} else if (room != 0) {
|
} else if (room != 0) {
|
||||||
created = true;
|
created = true;
|
||||||
conv = new Room(room);
|
conv = new Room(room);
|
||||||
|
|
||||||
|
if (!room->getJoined()) {
|
||||||
|
emit setRoomJoined(id->account, id->name, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conv != 0) {
|
if (conv != 0) {
|
||||||
@ -283,11 +287,18 @@ void Squawk::onConversationShown()
|
|||||||
void Squawk::onConversationClosed(QObject* parent)
|
void Squawk::onConversationClosed(QObject* parent)
|
||||||
{
|
{
|
||||||
Conversation* conv = static_cast<Conversation*>(sender());
|
Conversation* conv = static_cast<Conversation*>(sender());
|
||||||
Conversations::const_iterator itr = conversations.find({conv->getAccount(), conv->getJid()});
|
Models::Roster::ElId id(conv->getAccount(), conv->getJid());
|
||||||
|
Conversations::const_iterator itr = conversations.find(id);
|
||||||
if (itr == conversations.end()) {
|
if (itr == conversations.end()) {
|
||||||
qDebug() << "Conversation has been closed but can not be found among other opened conversations, application is most probably going to crash";
|
qDebug() << "Conversation has been closed but can not be found among other opened conversations, application is most probably going to crash";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (conv->isMuc) {
|
||||||
|
Room* room = static_cast<Room*>(conv);
|
||||||
|
if (room->autoJoined()) {
|
||||||
|
emit setRoomJoined(id.account, id.name, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
conversations.erase(itr);
|
conversations.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,8 @@ signals:
|
|||||||
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
|
||||||
void removeContactRequest(const QString& account, const QString& jid);
|
void removeContactRequest(const QString& account, const QString& jid);
|
||||||
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||||
|
void setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||||
|
void setRoomAutoJoin(const QString& account, const QString& jid, bool joined);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newAccount(const QMap<QString, QVariant>& account);
|
void newAccount(const QMap<QString, QVariant>& account);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "chat.h"
|
#include "chat.h"
|
||||||
|
|
||||||
Chat::Chat(Models::Contact* p_contact, QWidget* parent):
|
Chat::Chat(Models::Contact* p_contact, QWidget* parent):
|
||||||
Conversation(p_contact->getAccountJid(), p_contact->getAccountResource(), p_contact->getJid(), "", p_contact->getAccountName(), parent),
|
Conversation(false, p_contact->getAccountJid(), p_contact->getAccountResource(), p_contact->getJid(), "", p_contact->getAccountName(), parent),
|
||||||
contact(p_contact)
|
contact(p_contact)
|
||||||
{
|
{
|
||||||
setName(p_contact->getContactName());
|
setName(p_contact->getContactName());
|
||||||
|
@ -24,14 +24,15 @@
|
|||||||
#include <QGraphicsDropShadowEffect>
|
#include <QGraphicsDropShadowEffect>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
Conversation::Conversation(const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent):
|
Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
isMuc(muc),
|
||||||
myJid(mJid),
|
myJid(mJid),
|
||||||
myResource(mRes),
|
myResource(mRes),
|
||||||
palJid(pJid),
|
palJid(pJid),
|
||||||
activePalResource(pRes),
|
activePalResource(pRes),
|
||||||
account(acc),
|
account(acc),
|
||||||
line(new MessageLine()),
|
line(new MessageLine(muc)),
|
||||||
m_ui(new Ui::Conversation()),
|
m_ui(new Ui::Conversation()),
|
||||||
ker(),
|
ker(),
|
||||||
thread(),
|
thread(),
|
||||||
|
@ -46,7 +46,7 @@ class Conversation : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Conversation(const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent = 0);
|
Conversation(bool muc, const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent = 0);
|
||||||
~Conversation();
|
~Conversation();
|
||||||
|
|
||||||
QString getJid() const;
|
QString getJid() const;
|
||||||
@ -75,6 +75,9 @@ protected slots:
|
|||||||
void onAttach();
|
void onAttach();
|
||||||
void onFileSelected();
|
void onFileSelected();
|
||||||
|
|
||||||
|
public:
|
||||||
|
const bool isMuc;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum Scroll {
|
enum Scroll {
|
||||||
nothing,
|
nothing,
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
const QRegExp urlReg("^(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
const QRegExp urlReg("^(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
|
||||||
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
|
||||||
|
|
||||||
MessageLine::MessageLine(QWidget* parent):
|
MessageLine::MessageLine(bool p_room, QWidget* parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
messageIndex(),
|
messageIndex(),
|
||||||
messageOrder(),
|
messageOrder(),
|
||||||
@ -31,7 +31,7 @@ MessageLine::MessageLine(QWidget* parent):
|
|||||||
myName(),
|
myName(),
|
||||||
palNames(),
|
palNames(),
|
||||||
views(),
|
views(),
|
||||||
room(false)
|
room(p_room)
|
||||||
{
|
{
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
setBackgroundRole(QPalette::Base);
|
setBackgroundRole(QPalette::Base);
|
||||||
@ -45,11 +45,6 @@ MessageLine::~MessageLine()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLine::setRoom(bool p_room)
|
|
||||||
{
|
|
||||||
room = p_room;
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
MessageLine::Position MessageLine::message(const Shared::Message& msg)
|
||||||
{
|
{
|
||||||
QString id = msg.getId();
|
QString id = msg.getId();
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
end,
|
end,
|
||||||
invalid
|
invalid
|
||||||
};
|
};
|
||||||
MessageLine(QWidget* parent = 0);
|
MessageLine(bool p_room, QWidget* parent = 0);
|
||||||
~MessageLine();
|
~MessageLine();
|
||||||
|
|
||||||
Position message(const Shared::Message& msg);
|
Position message(const Shared::Message& msg);
|
||||||
@ -45,7 +45,6 @@ public:
|
|||||||
QString firstMessageId() const;
|
QString firstMessageId() const;
|
||||||
void showBusyIndicator();
|
void showBusyIndicator();
|
||||||
void hideBusyIndicator();
|
void hideBusyIndicator();
|
||||||
void setRoom(bool p_room);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void resize(int amount);
|
void resize(int amount);
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
#include "room.h"
|
#include "room.h"
|
||||||
|
|
||||||
Room::Room(Models::Room* p_room, QWidget* parent):
|
Room::Room(Models::Room* p_room, QWidget* parent):
|
||||||
Conversation(p_room->getAccountJid(), p_room->getAccountResource(), p_room->getJid(), "", p_room->getAccountName(), parent),
|
Conversation(true, p_room->getAccountJid(), p_room->getAccountResource(), p_room->getJid(), "", p_room->getAccountName(), parent),
|
||||||
room(p_room)
|
room(p_room)
|
||||||
{
|
{
|
||||||
setName(p_room->getName());
|
setName(p_room->getName());
|
||||||
line->setMyName(room->getNick());
|
line->setMyName(room->getNick());
|
||||||
line->setRoom(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Room::~Room()
|
Room::~Room()
|
||||||
@ -44,3 +43,8 @@ void Room::handleSendMessage(const QString& text)
|
|||||||
msg.setCurrentTime();
|
msg.setCurrentTime();
|
||||||
emit sendMessage(msg);
|
emit sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Room::autoJoined() const
|
||||||
|
{
|
||||||
|
return room->getAutoJoin();
|
||||||
|
}
|
||||||
|
@ -32,6 +32,8 @@ public:
|
|||||||
Room(Models::Room* p_room, QWidget* parent = 0);
|
Room(Models::Room* p_room, QWidget* parent = 0);
|
||||||
~Room();
|
~Room();
|
||||||
|
|
||||||
|
bool autoJoined() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void handleSendMessage(const QString & text) override;
|
void handleSendMessage(const QString & text) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user