home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2002 December / PCpro_2002_12.ISO / browser / netscape7 / nim.xpi / bin / chrome / aim.jar / content / aim / SidebarPanel.js < prev    next >
Encoding:
Text File  |  2002-08-16  |  60.3 KB  |  1,701 lines

  1. var processInviteTimer = -1;
  2.  
  3. /*
  4.  * Function: UpdateMenuItemsForApp(isonline)
  5.  * Arguments: 
  6.  *       isonline -- login state (offline/online)
  7.  * Return: None
  8.  * Description: This function is called when the user signs on/off and on load of Standalone.
  9.  * According to the the input parameter, the menu items in the standalone get updated.
  10. */
  11.  
  12. function UpdateMenuItemsForApp(isonline)
  13. {
  14.   if ( isonline == "Offline"){
  15.    ClearProcessTimer();
  16.    top.title = aimString("app.title.SignOn");
  17.    top.document.getElementById("miSignOn").setAttribute("label", aimString("miSignOn.SignOn"));
  18.    top.document.getElementById("miSignOn").setAttribute("oncommand", "cmdSignOn();");
  19.    top.document.getElementById("miSignOn").setAttribute("disabled", "false");
  20.    top.document.getElementById("miSignOffClose").setAttribute("disabled", "true");
  21.    top.document.getElementById("miIcqSignOn").setAttribute("label", aimString("miSignOn.SignOn"));
  22.    top.document.getElementById("miIcqSignOn").setAttribute("oncommand", "cmdSignOn();");
  23.    top.document.getElementById("miIcqSignOn").setAttribute("disabled", "false");
  24.    top.document.getElementById("miIcqSignOffClose").setAttribute("disabled", "true");
  25.    top.document.getElementById("change_password").setAttribute("disabled", "true");
  26.    top.document.getElementById("confirm_account").setAttribute("disabled", "true");
  27.    top.document.getElementById("change_email").setAttribute("disabled", "true");
  28.    top.document.getElementById("people_menu").setAttribute("hidden", "true");
  29.    top.document.getElementById("people_menu_icq").setAttribute("hidden", "true");
  30.    top.document.getElementById("menu_PeoplePopup").setAttribute("collapsed", "true");
  31.    top.document.getElementById("menu_PeoplePopup_icq").setAttribute("collapsed", "true");
  32.    top.document.getElementById("menu_Away").setAttribute("hidden", "true");
  33.    top.document.getElementById("away_seperator").setAttribute("hidden", "true");
  34.    top.document.getElementById("menu_Away_icq").setAttribute("hidden", "true");
  35.    top.document.getElementById("away_icq_seperator").setAttribute("hidden", "true");
  36.    top.document.getElementById("cmd_IM").setAttribute("disabled", "true");
  37.    top.document.getElementById("cmd_import").setAttribute("disabled", "true");
  38.    top.document.getElementById("cmd_export").setAttribute("disabled", "true");
  39.   }
  40.  else {
  41.    top.document.getElementById("miSignOn").setAttribute("label", aimString("miSignOn.SignOff"));
  42.    top.document.getElementById("miSignOn").setAttribute("oncommand", "cmdSignOff();");
  43.    top.document.getElementById("miSignOn").setAttribute("disabled", "true");
  44.    top.document.getElementById("miSignOffClose").setAttribute("disabled", "false");
  45.    top.document.getElementById("miIcqSignOn").setAttribute("label", aimString("miSignOn.SignOff"));
  46.    top.document.getElementById("miIcqSignOn").setAttribute("oncommand", "cmdSignOff();");
  47.    top.document.getElementById("miIcqSignOn").setAttribute("disabled", "true");
  48.    top.document.getElementById("miIcqSignOffClose").setAttribute("disabled", "false");
  49.    top.document.getElementById("change_password").setAttribute("disabled", "false");
  50.    top.document.getElementById("confirm_account").setAttribute("disabled", "false");
  51.    top.document.getElementById("change_email").setAttribute("disabled", "false");
  52.    if (isIcq() == true) {
  53.      top.document.getElementById("people_menu_icq").setAttribute("hidden", "false");
  54.      top.document.getElementById("menu_PeoplePopup_icq").setAttribute("collapsed", "false");
  55.      top.document.getElementById("menu_Away_icq").setAttribute("hidden", "false");
  56.      top.document.getElementById("away_icq_seperator").setAttribute("hidden", "false");
  57.      top.document.getElementById("people_menu").setAttribute("hidden", "true");
  58.      top.document.getElementById("menu_PeoplePopup").setAttribute("collapsed", "true");
  59.      top.document.getElementById("menu_Away").setAttribute("hidden", "true");
  60.      top.document.getElementById("away_seperator").setAttribute("hidden", "true");
  61.      }
  62.      else
  63.      {
  64.      top.document.getElementById("people_menu").setAttribute("hidden", "false");
  65.      // top.document.getElementById("menu_Away").setAttribute("hidden", "false");
  66.      top.document.getElementById("menu_PeoplePopup").setAttribute("collapsed", "false");
  67.      top.document.getElementById("menu_Away").setAttribute("hidden", "false");
  68.      top.document.getElementById("away_seperator").setAttribute("hidden", "false");
  69.      top.document.getElementById("people_menu_icq").setAttribute("hidden", "true");
  70.      top.document.getElementById("menu_PeoplePopup_icq").setAttribute("collapsed", "true");
  71.      top.document.getElementById("menu_Away_icq").setAttribute("hidden", "true");
  72.      top.document.getElementById("away_icq_seperator").setAttribute("hidden", "true");
  73.      }
  74.    top.document.getElementById("cmd_IM").setAttribute("disabled", "false");
  75.    top.document.getElementById("cmd_import").setAttribute("disabled", "false");
  76.    top.document.getElementById("cmd_export").setAttribute("disabled", "false");
  77.    // SetupCommandUpdateHandlers() will initialize command observers for Online tree and listsetup tree.
  78.    // timeout is used coz it takes a bit of time for the Online and listsetup tab to show up!
  79.    setTimeout("AimSetupCommandUpdateHandlers()", 500);
  80.    aimMigrateBuddyList( aimSessionCurrentScreenName() );
  81.    SetAwayMenu();
  82.    SetProcessTimer(10000);
  83.  
  84.     var aimTodaypref = aimPrefsManager().GetBoolPref("aim.general.today", null, false);
  85.     if (aimTodaypref) {
  86.       var navigatorWindow;
  87.       var possibleNavigator = top.document.getElementById("main-window");
  88.       if (possibleNavigator && possibleNavigator.getAttribute("windowtype") == "navigator:browser")
  89.         navigatorWindow = top;
  90.  
  91.       const WMEDIATOR_CONTRACTID     = "@mozilla.org/rdf/datasource;1?name=window-mediator";
  92.       const nsIWindowMediator        = Components.interfaces.nsIWindowMediator;
  93.       // if not, get the most recently used browser window
  94.       if (!navigatorWindow) {
  95.         var wm = Components.classes[WMEDIATOR_CONTRACTID].getService(nsIWindowMediator);
  96.         navigatorWindow = wm.getMostRecentWindow("navigator:browser");
  97.       }
  98.  
  99.       // if no browser window available open the mini browser
  100.       if (!navigatorWindow)
  101.         aimToday();
  102.  
  103.       
  104.     }  
  105.  }
  106. }
  107.  
  108. /****************  Window Management *****************/
  109.  
  110. function AimSidebarPanelOnWndLoad() {
  111.   var todayhide = aimPrefsManager().GetBoolPref("aim.internal.hidetoday", null, false);
  112.   if (todayhide)
  113.   {
  114.     document.getElementById("btnbuddyorgtoday").setAttribute("style", "display: none" );
  115.   }
  116.   var hasState;
  117.   var hideConnection = aimPrefsManager().GetBoolPref("aim.session.hideconnection", null, false);
  118.   if (hideConnection == true) {
  119.     picker = document.getElementById('sessionPicker');
  120.     picker.setAttribute("style", "display: none" );
  121.     picker = document.getElementById('sessionPickerLabel');
  122.     picker.setAttribute("style", "display: none" );
  123.   } 
  124.  
  125.   enableSignOnButton(false);
  126.     // Read signon prefs. We need to load at least the screen name here,
  127.     // but might as well load the password and autoLogin prefs, too.
  128.  
  129.     var screenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  130.     
  131.     //dump("ScreenName is " + screenName);
  132.  
  133.     var password = aimSessionGetPassword(null);
  134.     var autoLogin = aimPrefsManager().GetBoolPref("aim.session.autologin", null, false);
  135.     var firstTime = aimPrefsManager().GetBoolPref("aim.session.firsttime", null, true); // firsttime is a GLOBAL pref
  136.     var alreadyFinishedWizard = aimPrefsManager().GetBoolPref("aim.session.finishedwizard", null, false);
  137.  
  138.   addSidebarSessionListener();  
  139.   var connectionName = aimPrefsManager().GetCharPref("aim.session.userconnectionname", null, true);
  140.   setMenuPopUp (connectionName);
  141.     top.AIMDocumentPath=window;
  142.  
  143.   // If this is the first time the user is launching aim, pop open the wizard.
  144.   // If not, ignore and move on.
  145.   if (firstTime) {
  146.     //***** turning off this behavior but we may still need to know if the
  147.     //***** wizard has run yet or not.
  148.     //aimGlobalCmdStartupWizard();
  149.     // Set pref so we don't pop open the wizard again automatically if the user doesn't finish the wizard the first time.
  150.     aimPrefsManager().SetBoolPref("aim.session.firsttime",false, null, true);
  151.   }    
  152.  
  153.     // Initialize online state
  154.  
  155.     var state = aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true);
  156.     
  157.     if (state == null){
  158.         state = aimRDF().GetLiteral("Register");    
  159.     hasState = true;    
  160.         }
  161.  
  162.   if (alreadyFinishedWizard && (hasState || state == aimRDF().GetLiteral("Register")))
  163.     state = aimRDF().GetLiteral("Offline");
  164.  
  165.    if (screenName && screenName !="" && !alreadyFinishedWizard){
  166.       //we are in that special state of having had another wizard set a screen name
  167.       //but we havent finished up the 'registration'
  168.       aimSessionRegister(screenName);
  169.       aimPrefsManager().SetBoolPref("aim.session.finishedwizard",true, null, true);
  170.       //preset the latestaimscreenname so it will be preserved  if the user
  171.       //switches services before ever signing on it will still remember the
  172.       //aim screenname
  173.       aimPrefsManager().SetCharPref("aim.session.latestaimscreenname",screenName, null, true);
  174.       state = aimRDF().GetLiteral("Offline");   
  175.    }  
  176.   // Check whether the Sidebar buddylist is getting loaded or the Standalone one
  177.   CheckIfApp("Aim:AimApp");
  178.   CheckIfSidebar();
  179.  
  180.   // If App then initialize the menu items.
  181.   if ((IsApp) && (!IsSidebar)) 
  182.     UpdateMenuItemsForApp("Offline");
  183.   
  184.     
  185.   OnlineObserver.onAssert(aimRDFDataSource(), aimRDFSession(), aimRDFSessionState(), state);
  186.   // Watch future changes to online state
  187.     aimRDFDataSource().AddObserver(OnlineObserver);
  188.     
  189.     
  190.   var firstLogin = aimPrefsManager().GetBoolPref("aim.session.appfirstlogin", null,true);
  191.   // Auto login
  192.     
  193. if (screenName && screenName != '' && password && password != '' && autoLogin && firstLogin != false &&
  194.     connectionName && connectionName !='') {
  195.       if (state.EqualsNode(aimRDF().GetLiteral("Offline"))) {
  196.  
  197.             if (!IsServiceCorrect(screenName, connectionName)) {
  198.                 return;  
  199.             }
  200.  
  201.             setConnectionInfo (connectionName, "im", screenName);
  202.             aimSessionLogin(screenName, password);
  203.        }
  204.     }
  205.     else
  206.     {
  207.         if (screenName && screenName != '')
  208.         {
  209.             if (!password || password == '')
  210.                 document.getElementById('fldPassword').focus();
  211.       else
  212.         enableSignOnButton(true); //ok..we have SN and password. Enable the signon button
  213.         }
  214.         else
  215.             document.getElementById('fldScreenName').focus();
  216.             
  217.     }
  218. }
  219.  
  220. function resetPopUp()
  221. {
  222.   setMenuPopUp (document.getElementById("sessionTypeListmenu").value);
  223. }
  224.  
  225.  
  226. function AimSidebarPanelSetAwayMsgBtn(){
  227.   var menu = window.document.getElementById("btnaway");
  228.   if (isIcq() == true)
  229.   {
  230.     // this is an Icq session
  231.     var sidebar_file = GetRdfFileUrl("default-messages-icq.rdf", "icqdm.rdf"); 
  232.     menu.setAttribute('ref', "NC:ICQ/AwayMessageBag");  
  233.   }
  234.     else
  235.   {
  236.     var sidebar_file = GetRdfFileUrl("default-messages.rdf", "dm.rdf");
  237.     menu.setAttribute('ref', "NC:AIM/AwayMessageBag");  
  238.   }
  239.   var datasource = aimRDF().GetDataSource(sidebar_file);
  240.   var menudb=menu.database.GetDataSources();
  241.   while   (menudb.hasMoreElements()) {
  242.                 var curDS= menudb.getNext();
  243.               curDS=curDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
  244.                 menu.database.RemoveDataSource(curDS);
  245.         }
  246.     menu.database.AddDataSource(datasource);
  247.   menu.builder.rebuild();
  248. }
  249.  
  250.  
  251. function SetAwayMenu(){
  252.   var menu;
  253.   if (isIcq() == true) {
  254.     menu = top.document.getElementById("menu_Away_icq");
  255.     // this is an Icq session
  256.     var sidebar_file = GetRdfFileUrl("default-messages-icq.rdf", "icqdm.rdf"); 
  257.     menu.setAttribute('ref', "NC:ICQ/AwayMessageBag");  
  258.   }
  259.     else {
  260.     menu = top.document.getElementById("menu_Away");
  261.       var sidebar_file = GetRdfFileUrl("default-messages.rdf", "dm.rdf");  
  262.   }
  263.   var datasource = aimRDF().GetDataSource(sidebar_file);
  264.     var menudb=menu.database.GetDataSources();
  265.   while   (menudb.hasMoreElements()) {
  266.                 var curDS= menudb.getNext();
  267.                 curDS=curDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
  268.                 menu.database.RemoveDataSource(curDS);
  269.         }
  270.     menu.database.AddDataSource(datasource);
  271.     menu.builder.rebuild();
  272. }
  273.  
  274. function AimSidebarPanelOnWndUnload() {
  275.  
  276.     // Save signon fields if offline. If online, we saved during signon.
  277.     var state = aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true);
  278.     if (state == null || state.EqualsNode(aimRDF().GetLiteral("Offline")))
  279.         SaveFieldsToPrefs();
  280.   aimRDFDataSource().RemoveObserver(OnlineObserver);
  281.   ClearProcessTimer();
  282.   removeSidebarSessionListener();
  283. }
  284.  
  285. function InitFieldsFromPrefs( doSNAndPasswd, curScreenName) {
  286.  
  287.  
  288.     if (doSNAndPasswd == true) {
  289.         var screenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  290.         var password = aimSessionGetPassword(null);
  291.         document.getElementById('fldScreenName').value = screenName;
  292.     }
  293.     var savePassword = aimPrefsManager().GetBoolPref("aim.session.storepassword", null, false);
  294.     var autoLogin = aimPrefsManager().GetBoolPref("aim.session.autologin", null, false);
  295.     document.getElementById('chkSavePassword').checked = savePassword;
  296.  
  297.     // PRASS TODO: This does something wrong. Keeps switching the pulldown incorrectly. Need to look into
  298.     // For now commenting out set menu pop up
  299.     var connectionName;
  300.   connectionName = aimPrefsManager().GetCharPref("aim.session.connectionname", null, false);
  301.   if (curScreenName) {
  302.         var connectionName;
  303.         if(doSNAndPasswd == true) {
  304.             connectionName = aimPrefsManager().GetCharPref("aim.session.connectionname", null, false);
  305.         }
  306.         else
  307.             connectionName = aimPrefsManager().GetCharPrefEdit("aim.session.connectionname", null, false, 
  308.                                                 curScreenName, -1);
  309.   //setMenuPopUp (connectionName);
  310.   }
  311.  
  312.     if(doSNAndPasswd == true && savePassword)
  313.         document.getElementById('fldPassword').value = password;
  314.     if (doSNAndPasswd == true && !savePassword)
  315.         document.getElementById('fldPassword').value = '';
  316.  
  317.  
  318.     document.getElementById('chkAutoLogin').checked = autoLogin;
  319.     EnableInputs();
  320. }
  321.  
  322.  
  323. function setMenuPopUp (pLabel){
  324.   
  325.   dump("starting setMenuPopUp pLabel=" + pLabel + "\n");
  326.     
  327.   if (!pLabel || pLabel == "") {
  328.     pLabel = "AIM";
  329.     }
  330.   var menuPopup = document.getElementById("sessionTypeList");
  331.   if (!menuPopup) {   
  332.     return;
  333.   }
  334.   var menuItems = menuPopup.childNodes;
  335.   var menuItem;
  336.   var defItem;
  337.   for (var i=0; i < menuItems.length; i++)
  338.   {
  339.     menuItem = menuItems.item(i);
  340.     if (menuItem.getAttribute("label") == pLabel )
  341.     {
  342.       document.getElementById('sessionTypeListmenu').selectedItem = menuItem;
  343.       UpdateCurrentWindow(pLabel);
  344.       return;
  345.     }
  346.     if (menuItem.getAttribute("label") == "AIM")  
  347.       defItem = menuItem;
  348.   }   
  349.     //default
  350.   document.getElementById('sessionTypeListmenu').selectedItem = defItem;
  351.   UpdateCurrentWindow(pLabel);
  352.   
  353. }
  354.  
  355. function SaveFieldsToPrefs() {
  356.   var screenName = document.getElementById('fldScreenName').value;
  357.   var password = document.getElementById('fldPassword').value;
  358.   var autoLogin = document.getElementById('chkAutoLogin').checked;
  359.   var savePassword = document.getElementById('chkSavePassword').checked;
  360.   var connectionNameNode = document.getElementById('sessionTypeListmenu').selectedItem;
  361.   var connectionName = connectionNameNode.getAttribute("label");
  362.  
  363.   //safety check for trying to save an "empty" screen name. 
  364.   if(screenName != ""){
  365.     aimPrefsManager().SetCharPref("aim.session.screenname", screenName, null, true);
  366.     aimPrefsManager().SetCharPref("aim.session.connectionname", connectionName, null, false);
  367.     //aimPrefsManager().SetCharPref("aim.session.userconnectionname", connectionName, null, true);
  368.  
  369.     // test screenname to see if there are any non-numeric chars
  370.     // if there are - then it's not a valid ICQ screen name so do not store it.
  371.     // if there are only numeric chars then it's not a valid AIM screen name since 
  372.     // they have to start with a letter at least.
  373.   
  374.     var foundNonNumeric = screenName.match(/[\D]+/g); //matches any alpha chars
  375.   
  376.     switch(connectionName){
  377.        case "ICQ": if(!foundNonNumeric){
  378.                       aimPrefsManager().SetCharPref("aim.session.latesticqscreenname", screenName, null, true);
  379.                       }
  380.                    break;
  381.        case "AIM": if(foundNonNumeric){
  382.                       aimPrefsManager().SetCharPref("aim.session.latestaimscreenname", screenName, null, true);
  383.                       }
  384.                    break;          
  385.   
  386.     }
  387.   }
  388.  
  389.  
  390.     if (savePassword)
  391.         aimSessionSavePassword(password);
  392.     else
  393.         aimSessionSavePassword("");
  394.  
  395.     aimPrefsManager().SetBoolPref("aim.session.storepassword", savePassword, null, false);
  396.     aimPrefsManager().SetBoolPref("aim.session.autologin", autoLogin, null, false);
  397. }
  398.  
  399.  
  400. function EnableInputs() {
  401.   var password = document.getElementById("fldPassword").value;
  402.     var savePassword = document.getElementById("chkSavePassword").checked;
  403.  
  404.     if (password != "") {
  405.     enableSignOnButton(true);
  406.     document.getElementById("chkSavePassword").disabled = false;
  407.         document.getElementById("chkAutoLogin").disabled = !savePassword;
  408.  
  409.         // XXX This is what the AIM 3.0 client does. Not sure if we should
  410.         //     change it.
  411.         if (!savePassword)
  412.             document.getElementById("chkAutoLogin").checked = false;
  413.     }
  414.     else {
  415.         enableSignOnButton(false);
  416.         document.getElementById("chkSavePassword").disabled = true;
  417.         document.getElementById("chkAutoLogin").disabled = true;
  418.  
  419.         // XXX This is what the AIM 3.0 client does. Not sure if we should
  420.         //     change it.
  421.         document.getElementById("chkSavePassword").checked = false;
  422.         document.getElementById("chkAutoLogin").checked = false;
  423.     }
  424. }
  425.  
  426.  
  427. /*
  428.  * Function: removeAllBuddyGroups()
  429.  *
  430.  * Arguments: none
  431.  * 
  432.  * Return: None
  433.  *
  434.  * Description: This function removes the IM datasource.
  435.  *
  436.  * Author: Suresh 12/13/01
  437.  */
  438.  
  439. function removeAllBuddyGroups()
  440. {
  441.   var aimbuddy = aimBuddyManager();
  442.   if (aimbuddy) {
  443.     aimbuddy.RemoveAllGroups();
  444.     aimbuddy.RemoveAuthGroup();
  445.   }
  446. }
  447.  
  448. /****************  RDF Observing ********************/
  449.  
  450. var OnlineObserver = new Object();
  451.  
  452. OnlineObserver.onAssert = function(datasource, source, property, target)
  453. {
  454.     if(source.EqualsNode(aimRDFSession()))
  455.     {
  456.         if(property.EqualsNode(aimRDFSessionState()))
  457.         {
  458.             var state = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  459.  
  460.             // flip to the appropriate panel in the deck
  461.       var deck = document.getElementById("PanelDeck");
  462.       var newIndex = deck.getAttribute("selectedIndex");
  463.       switch (state) {
  464.         case "Register":
  465.           newIndex = 4; // register panel
  466.           if  ((IsApp) && (!IsSidebar))  {
  467.               top.title = aimString("app.title.Register");
  468.               top.document.getElementById("navigator-throbber").setAttribute("busy", "true");
  469.               }
  470.           break;
  471.         case "Offline":
  472.           var fsttry = aimPrefsManager().GetBoolPref("aim.session.firsttry", null, true);
  473.           if (!fsttry)       
  474.             newIndex = 0;// sign-on panel
  475.  
  476.           if  ((IsApp) && (!IsSidebar))  {
  477.               top.title = aimString("app.title.SignOn");
  478.               UpdateMenuItemsForApp(state);
  479.               }
  480.           break;
  481.         case "Online":
  482.           newIndex = 3; // online panel
  483.           if  ((IsApp) && (!IsSidebar))  {
  484.             if (isIcq() == true) {
  485.               top.title = aimString("app.title.Online_ICQ").replace(/%UserName%/, aimSessionCurrentScreenName());
  486.             }
  487.             else {
  488.               top.title = aimString("app.title.Online").replace(/%UserName%/, aimSessionCurrentScreenName());
  489.             }
  490.             top.document.getElementById("navigator-throbber").setAttribute("busy", "false");
  491.             UpdateMenuItemsForApp(state);
  492.             }
  493.           if (isIcq() == true)
  494.           {
  495.             document.getElementById("ListSetup").setAttribute("context", "icqcontext");
  496.             document.getElementById("OnlineBuddies").setAttribute("context", "icqcontext");
  497.           }
  498.           else
  499.           {
  500.             document.getElementById("ListSetup").setAttribute("context", "context");
  501.             document.getElementById("OnlineBuddies").setAttribute("context", "context");
  502.           }
  503.           break;
  504.         case "OnlineAway":
  505.           newIndex = 2; // away panel
  506.           if  ((IsApp) && (!IsSidebar))
  507.             top.title = aimString("app.title.OnlineAway");
  508.           break;
  509.         case "Connecting":
  510.         case "Requesting":
  511.         case "Negotiating":
  512.         case "Validating":
  513.         case "Transferring":
  514.         case "Starting":
  515.           newIndex = 1; // connecting panel
  516.           if  ((IsApp) && (!IsSidebar))
  517.             top.title = aimString("app.title.Connecting");
  518.           newIndex = 1;
  519.       }
  520.       deck.setAttribute("selectedIndex", newIndex);
  521.       
  522.             if (state != "Offline" && state != "Online" && state != "Register" && state != "OnlineAway")
  523.             {
  524.         var str = aimString("btnSignOnProgress." + state);
  525.                 document.getElementById("btnSignOnProgress").setAttribute("value", str);
  526.                 var theProgressBar = document.getElementById("spconnectingprogressbar001");
  527.                 theProgressBar.setAttribute("value",parseInt(theProgressBar.getAttribute("value"))+15)
  528.             }
  529.       
  530.             if(state == "Online" || state == "OnlineAway")
  531.             {
  532.                     aimMigrateBuddyList( aimSessionCurrentScreenName() );
  533.             }
  534.       
  535.             // If returning to offline state, reinitialize the signon screen fields,
  536.             // which appear to be cleared out when they are hidden. We also do this
  537.             // when the form is loaded.
  538.             if (state == "Offline") {
  539.                 progress = window.document.getElementById("spconnectingprogressbar001");
  540.                       if ( progress && progress != undefined )
  541.                           progress.setAttribute("value", "0");
  542.                 InitFieldsFromPrefs(true, null);
  543.         //this call is to delete all our datasources during signoff. Timeout is used coz the Signon panel
  544.         //must be loaded before we call this function. Without timeout, this function is called before the signon panel
  545.         //is loaded and it takes few seconds to see the panel :( 
  546.         setTimeout('removeAllBuddyGroups()', 500);
  547.         
  548.             }
  549.       
  550.             if (state == "Online") { 
  551.                 AimSidebarPanelSetAwayMsgBtn();    
  552.           UpdateUserWarning(null);
  553.           UpdateAuthAwaitGroup();
  554.           setTimeout('SelectIndex(0)', 2000);
  555.  
  556.           }
  557.       
  558.         }
  559.    
  560.    if(property.EqualsNode(aimRDFWarningStatus())) {
  561.       var st = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  562.       UpdateUserWarning(st);
  563.    }
  564.     
  565.     }
  566. };
  567.  
  568. OnlineObserver.onUnassert = function(datasource, source, property, target)
  569. {
  570.     // XXX Do we need to remove the attribute here ???
  571. };
  572.     
  573. OnlineObserver.onChange = function(datasource, source, property, oldTarget, newTarget)
  574. {
  575.     OnlineObserver.onAssert(datasource, source, property, newTarget);
  576. };
  577.     
  578. OnlineObserver.onMove = function(datasource, oldSource, newSource, property, target)
  579. {
  580.     OnlineObserver.onAssert(datasource, newSource, property, target);
  581. };
  582.  
  583. OnlineObserver.beginUpdateBatch = function(datasource)
  584. {
  585. };
  586.  
  587. OnlineObserver.endUpdateBatch = function(datasource)
  588. {
  589. };
  590.  
  591. /**************** Command Handlers ******************/
  592.  
  593. function cmdPanelSignOn() 
  594. {
  595.     SaveFieldsToPrefs();
  596.  
  597.     var screenName = document.getElementById('fldScreenName').value;
  598.     var password = document.getElementById('fldPassword').value;
  599.  
  600.     var curConnName = document.getElementById("sessionTypeListmenu").label;
  601.  
  602.     if (!IsServiceCorrect(screenName, curConnName)) {
  603.        return;  
  604.     }
  605.  
  606.   setConnectionInfo (curConnName, "im", screenName);
  607.     aimSessionLogin(screenName, password);
  608.       
  609. }
  610.  
  611.  
  612.  
  613.  
  614.  
  615. /************* key/focus handlers *************/
  616.  
  617. // function cmdScreenName(event)
  618. // handles key events from screenname field
  619. // id="fldScreenName shift-tabbing goes to id="sessionTypeListmenu"
  620. // id="fldScreenName" tabbing goes to id="fldPassword"
  621.  
  622. function cmdScreenName(event) {
  623.    var prevTabOrderElement = "sessionTypeListmenu";
  624.    var nextTabOrderElement = "fldPassword";
  625.    
  626.   if ((event.keyCode == 9) && (event.shiftKey)) 
  627.     {
  628.       document.getElementById(prevTabOrderElement).focus();
  629.       document.getElementById(prevTabOrderElement).setAttribute("focus-ring", "true");
  630.       event.preventDefault();
  631.       return;
  632.     }
  633.   
  634.     var screenName = document.getElementById('fldScreenName').value;
  635.   try {
  636.         var password = "";
  637.       try {
  638.         password = aimSessionGetPassword(screenName);
  639.         } catch (e) {}
  640.         document.getElementById('fldPassword').value = password; 
  641.         document.getElementById('fldPassword').setAttribute("value",password);
  642.     } catch (e) {dump("exception\n");}
  643.   EnableInputs();
  644.   InitFieldsFromPrefs(false, screenName);
  645.  
  646.   // if the user types in screenname and if find the password from pref, enable the send button.
  647.   if ((password.length != 0) && (screenName.length != 0))
  648.     enableSignOnButton(true);
  649.   else
  650.     enableSignOnButton(false);
  651.   // ..so.. if the user enters username and password is filled from prefs, then on enter key sign on.
  652.   if ((event.keyCode == 13) && (password.length != 0) && (screenName.length != 0))
  653.     cmdPanelSignOn();
  654.  
  655.   // if the user presses Enter and password field is empty, put the focus in password field.
  656.   if ((event.keyCode == 13) && (password.length == 0))
  657.     document.getElementById(nextTabOrderElement).focus();
  658. }
  659.  
  660. function cmdPasswordKeyup(event) {
  661.     // Enabled state of savePassword checkbox depends on
  662.     // empty/non-empty password field
  663.   EnableInputs();
  664.   InitFieldsFromPrefs(false, null);
  665.   var password = document.getElementById('fldPassword').value;
  666.   if (password.length > 0){
  667.     enableSignOnButton(true);
  668.     }
  669.   else{
  670.     enableSignOnButton(false);
  671.     }
  672. if (event.keyCode == 13 && password.length > 0){
  673.    event.preventDefault();
  674.    cmdPanelSignOn();
  675.    }
  676. }
  677.  
  678.  
  679. /*
  680.  * Function: setFocusPassLink (event)
  681.  *
  682.  * Arguments: 
  683.  *      event -- key event passed from SpSignOnOrgoverlay
  684.  *
  685.  * Return: None
  686.  *
  687.  * Description: This function intervenes the default focus propagation and sets focus 
  688.  * to the forgot password link to make it accessible. When user hits tab from the Signon button, the focus
  689.  * goes to forgot  password link. Tab from here, goes to screen name field and cycles as before.
  690.  *
  691.  */
  692.  
  693. function setFocusPassLink(event) {
  694.    var currTabOrderElement = "spsignonSignOn2";
  695.    var nextTabOrderElement = "spsignonpasslink";
  696.  
  697.   if (event.shiftKey) {
  698.     //go to previous element - either the sign on button or the help button
  699.     document.getElementById(currTabOrderElement).removeAttribute("focus-ring");
  700.     return;
  701.    }
  702.   event.preventDefault();
  703.   document.getElementById(currTabOrderElement).removeAttribute("focus-ring");
  704.   document.getElementById(nextTabOrderElement).focus();
  705.   document.getElementById(nextTabOrderElement).setAttribute("focus-ring", "true");  
  706.   
  707. }
  708.  
  709. /*
  710.  * Function: unsetFocusPassLink (event)
  711.  *
  712.  * Arguments: 
  713.  *      event -- key event passed from SpSignOnOrgoverlay
  714.  *
  715.  * Return: None
  716.  *
  717.  * Description: This function is called on the onkeypress handler on the password link label.
  718.  * If shift-tab is pressed, it puts focus on the Signon button (provided password field is not empty).
  719.  * If just tab is entered, then focus is put on the Screen name field by rotating focus in clockwise 
  720.  * direction.
  721.  *
  722.  */
  723.  
  724. function unsetFocusPassLink(event) {
  725.    var prevTabOrderElement = "spsignonSignOn2";
  726.    var currTabOrderElement = "spsignonpasslink";
  727.    var nextTabOrderElement = "spregisterpasslink";
  728.  
  729.   if (event.shiftKey) {
  730.     // Shift tab should rotate focus in anti clockwise direction. In this case focus to sign on button
  731.     var password = document.getElementById('fldPassword').value;
  732.     if (password.length == 0) 
  733.         // Do not put focus in sign on button is passfield field was empty - since user can use the button
  734.         return;
  735.     event.preventDefault();
  736.     document.getElementById(prevTabOrderElement).focus();
  737.     document.getElementById(prevTabOrderElement).setAttribute("focus-ring", "true");
  738.   }
  739.   document.getElementById(currTabOrderElement).removeAttribute('focus-ring');
  740. }
  741.  
  742. /*
  743.  * Function: setFocusRegisterLink (event)
  744.  *
  745.  * Arguments: 
  746.  *      event -- key event passed from SpSignOnOrgoverlay
  747.  *
  748.  * Return: None
  749.  *
  750.  * Description: This function intervenes the default focus propagation and sets focus 
  751.  * to the register user link to make it accessible. When user hits tab from the forgot password link, the focus
  752.  * goes to register link. Tab from here, goes to screen name field and cycles as before.
  753.  *
  754.  */
  755.  
  756. function setFocusRegisterLink(event) {
  757.    var prevTabOrderElement = "spsignonSignOn2";
  758.    var currTabOrderElement = "spsignonpasslink";
  759.    var nextTabOrderElement = "spregisterpasslink";
  760.  
  761.   if (event.shiftKey) {
  762.     document.getElementById(currTabOrderElement).removeAttribute("focus-ring");
  763.     document.getElementById(currTabOrderElement).blur();
  764.     return;
  765.    }
  766.   event.preventDefault();
  767.   document.getElementById(currTabOrderElement).removeAttribute("focus-ring");
  768.   document.getElementById(currTabOrderElement).blur();
  769.   document.getElementById(nextTabOrderElement).focus();
  770.   document.getElementById(nextTabOrderElement).setAttribute("focus-ring", "true");  
  771.   
  772. }
  773.  
  774. /*
  775.  * Function: unsetFocusRegisterLink (event)
  776.  *
  777.  * Arguments: 
  778.  *      event -- key event passed from SpSignOnOrgoverlay
  779.  *
  780.  * Return: None
  781.  *
  782.  * Description: This function is called on the onkeypress handler on the register user link label.
  783.  * If shift-tab is pressed, it puts focus on the forgot password link.
  784.  * If just tab is entered, then focus is put on the Screen name field by rotating focus in clockwise 
  785.  * direction.
  786.  *
  787.  */
  788.  
  789. function unsetFocusRegisterLink(event) {
  790.    var prevTabOrderElement = "spsignonpasslink";
  791.    var currTabOrderElement = "spregisterpasslink";
  792.    //var nextTabOrderElement = "sessionTypeListmenu";
  793.    if (event.shiftKey) {
  794.      event.preventDefault();
  795.      document.getElementById(prevTabOrderElement).focus();
  796.      document.getElementById(prevTabOrderElement).setAttribute("focus-ring", "true");
  797.    }
  798.    document.getElementById(currTabOrderElement).removeAttribute('focus-ring');
  799.    document.getElementById(currTabOrderElement).blur();
  800. }
  801.  
  802.  
  803. function setFocusSignOnButton(event){
  804.    var currTabOrderElement = "spsignonHelp2";
  805.    var nextTabOrderElement = "spsignonSignOn2";
  806.    if(event.shiftKey){
  807.       return;
  808.    }
  809.    if(document.getElementById(nextTabOrderElement).getAttribute("disabled") == "true"){
  810.       setFocusPassLink(event);
  811.    }else{
  812.      return;
  813.    }
  814.  
  815.  
  816. }
  817.  
  818.  
  819.  
  820.   /*
  821.   * Name: enableSignOnButton
  822.   *
  823.   * Arguments: flag. 
  824.   *
  825.   * Description:
  826.   *
  827.   * This function enables or disables the signon button based on the flag.
  828.   *    true = enables the button
  829.   *    false = disables the button
  830.   *
  831.   * Return Value: none
  832.   *
  833.   * Author: Suresh Kasinathan<suresh@netscape.com> 8/20/01
  834.   *
  835.   */
  836.  
  837. function enableSignOnButton(flag) {
  838.   var signOnButton = document.getElementById('spsignonSignOn2');
  839.   if (signOnButton) {
  840.     if (flag)
  841.       signOnButton.setAttribute("disabled", "false");
  842.     else
  843.       signOnButton.setAttribute("disabled", "true");
  844.   }
  845. }
  846.  
  847. function cmdClickSavePassword() {
  848.     if (!document.getElementById('chkSavePassword').checked)
  849.         aimPrefsManager().SetBoolPref("aim.session.storepassword", false, null, false);
  850.     // Enabled state of autoLogin checkbox depends on
  851.     // state of savePassword checkbox
  852.   EnableInputs();
  853.   // Save fields so that icq/aim switcher will pick up the checkbox pref.
  854.   SaveFieldsToPrefs();
  855. }
  856.  
  857. function cmdClickAutoLogin() {
  858. }
  859.  
  860. function cmdRegisterScreenName() {
  861.     var screenName = document.getElementById('fldRegisterName').value;
  862.  
  863.     if (screenName == '') {
  864.         aimErrorBox(aimString("msg.NoScreenName"));
  865.         return;
  866.     }
  867.   
  868.   // this will call into nsIAimSession, save the screen name in prefs and
  869.   // notify our observers to go from the register panel to the signon panel
  870.   aimSessionRegister(screenName);
  871.  
  872.     document.getElementById('fldScreenName').value = screenName;
  873. }
  874.  
  875. function cmdDoubleClick(event)
  876. {
  877.   if (event.button != 0) return;
  878.   var target = event.originalTarget;
  879.   if (event.detail == 2 && target.localName == "treechildren") {
  880.     var row = new Object;
  881.     var colID = new Object;
  882.     var childElt = new Object;
  883.  
  884.     var tree = getSelectedTreeName();
  885.     var col = getSelectedTabName();
  886.     if (!tree || !col) return;
  887.     tree.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject).getCellAt(event.clientX, event.clientY, row, colID, childElt);
  888.  
  889.     if (row.value == -1)
  890.       return;
  891.  
  892.     var view = tree.treeBoxObject.view;
  893.     var level = view.getLevel(row.value);
  894.     if (level == 0)
  895.       return;
  896.     var colvalue = document.getElementById(colID.value);
  897.     if (colvalue && colvalue.getAttribute("cycler") != "true" && (childElt.value != "twisty"))
  898.       cmdNewIM();
  899.   }
  900. }
  901.  
  902. function cmdFocus(event)
  903.     {
  904.     dump('focus: ' + event.target.tagName + '\n');
  905.     }
  906. function cmdBlur(event)
  907.     {
  908.     dump('blur: ' + event.target.tagName + '\n');
  909.     }
  910. function cmdGroupKeyUp(event)
  911.     {
  912.     if (event.keyCode == 13)
  913.         {
  914.         var item = event.target.parentNode.parentNode.parentNode;
  915.         var name = item.getAttribute('Name');
  916.         var newName = event.target.value;
  917.  
  918.         aimBuddyRenameBuddyGroup(name, newName);
  919.         }
  920.     }
  921. function cmdBuddyKeyUp(event)
  922.     {
  923.     if (event.keyCode == 13)
  924.         {
  925.         var item = event.target.parentNode.parentNode.parentNode;
  926.         var screenName = item.getAttribute('ScreenName');
  927.         var newName = event.target.value;
  928.  
  929.         var groupItem = item.parentNode.parentNode;
  930.         var groupName = groupItem.getAttribute('Name');
  931.  
  932.         var nextBuddy = null;
  933.         if (item.nextSibling)
  934.             nextBuddy = item.nextSibling.getAttribute('ScreenName');
  935.  
  936.         // XXX aimBuddyReplaceBuddy(groupName, screenName, newName);
  937.         aimBuddyRemoveBuddy(groupName, screenName);
  938.         aimBuddyAddBuddy(groupName, newName, nextBuddy);
  939.         }
  940.     }
  941. function spInPlaceAddBuddy()
  942.     {
  943.       spInPlaceAddDelete( "AddBuddy" );
  944.     }
  945. function spAddBuddy()
  946.     {
  947.     val = prompt( "Enter Buddy Name","" );
  948.     }
  949. function spAddGroup()
  950.     {
  951.     val = prompt( "Enter Group Name", "" );
  952.     }
  953. function spInPlaceAddGroup()
  954.     {
  955.         spInPlaceAddDelete( "AddGroup" );
  956.     }
  957. function spInPlaceDelete()
  958.     {
  959.       spInPlaceAddDelete( "Delete" );
  960.     }
  961.  
  962. function spInPlaceAddDelete( what )    // "Delete", "AddGroup", "AddBuddy"
  963.     {
  964.     // Locate selection in setup list
  965.     // XXX There must be a better way to do this
  966.     var selectedGroup = null;
  967.     var selectedBuddy = null;
  968.     var tree = document.getElementById("ListSetup");
  969.     var groups = tree.childNodes[2].childNodes;
  970.     for (var i = 0; i != groups.length; i++)
  971.         {
  972.         if (groups[i].getAttribute("selected") == "true")
  973.             {
  974.             selectedGroup = groups[i].getAttribute("Name");
  975.             break;
  976.             }
  977.  
  978.         var buddies = null;
  979.         for (var j = 0; j != groups[i].childNodes.length; j++)
  980.             {
  981.             if (groups[i].childNodes[j].nodeName == "treechildren")
  982.                 {
  983.                 buddies = groups[i].childNodes[j].childNodes;
  984.                 break;
  985.                 }
  986.             }
  987.  
  988.         if (buddies)
  989.             {
  990.             for (var j = 0; j != buddies.length; j++)
  991.                 {
  992.                 if (buddies[j].getAttribute("selected") == "true")
  993.                     {
  994.                     selectedBuddy = buddies[j].getAttribute("ScreenName");
  995.                     break;
  996.                     }
  997.                 }
  998.  
  999.             if (selectedBuddy)
  1000.                 {
  1001.                 selectedGroup = groups[i].getAttribute("Name");
  1002.                 break;
  1003.                 }
  1004.             }
  1005.         }
  1006.  
  1007.     if (what == "AddBuddy")
  1008.         aimBuddyAddBuddy(selectedGroup, null, selectedBuddy);
  1009.     else if (what == "AddGroup")
  1010.         aimBuddyAddBuddyGroup(null, selectedGroup);
  1011.     else if (what == "Delete")
  1012.         {
  1013.         if (selectedBuddy)
  1014.             aimBuddyRemoveBuddy(selectedGroup, selectedBuddy);
  1015.         else if (selectedGroup)
  1016.             aimBuddyRemoveBuddyGroup(selectedGroup);
  1017.         }
  1018.     }
  1019.  
  1020. function spFindEmpty( display )    
  1021. {
  1022.     // Locate selection in setup list
  1023.     // XXX There must be a better way to do this
  1024.     var selectedGroup = null;
  1025.     var selectedBuddy = null;
  1026.     var tree = document.getElementById("ListSetup");
  1027.     var groups = tree.childNodes[2].childNodes;
  1028.  
  1029.     
  1030.     for (var i = 0; i != groups.length; i++)
  1031.     {
  1032.         var buddies = null;
  1033.         for (var j = 0; j != groups[i].childNodes.length; j++)
  1034.         {
  1035.             if (groups[i].childNodes[j].nodeName == "treechildren")
  1036.             {
  1037.                 buddies = groups[i].childNodes[j].childNodes;
  1038.                 break;
  1039.             }
  1040.         }
  1041.  
  1042.         if (buddies)
  1043.         {
  1044.             for (var j = 0; j != buddies.length; j++)
  1045.             {
  1046.                 if (buddies[j].getAttribute("ScreenName") == "")
  1047.                 {
  1048.                     selectedBuddy = buddies[j];
  1049.                     if ( display == "none" ) {
  1050.                         selectedBuddy.setAttribute("style", "visibility: hidden;");
  1051.                         selectedBuddy.setAttribute("Yabba", "Dabba;");
  1052.                     }
  1053.                     else {
  1054.                         selectedBuddy.setAttribute("style", "visibility: visible;");
  1055.                     }
  1056.                 }
  1057.                 if (buddies[j].getAttribute("type") == "text")
  1058.                 {
  1059.                     //dump( "Found an object that has a type of 'text'\n" );
  1060.                 }
  1061.             }
  1062.         }
  1063.     }
  1064.  
  1065.     //dump('  selectedGroup: ' + selectedGroup + '\n');
  1066.     //dump('  selectedBuddy: ' + selectedBuddy + '\n');
  1067. }
  1068. /*
  1069. function displayFrontTab(tabObj)
  1070. {
  1071.     tabOne=document.getElementById('tabOnline');
  1072.     tabTwo=document.getElementById('tabSetup');
  1073.     tabOne.setAttribute("style","");
  1074.     tabTwo.setAttribute("style","");
  1075.     tabObj.setAttribute("style","");
  1076. }
  1077.  
  1078. */
  1079.  
  1080. /*** setup chat callbacks for rendezvous ***/
  1081. /** start services **/
  1082. var IMServiceClass = Components.classes['@netscape.com/aim/IMManager;1'];
  1083. var pIIMManager  = IMServiceClass.getService(Components.interfaces.nsIIMManager);
  1084. var ChatManager = pIIMManager.QueryInterface(Components.interfaces.nsIAimChatManager);
  1085.  
  1086. /*** setup the chat call backs **/
  1087.  var ChatCallback = new Object();
  1088.  
  1089.  ChatCallback.OnRequestRoomComplete =  function(roomName,chatRoomObj){
  1090.   
  1091.   chatRoomObj.SetChatRoomCallback(ChatRoomCallback);
  1092.  
  1093.  top.chatRoomObj = chatRoomObj;
  1094.   window.setTimeout('top.chatRoomObj.Join()', 5000);
  1095.   window.setTimeout('top.chatRoomObj.Invite("vishy26aug", "Join this MAAN")', 10000);
  1096.   window.setTimeout('top.chatRoomObj.SendMessage("This is working!!")', 30000);
  1097.   window.setTimeout('top.chatRoomObj.SendWhisper("vishy26aug", "Private message for vishy26aug")', 30000);
  1098.  }
  1099.  
  1100.  
  1101.  ChatCallback.OnRequestRoomError =  function(roomName,errMsg){
  1102.  //dump("OnRequestRoomError: there was an error \n");
  1103.  
  1104.  }
  1105.  
  1106. /** setup the chat Room callbacks **/
  1107.  
  1108.  var ChatRoomCallback = new Object();
  1109.  
  1110.  ChatRoomCallback.OnJoined = function()
  1111.  {
  1112.   //dump("Yes I Joined\n");
  1113.  }
  1114.  
  1115.  ChatRoomCallback.OnUserJoined = function(screenName)
  1116.  {
  1117.   //dump( screenName + "joined the chat\n");
  1118.  }
  1119.  
  1120.  ChatRoomCallback.OnInfoUpdate = function()
  1121.  {
  1122.  }
  1123.  
  1124.  ChatRoomCallback.OnMessageReceived = function(screenName, language, message)
  1125.  {
  1126.   //dump (screenName + " SAYETH " + message + " IN " + language +"\n");
  1127.  }
  1128.  
  1129.  
  1130.  
  1131. var rendezvousCallback = new Object();
  1132.  
  1133. rendezvousCallback.OnProposalReceived = function (screenname, proposal)
  1134. {
  1135.     //dump ("got a proposal from " + screenname + "\n");
  1136.  
  1137.      //proposal.Accept();
  1138.      inviteArgsObj = {
  1139.          inviteProposalScreenName: screenname, 
  1140.          inviteProposalObj: proposal,
  1141.          invitedScreenNames: '',
  1142.          inviteToExistingWindow: false,
  1143.          inviteMode: 'incomingchat'
  1144.          }
  1145.      //dump('send proposal to dialog! \n;')
  1146.     window.openDialog('chrome://aim/content/chatInviteBuddy.xul','_blank','chrome,all,dialog=no',inviteArgsObj); 
  1147.     
  1148.      //dump("accepted the proposal");
  1149.  
  1150.      //ChatManager.RequestProposedRoom(ChatCallback, proposal);
  1151.  
  1152.  }
  1153.  
  1154. function setupChatRendezvous(){
  1155.     //dump("entering setupChatRendezvous 3\n");
  1156.     ChatManager.SetChatRendezvousCallback(rendezvousCallback)
  1157.     //dump("exiting setupChatRendezvous \n");
  1158. }
  1159.  
  1160.  
  1161. /***  end setup chat callbacks for rendezvous ***/
  1162.  
  1163. function cmdNewChatSidebar(invScreenName,invProposal,invScreenNames,toExistingWindow,invMode){
  1164.  
  1165.      inviteArgsObj = {
  1166.          inviteProposalScreenName: invScreenName, 
  1167.          inviteProposalObj: invProposal,
  1168.          invitedScreenNames: getSelectedBuddiesFromList(), //invScreenNames, (getSelectedBuddiesFromList is in App.js)
  1169.          inviteToExistingWindow: toExistingWindow,
  1170.          inviteMode: invMode
  1171.          }
  1172.          
  1173.     window.openDialog('chrome://aim/content/chatInviteBuddy.xul','_blank','chrome,all,dialog=no',inviteArgsObj);
  1174. }
  1175.  
  1176. // Function to open a new window for password lookup
  1177. function openPassLink()
  1178. {
  1179.   var checkSession=document.getElementById("sessionWatcher").getAttribute('sessionMode'); 
  1180.   if (checkSession == "Aim") {
  1181.     passLink = aimString("aim.password.url");
  1182.     openTopWin(passLink);
  1183.     return;
  1184.   }
  1185.   else {
  1186.     passLink = aimString("icq.password.url");
  1187.     openTopWin(passLink);  
  1188.     }
  1189.   
  1190. }
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196. /*
  1197.  * Function:  UpdateAuthAwaitGroup()
  1198.  *
  1199.  * Arguments: None
  1200.  *
  1201.  * Return: None
  1202.  *
  1203.  * 
  1204.  * Author: Prassanna 4/06/2002
  1205.  */
  1206.  
  1207. function UpdateAuthAwaitGroup()
  1208. {
  1209.   if (isIcq() == true) {
  1210.     // Session is ICQ. Show Auth Await Group.
  1211.     document.getElementById('AuthAwait1').setAttribute("hidden", "false");
  1212.     document.getElementById('AuthAwait2').setAttribute("hidden", "false");
  1213.   }
  1214.   else
  1215.   {
  1216.     // Session is AIM. Hide Auth Await Group.
  1217.     document.getElementById('AuthAwait1').setAttribute("hidden", "true");
  1218.     document.getElementById('AuthAwait2').setAttribute("hidden", "true");
  1219.   }
  1220. }
  1221.  
  1222. function UpdateUserWarning(warning)
  1223. {
  1224.   var name = document.getElementById("warnname");
  1225.   var warn = document.getElementById("warnamount");
  1226.   if (warning != null)
  1227.   {
  1228.     if (warning > 0)
  1229.     {
  1230.       warn.setAttribute("value", " " + warning + "%");
  1231.       name.setAttribute("class", "warned");
  1232.     }
  1233.     else
  1234.     {
  1235.       warn.setAttribute("value", "");
  1236.       name.setAttribute("class", "not-warned");
  1237.     }
  1238.     
  1239.     return
  1240.   }
  1241.   
  1242.   var curname=aimSessionCurrentScreenName();
  1243.  
  1244.   //document.getElementById("warnConnIcon").setAttribute("sessionType", aimPrefsManager().GetIntPref("aim.internal.intconnectiontype", null, true) );
  1245.  
  1246.   name.setAttribute("value",curname);
  1247.   
  1248.   var locateManager = aimLocateManager();
  1249.   var LocateCallbackObject = new Object();
  1250.   
  1251.   LocateCallbackObject.OnRequestUserInfoDefaultComplete = function(screenname, userobj)
  1252.   {
  1253.     var percent = userobj.GetWarningPercent();
  1254.     if (percent > 0 )
  1255.     {
  1256.       warn.setAttribute("value", " - " + percent + "%");
  1257.       name.setAttribute("class", "warned");
  1258.     }
  1259.     else
  1260.     {
  1261.       warn.setAttribute("value", "");
  1262.       name.setAttribute("class", "not-warned");
  1263.     }
  1264.   }
  1265.  
  1266.   LocateCallbackObject.OnRequestUserInfoDefaultError = function(screenname, error)
  1267.   {
  1268.     //nothing
  1269.   }
  1270.   
  1271.   if (navigator.platform != "MacPPC")
  1272.   {
  1273.     locateManager.RequestUserInfoDefault( LocateCallbackObject, curname);
  1274.   }
  1275. }
  1276.  
  1277.  
  1278. /*
  1279.  * Function: SetProcessTimer( interval )
  1280.  *
  1281.  * Arguments: 
  1282.  *      interval -- timeout in milliseconds 
  1283.  *
  1284.  * Return: None
  1285.  *
  1286.  * Description: This function sets the global (to App.js) timer 
  1287.  * processInviteTimer to fire after the specified interval
  1288.  *
  1289.  * Author: Syd 4/20/2001
  1290.  */
  1291.  
  1292. function SetProcessTimer( interval )
  1293. {
  1294.   processInviteTimer = setTimeout('ProcessInviteList()',interval);
  1295. }
  1296.  
  1297. /*
  1298.  * Function: ClearProcessTimer()
  1299.  *
  1300.  * Arguments: None
  1301.  *
  1302.  * Return: None
  1303.  *
  1304.  * Description: if the global processInviteTimer != -1, then
  1305.  * clear the timer, otherwise return. This function should 
  1306.  * be called by the onunload handler or at anytime the state
  1307.  * goes from online to offline
  1308.  *
  1309.  * Author: Syd 4/20/2001
  1310.  */
  1311.  
  1312. function ClearProcessTimer()
  1313. {
  1314.         if ( processInviteTimer != -1 ) {
  1315.                 window.clearTimeout( processInviteTimer );
  1316.                 processInviteTimer = -1;
  1317.         }
  1318. }
  1319.  
  1320.  
  1321.  
  1322. /*
  1323.  * Function: aimToday ()
  1324.  *
  1325.  * Arguments: None
  1326.  *
  1327.  * Return: None
  1328.  *
  1329.  * Description: This function launches the aimToday window.
  1330.  *
  1331.  */
  1332.  
  1333. function aimToday()
  1334. {
  1335.   var todayhide = aimPrefsManager().GetBoolPref("aim.internal.hidetoday", null, false);
  1336.   if (!todayhide)
  1337.   {
  1338.     var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
  1339.     var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
  1340.     var topWindow = windowManagerInterface.getMostRecentWindow( "mini:browser" );
  1341.     if ( topWindow )
  1342.     {
  1343.       topWindow.focus();
  1344.     }
  1345.     else
  1346.     {
  1347.       window.open("chrome://aim/content/mini.xul", "_blank", "chrome,extrachrome,menubar,resizable=no,status,toolbar");
  1348.     }
  1349.   }
  1350. }
  1351.  
  1352. function setFocusIfSignOnDisabled(event){
  1353.   if ((event.keyCode == 9) && (document.getElementById('spsignonSignOn2').getAttribute('disabled') == 'true')) {
  1354.     document.getElementById("spsignonHelp2").blur();
  1355.     setFocusPassLink(event)
  1356.   };
  1357. }
  1358.  
  1359.  
  1360. /*
  1361.  * Function: UpdateSessionImages(sessionType)
  1362.  *
  1363.  * Arguments: 
  1364.  *      sessionType -- "0" is Aim, "1" is TIH and "2" is Icq. Value passed from the Service selection 
  1365.  *                      pop-up menu.
  1366.  *
  1367.  * Return: None
  1368.  *
  1369.  * Description: This function sets the users choice of sessionType in the global pref. It also notifies all the observers
  1370.  * who are watching for the session-Mode changed message about the user's choice of service.
  1371.  *
  1372.  * Author: Prassanna 4/02/2002
  1373.  */
  1374.  
  1375. function UpdateSessionImages(sessionType)
  1376. {
  1377.   var session="";
  1378.   var connectionNameNode = document.getElementById('sessionTypeListmenu').selectedItem;
  1379.   var connectionName = connectionNameNode.getAttribute("label");
  1380.   aimPrefsManager().SetCharPref("aim.session.userconnectionname", connectionName, null, true);
  1381.   aimSession().SetAppIcon();
  1382.   var latestScreenNameOfType = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  1383.  
  1384.   switch (sessionType) {
  1385.         case "2": session="Icq";
  1386.                   latestScreenNameOfType = aimPrefsManager().GetCharPref("aim.session.latesticqscreenname",null, true);
  1387.                   //changeTitle("Contact List");
  1388.                   break;
  1389.         case "0": session="Aim";
  1390.                   latestScreenNameOfType = aimPrefsManager().GetCharPref("aim.session.latestaimscreenname",null, true);
  1391.                   //changeTitle("Buddy List");
  1392.                   break;   
  1393.   }
  1394.  
  1395.   /** start update sign on fields due to  sessionChange **/
  1396.   aimPrefsManager().SetCharPref("aim.session.screenname", latestScreenNameOfType, null, true);
  1397.   InitFieldsFromPrefs( true, latestScreenNameOfType)
  1398.   /** end update **/
  1399.    var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  1400.   observerService.notifyObservers(null, "sessionMode-changed", session);
  1401. }
  1402.  
  1403.  
  1404.  
  1405. /*
  1406.  * Function: UpdateCurrentWindow(sessionName)
  1407.  *
  1408.  * Arguments: 
  1409.  *      sessionName -- "Aim" or "Icq". passed when the current pop label is set
  1410.  *
  1411.  * Return: None
  1412.  *
  1413.  * Description: This function is called on load of sidebar buddy list. It basically sets 
  1414.  * sessionMode attribute on the broadcaster element when the apropriate seesin label is being set. 
  1415.  * This is done so that the current window  and the elements reflect the current sessionName.
  1416.  *
  1417.  * Author: Prassanna 4/02/2002
  1418.  */
  1419.  
  1420. function UpdateCurrentWindow(sessionName)
  1421. {
  1422.   var session;
  1423.   var elems = document.getElementById("sessionWatcher");
  1424.   switch (sessionName) {
  1425.         case "ICQ": session="Icq";
  1426.                     elems.setAttribute("sessionMode", "Icq"); 
  1427.                     break;
  1428.         case "AIM": session="Aim";
  1429.                     elems.setAttribute("sessionMode", "Aim"); 
  1430.                     break;   
  1431.   }
  1432.   var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  1433.   observerService.notifyObservers(null, "sessionMode-changed", session);
  1434. }
  1435.  
  1436.  
  1437.  
  1438. /*
  1439.  * Function: addSidebarSessionListener
  1440.  *
  1441.  * Arguments: None
  1442.  *
  1443.  * Return: None
  1444.  *
  1445.  * Description: This function is called on the load of sidebar buddylist panel. This adds a sessionSidebarObserver 
  1446.  * which waits for the sessionMode-changed message.
  1447.  *
  1448.  * Author: Prassanna 4/02/2002
  1449.  */
  1450.  
  1451. function addSidebarSessionListener() {
  1452.   var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
  1453.   observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
  1454.   if (observerService) {
  1455.     observerService.addObserver(sessionSidebarObserver, "sessionMode-changed", false);
  1456.   } else {
  1457.     dump("failed to get observer service\n");
  1458.   }
  1459. }
  1460.  
  1461. /*
  1462.  * Function: removeSidebarSessionListener
  1463.  *
  1464.  * Arguments: None
  1465.  *
  1466.  * Return: None
  1467.  *
  1468.  * Description: This function is called on the Unload of sidebar buddylist panel. This removes the existing sessionSidebarObserver 
  1469.  * on the current sidebarpanel.
  1470.  *
  1471.  * Author: Prassanna 4/02/2002
  1472.  */
  1473.  
  1474. function removeSidebarSessionListener() {
  1475.   var observerService = Components.classes["@mozilla.org/observer-service;1"].getService();
  1476.   observerService = observerService.QueryInterface(Components.interfaces.nsIObserverService);
  1477.   if (observerService)
  1478.   {
  1479.   observerService.removeObserver(sessionSidebarObserver, "sessionMode-changed");
  1480.   }
  1481. }
  1482.  
  1483. /*
  1484.  * Function: UpdateSidebarLabels(sessionName)
  1485.  *
  1486.  * Arguments: sessionName - Passed from the listener. Aim/Icq
  1487.  *
  1488.  * Return: None
  1489.  *
  1490.  * Description: This function is called when the notifier receives sessionMode changed notification. It bruteforces all
  1491.  * the UI widgets to have the appropriate display labels and tooltips based on sessionName.
  1492.  *
  1493.  * Author: Prassanna 4/02/2002
  1494.  */
  1495.  
  1496.  
  1497. function UpdateSidebarLabels(sessionName)
  1498. {
  1499.   switch (sessionName) {
  1500.         case "Icq": var icqval=  document.getElementById('sessionTypeIcq').getAttribute("label");
  1501.                     document.getElementById('sessionTypeListmenu').setAttribute("label",icqval);
  1502.                     document.getElementById('sessionTypeListmenu').setAttribute("value","2");
  1503.                     icqval=document.getElementById('btnbuddyorgsendim').getAttribute("icqtooltip");
  1504.                     document.getElementById('btnbuddyorgsendim').setAttribute("tooltiptext", icqval);
  1505.                     //icqval=document.getElementById('tabOnline').getAttribute("icqlabel");
  1506.                     //document.getElementById('tabOnline').setAttribute("label", icqval);
  1507.                     //icqval=document.getElementById('tabSetup').getAttribute("icqlabel");
  1508.                     //document.getElementById('tabSetup').setAttribute("label", icqval);
  1509.                     icqval=document.getElementById('btnbuddyorgsignoff').getAttribute("icqlabel");
  1510.                     document.getElementById('btnbuddyorgsignoff').setAttribute("label", icqval);
  1511.                     icqval=document.getElementById('btnbuddyorgsignoff').getAttribute("icqtooltip");
  1512.                     document.getElementById('btnbuddyorgsignoff').setAttribute("tooltiptext", icqval);
  1513.                     icqval=document.getElementById('btnSignOnCancel').getAttribute("icqtooltip");
  1514.                     document.getElementById('btnSignOnCancel').setAttribute("tooltiptext", icqval); 
  1515.                     icqval=document.getElementById('snid').getAttribute("icqlabel");
  1516.                     document.getElementById('snid').setAttribute("value", icqval);   
  1517.                     icqval=document.getElementById('chkAutoLogin').getAttribute("icqlabel");
  1518.                     document.getElementById('chkAutoLogin').setAttribute("label", icqval);   
  1519.                     icqval=document.getElementById('spsignonHelp2').getAttribute("icqtooltip");
  1520.                     document.getElementById('spsignonHelp2').setAttribute("tooltiptext", icqval);
  1521.                     icqval=document.getElementById('spsignonSignOn2').getAttribute("icqlabel");
  1522.                     document.getElementById('spsignonSignOn2').setAttribute("label", icqval);   
  1523.                     icqval=document.getElementById('spsignonSignOn2').getAttribute("icqtooltip");
  1524.                     document.getElementById('spsignonSignOn2').setAttribute("tooltiptext", icqval);
  1525.                     icqval=document.getElementById('spregisterpasslink').getAttribute("icqlabel");
  1526.                     document.getElementById('spregisterpasslink').setAttribute("value", icqval);   
  1527.                     icqval=document.getElementById('spregisterpasslink').getAttribute("icqtooltip");
  1528.                     document.getElementById('spregisterpasslink').setAttribute("tooltiptext", icqval);
  1529.                     icqval=document.getElementById('btnsetuporgbuddy').getAttribute("icqtooltip");
  1530.                     document.getElementById('btnsetuporgbuddy').setAttribute("tooltiptext", icqval);
  1531.                     icqval=document.getElementById('btnsetuporgdelete').getAttribute("icqtooltip");
  1532.                     document.getElementById('btnsetuporgdelete').setAttribute("tooltiptext", icqval);
  1533.                     icqval=document.getElementById('btnImBack').getAttribute("icqlabel");
  1534.                     document.getElementById('btnImBack').setAttribute("label", icqval);
  1535.                     var sidebarimpanel = top.document.getElementById('urn:sidebar:panel:im-panel');
  1536.                     if (sidebarimpanel)
  1537.                       sidebarimpanel.setAttribute("label", aimString("icq.sidebarTitle"));
  1538.                     break;
  1539.         case "Aim": var aimval=  document.getElementById('sessionTypeAim').getAttribute("label");
  1540.                     document.getElementById('sessionTypeListmenu').setAttribute("label",aimval);
  1541.                     document.getElementById('sessionTypeListmenu').setAttribute("value","0");
  1542.                     aimval=document.getElementById('btnbuddyorgsendim').getAttribute("imtooltip");
  1543.                     document.getElementById('btnbuddyorgsendim').setAttribute("tooltiptext", aimval);
  1544.                     //aimval=document.getElementById('tabOnline').getAttribute("imlabel");
  1545.                     //document.getElementById('tabOnline').setAttribute("label", aimval);
  1546.                     //aimval=document.getElementById('tabSetup').getAttribute("imlabel");
  1547.                     //document.getElementById('tabSetup').setAttribute("label", aimval);
  1548.                     aimval=document.getElementById('btnbuddyorgsignoff').getAttribute("imlabel");
  1549.                     document.getElementById('btnbuddyorgsignoff').setAttribute("label", aimval);
  1550.                     aimval=document.getElementById('btnbuddyorgsignoff').getAttribute("imtooltip");
  1551.                     document.getElementById('btnbuddyorgsignoff').setAttribute("tooltiptext", aimval);
  1552.                     aimval=document.getElementById('btnSignOnCancel').getAttribute("imtooltip");
  1553.                     document.getElementById('btnSignOnCancel').setAttribute("tooltiptext", aimval); 
  1554.                     aimval=document.getElementById('snid').getAttribute("imlabel");
  1555.                     document.getElementById('snid').setAttribute("value", aimval);   
  1556.                     aimval=document.getElementById('chkAutoLogin').getAttribute("imlabel");
  1557.                     document.getElementById('chkAutoLogin').setAttribute("label", aimval);   
  1558.                     aimval=document.getElementById('spsignonHelp2').getAttribute("imtooltip");
  1559.                     document.getElementById('spsignonHelp2').setAttribute("tooltiptext", aimval);
  1560.                     aimval=document.getElementById('spsignonSignOn2').getAttribute("imlabel");
  1561.                     document.getElementById('spsignonSignOn2').setAttribute("label", aimval);   
  1562.                     aimval=document.getElementById('spsignonSignOn2').getAttribute("imtooltip");
  1563.                     document.getElementById('spsignonSignOn2').setAttribute("tooltiptext", aimval);
  1564.                     aimval=document.getElementById('spregisterpasslink').getAttribute("imlabel");
  1565.                     document.getElementById('spregisterpasslink').setAttribute("value", aimval);   
  1566.                     aimval=document.getElementById('spregisterpasslink').getAttribute("imtooltip");
  1567.                     document.getElementById('spregisterpasslink').setAttribute("tooltiptext", aimval);
  1568.                     aimval=document.getElementById('btnsetuporgbuddy').getAttribute("imtooltip");
  1569.                     document.getElementById('btnsetuporgbuddy').setAttribute("tooltiptext", aimval);
  1570.                     aimval=document.getElementById('btnsetuporgdelete').getAttribute("imtooltip");
  1571.                     document.getElementById('btnsetuporgdelete').setAttribute("tooltiptext", aimval);
  1572.                     aimval=document.getElementById('btnImBack').getAttribute("imlabel");
  1573.                     document.getElementById('btnImBack').setAttribute("label", aimval);
  1574.                     var sidebarimpanel = top.document.getElementById('urn:sidebar:panel:im-panel');
  1575.                     if (sidebarimpanel)
  1576.                       sidebarimpanel.setAttribute("label", aimString("importexport.budlist"));
  1577.                     break;   
  1578.   }
  1579.   
  1580. }
  1581.  
  1582.  
  1583. /*
  1584.  * Function: observe
  1585.  *
  1586.  * Arguments: message - "sessionMode-changed"
  1587.  *              data - "Aim/Icq"
  1588.  *              passed by the notifier 
  1589.  *
  1590.  * Return: None
  1591.  *
  1592.  * Description: This function updates the sessionWatcher broadcaster with the passes sessionMode. It forces the css
  1593.  * to apply the image rules based on sessionMode attribute. It also  calls the UpsideSidebarLabels with the sessionMode
  1594.  * so that all the labels and tooltips are updated based on the sessionMode.
  1595.  *
  1596.  * Author: Prassanna 4/02/2002
  1597.  */
  1598.  
  1599. var sessionSidebarObserver = {
  1600.   observe: function(subject, message, data) {
  1601.   if (message == 'sessionMode-changed')  {
  1602.      // Update sessionMode attribute which updates all images thru css
  1603.      document.getElementById("sessionWatcher").setAttribute("sessionMode", data);
  1604.     // Update all strings and labels to workaround un-dynamic dtd:-(
  1605.      UpdateSidebarLabels(data);
  1606.      }
  1607.   }
  1608. }
  1609.  
  1610.  
  1611. /*
  1612.  * Function: getDs()
  1613.  *
  1614.  * Arguments: None
  1615.  *
  1616.  * Return: sidebar panel datasource
  1617.  *
  1618.  * Description: This function is called by the changeTitle function to obtain the sidebar datasource.
  1619.  *
  1620.  * Author: Prassanna 4/02/2002
  1621.  */
  1622.  
  1623. function getDs()
  1624. {
  1625.   var PANELS_RDF_FILE = "UPnls";
  1626.   try 
  1627.   {
  1628.     var locator_service = Components.classes["@mozilla.org/file/directory_service;1"].getService();
  1629.     if (locator_service)
  1630.       locator_service = locator_service.QueryInterface(Components.interfaces.nsIProperties);
  1631.       var sidebar_file = locator_service.get(PANELS_RDF_FILE, Components.interfaces.nsIFile);
  1632.     if (!sidebar_file.exists()) {
  1633.       //Sidebar panels file does not exist?
  1634.       return;
  1635.     }
  1636.         var file_url = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
  1637.         file_url.file = sidebar_file;
  1638.       return file_url.spec;
  1639.   } catch (ex) {
  1640.      throw(ex);
  1641.   }
  1642. }
  1643.  
  1644. /*
  1645.  * Function:  changeTitle(title)
  1646.  *
  1647.  * Arguments: title - the title for the instant messenger sidebarpanel  "BuddyList"/"ContactList"
  1648.  *
  1649.  * Return: None
  1650.  *
  1651.  * Description: This function is during UpdateSidebarLabels upon notification of session Change. This attempts to
  1652.  * change the title of the instant messenger sidebar panel  basedon user's service choice Aim/Icq
  1653.  *
  1654.  * Author: Prassanna 4/02/2002
  1655.  */
  1656.  
  1657.  
  1658. function changeTitle(title)
  1659. {
  1660.  
  1661.   var RDF = aimRDF();
  1662.   const NC = "http://home.netscape.com/NC-rdf#";
  1663.   var panels = window.parent.document.getElementById("sidebar-panels");
  1664.   var datasource = RDF.GetDataSource(getDs());
  1665.   //var datasource = panels.database;
  1666.  
  1667.   var persistNode = datasource.GetTarget(RDF.GetResource("urn:sidebar:panel:im-panel"),  RDF.GetResource(NC + "title"),true);
  1668.   if (persistNode)
  1669.   {
  1670.     datasource.Change(RDF.GetResource("urn:sidebar:panel:im-panel"),
  1671.                                     RDF.GetResource(NC + "title"), 
  1672.                                     persistNode,
  1673.                                     RDF.GetLiteral(title));
  1674.     
  1675. /*
  1676.     panels.setAttribute('ref', "urn:sidebar:current-panel-list");
  1677.     panels.setAttribute('last-selected-panel', "urn:sidebar:panel:im-panel");
  1678.     SidebarRebuild();
  1679.     for (var ii=2; ii < panels.childNodes.length; ii += 2) {
  1680.           var header = panels.childNodes.item(ii);
  1681.           var content = this.node.childNodes.item(ii+1);
  1682.           if (header.getAttribute('id') == "urn:sidebar:panel:im-panel") {
  1683.                header.setAttribute('selected', 'true');
  1684.                content.removeAttribute('hidden');
  1685.                content.removeAttribute('collapsed');
  1686.                header.reload();
  1687.          break;
  1688.         }
  1689.     }
  1690.  
  1691. // After setting the current panel disappears from view :-( Have to reload maunally. Commenting for now
  1692.   datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Flush();
  1693.   datasource.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource).Refresh(true);
  1694. */
  1695.   }
  1696.     
  1697.                    
  1698. }
  1699.  
  1700.  
  1701.