OSDN Git Service

Fix bugs of playing sound.
[ffftp/ffftp.git] / getput.c
index d7e00c2..1c287b6 100644 (file)
--- a/getput.c
+++ b/getput.c
@@ -120,6 +120,8 @@ static HANDLE hListAccMutex;                        /* 転送ファイルアクセス用ミューテ
 \r
 static int TransFiles = 0;                             /* 転送待ちファイル数 */\r
 static TRANSPACKET *TransPacketBase = NULL;    /* 転送ファイルリスト */\r
+// 同時接続対応\r
+static TRANSPACKET *NextTransPacketBase = NULL;\r
 \r
 // 同時接続対応\r
 //static int Canceled;         /* 中止フラグ YES/NO */\r
@@ -373,6 +375,9 @@ void AddTransFileList(TRANSPACKET *Pkt)
                        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
                }\r
        }\r
+       // 同時接続対応\r
+       if(NextTransPacketBase == NULL)\r
+               NextTransPacketBase = TransPacketBase;\r
        ReleaseMutex(hListAccMutex);\r
 \r
        return;\r
@@ -413,6 +418,9 @@ void AppendTransFileList(TRANSPACKET *Pkt)
                        Pos = Pos->Next;\r
                Pos->Next = Pkt;\r
        }\r
+       // 同時接続対応\r
+       if(NextTransPacketBase == NULL)\r
+               NextTransPacketBase = TransPacketBase;\r
 \r
        while(Pkt != NULL)\r
        {\r
@@ -494,19 +502,26 @@ static void EraseTransFileList(void)
                if(strcmp(New->Cmd, "BACKCUR") == 0)\r
                {\r
                        if(NotDel != NULL)\r
-                               free(NotDel);\r
+                               // 同時接続対応\r
+//                             free(NotDel);\r
+                               strcpy(NotDel->Cmd, "");\r
                        NotDel = New;\r
                        New = New->Next;\r
-                       NotDel->Next = NULL;\r
+                       // 同時接続対応\r
+//                     NotDel->Next = NULL;\r
                }\r
                else\r
                {\r
                        Next = New->Next;\r
-                       free(New);\r
+                       // 同時接続対応\r
+//                     free(New);\r
+                       strcpy(New->Cmd, "");\r
                        New = Next;\r
                }\r
        }\r
        TransPacketBase = NotDel;\r
+       // 同時接続対応\r
+       NextTransPacketBase = TransPacketBase;\r
        TransFiles = 0;\r
        PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);\r
        ReleaseMutex(hListAccMutex);\r
@@ -611,8 +626,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
        char Tmp[FMAX_PATH+1];\r
        int CwdSts;\r
        int GoExit;\r
-       int Down;\r
-       int Up;\r
+//     int Down;\r
+//     int Up;\r
+       static int Down;\r
+       static int Up;\r
        int DelNotify;\r
        int ThreadCount;\r
        SOCKET CmdSkt;\r
@@ -650,6 +667,12 @@ static ULONG WINAPI TransferThread(void *Dummy)
 //             Canceled = NO;\r
                Canceled[ThreadCount] = NO;\r
 \r
+               while(TransPacketBase != NULL && strcmp(TransPacketBase->Cmd, "") == 0)\r
+               {\r
+                       Pos = TransPacketBase;\r
+                       TransPacketBase = TransPacketBase->Next;\r
+                       free(Pos);\r
+               }\r
                NewCmdSkt = AskCmdCtrlSkt();\r
                if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())\r
                {\r
@@ -682,10 +705,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
                }\r
                CmdSkt = NewCmdSkt;\r
 //             if(TransPacketBase != NULL)\r
-               if(TrnSkt != INVALID_SOCKET && TransPacketBase != NULL)\r
+               if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)\r
                {\r
-                       Pos = TransPacketBase;\r
-                       TransPacketBase = TransPacketBase->Next;\r
+                       Pos = NextTransPacketBase;\r
+                       NextTransPacketBase = NextTransPacketBase->Next;\r
                        // ディレクトリ操作は非同期で行わない\r
 //                     ReleaseMutex(hListAccMutex);\r
                        if(hWndTrans == NULL)\r
@@ -1003,6 +1026,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                        for(i = 0; i < MAX_DATA_CONNECTION; i++)\r
                                                Canceled[i] = YES;\r
                                        EraseTransFileList();\r
+                                       Pos = NULL;\r
                                }\r
                                else\r
                                {\r
@@ -1032,7 +1056,8 @@ static ULONG WINAPI TransferThread(void *Dummy)
                        }\r
                        if(hWndTrans != NULL)\r
                                SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);\r
-                       free(Pos);\r
+                       if(Pos != NULL)\r
+                               strcpy(Pos->Cmd, "");\r
                }\r
 //             else\r
                else if(TransPacketBase == NULL)\r
@@ -1047,20 +1072,20 @@ static ULONG WINAPI TransferThread(void *Dummy)
                                        DestroyWindow(hWndTrans);\r
                                        hWndTrans = NULL;\r
 \r
-                                       if(GoExit == YES)\r
-                                       {\r
-                                               SoundPlay(SND_TRANS);\r
-\r
-                                               if(AskAutoExit() == NO)\r
-                                               {\r
-                                                       if(Down == YES)\r
-                                                               PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
-                                                       if(Up == YES)\r
-                                                               PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
-                                               }\r
-                                               Down = NO;\r
-                                               Up = NO;\r
-                                       }\r
+//                                     if(GoExit == YES)\r
+//                                     {\r
+//                                             SoundPlay(SND_TRANS);\r
+//\r
+//                                             if(AskAutoExit() == NO)\r
+//                                             {\r
+//                                                     if(Down == YES)\r
+//                                                             PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
+//                                                     if(Up == YES)\r
+//                                                             PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
+//                                             }\r
+//                                             Down = NO;\r
+//                                             Up = NO;\r
+//                                     }\r
                                }\r
                        }\r
                        BackgrndMessageProc();\r
@@ -1068,6 +1093,16 @@ static ULONG WINAPI TransferThread(void *Dummy)
 \r
                        if(GoExit == YES)\r
                        {\r
+                               SoundPlay(SND_TRANS);\r
+                               if(AskAutoExit() == NO)\r
+                               {\r
+                                       if(Down == YES)\r
+                                               PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);\r
+                                       if(Up == YES)\r
+                                               PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);\r
+                               }\r
+                               Down = NO;\r
+                               Up = NO;\r
                                PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0);\r
                                GoExit = NO;\r
                        }\r
@@ -3010,7 +3045,10 @@ static void DispUploadFinishMsg(TRANSPACKET *Pkt, int iRetCode)
 //                     if((Pkt->hWndTrans != NULL) && (TimeStart != 0))\r
 //                             SetTaskMsg(MSGJPN115, TimeStart, Pkt->ExistSize/TimeStart);\r
                        if((Pkt->hWndTrans != NULL) && (TimeStart[Pkt->ThreadCount] != 0))\r
-                               SetTaskMsg(MSGJPN115, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               // "0 B/S"と表示されるバグを修正\r
+                               // 原因は%dにあたる部分に64ビット値が渡されているため\r
+//                             SetTaskMsg(MSGJPN115, TimeStart[Pkt->ThreadCount], Pkt->ExistSize/TimeStart[Pkt->ThreadCount]);\r
+                               SetTaskMsg(MSGJPN115, (LONG)TimeStart[Pkt->ThreadCount], (LONG)(Pkt->ExistSize/TimeStart[Pkt->ThreadCount]));\r
                        else\r
                                SetTaskMsg(MSGJPN116);\r
                }\r