Changeset 2335

Show
Ignore:
Timestamp:
07/14/07 17:03:14 (1 year ago)
Author:
cstender
Message:

- create vcalendar container in xmlformat-vevent.c instead of vformat.c.

Now we can write e.g. METHOD or CALSCALE attributes BEFORE the vevent
or vtodo starts. This avoids corrupted entries.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • format-plugins/vformat/src/vformat.c

    r2330 r2335  
    890890                        break; 
    891891                case VFORMAT_TODO_10: 
    892                         str = g_string_append (str, "BEGIN:VCALENDAR\r\nVERSION:1.0\r\nPRODID:-//OpenSync//NONSGML OpenSync vformat 0.3//EN\r\nBEGIN:VTODO\r\n"); 
    893                         break; 
     892                case VFORMAT_TODO_20: 
    894893                case VFORMAT_EVENT_10: 
    895                         str = g_string_append (str, "BEGIN:VCALENDAR\r\nVERSION:1.0\r\nPRODID:-//OpenSync//NONSGML OpenSync vformat 0.3//EN\r\nBEGIN:VEVENT\r\n"); 
    896                         break; 
    897                 case VFORMAT_TODO_20: 
    898                         str = g_string_append (str, "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//OpenSync//NONSGML OpenSync vformat 0.3//EN\r\nBEGIN:VTODO\r\n"); 
    899                         break; 
    900894                case VFORMAT_EVENT_20: 
    901                         str = g_string_append (str, "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//OpenSync//NONSGML OpenSync vformat 0.3//EN\r\nBEGIN:VEVENT\r\n"); 
     895                        str = g_string_append (str, "BEGIN:VCALENDAR\r\n"); 
    902896                        break; 
    903897                case VFORMAT_NOTE: 
  • format-plugins/vformat/src/xmlformat-vevent.c

    r2334 r2335  
    748748        g_free(str); 
    749749 
    750         // create a new vcalendar 
    751         VFormat *vcalendar = vformat_new(); 
    752          
    753         osync_trace(TRACE_INTERNAL, "parsing xml attributes"); 
     750        // set default encoding 
    754751        const char *std_encoding = NULL; 
    755752        if (target == VFORMAT_EVENT_10 || target == VFORMAT_TODO_10) 
     
    758755                std_encoding = "B"; 
    759756 
    760         // parsing xml attributes 
    761         GList *alarmfields = NULL; 
    762         GList *timezonefields = NULL; 
     757        // create a new vcalendar 
     758        VFormat *vcalendar = vformat_new(); 
     759 
     760        // start parsing/generating attributes 
     761        osync_trace(TRACE_INTERNAL, "parsing xml attributes"); 
     762 
     763        VFormatAttribute *attr = NULL; 
     764 
     765        // prepare vcalendar container 
     766        if (target == VFORMAT_EVENT_10 || target == VFORMAT_TODO_10) { 
     767 
     768                // TODO: Handle DAYLIGHT attribute 
     769                // TODO: Handle GEO attribute 
     770 
     771                attr = vformat_attribute_new(NULL, "PRODID"); 
     772                vformat_attribute_add_value(attr, "-//OpenSync//NONSGML OpenSync vformat 0.3//EN"); 
     773                vformat_add_attribute(vcalendar, attr); 
     774         
     775                // TODO: Handle TZ attribute 
     776         
     777                attr = vformat_attribute_new(NULL, "VERSION"); 
     778                vformat_attribute_add_value(attr, "1.0"); 
     779                vformat_add_attribute(vcalendar, attr); 
     780 
     781        } else if (target == VFORMAT_EVENT_20 || target == VFORMAT_TODO_20) { 
     782 
     783                attr = vformat_attribute_new(NULL, "PRODID"); 
     784                vformat_attribute_add_value(attr, "-//OpenSync//NONSGML OpenSync vformat 0.3//EN"); 
     785                vformat_add_attribute(vcalendar, attr); 
     786 
     787                attr = vformat_attribute_new(NULL, "VERSION"); 
     788                vformat_attribute_add_value(attr, "2.0"); 
     789                vformat_add_attribute(vcalendar, attr); 
     790 
     791                // TODO: Handle CALSCALE attribute 
     792                // TODO: Handle METHOD attribute 
     793 
     794                // TODO: Handle VTIMEZONE component 
     795 
     796        } 
     797 
     798        // set begin attribute 
     799        attr = vformat_attribute_new(NULL, "BEGIN"); 
     800        if (target == VFORMAT_EVENT_10 || target == VFORMAT_EVENT_20) { 
     801                vformat_attribute_add_value(attr, "VEVENT"); 
     802        } else if (target == VFORMAT_TODO_10 || target == VFORMAT_TODO_20) { 
     803                vformat_attribute_add_value(attr, "VTODO"); 
     804        } 
     805        vformat_add_attribute(vcalendar, attr); 
     806 
     807        // TODO: Handle VALARM component 
    763808 
    764809        OSyncXMLField *xmlfield = osync_xmlformat_get_first_field(xmlformat); 
    765810        for(; xmlfield != NULL; xmlfield = osync_xmlfield_get_next(xmlfield)) { 
    766811 
    767                 // Skip Alarm* and Timezone* xmlfields, we handle them later 
     812                // Skip Alarm* and Timezone* xmlfields 
    768813                if (strstr(osync_xmlfield_get_name(xmlfield), "Alarm")) { 
    769814                        osync_trace(TRACE_INTERNAL, "Skipping %s", osync_xmlfield_get_name(xmlfield)); 
    770                         alarmfields = g_list_append(alarmfields, xmlfield); 
    771815                        continue; 
    772816                } else if (strstr(osync_xmlfield_get_name(xmlfield), "Timezone")) { 
    773817                        osync_trace(TRACE_INTERNAL, "Skipping %s", osync_xmlfield_get_name(xmlfield)); 
    774                         timezonefields = g_list_append(timezonefields, xmlfield); 
    775818                        continue; 
    776819                } 
     
    779822        } 
    780823 
    781         // TODO: Handle timezone and alarm xmlfields 
     824        osync_trace(TRACE_INTERNAL, "parsing xml attributes finished"); 
    782825         
    783826        // free hash tables