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.
cusax-fix
Romain Kuntz 18 years ago
parent 361c371535
commit 22e2fdccab

@ -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)

@ -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
}

@ -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];
}

Loading…
Cancel
Save