Implements warning dialog which is shown if Outlook is not the default

mail client.
fix-message-formatting 5216
hristoterezov 12 years ago
parent 3d1578190b
commit ae167a48d6

@ -883,6 +883,9 @@ plugin.addrbook.DESCRIPTION=If enabled everything you type in the search field \
plugin.addrbook.DEFAULT_IM_APP=Make Jitsi the default Instant Messaging Provider (Outlook integration)
plugin.addrbook.PREFIX=Specific phone number prefix
plugin.addrbook.PREFIX_EXAMPLE=Ex.: 00
plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT_TITLE=Error accessing your Microsoft Outlook contacts.
plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT={0} cannot currently access your Microsoft Outlook contacts because Outlook is not your default mail application.
plugin.addrbook.MAKE_OUTLOOK_DEFAULT_MAIL_CLIENT=Make Outlook default mail client
# Google Contacts
impl.googlecontacts.CONFIG_FORM_TITLE=Google Contacts

@ -76,3 +76,13 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac
{
return MAPIBitness_getOutlookVersion();
}
/**
* Returns true if Outlook is default mail client and false otherwise.
*
*/
JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_isOutlookDefaultMailClient
(JNIEnv *, jclass)
{
return (jboolean) MsOutlookUtils_isOutlookDefaultMailClient();
}

@ -30,6 +30,14 @@ JNIEXPORT int JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_M
JNIEXPORT int JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_getOutlookVersion
(JNIEnv *jniEnv, jclass clazz);
/*
* Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService
* Method: isOutlookDefaultMailClient
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_isOutlookDefaultMailClient
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif

@ -321,14 +321,14 @@ else if (OSUtils.IS_MAC
{
configService.setProperty(
PNAME_MAKE_JITSI_DEFAULT_IM_APPLICATION,
DefaultIMApp.isJitsiDefaultIMApp());
RegistryHandler.isJitsiDefaultIMApp());
}
else
{
boolean isDefaultIMApp
= Boolean.parseBoolean(isDefaultIMAppString);
if(DefaultIMApp.isJitsiDefaultIMApp() != isDefaultIMApp)
if(RegistryHandler.isJitsiDefaultIMApp() != isDefaultIMApp)
{
if(isDefaultIMApp)
setAsDefaultIMApplication();
@ -488,7 +488,7 @@ static void stopService()
public static void setAsDefaultIMApplication()
{
if (OSUtils.IS_WINDOWS)
DefaultIMApp.setJitsiAsDefaultApp();
RegistryHandler.setJitsiAsDefaultApp();
}
/**
@ -497,7 +497,7 @@ public static void setAsDefaultIMApplication()
public static void unsetDefaultIMApplication()
{
if (OSUtils.IS_WINDOWS)
DefaultIMApp.unsetDefaultApp();
RegistryHandler.unsetDefaultApp();
}
public static List<ProtocolProviderService> getProtocolProviders()

@ -0,0 +1,97 @@
/*
* Jitsi, 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.msoutlook;
import java.awt.event.*;
import javax.swing.*;
import org.jitsi.service.resources.*;
import net.java.sip.communicator.plugin.addrbook.*;
import net.java.sip.communicator.plugin.desktoputil.*;
/**
* A dialog with warning message that Outlook is not the default mail client
* shown when the contact source is started.
*
* @author Hristo Terezov
*/
public class DefaultMailClientMessageDialog
extends MessageDialog
{
/**
* Serial ID.
*/
private static final long serialVersionUID = -6321186451307613417L;
/**
* The <tt>ResourceManagementService</tt>
*/
private static ResourceManagementService resources
= AddrBookActivator.getResources();
/**
* Make Outlook default mail client check box.
*/
private JCheckBox defaultMailClientCheckBox = new SIPCommCheckBox(
resources
.getI18NString("plugin.addrbook.MAKE_OUTLOOK_DEFAULT_MAIL_CLIENT"));
public static int DONT_ASK_SELECTED_MASK = 1;
public static int DEFAULT_MAIL_CLIENT_SELECTED_MASK = 2;
/**
* Creates an instance of <tt>DefaultMailClientMessageDialog</tt>.
*/
public DefaultMailClientMessageDialog()
{
super(null,
AddrBookActivator.getResources().getI18NString(
"plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT_TITLE"),
resources.getI18NString(
"plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT",
new String[]{
resources.getSettingsString(
"service.gui.APPLICATION_NAME")}), false);
checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
checkBoxPanel.add(defaultMailClientCheckBox);
}
/**
* Handles the <tt>ActionEvent</tt>. Depending on the user choice sets
* the return code to the appropriate value.
*
* @param e the <tt>ActionEvent</tt> that notified us
*/
public void actionPerformed(ActionEvent e)
{
JButton button = (JButton)e.getSource();
if(!button.equals(okButton))
return;
this.returnCode = 0;
if (doNotAskAgain.isSelected())
{
this.returnCode = this.returnCode | DONT_ASK_SELECTED_MASK;
}
if (defaultMailClientCheckBox.isSelected())
{
this.returnCode
= this.returnCode | DEFAULT_MAIL_CLIENT_SELECTED_MASK;
}
this.dispose();
}
}

