Skip to content

Commit

Permalink
Show release notes at first run after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
tipichris committed Dec 21, 2011
1 parent 54ecfe2 commit ca49717
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
37 changes: 37 additions & 0 deletions content/overlay.js
Expand Up @@ -56,6 +56,43 @@ var tbdialout = {
if (!passmigrated) {
tbdialoututils.migratePass();
}

// If TBDialOut has been upgraded since the last time we showed upgrade notes,
// show the notes for the current version.
var updateshown = this.prefs.getCharPref("updateshown");
var showupdatenotes = this.prefs.getBoolPref("showupdatenotes");
// a false default should override user prefs, as there probably
// are no notes to display
if (showupdatenotes && this.prefs.prefHasUserValue("showupdatenotes")) {
showupdatenotes = false;
}

try {
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("tbdialout@oak-wood.co.uk", function(addon) {
// This is an asynchronous callback function that might not be called immediately
if (showupdatenotes && addon.version != updateshown) {
window.setTimeout(function() {
tbdialoututils.openInTab("http://www.oak-wood.co.uk/oss/tbdialout/updates/" + addon.version.replace(/\./g,'-'), "^http://www.oak-wood.co.uk", false);},
500);
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.tbdialout.");
prefs.setCharPref("updateshown", addon.version);
}
});
}
catch (ex) {
// pre Thunderbird 3.3
var em = Components.classes["@mozilla.org/extensions/manager;1"]
.getService(Components.interfaces.nsIExtensionManager);
var addon = em.getItemForID("tbdialout@oak-wood.co.uk");
if (showupdatenotes && addon.version != updateshown) {
window.setTimeout(function() {
tbdialoututils.openInTab("http://www.oak-wood.co.uk/oss/tbdialout/updates/" + addon.version.replace(/\./g,'-'), "^http://www.oak-wood.co.uk", false);},
500);
this.prefs.setCharPref("updateshown", addon.version);
}
}

},

// Check whether or not there are phone numbers for the selected
Expand Down
17 changes: 11 additions & 6 deletions content/utils.js
Expand Up @@ -85,7 +85,9 @@ var tbdialoututils = {

// clickmask is a string representation of a regular expression defining URLs which
// may be clicked through to within the tab.
openInTab: function (url, clickmask) {
openInTab: function (url, clickmask, setfocus) {
setfocus = typeof(setfocus) != 'undefined' ? setfocus : true;

// try to open the page in a new tab with Thunderbird
var tabmail = document.getElementById("tabmail");
if (!tabmail) {
Expand All @@ -95,7 +97,9 @@ var tbdialoututils = {
.getMostRecentWindow("mail:3pane");
if (mail3PaneWindow) {
tabmail = mail3PaneWindow.document.getElementById("tabmail");
mail3PaneWindow.focus();
if (setfocus) {
mail3PaneWindow.focus();
}
}
}
// allow user to click within the sites defined by the regexp mask
Expand All @@ -116,16 +120,17 @@ var tbdialoututils = {
var passtypes = ["custompass", "ami.secret"];
var idx;
var pass;
try {
for (idx in passtypes) {
for (idx in passtypes) {
try {
pass = this.prefs.getCharPref( passtypes[idx] );
if (pass.length > 0) {
this.setPass(passtypes[idx], pass);
}
this.prefs.clearUserPref(passtypes[idx]);
}
} catch (err) {
tbdialoututils.logger(1, "Error migrating passwords: " + err.message);
catch (err) {
tbdialoututils.logger(1, "Error migrating password " + passtypes[idx] + ": " + err.message);
}
}
this.prefs.setBoolPref("passmigrated", true);
},
Expand Down
2 changes: 2 additions & 0 deletions defaults/preferences/tbdialout.js
Expand Up @@ -7,6 +7,8 @@ pref( "extensions.tbdialout.customuser", "" );
pref( "extensions.tbdialout.custominbackground", true );
pref( "extensions.tbdialout.loglevel", 2);
pref( "extensions.tbdialout.passmigrated", false );
pref( "extensions.tbdialout.updateshown", "" );
pref( "extensions.tbdialout.showupdatenotes", true);
pref( "extensions.tbdialout.ami.channel", "" );
pref( "extensions.tbdialout.ami.context", "default" );
pref( "extensions.tbdialout.ami.host", "" );
Expand Down

0 comments on commit ca49717

Please sign in to comment.