filetransfer: split ft negotiation over SIP and TFTP transport itself
[siplcs.git] / src / core / sipe-ft.h
blob33aa7f9f9e2c675e98e0de5a7e70c771d538d7c0
1 /**
2 * @file sipe-ft.h
4 * pidgin-sipe
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
30 /**
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 guchar encryption_key[SIPE_FT_KEY_LENGTH];
39 guchar hash_key[SIPE_FT_KEY_LENGTH];
40 unsigned auth_cookie;
41 gchar *invitation_cookie;
43 struct sip_dialog *dialog;
45 gpointer cipher_context;
46 gpointer hmac_context;
48 gsize bytes_remaining_chunk;
50 guchar *encrypted_outbuf;
51 guchar *outbuf_ptr;
52 gsize outbuf_size;
54 struct sipe_backend_listendata *listendata;
56 #define SIPE_FILE_TRANSFER_PUBLIC ((struct sipe_file_transfer *) ft_private)
57 #define SIPE_FILE_TRANSFER_PRIVATE ((struct sipe_file_transfer_private *) ft)
59 /**
60 * Deallocate file transfer data structure
62 void sipe_core_ft_deallocate(struct sipe_file_transfer *ft);
64 /**
65 * Called when remote peer wants to send a file.
67 * Function initializes libpurple filetransfer API structure and calls
68 * purple_xfer_request().
70 * @param sipe_private Sipe core private data
71 * @param dialog SIP dialog used for the file transfer
72 * @param body parsed SIP message body as name-value pairs
74 void sipe_ft_incoming_transfer(struct sipe_core_private *sipe_private,
75 struct sip_dialog *dialog,
76 const GSList *body);
78 /**
79 * Handles incoming filetransfer message with ACCEPT invitation command.
81 * This message is sent during the negotiation phase when parameters of the
82 * transfer like IP address or TCP port are going to be set up.
84 * @param dialog SIP dialog used for the file transfer
85 * @param body parsed SIP message body as name-value pairs
87 void sipe_ft_incoming_accept(struct sip_dialog *dialog, const GSList *body);
89 /**
90 * Called when remote peer cancels ongoing file transfer.
92 * Function dispatches the request to libpurple
94 * @param dialog SIP dialog used for the file transfer
95 * @param body parsed SIP message body as name-value pairs
97 void sipe_ft_incoming_cancel(struct sip_dialog *dialog, const GSList *body);
99 /**
100 * Parses file transfer message body and creates a list with name-value pairs
102 * @param body file transfer SIP message body
104 * @return GSList of name-value pairs parsed from message body, NULL if body has
105 * incorrect format
107 GSList *sipe_ft_parse_msg_body(const gchar *body);
109 void sipe_ft_raise_error_and_cancel(struct sipe_file_transfer_private *ft_private,
110 const gchar *errmsg);