blob: 9cd5e97f339bbca208a3689b83a073e76c753f3a [file] [log] [blame]
Benny Prijonob0808372006-03-02 21:18:58 +00001/* $Id$ */
2/*
Nanang Izzuddina62ffc92011-05-05 06:14:19 +00003 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijonob0808372006-03-02 21:18:58 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJSIP_SIMPLE_ISCOMPOSING_H__
21#define __PJSIP_SIMPLE_ISCOMPOSING_H__
22
23/**
24 * @file iscomposing.h
25 * @brief Support for Indication of Message Composition (RFC 3994)
26 */
27#include <pjsip-simple/types.h>
28#include <pjlib-util/xml.h>
29
Benny Prijono312aff92006-06-17 04:08:30 +000030/**
31 * @defgroup PJSIP_ISCOMPOSING Message Composition Indication (RFC 3994)
32 * @ingroup PJSIP_SIMPLE
33 * @brief Support for Indication of Message Composition (RFC 3994)
34 * @{
35 *
36 * This implements message composition indication, as described in
37 * RFC 3994.
38 */
Benny Prijonob0808372006-03-02 21:18:58 +000039
40PJ_BEGIN_DECL
41
42
43/**
44 * Create XML message with MIME type "application/im-iscomposing+xml"
45 * to indicate the message composition status.
46 *
47 * @param pool Pool to allocate memory.
48 * @param is_composing Message composition indication status. Set to
49 * PJ_TRUE (or non-zero) to indicate that application
50 * is currently composing an instant message.
51 * @param lst_actv Optional attribute to indicate time of last
52 * activity. If none is to be specified, the value
53 * MUST be set to NULL.
54 * @param content_tp Optional attribute to indicate the content type of
55 * message being composed. If none is to be specified,
56 * the value MUST be set to NULL.
57 * @param refresh Optional attribute to indicate the interval when
58 * next indication will be sent, only when
59 * is_composing is non-zero. If none is to be
60 * specified, the value MUST be set to -1.
61 *
62 * @return An XML message containing the message indication.
63 * NULL will be returned when there's not enough
64 * memory to allocate the message.
65 */
66PJ_DECL(pj_xml_node*) pjsip_iscomposing_create_xml(pj_pool_t *pool,
67 pj_bool_t is_composing,
68 const pj_time_val *lst_actv,
69 const pj_str_t *content_tp,
70 int refresh);
71
72
73/**
74 * Create message body with Content-Type "application/im-iscomposing+xml"
75 * to indicate the message composition status.
76 *
77 * @param pool Pool to allocate memory.
78 * @param is_composing Message composition indication status. Set to
79 * PJ_TRUE (or non-zero) to indicate that application
80 * is currently composing an instant message.
81 * @param lst_actv Optional attribute to indicate time of last
82 * activity. If none is to be specified, the value
83 * MUST be set to NULL.
84 * @param content_tp Optional attribute to indicate the content type of
85 * message being composed. If none is to be specified,
86 * the value MUST be set to NULL.
87 * @param refresh Optional attribute to indicate the interval when
88 * next indication will be sent, only when
89 * is_composing is non-zero. If none is to be
90 * specified, the value MUST be set to -1.
91 *
92 * @return The SIP message body containing XML message
93 * indication. NULL will be returned when there's not
94 * enough memory to allocate the message.
95 */
96PJ_DECL(pjsip_msg_body*) pjsip_iscomposing_create_body( pj_pool_t *pool,
97 pj_bool_t is_composing,
98 const pj_time_val *lst_actv,
99 const pj_str_t *content_tp,
100 int refresh);
101
102
103/**
104 * Parse the buffer and return message composition indication in the
105 * message.
106 *
107 * @param pool Pool to allocate memory for the parsing process.
108 * @param msg The message to be parsed.
109 * @param len Length of the message.
110 * @param p_is_composing Optional pointer to receive iscomposing status.
111 * @param p_last_active Optional pointer to receive last active attribute.
112 * @param p_content_type Optional pointer to receive content type attribute.
113 * @param p_refresh Optional pointer to receive refresh time.
114 *
115 * @return PJ_SUCCESS if message can be successfully parsed.
116 */
117PJ_DECL(pj_status_t) pjsip_iscomposing_parse( pj_pool_t *pool,
118 char *msg,
119 pj_size_t len,
120 pj_bool_t *p_is_composing,
121 pj_str_t **p_last_active,
122 pj_str_t **p_content_type,
123 int *p_refresh );
124
125
Benny Prijono312aff92006-06-17 04:08:30 +0000126/**
127 * @}
128 */
129
Benny Prijonob0808372006-03-02 21:18:58 +0000130
131PJ_END_DECL
132
133
134#endif /* __PJSIP_SIMPLE_ISCOMPOSING_H__ */
135