home *** CD-ROM | disk | FTP | other *** search
- /*
- * The contents of this file are subject to the Netscape Public
- * License Version 1.1 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * The Original Code is Mozilla Communicator client code, released
- * March 31, 1998.
- *
- * The Initial Developer of the Original Code is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998-1999 Netscape Communications Corporation. All
- * Rights Reserved.
- *
- * Contributor(s):
- * Ben Goodger (30/09/99)
- */
-
- var wizardMap = {
- /*
- findAFriend1_0: { previous: null, next: "findAFriend1_1", finish: false },
- */
- findAFriend1_1: { previous: null, next: "findAFriend1_1_0", finish: false },
- findAFriend1_1_0: { previous: "findAFriend1_1", next: null, finish: false },
- findAFriend1_1_1: { previous: "findAFriend1_1", next: null, finish: true },
- findAFriend1_1_3: { previous: "findAFriend1_1", next: null, finish: true },
- findAFriend1_1_4: { previous: "findAFriend1_1", next: null, finish: true },
- findAFriend1_2: { previous: "findAFriend1_1", next: null, finish: true },
- }
-
- // page specific variables
- var profName = "";
- var profDir = "";
- var wizardManager = null;
-
- // startup procedure
- function Startup( startPage, frame_id )
- {
- if( frame_id == "" ) {
- dump("Please supply a content_frame ID!");
- return false;
- }
-
- // instantiate the Wizard Manager
- wizardManager = new WizardManager( frame_id, null, null, wizardMap );
- wizardManager.URL_PagePrefix = "chrome://aim/content/";
- wizardManager.URL_PagePostfix = ".xul";
-
- // set the button handler functions
- wizardManager.SetHandlers( null, null, onFinish, onCancel, null, null );
- // load the start page
- dump("calling loadpage...\n");
- dump("startPage:: " + startPage + "\n");
- wizardManager.LoadPage( startPage, false );
- }
-
- function onCancel()
- {
- window.close();
- }
-
- function onFinish()
- {
- // check if we're at final stage
-
- if( !wizardManager.wizardMap[wizardManager.currentPageTag].finish )
- return;
-
- window.close();
-
- }
-
-
-
- /** void ExitApp( void ) ;
- * - purpose: quits the application properly and finally, stops event loop
- * - in: nothing
- * - out: nothing
- **/
- function ExitApp()
- {
- // Need to call this to stop the event loop
- var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
- appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
- appShell.Quit();
- }
-
-
- /* new callback */
- var Callback = new Object();
- var containerArray = new Array();
- var numHits = null;
- var queryEmailAddress = null;
-
- Callback.OnRequestScreenNamesComplete = function(email,numScreenNames,pScreenNames)
- {
- //dump("Callback.OnRequestScreenNamesComplete called with email " + email + "\n");
- //dump("numScreenNames is " + numScreenNames + "\n");
-
- //dump("pScreenNames is " + pScreenNames + "\n");
-
- //numHits = document.createTextNode(numScreenNames);
-
- numHits = numScreenNames;
-
- if (pScreenNames[0] == null && numScreenNames > 0) {
- parent.wizardManager.LoadPage('findAFriend1_1_4',false);
- return;
- }
- queryEmailAddress = parent.wizardManager.WSM.PageData.findAFriend1_1.emailaddr.value;
-
- for(i=0;i<numScreenNames;i++){
- dump("found screenName:"+pScreenNames[i]+"\n");
-
- //new stuff
- containerArray[i]=pScreenNames[i];
-
- }
-
- dump("done with searching? \n");
-
- // myLocateCallbacks and locateManager instantiation
- /* commented out for now
- var pIIMManager = aimManager();
-
- if (!pIIMManager) {
- dump ("cmdFindBuddy:unable to get pIIMManager\n");
- return;
- }
-
- var pILocateManager = null;
-
- pILocateManager = aimManager().QueryInterface(Components.interfaces.nsIAimLocateManager);
-
- if (!pILocateManager) {
- dump("cmdFindBuddy:unable to get pILocateManager\n");
- return;
- }
-
- dump("building myLocateCallback object\n");
- var myLocateCallback = new Object();
-
- myLocateCallback.OnRequestDirectoryInfoEntryComplete = function(screenName,entry)
- {
- dump("myLocateCallback.OnRequestDirectoryInfoEntryComplete " + screenName + "\n");
- dump("FirstName is " + entry.FirstName + " ");
- dump("LastName is " + entry.LastName + " ");
- dump("ScreenName is " + entry.ScreenName + " ");
- dump("City is " + entry.City + " ");
- dump("Country is " + entry.Country + " ");
- dump("Zipcode is " + entry.Zipcode + " ");
- dump("State is " + entry.State + " ");
- dump("Maiden name is " + entry.MaidenName + "\n");
- }
-
- myLocateCallback.OnRequestDirectoryInfoEntryError = function(screenName, msg)
- {
-
- dump("myLocateCallback.OnRequestDirectoryInfoEntryCompleteError " + screenName + "\n");
- }
-
- for(j=0;j<numScreenNames; j++){
- dump("looking up info on:"+ pScreenNames[j]+"\n");
- //pILocateManager.RequestDirectoryInfoKeywords(LocateCallback,pScreenNames[j]);
- pILocateManager.RequestDirectoryInfoEntry(myLocateCallback,pScreenNames[j]);
-
- }
- */
-
- parent.wizardManager.LoadPage('findAFriend1_2',false);
- }
-
- Callback.OnRequestScreenNamesError = function(email,pErrMsg)
- {
- dump("Callback.OnRequestScreenNamesError called with email " + email + "\n");
-
- dump("pErrMsg is " + pErrMsg + "\n");
-
- parent.wizardManager.LoadPage('findAFriend1_1_1',false);
- }
-
- /*
- * Function: cmdFindBuddy()
- *
- * Arguments: None
- *
- * Return: None
- *
- * Description: Called in response to menu item of toolbar button in standalone
- * for finding a buddy. Opens FindBuddy.xul to place a
- * wizard that can be used to find a buddy.
- *
- *
- */
-
- function cmdFindBuddy()
- {
- dump("Entered cmdFindBuddy\n");
-
- var pIIMManager = aimManager();
-
- if (!pIIMManager)
- {
- dump ("cmdFindBuddy:unable to get pIIMManager\n");
- return;
- }
-
- dump("done testing feedbag manager\n");
-
-
- /* USERLOOKUPMANAGER */
- var pIUserLookupManager = aimUserLookupManager();
-
- if (!pIUserLookupManager)
- {
- dump("cmdFindBuddy:unable to get pIUserLookupManager\n");
- return;
- }
-
- dump("cmdFindBuddy: calling RequestScreenNames\n");
-
- var theEmailAddress=parent.wizardManager.WSM.PageData.findAFriend1_1.emailaddr.value
- //alert(theEmailAddress)
- pIUserLookupManager.RequestScreenNames(Callback,theEmailAddress);
-
-
- dump("done testing userlookupmanager now locatemanager\n");
-
- /* LOCATEMANAGER */
- var pILocateManager = aimLocateManager();
-
- if (!pILocateManager)
- {
- dump("cmdFindBuddy:unable to get pILocateManager\n");
- return;
- }
-
- dump("building LocateCallback object\n");
-
- var LocateCallback = new Object();
-
- LocateCallback.OnRequestDirectoryInfoKeywordsComplete = function(screenname, count,keywords)
- {
- dump("OnRequestDirectoryInfoKeywordsComplete " + screenname + "\n");
- dump ("The number of keywords is " + count + "\n");
- for (var i = 0; i < count ; i++) {
- dump(" " + keywords[i] + " ");
- }
- dump("\n");
- }
-
- LocateCallback.OnRequestDirectoryInfoKeywordsError = function(screenName, msg)
- {
- dump("OnRequestDirectoryInfoKeywordsCompleteError " + screenName + "\n");
-
- }
-
-
- LocateCallback.OnRequestDirectoryInfoEntryComplete = function(screenName,entry)
- {
- dump("LocateCallback.OnRequestDirectoryInfoEntryComplete " + screenName + "\n");
-
- dump("FirstName is " + entry.FirstName + " ");
- dump("LastName is " + entry.LastName + " ");
- dump("ScreenName is " + entry.ScreenName + " ");
- dump("City is " + entry.City + " ");
- dump("Country is " + entry.Country + " ");
- dump("Zipcode is " + entry.Zipcode + " ");
- dump("State is " + entry.State + " ");
- dump("Maiden name is " + entry.MaidenName + "\n");
- }
-
-
- dump("cmdFindBuddy: calling RequestDirectoryInfoEntry\n");
-
- //pILocateManager.RequestDirectoryInfoEntry(LocateCallback,"trip004");
- //pILocateManager.RequestDirectoryInfoEntry(LocateCallback,"trip002");
-
-
-
- //dump("cmdFindBuddy: calling RequestDirectoryInfoKeywords\n");
- //pILocateManager.RequestDirectoryInfoKeywords(LocateCallback,"trip004");
-
-
- /* ODIRMANAGER */
- /*
- dump("testing now odirmanager\n");
-
- var pIOdirManager = aimOdirManager();
-
- dump("building OdirCallback object\n");
-
- var OdirCallback = new Object();
-
- OdirCallback.OnRequestKeywordListComplete = function(count,keywords)
- {
- dump("OnRequestKeywordListComplete\n");
- for (var i = 0 ; i < count ; i++) {
- for (var j = 0 ; j < keywords[i].keywords.length ; j++)
- dump(" " + keywords[i].keywords[j] + " ");
- dump("\n");
- }
- }
- OdirCallback.OnRequestKeywordListError = function(pErrMsg)
- {
- dump("OnRequestKeywordListError\n");
- }
- OdirCallback.OnSearchDirectoryError = function(pErrMsg)
- {
- dump("OnSearchDirectoryError\n");
- }
-
- OdirCallback.OnSearchDirectoryComplete = function(count,entries)
- {
- dump("OdirCallback.OnSearchDirectoryComplete called with count " + count + "\n");
- for (var i = 0 ; i < count ; i++)
- {
- dump("FirstName is " + entries[i].FirstName + " ");
- dump("LastName is " + entries[i].LastName + " ");
- dump("ScreenName is " + entries[i].ScreenName + " ");
- dump("City is " + entries[i].City + " ");
- dump("Country is " + entries[i].Country + " ");
- dump("Zipcode is " + entries[i].Zipcode + " ");
- dump("State is " + entries[i].State + " ");
- dump("Maiden Name is " + entries[i].MaidenName + "\n");
- }
- }
-
- dump("cmdFindBuddy: calling Getallkeywords\n");
- pIOdirManager.RequestKeywordList(OdirCallback);
-
- dump("cmdFindBuddy: calling SearchDirectory\n");
-
- pIOdirManager.SearchDirectoryByEntry(OdirCallback, "vishy@netscape.com", "Viswanath", "Ramachandran");
-
- */
- dump("leaving cmdFindBuddy\n");
- }
-
-
-
- function cmdFindBuddyViaEntry(){
- dump("Entered cmdFindBuddyViaEntry\n");
-
- var pIOdirManager = aimOdirManager();
-
- if (!pIOdirManager)
- {
- dump("cmdFindBuddy:unable to get pIOdirManager\n");
- return;
- }
-
- dump("building OdirCallback object\n");
-
- var OdirCallback = new Object();
-
- OdirCallback.OnSearchDirectoryComplete = function (count, retOdirObj){
- for(i=0;i<count;i++){
- dump("ScreenName is:" +retOdirObj[i].ScreenName+"\n");
-
- }
-
- }
- OdirCallback.OnSearchDirectoryError = function(pErrMsg){
- dump("OnSearchDirectoryByEntryGeneralError\n");
- }
-
- testOdirObj={
- FirstName: "Andrew",
- Lastname: "Wooldridge",
- }
- dump("cmdFindBuddy: calling SearchByEntry\n");
-
- pIOdirManager.SearchDirectoryByEntryGeneral(OdirCallback, testOdirObj)
-
- }
-
-
- function cmdFindBuddyViaKeyWords(){
-
- dump("Entered cmdFindBuddyViaEntry\n");
-
- var pIOdirManager = aimOdirManager();
-
- pIOdirManager = aimManager().QueryInterface(Components.interfaces.nsIAimOdirManager);
-
- if (!pIOdirManager)
- {
- dump("cmdFindBuddy:unable to get pIOdirManager\n");
- return;
- }
-
- dump("building OdirCallback object\n");
-
- var OdirCallback = new Object();
-
- OdirCallback.OnSearchDirectoryComplete = function (count, retOdirObjArr){
- for(i=0;i<count;i++){
- dump("ScreenName is:" +retOdirObjArr[i].ScreenName+"\n");
-
- }
-
- }
- OdirCallback.OnSearchDirectoryError = function(pErrMsg){
- dump("OnSearchDirectoryByEntryGeneralError\n");
- }
-
- testArray=["cars","Books and Writing"]
- //actual call
- pIOdirManager.SearchDirectoryByKeywords(OdirCallback,2, testArray)
-
-
- }
-
-
- /* dom utility functions */
-
- /* makeElementFromString
- * inputs fragArray - array of strings, first item is the tagname
- * the rest are properties
- *
- * returns a dom element
- */
-
- function makeElementFromString(fragArray){
- tempEle=document.createElement(fragArray[0])
- for(i=1;i<tempEle.length;i++){
- tempEle.setAttribute(fragArray[i],"")
- }
- return tempEle
- }
-
- /* setManyAttributes */
- /* inputs:
- * theElement - some DOM element
- * attribArray - an array of strings of attribute names
- * valueArray - an array of strings of the corresponding values
- */
-
- function setManyAttributes(theElement,attribArray,valueArray){
- //alert(theElement.getAttribute("value"))
- for(j=0; j < attribArray.length; j++){
-
- theElement.setAttribute(attribArray[j],valueArray[j]);
-
- }
- }
-
-