OSDN Git Service

Modify documents.
[ffftp/ffftp.git] / filelist.c
index 1a6e3ff..74d14bb 100644 (file)
@@ -124,6 +124,8 @@ extern int RemoteWidth;
 extern int ListHeight;\r
 extern char FilterStr[FILTER_EXT_LEN+1];\r
 extern HWND hHelpWin;\r
+// 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+extern int SuppressRefresh;\r
 \r
 /* 設定値 */\r
 extern int LocalWidth;\r
@@ -147,6 +149,8 @@ static WNDPROC LocalProcPtr;
 static WNDPROC RemoteProcPtr;\r
 \r
 static HIMAGELIST ListImg = NULL;\r
+// ファイルアイコン表示対応\r
+static HIMAGELIST ListImgFileIcon = NULL;\r
 \r
 static char FindStr[40+1] = { "*" };           /* 検索文字列 */\r
 static int IgnoreNew = NO;\r
@@ -181,6 +185,9 @@ int MakeListWin(HWND hWnd, HINSTANCE hInst)
        LV_COLUMN LvCol;\r
        long Tmp;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        /*===== ローカル側のリストビュー =====*/\r
 \r
        hWndListLocal = CreateWindowEx(/*WS_EX_STATICEDGE*/WS_EX_CLIENTEDGE,\r
@@ -493,6 +500,11 @@ static void doTransferRemoteFile(void)
                remove(fn);\r
        }\r
 \r
+       // 同時接続対応\r
+       DisableUserOpe();\r
+       // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+       SuppressRefresh = 1;\r
+\r
        // ダウンロード先をテンポラリに設定\r
        SetLocalDirHist(TmpDir);\r
 \r
@@ -524,6 +536,12 @@ static void doTransferRemoteFile(void)
        SetLocalDirHist(LocDir);\r
        SetCurrentDirAsDirHist();\r
 \r
+       // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
+       SuppressRefresh = 0;\r
+       GetLocalDirForWnd();\r
+       // 同時接続対応\r
+       EnableUserOpe();\r
+\r
        remoteFileListBase = FileListBase;  // あとでフリーすること\r
        remoteFileListBaseNoExpand = FileListBaseNoExpand;  // あとでフリーすること\r
        strncpy_s(remoteFileDir, sizeof(remoteFileDir), TmpDir, _TRUNCATE);\r
@@ -786,6 +804,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                        return(CallWindowProc(ProcPtr, hWnd, message, wParam, lParam));\r
 \r
                case WM_DROPFILES :\r
+                       // 同時接続対応\r
+                       if(AskUserOpeDisabled() == YES)\r
+                               break;\r
                        // ドラッグ中は処理しない。ドラッグ後にWM_LBUTTONDOWNが飛んでくるため、そこで処理する。\r
                        if (Dragging == YES) \r
                                return (FALSE);\r
