Changeset View
Changeset View
Standalone View
Standalone View
src/icalformat_p.cpp
Show First 20 Lines • Show All 765 Lines • ▼ Show 20 Line(s) | |||||
766 | { | 766 | { | ||
767 | icalproperty *p = icalproperty_new_location(location.toUtf8().constData()); | 767 | icalproperty *p = icalproperty_new_location(location.toUtf8().constData()); | ||
768 | if (isRich) { | 768 | if (isRich) { | ||
769 | icalproperty_add_parameter(p, icalparameter_new_from_string("X-KDE-TEXTFORMAT=HTML")); | 769 | icalproperty_add_parameter(p, icalparameter_new_from_string("X-KDE-TEXTFORMAT=HTML")); | ||
770 | } | 770 | } | ||
771 | return p; | 771 | return p; | ||
772 | } | 772 | } | ||
773 | 773 | | |||
774 | icalproperty *ICalFormatImpl::writeAttendee(const Attendee::Ptr &attendee) | 774 | icalproperty *ICalFormatImpl::writeAttendee(const Attendee &attendee) | ||
775 | { | 775 | { | ||
776 | if (attendee->email().isEmpty()) { | 776 | if (attendee.email().isEmpty()) { | ||
777 | return nullptr; | 777 | return nullptr; | ||
778 | } | 778 | } | ||
779 | 779 | | |||
780 | icalproperty *p = | 780 | icalproperty *p = | ||
781 | icalproperty_new_attendee(QByteArray(QByteArray("mailto:") + attendee->email().toUtf8()).constData()); | 781 | icalproperty_new_attendee(QByteArray(QByteArray("mailto:") + attendee.email().toUtf8()).constData()); | ||
782 | 782 | | |||
783 | if (!attendee->name().isEmpty()) { | 783 | if (!attendee.name().isEmpty()) { | ||
784 | icalproperty_add_parameter(p, | 784 | icalproperty_add_parameter(p, | ||
785 | #if defined(USE_ICAL_3) | 785 | #if defined(USE_ICAL_3) | ||
786 | icalparameter_new_cn(attendee->name().toUtf8().constData())); | 786 | icalparameter_new_cn(attendee.name().toUtf8().constData())); | ||
787 | #else | 787 | #else | ||
788 | icalparameter_new_cn(quoteForParam(attendee->name()).toUtf8().constData())); | 788 | icalparameter_new_cn(quoteForParam(attendee.name()).toUtf8().constData())); | ||
789 | #endif | 789 | #endif | ||
790 | } | 790 | } | ||
791 | 791 | | |||
792 | icalproperty_add_parameter( | 792 | icalproperty_add_parameter( | ||
793 | p, icalparameter_new_rsvp(attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE)); | 793 | p, icalparameter_new_rsvp(attendee.RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE)); | ||
794 | 794 | | |||
795 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | 795 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | ||
796 | switch (attendee->status()) { | 796 | switch (attendee.status()) { | ||
797 | default: | 797 | default: | ||
798 | case Attendee::NeedsAction: | 798 | case Attendee::NeedsAction: | ||
799 | status = ICAL_PARTSTAT_NEEDSACTION; | 799 | status = ICAL_PARTSTAT_NEEDSACTION; | ||
800 | break; | 800 | break; | ||
801 | case Attendee::Accepted: | 801 | case Attendee::Accepted: | ||
802 | status = ICAL_PARTSTAT_ACCEPTED; | 802 | status = ICAL_PARTSTAT_ACCEPTED; | ||
803 | break; | 803 | break; | ||
804 | case Attendee::Declined: | 804 | case Attendee::Declined: | ||
Show All 10 Lines | 813 | case Attendee::Completed: | |||
815 | break; | 815 | break; | ||
816 | case Attendee::InProcess: | 816 | case Attendee::InProcess: | ||
817 | status = ICAL_PARTSTAT_INPROCESS; | 817 | status = ICAL_PARTSTAT_INPROCESS; | ||
818 | break; | 818 | break; | ||
819 | } | 819 | } | ||
820 | icalproperty_add_parameter(p, icalparameter_new_partstat(status)); | 820 | icalproperty_add_parameter(p, icalparameter_new_partstat(status)); | ||
821 | 821 | | |||
822 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 822 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | ||
823 | switch (attendee->role()) { | 823 | switch (attendee.role()) { | ||
824 | case Attendee::Chair: | 824 | case Attendee::Chair: | ||
825 | role = ICAL_ROLE_CHAIR; | 825 | role = ICAL_ROLE_CHAIR; | ||
826 | break; | 826 | break; | ||
827 | default: | 827 | default: | ||
828 | case Attendee::ReqParticipant: | 828 | case Attendee::ReqParticipant: | ||
829 | role = ICAL_ROLE_REQPARTICIPANT; | 829 | role = ICAL_ROLE_REQPARTICIPANT; | ||
830 | break; | 830 | break; | ||
831 | case Attendee::OptParticipant: | 831 | case Attendee::OptParticipant: | ||
832 | role = ICAL_ROLE_OPTPARTICIPANT; | 832 | role = ICAL_ROLE_OPTPARTICIPANT; | ||
833 | break; | 833 | break; | ||
834 | case Attendee::NonParticipant: | 834 | case Attendee::NonParticipant: | ||
835 | role = ICAL_ROLE_NONPARTICIPANT; | 835 | role = ICAL_ROLE_NONPARTICIPANT; | ||
836 | break; | 836 | break; | ||
837 | } | 837 | } | ||
838 | icalproperty_add_parameter(p, icalparameter_new_role(role)); | 838 | icalproperty_add_parameter(p, icalparameter_new_role(role)); | ||
839 | 839 | | |||
840 | icalparameter_cutype cutype = ICAL_CUTYPE_INDIVIDUAL; | 840 | icalparameter_cutype cutype = ICAL_CUTYPE_INDIVIDUAL; | ||
841 | switch (attendee->cuType()) { | 841 | switch (attendee.cuType()) { | ||
842 | case Attendee::Unknown: | 842 | case Attendee::Unknown: | ||
843 | cutype = ICAL_CUTYPE_UNKNOWN; | 843 | cutype = ICAL_CUTYPE_UNKNOWN; | ||
844 | break; | 844 | break; | ||
845 | default: | 845 | default: | ||
846 | case Attendee::Individual: | 846 | case Attendee::Individual: | ||
847 | cutype = ICAL_CUTYPE_INDIVIDUAL; | 847 | cutype = ICAL_CUTYPE_INDIVIDUAL; | ||
848 | break; | 848 | break; | ||
849 | case Attendee::Group: | 849 | case Attendee::Group: | ||
850 | cutype = ICAL_CUTYPE_GROUP; | 850 | cutype = ICAL_CUTYPE_GROUP; | ||
851 | break; | 851 | break; | ||
852 | case Attendee::Resource: | 852 | case Attendee::Resource: | ||
853 | cutype = ICAL_CUTYPE_RESOURCE; | 853 | cutype = ICAL_CUTYPE_RESOURCE; | ||
854 | break; | 854 | break; | ||
855 | case Attendee::Room: | 855 | case Attendee::Room: | ||
856 | cutype = ICAL_CUTYPE_ROOM; | 856 | cutype = ICAL_CUTYPE_ROOM; | ||
857 | break; | 857 | break; | ||
858 | } | 858 | } | ||
859 | icalproperty_add_parameter(p, icalparameter_new_cutype(cutype)); | 859 | icalproperty_add_parameter(p, icalparameter_new_cutype(cutype)); | ||
860 | 860 | | |||
861 | if (!attendee->uid().isEmpty()) { | 861 | if (!attendee.uid().isEmpty()) { | ||
862 | icalparameter *icalparameter_uid = icalparameter_new_x(attendee->uid().toUtf8().constData()); | 862 | icalparameter *icalparameter_uid = icalparameter_new_x(attendee.uid().toUtf8().constData()); | ||
863 | 863 | | |||
864 | icalparameter_set_xname(icalparameter_uid, "X-UID"); | 864 | icalparameter_set_xname(icalparameter_uid, "X-UID"); | ||
865 | icalproperty_add_parameter(p, icalparameter_uid); | 865 | icalproperty_add_parameter(p, icalparameter_uid); | ||
866 | } | 866 | } | ||
867 | 867 | | |||
868 | if (!attendee->delegate().isEmpty()) { | 868 | if (!attendee.delegate().isEmpty()) { | ||
869 | icalparameter *icalparameter_delegate = | 869 | icalparameter *icalparameter_delegate = | ||
870 | icalparameter_new_delegatedto(attendee->delegate().toUtf8().constData()); | 870 | icalparameter_new_delegatedto(attendee.delegate().toUtf8().constData()); | ||
871 | icalproperty_add_parameter(p, icalparameter_delegate); | 871 | icalproperty_add_parameter(p, icalparameter_delegate); | ||
872 | } | 872 | } | ||
873 | 873 | | |||
874 | if (!attendee->delegator().isEmpty()) { | 874 | if (!attendee.delegator().isEmpty()) { | ||
875 | icalparameter *icalparameter_delegator = | 875 | icalparameter *icalparameter_delegator = | ||
876 | icalparameter_new_delegatedfrom(attendee->delegator().toUtf8().constData()); | 876 | icalparameter_new_delegatedfrom(attendee.delegator().toUtf8().constData()); | ||
877 | icalproperty_add_parameter(p, icalparameter_delegator); | 877 | icalproperty_add_parameter(p, icalparameter_delegator); | ||
878 | } | 878 | } | ||
879 | 879 | | |||
880 | return p; | 880 | return p; | ||
881 | } | 881 | } | ||
882 | 882 | | |||
883 | icalproperty *ICalFormatImpl::writeAttachment(const Attachment::Ptr &att) | 883 | icalproperty *ICalFormatImpl::writeAttachment(const Attachment::Ptr &att) | ||
884 | { | 884 | { | ||
▲ Show 20 Lines • Show All 521 Lines • ▼ Show 20 Line(s) | |||||
1406 | { | 1406 | { | ||
1407 | Journal::Ptr journal(new Journal); | 1407 | Journal::Ptr journal(new Journal); | ||
1408 | readIncidence(vjournal, journal, tzList); | 1408 | readIncidence(vjournal, journal, tzList); | ||
1409 | 1409 | | |||
1410 | journal->resetDirtyFields(); | 1410 | journal->resetDirtyFields(); | ||
1411 | return journal; | 1411 | return journal; | ||
1412 | } | 1412 | } | ||
1413 | 1413 | | |||
1414 | Attendee::Ptr ICalFormatImpl::readAttendee(icalproperty *attendee) | 1414 | Attendee ICalFormatImpl::readAttendee(icalproperty *attendee) | ||
1415 | { | 1415 | { | ||
1416 | // the following is a hack to support broken calendars (like WebCalendar 1.0.x) | 1416 | // the following is a hack to support broken calendars (like WebCalendar 1.0.x) | ||
1417 | // that include non-RFC-compliant attendees. Otherwise libical 0.42 asserts. | 1417 | // that include non-RFC-compliant attendees. Otherwise libical 0.42 asserts. | ||
1418 | if (!icalproperty_get_value(attendee)) { | 1418 | if (!icalproperty_get_value(attendee)) { | ||
1419 | return Attendee::Ptr(); | 1419 | return {}; | ||
1420 | } | 1420 | } | ||
1421 | 1421 | | |||
1422 | icalparameter *p = nullptr; | 1422 | icalparameter *p = nullptr; | ||
1423 | 1423 | | |||
1424 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | 1424 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | ||
1425 | if (email.startsWith(QLatin1String("mailto:"), Qt::CaseInsensitive)) { | 1425 | if (email.startsWith(QLatin1String("mailto:"), Qt::CaseInsensitive)) { | ||
1426 | email = email.mid(7); | 1426 | email = email.mid(7); | ||
1427 | } | 1427 | } | ||
1428 | 1428 | | |||
1429 | // libical may return everything after ATTENDEE tag if the rest is | 1429 | // libical may return everything after ATTENDEE tag if the rest is | ||
1430 | // not meaningful. Verify the address to filter out these cases. | 1430 | // not meaningful. Verify the address to filter out these cases. | ||
1431 | if (!Person::isValidEmail(email)) { | 1431 | if (!Person::isValidEmail(email)) { | ||
1432 | return Attendee::Ptr(); | 1432 | return {}; | ||
1433 | } | 1433 | } | ||
1434 | 1434 | | |||
1435 | QString name; | 1435 | QString name; | ||
1436 | QString uid; | 1436 | QString uid; | ||
1437 | p = icalproperty_get_first_parameter(attendee, ICAL_CN_PARAMETER); | 1437 | p = icalproperty_get_first_parameter(attendee, ICAL_CN_PARAMETER); | ||
1438 | if (p) { | 1438 | if (p) { | ||
1439 | name = QString::fromUtf8(icalparameter_get_cn(p)); | 1439 | name = QString::fromUtf8(icalparameter_get_cn(p)); | ||
1440 | } else { | 1440 | } else { | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | 1531 | while (p) { | |||
1534 | if (xname == QLatin1String("X-UID")) { | 1534 | if (xname == QLatin1String("X-UID")) { | ||
1535 | uid = xvalue; | 1535 | uid = xvalue; | ||
1536 | } else { | 1536 | } else { | ||
1537 | custom[xname.toUtf8()] = xvalue; | 1537 | custom[xname.toUtf8()] = xvalue; | ||
1538 | } | 1538 | } | ||
1539 | p = icalproperty_get_next_parameter(attendee, ICAL_X_PARAMETER); | 1539 | p = icalproperty_get_next_parameter(attendee, ICAL_X_PARAMETER); | ||
1540 | } | 1540 | } | ||
1541 | 1541 | | |||
1542 | Attendee::Ptr a(new Attendee(name, email, rsvp, status, role, uid)); | 1542 | Attendee a(name, email, rsvp, status, role, uid); | ||
1543 | a->setCuType(cuType); | 1543 | a.setCuType(cuType); | ||
1544 | a->customProperties().setCustomProperties(custom); | 1544 | a.customProperties().setCustomProperties(custom); | ||
1545 | 1545 | | |||
1546 | p = icalproperty_get_first_parameter(attendee, ICAL_DELEGATEDTO_PARAMETER); | 1546 | p = icalproperty_get_first_parameter(attendee, ICAL_DELEGATEDTO_PARAMETER); | ||
1547 | if (p) { | 1547 | if (p) { | ||
1548 | a->setDelegate(QLatin1String(icalparameter_get_delegatedto(p))); | 1548 | a.setDelegate(QLatin1String(icalparameter_get_delegatedto(p))); | ||
1549 | } | 1549 | } | ||
1550 | 1550 | | |||
1551 | p = icalproperty_get_first_parameter(attendee, ICAL_DELEGATEDFROM_PARAMETER); | 1551 | p = icalproperty_get_first_parameter(attendee, ICAL_DELEGATEDFROM_PARAMETER); | ||
1552 | if (p) { | 1552 | if (p) { | ||
1553 | a->setDelegator(QLatin1String(icalparameter_get_delegatedfrom(p))); | 1553 | a.setDelegator(QLatin1String(icalparameter_get_delegatedfrom(p))); | ||
1554 | } | 1554 | } | ||
1555 | 1555 | | |||
1556 | return a; | 1556 | return a; | ||
1557 | } | 1557 | } | ||
1558 | 1558 | | |||
1559 | Person ICalFormatImpl::readOrganizer(icalproperty *organizer) | 1559 | Person ICalFormatImpl::readOrganizer(icalproperty *organizer) | ||
1560 | { | 1560 | { | ||
1561 | QString email = QString::fromUtf8(icalproperty_get_organizer(organizer)); | 1561 | QString email = QString::fromUtf8(icalproperty_get_organizer(organizer)); | ||
▲ Show 20 Lines • Show All 1531 Lines • Show Last 20 Lines |