text stringlengths 0 357 |
|---|
/** |
* Get height of image or video. The height is returned in pixels. |
* If the height is unknown or if the associated file is no image or video file, |
* 0 is returned. |
* |
* Often the ascpect ratio is the more interesting thing. You can calculate |
* this using dc_msg_get_width() / dc_msg_get_height(). |
* |
* See also dc_msg_get_duration(). |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @return Height in pixels, if applicable. 0 otherwise or if unknown. |
*/ |
int dc_msg_get_height(const dc_msg_t* msg) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { |
return 0; |
} |
return dc_param_get_int(msg->param, DC_PARAM_HEIGHT, 0); |
} |
/** |
* Get the duration of audio or video. The duration is returned in milliseconds (ms). |
* If the duration is unknown or if the associated file is no audio or video file, |
* 0 is returned. |
* |
* See also dc_msg_get_width() and dc_msg_get_height(). |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @return Duration in milliseconds, if applicable. 0 otherwise or if unknown. |
*/ |
int dc_msg_get_duration(const dc_msg_t* msg) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { |
return 0; |
} |
return dc_param_get_int(msg->param, DC_PARAM_DURATION, 0); |
} |
/** |
* Check if a padlock should be shown beside the message. |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @return 1=padlock should be shown beside message, 0=do not show a padlock beside the message. |
*/ |
int dc_msg_get_showpadlock(const dc_msg_t* msg) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC || msg->context==NULL) { |
return 0; |
} |
if (dc_param_get_int(msg->param, DC_PARAM_GUARANTEE_E2EE, 0)!=0) { |
return 1; |
} |
return 0; |
} |
/** |
* Get a summary for a message. |
* |
* The summary is returned by a dc_lot_t object with the following fields: |
* |
* - dc_lot_t::text1: contains the username or the string "Me". |
* The string may be colored by having a look at text1_meaning. |
* If the name should not be displayed, the element is NULL. |
* - dc_lot_t::text1_meaning: one of DC_TEXT1_USERNAME or DC_TEXT1_SELF. |
* Typically used to show dc_lot_t::text1 with different colors. 0 if not applicable. |
* - dc_lot_t::text2: contains an excerpt of the message text. |
* - dc_lot_t::timestamp: the timestamp of the message. |
* - dc_lot_t::state: The state of the message as one of the DC_STATE_* constants (see #dc_msg_get_state()). |
* |
* Typically used to display a search result. See also dc_chatlist_get_summary() to display a list of chats. |
* |
* @memberof dc_msg_t |
* @param msg The message object. |
* @param chat To speed up things, pass an already available chat object here. |
* If the chat object is not yet available, it is faster to pass NULL. |
* @return The summary as an dc_lot_t object. Must be freed using dc_lot_unref(). NULL is never returned. |
*/ |
dc_lot_t* dc_msg_get_summary(const dc_msg_t* msg, const dc_chat_t* chat) |
{ |
dc_lot_t* ret = dc_lot_new(); |
dc_contact_t* contact = NULL; |
dc_chat_t* chat_to_delete = NULL; |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { |
goto cleanup; |
} |
if (chat==NULL) { |
if ((chat_to_delete=dc_get_chat(msg->context, msg->chat_id))==NULL) { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.