00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import wx
00019 import wx.lib.stattext
00020 import wx.lib.intctrl
00021 import wx.lib.masked.numctrl
00022 import wx.lib.masked.ipaddrctrl
00023
00024 def create(parent):
00025 return appOptions(parent)
00026
00027 [wxID_APPOPTIONS, wxID_APPOPTIONSBUTTONAPPLY, wxID_APPOPTIONSBUTTONCANCEL,
00028 wxID_APPOPTIONSBUTTONLOCATEIP, wxID_APPOPTIONSCHECKBOXUNLIMITEDCAPTURE,
00029 wxID_APPOPTIONSGENSTATICTEXTMB, wxID_APPOPTIONSGENSTATICTEXTSTOPCAPTURING,
00030 wxID_APPOPTIONSINTCTRLMAXSTORAGE, wxID_APPOPTIONSIPADDRCTRLSELFIP,
00031 wxID_APPOPTIONSNOTEBOOKOPTIONS, wxID_APPOPTIONSNUMCTRLLATITUDE,
00032 wxID_APPOPTIONSNUMCTRLLONGITUDE, wxID_APPOPTIONSPANELINDENTIFICATION,
00033 wxID_APPOPTIONSPANELNETTRACE, wxID_APPOPTIONSRADIOBUTTONBYCOORD,
00034 wxID_APPOPTIONSRADIOBUTTONBYIPADDRESS,
00035 wxID_APPOPTIONSRADIOBUTTONDISABLETRACE,
00036 wxID_APPOPTIONSRADIOBUTTONENABLETRACE, wxID_APPOPTIONSSTATICBOX1,
00037 wxID_APPOPTIONSSTATICTEXTINFOCITY, wxID_APPOPTIONSSTATICTEXTINFOCOUNTRY,
00038 wxID_APPOPTIONSSTATICTEXTINFOISP, wxID_APPOPTIONSSTATICTEXTINFOLAT,
00039 wxID_APPOPTIONSSTATICTEXTINFOLON, wxID_APPOPTIONSSTATICTEXTINFOSTATEPROV,
00040 wxID_APPOPTIONSSTATICTEXTIPADDR, wxID_APPOPTIONSSTATICTEXTLAT,
00041 wxID_APPOPTIONSSTATICTEXTLON, wxID_APPOPTIONSSTATICTEXTORG,
00042 wxID_APPOPTIONSTEXTCTRLINFOCITY, wxID_APPOPTIONSTEXTCTRLINFOCOUNTRY,
00043 wxID_APPOPTIONSTEXTCTRLINFOISP, wxID_APPOPTIONSTEXTCTRLINFOLAT,
00044 wxID_APPOPTIONSTEXTCTRLINFOLON, wxID_APPOPTIONSTEXTCTRLINFOORG,
00045 wxID_APPOPTIONSTEXTCTRLINFOSTATPROV,
00046 ] = [wx.NewId() for _init_ctrls in range(36)]
00047
00048
00049
00050
00051
00052
00053 class appOptions(wx.Dialog):
00054 def _init_coll_notebookOptions_Pages(self, parent):
00055
00056
00057 parent.AddPage(imageId=-1, page=self.panelIndentification, select=True,
00058 text='Identification')
00059 parent.AddPage(imageId=-1, page=self.panelNetTrace, select=False,
00060 text='Network')
00061
00062 def _init_ctrls(self, prnt):
00063
00064 wx.Dialog.__init__(self, id=wxID_APPOPTIONS, name='appOptions',
00065 parent=prnt, pos=wx.Point(439, 314), size=wx.Size(580, 385),
00066 style=wx.DEFAULT_DIALOG_STYLE, title='Options')
00067 self.SetClientSize(wx.Size(564, 349))
00068 self.SetToolTipString('')
00069
00070 self.notebookOptions = wx.Notebook(id=wxID_APPOPTIONSNOTEBOOKOPTIONS,
00071 name='notebookOptions', parent=self, pos=wx.Point(0, 8),
00072 size=wx.Size(560, 304), style=0)
00073 self.notebookOptions.SetToolTipString('')
00074 self.notebookOptions.SetLabel('')
00075
00076 self.buttonCancel = wx.Button(id=wxID_APPOPTIONSBUTTONCANCEL,
00077 label='Cancel', name='buttonCancel', parent=self,
00078 pos=wx.Point(392, 320), size=wx.Size(75, 23), style=0)
00079 self.buttonCancel.Bind(wx.EVT_BUTTON, self.OnButtonCancelButton,
00080 id=wxID_APPOPTIONSBUTTONCANCEL)
00081
00082 self.buttonApply = wx.Button(id=wxID_APPOPTIONSBUTTONAPPLY,
00083 label='Apply', name='buttonApply', parent=self, pos=wx.Point(480,
00084 320), size=wx.Size(75, 23), style=0)
00085 self.buttonApply.Bind(wx.EVT_BUTTON, self.OnButtonApplyButton,
00086 id=wxID_APPOPTIONSBUTTONAPPLY)
00087
00088 self.panelIndentification = wx.Panel(id=wxID_APPOPTIONSPANELINDENTIFICATION,
00089 name='panelIndentification', parent=self.notebookOptions,
00090 pos=wx.Point(0, 0), size=wx.Size(552, 278),
00091 style=wx.TAB_TRAVERSAL)
00092 self.panelIndentification.SetToolTipString('')
00093 self.panelIndentification.SetLabel('')
00094 self.panelIndentification.SetHelpText('')
00095
00096 self.radioButtonByIPAddress = wx.RadioButton(id=wxID_APPOPTIONSRADIOBUTTONBYIPADDRESS,
00097 label='Idenfity Self using IP Address',
00098 name='radioButtonByIPAddress', parent=self.panelIndentification,
00099 pos=wx.Point(24, 32), size=wx.Size(168, 13), style=wx.RB_GROUP)
00100 self.radioButtonByIPAddress.SetValue(True)
00101 self.radioButtonByIPAddress.SetToolTipString('')
00102 self.radioButtonByIPAddress.Bind(wx.EVT_RADIOBUTTON,
00103 self.OnRadioButtonByIPAddressRadiobutton,
00104 id=wxID_APPOPTIONSRADIOBUTTONBYIPADDRESS)
00105
00106 self.radioButtonByCoord = wx.RadioButton(id=wxID_APPOPTIONSRADIOBUTTONBYCOORD,
00107 label='Identify Self using Coordinates',
00108 name='radioButtonByCoord', parent=self.panelIndentification,
00109 pos=wx.Point(24, 152), size=wx.Size(176, 13), style=0)
00110 self.radioButtonByCoord.SetValue(True)
00111 self.radioButtonByCoord.Bind(wx.EVT_RADIOBUTTON,
00112 self.OnRadioButtonByCoordRadiobutton,
00113 id=wxID_APPOPTIONSRADIOBUTTONBYCOORD)
00114
00115 self.staticTextIPAddr = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTIPADDR,
00116 label='IP Address', name='staticTextIPAddr',
00117 parent=self.panelIndentification, pos=wx.Point(176, 68),
00118 size=wx.Size(52, 13), style=0)
00119
00120 self.buttonLocateIP = wx.Button(id=wxID_APPOPTIONSBUTTONLOCATEIP,
00121 label='Locate Address', name='buttonLocateIP',
00122 parent=self.panelIndentification, pos=wx.Point(48, 96),
00123 size=wx.Size(112, 23), style=0)
00124 self.buttonLocateIP.Bind(wx.EVT_BUTTON, self.OnButtonLocateIPButton,
00125 id=wxID_APPOPTIONSBUTTONLOCATEIP)
00126
00127 self.staticTextLon = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTLON,
00128 label='longitude', name='staticTextLon',
00129 parent=self.panelIndentification, pos=wx.Point(112, 188),
00130 size=wx.Size(44, 13), style=0)
00131
00132 self.staticTextLat = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTLAT,
00133 label='Latitude', name='staticTextLat',
00134 parent=self.panelIndentification, pos=wx.Point(112, 218),
00135 size=wx.Size(39, 13), style=0)
00136 self.staticTextLat.SetToolTipString('')
00137
00138 self.ipAddrCtrlSelfIP = wx.lib.masked.ipaddrctrl.IpAddrCtrl(id=wxID_APPOPTIONSIPADDRCTRLSELFIP,
00139 name='ipAddrCtrlSelfIP', parent=self.panelIndentification,
00140 pos=wx.Point(48, 64), size=wx.Size(113, 22), style=0, value='')
00141 self.ipAddrCtrlSelfIP.SetToolTipString('')
00142
00143 self.staticTextInfoLon = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOLON,
00144 label='Longitude:', name='staticTextInfoLon',
00145 parent=self.panelIndentification, pos=wx.Point(272, 80),
00146 size=wx.Size(51, 13), style=0)
00147 self.staticTextInfoLon.SetToolTipString('')
00148
00149 self.staticTextInfoLat = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOLAT,
00150 label='Latitude:', name='staticTextInfoLat',
00151 parent=self.panelIndentification, pos=wx.Point(272, 104),
00152 size=wx.Size(43, 13), style=0)
00153 self.staticTextInfoLat.SetToolTipString('')
00154
00155 self.staticTextInfoCity = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOCITY,
00156 label='City:', name='staticTextInfoCity',
00157 parent=self.panelIndentification, pos=wx.Point(272, 128),
00158 size=wx.Size(23, 13), style=0)
00159 self.staticTextInfoCity.SetToolTipString('')
00160
00161 self.staticTextInfoStateProv = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOSTATEPROV,
00162 label='State/Province:', name='staticTextInfoStateProv',
00163 parent=self.panelIndentification, pos=wx.Point(272, 152),
00164 size=wx.Size(75, 13), style=0)
00165 self.staticTextInfoStateProv.SetToolTipString('')
00166
00167 self.staticTextInfoCountry = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOCOUNTRY,
00168 label='Country:', name='staticTextInfoCountry',
00169 parent=self.panelIndentification, pos=wx.Point(272, 176),
00170 size=wx.Size(43, 13), style=0)
00171 self.staticTextInfoCountry.SetToolTipString('')
00172
00173 self.staticTextOrg = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTORG,
00174 label='Organization:', name='staticTextOrg',
00175 parent=self.panelIndentification, pos=wx.Point(272, 200),
00176 size=wx.Size(65, 13), style=0)
00177 self.staticTextOrg.SetToolTipString('')
00178
00179 self.staticTextInfoISP = wx.StaticText(id=wxID_APPOPTIONSSTATICTEXTINFOISP,
00180 label='ISP:', name='staticTextInfoISP',
00181 parent=self.panelIndentification, pos=wx.Point(272, 224),
00182 size=wx.Size(20, 13), style=0)
00183
00184 self.textCtrlInfoCity = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOCITY,
00185 name='textCtrlInfoCity', parent=self.panelIndentification,
00186 pos=wx.Point(368, 126), size=wx.Size(144, 21), style=0, value='')
00187 self.textCtrlInfoCity.SetToolTipString('')
00188 self.textCtrlInfoCity.SetEditable(False)
00189
00190 self.textCtrlInfoLon = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOLON,
00191 name='textCtrlInfoLon', parent=self.panelIndentification,
00192 pos=wx.Point(368, 78), size=wx.Size(144, 21), style=0, value='')
00193 self.textCtrlInfoLon.SetEditable(False)
00194
00195 self.textCtrlInfoISP = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOISP,
00196 name='textCtrlInfoISP', parent=self.panelIndentification,
00197 pos=wx.Point(368, 222), size=wx.Size(144, 21), style=0, value='')
00198 self.textCtrlInfoISP.SetToolTipString('')
00199 self.textCtrlInfoISP.Enable(True)
00200 self.textCtrlInfoISP.SetEditable(False)
00201
00202 self.textCtrlInfoLat = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOLAT,
00203 name='textCtrlInfoLat', parent=self.panelIndentification,
00204 pos=wx.Point(368, 102), size=wx.Size(144, 21), style=0, value='')
00205 self.textCtrlInfoLat.SetToolTipString('')
00206 self.textCtrlInfoLat.SetEditable(False)
00207
00208 self.staticBox1 = wx.StaticBox(id=wxID_APPOPTIONSSTATICBOX1,
00209 label='IP Address Geographical Info.', name='staticBox1',
00210 parent=self.panelIndentification, pos=wx.Point(256, 56),
00211 size=wx.Size(272, 200), style=0)
00212 self.staticBox1.SetToolTipString('')
00213 self.staticBox1.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.BOLD, False,
00214 'Tahoma'))
00215
00216 self.textCtrlInfoStatProv = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOSTATPROV,
00217 name='textCtrlInfoStatProv', parent=self.panelIndentification,
00218 pos=wx.Point(368, 150), size=wx.Size(144, 21), style=0, value='')
00219 self.textCtrlInfoStatProv.SetToolTipString('')
00220 self.textCtrlInfoStatProv.SetEditable(False)
00221
00222 self.textCtrlInfoCountry = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOCOUNTRY,
00223 name='textCtrlInfoCountry', parent=self.panelIndentification,
00224 pos=wx.Point(368, 174), size=wx.Size(144, 21), style=0, value='')
00225 self.textCtrlInfoCountry.SetToolTipString('')
00226 self.textCtrlInfoCountry.SetEditable(False)
00227
00228 self.textCtrlInfoOrg = wx.TextCtrl(id=wxID_APPOPTIONSTEXTCTRLINFOORG,
00229 name='textCtrlInfoOrg', parent=self.panelIndentification,
00230 pos=wx.Point(368, 198), size=wx.Size(144, 21), style=0, value='')
00231 self.textCtrlInfoOrg.SetToolTipString('')
00232 self.textCtrlInfoOrg.Enable(True)
00233 self.textCtrlInfoOrg.SetEditable(False)
00234
00235 self.numCtrlLongitude = wx.lib.masked.numctrl.NumCtrl(id=wxID_APPOPTIONSNUMCTRLLONGITUDE,
00236 name='numCtrlLongitude', parent=self.panelIndentification,
00237 pos=wx.Point(48, 184), size=wx.Size(57, 22), style=0, value=0)
00238 self.numCtrlLongitude.SetAllowNegative(True)
00239 self.numCtrlLongitude.SetMax(180)
00240 self.numCtrlLongitude.SetBounds((-180, 180))
00241 self.numCtrlLongitude.SetMin(-180)
00242 self.numCtrlLongitude.SetToolTipString('')
00243 self.numCtrlLongitude.SetFractionWidth(2)
00244 self.numCtrlLongitude.SetIntegerWidth(3)
00245 self.numCtrlLongitude.SetStopFieldChangeIfInvalid(True)
00246
00247 self.numCtrlLatitude = wx.lib.masked.numctrl.NumCtrl(id=wxID_APPOPTIONSNUMCTRLLATITUDE,
00248 name='numCtrlLatitude', parent=self.panelIndentification,
00249 pos=wx.Point(48, 216), size=wx.Size(57, 22), style=0, value=0)
00250 self.numCtrlLatitude.SetMax(80)
00251 self.numCtrlLatitude.SetBounds((-80, 80))
00252 self.numCtrlLatitude.SetMin(-80)
00253 self.numCtrlLatitude.SetToolTipString('')
00254 self.numCtrlLatitude.SetFractionWidth(2)
00255 self.numCtrlLatitude.SetIntegerWidth(3)
00256 self.numCtrlLatitude.SetStopFieldChangeIfInvalid(True)
00257
00258 self.panelNetTrace = wx.Panel(id=wxID_APPOPTIONSPANELNETTRACE,
00259 name='panelNetTrace', parent=self.notebookOptions, pos=wx.Point(0,
00260 0), size=wx.Size(552, 278), style=wx.TAB_TRAVERSAL)
00261 self.panelNetTrace.SetToolTipString('')
00262 self.panelNetTrace.SetThemeEnabled(False)
00263
00264 self.radioButtonDisableTrace = wx.RadioButton(id=wxID_APPOPTIONSRADIOBUTTONDISABLETRACE,
00265 label="Don't record Network Traffic",
00266 name='radioButtonDisableTrace', parent=self.panelNetTrace,
00267 pos=wx.Point(24, 144), size=wx.Size(160, 13), style=wx.RB_GROUP)
00268 self.radioButtonDisableTrace.SetToolTipString('')
00269 self.radioButtonDisableTrace.SetValue(True)
00270 self.radioButtonDisableTrace.SetHelpText('')
00271 self.radioButtonDisableTrace.Bind(wx.EVT_RADIOBUTTON,
00272 self.OnRadioButtonDisableTraceRadiobutton,
00273 id=wxID_APPOPTIONSRADIOBUTTONDISABLETRACE)
00274
00275 self.radioButtonEnableTrace = wx.RadioButton(id=wxID_APPOPTIONSRADIOBUTTONENABLETRACE,
00276 label='Record Network Traffic', name='radioButtonEnableTrace',
00277 parent=self.panelNetTrace, pos=wx.Point(24, 32), size=wx.Size(144,
00278 13), style=0)
00279 self.radioButtonEnableTrace.SetValue(True)
00280 self.radioButtonEnableTrace.Bind(wx.EVT_RADIOBUTTON,
00281 self.OnRadioButtonEnableTraceRadiobutton,
00282 id=wxID_APPOPTIONSRADIOBUTTONENABLETRACE)
00283
00284 self.intCtrlMaxStorage = wx.lib.intctrl.IntCtrl(allow_long=False,
00285 allow_none=False, default_color=wx.BLACK,
00286 id=wxID_APPOPTIONSINTCTRLMAXSTORAGE, limited=False, max=10000,
00287 min=1, name='intCtrlMaxStorage', oob_color=wx.RED,
00288 parent=self.panelNetTrace, pos=wx.Point(248, 69), size=wx.Size(40,
00289 21), style=0, value=0)
00290 self.intCtrlMaxStorage.SetToolTipString('')
00291
00292 self.genStaticTextStopCapturing = wx.lib.stattext.GenStaticText(ID=wxID_APPOPTIONSGENSTATICTEXTSTOPCAPTURING,
00293 label='Stop recording when trace file exceeds',
00294 name='genStaticTextStopCapturing', parent=self.panelNetTrace,
00295 pos=wx.Point(48, 72), size=wx.Size(187, 13), style=0)
00296 self.genStaticTextStopCapturing.SetToolTipString('')
00297
00298 self.genStaticTextMB = wx.lib.stattext.GenStaticText(ID=wxID_APPOPTIONSGENSTATICTEXTMB,
00299 label='MB', name='genStaticTextMB', parent=self.panelNetTrace,
00300 pos=wx.Point(304, 72), size=wx.Size(14, 13), style=0)
00301
00302 self.checkBoxUnlimitedCapture = wx.CheckBox(id=wxID_APPOPTIONSCHECKBOXUNLIMITEDCAPTURE,
00303 label='Never stop recording', name='checkBoxUnlimitedCapture',
00304 parent=self.panelNetTrace, pos=wx.Point(48, 96), size=wx.Size(144,
00305 13), style=0)
00306 self.checkBoxUnlimitedCapture.SetValue(False)
00307 self.checkBoxUnlimitedCapture.SetToolTipString('')
00308 self.checkBoxUnlimitedCapture.Bind(wx.EVT_CHECKBOX,
00309 self.OnCheckBoxUnlimitedCaptureCheckbox,
00310 id=wxID_APPOPTIONSCHECKBOXUNLIMITEDCAPTURE)
00311
00312 self._init_coll_notebookOptions_Pages(self.notebookOptions)
00313
00314 def __init__(self, parent, geoIPDatabase):
00315 self._init_ctrls(parent)
00316 self.geoIPDB = geoIPDatabase
00317
00318 self.ipAddrValid = False
00319
00320
00321
00322
00323 def loadConfiguration(self, optConf):
00324
00325 if optConf.ident_getIdentByIPAddr() == True:
00326 self.radioButtonByIPAddress.SetValue(True)
00327 self.disableIdentCoordControls()
00328 self.buttonLocateIP.Enable()
00329 else:
00330 self.radioButtonByCoord.SetValue(True)
00331 self.disableIdentIPControls()
00332 self.buttonLocateIP.Disable()
00333
00334
00335 ipAddr = optConf.ident_getIPAddr()
00336
00337 if ipAddr != "":
00338 self.ipAddrValid = True
00339 self.ipAddrCtrlSelfIP.SetValue(ipAddr)
00340
00341
00342 lon, lat, city, stateProv, country, org, ISP = optConf.ident_getIPGeoInfo()
00343
00344 self.textCtrlInfoLon.Clear()
00345 self.textCtrlInfoLat.Clear()
00346 self.textCtrlInfoCity.Clear()
00347 self.textCtrlInfoStatProv.Clear()
00348 self.textCtrlInfoCountry.Clear()
00349 self.textCtrlInfoOrg.Clear()
00350 self.textCtrlInfoISP.Clear()
00351
00352 self.textCtrlInfoLon.WriteText(lon)
00353 self.textCtrlInfoLat.WriteText(lat)
00354 self.textCtrlInfoCity.WriteText(city)
00355 self.textCtrlInfoStatProv.WriteText(stateProv)
00356 self.textCtrlInfoCountry.WriteText(country)
00357 self.textCtrlInfoOrg.WriteText(org)
00358 self.textCtrlInfoISP.WriteText(ISP)
00359
00360
00361 selfLon, selfLat = optConf.ident_getManualCoord()
00362
00363 self.numCtrlLongitude.SetValue(selfLon)
00364 self.numCtrlLatitude.SetValue(selfLat)
00365
00366
00367 dontStopRecording = optConf.network_getNeverStopRecording()
00368 if dontStopRecording == True:
00369 self.checkBoxUnlimitedCapture.SetValue(True)
00370 self.checkBoxUnlimitedCapture.Disable()
00371 else:
00372 self.checkBoxUnlimitedCapture.SetValue(False)
00373 self.checkBoxUnlimitedCapture.Enable()
00374
00375 recordFlag = optConf.network_getRecordTraffic()
00376
00377 if recordFlag == False:
00378 self.radioButtonDisableTrace.SetValue(True)
00379 self.disableTrafficRecordingControls()
00380 else:
00381 self.radioButtonEnableTrace.SetValue(True)
00382 self.enableTrafficRecordingControls()
00383
00384 self.intCtrlMaxStorage.SetValue(optConf.network_getRecordingMaxLimit())
00385 self.networkSettingsChanged = False
00386
00387
00388
00389
00390
00391 def disableIdentIPControls(self):
00392 self.ipAddrCtrlSelfIP.Disable()
00393
00394 self.textCtrlInfoLon.Disable()
00395 self.textCtrlInfoLat.Disable()
00396 self.textCtrlInfoCity.Disable()
00397 self.textCtrlInfoStatProv.Disable()
00398 self.textCtrlInfoCountry.Disable()
00399 self.textCtrlInfoOrg.Disable()
00400 self.textCtrlInfoISP.Disable()
00401
00402
00403
00404
00405
00406 def enableIdentIPControls(self):
00407 self.ipAddrCtrlSelfIP.Enable()
00408
00409 self.textCtrlInfoLon.Enable()
00410 self.textCtrlInfoLat.Enable()
00411 self.textCtrlInfoCity.Enable()
00412 self.textCtrlInfoStatProv.Enable()
00413 self.textCtrlInfoCountry.Enable()
00414 self.textCtrlInfoOrg.Enable()
00415 self.textCtrlInfoISP.Enable()
00416
00417
00418
00419
00420
00421 def disableIdentCoordControls(self):
00422 self.numCtrlLongitude.Disable()
00423 self.numCtrlLatitude.Disable()
00424
00425
00426
00427
00428
00429 def enableIdentCoordControls(self):
00430 self.numCtrlLongitude.Enable()
00431 self.numCtrlLatitude.Enable()
00432
00433
00434
00435
00436
00437 def OnButtonCancelButton(self, event):
00438 return self.EndModal(wx.ID_CANCEL)
00439
00440
00441
00442
00443
00444 def OnButtonApplyButton(self, event):
00445
00446 if self.radioButtonByIPAddress.GetValue() == True:
00447 self.OnButtonLocateIPButton(None, False)
00448 if self.ipAddrCtrlSelfIP.IsValid() == False or self.ipAddrCtrlSelfIP.GetAddress() == "...":
00449 dlg = wx.MessageDialog(None, "You must supply a valid IP Addresss", 'Error', wx.ICON_ERROR)
00450 result = dlg.ShowModal()
00451 dlg.Destroy()
00452 return
00453
00454 if self.ipAddrCtrlSelfIP.IsValid() == False and self.ipAddrCtrlSelfIP.GetAddress() != "...":
00455 self.ipAddrValid = False
00456 dlg = wx.MessageDialog(None, "The supplied IP Address is not valid, and will not be saved", 'Error', wx.ICON_ERROR)
00457 result = dlg.ShowModal()
00458 dlg.Destroy()
00459 else:
00460 self.ipAddrValid = True
00461
00462 if not self.numCtrlLongitude.IsValid() or not self.numCtrlLatitude.IsValid():
00463 self.coordValid = False
00464 dlg = wx.MessageDialog(None, "The supplied Coordinates are not valid, and will not be saved", 'Error', wx.ICON_ERROR)
00465 result = dlg.ShowModal()
00466 dlg.Destroy()
00467 else:
00468 self.coordValid = True
00469
00470 return self.EndModal(wx.ID_OK)
00471
00472
00473
00474
00475
00476
00477 def OnButtonLocateIPButton(self, event, validate=True):
00478 if validate == True:
00479 if self.ipAddrCtrlSelfIP.IsValid() == False:
00480 dlg = wx.MessageDialog(None, "The IP Address is not valid.", 'Error', wx.ICON_ERROR)
00481 result = dlg.ShowModal()
00482 dlg.Destroy()
00483 return
00484
00485 ipAddr = self.ipAddrCtrlSelfIP.GetAddress()
00486
00487 if validate == True:
00488 if ipAddr == "...":
00489 dlg = wx.MessageDialog(None, "You did not supply an IP Address.", 'Error', wx.ICON_ERROR)
00490 result = dlg.ShowModal()
00491 dlg.Destroy()
00492 return
00493
00494 self.geoIPDB.find_by_addr(ipAddr)
00495
00496
00497 self.textCtrlInfoLon.Clear()
00498 self.textCtrlInfoLat.Clear()
00499 self.textCtrlInfoCity.Clear()
00500 self.textCtrlInfoStatProv.Clear()
00501 self.textCtrlInfoCountry.Clear()
00502 self.textCtrlInfoISP.Clear()
00503 self.textCtrlInfoOrg.Clear()
00504
00505 self.textCtrlInfoLon.WriteText(str(self.geoIPDB.longitude))
00506 self.textCtrlInfoLat.WriteText(str(self.geoIPDB.latitude))
00507 self.textCtrlInfoCity.WriteText(self.geoIPDB.city)
00508 self.textCtrlInfoStatProv.WriteText("")
00509 self.textCtrlInfoCountry.WriteText(self.geoIPDB.country_name)
00510 self.textCtrlInfoISP.WriteText(self.getDBIsp())
00511 self.textCtrlInfoOrg.WriteText(self.getDBOrganization())
00512
00513
00514
00515 if validate == True:
00516 if self.geoIPDB.country_name == "Local Area Network":
00517 dlg = wx.MessageDialog(None, "The IP Address you entered is a local IP.\nYou must use a valid external IP Address (i.e. not in a 192.168.x.x or 172.16.x.x format)", 'Error', wx.ICON_ERROR)
00518 result = dlg.ShowModal()
00519 dlg.Destroy()
00520 return
00521
00522 if self.geoIPDB.city == "" and (self.geoIPDB.longitude != 0 or self.geoIPDB.latitude != 0):
00523 dlg = wx.MessageDialog(None, "Could not determine exact location of the supplied IP Address.\nYou may want to set your home location manually", 'Error', wx.ICON_ERROR)
00524 result = dlg.ShowModal()
00525 dlg.Destroy()
00526 return
00527
00528 if self.geoIPDB.city == "" and (self.geoIPDB.longitude == 0 and self.geoIPDB.latitude == 0):
00529 dlg = wx.MessageDialog(None, "Could not locate the supplied IP Address.\nYou may want to set your home location manually", 'Error', wx.ICON_ERROR)
00530 result = dlg.ShowModal()
00531 dlg.Destroy()
00532 return
00533
00534
00535
00536
00537
00538 def getDBIsp(self):
00539 return unicode(self.geoIPDB.isp)
00540
00541
00542
00543
00544
00545 def getDBOrganization(self):
00546 return unicode(self.geoIPDB.organization)
00547
00548
00549
00550
00551
00552 def OnRadioButtonByIPAddressRadiobutton(self, event):
00553 self.enableIdentIPControls()
00554 self.disableIdentCoordControls()
00555 self.buttonLocateIP.Enable()
00556
00557
00558
00559
00560
00561 def OnRadioButtonByCoordRadiobutton(self, event):
00562 self.disableIdentIPControls()
00563 self.enableIdentCoordControls()
00564 self.buttonLocateIP.Disable()
00565
00566
00567
00568
00569
00570
00571
00572
00573 def getConfigValid(self):
00574 if self.radioButtonByIPAddress.GetValue() == True and self.ipAddrCtrlSelfIP.IsValid() == True:
00575 return True
00576
00577 if self.radioButtonByCoord.GetValue() == True:
00578 if self.numCtrlLongitude.IsValid() == True and self.numCtrlLatitude.IsValid() == True:
00579 return True;
00580
00581 return False
00582
00583
00584
00585
00586
00587 def getIdentifyByIP(self):
00588 return self.radioButtonByIPAddress.GetValue()
00589
00590
00591
00592
00593
00594 def getIndentifyByCoord(self):
00595 return self.radioButtonByCoord.GetValue()
00596
00597
00598
00599
00600 def getIPAddress(self):
00601 return self.ipAddrCtrlSelfIP.GetAddress()
00602
00603
00604
00605
00606 def getIPGeoInfo(self):
00607 return (self.textCtrlInfoLon.GetValue(),
00608 self.textCtrlInfoLat.GetValue(),
00609 self.textCtrlInfoCity.GetValue(),
00610 self.textCtrlInfoStatProv.GetValue(),
00611 self.textCtrlInfoCountry.GetValue(),
00612 self.textCtrlInfoOrg.GetValue(),
00613 self.textCtrlInfoISP.GetValue())
00614
00615
00616
00617
00618
00619 def getCoordinates(self):
00620 return (str(self.numCtrlLongitude.GetValue()),
00621 str(self.numCtrlLatitude.GetValue()))
00622
00623
00624 """
00625 network tab related
00626 """
00627
00628
00629
00630 def OnRadioButtonDisableTraceRadiobutton(self, event):
00631 self.disableTrafficRecordingControls()
00632 self.networkSettingsChanged = True
00633
00634
00635
00636
00637
00638 def OnRadioButtonEnableTraceRadiobutton(self, event):
00639 self.enableTrafficRecordingControls()
00640 self.networkSettingsChanged = True
00641
00642
00643
00644
00645
00646 def OnCheckBoxUnlimitedCaptureCheckbox(self, event):
00647 self.networkSettingsChanged = True
00648 if self.checkBoxUnlimitedCapture.GetValue() == True:
00649 self.intCtrlMaxStorage.Disable()
00650 else:
00651 self.intCtrlMaxStorage.Enable()
00652
00653
00654
00655
00656 def enableTrafficRecordingControls(self):
00657 self.checkBoxUnlimitedCapture.Enable()
00658 self.intCtrlMaxStorage.Enable()
00659
00660 self.OnCheckBoxUnlimitedCaptureCheckbox(None)
00661
00662
00663
00664
00665 def disableTrafficRecordingControls(self):
00666 self.checkBoxUnlimitedCapture.Disable()
00667 self.intCtrlMaxStorage.Disable()
00668
00669
00670
00671
00672
00673 def getNetworkMaxStorage(self):
00674 return self.intCtrlMaxStorage.GetValue()
00675
00676
00677
00678
00679
00680 def getNetworkUnlimitedCapture(self):
00681 return self.checkBoxUnlimitedCapture.GetValue()
00682
00683
00684
00685 def getNetworkRecordTraffic(self):
00686 return self.radioButtonEnableTrace.GetValue()
00687
00688
00689