document.getElementById('offline_import_btn').disabled = true;
}
+ // Attempt auto-login, if provided
+ if("arguments" in window && window.arguments.length > 0 && window.arguments[0].wrappedJSObject != undefined && window.arguments[0].wrappedJSObject.loginInfo != undefined) {
+ auto_login(window.arguments[0].wrappedJSObject.loginInfo);
+ // Regardless of success, clear that variable now, so we don't possibly have passwords hanging around.
+ window.arguments[0].wrappedJSObject.loginInfo = null;
+ }
+
} catch(E) {
var error = offlineStrings.getFormattedString('common.exception', [E, '']);
try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
}
}
+function auto_login(loginInfo) {
+ if(G.data.session) return; // We are logged in. No auto-logoff supported.
+ if(loginInfo.host) G.auth.controller.view.server_prompt.value = loginInfo.host;
+ if(loginInfo.user) G.auth.controller.view.name_prompt.value = loginInfo.user;
+ if(loginInfo.passwd) G.auth.controller.view.password_prompt.value = loginInfo.passwd;
+ if(loginInfo.host && loginInfo.user && loginInfo.passwd && G.data.ws_info && G.data.ws_info[loginInfo.host]) {
+ G.auth.login();
+ }
+}
+
dump('exiting main/main.js\n');
* @param aChromeURISpec a string specifying the URI of the window to open.\r
* @param aArgument an argument to pass to the window (may be null)\r
*/\r
-function findOrOpenWindow(aWindowType, aChromeURISpec, aName, aArgument)\r
+function findOrOpenWindow(aWindowType, aChromeURISpec, aName, aArgument, aLoginInfo)\r
{\r
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].\r
getService(Components.interfaces.nsIWindowMediator);\r
var targetWindow = wm.getMostRecentWindow(aWindowType);\r
if (targetWindow != null) {\r
- if(typeof targetWindow.new_tabs == 'function' && aArgument != null)\r
- {\r
+ var noFocus = false;\r
+ if(typeof targetWindow.new_tabs == 'function' && aArgument != null) {\r
targetWindow.new_tabs(aArgument);\r
+ noFocus = true;\r
}\r
- else {\r
+ if(typeof targetWindow.auto_login == 'function' && aLoginInfo != null) {\r
+ targetWindow.auto_login(aLoginInfo);\r
+ noFocus = true;\r
+ }\r
+ if(!noFocus) {\r
targetwindow.focus;\r
}\r
}\r
else {\r
var params = null;\r
- if (aArgument != null && aArgument.length != 0)\r
+ if (aArgument != null && aArgument.length != 0 || aLoginInfo != null)\r
{\r
- params = { "openTabs" : aArgument };\r
+ params = { "openTabs" : aArgument, "loginInfo" : aLoginInfo };\r
params.wrappedJSObject = params;\r
}\r
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].\r
};\r
\r
var inParams = new Array();\r
+ var loginInfo = {};\r
+ var loginInfoProvided = false;\r
var position = 0;\r
while (position < cmdLine.length) {\r
var arg = cmdLine.getArgument(position).toLowerCase();\r
cmdLine.removeArguments(position, position + 1);\r
continue;\r
}\r
+ if (arg == '-ilshost' && cmdLine.length > position) {\r
+ loginInfo.host = cmdLine.getArgument(position + 1);\r
+ cmdLine.removeArguments(position, position + 1);\r
+ loginInfoProvided = true;\r
+ continue;\r
+ }\r
+ if (arg == '-ilsuser' && cmdLine.length > position) {\r
+ loginInfo.user = cmdLine.getArgument(position + 1);\r
+ cmdLine.removeArguments(position, position + 1);\r
+ loginInfoProvided = true;\r
+ continue;\r
+ }\r
+ if (arg == '-ilspassword' && cmdLine.length > position) {\r
+ loginInfo.passwd = cmdLine.getArgument(position + 1);\r
+ cmdLine.removeArguments(position, position + 1);\r
+ loginInfoProvided = true;\r
+ continue;\r
+ }\r
position=position + 1;\r
}\r
\r
- if (cmdLine.handleFlag("ILSlogin", false) || inParams.length > 0) {\r
- findOrOpenWindow(WINDOW_MAIN, XUL_MAIN, '_blank', inParams);\r
+ if (cmdLine.handleFlag("ILSlogin", false) || inParams.length > 0 || loginInfoProvided) {\r
+ findOrOpenWindow(WINDOW_MAIN, XUL_MAIN, '_blank', inParams, loginInfoProvided ? loginInfo : null);\r
cmdLine.preventDefault = true;\r
}\r
\r
if (cmdLine.handleFlag("ILSoffline", false) || cmdLine.handleFlag("ILSstandalone", false)) {\r
- findOrOpenWindow(WINDOW_STANDALONE, XUL_STANDALONE, 'Offline', null);\r
+ findOrOpenWindow(WINDOW_STANDALONE, XUL_STANDALONE, 'Offline', null, null);\r
cmdLine.preventDefault = true;\r
}\r
},\r
" with a 'default' tab\n" +\r
" -ILStab Open a 'default' tab alone\n" +\r
" -ILSurl <url> Open the specified url in an Evergreen tab\n" +\r
- " The above six imply -ILSlogin\n" +\r
+ " -ILShost Default hostname for login\n" +\r
+ " -ILSuser Default username for login\n" +\r
+ " -ILSpassword Default password for login\n" +\r
+ " The above three, if all specified, trigger an automatic login attempt\n" +\r
+ " The above nine imply -ILSlogin\n" +\r
" -ILSlogin Open the Evergreen Login window\n" +\r
" -ILSstandalone Open the Evergreen Standalone interface\n" +\r
" -ILSoffline Alias for -ILSstandalone\n",\r