@@ -793,7 +814,7 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                        if(hWnd == hWndListRemote)\r
                        {\r
                                if(AskConnecting() == YES)\r
-                                       UpLoadDragProc(wParam);\r
+                                       UploadDragProc(wParam);\r
                        }\r
                        else if(hWnd == hWndListLocal)\r
                        {\r
@@ -818,6 +839,9 @@ static LRESULT FileListCommonWndProc(HWND hWnd, UINT message, WPARAM wParam, LPA
                                hCsrDrg = LoadCursor(NULL, IDC_ARROW);\r
                                SetCursor(hCsrDrg);\r
 \r
+                               // 同時接続対応\r
+                               if(AskUserOpeDisabled() == YES)\r
+                                       break;\r
                                Point.x = (long)(short)LOWORD(lParam);\r
                                Point.y = (long)(short)HIWORD(lParam);\r
                                ClientToScreen(hWnd, &Point);\r
@@ -1117,6 +1141,9 @@ void GetListTabWidth(void)
        LV_COLUMN LvCol;\r
        int i;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvCol, 0, sizeof(LV_COLUMN));\r
+\r
        for(i = 0; i <= 3; i++)\r
        {\r
                LvCol.mask = LVCF_WIDTH;\r
@@ -1334,22 +1361,22 @@ void RefreshIconImageList(FLISTANCHOR *Anchor)
        int i;\r
        char Cur[FMAX_PATH+1];\r
        SHFILEINFO FileInfo;\r
-       SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
-       ShowWindow(hWndListLocal, SW_SHOW);\r
-       SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
-       ShowWindow(hWndListRemote, SW_SHOW);\r
-       ImageList_Destroy(ListImg);\r
-       ListImg = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 1);\r
-       hBitmap = LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(dirattr_bmp));\r
-       ImageList_AddMasked(ListImg, hBitmap, RGB(255,0,0));\r
-       DeleteObject(hBitmap);\r
-       ImageId = 0;\r
-       Pos = Anchor->Top;\r
-       for(i = 0; i < Anchor->Files; i++)\r
+       if(AskDispFileIcon() == YES)\r
        {\r
-               Pos->ImageId = -1;\r
-               if(AskDispFileIcon() == YES)\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)NULL);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+               ImageList_Destroy(ListImgFileIcon);\r
+               ListImgFileIcon = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 0, 1);\r
+               hBitmap = LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(dirattr16_bmp));\r
+               ImageList_AddMasked(ListImgFileIcon, hBitmap, RGB(255, 0, 0));\r
+               DeleteObject(hBitmap);\r
+               ImageId = 0;\r
+               Pos = Anchor->Top;\r
+               for(i = 0; i < Anchor->Files; i++)\r
                {\r
+                       Pos->ImageId = -1;\r
                        if(Pos->Node == NODE_DRIVE)\r
                                strcpy(Cur, Pos->File);\r
                        else\r
@@ -1360,20 +1387,27 @@ void RefreshIconImageList(FLISTANCHOR *Anchor)
                        }\r
                        if(SHGetFileInfoM(Cur, 0, &FileInfo, sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_ICON) != 0)\r
                        {\r
-                               if(ImageList_AddIcon(ListImg, FileInfo.hIcon) >= 0)\r
+                               if(ImageList_AddIcon(ListImgFileIcon, FileInfo.hIcon) >= 0)\r
                                {\r
                                        Pos->ImageId = ImageId;\r
                                        ImageId++;\r
                                }\r
                                DestroyIcon(FileInfo.hIcon);\r
                        }\r
+                       Pos = Pos->Next;\r
                }\r
-               Pos = Pos->Next;\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImgFileIcon);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
+       }\r
+       else\r
+       {\r
+               SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListLocal, SW_SHOW);\r
+               SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
+               ShowWindow(hWndListRemote, SW_SHOW);\r
        }\r
-       SendMessage(hWndListLocal, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
-       ShowWindow(hWndListLocal, SW_SHOW);\r
-       SendMessage(hWndListRemote, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)ListImg);\r
-       ShowWindow(hWndListRemote, SW_SHOW);\r
 }\r
 \r
 void GetLocalDirForWnd(void)\r