@ -48,6 +48,13 @@ public class MsOutlookAddrBookContactSourceService
public static final String PNAME_OUTLOOK_ADDR_BOOK_SEARCH_FIELD_DISABLED =
"net.java.sip.communicator.plugin.addrbook.OUTLOOK_ADDR_BOOK_SEARCH_FIELD_DISABLED";
/**
* Boolean property that defines whether the warning for the default mail
* client should be shown or not.
*/
public static final String PNAME_OUTLOOK_ADDR_BOOK_SHOW_DEFAULTMAILCLIENT_WARNING =
"net.java.sip.communicator.plugin.addrbook.SHOW_DEFAULTMAILCLIENT_WARNING";
private static final long MAPI_INIT_VERSION = 0;
private static final long MAPI_MULTITHREAD_NOTIFICATIONS = 0x00000001;
@ -132,6 +139,38 @@ public static void initMAPI(NotificationsDelegate notificationDelegate)
{
if(!isMAPIInitialized)
{
boolean isOutlookDefaultMailClient = isOutlookDefaultMailClient();
boolean showWarning
= AddrBookActivator.getConfigService().getBoolean(
PNAME_OUTLOOK_ADDR_BOOK_SHOW_DEFAULTMAILCLIENT_WARNING,
true);
if(!isOutlookDefaultMailClient && showWarning)
{
DefaultMailClientMessageDialog dialog
= new DefaultMailClientMessageDialog();
int result = dialog.showDialog();
if((result & DefaultMailClientMessageDialog
.DONT_ASK_SELECTED_MASK) != 0)
{
AddrBookActivator.getConfigService().setProperty(
PNAME_OUTLOOK_ADDR_BOOK_SHOW_DEFAULTMAILCLIENT_WARNING,
false);
}
if((result & DefaultMailClientMessageDialog
.DEFAULT_MAIL_CLIENT_SELECTED_MASK) != 0)
{
RegistryHandler.setOutlookAsDefaultMailClient();
}
}
if(isOutlookDefaultMailClient && !showWarning)
{
AddrBookActivator.getConfigService().setProperty(
PNAME_OUTLOOK_ADDR_BOOK_SHOW_DEFAULTMAILCLIENT_WARNING,
true);
}
String logFileName = "";
String homeLocation = System.getProperty(
"net.java.sip.communicator.SC_LOG_DIR_LOCATION");
@ -204,7 +243,7 @@ private static native void MAPIInitialize(
String logFileName,
int logLevel)
throws MsOutlookMAPIHResultException;
/**
* Uninitializes MAPI.
*/
@ -222,6 +261,8 @@ public static void UninitializeMAPI()
public static native int getOutlookBitnessVersion();
public static native int getOutlookVersion();
private static native boolean isOutlookDefaultMailClient();
/**
* Creates query that searches for <tt>SourceContact</tt>s

@ -11,12 +11,12 @@
import net.java.sip.communicator.plugin.addrbook.*;
/**
* Reading and writing the registry for default IM application used by
* Outlook 2010 and higher integration of presence statuses.
* Reading and writing the registry keys used by
* Outlook 2010 and higher.
*
* @author Hristo Terezov
*/
public class DefaultIMApp
public class RegistryHandler
{
/**
* The key under which the default IM application is placed.
@ -36,6 +36,12 @@ public class DefaultIMApp
*/
private static String REGISTRY_DEFAULT_IM_APPLICATION_COMMUNICATOR
= "Communicator";
/**
* The key under which the default IM application is placed.
*/
private static String REGISTRY_DEFAULT_MAIL_CLIENT_KEY
= "Software\\Clients\\Mail";
/**
* Checks whether given application is the default IM application or not.
@ -82,6 +88,19 @@ public static void setDefaultIMApp(String appName)
REGISTRY_DEFAULT_IM_APPLICATION_VALUE,
appName);
}
/**
* Sets Outlook as default mail client.
*/
public static void setOutlookAsDefaultMailClient()
{
Advapi32Util.registrySetStringValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_DEFAULT_MAIL_CLIENT_KEY,
null,
"Microsoft Outlook");
}
/**
* Sets Jitsi as default IM application.

@ -37,7 +37,7 @@ public class MessageDialog
protected JButton okButton = new JButton(
DesktopUtilActivator.getResources().getI18NString("service.gui.OK"));
private JCheckBox doNotAskAgain = new SIPCommCheckBox(
protected JCheckBox doNotAskAgain = new SIPCommCheckBox(
DesktopUtilActivator.getResources()
.getI18NString("service.gui.DO_NOT_ASK_AGAIN"));
@ -49,7 +49,7 @@ public class MessageDialog
private TransparentPanel buttonsPanel
= new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
private TransparentPanel checkBoxPanel
protected TransparentPanel checkBoxPanel
= new TransparentPanel(new FlowLayout(FlowLayout.LEADING));
private TransparentPanel mainPanel
@ -57,7 +57,7 @@ public class MessageDialog
private boolean isConfirmationEnabled = true;
private int returnCode;
protected int returnCode;
/**
* Indicates that the OK button is pressed.

Loading…
Cancel
Save