Esempio n. 1
0
	def __init__(self,audio=False,vibra=True):
		self.manager = MNotificationManager('wazappnotify','WazappNotify');
		self.vibra = vibra
		
		
		
		self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings
		self.devInfo = QSystemDeviceInfo();
		
		self.devInfo.currentProfileChanged.connect(self.profileChanged);
		
		
		if audio:
			self.audio = QMediaPlayer(); 
			self.audio.setVolume(100);
		else:
			self.audio = False
			
		self.enabled = True
		self.notifications = {}
		
		if self.vibra:
			self.vibra = QFeedbackHapticsEffect();
			self.vibra.setIntensity(1.0);
			self.vibra.setDuration(200);
Esempio n. 2
0
    def setupDevice(self):
        self.deviceInfo = QSystemDeviceInfo(self)
        self._batteryLevel = self.deviceInfo.batteryLevel()
        self.deviceInfo.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.deviceInfo.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.deviceInfo.powerStateChanged.connect(self.updatePowerState)
        self._imei = self.deviceInfo.imei()
        self._imsi = self.deviceInfo.imsi()
        self._manufacturer = self.deviceInfo.manufacturer()
        self._model = self.deviceInfo.model()
        self._product = self.deviceInfo.productName()
        self._deviceLock = self.deviceInfo.isDeviceLocked()

        methods = self.deviceInfo.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self._inputMethod = " ".join(inputs)
        self.updateSimStatus()
        self.updateProfile()

        self._bluetoothState = self.deviceInfo.currentBluetoothPowerState()
        self.deviceInfo.bluetoothStateChanged.connect(
            self.updateBluetoothState)
Esempio n. 3
0
    def setupDevice(self):
        self.deviceInfo = QSystemDeviceInfo(self)
        self._batteryLevel = self.deviceInfo.batteryLevel()
        self.deviceInfo.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.deviceInfo.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.deviceInfo.powerStateChanged.connect(self.updatePowerState)
        self._imei = self.deviceInfo.imei()
        self._imsi = self.deviceInfo.imsi()
        self._manufacturer = self.deviceInfo.manufacturer()
        self._model = self.deviceInfo.model()
        self._product = self.deviceInfo.productName()
        self._deviceLock = self.deviceInfo.isDeviceLocked()

        methods = self.deviceInfo.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self._inputMethod = " ".join(inputs)
        self.updateSimStatus()
        self.updateProfile()

        self._bluetoothState = self.deviceInfo.currentBluetoothPowerState()
        self.deviceInfo.bluetoothStateChanged.connect(self.updateBluetoothState)
Esempio n. 4
0
	def __init__(self,audio=False,vibra=False):
		_d = NotifierDebug();
		self._d = _d.d;
		
		self.manager = MNotificationManager('wazappnotify','WazappNotify');
		self.vibra = vibra
		
		
		
		self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings
		self.devInfo = QSystemDeviceInfo();
		
		self.devInfo.currentProfileChanged.connect(self.profileChanged);
		
		
		if audio:
			self.audio = QMediaPlayer(); 
			self.audio.setVolume(100);
		else:
			self.audio = False
			
		self.enabled = True
		self.notifications = {}
		
		if self.vibra:
			self.vibra = QFeedbackHapticsEffect();
			self.vibra.setIntensity(1.0);
			self.vibra.setDuration(200);
Esempio n. 5
0
    def setupDevice(self):
        del self.di

        self.di = QSystemDeviceInfo(self)
        self.batteryLevelBar.setValue(self.di.batteryLevel())
        self.di.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.di.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.di.powerStateChanged.connect(self.updatePowerState)
        self.ImeiLabel.setText(self.di.imei())
        self.imsiLabel.setText(self.di.imsi())
        self.manufacturerLabel.setText(self.di.manufacturer())
        self.modelLabel.setText(self.di.model())
        self.productLabel.setText(self.di.productName())
        self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

        self.updateSimStatus()
        self.updateProfile()

        self.di.currentProfileChanged.connect(self.onProfileChanged)
        if self.di.currentPowerState() == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif self.di.currentPowerState(
        ) == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        else:
            self.radioButton.setChecked(True)

        methods = self.di.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self.inputMethodLabel.setText(" ".join(inputs))
Esempio n. 6
0
	def __init__(self,audio=True,vibra=True):
		_d = NotifierDebug();
		self._d = _d.d;

		self.manager = MNotificationManager('wazappnotify','WazappNotify');
		self.vibra = vibra

		self.personalRingtone = WAConstants.DEFAULT_SOUND_NOTIFICATION;
		self.personalVibrate = True;
		self.groupRingtone = WAConstants.DEFAULT_SOUND_NOTIFICATION;
		self.groupVibrate = True;
		
		QCoreApplication.setApplicationName("Wazapp");


		self.audioOutput = Phonon.AudioOutput(Phonon.MusicCategory, None)
		self.mediaObject = Phonon.MediaObject(None)
		Phonon.createPath(self.mediaObject, self.audioOutput)		

		self.profileChanged(0, 0, self.getCurrentProfile(), 0)
		bus = dbus.SessionBus()
		mybus = bus.get_object('com.nokia.profiled', '/com/nokia/profiled')
		self.nface = dbus.Interface(mybus, 'com.nokia.profiled')
		self.nface.connect_to_signal("profile_changed", self.profileChanged)
		#prof = self.getCurrentProfile()
		#reply = self.nface.get_value(prof,"ringing.alert.volume");
		#self.currentProfile = prof
		#self.currentVolume = "1.0" if reply=="100" else "0." + reply
		#self._d("Checking current profile: " + prof + " - Volume: " + self.currentVolume)
		#self.audioOutput.setVolume(float(self.currentVolume))

		
		#self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings
		self.devInfo = QSystemDeviceInfo();
		
		#self.devInfo.currentProfileChanged.connect(self.profileChanged);
		
		self.audio = True
		'''if audio:
			self.audio = QMediaPlayer(None,QMediaPlayer.LowLatency); 
			self.audio.setVolume(100);
		else:
			self.audio = False'''
			
		self.enabled = True
		self.notifications = {}
		

		# vibration comes too early here, now handled by ui.py when the message is already added in QML
		# well, the truth is that sound comes too late... :D
		#>> Any notification should be handler by the notifier, not UI :P I don't feel it's too early though,
		# but if necessary connect to a signal and vibrate from here.
		if self.vibra:
			self.vibra = QFeedbackHapticsEffect();
			self.vibra.setIntensity(1.0);
			self.vibra.setDuration(200);
Esempio n. 7
0
    def setupDevice(self):
        del self.di

        self.di = QSystemDeviceInfo(self)
        self.batteryLevelBar.setValue(self.di.batteryLevel())
        self.di.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.di.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.di.powerStateChanged.connect(self.updatePowerState)
        self.ImeiLabel.setText(self.di.imei())
        self.imsiLabel.setText(self.di.imsi())
        self.manufacturerLabel.setText(self.di.manufacturer())
        self.modelLabel.setText(self.di.model())
        self.productLabel.setText(self.di.productName())
        self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

        self.updateSimStatus()
        self.updateProfile()

        self.di.currentProfileChanged.connect(self.onProfileChanged)
        if self.di.currentPowerState() == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        else:
            self.radioButton.setChecked(True)

        methods = self.di.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self.inputMethodLabel.setText(" ".join(inputs))
Esempio n. 8
0
	def getImsi():
		#return "000000000000000"
		dev_info = QSystemDeviceInfo();
		return dev_info.imsi();
