OSDN Git Service

エラー判定でErrorCheck関数を用いる場面を増やした。
authorsirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sun, 19 Sep 2010 09:45:38 +0000 (09:45 +0000)
committersirakaba <sirakaba@9df91469-1e22-0410-86e7-ea8537beb833>
Sun, 19 Sep 2010 09:45:38 +0000 (09:45 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tpi/tpi@313 9df91469-1e22-0410-86e7-ea8537beb833

src/lychee/frm_main.cpp
src/lychee/frm_main.h

index b988e9a..1b0e6eb 100644 (file)
@@ -264,15 +264,13 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
        this->fnArchive = wxFileName(mkDlg.cbDir->GetValue(), mkDlg.cbFileName->GetValue());\r
        if (! tpi.InitLibrary(mkDlg.afInfo[nSelected].szTPIName, this->fnArchive.GetFullPath(), mkDlg.afInfo[nSelected].nTypeId))\r
        {\r
-               wxLogError(_("Error: %s!"), wxT("InitLibrary()!"));\r
+               this->ErrorCheck(tpi.nErrorCode, wxT("InitLibrary"));\r
                return;\r
        }\r
 \r
        // コールバック関数を設定。\r
-       if (! tpi.SetCallbackProc(TPICallbackProc))\r
-       {\r
-               wxLogError(_("Error: %s!"), wxT("SetCallbackProc()!"));\r
-       }\r
+       tpi.SetCallbackProc(TPICallbackProc);\r
+       this->ErrorCheck(tpi.nErrorCode, wxT("SetCallbackProc"));\r
 \r
        // 処理を行う。\r
        {\r
@@ -287,11 +285,8 @@ void MainFrame::OnArcCreate(wxCommandEvent& e)
                piInfo.fiInfo.nUnpackedSize = mkDlg.files.GetCount();\r
                procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
-               if (! tpi.Command(TPI_COMMAND_CREATE, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files))\r
-               {\r
-                       this->ErrorCheck(tpi.nErrorCode);\r
-                       return;\r
-               }\r
+               tpi.Command(TPI_COMMAND_CREATE, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files);\r
+               this->ErrorCheck(tpi.nErrorCode);\r
                procDlg.Show(false);\r
        }\r
        tpi.FreeLibrary();\r
@@ -344,7 +339,16 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        {\r
                procDlg.Show(false);\r
                tpi.FreeLibrary();\r
-               wxLogError(_("No plug-in supporting this archive was found!"));\r
+               if (this->IsShown())\r
+               {\r
+                       wxBell();\r
+                       this->statusbar->SetStatusText(_("No plug-in supporting this archive was found!"), 4);\r
+               }\r
+               else\r
+               {\r
+                       wxLogError(_("No plug-in supporting this archive was found!"));\r
+                       this->Close(true);\r
+               }\r
                return;\r
        }\r
        procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
@@ -357,7 +361,7 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        {\r
                procDlg.Show(false);\r
                tpi.FreeLibrary();\r
-               wxLogError(_("Error: %s!"), wxT("OpenArchive()"));\r
+               this->ErrorCheck(tpi.nErrorCode, wxT("OpenArchive"));\r
                return;\r
        }\r
 \r
@@ -439,22 +443,15 @@ void MainFrame::OnArcOpen(wxCommandEvent& e)
        }\r
 \r
        // GetFileInformationがエラー終了した場合。\r
-       if (tpi.nErrorCode != TPI_ERROR_S_ENDOFDATA)\r
-       {\r
-               wxLogError(_("Error: %s!"), wxT("GetFileInformation()"));\r
-       }\r
+       this->ErrorCheck(tpi.nErrorCode, wxT("GetFileInformation"));\r
 \r
        // 書庫の情報を取得。\r
-       if (! tpi.GetArchiveInformation(& this->aiArchive))\r
-       {\r
-               wxLogError(_("Error: %s!"), wxT("GetArchiveInformation()"));\r
-       }\r
+       tpi.GetArchiveInformation(& this->aiArchive);\r
+       this->ErrorCheck(tpi.nErrorCode, wxT("GetArchiveInformation"));\r
 \r
        // 書庫を閉じる。\r
-       if (! tpi.CloseArchive())\r
-       {\r
-               wxLogError(_("Error: %s!"), wxT("CloseArchive()"));\r
-       }\r
+       tpi.CloseArchive();\r
+       this->ErrorCheck(tpi.nErrorCode, wxT("CloseArchive"));\r
 \r
        // 以下、UI処理。\r
        this->fileinfo.Shrink();\r
@@ -520,7 +517,7 @@ void MainFrame::OnArcClose(wxCommandEvent& e)
        // DnDで書庫を開くときは既に読み込まれているTPIを用いるので、解放してはいけない。\r
        if (e.GetExtraLong() == 0)\r
        {\r
-               this->tpi.FreeLibrary();\r
+               tpi.FreeLibrary();\r
        }\r
 }\r
 \r
