diff options
author | Sebastien Vincent <seb@jitsi.org> | 2010-10-04 09:27:20 +0000 |
---|---|---|
committer | Sebastien Vincent <seb@jitsi.org> | 2010-10-04 09:27:20 +0000 |
commit | f7078b197ba877dc981592b927886f8d9a7fd143 (patch) | |
tree | 2a72f902e80b5a0a6e2a6bafe7b3001807b11bc5 /src | |
parent | 23cd620acccc8e7945c54bf7c8d387519b872560 (diff) | |
download | jitsi-f7078b197ba877dc981592b927886f8d9a7fd143.zip jitsi-f7078b197ba877dc981592b927886f8d9a7fd143.tar.gz jitsi-f7078b197ba877dc981592b927886f8d9a7fd143.tar.bz2 |
If an update link is provided by provisioning configuration, use it instead of default ones.
Diffstat (limited to 'src')
6 files changed, 98 insertions, 18 deletions
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 f81b0df..d1b765f 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;ZI)V + * Signature: (Ljava/lang/String;ZILjava/lang/String;)V */ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle - (JNIEnv *, jclass, jstring, jboolean, jint); + (JNIEnv *, jclass, jstring, jboolean, jint, jstring); #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 c5df1a9..f5d4126 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 @@ -16,7 +16,7 @@ * installed in /Library/Frameworks/. This Framework is * available at http://sparkle.andymatuschak.org/ * - * @author Romain Kuntz + * @author Romain Kuntz * @author Egidijus Jankauskas */ @@ -27,21 +27,21 @@ /* * Class: net_java_sip_communicator_impl_sparkle_SparkleActivator * Method: initSparkle - * Signature: (Ljava/lang/String;ZI)V + * Signature: (Ljava/lang/String;ZILjava/lang/String;)V */ JNIEXPORT void JNICALL Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle (JNIEnv *env, jclass obj, jstring pathToSparkleFramework, - jboolean updateAtStartup, jint checkInterval) + jboolean updateAtStartup, jint checkInterval, jstring downloadLink) { BOOL hasLaunchedBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"SCHasLaunchedBefore"]; - + if(!hasLaunchedBefore) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"SCHasLaunchedBefore"]; [[NSUserDefaults standardUserDefaults] synchronize]; } - + // The below code was used to avoid to link the Sparkle framework // at comilation time. //const char *path = (*env)->GetStringUTFChars(env, pathToSparkleFramework, 0); @@ -49,9 +49,21 @@ Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle //Class suUpdaterClass = [bundle classNamed:@"SUUpdater"]; //id suUpdater = [[suUpdaterClass alloc] init]; //(*env)->ReleaseStringUTFChars(env, pathToSparkleFramework, path); - + SUUpdater *suUpdater = [SUUpdater updaterForBundle:[NSBundle mainBundle]]; - + + if(downloadLink) + { + const char* link = (*env)->GetStringUTFChars(env, downloadLink, 0); + NSString* sLink = [NSString stringWithCString: link length: strlen(link)]; + NSURL* nsLink = [NSURL URLWithString: sLink]; + + if(nsLink) + { + [suUpdater setFeedURL: nsLink]; + } + } + NSMenu* menu = [[NSApplication sharedApplication] mainMenu]; NSMenu* applicationMenu = [[menu itemAtIndex:0] submenu]; NSMenuItem* checkForUpdatesMenuItem = [[NSMenuItem alloc] @@ -61,7 +73,7 @@ Java_net_java_sip_communicator_impl_sparkle_SparkleActivator_initSparkle [checkForUpdatesMenuItem setEnabled:YES]; [checkForUpdatesMenuItem setTarget:suUpdater]; - + // 0 => top, 1 => after "About..." [applicationMenu insertItem:checkForUpdatesMenuItem atIndex:1]; diff --git a/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java b/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java index 8a98b5f..80477e3 100644 --- a/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java +++ b/src/net/java/sip/communicator/impl/sparkle/SparkleActivator.java @@ -7,6 +7,8 @@ package net.java.sip.communicator.impl.sparkle; import org.osgi.framework.*; + +import net.java.sip.communicator.service.configuration.*; import net.java.sip.communicator.util.*; /** @@ -23,16 +25,31 @@ public class SparkleActivator private static Logger logger = Logger.getLogger(SparkleActivator.class); /** + * A reference to the ConfigurationService implementation instance that + * is currently registered with the bundle context. + */ + private static ConfigurationService configurationService = null; + + /** + * The current BundleContext. + */ + private static BundleContext bundleContext = null; + + /** * Native method declaration * * @param pathToSparkleFramework the path to the Sparkle framerok * @param updateAtStartup specifies whether Sparkle should be checking for * updates on startup. * @param checkInterval specifies an interval for the update checks. + * @param downloadLink a custom download link for sparkle (i.e. the + * SUFeedURL). If null the default URL will be choosen (the + * SUFeedURL parameter in the .app/Contents/Info.pList). */ public native static void initSparkle(String pathToSparkleFramework, boolean updateAtStartup, - int checkInterval); + int checkInterval, + String downloadLink); /** * Whether updates are checked at startup @@ -51,6 +68,12 @@ public class SparkleActivator private static boolean sparkleLibLoaded = false; /** + * Property name for the update link in the configuration file. + */ + private static final String PROP_UPDATE_LINK = + "net.java.sip.communicator.UPDATE_LINK"; + + /** * Initialize and start Sparkle * * @param bundleContext BundleContext @@ -58,6 +81,8 @@ public class SparkleActivator */ public void start(BundleContext bundleContext) throws Exception { + this.bundleContext = bundleContext; + /** * Dynamically loads JNI object. Will fail if non-MacOSX * or when libinit_sparkle.dylib is outside of the LD_LIBRARY_PATH @@ -79,10 +104,14 @@ public class SparkleActivator return; } + String downloadLink = getConfigurationService().getString( + PROP_UPDATE_LINK); + + System.out.println("download link is: " + downloadLink); // TODO: better way to get the Sparkle Framework path? initSparkle(System.getProperty("user.dir") + "/../../Frameworks/Sparkle.framework", - updateAtStartup, checkInterval); + updateAtStartup, checkInterval, downloadLink); if (logger.isInfoEnabled()) logger.info("Sparkle Plugin ...[Started]"); } @@ -97,7 +126,28 @@ public class SparkleActivator */ public void stop(BundleContext bundleContext) throws Exception { + bundleContext = null; if (logger.isInfoEnabled()) logger.info("Sparkle Plugin ...[Stopped]"); } + + /** + * Returns a reference to a ConfigurationService implementation currently + * registered in the bundle context or null if no such implementation was + * found. + * + * @return a currently valid implementation of the ConfigurationService. + */ + public static ConfigurationService getConfigurationService() + { + if (configurationService == null) + { + ServiceReference confReference + = bundleContext.getServiceReference( + ConfigurationService.class.getName()); + configurationService + = (ConfigurationService)bundleContext.getService(confReference); + } + return configurationService; + } } diff --git a/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf b/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf index 2bfc04d..a905b84 100644 --- a/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf +++ b/src/net/java/sip/communicator/impl/sparkle/sparkle.manifest.mf @@ -5,4 +5,5 @@ Bundle-Vendor: sip-communicator.org Bundle-Version: 0.0.1 System-Bundle: yes Import-Package: org.osgi.framework, + net.java.sip.communicator.service.configuration, net.java.sip.communicator.util diff --git a/src/net/java/sip/communicator/plugin/updatechecker/Resources.java b/src/net/java/sip/communicator/plugin/updatechecker/Resources.java index 31db17b..f845bd1 100644 --- a/src/net/java/sip/communicator/plugin/updatechecker/Resources.java +++ b/src/net/java/sip/communicator/plugin/updatechecker/Resources.java @@ -39,7 +39,8 @@ public class Resources if (!configPropsFile.exists()) { if (logger.isInfoEnabled()) - logger.info("No config file specified for update checker. Disabling update checks"); + logger.info("No config file specified for update checker." + + " Disabling update checks"); return null; } diff --git a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java index 74b8fdc..1dc5128 100644 --- a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java +++ b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java @@ -72,6 +72,12 @@ public class UpdateCheckActivator private static final String UPDATECHECKER_ENABLED = "net.java.sip.communicator.plugin.updatechecker.ENABLED"; + /** + * Property name for the update link in the configuration file. + */ + private static final String PROP_UPDATE_LINK = + "net.java.sip.communicator.UPDATE_LINK"; + static { removeDownloadRestrictions(); @@ -237,7 +243,15 @@ public class UpdateCheckActivator net.java.sip.communicator.service.version.Version ver = verService.getCurrentVersion(); - String configString = Resources.getConfigString("update_link"); + String configString = null; + + configString = getConfigurationService().getString( + PROP_UPDATE_LINK); + + if(configString == null) + { + configString = Resources.getConfigString("update_link"); + } if(configString == null) { @@ -283,6 +297,8 @@ public class UpdateCheckActivator { final JDialog dialog = new SIPCommDialog() { + private static final long serialVersionUID = 0L; + protected void close(boolean isEscaped) { } @@ -695,9 +711,7 @@ public class UpdateCheckActivator { public void run() { - String osName = System.getProperty("os.name"); - - if (osName.startsWith("Windows")) + if (OSUtils.IS_WINDOWS) { // register update button Hashtable<String, String> toolsMenuFilter @@ -715,7 +729,7 @@ public class UpdateCheckActivator if(isNewestVersion()) return; - if (osName.startsWith("Windows")) + if (OSUtils.IS_WINDOWS) { windowsUpdaterShow(); return; @@ -723,6 +737,8 @@ public class UpdateCheckActivator final JDialog dialog = new SIPCommDialog() { + private static final long serialVersionUID = 0L; + protected void close(boolean isEscaped) { } |