Esempio n. 9
0
class SystemInfoModel(QtCore.QObject):
    changed = QtCore.Signal()

    def __init__(self):
        super(SystemInfoModel, self).__init__()
        self.systemInfo = QSystemInfo(self)
        self.setupGeneral()
        self.setupDevice()
        self.setupDisplay()
        self.setupStorage()
        self.setupNetwork()
        self.setupScreenSaver()

    @QtCore.Property(str, notify=changed)
    def currentLanguage(self):
        return self._currentLanguage

    @QtCore.Property("QStringList", notify=changed)
    def availableLanguages(self):
        return self._availableLanguages

    @QtCore.Property(int, notify=changed)
    def displayBrightness(self):
        return self._displayBrightness

    @QtCore.Property(int, notify=changed)
    def colorDepth(self):
        return self._colorDepth

    @QtCore.Property(str, notify=changed)
    def imei(self):
        return self._imei

    @QtCore.Property(str, notify=changed)
    def imsi(self):
        return self._imsi

    @QtCore.Property(str, notify=changed)
    def manufacturer(self):
        return self._manufacturer

    @QtCore.Property(str, notify=changed)
    def product(self):
        return self._product

    @QtCore.Property(str, notify=changed)
    def model(self):
        return self._model

    @QtCore.Property(str, notify=changed)
    def profile(self):
        return self._profile

    @QtCore.Property(str, notify=changed)
    def inputMethod(self):
        return self._inputMethod

    @QtCore.Property(bool, notify=changed)
    def deviceLock(self):
        return self._deviceLock

    @QtCore.Property(str, notify=changed)
    def simStatus(self):
        return self._simStatus

    @QtCore.Property(bool, notify=changed)
    def bluetoothState(self):
        return self._bluetoothState

    @QtCore.Property("QStringList", notify=changed)
    def volumeNames(self):
        return self._volumeNames

    @QtCore.Property("QStringList", notify=changed)
    def networksNames(self):
        return ["Wlan", "Ethernet", "Gsm", "Cdma", "Wcdma"]

    @QtCore.Property(bool, notify=changed)
    def screenSaverInhibited(self):
        return self._screenSaverInhibited

    def setupGeneral(self):
        self._currentLanguage = self.systemInfo.currentLanguage()
        self._availableLanguages = self.systemInfo.availableLanguages()

    def setupDevice(self):
        self.deviceInfo = QSystemDeviceInfo(self)
        self._batteryLevel = self.deviceInfo.batteryLevel()
        self.deviceInfo.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.deviceInfo.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.deviceInfo.powerStateChanged.connect(self.updatePowerState)
        self._imei = self.deviceInfo.imei()
        self._imsi = self.deviceInfo.imsi()
        self._manufacturer = self.deviceInfo.manufacturer()
        self._model = self.deviceInfo.model()
        self._product = self.deviceInfo.productName()
        self._deviceLock = self.deviceInfo.isDeviceLocked()

        methods = self.deviceInfo.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self._inputMethod = " ".join(inputs)
        self.updateSimStatus()
        self.updateProfile()

        self._bluetoothState = self.deviceInfo.currentBluetoothPowerState()
        self.deviceInfo.bluetoothStateChanged.connect(
            self.updateBluetoothState)

    def setupDisplay(self):
        self.displayInfo = QSystemDisplayInfo()
        self._displayBrightness = self.displayInfo.displayBrightness(0)
        self._colorDepth = self.displayInfo.colorDepth(0)

    def setupStorage(self):
        self.storageInfo = QSystemStorageInfo()
        self._volumeNames = self.storageInfo.logicalDrives()

    @QtCore.Slot(str, result=str)
    def storageType(self, volumeName):
        names = {
            QSystemStorageInfo.InternalDrive: "Internal",
            QSystemStorageInfo.RemovableDrive: "Removable",
            QSystemStorageInfo.CdromDrive: "CD-Rom",
            QSystemStorageInfo.RemoteDrive: "Network",
        }

        volType = self.storageInfo.typeForDrive(volumeName)

        return names.get(volType, "Unknown")

    @QtCore.Slot(str, result=str)
    def totalStorageSize(self, volumeName):
        return self.convert_bytes(self.storageInfo.totalDiskSpace(volumeName))

    @QtCore.Slot(str, result=str)
    def availableStorageSize(self, volumeName):
        return self.convert_bytes(
            self.storageInfo.availableDiskSpace(volumeName))

    def convert_bytes(self, bytes):
        # From http://www.5dollarwhitebox.org/drupal/node/84
        bytes = float(bytes)
        if bytes >= 1099511627776:
            terabytes = bytes / 1099511627776
            size = '%.2fT' % terabytes
        elif bytes >= 1073741824:
            gigabytes = bytes / 1073741824
            size = '%.2fG' % gigabytes
        elif bytes >= 1048576:
            megabytes = bytes / 1048576
            size = '%.2fM' % megabytes
        elif bytes >= 1024:
            kilobytes = bytes / 1024
            size = '%.2fK' % kilobytes
        else:
            size = '%.2fb' % bytes
        return size

    def setupNetwork(self):
        self.networkInfo = QSystemNetworkInfo()

    def modeEnumForName(self, name):
        try:
            mode = getattr(QSystemNetworkInfo, name.capitalize() + "Mode")
        except AttributeError as e:
            print e
            return None

        return mode

    @QtCore.Slot(str, result=str)
    def networkStatus(self, modeName):
        mode = self.modeEnumForName(modeName)
        status = self.networkInfo.networkStatus(mode)
        statusName = str(status).split('.')[-1]
        # Split the CamelCase enum name
        import re
        return re.sub(r'([a-z])([A-Z])', r'\1 \2', statusName)

    @QtCore.Slot(str, result=str)
    def networkName(self, modeName):
        mode = self.modeEnumForName(modeName)
        name = self.networkInfo.networkName(mode)
        return name if name else "<Unknown>"

    @QtCore.Slot(str, result=str)
    def networkInterfaceName(self, modeName):
        mode = self.modeEnumForName(modeName)
        name = self.networkInfo.interfaceForMode(mode).humanReadableName()
        return name if name else "<Unknown>"

    @QtCore.Slot(str, result=str)
    def networkMacAddress(self, modeName):
        mode = self.modeEnumForName(modeName)
        mac = self.networkInfo.macAddress(mode)
        return mac if mac else "<Unknown>"

    @QtCore.Slot(str, result=int)
    def networkSignalStrength(self, modeName):
        mode = self.modeEnumForName(modeName)
        return self.networkInfo.networkSignalStrength(mode)

    @QtCore.Slot(result=str)
    def cellId(self):
        cell = self.networkInfo.cellId()
        return str(cell) if cell != -1 else "<Unavailable>"

    @QtCore.Slot(result=str)
    def locationAreaCode(self):
        code = self.networkInfo.locationAreaCode()
        return str(code) if code != -1 else "<Unavailable>"

    @QtCore.Slot(result=str)
    def currentMCC(self):
        code = self.networkInfo.currentMobileCountryCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def currentMNC(self):
        code = self.networkInfo.currentMobileNetworkCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def homeMCC(self):
        code = self.networkInfo.homeMobileCountryCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def homeMNC(self):
        code = self.networkInfo.homeMobileNetworkCode()
        return code if code else "<Unavailable>"

    def setupScreenSaver(self):
        self.saverInfo = QSystemScreenSaver(self)
        self._screenSaverInhibited = self.saverInfo.screenSaverInhibited()

    def updateBluetoothState(self, on):
        self._bluetoothState = on
        self.changed.emit()

    def updateBatteryStatus(self, status):
        self._batteryLevel = status
        self.emit(QtCore.SIGNAL('changed()'))

    def displayBatteryStatus(self, status):
        pass

    def updatePowerState(self, newState):
        pass

    def updateSimStatus(self):
        if self.deviceInfo:
            status = self.deviceInfo.simStatus()
            if status == QSystemDeviceInfo.SimLocked:
                simstring = "Sim Locked"
            elif status == QSystemDeviceInfo.SimNotAvailable:
                simstring = "Sim not available"
            elif status == QSystemDeviceInfo.SingleSimAvailable:
                simstring = "Single Sim Available"
            elif status == QSystemDeviceInfo.DualSimAvailable:
                simstring = "Dual Sim available"
            else:
                simstring = ""

            self._simStatus = simstring

    def updateProfile(self):
        if self.deviceInfo:
            current = self.deviceInfo.currentProfile()
            if current == QSystemDeviceInfo.UnknownProfile:
                profilestring = "Unknown"
            elif current == QSystemDeviceInfo.SilentProfile:
                profilestring = "Silent"
            elif current == QSystemDeviceInfo.NormalProfile:
                profilestring = "Normal"
            elif current == QSystemDeviceInfo.LoudProfile:
                profilestring = "Loud"
            elif current == QSystemDeviceInfo.VibProfile:
                profilestring = "Vibrate"
            elif current == QSystemDeviceInfo.OfflineProfile:
                profilestring = "Offline"
            elif current == QSystemDeviceInfo.PowersaveProfile:
                profilestring = "Powersave"
            elif current == QSystemDeviceInfo.CustomProfile:
                profilestring = "custom"

            self._profile = profilestring
