#ifndef __Desk_Export_h
#define __Desk_Export_h

#ifndef __Desk_wimp_h
	#include "Desk.Wimp.h"
#endif

typedef int (*Desk_export_filesaver)( const char *filename, void *reference);
/* 
This type of function should save data to file given by 'filename',
using info in 'reference'. It should return 0 if it was successful.
'ref' is the (void *) originally passed to
 */

typedef int (*Desk_export_ramsaver)( Desk_message_block* ramfetch, int progress, void* reference);
/*
This type of function should Wimp_TransferBlock data. Note that you can
do this using multiple Wimp_TransferBlock's if this is more convenient.
Should return the total number of bytes transfered into 'destbuffer' -
if less than buffersize, then transfer has finished. If <0, error has
occurred. 'reference' is the (void *) originally passed to
Desk_Export_ExportData.
 */


typedef enum	{
	Desk_export_result_OK	= 0,
	Desk_export_result_RECEIVERFAILED,
	Desk_export_result_FILESAVERFAILED,
	Desk_export_result_RAMSAVERFAILED
	}
	Desk_export_result;


typedef void (*Desk_export_resulthandler)( Desk_export_result result, void *reference);


void	Desk_Export_ExportData(
			Desk_event_pollblock*		event,		/* NULL or Desk_message_DATAREQUEST if relevent...		*/
			Desk_mouse_block*		mouse,		/* NULL if not saving from a drag. Note event_USERDRAG doesn't return mouse info */
			const char*			leafname,
			Desk_export_filesaver		filesaver,
			Desk_export_ramsaver		ramsaver,
			Desk_export_resulthandler	resulthandler,
			size_t				estimatedsize,
			int				filetype,
			void*				reference
			);


void	Desk_Export_ExportData2(
			Desk_event_pollblock*		event,		/* NULL or Desk_message_DATAREQUEST if relevent...		*/
			Desk_mouse_block*		mouse,		/* NULL if not saving from a drag.				*/
			const char*			leafname,
			Desk_export_filesaver		filesaver,
			Desk_export_ramsaver		ramsaver,
			Desk_export_resulthandler	resulthandler,
			size_t				estimatedsize,
			int				filetype,
			void*				reference,
			Desk_message_action		initial_messageaction,
			Desk_task_handle		destination
			);
/*
As Desk_Export_ExportData, except you can set the message action of the
first message sent. This is for use in the External Edit protocol, where
the first message is a EditDataSave, rather than DataSave, but the
message data and rest of the protocol are identical.
 */


#endif
