LosaDev source snapshot 2019

This commit is contained in:
LosaDev committed 2026-11-07 13:30:45 +07:00
commit c198676e97
20588 files changed
+8812878

No files matched your search

@@ -0,0 +1,230 @@
#include "StdAfx.h"
#include "BaseCommand.h"
#include "../resource.h"
#include "../LS_launcherDlg.h"
#include "../LauncherTabCtrl.h"
BaseCommand::BaseCommand(DWORD type) : m_commandType(type)
{
Init();
}
BaseCommand::~BaseCommand(void)
{
Destroy();
}
void BaseCommand::Init()
{
m_launcher = NULL;
m_isServiceAll = FALSE;
m_isApplyAll = FALSE;
m_state = CST_BEFORE_EXCUTE;
m_error = CET_NOERROR;
}
void BaseCommand::Destroy()
{
}
BOOL BaseCommand::Execute()
{
if( NULL == m_launcher )
{
m_error = CET_WRONG_NO_LAUNCHER;
return FALSE;
}
if( m_isApplyAll )
{
if( m_isServiceAll )
{
for( int i = 0 ; i < GetDialogCount() ; i++ )
{
CServerDialog* dialog = GetDialog(i);
if( !ExecuteServiceAll( dialog ) )
return FALSE;
}
}
else
{
for( int i = 0 ; i < GetDialogCount() ; i++ )
{
CServerDialog* dialog = GetDialog(i);
if( !ExecuteServiceOne( dialog ) )
return FALSE;
}
}
}
else
{
if( m_isServiceAll )
{
for( UINT i = 0 ; i < m_tabIndexes.size() ; i++ )
{
CServerDialog* dialog = GetDialog(m_tabIndexes[i]);
if( !ExecuteServiceAll(dialog) )
return FALSE;
}
}
else
{
for( UINT i = 0 ; i < m_tabIndexes.size() ; i++ )
{
CServerDialog* dialog = GetDialog(m_tabIndexes[i]);
if( !ExecuteServiceOne(dialog) )
return FALSE;
}
}
}
if( m_isWait && m_state != CST_ALREADY_EXCUTE )
{
m_state = CST_WAITING;
m_launcher->BatchWait();
return FALSE;
}
m_state = CST_EXCUTE_DONE;
return TRUE;
}
BOOL BaseCommand::CheckContinue()
{
if( NULL == m_launcher )
{
m_error = CET_WRONG_NO_LAUNCHER;
return FALSE;
}
if( m_state != CST_WAITING )
return FALSE;
if( m_isApplyAll )
{
if( m_isServiceAll )
{
for( int i = 0 ; i < GetDialogCount() ; i++ )
{
CServerDialog* dialog = GetDialog(i);
if( !CheckContinueServiceAll(dialog) )
{
return FALSE;
}
}
}
else
{
for( int i = 0 ; i < GetDialogCount() ; i++ )
{
CServerDialog* dialog = GetDialog(i);
if( !CheckContinueServiceOne(dialog) )
{
return FALSE;
}
}
}
}
else
{
if( m_isServiceAll )
{
for( UINT i = 0 ; i < m_tabIndexes.size() ; i++ )
{
CServerDialog* dialog = GetDialog(m_tabIndexes[i]);
if( !CheckContinueServiceAll(dialog) )
return FALSE;
}
}
else
{
for( UINT i = 0 ; i < m_tabIndexes.size() ; i++ )
{
CServerDialog* dialog = GetDialog(m_tabIndexes[i]);
if( !CheckContinueServiceOne(dialog) )
return FALSE;
}
}
}
m_state = CST_EXCUTE_DONE;
return TRUE;
}
BOOL BaseCommand::IsValid()
{
// 전체적으로 체크할 오류?..
if( !m_launcher )
return FALSE;
// Apply All 처리 - TabIndex가 있으면 ApplyAll이 아니다
if( m_tabIndexes.empty() )
{
m_isApplyAll = TRUE;
}
else
{
m_isApplyAll = FALSE;
}
return IsValidDetail();
}
void BaseCommand::SetOption( DWORD optionBit )
{
m_isWait = FALSE;
if( BITCHK(optionBit, BOT_SERVICE_WAIT) )
{
m_isWait = TRUE;
}
m_isServiceAll = FALSE;
if( BITCHK(optionBit, BOT_ALL_SERVICE) )
{
m_isServiceAll = TRUE;
}
}
void BaseCommand::SetCommandText(const char* commandLine)
{
TCHAR tcommandLine[_MAX_FNAME];
#ifdef UNICODE
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, commandLine, strlen(commandLine)+1, tcommandLine, _MAX_FNAME-1 );
#else
strcpy_s( tstring, string );
#endif
m_commandText.Format( _T("%s"), tcommandLine );
}
void BaseCommand::AddString( const char* string, int len )
{
TCHAR tstring[_MAX_FNAME];
CString temp;
#ifdef UNICODE
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, string, len, tstring, _MAX_FNAME-1 );
tstring[len] = 0;
#else
strcpy_s( tstring, string );
#endif
temp.Format( _T("%s"), tstring );
m_strings.push_back( temp );
}
CServerDialog* BaseCommand::GetDialog(int index)
{
CServerDialog* dlg = m_launcher->GetTabDialog(index);
if(dlg)
{
m_launcher->m_serverTabs.UserFocus(index);
}
return dlg;
}
int BaseCommand::GetDialogCount()
{
return m_launcher->GetTabDialogCount();
}
@@ -0,0 +1,66 @@
#pragma once
#include <vector>
#include "BatchCompileDefine.h"
class CLS_launcherDlg;
class CServerDialog;
class BaseCommand
{
public:
BaseCommand(DWORD type);
virtual ~BaseCommand(void);
private:
void Init();
void Destroy();
public:
BOOL Execute();
BOOL CheckContinue();
BOOL IsValid();
void SetOption( DWORD optionBit );
void SetCommandText(const char* commandLine);
protected:
virtual BOOL ExecuteServiceAll(CServerDialog* dialog) = 0;
virtual BOOL ExecuteServiceOne(CServerDialog* dialog) = 0;
virtual BOOL CheckContinueServiceAll(CServerDialog* dialog) = 0;
virtual BOOL CheckContinueServiceOne(CServerDialog* dialog) = 0;
virtual BOOL IsValidDetail() = 0;
public:
DWORD GetType() { return m_commandType; }
void SetLauncher( CLS_launcherDlg* launcher ) { m_launcher = launcher; }
void AddIndex( int index ) { m_tabIndexes.push_back( index ); }
void AddString( const char* string, int len );
CServerDialog* GetDialog(int index);
int GetDialogCount();
DWORD GetState() { return m_state; }
DWORD GetError() { return m_error; }
CString GetCommand() { return m_commandText; }
protected:
const DWORD m_commandType;
CString m_commandText;
CLS_launcherDlg* m_launcher;
VECINT m_tabIndexes;
VECCSTRING m_strings;
BOOL m_isWait;
BOOL m_isServiceAll;
BOOL m_isApplyAll;
DWORD m_state;
DWORD m_error;
};
@@ -0,0 +1,130 @@
#include "stdafx.h"
#include "Batch.h"
#include "BatchManager.h"
#include "BatchScanner.h"
Batch::Batch(void)
{
Init();
}
Batch::~Batch(void)
{
Destroy();
}
void Batch::Init()
{
m_commands.reserve( 32 );
m_currentIndex = 0;
}
void Batch::Destroy()
{
for( unsigned i = 0 ; i < m_commands.size() ; i++ )
{
if( m_commands[i] )
{
delete m_commands[i];
}
}
m_commands.clear();
}
BOOL Batch::OpenFile( TCHAR* fileName )
{
return m_file.OpenFile( fileName );
}
BOOL Batch::ScanProcess( BatchScanner* scanner, CLS_launcherDlg* launcher )
{
if( NULL == scanner )
return FALSE;
char line[_MAX_FNAME];
while( true )
{
if( !m_file.GetLine( line, _MAX_FNAME ) )
{
break;
}
BaseCommand* command = scanner->Scanner(line);
if( !command )
{
Destroy();
return FALSE;
}
command->SetLauncher( launcher );
if( !command->IsValid() )
{
delete command;
command = NULL;
Destroy();
return FALSE;
}
m_commands.push_back( command );
}
if( m_commands.empty() )
return FALSE;
return TRUE;
}
BOOL Batch::Execute(CBatchManager* batchManager)
{
if( m_commands.empty() )
return FALSE;
for( m_currentIndex ; m_currentIndex < m_commands.size() ; m_currentIndex++ )
{
BaseCommand* command = m_commands[m_currentIndex];
if( !command ) continue;
int index = 0;
batchManager->BeginProgress(command->GetCommand(), 0, _T("..."));
if(batchManager->IsConsoleMode())
_tprintf(command->GetCommand());
if( !command->Execute() )
{
return FALSE;
}
batchManager->EndProgress( 100, _T("completed"),FALSE);
}
return TRUE;
}
BOOL Batch::CheckContinue()
{
if( m_commands.empty() )
return FALSE;
if( m_currentIndex >= m_commands.size() )
return FALSE;
return m_commands[m_currentIndex]->CheckContinue();
}
BOOL Batch::Next()
{
m_currentIndex++;
if( m_currentIndex >= m_commands.size() )
return FALSE;
return TRUE;
}
DWORD Batch::GetCurrentState()
{
if( m_currentIndex >= m_commands.size() )
return CST_UNKNOWN_COMMAND;
return m_commands[m_currentIndex]->GetState();
}
@@ -0,0 +1,44 @@
#pragma once
#include <vector>
#include "BatchCompileDefine.h"
#include "FileReader.h"
class BatchScanner;
class CLS_launcherDlg;
class BaseCommand;
class CBatchManager;
using namespace std;
class Batch
{
public:
typedef vector<BaseCommand*> VECCOMMANDS;
public:
Batch(void);
~Batch(void);
private:
void Init();
void Destroy();
public:
BOOL OpenFile( TCHAR* fileName );
BOOL ScanProcess( BatchScanner* scanner, CLS_launcherDlg* launcher );
BOOL Execute(CBatchManager* batchManager);
BOOL CheckContinue();
BOOL Next();
public:
void ResetExecute() { m_currentIndex = 0; }
DWORD GetCurrentState();
private:
FileReader m_file;
VECCOMMANDS m_commands;
UINT m_currentIndex;
};
@@ -0,0 +1,79 @@
#pragma once
#define MAX_TOKEN_BUFFER_SIZE 32
#define TOKEN_SPLIT_CHAR _T(' ')
enum BatchCommandType
{
BCT_NONE = -1,
BCT_PLAY = 0,
BCT_STOP,
BCT_SYNC,
BCT_INSTALL,
BCT_UNINSTALL,
BCT_BACKUP,
BCT_REMOVE,
BCT_WAIT,
BCT_QUIT,
BCT_END,
};
enum BatchOptionType
{
BOT_SERVICE_WAIT = 0,
BOT_ALL_SERVICE,
//BOT_WATCHDOG,
//BOT_APPLYALL,
//BOT_RECURSIVE,
// 여기까지 비트처리 옵션들
//====================
// 여기부터 기타 옵션들
BOT_TABINDEX,
BOT_END,
};
enum CommandStateType
{
CST_NONE = 0,
CST_BEFORE_EXCUTE,
CST_WAITING,
CST_EXCUTE_DONE,
CST_FAIL,
CST_SYNC_CHECK,
CST_ALREADY_EXCUTE,
CST_UNKNOWN_COMMAND, // 나와선 안될 오류
CST_END,
};
enum CommandErrorType
{
CET_NONE = 0,
CET_NOERROR,
CET_WRONG_COMMAND_LINE, // 명령어 잘못됨
CET_WRONG_NO_LAUNCHER, // 런쳐 없음 - 나와선 안될 오류
// common Error
CET_ERROR_NO_COMMAND, // 커맨드 없음
CET_ERROR_NO_SERVICENAME, // 서비스 이름 없음
CET_ERROR_WRONG_COMMAND, // 잘못된 명령어
CET_ERROR_WRONG_SERVICENAME, // 잘못된 서비스 이름
CET_ERROR_WRONG_TABINDEX, // 잘못된 탭인덱스
CET_ERROR_NO_NEED_SERVICENAME, // '/a' 옵션과 서비스 이름 중첩
// Play Error
// Stop Error
// Uninstall Error
// Install Error
CET_ERROR_INSTALL_NO_INIFILE,
CET_ERROR_INSTALL_NO_EXEFILE,
// Sync Error
CET_END
};
#define BITON(x, y) ( x |= (1 << y) )
#define BITOFF(x, y) ( x &= !(1 << y ) )
#define BITCHK(x, y) ( x & (1 << y) )
typedef std::vector<int> VECINT;
typedef std::vector<CString> VECCSTRING;
@@ -0,0 +1,231 @@
#include "StdAfx.h"
#include "Batch.h"
#include "../resource.h"
#include "../BatchDialog.h"
#include "BatchManager.h"
CBatchManager::CBatchManager(void) : m_currentIndex(0), m_batchDlg(NULL), m_current(0), m_elapse(0), m_beginTime(0)
{
Init();
}
CBatchManager::~CBatchManager(void)
{
Destroy();
}
void CBatchManager::Init()
{
m_batchs.reserve( 32 );
if(!m_batchDlg)
{
m_batchDlg = new CBatchDialog();
m_batchDlg->Create(IDD_BATCH_DIALOG, NULL);
m_batchDlg->SetWindowPos(&m_batchDlg->wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
m_consoleMode = FALSE;
}
}
void CBatchManager::Destroy()
{
for( unsigned i = 0 ; i < m_batchs.size() ; i++ )
{
if( m_batchs[i] )
{
delete m_batchs[i];
}
}
m_batchs.clear();
}
void CBatchManager::ShowDialog()
{
if(m_batchDlg)
{
CString log;
log.Format(_T("Elapsed : %lu s"), 0);
m_batchDlg->UpdateBatchResult(log);
m_batchDlg->CenterWindow();
m_batchDlg->ShowWindow(SW_SHOW);
}
}
void CBatchManager::End()
{
}
BOOL CBatchManager::AddBatchFile( TCHAR* batchFileName, CLS_launcherDlg* launcher )
{
CString checkNull = batchFileName;
if(checkNull.IsEmpty())
return FALSE;
Batch* batch = new Batch;
if( !batch->OpenFile( batchFileName ) )
{
delete batch;
Error(_T("File open"), _T("failed"), TRUE);
return FALSE;
}
if( !batch->ScanProcess( &m_Scanner, launcher ) )
{
delete batch;
Error(_T("Command parsing"), _T("failed"));
return FALSE;
}
m_batchs.push_back( batch );
return TRUE;
}
BOOL CBatchManager::Execute()
{
if( m_batchs.empty() )
return FALSE;
if( m_currentIndex >= m_batchs.size() )
return TRUE;
for( m_currentIndex ; m_currentIndex < m_batchs.size() ; m_currentIndex++ )
{
Batch *batch = m_batchs[m_currentIndex];
if( !batch ) continue;
if( !batch->Execute(this) )
{
return FALSE;
}
}
return TRUE;
}
BOOL CBatchManager::CheckContinue()
{
if( m_batchs.empty() )
return FALSE;
if( m_currentIndex >= m_batchs.size() )
return FALSE;
return m_batchs[m_currentIndex]->CheckContinue();
}
BOOL CBatchManager::Next()
{
if( m_currentIndex >= m_batchs.size() )
return FALSE;
if( !m_batchs[m_currentIndex]->Next() )
{
m_currentIndex++;
if( m_currentIndex >= m_batchs.size() )
return FALSE;
}
return TRUE;
}
BOOL CBatchManager::HaveBaches()
{
if(m_batchs.size() > 0) return TRUE;
return FALSE;
}
int CBatchManager::BeginProgress(const TCHAR* title, const int progress, const TCHAR* result)
{
m_beginTime = GetTickCount();
m_batchDlg->BeginProgress(title, progress, result, m_current);
return m_current;
}
void CBatchManager::DoingProgress(const int progress)
{
m_batchDlg->DoingProgress(m_current, progress);
}
void CBatchManager::ShowExecuteResult(const TCHAR* result, BOOL quit)
{
if(IsConsoleMode())
{
_tprintf(_T("\t\t %s \n"), result);
}
}
void CBatchManager::EndProgress(const int progress, const TCHAR* result, BOOL quit)
{
DWORD elapse = GetTickCount() - m_beginTime;
m_elapse += elapse;
CString log;
log.Format(_T("Elapsed : %0.2lf s"), (double)m_elapse / 1000.0);
m_batchDlg->EndProgress(m_current, progress, result);
m_batchDlg->UpdateBatchResult(log);
ShowExecuteResult(result, quit);
}
void CBatchManager::EndProgress(const int progress, const TCHAR* result)
{
DWORD elapse = GetTickCount() - m_beginTime;
m_elapse += elapse;
CString log;
log.Format(_T("Elapsed : %0.2lf s"), (double)m_elapse / 1000.0);
m_batchDlg->EndProgress(m_current, progress, result);
m_batchDlg->UpdateBatchResult(log);
}
void CBatchManager::Error(const TCHAR* title, const TCHAR* result, BOOL quit)
{
BeginProgress(title, 0, result);
EndProgress(0, result);
if(IsConsoleMode())
{
_tprintf(_T("%s %s \n"), title, result);
}
else
ShowDialog();
}
void CBatchManager::ResetExecute()
{
for( UINT i = 0 ; i < m_batchs.size() ; i ++ )
{
Batch* batch = m_batchs[i];
if( !batch ) continue;
batch->ResetExecute();
}
m_currentIndex = 0;
}
DWORD CBatchManager::GetCurrentState()
{
if( m_currentIndex >= m_batchs.size() )
return CST_UNKNOWN_COMMAND;
return m_batchs[m_currentIndex]->GetCurrentState();
}
void CBatchManager::SetConsoleMode(BOOL mode)
{
m_consoleMode = mode;
}
BOOL CBatchManager::IsConsoleMode()
{
return m_consoleMode;
}
@@ -0,0 +1,61 @@
#pragma once
#include "BatchScanner.h"
class Batch;
class CLS_launcherDlg;
class CBatchDialog;
using namespace std;
class CBatchManager
{
public:
typedef vector<Batch*> BATCHES;
public:
CBatchManager(void);
~CBatchManager(void);
private:
void Init();
void Destroy();
public:
void ShowDialog();
void End();
public:
BOOL AddBatchFile( TCHAR* batchFileName, CLS_launcherDlg* launcher );
BOOL Execute();
BOOL CheckContinue();
BOOL Next();
BOOL HaveBaches();
public:
int BeginProgress(const TCHAR* title, const int progress, const TCHAR* result);
void DoingProgress(const int progress);
void EndProgress(const int progress, const TCHAR* result);
void EndProgress(const int progress, const TCHAR* result, BOOL quit);
void Error(const TCHAR* title, const TCHAR* result, BOOL quit=NULL);
public:
void ResetExecute();
DWORD GetCurrentState();
void SetConsoleMode(BOOL mode);
BOOL IsConsoleMode();
void ShowExecuteResult(const TCHAR* result, BOOL quit);
protected:
BatchScanner m_Scanner;
BATCHES m_batchs;
UINT m_currentIndex;
CBatchDialog* m_batchDlg;
int m_current;
int m_elapse;
DWORD m_beginTime;
BOOL m_consoleMode;
};
@@ -0,0 +1,370 @@
#include "StdAfx.h"
#include "BatchScanner.h"
#include "PlayCommand.h"
#include "StopCommand.h"
#include "SyncCommand.h"
#include "QuitCommand.h"
#include "InstallCommand.h"
#include "UninstallCommand.h"
BatchScanner::BatchScanner(void)
{
Init();
}
BatchScanner::~BatchScanner(void)
{
Destroy();
}
void BatchScanner::Init()
{
InitCommand();
InitOption();
}
void BatchScanner::Destroy()
{
}
void BatchScanner::InitCommand()
{
strcpy_s(m_commandTokens[BCT_PLAY], "play" );
strcpy_s(m_commandTokens[BCT_STOP], "stop");
strcpy_s(m_commandTokens[BCT_SYNC], "sync");
strcpy_s(m_commandTokens[BCT_INSTALL], "install");
strcpy_s(m_commandTokens[BCT_UNINSTALL],"uninstall");
strcpy_s(m_commandTokens[BCT_BACKUP], "backup");
strcpy_s(m_commandTokens[BCT_REMOVE], "remove");
strcpy_s(m_commandTokens[BCT_WAIT], "wait");
strcpy_s(m_commandTokens[BCT_QUIT], "quit");
}
void BatchScanner::InitOption()
{
strcpy_s(m_optionTokens[BOT_SERVICE_WAIT], "/w");
strcpy_s(m_optionTokens[BOT_ALL_SERVICE], "/a");
strcpy_s(m_optionTokens[BOT_TABINDEX], "/t");
}
BaseCommand* BatchScanner::Scanner( const char* commandLine )
{
if( !commandLine )
return NULL;
int commandLen = strlen(commandLine);
if( 0 == commandLen ) return NULL;
VECCHARTOKEN tokens;
if( SplitToken( commandLine, commandLen, tokens ) )
{
return MakeCommand( tokens );
}
return NULL;
}
BOOL BatchScanner::SplitToken( const char* commandLine, int commandLen, VECCHARTOKEN& tokens )
{
if( !commandLine || strlen(commandLine) == 0 )
{
return FALSE;
}
int index = -1;
do
{
JumpSplitChar( commandLine, commandLen, index ); //공백을 제외한 첫글자 위치를 index에 넣어줌.
if( commandLine[index] == NULL)
{
break;
}
tokens.push_back( &commandLine[index] ); //첫 문자열을 집어넣음.
FindSplitChar(commandLine, commandLen, index ); //공백을 만날때 까지 index ++;
}while(commandLine[index] != NULL); //배치 파일의 글자 시작 index를 VECCHARTOKEN에 push
if( tokens.size() < 1 )
{
return FALSE;
}
return TRUE;
}
void BatchScanner::JumpSplitChar( const char* commandLine, int commandLen, int& index )
{
while( (TOKEN_SPLIT_CHAR == commandLine[++index]) && (commandLen >= index) )
{
}
}
void BatchScanner::FindSplitChar( const char* commandLine, int commandLen, int& index )
{
while( (TOKEN_SPLIT_CHAR != commandLine[++index]) && (commandLen >= index ) )
{
if( NULL == commandLine[index] )
break;
}
}
BaseCommand* BatchScanner::MakeCommand( VECCHARTOKEN& tokens )
{
if( tokens.size() < 1 )
return NULL;
DWORD commandType = BCT_NONE; //CommandState()를 통해 play,stop 같은 커멘트 타입이 정해짐.
DWORD optionBit = 0;
SETINDEXES tabIndexes;
SETINDEXES stringIndexes;
int index = 0;
CommandStateType state = CS_COMMAND; //배치파일 처음은 play stop 같은 commend임,
while( (CS_DONE != state) && (CS_FAIL != state) )
{
if( (unsigned int)index >= tokens.size() )
{
state = CS_DONE;
}
switch(state)
{
case CS_COMMAND:
{
state = CommandState( tokens[index], commandType );
index++;
}
break;
case CS_OPTION:
{
state = OptionState( tokens[index], optionBit );
if( CS_STRING != state ) // 서비스네임이라면 인덱스 증가 시키면 안됨
{
index++;
}
}
break;
case CS_TABINDEX:
{
state = TabIndexState( tokens[index], tabIndexes );
if( CS_TABINDEX == state )
{
index++;
}
}
break;
case CS_STRING:
{
stringIndexes.insert( index );
state = CS_OPTION;
index++;
}
break;
case CS_DONE:
{
}
break;
default:
break;
}
}
if( CS_FAIL == state )
{
return NULL;
}
//분리한 각 코맨드 및 문자들 처리./////////////////
BaseCommand* command = GetCommand( commandType );
command->SetCommandText( tokens[0] );
command->SetOption( optionBit );
for( INDEXESITER it = tabIndexes.begin() ; it != tabIndexes.end() ; ++it )
{
int tabIndex = *it;
command->AddIndex( tabIndex );
}
for( INDEXESITER it = stringIndexes.begin() ; it != stringIndexes.end() ; ++it )
{
int stringIndex = *it;
command->AddString( tokens[stringIndex], GetServiceNameLen( tokens[stringIndex] ) );
}
return command; //batchCommand;
}
BaseCommand* BatchScanner::GetCommand( DWORD type )
{
BaseCommand* command = NULL;
switch( type )
{
case BCT_PLAY:
command = new PlayCommand;
break;
case BCT_STOP:
command = new StopCommand;
break;
case BCT_SYNC:
command = new SyncCommand;
break;
case BCT_INSTALL:
command = new InstallCommand;
break;
case BCT_UNINSTALL:
command = new UninstallCommand;
break;
case BCT_QUIT:
command = new QuitCommand;
break;
case BCT_BACKUP:
case BCT_REMOVE:
case BCT_WAIT:
default:
break;
}
return command;
}
BatchScanner::CommandStateType BatchScanner::CommandState( const char* command, DWORD& commandType )
{
commandType = GetCommandType( command );
if( BCT_END == commandType )
{
return CS_FAIL;
}
else
{
return CS_OPTION;
}
}
BatchScanner::CommandStateType BatchScanner::OptionState( const char* command, DWORD& optionBit )
{
DWORD option = GetOptionType( command );
if( BOT_END == option )
{
return CS_STRING;
}
else if( BOT_TABINDEX == option )
{
return CS_TABINDEX;
}
else
{
if( BITCHK( optionBit, option ) )
{
return CS_FAIL;
}
else
{
BITON( optionBit, option ); // /w (optionBit == 1), /a (potionBit == 5)
return CS_OPTION;
}
}
}
BatchScanner::CommandStateType BatchScanner::TabIndexState( const char* command, SETINDEXES& tabIndexes )
{
DWORD digit;
if( GetDigit( command, digit ) )
{
tabIndexes.insert( digit );
return CS_TABINDEX;
}
return CS_OPTION;
}
int BatchScanner::GetCommandType( const char* command )
{
int type = 0;
for( type ; type < BCT_END ; type++ )
{
if( TokenCompare( m_commandTokens[type], command ) )
{
break;
}
}
return type;
}
int BatchScanner::GetOptionType( const char* command )
{
unsigned int type = 0;
for( type ; type < BOT_END ; type++ )
{
if( TokenCompare( m_optionTokens[type], command ) )
{
break;
}
}
return type;
}
BOOL BatchScanner::GetDigit( const char* command, DWORD& digit )
{
digit = 0;
char ch = 0;
while( true )
{
ch = *command;
if( IsDigit( ch ) )
{
digit = digit*10 + ( ch - '0' );
command++;
}
else
{
break;
}
}
if( (TOKEN_SPLIT_CHAR == ch) || (NULL == ch) )
{
return TRUE;
}
return FALSE;
}
BOOL BatchScanner::TokenCompare( const char* token, const char* command )
{
//미리 저장해둔 명령어 비교.
unsigned int tokenLen = strlen(token);
if( strlen(command) < tokenLen )
{
return FALSE;
}
if( strncmp( token, command, tokenLen ) == 0)
{
if( (TOKEN_SPLIT_CHAR == command[tokenLen]) ||
(NULL == command[tokenLen]) )
{
return TRUE;
}
}
return FALSE;
}
int BatchScanner::GetServiceNameLen( const char* serviceName )
{
int len = 0;
while(true)
{
if( (TOKEN_SPLIT_CHAR == serviceName[len]) ||
(NULL == serviceName[len]) )
{
break;
}
len++;
}
return len;
}
@@ -0,0 +1,66 @@
#pragma once
#include <vector>
#include <set>
#include "BatchCompileDefine.h"
#include "BaseCommand.h"
class BatchScanner
{
public:
typedef std::vector<const char*> VECCHARTOKEN;
typedef std::set<int> SETINDEXES;
typedef SETINDEXES::iterator INDEXESITER;
enum CommandStateType
{
CS_COMMAND,
CS_OPTION,
CS_TABINDEX,
CS_STRING,
CS_DONE,
CS_FAIL,
CS_END
};
public:
BatchScanner(void);
~BatchScanner(void);
private:
void Init();
void Destroy();
void InitCommand();
void InitOption();
public:
// virtual ??
BaseCommand* Scanner( const char* commandLine );
private:
BOOL SplitToken( const char* commandLine, int commandLen, VECCHARTOKEN& tokens );
void JumpSplitChar( const char* commandLine, int commandLen, int& index );
void FindSplitChar( const char* commandLine, int commandLen, int& index );
private:
BaseCommand* MakeCommand( VECCHARTOKEN& tokens );
BaseCommand* GetCommand( DWORD type );
CommandStateType CommandState( const char* command, DWORD& commandType );
CommandStateType OptionState( const char* command, DWORD& optionBit );
CommandStateType TabIndexState( const char* command, SETINDEXES& tabIndexes );
int GetCommandType( const char* command );
int GetOptionType( const char* command );
BOOL GetDigit( const char* command, DWORD& digit );
BOOL IsDigit( const char ch ) { return ( ('0' <= ch) && ( ch <= '9') ); }
BOOL TokenCompare( const char* token, const char* command );
int GetServiceNameLen( const char* serviceName );
private:
char m_commandTokens[BCT_END][MAX_TOKEN_BUFFER_SIZE];
char m_optionTokens[BOT_END][MAX_TOKEN_BUFFER_SIZE];
};
@@ -0,0 +1,150 @@
#ifndef _MEMDC_H_
#define _MEMDC_H_
#include <afxwin.h>
////////////////////////////////////////////////////////////////////////////////
// CUserMemDC - memory DC
//
// Author: Keith Rule
// Email: [email protected]
// Copyright 1996-2002, Keith Rule
//
// You may freely use or modify this code provided this
// copyright is included in all derived versions.
//
// History - 10/03/97 Fixed scrolling bug.
// Added print support. - KR
//
// 11/03/99 Fixed most common complaint. Added
// background color fill. - KR
//
// 11/03/99 Added support for mapping modes other than
// MM_TEXT as suggested by Lee Sang Hun. - KR
//
// 02/11/02 Added support for CScrollView as supplied
// by Gary Kirkham. - KR
//
// 04/19/06 Modified background fill to try and use
// correct background brush/color - AGB
//
// This class implements a memory device context which allows
// flicker free drawing.
////////////////////////////////////////////////////////////////////////////////
class CUserMemDC : public CDC
{
private:
BOOL m_bMemDC; // TRUE if not printing
CBitmap m_MemBitmap; // offscreen bitmap
CBitmap* m_pOldBitmap; // original bitmap
CDC* m_pDC; // saves CDC passed in constructor
CRect m_rect; // rectangle of drawing area
public:
// constructor sets up the memory DC
CUserMemDC(CDC* pDC, const CRect* pRect = NULL) : CDC()
{
// make sure the call provided a valid device context
ASSERT(pDC != NULL);
// save the original device context for later BitBlt()
m_pDC = pDC;
// check whether we're printing
m_bMemDC = !pDC->IsPrinting();
// get the output rectangle
if (pRect == NULL)
pDC->GetClipBox(&m_rect);
else
m_rect = *pRect;
if (m_bMemDC)
{
// do the memory DC stuff if not printing
// create a memory DC
CreateCompatibleDC(pDC);
// create new bitmap and save old bitmap
pDC->LPtoDP(&m_rect);
m_MemBitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_pOldBitmap = SelectObject(&m_MemBitmap);
SetMapMode(pDC->GetMapMode());
SetWindowExt(pDC->GetWindowExt());
SetViewportExt(pDC->GetViewportExt());
pDC->DPtoLP(&m_rect);
// set window origin
SetWindowOrg(m_rect.left, m_rect.top);
}
else
{
// make a copy of the relevant parts of the original DC for printing
m_bPrinting = pDC->m_bPrinting;
m_hDC = pDC->m_hDC;
m_hAttribDC = pDC->m_hAttribDC;
}
// fill background
CWnd* pWnd = pDC->GetWindow();
HWND hWnd = NULL;
if (pWnd != NULL)
{
hWnd = pWnd->m_hWnd;
if (hWnd != NULL)
{
if (GetClassLongPtr(hWnd, GCW_ATOM) == 32770)
{
// if window is a dialog box, use dialog background color
FillSolidRect(m_rect, GetSysColor(COLOR_BTNFACE));
}
else
{
// try to get background brush for window class
ULONG_PTR ulpBrush = GetClassLongPtr(hWnd, GCLP_HBRBACKGROUND);
if (ulpBrush)
{
// fill with class background brush
FillRect(m_rect, CBrush::FromHandle((HBRUSH)ulpBrush));
}
else
hWnd = NULL;
}
}
}
if (hWnd == NULL)
FillSolidRect(m_rect, pDC->GetBkColor());
}
// destructor copies the contents of the memory DC to the original DC
~CUserMemDC()
{
if (m_bMemDC)
{
// copy the offscreen bitmap onto the screen
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);
// restore the original bitmap
m_pDC->SelectObject(m_pOldBitmap);
}
else
{
// all we need to do is replace the DC with an illegal value,
// this keeps us from accidently deleting the handles associated
// with the CDC that was passed to the constructor
m_hDC = m_hAttribDC = NULL;
}
}
// allow usage as a pointer
CUserMemDC* operator->() { return this; }
// allow usage as a pointer
operator CUserMemDC*() { return this; }
};
#endif //#ifndef _MEMDC_H_
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,75 @@
#include "StdAfx.h"
#include "FileReader.h"
FileReader::FileReader(void)
{
Init();
}
FileReader::~FileReader(void)
{
Destroy();
}
void FileReader::Init()
{
m_readFile.clear();
}
void FileReader::Destroy()
{
if( m_readFile.is_open() )
{
m_readFile.close();
}
}
BOOL FileReader::OpenFile( TCHAR* fileName )
{
if( _tcslen( fileName ) >= _MAX_FNAME )
{
return FALSE;
}
#ifdef UNICODE
char _fileName[_MAX_FNAME];
int ret = WideCharToMultiByte( CP_ACP, 0, fileName, _tcslen( fileName ), _fileName, sizeof(_fileName), NULL, NULL );
_fileName[ret] = 0;
m_readFile.open( _fileName, ios::in );
#else
m_readFile.open( fileName, ios::in );
#endif
if( !m_readFile.is_open() )
{
return FALSE;
}
return TRUE;
}
BOOL FileReader::GetLine( char* line, int len )
{
/*if( !m_readFile.is_open() || m_readFile.eof() )
{
return FALSE;
}*/
m_readFile.getline( line, len );
if( 0 == strlen(line ) )
{
if( m_readFile.eof() )
{
return FALSE;
}
else
{
return GetLine( line, len );
}
}
return TRUE;
}
@@ -0,0 +1,25 @@
#pragma once
#include <fstream>
using namespace std;
class FileReader
{
public:
FileReader(void);
~FileReader(void);
private:
void Init();
void Destroy();
public:
BOOL OpenFile( TCHAR* fileName );
BOOL GetLine( char* line, int len );
private:
TCHAR m_fileName[_MAX_FNAME];
ifstream m_readFile;
};
@@ -0,0 +1,81 @@
#include "StdAfx.h"
#include "InstallCommand.h"
#include "../resource.h"
#include "../LS_launcherDlg.h"
#include "../ServerDialog.h"
#include "../cFile.h"
InstallCommand::InstallCommand(): BaseCommand(BCT_INSTALL)
{
}
InstallCommand::~InstallCommand()
{
}
BOOL InstallCommand::ExecuteServiceAll(CServerDialog* dialog)
{
return ExecuteServiceOne(dialog);
}
BOOL InstallCommand::ExecuteServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
// ÀÌ¹Ì ¼³Ä¡µÆ´Ù¸é?
if( CheckContinueServiceOne( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandInstall( m_strings[0], m_strings[1], m_strings[2] ) )
{
return FALSE;
}
return TRUE;
}
BOOL InstallCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
return CheckContinueServiceOne(dialog);
}
BOOL InstallCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
int index = dialog->FindServiceIndex( m_strings[0] );
if( index == -1 )
{
return FALSE;
}
return TRUE;
}
BOOL InstallCommand::IsValidDetail()
{
if( m_strings.size() != 3 )
return FALSE;
cFileReader exeFile;
if( !exeFile.Open( m_strings[1].GetBuffer() ) )
{
return FALSE;
}
exeFile.Close();
cFileReader iniFile;
if( !iniFile.Open( m_strings[2].GetBuffer() ) )
{
return FALSE;
}
iniFile.Close();
return TRUE;
}
@@ -0,0 +1,19 @@
#pragma once
#include "BaseCommand.h"
class InstallCommand
: public BaseCommand
{
public:
InstallCommand();
~InstallCommand();
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
};
@@ -0,0 +1,173 @@
// ListCtrlEx.cpp : implementation file
//
#include "stdafx.h"
#include "ListCtrlEx.h"
#include <tchar.h>
// CListCtrlEx
IMPLEMENT_DYNAMIC(CListCtrlEx, CListCtrl)
CListCtrlEx::CListCtrlEx() : m_ProgressColumn(0)
{
m_progress = NULL;
}
CListCtrlEx::~CListCtrlEx()
{
}
BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl)
ON_WM_PAINT()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
END_MESSAGE_MAP()
// CListCtrlEx message handlers
void CListCtrlEx::OnPaint()
{
// TODO: Add your message handler code here
// Do not call CListCtrl::OnPaint() for painting messages
int Top=GetTopIndex();
int Total=GetItemCount();
int PerPage=GetCountPerPage();
int LastItem=((Top+PerPage)>Total)?Total:Top+PerPage;
CHeaderCtrl* pHeader=GetHeaderCtrl();
POSITION pos = m_ProgressList.GetHeadPosition();
for(int i=Top;i<LastItem;i++)
{
if(pos != NULL)
{
CTextProgressCtrl* progress = m_ProgressList.GetAt(pos);
CRect ColRt;
pHeader->GetItemRect(m_ProgressColumn,&ColRt);
// get the rect
CString Data=GetItemText(i,m_ProgressColumn);
//SetItemText(i,m_ProgressColumn,_T(""));
CRect rt;
GetItemRect(i,&rt,LVIR_BOUNDS);
rt.top+=1;
rt.bottom-=1;
rt.right -= 10;
rt.left+=ColRt.left;
int Width=ColRt.Width() ;
rt.right=rt.left+Width-4;
int Percent=_ttoi(Data.GetBuffer());
// set the position on the control
progress->MoveWindow(rt);
progress->SetPos(Percent);
progress->ShowWindow(SW_SHOWNORMAL);
m_ProgressList.GetNext(pos);
}
}
CListCtrl::OnPaint();
}
void CListCtrlEx::InitProgressColumn(int ColNum/*=0*/)
{
m_ProgressColumn=ColNum;
// create the progress control and set their position
}
int CListCtrlEx::InsertItem( _In_ const LVITEM* pItem )
{
m_ProgressList.AddTail(CreateProgress());
return CListCtrl::InsertItem(pItem);
}
int CListCtrlEx::InsertItem( _In_ int nItem, _In_z_ LPCTSTR lpszItem )
{
m_ProgressList.AddTail(CreateProgress());
return CListCtrl::InsertItem(nItem,lpszItem);
}
int CListCtrlEx::InsertItem( _In_ int nItem, _In_z_ LPCTSTR lpszItem, _In_ int nImage )
{
m_ProgressList.AddTail(CreateProgress());
return CListCtrl::InsertItem(nItem,lpszItem,nImage);
}
BOOL CListCtrlEx::SetItemText( _In_ int nItem, _In_ int nSubItem, _In_z_ LPCTSTR lpszText )
{
return CListCtrl::SetItemText(nItem,nSubItem,lpszText);
}
BOOL CListCtrlEx::DeleteItem( _In_ int nItem )
{
CTextProgressCtrl* progress = m_ProgressList.RemoveTail();
delete progress;
return CListCtrl::DeleteItem(nItem);
}
BOOL CListCtrlEx::DeleteAllItems()
{
POSITION pos = m_ProgressList.GetHeadPosition();
while(pos)
{
CTextProgressCtrl* progress = m_ProgressList.GetAt(pos);
delete progress;
m_ProgressList.GetNext(pos);
}
m_ProgressList.RemoveAll();
return CListCtrl::DeleteAllItems();
}
CTextProgressCtrl* CListCtrlEx::CreateProgress()
{
CTextProgressCtrl* pControl=new CTextProgressCtrl();
CRect rt;
pControl->Create(NULL,rt,this,IDC_PROGRESS_LIST+ m_ProgressList.GetCount());
pControl->ShowWindow(SW_HIDE);
return pControl;
}
#if 0
void CListCtrlEx::SetProgressRange( int progressIndex, int min, int max )
{
if(m_ProgressList.GetSize() < progressIndex)
{
CProgressCtrl* progress = m_ProgressList.GetAt(progressIndex);
}
}
#endif
void CListCtrlEx::OnSetFocus(CWnd* pOldWnd)
{
CListCtrl::OnSetFocus(pOldWnd);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
}
void CListCtrlEx::OnKillFocus(CWnd* pNewWnd)
{
CListCtrl::OnKillFocus(pNewWnd);
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
}
@@ -0,0 +1,47 @@
#pragma once
#include "TextProgressCtrl.h"
#include <atlcoll.h>
// CListCtrlEx
#define IDC_PROGRESS_LIST WM_USER
class CListCtrlEx : public CListCtrl
{
DECLARE_DYNAMIC(CListCtrlEx)
// the array of the Progress Controls in the list control
ATL::CAtlList<CTextProgressCtrl*> m_ProgressList;
// the column which should contain the progress bars
int m_ProgressColumn;
public:
CListCtrlEx();
virtual ~CListCtrlEx();
public:
// initialize the column containing the bars
void InitProgressColumn(int ColNum=0);
//void SetProgressRange( int progressIndex, int min, int max ); NotWorking
public:
int InsertItem(_In_ const LVITEM* pItem);
int InsertItem(_In_ int nItem, _In_z_ LPCTSTR lpszItem);
int InsertItem(_In_ int nItem, _In_z_ LPCTSTR lpszItem, _In_ int nImage);
BOOL SetItemText(_In_ int nItem, _In_ int nSubItem, _In_z_ LPCTSTR lpszText);
BOOL DeleteItem(_In_ int nItem);
BOOL DeleteAllItems();
protected:
CTextProgressCtrl* CreateProgress();
protected:
CTextProgressCtrl* m_progress;
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
};
@@ -0,0 +1,99 @@
#include "StdAfx.h"
#include "PlayCommand.h"
#include "../resource.h"
#include "../LS_launcherDlg.h"
#include "../ServerDialog.h"
PlayCommand::PlayCommand() : BaseCommand(BCT_PLAY)
{
}
PlayCommand::~PlayCommand()
{
}
BOOL PlayCommand::ExecuteServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceAll( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandPlayAll() )
{
return FALSE;
}
return TRUE;
}
BOOL PlayCommand::ExecuteServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceOne( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandPlay( m_strings[0] ) )
{
return FALSE;
}
return TRUE;
}
BOOL PlayCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
int serviceCount = dialog->GetServiceCount();
for( int index = 0; index < serviceCount ; index ++ )
{
if( !dialog->IsServiceOn(index) )
{
return FALSE;
}
}
return TRUE;
}
BOOL PlayCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( !dialog->IsServiceOn(m_strings[0]) )
{
return FALSE;
}
return TRUE;
}
BOOL PlayCommand::IsValidDetail()
{
if( m_isServiceAll )
{
if( !m_strings.empty() )
return FALSE;
}
else
{
if( m_strings.size() != 1 )
return FALSE;
}
return TRUE;
}
@@ -0,0 +1,18 @@
#pragma once
#include "BaseCommand.h"
class PlayCommand : public BaseCommand
{
public:
PlayCommand();
~PlayCommand();
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
};
@@ -0,0 +1,40 @@
#include "StdAfx.h"
#include "QuitCommand.h"
#include "../resource.h"
#include "../ServerDialog.h"
QuitCommand::QuitCommand(): BaseCommand(BCT_QUIT)
{
}
QuitCommand::~QuitCommand()
{
}
BOOL QuitCommand::ExecuteServiceAll(CServerDialog* dialog)
{
AfxGetMainWnd()->SendMessage(WM_CLOSE);
return TRUE;
}
BOOL QuitCommand::ExecuteServiceOne(CServerDialog* dialog)
{
AfxGetMainWnd()->SendMessage(WM_CLOSE);
return TRUE;
}
BOOL QuitCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
return TRUE;
}
BOOL QuitCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
return TRUE;
}
BOOL QuitCommand::IsValidDetail()
{
return TRUE;
}
@@ -0,0 +1,20 @@
#pragma once
#include "BaseCommand.h"
class QuitCommand : public BaseCommand
{
public:
QuitCommand(void);
~QuitCommand(void);
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
};
@@ -0,0 +1,98 @@
#include "StdAfx.h"
#include "StopCommand.h"
#include "../resource.h"
#include "../ServerDialog.h"
StopCommand::StopCommand() : BaseCommand(BCT_STOP)
{
}
StopCommand::~StopCommand()
{
}
BOOL StopCommand::ExecuteServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceAll( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandStopAll() )
{
return FALSE;
}
return TRUE;
}
BOOL StopCommand::ExecuteServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceOne( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandStop( m_strings[0] ) )
{
return FALSE;
}
return TRUE;
}
BOOL StopCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
int serviceCount = dialog->GetServiceCount();
for( int index = 0; index < serviceCount ; index ++ )
{
if( dialog->IsServiceOn(index) )
{
return FALSE;
}
}
return TRUE;
}
BOOL StopCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( dialog->IsServiceOn(m_strings[0]) )
{
return FALSE;
}
return TRUE;
}
BOOL StopCommand::IsValidDetail()
{
if( m_isServiceAll )
{
if( !m_strings.empty() )
return FALSE;
}
else
{
if( m_strings.size() != 1 )
return FALSE;
}
return TRUE;
}
@@ -0,0 +1,19 @@
#pragma once
#include "BaseCommand.h"
class StopCommand : public BaseCommand
{
public:
StopCommand();
~StopCommand();
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
};
@@ -0,0 +1,129 @@
#include "StdAfx.h"
#include "SyncCommand.h"
#include "../resource.h"
#include "../LS_launcherDlg.h"
#include "../ServerDialog.h"
#include <direct.h>
SyncCommand::SyncCommand() : BaseCommand(BCT_SYNC)
{
}
SyncCommand::~SyncCommand()
{
}
BOOL SyncCommand::ExecuteServiceAll(CServerDialog* dialog)
{
return ExecuteServiceOne(dialog);
}
BOOL SyncCommand::ExecuteServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckCompleteDialogs( m_syncCommandDialogs, dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( m_syncCommandDialogs.size() != m_syncComplteDialogs.size() )
{
return TRUE;
}
if( !dialog->CommandFileSync( m_strings[0] ) )
{
return FALSE;
}
PushCompleteDialogs( m_syncCommandDialogs, dialog );
return TRUE;
}
BOOL SyncCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
return CheckContinueServiceOne(dialog);
}
BOOL SyncCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( !dialog->IsSyncComplete() )
{
return FALSE;
}
if( CheckCompleteDialogs( m_syncComplteDialogs, dialog ) )
{
return TRUE;
}
PushCompleteDialogs( m_syncComplteDialogs, dialog );
if( m_syncComplteDialogs.size() == m_totalSyncTabCount )
return TRUE;
return BaseCommand::Execute();
}
BOOL SyncCommand::IsValidDetail()
{
if( m_strings.size() != 1 )
{
return FALSE;
}
TCHAR tPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH, tPath);
if( _tchdir(m_strings[0].GetBuffer()) == -1 )
{
return FALSE;
}
_tchdir( tPath );
GetCurrentDirectory(MAX_PATH, tPath);
// FileSync´Â ¹«Á¶°Ç WaitMode·Î ÇÑ´Ù
m_isWait = TRUE;
if( m_isApplyAll )
{
m_totalSyncTabCount = GetDialogCount();
}
else
{
m_totalSyncTabCount = m_tabIndexes.size();
}
m_syncComplteDialogs.clear();
return TRUE;
}
void SyncCommand::PushCompleteDialogs( SETDIALOGS& dialogs, CServerDialog* dialog )
{
DIALOGSITER it = dialogs.find( dialog );
if( it == dialogs.end() )
{
dialogs.insert( dialog );
}
}
BOOL SyncCommand::CheckCompleteDialogs( SETDIALOGS& dialogs, CServerDialog* dialog )
{
DIALOGSITER it = dialogs.find( dialog );
if( it != dialogs.end() )
{
return TRUE;
}
return FALSE;
}
@@ -0,0 +1,32 @@
#pragma once
#include <set>
#include "BaseCommand.h"
class SyncCommand : public BaseCommand
{
public:
SyncCommand();
~SyncCommand();
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
private:
typedef std::set<CServerDialog*> SETDIALOGS;
typedef SETDIALOGS::iterator DIALOGSITER;
void PushCompleteDialogs( SETDIALOGS& dialogs, CServerDialog* dialog );
BOOL CheckCompleteDialogs( SETDIALOGS& dialogs, CServerDialog* dialog );
private:
UINT m_totalSyncTabCount;
SETDIALOGS m_syncCommandDialogs;
SETDIALOGS m_syncComplteDialogs;
};
@@ -0,0 +1,615 @@
// TextProgressCtrl.cpp : implementation file
//
// Written by Chris Maunder ([email protected])
// Copyright 1998-2005.
//
// TextProgressCtrl is a drop-in replacement for the standard
// CProgressCtrl that displays text in a progress control.
//
// Homepage: http://www.codeproject.com/miscctrl/text_progressctrl.asp
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the author's written consent, and providing that this
// notice and the author's name is included. If the source code in
// this file is used in any commercial application then an email to
// me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer or anything else vaguely within its vicinity.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
////////////////////////////////////////////////////////////////////////////////
// Revision History - by PJ Arends ([email protected])
// July 1, 2001 - added functionality to set font to parent windows font
// July 15, 2001 - added SetTextColor() and GetTextColor() functions
// August 2, 2001 - Added functionality where the control now responds to
// PBM_* progress bar messages. Now the control can be
// controlled by sending messages to its HWND.
// - added PBM_SETTEXTCOLOR and PBM_SETSHOWTEXT messages
// - added the ability to call GetPos() via OnGetPos()
// January 3, 2005 - By Kriz: Added two basic methods some other changes to
// allow the user to switch between the three alignment
// styles LEFT, CENTER and RIGHT - even on the fly if that's
// needed. Methods: AlignText and AlignTextInvalidate
// - By C Maunder: updated the code so it compiles in VC7
// March 6, 2006 - By A. Bommarito: changed to allow text in vertical
// progress bars; added method to change text background
// color; added capability to independently control display
// of text and percentage complete; added marquee mode;
// changed to exclusively use messaging interface
// February 22, 2007 - By A. Bommarito: changed to fix problem where progress bar
// border didn't display on XP and above when a manifest file
// specified use of Version 6 of the Common Controls; fixed
// problem with AppendFormat method being used without an
// _T() around the format string - caused compile error when
// using Unicode (message from dev75040); added complete turn
// off of Marquee style (message from Robert Pickford)
//
////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "TextProgressCtrl.h"
//#include "CUserMemDC.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl
#define IDT_MARQUEE 1 // timer used to update marquee style progress bar
#define EDGE_SPACE 2 // number of pixels to space text away from edge of progress bar
CTextProgressCtrl::CTextProgressCtrl()
{
// default range
m_nMin = 0;
m_nMax = 100;
// default step size
m_nStepSize = 10;
// initial starting position
m_nPos = 0;
// default colors
m_crBarClr = CLR_DEFAULT;
m_crBarBkClr = CLR_DEFAULT;
m_crTextClr = CLR_DEFAULT;
m_crTextBkClr = CLR_DEFAULT;
// default to show percent complete, all text centered
m_bShowPercent = TRUE;
m_dwTextStyle = DT_CENTER;
// default marquee bar size of 20% of full progress bar
m_nMarqueeSize = 20;
}
CTextProgressCtrl::~CTextProgressCtrl()
{
// delete vertical font if needed
if (m_VerticalFont.m_hObject)
m_VerticalFont.DeleteObject();
}
BEGIN_MESSAGE_MAP(CTextProgressCtrl, CProgressCtrl)
//{{AFX_MSG_MAP(CTextProgressCtrl)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
ON_MESSAGE(PBM_SETRANGE, OnSetRange)
ON_MESSAGE(PBM_SETPOS, OnSetPos)
ON_MESSAGE(PBM_DELTAPOS, OnOffsetPos)
ON_MESSAGE(PBM_SETSTEP, OnSetStep)
ON_MESSAGE(PBM_STEPIT, OnStepIt)
ON_MESSAGE(PBM_SETRANGE32, OnSetRange32)
ON_MESSAGE(PBM_GETRANGE, OnGetRange)
ON_MESSAGE(PBM_GETPOS, OnGetPos)
ON_MESSAGE(PBM_SETBARCOLOR, OnSetBarColor)
ON_MESSAGE(PBM_SETBKCOLOR, OnSetBarBkColor)
ON_MESSAGE(PBM_USERGETBARCOLOR, OnGetBarColor)
ON_MESSAGE(PBM_USERGETBKCOLOR, OnGetBarBkColor)
ON_MESSAGE(PBM_SETTEXTCOLOR, OnSetTextColor)
ON_MESSAGE(PBM_GETTEXTCOLOR, OnGetTextColor)
ON_MESSAGE(PBM_SETTEXTBKCOLOR, OnSetTextBkColor)
ON_MESSAGE(PBM_GETTEXTBKCOLOR, OnGetTextBkColor)
ON_MESSAGE(PBM_SETSHOWPERCENT, OnSetShowPercent)
ON_MESSAGE(PBM_ALIGNTEXT, OnAlignText)
ON_MESSAGE(PBM_SETMARQUEE, OnSetMarquee)
ON_MESSAGE(PBM_SETMARQUEEOPTIONS, OnSetMarqueeOptions)
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl message handlers
BOOL CTextProgressCtrl::OnEraseBkgnd(CDC* /*pDC*/)
{
return TRUE;
}
void CTextProgressCtrl::OnPaint()
{
if (m_nMin >= m_nMax)
return;
CPaintDC PaintDC(this); // device context for painting
CUserMemDC dc(&PaintDC); // memory device context
// get colors to use
COLORREF crBarColor = (COLORREF)OnGetBarColor(0, 0);
COLORREF crBarBkColor = (COLORREF)OnGetBarBkColor(0, 0);
COLORREF crTextColor = (COLORREF)OnGetTextColor(0, 0);
COLORREF crTextBkColor = (COLORREF)OnGetTextBkColor(0, 0);;
// select progress bar font if there is one, else select parent font
if (GetFont())
dc.SelectObject(GetFont());
else
dc.SelectObject(GetParent()->GetFont());
// get bar dimensions and draw bar outline
BOOL bLeft = true, bMiddle = true, bRight = true;
CRect LeftRect, MiddleRect, RightRect, ClientRect;
GetClientRect(&ClientRect);
DrawEdge(dc, ClientRect, EDGE_SUNKEN, BF_ADJUST | BF_RECT | BF_FLAT);
LeftRect = MiddleRect = RightRect = ClientRect;
// compute the fractional position
double dFraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin));
// get the control style
DWORD dwStyle = GetStyle();
// create a vertical font if needed
if ((dwStyle & PBS_VERTICAL) && (!m_VerticalFont.m_hObject))
CreateVerticalFont();
if (dwStyle & PBS_MARQUEE)
{
if (dwStyle & PBS_VERTICAL)
{
MiddleRect.top = MiddleRect.bottom - (int)((MiddleRect.Height()) * dFraction);
MiddleRect.bottom = MiddleRect.top + (((LeftRect.Height() * m_nMarqueeSize) + 50) / 100);
if (MiddleRect.bottom >= LeftRect.bottom)
{
bLeft = false;
MiddleRect.bottom = LeftRect.bottom;
}
else
LeftRect.top = MiddleRect.bottom;
if (MiddleRect.top <= RightRect.top)
{
bRight = false;
MiddleRect.top = RightRect.top;
}
else
RightRect.bottom = MiddleRect.top;
}
else
{
MiddleRect.right = MiddleRect.left + (int)((MiddleRect.Width()) * dFraction);
MiddleRect.left = MiddleRect.right - (((LeftRect.Width() * m_nMarqueeSize) + 50) / 100);
if (MiddleRect.left <= LeftRect.left)
{
bLeft = false;
MiddleRect.left = LeftRect.left;
}
else
LeftRect.right = MiddleRect.left;
if (MiddleRect.right >= RightRect.right)
{
bRight = false;
MiddleRect.right = RightRect.right;
}
else
RightRect.left = MiddleRect.right;
}
}
else
{
bLeft = false;
if (dwStyle & PBS_VERTICAL)
{
MiddleRect.top = MiddleRect.bottom - (int)((MiddleRect.Height()) * dFraction);
RightRect.bottom = MiddleRect.top;
}
else
{
MiddleRect.right = MiddleRect.left + (int)((MiddleRect.Width()) * dFraction);
RightRect.left = MiddleRect.right;
}
}
if (bLeft)
dc.FillSolidRect(LeftRect, crBarBkColor);
if (bMiddle)
dc.FillSolidRect(MiddleRect, crBarColor);
if (bRight)
dc.FillSolidRect(RightRect, crBarBkColor);
// draw text if needed
CString str;
GetWindowText(str);
if (m_bShowPercent)
str.AppendFormat(_T("%d%%"), (int)((dFraction * 100.0) + 0.5));
if (str.GetLength())
{
CFont *pOldFont = NULL;
CPoint ptStart;
CSize szText;
if (dwStyle & PBS_VERTICAL)
{
pOldFont = (CFont*)dc.SelectObject(&m_VerticalFont);
szText = dc.GetOutputTextExtent(str);
switch (m_dwTextStyle)
{
case DT_LEFT:
ptStart.y = ClientRect.bottom - 1 - EDGE_SPACE;
break;
case DT_RIGHT:
ptStart.y = ClientRect.top + szText.cx + EDGE_SPACE;
break;
case DT_CENTER:
default:
ptStart.y = ClientRect.top + szText.cx + (ClientRect.Height() - szText.cx) / 2;
break;
}
ptStart.x = ClientRect.left + ((ClientRect.Width() - szText.cy) / 2);
}
else
{
szText = dc.GetOutputTextExtent(str);
switch (m_dwTextStyle)
{
case DT_LEFT:
ptStart.x = ClientRect.left + EDGE_SPACE;
break;
case DT_RIGHT:
ptStart.x = ClientRect.right - szText.cx - 1 - EDGE_SPACE;
break;
case DT_CENTER:
default:
ptStart.x = ClientRect.left + ((ClientRect.Width() - szText.cx) / 2);
break;
}
ptStart.y = ClientRect.top + ((ClientRect.Height() - szText.cy) / 2);
}
dc.SetBkMode(TRANSPARENT);
CRgn rgn;
if (bLeft)
{
rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom);
dc.SelectClipRgn(&rgn);
dc.SetTextColor(crTextColor);
dc.ExtTextOut(ptStart.x, ptStart.y, ETO_CLIPPED, &ClientRect, str, NULL);
rgn.DeleteObject();
}
if (bMiddle)
{
rgn.CreateRectRgn(MiddleRect.left, MiddleRect.top, MiddleRect.right, MiddleRect.bottom);
dc.SelectClipRgn(&rgn);
dc.SetTextColor(crTextBkColor);
dc.ExtTextOut(ptStart.x, ptStart.y, ETO_CLIPPED, &ClientRect, str, NULL);
rgn.DeleteObject();
}
if (bRight)
{
rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom);
dc.SelectClipRgn(&rgn);
dc.SetTextColor(crTextColor);
dc.ExtTextOut(ptStart.x, ptStart.y, ETO_CLIPPED, &ClientRect, str, NULL);
rgn.DeleteObject();
}
if (pOldFont)
dc.SelectObject(pOldFont);
}
}
void CTextProgressCtrl::OnTimer(UINT_PTR nIDEvent)
{
static int nDirection = +1;
if (nIDEvent == IDT_MARQUEE)
{
int nPosition = GetPos();
int nMax = (int)((((double)(100 + m_nMarqueeSize) * (double)m_nMax) + 0.5) / 100.0);
if ((nDirection == 1) && (nPosition >= nMax))
nDirection = -1;
else if ((nDirection == -1) && (nPosition <= m_nMin))
nDirection = +1;
SetPos(nPosition + nDirection);
}
}
LRESULT CTextProgressCtrl::OnSetRange(WPARAM, LPARAM lparamRange)
{
// set new 16-bit range, returning old one
return (OnSetRange32(LOWORD(lparamRange), HIWORD(lparamRange)));
}
LRESULT CTextProgressCtrl::OnSetPos(WPARAM nNewPos, LPARAM)
{
// save old position for return
int nOldPos = m_nPos;
// set new position
m_nPos = (int)nNewPos;
// limit position to inside of range
DWORD dwStyle = GetStyle();
if (m_nPos < m_nMin)
m_nPos = m_nMin;
if (dwStyle & PBS_MARQUEE)
{
int nMax = (int)((((double)(100 + m_nMarqueeSize) * (double)m_nMax) + 0.5) / 100.0);
if (m_nPos > nMax)
m_nPos = nMax;
}
else if (m_nPos > m_nMax)
m_nPos = m_nMax;
// call a common routine to redraw window
CommonPaint();
// return old position
return ((LRESULT)nOldPos);
}
LRESULT CTextProgressCtrl::OnOffsetPos(WPARAM nIncrement, LPARAM)
{
// set new position, returning old one
return (OnSetPos((WPARAM)(m_nPos + (int)nIncrement), 0));
}
LRESULT CTextProgressCtrl::OnSetStep(WPARAM nStepInc, LPARAM)
{
// save old step size for return
int nOldStep = m_nStepSize;
// set new step size
m_nStepSize = (int)nStepInc;
// return old step size
return ((LRESULT)nOldStep);
}
LRESULT CTextProgressCtrl::OnStepIt(WPARAM, LPARAM)
{
// compute new position, wrapping if needed
int nPos = m_nPos + m_nStepSize;
if (nPos < m_nMin)
nPos = m_nMax - abs(m_nMin - nPos);
else if (nPos > m_nMax)
nPos = m_nMin + abs(nPos - m_nMax);
// set new position, returning old one
return ((LRESULT)OnSetPos((WPARAM)nPos, 0));
}
LRESULT CTextProgressCtrl::OnSetRange32(WPARAM nLowLim, LPARAM nHighLim)
{
// save old range for return
int nOldMin = m_nMin;
int nOldMax = m_nMax;
// set new range
m_nMin = (int)nLowLim;
m_nMax = (int)nHighLim;
// return old range (16 bit only)
return (MAKELRESULT(LOWORD(nOldMin), LOWORD(nOldMax)));
}
LRESULT CTextProgressCtrl::OnGetRange(WPARAM bWhichLimit, LPARAM pPBRange)
{
// get arguments into proper types
BOOL bType = (BOOL)bWhichLimit;
PPBRANGE pRange = (PPBRANGE)pPBRange;
// return both range limits if a pointer was provided
if (pRange)
{
pRange->iLow = m_nMin;
pRange->iHigh = m_nMax;
}
// return selected range limit
return ((LRESULT)(bType ? m_nMin : m_nMax));
}
LRESULT CTextProgressCtrl::OnGetPos(WPARAM, LPARAM)
{
// return current position
return ((LRESULT)m_nPos);
}
LRESULT CTextProgressCtrl::OnSetBarColor(WPARAM, LPARAM crBar)
{
// call a common routine to redraw window
CommonPaint();
// set new bar color, returning old one
COLORREF crOldBarClr = m_crBarClr;
m_crBarClr = (COLORREF)crBar;
return ((LRESULT)crOldBarClr);
}
LRESULT CTextProgressCtrl::OnSetBarBkColor(WPARAM, LPARAM crBarBk)
{
// call a common routine to redraw window
CommonPaint();
// set new bar background color, returning old one
COLORREF crOldBarBkClr = m_crBarBkClr;
m_crBarBkClr = (COLORREF)crBarBk;
return ((LRESULT)crOldBarBkClr);
}
LRESULT CTextProgressCtrl::OnGetBarColor(WPARAM, LPARAM)
{
// return current bar color
return ((LRESULT)((m_crBarClr == CLR_DEFAULT)? ::GetSysColor(COLOR_HIGHLIGHT) : m_crBarClr));
}
LRESULT CTextProgressCtrl::OnGetBarBkColor(WPARAM, LPARAM)
{
// return current bar background color
return ((LRESULT)((m_crBarBkClr == CLR_DEFAULT)? ::GetSysColor(COLOR_BTNFACE) : m_crBarBkClr));
}
LRESULT CTextProgressCtrl::OnSetTextColor(WPARAM, LPARAM crText)
{
// call a common routine to redraw window
CommonPaint();
// set new text color, returning old one
COLORREF crOldTextClr = m_crTextClr;
m_crTextClr = (COLORREF)crText;
return ((LRESULT)crOldTextClr);
}
LRESULT CTextProgressCtrl::OnGetTextColor(WPARAM, LPARAM)
{
// return current text color
return ((LRESULT)((m_crTextClr == CLR_DEFAULT ? ::GetSysColor(COLOR_WINDOWTEXT) : m_crTextClr)));
}
LRESULT CTextProgressCtrl::OnSetTextBkColor(WPARAM, LPARAM crTextBkClr)
{
// call a common routine to redraw window
CommonPaint();
// set new text background color, returning old one
COLORREF crOldTextBkClr = m_crTextBkClr;
m_crTextBkClr = (COLORREF)crTextBkClr;
return ((LRESULT)crOldTextBkClr);
}
LRESULT CTextProgressCtrl::OnGetTextBkColor(WPARAM, LPARAM)
{
// return current text background color
return ((LRESULT)((m_crTextBkClr == CLR_DEFAULT ? ::GetSysColor(COLOR_WINDOW) : m_crTextBkClr)));
}
LRESULT CTextProgressCtrl::OnSetShowPercent(WPARAM bShow, LPARAM)
{
// call a common routine to redraw window
CommonPaint();
// set new percent completed display state, returning old one
BOOL bOldShow = m_bShowPercent;
m_bShowPercent = (BOOL)bShow;
return ((LRESULT)bOldShow);
}
LRESULT CTextProgressCtrl::OnAlignText(WPARAM dwAlignment, LPARAM)
{
// get argument into proper type
DWORD dwAlign = (DWORD)dwAlignment;
// check input
ASSERT((dwAlign == DT_LEFT) || (dwAlign == DT_RIGHT) || (dwAlign == DT_CENTER));
// call a common routine to redraw window
CommonPaint();
// set new text alignment mode, returning old one
DWORD dwOldTextStyle = m_dwTextStyle;
m_dwTextStyle = dwAlign;
return ((LRESULT)dwOldTextStyle);
}
LRESULT CTextProgressCtrl::OnSetMarquee(WPARAM bShow, LPARAM uMsecBetweenUpdate)
{
// call a common routine to redraw window
CommonPaint();
// can't have percent complete for this style
m_bShowPercent = false;
// turn marquee mode on or off
if ((BOOL)bShow)
{
ModifyStyle(0, PBS_MARQUEE);
SetTimer(IDT_MARQUEE, (UINT)uMsecBetweenUpdate, NULL);
}
else
{
KillTimer(IDT_MARQUEE);
ModifyStyle(PBS_MARQUEE, 0);
}
// return current marquee mode
return ((LRESULT)bShow);
}
LRESULT CTextProgressCtrl::OnSetMarqueeOptions(WPARAM nBarSize, LPARAM)
{
// get argument into proper type
int nBar = (int)nBarSize;
// call a common routine to redraw window
CommonPaint();
// set new marquee bar size
m_nMarqueeSize = nBar;
// return bar size (have to return something from a message)
return ((LRESULT)nBar);
}
////////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl helper functions
void CTextProgressCtrl::CreateVerticalFont()
{
// delete old font if it exists
if (m_VerticalFont.m_hObject)
m_VerticalFont.DeleteObject();
// create a new vertical font based on the current font
LOGFONT lf;
GetFont()->GetLogFont(&lf);
lf.lfEscapement = lf.lfOrientation = 900;
m_VerticalFont.CreateFontIndirect(&lf);
}
void CTextProgressCtrl::CommonPaint()
{
//
// common place to mess with redraw options
//
// note that Invalidate() by itself won't cause
// a repaint when this control is used in a modeless
// dialog box
//
// also note that the marquee timer won't work in a modeless
// dialog - to use marquee mode in a modeless dialog the code
// that is running will have to pump Windows messages
//
RedrawWindow();
}
@@ -0,0 +1,293 @@
#ifndef _TEXTPROGRESSCTRL_H_
#define _TEXTPROGRESSCTRL_H_
#include "CUserMemDC.h"
//
// TextProgressCtrl.h : header file for CTextProgressCtrl class
//
// Written by Chris Maunder ([email protected])
// Copyright 1998-2005.
//
// TextProgressCtrl is a drop-in replacement for the standard
// CProgressCtrl that displays text in a progress control.
//
// Homepage: http://www.codeproject.com/miscctrl/text_progressctrl.asp
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the author's written consent, and providing that this
// notice and the author's name is included. If the source code in
// this file is used in any commercial application then an email to
// me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer, causes your pet cat to fall ill, increases baldness or
// makes you car start emitting strange noises when you start it up.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
//
// See file TextProgressCtrl.cpp for modification history.
//
////////////////////////////////////////////////////////////////////////////////
//
// To set the range (16 bit):
// call SetRange(WORD wLower, WORD wUpper)
// or SendMessage(PBM_SETRANGE, 0, MAKELPARAM(wLower, wUpper))
// or ::SendMessage(m_hWnd, PBM_SETRANGE, 0, MAKELPARAM(wLower, wUpper))
//
// To set the position:
// call SetPos(int nNewPos)
// or SendMessage(PBM_SETPOS, (WPARAM)nNewPos, 0)
// or ::SendMessage(m_hWnd, PBM_SETPOS, (WPARAM)nNewPos, 0)
//
// To set the position using a delta value:
// call OffsetPos(int nIncrement)
// or SendMessage(PBM_DELTAPOS, (WPARAM)nIncrement, 0)
// or ::SendMessage(m_hWnd, PBM_DELTAPOS, (WPARAM)nIncrement, 0)
//
// To set the step increment size:
// call SetStep(int nStepInc)
// or SendMessage(PBM_SETSTEP, (WPARAM)nStepInc, 0)
// or ::SendMessage(m_hWnd, PBM_SETSTEP, (WPARAM)nStepInc, 0)
//
// To step the position by the step increment size:
// call StepIt()
// or SendMessage(PBM_STEPIT, 0, 0)
// or ::SendMessage(m_hWnd, PBM_STEPIT, 0, 0)
//
// To set the range (32 bit):
// call SetRange32(int nLowLim, int nHighLim)
// or SendMessage(PBM_SETRANGE32, (WPARAM)nLowLim, (LPARAM)nHighLim)
// or ::SendMessage(m_hWnd, PBM_SETRANGE32, (WPARAM)nLowLim, (LPARAM)nHighLim)
//
// To get the current range:
// call GetRange(BOOL bWhichLimit, PBRANGE* pPBRange)
// or SendMessage(PBM_GETRANGE, (WPARAM)bWhichLimit, (LPARAM)pBBRange)
// or ::SendMessage(m_hWnd, PBM_GETRANGE, (WPARAM)bWhichLimit, (LPARAM)pBBRange)
//
// To get the current position:
// call GetPos()
// or SendMessage(PBM_GETPOS, 0, 0)
// or ::SendMessage(m_hWnd, PBM_GETPOS, 0, 0)
//
// To set the bar color:
// call SetBarColor(COLORREF crBar)
// or SendMessage (PBM_SETBARCOLOR, 0, (LPARAM)crBar)
// or ::SendMessage (m_hwnd, PBM_SETBARCOLOR, 0, (LPARAM)crBar)
//
// To get the bar color:
// call GetBarColor()
// or SendMessage (PBM_USERGETBARCOLOR, 0, 0)
// or ::SendMessage (m_hwnd, PBM_USERGETBARCOLOR, 0, 0)
//
// To set the bar background color:
// call SetBkColor(COLORREF crBarBk)
// or SetBarBkColor(COLORREF crBarBk)
// or SendMessage (PBM_SETBARBKCOLOR, 0, (LPARAM)crBarBk)
// or ::SendMessage (m_hwnd, PBM_SETBARBKCOLOR, 0, (LPARAM)crBarBk)
//
// To get the bar background color:
// call GetBarBkColor()
// or SendMessage (PBM_GETBARBKCOLOR, 0, 0)
// or ::SendMessage (m_hwnd, PBM_GETBARBKCOLOR, 0, 0)
//
// To operate on the bar text:
// use any of the normal CWnd window text functions, such as
// SetWindowText, GetWindowText, GetWindowTextLength, SetFont and GetFont
//
// To set the text color:
// call SetTextColor(COLORREF crTextClr)
// or SendMessage (PBM_SETTEXTCOLOR, 0, (LPARAM)crTextClr)
// or ::SendMessage (m_hwnd, PBM_SETTEXTCOLOR, 0, (LPARAM)crTextClr)
// To get the text color:
// call GetTextColor()
// or SendMessage (PBM_GETTEXTCOLOR, 0, 0)
// or ::SendMessage (m_hwnd, PBM_GETTEXTCOLOR, 0, 0)
//
// To set the text background color:
// call SetTextBkColor(COLORREF crTextBkClr)
// or SendMessage (PBM_SETTEXTBKCOLOR, 0, (LPARAM)crTextBkClr)
// or ::SendMessage (m_hwnd, PBM_SETTEXTBKCOLOR, 0, (LPARAM)crTextBkClr)
//
// To get the text background color:
// call GetTextBkColor()
// or SendMessage (PBM_GETTEXTBKCOLOR, 0, 0)
// or ::SendMessage (m_hwnd, PBM_GETTEXTBKCOLOR, 0, 0)
//
// To show or hide percentage complete:
// call SetShowPercent(BOOL bShow)
// or SendMessage(PBM_SETSHOWPERCENT, (WPARAM)bShow, 0)
// or ::SendMessage(m_hWnd, PBM_SETSHOWPERCENT, (WPARAM)bShow, 0)
//
// To set the text alignment mode:
// call AlignText(DWORD dwAlignment), where dwAlignment = DT_LEFT, DT_RIGHT or DT_CENTER
// or SendMessage(PBM_ALIGNTEXT, (WPARAM)dwAlignment, 0)
// or SendMessage(m_hWnd, PBM_ALIGNTEXT, (WPARAM)dwAlignment, 0)
//
// To turn on/off marquee mode
// call SetMarquee(BOOL bOn, int nMsecBetweenUpdate)
// or SendMessage(PBM_SETMARQUEE, (WPARAM)bOn, (LPARAM)nMsecBetweenUpdate)
// or ::SendMessage(m_hWnd, PBM_SETMARQUEE, (WPARAM)bOn, (LPARAM)nMsecBetweenUpdate)
//
// To set marquee options
// call SetMarqueeOptions(int nBarSize)
// or SendMessage(PBM_SETMARQUEEOPTIONS, (WPARAM)nBarSize, 0)
// or ::SendMessage(m_hWnd, PBM_SETMARQUEEOPTIONS, (WPARAM)nBarSize, 0)
//
////////////////////////////////////////////////////////////////////////////////
// setup aliases using "Colour" instead of "Color"
#define SetBarColour SetBarColor
#define GetBarColour GetBarColor
#define SetBgColour SetBarBkColor
#define GetBgColour GetBarBkColor
#define SetTextColour SetTextColor
#define GetTextColour GetTextColor
// define progress bar stuff that may not be elsewhere defined (if needed)
#ifndef PBS_SMOOTH
#define PBS_SMOOTH 0x01
#endif
#ifndef PBS_VERTICAL
#define PBS_VERTICAL 0x04
#endif
#ifndef PBS_MARQUEE
#define PBS_MARQUEE 0x08
#endif
#ifndef PBM_SETRANGE32
#define PBM_SETRANGE32 (WM_USER+6)
typedef struct
{
int iLow;
int iHigh;
} PBRANGE, *PPBRANGE;
#endif
#ifndef PBM_GETRANGE
#define PBM_GETRANGE (WM_USER+7)
#endif
#ifndef PBM_GETPOS
#define PBM_GETPOS (WM_USER+8)
#endif
#ifndef PBM_SETBARCOLOR
#define PBM_SETBARCOLOR (WM_USER+9)
#endif
#ifndef PBM_SETBKCOLOR
#define PBM_SETBKCOLOR CCM_SETBKCOLOR
#endif
#ifndef PBM_SETMARQUEE
#define PBM_SETMARQUEE (WM_USER+10)
#endif
// setup message codes for new messages
#define PBM_USERGETBARCOLOR (WM_USER+100)
#define PBM_USERGETBKCOLOR (WM_USER+101)
#define PBM_SETTEXTCOLOR (WM_USER+102)
#define PBM_GETTEXTCOLOR (WM_USER+103)
#define PBM_SETTEXTBKCOLOR (WM_USER+104)
#define PBM_GETTEXTBKCOLOR (WM_USER+105)
#define PBM_SETSHOWPERCENT (WM_USER+106)
#define PBM_ALIGNTEXT (WM_USER+107)
#define PBM_SETMARQUEEOPTIONS (WM_USER+108)
////////////////////////////////////////////////////////////////////////////////
// CTextProgressCtrl class
class CTextProgressCtrl : public CProgressCtrl
{
// Constructor / Destructor
public:
CTextProgressCtrl();
virtual ~CTextProgressCtrl();
// Operations
public:
inline COLORREF SetBarColor(COLORREF crBarClr = CLR_DEFAULT)
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_SETBARCOLOR, 0, (LPARAM)crBarClr)); }
inline COLORREF GetBarColor() const
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_USERGETBARCOLOR, 0, 0)); }
inline COLORREF SetBarBkColor(COLORREF crBarBkClr = CLR_DEFAULT)
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_SETBKCOLOR, 0, (LPARAM)crBarBkClr)); }
inline COLORREF GetBarBkColor() const
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_USERGETBKCOLOR, 0, 0)); }
inline COLORREF SetTextColor(COLORREF crTextClr = CLR_DEFAULT)
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_SETTEXTCOLOR, 0, (LPARAM)crTextClr)); }
inline COLORREF GetTextColor() const
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_GETTEXTCOLOR, 0, 0)); }
inline COLORREF SetTextBkColor(COLORREF crTextBkClr = CLR_DEFAULT)
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_SETTEXTBKCOLOR, 0, (LPARAM)crTextBkClr)); }
inline COLORREF GetTextBkColor() const
{ ASSERT(::IsWindow(m_hWnd)); return ((COLORREF) ::SendMessage(m_hWnd, PBM_GETTEXTBKCOLOR, 0, 0)); }
inline BOOL SetShowPercent(BOOL bShow)
{ ASSERT(::IsWindow(m_hWnd)); return ((BOOL) ::SendMessage(m_hWnd, PBM_SETSHOWPERCENT, (WPARAM)bShow, 0)); }
inline DWORD AlignText(DWORD dwAlignment = DT_CENTER)
{ ASSERT(::IsWindow(m_hWnd)); return ((DWORD) ::SendMessage(m_hWnd, PBM_ALIGNTEXT, (WPARAM)dwAlignment, 0)); }
inline BOOL SetMarquee(BOOL bOn, UINT uMsecBetweenUpdate)
{ ASSERT(::IsWindow(m_hWnd)); return ((BOOL) ::SendMessage(m_hWnd, PBM_SETMARQUEE, (WPARAM)bOn, (LPARAM)uMsecBetweenUpdate)); }
inline int SetMarqueeOptions(int nBarSize)
{ ASSERT(::IsWindow(m_hWnd)); return ((BOOL) ::SendMessage(m_hWnd, PBM_SETMARQUEEOPTIONS, (WPARAM)nBarSize, 0)); }
// Generated message map functions
protected:
//{{AFX_MSG(CTextProgressCtrl)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnPaint();
afx_msg void OnTimer(UINT_PTR nIDEvent);
//}}AFX_MSG
// handlers for shell progress control standard messages
afx_msg LRESULT OnSetRange(WPARAM, LPARAM lparamRange);
afx_msg LRESULT OnSetPos(WPARAM nNewPos, LPARAM);
afx_msg LRESULT OnOffsetPos(WPARAM nIncrement, LPARAM);
afx_msg LRESULT OnSetStep(WPARAM nStepInc, LPARAM);
afx_msg LRESULT OnStepIt(WPARAM, LPARAM);
afx_msg LRESULT OnSetRange32(WPARAM nLowLim, LPARAM nHighLim);
afx_msg LRESULT OnGetRange(WPARAM bWhichLimit, LPARAM pPBRange);
afx_msg LRESULT OnGetPos(WPARAM, LPARAM);
afx_msg LRESULT OnSetBarColor(WPARAM, LPARAM crBar);
afx_msg LRESULT OnSetBarBkColor(WPARAM, LPARAM crBarBk);
// new handlers added by this class
afx_msg LRESULT OnGetBarColor(WPARAM, LPARAM);
afx_msg LRESULT OnGetBarBkColor(WPARAM, LPARAM);
afx_msg LRESULT OnSetTextColor(WPARAM, LPARAM crText);
afx_msg LRESULT OnGetTextColor(WPARAM, LPARAM);
afx_msg LRESULT OnSetTextBkColor(WPARAM, LPARAM crTextBk);
afx_msg LRESULT OnGetTextBkColor(WPARAM, LPARAM);
afx_msg LRESULT OnSetShowPercent(WPARAM bShow, LPARAM);
afx_msg LRESULT OnAlignText(WPARAM dwAlignment, LPARAM);
afx_msg LRESULT OnSetMarquee(WPARAM bOn, LPARAM nMsecBetweenUpdate);
afx_msg LRESULT OnSetMarqueeOptions(WPARAM nBarSize, LPARAM);
// helper functions
void CreateVerticalFont();
void CommonPaint();
DECLARE_MESSAGE_MAP()
// variables for class
BOOL m_bShowPercent; // true to show percent complete as text
CFont m_VerticalFont; // font for vertical progress bars
COLORREF m_crBarClr, m_crBarBkClr; // bar colors
COLORREF m_crTextClr, m_crTextBkClr; // text colors
DWORD m_dwTextStyle; // alignment style for text
int m_nPos; // current position within range
int m_nStepSize; // current step size
int m_nMin, m_nMax; // minimum and maximum values of range
int m_nMarqueeSize; // size of sliding marquee bar in percent (0 - 100)
};
////////////////////////////////////////////////////////////////////////////////
#endif //#ifndef _TEXTPROGRESSCTRL_H_
@@ -0,0 +1,95 @@
#include "StdAfx.h"
#include "UninstallCommand.h"
#include "../resource.h"
#include "../LS_launcherDlg.h"
#include "../ServerDialog.h"
UninstallCommand::UninstallCommand() : BaseCommand(BCT_UNINSTALL)
{
}
UninstallCommand::~UninstallCommand()
{
}
BOOL UninstallCommand::ExecuteServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceAll( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandUninstallAll() )
{
return FALSE;
}
return TRUE;
}
BOOL UninstallCommand::ExecuteServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
if( CheckContinueServiceOne( dialog ) )
{
m_state = CST_ALREADY_EXCUTE;
return TRUE;
}
m_state = CST_BEFORE_EXCUTE;
if( !dialog->CommandUninstall( m_strings[0] ) )
{
return FALSE;
}
return TRUE;
}
BOOL UninstallCommand::CheckContinueServiceAll(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
int serviceCount = dialog->GetServiceCount();
if( serviceCount != 0 )
return FALSE;
return TRUE;
}
BOOL UninstallCommand::CheckContinueServiceOne(CServerDialog* dialog)
{
if( !dialog )
return FALSE;
int index = dialog->FindServiceIndex( m_strings[0] );
if( index != -1 )
{
return FALSE;
}
return TRUE;
}
BOOL UninstallCommand::IsValidDetail()
{
if( m_isServiceAll )
{
if( !m_strings.empty() )
return FALSE;
}
else
{
if( m_strings.size() != 1 )
return FALSE;
}
return TRUE;
}
@@ -0,0 +1,18 @@
#pragma once
#include "BaseCommand.h"
class UninstallCommand : public BaseCommand
{
public:
UninstallCommand();
~UninstallCommand();
public:
BOOL ExecuteServiceAll(CServerDialog* dialog);
BOOL ExecuteServiceOne(CServerDialog* dialog);
BOOL CheckContinueServiceAll(CServerDialog* dialog);
BOOL CheckContinueServiceOne(CServerDialog* dialog);
BOOL IsValidDetail();
};