Example #1
0
QString ApplicationInfo::vCardDir()
{
	QDir vcard(pathToProfile(activeProfile) + "/vcard");
	if (!vcard.exists()) {
		QDir profile(pathToProfile(activeProfile));
		profile.mkdir("vcard");
	}

	return vcard.path();
}
Example #2
0
QString SeasideCache::exportContacts()
{
    QVersitContactExporter exporter;

    QList<QContact> contacts;
    contacts.reserve(instance->m_people.count());

    QList<QContactLocalId> contactsToFetch;
    contactsToFetch.reserve(instance->m_people.count());

    const QContactLocalId selfId = instance->m_manager.selfContactId();

    typedef QHash<QContactLocalId, SeasideCacheItem>::iterator iterator;
    for (iterator it = instance->m_people.begin(); it != instance->m_people.end(); ++it) {
        if (it.key() == selfId) {
            continue;
        } else if (it->hasCompleteContact) {
            contacts.append(it->contact);
        } else {
            contactsToFetch.append(it.key());
        }
    }

    if (!contactsToFetch.isEmpty()) {
        QList<QContact> fetchedContacts = instance->m_manager.contacts(contactsToFetch);
        contacts.append(fetchedContacts);
    }

    if (!exporter.exportContacts(contacts)) {
        qWarning() << Q_FUNC_INFO << "Failed to export contacts: " << exporter.errorMap();
        return QString();
    }

    QFile vcard(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)
              + QDir::separator()
              + QDateTime::currentDateTime().toString("ss_mm_hh_dd_mm_yyyy")
              + ".vcf");

    if (!vcard.open(QIODevice::WriteOnly)) {
        qWarning() << "Cannot open " << vcard.fileName();
        return QString();
    }

    QVersitWriter writer(&vcard);
    if (!writer.startWriting(exporter.documents())) {
        qWarning() << Q_FUNC_INFO << "Can't start writing vcards " << writer.error();
        return QString();
    }

    // TODO: thread
    writer.waitForFinished();
    return vcard.fileName();
}
Example #3
0
/** Imports contacts from a vCard present in descriptor*/
void CAgentTest::ImportContactsFromDescriptorL(const TDesC8& aVCard)
	{
	RDesReadStream vcard(aVCard);
	CleanupClosePushL(vcard);
	CArrayPtr<CContactItem>* contactItems;
	TBool success = EFalse;
	contactItems = iDb->ImportContactsL(TUid::Uid(KUidVCardConvDefaultImpl), vcard, success, CContactDatabase::ETTFormat);
	CleanupStack::PushL(TCleanupItem(CleanUpResetAndDestroy, contactItems));
	iIdArray->Reset();
	TContactItemId contactId;
	for(TInt loop = 0;loop < contactItems->Count();++loop)
		{
		contactId = (*contactItems)[loop]->Id();
		iIdArray->AddL(contactId);		
		}
	CleanupStack::PopAndDestroy(contactItems);
	CleanupStack::PopAndDestroy(&vcard);
	}
Example #4
0
void
iq (int fd){

    char *xmlns;

    xmlns = xmlget(client[fd].buffer, "iq.query..xmlns");
    if (!strcmp(xmlns,"jabber:iq:agents")) {
        agents(fd);
    } else if (!strcmp(xmlns,"jabber:iq:roster")) { 
        roster(fd);
    } else if (!strcmp(xmlns,"vcard-temp")) { 
        vcard(fd);
    } else {
        /*  */
        /* send back an error */
    }

    free (xmlns);
}
QString SeasidePeopleModel::exportContacts() const
{
    QVersitContactExporter exporter;

    QList<QContact> contacts;
    contacts.reserve(priv->contactIds.size());

    foreach (const QContactLocalId &contactId, priv->contactIds) {
        SeasidePerson *p = personById(contactId);

        if (p->id() == manager()->selfContactId())
            continue;

        contacts.append(p->contact());
    }

    if (!exporter.exportContacts(contacts)) {
        qWarning() << Q_FUNC_INFO << "Failed to export contacts: " << exporter.errorMap();
        return QString();
    }

    QFile
        vcard(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)
              + QDir::separator()
              + QDateTime::currentDateTime().toString("ss_mm_hh_dd_mm_yyyy")
              + ".vcf");

    if (!vcard.open(QIODevice::WriteOnly)) {
        qWarning() << "Cannot open " << vcard.fileName();
        return QString();
    }

    QVersitWriter writer(&vcard);
    if (!writer.startWriting(exporter.documents())) {
        qWarning() << Q_FUNC_INFO << "Can't start writing vcards " << writer.error();
        return QString();
    }

    // TODO: thread
    writer.waitForFinished();
    return vcard.fileName();
}
Example #6
0
/*! \internal */
void EmailService::emailVCard( const QString&, const QMailMessageId&, const QString& filename, const QString& description )
{
    qLog(Messaging) << "EmailService::emailVCard( , ," << filename << "," << description << ")";

    emit vcard(filename, description);
}
Example #7
0
/*!
    Direct the \i Email service to interact with the user to compose a new
    e-mail message for sending the vcard data in \a request.

    This slot corresponds to a QDS service with a request data type of
    "text/x-vcard" and no response data.

    This slot corresponds to the QCop service message
    \c{Email::emailVCard(QDSActionRequest)}.
*/
void EmailService::emailVCard( const QDSActionRequest& request )
{
    qLog(Messaging) << "EmailService::emailVCard( QDSActionRequest )";

    emit vcard(request);
}