void MyXmppClient::initVCard(const QXmppVCardIq &vCard) { QString bareJid = vCard.from(); RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid ); vCardData dataVCard; if( item != 0 ) { /* set nickname */ QXmppRosterIq::Item itemRoster = rosterManager->getRosterEntry( bareJid ); QString nickName = vCard.nickName(); if( (!nickName.isEmpty()) && (!nickName.isNull()) && (itemRoster.name().isEmpty()) ) { qDebug() << "MyXmppClient::initPresence: updating name for"<< bareJid; item->setContactName( nickName ); } /* avatar */ bool isAvatarCreated = true; QString avatarFile = cacheIM->getAvatarCache( bareJid ); if( (avatarFile.isEmpty() || avatarFile == "qrc:/avatar" || (flVCardRequest != "")) && vCard.photo() != "" ) { isAvatarCreated = cacheIM->setAvatarCache( bareJid, vCard.photo() ); } item->setAvatar(cacheIM->getAvatarCache(bareJid)); dataVCard.nickName = nickName; dataVCard.firstName = vCard.firstName(); dataVCard.fullName = vCard.fullName();; dataVCard.middleName = vCard.middleName(); dataVCard.lastName = vCard.lastName(); dataVCard.url = vCard.url(); dataVCard.eMail = vCard.email(); if( flVCardRequest == bareJid ) { qmlVCard->setPhoto( avatarFile ); qmlVCard->setNickName( vCard.nickName() ); qmlVCard->setMiddleName( vCard.middleName() ); qmlVCard->setLastName( vCard.lastName() ); qmlVCard->setFullName( vCard.fullName() ); qmlVCard->setName( vCard.firstName() ); qmlVCard->setBirthday( vCard.birthday().toString("dd.MM.yyyy") ); qmlVCard->setEMail( vCard.email() ); qmlVCard->setUrl( vCard.url() ); qmlVCard->setJid( bareJid ); flVCardRequest = ""; emit vCardChanged(); } cacheIM->setVCard( bareJid, dataVCard ); } }
void MyXmppClient::initRoster() { qDebug() << "MyXmppClient::initRoster() called"; if (!rosterManager->isRosterReceived()) { qDebug() << "MyXmppClient::initRoster(): roster not available yet"; return; } cachedRoster->cleanList(); QStringList listBareJids = rosterManager->getRosterBareJids(); for( int j=0; j < listBareJids.length(); j++ ) { QString bareJid = listBareJids.at(j); cacheIM->addCacheJid( bareJid ); QXmppRosterIq::Item itemRoster = rosterManager->getRosterEntry( bareJid ); QString name = itemRoster.name(); vCardData vCdata = cacheIM->getVCard( bareJid ); if ( vCdata.isEmpty() && !disableAvatarCaching ) { qDebug() << "MyXmppClient::initRoster():" << bareJid << "has no VCard. Requesting."; vCardManager->requestVCard( bareJid ); } RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->find(bareJid); if (itemExists == 0) { RosterItemModel *itemModel = new RosterItemModel( ); itemModel->setPresence( this->getPicPresence( QXmppPresence::Unavailable ) ); itemModel->setContactName( name ); itemModel->setJid( bareJid ); itemModel->setAvatar(cacheIM->getAvatarCache(bareJid)); cachedRoster->append(itemModel); itemModel = 0; delete itemModel; } else if (itemExists->name() != name) { itemExists->setContactName(name); emit contactRenamed(bareJid,name); } itemExists = 0; delete itemExists; } emit rosterChanged(); }
void MyXmppClient::itemAdded(const QString &bareJid ) { qDebug() << "MyXmppClient::itemAdded(): " << bareJid; QStringList resourcesList = rosterManager->getResources( bareJid ); RosterItemModel *itemExists = (RosterItemModel*)cachedRoster->find(bareJid); if (itemExists == 0) { RosterItemModel *itemModel = new RosterItemModel( ); itemModel->setPresence( this->getPicPresence(QXmppPresence::Unavailable) ); itemModel->setJid( bareJid ); itemModel->setAvatar(cacheIM->getAvatarCache(bareJid)); cachedRoster->append( itemModel ); itemModel = 0; delete itemModel; }; itemExists = 0; delete itemExists; for( int L = 0; L<resourcesList.length(); L++ ) { QString resource = resourcesList.at(L); this->initPresence( bareJid, resource ); } }
void MyXmppClient::initVCard(const QXmppVCardIq &vCard) { QString bareJid = vCard.from(); RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid ); vCardData dataVCard; if( item != 0 ) { /* set nickname */ QXmppRosterIq::Item itemRoster = rosterManager->getRosterEntry( bareJid ); QString nickName = vCard.nickName(); if( (!nickName.isEmpty()) && (!nickName.isNull()) && (itemRoster.name().isEmpty()) ) { qDebug() << "MyXmppClient::initPresence: updating name for"<< bareJid; item->setContactName( nickName ); } /* avatar */ bool isAvatarCreated = true; QString avatarFile = cacheIM->getAvatarCache( bareJid ); if( (avatarFile.isEmpty() || avatarFile == "qrc:/avatar") && vCard.photo() != "" && !disableAvatarCaching) { isAvatarCreated = cacheIM->setAvatarCache( bareJid, vCard.photo() ); } item->setAvatar(cacheIM->getAvatarCache(bareJid)); dataVCard.nickName = nickName; dataVCard.firstName = vCard.firstName(); dataVCard.fullName = vCard.fullName();; dataVCard.middleName = vCard.middleName(); dataVCard.lastName = vCard.lastName(); dataVCard.url = vCard.url(); dataVCard.eMail = vCard.email(); cacheIM->setVCard( bareJid, dataVCard ); } }