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/App.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');"/>
- <broadcaster id="IM:TaskIcon" online-state="offline"/>
- </commandset>
-
-
- <menupopup id="taskPopup">
- <menuitem id="IMMenuItem" position="2" label="&IMCmd.label;" accesskey="&IMCmd.accesskey;" key="key_im" command="Tasks:IM" />
- </menupopup>
-
- <box id="component-bar">
- <button class="button-toolbar-4 taskbutton" id="mini-aim" position="2"
- tooltip="aTooltip" tooltiptext="&IMCmd.tooltip;"
- oncommand="toOpenWindowByType('Aim:AimApp', 'chrome://aim/content/App.xul');">
- <observes element="IM:TaskIcon" attribute="online-state"/>
- </button>
- </box>
-
- <script type="application/x-javascript">
- <![CDATA[
- var RDF = null;
- function GetRDFService()
- {
- if ( RDF == null ) {
- var RDFClass = Components.classes['@mozilla.org/rdf/rdf-service;1'];
- RDF = RDFClass.getService(Components.interfaces.nsIRDFService);
- }
- }
-
- var AimIconObserver = new Object();
-
- AimIconObserver.onAssert = function(datasource, source, property, target) {
- if (source.EqualsNode(aimRDFSession())) {
- if (property.EqualsNode(aimRDFSessionState())) {
- try {
- var state = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
- var taskIconObserver = window.document.getElementById("IM:TaskIcon");
- if (state == "Offline") {
- taskIconObserver.setAttribute("online-state", "offline");
- }
- else if (state == "Online") {
- taskIconObserver.setAttribute("online-state", "online");
- }
- else if (state == "OnlineAway") {
- taskIconObserver.setAttribute("online-state", "away");
- }
- else {
- taskIconObserver.setAttribute("online-state", "offline");
- }
- }
- catch (ex)
- {
- //dump("\n cannot find aim task icon yet");
- }
- }
- }
- }
-
- AimIconObserver.onUnassert = function(datasource, source, property, target) {};
-
- AimIconObserver.onChange = function(datasource, source, property, oldTarget, newTarget) {
- AimIconObserver.onAssert(datasource, source, property, newTarget);
- };
-
- AimIconObserver.onMove = function(datasource, oldSource, newSource, property, target) {
- AimIconObserver.onAssert(datasource, newSource, property, target);
- };
-
- AimIconObserver.beginUpdateBatch = function(datasource) {
- };
-
- AimIconObserver.endUpdateBatch = function(datasource) {
- };
-
- /*
- * Name: startobserve
- *
- * Arguments: none
- *
- * Description:
- *
- * This function is called on a timer until the AIM data source becomes available (this happens when the
- * user opens up AIM content in the sidebar). The purpose of this function is to register an observer on
- * aim state changes. This observer (AIMIconObserver) is responsible for changing the running man icon
- * in the taskbar.
- *
- * Return Value: none
- *
- * Author: Syd Logan syd@netscape.com 5/18/2001
- *
- */
-
- function startobserve()
- {
- try {
- if ( aimRDFDataSource() ) {
- var im_state = aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true);
- if (im_state == null)
- im_state = aimRDF().GetLiteral("Register");
- AimIconObserver.onAssert(aimRDFDataSource(), aimRDFSession(), aimRDFSessionState(), im_state);
- aimRDFDataSource().AddObserver(AimIconObserver);
- }
- else {
- setTimeout("startobserve()", 1000);
- }
- }
- catch ( ex ) {
- setTimeout("startobserve()", 1000);
- }
- }
-
- /*
- * Name: removeobserve
- *
- * Arguments: none
- *
- * Description:
- *
- * This function mimics startobserve, waiting until the observer has
- * the AimIcon Observer has been set, then removes the Observer.
- * Call this function when the xul file is removed.
- *
- * Return Value: none
- *
- * Author: Joseph Elwell jelwell@netscape.com 7/19/2001
- *
- */
-
- function removeobserve()
- {
- try {
- if ( aimRDFDataSource() ) {
- aimRDFDataSource().RemoveObserver(AimIconObserver);
- }
- else {
- setTimeout("removeobserve()", 1000);
- }
- }
- catch ( ex ) {
- setTimeout("removeobserve()", 1000);
- }
- }
-
-
- /*
- * 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. The purpose of this function is to autologin to aim if that 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, and all the necessary data for autologin is present,
- * then the user is signed onto aim service. There is some checks to see if aims idebar panel is clicked or
- * loaded on top in which case, this function just returns (since sidebar aim panel can take care of this scenario)
- * Return Value: none
- */
-
- 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;
-
- var panelset=document.getElementById("sidebar-panels");
- for (var i=0; i<panelset.childNodes.length-1; i+=2) {
- var panel=panelset.childNodes.item(i);
- if (panel.getAttribute('id') == "urn:sidebar:panel:im-panel"){
- if (panel.getAttribute('selected')) {
- //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;
-
- if(pIAimSession)
- {
- var password = pIAimSession.GetSavedPassword(screenName);
- if (!password || password == '')
- return;
- pIAimSession.Login(screenName, password, getsidebarframe());
- aimMigrateBuddyList( aimSessionCurrentScreenName() );
- return;
- }
- }
-
- /*
- * Name: loginObserver
- * Arguments: none
- * Description:
- * If the user quits application then this observer listens to it and
- * resets appfirstlogin preference back to true.
- * Return Value: none
- */
-
- var loginObserver = {
- Observe: function(subject, message, data) {
- if (message == 'quit-application')
- aimPrefsManager().SetBoolPref("aim.session.appfirstlogin",true,null, true);
- }
- }
-
-
- /*
- * Name: addLoadListener()
- * Arguments: none
- * Description:
- * This function is called on the load of the window. This will add an observer
- * which will wait for the "quit" application message.
- * Return Value: none
- */
-
- function addLoadListener() {
- var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
- observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
- if (observerService) {
- observerService.AddObserver(loginObserver, "quit-application");
- } else {
- //dump("failed to get observer service\n");
- }
-
- // On load of this window, if there is a sidebar, check for aim auto login
- if (document.getElementById('sidebar-box'))
- checkAimAutoLogin();
- }
-
-
- /*
- * Name: removeLoadListener()
- * Arguments: none
- * Description:
- * This function is called on the unload of the window. This will remove the loginObserver
- * Return Value: none
- */
-
-
- function removeLoadListener() {
- var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
- observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
- if (observerService)
- {
- observerService.RemoveObserver(loginObserver, "quit-application");
- }
- }
-
-
- // start the ball rolling
-
- setTimeout("startobserve()", 1000);
- addEventListener("unload",removeobserve,true);
-
- // Add listeners for sidebar autologin
- /*window.addEventListener("load", addLoadListener, false);
- window.addEventListener("unload", removeLoadListener, false);
- Commenting out until presense crash has been figured out
- */
-
- ]]>
- </script>
-
- </overlay>
-