author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libicalss/icalclassify.c | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libicalss/icalclassify.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libicalss/icalclassify.c | 132 |
1 files changed, 47 insertions, 85 deletions
diff --git a/libical/src/libicalss/icalclassify.c b/libical/src/libicalss/icalclassify.c index c029309..61ddbd3 100644 --- a/libical/src/libicalss/icalclassify.c +++ b/libical/src/libicalss/icalclassify.c | |||
@@ -26,10 +26,10 @@ | |||
26 | #include "config.h" | 26 | #include "config.h" |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #include "icalerror.h" | ||
30 | #include "ical.h" | 29 | #include "ical.h" |
31 | #include "icalclassify.h" | 30 | #include "icalclassify.h" |
32 | #include "icalmemory.h" | 31 | #include "icalmemory.h" |
32 | |||
33 | #include <ctype.h> /* For tolower() */ | 33 | #include <ctype.h> /* For tolower() */ |
34 | #include <string.h> /* for index() */ | 34 | #include <string.h> /* for index() */ |
35 | #include <stdlib.h> /* for malloc and free */ | 35 | #include <stdlib.h> /* for malloc and free */ |
@@ -146,7 +146,7 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c, | |||
146 | p != 0; | 146 | p != 0; |
147 | p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) | 147 | p = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY)) |
148 | { | 148 | { |
149 | const char* this_attendee | 149 | char* this_attendee |
150 | = icalclassify_lowercase(icalproperty_get_attendee(p)); | 150 | = icalclassify_lowercase(icalproperty_get_attendee(p)); |
151 | char* this_upn = strchr(this_attendee,':'); | 151 | char* this_upn = strchr(this_attendee,':'); |
152 | 152 | ||
@@ -157,10 +157,14 @@ icalproperty* icalclassify_find_attendee(icalcomponent *c, | |||
157 | } | 157 | } |
158 | 158 | ||
159 | if(strcmp(this_upn,upn)==0){ | 159 | if(strcmp(this_upn,upn)==0){ |
160 | free(lattendee); | ||
161 | free(this_attendee); | ||
160 | return p; | 162 | return p; |
161 | } | 163 | } |
162 | 164 | ||
165 | free(this_attendee); | ||
163 | } | 166 | } |
167 | free(lattendee); | ||
164 | 168 | ||
165 | return 0; | 169 | return 0; |
166 | 170 | ||
@@ -284,7 +288,7 @@ int icalssutil_is_rescheduled(icalcomponent* a,icalcomponent* b) | |||
284 | p1 = icalcomponent_get_first_property(i1,kind_array[i]); | 288 | p1 = icalcomponent_get_first_property(i1,kind_array[i]); |
285 | p2 = icalcomponent_get_first_property(i2,kind_array[i]); | 289 | p2 = icalcomponent_get_first_property(i2,kind_array[i]); |
286 | 290 | ||
287 | if( (p1!=0)^(p1!=0) ){ | 291 | if( (p1!=0)^(p2!=0) ){ |
288 | /* Return true if the property exists in one component and not | 292 | /* Return true if the property exists in one component and not |
289 | the other */ | 293 | the other */ |
290 | return 1; | 294 | return 1; |
@@ -546,7 +550,6 @@ int icalclassify_reply_crasher_decline( | |||
546 | struct icalclassify_parts *match, | 550 | struct icalclassify_parts *match, |
547 | const char* user) | 551 | const char* user) |
548 | { | 552 | { |
549 | icalparameter_partstat partstat; | ||
550 | icalproperty* attendee; | 553 | icalproperty* attendee; |
551 | icalclassify_pre; | 554 | icalclassify_pre; |
552 | 555 | ||
@@ -642,47 +645,47 @@ int icalclassify_delinecounter( | |||
642 | struct icalclassify_map { | 645 | struct icalclassify_map { |
643 | icalproperty_method method; | 646 | icalproperty_method method; |
644 | int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); | 647 | int (*fn)(struct icalclassify_parts *comp,struct icalclassify_parts *match, const char* user); |
645 | ical_class class; | 648 | icalproperty_xlicclass class; |
646 | } icalclassify_map[] = | 649 | } icalclassify_map[] = |
647 | { {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_PUBLISH_NEW_CLASS}, | 650 | { {ICAL_METHOD_PUBLISH,icalclassify_publish_new,ICAL_XLICCLASS_PUBLISHNEW}, |
648 | {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_PUBLISH_UPDATE_CLASS}, | 651 | {ICAL_METHOD_PUBLISH,icalclassify_publish_update,ICAL_XLICCLASS_PUBLISHUPDATE}, |
649 | {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_PUBLISH_FREEBUSY_CLASS}, | 652 | {ICAL_METHOD_PUBLISH,icalclassify_publish_freebusy,ICAL_XLICCLASS_PUBLISHFREEBUSY}, |
650 | {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_REQUEST_DELEGATE_CLASS}, | 653 | {ICAL_METHOD_REQUEST,icalclassify_request_delegate,ICAL_XLICCLASS_REQUESTDELEGATE}, |
651 | {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_REQUEST_NEW_CLASS}, | 654 | {ICAL_METHOD_REQUEST,icalclassify_request_new,ICAL_XLICCLASS_REQUESTNEW}, |
652 | {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_REQUEST_UPDATE_CLASS}, | 655 | {ICAL_METHOD_REQUEST,icalclassify_request_update,ICAL_XLICCLASS_REQUESTUPDATE}, |
653 | {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_REQUEST_RESCHEDULE_CLASS}, | 656 | {ICAL_METHOD_REQUEST,icalclassify_request_reschedule,ICAL_XLICCLASS_REQUESTRESCHEDULE}, |
654 | 657 | ||
655 | {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_REQUEST_NEW_ORGANIZER_CLASS}, | 658 | {ICAL_METHOD_REQUEST,icalclassify_request_new_organizer,ICAL_XLICCLASS_REQUESTNEWORGANIZER}, |
656 | {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_REQUEST_FORWARD_CLASS}, | 659 | {ICAL_METHOD_REQUEST,icalclassify_request_forward,ICAL_XLICCLASS_REQUESTFORWARD}, |
657 | {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_REQUEST_STATUS_CLASS}, | 660 | {ICAL_METHOD_REQUEST,icalclassify_request_status,ICAL_XLICCLASS_REQUESTSTATUS}, |
658 | {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_REQUEST_FREEBUSY_CLASS}, | 661 | {ICAL_METHOD_REQUEST,icalclassify_request_freebusy,ICAL_XLICCLASS_REQUESTFREEBUSY}, |
659 | 662 | ||
660 | {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_REPLY_ACCEPT_CLASS}, | 663 | {ICAL_METHOD_REPLY,icalclassify_reply_accept,ICAL_XLICCLASS_REPLYACCEPT}, |
661 | {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_REPLY_DECLINE_CLASS}, | 664 | {ICAL_METHOD_REPLY,icalclassify_reply_decline,ICAL_XLICCLASS_REPLYDECLINE}, |
662 | {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_REPLY_DELEGATE_CLASS}, | 665 | {ICAL_METHOD_REPLY,icalclassify_reply_delegate,ICAL_XLICCLASS_REPLYDELEGATE}, |
663 | {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_REPLY_CRASHER_ACCEPT_CLASS}, | 666 | {ICAL_METHOD_REPLY,icalclassify_reply_crasher_accept,ICAL_XLICCLASS_REPLYCRASHERACCEPT}, |
664 | {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_REPLY_CRASHER_DECLINE_CLASS}, | 667 | {ICAL_METHOD_REPLY,icalclassify_reply_crasher_decline,ICAL_XLICCLASS_REPLYCRASHERDECLINE}, |
665 | 668 | ||
666 | {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_ADD_INSTANCE_CLASS}, | 669 | {ICAL_METHOD_ADD,icalclassify_add_instance,ICAL_XLICCLASS_ADDINSTANCE}, |
667 | 670 | ||
668 | {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_CANCEL_EVENT_CLASS}, | 671 | {ICAL_METHOD_CANCEL,icalclassify_cancel_event,ICAL_XLICCLASS_CANCELEVENT}, |
669 | {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_CANCEL_INSTANCE_CLASS}, | 672 | {ICAL_METHOD_CANCEL,icalclassify_cancel_instance,ICAL_XLICCLASS_CANCELINSTANCE}, |
670 | {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_CANCEL_ALL_CLASS}, | 673 | {ICAL_METHOD_CANCEL,icalclassify_cancel_all,ICAL_XLICCLASS_CANCELALL}, |
671 | 674 | ||
672 | {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_REFRESH_CLASS}, | 675 | {ICAL_METHOD_REFRESH,icalclassify_refesh,ICAL_XLICCLASS_REFRESH}, |
673 | {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_COUNTER_CLASS}, | 676 | {ICAL_METHOD_COUNTER,icalclassify_counter,ICAL_XLICCLASS_COUNTER}, |
674 | {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_DECLINECOUNTER_CLASS}, | 677 | {ICAL_METHOD_DECLINECOUNTER,icalclassify_delinecounter,ICAL_XLICCLASS_DECLINECOUNTER}, |
675 | {ICAL_METHOD_NONE,0,ICAL_NO_CLASS} | 678 | {ICAL_METHOD_NONE,0,ICAL_XLICCLASS_NONE} |
676 | }; | 679 | }; |
677 | 680 | ||
678 | 681 | ||
679 | ical_class icalclassify(icalcomponent* c,icalcomponent* match, | 682 | icalproperty_xlicclass icalclassify(icalcomponent* c,icalcomponent* match, |
680 | const char* user) | 683 | const char* user) |
681 | { | 684 | { |
682 | icalcomponent *inner; | 685 | icalcomponent *inner; |
683 | icalproperty *p; | 686 | icalproperty *p; |
684 | icalproperty_method method; | 687 | icalproperty_method method; |
685 | ical_class class = ICAL_UNKNOWN_CLASS; | 688 | icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN; |
686 | 689 | ||
687 | int i; | 690 | int i; |
688 | 691 | ||
@@ -692,7 +695,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match, | |||
692 | inner = icalcomponent_get_first_real_component(c); | 695 | inner = icalcomponent_get_first_real_component(c); |
693 | 696 | ||
694 | if (inner == 0) { | 697 | if (inner == 0) { |
695 | return ICAL_NO_CLASS; | 698 | return ICAL_XLICCLASS_NONE; |
696 | } | 699 | } |
697 | 700 | ||
698 | icalssutil_get_parts(c,&comp_parts); | 701 | icalssutil_get_parts(c,&comp_parts); |
@@ -709,7 +712,8 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match, | |||
709 | icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0) | 712 | icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0) |
710 | { | 713 | { |
711 | /* comp has a smaller sequence and a later DTSTAMP */ | 714 | /* comp has a smaller sequence and a later DTSTAMP */ |
712 | return ICAL_MISSEQUENCED_CLASS; | 715 | class = ICAL_XLICCLASS_MISSEQUENCED; |
716 | goto CLEANUP; | ||
713 | } | 717 | } |
714 | 718 | ||
715 | if( (comp_parts.sequence<match_parts.sequence ) | 719 | if( (comp_parts.sequence<match_parts.sequence ) |
@@ -718,14 +722,16 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match, | |||
718 | ( comp_parts.sequence == match_parts.sequence && | 722 | ( comp_parts.sequence == match_parts.sequence && |
719 | icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){ | 723 | icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){ |
720 | 724 | ||
721 | return ICAL_OBSOLETE_CLASS; | 725 | class = ICAL_XLICCLASS_OBSOLETE; |
726 | goto CLEANUP; | ||
722 | } | 727 | } |
723 | 728 | ||
724 | } | 729 | } |
725 | 730 | ||
726 | p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); | 731 | p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY); |
727 | if (p == 0) { | 732 | if (p == 0) { |
728 | return ICAL_UNKNOWN_CLASS; | 733 | class = ICAL_XLICCLASS_UNKNOWN; |
734 | goto CLEANUP; | ||
729 | } | 735 | } |
730 | method = icalproperty_get_method(p); | 736 | method = icalproperty_get_method(p); |
731 | 737 | ||
@@ -738,6 +744,7 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match, | |||
738 | } | 744 | } |
739 | } | 745 | } |
740 | 746 | ||
747 | CLEANUP: | ||
741 | icalssutil_free_parts(&comp_parts); | 748 | icalssutil_free_parts(&comp_parts); |
742 | icalssutil_free_parts(&match_parts); | 749 | icalssutil_free_parts(&match_parts); |
743 | 750 | ||
@@ -745,48 +752,3 @@ ical_class icalclassify(icalcomponent* c,icalcomponent* match, | |||
745 | 752 | ||
746 | } | 753 | } |
747 | 754 | ||
748 | struct class_map { | ||
749 | ical_class class; | ||
750 | char *str; | ||
751 | } class_map[] = { | ||
752 | {ICAL_NO_CLASS,"No class"}, | ||
753 | {ICAL_PUBLISH_NEW_CLASS,"New Publish"}, | ||
754 | {ICAL_PUBLISH_UPDATE_CLASS,"Publish Update"}, | ||
755 | {ICAL_PUBLISH_FREEBUSY_CLASS,"Publish freebusy"}, | ||
756 | {ICAL_REQUEST_NEW_CLASS,"New request"}, | ||
757 | {ICAL_REQUEST_UPDATE_CLASS,"Update"}, | ||
758 | {ICAL_REQUEST_RESCHEDULE_CLASS,"Reschedule"}, | ||
759 | {ICAL_REQUEST_DELEGATE_CLASS,"Delegate request"}, | ||
760 | {ICAL_REQUEST_NEW_ORGANIZER_CLASS,"New Organizer"}, | ||
761 | {ICAL_REQUEST_FORWARD_CLASS,"Forward"}, | ||
762 | {ICAL_REQUEST_STATUS_CLASS,"Status request"}, | ||
763 | {ICAL_REPLY_ACCEPT_CLASS,"Accept reply"}, | ||
764 | {ICAL_REPLY_DECLINE_CLASS,"Decline reply"}, | ||
765 | {ICAL_REPLY_DELEGATE_CLASS,"Delegation reply"}, | ||
766 | {ICAL_REPLY_CRASHER_ACCEPT_CLASS,"Crasher's accept reply"}, | ||
767 | {ICAL_REPLY_CRASHER_DECLINE_CLASS,"Crasher's decline reply"}, | ||
768 | {ICAL_ADD_INSTANCE_CLASS,"Add instance"}, | ||
769 | {ICAL_CANCEL_EVENT_CLASS,"Cancel event"}, | ||
770 | {ICAL_CANCEL_INSTANCE_CLASS,"Cancel instance"}, | ||
771 | {ICAL_CANCEL_ALL_CLASS,"Cancel all instances"}, | ||
772 | {ICAL_REFRESH_CLASS,"Refresh"}, | ||
773 | {ICAL_COUNTER_CLASS,"Counter"}, | ||
774 | {ICAL_DECLINECOUNTER_CLASS,"Decline counter"}, | ||
775 | {ICAL_MALFORMED_CLASS,"Malformed"}, | ||
776 | {ICAL_OBSOLETE_CLASS,"Obsolete"}, | ||
777 | {ICAL_MISSEQUENCED_CLASS,"Missequenced"}, | ||
778 | {ICAL_UNKNOWN_CLASS,"Unknown"} | ||
779 | }; | ||
780 | |||
781 | char* icalclassify_class_to_string(ical_class class) | ||
782 | { | ||
783 | int i; | ||
784 | |||
785 | for (i = 0;class_map[i].class != ICAL_UNKNOWN_CLASS;i++){ | ||
786 | if (class_map[i].class == class){ | ||
787 | return class_map[i].str; | ||
788 | } | ||
789 | } | ||
790 | |||
791 | return "Unknown"; | ||
792 | } | ||