1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * Copyright (C) 2003 Imendio AB 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public License as 7 * published by the Free Software Foundation; either version 2 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this program; if not, see <https://www.gnu.org/licenses> 17 */ 18 19 #ifndef __LM_MESSAGE_H__ 20 #define __LM_MESSAGE_H__ 21 22 #if !defined (LM_INSIDE_LOUDMOUTH_H) && !defined (LM_COMPILATION) 23 #error "Only <loudmouth/loudmouth.h> can be included directly, this file may disappear or change contents." 24 #endif 25 26 #include <loudmouth/lm-message-node.h> 27 28 G_BEGIN_DECLS 29 30 typedef struct LmMessagePriv LmMessagePriv; 31 32 typedef struct { 33 LmMessageNode *node; 34 35 LmMessagePriv *priv; 36 } LmMessage; 37 38 /** 39 * LmMessageType: 40 * @LM_MESSAGE_TYPE_MESSAGE: a message, <message/> 41 * @LM_MESSAGE_TYPE_PRESENCE: a presence element, <presence/> 42 * @LM_MESSAGE_TYPE_IQ: an info/query element, <iq/> 43 * @LM_MESSAGE_TYPE_STREAM: the stream:stream element, you probably don't need to create a message of this type. 44 * @LM_MESSAGE_TYPE_STREAM_ERROR: a stream:error element 45 * @LM_MESSAGE_TYPE_STREAM_FEATURES: 46 * @LM_MESSAGE_TYPE_AUTH: 47 * @LM_MESSAGE_TYPE_CHALLENGE: 48 * @LM_MESSAGE_TYPE_RESPONSE: 49 * @LM_MESSAGE_TYPE_SUCCESS: 50 * @LM_MESSAGE_TYPE_FAILURE: 51 * @LM_MESSAGE_TYPE_PROCEED: 52 * @LM_MESSAGE_TYPE_STARTTLS: 53 * @LM_MESSAGE_TYPE_UNKNOWN: incoming message is of some unknown type. 54 * 55 * Describes what type of message a message is. This maps directly to top level elements in the jabber protocol. 56 */ 57 typedef enum { 58 LM_MESSAGE_TYPE_MESSAGE, 59 LM_MESSAGE_TYPE_PRESENCE, 60 LM_MESSAGE_TYPE_IQ, 61 LM_MESSAGE_TYPE_STREAM, 62 LM_MESSAGE_TYPE_STREAM_ERROR, 63 LM_MESSAGE_TYPE_STREAM_FEATURES, 64 LM_MESSAGE_TYPE_AUTH, 65 LM_MESSAGE_TYPE_CHALLENGE, 66 LM_MESSAGE_TYPE_RESPONSE, 67 LM_MESSAGE_TYPE_SUCCESS, 68 LM_MESSAGE_TYPE_FAILURE, 69 LM_MESSAGE_TYPE_PROCEED, 70 LM_MESSAGE_TYPE_STARTTLS, 71 LM_MESSAGE_TYPE_UNKNOWN 72 } LmMessageType; 73 74 /** 75 * LmMessageSubType: 76 * @LM_MESSAGE_SUB_TYPE_NOT_SET: the default. No "type" attribute will be sent. 77 * @LM_MESSAGE_SUB_TYPE_AVAILABLE: presence is available, applies to message type "presence" 78 * @LM_MESSAGE_SUB_TYPE_NORMAL: 79 * @LM_MESSAGE_SUB_TYPE_CHAT: message is a chat message, applies to message type "message" 80 * @LM_MESSAGE_SUB_TYPE_GROUPCHAT: message is a group chat message, applies to message type "message" 81 * @LM_MESSAGE_SUB_TYPE_HEADLINE: message is a headline message, applies to message type "message" 82 * @LM_MESSAGE_SUB_TYPE_UNAVAILABLE: presence is unavailable, applies to message type "presence" 83 * @LM_MESSAGE_SUB_TYPE_PROBE: a probe presence, applies to message type "presence" 84 * @LM_MESSAGE_SUB_TYPE_SUBSCRIBE: try to subscribe to another jids presence, applies to message type "presence" 85 * @LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE: unsubscribes from another jids presence, applies to message type "presence" 86 * @LM_MESSAGE_SUB_TYPE_SUBSCRIBED: reply from a subscribe message, informs that the subscription was successful. Applies to message type "presence" 87 * @LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED: reply from subscribe or unsubscribe message. If it's a reply from a subscribe message it notifies that the subscription failed. Applies to message type "presence" 88 * @LM_MESSAGE_SUB_TYPE_GET: used to get information from an IQ query, applies to message type "iq" 89 * @LM_MESSAGE_SUB_TYPE_SET: used to set information in a IQ call, applised to message type "iq" 90 * @LM_MESSAGE_SUB_TYPE_RESULT: message is an IQ reply, applies to message type "iq" 91 * @LM_MESSAGE_SUB_TYPE_ERROR: messages is an error, applies to all message types. 92 * 93 * Describes the sub type of a message. This is equal to the "type" attribute in the jabber protocol. What sub type a message can have is depending on the type of the message. 94 */ 95 typedef enum { 96 LM_MESSAGE_SUB_TYPE_NOT_SET = -10, 97 LM_MESSAGE_SUB_TYPE_AVAILABLE = -1, 98 LM_MESSAGE_SUB_TYPE_NORMAL = 0, 99 LM_MESSAGE_SUB_TYPE_CHAT, 100 LM_MESSAGE_SUB_TYPE_GROUPCHAT, 101 LM_MESSAGE_SUB_TYPE_HEADLINE, 102 LM_MESSAGE_SUB_TYPE_UNAVAILABLE, 103 LM_MESSAGE_SUB_TYPE_PROBE, 104 LM_MESSAGE_SUB_TYPE_SUBSCRIBE, 105 LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE, 106 LM_MESSAGE_SUB_TYPE_SUBSCRIBED, 107 LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED, 108 LM_MESSAGE_SUB_TYPE_GET, 109 LM_MESSAGE_SUB_TYPE_SET, 110 LM_MESSAGE_SUB_TYPE_RESULT, 111 LM_MESSAGE_SUB_TYPE_ERROR 112 } LmMessageSubType; 113 114 LmMessage * lm_message_new (const gchar *to, 115 LmMessageType type); 116 LmMessage * lm_message_new_with_sub_type (const gchar *to, 117 LmMessageType type, 118 LmMessageSubType sub_type); 119 LmMessageType lm_message_get_type (LmMessage *message); 120 LmMessageSubType lm_message_get_sub_type (LmMessage *message); 121 LmMessageNode * lm_message_get_node (LmMessage *message); 122 LmMessage * lm_message_ref (LmMessage *message); 123 void lm_message_unref (LmMessage *message); 124 125 G_END_DECLS 126 127 #endif /* __LM_MESSAGE_H__ */ 128