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