forked from blue/squawk
Disabled context menu on items of not connected account, roster contacts group moving, bugfixes with roster contacts group moving ungrouping and copying
This commit is contained in:
parent
e4d1e21ea0
commit
415d56ba69
20 changed files with 314 additions and 36 deletions
|
@ -1153,3 +1153,50 @@ void Core::Account::addNewRoom(const QString& jid, const QString& nick, const QS
|
|||
{"name", conf->getName()}
|
||||
});
|
||||
}
|
||||
|
||||
void Core::Account::addContactToGroupRequest(const QString& jid, const QString& groupName)
|
||||
{
|
||||
std::map<QString, Contact*>::const_iterator itr = contacts.find(jid);
|
||||
if (itr == contacts.end()) {
|
||||
qDebug() << "An attempt to add non existing contact" << jid << "of account" << name << "to the group" << groupName << ", skipping";
|
||||
} else {
|
||||
QXmppRosterManager& rm = client.rosterManager();
|
||||
QXmppRosterIq::Item item = rm.getRosterEntry(jid);
|
||||
QSet<QString> groups = item.groups();
|
||||
if (groups.find(groupName) == groups.end()) { //TODO need to change it, I guess that sort of code is better in qxmpp lib
|
||||
groups.insert(groupName);
|
||||
item.setGroups(groups);
|
||||
|
||||
QXmppRosterIq iq;
|
||||
iq.setType(QXmppIq::Set);
|
||||
iq.addItem(item);
|
||||
client.sendPacket(iq);
|
||||
} else {
|
||||
qDebug() << "An attempt to add contact" << jid << "of account" << name << "to the group" << groupName << "but it's already in that group, skipping";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Account::removeContactFromGroupRequest(const QString& jid, const QString& groupName)
|
||||
{
|
||||
std::map<QString, Contact*>::const_iterator itr = contacts.find(jid);
|
||||
if (itr == contacts.end()) {
|
||||
qDebug() << "An attempt to remove non existing contact" << jid << "of account" << name << "from the group" << groupName << ", skipping";
|
||||
} else {
|
||||
QXmppRosterManager& rm = client.rosterManager();
|
||||
QXmppRosterIq::Item item = rm.getRosterEntry(jid);
|
||||
QSet<QString> groups = item.groups();
|
||||
QSet<QString>::const_iterator gItr = groups.find(groupName);
|
||||
if (gItr != groups.end()) {
|
||||
groups.erase(gItr);
|
||||
item.setGroups(groups);
|
||||
|
||||
QXmppRosterIq iq;
|
||||
iq.setType(QXmppIq::Set);
|
||||
iq.addItem(item);
|
||||
client.sendPacket(iq);
|
||||
} else {
|
||||
qDebug() << "An attempt to remove contact" << jid << "of account" << name << "from the group" << groupName << "but it's not in that group, skipping";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
void unsubscribeFromContact(const QString& jid, const QString& reason);
|
||||
void removeContactRequest(const QString& jid);
|
||||
void addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups);
|
||||
void addContactToGroupRequest(const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& jid, const QString& groupName);
|
||||
|
||||
void setRoomJoined(const QString& jid, bool joined);
|
||||
void setRoomAutoJoin(const QString& jid, bool joined);
|
||||
|
|
|
@ -498,3 +498,23 @@ void Core::Squawk::downloadFileRequest(const QString& messageId, const QString&
|
|||
{
|
||||
network.downladFileRequest(messageId, url);
|
||||
}
|
||||
|
||||
void Core::Squawk::addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to add contact" << jid << "of existing account" << account << "to the group" << groupName << ", skipping";
|
||||
return;
|
||||
}
|
||||
itr->second->addContactToGroupRequest(jid, groupName);
|
||||
}
|
||||
|
||||
void Core::Squawk::removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to add contact" << jid << "of existing account" << account << "to the group" << groupName << ", skipping";
|
||||
return;
|
||||
}
|
||||
itr->second->removeContactFromGroupRequest(jid, groupName);
|
||||
}
|
||||
|
|
|
@ -79,6 +79,8 @@ public slots:
|
|||
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);
|
||||
void addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName);
|
||||
void removeContactRequest(const QString& account, const QString& jid);
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue