Updated to release 1.7.1
[siplcs.git] / src / sipmsg.h
blob9769562a1e5eb0cc531947b5985b920960e18aaf
1 /**
2 * @file sipmsg.h
4 * gaim
6 * Copyright (C) 2008 Novell, Inc.
7 * Copyright (C) 2005, Thomas Butter <butter@uni-mannheim.de>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef _PURPLE_SIPMSG_H
25 #define _PURPLE_SIPMSG_H
27 #include <glib.h>
29 struct sipmsg {
30 int response; /* 0 means request, otherwise response code */
31 gchar *method;
32 gchar *target;
33 GSList *headers;
34 GSList *new_headers;
35 int bodylen;
36 gchar *body;
37 gchar *signature;
38 gchar *rand;
39 gchar *num;
42 struct siphdrelement {
43 gchar *name;
44 gchar *value;
47 struct sipendpoint {
48 gchar *contact;
49 gchar *epid;
53 struct sipmsg *sipmsg_parse_msg(const gchar *msg);
54 struct sipmsg *sipmsg_parse_header(const gchar *header);
55 void sipmsg_print(const struct sipmsg *msg);
56 void sipmsg_add_header_now(struct sipmsg *msg, const gchar *name, const gchar *value);
57 void sipmsg_add_header(struct sipmsg *msg, const gchar *name, const gchar *value);
58 void sipmsg_add_header_now_pos(struct sipmsg *msg, const gchar *name, const gchar *value, int pos);
59 void sipmsg_strip_headers(struct sipmsg *msg, const gchar *keepers[]);
60 void sipmsg_merge_new_headers(struct sipmsg *msg);
61 void sipmsg_free(struct sipmsg *msg);
62 GSList *sipmsg_parse_endpoints_header(const gchar *header);
63 gchar *sipmsg_find_header(const struct sipmsg *msg, const gchar *name);
64 gchar *sipmsg_find_header_instance(const struct sipmsg *msg, const gchar *name, int which);
65 gchar *sipmsg_find_part_of_header(const char *hdr, const char * before, const char * after, const char * def);
66 gchar *sipmsg_find_auth_header(struct sipmsg *msg, const gchar *name);
67 void sipmsg_remove_header_now(struct sipmsg *msg, const gchar *name);
68 char *sipmsg_to_string(const struct sipmsg *msg);
70 /**
71 * Formats message to html if not yet.
72 * Either - keep as is if text/html, or escape text, or escape text and apply format string if any
74 * @param body in case of 'ms_text_format is Content-Type header' or NULL otherwise
75 * @param ms_text_format either ms-text-format ot Content-Type header.
77 * Allocates memory. Must be feed when done.
79 gchar *get_html_message(const gchar *ms_text_format, const gchar *body);
81 /**
82 * Parses headers-like 'msgr' attribute of INVITE's 'ms_text_format' header.
83 * Then retrieves value of 'X-MMS-IM-Format'.
85 * 'msgr' typically looks like:
86 * X-MMS-IM-Format: FN=Microsoft%20Sans%20Serif; EF=BI; CO=800000; CS=0; PF=22
88 gchar *sipmsg_get_x_mms_im_format(gchar *msgr);
90 /**
91 * Returns UTF-16LE/'modified base64' encoded X-MMS-IM-Format
92 * based on input x_mms_im_format.
94 gchar *sipmsg_get_msgr_string(gchar *x_mms_im_format);
96 /**
97 * Translates X-MMS-IM format to HTML presentation.
99 gchar *sipmsg_apply_x_mms_im_format(const char *x_mms_im_format, gchar *body);
101 #define sipe_parse_html msn_import_html
103 * Parses the Purple message formatting (html) into the MSN format.
105 * @param html The html message to format.
106 * @param attributes The returned attributes string.
107 * @param message The returned message string.
109 * @return The new message.
111 void sipe_parse_html(const char *html, char **attributes, char **message);
113 void msn_parse_format(const char *mime, char **pre_ret, char **post_ret);
114 void msn_import_html(const char *html, char **attributes, char **message);
115 #endif /* _PURPLE_SIPMSG_H */