basic context menu, subscribing unsubscribing to contacts
This commit is contained in:
parent
b845518ced
commit
ee59d92cdc
8 changed files with 137 additions and 4 deletions
|
@ -23,6 +23,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
|||
config.setUser(p_login);
|
||||
config.setDomain(p_server);
|
||||
config.setPassword(p_password);
|
||||
config.setAutoAcceptSubscriptions(true);
|
||||
|
||||
QObject::connect(&client, SIGNAL(connected()), this, SLOT(onClientConnected()));
|
||||
QObject::connect(&client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()));
|
||||
|
@ -183,7 +184,7 @@ void Core::Account::onRosterItemChanged(const QString& bareJid)
|
|||
|
||||
contact->setGroups(re.groups());
|
||||
contact->setSubscriptionState(state);
|
||||
contact->setName(name);
|
||||
contact->setName(re.name());
|
||||
}
|
||||
|
||||
void Core::Account::onRosterItemRemoved(const QString& bareJid)
|
||||
|
@ -738,3 +739,25 @@ void Core::Account::onClientError(QXmppClient::Error err)
|
|||
qDebug() << errorType << errorText;
|
||||
emit error(errorText);
|
||||
}
|
||||
|
||||
|
||||
void Core::Account::subscribeToContact(const QString& jid, const QString& reason)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
QXmppRosterManager& rm = client.rosterManager();
|
||||
rm.subscribe(jid, reason);
|
||||
} else {
|
||||
qDebug() << "An attempt to subscribe an account " << name << " to jid " << jid << " but the account is not in the connected state, skipping";
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Account::unsubscribeFromContact(const QString& jid, const QString& reason)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
QXmppRosterManager& rm = client.rosterManager();
|
||||
rm.unsubscribe(jid, reason);
|
||||
} else {
|
||||
qDebug() << "An attempt to unsubscribe an account " << name << " from jid " << jid << " but the account is not in the connected state, skipping";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
void sendMessage(const Shared::Message& data);
|
||||
void requestArchive(const QString& jid, int count, const QString& before);
|
||||
void setReconnectTimes(unsigned int times);
|
||||
void subscribeToContact(const QString& jid, const QString& reason);
|
||||
void unsubscribeFromContact(const QString& jid, const QString& reason);
|
||||
|
||||
signals:
|
||||
void connectionStateChanged(int);
|
||||
|
|
|
@ -331,3 +331,26 @@ void Core::Squawk::removeAccountRequest(const QString& name)
|
|||
emit removeAccount(name);
|
||||
acc->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void Core::Squawk::subscribeContact(const QString& account, const QString& jid, const QString& reason)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
itr->second->subscribeToContact(jid, reason);
|
||||
}
|
||||
|
||||
void Core::Squawk::unsubscribeContact(const QString& account, const QString& jid, const QString& reason)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
itr->second->unsubscribeFromContact(jid, reason);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public slots:
|
|||
void changeState(int state);
|
||||
void sendMessage(const QString& account, const Shared::Message& data);
|
||||
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);
|
||||
|
||||
private:
|
||||
typedef std::deque<Account*> Accounts;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue