diff options
6 files changed, 141 insertions, 10 deletions
diff --git a/lib/native/mac/libjmacosxaddrbook.jnilib b/lib/native/mac/libjmacosxaddrbook.jnilib Binary files differindex 64a5ce4..d355086 100755 --- a/lib/native/mac/libjmacosxaddrbook.jnilib +++ b/lib/native/mac/libjmacosxaddrbook.jnilib diff --git a/src/native/addrbook/macosx/Makefile b/src/native/addrbook/macosx/Makefile index 6b71ff5..cce1ce9 100644 --- a/src/native/addrbook/macosx/Makefile +++ b/src/native/addrbook/macosx/Makefile @@ -11,6 +11,7 @@ TARGET = ../../../../lib/native/mac/lib$(TARGET_BASENAME).jnilib $(TARGET): \ ../AddrBookContactQuery.c \ - net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m + net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m \ + net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m $(CC) $(CPPFLAGS) $^ $(LDFLAGS) -o $@ $(LIBS) -strip $(TARGET) diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m index be3ddd3..780431a 100644 --- a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m +++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery.m @@ -110,7 +110,7 @@ Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactQuery autoreleasePool = [[NSAutoreleasePool alloc] init];
- addressBook = [ABAddressBook addressBook];
+ addressBook = [ABAddressBook sharedAddressBook];
people = [addressBook people];
peopleCount = [people count];
for (i = 0; i < peopleCount; i++)
diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h new file mode 100644 index 0000000..ae75978 --- /dev/null +++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService */ + +#ifndef _Included_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService +#define _Included_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService + * Method: start + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_start + (JNIEnv *, jclass); + +/* + * Class: net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService + * Method: stop + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_stop + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m new file mode 100644 index 0000000..6645bc5 --- /dev/null +++ b/src/native/addrbook/macosx/net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.m @@ -0,0 +1,78 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#include "net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService.h" + +#import <AddressBook/ABGlobals.h> +#import <Foundation/NSAutoreleasePool.h> +#import <Foundation/NSNotification.h> +#import <Foundation/NSObject.h> + +@interface MacOSXAddrBookContactSourceService : NSObject +{ +} + +- (void)abDatabaseChangedExternallyNotification:(NSNotification *)notification; +- (void)abDatabaseChangedNotification:(NSNotification *)notification; +@end /* MacOSXAddrBookContactSourceService */ + +JNIEXPORT jlong JNICALL +Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_start + (JNIEnv *jniEnv, jclass clazz) +{ + NSAutoreleasePool *pool; + MacOSXAddrBookContactSourceService *mabcss; + + pool = [[NSAutoreleasePool alloc] init]; + + mabcss = [[MacOSXAddrBookContactSourceService alloc] init]; + if (mabcss) + { + NSNotificationCenter *notificationCenter + = [NSNotificationCenter defaultCenter]; + + [notificationCenter + addObserver:mabcss + selector:@selector(abDatabaseChangedExternallyNotification:) + name:kABDatabaseChangedExternallyNotification + object:nil]; + [notificationCenter + addObserver:mabcss + selector:@selector(abDatabaseChangedNotification:) + name:kABDatabaseChangedNotification + object:nil]; + } + + [pool release]; + return (jlong) mabcss; +} + +JNIEXPORT void JNICALL +Java_net_java_sip_communicator_plugin_addrbook_macosx_MacOSXAddrBookContactSourceService_stop + (JNIEnv *jniEnv, jclass clazz, jlong ptr) +{ + MacOSXAddrBookContactSourceService *mabcss + = (MacOSXAddrBookContactSourceService *) ptr; + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; + + [[NSNotificationCenter defaultCenter] removeObserver:mabcss]; + [mabcss release]; + + [pool release]; +} + +@implementation MacOSXAddrBookContactSourceService +- (void)abDatabaseChangedExternallyNotification:(NSNotification *)notification +{ +} + +- (void)abDatabaseChangedNotification:(NSNotification *)notification +{ +} +@end /* MacOSXAddrBookContactSourceService */ 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 570a1fa..46e54d2 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java +++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactSourceService.java @@ -21,20 +21,23 @@ public class MacOSXAddrBookContactSourceService {
static
{
- /*
- * Attempt to load the JNI counterpart as close to the startup of the
- * addrbook bundle as possible so that any possible problem is
- * discovered and reported as early as possible and outside of the UI
- * which uses MacOSXAddrBookContactSourceService later on.
- */
System.loadLibrary("jmacosxaddrbook");
}
/**
+ * The pointer to the native counterpart of this
+ * <tt>MacOSXAddrBookContactSourceService</tt>.
+ */
+ private long ptr;
+
+ /**
* Initializes a new <tt>MacOSXAddrBookContactSourceService</tt> instance.
*/
public MacOSXAddrBookContactSourceService()
{
+ ptr = start();
+ if (0 == ptr)
+ throw new IllegalStateException("ptr");
}
/**
@@ -85,13 +88,33 @@ public class MacOSXAddrBookContactSourceService }
/**
+ * Starts a new native <tt>MacOSXAddrBookContactSourceService</tt> instance.
+ *
+ * @return a pointer to the newly-started native
+ * <tt>MacOSXAddrBookContactSourceService</tt> instance
+ */
+ private static native long start();
+
+ /**
* Stops this <tt>ContactSourceService</tt> implementation and prepares it
* for garbage collection.
*
* @see AsyncContactSourceService#stop()
*/
- public void stop()
+ public synchronized void stop()
{
- // TODO Auto-generated method stub
+ if (0 != ptr)
+ {
+ stop(ptr);
+ ptr = 0;
+ }
}
+
+ /**
+ * Stops a native <tt>MacOSXAddrBookContactSourceService</tt>.
+ *
+ * @param ptr the pointer to the native
+ * <tt>MacOSXAddrBookContactSourceService</tt> to stop
+ */
+ private static native void stop(long ptr);
}
|