Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.googlecontacts
Class GoogleContactsServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.googlecontacts.GoogleContactsServiceImpl
All Implemented Interfaces:
GoogleContactsService

public class GoogleContactsServiceImpl
extends Object
implements GoogleContactsService

Implementation of Google Contacts service. We first get MAX_RESULT contacts from Google Contacts then we filter it to get MAX_RESULT that matched our query. If MAX_RESULT is not reach, we try with additional contacts (if there are more than MAX_RESULT contacts).

Author:
Sebastien Vincent

Field Summary
static int MAX_NUMBER
          Maximum number of contacts retrieved for a query.
static int MAX_RESULT
          Maximum number of results for a query.
 
Constructor Summary
GoogleContactsServiceImpl()
          Constructor.
 
Method Summary
 void addContactSource(GoogleContactsConnection cnx, boolean googleTalk)
          Add a contact source service with the specified GoogleContactsConnection.
 void addContactSource(String login, String password)
          Add a contact source service with the specified GoogleContactsConnection.
static byte[] downloadPhoto(com.google.gdata.data.ILink photoLink, com.google.gdata.client.contacts.ContactsService service)
          Retrieve photo of a contact.
 List<GoogleContactsConnectionImpl> getAccounts()
          Get list of stored connections.
 GoogleContactsConnection getConnection(String login, String password)
          Get a GoogleContactsConnection.
 List<GoogleContactsEntry> getContacts()
          Get the full contacts list.
 void removeConfig(GoogleContactsConnection cnx)
          Remove a connection.
 void removeContactSource(GoogleContactsConnection cnx)
          Add a contact source service with the specified.
 void removeContactSource(String login)
          Remove a contact source service with the specified GoogleContactsConnection.
 void saveConfig(GoogleContactsConnection cnx)
          Save configuration.
 List<GoogleContactsEntry> searchContact(GoogleContactsConnection cnx, GoogleQuery gQuery, int count, GoogleEntryCallback callback)
          Perform a search for a contact using regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_RESULT

public static final int MAX_RESULT
Maximum number of results for a query.

See Also:
Constant Field Values

MAX_NUMBER

public static final int MAX_NUMBER
Maximum number of contacts retrieved for a query.

See Also:
Constant Field Values
Constructor Detail

GoogleContactsServiceImpl

public GoogleContactsServiceImpl()
Constructor.

Method Detail

getAccounts

public List<GoogleContactsConnectionImpl> getAccounts()
Get list of stored connections.

Returns:
list of connections

removeConfig

public void removeConfig(GoogleContactsConnection cnx)
Remove a connection.

Parameters:
cnx - connection to save

saveConfig

public void saveConfig(GoogleContactsConnection cnx)
Save configuration.

Parameters:
cnx - connection to save

searchContact

public List<GoogleContactsEntry> searchContact(GoogleContactsConnection cnx,
                                               GoogleQuery gQuery,
                                               int count,
                                               GoogleEntryCallback callback)
Perform a search for a contact using regular expression.

Specified by:
searchContact in interface GoogleContactsService
Parameters:
cnx - GoogleContactsConnection to perform the query
gQuery - Google query
count - maximum number of matched contacts
callback - object that will be notified for each new GoogleContactsEntry found
Returns:
list of GoogleContactsEntry

getContacts

public List<GoogleContactsEntry> getContacts()
Get the full contacts list.

Specified by:
getContacts in interface GoogleContactsService
Returns:
list of GoogleContactsEntry

getConnection

public GoogleContactsConnection getConnection(String login,
                                              String password)
Get a GoogleContactsConnection.

Specified by:
getConnection in interface GoogleContactsService
Parameters:
login - login to connect to the service
password - password to connect to the service
Returns:
GoogleContactsConnection.

addContactSource

public void addContactSource(GoogleContactsConnection cnx,
                             boolean googleTalk)
Add a contact source service with the specified GoogleContactsConnection.

Specified by:
addContactSource in interface GoogleContactsService
Parameters:
cnx - GoogleContactsConnection.
googleTalk - if the contact source has been created as GoogleTalk account or via external Google Contacts

addContactSource

public void addContactSource(String login,
                             String password)
Add a contact source service with the specified GoogleContactsConnection.

Specified by:
addContactSource in interface GoogleContactsService
Parameters:
login - login
password - password

removeContactSource

public void removeContactSource(GoogleContactsConnection cnx)
Add a contact source service with the specified. GoogleContactsConnection.

Specified by:
removeContactSource in interface GoogleContactsService
Parameters:
cnx - GoogleContactsConnection.

removeContactSource

public void removeContactSource(String login)
Remove a contact source service with the specified GoogleContactsConnection.

Specified by:
removeContactSource in interface GoogleContactsService
Parameters:
login - login

downloadPhoto

public static byte[] downloadPhoto(com.google.gdata.data.ILink photoLink,
                                   com.google.gdata.client.contacts.ContactsService service)
Retrieve photo of a contact. Adapted from Google sample.

Parameters:
photoLink - photo link
service -
Returns:
byte array containing image photo or null if problem happened

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.