Example #1
0
void CertView::setCert(const QList<QSslCertificate> &cert) {
	qlCert = cert;

	if (qlCert.isEmpty()) {
		qlSubjectName->setText(QString());
		qlSubjectEmail->setText(QString());
		qlIssuerName->setText(QString());
	} else {
		QSslCertificate qscCert = qlCert.at(0);

		QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry));

		const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName);

		QString tmpName = name;
		tmpName = tmpName.replace(QLatin1String("\\x"), QLatin1String("%"));
		tmpName = QUrl::fromPercentEncoding(tmpName.toLatin1());

		qlSubjectName->setText(tmpName);

		if (emails.count() > 0)
			qlSubjectEmail->setText(emails.join(QLatin1String("<br />")));
		else
			qlSubjectEmail->setText(tr("(none)"));

		if (qlCert.count() > 1)
			qscCert = qlCert.last();

		const QString &issuer = qscCert.issuerInfo(QSslCertificate::CommonName);
		qlIssuerName->setText((issuer == name) ? tr("Self-signed") : issuer);
	}
}
Example #2
0
void CSkypeProto::OnContactFinded(CContact::Ref contact, HANDLE hSearch)
{
	PROTOSEARCHRESULT psr = {0};
	psr.cbSize = sizeof(psr);
	psr.flags = PSR_TCHAR;

	SEString data;
	contact->GetPropSkypename(data);
	psr.id = ::mir_utf8decodeW(data);
	contact->GetPropDisplayname(data);
	psr.nick  = ::mir_utf8decodeW(data);

	SEString firstName, lastName;
	contact->GetFullname(firstName, lastName);
	psr.firstName = ::mir_utf8decodeW(firstName);
	psr.lastName = ::mir_utf8decodeW(lastName);

	{
		contact->GetPropEmails(data);
		mir_ptr<wchar_t> emails( ::mir_utf8decodeW(data));

		wchar_t* main = ::wcstok(emails, L" ");
		if (main != NULL)
		{
			psr.email = main;
		}
	}

	this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_DATA, hSearch, (LPARAM)&psr);
}
Example #3
0
/*!
  Returns a list of email addresses belonging to the contact, including
  the default email address.
*/
QStringList OContact::emailList() const
{
    QString emailStr = emails();

    QStringList r;
    if ( !emailStr.isEmpty() ) {
	qDebug(" emailstr ");
	QStringList l = QStringList::split( emailSeparator(), emailStr );
	for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
	    r += (*it).simplifyWhiteSpace();
    }

    return r;
}
Example #4
0
void EmailEditWidget::storeContact( KABC::Addressee &contact ) const
{
  QStringList emails( mEmailList );

  // the preferred address is always the first one, remove it...
  if ( !emails.isEmpty() ) {
    emails.removeFirst();
  }

  // ... and prepend the one from the line edit
  if ( !mEmailEdit->text().isEmpty() ) {
      emails.prepend( mEmailEdit->text().toLower() );
  }

  contact.setEmails( emails );
}
Example #5
0
void CertView::setCert(const QList<QSslCertificate> &cert) {
	qlCert = cert;

	if (qlCert.isEmpty()) {
		qlSubjectName->setText(QString());
		qlSubjectEmail->setText(QString());
		qlIssuerName->setText(QString());
		qlExpiry->setText(QString());
	} else {
		QSslCertificate qscCert = qlCert.at(0);

		QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry));

		const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName);

		QString tmpName = name;
		tmpName = tmpName.replace(QLatin1String("\\x"), QLatin1String("%"));
		tmpName = QUrl::fromPercentEncoding(tmpName.toLatin1());

		qlSubjectName->setText(tmpName);

		if (emails.count() > 0)
			qlSubjectEmail->setText(emails.join(QLatin1String("<br />")));
		else
			qlSubjectEmail->setText(tr("(none)"));

		if (qscCert.expiryDate() <= QDateTime::currentDateTime())
			qlExpiry->setText(QString::fromLatin1("<font color=\"red\"><b>%1</b></font>").arg(qscCert.expiryDate().toString(Qt::SystemLocaleDate)));
		else
			qlExpiry->setText(qscCert.expiryDate().toString(Qt::SystemLocaleDate));

		if (qlCert.count() > 1)
			qscCert = qlCert.last();

		const QString &issuer = qscCert.issuerInfo(QSslCertificate::CommonName);
		qlIssuerName->setText((issuer == name) ? tr("Self-signed") : issuer);
	}
}
Example #6
0
/*!
  Returns a rich text formatted QString representing the contents the contact.
*/
QString OPimContact::toRichText() const
{
    QString text;
    QString value, comp, state;
    QString str;
    bool marker = false;

    Config cfg( "qpe" );
    cfg.setGroup( "Appearance" );
    int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );

    // name, jobtitle and company
    if ( !( value = fullName() ).isEmpty() )
        text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>";

    if ( !( value = jobTitle() ).isEmpty() )
        text += Qtopia::escapeString( value ) + " ";

    comp = company();
    if ( !( value = department() ).isEmpty() )
    {
        text += Qtopia::escapeString( value );
        if ( comp )
            text += ", " + Qtopia::escapeString( comp );
    }
    else if ( comp )
        text += "<br>" + Qtopia::escapeString( comp );
    text += "<br><hr>";

    // defailt email
    QString defEmail = defaultEmail();
    if ( !defEmail.isEmpty() )
    {
        text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>"
                + Qtopia::escapeString( defEmail );
        marker = true;
    }

    // business address
    if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
            !businessZip().isEmpty() || !businessCountry().isEmpty() )
    {
        text += QObject::tr( "<br><b>Work Address:</b>" );
        marker = true;
    }

    if ( !( value = businessStreet() ).isEmpty() )
    {
        text += "<br>" + Qtopia::escapeString( value );
        marker = true;
    }

    switch ( addressformat )
    {
    case Zip_City_State:
        { //  Zip_Code City, State
            state = businessState();
            if ( !( value = businessZip() ).isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( value ) + " ";
                marker = true;

            }
            if ( !( value = businessCity() ).isEmpty() )
            {
                marker = true;
                if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
                    text += "<br>";
                text += Qtopia::escapeString( value );
                if ( state )
                    text += ", " + Qtopia::escapeString( state );
            }
            else if ( !state.isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( state );
                marker = true;
            }
            break;
        }
    case City_State_Zip:
        { // City, State Zip_Code
            state = businessState();
            if ( !( value = businessCity() ).isEmpty() )
            {
                marker = true;
                text += "<br>" + Qtopia::escapeString( value );
                if ( state )
                    text += ", " + Qtopia::escapeString( state );
            }
            else if ( !state.isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( state );
                marker = true;
            }
            if ( !( value = businessZip() ).isEmpty() )
            {
                text += " " + Qtopia::escapeString( value );
                marker = true;
            }
            break;
        }
    }

    if ( !( value = businessCountry() ).isEmpty() )
    {
        text += "<br>" + Qtopia::escapeString( value );
        marker = true;
    }

    // rest of Business data
    str = office();
    if ( !str.isEmpty() )
    {
        text += "<br><b>" + QObject::tr( "Office: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = businessWebpage();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = businessPhone();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = businessFax();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = businessMobile();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = businessPager();
    if ( !str.isEmpty() )
    {
        text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }

    // text += "<br>";

    // home address
    if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
            !homeZip().isEmpty() || !homeCountry().isEmpty() )
    {
        text += QObject::tr( "<br><b>Home Address:</b>" );
        marker = true;
    }

    if ( !( value = homeStreet() ).isEmpty() )
    {
        text += "<br>" + Qtopia::escapeString( value );
        marker = true;
    }

    switch ( addressformat )
    {
    case Zip_City_State:
        { //  Zip_Code City, State
            state = homeState();
            if ( !( value = homeZip() ).isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( value ) + " ";
                marker = true;
            }
            if ( !( value = homeCity() ).isEmpty() )
            {
                marker = true;
                if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
                    text += "<br>";
                text += Qtopia::escapeString( value );
                if ( !state.isEmpty() )
                    text += ", " + Qtopia::escapeString( state );
            }
            else if ( !state.isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( state );
                marker = true;
            }
            break;
        }
    case City_State_Zip:
        { // City, State Zip_Code
            state = homeState();
            if ( !( value = homeCity() ).isEmpty() )
            {
                marker = true;
                text += "<br>" + Qtopia::escapeString( value );
                if ( state )
                    text += ", " + Qtopia::escapeString( state );
            }
            else if ( !state.isEmpty() )
            {
                text += "<br>" + Qtopia::escapeString( state );
                marker = true;
            }
            if ( !( value = homeZip() ).isEmpty() )
            {
                text += " " + Qtopia::escapeString( value );
                marker = true;
            }
            break;
        }
    }

    if ( !( value = homeCountry() ).isEmpty() )
    {
        text += "<br>" + Qtopia::escapeString( value );
        marker = true;
    }

    // rest of Home data
    str = homeWebpage();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = homePhone();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = homeFax();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }
    str = homeMobile();
    if ( !str.isEmpty() )
    {
        text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>"
                + Qtopia::escapeString( str );
        marker = true;
    }

    if ( marker )
        text += "<br><hr>";

    // the rest...
    str = emails();
    if ( !str.isEmpty() && ( str != defEmail ) )
        text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>"
                + Qtopia::escapeString( str );
    str = profession();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>"
                + Qtopia::escapeString( str );
    str = assistant();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>"
                + Qtopia::escapeString( str );
    str = manager();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>"
                + Qtopia::escapeString( str );
    str = gender();
    if ( !str.isEmpty() && str.toInt() != 0 )
    {
        text += "<br>";
        if ( str.toInt() == 1 )
            str = QObject::tr( "Male" );
        else if ( str.toInt() == 2 )
            str = QObject::tr( "Female" );
        text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str;
    }
    str = spouse();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>"
                + Qtopia::escapeString( str );
    if ( birthday().isValid() )
    {
        str = TimeString::numberDateString( birthday() );
        text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>"
                + Qtopia::escapeString( str );
    }
    if ( anniversary().isValid() )
    {
        str = TimeString::numberDateString( anniversary() );
        text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>"
                + Qtopia::escapeString( str );
    }
    str = children();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Children: " ) + "</b>"
                + Qtopia::escapeString( str );

    str = nickname();
    if ( !str.isEmpty() )
        text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>"
                + Qtopia::escapeString( str );

    // categories
    if ( categoryNames( "Contacts" ).count() )
    {
        text += "<br><b>" + QObject::tr( "Category:" ) + "</b> ";
        text += categoryNames( "Contacts" ).join( ", " );
    }

    // notes last
    if ( !( value = notes() ).isEmpty() )
    {
        text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> ";
        QRegExp reg( "\n" );

        //QString tmp = Qtopia::escapeString(value);
        QString tmp = QStyleSheet::convertFromPlainText( value );
        //tmp.replace( reg, "<br>" );
        text += "<br>" + tmp + "<br>";
    }
    return text;
}
Example #7
0
	QList<QPair<QString, QVariant>> EntryBase::GetVCardRepresentation () const
	{
		Account_->GetClientConnection ()->FetchVCard (GetJID ());

		const auto vcard = GetVCard ();

		QList<QPair<QString, QVariant>> result
		{
			{ tr ("Photo"), QImage::fromData (vcard.photo ()) },
			{ "JID", vcard.from () },
			{ tr ("Real name"), vcard.fullName () },
			{ tr ("Birthday"), vcard.birthday () },
			{ "URL", vcard.url () },
			{ tr ("About"), vcard.description () }
		};

		for (const auto& phone : vcard.phones ())
		{
			if (phone.number ().isEmpty ())
				continue;

			QStringList attrs;
			if (phone.type () & QXmppVCardPhone::Preferred)
				attrs << tr ("preferred");
			if (phone.type () & QXmppVCardPhone::Home)
				attrs << tr ("home");
			if (phone.type () & QXmppVCardPhone::Work)
				attrs << tr ("work");
			if (phone.type () & QXmppVCardPhone::Cell)
				attrs << tr ("cell");

			result.append ({ tr ("Phone"), attrs.isEmpty () ?
						phone.number () :
						phone.number () + " (" + attrs.join (", ") + ")" });
		}

		for (const auto& email : vcard.emails ())
		{
			if (email.address ().isEmpty ())
				continue;

			QStringList attrs;
			if (email.type () == QXmppVCardEmail::Preferred)
				attrs << tr ("preferred");
			if (email.type () == QXmppVCardEmail::Home)
				attrs << tr ("home");
			if (email.type () == QXmppVCardEmail::Work)
				attrs << tr ("work");
			if (email.type () == QXmppVCardEmail::X400)
				attrs << "X400";

			result.append ({ "Email", attrs.isEmpty () ?
						email.address () :
						email.address () + " (" + attrs.join (", ") + ")" });
		}

		for (const auto& address : vcard.addresses ())
		{
			if ((address.country () + address.locality () + address.postcode () +
					address.region () + address.street ()).isEmpty ())
				continue;

			QStringList attrs;
			if (address.type () & QXmppVCardAddress::Home)
				attrs << tr ("home");
			if (address.type () & QXmppVCardAddress::Work)
				attrs << tr ("work");
			if (address.type () & QXmppVCardAddress::Postal)
				attrs << tr ("postal");
			if (address.type () & QXmppVCardAddress::Preferred)
				attrs << tr ("preferred");

			QString str;
			QStringList fields;
			auto addField = [&fields] (const QString& label, const QString& val)
			{
				if (!val.isEmpty ())
					fields << label.arg (val);
			};
			addField (tr ("Country: %1"), address.country ());
			addField (tr ("Region: %1"), address.region ());
			addField (tr ("Locality: %1", "User's locality"), address.locality ());
			addField (tr ("Street: %1"), address.street ());
			addField (tr ("Postal code: %1"), address.postcode ());

			result.append ({ tr ("Address"), fields });
		}

#if QXMPP_VERSION >= 0x000800
		const auto& orgInfo = vcard.organization ();
		result.append ({ tr ("Organization"), orgInfo.organization () });
		result.append ({ tr ("Organization unit"), orgInfo.unit () });
		result.append ({ tr ("Job title"), orgInfo.title () });
		result.append ({ tr ("Job role"), orgInfo.role () });
#endif
		return result;
	}