X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/99d52af203f63a5dd3d43626f569ac88c5ac9b14..2a95f59adc2bdd8f8a90cab8fd8d28f90bf9fc68:/src/com/owncloud/android/authenticator/AuthenticationRunnable.java diff --git a/src/com/owncloud/android/authenticator/AuthenticationRunnable.java b/src/com/owncloud/android/authenticator/AuthenticationRunnable.java index f40701f4..2df44275 100644 --- a/src/com/owncloud/android/authenticator/AuthenticationRunnable.java +++ b/src/com/owncloud/android/authenticator/AuthenticationRunnable.java @@ -1,10 +1,10 @@ /* ownCloud Android client application * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2012-2013 ownCloud Inc. * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -22,10 +22,12 @@ import java.net.URL; import org.apache.commons.httpclient.HttpStatus; -import com.owncloud.android.utils.OwnCloudClientUtils; +import com.owncloud.android.R; +import com.owncloud.android.network.OwnCloudClientUtils; import eu.alefzero.webdav.WebdavClient; +import android.content.Context; import android.net.Uri; import android.os.Handler; @@ -36,12 +38,14 @@ public class AuthenticationRunnable implements Runnable { private URL mUrl; private String mUsername; private String mPassword; + private Context mContext; - public AuthenticationRunnable(URL url, String username, String password) { + public AuthenticationRunnable(URL url, String username, String password, Context context) { mListener = null; mUrl = url; mUsername = username; mPassword = password; + mContext = context; } public void setOnAuthenticationResultListener( @@ -54,20 +58,20 @@ public class AuthenticationRunnable implements Runnable { public void run() { Uri uri; uri = Uri.parse(mUrl.toString()); - WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(uri, mUsername, mPassword); + WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(uri, mUsername, mPassword, mContext); int login_result = wdc.tryToLogin(); switch (login_result) { case HttpStatus.SC_OK: postResult(true, uri.toString()); break; case HttpStatus.SC_UNAUTHORIZED: - postResult(false, "Invalid login or/and password"); + postResult(false, mContext.getString(R.string.auth_unauthorized)); break; case HttpStatus.SC_NOT_FOUND: - postResult(false, "Wrong path given"); + postResult(false, mContext.getString(R.string.auth_not_found)); break; default: - postResult(false, "Internal server error, code: " + login_result); + postResult(false, String.format(mContext.getString(R.string.auth_internal), login_result)); } }