void MyXmppClient::itemChanged(const QString &bareJid ) { qDebug() << "MyXmppClient::itemChanged(): " << bareJid; QXmppRosterIq::Item rosterEntry = rosterManager->getRosterEntry( bareJid ); if (rosterEntry.name() != "") { RosterItemModel *item = (RosterItemModel*)cachedRoster->find( bareJid ); if( item != 0 ) item->setContactName( rosterEntry.name() ); emit contactRenamed(bareJid,rosterEntry.name()); item = 0; delete item; } }
int CUserInfoXmpp::UpdateUserInfo(const QXmppRosterIq::Item &rosterItem) { if(m_szJid.isEmpty()) m_szJid = rosterItem.bareJid(); m_Groups = rosterItem.groups(); SetName(rosterItem.name()); m_subscriptionType = FromQxmppSubscriptionType(rosterItem.subscriptionType()); return 0; }
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::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 ); } }