Esempio n. 10
0
 def getProfile():
     dev_info = QSystemDeviceInfo()
     return dev_info.currentProfile()
Esempio n. 11
0
 def getImei():
     #return "355960045823461";
     dev_info = QSystemDeviceInfo()
     return dev_info.imei()
Esempio n. 12
0
class Dialog(QWidget, Ui_Dialog):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.systemInfo = None
        self.di = None
        self.ni = None
        self.sti = None
        self.saver = None
        self.uiCreated = False

        self.setupUi(self)

        self.uiCreated = True
        self.setupGeneral()

        self.tabWidget.currentChanged.connect(self.tabChanged)
        self.versionComboBox.activated[int].connect(self.getVersion)
        self.featureComboBox.activated[int].connect(self.getFeature)

        self.updateDeviceLockedState()
        timer = QTimer(self)
        timer.timeout.connect(self.updateDeviceLockedState)
        timer.start(1000)

    def changeEvent(self, e):
        QWidget.changeEvent(self, e)

        if e.type() == QEvent.LanguageChange and self.uiCreated:
            self.retranslateUi(self)

    def tabChanged(self, index):
        if index == 0:
            self.setupGeneral()
        elif index == 1:
            self.setupDevice()
        elif index == 2:
            self.setupDisplay()
        elif index == 3:
            self.setupStorage()
        elif index == 4:
            self.setupNetwork()
        elif index == 5:
            self.setupSaver()

    def setupGeneral(self):
        del self.systemInfo

        self.systemInfo = QSystemInfo(self)
        self.curLanguageLineEdit.setText(self.systemInfo.currentLanguage())

        self.languagesComboBox.clear()
        self.languagesComboBox.insertItems(
            0, self.systemInfo.availableLanguages())
        self.countryCodeLabel.setText(self.systemInfo.currentCountryCode())

    def setupDevice(self):
        del self.di

        self.di = QSystemDeviceInfo(self)
        self.batteryLevelBar.setValue(self.di.batteryLevel())
        self.di.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.di.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.di.powerStateChanged.connect(self.updatePowerState)
        self.ImeiLabel.setText(self.di.imei())
        self.imsiLabel.setText(self.di.imsi())
        self.manufacturerLabel.setText(self.di.manufacturer())
        self.modelLabel.setText(self.di.model())
        self.productLabel.setText(self.di.productName())
        self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

        self.updateSimStatus()
        self.updateProfile()

        self.di.currentProfileChanged.connect(self.onProfileChanged)
        if self.di.currentPowerState() == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif self.di.currentPowerState(
        ) == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        else:
            self.radioButton.setChecked(True)

        methods = self.di.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self.inputMethodLabel.setText(" ".join(inputs))

    def updateDeviceLockedState(self):
        if self.di:
            self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

    def onProfileChanged(self, p):
        self.updateProfile()

    def setupDisplay(self):
        di = QSystemDisplayInfo()
        self.brightnessLabel.setText(str(di.displayBrightness(0)))
        self.colorDepthLabel.setText(str(di.colorDepth((0))))

    def setupStorage(self):
        if not self.sti:
            self.sti = QSystemStorageInfo(self)
            self.storageTreeWidget.header().setResizeMode(
                QHeaderView.ResizeToContents)
        self.updateStorage()

    def updateStorage(self):
        self.storageTreeWidget.clear()

        vols = self.sti.logicalDrives()
        for volName in vols:
            volType = self.sti.typeForDrive(volName)
            if volType == QSystemStorageInfo.InternalDrive:
                typeName = "Internal"
            elif volType == QSystemStorageInfo.RemovableDrive:
                typeName = "Removable"
            elif volType == QSystemStorageInfo.CdromDrive:
                typeName = "Cdrom"
            elif volType == QSystemStorageInfo.RemoteDrive:
                typeName = "Network"
            items = []
            items.append(volName)
            items.append(typeName)
            items.append(str(self.sti.totalDiskSpace(volName)))
            items.append(str(self.sti.availableDiskSpace(volName)))
            item = QTreeWidgetItem(items)
            self.storageTreeWidget.addTopLevelItem(item)

    def setupNetwork(self):
        del self.ni
        self.ni = QSystemNetworkInfo(self)
        self.netStatusComboBox.activated[int].connect(
            self.netStatusComboActivated)
        self.ni.networkSignalStrengthChanged.connect(
            self.networkSignalStrengthChanged)
        self.ni.networkNameChanged.connect(self.networkNameChanged)
        self.ni.networkStatusChanged.connect(self.networkStatusChanged)
        self.ni.networkModeChanged.connect(self.networkModeChanged)
        self.cellIdLabel.setText(str(self.ni.cellId()))
        self.locationAreaCodeLabel.setText(str(self.ni.locationAreaCode()))
        self.currentMMCLabel.setText(self.ni.currentMobileCountryCode())
        self.currentMNCLabel.setText(self.ni.currentMobileNetworkCode())
        self.homeMMCLabel.setText(self.ni.homeMobileCountryCode())
        self.homeMNCLabel.setText(self.ni.homeMobileNetworkCode())
        self.networkModeChanged(self.ni.currentMode())

    def netStatusComboActivated(self, index):
        status = ""
        reIndex = QSystemNetworkInfo.NetworkMode(index)
        self.displayNetworkStatus(self.ni.networkStatus(reIndex))
        self.macAddressLabel.setText(self.ni.macAddress(reIndex))
        strength = self.ni.networkSignalStrength(reIndex)
        if strength < 0:
            strength = 0
        self.signalLevelProgressBar.setValue(strength)
        self.InterfaceLabel.setText(
            self.ni.interfaceForMode(reIndex).humanReadableName())
        self.operatorNameLabel.setText(self.ni.networkName(reIndex))

    def getVersion(self, index):
        version = QSystemInfo.Version()
        if index == 0:
            self.versionLineEdit.setText("")
        elif index == 1:
            version = QSystemInfo.Os
        elif index == 2:
            version = QSystemInfo.QtCore
        elif index == 3:
            version = QSystemInfo.Firmware

        si = QSystemInfo()
        self.versionLineEdit.setText(si.version(version))

    def getFeature(self, index):
        if index == 0:
            return
        elif index == 1:
            feature = QSystemInfo.BluetoothFeature
        elif index == 2:
            feature = QSystemInfo.CameraFeature
        elif index == 3:
            feature = QSystemInfo.FmradioFeature
        elif index == 4:
            feature = QSystemInfo.IrFeature
        elif index == 5:
            feature = QSystemInfo.LedFeature
        elif index == 6:
            feature = QSystemInfo.MemcardFeature
        elif index == 7:
            feature = QSystemInfo.UsbFeature
        elif index == 8:
            feature = QSystemInfo.VibFeature
        elif index == 9:
            feature = QSystemInfo.WlanFeature
        elif index == 10:
            feature = QSystemInfo.SimFeature
        elif index == 11:
            feature = QSystemInfo.LocationFeature
        elif index == 12:
            feature = QSystemInfo.VideoOutFeature
        elif index == 13:
            feature = QSystemInfo.HapticsFeature

        si = QSystemInfo()
        text = "false"
        if si.hasFeatureSupported(feature):
            text = "true"
        self.featuresLineEdit.setText(text)

    def setupSaver(self):
        if not self.saver:
            self.saver = QSystemScreenSaver(self)

        saverEnabled = self.saver.screenSaverInhibited()
        self.saverInhibitedCheckBox.clicked.connect(self.setSaverEnabled)
        self.saverInhibitedCheckBox.setChecked(saverEnabled)

    def setSaverEnabled(self, b):
        if b:
            if not self.saver:
                self.saver = QSystemScreenSaver(self)
            if self.saver.setScreenSaverInhibit():
                pass
        else:
            del self.saver
            self.saver = None

    def updateBatteryStatus(self, level):
        self.batteryLevelBar.setValue(level)

    def updatePowerState(self, newState):
        if newState == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif newState == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif newState == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        elif newState == QSystemDeviceInfo.NoBatteryLevel:
            self.radioButton.setChecked(True)

    def displayBatteryStatus(self, status):
        if status == QSystemDeviceInfo.BatteryCritical:
            msg = " Battery is Critical (4% or less), please save your work or plug in the charger."
            QMessageBox.critical(self, "QSystemInfo", msg)
        elif status == QSystemDeviceInfo.BatteryVeryLow:
            msg = "Battery is Very Low (10%), please plug in the charger soon"
            QMessageBox.warning(self, "QSystemInfo", msg)
        elif status == QSystemDeviceInfo.BatteryLow:
            msg = "Battery is Low (40% or less)"
            QMessageBox.information(self, "QSystemInfo", msg)
        elif status == QSystemDeviceInfo.BatteryNormal:
            msg = "Battery is Normal (greater than 40%)"
            QMessageBox.information(self, "QSystemInfo", msg)

    def networkSignalStrengthChanged(self, mode, strength):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.signalLevelProgressBar.setValue(strength)

    def networkNameChanged(self, mode, text):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.operatorNameLabel.setText(text)

    def networkStatusChanged(self, mode, status):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.displayNetworkStatus(status)

    def networkModeChanged(self, mode):
        if mode == QSystemNetworkInfo.WlanMode:
            self.primaryModeLabel.setText("Wlan")

        if mode == QSystemNetworkInfo.EthernetMode:
            self.primaryModeLabel.setText("Ethernet")

        if mode == QSystemNetworkInfo.GsmMode:
            self.primaryModeLabel.setText("Gsm")

        if mode == QSystemNetworkInfo.CdmaMode:
            self.primaryModeLabel.setText("Cdma")

        if mode == QSystemNetworkInfo.WcdmaMode:
            self.primaryModeLabel.setText("Wcdma")

        if mode == QSystemNetworkInfo.UnknownMode:
            self.primaryModeLabel.setText("None")

    def displayNetworkStatus(self, status):
        if status == QSystemNetworkInfo.UndefinedStatus:
            stat = "Undefined"
        if status == QSystemNetworkInfo.NoNetworkAvailable:
            stat = "No Network Available"
        if status == QSystemNetworkInfo.EmergencyOnly:
            stat = "Emergency Only"
        if status == QSystemNetworkInfo.Searching:
            stat = "Searching or Connecting"
        if status == QSystemNetworkInfo.Busy:
            stat = "Busy"
        if status == QSystemNetworkInfo.Connected:
            stat = "Connected"
        if status == QSystemNetworkInfo.HomeNetwork:
            stat = "Home Network"
        if status == QSystemNetworkInfo.Denied:
            stat = "Denied"
        if status == QSystemNetworkInfo.Roaming:
            stat = "Roaming"
        self.cellNetworkStatusLabel.setText(stat)

    def updateProfile(self):
        if self.di:
            current = self.di.currentProfile()
            if current == QSystemDeviceInfo.UnknownProfile:
                profilestring = "Unknown"
            elif current == QSystemDeviceInfo.SilentProfile:
                profilestring = "Silent"
            elif current == QSystemDeviceInfo.NormalProfile:
                profilestring = "Normal"
            elif current == QSystemDeviceInfo.LoudProfile:
                profilestring = "Loud"
            elif current == QSystemDeviceInfo.VibProfile:
                profilestring = "Vibrate"
            elif current == QSystemDeviceInfo.OfflineProfile:
                profilestring = "Offline"
            elif current == QSystemDeviceInfo.PowersaveProfile:
                profilestring = "Powersave"
            elif current == QSystemDeviceInfo.CustomProfile:
                profilestring = "custom"

        self.profileLabel.setText(profilestring)

    def updateSimStatus(self):
        if self.di:
            status = self.di.simStatus()
            if status == QSystemDeviceInfo.SimLocked:
                simstring = "Sim Locked"
            elif status == QSystemDeviceInfo.SimNotAvailable:
                simstring = "Sim not available"
            elif status == QSystemDeviceInfo.SingleSimAvailable:
                simstring = "Single Sim Available"
            elif status == QSystemDeviceInfo.DualSimAvailable:
                simstring = "Dual Sim available"
            else:
                simstring = ""

            self.simStatusLabel.setText(simstring)

    def bluetoothChanged(self, b):
        if b:
            text = "On"
        else:
            text = "Off"
        self.bluetoothPowerLabel.setText(text)
