diff options
Diffstat (limited to 'src/native/macosx')
3 files changed, 35 insertions, 11 deletions
diff --git a/src/native/macosx/sparkle/Makefile b/src/native/macosx/sparkle/Makefile index c945e09..77bba79 100644 --- a/src/native/macosx/sparkle/Makefile +++ b/src/native/macosx/sparkle/Makefile @@ -1,10 +1,12 @@ # Author: Romain KUNTZ +# Requires the Sparkle.framework installed in /Library/Frameworks +# The Framework is available at http://sparkle.andymatuschak.org/ CC=gcc TARGET=libsparkle_init.dylib JNI_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ CFLAGS=-I$(JNI_INCLUDE_PATH) -LIBS=-framework AppKit,Foundation +LIBS=-framework AppKit -framework Foundation -framework Sparkle OBJS=net_java_sip_communicator_impl_sparkle_SparkleActivator.o all:$(TARGET) diff --git a/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.h b/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.h index 0343c02..f81b0df 100644 --- a/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.h +++ b/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.h @@ -10,10 +10,10 @@ extern "C" { /* * Class: net_java_sip_communicator_impl_sparkle_SparkleActivator * Method: initSparkle - * Signature: (Ljava/lang/String;)V + * Signature: (Ljava/lang/String;ZI)V */ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle - (JNIEnv *, jclass, jstring); + (JNIEnv *, jclass, jstring, jboolean, jint); #ifdef __cplusplus } diff --git a/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.m b/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.m index a415767..973b242 100644 --- a/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.m +++ b/src/native/macosx/sparkle/net_java_sip_communicator_impl_sparkle_SparkleActivator.m @@ -6,30 +6,45 @@ */ /** - * Init the Sparkle subsystem + * Init the Sparkle subsystem. + * + * To generate the .h file, compile SC, go to the + * classes/ directory, and execute: + * javah -jni net.java.sip.communicator.impl.sparkle.SparkleActivator + * + * For compilation, this requires the Sparkle.framework + * installed in /Library/Frameworks/. This Framework is + * available at http://sparkle.andymatuschak.org/ * * @author Romain Kuntz */ + #include <Cocoa/Cocoa.h> +#include <Sparkle/SUUpdater.h> #include "net_java_sip_communicator_impl_sparkle_SparkleActivator.h" /* * Class: net_java_sip_communicator_impl_sparkle_SparkleActivator * Method: initSparkle - * Signature: (Ljava/lang/String;)V + * Signature: (Ljava/lang/String;ZI)V */ -JNIEXPORT void JNICALL +JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle - (JNIEnv *env, jclass obj, jstring pathToSparkleFramework) + (JNIEnv *env, jclass obj, jstring pathToSparkleFramework, + jboolean updateAtStartup, jint checkInterval) { bool haveBundle = ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"] != nil); const char *path = (*env)->GetStringUTFChars(env, pathToSparkleFramework, 0); - NSBundle* bundle = [NSBundle bundleWithPath:[NSString stringWithCString: path]]; - Class suUpdaterClass = [bundle classNamed:@"SUUpdater"]; - id suUpdater = [[suUpdaterClass alloc] init]; - + // The below code was used to avoid to link the Sparkle framework + // at comilation time. + //NSBundle* bundle = [NSBundle bundleWithPath:[NSString stringWithCString: path]]; + //Class suUpdaterClass = [bundle classNamed:@"SUUpdater"]; + //id suUpdater = [[suUpdaterClass alloc] init]; + + SUUpdater *suUpdater = [SUUpdater alloc]; + (*env)->ReleaseStringUTFChars(env, pathToSparkleFramework, path); NSMenu* menu = [[NSApplication sharedApplication] mainMenu]; @@ -46,4 +61,11 @@ Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle // 0 => top, 1 => after "About..." [applicationMenu insertItem:checkForUpdatesMenuItem atIndex:1]; + + // Check at Startup (SUCheckAtStartup and SUScheduledCheckInterval + // specified in the Info.plist does not seem to work) + if (updateAtStartup == JNI_TRUE) + [suUpdater checkForUpdatesInBackground]; + + [suUpdater scheduleCheckWithInterval:checkInterval]; } |