bool Roster::stanzaReadWrite(int AHandlerId, const Jid &AStreamJid, Stanza &AStanza, bool &AAccept) { if (AHandlerId == FSHIRosterPush) { if (isOpen() && AStanza.isFromServer()) { AAccept = true; LOG_STRM_DEBUG(streamJid(),"Roster items push received"); processItemsElement(AStanza.firstElement("query",NS_JABBER_ROSTER),false); Stanza result = FStanzaProcessor->makeReplyResult(AStanza); FStanzaProcessor->sendStanzaOut(AStreamJid,result); } else if (!isOpen()) { REPORT_ERROR("Failed to process roster items push: Roster is closed"); } else if (!AStanza.isFromServer()) { REPORT_ERROR("Failed to process roster items push: Invalid stanza sender"); } } else if (AHandlerId == FSHISubscription) { Jid contactJid = AStanza.from(); QString status = AStanza.firstElement("status").text(); if (AStanza.type() == SUBSCRIPTION_SUBSCRIBE) { AAccept = true; FSubscriptionRequests += contactJid.bare(); LOG_STRM_INFO(streamJid(),QString("Subscribe presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Subscribe,status); } else if (AStanza.type() == SUBSCRIPTION_SUBSCRIBED) { AAccept = true; LOG_STRM_INFO(streamJid(),QString("Subscribed presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Subscribed,status); } else if (AStanza.type() == SUBSCRIPTION_UNSUBSCRIBE) { AAccept = true; FSubscriptionRequests -= contactJid.bare(); LOG_STRM_INFO(streamJid(),QString("Unsubscribe presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Unsubscribe,status); } else if (AStanza.type() == SUBSCRIPTION_UNSUBSCRIBED) { AAccept = true; LOG_STRM_INFO(streamJid(),QString("Unsubscribed presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Unsubscribed,status); } } return false; }
void QXmppRosterManager::_q_presenceReceived(const QXmppPresence& presence) { const QString jid = presence.from(); const QString bareJid = QXmppUtils::jidToBareJid(jid); const QString resource = QXmppUtils::jidToResource(jid); if (bareJid.isEmpty()) return; switch(presence.type()) { case QXmppPresence::Available: d->presences[bareJid][resource] = presence; emit presenceChanged(bareJid, resource); break; case QXmppPresence::Unavailable: d->presences[bareJid].remove(resource); emit presenceChanged(bareJid, resource); break; case QXmppPresence::Subscribe: if (client()->configuration().autoAcceptSubscriptions()) { // accept subscription request acceptSubscription(bareJid); // ask for reciprocal subscription subscribe(bareJid); } else { emit subscriptionReceived(bareJid); } break; default: break; } }
/** * This slot is triggered when user @a uin grants authorization to jabber user. */ void GatewayTask::processAuthGranted(const QString& uin) { ICQ::Session *session = qobject_cast<ICQ::Session*>( sender() ); XMPP::Jid user = d->icqJidTable[session]; // qDebug() << "[GT]" << user << "granted auth to" << uin << "nick" << session->contactName(uin); emit subscriptionReceived( user, uin, session->contactName(uin) ); }
void MyXmppClient::initRosterManager() { rosterManager = &xmppClient->rosterManager(); qDebug() << "MyXmppClient::clientStateChanged(): initializing roster manager"; QObject::connect( rosterManager, SIGNAL(presenceChanged(QString,QString)), this, SLOT(initPresence(const QString, const QString)), Qt::UniqueConnection ); QObject::connect( rosterManager, SIGNAL(rosterReceived()), this, SLOT(initRoster()), Qt::UniqueConnection ); QObject::connect( rosterManager, SIGNAL(subscriptionReceived(QString)), this, SLOT(notifyNewSubscription(QString)), Qt::UniqueConnection ); QObject::connect( rosterManager, SIGNAL(itemAdded(QString)), this, SLOT(itemAdded(QString)), Qt::UniqueConnection ); QObject::connect( rosterManager, SIGNAL(itemRemoved(QString)), this, SLOT(itemRemoved(QString)), Qt::UniqueConnection ); QObject::connect( rosterManager, SIGNAL(itemChanged(QString)), this, SLOT(itemChanged(QString)), Qt::UniqueConnection ); }
CFrmUserList::CFrmUserList(QWidget *parent) : QFrame(parent), m_UserList(this), ui(new Ui::CFrmUserList) { ui->setupUi(this); InitMenu(); m_pModel = new QStandardItemModel(this); if(m_pModel) { //增加头,只有增加了这个后,下面才会显示内容 m_pModel->setHorizontalHeaderLabels(QStringList() << tr("User name or group")<< tr("Information")); } m_UserList.setModel(m_pModel); m_UserList.show(); InsertGroup(tr("My friends")); bool check = connect(&m_UserList, SIGNAL(clicked(QModelIndex)), SLOT(clicked(QModelIndex))); Q_ASSERT(check); check = connect(&m_UserList, SIGNAL(doubleClicked(QModelIndex)), SLOT(doubleClicked(QModelIndex))); Q_ASSERT(check); check = connect(&m_UserList, SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotCustomContextMenuRequested(QPoint))); Q_ASSERT(check); check = connect(CGlobal::Instance()->GetMainWindow(), SIGNAL(sigMenuInitOperator(QMenu*)), SLOT(slotAddToMainMenu(QMenu*))); Q_ASSERT(check); check = connect(CGlobal::Instance()->GetMainWindow(), SIGNAL(sigRefresh()), SLOT(slotRefresh())); Q_ASSERT(check); check = connect(CGlobal::Instance()->GetMainWindow(), SIGNAL(sigMenuRemoveOperator(QMenu*)), SLOT(slotDeleteFromMainMenu(QMenu*))); Q_ASSERT(check); check = connect(CGlobal::Instance()->GetXmppClient(), SIGNAL(presenceReceived(const QXmppPresence)), SLOT(slotChangedPresence(QXmppPresence))); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->rosterManager(), SIGNAL(rosterReceived()), SLOT(slotRosterReceived())); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->rosterManager(), SIGNAL(subscriptionReceived(QString)), SLOT(slotSubscriptionReceived(QString))); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->rosterManager(), SIGNAL(itemAdded(QString)), SLOT(slotItemAdded(QString))); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->rosterManager(), SIGNAL(itemChanged(QString)), SLOT(slotItemChanged(QString))); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->rosterManager(), SIGNAL(itemRemoved(QString)), SLOT(slotItemRemoved(QString))); Q_ASSERT(check); check = connect(&CGlobal::Instance()->GetXmppClient()->vCardManager(), SIGNAL(vCardReceived(QXmppVCardIq)), SLOT(slotvCardReceived(QXmppVCardIq))); Q_ASSERT(check); check = connect(CGlobal::Instance()->GetXmppClient(), SIGNAL(messageReceived(QXmppMessage)), SLOT(slotClientMessageReceived(QXmppMessage))); Q_ASSERT(check); }