本文整理汇总了C++中QXmppPresence::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmppPresence::type方法的具体用法?C++ QXmppPresence::type怎么用?C++ QXmppPresence::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmppPresence
的用法示例。
在下文中一共展示了QXmppPresence::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: presenceReceived
void QXmppRosterManager::presenceReceived(const QXmppPresence& presence)
{
QString jid = presence.from();
QString bareJid = jidToBareJid(jid);
QString resource = jidToResource(jid);
if (bareJid.isEmpty())
return;
switch(presence.type())
{
case QXmppPresence::Available:
m_presences[bareJid][resource] = presence;
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Unavailable:
m_presences[bareJid].remove(resource);
emit presenceChanged(bareJid, resource);
break;
case QXmppPresence::Subscribe:
if (m_stream->configuration().autoAcceptSubscriptions())
{
QXmppPresence presence;
presence.setTo(jid);
presence.setType(QXmppPresence::Subscribed);
m_stream->sendPacket(presence);
}
break;
default:
break;
}
}
示例2: _q_presenceReceived
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;
}
}
示例3: slotPresenceReceived
void xmppClient::slotPresenceReceived(const QXmppPresence &presence)
{
const QLatin1String recipient("[email protected]");
// if we are the recipient, or if the presence is not from the recipient,
// do nothing
if (jidToBareJid(configuration().jid()) == recipient ||
jidToBareJid(presence.from()) != recipient ||
presence.type() != QXmppPresence::Available)
return;
// send the file and connect to the job's signals
QXmppTransferJob *job = transferManager->sendFile(presence.from(), "xmppClient.cpp");
bool check = connect( job, SIGNAL(error(QXmppTransferJob::Error)),
this, SLOT(slotError(QXmppTransferJob::Error)) );
Q_ASSERT(check);
check = connect( job, SIGNAL(finished()),
this, SLOT(slotFinished()) );
Q_ASSERT(check);
check = connect( job, SIGNAL(progress(qint64,qint64)),
this, SLOT(slotProgress(qint64,qint64)) );
Q_ASSERT(check);
}
示例4: PresenceToStatus
EntryStatus PresenceToStatus (const QXmppPresence& pres)
{
EntryStatus st (static_cast<State> (pres.availableStatusType () + 1), pres.statusText ());
if (pres.type () == QXmppPresence::Unavailable)
st.State_ = SOffline;
return st;
}
示例5: presenceToStatusText
QString presenceToStatusText(const QXmppPresence& presence)
{
QString statusText = presence.statusText();
if(statusText.isEmpty())
{
if(presence.type() == QXmppPresence::Available)
{
switch(presence.availableStatusType())
{
case QXmppPresence::Invisible:
statusText = "Offline";
break;
case QXmppPresence::Online:
case QXmppPresence::Chat:
statusText = "Available";
break;
case QXmppPresence::Away:
case QXmppPresence::XA:
statusText = "Idle";
break;
case QXmppPresence::DND:
statusText = "Busy";
break;
}
}
else
statusText = "Offline";
}
return statusText;
}
示例6: CheckVCardUpdate
void EntryBase::CheckVCardUpdate (const QXmppPresence& pres)
{
auto conn = Account_->GetClientConnection ();
if (!conn->GetInfoReqPolicyManager ()->IsRequestAllowed (InfoRequest::VCard, this))
return;
auto fetchVCard = [this, conn] () -> void
{
QPointer<EntryBase> ptr (this);
conn->FetchVCard (GetJID (),
[ptr] (const QXmppVCardIq& iq) { if (ptr) ptr->SetVCard (iq); });
};
const auto& vcardUpdate = pres.vCardUpdateType ();
if (vcardUpdate == QXmppPresence::VCardUpdateNoPhoto)
{
if (!Avatar_.isNull ())
{
Avatar_ = QImage ();
emit avatarChanged (GetAvatar ());
}
}
else if (vcardUpdate == QXmppPresence::VCardUpdateValidPhoto)
{
if (pres.photoHash () != VCardPhotoHash_)
fetchVCard ();
}
else if (pres.type () == QXmppPresence::Available && !HasBlindlyRequestedVCard_)
{
fetchVCard ();
HasBlindlyRequestedVCard_ = true;
}
}
示例7: slotPresenceReceived
void QFileTrans::slotPresenceReceived(const QXmppPresence &presence)
{
bool check;
Q_UNUSED(check);
// if we don't have a recipient, or if the presence is not from the recipient,
// do nothing
if (m_recipient.isEmpty() ||
QXmppUtils::jidToBareJid(presence.from()) != m_recipient ||
presence.type() != QXmppPresence::Available)
return;
// send the file and connect to the job's signals
QXmppTransferJob *job = transferManager->sendFile(presence.from(), ":/example_3_transferHandling.cpp", "example source code");
check = connect(job, SIGNAL(error(QXmppTransferJob::Error)),
this, SLOT(slotError(QXmppTransferJob::Error)));
Q_ASSERT(check);
check = connect(job, SIGNAL(finished()),
this, SLOT(slotFinished()));
Q_ASSERT(check);
check = connect(job, SIGNAL(progress(qint64,qint64)),
this, SLOT(slotProgress(qint64,qint64)));
Q_ASSERT(check);
}
示例8: setPresence
void rosterItem::setPresence(const QXmppPresence &presence)
{
// determine status text
QString statusText = presence.statusText();
if (statusText.isEmpty()) {
if(presence.type() == QXmppPresence::Available)
statusText = "Available";
else if(presence.type() == QXmppPresence::Unavailable)
statusText = "Offline";
}
// store data
setData(statusText, rosterItem::StatusText);
setData(static_cast<int>(presence.type()), PresenceType);
setData(static_cast<int>(presence.availableStatusType()), StatusType);
// update icon
QString icon;
if (presence.type() == QXmppPresence::Available) {
switch (presence.availableStatusType())
{
case QXmppPresence::Online:
case QXmppPresence::Chat:
icon = "green";
break;
case QXmppPresence::Away:
case QXmppPresence::XA:
icon = "orange";
break;
case QXmppPresence::DND:
icon = "red";
break;
case QXmppPresence::Invisible:
icon = "gray";
break;
}
} else {
icon = "gray";
}
if (!icon.isEmpty())
setIcon(QIcon(":/icons/resource/"+icon+".png"));
}
示例9: HandlePresence
void RoomHandler::HandlePresence (const QXmppPresence& pres, const QString& nick)
{
if (pres.type () == QXmppPresence::Unavailable &&
PendingNickChanges_.remove (nick))
return;
const bool existed = Nick2Entry_.contains (nick);
RoomParticipantEntry_ptr entry = GetParticipantEntry (nick);
if (pres.type () == QXmppPresence::Unavailable)
{
MakeLeaveMessage (pres, nick);
Account_->handleEntryRemoved (entry.get ());
Nick2Entry_.remove (nick);
return;
}
entry->SetClientInfo ("", pres);
const QXmppPresence::Status& xmppSt = pres.status ();
EntryStatus status (static_cast<State> (xmppSt.type ()),
xmppSt.statusText ());
const bool statusChanged = (status != entry->GetStatus (QString ()));
if (statusChanged)
entry->SetStatus (status, QString ());
if (!PendingNickChanges_.remove (nick))
{
if (!existed)
{
Account_->GetClientConnection ()->
FetchVCard (RoomJID_ + "/" + nick);
MakeJoinMessage (pres, nick);
entry->SetAffiliation (MUCManager_->getAffiliation (RoomJID_, nick));
entry->SetRole (MUCManager_->getRole (RoomJID_, nick));
}
else if (statusChanged)
MakeStatusChangedMessage (pres, nick);
}
}
示例10: slotPresenceReceived
void xmppClient::slotPresenceReceived(const QXmppPresence &presence)
{
// if we don't have a recipient, or if the presence is not from the recipient,
// do nothing
if (m_recipient.isEmpty() ||
QXmppUtils::jidToBareJid(presence.from()) != m_recipient ||
presence.type() != QXmppPresence::Available)
return;
// start the call and connect to the its signals
m_recipientFullJid = presence.from();
startCall();
}
示例11: slotPresenceReceived
void rpcClient::slotPresenceReceived(const QXmppPresence &presence)
{
const QLatin1String recipient("[email protected]");
// if we are the recipient, or if the presence is not from the recipient,
// do nothing
if (QXmppUtils::jidToBareJid(configuration().jid()) == recipient ||
QXmppUtils::jidToBareJid(presence.from()) != recipient ||
presence.type() != QXmppPresence::Available)
return;
// invoke the remote method in 1 second
m_remoteJid = presence.from();
QTimer::singleShot(1000, this, SLOT(slotInvokeRemoteMethod()));
}
示例12: getPicPresence
QString MyXmppClient::getPicPresence( const QXmppPresence &presence ) const
{
QString picPresenceName;
QXmppPresence::Type status = presence.type();
if( status != QXmppPresence::Available ) picPresenceName = "qrc:/presence/offline";
else
{
QXmppPresence::AvailableStatusType availableStatus = presence.availableStatusType();
if( availableStatus == QXmppPresence::Online ) picPresenceName = "qrc:/presence/online";
else if ( availableStatus == QXmppPresence::Chat ) picPresenceName = "qrc:/presence/chatty";
else if ( availableStatus == QXmppPresence::Away ) picPresenceName = "qrc:/presence/away";
else if ( availableStatus == QXmppPresence::XA ) picPresenceName = "qrc:/presence/xa";
else if ( availableStatus == QXmppPresence::DND ) picPresenceName = "qrc:/presence/busy";
}
return picPresenceName;
}
示例13: initPresence
void MyXmppClient::initPresence(const QString& bareJid, const QString& resource)
{
int indxItem = -1;
RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid, indxItem );
if( item == 0 ) {
return;
}
QXmppPresence xmppPresence = rosterManager->getPresence( bareJid, resource );
QXmppPresence::Type statusJid = xmppPresence.type();
QStringList _listResources = this->getResourcesByJid( bareJid );
if( (_listResources.count() > 0) && (!_listResources.contains(resource)) )
{
qDebug() << bareJid << "/" << resource << " ****************[" <<_listResources<<"]" ;
if( statusJid == QXmppPresence::Unavailable ) {
return;
}
}
item->setResource( resource );
QString picStatus = this->getPicPresence( xmppPresence );
item->setPresence( picStatus );
QString txtStatus = this->getTextStatus( xmppPresence.statusText(), xmppPresence );
item->setStatusText( txtStatus );
RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->find( bareJid, indxItem );
if( itemExists != 0 ) {
itemExists->copy( item );
QString picStatusPrev = itemExists->presence();
if( picStatusPrev != picStatus )
{
//emit presenceJidChanged( bareJid, txtStatus, picStatus );
emit rosterChanged();
}
}
item = 0; itemExists = 0;
delete item; delete itemExists;
emit contactStatusChanged(m_accountId,bareJid);
}
示例14: presenceReceived
void Xmpp_client::presenceReceived(const QXmppPresence& presence)
{
qDebug() << "Xmpp_client::presenceReceived !!!";
QString from = presence.from();
QString message;
switch(presence.type())
{
case QXmppPresence::Subscribe:
{
QXmppPresence subscribed;
subscribed.setTo(from);
subscribed.setType(QXmppPresence::Subscribed);
this->sendPacket(subscribed);
// reciprocal subscription
QXmppPresence subscribe;
subscribe.setTo(from);
subscribe.setType(QXmppPresence::Subscribe);
this->sendPacket(subscribe);
return;
}
break;
case QXmppPresence::Subscribed:
message = "<B>%1</B> accepted your request";
break;
case QXmppPresence::Unsubscribe:
message = "<B>%1</B> unsubscribe";
break;
case QXmppPresence::Unsubscribed:
message = "<B>%1</B> unsubscribed";
break;
default:
return;
break;
}
if(message.isEmpty())
return;
}
示例15: presenceReceived
void MyXmppClient::presenceReceived( const QXmppPresence & presence ) {
QString bareJid = getBareJidByJid(presence.from());
QString resource = getResourceByJid(presence.from());
QString myResource = xmppClient->configuration().resource();
if ((presence.from().indexOf( m_myjid ) >= 0 && resource == myResource) || (bareJid == "" && resource == "")) {
if (presence.type() == QXmppPresence::Unavailable) m_status = Offline;
else {
switch (presence.availableStatusType()) {
case QXmppPresence::Online: m_status = Online; break;
case QXmppPresence::Chat: m_status = Chat; break;
case QXmppPresence::Away: m_status = Away; break;
case QXmppPresence::XA: m_status = XA; break;
case QXmppPresence::DND: m_status = DND; break;
}
}
emit statusChanged(m_accountId);
}
}