@@ -576,10 +573,8 @@ void MainFrame::OnArcAdd(wxCommandEvent& e)
                piInfo.fiInfo.nUnpackedSize = mkDlg.files.GetCount();\r
                procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
-               if (! tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files))\r
-               {\r
-                       this->ErrorCheck(tpi.nErrorCode);\r
-               }\r
+               tpi.Command(TPI_COMMAND_ADD, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files);\r
+               this->ErrorCheck(tpi.nErrorCode);\r
                procDlg.Show(false);\r
        }\r
 \r
@@ -619,10 +614,8 @@ void MainFrame::OnArcConvert(wxCommandEvent& e)
 \r
        ProcessDialog procDlg;\r
        procDlg.Show(true);\r
-       if (! this->tpi.Command(swInfo.fMakeSFX ? TPI_COMMAND_SFX : TPI_COMMAND_UNSFX, & swInfo, this->fnArchive.GetFullPath(), files))\r
-       {\r
-               this->ErrorCheck(tpi.nErrorCode);\r
-       }\r
+       tpi.Command(swInfo.fMakeSFX ? TPI_COMMAND_SFX : TPI_COMMAND_UNSFX, & swInfo, this->fnArchive.GetFullPath(), files);\r
+       this->ErrorCheck(tpi.nErrorCode);\r
        procDlg.Show(false);\r
 }\r
 \r
@@ -715,10 +708,8 @@ void MainFrame::OnArcExtract(wxCommandEvent& e)
                piInfo.fiInfo.nUnpackedSize = mkDlg.files.GetCount();\r
                procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
-               if (! tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files))\r
-               {\r
-                       this->ErrorCheck(tpi.nErrorCode);\r
-               }\r
+               tpi.Command(TPI_COMMAND_EXTRACT, & swInfo, this->fnArchive.GetFullPath(), mkDlg.files);\r
+               this->ErrorCheck(tpi.nErrorCode);\r
                procDlg.Show(false);\r
        }\r
 \r
@@ -829,10 +820,8 @@ void MainFrame::OnArcDelete(wxCommandEvent& e)
                piInfo.fiInfo.nUnpackedSize = asFiles.GetCount();\r
                procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
-               if (! tpi.Command(TPI_COMMAND_DELETE, & swInfo, this->fnArchive.GetFullPath(), asFiles))\r
-               {\r
-                       this->ErrorCheck(tpi.nErrorCode);\r
-               }\r
+               tpi.Command(TPI_COMMAND_DELETE, & swInfo, this->fnArchive.GetFullPath(), asFiles);\r
+               this->ErrorCheck(tpi.nErrorCode);\r
                procDlg.Show(false);\r
        }\r
 \r
@@ -885,10 +874,8 @@ void MainFrame::OnArcRepair(wxCommandEvent&)
        procDlg.CallbackProc(TPI_NOTIFY_COMMON, & piInfo);\r
 \r
        TPI_SWITCHES swInfo;\r
-       if (! this->tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->fnArchive.GetFullPath(), asFiles))\r
-       {\r
-               this->ErrorCheck(tpi.nErrorCode);\r
-       }\r
+       tpi.Command(TPI_COMMAND_REPAIR, & swInfo, this->fnArchive.GetFullPath(), asFiles);\r
+       this->ErrorCheck(tpi.nErrorCode);\r
        procDlg.Show(false);    \r
 }\r
 \r
@@ -1047,11 +1034,12 @@ wxULongLong_t MainFrame::LoadTPI(wxString szFileName)
        return llFileCount;\r
 }\r
 \r
-int MainFrame::ErrorCheck(int nErrorCode)\r
+int MainFrame::ErrorCheck(int nErrorCode, wxString szAPIName)\r
 {\r
        switch (nErrorCode)\r
        {\r
        case TPI_ERROR_SUCCESS:\r
+       case TPI_ERROR_S_ENDOFDATA:\r
        case TPI_CALLBACK_CONTINUE:\r
                break;\r
        case TPI_ERROR_D_UNSUPPORTED:\r
@@ -1062,7 +1050,7 @@ int MainFrame::ErrorCheck(int nErrorCode)
                wxLogError(_("This operation is canceled by the user."));\r
                break;\r
        default:\r
-               wxLogError(_("Error code: %d"), nErrorCode);\r
+               wxLogError(_("Error: %s()!\nError code: %d"), szAPIName.c_str(), nErrorCode);\r
        }\r
        return nErrorCode;\r
 }\r
index b47945e..994c297 100644 (file)
@@ -65,7 +65,7 @@ public:
        void OnFilter(wxCommandEvent&);\r
 \r
        wxULongLong_t LoadTPI(wxString);\r
-       int ErrorCheck(int);\r
+       int ErrorCheck(int, wxString szAPIName = wxT("Command"));\r
 \r
        MainFrame();\r
        ~MainFrame();\r