Esempio n. 13
0
class Dialog(QWidget, Ui_Dialog):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.systemInfo = None
        self.di = None
        self.ni = None
        self.sti = None
        self.saver = None
        self.uiCreated = False

        self.setupUi(self)

        self.uiCreated = True
        self.setupGeneral()

        self.tabWidget.currentChanged.connect(self.tabChanged)
        self.versionComboBox.activated[int].connect(self.getVersion)
        self.featureComboBox.activated[int].connect(self.getFeature)


        self.updateDeviceLockedState()
        timer = QTimer(self)
        timer.timeout.connect(self.updateDeviceLockedState)
        timer.start(1000)


    def changeEvent(self, e):
        QWidget.changeEvent(self, e)

        if e.type() == QEvent.LanguageChange and self.uiCreated:
            self.retranslateUi(self)

    def tabChanged(self, index):
        if index == 0:
            self.setupGeneral()
        elif index == 1:
            self.setupDevice()
        elif index == 2:
            self.setupDisplay()
        elif index == 3:
            self.setupStorage()
        elif index == 4:
            self.setupNetwork()
        elif index == 5:
            self.setupSaver()

    def setupGeneral(self):
        del self.systemInfo

        self.systemInfo = QSystemInfo(self)
        self.curLanguageLineEdit.setText(self.systemInfo.currentLanguage())

        self.languagesComboBox.clear()
        self.languagesComboBox.insertItems(0, self.systemInfo.availableLanguages())
        self.countryCodeLabel.setText(self.systemInfo.currentCountryCode())

    def setupDevice(self):
        del self.di

        self.di = QSystemDeviceInfo(self)
        self.batteryLevelBar.setValue(self.di.batteryLevel())
        self.di.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.di.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.di.powerStateChanged.connect(self.updatePowerState)
        self.ImeiLabel.setText(self.di.imei())
        self.imsiLabel.setText(self.di.imsi())
        self.manufacturerLabel.setText(self.di.manufacturer())
        self.modelLabel.setText(self.di.model())
        self.productLabel.setText(self.di.productName())
        self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

        self.updateSimStatus()
        self.updateProfile()

        self.di.currentProfileChanged.connect(self.onProfileChanged)
        if self.di.currentPowerState() == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif self.di.currentPowerState() == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        else:
            self.radioButton.setChecked(True)

        methods = self.di.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self.inputMethodLabel.setText(" ".join(inputs))

    def updateDeviceLockedState(self):
        if self.di:
            self.deviceLockPushButton.setChecked(self.di.isDeviceLocked())

    def onProfileChanged(self, p):
        self.updateProfile()


    def setupDisplay(self):
        di = QSystemDisplayInfo()
        self.brightnessLabel.setText(str(di.displayBrightness(0)))
        self.colorDepthLabel.setText(str(di.colorDepth((0))))

    def setupStorage(self):
        if not self.sti:
            self.sti = QSystemStorageInfo(self)
            self.storageTreeWidget.header().setResizeMode(QHeaderView.ResizeToContents)
        self.updateStorage();

    def updateStorage(self):
        self.storageTreeWidget.clear()

        vols = self.sti.logicalDrives()
        for volName in vols:
            volType = self.sti.typeForDrive(volName)
            if volType == QSystemStorageInfo.InternalDrive:
                typeName =  "Internal"
            elif volType == QSystemStorageInfo.RemovableDrive:
                typeName = "Removable"
            elif volType == QSystemStorageInfo.CdromDrive:
                typeName =  "Cdrom"
            elif volType == QSystemStorageInfo.RemoteDrive:
                typeName =  "Network"
            items = []
            items.append(volName);
            items.append(typeName);
            items.append(str(self.sti.totalDiskSpace(volName)))
            items.append(str(self.sti.availableDiskSpace(volName)))
            item = QTreeWidgetItem(items)
            self.storageTreeWidget.addTopLevelItem(item)


    def setupNetwork(self):
        del self.ni
        self.ni = QSystemNetworkInfo(self)
        self.netStatusComboBox.activated[int].connect(self.netStatusComboActivated)
        self.ni.networkSignalStrengthChanged.connect(self.networkSignalStrengthChanged)
        self.ni.networkNameChanged.connect(self.networkNameChanged)
        self.ni.networkStatusChanged.connect(self.networkStatusChanged)
        self.ni.networkModeChanged.connect(self.networkModeChanged)
        self.cellIdLabel.setText(str(self.ni.cellId()))
        self.locationAreaCodeLabel.setText(str(self.ni.locationAreaCode()))
        self.currentMMCLabel.setText(self.ni.currentMobileCountryCode())
        self.currentMNCLabel.setText(self.ni.currentMobileNetworkCode())
        self.homeMMCLabel.setText(self.ni.homeMobileCountryCode())
        self.homeMNCLabel.setText(self.ni.homeMobileNetworkCode())
        self.networkModeChanged(self.ni.currentMode())

    def netStatusComboActivated(self, index):
        status = ""
        reIndex = index
        self.displayNetworkStatus(self.ni.networkStatus(reIndex))
        self.macAddressLabel.setText(self.ni.macAddress(reIndex))
        strength = self.ni.networkSignalStrength(reIndex)
        if strength < 0:
            strength = 0
        self.signalLevelProgressBar.setValue(strength)
        self.InterfaceLabel.setText(self.ni.interfaceForMode(reIndex).humanReadableName())
        self.operatorNameLabel.setText(self.ni.networkName(reIndex))

    def getVersion(self, index):
        version = QSystemInfo.Version()
        if index == 0:
            self.versionLineEdit.setText("")
        elif index == 1:
            version = QSystemInfo.Os
        elif index == 2:
            version = QSystemInfo.QtCore;
        elif index == 3:
            version = QSystemInfo.Firmware

        si = QSystemInfo()
        self.versionLineEdit.setText(si.version(version))

    def getFeature(self, index):
        if index == 0:
            return
        elif index == 1:
           feature = QSystemInfo.BluetoothFeature
        elif index == 2:
            feature = QSystemInfo.CameraFeature
        elif index == 3:
            feature = QSystemInfo.FmradioFeature
        elif index == 4:
            feature = QSystemInfo.IrFeature;
        elif index == 5:
            feature = QSystemInfo.LedFeature
        elif index == 6:
            feature = QSystemInfo.MemcardFeature
        elif index == 7:
            feature = QSystemInfo.UsbFeature
        elif index == 8:
            feature = QSystemInfo.VibFeature
        elif index == 9:
            feature = QSystemInfo.WlanFeature
        elif index == 10:
            feature = QSystemInfo.SimFeature
        elif index == 11:
            feature = QSystemInfo.LocationFeature
        elif index == 12:
            feature = QSystemInfo.VideoOutFeature
        elif index == 13:
            feature = QSystemInfo.HapticsFeature

        si = QSystemInfo()
        text = "false"
        if si.hasFeatureSupported(feature):
            text = "true"
        self.featuresLineEdit.setText(text)

    def setupSaver(self):
        if not self.saver:
            self.saver = QSystemScreenSaver(self)

        saverEnabled = self.saver.screenSaverInhibited()
        self.saverInhibitedCheckBox.clicked.connect(self.setSaverEnabled)
        self.saverInhibitedCheckBox.setChecked(saverEnabled)

    def setSaverEnabled(self, b):
        if b:
            if not self.saver:
                self.saver = QSystemScreenSaver(self)
            if self.saver.setScreenSaverInhibit():
                pass
        else:
            del self.saver
            self.saver = None


    def updateBatteryStatus(self, level):
        self.batteryLevelBar.setValue(level)

    def updatePowerState(self, newState):
        if newState == QSystemDeviceInfo.BatteryPower:
            self.radioButton_2.setChecked(True)
        elif newState == QSystemDeviceInfo.WallPower:
            self.radioButton_3.setChecked(True)
        elif newState == QSystemDeviceInfo.WallPowerChargingBattery:
            self.radioButton_4.setChecked(True)
        elif newState == QSystemDeviceInfo.NoBatteryLevel:
            self.radioButton.setChecked(True);

    def displayBatteryStatus(self, status):
        if status == QSystemDeviceInfo.BatteryCritical:
            msg = " Battery is Critical (4% or less), please save your work or plug in the charger."
            QMessageBox.critical(self, "QSystemInfo", msg)
        elif status == QSystemDeviceInfo.BatteryVeryLow:
            msg = "Battery is Very Low (10%), please plug in the charger soon"
            QMessageBox.warning(self, "QSystemInfo", msg);
        elif status == QSystemDeviceInfo.BatteryLow:
            msg = "Battery is Low (40% or less)";
            QMessageBox.information(self, "QSystemInfo", msg)
        elif status == QSystemDeviceInfo.BatteryNormal:
            msg = "Battery is Normal (greater than 40%)";
            QMessageBox.information(self, "QSystemInfo", msg)

    def networkSignalStrengthChanged(self, mode, strength):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.signalLevelProgressBar.setValue(strength)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.signalLevelProgressBar.setValue(strength)

    def networkNameChanged(self, mode, text):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.operatorNameLabel.setText(text);

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.operatorNameLabel.setText(text)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.operatorNameLabel.setText(text)


    def networkStatusChanged(self, mode, status):
        if mode == QSystemNetworkInfo.WlanMode:
            if self.netStatusComboBox.currentText() == "Wlan":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.EthernetMode:
            if self.netStatusComboBox.currentText() == "Ethernet":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.GsmMode:
            if self.netStatusComboBox.currentText() == "Gsm":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.CdmaMode:
            if self.netStatusComboBox.currentText() == "Cdma":
                self.displayNetworkStatus(status)

        if mode == QSystemNetworkInfo.WcdmaMode:
            if self.netStatusComboBox.currentText() == "Wcdma":
                self.displayNetworkStatus(status)

    def networkModeChanged(self, mode):
        if mode == QSystemNetworkInfo.WlanMode:
            self.primaryModeLabel.setText("Wlan")

        if mode == QSystemNetworkInfo.EthernetMode:
            self.primaryModeLabel.setText("Ethernet")

        if mode == QSystemNetworkInfo.GsmMode:
            self.primaryModeLabel.setText("Gsm")

        if mode == QSystemNetworkInfo.CdmaMode:
            self.primaryModeLabel.setText("Cdma")

        if mode == QSystemNetworkInfo.WcdmaMode:
            self.primaryModeLabel.setText("Wcdma")

        if mode == QSystemNetworkInfo.UnknownMode:
            self.primaryModeLabel.setText("None")


    def displayNetworkStatus(self, status):
        if status == QSystemNetworkInfo.UndefinedStatus:
            stat = "Undefined"
        if status == QSystemNetworkInfo.NoNetworkAvailable:
            stat = "No Network Available"
        if status == QSystemNetworkInfo.EmergencyOnly:
            stat = "Emergency Only"
        if status == QSystemNetworkInfo.Searching:
            stat = "Searching or Connecting"
        if status == QSystemNetworkInfo.Busy:
            stat = "Busy"
        if status == QSystemNetworkInfo.Connected:
            stat = "Connected"
        if status == QSystemNetworkInfo.HomeNetwork:
            stat = "Home Network"
        if status == QSystemNetworkInfo.Denied:
            stat = "Denied"
        if status == QSystemNetworkInfo.Roaming:
            stat = "Roaming"
        self.cellNetworkStatusLabel.setText(stat)

    def updateProfile(self):
        if self.di:
            current = self.di.currentProfile()
            if current == QSystemDeviceInfo.UnknownProfile:
                profilestring = "Unknown"
            elif current == QSystemDeviceInfo.SilentProfile:
                profilestring = "Silent"
            elif current == QSystemDeviceInfo.NormalProfile:
                profilestring = "Normal"
            elif current == QSystemDeviceInfo.LoudProfile:
                profilestring = "Loud"
            elif current == QSystemDeviceInfo.VibProfile:
                profilestring = "Vibrate"
            elif current == QSystemDeviceInfo.OfflineProfile:
                profilestring = "Offline";
            elif current == QSystemDeviceInfo.PowersaveProfile:
                profilestring = "Powersave";
            elif current ==  QSystemDeviceInfo.CustomProfile:
                profilestring = "custom";

        self.profileLabel.setText(profilestring);

    def updateSimStatus(self):
        if self.di:
            status = self.di.simStatus()
            if status == QSystemDeviceInfo.SimLocked:
                simstring = "Sim Locked";
            elif status == QSystemDeviceInfo.SimNotAvailable:
                simstring = "Sim not available";
            elif status == QSystemDeviceInfo.SingleSimAvailable:
                simstring = "Single Sim Available";
            elif status == QSystemDeviceInfo.DualSimAvailable:
                simstring = "Dual Sim available";
            else:
                simstring = ""

            self.simStatusLabel.setText(simstring)

    def bluetoothChanged(self, b):
        if b:
            text = "On"
        else:
            text = "Off"
        self.bluetoothPowerLabel.setText(text)
