1 /*******************************************************************************
\r
2 TPI - flexible but useless plug-in framework.
\r
3 Copyright (C) 2002-2009 Silky
\r
5 This library is free software; you can redistribute it and/or modify it under
\r
6 the terms of the GNU Lesser General Public License as published by the Free
\r
7 Software Foundation; either version 2.1 of the License, or (at your option)
\r
10 This library is distributed in the hope that it will be useful, but WITHOUT
\r
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
\r
15 You should have received a copy of the GNU Lesser General Public License along
\r
16 with this library; if not, write to the Free Software Foundation, Inc.,
\r
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
\r
20 *******************************************************************************/
\r
23 #include "dlg_process.h"
\r
25 ProcessDialog * g_procDlg = NULL;
\r
27 //******************************************************************************
\r
29 //******************************************************************************
\r
31 ProcessDialog::ProcessDialog(): wxDialog()
\r
33 ::wxXmlResource::Get()->Load(L_DIR_S_XRC wxT("dlg_process.xrc"));
\r
34 ::wxXmlResource::Get()->LoadDialog(this, this->GetParent(), wxT("dlg_process"));
\r
37 ProcessDialog::~ProcessDialog()
\r
42 //******************************************************************************
\r
44 //******************************************************************************
\r
46 BEGIN_EVENT_TABLE(ProcessDialog, wxDialog)
\r
47 EVT_INIT_DIALOG(ProcessDialog::OnInit)
\r
48 EVT_CLOSE( ProcessDialog::OnClose)
\r
51 //******************************************************************************
\r
53 //******************************************************************************
\r
55 void ProcessDialog::OnInit(wxInitDialogEvent &)
\r
58 this->ebSource = XRCCTRL(* this, "ebSource", wxTextCtrl);
\r
59 this->ebTarget = XRCCTRL(* this, "ebTarget", wxTextCtrl);
\r
60 this->gauge = XRCCTRL(* this, "gauge", wxGauge);
\r
61 this->fCancel = false;
\r
64 ::wxXmlResource::Get()->Unload(L_DIR_S_XRC wxT("dlg_process.xrc"));
\r
67 void ProcessDialog::OnClose(wxCloseEvent & e)
\r
69 if (e.CanVeto() && ::AskDlg(_("Really do you want to cancel this operation?"), this) == wxYES)
\r
71 this->fCancel = true;
\r
76 int ProcessDialog::CallbackProc(unsigned int _uMsg, void * _pStructure)
\r
78 if (_uMsg != TPI_NOTIFY_COMMON)
\r
80 return TPI_CALLBACK_UNSUPPORTED;
\r
83 TPI_PROCESSINFO * piInfo = (TPI_PROCESSINFO *) _pStructure;
\r
84 if (piInfo == NULL || ! g_procDlg->IsShown())
\r
86 return TPI_CALLBACK_CONTINUE;
\r
89 switch (piInfo->uMessage)
\r
91 case TPI_MESSAGE_STATUS:
\r
93 static int s_nGaugeCounter = 0;
\r
94 switch (piInfo->uStatus)
\r
96 case TPI_STATUS_OPENARCHIVE:
\r
97 this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
99 case TPI_STATUS_BEGINPROCESS:
\r
100 this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
101 this->ebTarget->ChangeValue(piInfo->fnDestination.GetFullPath());
\r
102 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
104 this->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
105 this->gauge->SetValue(0);
\r
107 ::wxSafeYield(this, true);
\r
109 case TPI_STATUS_INPROCESS:
\r
110 if (s_nGaugeCounter++ > 100)
\r
112 if (piInfo->fiInfo.llUnpackedSize > 10000)
\r
114 this->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
116 ::wxSafeYield(this, true);
\r
117 s_nGaugeCounter = 0;
\r
120 case TPI_STATUS_ENDPROCESS:
\r
121 // this->gauge->SetValue(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
125 this->ebSource->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
126 this->gauge->SetRange(piInfo->fiInfo.llUnpackedSize.ToULong());
\r
127 this->gauge->SetValue(0);
\r
130 // 更新しすぎると低速なので100ファイル毎に更新する。
\r
131 if (piInfo->llProcessedSize > this->gauge->GetValue() + 100)
\r
133 this->ebTarget->ChangeValue(piInfo->fiInfo.fnFileName.GetFullPath());
\r
134 this->gauge->SetValue(piInfo->llProcessedSize.ToULong());
\r
135 ::wxSafeYield(this, true);
\r
141 case TPI_MESSAGE_ASK:
\r
143 switch (piInfo->uStatus)
\r
145 case TPI_PARAM_PASSWORD:
\r
146 piInfo->szParam = ::wxGetPasswordFromUser(_("Password for:\n") + piInfo->fiInfo.fnFileName.GetFullPath(), wxT("Lychee"), wxEmptyString, this);
\r
147 if (piInfo->szParam.IsEmpty())
\r
149 this->fCancel = true;
\r
152 case TPI_PARAM_NEXTVOLUME:
\r
154 wxFileDialog fd(this, _("Select next volume of: ") + piInfo->fiInfo.fnFileName.GetFullName());
\r
155 fd.SetWindowStyleFlag(wxFD_FILE_MUST_EXIST);
\r
156 if (fd.ShowModal() == wxID_CANCEL)
\r
158 this->fCancel = true;
\r
160 piInfo->szParam = fd.GetPath();
\r
164 return TPI_CALLBACK_UNSUPPORTED;
\r
169 return TPI_CALLBACK_UNSUPPORTED;
\r
172 return this->fCancel ? TPI_CALLBACK_CANCEL : TPI_CALLBACK_CONTINUE;
\r
175 //******************************************************************************
\r
177 //******************************************************************************
\r
179 int __stdcall TPICallbackProc(unsigned int _uMsg, void * _pStructure)
\r
181 return g_procDlg == NULL ? TPI_CALLBACK_CONTINUE : g_procDlg->CallbackProc(_uMsg, _pStructure);
\r