Skip to content

Commit

Permalink
use Dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
sayurin committed Jul 25, 2018
1 parent f187e25 commit 55ba2fb
Show file tree
Hide file tree
Showing 17 changed files with 663 additions and 1,566 deletions.
16 changes: 0 additions & 16 deletions Resource/ffftp.en-US.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1354,13 +1354,6 @@ BEGIN
EDITTEXT DOWN_EXIST_NAME,7,20,220,12,ES_AUTOHSCROLL
END

IDD_OLEDRAG DIALOGEX 0, 0, 30, 13
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Transfering"
FONT 9, "MS Shell Dlg", 0, 0, 0x1
BEGIN
END

move_notify_dlg DIALOGEX 0, 0, 201, 82
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Move Files/Folders"
Expand Down Expand Up @@ -2079,14 +2072,6 @@ BEGIN
BOTTOMMARGIN, 117
END

IDD_OLEDRAG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 23
TOPMARGIN, 7
BOTTOMMARGIN, 6
END

move_notify_dlg, DIALOG
BEGIN
LEFTMARGIN, 7
Expand Down Expand Up @@ -2636,7 +2621,6 @@ BEGIN
IDS_MSGJPN281 "Cannnot connect with PASV mode"
IDS_MSGJPN282 "INI filename is not specified"
IDS_MSGJPN283 "INI file: "
IDS_MSGJPN284 "https://github.com/sayurin/ffftp"
IDS_MSGJPN285 "Failed to execute Registory Editor."
END

Expand Down
16 changes: 0 additions & 16 deletions Resource/ffftp.ja-JP.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1317,13 +1317,6 @@ BEGIN
EDITTEXT DOWN_EXIST_NAME,7,20,209,12,ES_AUTOHSCROLL
END

IDD_OLEDRAG DIALOGEX 0, 0, 30, 13
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Transfering"
FONT 9, "MS Shell Dlg", 400, 0, 0x80
BEGIN
END

move_notify_dlg DIALOGEX 0, 0, 201, 82
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "�t�@�C����t�H���_�̈ړ�"
Expand Down Expand Up @@ -2037,14 +2030,6 @@ BEGIN
BOTTOMMARGIN, 116
END

IDD_OLEDRAG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 23
TOPMARGIN, 7
BOTTOMMARGIN, 6
END

move_notify_dlg, DIALOG
BEGIN
LEFTMARGIN, 7
Expand Down Expand Up @@ -2597,7 +2582,6 @@ BEGIN
IDS_MSGJPN281 "PASV���[�h�Őڑ��ł��܂���"
IDS_MSGJPN282 "INI�t�@�C�������w�肳��Ă��܂���"
IDS_MSGJPN283 "INI�t�@�C���w��: "
IDS_MSGJPN284 "https://github.com/sayurin/ffftp"
IDS_MSGJPN285 "���W�X�g���G�f�B�^���N���ł��܂���ł���"
END

