From 22e2fdccab0ab5af0cc7a2cc87354e9bb52d760d Mon Sep 17 00:00:00 2001 From: Romain Kuntz Date: Tue, 20 May 2008 14:57:09 +0000 Subject: Updated the Sparkle JNI lib. Preferences such as whether update must be checked at startup or the check interval value can now be set (statically for now) in the SparkleActivator bundle which will take care of giving it to the JNI. --- src/native/macosx/sparkle/Makefile | 4 ++- ...ip_communicator_impl_sparkle_SparkleActivator.h | 4 +-- ...ip_communicator_impl_sparkle_SparkleActivator.m | 38 +++++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) (limited to 'src/native/macosx') 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 +#include #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]; } -- cgit v1.1