From ec81cdfe12332c66f6ed0e57af7570e7a8e47895 Mon Sep 17 00:00:00 2001 From: "mozilla%kewis.ch" Date: Mon, 3 Dec 2007 14:54:03 +0000 Subject: [PATCH] Fix bug 406569 - GData loader fails for lightning. r=dbo git-svn-id: svn://10.0.0.236/trunk@240309 18797224-902f-48f8-a5cc-f745e15eee43 --- .../components/calGoogleCalendarModule.js | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/mozilla/calendar/providers/gdata/components/calGoogleCalendarModule.js b/mozilla/calendar/providers/gdata/components/calGoogleCalendarModule.js index 4a7ff8cbe9d..fa6691d09da 100644 --- a/mozilla/calendar/providers/gdata/components/calGoogleCalendarModule.js +++ b/mozilla/calendar/providers/gdata/components/calGoogleCalendarModule.js @@ -87,19 +87,38 @@ var calGoogleCalendarModule = { if (this.mUtilsLoaded) return; + const kSUNBIRD_UID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}"; + const kLIGHTNING_UID = "{e2fda1a4-762b-4020-b5ad-a41df1933103}"; const scripts = ["calGoogleCalendar.js", "calGoogleSession.js", "calGoogleRequest.js", "calGoogleUtils.js"]; const baseScripts = ["calUtils.js", "calProviderBase.js"]; // First, load script from the application dir - var dirsvc = Components.classes["@mozilla.org/file/directory_service;1"] - .getService(Components.interfaces.nsIProperties); - try { - var appdir = dirsvc.get("GreD", Components.interfaces.nsIFile); - appdir.append("js"); - } catch (e) { - Components.utils.reportError("Error getting GRE Application Directory"); - throw(e); + var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]. + getService(Components.interfaces.nsIXULAppInfo); + if (appInfo.id == kSUNBIRD_UID) { + // On sunbird, the application dir is the GRE Application Directory + var dirsvc = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties); + try { + var appdir = dirsvc.get("GreD", Components.interfaces.nsIFile); + appdir.append("js"); + } catch (e) { + Components.utils.reportError("Error getting GRE Application Directory"); + throw(e); + } + } else { + // Otherwise, the application directory is the lightning extension directory + var extman = Components.classes["@mozilla.org/extensions/manager;1"] + .getService(Components.interfaces.nsIExtensionManager); + try { + var appdir = extman.getInstallLocation(kLIGHTNING_UID) + .getItemLocation(kLIGHTNING_UID); + appdir.append("js"); + } catch (e) { + Components.utils.reportError("Error getting Lightning Extension Directory"); + throw(e); + } } for each (var script in baseScripts) {