1 /*******************************************************************************
2 TPI - flexible but useless plug-in framework.
3 Copyright (C) 2002-2009 Silky
5 This library is free software; you can redistribute it and/or modify it under
6 the terms of the GNU Lesser General Public License as published by the Free
7 Software Foundation; either version 2.1 of the License, or (at your option)
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 You should have received a copy of the GNU Lesser General Public License along
16 with this library; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 $Id: dlg_process.cpp,v 1.6 2009/09/01 12:20:49 sirakaba Exp $
20 *******************************************************************************/
23 #include "dlg_process.h"
25 ProcessDialog * g_procDlg = NULL;
27 //******************************************************************************
29 //******************************************************************************
31 ProcessDialog::ProcessDialog(): wxDialog()
33 ::wxXmlResource::Get()->Load(FE_DIR_S_XRC wxT("dlg_process.xrc"));
34 ::wxXmlResource::Get()->LoadDialog(this, this->GetParent(), wxT("dlg_process"));
37 ProcessDialog::~ProcessDialog()
42 //******************************************************************************
44 //******************************************************************************
46 BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)
47 EVT_INIT_DIALOG(ProcessDialog::OnInit)
48 EVT_CLOSE( ProcessDialog::OnClose)
51 //******************************************************************************
53 //******************************************************************************
55 void ProcessDialog::OnInit(wxInitDialogEvent &)
57 // XRC
\82Æ
\8c\8b\82Ñ
\82Â
\82¯
\81B
58 this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);
59 this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);
60 this->gauge = XRCCTRL(* this, "gauge", wxGauge);
61 this->fCancel = false;
64 ::wxXmlResource::Get()->Unload(FE_DIR_S_XRC wxT("dlg_process.xrc"));
67 void ProcessDialog::OnClose(wxCloseEvent & e)
69 if (e.CanVeto() && ::AskDlg(wxT("Really do you want to cancel this operation?"), this) == wxYES)
76 //******************************************************************************
77 //
\83_
\83C
\83A
\83\8d\83O
\83v
\83\8d\83V
\81[
\83W
\83\83
78 //******************************************************************************
80 int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
82 if (_uMsg != TPI_NOTIFY_COMMON)
84 return TPI_CALLBACK_UNSUPPORTED;
87 TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;
88 if (g_procDlg == NULL || piInfo == NULL || ! g_procDlg->IsShown())
90 return TPI_CALLBACK_CONTINUE;
93 switch (piInfo->uMessage)
95 case TPI_MESSAGE_STATUS:
97 static int s_nGaugeCounter = 0;
98 switch (piInfo->uStatus)
100 case TPI_STATUS_OPENARCHIVE:
101 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
103 case TPI_STATUS_BEGINPROCESS:
104 g_procDlg->ebTarget->ChangeValue((piInfo->fnDestination.IsOk() ? piInfo->fnDestination : piInfo->fiInfo.fnFileName).GetFullPath());
105 if (piInfo->fiInfo.llUnpackedSize > 10000)
107 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
108 g_procDlg->gauge->SetValue(0);
110 ::wxSafeYield(g_procDlg, true);
112 case TPI_STATUS_INPROCESS:
113 if (s_nGaugeCounter++ > 100)
115 if (piInfo->fiInfo.llUnpackedSize > 10000)
117 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
119 ::wxSafeYield(g_procDlg, true);
123 case TPI_STATUS_ENDPROCESS:
124 // g_procDlg->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());
126 //
\8f\91\8cÉ
\83\8d\81[
\83h
\8e\9e\97p
\82Ì
\93Æ
\8e©
\8ed
\97l
\81B
128 g_procDlg->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
129 g_procDlg->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
130 g_procDlg->gauge->SetValue(0);
133 //
\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
134 if (piInfo->llProcessedSize > g_procDlg->gauge->GetValue() + 100)
136 g_procDlg->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
137 g_procDlg->gauge->SetValue(piInfo->llProcessedSize.ToULong());
138 ::wxSafeYield(g_procDlg, true);
144 case TPI_MESSAGE_ASK:
146 switch (piInfo->uStatus)
148 case TPI_PARAM_PASSWORD:
149 piInfo->szParam = ::wxGetPasswordFromUser(wxT("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Frontend"), wxEmptyString, g_procDlg);
150 if (piInfo->szParam.IsEmpty())
152 g_procDlg->fCancel = true;
155 case TPI_PARAM_NEXTVOLUME:
157 wxFileDialog fd(g_procDlg, wxT("Select next volume"));
158 fd.SetWindowStyleFlag(wxFD_FILE_MUST_EXIST);
159 if (fd.ShowModal() == wxID_CANCEL)
161 g_procDlg->fCancel = true;
163 piInfo->szParam = fd.GetFilename();
167 return TPI_CALLBACK_UNSUPPORTED;
172 return TPI_CALLBACK_UNSUPPORTED;
175 return g_procDlg->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;