Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
icalrestriction.c File Reference
#include "icalrestriction.h"
#include "icalenums.h"
#include "icalerror.h"
#include <assert.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  icalrestriction_property_record
struct  icalrestriction_component_record

Defines

#define TMP_BUF_SIZE   1024

Typedefs

typedef char *(* restriction_func )(struct icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
typedef struct
icalrestriction_property_record 
icalrestriction_property_record
typedef struct
icalrestriction_component_record 
icalrestriction_component_record

Functions

icalrestriction_property_recordicalrestriction_get_property_restriction (icalproperty_method method, icalcomponent_kind component, icalproperty_kind property)
icalrestriction_component_recordicalrestriction_get_component_restriction (icalproperty_method method, icalcomponent_kind component, icalcomponent_kind subcomponent)
int icalrestriction_compare (icalrestriction_kind restr, int count)
char * icalrestriction_may_be_draft_final_canceled (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_may_be_comp_need_process (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_may_be_tent_conf (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_may_be_tent_conf_cancel (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_be_cancel_if_present (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_be_canceled_no_attendee (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_be_recurring (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_have_duration (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_have_repeat (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_if_tz_ref (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_no_dtend (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_no_duration (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
char * icalrestriction_must_be_email (icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)
int icalrestriction_check_component (icalproperty_method method, icalcomponent *comp)
int icalrestriction_check (icalcomponent *outer_comp)

Variables

icalrestriction_component_record icalrestriction_component_records []
icalrestriction_property_record icalrestriction_property_records []
icalrestriction_property_record null_prop_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_UNKNOWN,0}
icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0}
char compare_map [ICAL_RESTRICTION_UNKNOWN+1][3]
 The each row gives the result of comparing a restriction against a count.
char restr_string_map [ICAL_RESTRICTION_UNKNOWN+1][60]

Class Documentation

struct icalrestriction_property_record

Definition at line 36 of file icalrestriction.c.

Collaboration diagram for icalrestriction_property_record:
Class Members
icalcomponent_kind component
restriction_func function
icalproperty_method method
icalproperty_kind property
icalrestriction_kind restriction
struct icalrestriction_component_record

Definition at line 45 of file icalrestriction.c.

Collaboration diagram for icalrestriction_component_record:
Class Members
icalcomponent_kind component
restriction_func function
icalproperty_method method
icalrestriction_kind restriction
icalcomponent_kind subcomponent

Define Documentation

#define TMP_BUF_SIZE   1024

Definition at line 20 of file icalrestriction.c.


Typedef Documentation

typedef char*(* restriction_func)(struct icalrestriction_property_record *rec, icalcomponent *comp, icalproperty *prop)

Definition at line 33 of file icalrestriction.c.


Function Documentation

int icalrestriction_check ( icalcomponent *  outer_comp)

Definition at line 371 of file icalrestriction.c.

{
    icalcomponent_kind comp_kind;
    icalproperty_method method;
    icalcomponent* inner_comp;
    icalproperty *method_prop;
    int valid;
    
    icalerror_check_arg_rz( (outer_comp!=0), "outer comp");


    /* Get the Method value from the outer component */

    comp_kind = icalcomponent_isa(outer_comp);

    if (comp_kind != ICAL_VCALENDAR_COMPONENT){
       icalerror_set_errno(ICAL_BADARG_ERROR);
       return 0;
    }

    method_prop = icalcomponent_get_first_property(outer_comp,
                                             ICAL_METHOD_PROPERTY);

    if (method_prop == 0){
       method = ICAL_METHOD_NONE;
    } else {
       method = icalproperty_get_method(method_prop);
    }
   

    /* Check the VCALENDAR wrapper */
    valid = icalrestriction_check_component(ICAL_METHOD_NONE,outer_comp);


    /* Now check the inner components */

    for(inner_comp= icalcomponent_get_first_component(outer_comp,
                                                ICAL_ANY_COMPONENT);
       inner_comp != 0;
       inner_comp= icalcomponent_get_next_component(outer_comp,
                                               ICAL_ANY_COMPONENT)){

       valid = valid && icalrestriction_check_component(method,inner_comp);

    }


    return valid;

}

Here is the call graph for this function:

Here is the caller graph for this function:

int icalrestriction_check_component ( icalproperty_method  method,
icalcomponent *  comp 
)

Definition at line 286 of file icalrestriction.c.

{
    icalproperty_kind kind;
    icalcomponent_kind comp_kind;
    icalrestriction_kind restr;
    icalrestriction_property_record *prop_record;
    char* funcr = 0;
    icalproperty *prop;

    int count;
    int compare;
    int valid = 1;

    comp_kind = icalcomponent_isa(comp);

    /* Check all of the properties in this component */

    for(kind = ICAL_ANY_PROPERTY+1; kind != ICAL_NO_PROPERTY; kind++){
       count = icalcomponent_count_properties(comp, kind);
       
       prop_record = icalrestriction_get_property_restriction(method, 
                                                  comp_kind,
                                                  kind);

       restr = prop_record->restriction;

       if(restr == ICAL_RESTRICTION_ONEEXCLUSIVE ||
           restr == ICAL_RESTRICTION_ONEMUTUAL) {

           /* First treat is as a 0/1 restriction */
           restr = ICAL_RESTRICTION_ZEROORONE;
           compare = icalrestriction_compare(restr,count);

       } else {

           compare = icalrestriction_compare(restr,count);
       }

       assert(compare != -1);

       if (compare == 0){
           char temp[TMP_BUF_SIZE];
           
           snprintf(temp, TMP_BUF_SIZE,"Failed iTIP restrictions for %s property. Expected %s instances of the property and got %d",
                  icalenum_property_kind_to_string(kind),
                  restr_string_map[restr], count);
           
           icalcomponent_add_property
              (comp,
               icalproperty_vanew_xlicerror(
                   temp,
                   icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP),
                   0));   
       } 


       prop = icalcomponent_get_first_property(comp, kind);

       if (prop != 0 && prop_record->function !=0  ){
           funcr =  prop_record->function(prop_record,comp,prop);
       }

       if(funcr !=0){
           icalcomponent_add_property
              (comp,
               icalproperty_vanew_xlicerror(
                   funcr,
                   icalparameter_new_xlicerrortype(
                      ICAL_XLICERRORTYPE_INVALIDITIP),
                   0));   

           compare = 0;
       }

       valid = valid && compare;
    }



    return valid;


}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file icalrestriction.c.

                                                              {

    if ( restr < ICAL_RESTRICTION_NONE || restr > ICAL_RESTRICTION_UNKNOWN
        || count < 0){
       return -1;
    }

    if (count > 2) {
       count = 2;
    }

    return compare_map[restr][count];

}

Here is the caller graph for this function:

Definition at line 445 of file icalrestriction.c.

Definition at line 423 of file icalrestriction.c.

Here is the caller graph for this function:

char* icalrestriction_may_be_comp_need_process ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 137 of file icalrestriction.c.

{
    icalproperty_status stat = icalproperty_get_status(prop);

    if( !( stat == ICAL_STATUS_COMPLETED ||
          stat == ICAL_STATUS_NEEDSACTION ||
          stat == ICAL_STATUS_INPROCESS )){

       return "Failed iTIP restrictions for STATUS property. Value must be one of COMPLETED, NEEDS-ACTION or IN-PROCESS";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_may_be_draft_final_canceled ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 118 of file icalrestriction.c.

{

    icalproperty_status stat = icalproperty_get_status(prop);

    if( !( stat == ICAL_STATUS_DRAFT ||
          stat == ICAL_STATUS_FINAL ||
          stat == ICAL_STATUS_CANCELLED )){

       return "Failed iTIP restrictions for STATUS property. Value must be one of DRAFT, FINAL, or CANCELED";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_may_be_tent_conf ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 154 of file icalrestriction.c.

                                                      {
    icalproperty_status stat = icalproperty_get_status(prop);

    if( !( stat == ICAL_STATUS_TENTATIVE ||
          stat == ICAL_STATUS_CONFIRMED )){

       return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE or CONFIRMED";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_may_be_tent_conf_cancel ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 168 of file icalrestriction.c.

{
    icalproperty_status stat = icalproperty_get_status(prop);

    if( !( stat == ICAL_STATUS_TENTATIVE ||
          stat == ICAL_STATUS_CONFIRMED ||
          stat == ICAL_STATUS_CANCELLED )){

       return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE, CONFIRMED or CANCELED";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_must_be_cancel_if_present ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 186 of file icalrestriction.c.

{
    /* This routine will not be called if prop == 0 */
    icalproperty_status stat = icalproperty_get_status(prop);

    if( stat != ICAL_STATUS_CANCELLED)
    {
       return "Failed iTIP restrictions for STATUS property. Value must be CANCELLED";

    }
 

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_must_be_canceled_no_attendee ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 204 of file icalrestriction.c.

{

    /* Hack. see rfc2446, 3.2.5 CANCEL for porperty STATUS. I don't
       understand the note */

    return 0;    
}
char* icalrestriction_must_be_email ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 270 of file icalrestriction.c.

{
    icalproperty_status stat = icalproperty_get_action(prop);

    if( !( stat == ICAL_ACTION_EMAIL)){

       return "Failed iTIP restrictions for ACTION property. Value must be EMAIL.";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_must_be_recurring ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 215 of file icalrestriction.c.

                                                      {
    /* Hack */
    return 0;    
}
char* icalrestriction_must_have_duration ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 221 of file icalrestriction.c.

                                                       {
    
    if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){

       return "Failed iTIP restrictions. This component must have a DURATION property";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_must_have_repeat ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 233 of file icalrestriction.c.

                                                      {
    if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){

       return "Failed iTIP restrictions. This component must have a REPEAT property";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_must_if_tz_ref ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 244 of file icalrestriction.c.

                                                    {

    /* Hack */
    return 0;    
}
char* icalrestriction_no_dtend ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 251 of file icalrestriction.c.

                                               {

    if( icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){

       return "Failed iTIP restrictions. The component must not have both DURATION and DTEND";

    }

    return 0;    
}

Here is the call graph for this function:

char* icalrestriction_no_duration ( icalrestriction_property_record rec,
icalcomponent *  comp,
icalproperty *  prop 
)

Definition at line 263 of file icalrestriction.c.

                                                 {

    /* _no_dtend takes care of this one */
    return 0;    
}                                     

Variable Documentation

Initial value:
 {
    { 1, 1, 1},
    { 1, 0, 0},
    { 0, 1, 0},
    { 1, 1, 1},
    { 0, 1, 1},
    { 1, 1, 0},
    { 1, 1, 0},
    { 1, 1, 0},
    { 1, 1, 1} 
}

The each row gives the result of comparing a restriction against a count.

The columns in each row represent 0,1,2+. '-1' indicates 'invalid, 'don't care' or 'needs more analysis' So, for ICAL_RESTRICTION_ONE, if there is 1 of a property with that restriction, it passes, but if there are 0 or 2+, it fails.

Definition at line 75 of file icalrestriction.c.

Definition at line 62 of file icalrestriction.c.

Definition at line 63 of file icalrestriction.c.

Definition at line 66 of file icalrestriction.c.

Definition at line 65 of file icalrestriction.c.

Initial value:
 {
    "unknown number",
    "0",
    "1",
    "zero or more",
    "one or more" ,
    "zero or one",
    "zero or one, exclusive with another property",
    "zero or one, mutual with another property",
    "unknown number" 
}

Definition at line 87 of file icalrestriction.c.