Beispiel #1
0
Contact::ref UserSearchController::convertJIDtoContact(const JID& jid) {
    Contact::ref contact = std::make_shared<Contact>();
    contact->jid = jid;

    // name lookup
    boost::optional<XMPPRosterItem> rosterItem = rosterController_->getItem(jid);
    if (rosterItem && !rosterItem->getName().empty()) {
        contact->name = rosterItem->getName();
    } else {
        VCard::ref vcard = vcardManager_->getVCard(jid);
        if (vcard && !vcard->getFullName().empty()) {
            contact->name = vcard->getFullName();
        } else {
            contact->name = jid.toString();
        }
    }

    // presence lookup
    Presence::ref presence = presenceOracle_->getAccountPresence(jid);
    if (presence) {
        contact->statusType = presence->getShow();
    } else {
        contact->statusType = StatusShow::None;
    }

    // avatar lookup
    contact->avatarPath = avatarManager_->getAvatarPath(jid);
    return contact;
}
std::vector<std::string> ContactEditController::nameSuggestionsFromVCard(VCard::ref vcard) {
	std::vector<std::string> suggestions;
	if (!vcard->getNickname().empty()) {
		suggestions.push_back(vcard->getNickname());
	}
	if (!vcard->getFullName().empty()) {
		suggestions.push_back(vcard->getFullName());
	}
	if (!vcard->getGivenName().empty()) {
		std::string suggestedName;
		suggestedName = vcard->getGivenName();
		boost::algorithm::trim(suggestedName);
		suggestions.push_back(suggestedName);
	}
	return suggestions;
}
        void testGetVCard() {
            std::shared_ptr<VCardFileStorage> testling(createTestling());
            VCard::ref vcard(new VCard());
            vcard->setFullName("Alice In Wonderland");
            testling->setVCard(JID("*****@*****.**"), vcard);

            VCard::ref result = testling->getVCard(JID("*****@*****.**"));
            CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), result->getFullName());
        }
Beispiel #4
0
		void testGet_ExistingVCard() {
			boost::shared_ptr<VCardManager> testling = createManager();
			VCard::ref vcard(new VCard());
			vcard->setFullName("Foo Bar");
			vcardStorage->setVCard(JID("[email protected]/baz"), vcard);

			VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("[email protected]/baz"));

			CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), result->getFullName());
			CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel->sentStanzas.size()));
		}
Beispiel #5
0
void QtVCardWidget::setVCard(VCard::ref vcard) {
    clearFields();
    this->vcard = std::make_shared<VCard>(*vcard);
    ui->photoAndName->setFormattedName(P2QSTRING(vcard->getFullName()));
    ui->photoAndName->setNickname(P2QSTRING(vcard->getNickname()));
    ui->photoAndName->setPrefix(P2QSTRING(vcard->getPrefix()));
    ui->photoAndName->setGivenName(P2QSTRING(vcard->getGivenName()));
    ui->photoAndName->setMiddleName(P2QSTRING(vcard->getMiddleName()));
    ui->photoAndName->setFamilyName(P2QSTRING(vcard->getFamilyName()));
    ui->photoAndName->setSuffix(P2QSTRING(vcard->getSuffix()));
    ui->photoAndName->setAvatar(vcard->getPhoto(), vcard->getPhotoType());

    for (const auto& address : vcard->getEMailAddresses()) {
        if (address.isInternet) {
            QtVCardInternetEMailField* internetEmailField = new QtVCardInternetEMailField(this, ui->cardFields);
            internetEmailField->initialize();
            internetEmailField->setInternetEMailAddress(address);
            appendField(internetEmailField);
        }
    }

    for (const auto& telephone : vcard->getTelephones()) {
        QtVCardTelephoneField* telField = new QtVCardTelephoneField(this, ui->cardFields);
        telField->initialize();
        telField->setTelephone(telephone);
        appendField(telField);
    }

    for (const auto& address : vcard->getAddresses()) {
        QtVCardAddressField* addressField = new QtVCardAddressField(this, ui->cardFields);
        addressField->initialize();
        addressField->setAddress(address);
        appendField(addressField);
    }

    for (const auto& label : vcard->getAddressLabels()) {
        QtVCardAddressLabelField* addressLabelField = new QtVCardAddressLabelField(this, ui->cardFields);
        addressLabelField->initialize();
        addressLabelField->setAddressLabel(label);
        appendField(addressLabelField);
    }

    if (!vcard->getBirthday().is_not_a_date_time()) {
        QtVCardBirthdayField* bdayField = new QtVCardBirthdayField(this, ui->cardFields);
        bdayField->initialize();
        bdayField->setBirthday(vcard->getBirthday());
        appendField(bdayField);
    }

    for (const auto& jid : vcard->getJIDs()) {
        QtVCardJIDField* jidField = new QtVCardJIDField(this, ui->cardFields);
        jidField->initialize();
        jidField->setJID(jid);
        appendField(jidField);
    }

    if (!vcard->getDescription().empty()) {
        QtVCardDescriptionField* descField = new QtVCardDescriptionField(this, ui->cardFields);
        descField->initialize();
        descField->setDescription(vcard->getDescription());
        appendField(descField);
    }

    for (const auto& org : vcard->getOrganizations()) {
        QtVCardOrganizationField* orgField = new QtVCardOrganizationField(this, ui->cardFields);
        orgField->initialize();
        orgField->setOrganization(org);
        appendField(orgField);
    }

    for (const auto& role : vcard->getRoles()) {
        QtVCardRoleField* roleField = new QtVCardRoleField(this, ui->cardFields);
        roleField->initialize();
        roleField->setRole(role);
        appendField(roleField);
    }

    for (const auto& title : vcard->getTitles()) {
        QtVCardTitleField* titleField = new QtVCardTitleField(this, ui->cardFields);
        titleField->initialize();
        titleField->setTitle(title);
        appendField(titleField);
    }

    for (const auto& url : vcard->getURLs()) {
        QtVCardURLField* urlField = new QtVCardURLField(this, ui->cardFields);
        urlField->initialize();
        urlField->setURL(url);
        appendField(urlField);
    }

    relayoutToolButton();
    setEditable(editable);
}