Show login/password window if we get a credentials problem from Google Contacts.

cusax-fix
Sebastien Vincent 16 years ago
parent 5a1f93e019
commit ec46651473

@ -6,10 +6,12 @@
*/
package net.java.sip.communicator.impl.googlecontacts;
import com.google.gdata.client.*;
import com.google.gdata.client.contacts.*;
import com.google.gdata.util.*;
import net.java.sip.communicator.service.googlecontacts.*;
import net.java.sip.communicator.util.*;
/**
* Google Contacts credentials to connect to the service.
@ -19,6 +21,12 @@
public class GoogleContactsConnectionImpl
implements GoogleContactsConnection
{
/**
* Logger.
*/
private static final Logger logger =
Logger.getLogger(GoogleContactsConnectionImpl.class);
/**
* Login.
*/
@ -106,9 +114,9 @@ public void setPassword(String password)
/**
* Initialize connection.
*
* @return true if connection succeed, false if credentials is wrong
* @return connection status
*/
public boolean connect()
public ConnectionStatus connect()
{
try
{
@ -116,10 +124,18 @@ public boolean connect()
}
catch(AuthenticationException e)
{
return false;
logger.info("Google contacts connection failure: " + e);
if(e instanceof GoogleService.InvalidCredentialsException)
{
return ConnectionStatus.ERROR_INVALID_CREDENTIALS;
}
else
{
return ConnectionStatus.ERROR_UNKNOWN;
}
}
return true;
return ConnectionStatus.SUCCESS;
}
/**

@ -122,7 +122,9 @@ private void loadConfig()
if(cnx != null)
{
if(!cnx.connect())
if(cnx.connect() ==
GoogleContactsConnection.ConnectionStatus.
ERROR_INVALID_CREDENTIALS)
{
cnx.setEnabled(false);
AccountSettingsForm settings = new AccountSettingsForm();

@ -184,7 +184,9 @@ public GoogleContactsConnectionImpl getConnection()
{
cnx = new GoogleContactsConnectionImpl(login, password);
if(cnx.connect() == false)
if(cnx.connect() ==
GoogleContactsConnection.ConnectionStatus.
ERROR_INVALID_CREDENTIALS)
{
synchronized(this)
{
@ -215,7 +217,9 @@ public GoogleContactsConnectionImpl getConnection()
}
}
}
else if(!cnx.connect())
else if(cnx.connect() ==
GoogleContactsConnection.ConnectionStatus.
ERROR_INVALID_CREDENTIALS)
{
synchronized(this)
{

@ -214,7 +214,8 @@ public void actionPerformed(ActionEvent e)
cnx.setPassword(password);
}
if(!cnx.connect())
if(cnx.connect() == GoogleContactsConnection.ConnectionStatus.
ERROR_INVALID_CREDENTIALS)
{
JOptionPane.showMessageDialog(
this,

@ -13,6 +13,28 @@
*/
public interface GoogleContactsConnection
{
/**
* Enumeration for connection status.
*
*/
public enum ConnectionStatus
{
/**
* Connection has failed due to invalid credentials.
*/
ERROR_INVALID_CREDENTIALS,
/**
* Connection has failed due to unknown reason.
*/
ERROR_UNKNOWN,
/**
* Connection has succeed.
*/
SUCCESS;
}
/**
* Get login.
*
@ -44,7 +66,7 @@ public interface GoogleContactsConnection
/**
* Initialize connection.
*
* @return true if connection succeed, false if credentials is wrong
* @return connection status
*/
public boolean connect();
public ConnectionStatus connect();
}

Loading…
Cancel
Save