mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Updated implementation of SingleSessionManager#saveAllClients for current HashMap
This commit is contained in:
parent
5130a93ef5
commit
1d95320277
@ -26,14 +26,13 @@ package com.owncloud.android.lib.common;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
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;
|
||||||
import android.net.Uri;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
@ -54,9 +53,6 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
|
|
||||||
private static final String TAG = SingleSessionManager.class.getSimpleName();
|
private static final String TAG = SingleSessionManager.class.getSimpleName();
|
||||||
|
|
||||||
private Map<String, Map<OwnCloudCredentials, OwnCloudClient>> mClientsPerServer =
|
|
||||||
new HashMap<String, Map<OwnCloudCredentials, OwnCloudClient>>();
|
|
||||||
|
|
||||||
private Map<String, OwnCloudClient> mClientsWithKnownUsername =
|
private Map<String, OwnCloudClient> mClientsWithKnownUsername =
|
||||||
new HashMap<String, OwnCloudClient>();
|
new HashMap<String, OwnCloudClient>();
|
||||||
|
|
||||||
@ -167,31 +163,17 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
throws AccountNotFoundException, AuthenticatorException, IOException,
|
throws AccountNotFoundException, AuthenticatorException, IOException,
|
||||||
OperationCanceledException {
|
OperationCanceledException {
|
||||||
|
|
||||||
// Get all accounts
|
Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator();
|
||||||
Account [] accounts = AccountManager.get(context.getApplicationContext())
|
String accountName = null;
|
||||||
.getAccountsByType(accountType);
|
Account account = null;
|
||||||
|
while (accountNames.hasNext()) {
|
||||||
// Save cookies for all accounts
|
accountName = accountNames.next();
|
||||||
for(Account account: accounts){
|
account = new Account(accountName, accountType);
|
||||||
|
AccountUtils.saveClient(
|
||||||
Uri serverBaseUri =
|
mClientsWithKnownUsername.get(accountName),
|
||||||
Uri.parse(AccountUtils.getBaseUrlForAccount(context, account));
|
account,
|
||||||
|
context);
|
||||||
Map<OwnCloudCredentials, OwnCloudClient> clientsPerAccount =
|
|
||||||
mClientsPerServer.get(serverBaseUri.toString());
|
|
||||||
|
|
||||||
if (clientsPerAccount != null) {
|
|
||||||
OwnCloudCredentials credentials =
|
|
||||||
AccountUtils.getCredentialsForAccount(context, account);
|
|
||||||
|
|
||||||
/// TODO - CRITERIA FOR MATCH OF KEYS!!!
|
|
||||||
OwnCloudClient client = clientsPerAccount.get(credentials);
|
|
||||||
if (client != null) {
|
|
||||||
AccountUtils.saveClient(client, account, context.getApplicationContext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user