Skip to content

Commit

Permalink
IHG 1.7.0 Release Candidate 3
Browse files Browse the repository at this point in the history
On IHG update, the default 'hostf.xml' is now empty and comes with lastModifiedTime stamp set to zero.
This initiates an update from the online server if 'host file automatic update' is set 'true'.

Jörn Reppenhagen and Ricardo A. Rivas are credited for their translation contribution.

Signed-off-by: Rookie <Rookie@gmail.com>
  • Loading branch information
Rookie authored and Rookie committed Jun 3, 2017
1 parent cf3056e commit 92624c5
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 8,194 deletions.
1 change: 1 addition & 0 deletions chrome/content/imagegrabber/imagegrabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ihg_Functions.hostGrabber = function hostGrabber(docLinks, filterImages) {
ihg_Functions.LOG("In hostGrabber, call to function initVars failed for some reason.\n");
return;
}
if (ihg_Globals.hostfAutoUpdate && filterImages) ihg_Functions.autoUpdate();

try {
if (content.document.documentElement.outerHTML &&
Expand Down
27 changes: 27 additions & 0 deletions chrome/content/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function ihg_initOverlay() {
ihg_Globals.addonPath = addon.getResourceURI("").QueryInterface(Components.interfaces.nsIFileURL).file.path;
ihgDefaultBranch.setCharPref("addonPath", ihg_Globals.addonPath);
ihgDefaultBranch.lockPref("addonPath");
ihgDefaultBranch.setCharPref("addonVersionCurrent", addon.version);
ihgDefaultBranch.lockPref("addonVersionCurrent");
CheckUpdate();
}
AddonManager.getAddonByID(id, tempFunc);
}
Expand All @@ -34,6 +37,10 @@ function ihg_initOverlay() {
ihg_Globals.addonPath = nsLocFile.path;
ihgDefaultBranch.setCharPref("addonPath", ihg_Globals.addonPath);
ihgDefaultBranch.lockPref("addonPath");
let version = ExtensionManager.getItemForID(id).version;
ihgDefaultBranch.setCharPref("addonVersionCurrent", version);
ihgDefaultBranch.lockPref("addonVersionCurrent");
CheckUpdate();
}

ihgDefaultBranch.setCharPref("enable@startup", stringify({enableConLog: ihg_Globals.conLogOut, enableDebug: ihg_Globals.debugOut}));
Expand Down Expand Up @@ -73,6 +80,26 @@ function ihgConsoleWindow_onloaded()
ihg_Globals.Console = ihg_Globals.ConsoleWin.Accessor;
}

function CheckUpdate() {
var versionComparator = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);

var ihgBranch = ihg_Globals.prefManager.getBranch("extensions.imagegrabber.");

let Prev = ihgBranch.getCharPref("addonVersionPrevious");
let Curr = ihgBranch.getCharPref("addonVersionCurrent");

if (versionComparator.compare(Curr, Prev) > 0) {
var default_hostFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
default_hostFile.initWithPath(ihg_Globals.addonPath);
default_hostFile.append("hostf.xml");
if (default_hostFile.exists()) {
default_hostFile.lastModifiedTime = 0;
ihgBranch.setCharPref("addonVersionPrevious", Curr);
}
}
}

function ihg_toolbarButtonCommand(event) {
if (event.target.id == "imagehostgrabber-toolbarbutton")
ihg_Functions.hostGrabber(null, false);
Expand Down
1 change: 1 addition & 0 deletions defaults/preferences/imagegrabber.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pref("extensions.imagegrabber.addonVersionPrevious", "");
pref("extensions.imagegrabber.autorename", true);
pref("extensions.imagegrabber.fileexistsbehavior", "rename");
pref("extensions.imagegrabber.killmenow", false);
Expand Down

0 comments on commit 92624c5

Please sign in to comment.