diff options
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
5 files changed, 331 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookActivator.java b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookActivator.java new file mode 100644 index 0000000..2b55fb9 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookActivator.java @@ -0,0 +1,95 @@ +/*
+ * 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.msoutlook;
+
+import net.java.sip.communicator.service.contactsource.*;
+
+import org.osgi.framework.*;
+
+/**
+ * Implements <tt>BundleActivator</tt> for the msoutlook plug-in which provides
+ * support for Microsoft Outlook.
+ *
+ * @author Lyubomir Marinov
+ */
+public class MsOutlookActivator
+ implements BundleActivator
+{
+ /**
+ * The <tt>MsOutlookAddressBookContactSourceService</tt> which implements
+ * <tt>ContactSourceService</tt> for the Address Book of Microsoft Outlook.
+ */
+ private MsOutlookAddressBookContactSourceService msoabcss;
+
+ /**
+ * The <tt>ServiceRegistration</tt> of {@link #msoabcss} in the
+ * <tt>BundleContext</tt> in which this <tt>MsOutlookActivator</tt> has been
+ * started.
+ */
+ private ServiceRegistration msoabcssServiceRegistration;
+
+ /**
+ * Starts the msoutlook plug-in.
+ *
+ * @param bundleContext the <tt>BundleContext</tt> in which the msoutlook
+ * plug-in is to be started
+ * @throws Exception if anything goes wrong while starting the msoutlook
+ * plug-in
+ * @see BundleActivator#start(BundleContext)
+ */
+ public void start(BundleContext bundleContext)
+ throws Exception
+ {
+ msoabcss = new MsOutlookAddressBookContactSourceService();
+ try
+ {
+ msoabcssServiceRegistration
+ = bundleContext.registerService(
+ ContactSourceService.class.getName(),
+ msoabcss,
+ null);
+ }
+ finally
+ {
+ if (msoabcssServiceRegistration == null)
+ {
+ msoabcss.stop();
+ msoabcss = null;
+ }
+ }
+ }
+
+ /**
+ * Stops the msoutlook plug-in.
+ *
+ * @param bundleContext the <tt>BundleContext</tt> in which the msoutlook
+ * plug-in is to be stopped
+ * @throws Exception if anything goes wrong while stopping the msoutlook
+ * plug-in
+ * @see BundleActivator#stop(BundleContext)
+ */
+ public void stop(BundleContext bundleContext)
+ throws Exception
+ {
+ try
+ {
+ if (msoabcssServiceRegistration != null)
+ {
+ msoabcssServiceRegistration.unregister();
+ msoabcssServiceRegistration = null;
+ }
+ }
+ finally
+ {
+ if (msoabcss != null)
+ {
+ msoabcss.stop();
+ msoabcss = null;
+ }
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactQuery.java b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactQuery.java new file mode 100644 index 0000000..de037cb --- /dev/null +++ b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactQuery.java @@ -0,0 +1,72 @@ +/*
+ * 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.msoutlook;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.contactsource.*;
+
+/**
+ * Implements <tt>ContactQuery</tt> for the Address Book of Microsoft Outlook.
+ *
+ * @author Lyubomir Marinov
+ */
+public class MsOutlookAddressBookContactQuery
+ extends AbstractContactQuery<MsOutlookAddressBookContactSourceService>
+{
+ /**
+ * Initializes a new <tt>MsOutlookAddressBookContactQuery</tt> instance to
+ * be performed by a specific
+ * <tt>MsOutlookAddressBookContactSourceService</tt>.
+ *
+ * @param msoabcss the <tt>MsOutlookAddressBookContactSourceService</tt>
+ * which is to perform the new <tt>ContactQuery</tt>
+ */
+ public MsOutlookAddressBookContactQuery(
+ MsOutlookAddressBookContactSourceService msoabcss)
+ {
+ super(msoabcss);
+ }
+
+ /**
+ * Cancels this <tt>ContactQuery</tt>.
+ *
+ * @see ContactQuery#cancel()
+ */
+ public void cancel()
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Gets the <tt>List</tt> of <tt>SourceContact</tt>s which match this
+ * <tt>ContactQuery</tt>.
+ *
+ * @return the <tt>List</tt> of <tt>SourceContact</tt>s which match this
+ * <tt>ContactQuery</tt>
+ * @see ContactQuery#getQueryResults()
+ */
+ public List<SourceContact> getQueryResults()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Gets the status of this <tt>ContactQuery</tt> which can be one of the
+ * <tt>QUERY_XXX</tt> constants defined by <tt>ContactQuery</tt>.
+ *
+ * @return the status of this <tt>ContactQuery</tt> which can be one of the
+ * <tt>QUERY_XXX</tt> constants defined by <tt>ContactQuery</tt>
+ * @see ContactQuery#getStatus()
+ */
+ public int getStatus()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactSourceService.java b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactSourceService.java new file mode 100644 index 0000000..0343744 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookAddressBookContactSourceService.java @@ -0,0 +1,95 @@ +/*
+ * 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.msoutlook;
+
+import net.java.sip.communicator.service.contactsource.*;
+
+/**
+ * Implements <tt>ContactSourceService</tt> for the Address Book of Microsoft
+ * Outlook.
+ *
+ * @author Lyubomir Marinov
+ */
+public class MsOutlookAddressBookContactSourceService
+ implements ContactSourceService
+{
+ private static final long MAPI_INIT_VERSION = 0;
+
+ private static final long MAPI_MULTITHREAD_NOTIFICATIONS = 0x00000001;
+
+ /**
+ * Initializes a new <tt>MsOutlookAddressBookContactSourceService</tt>
+ * instance.
+ *
+ * @throws MsOutlookMAPIHResultException if anything goes wrong while
+ * initializing the new <tt>MsOutlookAddressBookContactSourceService</tt>
+ * instance
+ */
+ public MsOutlookAddressBookContactSourceService()
+ throws MsOutlookMAPIHResultException
+ {
+ MAPIInitialize(MAPI_INIT_VERSION, MAPI_MULTITHREAD_NOTIFICATIONS);
+ }
+
+ /**
+ * Gets a human-readable <tt>String</tt> which names this
+ * <tt>ContactSourceService</tt> implementation.
+ *
+ * @return a human-readable <tt>String</tt> which names this
+ * <tt>ContactSourceService</tt> implementation
+ * @see ContactSourceService#getDisplayName()
+ */
+ public String getDisplayName()
+ {
+ return "Microsoft Outlook Address Book";
+ }
+
+ /**
+ * Gets a <tt>String</tt> which uniquely identifies the instances of the
+ * <tt>MsOutlookAddressBookContactSourceService</tt> implementation.
+ *
+ * @return a <tt>String</tt> which uniquely identifies the instances of the
+ * <tt>MsOutlookAddressBookContactSourceService</tt> implementation
+ * @see ContactSourceService#getIdentifier()
+ */
+ public String getIdentifier()
+ {
+ return "MsOutlookAddressBook";
+ }
+
+ private static native void MAPIInitialize(long version, long flags)
+ throws MsOutlookMAPIHResultException;
+
+ private static native void MAPIUninitialize();
+
+ /**
+ * Queries this <tt>ContactSourceService</tt> for <tt>SourceContact</tt>s
+ * which match a specific <tt>query</tt> <tt>String</tt>.
+ *
+ * @param query the <tt>String</tt> which this <tt>ContactSourceService</tt>
+ * is being queried for
+ * @return a <tt>ContactQuery</tt> which represents the query of this
+ * <tt>ContactSourceService</tt> implementation for the specified
+ * <tt>String</tt> and via which the matching <tt>SourceContact</tt>s (if
+ * any) will be returned
+ * @see ContactSourceService#queryContactSource(String)
+ */
+ public ContactQuery queryContactSource(String query)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Stops this <tt>ContactSourceService</tt> implementation and prepares it
+ * for garbage collection.
+ */
+ void stop()
+ {
+ MAPIUninitialize();
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookMAPIHResultException.java b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookMAPIHResultException.java new file mode 100644 index 0000000..d5a6f6f --- /dev/null +++ b/src/net/java/sip/communicator/plugin/msoutlook/MsOutlookMAPIHResultException.java @@ -0,0 +1,61 @@ +/*
+ * 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.msoutlook;
+
+/**
+ * Represents a specific Microsoft Outlook MAPI <tt>HRESULT</tt> as an
+ * <tt>Exception</tt>.
+ *
+ * @author Lyubomir Marinov
+ */
+public class MsOutlookMAPIHResultException
+ extends Exception
+{
+ /**
+ * The <tt>HRESULT</tt> which is represented by this <tt>Exception</tt>.
+ */
+ private final long hResult;
+
+ /**
+ * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
+ * is to represent a specific <tt>HRESULT</tt>.
+ *
+ * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
+ */
+ public MsOutlookMAPIHResultException(long hResult)
+ {
+ this.hResult = hResult;
+ }
+
+ /**
+ * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
+ * is to represent a specific <tt>HRESULT</tt> and to provide a specific
+ * <tt>String</tt> message.
+ *
+ * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
+ * @param message the <tt>String</tt> message to be provided by the new
+ * instance
+ */
+ public MsOutlookMAPIHResultException(long hResult, String message)
+ {
+ super(message);
+
+ this.hResult = hResult;
+ }
+
+ /**
+ * Gets the <tt>HRESULT</tt> which is represented by this
+ * <tt>Exception</tt>.
+ *
+ * @return the <tt>HRESULT</tt> which is represented by this
+ * <tt>Exception</tt>
+ */
+ public long getHResult()
+ {
+ return hResult;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/msoutlook/msoutlook.manifest.mf b/src/net/java/sip/communicator/plugin/msoutlook/msoutlook.manifest.mf new file mode 100644 index 0000000..8909037 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/msoutlook/msoutlook.manifest.mf @@ -0,0 +1,8 @@ +Bundle-Activator: net.java.sip.communicator.plugin.msoutlook.MsOutlookActivator
+Bundle-Description: Microsoft Outlook support
+Bundle-Name: Microsoft Outlook support
+Bundle-Vendor: sip-communicator.org
+Bundle-Version: 0.0.1
+Import-Package: net.java.sip.communicator.service.contactsource,
+ org.osgi.framework
+System-Bundle: yes
|