Expand Down
2 changes: 0 additions & 2 deletions Resource/resource.en-US.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#define opt_disp1_dlg 181
#define bmark_edit_dlg 182
#define opt_tool_dlg1 183
#define IDD_OLEDRAG 184
#define move_notify_dlg 185
#define forcepasschange_dlg 186
#define newmasterpasswd_dlg 187
Expand Down Expand Up @@ -720,7 +719,6 @@
#define IDS_MSGJPN281 10281
#define IDS_MSGJPN282 10282
#define IDS_MSGJPN283 10283
#define IDS_MSGJPN284 10284
#define IDS_MSGJPN285 10285
#define IDS_MSGJPN289 10289
#define IDS_MSGJPN292 10292
Expand Down
2 changes: 0 additions & 2 deletions Resource/resource.ja-JP.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#define opt_disp1_dlg 181
#define bmark_edit_dlg 182
#define opt_tool_dlg1 183
#define IDD_OLEDRAG 184
#define move_notify_dlg 185
#define forcepasschange_dlg 186
#define newmasterpasswd_dlg 187
Expand Down Expand Up @@ -720,7 +719,6 @@
#define IDS_MSGJPN281 10281
#define IDS_MSGJPN282 10282
#define IDS_MSGJPN283 10283
#define IDS_MSGJPN284 10284
#define IDS_MSGJPN285 10285
#define IDS_MSGJPN289 10289
#define IDS_MSGJPN292 10292
Expand Down
7 changes: 2 additions & 5 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1682,9 +1682,7 @@ void ChangeDirBmarkProc(int MarkID);
void ChangeDirDirectProc(int Win);
void ChangeDirDropFileProc(WPARAM wParam);
void ChmodProc(void);
// 64ビット対応
//BOOL CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK ChmodDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
std::optional<std::wstring> ChmodDialog(std::wstring const& text);
void SomeCmdProc(void);
void CalcFileSizeProc(void);
void DispCWDerror(HWND hWnd);
Expand Down Expand Up @@ -1724,7 +1722,7 @@ void InitPWDcommand();
int DoRMD(char *Path);
int DoDELE(char *Path);
int DoRENAME(char *Src, char *Dst);
int DoCHMOD(char *Path, char *Mode);
int DoCHMOD(const char *Path, const char *Mode);
// 同時接続対応
//int DoSIZE(char *Path, LONGLONG *Size);
int DoSIZE(SOCKET cSkt, char *Path, LONGLONG *Size, int *CancelCheckWork);
Expand Down Expand Up @@ -1913,7 +1911,6 @@ void AttrValue2String(int Attr, char *Buf, int ShowNumber);
void FormatIniString(char *Str);
fs::path SelectFile(bool open, HWND hWnd, UINT titleId, const wchar_t* initialFileName, const wchar_t* extension, std::initializer_list<FileType> fileTypes);
int SelectDir(HWND hWnd, char *Buf, int MaxLen);
int xtoi(char *Str);
int CheckFileReadable(char *Fname);
int max1(int n, int m);
int min1(int n, int m);
Expand Down
177 changes: 58 additions & 119 deletions connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@

/*===== プロトタイプ =====*/

// 64ビット対応
//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
// 同時接続対応
//static int SendInitCommand(char *Cmd);
static int SendInitCommand(SOCKET Socket, char *Cmd, int *CancelCheckWork);
static void AskUseFireWall(char *Host, int *Fire, int *Pasv, int *List);
static void SaveCurrentSetToHistory(void);
Expand Down Expand Up @@ -245,27 +240,59 @@ void ConnectProc(int Type, int Num)
}


/*----- ホスト名を入力してホストへ接続 ----------------------------------------
*
* Parameter
* なし
*
* Return Value
* なし
*----------------------------------------------------------------------------*/

