summaryrefslogtreecommitdiffabout
path: root/RequestDlg.cpp
authorMichael Krelin <hacker@klever.net>2012-12-08 21:19:17 (UTC)
committer Michael Krelin <hacker@klever.net>2012-12-11 21:59:29 (UTC)
commit8808689fe340bec6e90ab13dd502292b0579cf1f (patch) (unidiff)
tree45b7c863151341f687b74e40bffcbd7ab5468783 /RequestDlg.cpp
parent6e7e413ca364d79673e523c09767c18e7cff1bec (diff)
downloadpumpkin-osx/0.0.zip
pumpkin-osx/0.0.tar.gz
pumpkin-osx/0.0.tar.bz2
initial osx portosx/0.0
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'RequestDlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--RequestDlg.cpp299
1 files changed, 0 insertions, 299 deletions
diff --git a/RequestDlg.cpp b/RequestDlg.cpp
deleted file mode 100644
index 94a8a98..0000000
--- a/RequestDlg.cpp
+++ b/dev/null
@@ -1,299 +0,0 @@
1// RequestDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "RequestDlg.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CRequestDlg dialog
16
17
18CRequestDlg::CRequestDlg(CWnd* pParent /*=NULL*/)
19 : CDialog(CRequestDlg::IDD, pParent)
20{
21 m_Put=TRUE;
22 m_Drop=FALSE;
23 //{{AFX_DATA_INIT(CRequestDlg)
24 m_Host = m_MRUHost;
25 m_LocalFile = _T("");
26 m_RemoteFile = _T("");
27 m_Type = _T("octet");
28 m_strBSize = _T("");
29 //}}AFX_DATA_INIT
30}
31
32
33void CRequestDlg::DoDataExchange(CDataExchange* pDX)
34{
35 CDialog::DoDataExchange(pDX);
36 if(!pDX->m_bSaveAndValidate)
37 m_strBSize.Format("%u",m_BSize);
38 //{{AFX_DATA_MAP(CRequestDlg)
39 DDX_Control(pDX, IDC_REMOTEFILE, m_RemoteFileCtl);
40 DDX_Control(pDX, IDC_LOCALFILE, m_LocalFileCtl);
41 DDX_Control(pDX, IDC_REFRESH, m_RefreshCtl);
42 DDX_Control(pDX, IDOK, m_OKCtl);
43 DDX_Control(pDX, IDC_TALKS, m_TalksCtl);
44 DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl);
45 DDX_CBString(pDX, IDC_TALKS, m_Host);
46 DDX_Text(pDX, IDC_LOCALFILE, m_LocalFile);
47 DDX_Text(pDX, IDC_REMOTEFILE, m_RemoteFile);
48 DDX_CBString(pDX, IDC_TYPE, m_Type);
49 DDX_CBString(pDX, IDC_BSIZE, m_strBSize);
50 //}}AFX_DATA_MAP
51 if(pDX->m_bSaveAndValidate)
52 m_BSize=atoi(m_strBSize);
53}
54
55CString CRequestDlg::m_MRUHost;
56
57BEGIN_MESSAGE_MAP(CRequestDlg, CDialog)
58 //{{AFX_MSG_MAP(CRequestDlg)
59 ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
60 ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
61 ON_EN_CHANGE(IDC_LOCALFILE, OnChangeLocalfile)
62 ON_EN_CHANGE(IDC_REMOTEFILE, OnChangeRemotefile)
63 ON_CBN_EDITCHANGE(IDC_TALKS, OnEditchangeTalks)
64 ON_CBN_SELCHANGE(IDC_TALKS, OnSelchangeTalks)
65 ON_WM_CTLCOLOR()
66 ON_WM_DROPFILES()
67 //}}AFX_MSG_MAP
68END_MESSAGE_MAP()
69
70/////////////////////////////////////////////////////////////////////////////
71// CRequestDlg message handlers
72
73BOOL CRequestDlg::OnInitDialog()
74{
75 CDialog::OnInitDialog();
76
77 m_RefreshCtl.SendMessage(WM_SETFONT,(WPARAM)::GetStockObject(ANSI_FIXED_FONT),0);
78 m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE));
79
80CString title;
81 title.LoadString(m_Put?IDS_TITLE_PUTREQUEST:IDS_TITLE_GETREQUEST);
82 SetWindowText(title);
83 UpdateOK();
84 SyncNames();
85 BringWindowToTop();
86 SetForegroundWindow();
87 OnRefresh();
88 if(!m_MRUHost.IsEmpty())
89 m_TalksCtl.SetWindowText(m_MRUHost);
90 else{
91 if(m_TalksCtl.GetCount()==1){
92 CString tmp;
93 m_TalksCtl.GetLBText(0,tmp);
94 m_TalksCtl.SetWindowText(tmp);
95 }
96 }
97
98 // CG: The following block was added by the ToolTips component.
99 {
100 // Create the ToolTip control.
101 m_tooltip.Create(this);
102 m_tooltip.Activate(TRUE);
103
104 m_tooltip.AddTool(&m_BrowseCtl,IDC_BROWSE);
105 m_tooltip.AddTool(&m_RefreshCtl,IDC_REFRESH);
106 }
107
108 if(m_Put)
109 DragAcceptFiles();
110
111 if(m_Drop || !m_Put){
112 m_RemoteFileCtl.SetFocus();
113 return FALSE;
114 }
115
116 return TRUE; // return TRUE unless you set the focus to a control
117 // EXCEPTION: OCX Property Pages should return FALSE
118}
119
120void CRequestDlg::OnRefresh()
121{
122 m_TalksCtl.ResetContent();
123CWnd *wnd = CWnd::FindWindow(NULL,NULL);
124CString wtalkHead,wtalkAt;
125 wtalkHead.LoadString(IDS_WTALKHEADING);wtalkAt.LoadString(IDS_WTALKAT);
126CString otalxHead,otalxAt;
127 otalxHead.LoadString(IDS_OTALXHEADING);otalxAt.LoadString(IDS_OTALXAT);
128 while(wnd){
129 CString text;
130 wnd->GetWindowText(text);
131 int tw = text.Find(wtalkHead);
132 if(tw==0){
133 text=text.Mid(wtalkHead.GetLength());
134 int at = text.Find(wtalkAt);
135 if(at>=0){
136 if(text.GetLength()>(at+wtalkAt.GetLength())){
137 text=text.Left(at)+'@'+text.Mid(at+wtalkAt.GetLength());
138 text.TrimLeft();
139 text.TrimRight();
140 VERIFY(m_TalksCtl.AddString(text)>=0);
141 }
142 }
143 }else{
144 tw = text.Find(otalxHead);
145 if(tw==0){
146 text=text.Mid(otalxHead.GetLength());
147 int at = text.Find(otalxAt);
148 if(at>=0){
149 if(text.GetLength()>(at+otalxAt.GetLength())){
150 text=text.Left(at)+'@'+text.Mid(at+otalxAt.GetLength());
151 text.TrimLeft();
152 text.TrimRight();
153 VERIFY(m_TalksCtl.AddString(text)>=0);
154 }
155 }
156 }
157 }
158 wnd = wnd->GetNextWindow();
159 }
160 UpdateOK();
161}
162
163void CRequestDlg::OnBrowse()
164{
165 UpdateData(TRUE);
166CFileDialog cfd(m_Put,NULL,m_LocalFile.IsEmpty()?NULL:m_LocalFile,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|(m_Put?OFN_FILEMUSTEXIST:OFN_OVERWRITEPROMPT),NULL,this);
167CString title;
168 title.LoadString(IDS_TITLE_BROWSEFILE);
169 cfd.m_ofn.lpstrTitle=(LPCTSTR)title;
170 if(cfd.DoModal()==IDOK){
171 m_LocalFile=cfd.GetPathName();
172 UpdateData(FALSE);
173 SyncNames();
174 UpdateOK();
175 }
176}
177
178void CRequestDlg::SyncNames()
179{
180 if(m_Put){
181 CString tmp;
182 m_LocalFileCtl.GetWindowText(tmp);
183 int s=tmp.ReverseFind('\\');
184 if(s>=0)
185 tmp=tmp.Mid(s+1);
186 else{
187 s = tmp.ReverseFind('/');
188 if(s>=0)
189 tmp=tmp.Mid(s+1);
190 }
191 if(!tmp.IsEmpty())
192 m_RemoteFileCtl.SetWindowText(tmp);
193 }else{
194 CString tmp;
195 m_RemoteFileCtl.GetWindowText(tmp);
196 int s=tmp.ReverseFind('\\');
197 if(s>=0)
198 tmp=tmp.Mid(s+1);
199 else{
200 s = tmp.ReverseFind('/');
201 if(s>=0)
202 tmp=tmp.Mid(s+1);
203 }
204 if(!tmp.IsEmpty())
205 m_LocalFileCtl.SetWindowText(tmp);
206 }
207}
208
209void CRequestDlg::OnChangeLocalfile()
210{
211 if(m_Put)
212 SyncNames();
213 UpdateOK();
214}
215
216void CRequestDlg::OnChangeRemotefile()
217{
218 if(!m_Put)
219 SyncNames();
220 UpdateOK();
221}
222
223void CRequestDlg::UpdateOK()
224{
225CString t;
226 m_LocalFileCtl.GetWindowText(t);
227 if(t.IsEmpty())
228 gotodAble;
229 m_RemoteFileCtl.GetWindowText(t);
230 if(t.IsEmpty())
231 goto dAble;
232 m_TalksCtl.GetWindowText(t);
233 if(t.IsEmpty())
234 goto dAble;
235 m_OKCtl.EnableWindow(TRUE);
236 return;
237dAble:
238 m_OKCtl.EnableWindow(FALSE);
239}
240
241void CRequestDlg::OnEditchangeTalks()
242{
243 UpdateOK();
244}
245
246void CRequestDlg::OnSelchangeTalks()
247{
248 UpdateOK();
249}
250
251HBRUSH CRequestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
252{
253 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
254 UpdateOK();
255 return hbr;
256}
257
258BOOL CRequestDlg::PreTranslateMessage(MSG* pMsg)
259{
260 // CG: The following block was added by the ToolTips component.
261 {
262 // Let the ToolTip process this message.
263 if(::IsWindow(m_tooltip.m_hWnd))
264 m_tooltip.RelayEvent(pMsg);
265
266 return CDialog::PreTranslateMessage(pMsg);
267 }
268}
269
270int CRequestDlg::DoModal()
271{
272int rv = CDialog::DoModal();
273 if(rv==IDOK)
274 m_MRUHost=m_Host;
275 return rv;
276}
277
278void CRequestDlg::OnDropFiles(HDROP hDropInfo)
279{
280UINT files = ::DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);
281 if(files!=1){
282 CString title,text;
283 title.LoadString(IDS_DROPFILES_TITLE);
284 text.LoadString(IDS_NOMULTIPLEDROP_TEXT);
285 if(MessageBox(text,title,MB_ICONSTOP|MB_OKCANCEL)!=IDOK){
286 ::DragFinish(hDropInfo);
287 return;
288 }
289 }
290 ASSERT(files);
291CString theFile;
292UINT fileNameLength = ::DragQueryFile(hDropInfo,0,NULL,0);
293 ASSERT(fileNameLength);
294 VERIFY(::DragQueryFile(hDropInfo,0,theFile.GetBuffer(fileNameLength+5),fileNameLength+4)<=fileNameLength);
295 theFile.ReleaseBuffer();
296 m_LocalFileCtl.SetWindowText(theFile);
297 SyncNames();
298 ::DragFinish(hDropInfo);
299}