3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_MESSAGE_H_
23 #define _PURPLE_MESSAGE_H_
27 * @section_id: libpurple-message
28 * @short_description: serializable messages
29 * @title: Message model
31 * #PurpleMessage object collects data about a certain (incoming or outgoing) message.
32 * It (TODO: will be) serializable, so it can be stored in log and retrieved
36 #include <glib-object.h>
38 typedef struct _PurpleMessage PurpleMessage
;
39 typedef struct _PurpleMessageClass PurpleMessageClass
;
41 #define PURPLE_TYPE_MESSAGE (purple_message_get_type())
42 #define PURPLE_MESSAGE(smiley) (G_TYPE_CHECK_INSTANCE_CAST((smiley), PURPLE_TYPE_MESSAGE, PurpleMessage))
43 #define PURPLE_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_MESSAGE, PurpleMessageClass))
44 #define PURPLE_IS_MESSAGE(smiley) (G_TYPE_CHECK_INSTANCE_TYPE((smiley), PURPLE_TYPE_MESSAGE))
45 #define PURPLE_IS_MESSAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_MESSAGE))
46 #define PURPLE_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_MESSAGE, PurpleMessageClass))
51 * A message data container.
62 * Base class for #PurpleMessage objects.
64 struct _PurpleMessageClass
67 GObjectClass parent_class
;
69 void (*purple_reserved1
)(void);
70 void (*purple_reserved2
)(void);
71 void (*purple_reserved3
)(void);
72 void (*purple_reserved4
)(void);
78 * purple_message_get_type:
80 * Returns: the #GType for a message.
83 purple_message_get_type(void);
86 * purple_message_new_outgoing:
87 * @who: Message's recipient.
88 * @contents: The contents of a message.
89 * @flags: The message flags.
91 * Creates new outgoing message (the user is the author).
93 * You don't need to set the #PURPLE_MESSAGE_SEND flag.
95 * Returns: the new #PurpleMessage.
98 purple_message_new_outgoing(const gchar
*who
, const gchar
*contents
,
99 PurpleMessageFlags flags
);
102 * purple_message_new_incoming:
103 * @who: Message's author.
104 * @contents: The contents of a message.
105 * @flags: The message flags.
106 * @timestamp: The time of transmitting a message. May be %0 for a current time.
108 * Creates new incoming message (the user is the recipient).
110 * You don't need to set the #PURPLE_MESSAGE_RECV flag.
112 * Returns: the new #PurpleMessage.
115 purple_message_new_incoming(const gchar
*who
, const gchar
*contents
,
116 PurpleMessageFlags flags
, guint64 timestamp
);
119 * purple_message_new_system:
120 * @contents: The contents of a message.
121 * @flags: The message flags.
123 * Creates new system message.
125 * You don't need to set the #PURPLE_MESSAGE_SYSTEM flag.
127 * Returns: the new #PurpleMessage.
130 purple_message_new_system(const gchar
*contents
, PurpleMessageFlags flags
);
133 * purple_message_get_id:
136 * Returns the unique identifier of the message. These identifiers are not
137 * serialized - it's a per-session id.
139 * Returns: the global identifier of @msg.
142 purple_message_get_id(const PurpleMessage
*msg
);
145 * purple_message_find_by_id:
146 * @id: The message identifier.
148 * Finds the message with a given @id.
150 * Returns: the #PurpleMessage, or %NULL if not found.
153 purple_message_find_by_id(guint id
);
156 * purple_message_get_author:
159 * Returns the author of the message - his screen name (not a local alias).
161 * Returns: the author of @msg.
164 purple_message_get_author(const PurpleMessage
*msg
);
167 * purple_message_get_recipient:
170 * Returns the recipient of the message - his screen name (not a local alias).
172 * Returns: the recipient of @msg.
175 purple_message_get_recipient(const PurpleMessage
*msg
);
178 * purple_message_set_author_alias:
182 * Sets the alias of @msg's author. You don't normally need to call this.
185 purple_message_set_author_alias(PurpleMessage
*msg
, const gchar
*alias
);
188 * purple_message_get_author_alias:
191 * Returns the alias of @msg author.
193 * Returns: the @msg author's alias.
196 purple_message_get_author_alias(const PurpleMessage
*msg
);
199 * purple_message_set_contents:
201 * @cont: The contents.
203 * Sets the contents of the @msg. It might be HTML.
206 purple_message_set_contents(PurpleMessage
*msg
, const gchar
*cont
);
209 * purple_message_get_contents:
212 * Returns the contents of the message.
214 * Returns: the contents of @msg.
217 purple_message_get_contents(const PurpleMessage
*msg
);
220 * purple_message_is_empty:
223 * Checks, if the message's body is empty.
225 * Returns: %TRUE, if @msg is empty.
228 purple_message_is_empty(const PurpleMessage
*msg
);
231 * purple_message_set_time:
233 * @msgtime: The timestamp of a message.
235 * Sets the @msg's timestamp. It should be a date of posting, but it can be
236 * a date of receiving (if the former is not available).
239 purple_message_set_time(PurpleMessage
*msg
, guint64 msgtime
);
242 * purple_message_get_time:
245 * Returns a @msg's timestamp.
247 * Returns: @msg's timestamp.
250 purple_message_get_time(const PurpleMessage
*msg
);
253 * purple_message_set_flags:
255 * @flags: The message flags.
257 * Sets flags for @msg. It shouldn't be in a conflict with a message type,
258 * so use it carefully.
261 purple_message_set_flags(PurpleMessage
*msg
, PurpleMessageFlags flags
);
264 * purple_message_get_flags:
267 * Returns the flags of a @msg.
269 * Returns: the flags of a @msg.
272 purple_message_get_flags(const PurpleMessage
*msg
);
276 #endif /* _PURPLE_MESSAGE_H_ */