Back to index

lightning-sunbird  0.9+nobinonly
Functions
testclassify.c File Reference
#include <stdio.h>
#include "ical.h"
#include <errno.h>
#include <string.h>
#include "icalss.h"

Go to the source code of this file.

Functions

const char * get_note (icalcomponent *c)
int main (int argc, char *argv[])

Function Documentation

const char* get_note ( icalcomponent *  c)

Definition at line 35 of file testclassify.c.

{
    icalproperty *p;
    const char* note = 0;

    if(c != 0){
        for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY);
            p!= 0;
            p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){
            if(strcmp(icalproperty_get_x_name(p),"X-LIC-NOTE")==0){
            note = icalproperty_get_x(p);
            }
        }
    } 
    
    if(note == 0){
        note = "None";
    }
    
    return note;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 58 of file testclassify.c.

{
    icalcomponent *c;
    int i=0;

    /* Open up the two storage files, one for the incomming components, 
       one for the calendar */
    icalset* incoming = icalset_new_file("../../test-data/incoming.ics");
    icalset* cal = icalset_new_file("../../test-data/calendar.ics");

    assert(incoming!= 0);
    assert(cal!=0);

    /* Iterate through all of the incoming components */
    for(c=icalset_get_first_component(incoming);c!=0;
       c=icalset_get_next_component(incoming)){
       
       icalproperty_xlicclass class;
       icalcomponent *match = 0;
        const char* this_uid;

       i++;

        /* Check this component against the restrictions imposed by
           iTIP. An errors will be inserted as X-LIC-ERROR properties
           in the component. The Parser will also insert errors if it
           cannot parse the component */
        icalcomponent_check_restrictions(c);

        /* If there are any errors, print out the component */
        if(icalcomponent_count_errors(c) != 0){
            printf("----- Component has errors ------- \n%s-----------------\n",
                   icalcomponent_as_ical_string(c));
        }

        /* Use one of the icalcomponent convenience routines to get
           the UID. This routine will save you from having to use
           icalcomponent_get_inner(),
           icalcomponent_get_first_property(), checking the return
           value, and then calling icalproperty_get_uid. There are
           several other convenience routines for DTSTART, DTEND,
           DURATION, SUMMARY, METHOD, and COMMENT */
       this_uid = icalcomponent_get_uid(c);

        if(this_uid != 0){
            /* Look in the calendar for a component with the same UID
               as the incomming component. We should reall also be
               checking the RECURRENCE-ID. Another way to do this
               operation is to us icalset_find_match(), which does use
               the RECURRENCE-ID. */
            match = icalset_fetch(cal,this_uid);
        }

        
        /* Classify the incoming component. The third argument is the
           calid of the user who owns the calendar. In a real program,
           you would probably switch() on the class.*/
       class = icalclassify(c,match,"A@example.com");

       printf("Test %d\n\
Incoming:      %s\n\
Matched:       %s\n\
Classification: %s\n\n",
               i,get_note(c),get_note(match),
               icalproperty_enum_to_string(class));     
    }

    return 0;
}

Here is the call graph for this function: