~rmcbride/ubuntu/lucid/ubuntuone-client/fixucg

« back to all changes in this revision

Viewing changes to ubuntuone/oauthdesktop/main.py

  • Committer: Bazaar Package Importer
  • Author(s): Rodney Dawes
  • Date: 2009-07-16 17:00:00 UTC
  • mto: (17.1.1 ubuntuone-client)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20090716170000-tnnk149g57bxxo24
Tags: upstream-0.90.4
ImportĀ upstreamĀ versionĀ 0.90.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
DBusGMainLoop(set_as_default=True)
45
45
 
 
46
# Disable the invalid name warning, as we have a lot of DBus style names
 
47
# pylint: disable-msg=C0103
 
48
 
46
49
class NoDefaultConfigError(Exception):
47
50
    """No default section in configuration file"""
48
51
    pass
88
91
                                     consumer_secret,
89
92
                                     callback_parent=self.got_token,
90
93
                                     callback_denied=self.got_denial,
 
94
                                     callback_notoken=self.got_no_token,
 
95
                                     callback_error=self.got_error,
91
96
                                     do_login=do_login)
92
97
 
93
98
        logger.debug("Calling auth.client.ensure_access_token in thread")
148
153
 
149
154
    def is_valid_url(self, url):
150
155
        """Simple check for URL validity"""
 
156
        # pylint: disable-msg=W0612
151
157
        scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
152
158
        if scheme and netloc:
153
159
            return True
163
169
        """Callback function when request token has been denied"""
164
170
        self.dbus_object.AuthorizationDenied()
165
171
 
 
172
    def got_no_token(self):
 
173
        """Callback function when access token is not in keyring."""
 
174
        self.dbus_object.NoCredentials()
 
175
 
 
176
    def got_error(self, message):
 
177
        """Callback function to emit an error message over DBus."""
 
178
        self.dbus_object.OAuthError(message)
 
179
 
166
180
    def __get_url(self, realm, option, actual_realm=None):
167
181
        """Construct a full URL from realm and a URLpath for that realm in
168
182
           the config file."""
241
255
        """Fire the signal when the user denies authorization."""
242
256
        self.currently_authing = False
243
257
 
 
258
    @dbus.service.signal(dbus_interface='com.ubuntuone.Authentication')
 
259
    def NoCredentials(self):
 
260
        """Fired when the user does not have a token in the keyring."""
 
261
        self.currently_authing = False
 
262
 
 
263
    @dbus.service.signal(dbus_interface='com.ubuntuone.Authentication',
 
264
                         signature='s')
 
265
    def OAuthError(self, message):
 
266
        """Fire the signal when an error needs to be propagated to the user."""
 
267
        self.currently_authing = False
 
268
        return message
 
269
 
244
270
def main():
245
271
    """Start everything"""
246
272
    logger.debug("Starting up at %s", time.asctime())
250
276
    from twisted.internet import reactor
251
277
 
252
278
    logger.debug("Creating the D-Bus service")
253
 
    login = Login(dbus.service.BusName("com.ubuntuone.Authentication",
254
 
         bus=dbus.SessionBus()))
 
279
    Login(dbus.service.BusName("com.ubuntuone.Authentication",
 
280
                               bus=dbus.SessionBus()))
255
281
    # cleverness here to say:
256
282
    # am I already running (bound to this d-bus name)?
257
283
    # if so, send a signal to the already running instance