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