00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 import wx
00021 import wx.richtext
00022 from objects.logic.common.logger import logger
00023 import webbrowser
00024 from objects.geoip.geoIPUtils import geoIPUtils
00025 from objects.logic.common.exception import exception
00026 from objects.logic.common.globalStrings import globalStrings
00027 import os
00028
00029
00030 def create(parent):
00031 return aboutDialog(parent)
00032
00033 [wxID_ABOUTDIALOG, wxID_ABOUTDIALOGABOUTTEXT,
00034 wxID_ABOUTDIALOGBUTTONUPDATEIPDB, wxID_ABOUTDIALOGBUTTONVISITWEBSITE,
00035 wxID_ABOUTDIALOGVIEWLICENSE,
00036 ] = [wx.NewId() for _init_ctrls in range(5)]
00037
00038
00039
00040
00041
00042
00043 class aboutDialog(wx.Dialog):
00044 def _init_ctrls(self, prnt):
00045
00046 wx.Dialog.__init__(self, id=wxID_ABOUTDIALOG, name='aboutDialog',
00047 parent=prnt, pos=wx.Point(397, 368), size=wx.Size(475, 256),
00048 style=wx.DEFAULT_DIALOG_STYLE, title='About EyeSpy ...')
00049 self.SetClientSize(wx.Size(459, 220))
00050 self.SetToolTipString('')
00051 self.SetIcon(wx.Icon(u'./res/images/ico/eyespy_small.ico',
00052 wx.BITMAP_TYPE_ICO))
00053
00054 self.aboutText = wx.richtext.RichTextCtrl(id=wxID_ABOUTDIALOGABOUTTEXT,
00055 parent=self, pos=wx.Point(8, 8), size=wx.Size(432, 120),
00056 style=wx.richtext.RE_MULTILINE, value='')
00057 self.aboutText.SetName('aboutText')
00058 self.aboutText.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL,
00059 False, 'Tahoma'))
00060 self.aboutText.SetLabel('text')
00061 self.aboutText.Enable(False)
00062
00063 self.buttonUpdateIPDB = wx.Button(id=wxID_ABOUTDIALOGBUTTONUPDATEIPDB,
00064 label='Install IP Database', name='buttonUpdateIPDB', parent=self,
00065 pos=wx.Point(24, 144), size=wx.Size(168, 23), style=0)
00066 self.buttonUpdateIPDB.Bind(wx.EVT_BUTTON, self.OnButtonUpdateIPDBButton,
00067 id=wxID_ABOUTDIALOGBUTTONUPDATEIPDB)
00068
00069 self.buttonVisitWebsite = wx.Button(id=wxID_ABOUTDIALOGBUTTONVISITWEBSITE,
00070 label='EyeSpy Home Page', name='buttonVisitWebsite', parent=self,
00071 pos=wx.Point(128, 184), size=wx.Size(192, 24), style=0)
00072 self.buttonVisitWebsite.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL,
00073 wx.BOLD, False, 'Tahoma'))
00074 self.buttonVisitWebsite.SetForegroundColour(wx.Colour(255, 0, 0))
00075 self.buttonVisitWebsite.Bind(wx.EVT_BUTTON,
00076 self.OnButtonVisitWebsiteButton,
00077 id=wxID_ABOUTDIALOGBUTTONVISITWEBSITE)
00078
00079 self.ViewLicense = wx.Button(id=wxID_ABOUTDIALOGVIEWLICENSE,
00080 label='View License', name='ViewLicense', parent=self,
00081 pos=wx.Point(248, 144), size=wx.Size(168, 23), style=0)
00082 self.ViewLicense.Bind(wx.EVT_BUTTON, self.OnViewLicenseButton,
00083 id=wxID_ABOUTDIALOGVIEWLICENSE)
00084
00085 def __init__(self, parent, optionsConfig):
00086 self._init_ctrls(parent)
00087 self.optConfig = optionsConfig
00088
00089 self.geoUtils = geoIPUtils("")
00090 lastUpdateTime = self.geoUtils.getLastUpdateTime()
00091
00092
00093
00094 aboutString = globalStrings.ABOUT_STRING
00095
00096 aboutString += "\n"
00097
00098 if (self.geoUtils.isGEOIPDatabaseInstalled() == False):
00099 aboutString += "The GEO IP Database is not included by default with EyeSpy. "
00100 aboutString += "Please visit EyeSpy's home page to view instructions on how to obtain a copy.\n"
00101 else:
00102 aboutString += "The Last GEO IP Update was on: " + lastUpdateTime
00103
00104
00105 self.aboutText.WriteText(aboutString)
00106
00107
00108
00109
00110 def OnButtonUpdateIPDBButton(self, event):
00111 dlg = wx.FileDialog(self, "Install GEO IP Database ...", os.getcwd(), "*.dat", "GeoIP Data files (*.dat)|*.dat", style=wx.OPEN)
00112
00113 if dlg.ShowModal() == wx.ID_OK:
00114 geoIPArchivePath = dlg.GetPath()
00115 print geoIPArchivePath
00116
00117 self.geoUtils = geoIPUtils(geoIPArchivePath)
00118
00119
00120
00121
00122
00123 try:
00124 self.geoUtils.updateGEOIPDatabase(geoIPArchivePath)
00125
00126 dlg = wx.MessageDialog(None, "Database was successfully installed.\nYou must restart the application for changes to take effect", 'Info', wx.ICON_INFORMATION)
00127 result = dlg.ShowModal()
00128 dlg.Destroy()
00129
00130
00131 except Exception, ex:
00132 logger.log(__name__ + ": GEO IP Database not updated because of an exception")
00133
00134 errMsg = "Could update Geo IP Database: %s" % str(ex)
00135 dlg = wx.MessageDialog(None, errMsg, 'Error', wx.ICON_ERROR)
00136 result = dlg.ShowModal()
00137 dlg.Destroy()
00138
00139
00140
00141
00142 def OnButtonVisitWebsiteButton(self, event):
00143 webbrowser.open_new_tab(self.optConfig.navigation_getAppHomePage())
00144
00145
00146
00147 def OnViewLicenseButton(self, event):
00148 webbrowser.open_new_tab(self.optConfig.navigation_getLicenseSite())
00149
00150
00151