mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Persistent cookies: Create saveClient in OwnCloudClientMap
This commit is contained in:
parent
37f4383b07
commit
811190065d
@ -28,6 +28,7 @@ import java.io.IOException;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
|
import android.accounts.AccountManager;
|
||||||
import android.accounts.AuthenticatorException;
|
import android.accounts.AuthenticatorException;
|
||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -35,6 +36,7 @@ import android.content.Context;
|
|||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
import com.owncloud.android.lib.common.OwnCloudClientFactory;
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
||||||
|
import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map for {@link OwnCloudClient} instances associated to ownCloud {@link Account}s
|
* Map for {@link OwnCloudClient} instances associated to ownCloud {@link Account}s
|
||||||
@ -43,9 +45,12 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce
|
|||||||
*
|
*
|
||||||
* TODO consider converting into a non static object saved in the application context
|
* TODO consider converting into a non static object saved in the application context
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
|
* @author masensio
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class OwnCloudClientMap {
|
public class OwnCloudClientMap {
|
||||||
|
|
||||||
|
|
||||||
private static ConcurrentMap<String, OwnCloudClient> mClients =
|
private static ConcurrentMap<String, OwnCloudClient> mClients =
|
||||||
new java.util.concurrent.ConcurrentHashMap<String, OwnCloudClient>();
|
new java.util.concurrent.ConcurrentHashMap<String, OwnCloudClient>();
|
||||||
|
|
||||||
@ -73,4 +78,14 @@ public class OwnCloudClientMap {
|
|||||||
mClients.clear();
|
mClients.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized void saveClient(Account account, Context context) {
|
||||||
|
|
||||||
|
// Account Manager
|
||||||
|
AccountManager ac = AccountManager.get(context);
|
||||||
|
|
||||||
|
OwnCloudClient client = mClients.get(account);
|
||||||
|
|
||||||
|
String cookies = client.getState().getCookies().toString();
|
||||||
|
ac.setUserData(account, Constants.KEY_COOKIES, cookies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,5 +160,9 @@ public class AccountUtils {
|
|||||||
* Flag signaling if the ownCloud server supports Share API"
|
* Flag signaling if the ownCloud server supports Share API"
|
||||||
*/
|
*/
|
||||||
public static final String KEY_SUPPORTS_SHARE_API = "oc_supports_share_api";
|
public static final String KEY_SUPPORTS_SHARE_API = "oc_supports_share_api";
|
||||||
|
/**
|
||||||
|
* OC accout cookies
|
||||||
|
*/
|
||||||
|
public static final String KEY_COOKIES = "oc_account_cookies";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user