Ejemplo n.º 1
0
QString MyXmppClient::getPresenceByOrderID( int id ) {
    if (cachedRoster->count() >= id+1) {
        RosterItemModel *item = (RosterItemModel*)cachedRoster->getElementByID(id);
        if (item != 0) return item->presence(); else return "";
    }
    return "";
}
Ejemplo n.º 2
0
QString MyXmppClient::getPropertyByJid( QString bareJid, QString property ) {
    RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid );
    if (item != 0) {
      if (property == "name") return item->name();
      else if (property == "presence") return item->presence();
      else if (property == "resource") return item->resource();
      else if (property == "statusText") return item->statusText();
      else if (property == "unreadMsg") return QString::number(item->unreadMsg());
      } else return "(unknown)";
}
Ejemplo n.º 3
0
QString MyXmppClient::getPropertyByOrderID(int id, QString property) {
  bool onlineContactFound;
  int  iterations = id;
  while (!onlineContactFound && cachedRoster->count() >= id+1) {
    RosterItemModel *item = (RosterItemModel*)cachedRoster->getElementByID(id);
    if (item != 0) {
        if (item->presence() != "qrc:/presence/offline") {
            if (iterations == 0) return getPropertyByJid(item->jid(),property);
            else iterations--;
        }
        id++;
    } else break;
  }
  return "";
}
Ejemplo n.º 4
0
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);
}