Detects Google Contacts support in contact source via the protocol provider of the account ('Google Talk') or the Google contacts source is extern (created via the Google Contacts configuration form), in addition to the SRV method.

cusax-fix
Sebastien Vincent 14 years ago
parent 7135885a22
commit 2b96e2ee91

@ -288,7 +288,9 @@ public void run()
{
enableContactSource(
provider.getAccountID().getAccountAddress(),
password);
password,
provider.getProtocolDisplayName().equals(
"Google Talk"));
}
}
}).start();
@ -348,15 +350,19 @@ public void stop(BundleContext bundleContext)
*
* @param login login
* @param password password
* @param googleTalk if the provider service is GoogleTalk
* @return a <tt>GoogleContactsSourceService</tt> instance
*/
public static GoogleContactsSourceService enableContactSource(
String login, String password)
String login, String password,
boolean googleTalk)
{
GoogleContactsSourceService css = new GoogleContactsSourceService(
login, password);
ServiceRegistration cssServiceRegistration = null;
css.setGoogleTalk(googleTalk);
try
{
cssServiceRegistration
@ -386,14 +392,19 @@ public static GoogleContactsSourceService enableContactSource(
* <tt>GoogleContactsConnection</tt>.
*
* @param cnx <tt>GoogleContactsConnection</tt>
* @param googleTalk if the contact source has been created as GoogleTalk
* account or via external Google Contacts
* @return a <tt>GoogleContactsSourceService</tt> instance
*/
public static GoogleContactsSourceService enableContactSource(
GoogleContactsConnection cnx)
GoogleContactsConnection cnx,
boolean googleTalk)
{
GoogleContactsSourceService css = new GoogleContactsSourceService(cnx);
ServiceRegistration cssServiceRegistration = null;
css.setGoogleTalk(googleTalk);
try
{
cssServiceRegistration

@ -157,7 +157,7 @@ private void loadConfig()
/* register contact source */
if(cnx.isEnabled())
{
addContactSource(cnx);
addContactSource(cnx, true);
}
}
}
@ -430,14 +430,17 @@ public GoogleContactsConnection getConnection(String login,
}
/**
* Add a contact source service with the specified.
*
* Add a contact source service with the specified
* <tt>GoogleContactsConnection</tt>.
*
* @param cnx <tt>GoogleContactsConnection</tt>.
* @param googleTalk if the contact source has been created as GoogleTalk
* account or via external Google Contacts
*/
public void addContactSource(GoogleContactsConnection cnx)
public void addContactSource(GoogleContactsConnection cnx,
boolean googleTalk)
{
GoogleContactsActivator.enableContactSource(cnx);
GoogleContactsActivator.enableContactSource(cnx, googleTalk);
}
/**
@ -449,7 +452,7 @@ public void addContactSource(GoogleContactsConnection cnx)
*/
public void addContactSource(String login, String password)
{
GoogleContactsActivator.enableContactSource(login, password);
GoogleContactsActivator.enableContactSource(login, password, false);
}
/**

@ -59,6 +59,12 @@ public class GoogleContactsSourceService
*/
private AccountSettingsForm settings = null;
/**
* If the account has been created using GoogleTalk wizard or via
* external Google Contacts.
*/
private boolean googleTalk = false;
/**
* Constructor.
*
@ -96,6 +102,29 @@ public String getLogin()
return login;
}
/**
* Set whether or not the account has been created via GoogleTalk wizard or
* external Google contacts.
*
* @param googleTalk value to set
*/
public void setGoogleTalk(boolean googleTalk)
{
this.googleTalk = googleTalk;
}
/**
* Returns whether or not the account has been created via GoogleTalk
* wizard or via external Google Contacts.
*
* @return true if account has been created via GoogleTalk wizard or via
* external Google Contacts.
*/
public boolean isGoogleTalk()
{
return googleTalk;
}
/**
* Queries this search source for the given <tt>searchPattern</tt>.
*
@ -174,6 +203,12 @@ public GoogleContactsConnectionImpl getConnection()
return null;
}
// To detect that account is a google ones, we try the following:
// - lookup in SRV and see if it is google.com;
// - if the account has been created with GoogleTalk form;
// - if it is an "external" google contact.
// SRV checks
for(SRVRecord srv : srvRecords)
{
if(srv.getTarget().endsWith("google.com") ||
@ -184,6 +219,12 @@ public GoogleContactsConnectionImpl getConnection()
}
}
// GoogleTalk based account or external Google Contacts ?
if(!isGoogleAppsOrGmail)
{
isGoogleAppsOrGmail = googleTalk;
}
if(isGoogleAppsOrGmail)
{
if(cnx == null)

@ -225,8 +225,8 @@ public void actionPerformed(ActionEvent e)
if(ret == 1)
{
GoogleContactsConnectionImpl cnx
= (GoogleContactsConnectionImpl) settingsForm.getConnection();
GoogleContactsConnectionImpl cnx =
(GoogleContactsConnectionImpl) settingsForm.getConnection();
tableModel.addAccount(cnx, true, cnx.getPrefix());
new RefreshContactSourceThread(null, cnx).start();
GoogleContactsActivator.getGoogleContactsService().saveConfig(
@ -351,7 +351,7 @@ public void run()
if(newCnx != null)
{
GoogleContactsActivator.getGoogleContactsService().
addContactSource(newCnx);
addContactSource(newCnx, true);
}
}
}

@ -204,7 +204,7 @@ public Class<?> getColumnClass(int columnIndex)
*/
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
if(columnIndex != 0 || columnIndex != 2)
if(columnIndex != 0 && columnIndex != 2)
throw new IllegalArgumentException("non editable column!");
GoogleContactsConfigForm.RefreshContactSourceThread th = null;

@ -58,9 +58,12 @@ public GoogleContactsConnection getConnection(String login,
* Add a contact source service with the specified
* <tt>GoogleContactsConnection</tt>.
*
* @param cnx <tt>GoogleContactsConnection</tt>.
* @param cnx <tt>GoogleContactsConnection</tt>
* @param googleTalk if the contact source has been created as GoogleTalk
* account or via external Google Contacts
*/
public void addContactSource(GoogleContactsConnection cnx);
public void addContactSource(GoogleContactsConnection cnx,
boolean googleTalk);
/**
* Remove a contact source service with the specified

Loading…
Cancel
Save