~ubuntu-branches/ubuntu/trusty/lottanzb/trusty

« back to all changes in this revision

Viewing changes to lottanzb/gui/prefs/remote_access.py

  • Committer: Daniel Holbach
  • Date: 2011-02-21 07:47:30 UTC
  • mfrom: (7.1.1 natty)
  • Revision ID: daniel.holbach@canonical.com-20110221074730-9ozyhdic25bo6k2g
Tags: 0.6-1ubuntu1
* debian/lottanzb.install, debian/icons/*:
  + Add dark and light application icon for the panel menu.
* New upstream release.

* Switch to dpkg-source 3.0 (quilt) format.
* Use debhelper 7 instead of cdbs.
* Use dh_python2 instead of python-support.
* Delete superfluous debian/pyversions and debian/pycompat.

* debian/compat:
  + Bump to debhelper 7.
* debian/control:
  + Change Priority from extra to optional.
  + Replace XS-Python-Version with X-Python-Version and bump it to >= 2.6.
  + Remove cdbs and python-support from Build-Depends.
  + Bump debhelper to >= 7.0.50~ in Build-Depends.
  + Bump python to >= 2.6.6-3 in Build-Depends.
  + Remove python-kiwi, hellanzb and python from Depends.
  + Add python-configobj to Depends.
  + Bump python-gtk2 to >= 2.16 in Depends.
  + Bump yelp to >= 2.30 in Recommends for Mallard support.
  + Add python-apt and apturl to Recommends.
  + Add sabnzbdplus to Suggests.
  + Replace hellanzb with sabnzbdplus in Enhances.
  + Update Description.
* debian/copyright:
  + Make it machine-interpretable according to DEP-5.
  + Remove information for Kiwi code.
  + Update information for help/*.
  + Add information for lottanzb/backend/interface/multipart_post_handler.py.
* debian/lottanzb.lintian-overrides:
  + Override extra-license-file warning for documentation files.
* debian/lottanzb.menu:
  + Update application title.
* debian/patches/lock-file-name.patch:
  + Delete because fixed upstream.
* debian/rules:
  + Install into private directory /usr/share/lottanzb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008-2011 LottaNZB Development Team
 
2
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; version 3.
 
6
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
15
 
 
16
from lottanzb.core.environ import _
 
17
from lottanzb.backend import Backend
 
18
from lottanzb.config.sabnzbd import create_api_key
 
19
from lottanzb.gui.prefs.base import Tab
 
20
from lottanzb.gui.framework.proxy import (
 
21
    GObjectEndPoint, ToggleEndPoint, SpinButtonEndPoint, DelayedEntryEndPoint,
 
22
    LabelEndPoint, Conduit, ConduitCollection, DelayedPasswordEntryEndPoint)
 
23
 
 
24
class RemoteAccessTab(Tab):
 
25
    abstract = False
 
26
    builder_file = "prefs_tab_remote_access"
 
27
    label = _("Remote Access")
 
28
    help_topic = "remote-access"
 
29
    
 
30
    def __init__(self, component_manager):
 
31
        Tab.__init__(self, component_manager)
 
32
        
 
33
        self.conduits = ConduitCollection()
 
34
    
 
35
    def set_config(self, lottanzb_config, sabnzbd_config):
 
36
        self.conduits.remove_all()
 
37
        
 
38
        self.conduits.add(Conduit(
 
39
            GObjectEndPoint(sabnzbd_config.misc, "host"),
 
40
            RemoteConnnectionEndPoint(self.allow_remote_connections)))
 
41
        
 
42
        self.conduits.add(Conduit(
 
43
            GObjectEndPoint(sabnzbd_config.misc, "port"),
 
44
            SpinButtonEndPoint(self.port)))
 
45
        
 
46
        self.conduits.add(Conduit(
 
47
            GObjectEndPoint(sabnzbd_config.misc, "username"),
 
48
            DelayedEntryEndPoint(self.username)))
 
49
        
 
50
        self.conduits.add(Conduit(
 
51
            GObjectEndPoint(sabnzbd_config.misc, "password"),
 
52
            DelayedPasswordEntryEndPoint(self.password)))
 
53
        
 
54
        self.conduits.add(Conduit(
 
55
            GObjectEndPoint(sabnzbd_config.misc, "api_key"),
 
56
            LabelEndPoint(self.api_key)))
 
57
        
 
58
        info = self._component_manager.get(Backend).interface.connection_info
 
59
        
 
60
        self.allow_remote_connections.set_sensitive(info.is_local)
 
61
        
 
62
        if sabnzbd_config.misc.username or sabnzbd_config.misc.password:
 
63
            self.authenticate.set_active(True)
 
64
        else:
 
65
            self.authenticate.set_active(False)
 
66
        
 
67
        self.authenticate.emit("toggled")
 
68
    
 
69
    def on_authenticate__toggled(self, widget):
 
70
        active = widget.get_active()
 
71
        
 
72
        self.username.set_sensitive(active)
 
73
        self.username_label.set_sensitive(active)
 
74
        self.password.set_sensitive(active)
 
75
        self.password_label.set_sensitive(active)
 
76
        
 
77
        if not active:
 
78
            self.username.set_text("")
 
79
            self.password.set_text("")
 
80
    
 
81
    def on_generate_api_key__clicked(self, widget):
 
82
        self.api_key.set_text(create_api_key())
 
83
    
 
84
    def needs_restart(self, lottanzb_config, old_lottanzb_config,
 
85
        sabnzbd_config, old_sabnzbd_config):
 
86
        old = [old_sabnzbd_config.misc.host, old_sabnzbd_config.misc.port]
 
87
        new = [sabnzbd_config.misc.host, sabnzbd_config.misc.port]
 
88
        
 
89
        return old != new
 
90
 
 
91
 
 
92
class RemoteConnnectionEndPoint(ToggleEndPoint):
 
93
    def get_value(self):
 
94
        if self._object.get_active():
 
95
            return "0.0.0.0"
 
96
        else:
 
97
            return "localhost"
 
98
    
 
99
    def set_value(self, value):
 
100
        if value in ("localhost", "127.0.0.1"):
 
101
            self._object.set_active(False)
 
102
        else:
 
103
            self._object.set_active(True)