From 858a5e3acfc3c1f972c3cfbc79ea78b6480c549c Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Wed, 24 Apr 2019 18:43:09 +0200 Subject: [PATCH] add a function to check if a given message object is bound to a location --- cmdline/cmdline.c | 3 ++- src/dc_msg.c | 13 ++++++++++++- src/dc_msg.h | 1 + src/deltachat.h | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmdline/cmdline.c b/cmdline/cmdline.c index 3d33655f..9bd5d196 100644 --- a/cmdline/cmdline.c +++ b/cmdline/cmdline.c @@ -264,10 +264,11 @@ static void log_msg(dc_context_t* context, const char* prefix, dc_msg_t* msg) char* temp2 = dc_timestamp_to_str(dc_msg_get_timestamp(msg)); char* msgtext = dc_msg_get_text(msg); - dc_log_info(context, 0, "%s#%i%s: %s (Contact#%i): %s %s%s%s%s [%s]", + dc_log_info(context, 0, "%s#%i%s%s: %s (Contact#%i): %s %s%s%s%s [%s]", prefix, (int)dc_msg_get_id(msg), dc_msg_get_showpadlock(msg)? UTF8_LOCK : "", + dc_msg_has_location(msg)? UTF8_ROUND_PUSHPIN : "", contact_name, contact_id, msgtext, diff --git a/src/dc_msg.c b/src/dc_msg.c index bb09509d..8919ec0e 100644 --- a/src/dc_msg.c +++ b/src/dc_msg.c @@ -314,6 +314,16 @@ int dc_msg_has_deviating_timestamp(const dc_msg_t* msg) } +int dc_msg_has_location(const dc_msg_t* msg) +{ + if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { + return 0; + } + + return (msg->location_id!=0); +} + + /** * Get the text of the message. * If there is no text associated with the message, an empty string is returned. @@ -813,7 +823,7 @@ cleanup: #define DC_MSG_FIELDS " m.id,rfc724_mid,m.mime_in_reply_to,m.server_folder,m.server_uid,m.move_state,m.chat_id, " \ " m.from_id,m.to_id,m.timestamp,m.timestamp_sent,m.timestamp_rcvd, m.type,m.state,m.msgrmsg,m.txt, " \ - " m.param,m.starred,m.hidden,c.blocked " + " m.param,m.starred,m.hidden,m.location_id, c.blocked " static int dc_msg_set_from_stmt(dc_msg_t* msg, sqlite3_stmt* row, int row_offset) /* field order must be DC_MSG_FIELDS */ @@ -842,6 +852,7 @@ static int dc_msg_set_from_stmt(dc_msg_t* msg, sqlite3_stmt* row, int row_offset dc_param_set_packed( msg->param, (char*)sqlite3_column_text (row, row_offset++)); msg->starred = sqlite3_column_int (row, row_offset++); msg->hidden = sqlite3_column_int (row, row_offset++); + msg->location_id = sqlite3_column_int (row, row_offset++); msg->chat_blocked = sqlite3_column_int (row, row_offset++); if (msg->chat_blocked==2) { diff --git a/src/dc_msg.h b/src/dc_msg.h index c887269b..82b6627c 100644 --- a/src/dc_msg.h +++ b/src/dc_msg.h @@ -71,6 +71,7 @@ struct _dc_msg int is_dc_message; /**< Set to 1 if the message was sent by another messenger. 2=reply to messenger message. 0 otherwise. */ int starred; /**< Starred-state of the message. 0=no, 1=yes. */ int chat_blocked; /**< Internal */ + uint32_t location_id; dc_param_t* param; /**< Additional paramter for the message. Never a NULL-pointer. It is recommended to use setters and getters instead of accessing this field directly. */ }; diff --git a/src/deltachat.h b/src/deltachat.h index 6cfaa941..c94f11e4 100644 --- a/src/deltachat.h +++ b/src/deltachat.h @@ -538,6 +538,7 @@ int dc_msg_get_showpadlock (const dc_msg_t*); dc_lot_t* dc_msg_get_summary (const dc_msg_t*, const dc_chat_t*); char* dc_msg_get_summarytext (const dc_msg_t*, int approx_characters); int dc_msg_has_deviating_timestamp(const dc_msg_t*); +int dc_msg_has_location (const dc_msg_t*); int dc_msg_is_sent (const dc_msg_t*); int dc_msg_is_starred (const dc_msg_t*); int dc_msg_is_forwarded (const dc_msg_t*);