void QuickConnectProc(void)
{
// ホスト名を入力してホストへ接続
void QuickConnectProc() {
struct QuickCon {
using result_t = bool;
std::wstring hostname;
std::wstring username;
std::wstring password;
bool firewall;
bool passive;
INT_PTR OnInit(HWND hDlg) {
SendDlgItemMessageW(hDlg, QHOST_HOST, CB_LIMITTEXT, FMAX_PATH, 0);
SendDlgItemMessageW(hDlg, QHOST_HOST, WM_SETTEXT, 0, (LPARAM)L"");
SendDlgItemMessageW(hDlg, QHOST_USER, EM_LIMITTEXT, USER_NAME_LEN, 0);
if (QuickAnonymous == YES) {
SendDlgItemMessageW(hDlg, QHOST_USER, WM_SETTEXT, 0, (LPARAM)L"anonymous");
SendDlgItemMessageW(hDlg, QHOST_PASS, WM_SETTEXT, 0, (LPARAM)u8(UserMailAdrs).c_str());
} else {
SendDlgItemMessageW(hDlg, QHOST_USER, WM_SETTEXT, 0, (LPARAM)L"");
SendDlgItemMessageW(hDlg, QHOST_PASS, WM_SETTEXT, 0, (LPARAM)L"");
}
SendDlgItemMessageW(hDlg, QHOST_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);
SendDlgItemMessageW(hDlg, QHOST_FWALL, BM_SETCHECK, FwallDefault, 0);
SendDlgItemMessageW(hDlg, QHOST_PASV, BM_SETCHECK, PasvDefault, 0);
for (int i = 0; i < HISTORY_MAX; i++)
if (HISTORYDATA Tmp; GetHistoryByNum(i, &Tmp) == FFFTP_SUCCESS)
SendDlgItemMessageW(hDlg, QHOST_HOST, CB_ADDSTRING, 0, (LPARAM)u8(Tmp.HostAdrs).c_str());
return TRUE;
}
void OnCommand(HWND hDlg, WORD id) {
switch (id) {
case IDOK:
hostname = GetText(hDlg, QHOST_HOST);
username = GetText(hDlg, QHOST_USER);
password = GetText(hDlg, QHOST_PASS);
firewall = SendDlgItemMessageW(hDlg, QHOST_FWALL, BM_GETCHECK, 0, 0) == BST_CHECKED;
passive = SendDlgItemMessageW(hDlg, QHOST_PASV, BM_GETCHECK, 0, 0) == BST_CHECKED;
EndDialog(hDlg, true);
break;
case IDCANCEL:
EndDialog(hDlg, false);
break;
}
}
};
char Tmp[FMAX_PATH+1 + USER_NAME_LEN+1 + PASSWORD_LEN+1 + 2];
char File[FMAX_PATH+1];

SaveBookMark();
SaveCurrentSetToHost();

if(DialogBoxParam(GetFtpInst(), MAKEINTRESOURCE(hostname_dlg), GetMainHwnd(), QuickConDialogCallBack, (LPARAM)Tmp) == YES)
{
if (QuickCon qc; Dialog(GetFtpInst(), hostname_dlg, GetMainHwnd(), qc)) {
/* 接続中なら切断する */
if(CmdCtrlSocket != INVALID_SOCKET)
if (CmdCtrlSocket != INVALID_SOCKET)
DisconnectProc();

SetTaskMsg("----------------------------");
Expand All @@ -274,18 +301,16 @@ void QuickConnectProc(void)
CopyDefaultHost(&CurHost);
// UTF-8対応
CurHost.CurNameKanjiCode = CurHost.NameKanjiCode;
if(SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == FFFTP_SUCCESS)
{
if(strlen(CurHost.UserName) == 0)
{
strcpy(CurHost.UserName, Tmp + FMAX_PATH+1);
strcpy(CurHost.PassWord, Tmp + FMAX_PATH+1 + USER_NAME_LEN+1);
if (strcpy(Tmp, u8(qc.hostname).c_str()); SplitUNCpath(Tmp, CurHost.HostAdrs, CurHost.RemoteInitDir, File, CurHost.UserName, CurHost.PassWord, &CurHost.Port) == FFFTP_SUCCESS) {
if (strlen(CurHost.UserName) == 0) {
strcpy(CurHost.UserName, u8(qc.username).c_str());
strcpy(CurHost.PassWord, u8(qc.password).c_str());
}

SetCurrentHost(HOSTNUM_NOENTRY);
AskUseFireWall(CurHost.HostAdrs, &CurHost.FireWall, &CurHost.Pasv, &CurHost.ListCmdOnly);
CurHost.FireWall = (int)Tmp[FMAX_PATH+1 + USER_NAME_LEN+1 + PASSWORD_LEN+1];
CurHost.Pasv = (int)Tmp[FMAX_PATH+1 + USER_NAME_LEN+1 + PASSWORD_LEN+1 + 1];
CurHost.FireWall = qc.firewall ? 1 : 0;
CurHost.Pasv = qc.passive ? 1 : 0;

SetHostKanaCnvImm(CurHost.KanaCnv);
SetHostKanjiCodeImm(CurHost.KanjiCode);
Expand All @@ -298,15 +323,12 @@ void QuickConnectProc(void)
CmdCtrlSocket = DoConnect(&CurHost, CurHost.HostAdrs, CurHost.UserName, CurHost.PassWord, CurHost.Account, CurHost.Port, CurHost.FireWall, NO, CurHost.Security, &CancelFlg);
TrnCtrlSocket = CmdCtrlSocket;

if(CmdCtrlSocket != INVALID_SOCKET)
{
if (CmdCtrlSocket != INVALID_SOCKET) {
// UTF-8対応
if(CurHost.CurNameKanjiCode == KANJI_AUTO)
{
if(DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)
if (CurHost.CurNameKanjiCode == KANJI_AUTO) {
if (DoDirListCmdSkt("", "", 999, &CancelFlg) == FTP_COMPLETE)
CurHost.CurNameKanjiCode = AnalyzeNameKanjiCode(999);
switch(CurHost.CurNameKanjiCode)
{
switch (CurHost.CurNameKanjiCode) {
case KANJI_SJIS:
SetTaskMsg(MSGJPN343, MSGJPN345);
break;
Expand Down Expand Up @@ -341,97 +363,14 @@ void QuickConnectProc(void)
GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);
EnableUserOpe();

if(strlen(File) > 0)
if (strlen(File) > 0)
DirectDownloadProc(File);
}
else
{
} else {
SoundPlay(SND_ERROR);
EnableUserOpe();
}
}
}
return;
}


/*----- クイック接続ダイアログのコールバック ----------------------------------
*
* Parameter
* HWND hDlg : ウインドウハンドル
* UINT message : メッセージ番号
* WPARAM wParam : メッセージの WPARAM 引数
* LPARAM lParam : メッセージの LPARAM 引数
*
* Return Value
* BOOL TRUE/FALSE
*----------------------------------------------------------------------------*/

// 64ビット対応
//static BOOL CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
static INT_PTR CALLBACK QuickConDialogCallBack(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
static char *Buf;
int i;
HISTORYDATA Tmp;

//char Str[HOST_ADRS_LEN+USER_NAME_LEN+INIT_DIR_LEN+5+1];

switch (iMessage)
{
case WM_INITDIALOG :
SendDlgItemMessage(hDlg, QHOST_HOST, CB_LIMITTEXT, FMAX_PATH, 0);
SendDlgItemMessage(hDlg, QHOST_HOST, WM_SETTEXT, 0, (LPARAM)"");
SendDlgItemMessage(hDlg, QHOST_USER, EM_LIMITTEXT, USER_NAME_LEN, 0);
if(QuickAnonymous == YES)
{
SendDlgItemMessage(hDlg, QHOST_USER, WM_SETTEXT, 0, (LPARAM)"anonymous");
SendDlgItemMessage(hDlg, QHOST_PASS, WM_SETTEXT, 0, (LPARAM)UserMailAdrs);
}
else
{
SendDlgItemMessage(hDlg, QHOST_USER, WM_SETTEXT, 0, (LPARAM)"");
SendDlgItemMessage(hDlg, QHOST_PASS, WM_SETTEXT, 0, (LPARAM)"");
}
SendDlgItemMessage(hDlg, QHOST_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);
SendDlgItemMessage(hDlg, QHOST_FWALL, BM_SETCHECK, FwallDefault, 0);
SendDlgItemMessage(hDlg, QHOST_PASV, BM_SETCHECK, PasvDefault, 0);
for(i = 0; i < HISTORY_MAX; i++)
{
if(GetHistoryByNum(i, &Tmp) == FFFTP_SUCCESS)
{
//sprintf(Str, "%s (%s) %s", Tmp.HostAdrs, Tmp.UserName, Tmp.RemoteInitDir);
//SendDlgItemMessage(hDlg, QHOST_HOST, CB_ADDSTRING, 0, (LPARAM)Str);
SendDlgItemMessage(hDlg, QHOST_HOST, CB_ADDSTRING, 0, (LPARAM)Tmp.HostAdrs);
}
}
Buf = (char *)lParam;
return(TRUE);

case WM_COMMAND :
switch(GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK :
SendDlgItemMessage(hDlg, QHOST_HOST, WM_GETTEXT, FMAX_PATH+1, (LPARAM)Buf);
SendDlgItemMessage(hDlg, QHOST_USER, WM_GETTEXT, USER_NAME_LEN+1, (LPARAM)Buf + FMAX_PATH+1);
SendDlgItemMessage(hDlg, QHOST_PASS, WM_GETTEXT, PASSWORD_LEN+1, (LPARAM)Buf + FMAX_PATH+1 + USER_NAME_LEN+1);
*(Buf + FMAX_PATH+1 + USER_NAME_LEN+1 + PASSWORD_LEN+1) = (char)SendDlgItemMessage(hDlg, QHOST_FWALL, BM_GETCHECK, 0, 0);
*(Buf + FMAX_PATH+1 + USER_NAME_LEN+1 + PASSWORD_LEN+1+1) = (char)SendDlgItemMessage(hDlg, QHOST_PASV, BM_GETCHECK, 0, 0);
EndDialog(hDlg, YES);
break;

case IDCANCEL :
EndDialog(hDlg, NO);
break;

// case QHOST_HOST :
// if(HIWORD(wParam) == CBN_EDITCHANGE)
// DoPrintf("EDIT");
// break;
}
return(TRUE);
}
return(FALSE);
}


Expand Down
Loading

0 comments on commit 55ba2fb

Please sign in to comment.