Esempio n. 14
0
class SystemInfoModel(QtCore.QObject):
    changed = QtCore.Signal()

    def __init__(self):
        super(SystemInfoModel, self).__init__()
        self.systemInfo = QSystemInfo(self)
        self.setupGeneral()
        self.setupDevice()
        self.setupDisplay()
        self.setupStorage()
        self.setupNetwork()
        self.setupScreenSaver()

    @QtCore.Property(str, notify=changed)
    def currentLanguage(self):
        return self._currentLanguage

    @QtCore.Property("QStringList", notify=changed)
    def availableLanguages(self):
        return self._availableLanguages

    @QtCore.Property(int, notify=changed)
    def displayBrightness(self):
        return self._displayBrightness

    @QtCore.Property(int, notify=changed)
    def colorDepth(self):
        return self._colorDepth

    @QtCore.Property(str, notify=changed)
    def imei(self):
        return self._imei

    @QtCore.Property(str, notify=changed)
    def imsi(self):
        return self._imsi

    @QtCore.Property(str, notify=changed)
    def manufacturer(self):
        return self._manufacturer

    @QtCore.Property(str, notify=changed)
    def product(self):
        return self._product

    @QtCore.Property(str, notify=changed)
    def model(self):
        return self._model

    @QtCore.Property(str, notify=changed)
    def profile(self):
        return self._profile

    @QtCore.Property(str, notify=changed)
    def inputMethod(self):
        return self._inputMethod

    @QtCore.Property(bool, notify=changed)
    def deviceLock(self):
        return self._deviceLock

    @QtCore.Property(str, notify=changed)
    def simStatus(self):
        return self._simStatus

    @QtCore.Property(bool, notify=changed)
    def bluetoothState(self):
        return self._bluetoothState

    @QtCore.Property("QStringList", notify=changed)
    def volumeNames(self):
        return self._volumeNames

    @QtCore.Property("QStringList", notify=changed)
    def networksNames(self):
        return ["Wlan", "Ethernet", "Gsm", "Cdma", "Wcdma"]

    @QtCore.Property(bool, notify=changed)
    def screenSaverInhibited(self):
        return self._screenSaverInhibited

    def setupGeneral(self):
        self._currentLanguage = self.systemInfo.currentLanguage()
        self._availableLanguages = self.systemInfo.availableLanguages()

    def setupDevice(self):
        self.deviceInfo = QSystemDeviceInfo(self)
        self._batteryLevel = self.deviceInfo.batteryLevel()
        self.deviceInfo.batteryLevelChanged.connect(self.updateBatteryStatus)
        self.deviceInfo.batteryStatusChanged.connect(self.displayBatteryStatus)
        self.deviceInfo.powerStateChanged.connect(self.updatePowerState)
        self._imei = self.deviceInfo.imei()
        self._imsi = self.deviceInfo.imsi()
        self._manufacturer = self.deviceInfo.manufacturer()
        self._model = self.deviceInfo.model()
        self._product = self.deviceInfo.productName()
        self._deviceLock = self.deviceInfo.isDeviceLocked()

        methods = self.deviceInfo.inputMethodType()
        inputs = []
        if methods & QSystemDeviceInfo.Keys:
            inputs.append("Keys")
        if methods & QSystemDeviceInfo.Keypad:
            inputs.append("Keypad")
        if methods & QSystemDeviceInfo.Keyboard:
            inputs.append("Keyboard")
        if methods & QSystemDeviceInfo.SingleTouch:
            inputs.append("Touch Screen")
        if methods & QSystemDeviceInfo.MultiTouch:
            inputs.append("Multi touch")
        if methods & QSystemDeviceInfo.Mouse:
            inputs.append("Mouse")

        self._inputMethod = " ".join(inputs)
        self.updateSimStatus()
        self.updateProfile()

        self._bluetoothState = self.deviceInfo.currentBluetoothPowerState()
        self.deviceInfo.bluetoothStateChanged.connect(self.updateBluetoothState)

    def setupDisplay(self):
        self.displayInfo = QSystemDisplayInfo()
        self._displayBrightness = self.displayInfo.displayBrightness(0)
        self._colorDepth = self.displayInfo.colorDepth(0)

    def setupStorage(self):
        self.storageInfo = QSystemStorageInfo()
        self._volumeNames = self.storageInfo.logicalDrives()

    @QtCore.Slot(str, result=str)
    def storageType(self, volumeName):
        names = {
            QSystemStorageInfo.InternalDrive: "Internal",
            QSystemStorageInfo.RemovableDrive: "Removable",
            QSystemStorageInfo.CdromDrive: "CD-Rom",
            QSystemStorageInfo.RemoteDrive: "Network",
        }

        volType = self.storageInfo.typeForDrive(volumeName)

        return names.get(volType, "Unknown")

    @QtCore.Slot(str, result=str)
    def totalStorageSize(self, volumeName):
        return self.convert_bytes(self.storageInfo.totalDiskSpace(volumeName))

    @QtCore.Slot(str, result=str)
    def availableStorageSize(self, volumeName):
        return self.convert_bytes(self.storageInfo.availableDiskSpace(volumeName))

    def convert_bytes(self, bytes):
        # From http://www.5dollarwhitebox.org/drupal/node/84
        bytes = float(bytes)
        if bytes >= 1099511627776:
            terabytes = bytes / 1099511627776
            size = '%.2fT' % terabytes
        elif bytes >= 1073741824:
            gigabytes = bytes / 1073741824
            size = '%.2fG' % gigabytes
        elif bytes >= 1048576:
            megabytes = bytes / 1048576
            size = '%.2fM' % megabytes
        elif bytes >= 1024:
            kilobytes = bytes / 1024
            size = '%.2fK' % kilobytes
        else:
            size = '%.2fb' % bytes
        return size

    def setupNetwork(self):
        self.networkInfo = QSystemNetworkInfo()

    def modeEnumForName(self, name):
        try:
            mode = getattr(QSystemNetworkInfo, name.capitalize() + "Mode")
        except AttributeError as e:
            print e
            return None

        return mode

    @QtCore.Slot(str, result=str)
    def networkStatus(self, modeName):
        mode = self.modeEnumForName(modeName)
        status = self.networkInfo.networkStatus(mode)
        statusName = str(status).split('.')[-1]
        # Split the CamelCase enum name
        import re
        return re.sub(r'([a-z])([A-Z])', r'\1 \2', statusName)

    @QtCore.Slot(str, result=str)
    def networkName(self, modeName):
        mode = self.modeEnumForName(modeName)
        name = self.networkInfo.networkName(mode)
        return name if name else "<Unknown>"

    @QtCore.Slot(str, result=str)
    def networkInterfaceName(self, modeName):
        mode = self.modeEnumForName(modeName)
        name = self.networkInfo.interfaceForMode(mode).humanReadableName()
        return name if name else "<Unknown>"

    @QtCore.Slot(str, result=str)
    def networkMacAddress(self, modeName):
        mode = self.modeEnumForName(modeName)
        mac = self.networkInfo.macAddress(mode)
        return mac if mac else "<Unknown>"

    @QtCore.Slot(str, result=int)
    def networkSignalStrength(self, modeName):
        mode = self.modeEnumForName(modeName)
        return self.networkInfo.networkSignalStrength(mode)

    @QtCore.Slot(result=str)
    def cellId(self):
        cell = self.networkInfo.cellId()
        return str(cell) if cell != -1 else "<Unavailable>"

    @QtCore.Slot(result=str)
    def locationAreaCode(self):
        code = self.networkInfo.locationAreaCode()
        return str(code) if code != -1 else "<Unavailable>"

    @QtCore.Slot(result=str)
    def currentMCC(self):
        code = self.networkInfo.currentMobileCountryCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def currentMNC(self):
        code = self.networkInfo.currentMobileNetworkCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def homeMCC(self):
        code = self.networkInfo.homeMobileCountryCode()
        return code if code else "<Unavailable>"

    @QtCore.Slot(result=str)
    def homeMNC(self):
        code = self.networkInfo.homeMobileNetworkCode()
        return code if code else "<Unavailable>"

    def setupScreenSaver(self):
        self.saverInfo = QSystemScreenSaver(self)
        self._screenSaverInhibited = self.saverInfo.screenSaverInhibited()

    def updateBluetoothState(self, on):
        self._bluetoothState = on
        self.changed.emit()

    def updateBatteryStatus(self, status):
        self._batteryLevel = status
        self.emit(QtCore.SIGNAL('changed()'))

    def displayBatteryStatus(self, status):
        pass

    def updatePowerState(self, newState):
        pass

    def updateSimStatus(self):
        if self.deviceInfo:
            status = self.deviceInfo.simStatus()
            if status == QSystemDeviceInfo.SimLocked:
                simstring = "Sim Locked";
            elif status == QSystemDeviceInfo.SimNotAvailable:
                simstring = "Sim not available";
            elif status == QSystemDeviceInfo.SingleSimAvailable:
                simstring = "Single Sim Available";
            elif status == QSystemDeviceInfo.DualSimAvailable:
                simstring = "Dual Sim available";
            else:
                simstring = ""

            self._simStatus = simstring


    def updateProfile(self):
        if self.deviceInfo:
            current = self.deviceInfo.currentProfile()
            if current == QSystemDeviceInfo.UnknownProfile:
                profilestring = "Unknown"
            elif current == QSystemDeviceInfo.SilentProfile:
                profilestring = "Silent"
            elif current == QSystemDeviceInfo.NormalProfile:
                profilestring = "Normal"
            elif current == QSystemDeviceInfo.LoudProfile:
                profilestring = "Loud"
            elif current == QSystemDeviceInfo.VibProfile:
                profilestring = "Vibrate"
            elif current == QSystemDeviceInfo.OfflineProfile:
                profilestring = "Offline";
            elif current == QSystemDeviceInfo.PowersaveProfile:
                profilestring = "Powersave";
            elif current ==  QSystemDeviceInfo.CustomProfile:
                profilestring = "custom";

            self._profile = profilestring
