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