1 /* 2 * message.h - Header for TpMessage 3 * Copyright (C) 2006-2010 Collabora Ltd. 4 * Copyright (C) 2006-2008 Nokia Corporation 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION) 22 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly." 23 #endif 24 25 #ifndef __TP_MESSAGE_H__ 26 #define __TP_MESSAGE_H__ 27 28 #include <telepathy-glib/defs.h> 29 #include <telepathy-glib/enums.h> 30 #include <telepathy-glib/handle.h> 31 32 G_BEGIN_DECLS 33 34 #define TP_TYPE_MESSAGE (tp_message_get_type ()) 35 #define TP_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TYPE_MESSAGE, TpMessage)) 36 #define TP_MESSAGE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), TP_TYPE_MESSAGE, TpMessageClass)) 37 #define TP_IS_MESSAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TYPE_MESSAGE)) 38 #define TP_IS_MESSAGE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), TP_TYPE_MESSAGE)) 39 #define TP_MESSAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_MESSAGE, TpMessageClass)) 40 41 typedef struct _TpMessage TpMessage; 42 typedef struct _TpMessageClass TpMessageClass; 43 44 GType tp_message_get_type (void); 45 46 void tp_message_destroy (TpMessage *self); 47 guint tp_message_count_parts (TpMessage *self); 48 const GHashTable *tp_message_peek (TpMessage *self, guint part); 49 _TP_AVAILABLE_IN_0_20 50 GVariant *tp_message_dup_part (TpMessage *self, guint part); 51 guint tp_message_append_part (TpMessage *self); 52 void tp_message_delete_part (TpMessage *self, guint part); 53 54 gboolean tp_message_delete_key (TpMessage *self, guint part, const gchar *key); 55 void tp_message_set_boolean (TpMessage *self, guint part, const gchar *key, 56 gboolean b); 57 void tp_message_set_int32 (TpMessage *self, guint part, const gchar *key, 58 gint32 i); 59 #define tp_message_set_int16(s, p, k, i) \ 60 tp_message_set_int32 (s, p, k, (gint16) i) 61 void tp_message_set_int64 (TpMessage *self, guint part, const gchar *key, 62 gint64 i); 63 void tp_message_set_uint32 (TpMessage *self, guint part, const gchar *key, 64 guint32 u); 65 #define tp_message_set_uint16(s, p, k, u) \ 66 tp_message_set_uint32 (s, p, k, (guint16) u) 67 void tp_message_set_uint64 (TpMessage *self, guint part, const gchar *key, 68 guint64 u); 69 void tp_message_set_string (TpMessage *self, guint part, const gchar *key, 70 const gchar *s); 71 void tp_message_set_string_printf (TpMessage *self, guint part, 72 const gchar *key, const gchar *fmt, ...) G_GNUC_PRINTF (4, 5); 73 void tp_message_set_bytes (TpMessage *self, guint part, const gchar *key, 74 guint len, gconstpointer bytes); 75 void tp_message_set (TpMessage *self, guint part, const gchar *key, 76 const GValue *source); 77 _TP_AVAILABLE_IN_0_20 78 void tp_message_set_variant (TpMessage *self, guint part, const gchar *key, 79 GVariant *value); 80 81 gchar * tp_message_to_text (TpMessage *message, 82 TpChannelTextMessageFlags *out_flags) G_GNUC_WARN_UNUSED_RESULT; 83 84 #ifndef TP_DISABLE_DEPRECATED 85 /* Takes a TpCMMessage */ 86 _TP_DEPRECATED_FOR (tp_cm_message_set_sender) 87 void tp_message_set_handle (TpMessage *self, guint part, const gchar *key, 88 TpHandleType handle_type, TpHandle handle_or_0); 89 90 _TP_DEPRECATED_FOR (tp_cm_message_take_message) 91 void tp_message_take_message (TpMessage *self, guint part, const gchar *key, 92 TpMessage *message); 93 94 _TP_DEPRECATED_FOR (tp_cm_message_set_sender) 95 void tp_message_ref_handle (TpMessage *self, TpHandleType handle_type, 96 TpHandle handle); 97 #endif 98 99 gboolean tp_message_is_mutable (TpMessage *self); 100 101 TpChannelTextMessageType tp_message_get_message_type (TpMessage *self); 102 const gchar *tp_message_get_token (TpMessage *self); 103 gint64 tp_message_get_sent_timestamp (TpMessage *self); 104 gint64 tp_message_get_received_timestamp (TpMessage *self); 105 gboolean tp_message_is_scrollback (TpMessage *self); 106 gboolean tp_message_is_rescued (TpMessage *self); 107 const gchar *tp_message_get_supersedes (TpMessage *self); 108 const gchar *tp_message_get_specific_to_interface (TpMessage *self); 109 gboolean tp_message_is_delivery_report (TpMessage *self); 110 _TP_AVAILABLE_IN_0_16 111 guint32 tp_message_get_pending_message_id (TpMessage *self, 112 gboolean *valid); 113 114 G_END_DECLS 115 116 #endif /* __TP_MESSAGE_H__ */ 117