From 96bb21d04df517645c27cac1eea5bc5f9a4ac1da Mon Sep 17 00:00:00 2001 From: Rainer Clasen Date: Fri, 17 Jun 2011 10:12:34 +0200 Subject: [PATCH] Fit: ignore unknown message types do not bail out on unknown message types. This violates the design of the Fit format of being extensible. As this was the last thing using the global_msg_names QMap, I've nuked this, aswell. --- src/FitRideFile.cpp | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/FitRideFile.cpp b/src/FitRideFile.cpp index a20bd3161..119d18112 100644 --- a/src/FitRideFile.cpp +++ b/src/FitRideFile.cpp @@ -63,8 +63,6 @@ struct FitDefinition { struct FitFileReaderState { - static QMap global_msg_names; - QFile &file; QStringList &errors; RideFile *rideFile; @@ -84,18 +82,6 @@ struct FitFileReaderState last_time(0), interval(0), devices(0), stopped(true), last_event_type(-1), last_event(-1), last_msg_type(-1) { - if (global_msg_names.isEmpty()) { - global_msg_names.insert(0, "file_id"); - global_msg_names.insert(18, "session"); - global_msg_names.insert(19, "lap"); - global_msg_names.insert(RECORD_TYPE, "record"); - global_msg_names.insert(21, "event"); - global_msg_names.insert(22, "undocumented"); - global_msg_names.insert(23, "device_info"); - global_msg_names.insert(34, "activity"); - global_msg_names.insert(49, "file_creator"); - global_msg_names.insert(72, "undocumented_2"); // New for Garmin 800 - } } struct TruncatedRead {}; @@ -335,14 +321,8 @@ struct FitFileReaderState int reserved = read_byte(&count); (void) reserved; // unused int architecture = read_byte(&count); int global_msg_num = read_short(&count); - if (!global_msg_names.contains(global_msg_num)) { - errors << QString("unknown global_msg_num %1").arg(global_msg_num); - stop = true; - return count; - } - /*printf("definition: local type %d is %s\n", - local_msg_type, - global_msg_names[global_msg_num].toAscii().constData());*/ + /*printf("definition: local type %d\n", + local_msg_type);*/ if (architecture != 0) { errors << QString("unsupported architecture %1").arg(architecture); stop = true; @@ -410,7 +390,7 @@ struct FitFileReaderState // other one that might be useful is DeviceInfo, but it doesn't // seem to be filled in properly. Sean's Cinqo, for example, // shows up as manufacturer #65535, even though it should be #7. - // printf("msg: %s\n", global_msg_names[def.global_msg_num].toAscii().constData()); + // printf("msg: %d\n", global_msg_num); switch (def.global_msg_num) { case 0: decodeFileId(def, time_offset, values); break; case 19: decodeLap(def, time_offset, values); break; @@ -489,13 +469,7 @@ struct FitFileReaderState int crc = read_short(); (void) crc; foreach(int num, unknown_global_msg_nums) { - if (global_msg_names.contains(num)) { - errors << ("unsupported global message \"" + global_msg_names[num] + - "\" (%1); ignoring it").arg(num); - } - else { - errors << QString("unsupported global message number %1; ignoring it").arg(num); - } + errors << QString("unknown global message number %1; ignoring it").arg(num); } foreach(int num, unknown_record_fields) errors << QString("unknown record field %1; ignoring it").arg(num); @@ -504,8 +478,6 @@ struct FitFileReaderState } }; -QMap FitFileReaderState::global_msg_names; - RideFile *FitFileReader::openRideFile(QFile &file, QStringList &errors) const { QSharedPointer state(new FitFileReaderState(file, errors));