diff --git a/gpx.cpp b/gpx.cpp index 51cd3d5..f2da689 100644 --- a/gpx.cpp +++ b/gpx.cpp @@ -60,6 +60,7 @@ Caches GPX::get_user_caches(__attribute__((unused)) const std::string& uuid, __a c.pos.lat = stof(el->lat().getValue()); c.pos.lon = stof(el->lon().getValue()); c.type = el->type().getValue(); + c.status = unknown; if (c.type.starts_with("Geocache|")) c.type.erase(0, 9); if (c.type.ends_with(" Cache")) diff --git a/ocdb.cpp b/ocdb.cpp index c19fcb6..53d0359 100644 --- a/ocdb.cpp +++ b/ocdb.cpp @@ -330,6 +330,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const { while (res == SQLITE_ROW) { c.code = reinterpret_cast(sqlite3_column_text(stmt, 0)); c.pos = get_lat_lon(reinterpret_cast(sqlite3_column_text(stmt, 1))); + c.status = ok; cc.push_back(c); res = sqlite3_step(stmt); } @@ -348,7 +349,7 @@ Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) in Caches cc; Cache c; //code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT) - std::string sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);"; + std::string sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);"; res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL); if (res != SQLITE_OK) { @@ -369,6 +370,17 @@ Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) in //c.country = reinterpret_cast(sqlite3_column_text(stmt, 6)); c.region = reinterpret_cast(sqlite3_column_text(stmt, 7)); c.owner_uuid = reinterpret_cast(sqlite3_column_text(stmt, 8)); // TODO: we don't know owner's nick + + std::string tmp = reinterpret_cast(sqlite3_column_text(stmt, 9)); + if (tmp == "Available") + c.status = ok; + else if (tmp == "Temporarily unavailable") + c.status = disabled; + else if (tmp == "Archived") + c.status = archived; + else + c.status = unknown; + cc.push_back(c); res = sqlite3_step(stmt); }