Changeset 3303
- Timestamp:
- 05/01/08 14:26:47 (5 months ago)
- Files:
-
- plugins/syncml/src/syncml_devinf.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/syncml/src/syncml_devinf.c
r3259 r3303 512 512 /* check if all necessary tables exist */ 513 513 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) 515 515 schema_update = TRUE; 516 if (osync_db_ exists(db, "devices", oerror) < 1)516 if (osync_db_table_exists(db, "devices", oerror) < 1) 517 517 schema_update = TRUE; 518 if (osync_db_ exists(db, "datastores", oerror) < 1)518 if (osync_db_table_exists(db, "datastores", oerror) < 1) 519 519 schema_update = TRUE; 520 if (osync_db_ exists(db, "datastore_rx", oerror) < 1)520 if (osync_db_table_exists(db, "datastore_rx", oerror) < 1) 521 521 schema_update = TRUE; 522 if (osync_db_ exists(db, "datastore_tx", oerror) < 1)522 if (osync_db_table_exists(db, "datastore_tx", oerror) < 1) 523 523 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) 525 525 schema_update = TRUE; 526 if (osync_db_ exists(db, "properties", oerror) < 1)526 if (osync_db_table_exists(db, "properties", oerror) < 1) 527 527 schema_update = TRUE; 528 if (osync_db_ exists(db, "property_values", oerror) < 1)528 if (osync_db_table_exists(db, "property_values", oerror) < 1) 529 529 schema_update = TRUE; 530 if (osync_db_ exists(db, "property_params", oerror) < 1)530 if (osync_db_table_exists(db, "property_params", oerror) < 1) 531 531 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) 533 533 schema_update = TRUE; 534 534 … … 538 538 osync_trace(TRACE_INTERNAL, "%s - Has the database schema the correct version?", __func__); 539 539 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); 541 541 if (!result && *oerror) 542 542 { … … 547 547 } 548 548 else if (!result || 549 !(( GList *) result)->data ||550 !(( GList *) ((GList *) result)->data)->data)549 !((OSyncList *) result)->data || 550 !((OSyncList *) ((OSyncList *) result)->data)->data) 551 551 { 552 552 /* no row returned or empty version */ … … 557 557 { 558 558 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); 560 560 if (db_version < db_schema_version) 561 561 schema_update = TRUE; … … 577 577 578 578 /* drop all existing tables */ 579 if (osync_db_ exists(db, "versions", oerror) > 0 &&579 if (osync_db_table_exists(db, "versions", oerror) > 0 && 580 580 !osync_db_query(db, "DROP TABLE versions", oerror)) 581 581 goto error; 582 if (osync_db_ exists(db, "devices", oerror) > 0 &&582 if (osync_db_table_exists(db, "devices", oerror) > 0 && 583 583 !osync_db_query(db, "DROP TABLE devices", oerror)) 584 584 goto error; 585 if (osync_db_ exists(db, "datastores", oerror) > 0 &&585 if (osync_db_table_exists(db, "datastores", oerror) > 0 && 586 586 !osync_db_query(db, "DROP TABLE datastores", oerror)) 587 587 goto error; 588 if (osync_db_ exists(db, "datastore_rx", oerror) > 0 &&588 if (osync_db_table_exists(db, "datastore_rx", oerror) > 0 && 589 589 !osync_db_query(db, "DROP TABLE datastore_rx", oerror)) 590 590 goto error; 591 if (osync_db_ exists(db, "datastore_tx", oerror) > 0 &&591 if (osync_db_table_exists(db, "datastore_tx", oerror) > 0 && 592 592 !osync_db_query(db, "DROP TABLE datastore_tx", oerror)) 593 593 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 && 595 595 !osync_db_query(db, "DROP TABLE content_type_capabilities", oerror)) 596 596 goto error; 597 if (osync_db_ exists(db, "properties", oerror) > 0 &&597 if (osync_db_table_exists(db, "properties", oerror) > 0 && 598 598 !osync_db_query(db, "DROP TABLE properties", oerror)) 599 599 goto error; 600 if (osync_db_ exists(db, "property_values", oerror) > 0 &&600 if (osync_db_table_exists(db, "property_values", oerror) > 0 && 601 601 !osync_db_query(db, "DROP TABLE property_values", oerror)) 602 602 goto error; 603 if (osync_db_ exists(db, "property_params", oerror) > 0 &&603 if (osync_db_table_exists(db, "property_params", oerror) > 0 && 604 604 !osync_db_query(db, "DROP TABLE property_params", oerror)) 605 605 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 && 607 607 !osync_db_query(db, "DROP TABLE property_param_values", oerror)) 608 608 goto error; … … 998 998 char *query = g_strdup_printf(device_query, esc_devid); 999 999 // FIXME: unclean error handling 1000 GList *result = osync_db_query_table(db, query, oerror);1000 OSyncList *result = osync_db_query_table(db, query, oerror); 1001 1001 safe_cfree(&query); 1002 1002 unsigned int count = 0; 1003 GList *row;1003 OSyncList *row; 1004 1004 for (row = result; row; row = row->next) 1005 1005 { 1006 1006 count++; 1007 1007 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))); 1020 1020 } 1021 1021 osync_db_free_list(result); … … 1037 1037 for (row = result; row; row = row->next) 1038 1038 { 1039 GList *columns = row->data;1039 OSyncList *columns = row->data; 1040 1040 1041 1041 // 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)) 1045 1045 smlDevInfDataStoreSetRxPref( 1046 1046 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)) 1050 1050 smlDevInfDataStoreSetTxPref( 1051 1051 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)); 1055 1055 unsigned int bit; 1056 1056 for (bit = 0; bit < 8; bit++) … … 1063 1063 query = g_strdup_printf(rx_query, esc_devid, esc_datastore); 1064 1064 // 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); 1066 1066 safe_cfree(&query); 1067 GList *rx_row;1067 OSyncList *rx_row; 1068 1068 for (rx_row = rx_result; rx_row; rx_row = rx_row->next) 1069 1069 { 1070 GList *rx_columns = rx_row->data;1070 OSyncList *rx_columns = rx_row->data; 1071 1071 1072 1072 // FIXME: unclean error handling 1073 1073 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), 1076 1076 &error); 1077 1077 smlDevInfDataStoreAddRx(datastore, ctype); … … 1083 1083 query = g_strdup_printf(tx_query, esc_devid, esc_datastore); 1084 1084 // 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); 1086 1086 safe_cfree(&query); 1087 GList *tx_row;1087 OSyncList *tx_row; 1088 1088 for (tx_row = tx_result; tx_row; tx_row = tx_row->next) 1089 1089 { 1090 GList *tx_columns = tx_row->data;1090 OSyncList *tx_columns = tx_row->data; 1091 1091 1092 1092 // FIXME: unclean error handling 1093 1093 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), 1096 1096 &error); 1097 1097 smlDevInfDataStoreAddTx(datastore, ctype); … … 1115 1115 { 1116 1116 count++; 1117 GList *columns = row->data;1117 OSyncList *columns = row->data; 1118 1118 1119 1119 SmlDevInfCTCap *ctcap = smlDevInfNewCTCap(&error); … … 1121 1121 goto error; 1122 1122 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)); 1125 1125 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)); 1128 1128 1129 1129 /* reading property */ … … 1133 1133 query = g_strdup_printf(property_query, esc_devid, esc_ct, esc_version); 1134 1134 // 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); 1136 1136 safe_cfree(&query); 1137 1137 unsigned int prop_count = 0; 1138 GList *prop_row;1138 OSyncList *prop_row; 1139 1139 for (prop_row = prop_result; prop_row; prop_row = prop_row->next) 1140 1140 { 1141 1141 prop_count++; 1142 GList *prop_columns = prop_row->data;1142 OSyncList *prop_columns = prop_row->data; 1143 1143 1144 1144 SmlDevInfProperty *property = smlDevInfNewProperty(&error); … … 1146 1146 goto error; 1147 1147 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))) 1153 1153 smlDevInfPropertySetNoTruncate(property); 1154 smlDevInfPropertySetDisplayName(property, g_list_nth_data(prop_columns, 5));1154 smlDevInfPropertySetDisplayName(property, osync_list_nth_data(prop_columns, 5)); 1155 1155 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)); 1157 1157 1158 1158 /* reading property values */ … … 1162 1162 esc_ct, esc_version, esc_prop_name); 1163 1163 // 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); 1165 1165 safe_cfree(&query); 1166 1166 unsigned int prop_value_count = 0; 1167 GList *prop_value_row;1167 OSyncList *prop_value_row; 1168 1168 for (prop_value_row = prop_value_result; prop_value_row; prop_value_row = prop_value_row->next) 1169 1169 { 1170 1170 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)); 1174 1174 } 1175 1175 osync_db_free_list(prop_value_result); … … 1183 1183 esc_ct, esc_version, esc_prop_name); 1184 1184 // 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); 1186 1186 safe_cfree(&query); 1187 1187 unsigned int prop_param_count = 0; 1188 GList *prop_param_row;1188 OSyncList *prop_param_row; 1189 1189 for (prop_param_row = prop_param_result; prop_param_row; prop_param_row = prop_param_row->next) 1190 1190 { 1191 1191 prop_param_count++; 1192 GList *prop_param_columns = prop_param_row->data;1192 OSyncList *prop_param_columns = prop_param_row->data; 1193 1193 1194 1194 SmlDevInfPropParam *prop_param = smlDevInfNewPropParam(&error); … … 1196 1196 goto error; 1197 1197 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)); 1201 1201 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)); 1203 1203 1204 1204 /* reading property parameter values */ … … 1209 1209 esc_param_name); 1210 1210 // 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); 1212 1212 safe_cfree(&query); 1213 1213 unsigned int param_value_count = 0; 1214 GList *param_value_row;1214 OSyncList *param_value_row; 1215 1215 for (param_value_row = param_value_result; param_value_row; param_value_row = param_value_row->next) 1216 1216 { 1217 1217 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)); 1221 1221 } 1222 1222 osync_db_free_list(param_value_result);
