2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Network/multi_xfer.h $
16 * Revision 1.3 2002/06/09 04:41:14 relnev
17 * added copyright header
19 * Revision 1.2 2002/05/26 20:22:48 theoddone33
20 * Most of network/ works
22 * Revision 1.1.1.1 2002/05/03 03:28:12 root
26 * 5 12/14/98 4:01p Dave
27 * Got multi_data stuff working well with new xfer stuff.
29 * 4 12/14/98 12:13p Dave
30 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
33 * 3 11/05/98 5:55p Dave
34 * Big pass at reducing #includes
36 * 2 10/07/98 10:53a Dave
39 * 1 10/07/98 10:50a Dave
41 * 21 5/21/98 3:45a Sandeep
42 * Make sure file xfer sender side uses correct directory type.
44 * 20 4/23/98 6:18p Dave
45 * Store ETS values between respawns. Put kick feature in the text
46 * messaging system. Fixed text messaging system so that it doesn't
47 * process or trigger ship controls. Other UI fixes.
49 * 19 4/01/98 11:19p Dave
50 * Put in auto-loading of xferred pilot pic files. Grey out background
51 * behind pinfo popup. Put a chatbox message in when players are kicked.
52 * Moved mission title down in briefing. Other ui fixes.
54 * 18 3/23/98 5:42p Dave
55 * Put in automatic xfer of pilot pic files. Changed multi_xfer system so
56 * that it can support multiplayer sends/received between client and
57 * server simultaneously.
59 * 17 3/21/98 7:14p Dave
60 * Fixed up standalone player slot switching. Made training missions not
61 * count towards player stats.
63 * 16 2/22/98 2:53p Dave
64 * Put in groundwork for advanced multiplayer campaign options.
66 * 15 2/20/98 4:43p Dave
67 * Finished support for multiplayer player data files. Split off
68 * multiplayer campaign functionality.
70 * 14 2/19/98 6:26p Dave
71 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
72 * initial support for player data uploading.
74 * 13 2/18/98 10:21p Dave
75 * Ripped out old file xfer system. Put in brand new xfer system.
80 #ifndef _FREESPACE_FILE_TRANSFER_HEADER
81 #define _FREESPACE_FILE_TRANSFER_HEADER
85 // ------------------------------------------------------------------------------------------
86 // MULTI XFER DEFINES/VARS
89 typedef uint PSNET_SOCKET_RELIABLE;
91 // status codes for transfers
92 #define MULTI_XFER_NONE -1 // nothing is happening - this is an invalid handle
93 #define MULTI_XFER_SUCCESS 0 // the xfer has successfully transferred
94 #define MULTI_XFER_FAIL 1 // the xfer has failed for one reason or another
95 #define MULTI_XFER_UNKNOWN 2 // the xfer has finished but its unknown if it was successful - wait a while longer
96 #define MULTI_XFER_TIMEDOUT 3 // the xfer has timed-out during some stage of the process
97 #define MULTI_XFER_IN_PROGRESS 4 // the xfer is in progress
98 #define MULTI_XFER_QUEUED 5 // queued up - hasn't started yet
100 #define MULTI_XFER_FLAG_AUTODESTROY (1<<15) // automatically clear and free an xfer handle that is done
101 #define MULTI_XFER_FLAG_REJECT (1<<16) // set by the receive callback function if we want to disallow xfer of this file
102 // if this flag is set, the system will only xfer one file at a time to a given destination.
103 // so, suppose you start sending 3 files to one target, all which have this flag set. Only the first file will send.
104 // Once it is complete, the second one will go. Then the third. This is extremely useful for files where you don't
105 // _really_ care if it arrives or not (eg - sending multiple pilot pics or sounds or squad logos, etc). If you _do_
106 // care about the file (eg - mission files), you probably shouldn't be using this flag
107 #define MULTI_XFER_FLAG_QUEUE (1<<17)
109 // the xfer system is guaranteed never to spew data larger than this
110 #define MULTI_XFER_MAX_SIZE 500
112 // ------------------------------------------------------------------------------------------
113 // MULTI XFER FUNCTIONS
116 // initialize all file xfer transaction stuff, call in multi_level_init()
117 void multi_xfer_init(void (*multi_xfer_recv_callback)(int handle));
119 // do frame for all file xfers, call in multi_do_frame()
120 void multi_xfer_do();
122 // close down the file xfer system
123 void multi_xfer_close();
125 // reset the xfer system, including shutting down/killing all active xfers
126 void multi_xfer_reset();
128 // send a file to the specified player, return a handle
129 int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags = 0);
131 // get the status of the current file xfer
132 int multi_xfer_get_status(int handle);
134 // abort a transferring file
135 void multi_xfer_abort(int handle);
137 // release an xfer handle
138 void multi_xfer_release_handle(int handle);
140 // get the filename of the xfer for the given handle
141 char *multi_xfer_get_filename(int handle);
143 // lock the xfer system (don't accept incoming files, don't allow outgoing files)
144 void multi_xfer_lock();
146 // unlock the xfer system
147 void multi_xfer_unlock();
149 // force all receives to go into the specified directory by cfile type
150 void multi_xfer_force_dir(int cf_type);
152 // forces the given xfer entry to the specified directory type (only valid when called from the recv_callback function)
153 void multi_xfer_handle_force_dir(int handle,int cf_type);
155 // xor the flag on a given entry
156 void multi_xfer_xor_flags(int handle,int flags);
158 // get the flags for a given entry
159 int multi_xfer_get_flags(int handle);
161 // if the passed filename is being xferred, return the xfer handle, otherwise return -1
162 int multi_xfer_lookup(char *filename);
164 // get the % of completion of the passed file handle, return < 0 if invalid
165 float multi_xfer_pct_complete(int handle);
167 // get the socket of the file xfer (useful for identifying players)
168 uint multi_xfer_get_sock(int handle);
170 // get the CF_TYPE of the directory this file is going to
171 int multi_xfer_get_force_dir(int handle);
173 // ------------------------------------------------------------------------------------------
174 // MULTI XFER PACKET HANDLERS
177 // process an incoming file xfer data packet, return bytes processed, guaranteed to process the entire
178 // packet regardless of error conditions
179 int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who);