Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | a771a51 | 2007-02-19 01:13:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 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 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 29 | /** |
| 30 | * @defgroup PJSIP_ISCOMPOSING Message Composition Indication (RFC 3994) |
| 31 | * @ingroup PJSIP_SIMPLE |
| 32 | * @brief Support for Indication of Message Composition (RFC 3994) |
| 33 | * @{ |
| 34 | * |
| 35 | * This implements message composition indication, as described in |
| 36 | * RFC 3994. |
| 37 | */ |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 38 | |
| 39 | PJ_BEGIN_DECL |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Create XML message with MIME type "application/im-iscomposing+xml" |
| 44 | * to indicate the message composition status. |
| 45 | * |
| 46 | * @param pool Pool to allocate memory. |
| 47 | * @param is_composing Message composition indication status. Set to |
| 48 | * PJ_TRUE (or non-zero) to indicate that application |
| 49 | * is currently composing an instant message. |
| 50 | * @param lst_actv Optional attribute to indicate time of last |
| 51 | * activity. If none is to be specified, the value |
| 52 | * MUST be set to NULL. |
| 53 | * @param content_tp Optional attribute to indicate the content type of |
| 54 | * message being composed. If none is to be specified, |
| 55 | * the value MUST be set to NULL. |
| 56 | * @param refresh Optional attribute to indicate the interval when |
| 57 | * next indication will be sent, only when |
| 58 | * is_composing is non-zero. If none is to be |
| 59 | * specified, the value MUST be set to -1. |
| 60 | * |
| 61 | * @return An XML message containing the message indication. |
| 62 | * NULL will be returned when there's not enough |
| 63 | * memory to allocate the message. |
| 64 | */ |
| 65 | PJ_DECL(pj_xml_node*) pjsip_iscomposing_create_xml(pj_pool_t *pool, |
| 66 | pj_bool_t is_composing, |
| 67 | const pj_time_val *lst_actv, |
| 68 | const pj_str_t *content_tp, |
| 69 | int refresh); |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * Create message body with Content-Type "application/im-iscomposing+xml" |
| 74 | * to indicate the message composition status. |
| 75 | * |
| 76 | * @param pool Pool to allocate memory. |
| 77 | * @param is_composing Message composition indication status. Set to |
| 78 | * PJ_TRUE (or non-zero) to indicate that application |
| 79 | * is currently composing an instant message. |
| 80 | * @param lst_actv Optional attribute to indicate time of last |
| 81 | * activity. If none is to be specified, the value |
| 82 | * MUST be set to NULL. |
| 83 | * @param content_tp Optional attribute to indicate the content type of |
| 84 | * message being composed. If none is to be specified, |
| 85 | * the value MUST be set to NULL. |
| 86 | * @param refresh Optional attribute to indicate the interval when |
| 87 | * next indication will be sent, only when |
| 88 | * is_composing is non-zero. If none is to be |
| 89 | * specified, the value MUST be set to -1. |
| 90 | * |
| 91 | * @return The SIP message body containing XML message |
| 92 | * indication. NULL will be returned when there's not |
| 93 | * enough memory to allocate the message. |
| 94 | */ |
| 95 | PJ_DECL(pjsip_msg_body*) pjsip_iscomposing_create_body( pj_pool_t *pool, |
| 96 | pj_bool_t is_composing, |
| 97 | const pj_time_val *lst_actv, |
| 98 | const pj_str_t *content_tp, |
| 99 | int refresh); |
| 100 | |
| 101 | |
| 102 | /** |
| 103 | * Parse the buffer and return message composition indication in the |
| 104 | * message. |
| 105 | * |
| 106 | * @param pool Pool to allocate memory for the parsing process. |
| 107 | * @param msg The message to be parsed. |
| 108 | * @param len Length of the message. |
| 109 | * @param p_is_composing Optional pointer to receive iscomposing status. |
| 110 | * @param p_last_active Optional pointer to receive last active attribute. |
| 111 | * @param p_content_type Optional pointer to receive content type attribute. |
| 112 | * @param p_refresh Optional pointer to receive refresh time. |
| 113 | * |
| 114 | * @return PJ_SUCCESS if message can be successfully parsed. |
| 115 | */ |
| 116 | PJ_DECL(pj_status_t) pjsip_iscomposing_parse( pj_pool_t *pool, |
| 117 | char *msg, |
| 118 | pj_size_t len, |
| 119 | pj_bool_t *p_is_composing, |
| 120 | pj_str_t **p_last_active, |
| 121 | pj_str_t **p_content_type, |
| 122 | int *p_refresh ); |
| 123 | |
| 124 | |
Benny Prijono | 312aff9 | 2006-06-17 04:08:30 +0000 | [diff] [blame] | 125 | /** |
| 126 | * @} |
| 127 | */ |
| 128 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 129 | |
| 130 | PJ_END_DECL |
| 131 | |
| 132 | |
| 133 | #endif /* __PJSIP_SIMPLE_ISCOMPOSING_H__ */ |
| 134 | |