1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00
This commit is contained in:
B. Petersen 2017-11-20 16:19:56 +01:00
parent 65b4d2d515
commit c278145081
5 changed files with 355 additions and 275 deletions

View file

@ -216,7 +216,7 @@ static void log_msglist(mrmailbox_t* mailbox, mrarray_t* msglist)
contact_name, contact_name,
contact_id, contact_id,
msg->m_text, msg->m_text,
mrmsg_show_padlock(msg)? "\xF0\x9F\x94\x92" : "", mrmsg_get_showpadlock(msg)? "\xF0\x9F\x94\x92" : "",
msg->m_starred? " \xE2\x98\x85" : "", msg->m_starred? " \xE2\x98\x85" : "",
msg->m_from_id==1? "" : (msg->m_state==MR_STATE_IN_SEEN? "[SEEN]" : (msg->m_state==MR_STATE_IN_NOTICED? "[NOTICED]":"[FRESH]")), msg->m_from_id==1? "" : (msg->m_state==MR_STATE_IN_SEEN? "[SEEN]" : (msg->m_state==MR_STATE_IN_NOTICED? "[NOTICED]":"[FRESH]")),
mrparam_get_int(msg->m_param, MRP_SYSTEM_CMD, 0)? "[SYSTEM]" : "", mrparam_get_int(msg->m_param, MRP_SYSTEM_CMD, 0)? "[SYSTEM]" : "",

View file

@ -140,6 +140,7 @@ typedef struct mrchat_t
mrchat_t* mrchat_new (mrmailbox_t*); mrchat_t* mrchat_new (mrmailbox_t*);
void mrchat_empty (mrchat_t*); void mrchat_empty (mrchat_t*);
void mrchat_unref (mrchat_t*); void mrchat_unref (mrchat_t*);
char* mrchat_get_subtitle (mrchat_t*); char* mrchat_get_subtitle (mrchat_t*);
/* library-internal */ /* library-internal */

View file

@ -3078,6 +3078,8 @@ cleanup:
* sending may be delayed eg. due to network problems. However, from your * sending may be delayed eg. due to network problems. However, from your
* view, you're done with the message. Sooner or later it will find its way. * view, you're done with the message. Sooner or later it will find its way.
* *
* To send messages of other types, see mrmailbox_send_msg().
*
* @memberof mrmailbox_t * @memberof mrmailbox_t
* *
* @param mailbox The mailbox object as returned from mrmailbox_new(). * @param mailbox The mailbox object as returned from mrmailbox_new().

View file

