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
@ -118,6 +118,7 @@ void Core::Account::disconnect()
|
|||||||
{
|
{
|
||||||
reconnectTimes = 0;
|
reconnectTimes = 0;
|
||||||
if (state != Shared::disconnected) {
|
if (state != Shared::disconnected) {
|
||||||
|
clearConferences();
|
||||||
client.disconnectFromServer();
|
client.disconnectFromServer();
|
||||||
state = Shared::disconnected;
|
state = Shared::disconnected;
|
||||||
emit connectionStateChanged(state);
|
emit connectionStateChanged(state);
|
||||||
@ -138,14 +139,16 @@ void Core::Account::onClientConnected()
|
|||||||
|
|
||||||
void Core::Account::onClientDisconnected()
|
void Core::Account::onClientDisconnected()
|
||||||
{
|
{
|
||||||
|
clearConferences();
|
||||||
if (state != Shared::disconnected) {
|
if (state != Shared::disconnected) {
|
||||||
if (reconnectTimes > 0) {
|
if (reconnectTimes > 0) {
|
||||||
|
qDebug() << "Account" << name << "is reconnecting for" << reconnectTimes << "more times";
|
||||||
--reconnectTimes;
|
--reconnectTimes;
|
||||||
qDebug() << "Reconnecting...";
|
|
||||||
state = Shared::connecting;
|
state = Shared::connecting;
|
||||||
client.connectToServer(config, presence);
|
client.connectToServer(config, presence);
|
||||||
emit connectionStateChanged(state);
|
emit connectionStateChanged(state);
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "Account" << name << "has been disconnected";
|
||||||
state = Shared::disconnected;
|
state = Shared::disconnected;
|
||||||
emit connectionStateChanged(state);
|
emit connectionStateChanged(state);
|
||||||
}
|
}
|
||||||
@ -312,6 +315,7 @@ void Core::Account::handleNewConference(Core::Conference* contact)
|
|||||||
{
|
{
|
||||||
handleNewRosterItem(contact);
|
handleNewRosterItem(contact);
|
||||||
QObject::connect(contact, SIGNAL(nickChanged(const QString&)), this, SLOT(onMucNickNameChanged(const QString&)));
|
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(joinedChanged(bool)), this, SLOT(onMucJoinedChanged(bool)));
|
||||||
QObject::connect(contact, SIGNAL(autoJoinChanged(bool)), this, SLOT(onMucAutoJoinChanged(bool)));
|
QObject::connect(contact, SIGNAL(autoJoinChanged(bool)), this, SLOT(onMucAutoJoinChanged(bool)));
|
||||||
QObject::connect(contact, SIGNAL(addParticipant(const QString&, const QMap<QString, QVariant>&)),
|
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)
|
void Core::Account::onMucAutoJoinChanged(bool autoJoin)
|
||||||
{
|
{
|
||||||
|
storeConferences();
|
||||||
Conference* room = static_cast<Conference*>(sender());
|
Conference* room = static_cast<Conference*>(sender());
|
||||||
emit changeRoom(room->jid, {
|
emit changeRoom(room->jid, {
|
||||||
{"autoJoin", autoJoin}
|
{"autoJoin", autoJoin}
|
||||||
@ -1035,6 +1040,7 @@ void Core::Account::onMucAutoJoinChanged(bool autoJoin)
|
|||||||
|
|
||||||
void Core::Account::onMucNickNameChanged(const QString& nickName)
|
void Core::Account::onMucNickNameChanged(const QString& nickName)
|
||||||
{
|
{
|
||||||
|
storeConferences();
|
||||||
Conference* room = static_cast<Conference*>(sender());
|
Conference* room = static_cast<Conference*>(sender());
|
||||||
emit changeRoom(room->jid, {
|
emit changeRoom(room->jid, {
|
||||||
{"nick", nickName}
|
{"nick", nickName}
|
||||||
@ -1080,3 +1086,53 @@ void Core::Account::onMucRemoveParticipant(const QString& nickName)
|
|||||||
Conference* room = static_cast<Conference*>(sender());
|
Conference* room = static_cast<Conference*>(sender());
|
||||||
emit removeRoomParticipant(room->jid, nickName);
|
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 setRoomJoined(const QString& jid, bool joined);
|
||||||
void setRoomAutoJoin(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:
|
signals:
|
||||||
void connectionStateChanged(int);
|
void connectionStateChanged(int);
|
||||||
@ -139,6 +141,7 @@ private slots:
|
|||||||
void onMucJoinedChanged(bool joined);
|
void onMucJoinedChanged(bool joined);
|
||||||
void onMucAutoJoinChanged(bool autoJoin);
|
void onMucAutoJoinChanged(bool autoJoin);
|
||||||
void onMucNickNameChanged(const QString& nickName);
|
void onMucNickNameChanged(const QString& nickName);
|
||||||
|
void onMucSubjectChanged(const QString& subject);
|
||||||
void onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
void onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
||||||
void onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
void onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
||||||
void onMucRemoveParticipant(const QString& nickName);
|
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;
|
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;
|
Shared::SubscriptionState castSubscriptionState(QXmppRosterIq::Item::SubscriptionType qs) const;
|
||||||
void logMessage(const QXmppMessage& msg, const QString& reason = "Message wasn't handled: ");
|
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(joined()), this, SLOT(onRoomJoined()));
|
||||||
connect(room, SIGNAL(left()), this, SLOT(onRoomLeft()));
|
connect(room, SIGNAL(left()), this, SLOT(onRoomLeft()));
|
||||||
connect(room, SIGNAL(nameChanged(const QString&)), this, SLOT(onRoomNameChanged(const QString&)));
|
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(participantAdded(const QString&)), this, SLOT(onRoomParticipantAdded(const QString&)));
|
||||||
connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&)));
|
connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&)));
|
||||||
connect(room, SIGNAL(participantRemoved(const QString&)), this, SLOT(onRoomParticipantRemoved(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()
|
Core::Conference::~Conference()
|
||||||
{
|
{
|
||||||
|
if (joined) {
|
||||||
|
room->leave();
|
||||||
|
}
|
||||||
|
room->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Core::Conference::getNick() const
|
QString Core::Conference::getNick() const
|
||||||
@ -183,3 +188,17 @@ void Core::Conference::onRoomParticipantRemoved(const QString& p_name)
|
|||||||
emit removeParticipant(resource);
|
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();
|
~Conference();
|
||||||
|
|
||||||
QString getNick() const;
|
QString getNick() const;
|
||||||
|
QString getSubject() const;
|
||||||
void setNick(const QString& p_nick);
|
void setNick(const QString& p_nick);
|
||||||
|
|
||||||
bool getJoined() const;
|
bool getJoined() const;
|
||||||
@ -48,6 +49,7 @@ signals:
|
|||||||
void nickChanged(const QString& nick);
|
void nickChanged(const QString& nick);
|
||||||
void joinedChanged(bool joined);
|
void joinedChanged(bool joined);
|
||||||
void autoJoinChanged(bool autoJoin);
|
void autoJoinChanged(bool autoJoin);
|
||||||
|
void subjectChanged(const QString& subject);
|
||||||
void addParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
void addParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
||||||
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
||||||
void removeParticipant(const QString& name);
|
void removeParticipant(const QString& name);
|
||||||
@ -62,6 +64,7 @@ private slots:
|
|||||||
void onRoomJoined();
|
void onRoomJoined();
|
||||||
void onRoomLeft();
|
void onRoomLeft();
|
||||||
void onRoomNameChanged(const QString& p_name);
|
void onRoomNameChanged(const QString& p_name);
|
||||||
|
void onRoomSubjectChanged(const QString& p_name);
|
||||||
void onRoomNickNameChanged(const QString& p_nick);
|
void onRoomNickNameChanged(const QString& p_nick);
|
||||||
void onRoomError(const QXmppStanza::Error& err);
|
void onRoomError(const QXmppStanza::Error& err);
|
||||||
void onRoomParticipantAdded(const QString& p_name);
|
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());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeRoomParticipant(acc->getName(), jid, nick);
|
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 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 setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||||
void setRoomAutoJoin(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:
|
private:
|
||||||
typedef std::deque<Account*> Accounts;
|
typedef std::deque<Account*> Accounts;
|
||||||
|
3
global.h
3
global.h
@ -97,6 +97,9 @@ static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent"
|
|||||||
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
|
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
|
||||||
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
|
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
|
||||||
|
|
||||||
|
static const std::deque<QString> affiliationNames = {"Unspecified", "Outcast", "Nobody", "Member", "Admin", "Owner"};
|
||||||
|
static const std::deque<QString> roleNames = {"Unspecified", "Nobody", "Visitor", "Participant", "Moderator"};
|
||||||
|
|
||||||
QString generateUUID();
|
QString generateUUID();
|
||||||
|
|
||||||
class Message {
|
class Message {
|
||||||
|
3
main.cpp
3
main.cpp
@ -83,6 +83,9 @@ int main(int argc, char *argv[])
|
|||||||
QObject::connect(&w, SIGNAL(setRoomJoined(const QString&, const QString&, bool)), squawk, SLOT(setRoomJoined(const QString&, const QString&, bool)));
|
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(&w, SIGNAL(setRoomAutoJoin(const QString&, const QString&, bool)), squawk, SLOT(setRoomAutoJoin(const QString&, const QString&, bool)));
|
||||||
|
|
||||||
|
QObject::connect(&w, SIGNAL(removeRoomRequest(const QString&, const QString&)),
|
||||||
|
squawk, SLOT(removeRoomRequest(const QString&, const QString&)));
|
||||||
|
|
||||||
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>&)));
|
||||||
|
@ -26,6 +26,7 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||||||
joined(false),
|
joined(false),
|
||||||
jid(p_jid),
|
jid(p_jid),
|
||||||
nick(""),
|
nick(""),
|
||||||
|
subject(""),
|
||||||
messages(),
|
messages(),
|
||||||
participants()
|
participants()
|
||||||
{
|
{
|
||||||
@ -43,6 +44,11 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||||||
if (itr != data.end()) {
|
if (itr != data.end()) {
|
||||||
setNick(itr.value().toString());
|
setNick(itr.value().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itr = data.find("subject");
|
||||||
|
if (itr != data.end()) {
|
||||||
|
setSubject(itr.value().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::Room::~Room()
|
Models::Room::~Room()
|
||||||
@ -56,7 +62,7 @@ unsigned int Models::Room::getUnreadMessagesCount() const
|
|||||||
|
|
||||||
int Models::Room::columnCount() const
|
int Models::Room::columnCount() const
|
||||||
{
|
{
|
||||||
return 6;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Models::Room::getJid() const
|
QString Models::Room::getJid() const
|
||||||
@ -103,6 +109,8 @@ QVariant Models::Room::data(int column) const
|
|||||||
return getNick();
|
return getNick();
|
||||||
case 5:
|
case 5:
|
||||||
return getMessagesCount();
|
return getMessagesCount();
|
||||||
|
case 6:
|
||||||
|
return getSubject();
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -155,6 +163,8 @@ void Models::Room::update(const QString& field, const QVariant& value)
|
|||||||
setAutoJoin(value.toBool());
|
setAutoJoin(value.toBool());
|
||||||
} else if (field == "nick") {
|
} else if (field == "nick") {
|
||||||
setNick(value.toString());
|
setNick(value.toString());
|
||||||
|
} else if (field == "subject") {
|
||||||
|
setSubject(value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,3 +296,16 @@ void Models::Room::handleParticipantUpdate(std::map<QString, Participant*>::cons
|
|||||||
participants.insert(std::make_pair(part->getName(), part));
|
participants.insert(std::make_pair(part->getName(), part));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Models::Room::getSubject() const
|
||||||
|
{
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Models::Room::setSubject(const QString& sub)
|
||||||
|
{
|
||||||
|
if (sub != subject) {
|
||||||
|
subject = sub;
|
||||||
|
changed(6);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -45,6 +45,7 @@ public:
|
|||||||
QString getJid() const;
|
QString getJid() const;
|
||||||
QString getNick() const;
|
QString getNick() const;
|
||||||
QString getRoomName() const;
|
QString getRoomName() const;
|
||||||
|
QString getSubject() const;
|
||||||
|
|
||||||
QIcon getStatusIcon(bool big = false) const;
|
QIcon getStatusIcon(bool big = false) const;
|
||||||
QString getStatusText() const;
|
QString getStatusText() const;
|
||||||
@ -53,6 +54,7 @@ public:
|
|||||||
void setAutoJoin(bool p_autoJoin);
|
void setAutoJoin(bool p_autoJoin);
|
||||||
void setJid(const QString& p_jid);
|
void setJid(const QString& p_jid);
|
||||||
void setNick(const QString& p_nick);
|
void setNick(const QString& p_nick);
|
||||||
|
void setSubject(const QString& sub);
|
||||||
|
|
||||||
void update(const QString& field, const QVariant& value);
|
void update(const QString& field, const QVariant& value);
|
||||||
|
|
||||||
@ -75,6 +77,7 @@ private:
|
|||||||
bool joined;
|
bool joined;
|
||||||
QString jid;
|
QString jid;
|
||||||
QString nick;
|
QString nick;
|
||||||
|
QString subject;
|
||||||
Messages messages;
|
Messages messages;
|
||||||
std::map<QString, Participant*> participants;
|
std::map<QString, Participant*> participants;
|
||||||
|
|
||||||
|
@ -112,6 +112,11 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
result = room->getStatusIcon(false);
|
result = room->getStatusIcon(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Item::participant: {
|
||||||
|
Participant* p = static_cast<Participant*>(item);
|
||||||
|
result = p->getStatusIcon(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -148,6 +153,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
if (mc > 0) {
|
if (mc > 0) {
|
||||||
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
|
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
|
||||||
}
|
}
|
||||||
|
str += "Jabber ID: " + contact->getJid();
|
||||||
Shared::SubscriptionState ss = contact->getState();
|
Shared::SubscriptionState ss = contact->getState();
|
||||||
if (ss == Shared::both) {
|
if (ss == Shared::both) {
|
||||||
Shared::Availability av = contact->getAvailability();
|
Shared::Availability av = contact->getAvailability();
|
||||||
@ -180,6 +186,22 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
str += "\nStatus: " + s;
|
str += "\nStatus: " + s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = str;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Item::participant: {
|
||||||
|
Participant* p = static_cast<Participant*>(item);
|
||||||
|
QString str("");
|
||||||
|
Shared::Availability av = p->getAvailability();
|
||||||
|
str += "Availability: " + Shared::availabilityNames[av] + "\n";
|
||||||
|
QString s = p->getStatus();
|
||||||
|
if (s.size() > 0) {
|
||||||
|
str += "Status: " + s + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
str += "Affiliation: " + Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())] + "\n";
|
||||||
|
str += "Role: " + Shared::roleNames[static_cast<unsigned int>(p->getRole())];
|
||||||
|
|
||||||
result = str;
|
result = str;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -203,6 +225,9 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
str += QString("New messages: ") + std::to_string(count).c_str() + "\n";
|
str += QString("New messages: ") + std::to_string(count).c_str() + "\n";
|
||||||
}
|
}
|
||||||
str += QString("Subscription: ") + rm->getStatusText();
|
str += QString("Subscription: ") + rm->getStatusText();
|
||||||
|
if (rm->getJoined()) {
|
||||||
|
str += QString("\nMembers: ") + std::to_string(rm->childCount()).c_str();
|
||||||
|
}
|
||||||
result = str;
|
result = str;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -455,6 +455,41 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
|||||||
emit removeContactRequest(cnt->getAccountName(), cnt->getJid());
|
emit removeContactRequest(cnt->getAccountName(), cnt->getJid());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Models::Item::room: {
|
||||||
|
Models::Room* room = static_cast<Models::Room*>(item);
|
||||||
|
hasMenu = true;
|
||||||
|
|
||||||
|
QAction* dialog = contextMenu->addAction(Shared::icon("mail-message"), "Open conversation");
|
||||||
|
connect(dialog, &QAction::triggered, [this, index]() {
|
||||||
|
onRosterItemDoubleClicked(index);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Models::Roster::ElId id(room->getAccountName(), room->getJid());
|
||||||
|
if (room->getAutoJoin()) {
|
||||||
|
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), "Unsubscribe");
|
||||||
|
connect(unsub, &QAction::triggered, [this, id]() {
|
||||||
|
emit setRoomAutoJoin(id.account, id.name, false);
|
||||||
|
if (conversations.find(id) == conversations.end()) { //to leave the room if it's not opened in a conversation window
|
||||||
|
emit setRoomJoined(id.account, id.name, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
QAction* unsub = contextMenu->addAction(Shared::icon("news-subscribe"), "Subscribe");
|
||||||
|
connect(unsub, &QAction::triggered, [this, id]() {
|
||||||
|
emit setRoomAutoJoin(id.account, id.name, true);
|
||||||
|
if (conversations.find(id) == conversations.end()) { //to join the room if it's not already joined
|
||||||
|
emit setRoomJoined(id.account, id.name, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction* remove = contextMenu->addAction(Shared::icon("edit-delete"), "Remove");
|
||||||
|
connect(remove, &QAction::triggered, [this, id]() {
|
||||||
|
emit removeRoomRequest(id.account, id.name);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -62,6 +62,7 @@ signals:
|
|||||||
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 setRoomJoined(const QString& account, const QString& jid, bool joined);
|
||||||
void setRoomAutoJoin(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);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newAccount(const QMap<QString, QVariant>& account);
|
void newAccount(const QMap<QString, QVariant>& account);
|
||||||
|
@ -66,11 +66,6 @@ void Chat::updateState()
|
|||||||
statusIcon->setToolTip(Shared::availabilityNames[av]);
|
statusIcon->setToolTip(Shared::availabilityNames[av]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chat::setStatus(const QString& status)
|
|
||||||
{
|
|
||||||
statusLabel->setText(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chat::handleSendMessage(const QString& text)
|
void Chat::handleSendMessage(const QString& text)
|
||||||
{
|
{
|
||||||
Shared::Message msg(Shared::Message::chat);
|
Shared::Message msg(Shared::Message::chat);
|
||||||
|
@ -37,14 +37,13 @@ public:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onContactChanged(Models::Item* item, int row, int col);
|
void onContactChanged(Models::Item* item, int row, int col);
|
||||||
void handleSendMessage(const QString & text) override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setName(const QString & name) override;
|
void setName(const QString & name) override;
|
||||||
|
void handleSendMessage(const QString & text) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateState();
|
void updateState();
|
||||||
void setStatus(const QString& status);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Models::Contact* contact;
|
Models::Contact* contact;
|
||||||
|
@ -254,3 +254,8 @@ void Conversation::onFileSelected()
|
|||||||
|
|
||||||
d->deleteLater();
|
d->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Conversation::setStatus(const QString& status)
|
||||||
|
{
|
||||||
|
statusLabel->setText(status);
|
||||||
|
}
|
||||||
|
@ -67,6 +67,7 @@ protected:
|
|||||||
virtual void setName(const QString& name);
|
virtual void setName(const QString& name);
|
||||||
void applyVisualEffects();
|
void applyVisualEffects();
|
||||||
virtual void handleSendMessage(const QString& text) = 0;
|
virtual void handleSendMessage(const QString& text) = 0;
|
||||||
|
void setStatus(const QString& status);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onEnterPressed();
|
void onEnterPressed();
|
||||||
|
@ -24,6 +24,9 @@ Room::Room(Models::Room* p_room, QWidget* parent):
|
|||||||
{
|
{
|
||||||
setName(p_room->getName());
|
setName(p_room->getName());
|
||||||
line->setMyName(room->getNick());
|
line->setMyName(room->getNick());
|
||||||
|
setStatus(room->getSubject());
|
||||||
|
|
||||||
|
connect(room, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onRoomChanged(Models::Item*, int, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Room::~Room()
|
Room::~Room()
|
||||||
@ -48,3 +51,17 @@ bool Room::autoJoined() const
|
|||||||
{
|
{
|
||||||
return room->getAutoJoin();
|
return room->getAutoJoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Room::onRoomChanged(Models::Item* item, int row, int col)
|
||||||
|
{
|
||||||
|
if (item == room) {
|
||||||
|
switch (col) {
|
||||||
|
case 0:
|
||||||
|
setName(room->getRoomName());
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
setStatus(room->getSubject());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -34,6 +34,9 @@ public:
|
|||||||
|
|
||||||
bool autoJoined() const;
|
bool autoJoined() const;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void onRoomChanged(Models::Item* item, int row, int col);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void handleSendMessage(const QString & text) override;
|
void handleSendMessage(const QString & text) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user