[GME-commit] GMESRC/GME/XmlBackEnd svauto.idl, NONE, 1.1 OperOptions.cpp, NONE, 1.1 OperOptions.h, NONE, 1.1 MsgConsole.cpp, NONE, 1.1 MsgConsole.h, NONE, 1.1 DirSupplier.cpp, NONE, 1.1 DirSupplier.h, NONE, 1.1 FileHelp.cpp, NONE, 1.1 FileHelp.h, NONE, 1.1 CredentialDlg.cpp, NONE, 1.1 CredentialDlg.h, NONE, 1.1 CertificateDlg.cpp, NONE, 1.1 CertificateDlg.h, NONE, 1.1 SvnConfig.h, NONE, 1.1

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Thu Feb 7 13:36:08 CST 2008


Update of /project/gme-repository/GMESRC/GME/XmlBackEnd
In directory escher:/tmp/cvs-serv26819

Added Files:
	svauto.idl OperOptions.cpp OperOptions.h MsgConsole.cpp 
	MsgConsole.h DirSupplier.cpp DirSupplier.h FileHelp.cpp 
	FileHelp.h CredentialDlg.cpp CredentialDlg.h 
	CertificateDlg.cpp CertificateDlg.h SvnConfig.h 
Log Message:
New helper classes added to cvs.


CVS User: Zoltan Molnar, ISIS (zolmol)

--- NEW FILE: OperOptions.h ---
#pragma once

class CCoreXmlFile;

class OperatingOptions
{
	bool           parseBool   ( const std::string& p_line, const std::string& p_optStr);
	std::string    parseStr    ( const std::string& p_line, const std::string& p_optStr);
	void           loadSettings( const std::string& p_folder, const std::string& p_name);
public:
	OperatingOptions           ();
	void           reset       ();
	void           load        ( const std::string& p_folder);
	void           display     ( CCoreXmlFile * const p_parent);

	// members
	static const char *  m_usrConfName;
	static const char *  m_sysConfName;
	static const char *  m_sysConfDefContentsSvn;
	static const char *  m_sysConfDefContentsPlain;
	bool                 m_defCheckInOnSave;
	bool                 m_defCheckOutOnAction;
	bool                 m_alwaysFullLock;
	bool                 m_onDeleteAlwaysFullLock;
	bool                 m_onLoadShowStatus;
	bool                 m_measureTime;
	bool                 m_createLog;
	bool                 m_doRefTargetLock;
	bool                 m_doConnEndPointLock;
	bool                 m_doConnSegmentLock;
	bool                 m_doModelParentLock;
	bool                 m_doBaseTypeLock;
	bool                 m_partialLoad;
	bool                 m_useAccountInfo;
	bool                 m_automaticLogin;
	bool                 m_useAPIForSvn;
	bool                 m_dirNamesHashed;
	int                  m_dirNamesHashVal;
	double               m_purgeDelayFactor;
	std::string          m_nameParadigmFile;
	std::string          m_defUserName;
	std::string          m_defPassword;
	std::string          m_prefUrl;
	std::string          m_prefAccessMethod;
};

--- NEW FILE: svauto.idl ---

import "oaidl.idl";
import "ocidl.idl";


[
	object,
	uuid(195A5A09-F67C-4B7E-A864-1662A08A213B),
	dual,
	nonextensible,
	helpstring("ISvnExec Interface"),
	pointer_default(unique)
]
interface ISvnExec : IDispatch{
	[id(1), helpstring("method TryLock")] HRESULT TryLock(BSTR path, [out,retval] VARIANT_BOOL* success);
	[id(2), helpstring("method UnLock")] HRESULT UnLock(BSTR path, [out,retval] VARIANT_BOOL* success);
	[id(3), helpstring("method AddLockableProperty")] HRESULT AddLockableProperty(BSTR path);
	[id(4), helpstring("method GetLatest")] HRESULT GetLatest(BSTR path);
	[id(5), helpstring("method LightCheckOut")] HRESULT LightCheckOut(BSTR path, BSTR localDir);
	[id(6), helpstring("method Commit")] HRESULT Commit(BSTR path, VARIANT_BOOL keepLocked);
	[id(7), helpstring("method Add")] HRESULT Add(BSTR path, VARIANT_BOOL recursive);
	[id(8), helpstring("method SrvMkDir")] HRESULT SrvMkDir(BSTR path);
	[id(9), helpstring("method Resolve")] HRESULT Resolve(BSTR path, VARIANT_BOOL recursive);
	[id(10), helpstring("method CleanUp")] HRESULT CleanUp(BSTR path);
	[id(11), helpstring("method Status")] HRESULT Status(BSTR path, VARIANT_BOOL provideStatusMessage, [out,retval] BSTR* statusMessage);
	[id(12), helpstring("method Info")] HRESULT Info(BSTR url, VARIANT_BOOL recursive, VARIANT_BOOL provideInfoMessage, [out] BSTR* infoMsg, [out] BSTR* author, [out] BSTR* lockOwner);
	[id(13), helpstring("method IsVersioned")] HRESULT IsVersioned(BSTR path, VARIANT_BOOL isDir, VARIANT_BOOL suppressErrorMsg, [out, retval] VARIANT_BOOL* isVersioned);
	[id(14), helpstring("method IsLocked")] HRESULT IsLocked(BSTR path, [out] VARIANT_BOOL* isLocked, [out] BSTR* lockHolder);
	[id(15), helpstring("method Init")] HRESULT Init(BSTR username, BSTR password);
	[id(16), helpstring("method Logging")] HRESULT Logging(VARIANT_BOOL onoff);
};



