Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / message.h
blob375bd3a2565f65b5b46a05539a61396e46515199
1 /* purple
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
5 * source distribution.
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_
24 /**
25 * SECTION:message
26 * @include: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
33 * with any metadata.
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))
48 /**
49 * PurpleMessage:
51 * A message data container.
53 struct _PurpleMessage
55 /*< private >*/
56 GObject parent;
59 /**
60 * PurpleMessageClass:
62 * Base class for #PurpleMessage objects.
64 struct _PurpleMessageClass
66 /*< private >*/
67 GObjectClass parent_class;
69 void (*purple_reserved1)(void);
70 void (*purple_reserved2)(void);
71 void (*purple_reserved3)(void);
72 void (*purple_reserved4)(void);
75 G_BEGIN_DECLS
77 /**
78 * purple_message_get_type:
80 * Returns: the #GType for a message.
82 GType
83 purple_message_get_type(void);
85 /**
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.
97 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.
114 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.
129 PurpleMessage *
130 purple_message_new_system(const gchar *contents, PurpleMessageFlags flags);
133 * purple_message_get_id:
134 * @msg: The message.
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.
141 guint
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.
152 PurpleMessage *
153 purple_message_find_by_id(guint id);
156 * purple_message_get_author:
157 * @msg: The message.
159 * Returns the author of the message - his screen name (not a local alias).
161 * Returns: the author of @msg.
163 const gchar *
164 purple_message_get_author(const PurpleMessage *msg);
167 * purple_message_get_recipient:
168 * @msg: The message.
170 * Returns the recipient of the message - his screen name (not a local alias).
172 * Returns: the recipient of @msg.
174 const gchar *
175 purple_message_get_recipient(const PurpleMessage *msg);
178 * purple_message_set_author_alias:
179 * @msg: The message.
180 * @alias: The alias.
182 * Sets the alias of @msg's author. You don't normally need to call this.
184 void
185 purple_message_set_author_alias(PurpleMessage *msg, const gchar *alias);
188 * purple_message_get_author_alias:
189 * @msg: The message.
191 * Returns the alias of @msg author.
193 * Returns: the @msg author's alias.
195 const gchar *
196 purple_message_get_author_alias(const PurpleMessage *msg);
199 * purple_message_set_contents:
200 * @msg: The message.
201 * @cont: The contents.
203 * Sets the contents of the @msg. It might be HTML.
205 void
206 purple_message_set_contents(PurpleMessage *msg, const gchar *cont);
209 * purple_message_get_contents:
210 * @msg: The message.
212 * Returns the contents of the message.
214 * Returns: the contents of @msg.
216 const gchar *
217 purple_message_get_contents(const PurpleMessage *msg);
220 * purple_message_is_empty:
221 * @msg: The message.
223 * Checks, if the message's body is empty.
225 * Returns: %TRUE, if @msg is empty.
227 gboolean
228 purple_message_is_empty(const PurpleMessage *msg);
231 * purple_message_set_time:
232 * @msg: The message.
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).
238 void
239 purple_message_set_time(PurpleMessage *msg, guint64 msgtime);
242 * purple_message_get_time:
243 * @msg: The message.
245 * Returns a @msg's timestamp.
247 * Returns: @msg's timestamp.
249 guint64
250 purple_message_get_time(const PurpleMessage *msg);
253 * purple_message_set_flags:
254 * @msg: The message.
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.
260 void
261 purple_message_set_flags(PurpleMessage *msg, PurpleMessageFlags flags);
264 * purple_message_get_flags:
265 * @msg: The message.
267 * Returns the flags of a @msg.
269 * Returns: the flags of a @msg.
271 PurpleMessageFlags
272 purple_message_get_flags(const PurpleMessage *msg);
274 G_END_DECLS
276 #endif /* _PURPLE_MESSAGE_H_ */