Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
icalclassify.c File Reference
#include "ical.h"
#include "icalclassify.h"
#include "icalmemory.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  icalclassify_parts
struct  icalclassify_map

Defines

#define icalclassify_pre   int rtrn =0;
#define icalclassify_post   return rtrn;

Functions

char * icalclassify_lowercase (const char *str)
icalcomponent * icalclassify_find_overlaps (icalset *set, icalcomponent *comp)
icalproperty * icalclassify_find_attendee (icalcomponent *c, const char *attendee)
void icalssutil_free_parts (struct icalclassify_parts *parts)
void icalssutil_get_parts (icalcomponent *c, struct icalclassify_parts *parts)
int icalssutil_is_rescheduled (icalcomponent *a, icalcomponent *b)
int icalclassify_publish_new (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_publish_update (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_publish_freebusy (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_new (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_update (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_reschedule (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_delegate (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_new_organizer (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_status (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_forward (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_request_freebusy (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_reply_accept (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_reply_decline (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_reply_delegate (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_reply_crasher_accept (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_reply_crasher_decline (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_add_instance (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_cancel_event (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_cancel_instance (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_cancel_all (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_refesh (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_counter (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
int icalclassify_delinecounter (struct icalclassify_parts *comp, struct icalclassify_parts *match, const char *user)
icalproperty_xlicclass icalclassify (icalcomponent *c, icalcomponent *match, const char *user)

Variables

struct icalclassify_map icalclassify_map []

Class Documentation

struct icalclassify_parts

Definition at line 39 of file icalclassify.c.

Collaboration diagram for icalclassify_parts:
Class Members
icalcomponent * c
icalcomponent_kind inner_kind
icalproperty_method method
char * organizer
char * reply_attendee
icalparameter_partstat reply_partstat
int sequence
char * uid

Define Documentation

Definition at line 312 of file icalclassify.c.

#define icalclassify_pre   int rtrn =0;

Definition at line 309 of file icalclassify.c.


Function Documentation

icalproperty_xlicclass icalclassify ( icalcomponent *  c,
icalcomponent *  match,
const char *  user 
)

Definition at line 684 of file icalclassify.c.

{
    icalcomponent *inner;
    icalproperty *p;
    icalproperty_method method;
    icalproperty_xlicclass class = ICAL_XLICCLASS_UNKNOWN;

    int i;

    struct icalclassify_parts comp_parts;
    struct icalclassify_parts match_parts;

    inner = icalcomponent_get_first_real_component(c);
    
    if (inner == 0) {
       return ICAL_XLICCLASS_NONE;
    }

    icalssutil_get_parts(c,&comp_parts);
    icalssutil_get_parts(match,&match_parts);

    /* Determine if the incoming component is obsoleted by the match */
    if(match != 0 && (
       comp_parts.method == ICAL_METHOD_REQUEST
       )){
       assert ( ! ((comp_parts.dtstamp.is_utc==1)^
                  (match_parts.dtstamp.is_utc==1)));

       if( comp_parts.sequence<match_parts.sequence &&
           icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)>0)
       {
           /* comp has a smaller sequence and a later DTSTAMP */
           class = ICAL_XLICCLASS_MISSEQUENCED;
           goto CLEANUP;
       }

       if( (comp_parts.sequence<match_parts.sequence )
            /*&&icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0*/
            ||
          ( comp_parts.sequence == match_parts.sequence &&
            icaltime_compare(comp_parts.dtstamp,match_parts.dtstamp)<=0)){

           class = ICAL_XLICCLASS_OBSOLETE;
           goto CLEANUP;
       }

    }

    p = icalcomponent_get_first_property(c,ICAL_METHOD_PROPERTY);
    if (p == 0) {
       class = ICAL_XLICCLASS_UNKNOWN;
       goto CLEANUP;
    }
    method = icalproperty_get_method(p);

    for (i =0; icalclassify_map[i].method != ICAL_METHOD_NONE; i++){
       if(icalclassify_map[i].method == method){
           if( (*(icalclassify_map[i].fn))(&comp_parts,&match_parts,user)==1){
              class = icalclassify_map[i].class;
              break;
           }
       }
    }

CLEANUP:
    icalssutil_free_parts(&comp_parts); 
    icalssutil_free_parts(&match_parts);

    return class;

}

Here is the call graph for this function:

Here is the caller graph for this function:

int icalclassify_add_instance ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 567 of file icalclassify.c.

int icalclassify_cancel_all ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 600 of file icalclassify.c.

int icalclassify_cancel_event ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 578 of file icalclassify.c.

int icalclassify_cancel_instance ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 589 of file icalclassify.c.

int icalclassify_counter ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 622 of file icalclassify.c.

int icalclassify_delinecounter ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 633 of file icalclassify.c.

icalproperty* icalclassify_find_attendee ( icalcomponent *  c,
const char *  attendee 
)

Definition at line 124 of file icalclassify.c.

{
    icalproperty *p;
    icalcomponent* inner;
    char* lattendee;
    char* upn;

    if(attendee == 0){
        return 0;
    }

    lattendee = icalclassify_lowercase(attendee);
    upn =  strchr(lattendee,':');

    if (upn== 0){
        upn = lattendee;
    } else {
        upn++; /* skip the ";"*/
    }

    inner = icalcomponent_get_first_real_component(c);

    for(p  = icalcomponent_get_first_property(inner,ICAL_ATTENDEE_PROPERTY);
       p != 0;
       p  = icalcomponent_get_next_property(inner,ICAL_ATTENDEE_PROPERTY))
    {
       char* this_attendee
           = icalclassify_lowercase(icalproperty_get_attendee(p));
       char* this_upn = strchr(this_attendee,':');

        if(this_upn == 0){
            continue;
        } else {
            this_upn++;
        }

       if(strcmp(this_upn,upn)==0){
                     free(lattendee);
                     free(this_attendee);
            return p;
       }

              free(this_attendee);
    }
       free(lattendee);

    return 0;

}

Here is the call graph for this function:

Here is the caller graph for this function:

icalcomponent* icalclassify_find_overlaps ( icalset *  set,
icalcomponent *  comp 
)

Definition at line 77 of file icalclassify.c.

{
    icalcomponent *return_set;
    icalcomponent *c;
    struct icaltime_span span,compspan;
    
    icalerror_clear_errno();
    compspan = icalcomponent_get_span(comp);

    if(icalerrno != ICAL_NO_ERROR){
       return 0;
    }


    return_set = icalcomponent_new(ICAL_XROOT_COMPONENT);

    for(c = icalset_get_first_component(set);
       c != 0;
       c = icalset_get_next_component(set)){

       icalerror_clear_errno();

       span = icalcomponent_get_span(c);

       if(icalerrno != ICAL_NO_ERROR){
           continue;
       }

       if (compspan.start < span.end && 
           compspan.end > span.start){

           icalcomponent *clone = icalcomponent_new_clone(c);

           icalcomponent_add_component(return_set,clone);
       }      
    }

    if(icalcomponent_count_components(return_set,ICAL_ANY_COMPONENT) !=0){
       return return_set;
    } else {
       icalcomponent_free(return_set);
       return 0;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* icalclassify_lowercase ( const char *  str)

Definition at line 53 of file icalclassify.c.

{
    char* p = 0;
    char* ret;

    if(str ==0){
       return 0;
    }

    ret = icalmemory_strdup(str);

    for(p = ret; *p!=0; p++){
       *p = tolower(*p);
    }

    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int icalclassify_publish_freebusy ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 346 of file icalclassify.c.

int icalclassify_publish_new ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 316 of file icalclassify.c.

{
    icalclassify_pre;

    if(comp->method == ICAL_METHOD_PUBLISH &&
       match == 0 && comp->inner_kind != ICAL_VFREEBUSY_COMPONENT){
       rtrn = 1;
    }
       
    icalclassify_post;

}
int icalclassify_publish_update ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 331 of file icalclassify.c.

{
    icalclassify_pre;

    if(comp->method == ICAL_METHOD_PUBLISH &&
       match !=0 && comp->inner_kind != ICAL_VFREEBUSY_COMPONENT){
       rtrn = 1;
    }
       
    icalclassify_post;

}
int icalclassify_refesh ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 611 of file icalclassify.c.

int icalclassify_reply_accept ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 484 of file icalclassify.c.

{
    icalproperty* attendee;
    icalclassify_pre;

    attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);

    if(attendee != 0&&
       comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){
       rtrn = 1;
    }

    icalclassify_post
}

Here is the call graph for this function:

int icalclassify_reply_crasher_accept ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 534 of file icalclassify.c.

{
    icalproperty* attendee;
    icalclassify_pre;

    attendee= icalclassify_find_attendee(match->c,comp->reply_attendee);

    if(attendee == 0 &&
       comp->reply_partstat == ICAL_PARTSTAT_ACCEPTED){
       rtrn = 1;
    }
    icalclassify_post
}

Here is the call graph for this function:

int icalclassify_reply_crasher_decline ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 550 of file icalclassify.c.

{
    icalproperty* attendee;
    icalclassify_pre;


    attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);

    if(attendee == 0 &&
       comp->reply_partstat == ICAL_PARTSTAT_DECLINED){
       rtrn = 1;
    }
    icalclassify_post
}

Here is the call graph for this function:

int icalclassify_reply_decline ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 501 of file icalclassify.c.

{
    icalproperty* attendee;
    icalclassify_pre;

    attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);


    if( attendee != 0 &&
       comp->reply_partstat == ICAL_PARTSTAT_DECLINED){
       rtrn = 1;
    }
    icalclassify_post
}

Here is the call graph for this function:

int icalclassify_reply_delegate ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 518 of file icalclassify.c.

{
    icalproperty* attendee;
    icalclassify_pre;

    attendee = icalclassify_find_attendee(match->c,comp->reply_attendee);

    if( attendee != 0 &&
       comp->reply_partstat == ICAL_PARTSTAT_DELEGATED){
       rtrn = 1;
    }
    icalclassify_post
}

Here is the call graph for this function:

int icalclassify_request_delegate ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 417 of file icalclassify.c.

{
    icalproperty* attendee;
    icalparameter* param;
    icalclassify_pre;

    attendee = icalclassify_find_attendee(comp->c,user);

    if(attendee == 0){
        return 0;
    }

    param = icalproperty_get_first_parameter(attendee,ICAL_DELEGATEDFROM_PARAMETER);
           
    if (param != 0){
       rtrn = 1;
    }

    icalclassify_post

}

Here is the call graph for this function:

int icalclassify_request_forward ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 464 of file icalclassify.c.

Here is the call graph for this function:

int icalclassify_request_freebusy ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 474 of file icalclassify.c.

Here is the call graph for this function:

int icalclassify_request_new ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 362 of file icalclassify.c.

{
    /* Method is  REQUEST, and there is no match */

    icalclassify_pre

    if(match->c==0 && comp->method == ICAL_METHOD_REQUEST){
       rtrn = 1;
    }

    icalclassify_post

}
int icalclassify_request_new_organizer ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 442 of file icalclassify.c.

{
    /*   Organizer has changed between match and component */
    icalclassify_pre
    icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR);
    icalclassify_post

}

Here is the call graph for this function:

int icalclassify_request_reschedule ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 398 of file icalclassify.c.

{
    /* REQUEST method, Higher SEQUENCE than match, and one or more
       time-related properties are changed */
    icalclassify_pre

    if (match->c != 0 &&
       comp->sequence > match->sequence &&
       icalssutil_is_rescheduled(comp->c,match->c)){
       rtrn = 1;
    }

    icalclassify_post

}

Here is the call graph for this function:

int icalclassify_request_status ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 454 of file icalclassify.c.

Here is the call graph for this function:

int icalclassify_request_update ( struct icalclassify_parts comp,
struct icalclassify_parts match,
const char *  user 
)

Definition at line 378 of file icalclassify.c.

{
    /* REQUEST method, Higher SEQUENCE than match, and all
       time-related properties are unchanged */
    
    icalclassify_pre

    if (match != 0 &&
       comp->sequence >= match->sequence &&
       !icalssutil_is_rescheduled(comp->c,match->c)){
       rtrn = 1;
    }

    icalclassify_post

}

Here is the call graph for this function:

Definition at line 175 of file icalclassify.c.

{
    if(parts == 0){
       return;
    }

    if(parts->organizer != 0){
       free(parts->organizer);
    }

    if(parts->uid != 0){
       free(parts->uid);
    }

    if(parts->reply_attendee){
       free(parts->reply_attendee);
    }
}

Here is the caller graph for this function:

void icalssutil_get_parts ( icalcomponent *  c,
struct icalclassify_parts parts 
)

Definition at line 194 of file icalclassify.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int icalssutil_is_rescheduled ( icalcomponent *  a,
icalcomponent *  b 
)

Definition at line 268 of file icalclassify.c.

{
    icalproperty *p1,*p2;
    icalcomponent *i1,*i2;
    int i;

    icalproperty_kind kind_array[] = {
       ICAL_DTSTART_PROPERTY,
       ICAL_DTEND_PROPERTY,
       ICAL_DURATION_PROPERTY,
       ICAL_DUE_PROPERTY,
       ICAL_RRULE_PROPERTY,
       ICAL_RDATE_PROPERTY,
       ICAL_EXRULE_PROPERTY,
       ICAL_EXDATE_PROPERTY,
       ICAL_NO_PROPERTY
    };

    i1 = icalcomponent_get_first_real_component(a);
    i2 = icalcomponent_get_first_real_component(b);

    for(i =0; kind_array[i] != ICAL_NO_PROPERTY; i++){
       p1 = icalcomponent_get_first_property(i1,kind_array[i]);
       p2 = icalcomponent_get_first_property(i2,kind_array[i]);
       
       if( (p1!=0)^(p2!=0) ){
           /* Return true if the property exists in one component and not
              the other */
           return 1;
       }
       
       if(p1 && strcmp(icalproperty_as_ical_string(p1),
                     icalproperty_as_ical_string(p2)) != 0){
           return 1;
       }
    }

    return 0;
    
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation