home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABListSearchView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  62.4 KB  |  2,448 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. /* 
  19.    ABListSearchView.h -- view of user's mailfilters.
  20.    Created: Tao Cheng <tao@netscape.com>, 17-dec-96
  21.  */
  22.  
  23. #include "Frame.h"
  24. #include "ViewGlue.h"
  25. #include "ABListSearchView.h"
  26. #include "AB2PaneView.h"
  27. #include "ABNameFolderDlg.h"
  28. #include "ABMListDlg.h"
  29.  
  30. #if defined(USE_MOTIF_DND)
  31.  
  32. #include "OutlinerDrop.h"
  33.  
  34. #endif /* USE_MOTIF_DND */
  35.  
  36. #ifdef MOZ_MAIL_NEWS
  37. #include "ABSearchDlg.h"
  38. #include "MNView.h"
  39. #endif
  40. #include "Xfe/Xfe.h"
  41.  
  42. #include <Xm/ArrowB.h>
  43. #include <Xm/Label.h>
  44. #include <Xm/PushB.h>
  45. #include <Xm/TextF.h>
  46.  
  47. extern "C" {
  48. #include "xpassert.h"
  49. #include "xfe.h"
  50. #include "DtWidgets/ComboBox.h"
  51. #include "felocale.h"
  52.  
  53. XP_List* FE_GetDirServers();
  54. ABook*   fe_GetABook(MWContext *context);
  55. };
  56.  
  57. #include "libi18n.h"
  58. #include "intl_csi.h"
  59.  
  60. #include "xpgetstr.h"
  61.  
  62. #include "prefapi.h"
  63.  
  64. const char *XFE_ABListSearchView::dirExpand = 
  65.                                   "XFE_ABListSearchView::dirExpand";
  66. const char *XFE_ABListSearchView::dirsChanged = 
  67.                                   "XFE_ABListSearchView::dirsChanged";
  68. const char *XFE_ABListSearchView::dirSelect = 
  69.                                   "XFE_ABListSearchView::dirSelect";
  70.  
  71. // icons
  72. fe_icon XFE_ABListSearchView::m_personIcon = { 0 };
  73. fe_icon XFE_ABListSearchView::m_listIcon = { 0 };
  74. fe_icon XFE_ABListSearchView::m_securityIcon = { 0 };
  75.  
  76. extern int XFE_AB_SEARCH_DLG;
  77. extern int XFE_AB_SEARCH;
  78. extern int XFE_AB_STOP;
  79. extern int XFE_SEARCH_NO_MATCHES;
  80. extern int XFE_ADDR_ENTRY_ALREADY_EXISTS;
  81. extern int MK_ADDR_ENTRY_ALREADY_EXISTS;
  82.  
  83. #ifndef AB_MAX_STRLEN
  84. #define AB_MAX_STRLEN 1024
  85. #endif
  86.  
  87. #if defined(DEBUG_tao)
  88. #define D(x) printf x
  89. #else
  90. #define D(x)
  91. #endif
  92.  
  93. MenuSpec XFE_ABListSearchView::view_popup_spec[] = {
  94.   { xfeCmdComposeMessage,    PUSHBUTTON },
  95.   MENU_SEPARATOR,
  96.   { xfeCmdABDeleteEntry,PUSHBUTTON },
  97.   MENU_SEPARATOR,
  98.   { xfeCmdViewProperties,    PUSHBUTTON },
  99.   { NULL }
  100. };
  101.  
  102. XFE_ABListSearchView::XFE_ABListSearchView(XFE_Component *toplevel_component,
  103.                                            Widget         /* parent */,
  104.                                            XFE_View      *parent_view, 
  105.                                            MWContext     *context,
  106.                                            XP_List       *directories):
  107.     XFE_MNListView(toplevel_component, parent_view, context, (MSG_Pane *)NULL),
  108.     m_searchingDir(False),
  109.     m_searchStr(NULL),
  110.     m_searchInfo(NULL),
  111.     m_popup(0)
  112. {
  113.  
  114.   /* Initialize
  115.    */
  116. #if defined(USE_ABCOM)
  117.   m_containerInfo = 0;
  118.   m_abContainerPane = 0;
  119.   // TODO: what is the default??
  120.   m_sortType = AB_attribFullName;
  121. #else
  122.   m_sortType = AB_SortByFullNameCmd;
  123. #endif /* USE_ABCOM */
  124.   m_expandBtn = 0;
  125.  
  126.   m_ldapDisabled = False;
  127.   m_filterDirCombo = 0;
  128.   m_filterBoxForm = 0;
  129.   m_filterSearchBtn = 0;
  130.   m_filterStopBtn = 0;
  131.  
  132.   //
  133.   m_typeDownTimer = 0;
  134.  
  135.   // bstell: initialize doc_csid
  136.   INTL_CharSetInfo c = LO_GetDocumentCharacterSetInfo(m_contextData);
  137.   INTL_SetCSIDocCSID(c, fe_LocaleCharSetID);
  138.   INTL_SetCSIWinCSID(c, INTL_DocToWinCharSetID(INTL_GetCSIDocCSID(c)));
  139.  
  140.   /* Establish connection wih backend first
  141.    *
  142.    */
  143.   ((MWContext*)m_contextData)->type = MWContextAddressBook;
  144.   /* Allocate frontend data */
  145.   fe_addrbk_data* d = CONTEXT_DATA(m_contextData)->abdata 
  146.                     = XP_NEW_ZAP(fe_addrbk_data);
  147.  
  148.   /* setting stuff to null, don't remove these 
  149.    */
  150.   d->editlist = NULL;
  151.   d->edituser = NULL;
  152.   d->findshell = NULL;
  153.  
  154.   /* AddressBookPane
  155.    */
  156.   m_abPane = NULL;
  157.   m_dir = NULL;
  158.  
  159. #if defined(USE_ABCOM)
  160.   /* create the pane
  161.    */
  162.   int error = AB_CreateABPane((MSG_Pane **) &m_abPane,
  163.                               (MWContext *) m_contextData, /* or ABfeContext */
  164.                               fe_getMNMaster());
  165.  
  166.   error = 
  167.       AB_SetShowPropertySheetForEntryFunc((MSG_Pane *) m_abPane,
  168.          &XFE_ABListSearchView::ShowPropertySheetForEntryFunc);
  169. #else
  170.   m_AddrBook = fe_GetABook(0);
  171.   m_directories = directories;
  172.  
  173.   int nDirs = XP_ListCount(m_directories);
  174.   XP_ASSERT(nDirs);
  175.   m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories,1);
  176.   XP_ASSERT(m_dir);
  177.  
  178.   AB_InitAddressBookPane(&m_abPane,    /* returned sortPane */
  179.                          m_dir,        /* DIR_Server */
  180.                          m_AddrBook,   /* Address Book */
  181.                          (MWContext *) m_contextData, /* or ABfeContext */
  182.                          fe_getMNMaster(), 
  183.                          ABFullName /*AB_SortByFullNameCmd */, 
  184.                          True);
  185. #endif /* USE_ABCOM */
  186.  
  187.   /* Tao_04dec96: use XFE_MNListView
  188.    * connect pane and view
  189.    * MSG_SetFEData((MSG_Pane *)m_abPane, this);
  190.    */
  191.   setPane((MSG_Pane *)m_abPane);
  192.  
  193.   /* Tao_17dec96
  194.    * register interest in getting allconnectionsComplete
  195.    */
  196.   MWContext *top = XP_GetNonGridContext (context);
  197.   XFE_Frame *f = ViewGlue_getFrame(top);
  198.   if (f)
  199.       f->registerInterest(XFE_Frame::allConnectionsCompleteCallback,
  200.                           this,
  201.                           (XFE_FunctionNotification)allConnectionsComplete_cb);
  202.  
  203. }
  204.  
  205. XFE_ABListSearchView::~XFE_ABListSearchView()
  206. {
  207.     if (m_abPane)
  208. #if defined(USE_ABCOM)
  209.         AB_ClosePane(m_pane);
  210. #else
  211.         AB_CloseAddressBookPane(&m_abPane);
  212. #endif /* USE_ABCOM */
  213.     /* Tao_17dec96
  214.      * register interest ingetting allconnectionsComplete
  215.      */
  216.     MWContext *top = XP_GetNonGridContext (m_contextData);
  217.     XFE_Frame *f = ViewGlue_getFrame(top);
  218.     if (f)
  219.         f->unregisterInterest(XFE_Frame::allConnectionsCompleteCallback,
  220.                               this,
  221.                               (XFE_FunctionNotification)allConnectionsComplete_cb);
  222.  
  223.     //
  224.     if (m_popup)
  225.         delete m_popup;
  226. }
  227.  
  228. #if defined(USE_ABCOM)
  229. int 
  230. XFE_ABListSearchView::ShowPropertySheetForEntryFunc(MSG_Pane *pane,
  231.                                                     MWContext *context)
  232. {
  233. #if defined(DEBUG_tao)
  234.     printf("\nXFE_ABListSearchView::ShowPropertySheetForEntryFunc,pane=0x%x,context=0x%d\n",
  235.            pane,context);
  236. #endif
  237.     MSG_PaneType type = MSG_GetPaneType(pane);
  238.     if (type == AB_PERSONENTRYPANE) {
  239.         return fe_ShowPropertySheetForEntry(pane, context);
  240.     }/* if */
  241.     else if (type == AB_MAILINGLISTPANE) {
  242.         return fe_ShowPropertySheetForMList(pane, context);
  243.     }/* else */
  244.     return FALSE;
  245. }
  246.  
  247. AB_EntryType 
  248. XFE_ABListSearchView::getType(AB_ContainerInfo *container, ABID id)
  249. {
  250.     XP_ASSERT(container && id != AB_ABIDUNKNOWN);
  251.     
  252.     AB_AttributeValue *valueArray = NULL;
  253.     int error = AB_GetEntryAttribute(container,
  254.                                      id,
  255.                                      AB_attribEntryType, 
  256.                                      &valueArray);
  257.     XP_ASSERT(valueArray && valueArray->attrib == AB_attribEntryType);
  258.     AB_EntryType type = AB_Person;
  259.     if (valueArray)
  260.         type = valueArray->u.entryType;
  261.     AB_FreeEntryAttributeValue(valueArray);
  262.     return type;
  263. }
  264.  
  265. AB_EntryType 
  266. XFE_ABListSearchView::getType(MSG_Pane *abPane, MSG_ViewIndex index)
  267. {
  268.     XP_ASSERT(abPane && index != MSG_VIEWINDEXNONE);
  269.     
  270.     AB_AttributeValue *valueArray = NULL;
  271.     int error =  AB_GetEntryAttributeForPane(abPane,
  272.                                              index,
  273.                                              AB_attribEntryType, 
  274.                                              &valueArray);
  275.     XP_ASSERT(valueArray && valueArray->attrib == AB_attribEntryType);
  276.     AB_EntryType type = AB_Person;
  277.     if (valueArray)
  278.         type = valueArray->u.entryType;
  279.     AB_FreeEntryAttributeValue(valueArray);
  280.     return type;
  281. }
  282. #endif /* USE_ABCOM */
  283.  
  284. void XFE_ABListSearchView::setLdapDisabled(XP_Bool b)
  285. {
  286.     m_ldapDisabled = b;
  287. }
  288.  
  289. void XFE_ABListSearchView::idToPerson(DIR_Server *pDir,
  290.                                       ABID entry, PersonEntry* pPerson)
  291. {
  292.     if (pDir && 
  293.         entry != MSG_VIEWINDEXNONE && 
  294.         pPerson) {
  295.         DIR_Server *dir = pDir;
  296.         ABook      *aBook = m_AddrBook;
  297.         
  298.         char        a_line[AB_MAX_STRLEN];
  299.         
  300.         pPerson->WinCSID = m_contextData->fe.data->xfe_doc_csid;
  301.  
  302.         a_line[0] = '\0';
  303.         if (AB_GetNickname(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  304.             pPerson->pNickName = XP_STRDUP(a_line);
  305.         
  306.         a_line[0] = '\0';
  307.         if (AB_GetGivenName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  308.             pPerson->pGivenName = XP_STRDUP(a_line);
  309.         
  310.         a_line[0] = '\0';
  311.         if (AB_GetMiddleName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  312.             pPerson->pMiddleName = XP_STRDUP(a_line);
  313.         
  314.         a_line[0] = '\0';
  315.         if (AB_GetFamilyName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  316.             pPerson->pFamilyName = XP_STRDUP(a_line);
  317.         
  318.         a_line[0] = '\0';
  319.         if (AB_GetCompanyName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  320.             pPerson->pCompanyName = XP_STRDUP(a_line);
  321.         
  322.         a_line[0] = '\0';
  323.         if (AB_GetLocality(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  324.             pPerson->pLocality = XP_STRDUP(a_line);
  325.         
  326.         a_line[0] = '\0';
  327.         if (AB_GetRegion(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  328.             pPerson->pRegion = XP_STRDUP(a_line);
  329.         
  330.         a_line[0] = '\0';
  331.         if (AB_GetEmailAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  332.             pPerson->pEmailAddress = XP_STRDUP(a_line);
  333.       
  334.         a_line[0] = '\0';
  335.         if (AB_GetInfo(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  336.             pPerson->pInfo = XP_STRDUP(a_line);
  337.         
  338.         AB_GetHTMLMail(dir, aBook, entry, &(pPerson->HTMLmail));
  339.         
  340.         a_line[0] = '\0';
  341.         if (AB_GetTitle(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  342.             pPerson->pTitle = XP_STRDUP(a_line);
  343.         
  344.         a_line[0] = '\0';
  345.         if (AB_GetStreetAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  346.             pPerson->pAddress = XP_STRDUP(a_line);
  347.      
  348.         a_line[0] = '\0';
  349.         if (AB_GetPOAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  350.             pPerson->pPOAddress = XP_STRDUP(a_line);
  351.         
  352.         a_line[0] = '\0';
  353.         if (AB_GetZipCode(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  354.             pPerson->pZipCode = XP_STRDUP(a_line);
  355.         
  356.         a_line[0] = '\0';
  357.         if (AB_GetCountry(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  358.             pPerson->pCountry = XP_STRDUP(a_line);
  359.         
  360.         a_line[0] = '\0';
  361.         if (AB_GetWorkPhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  362.             pPerson->pWorkPhone = XP_STRDUP(a_line);
  363.         
  364.         a_line[0] = '\0';
  365.         if (AB_GetFaxPhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  366.             pPerson->pFaxPhone = XP_STRDUP(a_line);
  367.      
  368.         a_line[0] = '\0';
  369.         if (AB_GetHomePhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  370.             pPerson->pHomePhone = XP_STRDUP(a_line);
  371. #if 0
  372.         a_line[0] = '\0';
  373.         if (AB_GetDistName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  374.             pPerson->pDistName = XP_STRDUP(a_line);
  375. #endif
  376.         AB_GetSecurity(dir, aBook, entry, &pPerson->Security);
  377.         
  378.         a_line[0] = '\0';
  379.         if (AB_GetCoolAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  380.             pPerson->pCoolAddress = XP_STRDUP(a_line);
  381.         short use;
  382.         AB_GetUseServer(dir, aBook, entry, &use);
  383.         pPerson->UseServer = use;
  384.     }/* if */
  385. }
  386.  
  387. Boolean  
  388. XFE_ABListSearchView::isCommandEnabled(CommandType cmd, 
  389.                         void */* calldata = NULL */, XFE_CommandInfo*)
  390. {
  391.   uint32 count = 0;
  392.   const int *indices = 0;
  393.   m_outliner->getSelection(&indices, (int *) &count);
  394.   
  395.   AB_CommandType abCmd = (AB_CommandType)~0;
  396.  
  397.   if (cmd == xfeCmdComposeMessage)
  398.     abCmd = AB_NewMessageCmd;
  399.   else if (cmd == xfeCmdAddToAddressBook)
  400.     abCmd = AB_AddUserCmd;
  401.   else if (cmd == xfeCmdABNewList)
  402.     abCmd = AB_AddMailingListCmd;
  403.  
  404.   else if (cmd == xfeCmdImport)
  405.     abCmd = AB_ImportCmd;
  406.   else if (cmd == xfeCmdSaveAs)
  407.     abCmd = AB_SaveCmd;
  408.   else if (cmd == xfeCmdClose)
  409.     abCmd = AB_CloseCmd;
  410.  
  411.   else if (cmd == xfeCmdUndo)
  412.     abCmd = AB_UndoCmd;
  413.   else if (cmd == xfeCmdRedo)
  414.     abCmd = AB_RedoCmd;
  415.   else if (cmd == xfeCmdABDeleteEntry)
  416.     abCmd = AB_DeleteCmd;
  417.   else if (cmd == xfeCmdABSearchEntry)
  418.     abCmd = AB_LDAPSearchCmd; 
  419.   else if (cmd == xfeCmdViewProperties
  420.            || cmd == xfeCmdABEditEntry)
  421.     abCmd = AB_PropertiesCmd;
  422.   else if (cmd == xfeCmdABByType)
  423.     abCmd = AB_SortByTypeCmd;
  424.   else if (cmd == xfeCmdABByName)
  425.     abCmd = AB_SortByFullNameCmd;
  426.   else if (cmd == xfeCmdABByEmailAddress)
  427.     abCmd = AB_SortByEmailAddress;
  428.   else if (cmd == xfeCmdABByCompany)
  429.     abCmd = AB_SortByCompanyName;
  430.   else if (cmd == xfeCmdABByLocality)
  431.     abCmd = AB_SortByLocality;
  432.   else if (cmd == xfeCmdABByNickName)
  433.     abCmd = AB_SortByNickname;
  434.   else if (cmd == xfeCmdSortAscending)
  435.     abCmd = AB_SortAscending;
  436.   else if (cmd == xfeCmdSortDescending)
  437.     abCmd = AB_SortDescending;
  438.  
  439.   else if (cmd == xfeCmdABCall)
  440.     abCmd = AB_CallCmd;
  441.  
  442.   if (cmd == xfeCmdABCall &&
  443.       !fe_IsConferenceInstalled())
  444.       return FALSE;
  445.  
  446.   MSG_COMMAND_CHECK_STATE sState = MSG_NotUsed;
  447.   XP_Bool enable = FALSE, 
  448.           plural = FALSE;
  449.   if (abCmd != ((AB_CommandType)~0))
  450. #if defined(USE_ABCOM)
  451.       AB_CommandStatusAB2(m_pane, abCmd, 
  452.                           (MSG_ViewIndex *)indices, (int32) count, 
  453.                           &enable, &sState, NULL, &plural);
  454. #else
  455.       AB_CommandStatus(m_abPane, abCmd, (MSG_ViewIndex *)indices, count, 
  456.                        &enable, &sState, NULL, &plural);
  457. #endif /* USE_ABCOM */
  458.   return enable;
  459. }/* XFE_AddrBookView::isCommandEnabled() */
  460.  
  461. /* used by toplevel to see which view can handle a command.  Returns true
  462.  * if we can handle it. 
  463.  */
  464. Boolean 
  465. XFE_ABListSearchView::handlesCommand(CommandType cmd, 
  466.                                      void * /* calldata */, 
  467.                                      XFE_CommandInfo* /* i */)
  468. {
  469.     // handle view specific command
  470.   if (cmd == xfeCmdShowPopup
  471.       || cmd == xfeCmdImport
  472.       || cmd == xfeCmdSaveAs
  473.       || cmd == xfeCmdUndo
  474.       || cmd == xfeCmdRedo
  475.       || cmd == xfeCmdABDeleteEntry
  476.       || cmd == xfeCmdFindInObject
  477.       || cmd == xfeCmdFindAgain
  478.       || cmd == xfeCmdSearchAddress
  479.       || cmd == xfeCmdEditPreferences
  480.       || cmd == xfeCmdABByType
  481.       || cmd == xfeCmdABByName
  482.       || cmd == xfeCmdABByEmailAddress
  483.       || cmd == xfeCmdABByCompany
  484.       || cmd == xfeCmdABByLocality
  485.       || cmd == xfeCmdABByNickName
  486.       || cmd == xfeCmdSortAscending
  487.       || cmd == xfeCmdSortDescending
  488.       || cmd == xfeCmdAddToAddressBook
  489.       || cmd == xfeCmdABNewList
  490.       || cmd == xfeCmdViewProperties
  491.       || cmd == xfeCmdDisplayHTMLDomainsDialog
  492.       || cmd == xfeCmdABEditEntry
  493.       || cmd == xfeCmdABDeleteEntry
  494.       || cmd == xfeCmdABCall
  495.       || cmd == xfeCmdABvCard
  496.       || cmd == xfeCmdSelectAll)
  497.       return True;
  498.   return False;
  499.     
  500. }
  501.  
  502. /* this method is used by the toplevel to dispatch a command. */
  503. void 
  504. XFE_ABListSearchView::doCommand(CommandType cmd, 
  505.                                 void * /* calldata */,
  506.                                 XFE_CommandInfo* info)
  507. {
  508.     if (cmd == xfeCmdShowPopup) {
  509.         // Finish up the popup
  510.         int x, y, clickrow;
  511.         XEvent *event = info->event;
  512.  
  513.         m_outliner->translateFromRootCoords(event->xbutton.x_root,
  514.                                             event->xbutton.y_root,
  515.                                             &x, &y);
  516.         clickrow = m_outliner->XYToRow(x, y);
  517.         if (clickrow != -1) {
  518.             /* if it was actually in the outliner's content rows. 
  519.              */
  520.             if (m_popup)
  521.                 delete m_popup;
  522.  
  523.             m_popup = new XFE_PopupMenu("popup",(XFE_Frame *) getToplevel(), 
  524.                                         XfeAncestorFindApplicationShell(getToplevel()->
  525.                                                             getBaseWidget()));
  526.             m_popup->addMenuSpec(view_popup_spec);
  527.             m_popup->position (event);
  528.             m_popup->show();
  529.         }/* if */
  530.     }/* if */
  531.     else if (cmd == xfeCmdSelectAll)
  532.       m_outliner->selectAllItems();
  533.  
  534. }
  535.  
  536. /*
  537.  * Callbacks for outside world
  538.  */
  539. void
  540. XFE_ABListSearchView::newUser()
  541. {
  542. #if defined(USE_ABCOM)
  543.     int error = AB_CommandAB2(m_pane, AB_AddUserCmd, 
  544.                               (MSG_ViewIndex *) NULL, 0);
  545. #else
  546.       popupUserPropertyWindow(MSG_VIEWINDEXNONE, True, True);
  547. #endif /* USE_ABCOM */
  548. }
  549.  
  550. void 
  551. XFE_ABListSearchView::newList()
  552. {
  553. #if defined(USE_ABCOM)
  554.     int error = AB_CommandAB2(m_pane, AB_AddMailingListCmd, 
  555.                               (MSG_ViewIndex *) NULL, 0);
  556. #else
  557.   popupListPropertyWindow(MSG_VIEWINDEXNONE, True, False);
  558. #endif /* USE_ABCOM */
  559. }
  560.  
  561. void 
  562. XFE_ABListSearchView::delUser()
  563. {
  564.   /* check which is selected
  565.    */
  566.   uint32 count = 0;
  567.   const int *indices = 0;
  568.  
  569.  
  570. #if !defined(USE_ABCOM)
  571.   AB_GetEntryCount (m_dir, m_AddrBook, 
  572.                     &count, (ABID) ABTypeAll, 0);
  573. #endif /* USE_ABCOM */
  574.   count = 0;
  575.   m_outliner->getSelection(&indices, (int *) &count);
  576.   if (count > 0 && indices) {
  577.       int first = indices[0];
  578.       /* int AB_Command (ABPane* pane, AB_CommandType command,
  579.        * MSG_ViewIndex* indices, int32 numindices);
  580.        */
  581. #if defined(USE_ABCOM)
  582.       AB_CommandAB2(m_pane, 
  583.                     AB_DeleteCmd, 
  584.                     (MSG_ViewIndex *)indices, count);
  585. #else
  586.       AB_Command((ABPane *) m_abPane, 
  587.                  AB_DeleteCmd, 
  588.                  (MSG_ViewIndex *)indices, count);
  589. #endif /* USE_ABCOM */
  590.       
  591.       /* Tao_04dec96: use XFE_MNListView ???
  592.        */
  593.       AB_GetEntryCount (m_dir, m_AddrBook, 
  594.                         &count, (ABID) ABTypeAll, 0);
  595. #if 0
  596.       m_outliner->change(0, count, count);
  597. #endif
  598.       if (count) {
  599.         
  600.           int pos = (first <= (count-1))?first:(count-1);
  601.           m_outliner->selectItemExclusive(pos);
  602.           m_outliner->makeVisible(pos);
  603.       }/* if */
  604.       getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  605.   }/* if */
  606. }
  607.  
  608. void 
  609. XFE_ABListSearchView::undo()
  610. {
  611.   /* check which is selected
  612.    */
  613.   uint32 count = 0;
  614.   const int *indices = 0;
  615.   m_outliner->getSelection(&indices, (int *) &count);
  616.  
  617.     /* int AB_Command (ABPane* pane, AB_CommandType command,
  618.      * MSG_ViewIndex* indices, int32 numindices);
  619.      */
  620. #if defined(USE_ABCOM)
  621.   AB_CommandAB2(m_pane, 
  622.                 AB_UndoCmd, 
  623.                 (MSG_ViewIndex *)indices, count);
  624. #else
  625.     AB_Command((ABPane *) m_abPane, 
  626.            AB_UndoCmd, 
  627.            (MSG_ViewIndex *)indices, count);
  628. #endif /* USE_ABCOM */
  629.  
  630. #if 0
  631.     /* Tao_04dec96: use XFE_MNListView ???
  632.      */
  633.     AB_GetEntryCount (m_dir, m_AddrBook, 
  634.               &count, (ABID) ABTypeAll, 0);
  635.     m_outliner->change(0, count, count);
  636. #endif
  637.     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  638.  
  639. }
  640.  
  641. void 
  642. XFE_ABListSearchView::redo()
  643. {
  644.   /* check which is selected
  645.    */
  646.   uint32 count = 0;
  647.   const int *indices = 0;
  648.   m_outliner->getSelection(&indices, (int *) &count);
  649.  
  650.     /* int AB_Command (ABPane* pane, AB_CommandType command,
  651.      * MSG_ViewIndex* indices, int32 numindices);
  652.      */
  653. #if defined(USE_ABCOM)
  654.   AB_CommandAB2(m_pane, 
  655.                 AB_RedoCmd, 
  656.                 (MSG_ViewIndex *)indices, count);
  657. #else
  658.     AB_Command((ABPane *) m_abPane, 
  659.            AB_RedoCmd, 
  660.            (MSG_ViewIndex *)indices, count);
  661. #endif /* USE_ABCOM */
  662. #if 0
  663.     /* Tao_04dec96: use XFE_MNListView ???
  664.      */
  665.     AB_GetEntryCount (m_dir, m_AddrBook, 
  666.               &count, (ABID) ABTypeAll, 0);
  667.     m_outliner->change(0, count, count);
  668. #endif
  669.     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  670.  
  671. }
  672.  
  673. void
  674. XFE_ABListSearchView::propertiesCB()
  675. {
  676.     editProperty();
  677. }
  678.  
  679. void 
  680. XFE_ABListSearchView::popupUserPropertyWindow(ABID entry, XP_Bool newuser,
  681.                                               XP_Bool /* modal */)
  682. {
  683. #if defined(USE_ABCOM)
  684.     if (newuser)
  685.         editProperty();
  686.     else
  687.         newUser();
  688. #else
  689.   if (m_dir->dirType == LDAPDirectory) {
  690.       uint32 count = 0;
  691.       const int *indices = 0;
  692.       m_outliner->getSelection(&indices, (int *) &count);
  693.       AB_Command (m_abPane, AB_PropertiesCmd, (MSG_ViewIndex *)indices, count);
  694.   }/* if */
  695.   else {
  696.       fe_showABCardPropertyDlg(getToplevel()->getBaseWidget(),
  697.                                m_contextData,
  698.                                entry,
  699.                                newuser);
  700.       getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  701.   }/* else */
  702. #endif /* USE_ABCOM */
  703. }/* XFE_AddrBookView::popupUserPropertyWindow() */
  704.  
  705. void
  706. XFE_ABListSearchView::popupListPropertyWindow(ABID entry, XP_Bool newuser,
  707.                                               XP_Bool modal)
  708. {
  709.     XFE_ABMListDlg* listDlg = 
  710.         new XFE_ABMListDlg(this, 
  711.                            getToplevel()->getBaseWidget(), 
  712.                            "abMListProperties", 
  713.                            modal, m_contextData);
  714.     listDlg->setDlgValues(entry, newuser);
  715.     listDlg->show();
  716. }/* XFE_ABListSearchView::popupListPropertyWindow() */
  717.  
  718. void 
  719. XFE_ABListSearchView::editProperty()
  720. {
  721.   /* check which is selected
  722.    */
  723.   int count = 0;
  724.   const int *indices = 0;
  725.   m_outliner->getSelection(&indices, &count);
  726.   if (count > 0 && indices) {
  727. #if defined(USE_ABCOM)
  728.       int error = AB_CommandAB2(m_pane, AB_PropertiesCmd, 
  729.                                 (MSG_ViewIndex *)indices, (int32) count);
  730. #else
  731.     /* Take the first one 
  732.      */
  733.     ABID type;
  734.     ABID entry;
  735.  
  736.     entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) indices[0]);
  737.     
  738.     if (entry == MSG_VIEWINDEXNONE) 
  739.       return;
  740.     
  741.     AB_GetType(m_dir, m_AddrBook, entry, &type);
  742.     
  743.     /* Select
  744.     */
  745.     if (type == ABTypePerson)
  746.       popupUserPropertyWindow(entry, False, True);
  747.     else if (type == ABTypeList)
  748.       popupListPropertyWindow(entry, False, True);
  749. #endif /* USE_ABCOM */
  750.   }/* if */
  751. }
  752.  
  753.  
  754. int XFE_ABListSearchView::addToAddressBook() 
  755. {
  756.  
  757.     if (m_dir->dirType != LDAPDirectory)
  758.         return -1;
  759.  
  760.     uint32 count = 0;
  761.     const int *indices = 0;
  762.     m_outliner->getSelection(&indices, (int *) &count);
  763.     DIR_Server *pABDir = NULL;
  764.     DIR_GetPersonalAddressBook(m_directories, &pABDir);
  765.  
  766.     if (!pABDir)
  767.         return -1;
  768.  
  769.     int errorID = -1;
  770.  
  771.     ABID entry;
  772.     PersonEntry pPerson;
  773.     if (count == 1) {
  774.         /* pop up property sheet
  775.          */
  776.         if (MSG_VIEWINDEXNONE == 
  777.             (entry=AB_GetEntryIDAt((AddressPane *) m_abPane, 
  778.                                    (uint32) indices[0])))
  779.             return -1;
  780.  
  781.         pPerson.Initialize();
  782.  
  783.         idToPerson(m_dir, entry, &pPerson);
  784.         if (TRUE == 
  785.             (errorID=FE_ShowPropertySheetFor(m_contextData, 
  786.                                              MSG_VIEWINDEXNONE, &pPerson))) {
  787.  
  788.         }/* if */
  789.         else if (errorID == FALSE) {
  790.  
  791.         }/* else */
  792.         else if (errorID == -1) {
  793.         }/* else if */
  794.  
  795.         pPerson.CleanUp();            
  796.  
  797.     }/* if */
  798.     else {
  799.         for (int i=0; i < count; i++){
  800.             if (MSG_VIEWINDEXNONE == 
  801.                 (entry=AB_GetEntryIDAt((AddressPane *) m_abPane, 
  802.                                        (uint32) indices[i])))
  803.                 continue;
  804.  
  805.             pPerson.Initialize();
  806.             idToPerson(m_dir, entry, &pPerson);
  807.  
  808.             ABID newEntry;
  809.             errorID = AB_AddUser(pABDir, m_AddrBook, 
  810.                                  &pPerson, &newEntry);
  811.             if (errorID != 0 ||
  812.                 newEntry == MSG_VIEWINDEXNONE) {
  813.                 if (MK_ADDR_ENTRY_ALREADY_EXISTS == errorID)
  814.                     fe_Alert_2(getBaseWidget(),
  815.                                XP_GetString(XFE_ADDR_ENTRY_ALREADY_EXISTS));
  816.                 else {
  817.                     char tmp[128];
  818.                     XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  819.                                     "%s",
  820.                                     XP_GetString(errorID));
  821.                     fe_Alert_2(getBaseWidget(), tmp);
  822.                 }/* else */
  823.             }/* if */
  824.             pPerson.CleanUp();            
  825.         }/* for i */
  826.     }/* else */
  827.     return TRUE;
  828. }
  829.  
  830. void 
  831. XFE_ABListSearchView::paneChanged(XP_Bool asynchronous,
  832.                                   MSG_PANE_CHANGED_NOTIFY_CODE notify_code,
  833.                                   int32 value)
  834. {
  835. #if defined(DEBUG_tao)
  836.     printf("\nXFE_ABListSearchView::paneChanged, asynchronous=%d, notify_code=%d, value=0x%x", asynchronous, notify_code, value);
  837. #endif
  838.     // remove the timer
  839.     if (m_typeDownTimer) {
  840.         XtRemoveTimeOut(m_typeDownTimer);
  841.         m_typeDownTimer = 0;
  842.     }/* if */
  843.  
  844. #if defined(USE_ABCOM)
  845.     // rewrite with new APIs
  846.     XP_ASSERT(0);
  847.  
  848. #else
  849.     /* Shall we free existing list ?
  850.      */
  851.     m_directories = FE_GetDirServers();
  852.     int nDirs = XP_ListCount(m_directories);
  853.     XP_Bool found = False;
  854.     for (int i=0; i < nDirs; i++) {
  855.         DIR_Server *dir = 
  856.             (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1);
  857.         if (dir == m_dir ||
  858.             (dir && m_dir && 
  859.              (dir->dirType == m_dir->dirType))) {
  860.             if ((dir->serverName==NULL && m_dir->serverName==NULL) ||
  861.                 (dir->serverName && m_dir->serverName &&
  862.                  !XP_STRCMP(dir->serverName, m_dir->serverName))) {
  863.                 found = True;
  864.                 break;
  865.             }/* if */
  866.         }/* if */
  867.     }/* for i*/
  868.  
  869.     if (!found) {
  870.         /* m_dir got deleted
  871.          */
  872.         m_dir = NULL;
  873.         if (nDirs) {
  874.             /* lucky me!!
  875.              * assign the first one
  876.              */
  877.             m_dir = (DIR_Server *) XP_ListGetObjectNum(m_directories, 1);
  878.         }/* if */
  879.     }/* if */
  880.  
  881.     /* And the combo list
  882.      */
  883.     refreshCombo();
  884.  
  885.     /* notify parent
  886.      */
  887.     notifyInterested(XFE_ABListSearchView::dirsChanged, m_directories);
  888. #endif 
  889. }
  890.  
  891. void
  892. XFE_ABListSearchView::refreshCombo()
  893. {
  894.     // remove the timer
  895.     if (m_typeDownTimer) {
  896.         XtRemoveTimeOut(m_typeDownTimer);
  897.         m_typeDownTimer = 0;
  898.     }/* if */
  899.  
  900. #if defined(USE_ABCOM)
  901.     uint32 nDirs = 0;
  902.     XFE_AB2PaneView *parV = (XFE_AB2PaneView *) getParent();
  903.     const AB_ContainerInfo **ctrArray = parV->getRootContainers(nDirs);
  904.  
  905.     XmString xmstr = 0;
  906.     for (int i=0; i < nDirs; i++) {
  907.         const DIR_Server *dir = 
  908.             AB_GetDirServerForContainer((AB_ContainerInfo *) ctrArray[i]);
  909.         
  910.         if (dir) {
  911.             if (m_ldapDisabled && 
  912.                 dir->dirType == LDAPDirectory)
  913.                 continue;
  914.             
  915.             xmstr = XmStringCreateLtoR(dir->description, 
  916.                                        XmSTRING_DEFAULT_CHARSET);
  917.             DtComboBoxAddItem(m_filterDirCombo, xmstr, 0, True );
  918.             // 
  919.             XmStringFree(xmstr);
  920.         }/* if */
  921.     }/* for i*/
  922.  
  923.     // set the current dir
  924.     // use containerInfo
  925.     if (m_dir) {
  926.         if (m_dir->description) {
  927.             xmstr = XmStringCreateLtoR(m_dir->description, 
  928.                                        XmSTRING_DEFAULT_CHARSET);
  929.             DtComboBoxSelectItem(m_filterDirCombo, xmstr);
  930.             XmStringFree(xmstr);
  931.         }/* if */
  932.  
  933.         // TODO: convert to abcom
  934.         AB_ChangeDirectory(m_abPane, m_dir);
  935.     }/* if */
  936.  
  937.  
  938. #else
  939.     if (m_directories) {
  940.         DtComboBoxDeleteAllItems(m_filterDirCombo);
  941.         int nDirs = XP_ListCount(m_directories);
  942.         XmString xmstr;
  943.         for (int i=0; i < nDirs; i++) {
  944.             DIR_Server *dir = 
  945.                 (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1);
  946.             if (dir) {
  947.                 if (m_ldapDisabled && 
  948.                     dir->dirType == LDAPDirectory)
  949.                     continue;
  950.                 xmstr = XmStringCreateLtoR(dir->description, 
  951.                                            XmSTRING_DEFAULT_CHARSET);
  952.                 DtComboBoxAddItem(m_filterDirCombo, xmstr, 0, True );
  953.                 XmStringFree(xmstr);
  954.             }/* if */
  955.         }/* for i*/
  956.  
  957.         // set the current dir
  958.         if (m_dir) {
  959.             if (m_dir->description) {
  960.                 xmstr = XmStringCreateLtoR(m_dir->description, 
  961.                                            XmSTRING_DEFAULT_CHARSET);
  962.                 DtComboBoxSelectItem(m_filterDirCombo, xmstr);
  963.                 XmStringFree(xmstr);
  964.             }/* if */
  965.             AB_ChangeDirectory(m_abPane, m_dir);
  966.         }/* if */
  967.     }/* if */
  968. #endif
  969. }
  970.  
  971. Widget
  972. XFE_ABListSearchView::makeFilterBox(Widget parent, XP_Bool stopBtn)
  973. {
  974.   /* Create simple search area
  975.    */
  976.  
  977.   /* child widgets
  978.    */
  979.   Widget filterPrompt;
  980.   Widget filterTypeIn;
  981.  
  982.   /* The form
  983.    */
  984.   m_filterBoxForm = XtVaCreateManagedWidget("filterBoxForm",
  985.                                             xmFormWidgetClass,
  986.                                             parent,
  987.                                             NULL);
  988.  
  989.   // create the arrow button stuff
  990.  
  991.   m_collapsedForm = XtVaCreateManagedWidget("collapsdForm",
  992.                                            xmFormWidgetClass,
  993.                                            m_filterBoxForm,
  994.                                            // XmNallowResize, FALSE,
  995.                                            // XmNskipAdjust, TRUE,
  996.                                            NULL);
  997.  
  998.   m_expandBtn = XtVaCreateManagedWidget("expandBtn",
  999.                                         xmArrowButtonWidgetClass,
  1000.                                         m_collapsedForm,
  1001.                                         XmNleftAttachment, XmATTACH_FORM,
  1002.                                         XmNtopAttachment, XmATTACH_FORM,
  1003.                                         XmNbottomAttachment, XmATTACH_FORM,
  1004.                                         XmNrightAttachment, XmATTACH_NONE,
  1005.                                         XmNarrowDirection, XmARROW_DOWN,
  1006.                                         XmNshadowThickness, 0,
  1007.                                         NULL);
  1008.  
  1009.   XtAddCallback(m_expandBtn, 
  1010.                 XmNactivateCallback, expandCallback, this);
  1011.  
  1012.   Arg av [20];
  1013.   int ac = 0;
  1014.  
  1015. #if 0
  1016.   XP_Bool ldapDisabled = False;
  1017.   PREF_GetBoolPref("mail.addr_book.ldap.disabled",&ldapDisabled);
  1018. #if 0
  1019.   XP_Bool locked = False;
  1020.   locked = PREF_PrefIsLocked("mail.addr_book.ldap.disabled");
  1021.   if (ldapDisabled || locked)
  1022.       ldapDisabled = True;
  1023. #endif
  1024.  
  1025. #else
  1026.   /* Combo Box
  1027.    */
  1028.   /* Get visual, colormap, and depth first???
  1029.    */
  1030.   Visual   *v = 0;
  1031.   Colormap  cmap = 0;
  1032.   Cardinal  depth = 0;
  1033.   XtVaGetValues (getToplevel()->getBaseWidget(), 
  1034.                  XmNvisual, &v, 
  1035.                  XmNcolormap, &cmap,
  1036.                  XmNdepth, &depth, 
  1037.                  NULL);
  1038.  
  1039.   /* Create a combobox for storing directories 
  1040.    */
  1041.   ac = 0;
  1042.  
  1043.   XtSetArg (av[ac], XmNvisual, v); ac++;
  1044.   XtSetArg (av[ac], XmNcolormap, cmap); ac++;
  1045.   XtSetArg (av[ac], XmNdepth, depth); ac++;
  1046.   XtSetArg (av[ac], XmNmoveSelectedItemUp, False); ac++;
  1047.   XtSetArg (av[ac], XmNtype, XmDROP_DOWN_LIST_BOX); ac++;
  1048.   XtSetArg (av[ac], XmNvisibleItemCount, 8); ac++; 
  1049.  
  1050.   m_filterDirCombo = DtCreateComboBox(m_collapsedForm, 
  1051.                       "filterDirCombo", av,ac);
  1052.   XtVaSetValues(m_filterDirCombo,
  1053.                 XmNleftAttachment, XmATTACH_WIDGET,
  1054.                 XmNleftWidget, m_expandBtn,
  1055.                 XmNtopAttachment, XmATTACH_FORM,
  1056.                 XmNrightAttachment, XmATTACH_FORM,
  1057.                 XmNbottomAttachment, XmATTACH_FORM,
  1058.                 NULL);
  1059.   XtManageChild(m_filterDirCombo);
  1060.  
  1061.   // Add fake items to comboBox
  1062.   XP_Bool ldapDisabled = False;
  1063.   PREF_GetBoolPref("mail.addr_book.ldap.disabled",&ldapDisabled);
  1064. #if 0
  1065.   XP_Bool locked = False;
  1066.   locked = PREF_PrefIsLocked("mail.addr_book.ldap.disabled");
  1067.   if (ldapDisabled || locked)
  1068.       ldapDisabled = True;
  1069. #endif
  1070.  
  1071.   XmString xmstr;
  1072. #if defined(USE_ABCOM)
  1073.  
  1074.     uint32 nDirs = 0;
  1075.     XFE_AB2PaneView *parV = (XFE_AB2PaneView *) getParent();
  1076.     const AB_ContainerInfo **ctrArray = parV->getRootContainers(nDirs);
  1077.  
  1078.     for (int i=0; i < nDirs; i++) {
  1079.         const DIR_Server *dir = 
  1080.             AB_GetDirServerForContainer((AB_ContainerInfo *) ctrArray[i]);
  1081.  
  1082.         if (dir) {
  1083.             if (ldapDisabled && 
  1084.                 dir->dirType == LDAPDirectory)
  1085.                 continue;
  1086.             
  1087.             xmstr = XmStringCreateLtoR(dir->description, 
  1088.                                        XmSTRING_DEFAULT_CHARSET);
  1089.             DtComboBoxAddItem(m_filterDirCombo, xmstr, 0, True );
  1090.             // 
  1091.             XmStringFree(xmstr);
  1092.         }/* if */
  1093.     }/* for i*/
  1094. #else
  1095.   DIR_Server *dirTop = NULL;
  1096.   int nDirs = XP_ListCount(m_directories);
  1097.   for (int i=0; i < nDirs; i++) {
  1098.     DIR_Server *dir = (DIR_Server *) XP_ListGetObjectNum(m_directories,i+1);
  1099.     if (dir) {
  1100.         if (ldapDisabled && 
  1101.             dir->dirType == LDAPDirectory)
  1102.             continue;
  1103.  
  1104.      xmstr = XmStringCreateLtoR(dir->description, 
  1105.                 XmSTRING_DEFAULT_CHARSET);
  1106.      DtComboBoxAddItem(m_filterDirCombo, xmstr, 0, True );
  1107.      // 
  1108.      if (!dirTop)
  1109.          dirTop = dir;
  1110.      XmStringFree(xmstr);
  1111.     }/* if */
  1112.   }/* for i*/
  1113.  
  1114.   // search button sensitivity
  1115.   XP_Bool searchOn = True;
  1116.   if (dirTop) {
  1117.       if (dirTop->dirType == PABDirectory) {
  1118.           searchOn = False;
  1119.      }/* if */
  1120.       else {
  1121.           searchOn = True;
  1122.       }/* else */
  1123.   }/* if */
  1124. #endif /* USE_ABCOM */
  1125.  
  1126. #endif /* !0 */
  1127.   /* Prompt
  1128.    */
  1129.   filterPrompt = XtVaCreateManagedWidget("filterPrompt",
  1130.                                          xmLabelWidgetClass,
  1131.                                          m_filterBoxForm,
  1132.                                          XmNtopAttachment, XmATTACH_FORM,
  1133.                                          XmNtopOffset, 4,
  1134.                                          XmNleftAttachment, XmATTACH_FORM,
  1135.                                          XmNleftOffset, 2,
  1136.                                          XmNrightAttachment, XmATTACH_NONE,
  1137.                                          XmNbottomAttachment, XmATTACH_NONE,
  1138.                                          NULL);
  1139.   m_filterPrompt = filterPrompt;
  1140.  
  1141.  
  1142.   XtVaSetValues(m_collapsedForm,
  1143.                 XmNleftAttachment, XmATTACH_FORM,
  1144.                 XmNtopAttachment, XmATTACH_WIDGET,
  1145.                 XmNtopWidget, filterPrompt,
  1146.                 XmNtopOffset, 4,
  1147.                 XmNrightAttachment, XmATTACH_NONE,
  1148.                 XmNbottomAttachment, XmATTACH_FORM,
  1149.                 NULL);
  1150.   filterTypeIn = XtVaCreateManagedWidget("filterTypeIn",
  1151.                                          xmTextFieldWidgetClass,
  1152.                                          m_filterBoxForm,
  1153.                                          XmNtopAttachment, XmATTACH_WIDGET,
  1154.                                          XmNtopWidget, filterPrompt,
  1155.                                          XmNtopOffset, 4,
  1156.                                          XmNleftAttachment, XmATTACH_WIDGET,
  1157.                                          XmNleftWidget, m_collapsedForm,
  1158.                                          XmNleftOffset, 3,
  1159.                                          XmNrightAttachment, XmATTACH_NONE,
  1160.                                          XmNbottomAttachment, XmATTACH_FORM,
  1161.                                          //XmNbottomOffset, 3,
  1162.                                          NULL);
  1163.  
  1164.   /* stop button
  1165.    */
  1166.   if (stopBtn) {
  1167.       ac = 0;
  1168.       XtSetArg(av[ac], XmNwidth, 100); ac++;
  1169. #if !defined(USE_ABCOM)
  1170.       XtSetArg(av[ac], XtNsensitive, False), ac++;
  1171. #endif
  1172.       XtSetArg(av[ac], XmNrecomputeSize, False), ac++;
  1173.       m_filterStopBtn = XmCreatePushButton(m_filterBoxForm, 
  1174.                                              "filterStopBtn", 
  1175.                                              av, ac);
  1176.       if (!ldapDisabled)
  1177.           XtManageChild(m_filterStopBtn);
  1178.       
  1179.       XtVaSetValues(m_filterStopBtn,
  1180.                     XmNleftAttachment, XmATTACH_NONE,
  1181.                     XmNtopAttachment, XmATTACH_NONE,
  1182.                     XmNrightAttachment, XmATTACH_FORM,
  1183.                     XmNbottomAttachment, XmATTACH_FORM,
  1184.                     XmNrightOffset, 4,
  1185.                     XmNbottomOffset, 4,
  1186.                     NULL);
  1187.   }/* if */
  1188.  
  1189.   /* search button
  1190.    */
  1191.   ac = 0;
  1192.   XtSetArg(av[ac], XmNwidth, 100); ac++;
  1193. #if !defined(USE_ABCOM)
  1194.   XtSetArg(av[ac], XtNsensitive, searchOn), ac++;
  1195. #endif
  1196.   XtSetArg(av[ac], XmNrecomputeSize, False), ac++;
  1197.   m_filterSearchBtn = XmCreatePushButton(m_filterBoxForm, 
  1198.                      "filterSearchBtn", 
  1199.                      av, ac);
  1200.   if (!ldapDisabled)
  1201.       XtManageChild(m_filterSearchBtn);
  1202.  
  1203.   if (stopBtn)
  1204.       XtVaSetValues(m_filterSearchBtn,
  1205.                     XmNleftAttachment, XmATTACH_NONE,
  1206.                     XmNtopAttachment, XmATTACH_NONE,
  1207.                     XmNrightAttachment, XmATTACH_WIDGET,
  1208.                     XmNrightWidget, m_filterStopBtn,
  1209.                     XmNbottomAttachment, XmATTACH_FORM,
  1210.                     XmNrightOffset, 3,
  1211.                     XmNbottomOffset, 4,
  1212.                     NULL);
  1213.   else
  1214.       XtVaSetValues(m_filterSearchBtn,
  1215.                     XmNleftAttachment, XmATTACH_NONE,
  1216.                     XmNtopAttachment, XmATTACH_NONE,
  1217.                     XmNrightAttachment, XmATTACH_FORM,
  1218.                     XmNbottomAttachment, XmATTACH_FORM,
  1219.                     XmNrightOffset, 4,
  1220.                     XmNbottomOffset, 4,
  1221.                     NULL);
  1222.   if (stopBtn)
  1223.       XtVaSetValues(filterTypeIn,
  1224.                     XmNrightAttachment, XmATTACH_WIDGET,
  1225.                     XmNrightWidget, m_filterSearchBtn,
  1226.                     XmNrightOffset, 2,
  1227.                     NULL);
  1228.   
  1229.  
  1230.   /* m_filterBoxForm
  1231.    */
  1232.   XtVaSetValues(m_filterBoxForm,
  1233.                 XmNleftAttachment, XmATTACH_FORM,
  1234.                 XmNtopAttachment, XmATTACH_FORM,
  1235.                 XmNrightAttachment, XmATTACH_FORM,
  1236.                 XmNbottomAttachment, XmATTACH_NONE,
  1237.                 NULL);
  1238.  
  1239.   /* manage this form
  1240.    */
  1241.   XtManageChild(m_filterBoxForm);
  1242.  
  1243.   /* Provide callbacks as for entries outside world
  1244.    */
  1245.   XtAddCallback(m_filterDirCombo, 
  1246.         XmNselectionCallback, 
  1247.         XFE_ABListSearchView::comboSelCallback, 
  1248.         this);
  1249.   XtAddCallback(filterTypeIn, 
  1250.         XmNvalueChangedCallback, 
  1251.         XFE_ABListSearchView::typeDownCallback, 
  1252.         this);
  1253.   XtAddCallback(filterTypeIn, 
  1254.         XmNactivateCallback, 
  1255.         XFE_ABListSearchView::typeActivateCallback, 
  1256.         this);
  1257.  
  1258.   XtAddCallback(m_filterSearchBtn, 
  1259.         XmNactivateCallback,
  1260.         XFE_ABListSearchView::searchCallback, 
  1261.         this);
  1262.  
  1263.   if (stopBtn)
  1264.       XtAddCallback(m_filterStopBtn, 
  1265.                     XmNactivateCallback,
  1266.                     XFE_ABListSearchView::searchCallback, 
  1267.                     this);
  1268.  
  1269.   return m_filterBoxForm;
  1270. }
  1271.  
  1272. void XFE_ABListSearchView::layout()
  1273. {
  1274.  
  1275.   XtVaSetValues(m_outliner->getBaseWidget(),
  1276.                 XmNleftAttachment, XmATTACH_FORM,
  1277.                 XmNtopAttachment, XmATTACH_FORM,
  1278.                 XmNrightAttachment, XmATTACH_FORM,
  1279.                 XmNbottomAttachment, XmATTACH_FORM,
  1280.                 NULL);
  1281.  
  1282. }
  1283.  
  1284. XFE_CALLBACK_DEFN(XFE_ABListSearchView, allConnectionsComplete)(XFE_NotificationCenter */*obj*/, 
  1285.                                 void */*clientData*/, 
  1286.                                 void */* callData */)
  1287. {
  1288.   stopSearch();
  1289. }
  1290.  
  1291. void
  1292. XFE_ABListSearchView::searchCallback(Widget w, 
  1293.                                      XtPointer clientData, 
  1294.                                      XtPointer callData)
  1295. {
  1296.   XFE_ABListSearchView *obj = (XFE_ABListSearchView *) clientData;
  1297.  
  1298.   if (!obj->isSearching())
  1299.       obj->searchDlg(w, callData);
  1300.   else
  1301.       obj->searchCB(w, callData);
  1302.  
  1303. }
  1304. void
  1305. XFE_ABListSearchView::searchDlg(Widget /* w */, 
  1306.                                 XtPointer /* callData */)
  1307. {
  1308.     if (!m_searchInfo) {
  1309.         m_searchInfo = 
  1310.             (ABSearchInfo_t *) XP_CALLOC(1, sizeof(ABSearchInfo_t));
  1311.         m_searchInfo->m_mode = AB_SEARCH_BASIC;
  1312.         m_searchInfo->m_obj = this;
  1313.         m_searchInfo->m_cbProc = &(XFE_ABListSearchView::searchDlgCB);
  1314.         m_searchInfo->m_logicOp = True; // and
  1315.     }/* if */
  1316.     m_searchInfo->m_dir = m_dir;
  1317.  
  1318.     fe_showABSearchDlg(getToplevel()->getBaseWidget(),
  1319.                        m_contextData,
  1320.                        m_searchInfo);
  1321. }
  1322.  
  1323. void
  1324. XFE_ABListSearchView::expandCallback(Widget /* w */, 
  1325.                                      XtPointer clientData, 
  1326.                                      XtPointer /* callData */)
  1327. {
  1328.   XFE_ABListSearchView *obj = (XFE_ABListSearchView *) clientData;
  1329.   obj->notifyInterested(XFE_ABListSearchView::dirExpand);
  1330. }
  1331.  
  1332. void
  1333. XFE_ABListSearchView::searchCB(Widget /* w */, 
  1334.                XtPointer /* callData */)
  1335. {
  1336.     // remove the timer
  1337.     if (m_typeDownTimer) {
  1338.         XtRemoveTimeOut(m_typeDownTimer);
  1339.         m_typeDownTimer = 0;
  1340.     }/* if */
  1341.  
  1342.     if (m_dir && m_dir->dirType == LDAPDirectory) {
  1343.         if (!m_searchingDir) {
  1344.             if (m_searchStr &&
  1345.                 XP_STRLEN(m_searchStr)) {
  1346. #if defined(USE_ABCOM)
  1347.                 int error = AB_SearchDirectoryAB2(m_pane,
  1348.                                                   m_searchStr);
  1349. #else
  1350.                 AB_SearchDirectory(m_abPane, m_searchStr);
  1351. #endif /* USE_ABCOM */
  1352.                 m_searchingDir = True;
  1353.                 
  1354.                 if (m_filterStopBtn) {
  1355.                     XtSetSensitive(m_filterSearchBtn, False);
  1356.                     XtSetSensitive(m_filterStopBtn, True);
  1357.                 }/* if */
  1358.                 else {
  1359. #if 1                    
  1360.                     XtSetSensitive(m_filterSearchBtn, False);
  1361.                     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  1362. #else
  1363.                     /* change label to Stop
  1364.                      */
  1365.                     fe_SetString(w, XmNlabelString, 
  1366.                                  XP_GetString(XFE_AB_STOP));
  1367. #endif
  1368.                 }/* else */
  1369.             }/* if */
  1370.         }/* if */
  1371.         else
  1372.             stopSearch();
  1373.     }/* if */
  1374. }/* XFE_AddrSearchView::searchCB() */
  1375.  
  1376. void XFE_ABListSearchView::stopSearch()
  1377. {
  1378.   /* Stop 
  1379.    */
  1380. #if defined(USE_ABCOM)
  1381.   int error = AB_FinishSearchAB2(m_pane);
  1382. #else
  1383.   AB_FinishSearch(m_abPane, m_contextData);
  1384. #endif /* USE_ABCOM */
  1385.   m_searchingDir = False;
  1386.   
  1387.   if (m_filterStopBtn) {
  1388.       XtSetSensitive(m_filterSearchBtn, True);
  1389.       XtSetSensitive(m_filterStopBtn, False);
  1390.   }/* if */
  1391.   else {
  1392. #if 1
  1393.       XtSetSensitive(m_filterSearchBtn, True);
  1394.       getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  1395. #else
  1396.       /* change label to Search
  1397.        */
  1398.       fe_SetString(m_filterSearchBtn, 
  1399.                    XmNlabelString, XP_GetString(XFE_AB_SEARCH_DLG));
  1400. #endif
  1401.   }/* else */
  1402.   
  1403.   uint32 count = 0;
  1404. #if defined(USE_ABCOM)
  1405.   count = MSG_GetNumLines(m_pane);
  1406. #else
  1407.   AB_GetEntryCount (m_dir, m_AddrBook, 
  1408.             &count, (ABID) ABTypeAll, 0);
  1409. #endif
  1410.  
  1411. #if defined(DEBUG_tao)
  1412.     printf("\n XFE_ABListSearchView::stopSearch=%d,count=%d", 
  1413.          m_outliner->getTotalLines(), count);
  1414. #endif
  1415.  
  1416.   if (!count) {
  1417.       char tmp[128];
  1418.       XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  1419.                       "%s",
  1420.                       XP_GetString(XFE_SEARCH_NO_MATCHES));
  1421.       fe_Alert_2(getBaseWidget(), tmp);
  1422.   }/* if */
  1423.   getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  1424.  
  1425. }/* */
  1426.  
  1427. XP_Bool XFE_ABListSearchView::isAscending()
  1428. {
  1429. #if defined(USE_ABCOM)
  1430.     return True; //AB_GetPaneSortedAscendingAB2(m_pane);
  1431. #else
  1432.     return AB_GetPaneSortedAscending(m_abPane);
  1433. #endif /* USE_ABCOM */
  1434. }
  1435.  
  1436. void XFE_ABListSearchView::setAscending(XP_Bool as)
  1437. {
  1438.   /* If need to re-sort
  1439.    */
  1440.   if (as != isAscending() || as != m_ascending) {
  1441.     /* Flip
  1442.      */
  1443.  
  1444. #if defined(USE_ABCOM)
  1445.       setSortType(m_sortType); 
  1446. #else
  1447.       setSortType((AB_CommandType)m_sortType); 
  1448. #endif /* USE_ABCOM */
  1449.   }/* if */
  1450. }
  1451.  
  1452. #if defined(USE_ABCOM)
  1453. void           
  1454. XFE_ABListSearchView::setSortType(AB_AttribID id)
  1455. {
  1456.     int error = AB_SortByAttribute(m_pane, id, m_ascending);
  1457.  
  1458.     // we shall not need to do so; but, just in case.
  1459.     m_outliner->invalidate();
  1460. }
  1461.  
  1462. AB_AttribID
  1463. XFE_ABListSearchView::getSortType()
  1464. {
  1465.     AB_AttribID attribID = AB_attribUnknown;
  1466.     int error = AB_GetPaneSortedByAB2(m_pane,
  1467.                                       &attribID);
  1468.     return attribID;
  1469. }
  1470.  
  1471. #else
  1472. ABID XFE_ABListSearchView::getSortType()
  1473. {
  1474.   return AB_GetPaneSortedBy(m_abPane);
  1475. }
  1476.  
  1477. void XFE_ABListSearchView::setSortType(AB_CommandType type)
  1478. {
  1479.    switch (type) {
  1480.    case AB_SortByNickname:
  1481.    case AB_SortByCompanyName:
  1482.    case AB_SortByLocality:
  1483.    case AB_SortByTypeCmd:
  1484.    case AB_SortByFullNameCmd:
  1485.    case AB_SortByEmailAddress:
  1486.     AB_Command(m_abPane, type, NULL, 0);
  1487.     /* Flip m_ascending if same type is called
  1488.      */
  1489.     if (m_sortType == type)
  1490.       m_ascending = m_ascending?False:True;
  1491.     m_sortType = type;
  1492.     m_outliner->invalidate();
  1493.     break;
  1494.  
  1495.  
  1496.    default:
  1497.      XP_ASSERT(0);
  1498.      break;
  1499.   }/* switch */
  1500.  
  1501. }
  1502. #endif /* USE_ABCOM */
  1503.  
  1504.  
  1505. /* Methods for the outlinable interface.
  1506.  */
  1507. // Converts between an index and some non positional data type.
  1508. // Used to maintain selection when the list is reordered.
  1509. void *
  1510. XFE_ABListSearchView::ConvFromIndex(int /*index*/)
  1511. {
  1512.   return 0;
  1513. }
  1514.  
  1515. // Converts between an index and some non positional data type.
  1516. // Used to maintain selection when the list is reordered.
  1517. int
  1518. XFE_ABListSearchView::ConvToIndex(void */*item*/)
  1519. {
  1520.   return 0;
  1521. }
  1522.  
  1523. char *
  1524. XFE_ABListSearchView::getColumnName(int /*column*/)
  1525. {
  1526.   return 0;
  1527. }
  1528.  
  1529. /* This method acquires one line of data: entryID is set for getColumnText
  1530.  */
  1531. /* This method acquires one line of data: entryID is set for getColumnText
  1532.  */
  1533. void*
  1534. XFE_ABListSearchView::acquireLineData(int line)
  1535. {
  1536. #if defined(USE_ABCOM)
  1537.     int error = AB_GetABIDForIndex(m_pane,
  1538.                                    (MSG_ViewIndex) line,
  1539.                                    &m_entryID);
  1540. #else
  1541.   m_entryID = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) line);
  1542. #endif /* USE_ABCOM */
  1543.  
  1544.   if (m_entryID == MSG_VIEWINDEXNONE)
  1545.     return 0;
  1546.   else
  1547.     return (void*)m_entryID;
  1548. }
  1549.  
  1550. // Returns the text and/or icon to display at the top of the column.
  1551. fe_icon*
  1552. XFE_ABListSearchView::getColumnHeaderIcon(int /*column*/)
  1553. {
  1554.   return 0;
  1555. }
  1556.  
  1557. // Returns the text and/or icon to display at the top of the column.
  1558. EOutlinerTextStyle 
  1559. XFE_ABListSearchView::getColumnHeaderStyle(int /*column*/)
  1560. {
  1561.   return OUTLINER_Default;
  1562. }
  1563.  
  1564. /*
  1565.  * The following 4 requests deal with the currently acquired line.
  1566.  */
  1567. EOutlinerTextStyle 
  1568. XFE_ABListSearchView::getColumnStyle(int /*column*/)
  1569. {
  1570.   /* To be refined
  1571.    */
  1572.   return OUTLINER_Default;
  1573. }
  1574.  
  1575. //
  1576. void
  1577. XFE_ABListSearchView::getTreeInfo(XP_Bool */*expandable*/,
  1578.                    XP_Bool */*is_expanded*/, 
  1579.                    int *depth, 
  1580.                    OutlinerAncestorInfo **/*ancestor*/)
  1581. {
  1582.   depth = 0;
  1583. }
  1584.  
  1585. //
  1586. void 
  1587. XFE_ABListSearchView::Buttonfunc(const OutlineButtonFuncData* data)
  1588. {
  1589.   int row = data->row, 
  1590.       clicks = data->clicks;
  1591.  
  1592.   // focus
  1593.   notifyInterested(XFE_MNListView::changeFocus, this);
  1594.  
  1595.   if (row < 0) {
  1596.       // focus
  1597.       notifyInterested(XFE_View::chromeNeedsUpdating, this);
  1598.  
  1599.       clickHeader(data);
  1600.       return;
  1601.   } 
  1602.   else {
  1603.       /* content row 
  1604.        */
  1605.       ABID entry;
  1606.       
  1607. #if defined(USE_ABCOM)
  1608.       int error = AB_GetABIDForIndex(m_pane,
  1609.                                      (MSG_ViewIndex) row,
  1610.                                      &entry);
  1611. #else
  1612.       entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) row);
  1613. #endif /* USE_ABCOM */
  1614.  
  1615.       if (entry == MSG_VIEWINDEXNONE) 
  1616.           return;
  1617.       
  1618.       if (clicks == 2) {
  1619.           m_outliner->selectItemExclusive(data->row);
  1620.           doubleClickBody(data);
  1621.       }/* clicks == 2 */
  1622.       else if (clicks == 1) {
  1623.           if (data->ctrl)
  1624.               {
  1625.                   m_outliner->toggleSelected(data->row);
  1626.               }
  1627.           else if (data->shift) {
  1628.               // select the range.
  1629.               const int *selected = 0;
  1630.               int count = 0;
  1631.   
  1632.               m_outliner->getSelection(&selected, &count);
  1633.               
  1634.               if (count == 0) { /* there wasn't anything selected yet. */
  1635.                   m_outliner->selectItemExclusive(data->row);
  1636.               }/* if count == 0 */
  1637.               else if (count == 1) {
  1638.                   /* there was only one, so we select the range from
  1639.                      that item to the new one. */
  1640.                   m_outliner->selectRangeByIndices(selected[0], data->row);
  1641.               }/* count == 1 */
  1642.               else {
  1643.                   /* we had a range of items selected, 
  1644.                    * so let's do something really
  1645.                    * nice with them. */
  1646.                   m_outliner->trimOrExpandSelection(data->row);
  1647.               }/* else */
  1648.           }/* if */
  1649.           else {
  1650.               m_outliner->selectItemExclusive(data->row);
  1651.           }/* else */
  1652.  
  1653.           getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  1654.       }/* clicks == 1 */
  1655.   }/* else */
  1656. }
  1657.  
  1658. void 
  1659. XFE_ABListSearchView::Flippyfunc(const OutlineFlippyFuncData */*data*/)
  1660. {
  1661. }
  1662.  
  1663. /* Tells the Outlinable object that the line data is no
  1664.  * longer needed, and it can free any storage associated with it.
  1665.  */ 
  1666. void
  1667. XFE_ABListSearchView::releaseLineData()
  1668. {
  1669. }
  1670.  
  1671. /*
  1672.  * Callbacks for outside world
  1673.  */
  1674. void XFE_ABListSearchView::comboSelCallback(Widget w, 
  1675.                    XtPointer clientData, 
  1676.                    XtPointer callData)
  1677. {
  1678.   XFE_ABListSearchView *obj = (XFE_ABListSearchView *) clientData;
  1679.   obj->comboSelCB(w, callData);
  1680. }
  1681.  
  1682.  
  1683. void
  1684. XFE_ABListSearchView::comboSelCB(Widget /* w */, XtPointer callData)
  1685. {
  1686.   DtComboBoxCallbackStruct *cbData = (DtComboBoxCallbackStruct *)callData;
  1687.   if (cbData->reason == XmCR_SELECT ) {
  1688.       char* text = 0;
  1689.       XmString str = cbData->item_or_text;
  1690.       
  1691.       XmStringGetLtoR(str, XmSTRING_DEFAULT_CHARSET, &text);
  1692.       if (*text ) {
  1693.           /* get the right dir server 
  1694.            */
  1695. #if defined(USE_ABCOM)
  1696.           uint32 nDirs = 0;
  1697.           XFE_AB2PaneView *parV = (XFE_AB2PaneView *) getParent();
  1698.           const AB_ContainerInfo **ctrArray = parV->getRootContainers(nDirs);
  1699.           for (int i=0; i < nDirs; i++) {
  1700.               const DIR_Server *dir = 
  1701.                   AB_GetDirServerForContainer((AB_ContainerInfo *) ctrArray[i]);
  1702.               if (dir &&
  1703.                   dir->description && 
  1704.                   !XP_STRCMP(dir->description, text)) {
  1705.                   selectContainer((AB_ContainerInfo *) ctrArray[i]);
  1706.                   notifyInterested(XFE_ABListSearchView::dirSelect,
  1707.                                    (void *) ctrArray[i]);
  1708.                   break;
  1709.               }/* if */
  1710.           }/* for i*/
  1711.           
  1712. #else
  1713.           int count = XP_ListCount(m_directories);
  1714.           for (int i=0; i < count; i++) {
  1715.               DIR_Server *dir = 
  1716.                   (DIR_Server *) XP_ListGetObjectNum(m_directories, i+1);
  1717.               if (dir &&
  1718.                   dir->description && 
  1719.                   !XP_STRCMP(dir->description, text)) {
  1720.                   selectDir(dir);
  1721.                   break;
  1722.               }/* if */
  1723.           }/* for i */
  1724. #endif /* !USE_ABCOM */
  1725.       }/* if */    
  1726.       XtFree(text);      
  1727.   }/* if */
  1728. }
  1729.  
  1730. void
  1731. XFE_ABListSearchView::typeActivateCallback(Widget /* w */, 
  1732.                    XtPointer clientData, 
  1733.                    XtPointer /* callData */)
  1734. {
  1735.   XFE_ABListSearchView *obj = (XFE_ABListSearchView *) clientData;
  1736.   if (obj->m_filterSearchBtn)
  1737.       obj->searchCB(obj->m_filterSearchBtn, NULL);
  1738. }
  1739.  
  1740. void
  1741. XFE_ABListSearchView::typeDownTimerCallback(XtPointer closure, XtIntervalId *)
  1742. {
  1743.     XFE_ABListSearchView *obj = (XFE_ABListSearchView *) closure;
  1744.  
  1745.     if (obj->m_filterSearchBtn)
  1746.         obj->searchCB(obj->m_filterSearchBtn, NULL);
  1747. }
  1748.  
  1749. void
  1750. XFE_ABListSearchView::typeDownCallback(Widget w, 
  1751.                    XtPointer clientData, 
  1752.                    XtPointer callData)
  1753. {
  1754.   XFE_ABListSearchView *obj = (XFE_ABListSearchView *) clientData;
  1755.   obj->typeDownCB(w, callData);
  1756. }
  1757.  
  1758. void
  1759. XFE_ABListSearchView::typeDownCB(Widget w, 
  1760.                  XtPointer /* callData */)
  1761. {
  1762.   // unregister any timer if there is one
  1763.   if (m_typeDownTimer) {
  1764.       XtRemoveTimeOut(m_typeDownTimer);
  1765.       m_typeDownTimer = 0;
  1766.   }/* if */
  1767.  
  1768.   const char *str;
  1769.   str = fe_GetTextField(w);
  1770.  
  1771.   m_searchStr = XP_STRDUP(str);
  1772.  
  1773.   if (!m_dir)
  1774.       return;
  1775.  
  1776.   if (m_dir->dirType == LDAPDirectory) {
  1777.       /* stop any search
  1778.        */
  1779.       stopSearch();
  1780.  
  1781.       /* add a timer
  1782.        */
  1783.       unsigned long interval = 900;
  1784.       PREF_GetIntPref("ldap_1.autoCompleteInterval", (int *) &interval);
  1785. #if defined(DEBUG_tao)
  1786.       printf("\nldap_1.autoCompleteInterval=%d\n", interval);
  1787. #endif
  1788.       m_typeDownTimer = XtAppAddTimeOut(fe_XtAppContext, interval,
  1789.                                         typeDownTimerCallback, this);
  1790.  
  1791.   }/* if */
  1792.   else if (m_dir->dirType == PABDirectory) {
  1793.     /* Do  type down 
  1794.      */
  1795.     Widget outlinerW = m_outliner->getBaseWidget();
  1796.     MSG_ViewIndex startIndex = 0;
  1797.     int i;
  1798.  
  1799.     startIndex = 0;
  1800. #if 1
  1801.     int count = 0;
  1802.     const int *indices = 0;
  1803.     m_outliner->getSelection(&indices, &count);
  1804.     if (count != 0)
  1805.         startIndex = *indices;
  1806. #else
  1807.     MSG_ViewIndex *indices = 0;
  1808.     uint count = 0;
  1809.     count = XmLGridGetSelectedRowCount(outlinerW);
  1810.     if (count != 0) {
  1811.       indices = (MSG_ViewIndex *) malloc (sizeof(MSG_ViewIndex) * count);
  1812.       XmLGridGetSelectedRows(outlinerW, (int *) indices, count);
  1813.       
  1814.       /* use the first one selected
  1815.        */
  1816.       startIndex = *indices;
  1817.       free (indices);
  1818.     }/* if */
  1819. #endif
  1820.     /* Get the first matching row
  1821.      */
  1822.     MSG_ViewIndex index = 0;
  1823.     i = AB_GetIndexMatchingTypedown(m_abPane, &index, str, startIndex);
  1824.     /* Steal from SubAllView.cpp
  1825.      */
  1826.     if (index == MSG_VIEWINDEXNONE) {
  1827.       m_outliner->deselectAllItems();
  1828.     }/* if */
  1829.     else {
  1830.       m_outliner->selectItemExclusive(index);
  1831.       m_outliner->makeVisible(index);
  1832.     }/* else */
  1833.     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);
  1834.   }/* if */
  1835. }/* XFE_ABListSearchView::typeDownCB() */
  1836.  
  1837. void XFE_ABListSearchView::changeEntryCount()
  1838. {
  1839.   uint32 count = 0;
  1840. #if defined(USE_ABCOM)
  1841.   count = MSG_GetNumLines(m_pane);
  1842. #if defined(DEBUG_tao)
  1843.   printf("\nXFE_ABListSearchView::changeEntryCount=%d\n", count);
  1844. #endif
  1845.  
  1846. #else
  1847.   AB_GetEntryCount(m_dir, m_AddrBook, 
  1848.                    &count, (ABID) ABTypeAll, 0);
  1849. #endif
  1850.   m_outliner->change(0, count, count);
  1851. }/* XFE_ABListSearchView::changeEntryCount() */
  1852.  
  1853. void XFE_ABListSearchView::unRegisterInterested()
  1854. {
  1855.   MWContext *top = XP_GetNonGridContext (m_contextData);
  1856.   XFE_Frame *f = ViewGlue_getFrame(top);
  1857.   f->unregisterInterest(XFE_Frame::allConnectionsCompleteCallback,
  1858.                         this,
  1859.                         (XFE_FunctionNotification)allConnectionsComplete_cb);
  1860. }
  1861.  
  1862. //
  1863. void XFE_ABListSearchView::expandCollapse(XP_Bool expand)
  1864. {
  1865.     if (m_expandBtn)
  1866.         XtVaSetValues(m_expandBtn, 
  1867.                       XmNarrowDirection, expand?XmARROW_DOWN:XmARROW_RIGHT,
  1868.                       NULL);
  1869. }
  1870.  
  1871. //
  1872. #if defined(USE_ABCOM)
  1873. void XFE_ABListSearchView::setContainerPane(MSG_Pane *pane)
  1874. {
  1875.     m_abContainerPane = pane;
  1876.  
  1877.     if (!m_containerInfo) {
  1878.     }/* if */
  1879. }
  1880.  
  1881. void XFE_ABListSearchView::selectContainer(AB_ContainerInfo *containerInfo)
  1882. {
  1883.     if (containerInfo == m_containerInfo)
  1884.         return;
  1885.  
  1886.     // remove the timer
  1887.     if (m_typeDownTimer) {
  1888.         XtRemoveTimeOut(m_typeDownTimer);
  1889.         m_typeDownTimer = 0;
  1890.     }/* if */
  1891.  
  1892.  
  1893.     /* refresh chrome as well
  1894.      */
  1895.     int error = -1;
  1896.     if (m_containerInfo) {
  1897.         error = AB_ChangeABContainer(m_pane,
  1898.                                      containerInfo);
  1899.     }/* if */
  1900.     else
  1901.         error = AB_InitializeABPane(m_pane,
  1902.                                     containerInfo);
  1903.         
  1904.     m_containerInfo = containerInfo;
  1905.  
  1906.     // TODO: take out this once BE support Notification
  1907.     changeEntryCount();
  1908.  
  1909.     /* TODO: remove refernce to dir
  1910.      */
  1911.     /* dir
  1912.      */
  1913.     m_dir = AB_GetDirServerForContainer(containerInfo);
  1914.  
  1915.     if (m_dir) {
  1916.         /* search button
  1917.          */
  1918.         if (m_dir->dirType == PABDirectory) {
  1919.             XtSetSensitive(m_filterSearchBtn, False);
  1920.         }/* if */
  1921.         else {
  1922.             XtSetSensitive(m_filterSearchBtn, True);
  1923.         }/* else */
  1924.         if(m_filterStopBtn)
  1925.             XtSetSensitive(m_filterStopBtn, False);
  1926.  
  1927.         if (m_dir->description) {
  1928.             XmString xmstr = XmStringCreateLtoR(m_dir->description, 
  1929.                                                 XmSTRING_DEFAULT_CHARSET);
  1930.             DtComboBoxSelectItem(m_filterDirCombo, xmstr);
  1931.             XmStringFree(xmstr);
  1932.         }/* if */
  1933.     }/* if */
  1934.     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);  
  1935. }
  1936. #endif /* USE_ABCOM */
  1937.  
  1938. void XFE_ABListSearchView::selectLine(int /* line */)
  1939. {
  1940.     /* shall deal with a line in ABPane
  1941.      */
  1942. }
  1943.  
  1944. void XFE_ABListSearchView::selectDir(DIR_Server* dir)
  1945. {
  1946.     if (dir == m_dir)
  1947.         return;
  1948.  
  1949.     // remove the timer
  1950.     if (m_typeDownTimer) {
  1951.         XtRemoveTimeOut(m_typeDownTimer);
  1952.         m_typeDownTimer = 0;
  1953.     }/* if */
  1954.  
  1955.     m_dir = dir;
  1956.     /* refresh chrome as well
  1957.      */
  1958.     AB_ChangeDirectory(m_abPane, m_dir);
  1959.     if (m_dir->dirType == PABDirectory) {
  1960.         XtSetSensitive(m_filterSearchBtn, False);
  1961.     }/* if */
  1962.     else {
  1963.         XtSetSensitive(m_filterSearchBtn, True);
  1964.     }/* else */
  1965.     getToplevel()->notifyInterested(XFE_View::chromeNeedsUpdating);  
  1966. }
  1967.  
  1968. void
  1969. XFE_ABListSearchView::searchDlgCB(ABSearchInfo_t *clientData, 
  1970.                                   void */* callData */)
  1971. {
  1972.     XFE_ABListSearchView *view = (XFE_ABListSearchView *) clientData->m_obj;
  1973.     view->startSearch(clientData);
  1974. }
  1975.  
  1976. void
  1977. XFE_ABListSearchView::startSearch(ABSearchInfo_t *info)
  1978. {
  1979.  
  1980.     MSG_SearchFree((MSG_Pane *) m_abPane);
  1981.     MSG_SearchAlloc((MSG_Pane *) m_abPane);
  1982.     MSG_AddLdapScope((MSG_Pane *) m_abPane, info->m_dir);
  1983.  
  1984.     uint16             nRules = info->m_nRules;
  1985.     ABSearchUIParam_t *params = info->m_params;
  1986.  
  1987.     for (int i=0; i < nRules; i++) {
  1988. #if defined(DEBUG_tao)
  1989.         printf("\n(i,attribute,op,val)=(%d,%d,%d,%s)\n",
  1990.                i,
  1991.                params[i].m_attribNval.attribute,
  1992.                params[i].m_op,
  1993.                params[i].m_attribNval.u.string?
  1994.                params[i].m_attribNval.u.string:"nil");
  1995. #endif
  1996.         if (!params[i].m_attribNval.u.string ||
  1997.             !XP_STRLEN(params[i].m_attribNval.u.string))
  1998.             continue;
  1999.  
  2000.         MSG_SearchError err =
  2001.             /* add a criterion line to the search 
  2002.              */
  2003. #ifdef FE_IMPLEMENTS_BOOLEAN_OR
  2004.             MSG_AddSearchTerm(m_pane,
  2005.                               params[i].m_attribNval.attribute,
  2006.                               params[i].m_op,
  2007.                               &(params[i].m_attribNval),
  2008.                               info->m_logicOp,
  2009.                               NULL);
  2010. #else
  2011.             MSG_AddSearchTerm(m_pane,
  2012.                               params[i].m_attribNval.attribute,
  2013.                               params[i].m_op,
  2014.                               &(params[i].m_attribNval));
  2015. #endif
  2016.         
  2017.     }/* for i */
  2018.  
  2019.     m_searchingDir = True;
  2020.  
  2021.     /* change label to Stop
  2022.      */
  2023.     fe_SetString(m_filterSearchBtn, 
  2024.                  XmNlabelString, XP_GetString(XFE_AB_STOP));
  2025. #if defined(USE_ABCOM)
  2026.     AB_SearchDirectoryAB2(m_pane, NULL);    
  2027. #else
  2028.     AB_SearchDirectory(m_abPane, NULL);    
  2029. #endif /* USE_ABCOM */
  2030. }
  2031.  
  2032. ABAddrMsgCBProcStruc* XFE_ABListSearchView::getSelections()
  2033. {
  2034.     int count = 0;
  2035.     const int *indices = 0;
  2036.     m_outliner->getSelection(&indices, &count);
  2037.     if (!count)
  2038.         return NULL;
  2039.  
  2040.     /* pack selected
  2041.      */
  2042.     ABAddrMsgCBProcStruc *pairs = 
  2043.         (ABAddrMsgCBProcStruc *) XP_CALLOC(1, sizeof(ABAddrMsgCBProcStruc));
  2044.     pairs->m_pairs = (StatusID_t **) XP_CALLOC(count, sizeof(StatusID_t*)); 
  2045.     for (int i=0; i < count; i++) {
  2046.         ABID entry;
  2047.         entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) indices[i]);
  2048.         if (entry == MSG_VIEWINDEXNONE) 
  2049.             continue;
  2050.  
  2051.         StatusID_t *pair;
  2052.         pair = (StatusID_t *) XP_CALLOC(1, sizeof(StatusID_t));
  2053.         pair->status = ::TO;
  2054.         pair->dir = m_dir;
  2055.         pair->id = entry;
  2056.         AB_GetType(m_dir, m_AddrBook, entry, &(pair->type));
  2057.         
  2058.         //email
  2059.         char a_line[AB_MAX_STRLEN];
  2060.         a_line[0] = '\0';
  2061.         AB_GetEmailAddress(m_dir, m_AddrBook, entry, a_line);
  2062.         pair->emailAddr = XP_STRDUP(a_line);
  2063.  
  2064.         // fullname
  2065.         a_line[0] = '\0';
  2066.         AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
  2067.         
  2068.         // assemble
  2069.         pair->dplyStr = NULL;
  2070.         AB_GetExpandedName(m_dir, m_AddrBook, entry, &(pair->dplyStr));
  2071.         if (!pair->dplyStr) {
  2072.             // fullname
  2073.             a_line[0] = '\0';
  2074.             AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
  2075.             pair->dplyStr = XP_STRDUP(a_line);
  2076.         }/* if */
  2077.  
  2078.         pairs->m_pairs[pairs->m_count] = pair;
  2079.         (pairs->m_count)++;
  2080.     }/* for i */
  2081.     return pairs;
  2082. }/* XFE_ABListSearchView::getSelections() */
  2083.  
  2084. #if defined(USE_MOTIF_DND)
  2085.  
  2086. fe_icon_data*
  2087. XFE_ABListSearchView::GetDragIconData(int row, int column)
  2088. {
  2089.     D(("XFE_ABListSearchView::GetDragIconData()\n"));
  2090.     /* TODO: get line data
  2091.      * determine entry type
  2092.      * return person/MN_Person, or, list/MN_People
  2093.      */
  2094.     fe_icon_data *icon_data = 0;
  2095.     if (row < 0) {
  2096. #if defined(DEBUG_tao)
  2097.         printf("\n XFE_ABListSearchView::GetDragIconData (row,col)=(%d,%d)\n",
  2098.                row, column);
  2099. #endif
  2100.         icon_data = &MN_Person; /* shall call make/initialize icons */
  2101.     }/* if */
  2102.     else {
  2103.         ABID entryID = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) row);
  2104.  
  2105.         if (entryID == MSG_VIEWINDEXNONE)
  2106.             return icon_data;
  2107.  
  2108.         ABID type;
  2109.         AB_GetType(m_dir, m_AddrBook, entryID, &type);
  2110.         if (type == ABTypePerson)
  2111.             icon_data = &MN_Person; /* shall call make/initialize icons */
  2112.         else if (type == ABTypeList)
  2113.             icon_data = &MN_People;
  2114.     }/* else */
  2115.     return icon_data;
  2116. }
  2117.  
  2118. void
  2119. XFE_ABListSearchView::GetDragTargets(int    row, int column,
  2120.                                      Atom **targets,
  2121.                                      int   *num_targets)
  2122. {
  2123.     D(("XFE_ABListSearchView::GetDragTargets(row=%d, col=%d)\n",row,column));
  2124.     
  2125.     XP_ASSERT(row > -1);
  2126.     if (row == -1) {
  2127.         *targets = NULL;
  2128.         *num_targets = 0;
  2129.     }/* if */
  2130.     else {
  2131.         if (!m_outliner->isSelected(row))
  2132.             m_outliner->selectItemExclusive(row);
  2133.         
  2134.         *num_targets = 2;
  2135.         
  2136.         *targets = new Atom[ *num_targets ];
  2137.         
  2138.         (*targets)[0] = XFE_OutlinerDrop::_XA_NETSCAPE_PAB;
  2139.         (*targets)[1] = XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV;
  2140.     }/* else */
  2141. }
  2142.  
  2143. void 
  2144. XFE_ABListSearchView::getDropTargets(void */*this_ptr*/,
  2145.                                      Atom **targets,
  2146.                                      int  *num_targets)
  2147. {
  2148.     D(("XFE_ABListSearchView::getDropTargets()\n"));
  2149.     *num_targets = 2;
  2150.     *targets = new Atom[ *num_targets ];
  2151.  
  2152.     (*targets)[0] = XFE_OutlinerDrop::_XA_NETSCAPE_PAB;
  2153.     (*targets)[1] = XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV;
  2154. }
  2155.  
  2156. char *
  2157. XFE_ABListSearchView::DragConvert(Atom atom)
  2158. {
  2159.     /* pack data
  2160.      */
  2161.     if (atom == XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV) {
  2162. #if defined(DEBUG_tao)
  2163.         printf("\nXFE_ABListSearchView::DragConvert:_XA_NETSCAPE_DIRSERV\n");
  2164. #endif        
  2165.         uint32 count = 0;
  2166.         const int *indices = 0;
  2167.  
  2168.         m_outliner->getSelection(&indices, (int *) &count);
  2169.  
  2170.         char tmp[32];
  2171.         sprintf(tmp, "%d", count);
  2172.  
  2173.         int len = XP_STRLEN(tmp);
  2174.         char *buf = (char *) XtCalloc(len, sizeof(char));
  2175.         buf = XP_STRCAT(buf, tmp);        
  2176.         for (int i=0; i < count; i++) {
  2177.             sprintf(tmp, "%d", indices[i]);
  2178.             len += XP_STRLEN(tmp)+1;
  2179.             buf = XtRealloc(buf, len);
  2180.             buf = XP_STRCAT(buf, " ");        
  2181.             buf = XP_STRCAT(buf, tmp);                    
  2182.         }/* for i */
  2183. #if defined(DEBUG_tao)
  2184.         printf("\nXFE_ABListSearchView::DragConvert:_XA_NETSCAPE_DIRSERV=%x\n", buf);
  2185. #endif
  2186.         return buf;
  2187.     }/* if */
  2188.     else if (atom == XFE_OutlinerDrop::_XA_NETSCAPE_PAB)    {
  2189. #if defined(DEBUG_tao)
  2190.         printf("\nXFE_ABListSearchView::DragConvert:_XA_NETSCAPE_PAB\n");
  2191. #endif        
  2192.         uint32 count = 0;
  2193.         const int *indices = 0;
  2194.  
  2195.         m_outliner->getSelection(&indices, (int *) &count);
  2196.  
  2197.         char tmp[32];
  2198.         sprintf(tmp, "%d", count);
  2199.  
  2200.         int len = XP_STRLEN(tmp);
  2201.         char *buf = (char *) XtCalloc(len, sizeof(char));
  2202.         buf = XP_STRCAT(buf, tmp);        
  2203.         for (int i=0; i < count; i++) {
  2204.             sprintf(tmp, "%d", indices[i]);
  2205.             len += XP_STRLEN(tmp)+1;
  2206.             buf = XtRealloc(buf, len);
  2207.             buf = XP_STRCAT(buf, " ");        
  2208.             buf = XP_STRCAT(buf, tmp);                    
  2209.         }/* for i */
  2210. #if defined(DEBUG_tao)
  2211.         printf("\nXFE_ABListSearchView::DragConvert:_XA_NETSCAPE_PAB=%x\n", buf);
  2212. #endif
  2213.         return buf;
  2214.     }/* else if */
  2215.     return (char *) NULL;
  2216. }
  2217.  
  2218. int
  2219. XFE_ABListSearchView::ProcessTargets(int row, int col,
  2220.                                      Atom *targets,
  2221.                                      const char **data,
  2222.                                      int numItems)
  2223. {
  2224.     int i;
  2225.  
  2226.     D(("XFE_ABListSearchView::ProcessTargets(row=%d, col=%d, numItems=%d)\n", row, col, numItems));
  2227.     
  2228.     for (i=0; i < numItems; i++) {
  2229.         if (targets[i]==None || data[i]==NULL || strlen(data[i])==0)
  2230.             continue;
  2231.         
  2232.         D(("  [%d] %s: \"%s\"\n",i,XmGetAtomName(XtDisplay(m_widget),targets[i]),data[i]));
  2233.         if (targets[i] == XFE_OutlinerDrop::_XA_NETSCAPE_PAB) {
  2234. #if defined(DEBUG_tao)
  2235.             printf("\nXFE_ABListSearchView::ProcessTargets:_XA_NETSCAPE_PAB\n");
  2236. #endif        
  2237.             /* decode
  2238.              */            
  2239.             char *pStr = (char *) XP_STRDUP(data[i]);
  2240.             int   len = XP_STRLEN(pStr);
  2241.  
  2242.             uint32 pCount = 0;
  2243.             char tmp[32];
  2244.             sscanf(data[i], "%d", &pCount);
  2245.             int *indices = (int *) XP_CALLOC(pCount, sizeof(int));
  2246.             
  2247.             char *tok = 0,
  2248.                  *last = 0;
  2249.             int   count = 0;
  2250.             char *sep = " ";
  2251.  
  2252.             while (((tok=XP_STRTOK_R(count?nil:pStr, sep, &last)) != NULL)&&
  2253.                    XP_STRLEN(tok) &&
  2254.                    count < len) {
  2255.                 int index = atoi(tok);
  2256.                 if (!count)
  2257.                     XP_ASSERT(index == pCount);
  2258.                 else
  2259.                     indices[count-1] =     index;
  2260.                 count++;
  2261.             }/* while */
  2262.             return TRUE;
  2263.         }/* if */
  2264.         else if (targets[i] == XFE_OutlinerDrop::_XA_NETSCAPE_DIRSERV) {
  2265. #if defined(DEBUG_tao)
  2266.             printf("\nXFE_ABListSearchView::ProcessTargets:_XA_NETSCAPE_DIRSERV\n");
  2267. #endif        
  2268.             return TRUE;
  2269.         }/* else if */
  2270.     }/* for i */
  2271.     return FALSE;
  2272. }
  2273.  
  2274. /* external entries
  2275.  */
  2276. fe_icon_data*
  2277. XFE_ABListSearchView::getDragIconData(void *this_ptr,
  2278.                                       int   row,
  2279.                                       int   column)
  2280. {
  2281.     XFE_ABListSearchView *view = (XFE_ABListSearchView*)this_ptr;    
  2282.     return view->GetDragIconData(row, column);
  2283. }
  2284.  
  2285. void
  2286. XFE_ABListSearchView::getDragTargets(void  *this_ptr,
  2287.                                      int    row, int column,
  2288.                                      Atom **targets, int *num_targets)
  2289. {
  2290.     XFE_ABListSearchView *view = (XFE_ABListSearchView*)this_ptr;    
  2291.     view->GetDragTargets(row, column, targets, num_targets);
  2292. }
  2293.  
  2294. char *
  2295. XFE_ABListSearchView::dragConvert(void *this_ptr,
  2296.                                   Atom atom)
  2297. {
  2298.   XFE_ABListSearchView *view = (XFE_ABListSearchView*) this_ptr;
  2299.   
  2300.   return view->DragConvert(atom);
  2301. }
  2302.  
  2303. int
  2304. XFE_ABListSearchView::processTargets(void *this_ptr,
  2305.                                      int row, int col,
  2306.                                      Atom *targets,
  2307.                                      const char **data,
  2308.                                      int numItems)
  2309. {
  2310.     XFE_ABListSearchView *view = (XFE_ABListSearchView*)this_ptr;
  2311.     
  2312.     return view->ProcessTargets(row, col, targets, data, numItems);
  2313. }
  2314.  
  2315. #else /* USE_MOTIF_DND */
  2316.  
  2317. // Address field drop site handler
  2318. void
  2319. XFE_ABListSearchView::entryListDropCallback(Widget, 
  2320.                                             void* cd,
  2321.                                             fe_dnd_Event type,
  2322.                                             fe_dnd_Source *source,
  2323.                                             XEvent* /* event */) 
  2324. {
  2325.     XFE_ABListSearchView *ad = (XFE_ABListSearchView *)cd;
  2326.     if (type == FE_DND_DROP && 
  2327.         ad && 
  2328.         source)
  2329. #if defined(USE_ABCOM)
  2330.         ad->entryListDropCB(source, event);
  2331. #else
  2332.         ad->entryListDropCB(source);
  2333. #endif /* USE_ABCOM */
  2334. }
  2335.  
  2336. #if defined(USE_ABCOM)
  2337. void
  2338. XFE_ABListSearchView::entryListDropCB(fe_dnd_Source *source, XEvent *event)
  2339. {
  2340. #if defined(DEBUG_tao)
  2341.     printf("\nXFE_ABListSearchView::entryListDropCB:srcType=%d\n",
  2342.            source->type);
  2343. #endif
  2344.     XP_ASSERT(source && event && m_outliner);
  2345.     unsigned int state = event->xbutton.state;
  2346.     XP_Bool shift = ((state & ShiftMask) != 0),
  2347.             ctrl = ((state & ControlMask) != 0);
  2348.  
  2349.     /* onto which 
  2350.      */
  2351.     int row = -1;
  2352.     int x, y;
  2353.  
  2354.     m_outliner->translateFromRootCoords(event->xbutton.x_root, 
  2355.                                         event->xbutton.y_root, 
  2356.                                         &x, &y);
  2357.     
  2358.     row = m_outliner->XYToRow(x, y);
  2359.     if (row < 0 ||
  2360.         row >= m_outliner->getTotalLines())
  2361.         XP_ASSERT(0);
  2362.  
  2363. #if defined(DEBUG_tao)
  2364.     printf("\nXFE_ABListSearchView::entryListDropCallback,shift=%d, ctrl=%d, row=%d",
  2365.            shift, ctrl, row);
  2366. #endif
  2367.     AB_ContainerInfo *containerInfo = 
  2368.         AB_GetContainerForIndex(m_pane, (MSG_ViewIndex) row);
  2369.  
  2370.     switch (source->type) {
  2371.     case FE_DND_ADDRESSBOOK:
  2372.     case FE_DND_BOOKS_DIRECTORIES: {
  2373.         XFE_MNListView* listView = (XFE_MNListView *) source->closure;
  2374.         XFE_Outliner *outliner = listView->getOutliner();
  2375.         const int *indices = NULL;
  2376.         int32 numIndices = 0;
  2377.         outliner->getSelection(&indices, &numIndices);
  2378.         MSG_Pane *srcPane = listView->getPane();
  2379.         AB_DragEffect effect = 
  2380.             AB_DragEntriesIntoContainerStatus(srcPane,
  2381.                                               (const MSG_ViewIndex *) indices,
  2382.                                               (int32) numIndices,
  2383.                                               m_containerInfo,
  2384.                                               AB_Default_Drag); 
  2385.         int error = 0;
  2386.         if (effect == AB_Drag_Not_Allowed)
  2387.             return;
  2388.         else
  2389.             error = 
  2390.                 AB_DragEntriesIntoContainer(srcPane,
  2391.                                             (const MSG_ViewIndex *) indices,
  2392.                                             (int32) numIndices,
  2393.                                             containerInfo?containerInfo
  2394.                                                          :m_containerInfo,
  2395.                                             effect);
  2396.     }
  2397.     
  2398.     break;
  2399.         
  2400.     default:
  2401.         break;
  2402.     }/* switch */
  2403. }
  2404.  
  2405. #else
  2406. void
  2407. XFE_ABListSearchView::entryListDropCB(fe_dnd_Source *source)
  2408. {
  2409.     switch (source->type) {
  2410.  
  2411.     case FE_DND_ADDRESSBOOK: {
  2412. #if defined(DEBUG_tao)
  2413.         printf("\nXFE_ABListSearchView::entryListDropCB:FE_DND_ADDRESSBOOK\n");
  2414. #endif
  2415.         break;
  2416.     }
  2417.  
  2418.     case FE_DND_BOOKS_DIRECTORIES: {
  2419. #if defined(DEBUG_tao)
  2420.         printf("\nXFE_ABListSearchView::entryListDropCB:FE_DND_BOOKS_DIRECTORIES\n");
  2421. #endif
  2422.         
  2423.         break;
  2424.     }
  2425.     default:
  2426.         break;
  2427.     }
  2428. }
  2429.  
  2430. #endif
  2431.  
  2432. #endif /* !USE_MOTIF_DND */
  2433.  
  2434. #if defined(USE_ABCOM)
  2435. extern "C" int 
  2436. FE_ShowPropertySheeetForAB2(MSG_Pane *pane,
  2437.                             AB_EntryType entryType)
  2438. {
  2439.     if (entryType == AB_MailingList) {
  2440.         
  2441.     }/* if */
  2442.     else if (entryType == AB_Person) {
  2443.         
  2444.     }/* else */
  2445.     return FALSE;
  2446. }
  2447. #endif /* USE_ABCOM */
  2448.