• R/O
  • HTTP
  • SSH
  • HTTPS

ffftp: Commit

FFFTPのソースコードです。


Commit MetaInfo

Revision564d244d7a0347b127bc0549cd31206a29f25d8f (tree)
Time2012-02-23 00:56:27
Authors_kawamoto <s_kawamoto@user...>
Commiters_kawamoto

Log Message

Add support for importing settings from registry.

Change Summary

Incremental Difference

Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/Resource/FFFTP.rc
+++ b/Resource/FFFTP.rc
@@ -1423,6 +1423,16 @@ BEGIN
14231423 PUSHBUTTON "中止(&S)",UPDOWNAS_STOP,101,66,50,14
14241424 END
14251425
1426+ini_from_reg_dlg DIALOG 0, 0, 211, 64
1427+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
1428+CAPTION "レジストリの設定のインポート"
1429+FONT 9, "MS Shell Dlg"
1430+BEGIN
1431+ LTEXT "INIファイルを使用するように設定されていますが、INIファイルではなくレジストリに設定が存在することを検出しました。\r\nレジストリの設定をインポートしますか。",-1,7,7,196,36
1432+ DEFPUSHBUTTON "はい",IDOK,48,42,50,14
1433+ PUSHBUTTON "いいえ",IDCANCEL,112,42,50,14
1434+END
1435+
14261436
14271437 /////////////////////////////////////////////////////////////////////////////
14281438 //
@@ -1578,9 +1588,9 @@ BEGIN
15781588 forcepasschange_dlg, DIALOG
15791589 BEGIN
15801590 LEFTMARGIN, 7
1581- RIGHTMARGIN, 139
1591+ RIGHTMARGIN, 204
15821592 TOPMARGIN, 7
1583- BOTTOMMARGIN, 43
1593+ BOTTOMMARGIN, 57
15841594 END
15851595
15861596 opt_trmode2_dlg, DIALOG
@@ -2066,9 +2076,9 @@ BEGIN
20662076 updatesslroot_dlg, DIALOG
20672077 BEGIN
20682078 LEFTMARGIN, 7
2069- RIGHTMARGIN, 139
2079+ RIGHTMARGIN, 204
20702080 TOPMARGIN, 7
2071- BOTTOMMARGIN, 43
2081+ BOTTOMMARGIN, 57
20722082 END
20732083
20742084 updown_as_with_ext_dlg, DIALOG
@@ -2076,7 +2086,15 @@ BEGIN
20762086 LEFTMARGIN, 7
20772087 RIGHTMARGIN, 180
20782088 TOPMARGIN, 7
2079- BOTTOMMARGIN, 87
2089+ BOTTOMMARGIN, 82
2090+ END
2091+
2092+ ini_from_reg_dlg, DIALOG
2093+ BEGIN
2094+ LEFTMARGIN, 7
2095+ RIGHTMARGIN, 204
2096+ TOPMARGIN, 7
2097+ BOTTOMMARGIN, 57
20802098 END
20812099 END
20822100 #endif // APSTUDIO_INVOKED
--- a/Resource/resource.h
+++ b/Resource/resource.h
@@ -114,6 +114,7 @@
114114 #define savecrypt_dlg 191
115115 #define updatesslroot_dlg 192
116116 #define updown_as_with_ext_dlg 193
117+#define ini_from_reg_dlg 194
117118 #define TRANS_TIME_BAR 1002
118119 #define TRANS_TEXT 1003
119120 #define TRANS_REMOTE 1003
@@ -629,7 +630,7 @@
629630 //
630631 #ifdef APSTUDIO_INVOKED
631632 #ifndef APSTUDIO_READONLY_SYMBOLS
632-#define _APS_NEXT_RESOURCE_VALUE 193
633+#define _APS_NEXT_RESOURCE_VALUE 195
633634 #define _APS_NEXT_COMMAND_VALUE 40177
634635 #define _APS_NEXT_CONTROL_VALUE 1213
635636 #define _APS_NEXT_SYMED_VALUE 101
--- a/Resource_eng/FFFTP-eng.rc
+++ b/Resource_eng/FFFTP-eng.rc
@@ -1452,6 +1452,16 @@ BEGIN
14521452 PUSHBUTTON "Cancel",UPDOWNAS_STOP,101,66,50,14
14531453 END
14541454
1455+ini_from_reg_dlg DIALOG 0, 0, 211, 64
1456+STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
1457+CAPTION "Import settings from registry"
1458+FONT 9, "MS Shell Dlg"
1459+BEGIN
1460+ LTEXT "The INI file that will be used was not found, but settings are detected in the registry.\r\nImport settings from the registry to the INI file?",-1,7,7,196,36
1461+ DEFPUSHBUTTON "Yes",IDOK,48,42,50,14
1462+ PUSHBUTTON "No",IDCANCEL,112,42,50,14
1463+END
1464+
14551465
14561466 /////////////////////////////////////////////////////////////////////////////
14571467 //
@@ -1607,9 +1617,9 @@ BEGIN
16071617 forcepasschange_dlg, DIALOG
16081618 BEGIN
16091619 LEFTMARGIN, 7
1610- RIGHTMARGIN, 139
1620+ RIGHTMARGIN, 204
16111621 TOPMARGIN, 7
1612- BOTTOMMARGIN, 43
1622+ BOTTOMMARGIN, 57
16131623 END
16141624
16151625 opt_trmode2_dlg, DIALOG
@@ -2092,9 +2102,9 @@ BEGIN
20922102 updatesslroot_dlg, DIALOG
20932103 BEGIN
20942104 LEFTMARGIN, 7
2095- RIGHTMARGIN, 139
2105+ RIGHTMARGIN, 204
20962106 TOPMARGIN, 7
2097- BOTTOMMARGIN, 43
2107+ BOTTOMMARGIN, 57
20982108 END
20992109
21002110 updown_as_with_ext_dlg, DIALOG
@@ -2102,7 +2112,15 @@ BEGIN
21022112 LEFTMARGIN, 7
21032113 RIGHTMARGIN, 180
21042114 TOPMARGIN, 7
2105- BOTTOMMARGIN, 87
2115+ BOTTOMMARGIN, 82
2116+ END
2117+
2118+ ini_from_reg_dlg, DIALOG
2119+ BEGIN
2120+ LEFTMARGIN, 7
2121+ RIGHTMARGIN, 204
2122+ TOPMARGIN, 7
2123+ BOTTOMMARGIN, 57
21062124 END
21072125 END
21082126 #endif // APSTUDIO_INVOKED
--- a/Resource_eng/resource.h
+++ b/Resource_eng/resource.h
@@ -114,6 +114,7 @@
114114 #define savecrypt_dlg 191
115115 #define updatesslroot_dlg 192
116116 #define updown_as_with_ext_dlg 193
117+#define ini_from_reg_dlg 194
117118 #define TRANS_TIME_BAR 1002
118119 #define TRANS_TEXT 1003
119120 #define TRANS_REMOTE 1003
@@ -629,7 +630,7 @@
629630 //
630631 #ifdef APSTUDIO_INVOKED
631632 #ifndef APSTUDIO_READONLY_SYMBOLS
632-#define _APS_NEXT_RESOURCE_VALUE 193
633+#define _APS_NEXT_RESOURCE_VALUE 195
633634 #define _APS_NEXT_COMMAND_VALUE 40177
634635 #define _APS_NEXT_CONTROL_VALUE 1213
635636 #define _APS_NEXT_SYMED_VALUE 101
--- a/common.h
+++ b/common.h
@@ -1704,12 +1704,17 @@ int CheckFname(char *str, char *regexp);
17041704 void SaveRegistry(void);
17051705 int LoadRegistry(void);
17061706 void ClearRegistry(void);
1707+// ポータブル版判定
1708+void ClearIni(void);
17071709 void SetMasterPassword( const char* );
17081710 int GetMasterPasswordStatus(void);
17091711 int ValidateMasterPassword(void);
17101712 DWORD LoadHideDriveListRegistry(void);
17111713 void SaveSettingsToFile(void);
17121714 int LoadSettingsFromFile(void);
1715+// ポータブル版判定
1716+int IsRegAvailable();
1717+int IsIniAvailable();
17131718
17141719 /*===== lvtips.c =====*/
17151720
--- a/main.c
+++ b/main.c
@@ -407,6 +407,8 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
407407 char PwdBuf[FMAX_PATH+1];
408408 int useDefautPassword = 0; /* 警告文表示用 */
409409 int masterpass;
410+ // ポータブル版判定
411+ int ImportPortable;
410412
411413 sts = FFFTP_FAIL;
412414
@@ -448,10 +450,20 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
448450 GetModuleFileName(NULL, PortableFilePath, FMAX_PATH);
449451 strcpy(GetFileName(PortableFilePath), "portable");
450452 CheckPortableVersion();
453+ ImportPortable = NO;
451454 if(PortableVersion == YES)
452455 {
453456 ForceIni = YES;
454457 RegType = REGTYPE_INI;
458+ if(IsRegAvailable() == YES && IsIniAvailable() == NO)
459+ {
460+ if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(ini_from_reg_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)
461+ {
462+ ImportPortable = YES;
463+ ForceIni = NO;
464+ RegType = REGTYPE_REG;
465+ }
466+ }
455467 }
456468
457469 // AllocConsole();
@@ -506,6 +518,13 @@ static int InitApp(LPSTR lpszCmdLine, int cmdShow)
506518 {
507519 LoadRegistry();
508520
521+ // ポータブル版判定
522+ if(ImportPortable == YES)
523+ {
524+ ForceIni = YES;
525+ RegType = REGTYPE_INI;
526+ }
527+
509528 // 暗号化通信対応
510529 SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);
511530 SetSSLConfirmCallback(SSLConfirmCallback);
@@ -1387,6 +1406,8 @@ static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
13871406 if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)
13881407 {
13891408 ClearRegistry();
1409+ // ポータブル版判定
1410+ ClearIni();
13901411 SaveExit = NO;
13911412 PostMessage(hWnd, WM_CLOSE, 0, 0L);
13921413 }
@@ -2094,6 +2115,9 @@ static void ExitProc(HWND hWnd)
20942115 {
20952116 GetListTabWidth();
20962117 SaveRegistry();
2118+ // ポータブル版判定
2119+ if(RegType == REGTYPE_REG)
2120+ ClearIni();
20972121
20982122 if((CacheEntry > 0) && (CacheSave == YES))
20992123 SaveCache();
--- a/mbswrapper.c
+++ b/mbswrapper.c
@@ -2156,6 +2156,18 @@ END_ROUTINE
21562156 return r;
21572157 }
21582158
2159+BOOL DeleteFileM(LPCSTR lpFileName)
2160+{
2161+ BOOL r = FALSE;
2162+ wchar_t* pw0 = NULL;
2163+START_ROUTINE
2164+ pw0 = DuplicateMtoW(lpFileName, -1);
2165+ r = DeleteFileW(pw0);
2166+END_ROUTINE
2167+ FreeDuplicatedString(pw0);
2168+ return r;
2169+}
2170+
21592171 int mkdirM(const char * _Path)
21602172 {
21612173 int r = -1;
--- a/mbswrapper.h
+++ b/mbswrapper.h
@@ -176,6 +176,9 @@ BOOL CopyFileM(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, BOOL bFailIfExis
176176 #undef MoveFile
177177 #define MoveFile MoveFileM
178178 BOOL MoveFileM(LPCSTR lpExistingFileName, LPCSTR lpNewFileName);
179+#undef DeleteFile
180+#define DeleteFile DeleteFileM
181+BOOL DeleteFileM(LPCSTR lpFileName);
179182 #undef mkdir
180183 #define mkdir _mkdirM
181184 int mkdirM(const char * _Path);
--- a/registry.c
+++ b/registry.c
@@ -1130,6 +1130,20 @@ void ClearRegistry(void)
11301130 }
11311131
11321132
1133+// ポータブル版判定
1134+void ClearIni(void)
1135+{
1136+// FILE *Strm;
1137+// if((Strm = fopen(AskIniFilePath(), "rt")) != NULL)
1138+// {
1139+// fclose(Strm);
1140+// MoveFileToTrashCan(AskIniFilePath());
1141+// }
1142+ DeleteFile(AskIniFilePath());
1143+ return;
1144+}
1145+
1146+
11331147 /*----- 設定をファイルに保存 --------------------------------------------------
11341148 *
11351149 * Parameter
@@ -1966,18 +1980,20 @@ static int CloseReg(void *Handle)
19661980 {
19671981 REGDATATBL *Pos;
19681982 REGDATATBL *Next;
1969- FILE *Strm;
1983+ // ポータブル版判定
1984+// FILE *Strm;
19701985
19711986 if(TmpRegType == REGTYPE_REG)
19721987 {
19731988 RegCloseKey(Handle);
19741989
19751990 /* INIファイルを削除 */
1976- if((Strm = fopen(AskIniFilePath(), "rt")) != NULL)
1977- {
1978- fclose(Strm);
1979- MoveFileToTrashCan(AskIniFilePath());
1980- }
1991+ // ポータブル版判定
1992+// if((Strm = fopen(AskIniFilePath(), "rt")) != NULL)
1993+// {
1994+// fclose(Strm);
1995+// MoveFileToTrashCan(AskIniFilePath());
1996+// }
19811997 }
19821998 else
19831999 {
@@ -2927,3 +2943,33 @@ DWORD GetRandamDWRODValue(void)
29272943 }
29282944 return rndValue;
29292945 }
2946+
2947+// ポータブル版判定
2948+int IsRegAvailable()
2949+{
2950+ int Sts;
2951+ void* h;
2952+ Sts = NO;
2953+ SetRegType(REGTYPE_REG);
2954+ if(OpenReg("FFFTP", &h) == FFFTP_SUCCESS)
2955+ {
2956+ CloseReg(h);
2957+ Sts = YES;
2958+ }
2959+ return Sts;
2960+}
2961+
2962+int IsIniAvailable()
2963+{
2964+ int Sts;
2965+ void* h;
2966+ Sts = NO;
2967+ SetRegType(REGTYPE_INI);
2968+ if(OpenReg("FFFTP", &h) == FFFTP_SUCCESS)
2969+ {
2970+ CloseReg(h);
2971+ Sts = YES;
2972+ }
2973+ return Sts;
2974+}
2975+
Show on old repository browser