Changeset 2454

Show
Ignore:
Timestamp:
08/16/07 11:43:09 (1 year ago)
Author:
paule
Message:

Fix for various XML format errors; fix segfault when converting todo alarms from Opie; sort xml contact fields

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/opie-sync/src/opie_format.c

    r2451 r2454  
    324324        xmlFreeDoc(idoc); 
    325325 
    326         // FIXME: remove this later
     326        // FIXME: remove this later by adding in a pre-sorted way
    327327        osync_xmlformat_sort(out_xmlformat); 
     328        if(oxf_name) 
     329                osync_xmlfield_sort(oxf_name); 
     330        if(oxf_organisation) 
     331                osync_xmlfield_sort(oxf_organisation); 
     332        if(oxf_homeaddress) 
     333                osync_xmlfield_sort(oxf_homeaddress); 
     334        if(oxf_workaddress) 
     335                osync_xmlfield_sort(oxf_workaddress); 
    328336         
    329337        unsigned int size; 
     
    634642                                        } 
    635643                                        out_xmlfield = osync_xmlfield_new(out_xmlformat, "Status", error); 
    636                                         osync_xmlfield_set_key_value(out_xmlfield, "Content", iprop->children->content); 
     644                                        osync_xmlfield_set_key_value(out_xmlfield, "Content", status); 
    637645                                } 
    638646                                else if(!strcasecmp(iprop->name, "StartDate")) 
     
    640648                                        out_xmlfield = osync_xmlfield_new(out_xmlformat, "DateStarted", error); 
    641649                                        osync_xmlfield_set_key_value(out_xmlfield, "Content", iprop->children->content); 
    642                                         osync_xmlfield_set_key_value(out_xmlfield, "Value", "DATE"); /* FIXME I doubt this is still valid */ 
     650                                        osync_xmlfield_set_attr(out_xmlfield, "Value", "DATE"); 
    643651                                } 
    644652                                else if(!strcasecmp(iprop->name, "Categories")) 
     
    665673                                        // RFC2445 says the default value type is DATE-TIME. But Opie only 
    666674                                        // stores DATE as completed date => alter VALUE to DATE 
    667                                         osync_xmlfield_set_key_value(out_xmlfield, "Value", "DATE"); /* FIXME I doubt this is still valid */ 
     675                                        osync_xmlfield_set_attr(out_xmlfield, "Value", "DATE"); 
    668676                                        xmlFree(completeDate); 
    669677                                } 
     
    687695                                        duedatestr = g_strdup_printf("%04d%02d%02d", dateyear, datemonth, dateday); 
    688696                                        duedate = g_date_new_dmy(dateday, datemonth, dateyear); 
    689                                         out_xmlfield = osync_xmlfield_new(out_xmlformat, "DateDue", error); 
     697                                        out_xmlfield = osync_xmlfield_new(out_xmlformat, "Due", error); 
    690698                                        osync_xmlfield_set_key_value(out_xmlfield, "Content", duedatestr); 
    691699                                        // RFC2445 says the default value type is DATE-TIME. But Opie only 
    692700                                        // stores DATE as due date => alter VALUE to DATE 
    693                                         osync_xmlfield_set_key_value(out_xmlfield, "Value", "DATE"); /* FIXME I doubt this is still valid */ 
     701                                        osync_xmlfield_set_attr(out_xmlfield, "Value", "DATE"); 
    694702                                } 
    695703                                if(datedaystr)   xmlFree(datedaystr); 
     
    726734        xmlFreeDoc(idoc); 
    727735 
    728         // FIXME: remove this later
     736        // FIXME: remove this later by adding in a pre-sorted way
    729737        osync_xmlformat_sort(out_xmlformat); 
    730738         
     
    827835                        } 
    828836                } 
    829                 else if(!strcmp("DateDue", fieldname)) { 
     837                else if(!strcmp("Due", fieldname)) { 
    830838                        duestr = osync_xmlfield_get_key_value(in_xmlfield, "Content"); 
    831839                        if(duestr) { 
     
    978986                                                char *startvdate = g_strdup_printf("%04d%02d%02d", localtm->tm_year + 1900, (localtm->tm_mon + 1), localtm->tm_mday); 
    979987                                                osync_xmlfield_set_key_value(out_xmlfield, "Content", startvdate); 
    980                                                 osync_xmlfield_set_key_value(out_xmlfield, "Value", "DATE"); 
     988                                                osync_xmlfield_set_attr(out_xmlfield, "Value", "DATE"); 
    981989                                                g_free(startvdate); 
    982990                                                g_free(localtm); 
     
    10091017                                                char *endvdate = g_strdup_printf("%04d%02d%02d", localtm->tm_year + 1900, (localtm->tm_mon + 1), localtm->tm_mday); 
    10101018                                                osync_xmlfield_set_key_value(out_xmlfield, "Content", endvdate); 
    1011                                                 osync_xmlfield_set_key_value(out_xmlfield, "Value", "DATE"); 
     1019                                                osync_xmlfield_set_attr(out_xmlfield, "Value", "DATE"); 
    10121020                                                g_free(endvdate); 
    10131021                                                g_free(localtm); 
     
    10741082        xmlFreeDoc(idoc); 
    10751083 
    1076         // FIXME: remove this later
     1084        // FIXME: remove this later by adding in a pre-sorted way
    10771085        osync_xmlformat_sort(out_xmlformat); 
    10781086         
     
    12391247        xmlFreeDoc(idoc); 
    12401248 
    1241         // FIXME: remove this later
     1249        // FIXME: remove this later by adding in a pre-sorted way
    12421250        osync_xmlformat_sort(out_xmlformat); 
    12431251         
     
    14191427        time_t utime = 0; 
    14201428        if(vtime) { 
    1421                 const char *vtimetype = osync_xmlfield_get_key_value(xmlfield, "Value"); 
     1429                const char *vtimetype = osync_xmlfield_get_attr(xmlfield, "Value"); 
    14221430                if(vtimetype && !strcasecmp(vtimetype, "DATE")) { 
    14231431                        /* vtime has date but no time, so we treat it as midnight local time */ 
     
    17231731                        for(i=0; alarmargs[i]!=NULL; i++) { 
    17241732                                if(i==0) { 
    1725                                         char *dateonly = g_strndup(alarmargs[i], 8); 
    1726                                         alarmdatestr = g_strdup_printf("%sT%s", dateonly, alarmargs[8]); 
    1727                                         g_free(dateonly); 
     1733                                        if(strlen(alarmargs[i]) == 14) { 
     1734                                                char *dateonly = g_strndup(alarmargs[i], 8); 
     1735                                                alarmdatestr = g_strdup_printf("%sT%s", dateonly, alarmargs[i] + 8); 
     1736                                                g_free(dateonly); 
     1737                                        } 
    17281738                                } 
    17291739                                else if(i==2)