/*
 =======================================================================================
  Name        :IniData.h
 
  Author      :Vincent lhullier             Date :21/07/97
 
  Description :function for initial value (saving, loading, ... ) Header file
 =======================================================================================
  Modification -> Author :                  Date :
  Description :
 =======================================================================================
 */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifndef __INIDATA_H__
#define __INIDATA_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <afxdisp.h>
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
typedef struct tdstProject_ tdstProject;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/*
 =======================================================================================
	Constants
 =======================================================================================
 */
/*
 * Ini file
 */
#define C_szIniFile "MngData.ini"

/* 
 * For Update Flags
 */
#define C_UpdateOption_lObtainAfter			0x0001
#define C_UpdateOption_lConfirmObtainAfter	0x0002
#define C_UpdateOption_lForce				0x0004
#define C_UpdateOption_lConfirmForce		0x0008
#define C_UpdateOption_lShowDifferences		0x0010

/* 
 * type of list
 */
#define C_ConfigType_cObtain	0
#define C_ConfigType_cUpdate	1

/*
 =======================================================================================
	Structures
 =======================================================================================
 */

/*
 * structure to store config of file list information
 */
typedef struct tdstFileListConfig_
{
	char			szKey[20];					// congfing entry in vss entry
	char			cIndex;						// current config index
	char			szId[20];					// current config id
	char			szName[40];					// current config name
	long			lNumberOfFiles;				// number of file in current config
	char			**d_szFile;					// list of file name in current config

} tdstFileListConfig;

/*
 * structure to store program information
 */
typedef struct tdstIniData_
{
	char				szTempPath[MAX_PATH];		// temporary path
	char				szLocalPath[MAX_PATH];		// name of local data path
	char				szVssPath[MAX_PATH];		// vss data path
	char				szVssDatabase[MAX_PATH];	// vss data path
	char				szVssUserName[20];			// User Name

	char				szInUpdateSem[MAX_PATH];	// name of file used as update semaphore
	char				szVssInUpdate[MAX_PATH];	// full name of vss file
	char				szLocalInUpdate[MAX_PATH];	// full name of local file
	
	char				szInObtainSem[MAX_PATH];	// name of file used as obtain semaphore
	char				szVssInObtain[MAX_PATH];	// full name of vss file
	char				szLocalInObtain[MAX_PATH];	// full name of local file

	char				szModifFile[MAX_PATH];		// name of file that contains modificationq

	COleDateTime		*p_oObtainingTime;			// last obtaining time but within a OLE date time object
	/*
	long				lNumberOfObtainedFiles;		// number of file (projetc) obtained
	char				**d_szObtainedFile;			// description of obtained files
	*/

	char				a_cAvailableConfig[ 100 ];	// array of config available in ini file
	tdstFileListConfig	stObtainConfig;
	tdstFileListConfig	stUpdateConfig;

	/*
	long				lNumberOfFilesToObtain;		// files to obtained ( without recursive or not project)
	char				**d_szFileToObtain;			// list of file name that will be obtained ( without project )
	*/
} tdstIniData;

/*
 * structure to store Window preference and options
 */
typedef struct tdstWindowsPref_
{
	RECT stMainPos;								// main window position and size
	RECT stFilePos;								// file window position and size
	RECT stModifPos;							// modif list window position and size
	RECT stConflictPos;							// conflict window pos and size
	RECT stUpdateWithConfigPos;					// Update with config window pos abnd size
	long lUpdateFlags;							// Update options
	/*
	 * batch obtain preferences
	 */
	long lElapseTime;
	char cRelativeDay;
	char cHour;
	char cMinute;
	BOOL bWaitToBeAlone;
	BOOL bUseTimer;
}tdstWindowsPref;
 
/*
 *******************************************************************************
 * Globals
 *******************************************************************************
 */
extern COleDateTime		g_oObtainingTime;		// obtaining time
extern tdstIniData		g_stIniData;			// initial data
extern char				g_szIniFile[MAX_PATH];	// ini file
extern tdstWindowsPref	g_stWinPref;			// program options

/*
 *******************************************************************************
 * Functions
 *******************************************************************************
 */

/*
 * specific function for file list configuration
 */

void fn_IniD_vFreeFileList		( tdstFileListConfig *_p_stFileList );
void fn_IniD_vWriteFileList		( tdstFileListConfig *_p_stFileList, char *_szIniFile );
void fn_IniD_vDeleteFileList	( char _cConfig, char *_szIniFile );
void fn_IniD_vRenameFileList	( char _cConfig, char *_szNewName, char *_szIniFile );
BOOL fn_IniD_bGetFileList		( tdstFileListConfig *_p_stFileList, char _cConfig, char *_szIniFile );
void fn_IniD_vSetSingleFileList	( tdstFileListConfig *_p_stFileList, char *_szFileName );

char fn_IniD_cGetIndexFromId( char *_szId );
char fn_IniD_cGetNumberOfConfig( void );
char fn_IniD_cGetAvailableConfig( void );
void fn_IniD_vGetConfigName( char _cConfig, char *_szName );
char fn_IniD_cGetConfigType( char _cConfig );

/*
 * function to get/set single initial data
 */
void fn_IniD_vSetLocalPath( char *_szPath );
void fn_IniD_vSetVssDatabase( char *_szSourceSafeIni );
void fn_IniD_vSetVssUserName( char *_szUserName );
void fn_IniD_vSetModifListFile( char *_szFileName );
void fn_IniD_vSetUpdateFlag( long _lFlag, BOOL _bValue );

/*
 * function for obtaining data information
 */
void fn_IniD_vSaveObtainingDate( void );
void fn_IniD_vSaveObtainingInfo( void );
//void fn_IniD_vFreeObtainedFileList( void );
void fn_IniD_vGetObtainingInfo( void );

/*
 * function to free list of file to obtain
 */
//void fn_IniD_vFreeFileListToObtain( void );

/*
 * function for windows preference data
 */
void fn_IniD_vGetWindowPreference( void );
void fn_IniD_vWriteWindowPreference( void );

/*
 * function for all ini data
 */
void fn_IniD_vGetAllFromIniFile( BOOL _bFirst );

#endif //__INIDATA_H__