2 * $Logfile: /Freespace2/code/Network/multi_xfer.h $
8 * Revision 1.1 2002/05/03 03:28:12 root
12 * 5 12/14/98 4:01p Dave
13 * Got multi_data stuff working well with new xfer stuff.
15 * 4 12/14/98 12:13p Dave
16 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
19 * 3 11/05/98 5:55p Dave
20 * Big pass at reducing #includes
22 * 2 10/07/98 10:53a Dave
25 * 1 10/07/98 10:50a Dave
27 * 21 5/21/98 3:45a Sandeep
28 * Make sure file xfer sender side uses correct directory type.
30 * 20 4/23/98 6:18p Dave
31 * Store ETS values between respawns. Put kick feature in the text
32 * messaging system. Fixed text messaging system so that it doesn't
33 * process or trigger ship controls. Other UI fixes.
35 * 19 4/01/98 11:19p Dave
36 * Put in auto-loading of xferred pilot pic files. Grey out background
37 * behind pinfo popup. Put a chatbox message in when players are kicked.
38 * Moved mission title down in briefing. Other ui fixes.
40 * 18 3/23/98 5:42p Dave
41 * Put in automatic xfer of pilot pic files. Changed multi_xfer system so
42 * that it can support multiplayer sends/received between client and
43 * server simultaneously.
45 * 17 3/21/98 7:14p Dave
46 * Fixed up standalone player slot switching. Made training missions not
47 * count towards player stats.
49 * 16 2/22/98 2:53p Dave
50 * Put in groundwork for advanced multiplayer campaign options.
52 * 15 2/20/98 4:43p Dave
53 * Finished support for multiplayer player data files. Split off
54 * multiplayer campaign functionality.
56 * 14 2/19/98 6:26p Dave
57 * Fixed a few file xfer bugs. Tweaked mp team select screen. Put in
58 * initial support for player data uploading.
60 * 13 2/18/98 10:21p Dave
61 * Ripped out old file xfer system. Put in brand new xfer system.
66 #ifndef _FREESPACE_FILE_TRANSFER_HEADER
67 #define _FREESPACE_FILE_TRANSFER_HEADER
69 // ------------------------------------------------------------------------------------------
70 // MULTI XFER DEFINES/VARS
73 typedef uint PSNET_SOCKET_RELIABLE;
75 // status codes for transfers
76 #define MULTI_XFER_NONE -1 // nothing is happening - this is an invalid handle
77 #define MULTI_XFER_SUCCESS 0 // the xfer has successfully transferred
78 #define MULTI_XFER_FAIL 1 // the xfer has failed for one reason or another
79 #define MULTI_XFER_UNKNOWN 2 // the xfer has finished but its unknown if it was successful - wait a while longer
80 #define MULTI_XFER_TIMEDOUT 3 // the xfer has timed-out during some stage of the process
81 #define MULTI_XFER_IN_PROGRESS 4 // the xfer is in progress
82 #define MULTI_XFER_QUEUED 5 // queued up - hasn't started yet
84 #define MULTI_XFER_FLAG_AUTODESTROY (1<<15) // automatically clear and free an xfer handle that is done
85 #define MULTI_XFER_FLAG_REJECT (1<<16) // set by the receive callback function if we want to disallow xfer of this file
86 // if this flag is set, the system will only xfer one file at a time to a given destination.
87 // so, suppose you start sending 3 files to one target, all which have this flag set. Only the first file will send.
88 // Once it is complete, the second one will go. Then the third. This is extremely useful for files where you don't
89 // _really_ care if it arrives or not (eg - sending multiple pilot pics or sounds or squad logos, etc). If you _do_
90 // care about the file (eg - mission files), you probably shouldn't be using this flag
91 #define MULTI_XFER_FLAG_QUEUE (1<<17)
93 // the xfer system is guaranteed never to spew data larger than this
94 #define MULTI_XFER_MAX_SIZE 500
96 // ------------------------------------------------------------------------------------------
97 // MULTI XFER FUNCTIONS
100 // initialize all file xfer transaction stuff, call in multi_level_init()
101 void multi_xfer_init(void (*multi_xfer_recv_callback)(int handle));
103 // do frame for all file xfers, call in multi_do_frame()
104 void multi_xfer_do();
106 // close down the file xfer system
107 void multi_xfer_close();
109 // reset the xfer system, including shutting down/killing all active xfers
110 void multi_xfer_reset();
112 // send a file to the specified player, return a handle
113 int multi_xfer_send_file(PSNET_SOCKET_RELIABLE who, char *filename, int cfile_flags, int flags = 0);
115 // get the status of the current file xfer
116 int multi_xfer_get_status(int handle);
118 // abort a transferring file
119 void multi_xfer_abort(int handle);
121 // release an xfer handle
122 void multi_xfer_release_handle(int handle);
124 // get the filename of the xfer for the given handle
125 char *multi_xfer_get_filename(int handle);
127 // lock the xfer system (don't accept incoming files, don't allow outgoing files)
128 void multi_xfer_lock();
130 // unlock the xfer system
131 void multi_xfer_unlock();
133 // force all receives to go into the specified directory by cfile type
134 void multi_xfer_force_dir(int cf_type);
136 // forces the given xfer entry to the specified directory type (only valid when called from the recv_callback function)
137 void multi_xfer_handle_force_dir(int handle,int cf_type);
139 // xor the flag on a given entry
140 void multi_xfer_xor_flags(int handle,int flags);
142 // get the flags for a given entry
143 int multi_xfer_get_flags(int handle);
145 // if the passed filename is being xferred, return the xfer handle, otherwise return -1
146 int multi_xfer_lookup(char *filename);
148 // get the % of completion of the passed file handle, return < 0 if invalid
149 float multi_xfer_pct_complete(int handle);
151 // get the socket of the file xfer (useful for identifying players)
152 uint multi_xfer_get_sock(int handle);
154 // get the CF_TYPE of the directory this file is going to
155 int multi_xfer_get_force_dir(int handle);
157 // ------------------------------------------------------------------------------------------
158 // MULTI XFER PACKET HANDLERS
161 // process an incoming file xfer data packet, return bytes processed, guaranteed to process the entire
162 // packet regardless of error conditions
163 int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who);