6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2010 Jakub Adam <jakub.adam@ktknet.cz>
8 * Copyright (C) 2010 Tomáš Hrabčík <tomas.hrabcik@tieto.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 /* Forward declarations */
26 struct sipe_core_private
;
28 #define SIPE_FT_KEY_LENGTH 24
31 * File transport (private part)
33 struct sipe_file_transfer_private
{
34 struct sipe_file_transfer
public;
36 struct sipe_core_private
*sipe_private
;
38 gboolean peer_using_nat
;
41 guchar encryption_key
[SIPE_FT_KEY_LENGTH
];
42 guchar hash_key
[SIPE_FT_KEY_LENGTH
];
44 gchar
*invitation_cookie
;
46 struct sip_dialog
*dialog
;
48 gpointer cipher_context
;
49 gpointer hmac_context
;
51 gsize bytes_remaining_chunk
;
53 guchar
*encrypted_outbuf
;
57 struct sipe_backend_listendata
*listendata
;
59 #define SIPE_FILE_TRANSFER_PUBLIC ((struct sipe_file_transfer *) ft_private)
60 #define SIPE_FILE_TRANSFER_PRIVATE ((struct sipe_file_transfer_private *) ft)
63 * Called when remote peer wants to send a file.
65 * Function initializes libpurple filetransfer API structure and calls
66 * purple_xfer_request().
68 * @param sipe_private Sipe core private data
69 * @param dialog SIP dialog used for the file transfer
70 * @param body parsed SIP message body as name-value pairs
72 void sipe_ft_incoming_transfer(struct sipe_core_private
*sipe_private
,
73 struct sip_dialog
*dialog
,
77 * Handles incoming filetransfer message with ACCEPT invitation command.
79 * This message is sent during the negotiation phase when parameters of the
80 * transfer like IP address or TCP port are going to be set up.
82 * @param dialog SIP dialog used for the file transfer
83 * @param body parsed SIP message body as name-value pairs
85 void sipe_ft_incoming_accept(struct sip_dialog
*dialog
, const GSList
*body
);
88 * Called when remote peer cancels ongoing file transfer.
90 * Function dispatches the request to libpurple
92 * @param dialog SIP dialog used for the file transfer
93 * @param body parsed SIP message body as name-value pairs
95 void sipe_ft_incoming_cancel(struct sip_dialog
*dialog
, const GSList
*body
);
98 * Parses file transfer message body and creates a list with name-value pairs
100 * @param body file transfer SIP message body
102 * @return GSList of name-value pairs parsed from message body, NULL if body has
105 GSList
*sipe_ft_parse_msg_body(const gchar
*body
);
107 void sipe_ft_raise_error_and_cancel(struct sipe_file_transfer_private
*ft_private
,
108 const gchar
*errmsg
);