-rw-r--r-- | PumpKINDlg.cpp | 109 |
1 files changed, 101 insertions, 8 deletions
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp index b6b8a36..4cb1633 100644 --- a/PumpKINDlg.cpp +++ b/PumpKINDlg.cpp | |||
@@ -2,15 +2,17 @@ | |||
2 | // | 2 | // |
3 | 3 | ||
4 | #include "stdafx.h" | 4 | #include "stdafx.h" |
5 | #include "PumpKIN.h" | 5 | #include "PumpKIN.h" |
6 | #include "PumpKINDlg.h" | 6 | #include "PumpKINDlg.h" |
7 | 7 | ||
8 | #include "ACLTargetCombo.h" | ||
8 | #include "PropsServer.h" | 9 | #include "PropsServer.h" |
9 | #include "PropsNetwork.h" | 10 | #include "PropsNetwork.h" |
10 | #include "PropsSounds.h" | 11 | #include "PropsSounds.h" |
12 | #include "PropsACL.h" | ||
11 | #include "ConfirmRRQDlg.h" | 13 | #include "ConfirmRRQDlg.h" |
12 | #include "ConfirmWRQDlg.h" | 14 | #include "ConfirmWRQDlg.h" |
13 | #include "RequestDlg.h" | 15 | #include "RequestDlg.h" |
14 | #include "Resolver.h" | 16 | #include "Resolver.h" |
15 | #include "Retrier.h" | 17 | #include "Retrier.h" |
16 | #include "Trayer.h" | 18 | #include "Trayer.h" |
@@ -76,12 +78,16 @@ END_MESSAGE_MAP() | |||
76 | ///////////////////////////////////////////////////////////////////////////// | 78 | ///////////////////////////////////////////////////////////////////////////// |
77 | // CPumpKINDlg dialog | 79 | // CPumpKINDlg dialog |
78 | 80 | ||
79 | CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/) | 81 | CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/) |
80 | : CDialog(CPumpKINDlg::IDD, pParent) | 82 | : CDialog(CPumpKINDlg::IDD, pParent) |
81 | { | 83 | { |
84 | m_Listener.m_Daddy = this; | ||
85 | |||
86 | m_bListen = TRUE; | ||
87 | |||
82 | m_ListenPort = 69; | 88 | m_ListenPort = 69; |
83 | m_bTFTPSubdirs = TRUE; | 89 | m_bTFTPSubdirs = TRUE; |
84 | m_RRQMode = rrqAlwaysConfirm; | 90 | m_RRQMode = rrqAlwaysConfirm; |
85 | m_WRQMode = wrqAlwaysConfirm; | 91 | m_WRQMode = wrqAlwaysConfirm; |
86 | m_TFTPTimeOut = CTimeSpan(0,0,0,30); | 92 | m_TFTPTimeOut = CTimeSpan(0,0,0,30); |
87 | m_RetryTimeOut = CTimeSpan(0,0,0,10); | 93 | m_RetryTimeOut = CTimeSpan(0,0,0,10); |
@@ -104,19 +110,29 @@ CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/) | |||
104 | m_bmpBack.LoadBitmap(IDB_BACKGROUND); | 110 | m_bmpBack.LoadBitmap(IDB_BACKGROUND); |
105 | m_bmpBack.GetBitmap(&m_bitmapBack); | 111 | m_bmpBack.GetBitmap(&m_bitmapBack); |
106 | m_Retrier = new CRetrier(this); | 112 | m_Retrier = new CRetrier(this); |
107 | ASSERT(m_Retrier); | 113 | ASSERT(m_Retrier); |
108 | m_Trayer = new CTrayer(this); | 114 | m_Trayer = new CTrayer(this); |
109 | ASSERT(m_Trayer); | 115 | ASSERT(m_Trayer); |
116 | /* Ensure we're backwards compatible */ | ||
117 | ASSERT(CPumpKINDlg::rrqGiveAll==0); | ||
118 | ASSERT(CPumpKINDlg::rrqAlwaysConfirm==1); | ||
119 | ASSERT(CPumpKINDlg::rrqDenyAll==2); | ||
120 | ASSERT(CPumpKINDlg::wrqTakeAll==0); | ||
121 | ASSERT(CPumpKINDlg::wrqConfirmIfExists==1); | ||
122 | ASSERT(CPumpKINDlg::wrqAlwaysConfirm==2); | ||
123 | ASSERT(CPumpKINDlg::wrqDenyAll==3); | ||
124 | /* -- */ | ||
110 | LoadSettings(); | 125 | LoadSettings(); |
111 | } | 126 | } |
112 | 127 | ||
113 | void CPumpKINDlg::DoDataExchange(CDataExchange* pDX) | 128 | void CPumpKINDlg::DoDataExchange(CDataExchange* pDX) |
114 | { | 129 | { |
115 | CDialog::DoDataExchange(pDX); | 130 | CDialog::DoDataExchange(pDX); |
116 | //{{AFX_DATA_MAP(CPumpKINDlg) | 131 | //{{AFX_DATA_MAP(CPumpKINDlg) |
132 | DDX_Control(pDX, IDC_LISTENING, m_ListenCtl); | ||
117 | DDX_Control(pDX, IDC_ABORT, m_AbortCtl); | 133 | DDX_Control(pDX, IDC_ABORT, m_AbortCtl); |
118 | DDX_Control(pDX, IDC_OPTIONS, m_OptionsCtl); | 134 | DDX_Control(pDX, IDC_OPTIONS, m_OptionsCtl); |
119 | DDX_Control(pDX, IDC_LOG, m_Log); | 135 | DDX_Control(pDX, IDC_LOG, m_Log); |
120 | DDX_Control(pDX, IDC_CONNECTIONS, m_List); | 136 | DDX_Control(pDX, IDC_CONNECTIONS, m_List); |
121 | //}}AFX_DATA_MAP | 137 | //}}AFX_DATA_MAP |
122 | } | 138 | } |
@@ -148,12 +164,14 @@ BEGIN_MESSAGE_MAP(CPumpKINDlg, CDialog) | |||
148 | ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile) | 164 | ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile) |
149 | ON_WM_WINDOWPOSCHANGING() | 165 | ON_WM_WINDOWPOSCHANGING() |
150 | ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog) | 166 | ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog) |
151 | ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder) | 167 | ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder) |
152 | ON_WM_DROPFILES() | 168 | ON_WM_DROPFILES() |
153 | ON_BN_CLICKED(ID_HELP, OnHelp) | 169 | ON_BN_CLICKED(ID_HELP, OnHelp) |
170 | ON_BN_CLICKED(IDC_LISTENING, OnListening) | ||
171 | ON_COMMAND(ID_TRAY_LISTEN, OnTrayListen) | ||
154 | //}}AFX_MSG_MAP | 172 | //}}AFX_MSG_MAP |
155 | END_MESSAGE_MAP() | 173 | END_MESSAGE_MAP() |
156 | 174 | ||
157 | ///////////////////////////////////////////////////////////////////////////// | 175 | ///////////////////////////////////////////////////////////////////////////// |
158 | // CPumpKINDlg message handlers | 176 | // CPumpKINDlg message handlers |
159 | 177 | ||
@@ -214,12 +232,14 @@ CRect rc, drc; | |||
214 | 232 | ||
215 | if(m_bShown) | 233 | if(m_bShown) |
216 | ShowWindow(SW_SHOW); | 234 | ShowWindow(SW_SHOW); |
217 | else | 235 | else |
218 | ShowWindow(SW_HIDE); | 236 | ShowWindow(SW_HIDE); |
219 | 237 | ||
238 | m_ListenCtl.SetCheck(m_Listener.m_bListen?1:0); | ||
239 | |||
220 | // CG: The following block was added by the ToolTips component. | 240 | // CG: The following block was added by the ToolTips component. |
221 | { | 241 | { |
222 | // Create the ToolTip control. | 242 | // Create the ToolTip control. |
223 | m_tooltip.Create(this); | 243 | m_tooltip.Create(this); |
224 | m_tooltip.Activate(TRUE); | 244 | m_tooltip.Activate(TRUE); |
225 | 245 | ||
@@ -321,17 +341,16 @@ HCURSOR CPumpKINDlg::OnQueryDragIcon() | |||
321 | 341 | ||
322 | int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) | 342 | int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) |
323 | { | 343 | { |
324 | if (CDialog::OnCreate(lpCreateStruct) == -1) | 344 | if (CDialog::OnCreate(lpCreateStruct) == -1) |
325 | return -1; | 345 | return -1; |
326 | 346 | ||
327 | m_Listener.m_Daddy=this; | 347 | if(!m_Listener.SetListen(m_bListen)) { |
328 | if(!m_Listener.Create(m_ListenPort,SOCK_DGRAM)){ | 348 | m_bListen=FALSE; |
329 | TRACE0("Failed to create socket\n"); | 349 | TRACE0("Failed to create socket\n"); |
330 | AfxMessageBox(IDS_BOX_CANTBIND,MB_OK|MB_ICONEXCLAMATION); | 350 | AfxMessageBox(IDS_BOX_CANTBIND,MB_OK|MB_ICONEXCLAMATION); |
331 | return -1; | ||
332 | } | 351 | } |
333 | 352 | ||
334 | if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){ | 353 | if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){ |
335 | TRACE0("Failed to create trayer\n"); | 354 | TRACE0("Failed to create trayer\n"); |
336 | return -1; | 355 | return -1; |
337 | } | 356 | } |
@@ -661,23 +680,28 @@ BOOL CRRQSocket::Create(LPCTSTR localFile,LPCTSTR hostName) | |||
661 | ASSERT(m_Daddy); | 680 | ASSERT(m_Daddy); |
662 | ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName); | 681 | ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName); |
663 | m_Daddy->m_Xfers[m_hSocket]=this; | 682 | m_Daddy->m_Xfers[m_hSocket]=this; |
664 | CString lFile = localFile?localFile:m_FileName; | 683 | CString lFile = localFile?localFile:m_FileName; |
665 | TurnSlashes(lFile,TRUE); | 684 | TurnSlashes(lFile,TRUE); |
666 | UpdateList(); | 685 | UpdateList(); |
667 | if(!localFile){// Check only if server | 686 | if(!localFile){// Check only for incoming requests |
668 | if(CheckBadRelativeness(m_FileName)){ | 687 | if(CheckBadRelativeness(m_FileName)){ |
669 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); | 688 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); |
670 | return TRUE; | 689 | return TRUE; |
671 | } | 690 | } |
672 | switch(m_Daddy->m_RRQMode){ | 691 | int atar=m_Daddy->m_aclRules.FindTarget(acl_rule::opRRQ,m_Peer.sin_addr.s_addr); |
692 | if(atar<0) | ||
693 | atar = m_Daddy->m_RRQMode; | ||
694 | switch(atar){ | ||
673 | case CPumpKINDlg::rrqGiveAll: | 695 | case CPumpKINDlg::rrqGiveAll: |
674 | break; | 696 | break; |
675 | case CPumpKINDlg::rrqAlwaysConfirm: | 697 | case CPumpKINDlg::rrqAlwaysConfirm: |
676 | if(ConfirmRequest()) | 698 | if(ConfirmRequest()) |
677 | break; | 699 | break; |
700 | default: | ||
701 | TRACE1("Unexpected access target: %d\n",atar); | ||
678 | case CPumpKINDlg::rrqDenyAll: | 702 | case CPumpKINDlg::rrqDenyAll: |
679 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); | 703 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); |
680 | return TRUE; | 704 | return TRUE; |
681 | } | 705 | } |
682 | } | 706 | } |
683 | CString fn = localFile?ApplyRootGently(lFile):ApplyRoot(lFile); | 707 | CString fn = localFile?ApplyRootGently(lFile):ApplyRoot(lFile); |
@@ -1104,13 +1128,13 @@ LV_FINDINFO lvf; | |||
1104 | int i = m_Daddy->m_List.FindItem(&lvf); | 1128 | int i = m_Daddy->m_List.FindItem(&lvf); |
1105 | if(i>=0) | 1129 | if(i>=0) |
1106 | m_Daddy->m_List.DeleteItem(i); | 1130 | m_Daddy->m_List.DeleteItem(i); |
1107 | delete this; | 1131 | delete this; |
1108 | } | 1132 | } |
1109 | 1133 | ||
1110 | void CPumpKINDlg::LogLine(LPCTSTR str) | 1134 | void CPumpKINDlg::LogLineToScreen(LPCTSTR str) |
1111 | { | 1135 | { |
1112 | ASSERT(m_LogLength); | 1136 | ASSERT(m_LogLength); |
1113 | while(m_Log.GetCount()>m_LogLength && m_Log.GetCount()!=LB_ERR){ | 1137 | while(m_Log.GetCount()>m_LogLength && m_Log.GetCount()!=LB_ERR){ |
1114 | CTime *t = (CTime*)m_Log.GetItemData(0); | 1138 | CTime *t = (CTime*)m_Log.GetItemData(0); |
1115 | if(((DWORD)t)!=LB_ERR){ | 1139 | if(((DWORD)t)!=LB_ERR){ |
1116 | ASSERT(t); | 1140 | ASSERT(t); |
@@ -1160,46 +1184,56 @@ CString rv = m_Daddy->m_TFTPRoot; | |||
1160 | void CPumpKINDlg::OnOptions() | 1184 | void CPumpKINDlg::OnOptions() |
1161 | { | 1185 | { |
1162 | CPropertySheet cps(IDS_TITLE_OPTIONS,this); | 1186 | CPropertySheet cps(IDS_TITLE_OPTIONS,this); |
1163 | CPropsServer server; | 1187 | CPropsServer server; |
1164 | CPropsNetwork network; | 1188 | CPropsNetwork network; |
1165 | CPropsSounds sounds; | 1189 | CPropsSounds sounds; |
1190 | CPropsACL acl; | ||
1166 | 1191 | ||
1167 | server.m_RRQMode=m_RRQMode; | 1192 | server.m_RRQMode=m_RRQMode; |
1168 | server.m_TFTPRoot=m_TFTPRoot; | 1193 | server.m_TFTPRoot=m_TFTPRoot; |
1169 | server.m_TFTPSubdirs=m_bTFTPSubdirs; | 1194 | server.m_TFTPSubdirs=m_bTFTPSubdirs; |
1170 | server.m_WRQMode=m_WRQMode; | 1195 | server.m_WRQMode=m_WRQMode; |
1171 | server.m_PromptTimeOut=m_PromptTimeOut; | 1196 | server.m_PromptTimeOut=m_PromptTimeOut; |
1197 | server.m_LogFile=m_LogFile; | ||
1172 | 1198 | ||
1173 | network.m_ListenPort=m_ListenPort; | 1199 | network.m_ListenPort=m_ListenPort; |
1174 | network.m_SpeakPort=m_SpeakPort; | 1200 | network.m_SpeakPort=m_SpeakPort; |
1175 | network.m_TimeOut=m_TFTPTimeOut.GetTotalSeconds(); | 1201 | network.m_TimeOut=m_TFTPTimeOut.GetTotalSeconds(); |
1176 | network.m_BlockSize=m_BlockSize; | 1202 | network.m_BlockSize=m_BlockSize; |
1177 | 1203 | ||
1178 | sounds.m_Request = m_bnwRequest; | 1204 | sounds.m_Request = m_bnwRequest; |
1179 | sounds.m_Success = m_bnwSuccess; | 1205 | sounds.m_Success = m_bnwSuccess; |
1180 | sounds.m_Abort = m_bnwAbort; | 1206 | sounds.m_Abort = m_bnwAbort; |
1181 | 1207 | ||
1208 | acl.m_rulist = m_aclRules; | ||
1209 | |||
1182 | cps.AddPage(&server); | 1210 | cps.AddPage(&server); |
1183 | cps.AddPage(&network); | 1211 | cps.AddPage(&network); |
1184 | cps.AddPage(&sounds); | 1212 | cps.AddPage(&sounds); |
1213 | cps.AddPage(&acl); | ||
1185 | if(cps.DoModal()==IDOK){ | 1214 | if(cps.DoModal()==IDOK){ |
1186 | m_RRQMode=server.m_RRQMode; | 1215 | m_RRQMode=server.m_RRQMode; |
1187 | m_TFTPRoot=server.m_TFTPRoot; | 1216 | m_TFTPRoot=server.m_TFTPRoot; |
1188 | m_bTFTPSubdirs=server.m_TFTPSubdirs; | 1217 | m_bTFTPSubdirs=server.m_TFTPSubdirs; |
1189 | m_WRQMode=server.m_WRQMode; | 1218 | m_WRQMode=server.m_WRQMode; |
1190 | m_PromptTimeOut=server.m_PromptTimeOut; | 1219 | m_PromptTimeOut=server.m_PromptTimeOut; |
1220 | m_LogFile=server.m_LogFile; | ||
1191 | 1221 | ||
1192 | m_ListenPort=network.m_ListenPort; | 1222 | m_ListenPort=network.m_ListenPort; |
1193 | m_SpeakPort=network.m_SpeakPort; | 1223 | m_SpeakPort=network.m_SpeakPort; |
1194 | m_TFTPTimeOut=CTimeSpan(network.m_TimeOut); | 1224 | m_TFTPTimeOut=CTimeSpan(network.m_TimeOut); |
1195 | m_BlockSize=network.m_BlockSize; | 1225 | m_BlockSize=network.m_BlockSize; |
1196 | 1226 | ||
1197 | m_bnwRequest = sounds.m_Request; | 1227 | m_bnwRequest = sounds.m_Request; |
1198 | m_bnwSuccess = sounds.m_Success; | 1228 | m_bnwSuccess = sounds.m_Success; |
1199 | m_bnwAbort = sounds.m_Abort; | 1229 | m_bnwAbort = sounds.m_Abort; |
1230 | |||
1231 | m_aclRules = acl.m_rulist; | ||
1232 | |||
1233 | m_lastlogerr.Empty(); | ||
1200 | } | 1234 | } |
1201 | } | 1235 | } |
1202 | 1236 | ||
1203 | BOOL CRRQSocket::ConfirmRequest() | 1237 | BOOL CRRQSocket::ConfirmRequest() |
1204 | { | 1238 | { |
1205 | CConfirmRRQDlg cd(NULL); | 1239 | CConfirmRRQDlg cd(NULL); |
@@ -1241,14 +1275,16 @@ CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(lf); | |||
1241 | } | 1275 | } |
1242 | BOOL exists; | 1276 | BOOL exists; |
1243 | if(!_access((LPCTSTR)fn,0)) | 1277 | if(!_access((LPCTSTR)fn,0)) |
1244 | m_Rename=exists=TRUE; | 1278 | m_Rename=exists=TRUE; |
1245 | else | 1279 | else |
1246 | m_Rename=exists=FALSE; | 1280 | m_Rename=exists=FALSE; |
1247 | // *** m_WRQMode only if server transfer | 1281 | int atar=m_Daddy->m_aclRules.FindTarget(acl_rule::opWRQ,m_Peer.sin_addr.s_addr); |
1248 | switch(m_Daddy->m_WRQMode){ | 1282 | if(atar<0) |
1283 | atar=m_Daddy->m_WRQMode; | ||
1284 | switch(atar){ | ||
1249 | case CPumpKINDlg::wrqTakeAll: | 1285 | case CPumpKINDlg::wrqTakeAll: |
1250 | if(exists){ | 1286 | if(exists){ |
1251 | if(!RenameFile(fn)){ | 1287 | if(!RenameFile(fn)){ |
1252 | Deny(tftp::errDiskFull,IDS_TFTP_ERROR_FAILEDTORENAME); | 1288 | Deny(tftp::errDiskFull,IDS_TFTP_ERROR_FAILEDTORENAME); |
1253 | return TRUE; | 1289 | return TRUE; |
1254 | } | 1290 | } |
@@ -1265,12 +1301,14 @@ CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(lf); | |||
1265 | RenameFile(fn); | 1301 | RenameFile(fn); |
1266 | if(SaveAs(fn)) | 1302 | if(SaveAs(fn)) |
1267 | break; | 1303 | break; |
1268 | }else | 1304 | }else |
1269 | break; | 1305 | break; |
1270 | } | 1306 | } |
1307 | default: | ||
1308 | TRACE1("Unexpected access target: %d\n",atar); | ||
1271 | case CPumpKINDlg::wrqDenyAll: | 1309 | case CPumpKINDlg::wrqDenyAll: |
1272 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); | 1310 | Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS); |
1273 | return TRUE; | 1311 | return TRUE; |
1274 | } | 1312 | } |
1275 | } | 1313 | } |
1276 | CFileException e; | 1314 | CFileException e; |
@@ -1792,54 +1830,60 @@ void CPumpKINDlg::OnTraySendfile() | |||
1792 | } | 1830 | } |
1793 | 1831 | ||
1794 | void CPumpKINDlg::LoadSettings() | 1832 | void CPumpKINDlg::LoadSettings() |
1795 | { | 1833 | { |
1796 | CWinApp *app = AfxGetApp(); | 1834 | CWinApp *app = AfxGetApp(); |
1797 | ASSERT(app); | 1835 | ASSERT(app); |
1836 | m_bListen=app->GetProfileInt("TFTPSettings","Listen",m_bListen); | ||
1798 | m_bnwRequest=app->GetProfileString("BellsNWhistles","Request",m_bnwRequest); | 1837 | m_bnwRequest=app->GetProfileString("BellsNWhistles","Request",m_bnwRequest); |
1799 | m_bnwSuccess=app->GetProfileString("BellsNWhistles","Success",m_bnwSuccess); | 1838 | m_bnwSuccess=app->GetProfileString("BellsNWhistles","Success",m_bnwSuccess); |
1800 | m_bnwAbort=app->GetProfileString("BellsNWhistles","Abort",m_bnwAbort); | 1839 | m_bnwAbort=app->GetProfileString("BellsNWhistles","Abort",m_bnwAbort); |
1801 | m_bTFTPSubdirs=app->GetProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs); | 1840 | m_bTFTPSubdirs=app->GetProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs); |
1802 | m_ListenPort=app->GetProfileInt("TFTPSettings","ListenPort",m_ListenPort); | 1841 | m_ListenPort=app->GetProfileInt("TFTPSettings","ListenPort",m_ListenPort); |
1803 | m_LogLength=app->GetProfileInt("UISettings","LogLength",m_LogLength); | 1842 | m_LogLength=app->GetProfileInt("UISettings","LogLength",m_LogLength); |
1804 | m_PromptTimeOut=app->GetProfileInt("UISettings","PromptTimeout",m_PromptTimeOut); | 1843 | m_PromptTimeOut=app->GetProfileInt("UISettings","PromptTimeout",m_PromptTimeOut); |
1805 | m_RRQMode=app->GetProfileInt("TFTPSettings","RRQMode",m_RRQMode); | 1844 | m_RRQMode=app->GetProfileInt("TFTPSettings","RRQMode",m_RRQMode); |
1806 | m_SpeakPort=app->GetProfileInt("TFTPSettings","SpeakPort",m_SpeakPort); | 1845 | m_SpeakPort=app->GetProfileInt("TFTPSettings","SpeakPort",m_SpeakPort); |
1807 | m_TFTPRoot=app->GetProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot); | 1846 | m_TFTPRoot=app->GetProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot); |
1847 | m_LogFile=app->GetProfileString("General","LogFile",m_LogFile); | ||
1808 | m_TFTPTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds())); | 1848 | m_TFTPTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds())); |
1809 | m_BlockSize=app->GetProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize); | 1849 | m_BlockSize=app->GetProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize); |
1810 | m_RetryTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds())); | 1850 | m_RetryTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds())); |
1811 | m_WRQMode=app->GetProfileInt("TFTPSettings","WRQMode",m_WRQMode); | 1851 | m_WRQMode=app->GetProfileInt("TFTPSettings","WRQMode",m_WRQMode); |
1812 | m_bShown=app->GetProfileInt("UISettings","Visble",m_bShown); | 1852 | m_bShown=app->GetProfileInt("UISettings","Visble",m_bShown); |
1813 | if(m_TFTPRoot.IsEmpty()){ | 1853 | if(m_TFTPRoot.IsEmpty()){ |
1814 | DWORD dL = ::GetCurrentDirectory(0,NULL); | 1854 | DWORD dL = ::GetCurrentDirectory(0,NULL); |
1815 | VERIFY(::GetCurrentDirectory(dL,m_TFTPRoot.GetBuffer(dL))); | 1855 | VERIFY(::GetCurrentDirectory(dL,m_TFTPRoot.GetBuffer(dL))); |
1816 | m_TFTPRoot.ReleaseBuffer(); | 1856 | m_TFTPRoot.ReleaseBuffer(); |
1817 | } | 1857 | } |
1818 | ::SetCurrentDirectory(m_TFTPRoot); | 1858 | ::SetCurrentDirectory(m_TFTPRoot); |
1859 | m_aclRules.LoadProfile(app); | ||
1819 | } | 1860 | } |
1820 | 1861 | ||
1821 | void CPumpKINDlg::SaveSettings() | 1862 | void CPumpKINDlg::SaveSettings() |
1822 | { | 1863 | { |
1823 | CWinApp *app = AfxGetApp(); | 1864 | CWinApp *app = AfxGetApp(); |
1824 | ASSERT(app); | 1865 | ASSERT(app); |
1866 | app->WriteProfileInt("TFTPSettings","Listen",m_bListen); | ||
1825 | app->WriteProfileString("BellsNWhistles","Request",m_bnwRequest); | 1867 | app->WriteProfileString("BellsNWhistles","Request",m_bnwRequest); |
1826 | app->WriteProfileString("BellsNWhistles","Success",m_bnwSuccess); | 1868 | app->WriteProfileString("BellsNWhistles","Success",m_bnwSuccess); |
1827 | app->WriteProfileString("BellsNWhistles","Abort",m_bnwAbort); | 1869 | app->WriteProfileString("BellsNWhistles","Abort",m_bnwAbort); |
1828 | app->WriteProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs); | 1870 | app->WriteProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs); |
1829 | app->WriteProfileInt("TFTPSettings","ListenPort",m_ListenPort); | 1871 | app->WriteProfileInt("TFTPSettings","ListenPort",m_ListenPort); |
1830 | app->WriteProfileInt("UISettings","LogLength",m_LogLength); | 1872 | app->WriteProfileInt("UISettings","LogLength",m_LogLength); |
1831 | app->WriteProfileInt("UISettings","PromptTimeout",m_PromptTimeOut); | 1873 | app->WriteProfileInt("UISettings","PromptTimeout",m_PromptTimeOut); |
1832 | app->WriteProfileInt("TFTPSettings","RRQMode",m_RRQMode); | 1874 | app->WriteProfileInt("TFTPSettings","RRQMode",m_RRQMode); |
1833 | app->WriteProfileInt("TFTPSettings","SpeakPort",m_SpeakPort); | 1875 | app->WriteProfileInt("TFTPSettings","SpeakPort",m_SpeakPort); |
1834 | app->WriteProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot); | 1876 | app->WriteProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot); |
1877 | app->WriteProfileString("General","LogFile",m_LogFile); | ||
1835 | app->WriteProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds()); | 1878 | app->WriteProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds()); |
1836 | app->WriteProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize); | 1879 | app->WriteProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize); |
1837 | app->WriteProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds()); | 1880 | app->WriteProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds()); |
1838 | app->WriteProfileInt("TFTPSettings","WRQMode",m_WRQMode); | 1881 | app->WriteProfileInt("TFTPSettings","WRQMode",m_WRQMode); |
1839 | app->WriteProfileInt("UISettings","Visble",m_bShown); | 1882 | app->WriteProfileInt("UISettings","Visble",m_bShown); |
1883 | m_aclRules.SaveProfile(app); | ||
1840 | } | 1884 | } |
1841 | 1885 | ||
1842 | void CPumpKINDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) | 1886 | void CPumpKINDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) |
1843 | { | 1887 | { |
1844 | CDialog::OnWindowPosChanging(lpwndpos); | 1888 | CDialog::OnWindowPosChanging(lpwndpos); |
1845 | if(!m_bExiting){ | 1889 | if(!m_bExiting){ |
@@ -1981,6 +2025,55 @@ void CXferSocket::SetTry(tftp *p) | |||
1981 | } | 2025 | } |
1982 | 2026 | ||
1983 | void CPumpKINDlg::OnHelp() | 2027 | void CPumpKINDlg::OnHelp() |
1984 | { | 2028 | { |
1985 | AfxGetApp()->WinHelp(0,HELP_FINDER); | 2029 | AfxGetApp()->WinHelp(0,HELP_FINDER); |
1986 | } | 2030 | } |
2031 | |||
2032 | BOOL CListenSocket::SetListen(BOOL b) { | ||
2033 | ASSERT(m_Daddy); | ||
2034 | if(b==m_bListen) | ||
2035 | return TRUE; | ||
2036 | if(b) { | ||
2037 | if(!Create(m_Daddy->m_ListenPort,SOCK_DGRAM)) | ||
2038 | return FALSE; | ||
2039 | return m_bListen=TRUE; | ||
2040 | }else{ | ||
2041 | Close(); m_bListen=FALSE; | ||
2042 | return TRUE; | ||
2043 | } | ||
2044 | } | ||
2045 | |||
2046 | void CPumpKINDlg::OnListening() | ||
2047 | { | ||
2048 | if(!m_Listener.SetListen(m_ListenCtl.GetCheck()==1)) { | ||
2049 | TRACE0("Failed to create socket\n"); | ||
2050 | AfxMessageBox(IDS_BOX_CANTBIND,MB_OK|MB_ICONEXCLAMATION); | ||
2051 | } | ||
2052 | m_ListenCtl.SetCheck(m_Listener.m_bListen?1:0); | ||
2053 | m_bListen=m_Listener.m_bListen; | ||
2054 | } | ||
2055 | |||
2056 | void CPumpKINDlg::OnTrayListen() | ||
2057 | { | ||
2058 | if(!m_Listener.SetListen(!m_Listener.m_bListen)) { | ||
2059 | TRACE0("Failed to create socket\n"); | ||
2060 | AfxMessageBox(IDS_BOX_CANTBIND,MB_OK|MB_ICONEXCLAMATION); | ||
2061 | } | ||
2062 | m_ListenCtl.SetCheck(m_Listener.m_bListen?1:0); | ||
2063 | m_bListen=m_Listener.m_bListen; | ||
2064 | } | ||
2065 | |||
2066 | void CPumpKINDlg::LogLine(LPCTSTR str) | ||
2067 | { | ||
2068 | LogLineToScreen(str); | ||
2069 | if(!m_LogFile.IsEmpty()) { | ||
2070 | if(!Klever::LogRecord((LPCTSTR)m_LogFile,str)) { | ||
2071 | if(m_lastlogerr!=m_LogFile) { | ||
2072 | CString tmp; | ||
2073 | tmp.Format(IDS_LOG_LOGERROR,m_LogFile); | ||
2074 | LogLineToScreen(tmp); | ||
2075 | m_lastlogerr=m_LogFile; | ||
2076 | } | ||
2077 | } | ||
2078 | } | ||
2079 | } | ||