Changeset View
Changeset View
Standalone View
Standalone View
src/vcardtool.cpp
Show First 20 Lines • Show All 646 Lines • ▼ Show 20 Line(s) | 646 | for (const FieldGroup &group : lstGroup) { | |||
---|---|---|---|---|---|
647 | VCardLine line(group.fieldGroupName(), group.value()); | 647 | VCardLine line(group.fieldGroupName(), group.value()); | ||
648 | addParameters(line, group.parameters()); | 648 | addParameters(line, group.parameters()); | ||
649 | card.addLine(line); | 649 | card.addLine(line); | ||
650 | } | 650 | } | ||
651 | 651 | | |||
652 | // IMPP (supported in vcard 3 too) | 652 | // IMPP (supported in vcard 3 too) | ||
653 | const QVector<Impp> lstImpp = (*addrIt).imppList(); | 653 | const QVector<Impp> lstImpp = (*addrIt).imppList(); | ||
654 | for (const Impp &impp : lstImpp) { | 654 | for (const Impp &impp : lstImpp) { | ||
655 | VCardLine line(QStringLiteral("IMPP"), impp.address()); | 655 | VCardLine line(QStringLiteral("IMPP"), impp.address().url()); | ||
656 | line.addParameter(QStringLiteral("X-SERVICE-TYPE"), Impp::typeToString(impp.type())); | | |||
657 | QMapIterator<QString, QStringList> i(impp.parameters()); | 656 | QMapIterator<QString, QStringList> i(impp.parameters()); | ||
658 | while (i.hasNext()) { | 657 | while (i.hasNext()) { | ||
659 | i.next(); | 658 | i.next(); | ||
660 | if (i.key().toLower() != QStringLiteral("x-service-type")) { | 659 | if (i.key().toLower() != QStringLiteral("x-service-type")) { | ||
661 | line.addParameter(i.key(), i.value().join(QLatin1Char(','))); | 660 | line.addParameter(i.key(), i.value().join(QLatin1Char(','))); | ||
662 | } | 661 | } | ||
663 | } | 662 | } | ||
664 | card.addLine(line); | 663 | card.addLine(line); | ||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 865 | else if (identifier == QLatin1String("caluri")) { | |||
868 | calurl.setType(CalendarUrl::CALUri); | 867 | calurl.setType(CalendarUrl::CALUri); | ||
869 | const QUrl url = QUrl((*lineIt).value().toString()); | 868 | const QUrl url = QUrl((*lineIt).value().toString()); | ||
870 | calurl.setUrl(url); | 869 | calurl.setUrl(url); | ||
871 | calurl.setParameters((*lineIt).parameterMap()); | 870 | calurl.setParameters((*lineIt).parameterMap()); | ||
872 | addr.insertCalendarUrl(calurl); | 871 | addr.insertCalendarUrl(calurl); | ||
873 | } | 872 | } | ||
874 | //IMPP | 873 | //IMPP | ||
875 | else if (identifier == QLatin1String("impp")) { | 874 | else if (identifier == QLatin1String("impp")) { | ||
876 | QString imppStr = (*lineIt).value().toString(); | 875 | QUrl imppUrl((*lineIt).value().toString()); | ||
877 | Impp impp; | 876 | Impp impp; | ||
878 | impp.setParameters((*lineIt).parameterMap()); | 877 | impp.setParameters((*lineIt).parameterMap()); | ||
879 | if (!(*lineIt).parameter(QStringLiteral("x-service-type")).isEmpty()) { | 878 | if (!(*lineIt).parameter(QStringLiteral("x-service-type")).isEmpty() && imppUrl.scheme().isEmpty()) { | ||
880 | impp.setAddress(imppStr); | 879 | imppUrl.setScheme(normalizeImppServiceType((*lineIt).parameter(QStringLiteral("x-service-type")).toLower())); | ||
881 | const QString serviceType = (*lineIt).parameter(QStringLiteral("x-service-type")).toLower(); | | |||
882 | imppService(serviceType, impp); | | |||
883 | } else { | | |||
884 | const int pos = imppStr.indexOf(QLatin1Char(':')); | | |||
885 | if (pos != -1) { | | |||
886 | const QString serviceType = imppStr.left(pos); | | |||
887 | const QString address = imppStr.right(imppStr.length() - pos - 1); | | |||
888 | impp.setAddress(address); | | |||
889 | imppService(serviceType, impp); | | |||
890 | } | | |||
891 | } | 880 | } | ||
881 | impp.setAddress(imppUrl); | ||||
892 | addr.insertImpp(impp); | 882 | addr.insertImpp(impp); | ||
893 | } | 883 | } | ||
894 | // CLASS | 884 | // CLASS | ||
895 | else if (identifier == QLatin1String("class")) { | 885 | else if (identifier == QLatin1String("class")) { | ||
896 | addr.setSecrecy(parseSecrecy(*lineIt)); | 886 | addr.setSecrecy(parseSecrecy(*lineIt)); | ||
897 | } | 887 | } | ||
898 | // GENDER | 888 | // GENDER | ||
899 | else if (identifier == QLatin1String("gender")) { | 889 | else if (identifier == QLatin1String("gender")) { | ||
▲ Show 20 Lines • Show All 676 Lines • ▼ Show 20 Line(s) | 1565 | if (!mid.isEmpty()) { | |||
1576 | list << mid; | 1566 | list << mid; | ||
1577 | } else { | 1567 | } else { | ||
1578 | list << QString(); | 1568 | list << QString(); | ||
1579 | } | 1569 | } | ||
1580 | 1570 | | |||
1581 | return list; | 1571 | return list; | ||
1582 | } | 1572 | } | ||
1583 | 1573 | | |||
1584 | void VCardTool::imppService(const QString &serviceType, KContacts::Impp &impp) const | 1574 | QString VCardTool::normalizeImppServiceType(const QString &serviceType) const | ||
1585 | { | 1575 | { | ||
1586 | if (serviceType == QLatin1String("facebook")) { | 1576 | if (serviceType == QLatin1String("jabber")) { | ||
1587 | impp.setType(KContacts::Impp::Facebook); | 1577 | return QStringLiteral("xmpp"); | ||
1588 | } else if (serviceType == QLatin1String("jabber")) { | 1578 | } | ||
1589 | impp.setType(KContacts::Impp::Jabber); | 1579 | if (serviceType == QLatin1String("yahoo")) { | ||
1590 | } else if (serviceType == QLatin1String("sip")) { | 1580 | return QStringLiteral("ymsgr"); | ||
1591 | impp.setType(KContacts::Impp::Sip); | 1581 | } | ||
1592 | } else if (serviceType == QLatin1String("aim")) { | 1582 | if (serviceType == QLatin1String("gadugadu")) { | ||
1593 | impp.setType(KContacts::Impp::Aim); | 1583 | return QStringLiteral("gg"); | ||
1594 | } else if (serviceType == QLatin1String("msn")) { | | |||
1595 | impp.setType(KContacts::Impp::Msn); | | |||
1596 | } else if (serviceType == QLatin1String("twitter")) { | | |||
1597 | impp.setType(KContacts::Impp::Twitter); | | |||
1598 | } else if (serviceType == QLatin1String("googletalk")) { | | |||
1599 | impp.setType(KContacts::Impp::GoogleTalk); | | |||
1600 | } else if (serviceType == QLatin1String("xmpp")) { | | |||
1601 | impp.setType(KContacts::Impp::Xmpp); | | |||
1602 | } else if (serviceType == QLatin1String("icq")) { | | |||
1603 | impp.setType(KContacts::Impp::Icq); | | |||
1604 | } else if (serviceType == QLatin1String("yahoo")) { | | |||
1605 | impp.setType(KContacts::Impp::Yahoo); | | |||
1606 | } else if (serviceType == QLatin1String("qq")) { | | |||
1607 | impp.setType(KContacts::Impp::Qq); | | |||
1608 | } else if (serviceType == QLatin1String("gadugadu")) { | | |||
1609 | impp.setType(KContacts::Impp::GaduGadu); | | |||
1610 | } else if (serviceType == QLatin1String("owncloud-handle")) { | | |||
1611 | impp.setType(KContacts::Impp::Ownclound); | | |||
1612 | } else if (serviceType == QLatin1String("skype")) { | | |||
1613 | impp.setType(KContacts::Impp::Skype); | | |||
1614 | } else { | | |||
1615 | qCDebug(KCONTACTS_LOG) << "unknown service type " << serviceType; | | |||
1616 | } | 1584 | } | ||
1585 | return serviceType; | ||||
1617 | } | 1586 | } |