Esempio n. 15
0
	def getProfile():
		dev_info = QSystemDeviceInfo();
		return dev_info.currentProfile();
Esempio n. 16
0
	def getImei():
		#return "355960045823461";
		dev_info = QSystemDeviceInfo();
		return dev_info.imei();
Esempio n. 17
0
 def getImei():
     dev_info = QSystemDeviceInfo()
     return dev_info.imei()
Esempio n. 18
0
 def getImsi():
     #return "000000000000000"
     dev_info = QSystemDeviceInfo()
     return dev_info.imsi()
Esempio n. 19
0
class Notifier():
	def __init__(self,audio=False,vibra=False):
		_d = NotifierDebug();
		self._d = _d.d;
		
		self.manager = MNotificationManager('wazappnotify','WazappNotify');
		self.vibra = vibra
		
		
		
		self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings
		self.devInfo = QSystemDeviceInfo();
		
		self.devInfo.currentProfileChanged.connect(self.profileChanged);
		
		
		if audio:
			self.audio = QMediaPlayer(); 
			self.audio.setVolume(100);
		else:
			self.audio = False
			
		self.enabled = True
		self.notifications = {}
		
		if self.vibra:
			self.vibra = QFeedbackHapticsEffect();
			self.vibra.setIntensity(1.0);
			self.vibra.setDuration(200);
	
	
	
	def profileChanged(self):
		self._d("Profile changed");
	
	def enable(self):
		self.enabled = True
	
	def disable(self):
		self.enabled = False
	
	def saveNotification(self,jid,data):
		self.notifications[jid] = data;
		
	
	def getCurrentSoundPath(self):
		activeProfile = self.devInfo.currentProfile();
		
		if activeProfile in (QSystemDeviceInfo.Profile.NormalProfile,QSystemDeviceInfo.Profile.LoudProfile):
			if self.enabled:
				return self.newMessageSound;
			else:
				return WAConstants.FOCUSED_SOUND_NOTIFICATION
				
		elif activeProfile  == QSystemDeviceInfo.Profile.BeepProfile:
			return WAConstants.DEFAULT_BEEP_NOTIFICATION 
		else:
			return WAConstants.NO_SOUND
		
	
	
	def hideNotification(self,jid):
		if self.notifications.has_key(jid):
			#jid = jids[0]
			nId = self.notifications[jid]["id"];
			del self.notifications[jid]
			self._d("DELETING NOTIFICATION BY ID "+str(nId));
			self.manager.removeNotification(nId);
		
				
	def notificationCallback(self,jid):
		#nId = 0
		#jids = [key for key,value in self.notifications.iteritems() if value["id"]==nId]
		#if len(jids):
		if self.notifications.has_key(jid):
			#jid = jids[0]
			nId = self.notifications[jid]["id"];
			self.notifications[jid]["callback"](jid);
			del self.notifications[jid]
			#self.manager.removeNotification(nId);
		
				
	def newMessage(self,jid,contactName,message,picture=None,callback=False):
		
		activeConvJId = self.ui.getActiveConversation()
		
		max_len = min(len(message),20)
		
		if self.enabled:
			
			
			if(activeConvJId == jid or activeConvJId == ""):
				if self.vibra:
					self.vibra.start()
				return
			
			n = MNotification("wazapp.message.new",contactName, message);
			n.image = picture
			n.manager = self.manager;
			action = lambda: self.notificationCallback(jid)
			
			n.setAction(action);
		
			notifications = n.notifications();
			
			
			if self.notifications.has_key(jid):
				nId = self.notifications[jid]['id'];
				
				
				for notify in notifications:
					if int(notify[0]) == nId:
						n.id = nId
						break
				
				if n.id != nId:
					del self.notifications[jid]
			
				
			if(n.publish()):
				nId = n.id;
				self.saveNotification(jid,{"id":nId,"callback":callback});
		
		
		#if self.vibra:
		#	self.vibra.start()
		
		if self.audio:
			soundPath = self.getCurrentSoundPath();
			self._d(soundPath)
			self.audio.setMedia(QUrl.fromLocalFile(soundPath));
			self.audio.play();
