1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

add a function to check if a given message object is bound to a location

This commit is contained in:
B. Petersen 2019-04-24 18:43:09 +02:00
parent 8b0ff6b3e8
commit 858a5e3acf
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC
4 changed files with 16 additions and 2 deletions

View file

@ -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* temp2 = dc_timestamp_to_str(dc_msg_get_timestamp(msg));
char* msgtext = dc_msg_get_text(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, prefix,
(int)dc_msg_get_id(msg), (int)dc_msg_get_id(msg),
dc_msg_get_showpadlock(msg)? UTF8_LOCK : "", dc_msg_get_showpadlock(msg)? UTF8_LOCK : "",
dc_msg_has_location(msg)? UTF8_ROUND_PUSHPIN : "",
contact_name, contact_name,
contact_id, contact_id,
msgtext, msgtext,

View file

@ -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. * Get the text of the message.
* If there is no text associated with the message, an empty string is returned. * 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, " \ #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.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 */ 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++)); dc_param_set_packed( msg->param, (char*)sqlite3_column_text (row, row_offset++));
msg->starred = sqlite3_column_int (row, row_offset++); msg->starred = sqlite3_column_int (row, row_offset++);
msg->hidden = 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++); msg->chat_blocked = sqlite3_column_int (row, row_offset++);
if (msg->chat_blocked==2) { if (msg->chat_blocked==2) {

View file

@ -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 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 starred; /**< Starred-state of the message. 0=no, 1=yes. */
int chat_blocked; /**< Internal */ 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. */ 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. */
}; };

View file

@ -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*); 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); 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_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_sent (const dc_msg_t*);
int dc_msg_is_starred (const dc_msg_t*); int dc_msg_is_starred (const dc_msg_t*);
int dc_msg_is_forwarded (const dc_msg_t*); int dc_msg_is_forwarded (const dc_msg_t*);