Rename message.[ch] to purplemessage.[ch]
Testing Done:
compiled and ran locally.
Reviewed at https://reviews.imfreedom.org/r/408/
--- a/doc/reference/libpurple/libpurple-docs.xml Mon Jan 11 00:20:09 2021 -0600
+++ b/doc/reference/libpurple/libpurple-docs.xml Mon Jan 11 01:08:47 2021 -0600
@@ -109,7 +109,7 @@
- <xi:include href="xml/message.xml" />
+ <xi:include href="xml/purplemessage.xml" /> <xi:include href="xml/purpleattachment.xml" />
<xi:include href="xml/log.xml" />
<xi:include href="xml/cmds.xml" />
--- a/libpurple/conversation.h Mon Jan 11 00:20:09 2021 -0600
+++ b/libpurple/conversation.h Mon Jan 11 01:08:47 2021 -0600
@@ -112,7 +112,7 @@
+#include "purplemessage.h" /**************************************************************************/
--- a/libpurple/core.c Mon Jan 11 00:20:09 2021 -0600
+++ b/libpurple/core.c Mon Jan 11 01:08:47 2021 -0600
@@ -31,12 +31,12 @@
+#include "purplemessage.h" #include "purpleprivate.h"
#include "savedstatuses.h"
--- a/libpurple/meson.build Mon Jan 11 00:20:09 2021 -0600
+++ b/libpurple/meson.build Mon Jan 11 01:08:47 2021 -0600
@@ -33,7 +33,6 @@
@@ -57,6 +56,7 @@
'purpleimconversation.c',
'purpleprotocolattention.c',
'purpleprotocolclient.c',
@@ -121,7 +121,6 @@
@@ -145,6 +144,7 @@
'purpleprotocolattention.h',
'purpleprotocolclient.h',
@@ -222,13 +222,13 @@
'purpleimconversation.h',
--- a/libpurple/message.c Mon Jan 11 00:20:09 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,572 +0,0 @@
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
-#include <glib/gi18n-lib.h>
-#include "purpleprivate.h"
- * A message data container.
- PurpleMessageContentType content_type;
- PurpleMessageFlags flags;
- GHashTable *attachments;
-static GParamSpec *properties[N_PROPERTIES];
-G_DEFINE_TYPE(PurpleMessage, purple_message, G_TYPE_OBJECT)
-/******************************************************************************
- *****************************************************************************/
-purple_message_set_id(PurpleMessage *message, guint id) {
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_ID]);
-purple_message_set_author(PurpleMessage *message, const gchar *author) {
- g_free(message->author);
- message->author = g_strdup(author);
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR]);
-/******************************************************************************
- * GObject Implementation
- *****************************************************************************/
-purple_message_get_property(GObject *object, guint param_id, GValue *value,
- PurpleMessage *message = PURPLE_MESSAGE(object);
- g_value_set_uint(value, purple_message_get_id(message));
- g_value_set_string(value, purple_message_get_author(message));
- case PROP_AUTHOR_ALIAS:
- g_value_set_string(value, purple_message_get_author_alias(message));
- g_value_set_string(value, purple_message_get_recipient(message));
- g_value_set_string(value, purple_message_get_contents(message));
- case PROP_CONTENT_TYPE:
- g_value_set_enum(value, purple_message_get_content_type(message));
- g_value_set_boxed(value, purple_message_get_timestamp(message));
- g_value_set_flags(value, purple_message_get_flags(message));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
-purple_message_set_property(GObject *object, guint param_id,
- const GValue *value, GParamSpec *pspec)
- PurpleMessage *message = PURPLE_MESSAGE(object);
- purple_message_set_id(message, g_value_get_uint(value));
- purple_message_set_author(message, g_value_get_string(value));
- case PROP_AUTHOR_ALIAS:
- purple_message_set_author_alias(message, g_value_get_string(value));
- purple_message_set_recipient(message, g_value_get_string(value));
- purple_message_set_contents(message, g_value_get_string(value));
- case PROP_CONTENT_TYPE:
- purple_message_set_content_type(message, g_value_get_enum(value));
- purple_message_set_timestamp(message, g_value_get_boxed(value));
- purple_message_set_flags(message, g_value_get_flags(value));
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
-purple_message_finalize(GObject *obj) {
- PurpleMessage *message = PURPLE_MESSAGE(obj);
- g_free(message->author);
- g_free(message->author_alias);
- g_free(message->recipient);
- g_free(message->contents);
- if(message->timestamp != NULL) {
- g_date_time_unref(message->timestamp);
- g_hash_table_destroy(message->attachments);
- G_OBJECT_CLASS(purple_message_parent_class)->finalize(obj);
-purple_message_init(PurpleMessage *message) {
- message->attachments = g_hash_table_new_full(g_int64_hash, g_int64_equal,
-purple_message_class_init(PurpleMessageClass *klass) {
- GObjectClass *obj_class = G_OBJECT_CLASS(klass);
- obj_class->get_property = purple_message_get_property;
- obj_class->set_property = purple_message_set_property;
- obj_class->finalize = purple_message_finalize;
- * The account specific identifier of the message.
- properties[PROP_ID] = g_param_spec_uint(
- "The session-unique message id",
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::author:
- * The author of the message.
- properties[PROP_AUTHOR] = g_param_spec_string(
- "The username of the person, who sent the message.",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::author-alias:
- * The alias of the author.
- properties[PROP_AUTHOR_ALIAS] = g_param_spec_string(
- "author-alias", "Author's alias",
- "The alias of the sender",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::recipient:
- * The recipient of the message.
- properties[PROP_RECIPIENT] = g_param_spec_string(
- "recipient", "Recipient",
- "The username of the recipient.",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::content:
- * The contents of the message.
- properties[PROP_CONTENTS] = g_param_spec_string(
- "contents", "Contents",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::content-type:
- * The content-type of the message.
- properties[PROP_CONTENT_TYPE] = g_param_spec_enum(
- "content-type", "content-type",
- "The content-type of the message.",
- PURPLE_TYPE_MESSAGE_CONTENT_TYPE, PURPLE_MESSAGE_CONTENT_TYPE_PLAIN,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::timestamp:
- * The timestamp of the message.
- properties[PROP_TIMESTAMP] = g_param_spec_boxed(
- "timestamp", "timestamp",
- "The timestamp of the message",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- * PurpleMessage::flags:
- * The #PurpleMessageFlags for the message.
- properties[PROP_FLAGS] = g_param_spec_flags(
- "Bitwise set of #PurpleMessageFlags flags",
- PURPLE_TYPE_MESSAGE_FLAGS, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-/******************************************************************************
- *****************************************************************************/
-purple_message_new_outgoing(const gchar *author, const gchar *recipient,
- const gchar *contents, PurpleMessageFlags flags)
- PurpleMessage *message = NULL;
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV));
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM));
- flags |= PURPLE_MESSAGE_SEND;
- dt = g_date_time_new_now_local();
- /* who may be NULL for outgoing MUC messages */
- message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE,
- "recipient", recipient,
-purple_message_new_incoming(const gchar *who, const gchar *contents,
- PurpleMessageFlags flags, guint64 timestamp)
- PurpleMessage *message = NULL;
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND));
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM));
- flags |= PURPLE_MESSAGE_RECV;
- dt = g_date_time_new_now_local();
- dt = g_date_time_new_from_unix_local((gint64)timestamp);
- message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE,
-purple_message_new_system(const gchar *contents, PurpleMessageFlags flags) {
- PurpleMessage *message = NULL;
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND));
- g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV));
- flags |= PURPLE_MESSAGE_SYSTEM;
- dt = g_date_time_new_now_local();
- message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE,
-purple_message_get_id(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0);
-purple_message_get_author(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- return message->author;
-purple_message_set_recipient(PurpleMessage *message, const gchar *recipient) {
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_free(message->recipient);
- message->recipient = g_strdup(recipient);
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_RECIPIENT]);
-purple_message_get_recipient(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- return message->recipient;
-purple_message_set_author_alias(PurpleMessage *message,
- const gchar *author_alias)
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_free(message->author_alias);
- message->author_alias = g_strdup(author_alias);
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR_ALIAS]);
-purple_message_get_author_alias(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- if (message->author_alias == NULL)
- return purple_message_get_author(message);
- return message->author_alias;
-purple_message_set_contents(PurpleMessage *message, const gchar *contents) {
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_free(message->contents);
- message->contents = g_strdup(contents);
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENTS]);
-purple_message_get_contents(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- return message->contents;
-purple_message_set_content_type(PurpleMessage *message,
- PurpleMessageContentType content_type)
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- message->content_type = content_type;
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENT_TYPE]);
-PurpleMessageContentType
-purple_message_get_content_type(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message),
- PURPLE_MESSAGE_CONTENT_TYPE_PLAIN);
- return message->content_type;
-purple_message_is_empty(PurpleMessage *message) {
- return (message->contents == NULL || message->contents[0] == '\0');
-purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp) {
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_clear_pointer(&message->timestamp, g_date_time_unref);
- if(timestamp != NULL) {
- message->timestamp = g_date_time_ref(timestamp);
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_TIMESTAMP]);
-purple_message_get_timestamp(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0);
- if(message->timestamp == NULL) {
- GDateTime *dt = g_date_time_new_now_local();
- purple_message_set_timestamp(message, dt);
- return message->timestamp;
-purple_message_format_timestamp(PurpleMessage *message, const gchar *format) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- g_return_val_if_fail(format != NULL, NULL);
- dt = purple_message_get_timestamp(message);
- return g_date_time_format(dt, format);
-purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags) {
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- message->flags = flags;
- g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_FLAGS]);
-purple_message_get_flags(PurpleMessage *message) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0);
-purple_message_add_attachment(PurpleMessage *message,
- PurpleAttachment *attachment)
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE);
- g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), FALSE);
- return g_hash_table_insert(message->attachments,
- purple_attachment_get_hash_key(attachment),
- g_object_ref(G_OBJECT(attachment)));
-purple_message_remove_attachment(PurpleMessage *message, guint64 id) {
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE);
- return g_hash_table_remove(message->attachments, &id);
-purple_message_get_attachment(PurpleMessage *message, guint64 id) {
- PurpleAttachment *attachment = NULL;
- g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL);
- attachment = g_hash_table_lookup(message->attachments, &id);
- if(PURPLE_IS_ATTACHMENT(attachment)) {
- return PURPLE_ATTACHMENT(g_object_ref(G_OBJECT(attachment)));
-purple_message_foreach_attachment(PurpleMessage *message,
- PurpleAttachmentForeachFunc func,
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_return_if_fail(func != NULL);
- g_hash_table_iter_init(&iter, message->attachments);
- while(g_hash_table_iter_next(&iter, NULL, &value)) {
- func(PURPLE_ATTACHMENT(value), data);
-purple_message_clear_attachments(PurpleMessage *message) {
- g_return_if_fail(PURPLE_IS_MESSAGE(message));
- g_hash_table_remove_all(message->attachments);
--- a/libpurple/message.h Mon Jan 11 00:20:09 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,431 +0,0 @@
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, see <https://www.gnu.org/licenses/>.
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#ifndef PURPLE_MESSAGE_H
-#define PURPLE_MESSAGE_H
- * @section_id: libpurple-message
- * @short_description: serializable messages
- * @title: Message model
- * #PurpleMessage object collects data about a certain (incoming or outgoing) message.
- * It (TODO: will be) serializable, so it can be stored in log and retrieved
-#include <glib-object.h>
-#include <libpurple/purpleattachment.h>
- * The standard _get_type macro for #PurpleMessage.
-#define PURPLE_TYPE_MESSAGE purple_message_get_type()
- * @PURPLE_MESSAGE_SEND: Outgoing message.
- * @PURPLE_MESSAGE_RECV: Incoming message.
- * @PURPLE_MESSAGE_SYSTEM: System message.
- * @PURPLE_MESSAGE_AUTO_RESP: Auto response.
- * @PURPLE_MESSAGE_ACTIVE_ONLY: Hint to the UI that this message should not be
- * shown in conversations which are only open for
- * internal UI purposes (e.g. for contact-aware
- * @PURPLE_MESSAGE_NICK: Contains your nick.
- * @PURPLE_MESSAGE_NO_LOG: Do not log.
- * @PURPLE_MESSAGE_ERROR: Error message.
- * @PURPLE_MESSAGE_DELAYED: Delayed message.
- * @PURPLE_MESSAGE_RAW: "Raw" message - don't apply formatting
- * @PURPLE_MESSAGE_IMAGES: Message contains images
- * @PURPLE_MESSAGE_NOTIFY: Message is a notification
- * @PURPLE_MESSAGE_NO_LINKIFY: Message should not be auto-linkified
- * @PURPLE_MESSAGE_INVISIBLE: Message should not be displayed
- * @PURPLE_MESSAGE_REMOTE_SEND: Message sent from another location,
- * not an echo of a local one
- * Flags applicable to a message. Most will have send, recv or system.
-typedef enum /*< flags >*/
- PURPLE_MESSAGE_SEND = 1 << 0,
- PURPLE_MESSAGE_RECV = 1 << 1,
- PURPLE_MESSAGE_SYSTEM = 1 << 2,
- PURPLE_MESSAGE_AUTO_RESP = 1 << 3,
- PURPLE_MESSAGE_ACTIVE_ONLY = 1 << 4,
- PURPLE_MESSAGE_NICK = 1 << 5,
- PURPLE_MESSAGE_NO_LOG = 1 << 6,
- PURPLE_MESSAGE_ERROR = 1 << 7,
- PURPLE_MESSAGE_DELAYED = 1 << 8,
- PURPLE_MESSAGE_RAW = 1 << 9,
- PURPLE_MESSAGE_IMAGES = 1 << 10,
- PURPLE_MESSAGE_NOTIFY = 1 << 11,
- PURPLE_MESSAGE_NO_LINKIFY = 1 << 12,
- PURPLE_MESSAGE_INVISIBLE = 1 << 13,
- PURPLE_MESSAGE_REMOTE_SEND = 1 << 14,
- * PurpleMessageContentType:
- * @PURPLE_MESSAGE_CONTENT_TYPE_PLAIN: The message has no formatting.
- * @PURPLE_MESSAGE_CONTENT_TYPE_HTML: The message is formatted in HTML.
- * @PURPLE_MESSAGE_CONTENT_TYPE_XHTML: The mesage is formatted in XHTML.
- * @PURPLE_MESSAGE_CONTENT_TYPE_MARKDOWN: The message is formatted in Markdown.
- * The message formatting for the message.
-typedef enum /*< prefix=PURPLE_MESSAGE_CONTENT_TYPE,underscore_name=PURPLE_MESSAGE_CONTENT_TYPE >*/
- PURPLE_MESSAGE_CONTENT_TYPE_PLAIN = 0,
- PURPLE_MESSAGE_CONTENT_TYPE_HTML,
- PURPLE_MESSAGE_CONTENT_TYPE_XHTML,
- PURPLE_MESSAGE_CONTENT_TYPE_MARKDOWN,
-} PurpleMessageContentType;
- * purple_message_get_type:
- * Returns: the #GType for a message.
-G_DECLARE_FINAL_TYPE(PurpleMessage, purple_message, PURPLE, MESSAGE, GObject)
- * purple_message_new_outgoing:
- * @recipient: The recipient.
- * @contents: The contents.
- * @flags: The #PurpleMessageFlags.
- * Creates new outgoing message to @recipient.
- * You don't need to set the #PURPLE_MESSAGE_SEND flag. If the message is not
- * plain text be sure to call purple_message_set_content_type().
- * Returns: (transfer full): The new #PurpleMessage instance.
-PurpleMessage *purple_message_new_outgoing(const gchar *author, const gchar *recipient, const gchar *contents, PurpleMessageFlags flags);
- * purple_message_new_incoming:
- * @who: Message's author.
- * @contents: The contents of a message.
- * @flags: The message flags.
- * @timestamp: The time of transmitting a message. May be 0 for a current time.
- * Creates new incoming message (the user is the recipient).
- * You don't need to set the #PURPLE_MESSAGE_RECV flag.
- * Returns: the new #PurpleMessage.
-PurpleMessage *purple_message_new_incoming(const gchar *who, const gchar *contents, PurpleMessageFlags flags, guint64 timestamp);
- * purple_message_new_system:
- * @contents: The contents of a message.
- * @flags: The message flags.
- * Creates new system message.
- * You don't need to set the #PURPLE_MESSAGE_SYSTEM flag.
- * Returns: the new #PurpleMessage.
-PurpleMessage *purple_message_new_system(const gchar *contents, PurpleMessageFlags flags);
- * purple_message_get_id:
- * @message: The message.
- * Returns the unique identifier of the message. These identifiers are not
- * serialized - it's a per-session id.
- * Returns: the global identifier of @message.
-guint purple_message_get_id(PurpleMessage *message);
- * purple_message_get_author:
- * @message: The message.
- * Returns the author of the message, not a local alias.
- * Returns: the author of @message.
-const gchar *purple_message_get_author(PurpleMessage *message);
- * purple_message_set_recipient:
- * @message: The #PurpleMessage instance.
- * @recipient: The name of the recipient.
- * Sets the recipient of @message to @recipient.
-void purple_message_set_recipient(PurpleMessage *message, const gchar *recipient);
- * purple_message_get_recipient:
- * @message: The message.
- * Returns the recipient of the message, not a local alias.
- * Returns: the recipient of @message.
-const gchar *purple_message_get_recipient(PurpleMessage *message);
- * purple_message_set_author_alias:
- * @message: The message.
- * Sets the alias of @message's author. You don't normally need to call this.
-void purple_message_set_author_alias(PurpleMessage *message, const gchar *alias);
- * purple_message_get_author_alias:
- * @message: The message.
- * Returns the alias of @message author.
- * Returns: the @message author's alias.
-const gchar *purple_message_get_author_alias(PurpleMessage *message);
- * purple_message_set_contents:
- * @message: The message.
- * Sets the contents of the @message. It might be HTML.
-void purple_message_set_contents(PurpleMessage *message, const gchar *cont);
- * purple_message_get_contents:
- * @message: The message.
- * Returns the contents of the message.
- * Returns: the contents of @message.
-const gchar *purple_message_get_contents(PurpleMessage *message);
- * purple_message_set_content_type:
- * @message: The #PurpleMessage instance.
- * @content_type: The #PurpleMessageContentType value.
- * Sets the content-type of @message to @content_type.
-void purple_message_set_content_type(PurpleMessage *message, PurpleMessageContentType content_type);
- * purple_message_get_content_type:
- * @message: The #PurpleMessage instance.
- * Gets the content-type of @message.
- * Returns: The #PurpleMessageContentType of @message.
-PurpleMessageContentType purple_message_get_content_type(PurpleMessage *message);
- * purple_message_is_empty:
- * @message: The message.
- * Checks, if the message's body is empty.
- * Returns: %TRUE, if @message is empty.
-gboolean purple_message_is_empty(PurpleMessage *message);
- * purple_message_set_timestamp:
- * @message: The #PurpleMessage instance.
- * @timestamp: (nullable): The #GDateTime of the message.
- * Sets the timestamp of @message.
-void purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp);
- * purple_message_get_timestamp:
- * @message: The message.
- * Returns a @message's timestamp. If @message does not currently have a
- * timestamp, the current time will be set as the time stamp and returned.
- * Returns: (transfer none): The #GDateTime timestamp from @message.
-GDateTime *purple_message_get_timestamp(PurpleMessage *message);
- * purple_message_format_timestamp:
- * @message: The #PurpleMessage instance.
- * @format: The format to output the time stamp as.
- * Formats the timestamp of @message and returns it.
- * Returns: The formatted timestamp.
-gchar *purple_message_format_timestamp(PurpleMessage *message, const gchar *format);
- * purple_message_set_flags:
- * @message: The message.
- * @flags: The message flags.
- * Sets flags for @message. It shouldn't be in a conflict with a message type,
-void purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags);
- * purple_message_get_flags:
- * @message: The message.
- * Returns the flags of a @message.
- * Returns: the flags of a @message.
-PurpleMessageFlags purple_message_get_flags(PurpleMessage *message);
- * purple_message_add_attachment:
- * @message: The #PurpleMessage instance.
- * @attachment: The #PurpleAttachment instance.
- * Adds @attachment to @message.
- * Returns %TRUE if an attachment with the same ID did not already exist.
-gboolean purple_message_add_attachment(PurpleMessage *message, PurpleAttachment *attachment);
- * purple_message_remove_attachment:
- * @message: The #PurpleMessage instance.
- * @id: The id of the #PurpleAttachment
- * Removes the #PurpleAttachment identified by @id if it exists.
- * Returns: %TRUE if the #PurpleAttachment was found and removed, %FALSE
-gboolean purple_message_remove_attachment(PurpleMessage *message, guint64 id);
- * purple_message_get_attachment:
- * @message: The #PurpleMessage instance.
- * @id: The id of the #PurpleAttachment to get.
- * Retrieves the #PurpleAttachment identified by @id from @message.
- * Returns: (transfer full): The #PurpleAttachment if it was found, otherwise
-PurpleAttachment *purple_message_get_attachment(PurpleMessage *message, guint64 id);
- * purple_message_foreach_attachment:
- * @message: The #PurpleMessage instance.
- * @func: (scope call): The #PurpleAttachmentForeachFunc to call.
- * @data: User data to pass to @func.
- * Calls @func for each #PurpleAttachment that's attached to @message.
-void purple_message_foreach_attachment(PurpleMessage *message, PurpleAttachmentForeachFunc func, gpointer data);
- * purple_message_clear_attachments:
- * @message: The #PurpleMessage instance.
- * Removes all attachments from @message.
-void purple_message_clear_attachments(PurpleMessage *message);
-#endif /* PURPLE_MESSAGE_H */
--- a/libpurple/protocol.h Mon Jan 11 00:20:09 2021 -0600
+++ b/libpurple/protocol.h Mon Jan 11 01:08:47 2021 -0600
@@ -55,11 +55,11 @@
#include "purpleaccountoption.h"
#include "purpleaccountusersplit.h"
+#include "purplemessage.h" #include "purplewhiteboard.h"
#include "purplewhiteboardops.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purplemessage.c Mon Jan 11 01:08:47 2021 -0600
@@ -0,0 +1,573 @@
+ * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. +#include <glib/gi18n-lib.h> +#include "purplemessage.h" +#include "purpleprivate.h" + * A message data container. + PurpleMessageContentType content_type; + PurpleMessageFlags flags; + GHashTable *attachments; +static GParamSpec *properties[N_PROPERTIES]; +G_DEFINE_TYPE(PurpleMessage, purple_message, G_TYPE_OBJECT) +/****************************************************************************** + *****************************************************************************/ +purple_message_set_id(PurpleMessage *message, guint id) { + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_ID]); +purple_message_set_author(PurpleMessage *message, const gchar *author) { + g_free(message->author); + message->author = g_strdup(author); + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR]); +/****************************************************************************** + * GObject Implementation + *****************************************************************************/ +purple_message_get_property(GObject *object, guint param_id, GValue *value, + PurpleMessage *message = PURPLE_MESSAGE(object); + g_value_set_uint(value, purple_message_get_id(message)); + g_value_set_string(value, purple_message_get_author(message)); + case PROP_AUTHOR_ALIAS: + g_value_set_string(value, purple_message_get_author_alias(message)); + g_value_set_string(value, purple_message_get_recipient(message)); + g_value_set_string(value, purple_message_get_contents(message)); + case PROP_CONTENT_TYPE: + g_value_set_enum(value, purple_message_get_content_type(message)); + g_value_set_boxed(value, purple_message_get_timestamp(message)); + g_value_set_flags(value, purple_message_get_flags(message)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); +purple_message_set_property(GObject *object, guint param_id, + const GValue *value, GParamSpec *pspec) + PurpleMessage *message = PURPLE_MESSAGE(object); + purple_message_set_id(message, g_value_get_uint(value)); + purple_message_set_author(message, g_value_get_string(value)); + case PROP_AUTHOR_ALIAS: + purple_message_set_author_alias(message, g_value_get_string(value)); + purple_message_set_recipient(message, g_value_get_string(value)); + purple_message_set_contents(message, g_value_get_string(value)); + case PROP_CONTENT_TYPE: + purple_message_set_content_type(message, g_value_get_enum(value)); + purple_message_set_timestamp(message, g_value_get_boxed(value)); + purple_message_set_flags(message, g_value_get_flags(value)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); +purple_message_finalize(GObject *obj) { + PurpleMessage *message = PURPLE_MESSAGE(obj); + g_free(message->author); + g_free(message->author_alias); + g_free(message->recipient); + g_free(message->contents); + if(message->timestamp != NULL) { + g_date_time_unref(message->timestamp); + g_hash_table_destroy(message->attachments); + G_OBJECT_CLASS(purple_message_parent_class)->finalize(obj); +purple_message_init(PurpleMessage *message) { + message->attachments = g_hash_table_new_full(g_int64_hash, g_int64_equal, +purple_message_class_init(PurpleMessageClass *klass) { + GObjectClass *obj_class = G_OBJECT_CLASS(klass); + obj_class->get_property = purple_message_get_property; + obj_class->set_property = purple_message_set_property; + obj_class->finalize = purple_message_finalize; + * The account specific identifier of the message. + properties[PROP_ID] = g_param_spec_uint( + "The session-unique message id", + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::author: + * The author of the message. + properties[PROP_AUTHOR] = g_param_spec_string( + "The username of the person, who sent the message.", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::author-alias: + * The alias of the author. + properties[PROP_AUTHOR_ALIAS] = g_param_spec_string( + "author-alias", "Author's alias", + "The alias of the sender", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::recipient: + * The recipient of the message. + properties[PROP_RECIPIENT] = g_param_spec_string( + "recipient", "Recipient", + "The username of the recipient.", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::content: + * The contents of the message. + properties[PROP_CONTENTS] = g_param_spec_string( + "contents", "Contents", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::content-type: + * The content-type of the message. + properties[PROP_CONTENT_TYPE] = g_param_spec_enum( + "content-type", "content-type", + "The content-type of the message.", + PURPLE_TYPE_MESSAGE_CONTENT_TYPE, PURPLE_MESSAGE_CONTENT_TYPE_PLAIN, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::timestamp: + * The timestamp of the message. + properties[PROP_TIMESTAMP] = g_param_spec_boxed( + "timestamp", "timestamp", + "The timestamp of the message", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + * PurpleMessage::flags: + * The #PurpleMessageFlags for the message. + properties[PROP_FLAGS] = g_param_spec_flags( + "Bitwise set of #PurpleMessageFlags flags", + PURPLE_TYPE_MESSAGE_FLAGS, 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(obj_class, N_PROPERTIES, properties); +/****************************************************************************** + *****************************************************************************/ +purple_message_new_outgoing(const gchar *author, const gchar *recipient, + const gchar *contents, PurpleMessageFlags flags) + PurpleMessage *message = NULL; + g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV)); + g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM)); + flags |= PURPLE_MESSAGE_SEND; + dt = g_date_time_new_now_local(); + /* who may be NULL for outgoing MUC messages */ + message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, + "recipient", recipient, +purple_message_new_incoming(const gchar *who, const gchar *contents, + PurpleMessageFlags flags, guint64 timestamp) + PurpleMessage *message = NULL; + g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND)); + g_warn_if_fail(!(flags & PURPLE_MESSAGE_SYSTEM)); + flags |= PURPLE_MESSAGE_RECV; + dt = g_date_time_new_now_local(); + dt = g_date_time_new_from_unix_local((gint64)timestamp); + message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, +purple_message_new_system(const gchar *contents, PurpleMessageFlags flags) { + PurpleMessage *message = NULL; + g_warn_if_fail(!(flags & PURPLE_MESSAGE_SEND)); + g_warn_if_fail(!(flags & PURPLE_MESSAGE_RECV)); + flags |= PURPLE_MESSAGE_SYSTEM; + dt = g_date_time_new_now_local(); + message = PURPLE_MESSAGE(g_object_new(PURPLE_TYPE_MESSAGE, +purple_message_get_id(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); +purple_message_get_author(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + return message->author; +purple_message_set_recipient(PurpleMessage *message, const gchar *recipient) { + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_free(message->recipient); + message->recipient = g_strdup(recipient); + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_RECIPIENT]); +purple_message_get_recipient(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + return message->recipient; +purple_message_set_author_alias(PurpleMessage *message, + const gchar *author_alias) + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_free(message->author_alias); + message->author_alias = g_strdup(author_alias); + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_AUTHOR_ALIAS]); +purple_message_get_author_alias(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + if (message->author_alias == NULL) + return purple_message_get_author(message); + return message->author_alias; +purple_message_set_contents(PurpleMessage *message, const gchar *contents) { + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_free(message->contents); + message->contents = g_strdup(contents); + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENTS]); +purple_message_get_contents(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + return message->contents; +purple_message_set_content_type(PurpleMessage *message, + PurpleMessageContentType content_type) + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + message->content_type = content_type; + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_CONTENT_TYPE]); +PurpleMessageContentType +purple_message_get_content_type(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), + PURPLE_MESSAGE_CONTENT_TYPE_PLAIN); + return message->content_type; +purple_message_is_empty(PurpleMessage *message) { + return (message->contents == NULL || message->contents[0] == '\0'); +purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp) { + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_clear_pointer(&message->timestamp, g_date_time_unref); + if(timestamp != NULL) { + message->timestamp = g_date_time_ref(timestamp); + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_TIMESTAMP]); +purple_message_get_timestamp(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); + if(message->timestamp == NULL) { + GDateTime *dt = g_date_time_new_now_local(); + purple_message_set_timestamp(message, dt); + return message->timestamp; +purple_message_format_timestamp(PurpleMessage *message, const gchar *format) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + g_return_val_if_fail(format != NULL, NULL); + dt = purple_message_get_timestamp(message); + return g_date_time_format(dt, format); +purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags) { + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + message->flags = flags; + g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_FLAGS]); +purple_message_get_flags(PurpleMessage *message) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), 0); +purple_message_add_attachment(PurpleMessage *message, + PurpleAttachment *attachment) + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE); + g_return_val_if_fail(PURPLE_IS_ATTACHMENT(attachment), FALSE); + return g_hash_table_insert(message->attachments, + purple_attachment_get_hash_key(attachment), + g_object_ref(G_OBJECT(attachment))); +purple_message_remove_attachment(PurpleMessage *message, guint64 id) { + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), FALSE); + return g_hash_table_remove(message->attachments, &id); +purple_message_get_attachment(PurpleMessage *message, guint64 id) { + PurpleAttachment *attachment = NULL; + g_return_val_if_fail(PURPLE_IS_MESSAGE(message), NULL); + attachment = g_hash_table_lookup(message->attachments, &id); + if(PURPLE_IS_ATTACHMENT(attachment)) { + return PURPLE_ATTACHMENT(g_object_ref(G_OBJECT(attachment))); +purple_message_foreach_attachment(PurpleMessage *message, + PurpleAttachmentForeachFunc func, + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_return_if_fail(func != NULL); + g_hash_table_iter_init(&iter, message->attachments); + while(g_hash_table_iter_next(&iter, NULL, &value)) { + func(PURPLE_ATTACHMENT(value), data); +purple_message_clear_attachments(PurpleMessage *message) { + g_return_if_fail(PURPLE_IS_MESSAGE(message)); + g_hash_table_remove_all(message->attachments); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purplemessage.h Mon Jan 11 01:08:47 2021 -0600
@@ -0,0 +1,429 @@
+ * Purple - Internet Messaging Library + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <https://www.gnu.org/licenses/>. +#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) +# error "only <purple.h> may be included directly" +#ifndef PURPLE_MESSAGE_H +#define PURPLE_MESSAGE_H + * SECTION:purplemessage + * @section_id: libpurple-purplemessage + * @short_description: Message Object + * @title: Message Object + * #PurpleMessage represents any message passed between users in libpurple. +#include <glib-object.h> +#include <libpurple/purpleattachment.h> + * The standard _get_type macro for #PurpleMessage. +#define PURPLE_TYPE_MESSAGE purple_message_get_type() + * @PURPLE_MESSAGE_SEND: Outgoing message. + * @PURPLE_MESSAGE_RECV: Incoming message. + * @PURPLE_MESSAGE_SYSTEM: System message. + * @PURPLE_MESSAGE_AUTO_RESP: Auto response. + * @PURPLE_MESSAGE_ACTIVE_ONLY: Hint to the UI that this message should not be + * shown in conversations which are only open for + * internal UI purposes (e.g. for contact-aware + * @PURPLE_MESSAGE_NICK: Contains your nick. + * @PURPLE_MESSAGE_NO_LOG: Do not log. + * @PURPLE_MESSAGE_ERROR: Error message. + * @PURPLE_MESSAGE_DELAYED: Delayed message. + * @PURPLE_MESSAGE_RAW: "Raw" message - don't apply formatting. + * @PURPLE_MESSAGE_IMAGES: Message contains images. + * @PURPLE_MESSAGE_NOTIFY: Message is a notification. + * @PURPLE_MESSAGE_NO_LINKIFY: Message should not be auto-linkified. + * @PURPLE_MESSAGE_INVISIBLE: Message should not be displayed. + * @PURPLE_MESSAGE_REMOTE_SEND: Message sent from another location, not an echo + * Flags applicable to a message. Most will have send, recv or system. +typedef enum /*< flags >*/ + PURPLE_MESSAGE_SEND = 1 << 0, + PURPLE_MESSAGE_RECV = 1 << 1, + PURPLE_MESSAGE_SYSTEM = 1 << 2, + PURPLE_MESSAGE_AUTO_RESP = 1 << 3, + PURPLE_MESSAGE_ACTIVE_ONLY = 1 << 4, + PURPLE_MESSAGE_NICK = 1 << 5, + PURPLE_MESSAGE_NO_LOG = 1 << 6, + PURPLE_MESSAGE_ERROR = 1 << 7, + PURPLE_MESSAGE_DELAYED = 1 << 8, + PURPLE_MESSAGE_RAW = 1 << 9, + PURPLE_MESSAGE_IMAGES = 1 << 10, + PURPLE_MESSAGE_NOTIFY = 1 << 11, + PURPLE_MESSAGE_NO_LINKIFY = 1 << 12, + PURPLE_MESSAGE_INVISIBLE = 1 << 13, + PURPLE_MESSAGE_REMOTE_SEND = 1 << 14, + * PurpleMessageContentType: + * @PURPLE_MESSAGE_CONTENT_TYPE_PLAIN: The message has no formatting. + * @PURPLE_MESSAGE_CONTENT_TYPE_HTML: The message is formatted in HTML. + * @PURPLE_MESSAGE_CONTENT_TYPE_XHTML: The mesage is formatted in XHTML. + * @PURPLE_MESSAGE_CONTENT_TYPE_MARKDOWN: The message is formatted in Markdown. + * The message formatting for the message. +typedef enum /*< prefix=PURPLE_MESSAGE_CONTENT_TYPE,underscore_name=PURPLE_MESSAGE_CONTENT_TYPE >*/ + PURPLE_MESSAGE_CONTENT_TYPE_PLAIN = 0, + PURPLE_MESSAGE_CONTENT_TYPE_HTML, + PURPLE_MESSAGE_CONTENT_TYPE_XHTML, + PURPLE_MESSAGE_CONTENT_TYPE_MARKDOWN, +} PurpleMessageContentType; + * purple_message_get_type: + * Returns: the #GType for a message. +G_DECLARE_FINAL_TYPE(PurpleMessage, purple_message, PURPLE, MESSAGE, GObject) + * purple_message_new_outgoing: + * @recipient: The recipient. + * @contents: The contents. + * @flags: The #PurpleMessageFlags. + * Creates new outgoing message to @recipient. + * You don't need to set the #PURPLE_MESSAGE_SEND flag. If the message is not + * plain text be sure to call purple_message_set_content_type(). + * Returns: (transfer full): The new #PurpleMessage instance. +PurpleMessage *purple_message_new_outgoing(const gchar *author, const gchar *recipient, const gchar *contents, PurpleMessageFlags flags); + * purple_message_new_incoming: + * @who: Message's author. + * @contents: The contents of a message. + * @flags: The message flags. + * @timestamp: The time of transmitting a message. May be 0 for a current time. + * Creates new incoming message (the user is the recipient). + * You don't need to set the #PURPLE_MESSAGE_RECV flag. + * Returns: the new #PurpleMessage. +PurpleMessage *purple_message_new_incoming(const gchar *who, const gchar *contents, PurpleMessageFlags flags, guint64 timestamp); + * purple_message_new_system: + * @contents: The contents of a message. + * @flags: The message flags. + * Creates new system message. + * You don't need to set the #PURPLE_MESSAGE_SYSTEM flag. + * Returns: the new #PurpleMessage. +PurpleMessage *purple_message_new_system(const gchar *contents, PurpleMessageFlags flags); + * purple_message_get_id: + * @message: The message. + * Returns the unique identifier of the message. These identifiers are not + * serialized - it's a per-session id. + * Returns: the global identifier of @message. +guint purple_message_get_id(PurpleMessage *message); + * purple_message_get_author: + * @message: The message. + * Returns the author of the message, not a local alias. + * Returns: the author of @message. +const gchar *purple_message_get_author(PurpleMessage *message); + * purple_message_set_recipient: + * @message: The #PurpleMessage instance. + * @recipient: The name of the recipient. + * Sets the recipient of @message to @recipient. +void purple_message_set_recipient(PurpleMessage *message, const gchar *recipient); + * purple_message_get_recipient: + * @message: The message. + * Returns the recipient of the message, not a local alias. + * Returns: the recipient of @message. +const gchar *purple_message_get_recipient(PurpleMessage *message); + * purple_message_set_author_alias: + * @message: The message. + * Sets the alias of @message's author. You don't normally need to call this. +void purple_message_set_author_alias(PurpleMessage *message, const gchar *alias); + * purple_message_get_author_alias: + * @message: The message. + * Returns the alias of @message author. + * Returns: the @message author's alias. +const gchar *purple_message_get_author_alias(PurpleMessage *message); + * purple_message_set_contents: + * @message: The message. + * Sets the contents of the @message. It might be HTML. +void purple_message_set_contents(PurpleMessage *message, const gchar *cont); + * purple_message_get_contents: + * @message: The message. + * Returns the contents of the message. + * Returns: the contents of @message. +const gchar *purple_message_get_contents(PurpleMessage *message); + * purple_message_set_content_type: + * @message: The #PurpleMessage instance. + * @content_type: The #PurpleMessageContentType value. + * Sets the content-type of @message to @content_type. +void purple_message_set_content_type(PurpleMessage *message, PurpleMessageContentType content_type); + * purple_message_get_content_type: + * @message: The #PurpleMessage instance. + * Gets the content-type of @message. + * Returns: The #PurpleMessageContentType of @message. +PurpleMessageContentType purple_message_get_content_type(PurpleMessage *message); + * purple_message_is_empty: + * @message: The message. + * Checks, if the message's body is empty. + * Returns: %TRUE, if @message is empty. +gboolean purple_message_is_empty(PurpleMessage *message); + * purple_message_set_timestamp: + * @message: The #PurpleMessage instance. + * @timestamp: (nullable): The #GDateTime of the message. + * Sets the timestamp of @message. +void purple_message_set_timestamp(PurpleMessage *message, GDateTime *timestamp); + * purple_message_get_timestamp: + * @message: The message. + * Returns a @message's timestamp. If @message does not currently have a + * timestamp, the current time will be set as the time stamp and returned. + * Returns: (transfer none): The #GDateTime timestamp from @message. +GDateTime *purple_message_get_timestamp(PurpleMessage *message); + * purple_message_format_timestamp: + * @message: The #PurpleMessage instance. + * @format: The format to output the time stamp as. + * Formats the timestamp of @message and returns it. + * Returns: The formatted timestamp. +gchar *purple_message_format_timestamp(PurpleMessage *message, const gchar *format); + * purple_message_set_flags: + * @message: The message. + * @flags: The message flags. + * Sets flags for @message. It shouldn't be in a conflict with a message type, +void purple_message_set_flags(PurpleMessage *message, PurpleMessageFlags flags); + * purple_message_get_flags: + * @message: The message. + * Returns the flags of a @message. + * Returns: the flags of a @message. +PurpleMessageFlags purple_message_get_flags(PurpleMessage *message); + * purple_message_add_attachment: + * @message: The #PurpleMessage instance. + * @attachment: The #PurpleAttachment instance. + * Adds @attachment to @message. + * Returns %TRUE if an attachment with the same ID did not already exist. +gboolean purple_message_add_attachment(PurpleMessage *message, PurpleAttachment *attachment); + * purple_message_remove_attachment: + * @message: The #PurpleMessage instance. + * @id: The id of the #PurpleAttachment + * Removes the #PurpleAttachment identified by @id if it exists. + * Returns: %TRUE if the #PurpleAttachment was found and removed, %FALSE +gboolean purple_message_remove_attachment(PurpleMessage *message, guint64 id); + * purple_message_get_attachment: + * @message: The #PurpleMessage instance. + * @id: The id of the #PurpleAttachment to get. + * Retrieves the #PurpleAttachment identified by @id from @message. + * Returns: (transfer full): The #PurpleAttachment if it was found, otherwise +PurpleAttachment *purple_message_get_attachment(PurpleMessage *message, guint64 id); + * purple_message_foreach_attachment: + * @message: The #PurpleMessage instance. + * @func: (scope call): The #PurpleAttachmentForeachFunc to call. + * @data: User data to pass to @func. + * Calls @func for each #PurpleAttachment that's attached to @message. +void purple_message_foreach_attachment(PurpleMessage *message, PurpleAttachmentForeachFunc func, gpointer data); + * purple_message_clear_attachments: + * @message: The #PurpleMessage instance. + * Removes all attachments from @message. +void purple_message_clear_attachments(PurpleMessage *message); +#endif /* PURPLE_MESSAGE_H */ --- a/libpurple/server.h Mon Jan 11 00:20:09 2021 -0600
+++ b/libpurple/server.h Mon Jan 11 01:08:47 2021 -0600
@@ -40,9 +40,9 @@
#include "conversations.h"
#include "purpleattentiontype.h"
+#include "purplemessage.h" --- a/po/POTFILES.in Mon Jan 11 00:20:09 2021 -0600
+++ b/po/POTFILES.in Mon Jan 11 01:08:47 2021 -0600
@@ -57,7 +57,6 @@
libpurple/media/enum-types.c
@@ -255,6 +254,7 @@
libpurple/purplecredentialprovider.c
libpurple/purpleimconversation.c
+libpurple/purplemessage.c libpurple/purplepresence.c
libpurple/purpleprotocolattention.c
libpurple/purpleprotocolclient.c