@@ -1428,7 +1462,7 @@ void GetLocalDirForWnd(void)
        if(DispDrives)\r
        {\r
                GetLogicalDriveStrings(FMAX_PATH, Scan);\r
-               NoDrives = LoadHideDriveListRegistory();\r
+               NoDrives = LoadHideDriveListRegistry();\r
 \r
                Pos = Scan;\r
                while(*Pos != NUL)\r
@@ -1510,20 +1544,36 @@ static void AddDispFileList(FLISTANCHOR *Anchor, char *Name, FILETIME *Time, LON
 \r
                        if((Sort & SORT_GET_ORD) == SORT_ASCENT)\r
                        {\r
-                               if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
-                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
+                               // 読みにくいのでリファクタリング\r
+//                             if((((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0)) ||\r
+//#if defined(HAVE_TANDEM)\r
+//                                ((AskHostType() == HTYPE_TANDEM) &&\r
+//                                 ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+//                                     ((Cmp = Attr - Pos->Attr) < 0)) ||\r
+//#endif\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+//                                     ((Cmp = Size - Pos->Size) < 0)) ||\r
+//                                (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+//                                     ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
+//                             {\r
+//                                     break;\r
+//                             }\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = _mbsicmp(GetFileExt(Name), GetFileExt(Pos->File))) < 0))\r
+                                       break;\r
 #if defined(HAVE_TANDEM)\r
-                                  ((AskHostType() == HTYPE_TANDEM) &&\r
-                                   ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
-                                       ((Cmp = Attr - Pos->Attr) < 0)) ||\r
+                               if((AskHostType() == HTYPE_TANDEM) &&\r
+                                       ((Sort & SORT_MASK_ORD) == SORT_EXT) &&\r
+                                       ((Cmp = Attr - Pos->Attr) < 0))\r
+                                       break;\r
 #endif\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
-                                       ((Cmp = Size - Pos->Size) < 0)) ||\r
-                                  (((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
-                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0)))\r
-                               {\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_SIZE) &&\r
+                                       ((Cmp = Size - Pos->Size) < 0))\r
+                                       break;\r
+                               if(((Sort & SORT_MASK_ORD) == SORT_DATE) &&\r
+                                       ((Cmp = CompareFileTime(Time, &Pos->Time)) < 0))\r
                                        break;\r
-                               }\r
 \r
                                if(((Sort & SORT_MASK_ORD) == SORT_NAME) || (Cmp == 0))\r
                                {\r
@@ -1677,6 +1727,8 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        if(Pos == -1)\r
                Pos = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        /* アイコン/ファイル名 */\r
        LvItem.mask = LVIF_TEXT | LVIF_IMAGE;\r
        LvItem.iItem = Pos;\r
@@ -1689,8 +1741,8 @@ static void AddListView(HWND hWnd, int Pos, char *Name, int Type, LONGLONG Size,
        else\r
                LvItem.iImage = 4;\r
        // ファイルアイコン表示対応\r
-       if(hWnd == GetLocalHwnd() && ImageId >= 0)\r
-               LvItem.iImage = 5 + ImageId;\r
+       if(AskDispFileIcon() == YES && hWnd == GetLocalHwnd())\r
+               LvItem.iImage = ImageId + 5;\r
        LvItem.iItem = SendMessage(hWnd, LVM_INSERTITEM, 0, (LPARAM)&LvItem);\r
 \r
        /* 日付/時刻 */\r
@@ -1799,6 +1851,8 @@ void SelectFileInList(HWND hWnd, int Type)
        FILETIME Time2;\r
        int Find;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        WinDst = WIN_REMOTE;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -1977,8 +2031,10 @@ void FindFileInList(HWND hWnd, int Type)
        static char RegExp[FMAX_PATH+1] = { "" };\r
        char Name[FMAX_PATH+1];\r
        LV_ITEM LvItem;\r
-       const char *Title;\r
+       char *Title;\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        Win = WIN_LOCAL;\r
        Title = MSGJPN050;\r
        if(hWnd == GetRemoteHwnd())\r
@@ -2260,6 +2316,8 @@ int FindNameNode(int Win, char *Name)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&FindInfo, 0, sizeof(LV_FINDINFO));\r
        FindInfo.flags = LVFI_STRING;\r
        FindInfo.psz = Name;\r
        return(SendMessage(hWnd, LVM_FINDITEM, -1, (LPARAM)&FindInfo));\r
@@ -2287,6 +2345,8 @@ void GetNodeName(int Win, int Pos, char *Buf, int Max)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 0;\r
@@ -2320,6 +2380,8 @@ int GetNodeTime(int Win, int Pos, FILETIME *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 1;\r
@@ -2354,6 +2416,8 @@ int GetNodeSize(int Win, int Pos, LONGLONG *Buf)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2401,6 +2465,8 @@ int GetNodeAttr(int Win, int Pos, int *Buf)
        Ret = NO;\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
 #if defined(HAVE_TANDEM)\r
@@ -2448,6 +2514,8 @@ int GetNodeType(int Win, int Pos)
        if(Win == WIN_REMOTE)\r
                hWnd = GetRemoteHwnd();\r
 \r
+       // 変数が未初期化のバグ修正\r
+       memset(&LvItem, 0, sizeof(LV_ITEM));\r
        LvItem.mask = LVIF_TEXT;\r
        LvItem.iItem = Pos;\r
        LvItem.iSubItem = 2;\r
@@ -2485,6 +2553,8 @@ void GetNodeOwner(int Win, int Pos, char *Buf, int Max)
        strcpy(Buf, "");\r
        if(Win == WIN_REMOTE)\r
        {\r
+               // 変数が未初期化のバグ修正\r
+               memset(&LvItem, 0, sizeof(LV_ITEM));\r
                LvItem.mask = LVIF_TEXT;\r
                LvItem.iItem = Pos;\r
                LvItem.iSubItem = 5;\r
@@ -2584,6 +2654,9 @@ void MakeSelectedFileList(int Win, int Expand, int All, FILELIST **Base, int *Ca
                        if((Node == NODE_FILE) ||\r
                           ((Expand == NO) && (Node == NODE_DIR)))\r
                        {\r
+                               // 変数が未初期化のバグ修正\r
+                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                Pkt.InfoExist = 0;\r
                                GetNodeName(Win, Pos, Pkt.File, FMAX_PATH);\r
                                if(GetNodeSize(Win, Pos, &Pkt.Size) == YES)\r
@@ -2620,6 +2693,9 @@ void MakeSelectedFileList(int Win, int Expand, int All, FILELIST **Base, int *Ca
                        {\r
                                if(GetNodeType(Win, Pos) == NODE_DIR)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        GetNodeName(Win, Pos, Name, FMAX_PATH);\r
                                        strcpy(Pkt.File, Name);\r
                                        ReplaceAll(Pkt.File, '\\', '/');\r
@@ -2717,6 +2793,9 @@ void MakeDroppedFileList(WPARAM wParam, char *Cur, FILELIST **Base)
 \r
                if((GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY) == 0)\r
                {\r
+                       // 変数が未初期化のバグ修正\r
+                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                        Pkt.Node = NODE_FILE;\r
                        strcpy(Pkt.File, GetFileName(Name));\r
 \r
@@ -2747,6 +2826,9 @@ void MakeDroppedFileList(WPARAM wParam, char *Cur, FILELIST **Base)
 \r
                if(GetFileAttributes(Name) & FILE_ATTRIBUTE_DIRECTORY)\r
                {\r
+                       // 変数が未初期化のバグ修正\r
+                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                        Pkt.Node = NODE_DIR;\r
                        strcpy(Pkt.File, GetFileName(Name));\r
                        AddFileList(&Pkt, Base);\r
@@ -2866,6 +2948,9 @@ static void MakeRemoteTree2(char *Path, char *Cur, FILELIST **Base, int *CancelC
                        {\r
                                if(Pos->Node == NODE_DIR)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        /* まずディレクトリ名をセット */\r
                                        strcpy(Pkt.File, Pos->File);\r
                                        Pkt.Node = NODE_DIR;\r
@@ -2956,6 +3041,9 @@ void AddRemoteTreeToFileList(int Num, char *Path, int IncDir, FILELIST **Base)
                                {\r
                                        if(IncDir == RDIR_NLST)\r
                                        {\r
+                                               // 変数が未初期化のバグ修正\r
+                                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                                strcpy(Pkt.File, Dir);\r
                                                Pkt.Node = NODE_DIR;\r
                                                Pkt.Size = 0;\r
@@ -2974,6 +3062,9 @@ void AddRemoteTreeToFileList(int Num, char *Path, int IncDir, FILELIST **Base)
                                        if((Node == NODE_FILE) ||\r
                                           ((IncDir == RDIR_CWD) && (Node == NODE_DIR)))\r
                                        {\r
+                                               // 変数が未初期化のバグ修正\r
+                                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                                strcpy(Pkt.File, Dir);\r
                                                if(strlen(Pkt.File) > 0)\r
                                                        SetSlashTail(Pkt.File);\r
@@ -3141,6 +3232,9 @@ static void MakeLocalTree(char *Path, FILELIST **Base)
                        {\r
                                if(AskFilterStr(FindBuf.cFileName, NODE_FILE) == YES)\r
                                {\r
+                                       // 変数が未初期化のバグ修正\r
+                                       memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                        strcpy(Pkt.File, Path);\r
                                        SetSlashTail(Pkt.File);\r
                                        strcat(Pkt.File, FindBuf.cFileName);\r
@@ -3169,6 +3263,9 @@ static void MakeLocalTree(char *Path, FILELIST **Base)
                           (strcmp(FindBuf.cFileName, ".") != 0) &&\r
                           (strcmp(FindBuf.cFileName, "..") != 0))\r
                        {\r
+                               // 変数が未初期化のバグ修正\r
+                               memset(&Pkt, 0, sizeof(FILELIST));\r
+\r
                                strcpy(Src, Path);\r
                                SetYenTail(Src);\r
                                strcat(Src, FindBuf.cFileName);\r
@@ -4905,6 +5002,7 @@ static int ResolvFileInfo(char *Str, int ListType, char *Fname, LONGLONG *Size,
                                                        sTime.wSecond = atoi_n(Value + 12, 2);\r
                                                        sTime.wMilliseconds = 0;\r
                                                        SystemTimeToFileTime(&sTime, Time);\r
+                                                       // 時刻はGMT\r
 //                                                     SpecificLocalFileTime2FileTime(Time, AskHostTimeZone());\r
                                                        *InfoExist |= FINFO_DATE | FINFO_TIME;\r
                                                }\r