Пример #1
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_servicesWidget()
        self.ui.setupUi(self)

        # set up self.config
        self.__class__.screenSettings["daemons"] = []
        self.services = ["org.cups.cupsd", "bluetooth"]
        self.daemons = {}
        for service in self.services:
            self.daemons[service] = Daemon(service)

        # set initial states
        # TODO: avoid the code dublication here
        self.ui.enableCups.setChecked(self.daemons["org.cups.cupsd"].is_enabled())
        self.ui.enableBluetooth.setChecked(self.daemons["bluetooth"].is_enabled())
        self.ui.enableCups.setEnabled(self.daemons["org.cups.cupsd"].is_installed())
        self.ui.enableBluetooth.setEnabled(self.daemons["bluetooth"].is_installed())
Пример #2
0
    def __init__(self, *args):
        QtGui.QWidget.__init__(self, None)
        self.ui = Ui_securityWidget()
        self.ui.setupUi(self)

        # set up self.config
        self.config = Daemon()

        # set initial states
        self.ui.enableFire.setChecked(self.config.isEnabled("ufw"))
        self.ui.enableFire.setEnabled(self.config.isInstalled("ufw"))

        self.ui.enableClam.setEnabled(False)
        if self.config.isInstalled("clamd"):
            if os.system("grep -q ^Example /etc/clamav/clamd.conf"
                         ) == 256:  # 256 is 'no match'.
                if os.system(
                        "grep -q ^Example /etc/clamav/freshclam.conf") == 256:
                    self.ui.enableClam.setEnabled(True)
            self.ui.enableClam.setChecked(self.config.isEnabled("clamd"))
        else:
            self.ui.enableClam.setChecked(False)
Пример #3
0
    def shown(self):
        self.wallpaperSettings = wallpaperWidget.Widget.screenSettings
        self.mouseSettings = mouseWidget.Widget.screenSettings
        self.menuSettings = menuWidget.Widget.screenSettings
        self.styleSettings = styleWidget.Widget.screenSettings
        self.packageSettings = packageWidget.Widget.screenSettings
        self.servicesSettings = servicesWidget.Widget.screenSettings
        self.securitySettings = securityWidget.Widget.screenSettings
        self.extraSettings = extraWidget.Widget.screenSettings

        subject = "<p><li><b>%s</b></li><ul>"
        item = "<li>%s</li>"
        end = "</ul></p>"
        content = QString("")

        content.append("""<html><body><ul>""")

        # Mouse Settings
        content.append(subject % i18n("Mouse Settings"))

        content.append(item % i18n("Selected Mouse configuration: <b>%s</b>") %
                       self.mouseSettings["summaryMessage"]["selectedMouse"])
        content.append(item % i18n("Selected clicking behavior: <b>%s</b>") %
                       self.mouseSettings["summaryMessage"]["clickBehavior"])
        content.append(end)

        # Menu Settings
        content.append(subject % i18n("Menu Settings"))
        content.append(item % i18n("Selected Menu: <b>%s</b>") %
                       self.menuSettings["summaryMessage"])
        content.append(end)

        # Wallpaper Settings
        content.append(subject % i18n("Wallpaper Settings"))
        if not self.wallpaperSettings["hasChanged"]:
            content.append(item % i18n("You haven't selected any wallpaper."))
        else:
            content.append(
                item % i18n("Selected Wallpaper: <b>%s</b>") %
                os.path.basename(
                    str(self.wallpaperSettings["selectedWallpaper"])))
        content.append(end)

        # Style Settings
        content.append(subject % i18n("Style Settings"))

        if not self.styleSettings["hasChanged"]:
            content.append(item % i18n("You haven't selected any style."))
        else:
            content.append(item % i18n("Selected Style: <b>%s</b>") %
                           unicode(self.styleSettings["summaryMessage"]))

        content.append(end)

        # Notifier Settings
        if self.packageSettings["hasChanged"]:
            content.append(subject % i18n("Package Management Settings"))
            content.append(
                item % i18n("You have enabled or disabled octopi-notifier."))

            content.append(end)

        # Services Settings
        if self.servicesSettings["hasChanged"]:
            self.daemon = Daemon()
            self.svctext = i18n("You have: ")
            self.svcissset = False
            content.append(subject % i18n("Services Settings"))

            if self.servicesSettings[
                    "enableCups"] and not self.daemon.isEnabled(
                        "org.cups.cupsd"):
                self.svctext += i18n("enabled cups; ")
                self.svcisset = True
            elif not self.servicesSettings[
                    "enableCups"] and self.daemon.isEnabled("org.cups.cupsd"):
                self.svctext += i18n("disabled cups; ")
                self.svcisset = True
            if self.servicesSettings[
                    "enableBluetooth"] and not self.daemon.isEnabled(
                        "bluetooth"):
                self.svctext += i18n("enabled bluetooth; ")
                self.svcisset = True
            elif not self.servicesSettings[
                    "enableBluetooth"] and self.daemon.isEnabled("bluetooth"):
                self.svctext += i18n("disabled bluetooth; ")
                self.svcisset = True

            #FIXME: when can this ever happen?
            if not self.svcisset:
                self.svctext = i18n("You have made no changes.")
                self.servicesSettings["hasChanged"] = False

            content.append(item % i18n(self.svctext))

            content.append(end)

        # Security Settings
        if self.securitySettings["hasChanged"]:
            self.daemon = Daemon()
            self.sectext = i18n("You have: ")
            self.secisset = False
            content.append(subject % i18n("Security Settings"))

            if self.securitySettings[
                    "enableClam"] and not self.daemon.isEnabled("clamd"):
                self.sectext += i18n("enabled ClamAV; ")
                self.secisset = True
            elif not self.securitySettings[
                    "enableClam"] and self.daemon.isEnabled("clamd"):
                self.sectext += i18n("disabled ClamAV; ")
                self.secisset = True
            if self.securitySettings[
                    "enableFire"] and not self.daemon.isEnabled("ufw"):
                self.sectext += i18n("enabled the firewall; ")
                self.secisset = True
            elif not self.securitySettings[
                    "enableFire"] and self.daemon.isEnabled("ufw"):
                self.sectext += i18n("disabled the firewall; ")
                self.secisset = True

            if not self.secisset:
                self.sectext = i18n("You have made no changes.")
                self.securitySettings["hasChanged"] = False

            content.append(item % i18n(self.sectext))

            content.append(end)

        # Extra Settings
        if self.extraSettings["hasChanged"]:
            self.repos = Repos()
            self.extratext = i18n("You have: ")
            self.extraisset = False
            content.append(subject % i18n("Extra Settings"))

            if self.extraSettings[
                    "enableExtra"] and not self.repos.extraIsEnabled():
                self.extratext += i18n("enabled the [extra] repo; ")
                self.extraisset = True
            elif not self.extraSettings[
                    "enableExtra"] and self.repos.extraIsEnabled():
                self.extratext += i18n("disabled the [extra] repo; ")
                self.extraisset = True

            if not self.extraisset:
                self.extratext = i18n("You have made no changes.")
                self.extraSettings["hasChanged"] = False

            content.append(item % i18n(self.extratext))

            content.append(end)

        self.ui.textSummary.setText(content)