home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / 05_02.iso / software / netscape6 / nim.xpi / bin / chrome / aim.jar / content / aim / SidebarPanel.js < prev    next >
Encoding:
JavaScript  |  2001-09-10  |  21.6 KB  |  745 lines

  1. /****************  Window Management *****************/
  2.  
  3.  
  4. function AimSidebarPanelOnWndLoad() {
  5.   enableSignOnButton(false);
  6.     // Read signon prefs. We need to load at least the screen name here,
  7.     // but might as well load the password and autoLogin prefs, too.
  8.  
  9.     var screenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  10.     
  11.     dump("ScreenName is " + screenName);
  12.  
  13.     var password = aimSessionGetPassword(null);
  14.     var autoLogin = aimPrefsManager().GetBoolPref("aim.session.autologin", null, false);
  15.     var firstTime = aimPrefsManager().GetBoolPref("aim.session.firsttime", null, true); // firsttime is a GLOBAL pref
  16.     
  17.     
  18.     dump("setting AIMDocumentPath \n");
  19.         top.AIMDocumentPath=window;
  20.  
  21.   // If this is the first time the user is launching aim, pop open the wizard.
  22.   // If not, ignore and move on.
  23.   if (firstTime) {
  24.     aimGlobalCmdStartupWizard();
  25.     // Set pref so we don't pop open the wizard again automatically if the user doesn't finish the wizard the first time.
  26.     aimPrefsManager().SetBoolPref("aim.session.firsttime",false, null, true);
  27.   }    
  28.  
  29.     // Initialize online state
  30.     var state = aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true);
  31.     if (state == null)
  32.         state = aimRDF().GetLiteral("Register");
  33.       
  34.     OnlineObserver.onAssert(aimRDFDataSource(), aimRDFSession(), aimRDFSessionState(), state);
  35.  
  36.     // Watch future changes to online state
  37.     aimRDFDataSource().AddObserver(OnlineObserver);
  38.     
  39.     
  40.   //var firstLogin = aimPrefsManager().GetBoolPref("aim.session.appfirstlogin", null,true);
  41.   // Auto login
  42.     //if (screenName && screenName != '' && password && password != '' && autoLogin && firstLogin != false ) {
  43.   if (screenName && screenName != '' && password && password != '' && autoLogin) {
  44.     if (state.EqualsNode(aimRDF().GetLiteral("Offline")))
  45.             aimSessionLogin(screenName, password);
  46.     }
  47.     else
  48.     {
  49.         if (screenName && screenName != '')
  50.         {
  51.             if (!password || password == '')
  52.                 document.getElementById('fldPassword').focus();
  53.       else
  54.         enableSignOnButton(true); //ok..we have SN and password. Enable the signon button
  55.         }
  56.         else
  57.             document.getElementById('fldScreenName').focus();
  58.             
  59.     }
  60.     
  61. }
  62.  
  63.  
  64. function AimSidebarPanelSetAwayMsgBtn(){
  65.     dump("** aimsidebarpanelsetawaymsgbtn \n")
  66.   var sidebar_file = GetRdfFileUrl("default-messages.rdf", "dm.rdf");  
  67.   var datasource = aimRDF().GetDataSource(sidebar_file);
  68.  
  69.     menu = window.document.getElementById("btnaway");
  70.     var menudb=menu.database.GetDataSources();
  71.         while   (menudb.hasMoreElements()) {
  72.                 var curDS= menudb.getNext();
  73.                 curDS=curDS.QueryInterface(Components.interfaces.nsIRDFDataSource);
  74.                 menu.database.RemoveDataSource(curDS);
  75.         } 
  76.     menu.database.AddDataSource(datasource);
  77.     menu.builder.rebuild();
  78. }
  79.  
  80. function AimSidebarPanelOnWndUnload() {
  81.  
  82.     // Save signon fields if offline. If online, we saved during signon.
  83.     var state = aimRDFDataSource().GetTarget(aimRDFSession(), aimRDFSessionState(), true);
  84.     if (state == null || state.EqualsNode(aimRDF().GetLiteral("Offline")))
  85.         SaveFieldsToPrefs();
  86.  
  87.     aimRDFDataSource().RemoveObserver(OnlineObserver);
  88. }
  89.  
  90. function InitFieldsFromPrefs( doSNAndPasswd ) {
  91.  
  92. dump( "InitFieldsFromPrefs()\n" );
  93.  
  94.     if (doSNAndPasswd == true) {
  95.         var screenName = aimPrefsManager().GetCharPref("aim.session.screenname", null, true);
  96.         //var password = aimPrefsManager().GetCharPref("aim.session.password", null, false);
  97.         var password = aimSessionGetPassword(null);
  98.         document.getElementById('fldScreenName').value = screenName;
  99.     }
  100.     var savePassword = aimPrefsManager().GetBoolPref("aim.session.storepassword", null, false);
  101.     var autoLogin = aimPrefsManager().GetBoolPref("aim.session.autologin", null, false);
  102.  
  103.     document.getElementById('chkSavePassword').checked = savePassword;
  104.  
  105.     if(doSNAndPasswd == true && savePassword)
  106.         document.getElementById('fldPassword').value = password;
  107.         if (doSNAndPasswd == true && !savePassword)
  108.             document.getElementById('fldPassword').value = '';
  109.  
  110.  
  111.     document.getElementById('chkAutoLogin').checked = autoLogin;
  112.     EnableInputs();
  113. }
  114.  
  115. function SaveFieldsToPrefs() {
  116. dump( "SaveFieldsFromPrefs()\n" );
  117.  
  118.     var screenName = document.getElementById('fldScreenName').value;
  119.     var password = document.getElementById('fldPassword').value;
  120.     var autoLogin = document.getElementById('chkAutoLogin').checked;
  121.     var savePassword = document.getElementById('chkSavePassword').checked;
  122.  
  123.       aimPrefsManager().SetCharPref("aim.session.screenname", screenName, null, true);
  124.  
  125.     if (savePassword)
  126.         aimSessionSavePassword(password);//prefs.SetCharPref("aim.session.password", password);
  127.     else
  128.         aimSessionSavePassword("");//prefs.SetCharPref("aim.session.password", "");
  129.  
  130.     aimPrefsManager().SetBoolPref("aim.session.storepassword", savePassword, null, false);
  131.     aimPrefsManager().SetBoolPref("aim.session.autologin", autoLogin, null, false);
  132. }
  133.  
  134. function EnableInputs() {
  135.   var password = document.getElementById("fldPassword").value;
  136.     var savePassword = document.getElementById("chkSavePassword").checked;
  137.  
  138.     if (password != "") {
  139.     enableSignOnButton(true);
  140.     document.getElementById("chkSavePassword").disabled = false;
  141.         document.getElementById("chkAutoLogin").disabled = !savePassword;
  142.  
  143.         // XXX This is what the AIM 3.0 client does. Not sure if we should
  144.         //     change it.
  145.         if (!savePassword)
  146.             document.getElementById("chkAutoLogin").checked = false;
  147.     }
  148.     else {
  149.     enableSignOnButton(false);
  150.         document.getElementById("chkSavePassword").disabled = true;
  151.         document.getElementById("chkAutoLogin").disabled = true;
  152.  
  153.         // XXX This is what the AIM 3.0 client does. Not sure if we should
  154.         //     change it.
  155.         document.getElementById("chkSavePassword").checked = false;
  156.         document.getElementById("chkAutoLogin").checked = false;
  157.     }
  158. }
  159.  
  160. /****************  RDF Observing ********************/
  161.  
  162. var OnlineObserver = new Object();
  163.  
  164. OnlineObserver.onAssert = function(datasource, source, property, target)
  165. {
  166.     if(source.EqualsNode(aimRDFSession()))
  167.     {
  168.         if(property.EqualsNode(aimRDFSessionState()))
  169.         {
  170.             var state = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  171.  
  172.             dump('OnlineState: ' + state + '\n');
  173.  
  174.       // flip to the appropriate panel in the deck
  175.       var deck = document.getElementById("PanelDeck");
  176.       var newIndex = deck.getAttribute("index");
  177.       switch (state) {
  178.         case "Register":
  179.           newIndex = 4; // register panel
  180.           break;
  181.         case "Offline":
  182.           newIndex = 0; // sign-on panel
  183.           break;
  184.         case "Online":
  185.           newIndex = 3; // online panel
  186.           break;
  187.         case "OnlineAway":
  188.           newIndex = 2; // away panel
  189.           break;
  190.         case "Connecting":
  191.         case "Requesting":
  192.         case "Negotiating":
  193.         case "Validating":
  194.         case "Transferring":
  195.         case "Starting":
  196.           newIndex = 1;
  197.       }
  198.       
  199.       deck.setAttribute("index", newIndex);
  200.       
  201.             if (state != "Offline" && state != "Online" && state != "Register" && state != "OnlineAway")
  202.             {
  203.         var str = aimString("btnSignOnProgress." + state);
  204.                 document.getElementById("btnSignOnProgress").setAttribute("value", str);
  205.                 var theProgressBar = document.getElementById("spconnectingprogressbar001");
  206.                 theProgressBar.setAttribute("value",parseInt(theProgressBar.getAttribute("value"))+15)
  207.             }
  208.  
  209.             if(state == "Online" || state == "OnlineAway")
  210.             {
  211.                     aimMigrateBuddyList( aimSessionCurrentScreenName() );
  212.             }
  213.  
  214.             // If returning to offline state, reinitialize the signon screen fields,
  215.             // which appear to be cleared out when they are hidden. We also do this
  216.             // when the form is loaded.
  217.             if (state == "Offline") {
  218.                 progress = window.document.getElementById("spconnectingprogressbar001");
  219.                       if ( progress && progress != undefined )
  220.                           progress.setAttribute("value", "0");
  221.         InitFieldsFromPrefs(true);
  222.             }
  223.             if (state == "Online") { 
  224.                 AimSidebarPanelSetAwayMsgBtn();    
  225.           UpdateUserWarning(null);
  226.           }
  227.         }
  228.    
  229.    if(property.EqualsNode(aimRDFWarningStatus())) {
  230.       var st = target.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
  231.       UpdateUserWarning(st);
  232.    }
  233.     
  234.     }
  235. };
  236.  
  237. OnlineObserver.onUnassert = function(datasource, source, property, target)
  238. {
  239.     // XXX Do we need to remove the attribute here ???
  240. };
  241.     
  242. OnlineObserver.onChange = function(datasource, source, property, oldTarget, newTarget)
  243. {
  244.     OnlineObserver.onAssert(datasource, source, property, newTarget);
  245. };
  246.     
  247. OnlineObserver.onMove = function(datasource, oldSource, newSource, property, target)
  248. {
  249.     OnlineObserver.onAssert(datasource, newSource, property, target);
  250. };
  251.  
  252. OnlineObserver.beginUpdateBatch = function(datasource)
  253. {
  254. };
  255.  
  256. OnlineObserver.endUpdateBatch = function(datasource)
  257. {
  258. };
  259.  
  260. /**************** Command Handlers ******************/
  261.  
  262. function cmdPanelSignOn() 
  263. {
  264.     SaveFieldsToPrefs();
  265.  
  266.     var screenName = document.getElementById('fldScreenName').value;
  267.     var password = document.getElementById('fldPassword').value;
  268.  
  269.     aimSessionLogin(screenName, password);
  270.       
  271. }
  272.  
  273. function cmdPasswordKeyup(event) {
  274.     // Enabled state of savePassword checkbox depends on
  275.     // empty/non-empty password field
  276.   EnableInputs();
  277.   InitFieldsFromPrefs(false);
  278.   var password = document.getElementById('fldPassword').value;
  279.   if (password.length > 0)
  280.     enableSignOnButton(true);
  281.   else
  282.     enableSignOnButton(false);
  283.     if (event.keyCode == 13 && password.length > 0)
  284.         cmdPanelSignOn();
  285. }
  286.  
  287. function cmdScreenName(event) {
  288.     var screenName = document.getElementById('fldScreenName').value;
  289.   dump("cmdScreenName" + screenName + "\n");
  290.  
  291.     /* for (i in event) {
  292.         dump(i); dump ("->");
  293.         var j;
  294.         for (j in i) {
  295.             dump (j); dump (" ") ;  
  296.         } 
  297.         dump("\t");
  298.     }
  299.     //dump("which is " + event.which); */
  300.  
  301.     try {
  302.         var password = "";
  303.       try {
  304.         password = aimSessionGetPassword(screenName);
  305.         } catch (e) {}
  306.         document.getElementById('fldPassword').value = password; 
  307.         document.getElementById('fldPassword').setAttribute("value",password);
  308.     } catch (e) {dump("exception\n");}
  309.   EnableInputs();
  310.   InitFieldsFromPrefs(false);
  311.  
  312.   // if the user types in screenname and if find the password from pref, enable the send button.
  313.   if ((password.length != 0) && (screenName.length != 0))
  314.     enableSignOnButton(true);
  315.   else
  316.     enableSignOnButton(false);
  317.   // ..so.. if the user enters username and password is filled from prefs, then on enter key sign on.
  318.   if ((event.keyCode == 13) && (password.length != 0) && (screenName.length != 0))
  319.     cmdPanelSignOn();
  320.  
  321.   // if the user presses Enter and password fiels is empty, put the focus in password field.
  322.   if ((event.keyCode == 13) && (password.length == 0))
  323.     document.getElementById('fldPassword').focus();
  324. }
  325.  
  326.   /*
  327.   * Name: enableSignOnButton
  328.   *
  329.   * Arguments: flag. 
  330.   *
  331.   * Description:
  332.   *
  333.   * This function enables or disables the signon button based on the flag.
  334.   *    true = enables the button
  335.   *    false = disables the button
  336.   *
  337.   * Return Value: none
  338.   *
  339.   * Author: Suresh Kasinathan<suresh@netscape.com> 8/20/01
  340.   *
  341.   */
  342.  
  343. function enableSignOnButton(flag) {
  344.   var signOnButton = document.getElementById('spsignonSignOn2');
  345.   if (signOnButton) {
  346.     if (flag)
  347.       signOnButton.setAttribute("disabled", "false");
  348.     else
  349.       signOnButton.setAttribute("disabled", "true");
  350.   }
  351. }
  352.  
  353. function cmdClickSavePassword() {
  354.     // Enabled state of autoLogin checkbox depends on
  355.     // state of savePassword checkbox
  356.   EnableInputs();
  357. }
  358.  
  359. function cmdClickAutoLogin() {
  360. }
  361.  
  362. function cmdRegisterScreenName() {
  363.     var screenName = document.getElementById('fldRegisterName').value;
  364.  
  365.     if (screenName == '') {
  366.         aimErrorBox(aimString("msg.NoScreenName"));
  367.         return;
  368.     }
  369.   
  370.   // this will call into nsIAimSession, save the screen name in prefs and
  371.   // notify our observers to go from the register panel to the signon panel
  372.   aimSessionRegister(screenName);
  373.  
  374.     document.getElementById('fldScreenName').value = screenName;
  375. }
  376.  
  377. function cmdDoubleClick(event)
  378. {
  379.     var t = event.originalTarget;
  380.     if (t.localName != "treecell" &&
  381.         t.localName != "treeitem" &&
  382.         t.localName != "image" ) 
  383.  
  384.         return;
  385.  
  386.     var screenName = event.target.parentNode.parentNode.getAttribute('ScreenName');
  387.  
  388.     if(screenName) 
  389.         cmdNewIM();
  390. /*
  391.         if ( aimIMDoesIMExist(screenName) )
  392.             // XXX should be entity
  393.             aimErrorBox(aimString("msg.DuplicateIM"));
  394.         else {
  395.             if ( aimBuddyIsOnline(screenName) )
  396.                 aimIMInvokeIMForm(screenName, null);
  397.             else
  398.                 aimIMInvokeIMForm("", null);
  399.         }
  400.     }
  401. */
  402. }
  403. function cmdFocus(event)
  404.     {
  405.     dump('focus: ' + event.target.tagName + '\n');
  406.     }
  407. function cmdBlur(event)
  408.     {
  409.     dump('blur: ' + event.target.tagName + '\n');
  410.     }
  411. function cmdGroupKeyUp(event)
  412.     {
  413.     if (event.keyCode == 13)
  414.         {
  415.         var item = event.target.parentNode.parentNode.parentNode;
  416.         var name = item.getAttribute('Name');
  417.         var newName = event.target.value;
  418.  
  419.         dump('renameGroup: ' + name + ', ' + newName + '\n');
  420.         aimBuddyRenameBuddyGroup(name, newName);
  421.         }
  422.     }
  423. function cmdBuddyKeyUp(event)
  424.     {
  425.     if (event.keyCode == 13)
  426.         {
  427.         var item = event.target.parentNode.parentNode.parentNode;
  428.         var screenName = item.getAttribute('ScreenName');
  429.         var newName = event.target.value;
  430.  
  431.         var groupItem = item.parentNode.parentNode;
  432.         var groupName = groupItem.getAttribute('Name');
  433.  
  434.         var nextBuddy = null;
  435.         if (item.nextSibling)
  436.             nextBuddy = item.nextSibling.getAttribute('ScreenName');
  437.  
  438.         // XXX aimBuddyReplaceBuddy(groupName, screenName, newName);
  439.         aimBuddyRemoveBuddy(groupName, screenName);
  440.         aimBuddyAddBuddy(groupName, newName, nextBuddy);
  441.         }
  442.     }
  443. function spInPlaceAddBuddy()
  444.     {
  445.     dump('spInPlaceAddBuddy\n');
  446.     spInPlaceAddDelete( "AddBuddy" );
  447.     }
  448. function spAddBuddy()
  449.     {
  450.     val = prompt( "Enter Buddy Name","" );
  451.     }
  452. function spAddGroup()
  453.     {
  454.     val = prompt( "Enter Group Name", "" );
  455.     }
  456. function spInPlaceAddGroup()
  457.     {
  458.     dump('spInPlaceAddGroup\n');
  459.     spInPlaceAddDelete( "AddGroup" );
  460.     }
  461. function spInPlaceDelete()
  462.     {
  463.     dump('spDelete\n');
  464.     spInPlaceAddDelete( "Delete" );
  465.     }
  466.  
  467. function spInPlaceAddDelete( what )    // "Delete", "AddGroup", "AddBuddy"
  468.     {
  469.     // Locate selection in setup list
  470.     // XXX There must be a better way to do this
  471.     var selectedGroup = null;
  472.     var selectedBuddy = null;
  473.     var tree = document.getElementById("ListSetup");
  474.     var groups = tree.childNodes[2].childNodes;
  475.     for (var i = 0; i != groups.length; i++)
  476.         {
  477.         if (groups[i].getAttribute("selected") == "true")
  478.             {
  479.             selectedGroup = groups[i].getAttribute("Name");
  480.             break;
  481.             }
  482.  
  483.         var buddies = null;
  484.         for (var j = 0; j != groups[i].childNodes.length; j++)
  485.             {
  486.             if (groups[i].childNodes[j].nodeName == "treechildren")
  487.                 {
  488.                 buddies = groups[i].childNodes[j].childNodes;
  489.                 break;
  490.                 }
  491.             }
  492.  
  493.         if (buddies)
  494.             {
  495.             for (var j = 0; j != buddies.length; j++)
  496.                 {
  497.                 if (buddies[j].getAttribute("selected") == "true")
  498.                     {
  499.                     selectedBuddy = buddies[j].getAttribute("ScreenName");
  500.                     break;
  501.                     }
  502.                 }
  503.  
  504.             if (selectedBuddy)
  505.                 {
  506.                 selectedGroup = groups[i].getAttribute("Name");
  507.                 break;
  508.                 }
  509.             }
  510.         }
  511.  
  512.     dump('  selectedGroup: ' + selectedGroup + '\n');
  513.     dump('  selectedBuddy: ' + selectedBuddy + '\n');
  514.  
  515.     if (what == "AddBuddy")
  516.         aimBuddyAddBuddy(selectedGroup, null, selectedBuddy);
  517.     else if (what == "AddGroup")
  518.         aimBuddyAddBuddyGroup(null, selectedGroup);
  519.     else if (what == "Delete")
  520.         {
  521.         if (selectedBuddy)
  522.             aimBuddyRemoveBuddy(selectedGroup, selectedBuddy);
  523.         else if (selectedGroup)
  524.             aimBuddyRemoveBuddyGroup(selectedGroup);
  525.         }
  526.     }
  527.  
  528. function spFindEmpty( display )    
  529. {
  530.     // Locate selection in setup list
  531.     // XXX There must be a better way to do this
  532.     var selectedGroup = null;
  533.     var selectedBuddy = null;
  534.     var tree = document.getElementById("ListSetup");
  535.     var groups = tree.childNodes[2].childNodes;
  536.  
  537.     dump( "In spFindEmpty\n" );
  538.     for (var i = 0; i != groups.length; i++)
  539.     {
  540.         var buddies = null;
  541.         for (var j = 0; j != groups[i].childNodes.length; j++)
  542.         {
  543.             if (groups[i].childNodes[j].nodeName == "treechildren")
  544.             {
  545.                 buddies = groups[i].childNodes[j].childNodes;
  546.                 break;
  547.             }
  548.         }
  549.  
  550.         if (buddies)
  551.         {
  552.             for (var j = 0; j != buddies.length; j++)
  553.             {
  554.                 if (buddies[j].getAttribute("ScreenName") == "")
  555.                 {
  556.                     dump( "Found a screen name that is empty\n" );
  557.                     selectedBuddy = buddies[j];
  558.                     if ( display == "none" ) {
  559.                         dump( "Setting style to display: none\n" );
  560.                         selectedBuddy.setAttribute("style", "visibility: hidden;");
  561.                         selectedBuddy.setAttribute("Yabba", "Dabba;");
  562.                     }
  563.                     else {
  564.                         dump( "Setting style to display: block\n" );
  565.                         selectedBuddy.setAttribute("style", "visibility: visible;");
  566.                     }
  567.                 }
  568.                 if (buddies[j].getAttribute("type") == "text")
  569.                 {
  570.                     dump( "Found an object that has a type of 'text'\n" );
  571.                 }
  572.             }
  573.         }
  574.     }
  575.  
  576.     dump('  selectedGroup: ' + selectedGroup + '\n');
  577.     dump('  selectedBuddy: ' + selectedBuddy + '\n');
  578. }
  579. /*
  580. function displayFrontTab(tabObj)
  581. {
  582.     tabOne=document.getElementById('tabOnline');
  583.     tabTwo=document.getElementById('tabSetup');
  584.     tabOne.setAttribute("style","");
  585.     tabTwo.setAttribute("style","");
  586.     tabObj.setAttribute("style","");
  587. }
  588.  
  589. */
  590.  
  591. /*** setup chat callbacks for rendezvous ***/
  592. /** start services **/
  593. var IMServiceClass = Components.classes['@netscape.com/aim/IMManager;1'];
  594. var pIIMManager  = IMServiceClass.getService(Components.interfaces.nsIIMManager);
  595. var ChatManager = pIIMManager.QueryInterface(Components.interfaces.nsIAimChatManager);
  596.  
  597. /*** setup the chat call backs **/
  598.  var ChatCallback = new Object();
  599.  
  600.  ChatCallback.OnRequestRoomComplete =  function(roomName,chatRoomObj){
  601.   dump("OnRequestRoomComplete: success on " + roomName + "\n");
  602.  
  603.   chatRoomObj.SetChatRoomCallback(ChatRoomCallback);
  604.  
  605.  top.chatRoomObj = chatRoomObj;
  606.   window.setTimeout('top.chatRoomObj.Join()', 5000);
  607.   window.setTimeout('top.chatRoomObj.Invite("vishy26aug", "Join this MAAN")', 10000);
  608.   window.setTimeout('top.chatRoomObj.SendMessage("This is working!!")', 30000);
  609.   window.setTimeout('top.chatRoomObj.SendWhisper("vishy26aug", "Private message for vishy26aug")', 30000);
  610.  }
  611.  
  612.  
  613.  ChatCallback.OnRequestRoomError =  function(roomName,errMsg){
  614.   dump("OnRequestRoomError: there was an error \n");
  615.  
  616.  }
  617.  
  618. /** setup the chat Room callbacks **/
  619.  
  620.  var ChatRoomCallback = new Object();
  621.  
  622.  ChatRoomCallback.OnJoined = function()
  623.  {
  624.   dump("Yes I Joined\n");
  625.  }
  626.  
  627.  ChatRoomCallback.OnUserJoined = function(screenName)
  628.  {
  629.   dump( screenName + "joined the chat\n");
  630.  }
  631.  
  632.  ChatRoomCallback.OnInfoUpdate = function()
  633.  {
  634.  }
  635.  
  636.  ChatRoomCallback.OnMessageReceived = function(screenName, language, message)
  637.  {
  638.   dump (screenName + " SAYETH " + message + " IN " + language +"\n");
  639.  }
  640.  
  641.  
  642.  
  643. var rendezvousCallback = new Object();
  644.  
  645. rendezvousCallback.OnProposalReceived = function (screenname, proposal)
  646. {
  647.     dump ("got a proposal from " + screenname + "\n");
  648.  
  649.      //proposal.Accept();
  650.      inviteArgsObj = {
  651.          inviteProposalScreenName: screenname, 
  652.          inviteProposalObj: proposal,
  653.          invitedScreenNames: '',
  654.          inviteToExistingWindow: false,
  655.          inviteMode: 'incomingchat'
  656.          }
  657.      dump('send proposal to dialog! \n;')
  658.     window.openDialog('chrome://aim/content/chatInviteBuddy.xul','_blank','chrome,all,dialog=no',inviteArgsObj); 
  659.     
  660.      //dump("accepted the proposal");
  661.  
  662.      //ChatManager.RequestProposedRoom(ChatCallback, proposal);
  663.  
  664.  }
  665.  
  666. function setupChatRendezvous(){
  667.     dump("entering setupChatRendezvous 3\n");
  668.     ChatManager.SetChatRendezvousCallback(rendezvousCallback)
  669.     dump("exiting setupChatRendezvous \n");
  670. }
  671.  
  672.  
  673. /***  end setup chat callbacks for rendezvous ***/
  674.  
  675. function cmdNewChatSidebar(invScreenName,invProposal,invScreenNames,toExistingWindow,invMode){
  676.  
  677.      inviteArgsObj = {
  678.          inviteProposalScreenName: invScreenName, 
  679.          inviteProposalObj: invProposal,
  680.          invitedScreenNames: getSelectedBuddiesFromList(), //invScreenNames, (getSelectedBuddiesFromList is in App.js)
  681.          inviteToExistingWindow: toExistingWindow,
  682.          inviteMode: invMode
  683.          }
  684.          
  685.     window.openDialog('chrome://aim/content/chatInviteBuddy.xul','_blank','chrome,all,dialog=no',inviteArgsObj);
  686. }
  687.  
  688. // Function to open a new window for password lookup
  689. function openPassLink()
  690. {
  691.   aimRegionBundle = document.getElementById('bundle_aim_region');
  692.   passLink = aimRegionBundle.getString("aim.password.url");
  693.   openTopWin(passLink);
  694. }
  695.  
  696. function UpdateUserWarning(warning)
  697. {
  698.   var name = document.getElementById("warnname");
  699.   var warn = document.getElementById("warnamount");
  700.   if (warning != null)
  701.   {
  702.     if (warning > 0)
  703.     {
  704.       warn.setAttribute("value", " - " + warning + "%");
  705.       name.setAttribute("class", "warned");
  706.     }
  707.     else
  708.     {
  709.       warn.setAttribute("value", "");
  710.       name.setAttribute("class", "not-warned");
  711.     }
  712.     
  713.     return
  714.   }
  715.   
  716.   var curname=aimSessionCurrentScreenName();
  717.   
  718.   name.setAttribute("value",curname);
  719.   
  720.   var locateManager = aimLocateManager();
  721.   var LocateCallbackObject = new Object();
  722.   
  723.   LocateCallbackObject.OnRequestUserInfoDefaultComplete = function(screenname, userobj)
  724.   {
  725.     var percent = userobj.GetWarningPercent();
  726.     if (percent > 0 )
  727.     {
  728.       warn.setAttribute("value", " - " + percent + "%");
  729.       name.setAttribute("class", "warned");
  730.     }
  731.     else
  732.     {
  733.       warn.setAttribute("value", "");
  734.       name.setAttribute("class", "not-warned");
  735.     }
  736.   }
  737.  
  738.   LocateCallbackObject.OnRequestUserInfoDefaultError = function(screenname, error)
  739.   {
  740.     //nothing
  741.   }
  742.  
  743.   locateManager.RequestUserInfoDefault( LocateCallbackObject, curname); 
  744. }
  745.