comparison libpurple/protocols/msn/msg.h @ 31292:47b6eda87723

propagate from branch 'im.pidgin.pidgin' (head 07d0765c444a097af45c2650f54323afb900a07b) to branch 'im.pidgin.soc.2010.msn-tlc' (head f3998422a4724ab424e4e2328f58fc0504856557)
author masca@cpw.pidgin.im
date Mon, 19 Jul 2010 21:11:32 +0000
parents 358abb453add
children b4285ea42b6e
comparison
equal deleted inserted replaced
30698:e874875a74a7 31292:47b6eda87723
56 56
57 #include "command.h" 57 #include "command.h"
58 #include "session.h" 58 #include "session.h"
59 #include "transaction.h" 59 #include "transaction.h"
60 #include "user.h" 60 #include "user.h"
61 #include "slpmsg.h"
62 #include "slpmsg_part.h"
61 63
62 typedef void (*MsnMsgCb)(MsnMessage *, void *data); 64 typedef void (*MsnMsgCb)(MsnMessage *, void *data);
63 65
64 #define MSG_BODY_DEM "\r\n\r\n" 66 #define MSG_BODY_DEM "\r\n\r\n"
65 #define MSG_LINE_DEM "\r\n" 67 #define MSG_LINE_DEM "\r\n"
66 68
67 #define MSG_OIM_BODY_DEM "\n\n" 69 #define MSG_OIM_BODY_DEM "\n\n"
68 #define MSG_OIM_LINE_DEM "\n" 70 #define MSG_OIM_LINE_DEM "\n"
69
70 typedef struct
71 {
72 guint32 session_id;
73 guint32 id;
74 guint64 offset;
75 guint64 total_size;
76 guint32 length;
77 guint32 flags;
78 guint32 ack_id;
79 guint32 ack_sub_id;
80 guint64 ack_size;
81 } MsnSlpHeader;
82
83 typedef struct
84 {
85 guint32 value;
86 } MsnSlpFooter;
87 71
88 /** 72 /**
89 * A message. 73 * A message.
90 */ 74 */
91 struct _MsnMessage 75 struct _MsnMessage
93 size_t ref_count; /**< The reference count. */ 77 size_t ref_count; /**< The reference count. */
94 78
95 MsnMsgType type; 79 MsnMsgType type;
96 80
97 gboolean msnslp_message; 81 gboolean msnslp_message;
82 MsnSlpMessage *slpmsg;
83 MsnSlpMessagePart *part;
98 84
99 char *remote_user; 85 char *remote_user;
100 char flag; 86 char flag;
101 87
102 char *content_type; 88 char *content_type;
104 char *body; 90 char *body;
105 gsize body_len; 91 gsize body_len;
106 guint total_chunks; /**< How many chunks in this multi-part message */ 92 guint total_chunks; /**< How many chunks in this multi-part message */
107 guint received_chunks; /**< How many chunks we've received so far */ 93 guint received_chunks; /**< How many chunks we've received so far */
108 94
109 MsnSlpHeader msnslp_header; 95 GHashTable *header_table;
110 MsnSlpFooter msnslp_footer; 96 GList *header_list;
111
112 GHashTable *attr_table;
113 GList *attr_list;
114 97
115 gboolean ack_ref; /**< A flag that states if this message has 98 gboolean ack_ref; /**< A flag that states if this message has
116 been ref'ed for using it in a callback. */ 99 been ref'ed for using it in a callback. */
117 100
118 MsnCommand *cmd; 101 MsnCommand *cmd;
293 * @return The charset. 276 * @return The charset.
294 */ 277 */
295 const char *msn_message_get_charset(const MsnMessage *msg); 278 const char *msn_message_get_charset(const MsnMessage *msg);
296 279
297 /** 280 /**
298 * Sets an attribute in a message. 281 * Sets a header in a message.
299 * 282 *
300 * @param msg The message. 283 * @param msg The message.
301 * @param attr The attribute name. 284 * @param header The header name.
302 * @param value The attribute value. 285 * @param value The header value.
303 */ 286 */
304 void msn_message_set_attr(MsnMessage *msg, const char *attr, 287 void msn_message_set_header(MsnMessage *msg, const char *name,
305 const char *value); 288 const char *value);
306 289
307 /** 290 /**
308 * Returns an attribute from a message. 291 * Returns the value of a header from a message.
309 * 292 *
310 * @param msg The message. 293 * @param msg The message.
311 * @param attr The attribute. 294 * @param header The header value.
312 * 295 *
313 * @return The value, or @c NULL if not found. 296 * @return The value, or @c NULL if not found.
314 */ 297 */
315 const char *msn_message_get_attr(const MsnMessage *msg, const char *attr); 298 const char *msn_message_get_header_value(const MsnMessage *msg, const char *name);
316 299
317 /** 300 /**
318 * Parses the body and returns it in the form of a hashtable. 301 * Parses the body and returns it in the form of a hashtable.
319 * 302 *
320 * @param msg The message. 303 * @param msg The message.
324 GHashTable *msn_message_get_hashtable_from_body(const MsnMessage *msg); 307 GHashTable *msn_message_get_hashtable_from_body(const MsnMessage *msg);
325 308
326 void msn_message_show_readable(MsnMessage *msg, const char *info, 309 void msn_message_show_readable(MsnMessage *msg, const char *info,
327 gboolean text_body); 310 gboolean text_body);
328 311
329 void msn_message_parse_slp_body(MsnMessage *msg, const char *body,
330 size_t len);
331
332 char *msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size); 312 char *msn_message_gen_slp_body(MsnMessage *msg, size_t *ret_size);
333 313
334 char *msn_message_to_string(MsnMessage *msg); 314 char *msn_message_to_string(MsnMessage *msg);
335 315
336 void msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg); 316 void msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
337 317
338 void msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg); 318 void msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
339 319
320 /**
321 * Processes peer to peer messages.
322 *
323 * @param cmdproc The command processor.
324 * @param msg The message.
325 */
326 void msn_p2p_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
327
328 /**
329 * Processes emoticon messages.
330 *
331 * @param cmdproc The command processor.
332 * @param msg The message.
333 */
334 void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
335
340 void msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg); 336 void msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
341 337
338 /**
339 * Processes INVITE messages.
340 *
341 * @param cmdproc The command processor.
342 * @param msg The message.
343 */
344 void msn_invite_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
345
342 void msn_handwritten_msg(MsnCmdProc *cmdproc, MsnMessage *msg); 346 void msn_handwritten_msg(MsnCmdProc *cmdproc, MsnMessage *msg);
343 347
344 #endif /* MSN_MSG_H */ 348 #endif /* MSN_MSG_H */