forked from blue/squawk
icon and tooltip information in participants, saving bookmarks, subscription and unsubscription, deletion of MUCs
This commit is contained in:
parent
5547d78608
commit
5f8d38bd9a
19 changed files with 216 additions and 9 deletions
|
@ -118,6 +118,7 @@ void Core::Account::disconnect()
|
|||
{
|
||||
reconnectTimes = 0;
|
||||
if (state != Shared::disconnected) {
|
||||
clearConferences();
|
||||
client.disconnectFromServer();
|
||||
state = Shared::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
|
@ -138,14 +139,16 @@ void Core::Account::onClientConnected()
|
|||
|
||||
void Core::Account::onClientDisconnected()
|
||||
{
|
||||
clearConferences();
|
||||
if (state != Shared::disconnected) {
|
||||
if (reconnectTimes > 0) {
|
||||
qDebug() << "Account" << name << "is reconnecting for" << reconnectTimes << "more times";
|
||||
--reconnectTimes;
|
||||
qDebug() << "Reconnecting...";
|
||||
state = Shared::connecting;
|
||||
client.connectToServer(config, presence);
|
||||
emit connectionStateChanged(state);
|
||||
} else {
|
||||
qDebug() << "Account" << name << "has been disconnected";
|
||||
state = Shared::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
|
@ -312,6 +315,7 @@ void Core::Account::handleNewConference(Core::Conference* contact)
|
|||
{
|
||||
handleNewRosterItem(contact);
|
||||
QObject::connect(contact, SIGNAL(nickChanged(const QString&)), this, SLOT(onMucNickNameChanged(const QString&)));
|
||||
QObject::connect(contact, SIGNAL(subjectChanged(const QString&)), this, SLOT(onMucSubjectChanged(const QString&)));
|
||||
QObject::connect(contact, SIGNAL(joinedChanged(bool)), this, SLOT(onMucJoinedChanged(bool)));
|
||||
QObject::connect(contact, SIGNAL(autoJoinChanged(bool)), this, SLOT(onMucAutoJoinChanged(bool)));
|
||||
QObject::connect(contact, SIGNAL(addParticipant(const QString&, const QMap<QString, QVariant>&)),
|
||||
|
@ -1027,6 +1031,7 @@ void Core::Account::onMucJoinedChanged(bool joined)
|
|||
|
||||
void Core::Account::onMucAutoJoinChanged(bool autoJoin)
|
||||
{
|
||||
storeConferences();
|
||||
Conference* room = static_cast<Conference*>(sender());
|
||||
emit changeRoom(room->jid, {
|
||||
{"autoJoin", autoJoin}
|
||||
|
@ -1035,6 +1040,7 @@ void Core::Account::onMucAutoJoinChanged(bool autoJoin)
|
|||
|
||||
void Core::Account::onMucNickNameChanged(const QString& nickName)
|
||||
{
|
||||
storeConferences();
|
||||
Conference* room = static_cast<Conference*>(sender());
|
||||
emit changeRoom(room->jid, {
|
||||
{"nick", nickName}
|
||||
|
@ -1080,3 +1086,53 @@ void Core::Account::onMucRemoveParticipant(const QString& nickName)
|
|||
Conference* room = static_cast<Conference*>(sender());
|
||||
emit removeRoomParticipant(room->jid, nickName);
|
||||
}
|
||||
|
||||
void Core::Account::onMucSubjectChanged(const QString& subject)
|
||||
{
|
||||
Conference* room = static_cast<Conference*>(sender());
|
||||
emit changeRoom(room->jid, {
|
||||
{"subject", subject}
|
||||
});
|
||||
}
|
||||
|
||||
void Core::Account::storeConferences()
|
||||
{
|
||||
QXmppBookmarkSet bms = bm->bookmarks();
|
||||
QList<QXmppBookmarkConference> confs;
|
||||
for (std::map<QString, Conference*>::const_iterator itr = conferences.begin(), end = conferences.end(); itr != end; ++itr) {
|
||||
Conference* conference = itr->second;
|
||||
QXmppBookmarkConference conf;
|
||||
conf.setJid(conference->jid);
|
||||
conf.setName(conference->getName());
|
||||
conf.setNickName(conference->getNick());
|
||||
conf.setAutoJoin(conference->getAutoJoin());
|
||||
confs.push_back(conf);
|
||||
}
|
||||
bms.setConferences(confs);
|
||||
bm->setBookmarks(bms);
|
||||
}
|
||||
|
||||
void Core::Account::clearConferences()
|
||||
{
|
||||
for (std::map<QString, Conference*>::const_iterator itr = conferences.begin(), end = conferences.end(); itr != end; itr++) {
|
||||
itr->second->deleteLater();
|
||||
emit removeRoom(itr->first);
|
||||
}
|
||||
conferences.clear();
|
||||
}
|
||||
|
||||
void Core::Account::removeRoomRequest(const QString& jid)
|
||||
{
|
||||
std::map<QString, Conference*>::const_iterator itr = conferences.find(jid);
|
||||
if (itr == conferences.end()) {
|
||||
qDebug() << "An attempt to remove non existing room" << jid << "from account" << name << ", skipping";
|
||||
}
|
||||
itr->second->deleteLater();
|
||||
conferences.erase(itr);
|
||||
emit removeRoom(jid);
|
||||
storeConferences();
|
||||
}
|
||||
|
||||
void Core::Account::addRoomRequest(const QString& jid, const QString& nick, bool autoJoin)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ public:
|
|||
|
||||
void setRoomJoined(const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& jid, bool joined);
|
||||
void removeRoomRequest(const QString& jid);
|
||||
void addRoomRequest(const QString& jid, const QString& nick, bool autoJoin);
|
||||
|
||||
signals:
|
||||
void connectionStateChanged(int);
|
||||
|
@ -139,6 +141,7 @@ private slots:
|
|||
void onMucJoinedChanged(bool joined);
|
||||
void onMucAutoJoinChanged(bool autoJoin);
|
||||
void onMucNickNameChanged(const QString& nickName);
|
||||
void onMucSubjectChanged(const QString& subject);
|
||||
void onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
||||
void onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
||||
void onMucRemoveParticipant(const QString& nickName);
|
||||
|
@ -166,6 +169,8 @@ private:
|
|||
void initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing = false, bool forwarded = false, bool guessing = false) const;
|
||||
Shared::SubscriptionState castSubscriptionState(QXmppRosterIq::Item::SubscriptionType qs) const;
|
||||
void logMessage(const QXmppMessage& msg, const QString& reason = "Message wasn't handled: ");
|
||||
void storeConferences();
|
||||
void clearConferences();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
|
|||
connect(room, SIGNAL(joined()), this, SLOT(onRoomJoined()));
|
||||
connect(room, SIGNAL(left()), this, SLOT(onRoomLeft()));
|
||||
connect(room, SIGNAL(nameChanged(const QString&)), this, SLOT(onRoomNameChanged(const QString&)));
|
||||
connect(room, SIGNAL(subjectChanged(const QString&)), this, SLOT(onRoomSubjectChanged(const QString&)));
|
||||
connect(room, SIGNAL(participantAdded(const QString&)), this, SLOT(onRoomParticipantAdded(const QString&)));
|
||||
connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&)));
|
||||
connect(room, SIGNAL(participantRemoved(const QString&)), this, SLOT(onRoomParticipantRemoved(const QString&)));
|
||||
|
@ -47,6 +48,10 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
|
|||
|
||||
Core::Conference::~Conference()
|
||||
{
|
||||
if (joined) {
|
||||
room->leave();
|
||||
}
|
||||
room->deleteLater();
|
||||
}
|
||||
|
||||
QString Core::Conference::getNick() const
|
||||
|
@ -183,3 +188,17 @@ void Core::Conference::onRoomParticipantRemoved(const QString& p_name)
|
|||
emit removeParticipant(resource);
|
||||
}
|
||||
}
|
||||
|
||||
QString Core::Conference::getSubject() const
|
||||
{
|
||||
if (joined) {
|
||||
return room->subject();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Conference::onRoomSubjectChanged(const QString& p_name)
|
||||
{
|
||||
emit subjectChanged(p_name);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
~Conference();
|
||||
|
||||
QString getNick() const;
|
||||
QString getSubject() const;
|
||||
void setNick(const QString& p_nick);
|
||||
|
||||
bool getJoined() const;
|
||||
|
@ -48,6 +49,7 @@ signals:
|
|||
void nickChanged(const QString& nick);
|
||||
void joinedChanged(bool joined);
|
||||
void autoJoinChanged(bool autoJoin);
|
||||
void subjectChanged(const QString& subject);
|
||||
void addParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
||||
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
||||
void removeParticipant(const QString& name);
|
||||
|
@ -62,6 +64,7 @@ private slots:
|
|||
void onRoomJoined();
|
||||
void onRoomLeft();
|
||||
void onRoomNameChanged(const QString& p_name);
|
||||
void onRoomSubjectChanged(const QString& p_name);
|
||||
void onRoomNickNameChanged(const QString& p_nick);
|
||||
void onRoomError(const QXmppStanza::Error& err);
|
||||
void onRoomParticipantAdded(const QString& p_name);
|
||||
|
|
|
@ -464,3 +464,13 @@ void Core::Squawk::onAccountRemoveRoomPresence(const QString& jid, const QString
|
|||
Account* acc = static_cast<Account*>(sender());
|
||||
emit removeRoomParticipant(acc->getName(), jid, nick);
|
||||
}
|
||||
|
||||
void Core::Squawk::removeRoomRequest(const QString& account, const QString& jid)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to remove the room" << jid << "of non existing account" << account << ", skipping";
|
||||
return;
|
||||
}
|
||||
itr->second->removeRoomRequest(jid);
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ public slots:
|
|||
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);
|
||||
void removeRoomRequest(const QString& account, const QString& jid);
|
||||
|
||||
private:
|
||||
typedef std::deque<Account*> Accounts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue