~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/gio_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-12 01:42:55 UTC
  • mfrom: (6055.2.12 unparsedurl)
  • Revision ID: pqm@pqm.ubuntu.com-20110812014255-y3thbw6gdn7cw6uz
(jelmer) Add a URL object for manipulating parsed URLs. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
        #really use bzrlib.auth get_password for this
166
166
        #or possibly better gnome-keyring?
167
167
        auth = config.AuthenticationConfig()
168
 
        (scheme, urluser, urlpassword, host, port, urlpath) = \
169
 
           urlutils.parse_url(self.url)
 
168
        parsed_url = urlutils.URL.from_string(self.url)
170
169
        user = None
171
170
        if (flags & gio.ASK_PASSWORD_NEED_USERNAME and
172
171
                flags & gio.ASK_PASSWORD_NEED_DOMAIN):
173
 
            prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN\\username'
174
 
            user_and_domain = auth.get_user(scheme, host,
175
 
                    port=port, ask=True, prompt=prompt)
 
172
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
173
                      u' %(host)s DOMAIN\\username')
 
174
            user_and_domain = auth.get_user(parsed_url.scheme,
 
175
                parsed_url.host, port=parsed_url.port, ask=True,
 
176
                prompt=prompt)
176
177
            (domain, user) = user_and_domain.split('\\', 1)
177
178
            op.set_username(user)
178
179
            op.set_domain(domain)
179
180
        elif flags & gio.ASK_PASSWORD_NEED_USERNAME:
180
 
            user = auth.get_user(scheme, host,
181
 
                    port=port, ask=True)
 
181
            user = auth.get_user(parsed_url.scheme, parsed_url.host,
 
182
                    port=parsed_url.port, ask=True)
182
183
            op.set_username(user)
183
184
        elif flags & gio.ASK_PASSWORD_NEED_DOMAIN:
184
185
            #Don't know how common this case is, but anyway
185
186
            #a DOMAIN and a username prompt should be the
186
187
            #same so I will missuse the ui_factory get_username
187
188
            #a little bit here.
188
 
            prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN'
 
189
            prompt = (u'%s' % (parsed_url.scheme.upper(),) +
 
190
                      u' %(host)s DOMAIN')
189
191
            domain = ui.ui_factory.get_username(prompt=prompt)
190
192
            op.set_domain(domain)
191
193
 
192
194
        if flags & gio.ASK_PASSWORD_NEED_PASSWORD:
193
195
            if user is None:
194
196
                user = op.get_username()
195
 
            password = auth.get_password(scheme, host,
196
 
                    user, port=port)
 
197
            password = auth.get_password(parsed_url.scheme, parsed_url.host,
 
198
                    user, port=parsed_url.port)
197
199
            op.set_password(password)
198
200
        op.reply(gio.MOUNT_OPERATION_HANDLED)
199
201
 
207
209
 
208
210
    def _create_connection(self, credentials=None):
209
211
        if credentials is None:
210
 
            user, password = self._user, self._password
 
212
            user, password = self._parsed_url.user, self._parsed_url.password
211
213
        else:
212
214
            user, password = credentials
213
215