-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 | |||
@@ -7,2 +7,3 @@ | |||
7 | 7 | ||
8 | #include "ACLTargetCombo.h" | ||
8 | #include "PropsServer.h" | 9 | #include "PropsServer.h" |
@@ -10,2 +11,3 @@ | |||
10 | #include "PropsSounds.h" | 11 | #include "PropsSounds.h" |
12 | #include "PropsACL.h" | ||
11 | #include "ConfirmRRQDlg.h" | 13 | #include "ConfirmRRQDlg.h" |
@@ -81,2 +83,6 @@ CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/) | |||
81 | { | 83 | { |
84 | m_Listener.m_Daddy = this; | ||
85 | |||
86 | m_bListen = TRUE; | ||
87 | |||
82 | m_ListenPort = 69; | 88 | m_ListenPort = 69; |
@@ -109,2 +115,11 @@ CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/) | |||
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(); |
@@ -116,2 +131,3 @@ void CPumpKINDlg::DoDataExchange(CDataExchange* 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); |
@@ -153,2 +169,4 @@ BEGIN_MESSAGE_MAP(CPumpKINDlg, CDialog) | |||
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 |
@@ -219,2 +237,4 @@ CRect rc, drc; | |||
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. |
@@ -326,7 +346,6 @@ int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) | |||
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 | } |
@@ -666,3 +685,3 @@ CString lFile = localFile?localFile:m_FileName; | |||
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)){ |
@@ -671,3 +690,6 @@ CString lFile = localFile?localFile:m_FileName; | |||
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: |
@@ -677,2 +699,4 @@ CString lFile = localFile?localFile:m_FileName; | |||
677 | break; | 699 | break; |
700 | default: | ||
701 | TRACE1("Unexpected access target: %d\n",atar); | ||
678 | case CPumpKINDlg::rrqDenyAll: | 702 | case CPumpKINDlg::rrqDenyAll: |
@@ -1109,3 +1133,3 @@ int i = m_Daddy->m_List.FindItem(&lvf); | |||
1109 | 1133 | ||
1110 | void CPumpKINDlg::LogLine(LPCTSTR str) | 1134 | void CPumpKINDlg::LogLineToScreen(LPCTSTR str) |
1111 | { | 1135 | { |
@@ -1165,2 +1189,3 @@ CPropsNetwork network; | |||
1165 | CPropsSounds sounds; | 1189 | CPropsSounds sounds; |
1190 | CPropsACL acl; | ||
1166 | 1191 | ||
@@ -1171,2 +1196,3 @@ CPropsSounds sounds; | |||
1171 | server.m_PromptTimeOut=m_PromptTimeOut; | 1196 | server.m_PromptTimeOut=m_PromptTimeOut; |
1197 | server.m_LogFile=m_LogFile; | ||
1172 | 1198 | ||
@@ -1181,2 +1207,4 @@ CPropsSounds sounds; | |||
1181 | 1207 | ||
1208 | acl.m_rulist = m_aclRules; | ||
1209 | |||
1182 | cps.AddPage(&server); | 1210 | cps.AddPage(&server); |
@@ -1184,2 +1212,3 @@ CPropsSounds sounds; | |||
1184 | cps.AddPage(&sounds); | 1212 | cps.AddPage(&sounds); |
1213 | cps.AddPage(&acl); | ||
1185 | if(cps.DoModal()==IDOK){ | 1214 | if(cps.DoModal()==IDOK){ |
@@ -1190,2 +1219,3 @@ CPropsSounds sounds; | |||
1190 | m_PromptTimeOut=server.m_PromptTimeOut; | 1219 | m_PromptTimeOut=server.m_PromptTimeOut; |
1220 | m_LogFile=server.m_LogFile; | ||
1191 | 1221 | ||
@@ -1199,2 +1229,6 @@ CPropsSounds sounds; | |||
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 | } |
@@ -1246,4 +1280,6 @@ CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(lf); | |||
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: |
@@ -1270,2 +1306,4 @@ CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(lf); | |||
1270 | } | 1306 | } |
1307 | default: | ||
1308 | TRACE1("Unexpected access target: %d\n",atar); | ||
1271 | case CPumpKINDlg::wrqDenyAll: | 1309 | case CPumpKINDlg::wrqDenyAll: |
@@ -1797,2 +1835,3 @@ 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); |
@@ -1807,2 +1846,3 @@ CWinApp *app = AfxGetApp(); | |||
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())); |
@@ -1818,2 +1858,3 @@ CWinApp *app = AfxGetApp(); | |||
1818 | ::SetCurrentDirectory(m_TFTPRoot); | 1858 | ::SetCurrentDirectory(m_TFTPRoot); |
1859 | m_aclRules.LoadProfile(app); | ||
1819 | } | 1860 | } |
@@ -1824,2 +1865,3 @@ 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); |
@@ -1834,2 +1876,3 @@ CWinApp *app = AfxGetApp(); | |||
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()); |
@@ -1839,2 +1882,3 @@ CWinApp *app = AfxGetApp(); | |||
1839 | app->WriteProfileInt("UISettings","Visble",m_bShown); | 1882 | app->WriteProfileInt("UISettings","Visble",m_bShown); |
1883 | m_aclRules.SaveProfile(app); | ||
1840 | } | 1884 | } |
@@ -1986 +2030,50 @@ void CPumpKINDlg::OnHelp() | |||
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 | } | ||