@ -110,7 +110,6 @@ void mrmsg_empty(mrmsg_t* msg)
/** /**
* Set the type of a message. * Set the type of a message.
* Possible types are MR_MSG_TEXT, MR_MSG_IMAGE, MR_MSG_GIF,MR_MSG_AUDIO,, MR_MSG_VOICE, MR_MSG_VIDEO or MR_MSG_FILE.
* *
* See mrmailbox_send_msg() for some examples. * See mrmailbox_send_msg() for some examples.
* *
@ -119,6 +118,8 @@ void mrmsg_empty(mrmsg_t* msg)
* @param msg The message object to modify. * @param msg The message object to modify.
* *
* @param type Type to set for the message. * @param type Type to set for the message.
* Possible types are MR_MSG_TEXT (10), MR_MSG_IMAGE (20), MR_MSG_GIF (21),
* MR_MSG_AUDIO (40), MR_MSG_VOICE (41), MR_MSG_VIDEO (50) or MR_MSG_FILE (60).
* *
* @return None. * @return None.
*/ */
@ -132,28 +133,6 @@ void mrmsg_set_type(mrmsg_t* msg, int type)
} }
/**
* Set the file belonging to a message.
* The file may be an image, a video, an audio file, an PDF and so on.
* This function is a shortcut for mrparam_set(msg->m_param, MRP_FILE, file)
*
* @memberof mrmsg_t
*
* @param msg The message object to modify.
*
* @param file Path, filename and extension to set for the given message.
*
* @return None.
*/
void mrmsg_set_file(mrmsg_t* msg, const char* file)
{
if( msg == NULL ) {
return;
}
mrparam_set(msg->m_param, MRP_FILE, file);
}
/** /**
* Set the text of a message object. * Set the text of a message object.
* *
@ -183,58 +162,315 @@ void mrmsg_set_text(mrmsg_t* msg, const char* text)
/** /**
* Guess message type from suffix. * Set the file belonging to a message.
* The file may be an image, a video, an audio file, an PDF and so on.
* This function is a shortcut for mrparam_set(msg->m_param, MRP_FILE, file)
* *
* @private @memberof mrmsg_t * @memberof mrmsg_t
* *
* @param pathNfilename Path and filename of the file to guess the type for. * @param msg The message object to modify.
* *
* @param[out] ret_msgtype Guessed message type is copied here as one of the MR_MSG_* constants. * @param file Path, filename and extension to set for the given message.
* *
* @param[out] ret_mime The pointer to a string buffer is set to the guessed MIME-type. May be NULL. Must be free()'d by the caller. * @return None.
*
* @return None. But there are output parameters.
*/ */
void mrmsg_guess_msgtype_from_suffix(const char* pathNfilename, int* ret_msgtype, char** ret_mime) void mrmsg_set_file(mrmsg_t* msg, const char* file)
{ {
if( pathNfilename == NULL || ret_msgtype == NULL || ret_mime == NULL) { if( msg == NULL ) {
return; return;
} }
mrparam_set(msg->m_param, MRP_FILE, file);
}
*ret_msgtype = MR_MSG_UNDEFINED;
*ret_mime = NULL;
char* s = mr_get_filesuffix_lc(pathNfilename); /*******************************************************************************
if( s == NULL ) { * Getters
******************************************************************************/
/**
* Get the type of the message.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return One of MR_MSG_TEXT (10), MR_MSG_IMAGE (20), MR_MSG_GIF (21),
* MR_MSG_AUDIO (40), MR_MSG_VOICE (41), MR_MSG_VIDEO (50), MR_MSG_FILE (60)
* or MR_MSG_UNDEFINED (0) if the type is undefined.
*/
int mrmsg_get_type(mrmsg_t* msg)
{
if( msg == NULL ) {
return MR_MSG_UNDEFINED;
}
return msg->m_type;
}
/**
* Get the state of a message.
*
* Incoming message states:
* - MR_STATE_IN_FRESH (10) - Incoming _fresh_ message. Fresh messages are not noticed nor seen and are typically shown in notifications. Use mrmailbox_get_fresh_msgs() to get all fresh messages.
* - MR_STATE_IN_NOTICED (13) - Incoming _noticed_ message. Eg. chat opened but message not yet read - noticed messages are not counted as unread but did not marked as read nor resulted in MDNs. Use mrmailbox_marknoticed_chat() or mrmailbox_marknoticed_contact() to mark messages as being noticed.
* - MR_STATE_IN_SEEN (16) - Incoming message, really _seen_ by the user. Marked as read on IMAP and MDN may be send. Use mrmailbox_markseen_msgs() to mark messages as being seen.
*
* Outgoing message states:
* - MR_STATE_OUT_PENDING (20) - The user has send the "send" button but the
* message is not yet sent and is pending in some way. Maybe we're offline (no checkmark).
* - MR_STATE_OUT_ERROR (24) - _Unrecoverable_ error (_recoverable_ errors result in pending messages)
* - MR_STATE_OUT_DELIVERED (26) - Outgoing message successfully delivered to server (one checkmark). Note, that already delivered messages may get into the state MR_STATE_OUT_ERROR if we get such a hint from the server.
* If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_DELIVERED.
* - MR_STATE_OUT_MDN_RCVD (28) - Outgoing message read by the recipient (two checkmarks; this requires goodwill on the receiver's side)
* If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_READ.
*
* The state of just created message objects is MR_STATE_UNDEFINED (0).
* The state is always set by the core-library, users of the library cannot set the state directly, but it is changed implicitly eg.
* when calling mrmailbox_marknoticed_chat() or mrmailbox_markseen_msgs().
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return The state of the message.
*/
int mrmsg_get_state(mrmsg_t* msg)
{
if( msg == NULL ) {
return MR_STATE_UNDEFINED;
}
return msg->m_state;
}
/**
* Get the text of the message.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return Message text. The result must be free()'d.
*/
char* mrmsg_get_text(mrmsg_t* msg)
{
return safe_strdup(msg? msg->m_text : NULL);
}
/**
* Find out full path, file name and extension of the file associated with a
* message.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return Full path, file name and extension of the file associated with the
* message. If there is no file associated with the message, an emtpy
* string is returned. NULL is never returned and the returned value must be free()'d.
*/
char* mrmsg_get_file(mrmsg_t* msg)
{
char* ret = NULL;
if( msg == NULL ) {
goto cleanup; goto cleanup;
} }
if( strcmp(s, "mp3")==0 ) { ret = mrparam_get(msg->m_param, MRP_FILE, NULL);
*ret_msgtype = MR_MSG_AUDIO;
*ret_mime = safe_strdup("audio/mpeg"); cleanup:
return ret? ret : safe_strdup(NULL);
}
/**
* Get base file name without path. The base file name includes the extension; the path
* is not returned. To get the full path, use mrmsg_get_file().
*
* @param msg the message object
*
* @return base file name plus extension without part. If there is no file
* associated with the message, an empty string is returned. The returned
* value must be free()'d.
*/
char* mrmsg_get_filename(mrmsg_t* msg)
{
char* ret = NULL, *pathNfilename = NULL;
if( msg == NULL ) {
goto cleanup;
} }
else if( strcmp(s, "mp4")==0 ) {
*ret_msgtype = MR_MSG_VIDEO; pathNfilename = mrparam_get(msg->m_param, MRP_FILE, NULL);
*ret_mime = safe_strdup("video/mp4"); if( pathNfilename == NULL ) {
goto cleanup;
} }
else if( strcmp(s, "jpg")==0 || strcmp(s, "jpeg")==0 ) {
*ret_msgtype = MR_MSG_IMAGE; ret = mr_get_filename(pathNfilename);
*ret_mime = safe_strdup("image/jpeg");
cleanup:
free(pathNfilename);
return ret? ret : safe_strdup(NULL);
}
/**
* Get real author and title.
*
* - For voice messages, the author is the sender and the trackname is the sending time.
* - For music messages and videos, we read the information from the filename
* (we do not read ID3 and such at this stage, the needed libraries are too complicated and oversized.
* However, this is no big problem, as the sender usually sets the filename in a way we expect it)
*
* @memberof mrmsg_t
*
* @param msg the message object
*
* @return mrpoortext_t object that contains the author as mrpoortext_t::m_text1 and the title as mrpoortext_t::m_text2.
* Both may be NULL if unknown. The returned object must be freed using mrpoortext_unref() when no longer used.
*/
mrpoortext_t* mrmsg_get_mediainfo(mrmsg_t* msg)
{
mrpoortext_t* ret = mrpoortext_new();
char *pathNfilename = NULL;
mrcontact_t* contact = NULL;
if( msg == NULL || msg->m_mailbox == NULL ) {
goto cleanup;
} }
else if( strcmp(s, "png")==0 ) {
*ret_msgtype = MR_MSG_IMAGE; if( msg->m_type == MR_MSG_VOICE )
*ret_mime = safe_strdup("image/png"); {
if( (contact = mrmailbox_get_contact(msg->m_mailbox, msg->m_from_id))==NULL ) {
goto cleanup;
}
ret->m_text1 = safe_strdup((contact->m_name&&contact->m_name[0])? contact->m_name : contact->m_addr);
ret->m_text2 = mrstock_str(MR_STR_VOICEMESSAGE);
}
else
{
ret->m_text1 = mrparam_get(msg->m_param, MRP_AUTHORNAME, NULL);
ret->m_text2 = mrparam_get(msg->m_param, MRP_TRACKNAME, NULL);
if( ret->m_text1 && ret->m_text1[0] && ret->m_text2 && ret->m_text2[0] ) {
goto cleanup;
}
free(ret->m_text1); ret->m_text1 = NULL;
free(ret->m_text2); ret->m_text2 = NULL;
pathNfilename = mrparam_get(msg->m_param, MRP_FILE, NULL);
if( pathNfilename == NULL ) {
goto cleanup;
}
mrmsg_get_authorNtitle_from_filename(pathNfilename, &ret->m_text1, &ret->m_text2);
if( ret->m_text1 == NULL && ret->m_text2 != NULL ) {
ret->m_text1 = mrstock_str(MR_STR_AUDIO);
} }
else if( strcmp(s, "gif")==0 ) {
*ret_msgtype = MR_MSG_GIF;
*ret_mime = safe_strdup("image/gif");
} }
cleanup: cleanup:
free(s); free(pathNfilename);
mrcontact_unref(contact);
return ret;
} }
/**
* Check if a padlock should be shown beside the message.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return 1=padlock should be shown beside message, 0=do not show a padlock beside the message.
*/
int mrmsg_get_showpadlock(mrmsg_t* msg)
{
/* a padlock guarantees that the message is e2ee _and_ answers will be as well */
if( msg != NULL ) {
if( msg->m_mailbox && msg->m_mailbox->m_e2ee_enabled ) {
if( mrparam_get_int(msg->m_param, MRP_GUARANTEE_E2EE, 0) != 0 ) {
return 1;
}
}
}
return 0;
}
/**
* Get a summary for a message.
* Typically used to display a search result.
*
* @memberof mrmsg_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 returned summary is similar to mrchatlist_get_summary(), however, without
* "draft", "no messages" and so on. The result must be freed using mrpoortext_unref().
*/
mrpoortext_t* mrmsg_get_summary(mrmsg_t* msg, mrchat_t* chat)
{
mrpoortext_t* ret = mrpoortext_new();
mrcontact_t* contact = NULL;
mrchat_t* chat_to_delete = NULL;
if( msg==NULL ) {
goto cleanup;
}
if( chat == NULL ) {
if( (chat=mrmailbox_get_chat(msg->m_mailbox, msg->m_chat_id)) == NULL ) {
goto cleanup;
}
chat_to_delete = chat;
}
if( msg->m_from_id != MR_CONTACT_ID_SELF && chat->m_type == MR_CHAT_TYPE_GROUP ) {
contact = mrmailbox_get_contact(chat->m_mailbox, msg->m_from_id);
}
mrpoortext_fill(ret, msg, chat, contact);
cleanup:
mrcontact_unref(contact);
mrchat_unref(chat_to_delete);
return ret;
}
/**
* Get a message summary as a single line of text. Typically used for
* notifications.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @param approx_characters Rough length of the expected string.
*
* @return A summary for the given messages. The returned string must be free()'d.
*/
char* mrmsg_get_summarytext(mrmsg_t* msg, int approx_characters)
{
if( msg==NULL ) {
return safe_strdup(NULL);
}
return mrmsg_get_summarytext_by_raw(msg->m_type, msg->m_text, msg->m_param, approx_characters);
}
/*******************************************************************************
* Misc.
******************************************************************************/
int mrmsg_set_from_stmt__(mrmsg_t* ths, sqlite3_stmt* row, int row_offset) /* field order must be MR_MSG_FIELDS */ int mrmsg_set_from_stmt__(mrmsg_t* ths, sqlite3_stmt* row, int row_offset) /* field order must be MR_MSG_FIELDS */
{ {
mrmsg_empty(ths); mrmsg_empty(ths);
@ -299,66 +535,55 @@ int mrmsg_load_from_db__(mrmsg_t* ths, mrmailbox_t* mailbox, uint32_t id)
/** /**
* Get a summary for a message. The last parameter can be set to speed up * Guess message type from suffix.
* things if the chat object is already available; if not, it is faster to pass
* NULL here. The result must be freed using mrpoortext_unref().
* Typically used to display a search result.
* *
* @memberof mrmsg_t * @private @memberof mrmsg_t
* *
* @return The returned summary is similar to mrchatlist_get_summary(), however, without * @param pathNfilename Path and filename of the file to guess the type for.
* "draft", "no messages" and so on. *
* @param[out] ret_msgtype Guessed message type is copied here as one of the MR_MSG_* constants.
*
* @param[out] ret_mime The pointer to a string buffer is set to the guessed MIME-type. May be NULL. Must be free()'d by the caller.
*
* @return None. But there are output parameters.
*/ */
mrpoortext_t* mrmsg_get_summary(mrmsg_t* msg, mrchat_t* chat) void mrmsg_guess_msgtype_from_suffix(const char* pathNfilename, int* ret_msgtype, char** ret_mime)
{ {
mrpoortext_t* ret = mrpoortext_new(); if( pathNfilename == NULL || ret_msgtype == NULL || ret_mime == NULL) {
mrcontact_t* contact = NULL; return;
mrchat_t* chat_to_delete = NULL; }
if( msg==NULL ) { *ret_msgtype = MR_MSG_UNDEFINED;
*ret_mime = NULL;
char* s = mr_get_filesuffix_lc(pathNfilename);
if( s == NULL ) {
goto cleanup; goto cleanup;
} }
if( chat == NULL ) { if( strcmp(s, "mp3")==0 ) {
if( (chat=mrmailbox_get_chat(msg->m_mailbox, msg->m_chat_id)) == NULL ) { *ret_msgtype = MR_MSG_AUDIO;
goto cleanup; *ret_mime = safe_strdup("audio/mpeg");
} }
chat_to_delete = chat; else if( strcmp(s, "mp4")==0 ) {
*ret_msgtype = MR_MSG_VIDEO;
*ret_mime = safe_strdup("video/mp4");
} }
else if( strcmp(s, "jpg")==0 || strcmp(s, "jpeg")==0 ) {
if( msg->m_from_id != MR_CONTACT_ID_SELF && chat->m_type == MR_CHAT_TYPE_GROUP ) { *ret_msgtype = MR_MSG_IMAGE;
contact = mrmailbox_get_contact(chat->m_mailbox, msg->m_from_id); *ret_mime = safe_strdup("image/jpeg");
}
else if( strcmp(s, "png")==0 ) {
*ret_msgtype = MR_MSG_IMAGE;
*ret_mime = safe_strdup("image/png");
}
else if( strcmp(s, "gif")==0 ) {
*ret_msgtype = MR_MSG_GIF;
*ret_mime = safe_strdup("image/gif");
} }
mrpoortext_fill(ret, msg, chat, contact);
cleanup: cleanup:
mrcontact_unref(contact); free(s);
mrchat_unref(chat_to_delete);
return ret;
}
/**
* Check if a padlock should be shown beside the message.
*
* @memberof mrmsg_t
*
* @param msg The message object.
*
* @return 1=padlock should be shown beside message, 0=do not show a padlock beside the message.
*/
int mrmsg_show_padlock(mrmsg_t* msg)
{
/* a padlock guarantees that the message is e2ee _and_ answers will be as well */
if( msg != NULL ) {
if( msg->m_mailbox && msg->m_mailbox->m_e2ee_enabled ) {
if( mrparam_get_int(msg->m_param, MRP_GUARANTEE_E2EE, 0) != 0 ) {
return 1;
}
}
}
return 0;
} }
@ -380,22 +605,6 @@ void mrmsg_get_authorNtitle_from_filename(const char* pathNfilename, char** ret_
} }
/**
* Get a message summary as a single line of text. Typically used for
* notifications. The returned value must be free()'d.
*
* @memberof mrmsg_t
*/
char* mrmsg_get_summarytext(mrmsg_t* msg, int approx_characters)
{
if( msg==NULL ) {
return safe_strdup(NULL);
}
return mrmsg_get_summarytext_by_raw(msg->m_type, msg->m_text, msg->m_param, approx_characters);
}
char* mrmsg_get_summarytext_by_raw(int type, const char* text, mrparam_t* param, int approx_characters) char* mrmsg_get_summarytext_by_raw(int type, const char* text, mrparam_t* param, int approx_characters)
{ {
char* ret = NULL; char* ret = NULL;
@ -453,124 +662,6 @@ char* mrmsg_get_summarytext_by_raw(int type, const char* text, mrparam_t* param,
} }
/**
* Find out full path, file name and extension of the file associated with a
* message.
*
* @param msg the message object
*
* @return full path, file name and extension of the file associated with the
* message. If there is no file associated with the message, an emtpy
* string is returned. The returned value must be free()'d.
*/
char* mrmsg_get_file(mrmsg_t* msg)
{
char* ret = NULL;
if( msg == NULL ) {
goto cleanup;
}
ret = mrparam_get(msg->m_param, MRP_FILE, NULL);
cleanup:
return ret? ret : safe_strdup(NULL);
}
/**
* Get base file name without path. The base file name includes the extension; the path
* is not returned. To get the full path, use mrmsg_get_file().
*
* @param msg the message object
*
* @return base file name plus extension without part. If there is no file
* associated with the message, an empty string is returned. The returned
* value must be free()'d.
*/
char* mrmsg_get_filename(mrmsg_t* msg)
{
char* ret = NULL, *pathNfilename = NULL;
if( msg == NULL ) {
goto cleanup;
}
pathNfilename = mrparam_get(msg->m_param, MRP_FILE, NULL);
if( pathNfilename == NULL ) {
goto cleanup;
}
ret = mr_get_filename(pathNfilename);
cleanup:
free(pathNfilename);
return ret? ret : safe_strdup(NULL);
}
/**
* Get real author and title. (as return.text1, this is not always the sender, NULL if
* unknown) and title (return.text2, NULL if unknown) of a message.
*
* For voice messages, the author the sender and the trackname is the sending time
* For music messages, we read the information from the filename
* We do not read ID3 and such at this stage, the needed libraries may be buggy
* and the whole stuff is way to complicated.
* However, this is not a great disadvantage, as the sender usually sets the filename in a way we expect it -
* if not, we simply print the whole filename as we do it for documents. All fine in any case :-)
*
* @memberof mrmsg_t
*
* @param msg the message object
*
* @return poortext object that must be unref'd using mrpoortext_unref() when no longer used.
*/
mrpoortext_t* mrmsg_get_mediainfo(mrmsg_t* msg)
{
mrpoortext_t* ret = mrpoortext_new();
char *pathNfilename = NULL;
mrcontact_t* contact = NULL;
if( msg == NULL || msg->m_mailbox == NULL ) {
goto cleanup;
}
if( msg->m_type == MR_MSG_VOICE )
{
if( (contact = mrmailbox_get_contact(msg->m_mailbox, msg->m_from_id))==NULL ) {
goto cleanup;
}
ret->m_text1 = safe_strdup((contact->m_name&&contact->m_name[0])? contact->m_name : contact->m_addr);
ret->m_text2 = mrstock_str(MR_STR_VOICEMESSAGE);
}
else
{
ret->m_text1 = mrparam_get(msg->m_param, MRP_AUTHORNAME, NULL);
ret->m_text2 = mrparam_get(msg->m_param, MRP_TRACKNAME, NULL);
if( ret->m_text1 && ret->m_text1[0] && ret->m_text2 && ret->m_text2[0] ) {
goto cleanup;
}
free(ret->m_text1); ret->m_text1 = NULL;
free(ret->m_text2); ret->m_text2 = NULL;
pathNfilename = mrparam_get(msg->m_param, MRP_FILE, NULL);
if( pathNfilename == NULL ) {
goto cleanup;
}
mrmsg_get_authorNtitle_from_filename(pathNfilename, &ret->m_text1, &ret->m_text2);
if( ret->m_text1 == NULL && ret->m_text2 != NULL ) {
ret->m_text1 = mrstock_str(MR_STR_AUDIO);
}
}
cleanup:
free(pathNfilename);
mrcontact_unref(contact);
return ret;
}
int mrmsg_is_increation__(const mrmsg_t* msg) int mrmsg_is_increation__(const mrmsg_t* msg)
{ {
int is_increation = 0; int is_increation = 0;
@ -596,6 +687,8 @@ int mrmsg_is_increation__(const mrmsg_t* msg)
* `<filename>` is created then, the user should just delete * `<filename>` is created then, the user should just delete
* `<filename>.increation` * `<filename>.increation`
* *
* @memberof mrmsg_t
*
* @param msg the message object * @param msg the message object
* *
* @return 1=message is still in creation (`<filename>.increation` exists), * @return 1=message is still in creation (`<filename>.increation` exists),

View file

@ -83,47 +83,21 @@ typedef struct mrmsg_t
/** /**
* Type of the message. * Message type. It is recommended to use mrmsg_set_type() and mrmsg_get_type() to access this field.
*
* - MR_MSG_TEXT (10)
* - MR_MSG_IMAGE (20) - #m_param may contain MRP_FILE, MRP_WIDTH, MRP_HEIGHT
* - MR_MSG_GIF (21) - #m_param may contain MRP_FILE, MRP_WIDTH, MRP_HEIGHT
* - MR_MSG_AUDIO (40) - #m_param may contain MRP_FILE, MRP_DURATION
* - MR_MSG_VOICE (41) - #m_param may contain MRP_FILE, MRP_DURATION
* - MR_MSG_VIDEO (50) - #m_param may contain MRP_FILE, MRP_WIDTH, MRP_HEIGHT, MRP_DURATION
* - MR_MSG_FILE (60) - #m_param may contain MRP_FILE
*
* Undefined types are filed under MR_MSG_UNDEFINED (0).
*/ */
int m_type; int m_type;
#define MR_MSG_UNDEFINED 0 #define MR_MSG_UNDEFINED 0
#define MR_MSG_TEXT 10 #define MR_MSG_TEXT 10
#define MR_MSG_IMAGE 20 #define MR_MSG_IMAGE 20 /* m_param may contain MRP_FILE, MRP_WIDTH, MRP_HEIGHT */
#define MR_MSG_GIF 21 #define MR_MSG_GIF 21 /* - " - */
#define MR_MSG_AUDIO 40 #define MR_MSG_AUDIO 40 /* m_param may contain MRP_FILE, MRP_DURATION */
#define MR_MSG_VOICE 41 #define MR_MSG_VOICE 41 /* - " - */
#define MR_MSG_VIDEO 50 #define MR_MSG_VIDEO 50 /* m_param may contain MRP_FILE, MRP_WIDTH, MRP_HEIGHT, MRP_DURATION */
#define MR_MSG_FILE 60 #define MR_MSG_FILE 60 /* m_param may contain MRP_FILE */
/** /**
* Message state. * Message state. It is recommended to use mrmsg_get_state() to access this field.
*
* Incoming message states:
* - MR_STATE_IN_FRESH (10) - Incoming _fresh_ message. Fresh messages are not noticed nor seen and are typically shown in notifications. Use mrmailbox_get_fresh_msgs() to get all fresh messages.
* - MR_STATE_IN_NOTICED (13) - Incoming _noticed_ message. Eg. chat opened but message not yet read - noticed messages are not counted as unread but did not marked as read nor resulted in MDNs. Use mrmailbox_marknoticed_chat() or mrmailbox_marknoticed_contact() to mark messages as being noticed.
* - MR_STATE_IN_SEEN (16) - Incoming message, really _seen_ by the user. Marked as read on IMAP and MDN may be send. Use mrmailbox_markseen_msgs() to mark messages as being seen.
*
* Outgoing message states:
* - MR_STATE_OUT_PENDING (20) - The user has send the "send" button but the
* message is not yet sent and is pending in some way. Maybe we're offline (no checkmark).
* - MR_STATE_OUT_ERROR (24) - _Unrecoverable_ error (_recoverable_ errors result in pending messages)
* - MR_STATE_OUT_DELIVERED (26) - Outgoing message successfully delivered to server (one checkmark). Note, that already delivered messages may get into the state MR_STATE_OUT_ERROR if we get such a hint from the server.
* If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_DELIVERED.
* - MR_STATE_OUT_MDN_RCVD (28) - Outgoing message read by the recipient (two checkmarks; this requires goodwill on the receiver's side)
* If a sent message changes to this state, you'll receive the event #MR_EVENT_MSG_READ.
*
* The state of just created message objects is MR_STATE_UNDEFINED (0).
*/ */
int m_state; int m_state;
#define MR_STATE_UNDEFINED 0 #define MR_STATE_UNDEFINED 0
@ -135,12 +109,18 @@ typedef struct mrmsg_t
#define MR_STATE_OUT_DELIVERED 26 #define MR_STATE_OUT_DELIVERED 26
#define MR_STATE_OUT_MDN_RCVD 28 #define MR_STATE_OUT_MDN_RCVD 28
char* m_text; /**< message text or NULL if unset */ /**
mrparam_t* m_param; /**< Additional paramter for the message. MRP_FILE, MRP_WIDTH, MRP_HEIGHT etc. depends on #m_type. Never a NULL-pointer. */ * Message text. NULL if unset. It is recommended to use
* mrmsg_set_text() and mrmsg_get_text() to access this field.
*/
char* m_text;
mrparam_t* m_param; /**< Additional paramter for the message. MRP_FILE, MRP_WIDTH, MRP_HEIGHT etc. depends on the type. Never a NULL-pointer. */
int m_starred; /**< Starred-state of the message. 0=no, 1=yes. */ int m_starred; /**< Starred-state of the message. 0=no, 1=yes. */
int m_is_msgrmsg; /**< Set to 1 if the message was sent by another messenger. 0 otherwise. */ int m_is_msgrmsg; /**< Set to 1 if the message was sent by another messenger. 0 otherwise. */
/** @privatesection */ /** @privatesection */
mrmailbox_t* m_mailbox; /**< may be NULL, set on loading from database and on sending */ mrmailbox_t* m_mailbox; /**< may be NULL, set on loading from database and on sending */
char* m_rfc724_mid; /**< The RFC-742 Message-ID */ char* m_rfc724_mid; /**< The RFC-742 Message-ID */
char* m_server_folder; /**< Folder where the message was last seen on the server */ char* m_server_folder; /**< Folder where the message was last seen on the server */
@ -153,15 +133,19 @@ void mrmsg_unref (mrmsg_t*);
void mrmsg_empty (mrmsg_t*); void mrmsg_empty (mrmsg_t*);
void mrmsg_set_type (mrmsg_t*, int type); void mrmsg_set_type (mrmsg_t*, int type);
void mrmsg_set_file (mrmsg_t*, const char* file);
void mrmsg_set_text (mrmsg_t*, const char* text); void mrmsg_set_text (mrmsg_t*, const char* text);
void mrmsg_set_file (mrmsg_t*, const char* file);
mrpoortext_t* mrmsg_get_summary (mrmsg_t*, mrchat_t*); int mrmsg_get_type (mrmsg_t*);
char* mrmsg_get_summarytext (mrmsg_t*, int approx_characters); int mrmsg_get_state (mrmsg_t*);
int mrmsg_show_padlock (mrmsg_t*); char* mrmsg_get_text (mrmsg_t*);
char* mrmsg_get_file (mrmsg_t*); char* mrmsg_get_file (mrmsg_t*);
char* mrmsg_get_filename (mrmsg_t*); char* mrmsg_get_filename (mrmsg_t*);
mrpoortext_t* mrmsg_get_mediainfo (mrmsg_t*); mrpoortext_t* mrmsg_get_mediainfo (mrmsg_t*);
int mrmsg_get_showpadlock (mrmsg_t*);
mrpoortext_t* mrmsg_get_summary (mrmsg_t*, mrchat_t*);
char* mrmsg_get_summarytext (mrmsg_t*, int approx_characters);
int mrmsg_is_increation (mrmsg_t*); int mrmsg_is_increation (mrmsg_t*);
void mrmsg_save_param_to_disk (mrmsg_t*); void mrmsg_save_param_to_disk (mrmsg_t*);