00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 from objects.logic.common.exception import exception
00019 from objects.logic.common.logger import logger
00020 from objects.logic.configuration.configurator import configurator
00021 from objects.logic.common.globalStrings import globalStrings
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class optionsConfigurator(configurator):
00033
00034
00035
00036
00037
00038 def ident_getConfigCoordinates(self):
00039 lon = None
00040 lat = None
00041 configValid = self.ident_getConfigValid()
00042
00043 if self.ident_getIdentByIPAddr() == True:
00044 lon = self.getConfigValue("Identification", "info_longitude", "", False)
00045 lat = self.getConfigValue("Identification", "info_latitude", "", False)
00046
00047
00048 if lon == "" or lat == "":
00049 return 0, 0, configValid
00050 else:
00051 return float(lon), float(lat), configValid
00052
00053
00054 else:
00055 (lon, lat) = self.ident_getManualCoord()
00056 return lon, lat, configValid
00057
00058
00059
00060
00061 def ident_getIdentByIPAddr(self):
00062 identMethod = self.getConfigValue("Identification", "ident_method", "", False)
00063
00064 if identMethod == "BYIPADDR":
00065 return True
00066 else:
00067 return False
00068
00069
00070
00071
00072
00073 def ident_getIdentByCoord(self):
00074 identMethod = self.getConfigValue("Identification", "ident_method", "", False)
00075
00076 if identMethod == "BYCOORD":
00077 return True
00078 else:
00079 return False
00080
00081
00082
00083
00084 def ident_getIPAddr(self):
00085 ipAddr = self.getConfigValue("Identification", "ipaddress", "", True)
00086 return ipAddr
00087
00088
00089
00090
00091
00092
00093
00094
00095 def ident_getIPGeoInfo(self):
00096 lon = self.getConfigValue("Identification", "info_longitude", "", True)
00097 lat = self.getConfigValue("Identification", "info_latitude", "", True)
00098 city = self.getConfigValue("Identification", "info_city", "", True)
00099 statProv = self.getConfigValue("Identification", "info_state_prov", "", True)
00100 country = self.getConfigValue("Identification", "info_country", "", True)
00101 org = self.getConfigValue("Identification", "info_organization", "", True)
00102 ISP = self.getConfigValue("Identification", "info_isp", "", True)
00103
00104 return (self.readFmat(lon), lat, city, statProv, country, org, ISP)
00105
00106
00107
00108
00109
00110 def ident_getManualCoord(self):
00111 lon = self.getConfigValue("Identification", "manual_longitude", "0.00", True)
00112 lat = self.getConfigValue("Identification", "manual_latitude", "0.00", True)
00113
00114 return (float(lon), float(lat))
00115
00116
00117
00118
00119
00120
00121 def ident_getConfigValid(self):
00122 configValid = self.getConfigValue("Identification", "configuration_valid", "N", True)
00123
00124 return configValid
00125
00126
00127
00128
00129 def network_getRecordTraffic(self):
00130 recordTraffic = self.getConfigValue("Network", "record_traffic", "N", True)
00131
00132 if recordTraffic == "Y":
00133 return True
00134 else:
00135 return False
00136
00137
00138
00139
00140 def network_getNeverStopRecording(self):
00141 neverStorRecording = self.getConfigValue("Network", "never_stop_recording", "N", True)
00142
00143 if neverStorRecording == "Y":
00144 return True
00145 else:
00146 return False
00147
00148
00149
00150
00151 def network_getRecordingMaxLimit(self):
00152 recordingMaxLimit = self.getConfigValue("Network", "recording_max_limit", "100", True)
00153
00154 return int(recordingMaxLimit)
00155
00156
00157
00158
00159 def network_getSaveDeviceSelection(self):
00160 saveSelection = self.getConfigValue("Network", "save_device_selection", "N", True)
00161
00162 if saveSelection == "Y":
00163 return True
00164 else:
00165 return False
00166
00167
00168
00169
00170 def network_getSelectedDevice(self):
00171 selectedDevice = self.getConfigValue("Network", "selected_device", "", True)
00172
00173 return selectedDevice
00174
00175
00176
00177
00178
00179 def navigation_getLicenseSite(self):
00180 licenseSite = self.getConfigValue("navigation", "license_site", globalStrings.defLicenseSite, True)
00181
00182 return licenseSite
00183
00184 def navigation_getAppHomePage(self):
00185 homePage = self.getConfigValue("navigation", "home_page", globalStrings.defHomePage, True)
00186
00187 return homePage
00188
00189
00190 """
00191 --- Setters ---
00192 """
00193
00194
00195
00196 def ident_setIdentByIPAddr(self):
00197 self.setConfigValue("Identification", "ident_method", "BYIPADDR")
00198
00199
00200
00201 def ident_setIdentByCoord(self):
00202 self.setConfigValue("Identification", "ident_method", "BYCOORD")
00203
00204
00205
00206
00207 def ident_setIPAddr(self, ipAddr):
00208 self.setConfigValue("Identification", "ipaddress", ipAddr)
00209
00210 def ident_setIPGeoInfo(self, (lon, lat, city, stateProv, country, org, ISP)):
00211 self.setConfigValue("Identification", "info_longitude", lon)
00212 self.setConfigValue("Identification", "info_latitude", lat)
00213 self.setConfigValue("Identification", "info_city", city)
00214 self.setConfigValue("Identification", "info_state_prov", stateProv)
00215 self.setConfigValue("Identification", "info_country", country)
00216 self.setConfigValue("Identification", "info_organization", org)
00217 self.setConfigValue("Identification", "info_isp", ISP)
00218
00219
00220
00221
00222
00223
00224 def ident_setManualCoord(self, (lon, lat)):
00225
00226 lon = str(lon)
00227 lat = str(lat)
00228
00229 if lon == None or lon == "": lon = "0.00"
00230 if lat == None or lat == "": lat = "0.00"
00231
00232 self.setConfigValue("Identification", "manual_longitude", lon)
00233 self.setConfigValue("Identification", "manual_latitude", lat)
00234
00235
00236
00237
00238 def ident_setConfigValid(self, configValid):
00239 if configValid == True: configValid = "Y"
00240 else: configValid = "N"
00241
00242 self.setConfigValue("Identification", "configuration_valid", configValid)
00243
00244
00245
00246
00247
00248 def network_setRecordTraffic(self, value):
00249 if value == True: value = "Y"
00250 else: value = "N"
00251
00252 self.setConfigValue("Network", "record_traffic", value)
00253
00254
00255
00256
00257
00258 def network_setNeverStopRecording(self, value):
00259 if value == True: value = "Y"
00260 else: value = "N"
00261
00262 self.setConfigValue("Network", "never_stop_recording", value)
00263
00264
00265
00266
00267
00268 def network_setRecordingMaxLimit(self, maxLimit):
00269 self.setConfigValue("Network", "recording_max_limit", str(maxLimit))
00270
00271
00272
00273
00274
00275 def network_setSaveDeviceSelection(self, saveSelection):
00276 if saveSelection == True: saveSelection = "Y"
00277 else: saveSelection = "N"
00278
00279 self.setConfigValue("Network", "save_device_selection", saveSelection)
00280
00281
00282
00283
00284
00285 def network_setSelectedDevice(self, selectedDevice):
00286 self.setConfigValue("Network", "selected_device", selectedDevice)
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298