Changeset 3303

Show
Ignore:
Timestamp:
05/01/08 14:26:47 (5 months ago)
Author:
dgollub
Message:

Adapted syncml plugin to osync_db API changes.
Renamed osync_db_exists() to osync_db_table_exists(), patch by
Francesco Chiechi.

Changed use of GList to OSyncList for osync_db_query() return value.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/syncml/src/syncml_devinf.c

    r3259 r3303  
    512512    /* check if all necessary tables exist */ 
    513513    osync_trace(TRACE_INTERNAL, "%s - Does all tables exist?", __func__); 
    514     if (osync_db_exists(db, "versions", oerror) < 1) 
     514    if (osync_db_table_exists(db, "versions", oerror) < 1) 
    515515        schema_update = TRUE; 
    516     if (osync_db_exists(db, "devices", oerror) < 1) 
     516    if (osync_db_table_exists(db, "devices", oerror) < 1) 
    517517        schema_update = TRUE; 
    518     if (osync_db_exists(db, "datastores", oerror) < 1) 
     518    if (osync_db_table_exists(db, "datastores", oerror) < 1) 
    519519        schema_update = TRUE; 
    520     if (osync_db_exists(db, "datastore_rx", oerror) < 1) 
     520    if (osync_db_table_exists(db, "datastore_rx", oerror) < 1) 
    521521        schema_update = TRUE; 
    522     if (osync_db_exists(db, "datastore_tx", oerror) < 1) 
     522    if (osync_db_table_exists(db, "datastore_tx", oerror) < 1) 
    523523        schema_update = TRUE; 
    524     if (osync_db_exists(db, "content_type_capabilities", oerror) < 1) 
     524    if (osync_db_table_exists(db, "content_type_capabilities", oerror) < 1) 
    525525        schema_update = TRUE; 
    526     if (osync_db_exists(db, "properties", oerror) < 1) 
     526    if (osync_db_table_exists(db, "properties", oerror) < 1) 
    527527        schema_update = TRUE; 
    528     if (osync_db_exists(db, "property_values", oerror) < 1) 
     528    if (osync_db_table_exists(db, "property_values", oerror) < 1) 
    529529        schema_update = TRUE; 
    530     if (osync_db_exists(db, "property_params", oerror) < 1) 
     530    if (osync_db_table_exists(db, "property_params", oerror) < 1) 
    531531        schema_update = TRUE; 
    532     if (osync_db_exists(db, "property_param_values", oerror) < 1) 
     532    if (osync_db_table_exists(db, "property_param_values", oerror) < 1) 
    533533        schema_update = TRUE; 
    534534 
     
    538538        osync_trace(TRACE_INTERNAL, "%s - Has the database schema the correct version?", __func__); 
    539539        const char *version_query = "SELECT \"version\" FROM versions WHERE \"name\"='devinf_schema'"; 
    540         GList *result = osync_db_query_table(db, version_query, oerror); 
     540        OSyncList *result = osync_db_query_table(db, version_query, oerror); 
    541541        if (!result && *oerror) 
    542542        { 
     
    547547        } 
    548548        else if (!result || 
    549                  !((GList *) result)->data || 
    550                  !((GList *) ((GList *) result)->data)->data) 
     549                 !((OSyncList *) result)->data || 
     550                 !((OSyncList *) ((OSyncList *) result)->data)->data) 
    551551        { 
    552552            /* no row returned or empty version */ 
     
    557557        { 
    558558            osync_trace(TRACE_INTERNAL, "%s - Evaluating version ...", __func__); 
    559             unsigned int db_version = atoi(((GList *) ((GList *) result)->data)->data); 
     559            unsigned int db_version = atoi(((OSyncList *) ((OSyncList *) result)->data)->data); 
    560560            if (db_version < db_schema_version) 
    561561                schema_update = TRUE; 
     
    577577 
    578578        /* drop all existing tables */ 
    579         if (osync_db_exists(db, "versions", oerror) > 0 && 
     579        if (osync_db_table_exists(db, "versions", oerror) > 0 && 
    580580            !osync_db_query(db, "DROP TABLE versions", oerror)) 
    581581            goto error; 
    582         if (osync_db_exists(db, "devices", oerror) > 0 && 
     582        if (osync_db_table_exists(db, "devices", oerror) > 0 && 
    583583            !osync_db_query(db, "DROP TABLE devices", oerror)) 
    584584            goto error; 
    585         if (osync_db_exists(db, "datastores", oerror) > 0 && 
     585        if (osync_db_table_exists(db, "datastores", oerror) > 0 && 
    586586            !osync_db_query(db, "DROP TABLE datastores", oerror)) 
    587587            goto error; 
    588         if (osync_db_exists(db, "datastore_rx", oerror) > 0 && 
     588        if (osync_db_table_exists(db, "datastore_rx", oerror) > 0 && 
    589589            !osync_db_query(db, "DROP TABLE datastore_rx", oerror)) 
    590590            goto error; 
    591         if (osync_db_exists(db, "datastore_tx", oerror) > 0 && 
     591        if (osync_db_table_exists(db, "datastore_tx", oerror) > 0 && 
    592592            !osync_db_query(db, "DROP TABLE datastore_tx", oerror)) 
    593593            goto error; 
    594         if (osync_db_exists(db, "content_type_capabilities", oerror) > 0 && 
     594        if (osync_db_table_exists(db, "content_type_capabilities", oerror) > 0 && 
    595595            !osync_db_query(db, "DROP TABLE content_type_capabilities", oerror)) 
    596596            goto error; 
    597         if (osync_db_exists(db, "properties", oerror) > 0 && 
     597        if (osync_db_table_exists(db, "properties", oerror) > 0 && 
    598598            !osync_db_query(db, "DROP TABLE properties", oerror)) 
    599599            goto error; 
    600         if (osync_db_exists(db, "property_values", oerror) > 0 && 
     600        if (osync_db_table_exists(db, "property_values", oerror) > 0 && 
    601601            !osync_db_query(db, "DROP TABLE property_values", oerror)) 
    602602            goto error; 
    603         if (osync_db_exists(db, "property_params", oerror) > 0 && 
     603        if (osync_db_table_exists(db, "property_params", oerror) > 0 && 
    604604            !osync_db_query(db, "DROP TABLE property_params", oerror)) 
    605605            goto error; 
    606         if (osync_db_exists(db, "property_param_values", oerror) > 0 && 
     606        if (osync_db_table_exists(db, "property_param_values", oerror) > 0 && 
    607607            !osync_db_query(db, "DROP TABLE property_param_values", oerror)) 
    608608            goto error; 
     
    998998    char *query = g_strdup_printf(device_query, esc_devid); 
    999999    // FIXME: unclean error handling 
    1000     GList *result = osync_db_query_table(db, query, oerror); 
     1000    OSyncList *result = osync_db_query_table(db, query, oerror); 
    10011001    safe_cfree(&query); 
    10021002    unsigned int count = 0; 
    1003     GList *row; 
     1003    OSyncList *row; 
    10041004    for (row = result; row; row = row->next) 
    10051005    { 
    10061006        count++; 
    10071007        g_assert(count == 1); 
    1008         GList *columns = row->data; 
    1009  
    1010         devinf = smlDevInfNew(devid, atoi(g_list_nth_data(columns, 0)), &error); 
    1011         smlDevInfSetManufacturer(devinf, g_list_nth_data(columns, 1)); 
    1012         smlDevInfSetModel(devinf, g_list_nth_data(columns, 2)); 
    1013         smlDevInfSetOEM(devinf, g_list_nth_data(columns, 3)); 
    1014         smlDevInfSetSoftwareVersion(devinf, g_list_nth_data(columns, 4)); 
    1015         smlDevInfSetHardwareVersion(devinf, g_list_nth_data(columns, 5)); 
    1016         smlDevInfSetFirmwareVersion(devinf, g_list_nth_data(columns, 6)); 
    1017         smlDevInfSetSupportsUTC(devinf, atoi(g_list_nth_data(columns, 7))); 
    1018         smlDevInfSetSupportsLargeObjs(devinf, atoi(g_list_nth_data(columns, 8))); 
    1019         smlDevInfSetSupportsNumberOfChanges(devinf, atoi(g_list_nth_data(columns, 9))); 
     1008        OSyncList *columns = row->data; 
     1009 
     1010        devinf = smlDevInfNew(devid, atoi(osync_list_nth_data(columns, 0)), &error); 
     1011        smlDevInfSetManufacturer(devinf, osync_list_nth_data(columns, 1)); 
     1012        smlDevInfSetModel(devinf, osync_list_nth_data(columns, 2)); 
     1013        smlDevInfSetOEM(devinf, osync_list_nth_data(columns, 3)); 
     1014        smlDevInfSetSoftwareVersion(devinf, osync_list_nth_data(columns, 4)); 
     1015        smlDevInfSetHardwareVersion(devinf, osync_list_nth_data(columns, 5)); 
     1016        smlDevInfSetFirmwareVersion(devinf, osync_list_nth_data(columns, 6)); 
     1017        smlDevInfSetSupportsUTC(devinf, atoi(osync_list_nth_data(columns, 7))); 
     1018        smlDevInfSetSupportsLargeObjs(devinf, atoi(osync_list_nth_data(columns, 8))); 
     1019        smlDevInfSetSupportsNumberOfChanges(devinf, atoi(osync_list_nth_data(columns, 9))); 
    10201020    } 
    10211021    osync_db_free_list(result); 
     
    10371037    for (row = result; row; row = row->next) 
    10381038    { 
    1039         GList *columns = row->data; 
     1039        OSyncList *columns = row->data; 
    10401040 
    10411041        // FIXME: unclean error handling 
    1042         char *esc_datastore  = osync_db_sql_escape(g_list_nth_data(columns, 0)); 
    1043         SmlDevInfDataStore *datastore = smlDevInfDataStoreNew(g_list_nth_data(columns, 0), &error); 
    1044         if (g_list_nth_data(columns, 1)) 
     1042        char *esc_datastore  = osync_db_sql_escape(osync_list_nth_data(columns, 0)); 
     1043        SmlDevInfDataStore *datastore = smlDevInfDataStoreNew(osync_list_nth_data(columns, 0), &error); 
     1044        if (osync_list_nth_data(columns, 1)) 
    10451045            smlDevInfDataStoreSetRxPref( 
    10461046                datastore, 
    1047                 g_list_nth_data(columns, 1), 
    1048                 g_list_nth_data(columns, 2)); 
    1049         if (g_list_nth_data(columns, 3)) 
     1047                osync_list_nth_data(columns, 1), 
     1048                osync_list_nth_data(columns, 2)); 
     1049        if (osync_list_nth_data(columns, 3)) 
    10501050            smlDevInfDataStoreSetTxPref( 
    10511051                datastore, 
    1052                 g_list_nth_data(columns, 3), 
    1053                 g_list_nth_data(columns, 4)); 
    1054         unsigned int sync_cap = atoi(g_list_nth_data(columns, 5)); 
     1052                osync_list_nth_data(columns, 3), 
     1053                osync_list_nth_data(columns, 4)); 
     1054        unsigned int sync_cap = atoi(osync_list_nth_data(columns, 5)); 
    10551055        unsigned int bit; 
    10561056        for (bit = 0; bit < 8; bit++) 
     
    10631063        query = g_strdup_printf(rx_query, esc_devid, esc_datastore); 
    10641064        // FIXME: unclean error handling 
    1065         GList *rx_result = osync_db_query_table(db, query, oerror); 
     1065        OSyncList *rx_result = osync_db_query_table(db, query, oerror); 
    10661066        safe_cfree(&query); 
    1067         GList *rx_row; 
     1067        OSyncList *rx_row; 
    10681068        for (rx_row = rx_result; rx_row; rx_row = rx_row->next) 
    10691069        { 
    1070             GList *rx_columns = rx_row->data; 
     1070            OSyncList *rx_columns = rx_row->data; 
    10711071 
    10721072            // FIXME: unclean error handling 
    10731073            SmlDevInfContentType *ctype = smlDevInfNewContentType( 
    1074                                               g_list_nth_data(columns, 0), 
    1075                                               g_list_nth_data(columns, 1), 
     1074                                              osync_list_nth_data(columns, 0), 
     1075                                              osync_list_nth_data(columns, 1), 
    10761076                                              &error); 
    10771077            smlDevInfDataStoreAddRx(datastore, ctype); 
     
    10831083        query = g_strdup_printf(tx_query, esc_devid, esc_datastore); 
    10841084        // FIXME: unclean error handling 
    1085         GList *tx_result = osync_db_query_table(db, query, oerror); 
     1085        OSyncList *tx_result = osync_db_query_table(db, query, oerror); 
    10861086        safe_cfree(&query); 
    1087         GList *tx_row; 
     1087        OSyncList *tx_row; 
    10881088        for (tx_row = tx_result; tx_row; tx_row = tx_row->next) 
    10891089        { 
    1090             GList *tx_columns = tx_row->data; 
     1090            OSyncList *tx_columns = tx_row->data; 
    10911091 
    10921092            // FIXME: unclean error handling 
    10931093            SmlDevInfContentType *ctype = smlDevInfNewContentType( 
    1094                                               g_list_nth_data(columns, 0), 
    1095                                               g_list_nth_data(columns, 1), 
     1094                                              osync_list_nth_data(columns, 0), 
     1095                                              osync_list_nth_data(columns, 1), 
    10961096                                              &error); 
    10971097            smlDevInfDataStoreAddTx(datastore, ctype); 
     
    11151115    { 
    11161116        count++; 
    1117         GList *columns = row->data; 
     1117        OSyncList *columns = row->data; 
    11181118 
    11191119        SmlDevInfCTCap *ctcap = smlDevInfNewCTCap(&error); 
     
    11211121                goto error; 
    11221122 
    1123         smlDevInfCTCapSetCTType(ctcap, g_list_nth_data(columns, 0)); 
    1124         smlDevInfCTCapSetVerCT(ctcap, g_list_nth_data(columns, 1)); 
     1123        smlDevInfCTCapSetCTType(ctcap, osync_list_nth_data(columns, 0)); 
     1124        smlDevInfCTCapSetVerCT(ctcap, osync_list_nth_data(columns, 1)); 
    11251125        smlDevInfAppendCTCap(devinf, ctcap); 
    1126         char *esc_ct = osync_db_sql_escape(g_list_nth_data(columns, 0)); 
    1127         char *esc_version = osync_db_sql_escape(g_list_nth_data(columns, 1)); 
     1126        char *esc_ct = osync_db_sql_escape(osync_list_nth_data(columns, 0)); 
     1127        char *esc_version = osync_db_sql_escape(osync_list_nth_data(columns, 1)); 
    11281128 
    11291129        /* reading property */ 
     
    11331133        query = g_strdup_printf(property_query, esc_devid, esc_ct, esc_version); 
    11341134        // FIXME: unclean error handling 
    1135         GList *prop_result = osync_db_query_table(db, query, oerror); 
     1135        OSyncList *prop_result = osync_db_query_table(db, query, oerror); 
    11361136        safe_cfree(&query); 
    11371137        unsigned int prop_count = 0; 
    1138         GList *prop_row; 
     1138        OSyncList *prop_row; 
    11391139        for (prop_row = prop_result; prop_row; prop_row = prop_row->next) 
    11401140        { 
    11411141            prop_count++; 
    1142             GList *prop_columns = prop_row->data; 
     1142            OSyncList *prop_columns = prop_row->data; 
    11431143 
    11441144            SmlDevInfProperty *property = smlDevInfNewProperty(&error); 
     
    11461146                    goto error; 
    11471147 
    1148             smlDevInfPropertySetPropName(property, g_list_nth_data(prop_columns, 0)); 
    1149             smlDevInfPropertySetDataType(property, g_list_nth_data(prop_columns, 1)); 
    1150             smlDevInfPropertySetMaxOccur(property, g_ascii_strtoull(g_list_nth_data(prop_columns, 2), NULL, 0)); 
    1151             smlDevInfPropertySetMaxSize(property, g_ascii_strtoull(g_list_nth_data(prop_columns, 3), NULL, 0)); 
    1152             if (atoi(g_list_nth_data(prop_columns, 4))) 
     1148            smlDevInfPropertySetPropName(property, osync_list_nth_data(prop_columns, 0)); 
     1149            smlDevInfPropertySetDataType(property, osync_list_nth_data(prop_columns, 1)); 
     1150            smlDevInfPropertySetMaxOccur(property, g_ascii_strtoull(osync_list_nth_data(prop_columns, 2), NULL, 0)); 
     1151            smlDevInfPropertySetMaxSize(property, g_ascii_strtoull(osync_list_nth_data(prop_columns, 3), NULL, 0)); 
     1152            if (atoi(osync_list_nth_data(prop_columns, 4))) 
    11531153                smlDevInfPropertySetNoTruncate(property); 
    1154             smlDevInfPropertySetDisplayName(property, g_list_nth_data(prop_columns, 5)); 
     1154            smlDevInfPropertySetDisplayName(property, osync_list_nth_data(prop_columns, 5)); 
    11551155            smlDevInfCTCapAddProperty(ctcap, property); 
    1156             char *esc_prop_name = osync_db_sql_escape(g_list_nth_data(prop_columns, 0)); 
     1156            char *esc_prop_name = osync_db_sql_escape(osync_list_nth_data(prop_columns, 0)); 
    11571157 
    11581158            /* reading property values */ 
     
    11621162                         esc_ct, esc_version, esc_prop_name); 
    11631163            // FIXME: unclean error handling 
    1164             GList *prop_value_result = osync_db_query_table(db, query, oerror); 
     1164            OSyncList *prop_value_result = osync_db_query_table(db, query, oerror); 
    11651165            safe_cfree(&query); 
    11661166            unsigned int prop_value_count = 0; 
    1167             GList *prop_value_row; 
     1167            OSyncList *prop_value_row; 
    11681168            for (prop_value_row = prop_value_result; prop_value_row; prop_value_row = prop_value_row->next) 
    11691169            { 
    11701170                prop_value_count++; 
    1171                 GList *prop_value_columns = prop_value_row->data; 
    1172  
    1173                 smlDevInfPropertyAddValEnum(property, g_list_nth_data(prop_value_columns, 0)); 
     1171                OSyncList *prop_value_columns = prop_value_row->data; 
     1172 
     1173                smlDevInfPropertyAddValEnum(property, osync_list_nth_data(prop_value_columns, 0)); 
    11741174            } 
    11751175            osync_db_free_list(prop_value_result); 
     
    11831183                         esc_ct, esc_version, esc_prop_name); 
    11841184            // FIXME: unclean error handling 
    1185             GList *prop_param_result = osync_db_query_table(db, query, oerror); 
     1185            OSyncList *prop_param_result = osync_db_query_table(db, query, oerror); 
    11861186            safe_cfree(&query); 
    11871187            unsigned int prop_param_count = 0; 
    1188             GList *prop_param_row; 
     1188            OSyncList *prop_param_row; 
    11891189            for (prop_param_row = prop_param_result; prop_param_row; prop_param_row = prop_param_row->next) 
    11901190            { 
    11911191                prop_param_count++; 
    1192                 GList *prop_param_columns = prop_param_row->data; 
     1192                OSyncList *prop_param_columns = prop_param_row->data; 
    11931193 
    11941194                SmlDevInfPropParam *prop_param = smlDevInfNewPropParam(&error); 
     
    11961196                        goto error; 
    11971197 
    1198                 smlDevInfPropParamSetParamName(prop_param, g_list_nth_data(prop_param_columns, 0)); 
    1199                 smlDevInfPropParamSetDataType(prop_param, g_list_nth_data(prop_param_columns, 1)); 
    1200                 smlDevInfPropParamSetDisplayName(prop_param, g_list_nth_data(prop_param_columns, 2)); 
     1198                smlDevInfPropParamSetParamName(prop_param, osync_list_nth_data(prop_param_columns, 0)); 
     1199                smlDevInfPropParamSetDataType(prop_param, osync_list_nth_data(prop_param_columns, 1)); 
     1200                smlDevInfPropParamSetDisplayName(prop_param, osync_list_nth_data(prop_param_columns, 2)); 
    12011201                smlDevInfPropertyAddPropParam(property, prop_param); 
    1202                 char *esc_param_name = osync_db_sql_escape(g_list_nth_data(prop_param_columns, 0)); 
     1202                char *esc_param_name = osync_db_sql_escape(osync_list_nth_data(prop_param_columns, 0)); 
    12031203 
    12041204                /* reading property parameter values */ 
     
    12091209                             esc_param_name); 
    12101210                // FIXME: unclean error handling 
    1211                 GList *param_value_result = osync_db_query_table(db, query, oerror); 
     1211                OSyncList *param_value_result = osync_db_query_table(db, query, oerror); 
    12121212                safe_cfree(&query); 
    12131213                unsigned int param_value_count = 0; 
    1214                 GList *param_value_row; 
     1214                OSyncList *param_value_row; 
    12151215                for (param_value_row = param_value_result; param_value_row; param_value_row = param_value_row->next) 
    12161216                { 
    12171217                    param_value_count++; 
    1218                     GList *param_value_columns = param_value_row->data; 
    1219  
    1220                     smlDevInfPropParamAddValEnum(prop_param, g_list_nth_data(param_value_columns, 0)); 
     1218                    OSyncList *param_value_columns = param_value_row->data; 
     1219 
     1220                    smlDevInfPropParamAddValEnum(prop_param, osync_list_nth_data(param_value_columns, 0)); 
    12211221                } 
    12221222                osync_db_free_list(param_value_result);