~ubuntu-branches/ubuntu/oneiric/software-center/oneiric-security

« back to all changes in this revision

Viewing changes to softwarecenter/backend/login_sso.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Kiwinote, Gary Lasker, Matthew McGowan, Michael Vogt, Didier Roche
  • Date: 2011-09-26 16:59:33 UTC
  • Revision ID: package-import@ubuntu.com-20110926165933-q0h4l03stglesi0q
Tags: 4.1.23.6
[ Kiwinote ]
* softwarecenter/db/update.py:
  - update the sc-agent db even if there are no apps available (LP: #857268)
* softwarecenter/utils.py:
  - fix UnicodeDecodeError in get_icon_from_theme() (LP: #839391)
* utils/submit_review_gtk3.py:
  - fix UnicodeDecodeError in _on_one_gwibber_account() (LP: #836911)

[ Gary Lasker ]
* softwarecenter/ui/gtk3/app.py:
  - fix intermittent startup crashes (LP: #846674, LP: #857989) 

[ Matthew McGowan ]
* work around some oddness that seems to have broken 
  Gdk.EventButton.copy().

[ Michael Vogt ]
* softwarecenter/ui/gtk3/app.py:
  - do not crash if there is no active pane
* softwarecenter/backend/reviews.py:
  - be more robust against db corruption when writing out 
    the bsddb for unity (LP: #858437)
* softwarecenter/backend/login_sso.py:
  - port to the new SSO dbus API  (LP: #857514)

[ Didier Roche ]
* lp:~didrocks/software-center/replace_logintext_by_helptext:
  - use help_text internally to be aligned with the new ubuntu SSO
    parameter name (LP: #857514)

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from dbus.mainloop.glib import DBusGMainLoop
29
29
DBusGMainLoop(set_as_default=True)
30
30
 
 
31
from softwarecenter.utils import utf8
31
32
from login import LoginBackend
32
33
 
33
34
# mostly for testing
37
38
 
38
39
class LoginBackendDbusSSO(LoginBackend):
39
40
 
40
 
    def __init__(self, window_id, appname, login_text):
 
41
    def __init__(self, window_id, appname, help_text):
41
42
        super(LoginBackendDbusSSO, self).__init__()
42
43
        self.appname = appname
43
 
        self.login_text = login_text
 
44
        self.help_text = help_text
44
45
        self.bus = dbus.SessionBus()
45
 
        self.proxy = self.bus.get_object('com.ubuntu.sso', '/credentials')
 
46
        self.proxy = self.bus.get_object(
 
47
            'com.ubuntu.sso', '/com/ubuntu/sso/credentials')
46
48
        self.proxy.connect_to_signal("CredentialsFound", 
47
49
                                     self._on_credentials_found)
48
50
        self.proxy.connect_to_signal("CredentialsError", 
52
54
        self._window_id = window_id
53
55
        self._credentials = None
54
56
 
 
57
    def _get_params(self):
 
58
        p = {}
 
59
        if self.help_text:
 
60
            p['help_text'] = utf8(self.help_text)
 
61
        if self._window_id:
 
62
            p['window_id'] = self._window_id
 
63
        return p
 
64
 
55
65
    def login(self, username=None, password=None):
56
66
        LOG.debug("login()")
57
67
        self._credentials = None
58
 
        # alternatively use:
59
 
        #  login_or_register_to_get_credentials(appname, tc, help, xid)
60
 
        self.proxy.login_to_get_credentials(
61
 
            self.appname, self.login_text,
62
 
            self._window_id)
 
68
        self.proxy.login(self.appname, self._get_params())
63
69
        
64
70
    def login_or_register(self):
65
71
        LOG.debug("login_or_register()")
66
72
        self._credentials = None
67
 
        self.proxy.login_or_register_to_get_credentials(
68
 
            self.appname, "", self.login_text,
69
 
            self._window_id)
 
73
        self.proxy.register(self.appname, self._get_params())
70
74
 
71
75
    def _on_credentials_found(self, app_name, credentials):
72
76
        if app_name != self.appname:
96
100
 
97
101
class LoginBackendDbusSSOFake(LoginBackend):
98
102
 
99
 
    def __init__(self, window_id, appname, login_text):
 
103
    def __init__(self, window_id, appname, help_text):
100
104
        super(LoginBackendDbusSSOFake, self).__init__()
101
105
        self.appname = appname
102
 
        self.login_text = login_text
 
106
        self.help_text = help_text
103
107
        self._window_id = window_id
104
108
        self._fake_settings = FakeReviewSettings()
105
109
    
140
144
             )
141
145
        return c
142
146
 
143
 
def get_sso_backend(window_id, appname, login_text):
 
147
def get_sso_backend(window_id, appname, help_text):
144
148
    """ 
145
149
    factory that returns an sso loader singelton
146
150
    """
147
151
    if "SOFTWARE_CENTER_FAKE_REVIEW_API" in os.environ:
148
 
        sso_class = LoginBackendDbusSSOFake(window_id, appname, login_text)
 
152
        sso_class = LoginBackendDbusSSOFake(window_id, appname, help_text)
149
153
        LOG.warn('Using fake login SSO functionality. Only meant for testing purposes')
150
154
    else:
151
 
        sso_class = LoginBackendDbusSSO(window_id, appname, login_text)
 
155
        sso_class = LoginBackendDbusSSO(window_id, appname, help_text)
152
156
    return sso_class
153
157
   
154
158
if __name__ == "__main__":