diff --git a/cmdline/cmdline.c b/cmdline/cmdline.c index adb98ec0..e4784989 100644 --- a/cmdline/cmdline.c +++ b/cmdline/cmdline.c @@ -684,7 +684,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline) else if( strcmp(cmd, "groupimage")==0 ) { if( sel_chat ) { - ret = mrmailbox_set_chat_image(mailbox, sel_chat->m_id, (arg1&&arg1[0])?arg1:NULL)? COMMAND_SUCCEEDED : COMMAND_FAILED; + ret = mrmailbox_set_chat_profile_image(mailbox, sel_chat->m_id, (arg1&&arg1[0])?arg1:NULL)? COMMAND_SUCCEEDED : COMMAND_FAILED; } else { ret = safe_strdup("No chat selected."); diff --git a/src/mrchat.c b/src/mrchat.c index c1b0bb6a..30e4511d 100644 --- a/src/mrchat.c +++ b/src/mrchat.c @@ -107,8 +107,35 @@ void mrchat_empty(mrchat_t* chat) } +/******************************************************************************* + * Getters + ******************************************************************************/ + + /** - * Get a subtitle for a chat. The sibtitle is eg. the email-address or the + * Get the chat's profile image. + * The profile image is set using mrmailbox_set_chat_profile_image() for groups. + * For normal chats, the profile image is set using mrmailbox_set_contact_profile_image() (not yet implemented). + * + * @memberof mrchat_t + * + * @param chat The chat object. + * + * @return Path and file if the profile image, if any. NULL otherwise. + * Must be free()'d after usage. + */ +char* mrchat_get_profile_image(mrchat_t* chat) +{ + if( chat == NULL ) { + return NULL; + } + + return mrparam_get(chat->m_param, MRP_PROFILE_IMAGE, NULL); +} + + +/** + * Get a subtitle for a chat. The subtitle is eg. the email-address or the * number of group members. * * @memberof mrchat_t @@ -177,6 +204,11 @@ char* mrchat_get_subtitle(mrchat_t* chat) } +/******************************************************************************* + * Misc. + ******************************************************************************/ + + int mrchat_update_param__(mrchat_t* ths) { int success = 0; diff --git a/src/mrchat.h b/src/mrchat.h index 3f1f0cfa..cd736e7d 100644 --- a/src/mrchat.h +++ b/src/mrchat.h @@ -125,15 +125,9 @@ typedef struct mrchat_t */ int m_archived; - /** - * Additional parameters for the chat. - * - * To access the parameters, use mrparam_exists(), mrparam_get() for mrparam_get_int() - */ - mrparam_t* m_param; - /** @privatesection */ - char* m_grpid; /* NULL if unset */ + char* m_grpid; /**< Group ID that is used by all clients. Only used if the chat is a group. NULL if unset */ + mrparam_t* m_param; /**< Additional parameters for a chat. Should not be used directly. */ } mrchat_t; @@ -141,6 +135,7 @@ mrchat_t* mrchat_new (mrmailbox_t*); void mrchat_empty (mrchat_t*); void mrchat_unref (mrchat_t*); +char* mrchat_get_profile_image (mrchat_t*); char* mrchat_get_subtitle (mrchat_t*); /* library-internal */ diff --git a/src/mrevent.h b/src/mrevent.h index 63f01d8c..5d1b875b 100644 --- a/src/mrevent.h +++ b/src/mrevent.h @@ -136,7 +136,7 @@ extern "C" { /** * Group changed. The name or the image of a chat group was changed or members were added or removed. - * See mrmailbox_set_chat_name(), mrmailbox_set_chat_image(), mrmailbox_add_contact_to_chat() + * See mrmailbox_set_chat_name(), mrmailbox_set_chat_profile_image(), mrmailbox_add_contact_to_chat() * and mrmailbox_remove_contact_from_chat(). * * @param data1 chat_id diff --git a/src/mrmailbox.c b/src/mrmailbox.c index 17ae17f8..0b338494 100644 --- a/src/mrmailbox.c +++ b/src/mrmailbox.c @@ -3475,13 +3475,15 @@ cleanup: /** - * Set group image. + * Set group profile image. * * If the group is already _promoted_ (any message was sent to the group), * all group members are informed by a special status message that is sent automatically by this function. * * Sends out #MR_EVENT_CHAT_MODIFIED and #MR_EVENT_MSGS_CHANGED if a status message was sent. * + * To find out the profile image of a chat, use mrchat_get_profile_image() + * * @memberof mrmailbox_t * * @param mailbox Mailbox object as created by mrmailbox_new(). @@ -3493,7 +3495,7 @@ cleanup: * * @return 1=success, 0=error */ -int mrmailbox_set_chat_image(mrmailbox_t* mailbox, uint32_t chat_id, const char* new_image /*NULL=remove image*/) +int mrmailbox_set_chat_profile_image(mrmailbox_t* mailbox, uint32_t chat_id, const char* new_image /*NULL=remove image*/) { int success = 0, locked = 0;; mrchat_t* chat = mrchat_new(mailbox); diff --git a/src/mrmailbox.h b/src/mrmailbox.h index 05a1906d..0d3d98b4 100644 --- a/src/mrmailbox.h +++ b/src/mrmailbox.h @@ -277,12 +277,12 @@ mrchat_t* mrmailbox_get_chat (mrmailbox_t*, uint32_t chat_id); /* Handle group chats */ -uint32_t mrmailbox_create_group_chat (mrmailbox_t*, const char* name); -int mrmailbox_is_contact_in_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id); -int mrmailbox_add_contact_to_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id); +uint32_t mrmailbox_create_group_chat (mrmailbox_t*, const char* name); +int mrmailbox_is_contact_in_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id); +int mrmailbox_add_contact_to_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id); int mrmailbox_remove_contact_from_chat (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id); -int mrmailbox_set_chat_name (mrmailbox_t*, uint32_t chat_id, const char* name); -int mrmailbox_set_chat_image (mrmailbox_t*, uint32_t chat_id, const char* image); +int mrmailbox_set_chat_name (mrmailbox_t*, uint32_t chat_id, const char* name); +int mrmailbox_set_chat_profile_image (mrmailbox_t*, uint32_t chat_id, const char* image); /* Handle messages */