aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2011-08-24 12:06:49 +0000
committerYana Stamcheva <yana@jitsi.org>2011-08-24 12:06:49 +0000
commitf4479d54a2dbb6c2a3510e13f0940672c573f63d (patch)
treea0755aa976a0c50a8b67a1e6cdf860fd340adce9
parentd72f188060f348a8710e48c004a200e4b832405a (diff)
downloadjitsi-f4479d54a2dbb6c2a3510e13f0940672c573f63d.zip
jitsi-f4479d54a2dbb6c2a3510e13f0940672c573f63d.tar.gz
jitsi-f4479d54a2dbb6c2a3510e13f0940672c573f63d.tar.bz2
Merges contact source configurations in a single configuration form.
Adds the possibility to disable/enable MacOSX AddressBook and MS Outlook. Adds a prefix configuration to all contact sources: AddressBook, Outlook, LDAP, Google Contacts.
-rw-r--r--build.xml12
-rw-r--r--lib/felix.client.run.properties3
-rw-r--r--resources/config/defaults.properties1
-rw-r--r--resources/languages/resources.properties17
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java17
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java25
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java11
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java26
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java41
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsConfigForm.java5
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java55
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java28
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java12
-rw-r--r--src/net/java/sip/communicator/impl/ldap/LdapContactSourceService.java10
-rw-r--r--src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java55
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java70
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java149
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/PhoneNumberI18nServiceImpl.java7
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf9
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java16
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java16
-rw-r--r--src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java138
-rw-r--r--src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigForm.java187
-rw-r--r--src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf15
-rw-r--r--src/net/java/sip/communicator/plugin/ldap/LdapActivator.java4
-rw-r--r--src/net/java/sip/communicator/plugin/ldap/configform/DirectorySettingsForm.java42
-rw-r--r--src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java9
-rw-r--r--src/net/java/sip/communicator/service/contactsource/ExtendedContactSourceService.java8
-rw-r--r--src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java7
-rw-r--r--src/net/java/sip/communicator/service/gui/ConfigurationForm.java5
-rw-r--r--src/net/java/sip/communicator/service/ldap/LdapDirectorySettings.java20
31 files changed, 975 insertions, 45 deletions
diff --git a/build.xml b/build.xml
index ee88b82..28f3c13 100644
--- a/build.xml
+++ b/build.xml
@@ -931,7 +931,8 @@
bundle-plugin-chatconfig,bundle-certificate,bundle-packetlogging,
bundle-plugin-loggingutils,bundle-plugin-dnsconfig,
bundle-provdisc,bundle-provdisc-dhcp,bundle-provdisc-mdns,
- bundle-provisioning,bundle-addrbook,bundle-plugin-ldap"/>
+ bundle-provisioning,bundle-addrbook,bundle-plugin-ldap,
+ bundle-plugin-contactsourceconfig"/>
<!--BUNDLE-SC-LAUNCHER-->
<target name="bundle-sc-launcher">
@@ -2688,6 +2689,7 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/plugin/dnsconfig" />
</jar>
</target>
+
<target name="bundle-systemactivitynotifications">
<jar compress="false" destfile="${bundles.dest}/sysactivitynotifications.jar"
manifest="${src}/net/java/sip/communicator/impl/sysactivity/sysactivity.impl.manifest.mf">
@@ -2701,4 +2703,12 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
+ <target name="bundle-plugin-contactsourceconfig">
+ <jar compress="false" destfile="${bundles.dest}/plugin-contactsourceconfig.jar"
+ manifest="${src}/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf">
+ <zipfileset dir="${dest}/net/java/sip/communicator/plugin/contactsourceconfig"
+ prefix="net/java/sip/communicator/plugin/contactsourceconfig"/>
+ </jar>
+ </target>
+
</project>
diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties
index eff2f69..50a22b7 100644
--- a/lib/felix.client.run.properties
+++ b/lib/felix.client.run.properties
@@ -153,7 +153,8 @@ felix.auto.start.67= \
reference:file:sc-bundles/replacement-viddler.jar \
reference:file:sc-bundles/chatconfig.jar \
reference:file:sc-bundles/addrbook.jar \
- reference:file:sc-bundles/plugin-ldap.jar
+ reference:file:sc-bundles/plugin-ldap.jar \
+ reference:file:sc-bundles/plugin-contactsourceconfig.jar
# Level 68 is for profiler4j. Either don't use it or change the build.xml file
diff --git a/resources/config/defaults.properties b/resources/config/defaults.properties
index f3aa080..b2b9764 100644
--- a/resources/config/defaults.properties
+++ b/resources/config/defaults.properties
@@ -74,6 +74,7 @@ plugin.ippiaccregwizz.REGISTER_LINK=https://soap.ippi.fr/subscription/jitsi.php?
plugin.provisioning.IS_INITIAL_PROVISIONING_LINK=true
plugin.provisioning.DEFAULT_PROVISIONING_METHOD=
plugin.provisioning.DEFAULT_PROVISIONING_URI=
+plugin.provisioning.EXIT_ON_FAIL=false
# IP address of the backup resolver
net.java.sip.communicator.util.dns.BACKUP_RESOLVER_FALLBACK_IP=8.8.8.8
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index c21c02b..56abefa 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -633,6 +633,8 @@ impl.ldap.MAILSUFFIX_FIELD_EXAMPLE=@domain.org (do not forget to add \'@\')
impl.ldap.WORKPHONE_FIELD_EXAMPLE=companyPhone
impl.ldap.MOBILEPHONE_FIELD_EXAMPLE=mobilePhone
impl.ldap.HOMEPHONE_FIELD_EXAMPLE=homePhone
+impl.ldap.PHONE_PREFIX=Phone prefix
+impl.ldap.PHONE_PREFIX_EXAMPLE=Ex.: 00
# Address book plugin
plugin.addrbook.ADDRESS_BOOKS=Address book
@@ -641,6 +643,8 @@ plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK=Enable Microsoft Outlook search
plugin.addrbook.DESCRIPTION=If enabled everything you type in the search field \
of the contact list will be also searched in your system address book and all \
matching contacts from your address book will appear in your contact list.
+plugin.addrbook.PREFIX=Specific phone number prefix
+plugin.addrbook.PREFIX_EXAMPLE=Ex.: 00
# Google Contacts
impl.googlecontacts.CONFIG_FORM_TITLE=Google Contacts
@@ -653,6 +657,7 @@ impl.googlecontacts.SAVE=Save
impl.googlecontacts.CANCEL=Cancel
impl.googlecontacts.USERNAME=Account name
impl.googlecontacts.PASSWORD=Password
+impl.googlecontacts.PREFIX=Phone prefix
impl.googlecontacts.WRONG_CREDENTIALS=Wrong credentials for Google account {0}
# account info
@@ -758,7 +763,7 @@ plugin.generalconfig.CHECK_FOR_UPDATES=Check for updates on startup
plugin.generalconfig.STARTUP_CONFIG=Startup
plugin.generalconfig.LEAVE_CHATROOM_ON_WINDOW_CLOSE=Leave chat rooms when closing window
plugin.generalconfig.REMOVE_SPECIAL_PHONE_SYMBOLS=Remove special symbols before calling phone numbers
-plugin.generalconfig.SIP_CALL_CONFIG=SIP configuration
+plugin.generalconfig.SIP_CALL_CONFIG=SIP
# gibberish accregwizz
plugin.gibberishaccregwizz.PROTOCOL_NAME=Gibberish
@@ -1090,6 +1095,7 @@ settings if you are well aware of the way ZRTP and encryption in general work.
impl.media.security.zrtp.ZRTP_NINJA=ZRTP Ninja
+
# Profiler4J
plugin.profiler.PLUGIN_NAME=Profiler4j
@@ -1244,6 +1250,12 @@ plugin.chatconfig.replacement.ENABLE_SMILEY_STATUS=Enable smiley replacement
plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS=Enable Image/Video replacement
plugin.chatconfig.replacement.REPLACEMENT_SOURCES=Sources:
plugin.chatconfig.spellcheck.TITLE=SpellCheck
+<<<<<<< .mine
+plugin.spellcheck.LANG=Language
+plugin.spellcheck.EDIT_PERSONAL_DICT=Edit
+
+=======
+>>>>>>> .r8827
#provisioning plugin
plugin.provisioning.PROVISIONING=Provisioning
@@ -1258,6 +1270,7 @@ plugin.provisioning.RESTART_WARNING=Note that your changes will only take effect
plugin.provisioning.UUID=UUID
plugin.provisioning.COPYTOCLIPBOARD=Copy UUID to clipboard
plugin.provisioning.CLIPBOARD_FAILED=Failed to copy UUID to clipboard
+plugin.provisioning.EXIT_ON_FAIL=Exit the application if the provisioning fails
# packet logging service
plugin.loggingutils.PACKET_LOGGING_CONFIG=Logging
@@ -1301,3 +1314,5 @@ plugin.spellcheck.DICT_ERROR_TITLE=Error Switching Dictionary
plugin.spellcheck.DICT_ERROR=Cannot switch dictionary
plugin.spellcheck.DICT_RETRIEVE_ERROR=Dictionary cannot be fetched from
plugin.spellcheck.DICT_PROCESS_ERROR=Locale not recognized
+
+plugin.contactsourceconfig.CONTACT_SOURCE_TITLE=Contact sources \ No newline at end of file
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
index 0f1b681..a1eeb35 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsActivator.java
@@ -196,7 +196,7 @@ public class GoogleContactsActivator implements BundleActivator
Dictionary<String, String> properties =
new Hashtable<String, String>();
properties.put( ConfigurationForm.FORM_TYPE,
- ConfigurationForm.ADVANCED_TYPE);
+ ConfigurationForm.CONTACT_SOURCE_TYPE);
bundleContext.registerService(
ConfigurationForm.class.getName(),
@@ -205,7 +205,7 @@ public class GoogleContactsActivator implements BundleActivator
getClass().getClassLoader(),
"impl.googlecontacts.PLUGIN_ICON",
"impl.googlecontacts.CONFIG_FORM_TITLE",
- 2000, true),
+ 2000, false),
properties);
bundleContext.addServiceListener(new ServiceListener()
@@ -344,7 +344,8 @@ public class GoogleContactsActivator implements BundleActivator
* @param login login
* @param password password
*/
- public static void enableContactSource(String login, String password)
+ public static GoogleContactsSourceService enableContactSource(
+ String login, String password)
{
GoogleContactsSourceService css = new GoogleContactsSourceService(
login, password);
@@ -370,6 +371,8 @@ public class GoogleContactsActivator implements BundleActivator
cssList.put(css, cssServiceRegistration);
}
}
+
+ return css;
}
/**
@@ -378,10 +381,10 @@ public class GoogleContactsActivator implements BundleActivator
*
* @param cnx <tt>GoogleContactsConnection</tt>
*/
- public static void enableContactSource(GoogleContactsConnection cnx)
+ public static GoogleContactsSourceService enableContactSource(
+ GoogleContactsConnection cnx)
{
- GoogleContactsSourceService css = new GoogleContactsSourceService(
- cnx);
+ GoogleContactsSourceService css = new GoogleContactsSourceService(cnx);
ServiceRegistration cssServiceRegistration = null;
try
@@ -404,6 +407,8 @@ public class GoogleContactsActivator implements BundleActivator
cssList.put(css, cssServiceRegistration);
}
}
+
+ return css;
}
/**
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
index 9be306e..a59bab8 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsConnectionImpl.java
@@ -43,6 +43,11 @@ public class GoogleContactsConnectionImpl
private boolean enabled = false;
/**
+ * The google contact prefix.
+ */
+ private String prefix = null;
+
+ /**
* Google Contacts service.
*/
private final ContactsService googleService =
@@ -157,4 +162,24 @@ public class GoogleContactsConnectionImpl
{
this.enabled = enabled;
}
+
+ /**
+ * Sets the google contacts prefix.
+ *
+ * @param prefix the prefix to set
+ */
+ public void setPrefix(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ /**
+ * Returns the google contacts prefix.
+ *
+ * @return the google contacts prefix
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
index be783c8..c744ced 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsServiceImpl.java
@@ -114,11 +114,14 @@ public class GoogleContactsServiceImpl
boolean enabled = Boolean.parseBoolean((String)oen);
String login =
(String)configService.getProperty(path + ".account");
+ String prefix =
+ (String)configService.getProperty(path + ".prefix");
String password = credentialsService.loadPassword(path);
GoogleContactsConnectionImpl cnx = (GoogleContactsConnectionImpl)
getConnection(login, password);
cnx.setEnabled(enabled);
+ cnx.setPrefix(prefix);
if(cnx != null)
{
@@ -138,6 +141,7 @@ public class GoogleContactsServiceImpl
settings.getConnection();
// set the enabled state as before
cnx.setEnabled(enabled);
+ cnx.setPrefix(prefix);
saveConfig(cnx);
}
}
@@ -175,8 +179,10 @@ public class GoogleContactsServiceImpl
{
ConfigurationService configService =
GoogleContactsActivator.getConfigService();
+
CredentialsStorageService credentialsService =
GoogleContactsActivator.getCredentialsService();
+
String login = cnx.getLogin();
String path = CONFIGURATION_PATH + ".acc" + Math.abs(login.hashCode());
@@ -189,6 +195,11 @@ public class GoogleContactsServiceImpl
configService.setProperty(
path + ".enabled",
((GoogleContactsConnectionImpl)cnx).isEnabled());
+
+ configService.setProperty(
+ path + ".prefix",
+ ((GoogleContactsConnectionImpl)cnx).getPrefix());
+
credentialsService.storePassword(path, cnx.getPassword());
}
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
index 6d52148..28c3203 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsSourceService.java
@@ -45,6 +45,11 @@ public class GoogleContactsSourceService
private final String password;
/**
+ * The prefix for all google contact phone numbers.
+ */
+ private String phoneNumberprefix;
+
+ /**
* Google Contacts connection.
*/
private GoogleContactsConnection cnx = null;
@@ -78,6 +83,7 @@ public class GoogleContactsSourceService
this.cnx = cnx;
this.login = cnx.getLogin();
this.password = cnx.getPassword();
+ this.phoneNumberprefix = cnx.getPrefix();
}
/**
@@ -351,4 +357,24 @@ public class GoogleContactsSourceService
queries.notify();
}
}
+
+ /**
+ * Returns the phoneNumber prefix for all phone numbers.
+ *
+ * @return the phoneNumber prefix for all phone numbers
+ */
+ public String getPhoneNumberPrefix()
+ {
+ return phoneNumberprefix;
+ }
+
+ /**
+ * Sets the phone number prefix.
+ *
+ * @param phoneNumberprefix the phone number prefix to set
+ */
+ public void setPhoneNumberPrefix(String phoneNumberprefix)
+ {
+ this.phoneNumberprefix = phoneNumberprefix;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java b/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
index f67b7c5..ad06c93 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/configform/AccountSettingsForm.java
@@ -40,6 +40,11 @@ public class AccountSettingsForm
private JPasswordField passwordField;
/**
+ * The prefix field.
+ */
+ private JTextField prefixField;
+
+ /**
* Save button.
*/
private JButton saveBtn = new JButton(
@@ -59,7 +64,7 @@ public class AccountSettingsForm
/**
* The Google Contacts connection.
*/
- private GoogleContactsConnection cnx = null;
+ private GoogleContactsConnectionImpl cnx = null;
/**
* Constructor.
@@ -150,6 +155,29 @@ public class AccountSettingsForm
c.anchor = GridBagConstraints.LINE_END;
basePanel.add(passwordField, c);
+ JLabel prefixLabel = new JLabel(
+ Resources.getString("service.gui.PREFIX"));
+ this.prefixField = new JTextField();
+ prefixLabel.setLabelFor(prefixField);
+ c.gridx = 0;
+ c.gridy = 3;
+ c.weightx = 0;
+ c.weighty = 0;
+ c.gridwidth = 1;
+ c.insets = new Insets(2, 50, 0, 5);
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.LINE_START;
+ basePanel.add(prefixLabel, c);
+ c.gridx = 1;
+ c.gridy = 3;
+ c.weightx = 1;
+ c.weighty = 0;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ c.insets = new Insets(2, 5, 0, 50);
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.LINE_END;
+ basePanel.add(prefixField, c);
+
mainPanel.setLayout(boxLayout);
mainPanel.add(basePanel);
@@ -179,7 +207,8 @@ public class AccountSettingsForm
{
this.nameField.setText(cnx.getLogin());
this.passwordField.setText(cnx.getPassword());
- this.cnx = cnx;
+ this.prefixField.setText(cnx.getPrefix());
+ this.cnx = (GoogleContactsConnectionImpl) cnx;
}
else
{
@@ -202,11 +231,13 @@ public class AccountSettingsForm
{
String login = nameField.getText();
String password = new String(passwordField.getPassword());
+ String prefix = prefixField.getText();
if(cnx == null)
{
- cnx = GoogleContactsActivator.getGoogleContactsService().
- getConnection(login, password);
+ cnx = (GoogleContactsConnectionImpl) GoogleContactsActivator
+ .getGoogleContactsService()
+ .getConnection(login, password);
}
else
{
@@ -214,6 +245,8 @@ public class AccountSettingsForm
cnx.setPassword(password);
}
+ cnx.setPrefix(prefix);
+
if(cnx.connect() == GoogleContactsConnection.ConnectionStatus.
ERROR_INVALID_CREDENTIALS)
{
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 9d81006..a713b9e 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,9 @@ public class GoogleContactsConfigForm
if(ret == 1)
{
- GoogleContactsConnection cnx = settingsForm.getConnection();
- tableModel.addAccount(cnx, true);
+ GoogleContactsConnectionImpl cnx
+ = (GoogleContactsConnectionImpl) settingsForm.getConnection();
+ tableModel.addAccount(cnx, true, cnx.getPrefix());
new RefreshContactSourceThread(null, cnx).start();
GoogleContactsActivator.getGoogleContactsService().saveConfig(
cnx);
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 bc51bbc..c294f08 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/configform/GoogleContactsTableModel.java
@@ -41,12 +41,18 @@ public class GoogleContactsTableModel
* @param cnx account
* @param enabled if the account should be enabled
*/
- public void addAccount(GoogleContactsConnection cnx, boolean enabled)
+ public void addAccount( GoogleContactsConnection cnx,
+ boolean enabled,
+ String prefix)
{
if(cnx != null)
{
- ((GoogleContactsConnectionImpl)cnx).setEnabled(enabled);
- googleService.getAccounts().add((GoogleContactsConnectionImpl)cnx);
+ GoogleContactsConnectionImpl cnxImpl
+ = (GoogleContactsConnectionImpl) cnx;
+ cnxImpl.setEnabled(enabled);
+ cnxImpl.setPrefix(prefix);
+
+ googleService.getAccounts().add(cnxImpl);
}
}
@@ -88,6 +94,8 @@ public class GoogleContactsTableModel
return Resources.getString("impl.googlecontacts.ENABLED");
case 1:
return Resources.getString("impl.googlecontacts.ACCOUNT_NAME");
+ case 2:
+ return Resources.getString("impl.googlecontacts.PREFIX");
default:
throw new IllegalArgumentException("column not found");
}
@@ -113,8 +121,8 @@ public class GoogleContactsTableModel
*/
public int getColumnCount()
{
- // 2 columns: "enable" and "account name"
- return 2;
+ // 3 columns: "enable", "account name", "prefix"
+ return 3;
}
/**
@@ -133,6 +141,8 @@ public class GoogleContactsTableModel
return new Boolean(getAccountAt(row).isEnabled());
case 1:
return getAccountAt(row).getLogin();
+ case 2:
+ return getAccountAt(row).getPrefix();
default:
throw new IllegalArgumentException("column not found");
}
@@ -168,10 +178,10 @@ public class GoogleContactsTableModel
*/
public boolean isCellEditable(int row, int col)
{
- if(col == 0)
- return true;
- else
+ if(col == 1)
return false;
+ else
+ return true;
}
/**
@@ -193,25 +203,32 @@ public class GoogleContactsTableModel
*/
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
{
- if(columnIndex != 0)
+ if(columnIndex != 0 || columnIndex != 2)
throw new IllegalArgumentException("non editable column!");
GoogleContactsConfigForm.RefreshContactSourceThread th = null;
GoogleContactsConnectionImpl cnx = getAccountAt(rowIndex);
- if(cnx.isEnabled())
+ if (columnIndex == 0)
{
- th = new GoogleContactsConfigForm.RefreshContactSourceThread(cnx,
- null);
+ if(cnx.isEnabled())
+ {
+ th = new GoogleContactsConfigForm.RefreshContactSourceThread(cnx,
+ null);
+ }
+ else
+ {
+ th = new GoogleContactsConfigForm.RefreshContactSourceThread(null,
+ cnx);
+ }
+
+ cnx.setEnabled(!cnx.isEnabled());
+
+ th.start();
}
- else
+ else if (columnIndex == 2)
{
- th = new GoogleContactsConfigForm.RefreshContactSourceThread(null,
- cnx);
+ cnx.setPrefix(aValue.toString());
}
-
- cnx.setEnabled(!cnx.isEnabled());
-
- th.start();
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java
index 8b97fdf..df6c5fb 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/UIContactDetail.java
@@ -22,6 +22,11 @@ import net.java.sip.communicator.service.protocol.*;
public abstract class UIContactDetail
{
/**
+ * The prefix to be used when calling this contact detail.
+ */
+ private String prefix;
+
+ /**
* The address of this detail.
*/
private final String address;
@@ -102,6 +107,9 @@ public abstract class UIContactDetail
*/
public String getAddress()
{
+ if (prefix != null && prefix.trim().length() >= 0)
+ return prefix + address;
+
return address;
}
@@ -167,6 +175,26 @@ public abstract class UIContactDetail
}
/**
+ * Returns the prefix to be used when calling this contact detail.
+ *
+ * @return the prefix to be used when calling this contact detail
+ */
+ public String getPrefix()
+ {
+ return prefix;
+ }
+
+ /**
+ * Sets the prefix to be used when calling this contact detail.
+ *
+ * @param the prefix to be used when calling this contact detail
+ */
+ public void setPrefix(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ /**
* Returns the <tt>PresenceStatus</tt> of this <tt>ContactDetail</tt> or
* null if the detail doesn't support presence.
* @return the <tt>PresenceStatus</tt> of this <tt>ContactDetail</tt> or
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java
index 5dc929f..1ad4176 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java
@@ -262,6 +262,18 @@ public class SourceUIContact
null,
detail.getPreferredProtocolProvider(opSetClass),
detail.getPreferredProtocol(opSetClass));
+
+ ContactSourceService contactSource
+ = sourceContact.getContactSource();
+
+ if (contactSource instanceof ExtendedContactSourceService)
+ {
+ String prefix = ((ExtendedContactSourceService) contactSource)
+ .getPhoneNumberPrefix();
+
+ if (prefix != null)
+ setPrefix(prefix);
+ }
}
/**
diff --git a/src/net/java/sip/communicator/impl/ldap/LdapContactSourceService.java b/src/net/java/sip/communicator/impl/ldap/LdapContactSourceService.java
index ab3ef60..4b700b3 100644
--- a/src/net/java/sip/communicator/impl/ldap/LdapContactSourceService.java
+++ b/src/net/java/sip/communicator/impl/ldap/LdapContactSourceService.java
@@ -182,6 +182,16 @@ public class LdapContactSourceService
}
/**
+ * Returns the phoneNumber prefix for all phone numbers.
+ *
+ * @return the phoneNumber prefix for all phone numbers
+ */
+ public String getPhoneNumberPrefix()
+ {
+ return ldapDirectory.getSettings().getGlobalPhonePrefix();
+ }
+
+ /**
* Notifies this <tt>LdapContactSourceService</tt> that a specific
* <tt>LdapContactQuery</tt> has stopped.
*
diff --git a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java
index c16c267..fb61ccf 100644
--- a/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java
+++ b/src/net/java/sip/communicator/impl/ldap/LdapDirectorySettingsImpl.java
@@ -39,6 +39,7 @@ public class LdapDirectorySettingsImpl
this.setPassword("");
this.setBaseDN("");
this.setScope(Scope.defaultValue());
+ this.setGlobalPhonePrefix("");
// mail
List<String> lst = new ArrayList<String>();
lst.add("mail");
@@ -88,6 +89,7 @@ public class LdapDirectorySettingsImpl
this.setPassword(settings.getPassword());
this.setBaseDN(settings.getBaseDN());
this.setScope(settings.getScope());
+ this.setGlobalPhonePrefix(settings.getGlobalPhonePrefix());
this.mapAttributes = settings.mapAttributes;
this.mailSuffix = settings.mailSuffix;
}
@@ -158,6 +160,11 @@ public class LdapDirectorySettingsImpl
private Scope scope;
/**
+ * The global phone prefix.
+ */
+ private String globalPhonePrefix;
+
+ /**
* Mail suffix.
*/
private String mailSuffix = null;
@@ -414,6 +421,30 @@ public class LdapDirectorySettingsImpl
}
/**
+ * Returns the global prefix to be used when calling phones from this ldap
+ * source.
+ *
+ * @return the global prefix to be used when calling phones from this ldap
+ * source
+ */
+ public String getGlobalPhonePrefix()
+ {
+ return globalPhonePrefix;
+ }
+
+ /**
+ * Sets the global prefix to be used when calling phones from this ldap
+ * source.
+ *
+ * @param the global prefix to be used when calling phones from this ldap
+ * source
+ */
+ public void setGlobalPhonePrefix(String prefix)
+ {
+ this.globalPhonePrefix = prefix;
+ }
+
+ /**
* Checks if both LdapDirectorySettings instance have the same content
*
* @return whether both LdapDirectorySettings instance have the same content
@@ -432,7 +463,8 @@ public class LdapDirectorySettingsImpl
this.getBindDN().equals(other.getBindDN()) &&
this.getPassword().equals(other.getPassword()) &&
this.getBaseDN().equals(other.getBaseDN()) &&
- this.getScope().equals(other.getScope());
+ this.getScope().equals(other.getScope()) &&
+ this.getGlobalPhonePrefix().equals(other.getGlobalPhonePrefix());
}
/**
@@ -465,6 +497,8 @@ public class LdapDirectorySettingsImpl
this.getScope().hashCode());
hash = 31 * hash + (null == this.getBaseDN() ? 0 :
this.getBaseDN().hashCode());
+ hash = 31 * hash + (null == this.getGlobalPhonePrefix() ? 0 :
+ this.getGlobalPhonePrefix().hashCode());
return hash;
}
@@ -661,6 +695,9 @@ public class LdapDirectorySettingsImpl
configService.setProperty(
directoriesPath + "." + node + ".overridehomephone",
mergeStrings(this.getHomePhoneSearchFields()));
+ configService.setProperty(
+ directoriesPath + "." + node + ".globalPhonePrefix",
+ this.getGlobalPhonePrefix());
}
/**
@@ -803,6 +840,16 @@ public class LdapDirectorySettingsImpl
mapAttributes.put("homePhone", mergeString(ret));
}
+
+ if(configService.getProperty(directoriesPath + "." + node +
+ ".globalPhonePrefix") != null)
+ {
+ String ret = (String)configService.getProperty(
+ directoriesPath + "." + node + ".globalPhonePrefix");
+
+ if (ret != null)
+ setGlobalPhonePrefix(ret);
+ }
}
/**
@@ -859,6 +906,9 @@ public class LdapDirectorySettingsImpl
directoriesPath + "." + node + ".overridehomephone",
null);
configService.setProperty(
+ directoriesPath + "." + node + ".globalPhonePrefix",
+ null);
+ configService.setProperty(
directoriesPath + "." + node,
null);
}
@@ -878,7 +928,8 @@ public class LdapDirectorySettingsImpl
this.getAuth() + ", \n" +
this.getBindDN() + ", \n" +
this.getPassword() + ", \n" +
- this.getBaseDN() + " \n}";
+ this.getBaseDN() + ", \n" +
+ this.getGlobalPhonePrefix() + " \n}";
}
public LdapDirectorySettings clone()
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
index cad92eb..bfdcf90 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/AddrBookActivator.java
@@ -6,8 +6,13 @@
*/
package net.java.sip.communicator.plugin.addrbook;
+import java.util.*;
+
+import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
@@ -54,6 +59,17 @@ public class AddrBookActivator
private static PhoneNumberI18nService phoneNumberI18nService;
/**
+ * The <tt>ResourceManagementService</tt> through which we access resources.
+ */
+ private static ResourceManagementService resourceService;
+
+ /**
+ * The <tt>ConfigurationService</tt> through which we access configuration
+ * properties.
+ */
+ private static ConfigurationService configService;
+
+ /**
* Gets the <tt>PhoneNumberI18nService</tt> to be used by the functionality
* of the addrbook plug-in.
*
@@ -73,6 +89,44 @@ public class AddrBookActivator
}
/**
+ * Gets the <tt>ResourceManagementService</tt> to be used by the
+ * functionality of the addrbook plug-in.
+ *
+ * @return the <tt>ResourceManagementService</tt> to be used by the
+ * functionality of the addrbook plug-in
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourceService == null)
+ {
+ resourceService
+ = ServiceUtils.getService(
+ bundleContext,
+ ResourceManagementService.class);
+ }
+ return resourceService;
+ }
+
+ /**
+ * Gets the <tt>ConfigurationService</tt> to be used by the
+ * functionality of the addrbook plug-in.
+ *
+ * @return the <tt>ConfigurationService</tt> to be used by the
+ * functionality of the addrbook plug-in
+ */
+ public static ConfigurationService getConfigService()
+ {
+ if (configService == null)
+ {
+ configService
+ = ServiceUtils.getService(
+ bundleContext,
+ ConfigurationService.class);
+ }
+ return configService;
+ }
+
+ /**
* Starts the addrbook plug-in.
*
* @param bundleContext the <tt>BundleContext</tt> in which the addrbook
@@ -91,6 +145,22 @@ public class AddrBookActivator
new PhoneNumberI18nServiceImpl(),
null);
+ Dictionary<String, String> properties = new Hashtable<String, String>();
+
+ // Registers the sip config panel as advanced configuration form.
+ properties.put( ConfigurationForm.FORM_TYPE,
+ ConfigurationForm.CONTACT_SOURCE_TYPE);
+
+ bundleContext.registerService(
+ ConfigurationForm.class.getName(),
+ new LazyConfigurationForm(
+ AdvancedConfigForm.class.getName(),
+ getClass().getClassLoader(),
+ null,
+ "plugin.addrbook.ADDRESS_BOOKS",
+ 101, false),
+ properties);
+
/* Register the ContactSourceService implementation (if any). */
String cssClassName;
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java
new file mode 100644
index 0000000..1861a9e
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java
@@ -0,0 +1,149 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.addrbook;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.addrbook.macosx.MacOSXAddrBookContactSourceService;
+import net.java.sip.communicator.plugin.addrbook.msoutlook.MsOutlookAddrBookContactSourceService;
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ * Implementation of the advanced address book configuration form.
+ *
+ * @author Yana Stamcheva
+ */
+public class AdvancedConfigForm
+ extends TransparentPanel
+{
+ /**
+ * Creates the form.
+ */
+ public AdvancedConfigForm()
+ {
+ super(new BorderLayout());
+
+ JPanel propertiesPanel = new TransparentPanel();
+ propertiesPanel.setLayout(
+ new BoxLayout(propertiesPanel, BoxLayout.Y_AXIS));
+
+ JTextPane descriptionTextPane = new JTextPane();
+ descriptionTextPane.setEditable(false);
+ descriptionTextPane.setOpaque(false);
+ descriptionTextPane.setForeground(Color.GRAY);
+ descriptionTextPane.setText(
+ AddrBookActivator.getResources().getI18NString(
+ "plugin.addrbook.DESCRIPTION"));
+
+ propertiesPanel.add(descriptionTextPane);
+ propertiesPanel.add(Box.createVerticalStrut(15));
+
+ if (OSUtils.IS_MAC)
+ propertiesPanel.add(createEnableCheckBox(
+ "plugin.addrbook.ENABLE_MACOSX_ADDRESS_BOOK_SEARCH",
+ "plugin.addrbook.ENABLE_MACOSX_ADDRESSBOOK"));
+
+ if (OSUtils.IS_WINDOWS)
+ propertiesPanel.add(createEnableCheckBox(
+ "plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK_SEARCH",
+ "plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK"));
+
+ propertiesPanel.add(Box.createVerticalStrut(15));
+
+ propertiesPanel.add(createPrefixPanel());
+
+ add(propertiesPanel, BorderLayout.NORTH);
+ }
+
+ /**
+ * Creates the enable check box.
+ *
+ * @return the created enable check box
+ */
+ private Component createEnableCheckBox(final String configPropName,
+ String labelNameKey)
+ {
+ final JCheckBox checkBox = new JCheckBox(AddrBookActivator
+ .getResources().getI18NString(
+ labelNameKey),
+ AddrBookActivator.getConfigService().getBoolean(configPropName,
+ true));
+
+ checkBox.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent arg0)
+ {
+ AddrBookActivator.getConfigService().setProperty(
+ configPropName,
+ new Boolean(checkBox.isSelected()).toString());
+ }
+ });
+ return checkBox;
+ }
+
+ /**
+ * Creates the prefix panel.
+ *
+ * @return the created prefix panel
+ */
+ private JComponent createPrefixPanel()
+ {
+ JLabel prefixLabel = new JLabel(AddrBookActivator
+ .getResources().getI18NString("plugin.addrbook.PREFIX"));
+
+ final SIPCommTextField prefixField = new SIPCommTextField(
+ AddrBookActivator.getResources()
+ .getI18NString("plugin.addrbook.PREFIX_EXAMPLE"));
+
+ String storedPrefix = null;
+ if (OSUtils.IS_MAC)
+ storedPrefix = AddrBookActivator.getConfigService().getString(
+ MacOSXAddrBookContactSourceService
+ .MACOSX_ADDR_BOOK_PREFIX);
+
+ if (OSUtils.IS_WINDOWS)
+ storedPrefix = AddrBookActivator.getConfigService().getString(
+ MsOutlookAddrBookContactSourceService
+ .OUTLOOK_ADDR_BOOK_PREFIX);
+
+ if (storedPrefix != null && storedPrefix.length() > 0)
+ prefixField.setText(storedPrefix);
+
+ JPanel prefixPanel = new TransparentPanel(new BorderLayout());
+
+ prefixPanel.add(prefixLabel, BorderLayout.WEST);
+ prefixPanel.add(prefixField);
+
+ prefixField.addFocusListener(new FocusAdapter()
+ {
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ String prefix = prefixField.getText();
+
+ if (prefix == null || prefix.length() <= 0)
+ return;
+
+ if (OSUtils.IS_MAC)
+ AddrBookActivator.getConfigService().setProperty(
+ MacOSXAddrBookContactSourceService
+ .MACOSX_ADDR_BOOK_PREFIX,
+ prefix);
+
+ if (OSUtils.IS_WINDOWS)
+ AddrBookActivator.getConfigService().setProperty(
+ MsOutlookAddrBookContactSourceService
+ .OUTLOOK_ADDR_BOOK_PREFIX,
+ prefix);
+ }
+ });
+ return prefixPanel;
+ }
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/plugin/addrbook/PhoneNumberI18nServiceImpl.java b/src/net/java/sip/communicator/plugin/addrbook/PhoneNumberI18nServiceImpl.java
index 6ff5a8c..45ff96d 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/PhoneNumberI18nServiceImpl.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/PhoneNumberI18nServiceImpl.java
@@ -107,6 +107,13 @@ public class PhoneNumberI18nServiceImpl
}
}
+ /**
+ * Indicates if the given string is possibly a phone number.
+ *
+ * @param possibleNumber the string to be verified
+ * @return <tt>true</tt> if the possibleNumber is a phone number,
+ * <tt>false</tt> - otherwise
+ */
public boolean isPhoneNumber(String possibleNumber)
{
PhoneNumberUtil numberUtil = PhoneNumberUtil.getInstance();
diff --git a/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf b/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf
index f8b1032..fbafa49 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/addrbook/addrbook.manifest.mf
@@ -5,6 +5,11 @@ Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: net.java.sip.communicator.service.contactsource,
net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.util,
- org.osgi.framework
+ net.java.sip.communicator.util,
+ net.java.sip.communicator.service.gui,
+ net.java.sip.communicator.util.swing,
+ net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.service.configuration,
+ org.osgi.framework,
+ javax.swing
System-Bundle: yes
diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
index bb06efe..99ce518 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java
@@ -8,6 +8,7 @@ package net.java.sip.communicator.plugin.addrbook.macosx;
import java.util.regex.*;
+import net.java.sip.communicator.plugin.addrbook.AddrBookActivator;
import net.java.sip.communicator.service.contactsource.*;
/**
@@ -18,6 +19,9 @@ import net.java.sip.communicator.service.contactsource.*;
public class MacOSXAddrBookContactSourceService
extends AsyncContactSourceService
{
+ public static final String MACOSX_ADDR_BOOK_PREFIX
+ = "net.java.sip.communicator.plugin.addrbook.MACOSX_ADDR_BOOK_PREFIX";
+
static
{
System.loadLibrary("jmacosxaddrbook");
@@ -110,6 +114,18 @@ public class MacOSXAddrBookContactSourceService
}
/**
+ * Returns the global phone number prefix to be used when calling contacts
+ * from this contact source.
+ *
+ * @return the global phone number prefix
+ */
+ public String getPhoneNumberPrefix()
+ {
+ return AddrBookActivator.getConfigService()
+ .getString(MACOSX_ADDR_BOOK_PREFIX);
+ }
+
+ /**
* Stops a native <tt>MacOSXAddrBookContactSourceService</tt>.
*
* @param ptr the pointer to the native
diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
index ddb2a82..65166f8 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java
@@ -9,6 +9,7 @@ package net.java.sip.communicator.plugin.addrbook.msoutlook;
import java.util.*;
import java.util.regex.*;
+import net.java.sip.communicator.plugin.addrbook.AddrBookActivator;
import net.java.sip.communicator.service.contactsource.*;
/**
@@ -20,6 +21,9 @@ import net.java.sip.communicator.service.contactsource.*;
public class MsOutlookAddrBookContactSourceService
extends AsyncContactSourceService
{
+ public static final String OUTLOOK_ADDR_BOOK_PREFIX
+ = "net.java.sip.communicator.plugin.addrbook.OUTLOOK_ADDR_BOOK_PREFIX";
+
private static final long MAPI_INIT_VERSION = 0;
private static final long MAPI_MULTITHREAD_NOTIFICATIONS = 0x00000001;
@@ -173,6 +177,18 @@ public class MsOutlookAddrBookContactSourceService
}
/**
+ * Returns the global phone number prefix to be used when calling contacts
+ * from this contact source.
+ *
+ * @return the global phone number prefix
+ */
+ public String getPhoneNumberPrefix()
+ {
+ return AddrBookActivator.getConfigService()
+ .getString(OUTLOOK_ADDR_BOOK_PREFIX);
+ }
+
+ /**
* Notifies this <tt>MsOutlookAddrBookContactSourceService</tt> that a
* specific <tt>MsOutlookAddrBookContactQuery</tt> has stopped.
*
diff --git a/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java
new file mode 100644
index 0000000..c82f9e8
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigActivator.java
@@ -0,0 +1,138 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.contactsourceconfig;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.configuration.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ * @author Yana Stamcheva
+ */
+public class ContactSourceConfigActivator
+ implements BundleActivator
+{
+ /**
+ * The logger.
+ */
+ private static Logger logger
+ = Logger.getLogger(ContactSourceConfigActivator.class);
+
+ /**
+ * The {@link BundleContext} of the {@link SecurityConfigActivator}.
+ */
+ public static BundleContext bundleContext;
+
+ /**
+ * The {@link ResourceManagementService} of the
+ * {@link SecurityConfigActivator}. Can also be obtained from the
+ * {@link SecurityConfigActivator#bundleContext} on demand, but we add it
+ * here for convenience.
+ */
+ private static ResourceManagementService resources;
+
+ /**
+ * The <tt>ConfigurationService</tt> registered in {@link #bundleContext}
+ * and used by the <tt>SecurityConfigActivator</tt> instance to read and
+ * write configuration properties.
+ */
+ private static ConfigurationService configurationService;
+
+ /**
+ * The <tt>UIService</tt> registered in {@link #bundleContext}.
+ */
+ private static UIService uiService;
+
+ /**
+ * Starts this plugin.
+ * @param bc the BundleContext
+ * @throws Exception if some of the operations executed in the start method
+ * fails
+ */
+ public void start(BundleContext bc) throws Exception
+ {
+ bundleContext = bc;
+
+ Dictionary<String, String> properties = new Hashtable<String, String>();
+
+ // Registers the contact source panel as advanced configuration form.
+ properties.put( ConfigurationForm.FORM_TYPE,
+ ConfigurationForm.ADVANCED_TYPE);
+
+ bundleContext.registerService(
+ ConfigurationForm.class.getName(),
+ new LazyConfigurationForm(
+ ContactSourceConfigForm.class.getName(),
+ getClass().getClassLoader(),
+ null,
+ "plugin.contactsourceconfig.CONTACT_SOURCE_TITLE",
+ 101, true),
+ properties);
+ }
+
+ /**
+ * Invoked when this bundle is stopped.
+ * @param bc the BundleContext
+ * @throws Exception if some of the operations executed in the start method
+ * fails
+ */
+ public void stop(BundleContext bc) throws Exception {}
+
+ /**
+ * Returns a reference to the ResourceManagementService implementation
+ * currently registered in the bundle context or null if no such
+ * implementation was found.
+ *
+ * @return a currently valid implementation of the ResourceManagementService
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resources == null)
+ {
+ resources
+ = ResourceManagementServiceUtils.getService(bundleContext);
+ }
+ return resources;
+ }
+
+ /**
+ * Returns a reference to the ConfigurationService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the ConfigurationService.
+ */
+ public static ConfigurationService getConfigurationService()
+ {
+ if (configurationService == null)
+ {
+ configurationService
+ = ServiceUtils.getService(
+ bundleContext,
+ ConfigurationService.class);
+ }
+ return configurationService;
+ }
+
+ /**
+ * Gets the <tt>UIService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>SecurityConfigActivator</tt>.
+ *
+ * @return the <tt>UIService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>SecurityConfigActivator</tt>
+ */
+ public static UIService getUIService()
+ {
+ if (uiService == null)
+ uiService = ServiceUtils.getService(bundleContext, UIService.class);
+ return uiService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigForm.java b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigForm.java
new file mode 100644
index 0000000..6504e3e
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/contactsourceconfig/ContactSourceConfigForm.java
@@ -0,0 +1,187 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.contactsourceconfig;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import org.osgi.framework.*;
+
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.util.swing.*;
+
+/**
+ *
+ * @author Yana Stamcheva
+ */
+public class ContactSourceConfigForm
+ extends TransparentPanel
+ implements ServiceListener
+{
+ /**
+ * The drop down list of contact sources.
+ */
+ private final JComboBox contactSourceComboBox = new JComboBox();
+
+ /**
+ * Creates the <tt>ContactSourceConfigForm</tt>.
+ */
+ public ContactSourceConfigForm()
+ {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ contactSourceComboBox.setRenderer(new ContactSourceRenderer());
+
+ final JPanel centerPanel
+ = new TransparentPanel(new BorderLayout(10, 10));
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ centerPanel.setPreferredSize(new Dimension(450, 300));
+
+ contactSourceComboBox.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent event)
+ {
+ ConfigurationForm form
+ = (ConfigurationForm) contactSourceComboBox
+ .getSelectedItem();
+
+ centerPanel.removeAll();
+ JComponent c = (JComponent) form.getForm();
+ c.setOpaque(false);
+
+ centerPanel.add(c, BorderLayout.CENTER);
+
+ centerPanel.revalidate();
+ centerPanel.repaint();
+ }
+ });
+
+ init();
+
+ add(contactSourceComboBox);
+ add(Box.createVerticalStrut(10));
+ add(centerPanel);
+
+ ContactSourceConfigActivator.bundleContext.addServiceListener(this);
+ }
+
+ /**
+ * Initializes this panel.
+ */
+ private void init()
+ {
+ String osgiFilter = "("
+ + ConfigurationForm.FORM_TYPE
+ + "="+ConfigurationForm.CONTACT_SOURCE_TYPE+")";
+
+ ServiceReference[] confFormsRefs = null;
+ try
+ {
+ confFormsRefs = ContactSourceConfigActivator.bundleContext
+ .getServiceReferences( ConfigurationForm.class.getName(),
+ osgiFilter);
+ }
+ catch (InvalidSyntaxException ex)
+ {}
+
+ if(confFormsRefs != null)
+ {
+ for (int i = 0; i < confFormsRefs.length; i++)
+ {
+ ConfigurationForm form
+ = (ConfigurationForm) ContactSourceConfigActivator
+ .bundleContext.getService(confFormsRefs[i]);
+
+ Object formComponent = form.getForm();
+ if (formComponent instanceof Component)
+ addConfigForm(form);
+ }
+ }
+ }
+
+ /**
+ * Handles registration of a new configuration form.
+ * @param event the <tt>ServiceEvent</tt> that notified us
+ */
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference serviceRef = event.getServiceReference();
+
+ Object property = serviceRef.getProperty(ConfigurationForm.FORM_TYPE);
+ if (property != ConfigurationForm.CONTACT_SOURCE_TYPE)
+ return;
+
+ Object sService
+ = ContactSourceConfigActivator.bundleContext
+ .getService(serviceRef);
+
+ // we don't care if the source service is not a configuration form
+ if (!(sService instanceof ConfigurationForm))
+ return;
+
+ ConfigurationForm configForm = (ConfigurationForm) sService;
+
+ if (!configForm.isAdvanced())
+ return;
+
+ Object formComponent;
+ switch (event.getType())
+ {
+ case ServiceEvent.REGISTERED:
+ formComponent = configForm.getForm();
+ if (formComponent instanceof Component)
+ addConfigForm(configForm);
+ break;
+
+ case ServiceEvent.UNREGISTERING:
+ formComponent = configForm.getForm();
+ if (formComponent instanceof Component)
+ remove((Component) formComponent);
+ break;
+ }
+ }
+
+ /**
+ * Adds the given form to this configuration panel.
+ *
+ * @param form the <tt>ConfigurationForm</tt> to add
+ */
+ private void addConfigForm(ConfigurationForm form)
+ {
+ int cIndex = form.getIndex();
+
+ if (cIndex >= contactSourceComboBox.getItemCount())
+ contactSourceComboBox.addItem(form);
+ else
+ contactSourceComboBox.insertItemAt(form, cIndex);
+ }
+
+ /**
+ * The contact source combo box custom renderer.
+ */
+ private class ContactSourceRenderer extends DefaultListCellRenderer
+ {
+ public Component getListCellRendererComponent(
+ JList list, Object value, int index,
+ boolean isSelected, boolean hasFocus)
+ {
+ JLabel renderer
+ = (JLabel) super.getListCellRendererComponent(
+ list, value, index, isSelected, hasFocus);
+
+ if (value != null)
+ {
+ ConfigurationForm form = (ConfigurationForm) value;
+
+ renderer.setText(form.getTitle());
+ }
+
+ return renderer;
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf b/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf
new file mode 100644
index 0000000..f74b575
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/contactsourceconfig/contactsourceconfig.manifest.mf
@@ -0,0 +1,15 @@
+Bundle-Activator: net.java.sip.communicator.plugin.contactsourceconfig.ContactSourceConfigActivator
+Bundle-Description: Contact sources configuration
+Bundle-Name: Contact sources configuration
+Bundle-Vendor: sip-communicator.org
+Bundle-Version: 0.0.1
+Import-Package: net.java.sip.communicator.service.contactsource,
+ net.java.sip.communicator.service.protocol,
+ net.java.sip.communicator.util,
+ net.java.sip.communicator.service.gui,
+ net.java.sip.communicator.util.swing,
+ net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.service.configuration,
+ org.osgi.framework,
+ javax.swing
+System-Bundle: yes
diff --git a/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java b/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java
index d74c860..57dad85 100644
--- a/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java
+++ b/src/net/java/sip/communicator/plugin/ldap/LdapActivator.java
@@ -56,7 +56,7 @@ public class LdapActivator implements BundleActivator
Dictionary<String, String> properties =
new Hashtable<String, String>();
properties.put( ConfigurationForm.FORM_TYPE,
- ConfigurationForm.ADVANCED_TYPE);
+ ConfigurationForm.CONTACT_SOURCE_TYPE);
bundleContext.registerService(
ConfigurationForm.class.getName(),
@@ -65,7 +65,7 @@ public class LdapActivator implements BundleActivator
getClass().getClassLoader(),
"impl.ldap.PLUGIN_ICON",
"impl.ldap.CONFIG_FORM_TITLE",
- 2000, true),
+ 2000, false),
properties);
}
diff --git a/src/net/java/sip/communicator/plugin/ldap/configform/DirectorySettingsForm.java b/src/net/java/sip/communicator/plugin/ldap/configform/DirectorySettingsForm.java
index b2ec77c..60dc823 100644
--- a/src/net/java/sip/communicator/plugin/ldap/configform/DirectorySettingsForm.java
+++ b/src/net/java/sip/communicator/plugin/ldap/configform/DirectorySettingsForm.java
@@ -140,6 +140,18 @@ public class DirectorySettingsForm
private JComboBox scopeList = new JComboBox(scopeStrings);
/**
+ * The prefix label.
+ */
+ private final JLabel prefixLabel = new JLabel(
+ Resources.getString("impl.ldap.PHONE_PREFIX"));
+
+ /**
+ * The prefix field.
+ */
+ private final SIPCommTextField prefixField = new SIPCommTextField(
+ Resources.getString("impl.ldap.PHONE_PREFIX_EXAMPLE"));
+
+ /**
* Save button.
*/
private JButton saveBtn = new JButton(
@@ -388,6 +400,8 @@ public class DirectorySettingsForm
JPanel basePanel = new TransparentPanel(new GridBagLayout());
JPanel authPanel = new TransparentPanel(new GridBagLayout());
JPanel searchPanel = new TransparentPanel(new GridBagLayout());
+ JPanel prefixPanel = new TransparentPanel(new GridBagLayout());
+
//JPanel btnPanel = new TransparentPanel(new FlowLayout(
// FlowLayout.RIGHT));
BoxLayout boxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
@@ -635,6 +649,7 @@ public class DirectorySettingsForm
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
searchPanel.add(scopeLabel, c);
+
c.gridx = 1;
c.gridy = 2;
c.weightx = 0;
@@ -645,12 +660,34 @@ public class DirectorySettingsForm
c.anchor = GridBagConstraints.LINE_START;
searchPanel.add(scopeList, c);
+ c.gridx = 0;
+ c.gridy = 0;
+ c.weightx = 0;
+ c.weighty = 0;
+ c.gridwidth = 1;
+ c.insets = new Insets(2, 50, 0, 5);
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.LINE_START;
+ prefixPanel.add(prefixLabel, c);
+
+ c.gridx = 1;
+ c.gridy = 0;
+ c.weightx = 1;
+ c.weighty = 0;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ c.insets = new Insets(2, 5, 0, 50);
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.anchor = GridBagConstraints.LINE_END;
+ prefixPanel.add(prefixField, c);
+
mainPanel.setLayout(boxLayout);
mainPanel.add(basePanel);
mainPanel.add(new JSeparator());
mainPanel.add(searchPanel);
mainPanel.add(new JSeparator());
mainPanel.add(authPanel);
+ mainPanel.add(new JSeparator());
+ mainPanel.add(prefixPanel);
/* listeners */
this.encryptionBox.addActionListener(this);
@@ -716,6 +753,7 @@ public class DirectorySettingsForm
mergeStrings(settings.getMobilePhoneSearchFields()));
this.homePhoneField.setText(
mergeStrings(settings.getHomePhoneSearchFields()));
+ this.prefixField.setText(settings.getGlobalPhonePrefix());
}
/**
@@ -814,6 +852,7 @@ public class DirectorySettingsForm
mergeString(mobilePhoneField.getText()));
settings.setHomePhoneSearchFields(
mergeString(homePhoneField.getText()));
+ settings.setGlobalPhonePrefix(prefixField.getText());
}
/**
@@ -854,8 +893,7 @@ public class DirectorySettingsForm
for(LdapDirectory s :
LdapActivator.getLdapService().getServerSet())
{
- if(s.getSettings().getName().equals(
- this.nameField.getText()))
+ if(s.getSettings().getName().equals(nameField.getText()))
{
JOptionPane.showMessageDialog(
this,
diff --git a/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java b/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java
index 725ab20..9363ed4 100644
--- a/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java
+++ b/src/net/java/sip/communicator/plugin/ldap/configform/LdapTableModel.java
@@ -50,6 +50,8 @@ public class LdapTableModel
return Resources.getString("impl.ldap.SERVER_NAME");
case 2:
return Resources.getString("impl.ldap.SERVER_HOSTNAME");
+ case 3:
+ return Resources.getString("impl.ldap.PHONE_PREFIX");
default:
throw new IllegalArgumentException("column not found");
}
@@ -75,8 +77,8 @@ public class LdapTableModel
*/
public int getColumnCount()
{
- // 3 columns: "enable", "name" and "hostname"
- return 3;
+ // 4 columns: "enable", "name", "hostname" and "prefix"
+ return 4;
}
/**
@@ -97,6 +99,9 @@ public class LdapTableModel
return this.getServerAt(row).getSettings().getName();
case 2:
return this.getServerAt(row).getSettings().getHostname();
+ case 3:
+ return this.getServerAt(row).getSettings()
+ .getGlobalPhonePrefix();
default:
throw new IllegalArgumentException("column not found");
}
diff --git a/src/net/java/sip/communicator/service/contactsource/ExtendedContactSourceService.java b/src/net/java/sip/communicator/service/contactsource/ExtendedContactSourceService.java
index a5f8cbb..7ee9573 100644
--- a/src/net/java/sip/communicator/service/contactsource/ExtendedContactSourceService.java
+++ b/src/net/java/sip/communicator/service/contactsource/ExtendedContactSourceService.java
@@ -34,4 +34,12 @@ public interface ExtendedContactSourceService
* @return the created query
*/
public ContactQuery queryContactSource(Pattern queryPattern);
+
+ /**
+ * Returns the global phone number prefix to be used when calling contacts
+ * from this contact source.
+ *
+ * @return the global phone number prefix
+ */
+ public String getPhoneNumberPrefix();
}
diff --git a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
index 85c54cb..6923650 100644
--- a/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
+++ b/src/net/java/sip/communicator/service/googlecontacts/GoogleContactsConnection.java
@@ -69,4 +69,11 @@ public interface GoogleContactsConnection
* @return connection status
*/
public ConnectionStatus connect();
+
+ /**
+ * Returns the google contacts prefix.
+ *
+ * @return the google contacts prefix
+ */
+ public String getPrefix();
}
diff --git a/src/net/java/sip/communicator/service/gui/ConfigurationForm.java b/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
index fe43aae..f71801f 100644
--- a/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
+++ b/src/net/java/sip/communicator/service/gui/ConfigurationForm.java
@@ -40,6 +40,11 @@ public interface ConfigurationForm
public static final String ADVANCED_TYPE = "ADVANCED_TYPE";
/**
+ * The advanced contact source form type.
+ */
+ public static final String CONTACT_SOURCE_TYPE = "CONTACT_SOURCE_TYPE";
+
+ /**
* Returns the title of this configuration form.
* @return the title of this configuration form
*/
diff --git a/src/net/java/sip/communicator/service/ldap/LdapDirectorySettings.java b/src/net/java/sip/communicator/service/ldap/LdapDirectorySettings.java
index f76d71d..46e4563 100644
--- a/src/net/java/sip/communicator/service/ldap/LdapDirectorySettings.java
+++ b/src/net/java/sip/communicator/service/ldap/LdapDirectorySettings.java
@@ -1,5 +1,5 @@
/*
- * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ se* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
@@ -246,6 +246,24 @@ public interface LdapDirectorySettings
public void setHomePhoneSearchFields(List<String> list);
/**
+ * Returns the global prefix to be used when calling phones from this ldap
+ * source.
+ *
+ * @return the global prefix to be used when calling phones from this ldap
+ * source
+ */
+ public String getGlobalPhonePrefix();
+
+ /**
+ * Sets the global prefix to be used when calling phones from this ldap
+ * source.
+ *
+ * @param the global prefix to be used when calling phones from this ldap
+ * source
+ */
+ public void setGlobalPhonePrefix(String prefix);
+
+ /**
* Saves these settings through the configuration service
*
* @see LdapDirectorySettings#persistentSave