[
	object,
	uuid(D6503222-9EDC-4208-982A-0D66DD02C527),
	dual,
	nonextensible,
	helpstring("ISvnTester Interface"),
	pointer_default(unique)
]
interface ISvnTester : IDispatch {
	[id(1), helpstring("method info")]    HRESULT info    ([in] BSTR url,  [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive, [out,retval] BSTR* resultMsg);
	[id(2), helpstring("method status")]  HRESULT status  ([in] BSTR path, [in] VARIANT_BOOL byAPI, [out,retval] BSTR* resultMsg);
	[id(3), helpstring("method cleanup")] HRESULT cleanup ([in] BSTR path, [in] VARIANT_BOOL byAPI, [out,retval] BSTR* resultMsg);
	[id(4), helpstring("method resolve")] HRESULT resolve ([in] BSTR path, [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive);
	[id(5), helpstring("method commit")]  HRESULT commit  ([in] BSTR path, [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive);
	[id(6), helpstring("method checkout")] HRESULT checkout([in] BSTR url, [in] BSTR path, [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive);
	[id(7), helpstring("method add")]     HRESULT add     ([in] BSTR path, [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive);
	[id(8), helpstring("method propset")] HRESULT propset ([in] BSTR path, [in] BSTR propname, [in] BSTR propval, [in] VARIANT_BOOL byAPI, [in] VARIANT_BOOL recursive);
	[id(9), helpstring("method lock")]    HRESULT lock    ([in] BSTR path, [in] VARIANT_BOOL force, [in] VARIANT_BOOL byAPI);
	[id(10), helpstring("method unlock")] HRESULT unlock  ([in] BSTR path, [in] VARIANT_BOOL force, [in] VARIANT_BOOL byAPI);
};

--- NEW FILE: FileHelp.cpp ---
#include "stdafx.h"
#include "FileHelp.h"


// FileHelp
bool FileHelp::fileExist( const std::string& p_file)
{
	FILE * f = fopen( p_file.c_str(), "r");
	if( !f) 
		return false;

	fclose( f);
	return true;
}

bool FileHelp::isFile( const std::string& p_file)
{
	WIN32_FILE_ATTRIBUTE_DATA attr;

	if( GetFileAttributesEx( p_file.c_str(), GetFileExInfoStandard, &attr ) )
	{
		return FILE_ATTRIBUTE_DIRECTORY != ( attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	}

	return false;
}

bool FileHelp::isDir( const std::string& p_path)
{
	WIN32_FILE_ATTRIBUTE_DATA attr;

	if( GetFileAttributesEx( p_path.c_str(), GetFileExInfoStandard, &attr ) )
	{
		return FILE_ATTRIBUTE_DIRECTORY == ( attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	}

	return false;
}

bool FileHelp::isFileReadOnly( const std::string& p_file)
{
	WIN32_FILE_ATTRIBUTE_DATA attr;

	if( GetFileAttributesEx( p_file.c_str(), GetFileExInfoStandard, &attr ) )
	{
		return attr.dwFileAttributes & FILE_ATTRIBUTE_READONLY;
	}

	return false;
}

bool FileHelp::isFileReadOnly2( const std::string& p_file, bool* p_ptrFileExists)
{
	WIN32_FILE_ATTRIBUTE_DATA attr;
	ASSERT( p_ptrFileExists); // valid pointer

	if( GetFileAttributesEx( p_file.c_str(), GetFileExInfoStandard, &attr ) )
	{
		if( p_ptrFileExists) // pointer not zero
			*p_ptrFileExists = true;
		return attr.dwFileAttributes & FILE_ATTRIBUTE_READONLY;
	}

	return false;
}

bool FileHelp::isFileReadWrite( const std::string& p_file) // is a file and is read write
{
	WIN32_FILE_ATTRIBUTE_DATA attr;

	if( GetFileAttributesEx( p_file.c_str(), GetFileExInfoStandard, &attr ) )
	{
		return (attr.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != FILE_ATTRIBUTE_READONLY
			&&    (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY;
	}

	return false;
}

--- NEW FILE: CredentialDlg.h ---
#pragma once
#include "resource.h"

// CCredentialDlg dialog

class CCredentialDlg : public CDialog
{
	DECLARE_DYNAMIC(CCredentialDlg)

public:
	CCredentialDlg( bool p_maySave, const std::string& p_uName, CWnd* pParent = NULL);   // standard constructor
	virtual ~CCredentialDlg();

	std::string name();
	std::string word();
	bool        maySave();

// Dialog Data
	enum { IDD = IDD_DIALOG1 };

protected:
	bool        m_maySave;
	std::string m_suggestedName;

	bool        m_resMaySave;
	std::string m_resName;
	std::string m_resWord;

	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnBnClickedOk();
};

--- NEW FILE: MsgConsole.h ---
#pragma once

class MsgConsole
{
	CComPtr<IGMEOLEApp>   m_gme;
public:
	MsgConsole( bool p_create);
	void          sendMsg  ( const std::string&, int mtype );
	
	static void   ssendMsg ( const std::string&, int mtype );
};


--- NEW FILE: MsgConsole.cpp ---
#include "stdafx.h"
#include "MsgConsole.h"


// MsgConsole
MsgConsole::MsgConsole( bool p_create)
{
	if( p_create)
		m_gme.CoCreateInstance( L"GME.Application");
}

void MsgConsole::sendMsg( const std::string& p_msg, int p_mtype)
{
	if( m_gme)
	{
		m_gme->put_Visible( VARIANT_TRUE);
		CComBSTR msg( p_msg.c_str());
		m_gme->ConsoleMessage( msg, (msgtype_enum) p_mtype);
	}
}

//static
void MsgConsole::ssendMsg( const std::string& p_msg, int p_mtype)
{
	CComPtr<IGMEOLEApp> gme;
	gme.CoCreateInstance( L"GME.Application");
	if( gme)
	{
		gme->put_Visible( VARIANT_TRUE);
		CComBSTR msg( p_msg.c_str());
		gme->ConsoleMessage( msg, (msgtype_enum) p_mtype);
	}
}


--- NEW FILE: OperOptions.cpp ---
#include "stdafx.h"
#include <fstream>
#include "OperOptions.h"
#include "CoreXmlFile.h"

// OperatingOptions
OperatingOptions::OperatingOptions()
: m_defCheckInOnSave( false)
, m_defCheckOutOnAction( false)
, m_alwaysFullLock( false)
, m_onDeleteAlwaysFullLock( false)
, m_onLoadShowStatus( true)
, m_measureTime( false)
, m_createLog( false)
, m_doRefTargetLock( true)
, m_doConnEndPointLock( true)
, m_doConnSegmentLock( true)
, m_doModelParentLock( true)
, m_doBaseTypeLock( true)
, m_partialLoad( false)
, m_useAccountInfo( false)
, m_automaticLogin( false)
, m_useAPIForSvn( false)
, m_dirNamesHashed( false)
, m_dirNamesHashVal( 0)
, m_purgeDelayFactor( 1.)
, m_nameParadigmFile()
, m_defUserName()
, m_defPassword()
, m_prefUrl()
, m_prefAccessMethod()
{
}

void OperatingOptions::reset()
{
	m_defCheckInOnSave      = false;
	m_defCheckOutOnAction   = false;
	m_alwaysFullLock        = false;
	m_onDeleteAlwaysFullLock= false;
	m_onLoadShowStatus      = true;
	m_measureTime           = false;
	m_createLog             = false;
	m_doRefTargetLock       = true;
	m_doConnEndPointLock    = true;
	m_doConnSegmentLock     = true;
	m_doModelParentLock     = true;
	m_doBaseTypeLock        = true;
	m_partialLoad           = false;
	m_useAccountInfo        = false;
	m_automaticLogin        = false;
	m_useAPIForSvn          = false;
	m_dirNamesHashed        = false;
	m_dirNamesHashVal       = 0;
	m_purgeDelayFactor      = 1.;
	m_nameParadigmFile      = "";
	m_defUserName           = "";
	m_defPassword           = "";
	m_prefUrl               = "";
	m_prefAccessMethod      = "";
}

void OperatingOptions::load( const std::string& p_folder)
{
	reset();
	loadSettings( p_folder, m_sysConfName);
	loadSettings( p_folder, m_usrConfName);
}

bool OperatingOptions::parseBool( const std::string& p_line, const std::string& p_optStr)
{
	bool truef  = p_line.substr( p_optStr.length()).find( "true")  != std::string::npos;
	bool falsef = p_line.substr( p_optStr.length()).find( "false") != std::string::npos;
	bool rv = true;

	if( truef && !falsef)
		rv = true;
	else if( !truef && falsef)
		rv = false;
	else if( !truef && !falsef) // value doesn't contain neither true, nor false, assume true
		rv = true;
	else if( truef && falsef) // value might contain 'true' and 'false'
		rv = true;

	return rv;
}

std::string OperatingOptions::parseStr( const std::string& p_line, const std::string& p_optStr)
{
	std::string ret;
	int pos = p_line.find_first_not_of( "\t =", p_optStr.length()); // skip whitespaces, equal sign
	if( pos != std::string::npos) // found
	{
		int cpos = p_line.find_first_of( "\t #", pos); // find comments at the end of line, skip whitespaces too
		// value is between pos and cpos
		ret = p_line.substr( pos, cpos - pos); // cpos == -1 case is tolerated too by substr
	}

	return ret;
}

void OperatingOptions::loadSettings( const std::string& p_folder, const std::string& p_fName)
{
	std::ifstream options;
	options.open( ( p_folder + "\\" + p_fName).c_str(), std::ios_base::in);
	if( options.is_open())
	{
		char buff[1024];
		while( options.getline( buff, 1024))
		{
			std::string line( buff);
			if( line.empty() || line[0] == '#')
				continue;
			else if( 0 == line.find( "DefCheckInOnSave"))//=true"))
			{
				m_defCheckInOnSave = parseBool( line, "DefCheckInOnSave");//m_defCheckInOnSave = true;
			}
			else if( 0 == line.find( "DefCheckOutOnAction"))//=true"))
			{
				m_defCheckOutOnAction = parseBool( line, "DefCheckOutOnAction"); //m_defCheckOutOnAction = true;
			}
			else if( 0 == line.find( "PartialLoad"))//=true"))
			{
				m_partialLoad = parseBool( line, "PartialLoad"); //m_partialLoad = true;
			}
			else if( 0 == line.find( "UseAccountInfo"))//=true"))
			{
				m_useAccountInfo = parseBool( line, "UseAccountInfo"); //m_useAccountInfo = true;
			}
			else if( 0 == line.find( "AutomaticLogin"))//=true"))
			{
				m_automaticLogin = parseBool( line, "AutomaticLogin"); //m_automaticLogin = true;
			}
			else if( 0 == line.find( "account"))
			{
				//m_defUserName = line.substr( std::string( "account=").length());
				m_defUserName = parseStr( line, "account");
			}
			else if( 0 == line.find( "phrase"))
			{
				//m_defPassword = line.substr( std::string( "phrase=").length());
				m_defPassword = parseStr( line, "phrase");
			}
			else if( 0 == line.find( "PreferredUrl"))
			{
				m_prefUrl = parseStr( line, "PreferredUrl");
			}
			else if( 0 == line.find( "AccessMethod"))
			{
				m_prefAccessMethod = parseStr( line, "AccessMethod");
			}
			//else if( 0 == line.find( "AlwaysFullLock=true"))
			//{
			//	m_alwaysFullLock = true;
			//}
			//else if( 0 == line.find( "OnDeleteAlwaysFullLock=true"))
			//{
			//	m_onDeleteAlwaysFullLock = true;
			//}
			else if( 0 == line.find( "OnLoadShowStatus"))//=false"))
			{
				m_onLoadShowStatus = parseBool( line, "OnLoadShowStatus"); //m_onLoadShowStatus = false;
			}
			else if( 0 == line.find( "MeasureTime"))//=true"))
			{
				m_measureTime = parseBool( line, "MeasureTime"); //m_measureTime = true;
			}
			else if( 0 == line.find( "Log"))//=true"))
			{
				m_createLog = parseBool( line, "Log"); //m_createLog = true;
			}
			else if( 0 == line.find( "UseApiForSvn"))
			{
				m_useAPIForSvn = parseBool( line, "UseApiForSvn");
			}
			else if( 0 == line.find( "DirNamesHashed"))
			{
				m_dirNamesHashed = parseBool( line, "DirNamesHashed");
			}
			else if( 0 == line.find( "DirNamesHashedVal"))
			{
				int stoi = 0.;
				std::string v = parseStr( line, "DirNamesHashedVal");
				if( 1 == sscanf( v.c_str(), "%u", &stoi) && stoi >= 0)
					m_dirNamesHashVal = stoi;
			}
			else if( 0 == line.find( "PurgeDelayed"))
			{
				float stor = 0.;
				std::string v = parseStr( line, "PurgeDelayed");
				if( 1 == sscanf( v.c_str(), "%f", &stor) && stor >= 0)
					m_purgeDelayFactor = stor;
				//const char * ptr = line.c_str();
				//if( 1 == sscanf( ptr + std::string( "PurgeDelayed=").length(), "%f", &stor) && stor >= 0)
				//	m_purgeDelayFactor = stor;
			}
			//else if( 0 == line.find( "DoRefTargetLock=false"))
			//	m_doRefTargetLock = false;
			//else if( 0 == line.find( "DoConnEndPointLock=false"))
			//	m_doConnEndPointLock = false;
			//else if( 0 == line.find( "DoConnSegmentLock=false"))
			//	m_doConnSegmentLock = false;
			//else if( 0 == line.find( "DoModelParentLock=false"))
			//	m_doModelParentLock = false;
			//else if( 0 == line.find( "DoBaseTypeLock=false"))
			//	m_doBaseTypeLock = false;
		}
		options.close();
	}
}

void OperatingOptions::display( CCoreXmlFile * const parent)
{
	parent->sendMsg( std::string( "User options loaded:") , MSG_INFO);
	parent->sendMsg( std::string( "DefCheckInOnSave=" )     + (m_defCheckInOnSave?"true":"false"), MSG_INFO );
	parent->sendMsg( std::string( "DefCheckOutOnAction=" )  + (m_defCheckOutOnAction?"true":"false"), MSG_INFO );
	//parent->sendMsg( std::string( "AlwaysFullLock=" )       + (m_alwaysFullLock?"true":"false"), MSG_INFO);
	//parent->sendMsg( std::string( "OnDeleteAlwaysFullLock=")+ (m_onDeleteAlwaysFullLock?"true":"false"), MSG_INFO);
	parent->sendMsg( std::string( "OnLoadShowStatus=")      + (m_onLoadShowStatus?"true":"false"), MSG_INFO);
	parent->sendMsg( std::string( "MeasureTime=")           + (m_measureTime?"true":"false"), MSG_INFO);
#ifdef _DEBUG
	parent->sendMsg( std::string( "Log=")                   + (m_createLog?"true":"false"), MSG_INFO);
#endif
	parent->sendMsg( std::string( "PartialLoad=")           + (m_partialLoad?"true":"false"), MSG_INFO);
	//parent->sendMsg( std::string( "Adv. Settings {RTgt, CEnd, CSeg, ModP, BasT}=") 
	//	+ (m_doRefTargetLock?"{true,":"{false,")
	//	+ (m_doConnEndPointLock?"true,":"false,")
	//	+ (m_doConnSegmentLock?"true,":"false,")
	//	+ (m_doModelParentLock?"true,":"false,")
	//	+ (m_doBaseTypeLock?"true}":"false}"), MSG_INFO);
	char buff[250]; sprintf( buff, "%.2f, equal with %i minutes", m_purgeDelayFactor, (int)(m_purgeDelayFactor * 60));
	CTime back = CTime::GetCurrentTime() - CTimeSpan( 0, 0, (int)(m_purgeDelayFactor * 60), 0);

	parent->sendMsg( std::string( "PurgeDelayed=") + buff, MSG_INFO);
	if( m_purgeDelayFactor == 0.)
		parent->sendMsg( std::string( "Purge events: Disabled."), MSG_INFO);
	else
		parent->sendMsg( std::string( "Purge events older than ") + (LPCTSTR) back.Format( "[%Y-%m-%d %H:%M:%S]."), MSG_INFO);

	if( m_useAccountInfo)
		parent->sendMsg( std::string( m_automaticLogin?"Auto":"Manual") + std::string(" login with account=\"") + m_defUserName + "\"", MSG_INFO);
	if( !m_prefUrl.empty())
		parent->sendMsg( std::string( "PreferredUrl: ") + m_prefUrl, MSG_INFO);
}


--- NEW FILE: DirSupplier.cpp ---
#include "stdafx.h"
#include "DirSupplier.h"


// DirSupplier

DirSupplier::DirSupplier( bool p_hashed, int p_algorithm)
: m_hashed( p_hashed)
, m_algo( p_algorithm)
{
}

Dir256Iterator DirSupplier::begin256() const
{
	return * Dir256Iterator::createIteratorBeg();
}

Dir256Iterator DirSupplier::end256() const
{
	return * Dir256Iterator::createIteratorEnd();
}


Dir16Iterator DirSupplier::begin16() const
{
	return * Dir16Iterator::createIteratorBeg();
}

Dir16Iterator DirSupplier::end16() const
{
	return * Dir16Iterator::createIteratorEnd();
}

Dir256Iterator::Dir256Iterator( bool p_endIterator /*= false*/)
: m_i(0)
, m_j(0)
, m_algo( 0)
{
	if( p_endIterator)
	{
		m_i = m_j = m_max;
	}
}

//static 
Dir256Iterator* Dir256Iterator::createIteratorBeg()
{
	return new Dir256Iterator();
}

//static
Dir256Iterator* Dir256Iterator::createIteratorEnd()
{
	return new Dir256Iterator( true);
}

std::string Dir256Iterator::operator *() const
{
	static const char ans[] = "0123456789abcdef";
	char       lev[3]  = { 'z', 't', 0 };

	if( m_i > (int) sizeof( ans)/sizeof(char) || m_i < 0
		|| m_j > (int) sizeof( ans)/sizeof(char) || m_j < 0)
		return lev;

	lev[0] = ans[ m_i]; // form a name
	lev[1] = ans[ m_j];

	return lev;
}

Dir256Iterator& Dir256Iterator::operator++()
{
	if( ++m_j >= m_max)
	{
		m_j = 0;
		++m_i;
	}

	return *this;
}

Dir256Iterator::operator bool() const
{
	return m_i < m_max
		&& m_j < m_max;
}

bool Dir256Iterator::operator()() const
{
	return m_i < m_max
		&& m_j < m_max;
}

bool Dir256Iterator::operator !=( const Dir256Iterator& p_peer) const
{
	if( &p_peer == this)
		return false;

	bool me_valid = (*this);
	bool peer_valid = p_peer;

	if( me_valid && peer_valid) // examine details only if both are valid
	{
		if( m_i == p_peer.m_i
			&& m_j == p_peer.m_j)
		{
			return false;
		}
	}
	else if( !me_valid && !peer_valid) // both invalid
		return false;

	return true;
}

Dir16Iterator::Dir16Iterator( bool p_endIterator /*= false*/)
: m_i(0)
, m_algo( 0)
{
	if( p_endIterator)
	{
		m_i = m_max;
	}
}

//static 
Dir16Iterator* Dir16Iterator::createIteratorBeg()
{
	return new Dir16Iterator( );
}

//static
Dir16Iterator* Dir16Iterator::createIteratorEnd()
{
	return new Dir16Iterator( true);
}

std::string Dir16Iterator::operator *() const
{
	// we will create 16 dirs like 0, 1, 2, ..., f
	static const char ans[] = "0123456789abcdef";
	char       lev[2]  = { 'z', 0 };

	if( m_i > (int) sizeof( ans)/sizeof(char) || m_i < 0)
		return lev;

	lev[0] = ans[ m_i]; // form a name
	return lev;
}

Dir16Iterator& Dir16Iterator::operator++()
{
	++m_i;

	return *this;
}

Dir16Iterator::operator bool() const
{
	return m_i < m_max;
}

bool Dir16Iterator::operator()() const
{
	return m_i < m_max;
}

bool Dir16Iterator::operator !=( const Dir16Iterator& p_peer) const
{
	if( &p_peer == this)
		return false;

	bool me_valid = (*this);
	bool peer_valid = p_peer;

	if( me_valid && peer_valid) // examine details only if both are valid
	{
		if( m_i == p_peer.m_i)
			return false;
	}
	else if( !me_valid && !peer_valid) // both invalid
		return false;

	return true;
}

--- NEW FILE: CredentialDlg.cpp ---
// CredentialDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CredentialDlg.h"


// CCredentialDlg dialog

IMPLEMENT_DYNAMIC(CCredentialDlg, CDialog)
CCredentialDlg::CCredentialDlg( bool p_maySave, const std::string& p_uName, CWnd* pParent /*=NULL*/)
	: CDialog(CCredentialDlg::IDD, pParent)
	, m_maySave( p_maySave)
	, m_suggestedName( p_uName)
{
}

CCredentialDlg::~CCredentialDlg()
{
}

std::string CCredentialDlg::name()
{
	return m_resName;
}

std::string CCredentialDlg::word()
{
	return m_resWord;
}

bool        CCredentialDlg::maySave()
{
	return m_resMaySave;
}

void CCredentialDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CCredentialDlg, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()


// CCredentialDlg message handlers

BOOL CCredentialDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	GetDlgItem( IDC_STATIC1)->SetWindowText( "Hello");
	((CEdit *) GetDlgItem( IDC_EDITNAME))->SetWindowText( m_suggestedName.c_str());

	GetDlgItem( IDC_MAYBESAVED)->EnableWindow( m_maySave);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CCredentialDlg::OnBnClickedOk()
{
	CString res;
	CEdit * edt = 0;
	
	edt = (CEdit *) GetDlgItem( IDC_EDITNAME);
	edt->GetWindowText( res);
	m_resName = (LPCTSTR) res;

	edt = (CEdit *) GetDlgItem( IDC_EDITWORD);
	edt->GetWindowText( res);
	m_resWord = (LPCTSTR) res;

	CButton * btn = 0;
	btn = (CButton *) GetDlgItem( IDC_MAYBESAVED);
	m_resMaySave = btn->GetCheck() == BST_CHECKED;

	OnOK();
}

--- NEW FILE: FileHelp.h ---
#pragma once

class FileHelp
{
public:
	static bool isFileReadOnly   ( const std::string& p_file);
	static bool isFileReadOnly2  ( const std::string& p_file, bool * p_ptrExists);
	static bool isFileReadWrite  ( const std::string& p_file);
	static bool isFile           ( const std::string& p_dirOrFile);
	static bool isDir            ( const std::string& p_dir);
	static bool fileExist        ( const std::string& p_file);
};


--- NEW FILE: DirSupplier.h ---
#pragma once

class Dir256Iterator;
class Dir16Iterator;

class DirSupplier
{
	bool    m_hashed;
	int     m_algo;
public:
	DirSupplier( bool p_hashed, int p_algorithm);
	Dir256Iterator begin256() const;
	Dir256Iterator end256() const;

	Dir16Iterator  begin16() const;
	Dir16Iterator  end16() const;
};

class Dir256Iterator
{
	static const int m_max = 16;
	int m_i;
	int m_j;
	int m_algo;
	Dir256Iterator( bool p_endIterator = false);
public:
	static Dir256Iterator*  createIteratorBeg();
	static Dir256Iterator*  createIteratorEnd();
	std::string             operator *( ) const;
	bool                    operator!=( const Dir256Iterator& p_peer) const;
	Dir256Iterator&         operator++( );
	
	                        operator bool( ) const;
	bool                    operator()   ( ) const;
};

class Dir16Iterator
{
	static const int m_max = 16;
	int m_i;
	int m_algo;
	Dir16Iterator( bool p_endIterator = false);
public:
	static Dir16Iterator*   createIteratorBeg();
	static Dir16Iterator*   createIteratorEnd();
	std::string             operator * ( ) const;
	bool                    operator !=( const Dir16Iterator& p_peer) const;
	Dir16Iterator&          operator ++( );
	
	                        operator bool( ) const;
	bool                    operator()   ( ) const;
};

--- NEW FILE: CertificateDlg.cpp ---
// CertificateDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CertificateDlg.h"


// CCertificateDlg dialog

IMPLEMENT_DYNAMIC(CCertificateDlg, CDialog)
CCertificateDlg::CCertificateDlg( const std::string& p_cert, bool p_permAcceptEnabled, CWnd* pParent /*=NULL*/)
	: CDialog(CCertificateDlg::IDD, pParent)
	, m_text( p_cert)
	, m_permAcceptEnabled( p_permAcceptEnabled)
{

}

CCertificateDlg::~CCertificateDlg()
{
}

void CCertificateDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CCertificateDlg, CDialog)
	ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()


// CCertificateDlg message handlers

BOOL CCertificateDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	CWnd * txt = GetDlgItem(IDC_EDITTEXT);
	if( txt) txt->SetWindowText( m_text.c_str());
	// TODO:  Add extra initialization here

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CCertificateDlg::OnBnClickedOk()
{
	UpdateData();

	CButton* rdo1 = (CButton*) GetDlgItem( IDC_RADIO1);
	CButton* rdo2 = (CButton*) GetDlgItem( IDC_RADIO2);
	CButton* rdo3 = (CButton*) GetDlgItem( IDC_RADIO3);

	m_response = Response::PermanentAccept;
	if( rdo1->GetCheck() == BST_CHECKED)
		m_response = Response::PermanentAccept;
	else if( rdo2->GetCheck() == BST_CHECKED)
		m_response = Response::TemoraryAccept;
	else if( rdo2->GetCheck() == BST_CHECKED)
		m_response = Response::Reject;

	if( !m_permAcceptEnabled && m_response == Response::PermanentAccept)
	{
		AfxMessageBox( "Permanent accept is not a valid option"); 
		return;
	}

	OnOK();
}

CCertificateDlg::Response CCertificateDlg::getResp()
{
	return m_response;
}

--- NEW FILE: SvnConfig.h ---
#pragma once

#define USESVN  1

#if(USESVN)
#define USENEON 1
#define USESERF 0

#ifdef _DEBUG

#pragma comment(lib, "comsvcs.lib")
#pragma comment(lib, "zlibstatD.lib")
#pragma comment(lib, "setargv.obj")
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "shfolder.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "libapr.lib")
#pragma comment(lib, "libaprutil.lib")
#pragma comment(lib, "libapriconv.lib")
#pragma comment(lib, "xml.lib")
#pragma comment(lib, "libsvn_client-1.lib")
#pragma comment(lib, "libsvn_delta-1.lib")
#pragma comment(lib, "libsvn_diff-1.lib")
#pragma comment(lib, "libsvn_fs-1.lib")
#pragma comment(lib, "libsvn_fs_fs-1.lib")
#pragma comment(lib, "libsvn_ra-1.lib")
#pragma comment(lib, "libsvn_ra_dav-1.lib")
#pragma comment(lib, "libsvn_ra_local-1.lib")
#pragma comment(lib, "libsvn_ra_svn-1.lib")
#pragma comment(lib, "libsvn_repos-1.lib")
#pragma comment(lib, "libsvn_subr-1.lib")
#pragma comment(lib, "libsvn_wc-1.lib")
#pragma comment(lib, "libeay32.lib")
#pragma comment(lib, "ssleay32.lib")

#else
//comsvcs.lib zlibstat.lib setargv.obj advapi32.lib shfolder.lib ws2_32.lib libneon.lib libapr.lib libaprutil.lib libapriconv.lib xml.lib libsvn_client-1.lib libsvn_delta-1.lib libsvn_diff-1.lib libsvn_fs-1.lib libsvn_fs_fs-1.lib libsvn_ra-1.lib libsvn_ra_dav-1.lib libsvn_ra_local-1.lib libsvn_ra_svn-1.lib libsvn_repos-1.lib libsvn_subr-1.lib libsvn_wc-1.lib libeay32.lib ssleay32.lib
#pragma comment(lib, "comsvcs.lib")
#pragma comment(lib, "zlibstat.lib")
#pragma comment(lib, "setargv.obj")
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "shfolder.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "libapr.lib")
#pragma comment(lib, "libaprutil.lib")
#pragma comment(lib, "libapriconv.lib")
#pragma comment(lib, "xml.lib")
#pragma comment(lib, "libsvn_client-1.lib")
#pragma comment(lib, "libsvn_delta-1.lib")
#pragma comment(lib, "libsvn_diff-1.lib")
#pragma comment(lib, "libsvn_fs-1.lib")
#pragma comment(lib, "libsvn_fs_fs-1.lib")
#pragma comment(lib, "libsvn_ra-1.lib")
#pragma comment(lib, "libsvn_ra_dav-1.lib")
#pragma comment(lib, "libsvn_ra_local-1.lib")
#pragma comment(lib, "libsvn_ra_svn-1.lib")
#pragma comment(lib, "libsvn_repos-1.lib")
#pragma comment(lib, "libsvn_subr-1.lib")
#pragma comment(lib, "libsvn_wc-1.lib")
#pragma comment(lib, "libeay32.lib") 
#pragma comment(lib, "ssleay32.lib")

#endif


#if(USENEON)

	#ifdef _DEBUG
		#pragma comment(lib, "libNeonD.lib")
	#else
		#pragma comment(lib, "libNeon.lib")
	#endif

#endif

#if(USESERF)

	#pragma comment(lib, "libsvn_ra_serf-1.lib")
	#pragma comment(lib, "serf.lib")

#endif

#endif
--- NEW FILE: CertificateDlg.h ---
#pragma once
#include "resource.h"

// CCertificateDlg dialog

class CCertificateDlg : public CDialog
{
	DECLARE_DYNAMIC(CCertificateDlg)

public:
	CCertificateDlg( const std::string& p_text, bool p_permAcceptEnabled, CWnd* pParent = NULL);   // standard constructor
	virtual ~CCertificateDlg();

// Dialog Data
	enum { IDD = IDD_DIALOG2 };
	typedef enum Response
	{
		PermanentAccept
		, TemoraryAccept
		, Reject
	};


	Response getResp();

protected:
	std::string m_text;
	bool        m_permAcceptEnabled;
	Response    m_response;
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	virtual BOOL OnInitDialog();
	afx_msg void OnBnClickedOk();
};



More information about the GME-commit mailing list