diff -r 7cd75dde674b jar.mn --- a/jar.mn Tue May 24 16:39:51 2011 +0100 +++ b/jar.mn Wed Jul 20 23:24:28 2011 +0100 @@ -19,6 +19,7 @@ chatzilla.jar: % style chrome://global/content/customizeToolbar.xul chrome://chatzilla/skin/browserOverlay.css * content/chatzilla/contents.rdf (xul/content/contents.rdf) skin/modern/chatzilla/contents.rdf (xul/skin/contents.rdf) + content/chatzilla/xr/overlay.xul (xul/content/xr/overlay.xul) content/chatzilla/lib/js/utils.js (js/lib/utils.js) content/chatzilla/lib/js/events.js (js/lib/events.js) content/chatzilla/lib/js/connection-xpcom.js (js/lib/connection-xpcom.js) diff -r 7cd75dde674b locales/en-US/chrome/chatzilla.properties --- a/locales/en-US/chrome/chatzilla.properties Tue May 24 16:39:51 2011 +0100 +++ b/locales/en-US/chrome/chatzilla.properties Wed Jul 20 23:24:28 2011 +0100 @@ -115,6 +115,20 @@ msg.confirm = Confirm # ### End of notes ### +cmd.extension-manager.label = Extensions +cmd.extension-manager.help = +cmd.theme-manager.label = Themes +cmd.theme-manager.help = +cmd.add-ons.params = [] +cmd.add-ons.label = Add-ons +cmd.add-ons.help = +cmd.jsconsole.label = JavaScript Console +cmd.jsconsole.help = +cmd.about-config.label = Advanced Configuration +cmd.about-config.help = +cmd.update.label = Update... +cmd.update.help = + cmd.about.label = About ChatZilla cmd.about.help = Display information about this version of ChatZilla. @@ -946,7 +960,7 @@ msg.cmdmatch = Commands matchin msg.default.alias.help = This command is an alias for |%1$S|. msg.extra.params = Extra parameters ``%1$S'' ignored. msg.version.reply = ChatZilla %S [%S] -msg.source.reply = http://chatzilla.hacksrus.com/ +msg.source.reply = http://chatzilla.rdmsoft.com/xulrunner/ msg.nothing.to.cancel = No connection or /list in progress, nothing to cancel. msg.cancelling = Cancelling connection to ``%S''… msg.cancelling.list = Cancelling /list request… diff -r 7cd75dde674b xpi/makexpi.py --- a/xpi/makexpi.py Tue May 24 16:39:51 2011 +0100 +++ b/xpi/makexpi.py Wed Jul 20 23:24:28 2011 +0100 @@ -10,10 +10,13 @@ the original shell script import os import os.path import sys +import time import shutil import re import zipfile from os.path import join as joinpath +from subprocess import call, PIPE +from hashlib import sha1 # Set up settings and paths for finding files. pwd = os.path.dirname(__file__) @@ -81,6 +84,7 @@ def rm(path): except WindowsError, ex: if ex.errno != 2: raise + def mkdir(dir): """ acts like mkdir -p @@ -96,6 +100,13 @@ def copy(src, dst): """ shutil.copy(src, dst) +def copytree(src, dst): + """ + copy directory + """ + shutil.rmtree(dst) + shutil.copytree(src, dst) + def move(src, dst): """ move file @@ -111,6 +122,15 @@ def sed((pattern, replacement), input, o line = regex.sub(replacement, line) output.write(line) +def sha1_file(filename): + h = sha1() + with open(filename) as f: + while True: + d = f.read(65536) + if not d: break + h.update(d) + return h.hexdigest() + def zip(filename, source_dir, include=None, exclude=None): """ create a zip file of a directory's contents @@ -170,6 +190,7 @@ def version(fedir): fedir = getenv('FEDIR', joinpath(pwd, '..'), dir=True, check=True) xpifiles = getenv('XPIFILES', joinpath(pwd, 'resources'), dir=True, check=True) xpiroot = getenv('XPIROOT', joinpath(pwd, 'xpi-tree'), dir=True) +xrroot = getenv('XRROOT', joinpath(pwd, 'xr-tree'), dir=True) jarroot = getenv('JARROOT', joinpath(pwd, 'jar-tree'), dir=True) localedir = getenv('LOCALEDIR', joinpath(fedir, 'locales'), dir=True, check=True) locale = locale() @@ -181,11 +202,14 @@ else: version = version(fedir) xpiname = None +buildid = time.strftime("%Y%m%d%H") +theme_guid = '{972ce4c6-7e08-4474-a285-3208198ce6fd}' if debug > 0: print 'FEDIR = %s' % fedir print 'XPIFILES = %s' % xpifiles print 'XPIROOT = %s' % xpiroot + print 'XRROOT = %s' % xrroot print 'JARROOT = %s' % jarroot print 'LOCALEDIR = %s' % localedir print 'LOCALE = %s' % locale @@ -294,6 +318,15 @@ def progress_sed(infile, outfile, patter sed_infile.close() sed_outfile.close() +def sed_version_buildid(inpath, outpath): + echo('.') + infile = joinpath(*inpath) + tempfile = joinpath(*outpath) + ".tmp" + outfile = joinpath(*outpath) + sed(("@REVISION@", version), open(infile), open(tempfile, "w")) + sed(("@BUILDID@", buildid), open(tempfile), open(outfile, "w")) + rm(tempfile) + def progress_zip(indir, outfile): if debug > 1: print ' zip %s %s' % (indir, outfile) @@ -313,11 +346,14 @@ def do_clean(): rm(xpiroot) echo('.') rm(jarroot) + echo('.') + rm(xrroot) print('. done.') def do_build_base(): print 'Beginning build of ChatZilla %s...' % version - xpiname = check_xpiname('chatzilla-%s.xpi' % version) + basename = 'chatzilla-%s-%s' % (version, buildid) + xpiname = check_xpiname('%s.xpi' % basename) progress_echo(' Checking XPI structure') progress_mkdir(xpiroot) @@ -327,6 +363,16 @@ def do_build_base(): progress_mkdir(joinpath(xpiroot, 'components')) print ' done' + progress_echo(' Checking XULRunner structure') + progress_mkdir(xrroot) + progress_mkdir(joinpath(xrroot, 'chrome', 'branding')) + progress_mkdir(joinpath(xrroot, 'chrome', 'icons', 'default')) + progress_mkdir(joinpath(xrroot, 'components')) + progress_mkdir(joinpath(xrroot, 'defaults', 'preferences')) + progress_mkdir(joinpath(xrroot, 'extensions', theme_guid)) + progress_mkdir(joinpath(xrroot + '-mac', 'Contents', 'Resources')) + print ' done' + progress_echo(' Checking JAR structure') progress_mkdir(jarroot) print ' done' @@ -365,7 +411,86 @@ def do_build_base(): progress_chmod(joinpath(xpiroot, 'components', 'chatzilla-service.js'), 0664) progress_zip(xpiroot, joinpath(pwd, xpiname)) print ' done' - + + update_channel = getenv("UPDATE_CHANNEL", None) + progress_echo(' Creating XULRunner app') + progress_copy(joinpath(jarroot, 'chatzilla.jar'), joinpath(xrroot, 'chrome')) + progress_copy(joinpath(fedir, 'js', 'lib', 'chatzilla-service.js'), joinpath(xrroot, 'components')) + # TODO: manifest here? + progress_chmod(joinpath(xrroot, 'chrome', 'chatzilla.jar'), 0664) + progress_chmod(joinpath(xrroot, 'components', 'chatzilla-service.js'), 0664) + + sed_version_buildid((xpifiles, "chatzilla-prefs.xr.js"), (xrroot, "defaults", "preferences", "chatzilla-prefs.xr.js")) + if update_channel: + sed_version_buildid((xpifiles, "update-prefs.xr.js"), (xrroot, "defaults", "preferences", "update-prefs.xr.js")) + update_pref = "pref(\"app.update.channel\", \"%s\");" % update_channel + open(joinpath(xrroot, "defaults", "preferences", "channel-prefs.js"), "w").write(update_pref) + + sed_version_buildid((xpifiles, "themeinstall.rdf"), (xrroot, "extensions", theme_guid, "install.rdf")) + sed_version_buildid((xpifiles, "brand.dtd"), (xrroot, "chrome", "branding", "brand.dtd")) + sed_version_buildid((xpifiles, "brand.properties"), (xrroot, "chrome", "branding", "brand.properties")) + sed_version_buildid((xpifiles, "application.ini"), (xrroot, "application.ini")) + + progress_copy(joinpath(xpifiles, "chatzilla-window.ico"), joinpath(xrroot, "chrome", "icons", "default", "chatzilla-window.ico")) + progress_copy(joinpath(xpifiles, "chatzilla-window.xpm"), joinpath(xrroot, "chrome", "icons", "default", "chatzilla-window.xpm")) + progress_copy(joinpath(xpifiles, "chatzilla-window16.xpm"), joinpath(xrroot, "chrome", "icons", "default", "chatzilla-window16.xpm")) + progress_copy(joinpath(xpifiles, "chrome.xr.manifest"), joinpath(xrroot, "chrome", "chrome.manifest")) + + sed_version_buildid((xpifiles, "Info.plist"), (xrroot + "-mac", "Contents", "Info.plist")) + echo('.') + copytree(xrroot, joinpath(xrroot + "-mac", "Contents", "Resources")) + + print ' done' + + xrname = '%s-xr.zip' % basename + progress_echo(' Packaging XULRunner app') + progress_zip(xrroot, joinpath(pwd, xrname)) + + # Generally chatzilla.rdmsoft.com-specific stuff here. + if update_channel: + # TODO: update to latest tools and make this confgurable + upscripts = joinpath(pwd, "..", "..", "cz-xr.cvs", "mozilla", "tools", "update-packaging") + call([joinpath(upscripts, "make_full_update.sh"), "%s.mar" % basename, "xr-tree"], stdout = PIPE, stderr = PIPE) + echo('..') + call([joinpath(upscripts, "make_full_update.sh"), "%s.mac.mar" % basename, "xr-tree-mac"], stdout = PIPE, stderr = PIPE) + echo('..') +#TODO: port this bit (partials) + #~ if [ $FROM ]; then + #~ mkdir xr-tree-old + #~ cd xr-tree-old + #~ safeCommand $PERL $UPSCRIPTS/unwrap_full_update.pl ../$FROM + #~ echo -n .. + #~ FROM_ID=`grep BuildID application.ini | sed s/[^0-9]//g` + #~ cd .. + #~ safeCommand $UPSCRIPTS/make_incremental_update.sh $BASENAME.partial.mar xr-tree-old xr-tree + #~ echo -n . + #~ rm -rf xr-tree-old + #~ fi + with open("%s.txt" % basename, "w") as updata: + updata.write("version : %s\n" % version) + updata.write("buildid : %s\n" % buildid) + updata.write("zip-url : download/%s-xr.zip\n" % basename) + updata.write("zip-size : %d\n" % os.stat(xrname).st_size) + updata.write("mar-url : update/%s.mar\n" % basename) + updata.write("mar-size : %d\n" % os.stat("%s.mar" % basename).st_size) + updata.write("mar-sha1 : %s\n" % sha1_file("%s.mar" % basename)) + updata.write("mar-mac-url : update/%s.mac.mar\n" % basename) + updata.write("mar-mac-size : %d\n" % os.stat("%s.mac.mar" % basename).st_size) + updata.write("mar-mac-sha1 : %s\n" % sha1_file("%s.mac.mar" % basename)) + #~ if [ $FROM ]; then + #~ echo "partial-from : $FROM_ID" >> $UPDATA + #~ echo "partial-url : update/$BASENAME.partial.mar" >> $UPDATA + #~ echo "partial-size : "`stat --printf=%s $BASENAME.partial.mar` >> $UPDATA + #~ echo "partial-sha1 : "`sha1sum $BASENAME.partial.mar | head -c 40` >> $UPDATA + #~ fi + updata.write("channels : ") + echo('.') + else: + echo(' ') + #~ if [ -z $FROM ]; then echo -n " "; fi + + print ' done' + print 'Build of ChatZilla %s... ALL DONE' % version diff -r 7cd75dde674b xul/content/commands.js --- a/xul/content/commands.js Tue May 24 16:39:51 2011 +0100 +++ b/xul/content/commands.js Wed Jul 20 23:24:28 2011 +0100 @@ -257,6 +257,13 @@ function initCommands() ["statusbar", "toggle-ui status", CMD_CONSOLE], ["header", "toggle-ui header", CMD_CONSOLE], + ["extension-manager", "add-ons extensions", 0], + ["theme-manager", "add-ons themes", 0], + ["add-ons", cmdAddons, 0], + ["jsconsole", cmdJSConsole, 0], + ["about-config", cmdAboutConfig, 0], + ["update", cmdUpdate, 0], + // text-direction aliases ["rtl", "text-direction rtl", CMD_CONSOLE], ["ltr", "text-direction ltr", CMD_CONSOLE], @@ -4639,3 +4646,59 @@ function cmdURLs(e) client.urlLogger = logger; } } + +function cmdAddons(e) +{ + var winType = "Extension:Manager"; + var url = "chrome://mozapps/content/extensions/extensions.xul" + + if(!e.type && !client.hostCompat.addonManager) + e.type = "extensions"; + + if (e.type) + { + winType += "-" + e.type; + url += "?type=" + e.type; + } + + toOpenWindowByType(winType, url); +} + +function toOpenWindowByType(inType, url, features) +{ + var wm = getService("@mozilla.org/appshell/window-mediator;1", + "nsIWindowMediator"); + var topWindow = wm.getMostRecentWindow(inType); + + if(typeof features == "undefined") + features = "chrome,extrachrome,menubar,resizable," + + "scrollbars,status,toolbar"; + + if (topWindow) + topWindow.focus(); + else + window.open(url, "_blank", features); +} + +function cmdJSConsole(e) +{ + toOpenWindowByType("global:console", "chrome://global/content/console.xul"); +} + +function cmdAboutConfig(e) +{ + openDialog("chrome://global/content/config.xul"); +} + +function cmdUpdate(e) +{ + var um = getService("@mozilla.org/updates/update-manager;1", + "nsIUpdateManager"); + var prompter = newObject("@mozilla.org/updates/update-prompt;1", + "nsIUpdatePrompt"); + + if (um.activeUpdate && um.activeUpdate.state == "pending") + prompter.showUpdateDownloaded(um.activeUpdate); + else + prompter.checkForUpdates(); +} diff -r 7cd75dde674b xul/content/menus.js --- a/xul/content/menus.js Tue May 24 16:39:51 2011 +0100 +++ b/xul/content/menus.js Wed Jul 20 23:24:28 2011 +0100 @@ -135,6 +135,8 @@ function initMenus() var NetConnected = "(cx.network and cx.network.isConnected())"; var NetDisconnected = "(cx.network and !cx.network.isConnected())"; + var addons = "client.hostCompat.addonManager"; + client.menuSpecs["mainmenu:chatzilla"] = { label: MSG_MNU_CHATZILLA, accesskey: getAccessKeyForMenu('MSG_MNU_CHATZILLA'), @@ -147,6 +149,12 @@ function initMenus() ["-"], ["print"], ["save"], + ["-", {visibleif: XULRunner}], + ["extension-manager", {visibleif: XULRunner + " && !" + addons}], + ["theme-manager", {visibleif: XULRunner + " && !" + addons}], + ["add-ons", {visibleif: XULRunner + " && " + addons}], + ["jsconsole", {visibleif: XULRunner}], + ["about-config", {visibleif: XULRunner}], ["-", {visibleif: NotMac}], ["exit", {visibleif: Win}], ["quit", {visibleif: NotMac + " and " + NotWin}] diff -r 7cd75dde674b xul/content/static.js --- a/xul/content/static.js Tue May 24 16:39:51 2011 +0100 +++ b/xul/content/static.js Wed Jul 20 23:24:28 2011 +0100 @@ -43,7 +43,7 @@ const __cz_version = "0.9.87"; const __cz_condition = "green"; -const __cz_suffix = ""; +const __cz_suffix = "rdmsoft"; const __cz_guid = "59c81df5-4b7a-477b-912d-4e0fdf64e5f2"; const __cz_locale = "0.9.87"; @@ -526,6 +526,8 @@ function initApplicationCompatibility() case "{" + __cz_guid + "}": // We ARE the app, in other words, we're running in XULRunner. client.host = "XULRunner"; + client.hostCompat.addonManager = + (compareVersions(app.platformVersion, "1.8.1") <= 0); break; case "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": // SeaMonkey client.host = "Mozilla"; @@ -588,6 +590,31 @@ function initApplicationCompatibility() function initIcons() { + // This is a hack to make the theme manager work. + // XULRunner 1.8 doesn't read extensions from the app directory, + // so copy the default theme install.rdf to the profile. + if (client.host == "XULRunner") + { + try + { + const defaultThemeId = "{972ce4c6-7e08-4474-a285-3208198ce6fd}"; + var themeSrc = getSpecialDirectory("resource:app"); + var themeDest = getSpecialDirectory("ProfD"); + themeSrc.append("extensions"); themeDest.append("extensions"); + themeSrc.append(defaultThemeId); themeDest.append(defaultThemeId); + if (!themeDest.exists()) + mkdir(themeDest); + + themeSrc.append("install.rdf"); themeDest.append("install.rdf"); + if (!themeDest.exists()) + themeSrc.copyTo(themeDest.parent, "install.rdf") + } + catch(ex) + { + dd("failed to copy default theme"); + } + } + // Make sure we got the ChatZilla icon(s) in place first. const iconName = "chatzilla-window"; const suffixes = [".ico", ".xpm", "16.xpm"];