Esempio n. 20
0
 def getImei():
     dev_info = QSystemDeviceInfo()
     return dev_info.imei()
Esempio n. 21
0
class Notifier():
	def __init__(self,audio=False,vibra=True):
		self.manager = MNotificationManager('wazappnotify','WazappNotify');
		self.vibra = vibra
		
		
		
		self.newMessageSound = WAConstants.DEFAULT_SOUND_NOTIFICATION #fetch from settings
		self.devInfo = QSystemDeviceInfo();
		
		self.devInfo.currentProfileChanged.connect(self.profileChanged);
		
		
		if audio:
			self.audio = QMediaPlayer(); 
			self.audio.setVolume(100);
		else:
			self.audio = False
			
		self.enabled = True
		self.notifications = {}
		
		if self.vibra:
			self.vibra = QFeedbackHapticsEffect();
			self.vibra.setIntensity(1.0);
			self.vibra.setDuration(200);
	
	
	
	def profileChanged(self):
		print "Profile changed";
	
	def enable(self):
		#print "enabling notif"
		self.enabled = True
	
	def disable(self):
		#print "disabling notif"
		self.enabled = False
	
	def saveNotification(self,jid,data):
		self.notifications[jid] = data;
		
	
	def getCurrentSoundPath(self):
		activeProfile = self.devInfo.currentProfile();
		
		if activeProfile in (QSystemDeviceInfo.Profile.NormalProfile,QSystemDeviceInfo.Profile.LoudProfile):
			if self.enabled:
				return self.newMessageSound;
			else:
				return WAConstants.FOCUSED_SOUND_NOTIFICATION
				
		elif activeProfile  == QSystemDeviceInfo.Profile.BeepProfile:
			return WAConstants.DEFAULT_BEEP_NOTIFICATION 
		else:
			return WAConstants.NO_SOUND
		
	
	
	def hideNotification(self,jid):
		if self.notifications.has_key(jid):
			#jid = jids[0]
			nId = self.notifications[jid]["id"];
			del self.notifications[jid]
			print "DELETING NOTIFICATION BY ID "+str(nId);
			self.manager.removeNotification(nId);
		
				
	def notificationCallback(self,jid):
		#nId = 0
		#jids = [key for key,value in self.notifications.iteritems() if value["id"]==nId]
		#if len(jids):
		if self.notifications.has_key(jid):
			#jid = jids[0]
			nId = self.notifications[jid]["id"];
			self.notifications[jid]["callback"](jid);
			del self.notifications[jid]
			#self.manager.removeNotification(nId);
		
				
	def newMessage(self,jid,contactName,message,picture=None,callback=False):
		
		activeConvJId = self.ui.getActiveConversation()
		
		max_len = min(len(message),20)
		
		if self.enabled:
			
			
			if(activeConvJId == jid or activeConvJId == ""):
				if self.vibra:
					self.vibra.start()
				return
			
			n = MNotification("wazapp.message.new",contactName, message);
			n.image = picture
			n.manager = self.manager;
			action = lambda: self.notificationCallback(jid)
			
			n.setAction(action);
		
			notifications = n.notifications();
			
			
			if self.notifications.has_key(jid):
				nId = self.notifications[jid]['id'];
				
				
				for notify in notifications:
					if int(notify[0]) == nId:
						n.id = nId
						break
				
				if n.id != nId:
					del self.notifications[jid]
			
				
			if(n.publish()):
				nId = n.id;
				self.saveNotification(jid,{"id":nId,"callback":callback});
		
		
		#if self.vibra:
		#	self.vibra.start()
		
		if self.audio:
			soundPath = self.getCurrentSoundPath();
			print soundPath
			self.audio.setMedia(QUrl.fromLocalFile(soundPath));
			self.audio.play();