-/*******************************************************************************\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: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $\r
-*******************************************************************************/\r
-\r
-#include "frontend.h"\r
-#include "dlg_process.h"\r
-\r
-ProcessDialog * g_procDlg = NULL;\r
-\r
-//******************************************************************************\r
-// ProcessDialog\r
-//******************************************************************************\r
-\r
-ProcessDialog::ProcessDialog(): wxDialog()\r
-{\r
-}\r
-\r
-ProcessDialog::~ProcessDialog()\r
-{\r
- g_procDlg = NULL;\r
-}\r
-\r
-//******************************************************************************\r
-// Event table.\r
-//******************************************************************************\r
-\r
-BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)\r
- EVT_INIT_DIALOG(ProcessDialog::OnInit)\r
- EVT_CLOSE( ProcessDialog::OnClose)\r
-END_EVENT_TABLE()\r
-\r
-//******************************************************************************\r
-// Event handler.\r
-//******************************************************************************\r
-\r
-void ProcessDialog::OnInit(wxInitDialogEvent &)\r
-{\r
- // XRC\82Æ\8c\8b\82Ñ\82Â\82¯\81B\r
- this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);\r
- this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);\r
- this->gauge = XRCCTRL(* this, "gauge", wxGauge);\r
- this->fCancel = false;\r
- g_procDlg = this;\r
-\r
- ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc"));\r
-}\r
-\r
-void ProcessDialog::OnClose(wxCloseEvent & e)\r
-{\r
- if (e.CanVeto() && ::wxMessageBox(wxT("Really do you want to cancel this operation?"), wxMessageBoxCaptionStr, wxYES_NO | wxICON_EXCLAMATION, g_procDlg) == wxYES)\r
- {\r
- this->fCancel = true;\r
- }\r
- e.Veto();\r
-}\r
-\r
-//******************************************************************************\r
-// \83_\83C\83A\83\8d\83O\83v\83\8d\83V\81[\83W\83\83\r
-//******************************************************************************\r
-\r
-int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)\r
-{\r
- if (_uMsg != TPI_NOTIFY_COMMON)\r
- {\r
- return TPI_CALLBACK_UNSUPPORTED;\r
- }\r
-\r
- TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;\r
- if (g_procDlg == NULL || piInfo == NULL || piInfo->uMessage != TPI_MESSAGE_STATUS || ! g_procDlg->IsShown())\r
- {\r
- return TPI_CALLBACK_CONTINUE;\r
- }\r
-\r
- static int s_nGaugeCounter = 0;\r
- switch (piInfo->uStatus)\r
- {\r
- case TPI_STATUS_OPENARCHIVE:\r
- g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
- break;\r
- case TPI_STATUS_BEGINPROCESS:\r
- g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());\r
- if (piInfo->fiInfo.llUnpackedSize > 10000)\r
- {\r
- g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
- g_procDlg->gauge->SetValue(0);\r
- }\r
- ::wxSafeYield(g_procDlg, true);\r
- break;\r
- case TPI_STATUS_INPROCESS:\r
- if (s_nGaugeCounter++ > 100)\r
- {\r
- if (piInfo->fiInfo.llUnpackedSize > 10000)\r
- {\r
- g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
- }\r
- ::wxSafeYield(g_procDlg, true);\r
- s_nGaugeCounter = 0;\r
- }\r
- break;\r
- case TPI_STATUS_ENDPROCESS:\r
-// g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());\r
- break;\r
- // \8f\91\8cÉ\83\8d\81[\83h\8e\9e\97p\82Ì\93Æ\8e©\8ed\97l\81B\r
- case 0x1000:\r
- g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
- g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());\r
- g_procDlg->gauge->SetValue(0);\r
- break;\r
- case 0x1001:\r
- // \8dX\90V\82µ\82·\82¬\82é\82Æ\92á\91¬\82È\82Ì\82Å100\83t\83@\83C\83\8b\96\88\82É\8dX\90V\82·\82é\81B\r
- if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)\r
- {\r
- g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());\r
- g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());\r
- ::wxSafeYield(g_procDlg, true);\r
- }\r
- break;\r
- }\r
-\r
- return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;\r
-}\r
+/*******************************************************************************
+ 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_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $
+*******************************************************************************/
+
+#include "frontend.h"
+#include "dlg_process.h"
+
+ProcessDialog * g_procDlg = NULL;
+
+//******************************************************************************
+// ProcessDialog
+//******************************************************************************
+
+ProcessDialog::ProcessDialog(): wxDialog()
+{
+ ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("dlg_process.xrc"));
+ ::wxXmlResource::Get()->LoadDialog(this, this->GetParent(), wxT("dlg_process"));
+}
+
+ProcessDialog::~ProcessDialog()
+{
+ g_procDlg = NULL;
+}
+
+//******************************************************************************
+// Event table.
+//******************************************************************************
+
+BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)
+ EVT_INIT_DIALOG(ProcessDialog::OnInit)
+ EVT_CLOSE( ProcessDialog::OnClose)
+END_EVENT_TABLE()
+
+//******************************************************************************
+// Event handler.
+//******************************************************************************
+
+void ProcessDialog::OnInit(wxInitDialogEvent &)
+{
+ // XRC\82Æ\8c\8b\82Ñ\82Â\82¯\81B
+ this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);
+ this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);
+ this->gauge = XRCCTRL(* this, "gauge", wxGauge);
+ this->fCancel = false;
+ g_procDlg = this;
+
+ ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc"));
+}
+
+void ProcessDialog::OnClose(wxCloseEvent & e)
+{
+ if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES)
+ {
+ this->fCancel = true;
+ }
+ e.Veto();
+}
+
+//******************************************************************************
+// \83_\83C\83A\83\8d\83O\83v\83\8d\83V\81[\83W\83\83
+//******************************************************************************
+
+int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
+{
+ if (_uMsg != TPI_NOTIFY_COMMON)
+ {
+ return TPI_CALLBACK_UNSUPPORTED;
+ }
+
+ TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;
+ if (g_procDlg == NULL || piInfo == NULL || ! g_procDlg->IsShown())
+ {
+ return TPI_CALLBACK_CONTINUE;
+ }
+
+ switch (piInfo->uMessage)
+ {
+ case TPI_MESSAGE_STATUS:
+ {
+ static int s_nGaugeCounter = 0;
+ switch (piInfo->uStatus)
+ {
+ case TPI_STATUS_OPENARCHIVE:
+ g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
+ break;
+ case TPI_STATUS_BEGINPROCESS:
+ g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());
+ if (piInfo->fiInfo.llUnpackedSize > 10000)
+ {
+ g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
+ g_procDlg->gauge->SetValue(0);
+ }
+ ::wxSafeYield(g_procDlg, true);
+ break;
+ case TPI_STATUS_INPROCESS:
+ if (s_nGaugeCounter++ > 100)
+ {
+ if (piInfo->fiInfo.llUnpackedSize > 10000)
+ {
+ g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
+ }
+ ::wxSafeYield(g_procDlg, true);
+ s_nGaugeCounter = 0;
+ }
+ break;
+ case TPI_STATUS_ENDPROCESS:
+// g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());
+ break;
+ // \8f\91\8cÉ\83\8d\81[\83h\8e\9e\97p\82Ì\93Æ\8e©\8ed\97l\81B
+ case 0x1000:
+ g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
+ g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
+ g_procDlg->gauge->SetValue(0);
+ break;
+ case 0x1001:
+ // \8dX\90V\82µ\82·\82¬\82é\82Æ\92á\91¬\82È\82Ì\82Å100\83t\83@\83C\83\8b\96\88\82É\8dX\90V\82·\82é\81B
+ if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)
+ {
+ g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
+ g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
+ ::wxSafeYield(g_procDlg, true);
+ }
+ break;
+ }
+ break;
+ }
+ case TPI_MESSAGE_ASK:
+ {
+ switch (piInfo->uStatus)
+ {
+ case TPI_PARAM_PASSWORD:
+ piInfo->szParam = ::wxGetPasswordFromUser(wxT("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Frontend"), wxEmptyString, g_procDlg);
+ if (piInfo->szParam.IsEmpty())
+ {
+ g_procDlg->fCancel = true;
+ }
+ break;
+ case TPI_PARAM_NEXTVOLUME:
+ {
+ wxFileDialog fd(g_procDlg, wxT("Select next volume of: ") + piInfo->fiInfo.fnFileName.GetFullName());
+ fd.SetWindowStyleFlag(wxFD_FILE_MUST_EXIST);
+ if (fd.ShowModal() == wxID_CANCEL)
+ {
+ g_procDlg->fCancel = true;
+ }
+ piInfo->szParam = fd.GetPath();
+ break;
+ }
+ default:
+ return TPI_CALLBACK_UNSUPPORTED;
+ }
+ break;
+ }
+ default:
+ return TPI_CALLBACK_UNSUPPORTED;
+ }
+
+ return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;
+}