aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/googlecontacts
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2011-12-02 10:26:25 +0000
committerSebastien Vincent <seb@jitsi.org>2011-12-02 10:26:25 +0000
commit2b96e2ee910b8a6c0f573efeb7c73bb827a8d020 (patch)
tree9c1f63452fbd6b60027534949b5dc8b31ca14b67 /src/net/java/sip/communicator/impl/googlecontacts
parent7135885a22e6e4aa71f49300ddf616f569c6f8ba (diff)
downloadjitsi-2b96e2ee910b8a6c0f573efeb7c73bb827a8d020.zip
jitsi-2b96e2ee910b8a6c0f573efeb7c73bb827a8d020.tar.gz
jitsi-2b96e2ee910b8a6c0f573efeb7c73bb827a8d020.tar.bz2
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.
Diffstat (limited to 'src/net/java/sip/communicator/impl/googlecontacts')
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java17
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java15
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java41
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java6
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java2
5 files changed, 68 insertions, 13 deletions
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
index 6e2a0e0..243b9f0 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
@@ -288,7 +288,9 @@ public class GoogleContactsActivator implements BundleActivator
{
enableContactSource(
provider.getAccountID().getAccountAddress(),
- password);
+ password,
+ provider.getProtocolDisplayName().equals(
+ "Google Talk"));
}
}
}).start();
@@ -348,15 +350,19 @@ public class GoogleContactsActivator implements BundleActivator
*
* @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 class GoogleContactsActivator implements BundleActivator
* <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
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
index 6861fbf..0b1c98d 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
@@ -157,7 +157,7 @@ public class GoogleContactsServiceImpl
/* register contact source */
if(cnx.isEnabled())
{
- addContactSource(cnx);
+ addContactSource(cnx, true);
}
}
}
@@ -430,14 +430,17 @@ public class GoogleContactsServiceImpl
}
/**
- * 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 class GoogleContactsServiceImpl
*/
public void addContactSource(String login, String password)
{
- GoogleContactsActivator.enableContactSource(login, password);
+ GoogleContactsActivator.enableContactSource(login, password, false);
}
/**
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
index 1a71e82..518d5e2 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
@@ -60,6 +60,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.
*
* @param login login
@@ -97,6 +103,29 @@ public class GoogleContactsSourceService
}
/**
+ * 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>.
*
* @param queryPattern the pattern to search for
@@ -174,6 +203,12 @@ public class GoogleContactsSourceService
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 class GoogleContactsSourceService
}
}
+ // GoogleTalk based account or external Google Contacts ?
+ if(!isGoogleAppsOrGmail)
+ {
+ isGoogleAppsOrGmail = googleTalk;
+ }
+
if(isGoogleAppsOrGmail)
{
if(cnx == null)
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java b/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java
index 033456b..d170faf 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java
@@ -225,8 +225,8 @@ public class GoogleContactsConfigForm
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 class GoogleContactsConfigForm
if(newCnx != null)
{
GoogleContactsActivator.getGoogleContactsService().
- addContactSource(newCnx);
+ addContactSource(newCnx, true);
}
}
}
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java b/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java
index 3347f4d..5f1bdb1 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java
@@ -204,7 +204,7 @@ public class GoogleContactsTableModel
*/
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;