171
168
#really use bzrlib.auth get_password for this
172
169
#or possibly better gnome-keyring?
173
170
auth = config.AuthenticationConfig()
174
(scheme, urluser, urlpassword, host, port, urlpath) = \
175
urlutils.parse_url(self.url)
171
parsed_url = urlutils.URL.from_string(self.url)
177
173
if (flags & gio.ASK_PASSWORD_NEED_USERNAME and
178
174
flags & gio.ASK_PASSWORD_NEED_DOMAIN):
179
prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN\\username'
180
user_and_domain = auth.get_user(scheme, host,
181
port=port, ask=True, prompt=prompt)
175
prompt = (u'%s' % (parsed_url.scheme.upper(),) +
176
u' %(host)s DOMAIN\\username')
177
user_and_domain = auth.get_user(parsed_url.scheme,
178
parsed_url.host, port=parsed_url.port, ask=True,
182
180
(domain, user) = user_and_domain.split('\\', 1)
183
181
op.set_username(user)
184
182
op.set_domain(domain)
185
183
elif flags & gio.ASK_PASSWORD_NEED_USERNAME:
186
user = auth.get_user(scheme, host,
184
user = auth.get_user(parsed_url.scheme, parsed_url.host,
185
port=parsed_url.port, ask=True)
188
186
op.set_username(user)
189
187
elif flags & gio.ASK_PASSWORD_NEED_DOMAIN:
190
188
#Don't know how common this case is, but anyway
191
189
#a DOMAIN and a username prompt should be the
192
190
#same so I will missuse the ui_factory get_username
193
191
#a little bit here.
194
prompt = u'%s' % (scheme.upper(),) + u' %(host)s DOMAIN'
192
prompt = (u'%s' % (parsed_url.scheme.upper(),) +
195
194
domain = ui.ui_factory.get_username(prompt=prompt)
196
195
op.set_domain(domain)
198
197
if flags & gio.ASK_PASSWORD_NEED_PASSWORD:
200
199
user = op.get_username()
201
password = auth.get_password(scheme, host,
200
password = auth.get_password(parsed_url.scheme, parsed_url.host,
201
user, port=parsed_url.port)
203
202
op.set_password(password)
204
203
op.reply(gio.MOUNT_OPERATION_HANDLED)
214
213
def _create_connection(self, credentials=None):
215
214
if credentials is None:
216
user, password = self._user, self._password
215
user, password = self._parsed_url.user, self._parsed_url.password
218
217
user, password = credentials
254
253
self._set_connection(connection, credentials)
256
255
def _remote_path(self, relpath):
257
relative = urlutils.unescape(relpath).encode('utf-8')
258
remote_path = self._combine_paths(self._path, relative)
256
return self._parsed_url.clone(relpath).path
261
258
def has(self, relpath):
262
259
"""Does the target location exist?"""