OSDN Git Service

asInputをfilesへのポインタに変更。
[tpi/lychee.git] / src / lychee / dlg_make.cpp
index afe3525..0fb4a6c 100644 (file)
-/*******************************************************************************
-  TPI - flexible but useless plug-in framework.
-  Copyright (C) 2002-2009 Silky
-
-  This library is free software; you can redistribute it and/or modify it under
-  the terms of the GNU Lesser General Public License as published by the Free
-  Software Foundation; either version 2.1 of the License, or (at your option)
-  any later version.
-
-  This library is distributed in the hope that it will be useful, but WITHOUT
-  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
-  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
-  for more details.
-
-  You should have received a copy of the GNU Lesser General Public License along
-  with this library; if not, write to the Free Software Foundation, Inc.,
-  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-
-  $Id: dlg_make.cpp,v 1.15 2009/08/30 08:07:17 sirakaba Exp $
-*******************************************************************************/
-
-#include "frontend.h"
-
-#include "dlg_make.h"
-#include "frm_main.h"
-#include "functions.h"
-
-#include <wx/dirdlg.h>
-#include <wx/arrimpl.cpp>
-
-WX_DEFINE_OBJARRAY(ArrayTPI_FORMATINFO);
-
-//******************************************************************************
-// MakeDialog
-//******************************************************************************
-
-MakeDialog::MakeDialog(): wxDialog()
-{
-       this->bIsMake = true;
-}
-
-//******************************************************************************
-// Event Table.
-//******************************************************************************
-
-BEGIN_EVENT_TABLE(MakeDialog, wxDialog)
-       EVT_INIT_DIALOG(                 MakeDialog::OnInit)
-       EVT_BUTTON(XRCID("btnDefault"),  MakeDialog::OnBtnDefault)
-       EVT_BUTTON(XRCID("btnDesktop"),  MakeDialog::OnBtnDesktop)
-       EVT_BUTTON(XRCID("btnCurrent"),  MakeDialog::OnBtnCurrent)
-       EVT_BUTTON(XRCID("btnBrowse"),   MakeDialog::OnBtnBrowse)
-       EVT_BUTTON(XRCID("btnBrowseKF"), MakeDialog::OnBtnBrowseKF)
-       EVT_BUTTON(XRCID("btnOK"),       MakeDialog::OnBtnOK)
-       EVT_BUTTON(XRCID("btnCancel"),   MakeDialog::OnBtnCancel)
-       EVT_CHOICE(XRCID("chType"),      MakeDialog::OnChoice)
-       EVT_CHECKBOX(XRCID("cbUnmask"),  MakeDialog::OnCbUnmask)
-       EVT_NOTEBOOK_PAGE_CHANGED(XRCID("nbTabs"), MakeDialog::OnTabChanged)
-END_EVENT_TABLE()
-
-//******************************************************************************
-// Event handler.
-//******************************************************************************
-
-void MakeDialog::OnInit(wxInitDialogEvent&)
-{
-       // XRC\82Æ\8c\8b\82Ñ\82Â\82¯\81B
-       // "General"\83^\83u
-       this->cbDir             = XRCCTRL(* this, "cbDir",        wxComboBox);
-       this->cbFileName        = XRCCTRL(* this, "cbFileName",   wxComboBox);
-       this->cbOpenAfter       = XRCCTRL(* this, "cbOpenAfter",  wxCheckBox);
-       this->cbIgnorePath      = XRCCTRL(* this, "cbIgnorePath", wxCheckBox);
-       this->cbExitAfter       = XRCCTRL(* this, "cbExitAfter",  wxCheckBox);
-       this->chType            = XRCCTRL(* this, "chType",       wxChoice);
-       this->chDirMake         = XRCCTRL(* this, "chDirMake",    wxChoice);
-       // "Config"\83^\83u
-       this->scLevel           = XRCCTRL(* this, "scLevel",      wxSpinCtrl);
-       this->scRR              = XRCCTRL(* this, "scRR",         wxSpinCtrl);
-       this->tcPassword        = XRCCTRL(* this, "tcPassword",   wxTextCtrl);
-       this->tcKeyfile         = XRCCTRL(* this, "tcKeyfile",    wxTextCtrl);
-       this->cbSplitSize       = XRCCTRL(* this, "cbSplitSize",  wxComboBox);
-       this->cbUnmask          = XRCCTRL(* this, "cbUnmask",     wxCheckBox);
-       this->cbEncryptHeader   = XRCCTRL(* this, "cbEncryptHeader", wxCheckBox);
-       this->cbSolid           = XRCCTRL(* this, "cbSolid",      wxCheckBox);
-       this->cbMMOptimize      = XRCCTRL(* this, "cbMMOptimize", wxCheckBox);
-       this->cbMakeSFX         = XRCCTRL(* this, "cbMakeSFX",    wxCheckBox);
-       // "Comment"\83^\83u
-       this->tcComment         = XRCCTRL(* this, "tcComment",    wxTextCtrl);
-       // "Files"\83^\83u
-       this->lcFiles           = XRCCTRL(* this, "lcFiles",      wxListCtrl);
-
-       if (! this->cbDir->GetValue().IsEmpty())
-       {
-               return;
-       }
-
-       // ListCtrl\82É\97ñ\82ð\92Ç\89Á\81B
-       this->lcFiles->InsertColumn(0, wxT("Input"),  wxLIST_FORMAT_LEFT,  150);
-       this->lcFiles->InsertColumn(1, wxT("Output"), wxLIST_FORMAT_LEFT,  300);
-
-       ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_make.xrc"));
-
-       // \93W\8aJ\8e\9e\82Í\8ae\8eí\83R\83\93\83g\83\8d\81[\83\8b\82Ì\8fó\91Ô\82ð\95Ï\8dX\82·\82é\81B
-       if (! this->bIsMake)
-       {
-               this->cbFileName->Disable();
-               this->chType->Disable();
-               this->chDirMake->Enable();
-               this->scLevel->Disable();
-               this->scRR->Disable();
-               this->cbSplitSize->Disable();
-               this->cbEncryptHeader->Disable();
-               this->cbSolid->Disable();
-               this->cbMMOptimize->Disable();
-               this->cbMakeSFX->Disable();
-               this->tcComment->SetEditable(false);
-
-               // \8f\89\8aú\92l\82ð\90Ý\92è\81B
-               this->cbDir->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetPath());
-               this->cbFileName->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetFullName());
-
-               // \93W\8aJ\90æ\82ð\97\\91ª\81B\82½\82¾\82µDTV\83X\83L\83\83\83\93\82É\8e\9e\8aÔ\82ª\82©\82©\82é\8fê\8d\87\82Í\83X\83L\83b\83v\89Â\94\\81B
-               if (this->files.Count() < 3000 || ::AskDlg(wxT("This archive contains so many files that it takes long to check Directory Traversal Vulnerability(DTV) problem. If you are sure this archive is safe, you can skip this scanning process. Do you want to scan for DTV problem?"), this) == wxYES)
-               {
-                       wxNotebookEvent e;
-                       e.SetSelection(-3);
-                       this->OnTabChanged(e);
-               }
-               return;
-       }
-
-       // \83\89\83C\83u\83\89\83\8a\82ð\8c\9f\8dõ\81B
-       TPIHandle tpi;
-       wxFileSystem fs;
-       fs.ChangePathTo(FE_DIR_B_LIB, true);
-       wxString szTPIName = fs.FindFirst(wxT("*" TPI_EXT), wxFILE);
-       while (! szTPIName.IsEmpty())
-       {
-               // \83\8d\81[\83h\81B
-               if (tpi.InitLibrary(szTPIName, wxEmptyString, 0))
-               {
-                       // \91Î\89\9e\82·\82é\8c`\8e®\96¼\82ð\8eæ\93¾\81B
-                       TPI_FORMATINFO fiInfo;
-                       if (tpi.GetFormatInformation(& fiInfo, true) == TPI_ERROR_SUCCESS)
-                       {
-                               do
-                               {
-                                       if (fiInfo.llSupportedCommand & TPI_COMMAND_ADD)
-                                       {
-                                               fiInfo.szTPIName = szTPIName;
-                                               this->afInfo.Add(fiInfo);
-                                               this->chType->Append(fiInfo.szTypeName);
-                                       }
-                               }
-                               while (tpi.GetFormatInformation(& fiInfo, false) == TPI_ERROR_SUCCESS);
-                       }
-                       tpi.FreeLibrary();
-               }
-               szTPIName = fs.FindNext();
-       }
-
-       // \82Æ\82è\82 \82¦\82¸\8dÅ\8f\89\82Ì\8c`\8e®\82É\82µ\82Ä\82¨\82­\81B
-       this->chType->SetSelection(0);
-       wxCommandEvent e;
-       e.SetInt(0);
-       this->OnChoice(e);
-}
-
-void MakeDialog::OnBtnDefault(wxCommandEvent&)
-{
-}
-
-void MakeDialog::OnBtnDesktop(wxCommandEvent&)
-{
-       wxFileName fn(wxFileName::GetHomeDir(), wxT("Desktop"));
-       this->cbDir->SetValue(fn.GetFullPath());
-}
-
-void MakeDialog::OnBtnCurrent(wxCommandEvent&)
-{
-       this->cbDir->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetPath());
-}
-
-void MakeDialog::OnBtnBrowse(wxCommandEvent&)
-{
-       wxDirDialog dd(this);
-       dd.SetPath(this->cbDir->GetValue());
-       if (dd.ShowModal() == wxID_OK)
-       {
-               this->cbDir->SetValue(dd.GetPath());
-       }
-}
-
-void MakeDialog::OnBtnBrowseKF(wxCommandEvent&)
-{
-       wxFileDialog fd(this);
-       fd.SetWindowStyleFlag(wxFD_OPEN | wxFD_FILE_MUST_EXIST);
-       if (fd.ShowModal() == wxID_OK)
-       {
-               this->tcKeyfile->SetValue(fd.GetPath());
-       }
-}
-
-void MakeDialog::OnBtnOK(wxCommandEvent&)
-{
-       this->EndModal(wxID_OK);
-}
-
-void MakeDialog::OnBtnCancel(wxCommandEvent&)
-{
-       this->EndModal(wxID_CANCEL);
-}
-
-void MakeDialog::OnChoice(wxCommandEvent& e)
-{
-       TPI_FORMATINFO * fiInfo = & this->afInfo[e.GetInt()];
-       // \8c`\8e®\82ª\8ae\8eí\90Ý\92è\82É\91Î\89\9e\82µ\82Ä\82¢\82é\82©\81B
-       this->scLevel->SetRange(fiInfo->sCompressLevelMin, fiInfo->sCompressLevelMax);
-       this->scLevel->SetValue(fiInfo->sCompressLevelMax);
-       this->scLevel->Enable(fiInfo->sCompressLevelMin != fiInfo->sCompressLevelMax);
-       this->scRR->SetRange(fiInfo->sRecoveryRecordMin, fiInfo->sRecoveryRecordMax);
-       this->scRR->SetValue(fiInfo->sRecoveryRecordMin);
-       this->scRR->Enable(fiInfo->sRecoveryRecordMin != fiInfo->sRecoveryRecordMax);
-       this->cbSplitSize->Enable(fiInfo->fMultiVolume);
-       this->tcPassword->Enable(fiInfo->fEncryptPassword);
-       this->cbUnmask->Enable(fiInfo->fEncryptPassword);
-       this->tcKeyfile->Enable(fiInfo->fEncryptKeyFile);
-       this->cbEncryptHeader->Enable(fiInfo->fEncryptHeader);
-       this->cbMakeSFX->Enable(fiInfo->fSFX);
-       this->cbSolid->Enable(fiInfo->fSolid);
-       this->cbMMOptimize->Enable(fiInfo->fMMOptimize);
-       this->tcComment->Enable(fiInfo->fComment);
-}
-
-void MakeDialog::OnCbUnmask(wxCommandEvent&)
-{
-       this->tcPassword->SetWindowStyle(this->tcPassword->GetWindowStyle() & (this->cbUnmask->IsChecked() ? ~ wxTE_PASSWORD : wxTE_PASSWORD));
-       this->tcPassword->Refresh();
-}
-
-void MakeDialog::OnTabChanged(wxNotebookEvent& e)
-{
-       // "Files"\83^\83u\82Ì\82Æ\82«\82Í\8f\88\97\9d\81B
-       bool bReallyShow = e.GetSelection() == 3;
-       if (abs(e.GetSelection()) != 3)
-       {
-               return;
-       }
-
-       // "Files"\83^\83u\82ð\95\\8e¦\82·\82é\8f\89\89ñ\82©\82Ç\82¤\82©\81B
-       if (bReallyShow && this->lcFiles->GetItemCount() == 0)
-       {
-               // \83t\83@\83C\83\8b\83\8a\83X\83g\82ð\92Ç\89Á\81B
-               for (size_t i = 0; i < this->files.Count(); i++)
-               {
-                       this->lcFiles->InsertItem(i, this->files[i]);
-               }
-       }
-
-       if (bIsMake)
-       {
-               // \8ai\94[\83p\83X\82ð\90\84\91ª\81B
-               for (size_t i = 0; i < this->files.Count(); i++)
-               {
-                       if (bReallyShow)
-                       {
-                               this->lcFiles->SetItem(i, 1, this->files[i]);
-                       }
-               }
-       }
-       else
-       {
-               // \83t\83@\83C\83\8b\82Ì\8fo\97Í\90æ\82ð\90\84\91ª\81B
-               wxString szOutputRootDir = WillMakeDirByArcName((MainFrame *) this->GetParent(), this) ? MakeDirPath(wxFileName::DirName(this->cbDir->GetValue()), wxFileName(this->cbFileName->GetValue()).GetName(), false).GetPath() : this->cbDir->GetValue();
-
-               // \8ae\83t\83@\83C\83\8b\82É\83p\83X\82ð\95t\89Á\81B
-               bool fDTVWarning = false;
-               for (size_t i = 0; i < this->files.Count(); i++)
-               {
-                       wxString szOutputFile = szOutputRootDir + wxFileName::GetPathSeparator();
-                       wxFileName fnStored(this->files[i]);
-                       if (! this->cbIgnorePath->IsChecked())
-                       {
-                               szOutputFile += fnStored.GetPathWithSep();
-                       }
-                       szOutputFile += fnStored.GetFullName();
-                       wxFileName fnOutput(szOutputFile);
-                       if (! fnOutput.Normalize() || ! fnOutput.GetFullPath().StartsWith(szOutputRootDir))
-                       {
-                               fDTVWarning = true;
-                               if (bReallyShow)
-                               {
-                                       this->lcFiles->SetItemTextColour(i, * wxRED);
-                               }
-                       }
-                       if (bReallyShow)
-                       {
-                               this->lcFiles->SetItem(i, 1, fnOutput.GetFullPath());
-                       }
-               }
-
-               if (fDTVWarning && ::AskDlg(wxT("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! It is strongly recommended to ignore file path. Would you like to do so?"), this) == wxYES)
-               {
-                       this->cbIgnorePath->SetValue(true);
-                       if (bReallyShow)
-                       {
-                               this->OnTabChanged(e);
-                       }
-               }
-       }
-}
+/*******************************************************************************\r
+  TPI - flexible but useless plug-in framework.\r
+  Copyright (C) 2002-2009 Silky\r
+\r
+  This library is free software; you can redistribute it and/or modify it under\r
+  the terms of the GNU Lesser General Public License as published by the Free\r
+  Software Foundation; either version 2.1 of the License, or (at your option)\r
+  any later version.\r
+\r
+  This library is distributed in the hope that it will be useful, but WITHOUT\r
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or \r
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License\r
+  for more details.\r
+\r
+  You should have received a copy of the GNU Lesser General Public License along\r
+  with this library; if not, write to the Free Software Foundation, Inc.,\r
+  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\r
+\r
+  $Id$\r
+*******************************************************************************/\r
+\r
+#include "lychee.h"\r
+\r
+#include "dlg_make.h"\r
+#include "frm_main.h"\r
+#include "functions.h"\r
+\r
+#include <wx/dirdlg.h>\r
+#include <wx/arrimpl.cpp>\r
+\r
+WX_DEFINE_OBJARRAY(ArrayTPI_FORMATINFO);\r
+\r
+//******************************************************************************\r
+// MakeDialog\r
+//******************************************************************************\r
+\r
+MakeDialog::MakeDialog(): wxDialog()\r
+{\r
+       this->uCommand = TPI_COMMAND_CREATE;\r
+}\r
+\r
+//******************************************************************************\r
+// Event Table.\r
+//******************************************************************************\r
+\r
+BEGIN_EVENT_TABLE(MakeDialog, wxDialog)\r
+       EVT_INIT_DIALOG(                 MakeDialog::OnInit)\r
+       EVT_BUTTON(XRCID("btnDefault"),  MakeDialog::OnBtnDefault)\r
+       EVT_BUTTON(XRCID("btnDesktop"),  MakeDialog::OnBtnDesktop)\r
+       EVT_BUTTON(XRCID("btnCurrent"),  MakeDialog::OnBtnCurrent)\r
+       EVT_BUTTON(XRCID("btnBrowse"),   MakeDialog::OnBtnBrowse)\r
+       EVT_BUTTON(XRCID("btnBrowseKF"), MakeDialog::OnBtnBrowseKF)\r
+       EVT_BUTTON(XRCID("btnOK"),       MakeDialog::OnBtnOK)\r
+       EVT_BUTTON(XRCID("btnCancel"),   MakeDialog::OnBtnCancel)\r
+       EVT_CHOICE(XRCID("chType"),      MakeDialog::OnChoice)\r
+       EVT_CHECKBOX(XRCID("cbUnmask"),  MakeDialog::OnCbUnmask)\r
+       EVT_CHECKBOX(XRCID("cbMakeSFX"), MakeDialog::OnCbMakeSFX)\r
+       EVT_NOTEBOOK_PAGE_CHANGED(XRCID("nbTabs"), MakeDialog::OnTabChanged)\r
+END_EVENT_TABLE()\r
+\r
+//******************************************************************************\r
+// Event handler.\r
+//******************************************************************************\r
+\r
+void MakeDialog::OnInit(wxInitDialogEvent&)\r
+{\r
+       // XRCと結びつけ。\r
+       // "General"タブ\r
+       this->cbDir             = XRCCTRL(* this, "cbDir",        wxComboBox);\r
+       this->cbFileName        = XRCCTRL(* this, "cbFileName",   wxComboBox);\r
+       this->cbOpenAfter       = XRCCTRL(* this, "cbOpenAfter",  wxCheckBox);\r
+       this->cbIgnorePath      = XRCCTRL(* this, "cbIgnorePath", wxCheckBox);\r
+       this->cbExitAfter       = XRCCTRL(* this, "cbExitAfter",  wxCheckBox);\r
+       this->chType            = XRCCTRL(* this, "chType",       wxChoice);\r
+       this->chDirMake         = XRCCTRL(* this, "chDirMake",    wxChoice);\r
+       // "Config"タブ\r
+       this->scLevel           = XRCCTRL(* this, "scLevel",      wxSpinCtrl);\r
+       this->scRR              = XRCCTRL(* this, "scRR",         wxSpinCtrl);\r
+       this->cbSolid           = XRCCTRL(* this, "cbSolid",      wxCheckBox);\r
+       this->cbMMOptimize      = XRCCTRL(* this, "cbMMOptimize", wxCheckBox);\r
+       this->cbCompressHeader  = XRCCTRL(* this, "cbCompressHeader", wxCheckBox);\r
+       this->cbMakeSFX         = XRCCTRL(* this, "cbMakeSFX",    wxCheckBox);\r
+       // "Comment"タブ\r
+       this->tcComment         = XRCCTRL(* this, "tcComment",    wxTextCtrl);\r
+       // "Encryption"タブ\r
+       this->tcPassword        = XRCCTRL(* this, "tcPassword",   wxTextCtrl);\r
+       this->tcKeyfile         = XRCCTRL(* this, "tcKeyfile",    wxTextCtrl);\r
+       this->cbSplitSize       = XRCCTRL(* this, "cbSplitSize",  wxComboBox);\r
+       this->cbUnmask          = XRCCTRL(* this, "cbUnmask",     wxCheckBox);\r
+       this->cbEncryptHeader   = XRCCTRL(* this, "cbEncryptHeader", wxCheckBox);\r
+       this->chEncryptMethod   = XRCCTRL(* this, "chEncryptMethod", wxChoice);\r
+       // "Files"タブ\r
+       this->lcFiles           = XRCCTRL(* this, "lcFiles",      myListCtrl2);\r
+\r
+       // 2回目以降は無視。\r
+       if (! this->cbDir->GetValue().IsEmpty())\r
+       {\r
+               return;\r
+       }\r
+\r
+       // ListCtrlに列を追加。\r
+       // wxGTKでは直接wxLC_VIRTUALを指定しないと反映されない。\r
+       this->lcFiles->SetSingleStyle(wxLC_VIRTUAL);\r
+       this->lcFiles->InsertColumn(0, _("Input"),  wxLIST_FORMAT_LEFT,  150);\r
+       this->lcFiles->InsertColumn(1, _("Output"), wxLIST_FORMAT_LEFT,  290);\r
+       this->lcFiles->asInput = & this->files;\r
+       this->lcFiles->atDangerItem.SetTextColour(* wxRED);\r
+\r
+       ::wxXmlResource::Get()->Unload(L_DIR_S_XRC wxT("dlg_make.xrc"));\r
+\r
+       // 事前準備。\r
+       MainFrame * frm_main = (MainFrame *) this->GetParent();\r
+       wxString szArcPath = frm_main->fnArchive.GetPath(), szArcName = frm_main->fnArchive.GetName();\r
+\r
+       // パス履歴読み込み。\r
+       for (size_t i = 0; i < frm_main->conf.GetHistoryCount(CONF_HISTORY_PATH); i++)\r
+       {\r
+               wxString sz = frm_main->conf.ReadHistory(CONF_HISTORY_PATH, i);\r
+               if (sz.IsEmpty())\r
+               {\r
+                       continue;\r
+               }\r
+\r
+               this->cbDir->Append(sz);\r
+       }\r
+       // 書庫名履歴読み込み。\r
+       for (size_t i = 0; i < frm_main->conf.GetHistoryCount(CONF_HISTORY_NAME); i++)\r
+       {\r
+               wxString sz = frm_main->conf.ReadHistory(CONF_HISTORY_NAME, i);\r
+               if (sz.IsEmpty())\r
+               {\r
+                       continue;\r
+               }\r
+\r
+               this->cbFileName->Append(sz);\r
+       }\r
+\r
+       // パスを設定。\r
+       this->cbDir->SetValue(szArcPath);\r
+\r
+       // コマンド別の処理。\r
+       switch (this->uCommand)\r
+       {\r
+       case TPI_COMMAND_EXTRACT:\r
+               // 初期値を設定。\r
+               this->SetTitle(_("Extract"));\r
+               this->tcComment->SetValue(frm_main->aiArchive.szComment);\r
+\r
+               // コントロールを無効化。\r
+               this->scLevel->Disable();\r
+               this->scRR->Disable();\r
+               this->cbSolid->Disable();\r
+               this->cbMMOptimize->Disable();\r
+               this->tcComment->SetEditable(false);\r
+               this->cbEncryptHeader->Disable();\r
+               this->chEncryptMethod->Disable();\r
+       case TPI_COMMAND_ADD:\r
+               // コントロールを無効化(展開時も)。\r
+               this->cbFileName->Disable();\r
+               this->chType->Disable();\r
+               this->chDirMake->Enable();\r
+               this->cbSplitSize->Disable();\r
+               this->cbCompressHeader->Disable();\r
+               this->cbMakeSFX->Disable();\r
+\r
+               // 書庫名を設定。\r
+               this->cbFileName->SetValue(szArcName);\r
+\r
+               // 書庫形式欄を設定。\r
+               this->afInfo.Add(frm_main->aiArchive.fiInfo);\r
+               this->chType->Append(frm_main->aiArchive.fiInfo.szTypeName);\r
+               this->chType->SetSelection(0);\r
+               {\r
+                       wxCommandEvent e;\r
+                       e.SetInt(0);\r
+                       this->OnChoice(e);\r
+               }\r
+\r
+               if (this->uCommand != TPI_COMMAND_ADD)\r
+               {\r
+                       break;\r
+               }\r
+               this->SetTitle(_("Add"));\r
+\r
+               // コントロールを無効化(追加時のみ)。\r
+               this->cbDir->Disable();\r
+               this->chDirMake->Disable();\r
+               XRCCTRL(* this, "btnDefault", wxButton)->Disable();\r
+               XRCCTRL(* this, "btnDesktop", wxButton)->Disable();\r
+               XRCCTRL(* this, "btnCurrent", wxButton)->Disable();\r
+               XRCCTRL(* this, "btnBrowse",  wxButton)->Disable();\r
+               break;\r
+       case TPI_COMMAND_CREATE:\r
+               this->SetTitle(_("Create"));\r
+\r
+               // 書庫名を設定。初期化の都合上.を付加しておく。\r
+               this->cbFileName->SetValue(szArcName + wxT('.'));\r
+\r
+               // ライブラリを検索。\r
+               TPIHandle tpi;\r
+               wxDir fs(L_DIR_B_LIB);\r
+               wxString szTPIName;\r
+               if (fs.GetFirst(& szTPIName,wxT("*" TPI_EXT)))\r
+               {\r
+                       do\r
+                       {\r
+                               // ロード。\r
+                               wxString szLibName = L_DIR_B_LIB + szTPIName;\r
+                               if (tpi.InitLibrary(szLibName, wxEmptyString, 0))\r
+                               {\r
+                                       // 対応する形式名を取得。\r
+                                       TPI_FORMATINFO fiInfo;\r
+                                       if (tpi.GetFormatInformation(& fiInfo, true))\r
+                                       {\r
+                                               do\r
+                                               {\r
+                                                       if (fiInfo.eSupportedCommand & TPI_COMMAND_CREATE && (this->lcFiles->asInput->GetCount() == 1 || fiInfo.fArchive))\r
+                                                       {\r
+                                                               fiInfo.szTPIName = szLibName;\r
+                                                               this->afInfo.Add(fiInfo);\r
+                                                               this->chType->Append(fiInfo.szTypeName);\r
+                                                       }\r
+                                               }\r
+                                               while (tpi.GetFormatInformation(& fiInfo, false));\r
+                                       }\r
+                                       tpi.FreeLibrary();\r
+                               }\r
+                       }\r
+                       while (fs.GetNext(& szTPIName));\r
+               }\r
+\r
+               if (this->chType->GetCount() == 0)\r
+               {\r
+                       // 形式の候補が一つもない場合。\r
+                       XRCCTRL(* this, "btnOK", wxButton)->Disable();\r
+                       break;\r
+               }\r
+\r
+               // とりあえず最初の形式にしておく。\r
+               this->chType->SetSelection(0);\r
+               wxCommandEvent e;\r
+               e.SetInt(0);\r
+               this->OnChoice(e);\r
+               break;\r
+       }\r
+\r
+       // 展開/格納先を予測。ただしDTVスキャンに時間がかかる場合はスキップ可能。\r
+       if (this->lcFiles->asInput->GetCount() < 3000 || ::AskDlg(_("This archive contains so many files that it takes long to check Directory Traversal Vulnerability(DTV) problem. If you are sure this archive is safe, you can skip this scanning process. Do you want to scan for DTV problem?"), this) == wxYES)\r
+       {\r
+               wxNotebookEvent e;\r
+               e.SetSelection(3);\r
+               this->OnTabChanged(e);\r
+       }\r
+}\r
+\r
+void MakeDialog::OnBtnDefault(wxCommandEvent&)\r
+{\r
+       this->cbDir->SetValue(((MainFrame *) this->GetParent())->conf.ReadId(CONF_DEFAULT_PATH, (wxString) wxEmptyString));\r
+}\r
+\r
+void MakeDialog::OnBtnDesktop(wxCommandEvent&)\r
+{\r
+       wxFileName fn(wxFileName::GetHomeDir(), wxT("Desktop"));\r
+       this->cbDir->SetValue(fn.GetFullPath());\r
+}\r
+\r
+void MakeDialog::OnBtnCurrent(wxCommandEvent&)\r
+{\r
+       this->cbDir->SetValue(((MainFrame *) this->GetParent())->fnArchive.GetPath());\r
+}\r
+\r
+void MakeDialog::OnBtnBrowse(wxCommandEvent&)\r
+{\r
+       wxDirDialog dd(this);\r
+       dd.SetPath(this->cbDir->GetValue());\r
+       if (dd.ShowModal() == wxID_OK)\r
+       {\r
+               this->cbDir->SetValue(dd.GetPath());\r
+       }\r
+}\r
+\r
+void MakeDialog::OnBtnBrowseKF(wxCommandEvent&)\r
+{\r
+       wxFileDialog fd(this);\r
+       fd.SetWindowStyleFlag(wxFD_OPEN | wxFD_FILE_MUST_EXIST);\r
+       if (fd.ShowModal() == wxID_OK)\r
+       {\r
+               this->tcKeyfile->SetValue(fd.GetPath());\r
+       }\r
+}\r
+\r
+void MakeDialog::OnBtnOK(wxCommandEvent&)\r
+{\r
+       // 履歴書き込み。\r
+       if (this->uCommand != TPI_COMMAND_ADD)\r
+       {\r
+               MainFrame * frm_main = (MainFrame *) this->GetParent();\r
+               wxFileName fnCurrent(this->cbDir->GetValue(), this->uCommand == TPI_COMMAND_CREATE ? this->cbFileName->GetValue() : (wxString) wxEmptyString);\r
+               frm_main->conf.WriteHistory(CONF_HISTORY_FULL, fnCurrent.GetFullPath());\r
+               frm_main->conf.WriteHistory(CONF_HISTORY_PATH, fnCurrent.GetPath());\r
+               frm_main->conf.WriteHistory(CONF_HISTORY_NAME, fnCurrent.GetFullName());\r
+       }\r
+       this->EndModal(wxID_OK);\r
+}\r
+\r
+void MakeDialog::OnBtnCancel(wxCommandEvent&)\r
+{\r
+       this->EndModal(wxID_CANCEL);\r
+}\r
+\r
+void MakeDialog::OnChoice(wxCommandEvent& e)\r
+{\r
+       TPI_FORMATINFO * fiInfo = & this->afInfo[e.GetInt()];\r
+       // 形式が各種設定に対応しているか。\r
+       // 作成時/追加時/展開時設定。\r
+       this->tcPassword->Enable(fiInfo->fEncryptPassword);\r
+       this->tcKeyfile->Enable(fiInfo->fEncryptKeyFile);\r
+       this->cbUnmask->Enable(fiInfo->fEncryptPassword);\r
+       this->chEncryptMethod->Enable(fiInfo->fEncryptPassword || fiInfo->fEncryptKeyFile);\r
+       XRCCTRL(* this, "btnBrowseKF", wxButton)->Enable(fiInfo->fEncryptKeyFile);\r
+       if (this->uCommand == TPI_COMMAND_EXTRACT)\r
+       {\r
+               return;\r
+       }\r
+\r
+       // 作成時/追加時設定。\r
+       this->scLevel->SetRange(fiInfo->nCompressLevelMin, fiInfo->nCompressLevelMax);\r
+       this->scLevel->SetValue(fiInfo->nCompressLevelMax);\r
+       this->scLevel->Enable(fiInfo->nCompressLevelMin != fiInfo->nCompressLevelMax);\r
+       this->scRR->SetRange(fiInfo->nRecoveryRecordMin, fiInfo->nRecoveryRecordMax);\r
+       this->scRR->SetValue(fiInfo->nRecoveryRecordMin);\r
+       this->scRR->Enable(fiInfo->nRecoveryRecordMin != fiInfo->nRecoveryRecordMax);\r
+       this->cbEncryptHeader->Enable(fiInfo->fEncryptHeader);\r
+       this->cbCompressHeader->Enable(fiInfo->fCompressHeader);\r
+       this->cbSolid->Enable(fiInfo->fSolid);\r
+       this->cbMMOptimize->Enable(fiInfo->fMMOptimize);\r
+       this->tcComment->Enable(fiInfo->fComment);\r
+       if (this->uCommand == TPI_COMMAND_ADD)\r
+       {\r
+               return;\r
+       }\r
+\r
+       // 作成時設定。\r
+       this->cbSplitSize->Enable(fiInfo->fMultiVolume);\r
+       this->cbMakeSFX->Enable(fiInfo->fSFX);\r
+\r
+       wxFileName fn(this->cbFileName->GetValue());\r
+       fn.SetExt(this->cbMakeSFX->IsEnabled() && this->cbMakeSFX->IsChecked() ? EXE_EXT : fiInfo->szSuffix.BeforeFirst(wxT(';')));\r
+       this->cbFileName->SetValue(fn.GetFullName());\r
+}\r
+\r
+void MakeDialog::OnCbUnmask(wxCommandEvent&)\r
+{\r
+       this->tcPassword->SetWindowStyle(this->tcPassword->GetWindowStyle() & (this->cbUnmask->IsChecked() ? ~ wxTE_PASSWORD : wxTE_PASSWORD));\r
+       this->tcPassword->Refresh();\r
+}\r
+\r
+void MakeDialog::OnCbMakeSFX(wxCommandEvent&)\r
+{\r
+       wxFileName fn(this->cbFileName->GetValue());\r
+       fn.SetExt(this->cbMakeSFX->IsChecked() ? EXE_EXT : this->afInfo[this->chType->GetSelection()].szSuffix.BeforeFirst(wxT(';')));\r
+       this->cbFileName->SetValue(fn.GetFullName());\r
+}\r
+\r
+void MakeDialog::OnTabChanged(wxNotebookEvent& e)\r
+{\r
+       // "Files"タブのときは処理。\r
+       if (e.GetSelection() != 3)\r
+       {\r
+               return;\r
+       }\r
+       this->lcFiles->DeleteAllItems();\r
+       this->lcFiles->asOutput.Clear();\r
+       this->lcFiles->apItem.Clear();\r
+\r
+       switch (this->uCommand)\r
+       {\r
+       case TPI_COMMAND_EXTRACT:\r
+       {\r
+               // ファイルの出力先を推測。\r
+               wxString szOutputRootDir = WillMakeDirByArcName((MainFrame *) this->GetParent(), this) ? MakeDirPath(wxFileName::DirName(this->cbDir->GetValue()), wxFileName(this->cbFileName->GetValue()).GetName(), false).GetPath() : this->cbDir->GetValue();\r
+\r
+               // 各ファイルにパスを付加。\r
+               bool fDTVWarning = false;\r
+               for (size_t i = 0; i < this->lcFiles->asInput->GetCount(); i++)\r
+               {\r
+                       wxString szOutputFile = szOutputRootDir + wxFileName::GetPathSeparator();\r
+                       wxFileName fnStored(this->lcFiles->asInput->Item(i));\r
+                       if (! this->cbIgnorePath->IsChecked())\r
+                       {\r
+                               szOutputFile += fnStored.GetPathWithSep();\r
+                       }\r
+                       wxFileName fnOutput(szOutputFile + fnStored.GetFullName());\r
+                       if (! fnOutput.Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE | wxPATH_NORM_LONG) || ! fnOutput.GetFullPath().StartsWith(szOutputRootDir))\r
+                       {\r
+                               fDTVWarning = true;\r
+                               this->lcFiles->apItem.Add(& this->lcFiles->atDangerItem);\r
+                       }\r
+                       else\r
+                       {\r
+                               this->lcFiles->apItem.Add(NULL);\r
+                       }\r
+                       this->lcFiles->asOutput.Add(fnOutput.GetFullPath());\r
+               }\r
+\r
+               if (fDTVWarning && ::AskDlg(_("This archive may have Directory Traversal Vulnerability(DTV) problem, and some danger files may be extracted to the unexpected system directory! It is strongly recommended to ignore file path. Would you like to do so?"), this) == wxYES)\r
+               {\r
+                       this->cbIgnorePath->SetValue(true);\r
+                       this->OnTabChanged(e);\r
+               }\r
+               break;\r
+       }\r
+       case TPI_COMMAND_ADD:\r
+       case TPI_COMMAND_CREATE:\r
+               // TODO : 格納パスを推測。\r
+               this->lcFiles->asOutput = * this->lcFiles->asInput;\r
+               this->lcFiles->apItem.SetCount(this->lcFiles->asInput->GetCount(), NULL);\r
+               break;\r
+       }\r
+\r
+       // リストビューに表示。\r
+       this->lcFiles->SetItemCount(this->lcFiles->asInput->GetCount());\r
+}\r
+\r
+//******************************************************************************\r
+// myListCtrl2\r
+//******************************************************************************\r
+\r
+IMPLEMENT_DYNAMIC_CLASS(myListCtrl2, wxListView)\r
+\r
+//******************************************************************************\r
+// Event handler.\r
+//******************************************************************************\r
+wxString myListCtrl2::OnGetItemText(long i, long column) const\r
+{\r
+       // リストビューに項目を追加。\r
+       switch (column)\r
+       {\r
+       case 0:\r
+               return this->asInput->Item(i);\r
+       case 1:\r
+               return this->asOutput[i];\r
+       default:\r
+               return wxEmptyString;\r
+       }\r
+}\r
+\r
+wxListItemAttr * myListCtrl2::OnGetItemAttr(long i) const\r
+{\r
+       return (wxListItemAttr *) this->apItem[i];\r
+}\r