home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <?xml-stylesheet href="chrome://aim/skin/aimTasksOverlay.css" type="text/css"?>
-
- <!DOCTYPE overlay SYSTEM "chrome://aim/locale/AimTaskMenu.dtd" >
-
- <overlay id="aimTaskMenuID"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <script language="JavaScript" src="chrome://aim/content/aimHelpers.js" />
- <script language="JavaScript" src="chrome://aim/content/AimSession.js" />
- <script language="JavaScript" src="chrome://aim/content/Aim.js" />
-
-
- <keyset id="tasksKeys">
- <key id="key_im" key="&IMCmd.commandkey;" command="Tasks:IM" modifiers="accel"/>
- </keyset>
-
-
- <commandset id="tasksCommands">
- <command id="Tasks:IM" oncommand="toOpenWindowByType('Aim:AimApp', 'chrome://aim/content/App.xul');"/>
- </commandset>
-
-
- <menupopup id="taskPopup">
- <menuseparator id="sep_switchprofile" hidden="true"/>
- <menuitem id="cmd_switchprofile" hidden="true"/>
- </menupopup>
-
- <!-- MERC: SL Feb 26 - disable IM menu option in window
- <menupopup id="windowPopup">
- <menuitem id="IMMenuItem" insertafter="tasksMenuMail, tasksMenuNavigator" label="&IMCmd.label;" accesskey="&IMCmd.accesskey;" key="key_im" command="Tasks:IM" class="menuitem-iconic icon-aim16"/>
- </menupopup>
- -->
- <statusbarpanel id="component-bar">
- <toolbarbutton class="taskbutton" id="mini-aim" insertbefore="mini-comp"
- tooltip="aTooltip" tooltiptext="&IMCmd.tooltip;"
- oncommand="toOpenWindowByType('Aim:AimApp', 'chrome://aim/content/App.xul');"/>
- </statusbarpanel >
-
- <script type="application/x-javascript">
- <![CDATA[
-
- /*
- * Name: checkAimAutoLogin()
- * Arguments: none
- * Description:
- * This function is called everytime a component window( like nav, mail etc.) who can invoke an IM window
- * from their New menu is loaded. The purpose of this function is to autologin to aim if autologin preference is set.
- * There is a global pref - appfirstlogin which is true if the user is launching the app and
- * user has not signed to aim yet. If it is true, then the DoLogin function is called. The timeout is to take care
- * of the delay in loading sidebar buddylist panel.
- */
-
- function checkAimAutoLogin()
- {
- var first= aimPrefsManager().GetBoolPref("aim.session.appfirstlogin", null,true);
- /* If user had already chosen to signoff in some sidebar after the app is launched */
- if (first == false )
- return;
- setTimeout("DoLogin()", 1000);
- }
-
- /*
- * Name: DoLogin()
- * Arguments: none
- * Description:
- * This function checks to see if aim sidebar panel is clicked or loaded on top in which case,
- * this just returns (since sidebar aim panel can take care of this scenario)
- * It checks to see if all the necessary data for autologin is present,
- * If and only if all data is present, then the user is signed onto aim service.
- * (This scenario happens when the aim sidebar panel is collapsed but the user had used aim before and set up
- * the autologin pref to be true and has never login to aim this time of launch.)
- * Return Value: none
- */
-
- function DoLogin()
- {
- dump ("---+ AimTaskMenu.xul - DoLogin() document is " + document + "\n");
-
- // var panelset=document.getElementById("sidebar-box"); //was sidebar-panels but works with sidebar-box?
- var panelset=document.getElementById("sidebar-box"); // id = numberchatting
-
- //dump ("---+ panelset is " + panelset + "\n");
-
- // dump ("---+ document is " + top.parent.document.getAttribute('id') + "\n");
- // dump ("---+ document is " + top.document.nodeName + "\n"); // = #document
- // dump ("---+ " + parent.document.firstChild.nodeName + "\n"); // = window
-
- for (var i=0; i<panelset.childNodes.length-1; i+=2) {
- var panel=panelset.childNodes.item(i);
- dump ("---+ item is " + panel.getAttribute('id') + "\n");
- if (panel.getAttribute('id') == "urn:sidebar:panel:im-panel"){
- if (panel.getAttribute('selected')) {
- dump ("---+ panel is selected-- HOORAY!!\n");
- //already as top selected panel in sidebar - sidebar window load will do the rest-just return
- return;
- }
- }
- }
- var pIAimManager=Components.classes['@netscape.com/aim/IMManager;1'].getService(Components.interfaces.nsIIMManager);
- var pIAimSession = pIAimManager.QueryInterface(Components.interfaces.nsIAimSession);
-
- //user already logged in - just return
- var isOnline = pIAimSession.IsOnline();
- if ( isOnline == true )
- return;
-
- var autoLogin = aimPrefsManager().GetBoolPref("aim.session.autologin", null, false);
- if (!autoLogin)
- return;
-
- var screenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
- if (!screenName || screenName == '')
- return;
-
- var connectionName = aimPrefsManager().GetCharPref("aim.session.connectionname", null, false);
- if (!connectionName || connectionName == '')
- return;
-
- dump("DoLogin connectionName=" + connectionName);
-
- if (!IsServiceCorrect(screenName, connectionName)) {
- return;
- }
-
- if(pIAimSession)
- {
- var password = pIAimSession.GetSavedPassword(screenName);
- if (!password || password == '')
- return;
-
- setConnectionInfo (connectionName, "im");
-
- pIAimSession.Login(screenName, password, getsidebarframe());
-
- return;
- }
- }
-
- var instaimTaskObserver = null;
-
- function aimTaskObserver()
- {
- }
-
- aimTaskObserver.prototype.observe = function(subject, message, data) {
- if (message == 'sessionState-changed') {
- UpdateTaskImage(data);
- }
- if (message == 'sessionMode-changed') {
- ChangeTaskImage(data);
- }
- if (message == 'quit-application') {
- aimPrefsManager().SetBoolPref("aim.session.appfirstlogin",true,null, true);
- }
- }
-
- /*
- * Name: UpdateTaskImage(stateMsg)
- * Arguments: stateMsg - obtained passed from the observe code above. This contains the state information
- * Description: This function will change the task bar aim icon online-state attribute based on the input stateMsg. The css rules
- * will then take into effect and up[date the icon appropriately.
- * Author: Prassanna prass@netscape.com
- */
- function UpdateTaskImage(stateMsg)
- {
- var taskIcon= window.document.getElementById("mini-aim");
- switch (stateMsg) {
- case "Offline": taskIcon.setAttribute("online-state", "offline"); break;
- case "Online": taskIcon.setAttribute("online-state", "online"); break;
- case "OnlineAway": taskIcon.setAttribute("online-state", "away"); break;
- default: taskIcon.setAttribute("online-state", "offline");
- }
- }
-
-
-
- function ChangeTaskImage(Msg)
- {
- var taskIcon= window.document.getElementById("mini-aim");
- var windowIcon = window.document.getElementById("IMMenuItem");
- var ptIcon= window.document.getElementById("AimPT-button");
- if (taskIcon && windowIcon)
- {
- switch (Msg) {
- case "Aim": taskIcon.setAttribute("sessionMode", "Aim");
- windowIcon.setAttribute("class","menuitem-iconic icon-aim16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Aim");
- ptIcon.setAttribute("label","AIM");
- }
- break;
- case "Icq": taskIcon.setAttribute("sessionMode", "Icq");
- windowIcon.setAttribute("class","menuitem-iconic icon-icq16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Icq");
- ptIcon.setAttribute("label","ICQ");
- }
- break;
- default: var SessionType= getCurrentSessionType();
- if (SessionType == "ICQ")
- {
- taskIcon.setAttribute("sessionMode", "Icq");
- windowIcon.setAttribute("class","menuitem-iconic icon-icq16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Icq");
- ptIcon.setAttribute("label","ICQ");
- }
- }
- else
- {
- taskIcon.setAttribute("sessionMode", "Aim");
- windowIcon.setAttribute("class","menuitem-iconic icon-aim16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Aim");
- ptIcon.setAttribute("label","AIM");
- }
- }
- break;
- }
- }
- }
- /*
- * Name: initializeTaskIcon()
- * Arguments: none
- * This function is called a new window is loaded. This will initialize the aim task bar icon with the aimsession's current State
- * when the current window is loading.
- * Author: Prassanna prass@netscape.com
- */
- function initializeTaskIcon()
- {
- var pIAimManager=Components.classes['@netscape.com/aim/IMManager;1'].getService(Components.interfaces.nsIIMManager);
- var pIAimSession = pIAimManager.QueryInterface(Components.interfaces.nsIAimSession);
- var pState = eval(pIAimSession.CurrentState);
- var taskIcon = window.document.getElementById("mini-aim");
- var windowIcon = window.document.getElementById("IMMenuItem");
- var ptIcon= window.document.getElementById("AimPT-button");
- if (taskIcon && windowIcon) {
- var SessionType= getCurrentSessionType();
- if (SessionType == "ICQ")
- {
- taskIcon.setAttribute("sessionMode", "Icq");
- windowIcon.setAttribute("class","menuitem-iconic icon-icq16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Icq");
- ptIcon.setAttribute("label","ICQ");
- }
- }
- else
- {
- taskIcon.setAttribute("sessionMode", "Aim");
- windowIcon.setAttribute("class","menuitem-iconic icon-aim16");
- if (ptIcon) {
- ptIcon.setAttribute("sessionMode","Aim");
- ptIcon.setAttribute("label","AIM");
- }
- }
- switch (pState) {
- case 1: taskIcon.setAttribute("online-state", "offline"); break;
- case 8: taskIcon.setAttribute("online-state", "online"); break;
- case 9: taskIcon.setAttribute("online-state", "away"); break;
- default: taskIcon.setAttribute("online-state", "offline");
- }
- }
- }
-
- function Init()
- {
- var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
- observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
- if (observerService) {
- instaimTaskObserver = new aimTaskObserver();
- }
- if (observerService && instaimTaskObserver) {
- observerService.addObserver(instaimTaskObserver, "quit-application", false);
- observerService.addObserver(instaimTaskObserver,"sessionState-changed", false);
- observerService.addObserver(instaimTaskObserver,"sessionMode-changed", false);
- } else {
- instaimTaskObserver=null;
- dump("failed to get observer service\n");
- }
- // if there is a sidebar, check for aim auto login
- if (document.getElementById('sidebar-box'))
- checkAimAutoLogin();
-
- // initialize the aim task icon to the current icon state
- initializeTaskIcon();
-
- // Remove the observers during unload
- window.addEventListener("unload", Uninit, false);
- }
-
-
- function Uninit()
- {
- var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
- observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
- if (observerService && instaimTaskObserver)
- {
-
- observerService.removeObserver(instaimTaskObserver, "quit-application");
- observerService.removeObserver(instaimTaskObserver,"sessionState-changed");
- observerService.removeObserver(instaimTaskObserver,"sessionMode-changed");
- //instaimTaskObserver=null;
- }
- }
-
- window.addEventListener("load", Init, false);
- ]]>
- </script>
-
- </overlay>
-