text stringlengths 0 357 |
|---|
"UPDATE chats SET locations_last_sent=? WHERE id=?;"); |
sqlite3_bind_int64(stmt, 1, timestamp); |
sqlite3_bind_int (stmt, 2, chat_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
void dc_set_msg_location_id(dc_context_t* context, uint32_t msg_id, uint32_t location_id) |
{ |
sqlite3_stmt* stmt = NULL; |
stmt = dc_sqlite3_prepare(context->sql, |
"UPDATE msgs SET location_id=? WHERE id=?;"); |
sqlite3_bind_int64(stmt, 1, location_id); |
sqlite3_bind_int (stmt, 2, msg_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
/******************************************************************************* |
* parse kml-files |
******************************************************************************/ |
#define TAG_PLACEMARK 0x01 |
#define TAG_TIMESTAMP 0x02 |
#define TAG_WHEN 0x04 |
#define TAG_POINT 0x08 |
#define TAG_COORDINATES 0x10 |
static void kml_starttag_cb(void* userdata, const char* tag, char** attr) |
{ |
dc_kml_t* kml = (dc_kml_t*)userdata; |
if (strcmp(tag, "document")==0) |
{ |
const char* addr = dc_attr_find(attr, "addr"); |
if (addr) { |
kml->addr = dc_strdup(addr); |
} |
} |
else if (strcmp(tag, "placemark")==0) |
{ |
kml->tag = TAG_PLACEMARK; |
kml->curr.timestamp = 0; |
kml->curr.latitude = 0; |
kml->curr.longitude = 0.0; |
kml->curr.accuracy = 0.0; |
} |
else if (strcmp(tag, "timestamp")==0 && kml->tag&TAG_PLACEMARK) |
{ |
kml->tag = TAG_PLACEMARK|TAG_TIMESTAMP; |
} |
else if (strcmp(tag, "when")==0 && kml->tag&TAG_TIMESTAMP) |
{ |
kml->tag = TAG_PLACEMARK|TAG_TIMESTAMP|TAG_WHEN; |
} |
else if (strcmp(tag, "point")==0 && kml->tag&TAG_PLACEMARK) |
{ |
kml->tag = TAG_PLACEMARK|TAG_POINT; |
} |
else if (strcmp(tag, "coordinates")==0 && kml->tag&TAG_POINT) |
{ |
kml->tag = TAG_PLACEMARK|TAG_POINT|TAG_COORDINATES; |
const char* accuracy = dc_attr_find(attr, "accuracy"); |
if (accuracy) { |
kml->curr.accuracy = dc_atof(accuracy); |
} |
} |
} |
static void kml_text_cb(void* userdata, const char* text, int len) |
{ |
dc_kml_t* kml = (dc_kml_t*)userdata; |
if (kml->tag&(TAG_WHEN|TAG_COORDINATES)) |
{ |
char* val = dc_strdup(text); |
dc_str_replace(&val, "\n", ""); |
dc_str_replace(&val, "\r", ""); |
dc_str_replace(&val, "\t", ""); |
dc_str_replace(&val, " ", ""); |
if (kml->tag&TAG_WHEN && strlen(val)>=19) { |
struct tm tmval; |
memset(&tmval, 0, sizeof(struct tm)); |
// YYYY-MM-DDTHH:MM:SS |
// 0 4 7 10 13 16 19 |
val[4] = 0; tmval.tm_year = atoi(val) - 1900; |
val[7] = 0; tmval.tm_mon = atoi(val+5) - 1; |
val[10] = 0; tmval.tm_mday = atoi(val+8); |
val[13] = 0; tmval.tm_hour = atoi(val+11); |
val[16] = 0; tmval.tm_min = atoi(val+14); |
val[19] = 0; tmval.tm_sec = atoi(val+17); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.