home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABAddrSearchView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  19.4 KB  |  797 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.    ABAddrSearchView.cpp -- class definition for XFE_AddrSearchView
  20.    Created: Tao Cheng <tao@netscape.com>, 20-nov-96
  21.  */
  22.  
  23. #include "ABAddrSearchView.h"
  24. #include "ABAddresseeView.h"
  25.  
  26. #include "xpassert.h"
  27.  
  28. #include <Xm/Form.h>
  29. #include <Xm/Label.h>
  30. #include <Xm/PushB.h>
  31. #include <Xm/TextF.h>
  32.  
  33.  
  34. extern "C" {
  35. #include "xfe.h"
  36.  
  37. XP_List* FE_GetDirServers();
  38. ABook*   fe_GetABook(MWContext *context);
  39. XtPointer fe_tooltip_mappee(Widget widget, XtPointer data);
  40. }
  41.  
  42. #include "xpgetstr.h"
  43.  
  44. extern int XFE_AB_HEADER_NAME;
  45. extern int XFE_AB_HEADER_EMAIL;
  46.  
  47. extern int XFE_AB_HEADER_NICKNAME;
  48. extern int XFE_AB_HEADER_EMAIL;
  49. extern int XFE_AB_HEADER_COMPANY;
  50. extern int XFE_AB_HEADER_PHONE;
  51. extern int XFE_AB_HEADER_LOCALITY;
  52.  
  53. #ifndef AB_MAX_STRLEN
  54. #define AB_MAX_STRLEN 1024
  55. #endif
  56.  
  57. #define OUTLINER_GEOMETRY_PREF "addressbook.searchpane.outliner_geometry"
  58.  
  59. #if !defined(EMPTY_STRVAL)
  60. #define EMPTY_STRVAL(value) \
  61.   (!(value) || !((value)->u.string) || !XP_STRLEN(((value)->u.string)))
  62.  
  63. #endif
  64.  
  65. XFE_AddrSearchView::XFE_AddrSearchView(XFE_Component *toplevel_component,
  66.                                        Widget parent /* the form */,
  67.                                        XFE_View *parent_view, 
  68.                                        MWContext *context,
  69.                                        XP_List   *directories):
  70.     XFE_ABListSearchView(toplevel_component,
  71.                          parent,
  72.                          parent_view, 
  73.                          context,
  74.                          directories)
  75. {
  76.   /* Properties
  77.    */
  78.   m_propertyBtn = NULL;
  79.  
  80.   /* For outliner
  81.    */
  82.   int num_columns = OUTLINER_COLUMN_LAST;
  83.   static int column_widths[] = {3, 20, 20, 10, 10, 8, 8};
  84.   m_outliner = new XFE_Outliner("addressList",
  85.                                 this,
  86.                                 toplevel_component,
  87.                                 parent,
  88.                                 False, // constantSize
  89.                                 True,  // hasHeadings
  90.                                 num_columns,
  91.                                 num_columns-2,// num_visible 
  92.                 column_widths,
  93.                 OUTLINER_GEOMETRY_PREF);
  94.   m_outliner->setHideColumnsAllowed(True);
  95.  
  96.   /* BEGIN_3P: XmLGrid
  97.    */
  98.   XtVaSetValues(m_outliner->getBaseWidget(),
  99.                 XtVaTypedArg, XmNblankBackground, XmRString, "white", 6,
  100.                 XmNselectionPolicy, XmSELECT_MULTIPLE_ROW,
  101.                 XmNvisibleRows, 15,
  102.                 NULL);
  103.   XtVaSetValues(m_outliner->getBaseWidget(),
  104.                 XmNcellDefaults, True,
  105.                 XtVaTypedArg, XmNcellBackground, XmRString, "white", 6,
  106.                 NULL);
  107.   /* END_3P: XmLGrid
  108.    */
  109.  
  110.   /* Attachment
  111.    */
  112.   layout();
  113.  
  114.   /* 
  115.    * XFE_Outliner constructor does not allocate any content row
  116.    * XFE_Outliner::change(int first, int length, int newnumrows)
  117.    */
  118. #if !defined(USE_ABCOM)
  119.   uint32 count; 
  120.   /* Get # of existing entry
  121.    */
  122.   AB_GetEntryCount (m_dir, m_AddrBook, &count, (ABID) ABTypeAll, 0);
  123.   m_outliner->change(0, count, count);
  124. #endif /* USE_ABCOM */
  125.   m_outliner->show();
  126.   setBaseWidget(m_outliner->getBaseWidget());
  127.  
  128.   /* register interest
  129.    */
  130.   getToplevel()->registerInterest(XFE_View::chromeNeedsUpdating,
  131.                                   (XFE_NotificationCenter *) this,
  132.                                   (XFE_FunctionNotification) updateCommands_cb);
  133.  
  134. }/* XFE_AddrSearchView::XFE_AddrSearchView */
  135.  
  136. XFE_AddrSearchView::~XFE_AddrSearchView()
  137. {
  138.     getToplevel()->unregisterInterest(XFE_View::chromeNeedsUpdating,
  139.                                       (XFE_NotificationCenter *)this,
  140.                                       (XFE_FunctionNotification)updateCommands_cb);
  141.  
  142. }
  143.  
  144. XFE_CALLBACK_DEFN(XFE_AddrSearchView, updateCommands)(XFE_NotificationCenter*,
  145.                                                       void * /* clientData */, 
  146.                                                       void * /* callData */)
  147. {
  148.     if (!m_propertyBtn || 
  149.         !m_toBtn || 
  150.         !m_ccBtn || 
  151.         !m_bccBtn)
  152.         return;
  153.  
  154.     /* properties
  155.      */
  156.     XtSetSensitive(m_propertyBtn, m_dir?True:False);        
  157.  
  158. #if defined(USE_ABCOM)
  159.     uint32 count32 = MSG_GetNumLines(m_pane);
  160. #else
  161.     /* check which is selected
  162.      */
  163.     uint32 count32 = 0; 
  164.     /* Get # of existing entry
  165.      */
  166.     AB_GetEntryCount (m_dir, m_AddrBook, &count32, (ABID) ABTypeAll, 0);
  167. #endif /* USE_ABCOM */
  168.  
  169.     int count = 0; 
  170.     const int *indices = 0;
  171.     m_outliner->getSelection(&indices, &count);
  172.     if (count32 > 0 &&
  173.         count > 0 && 
  174.         indices) {
  175.         XtSetSensitive(m_toBtn, True);
  176.         XtSetSensitive(m_ccBtn, True);
  177.         XtSetSensitive(m_bccBtn, True);
  178. #if 0
  179.         if (m_dir->dirType == LDAPDirectory)
  180.             XtSetSensitive(m_addToAddressBtn, True);
  181.         else
  182.             XtSetSensitive(m_addToAddressBtn, False);
  183. #endif
  184.     }/* if */
  185.     else {
  186.         XtSetSensitive(m_toBtn, False);
  187.         XtSetSensitive(m_ccBtn, False);
  188.         XtSetSensitive(m_bccBtn, False);
  189. #if 0
  190.         XtSetSensitive(m_addToAddressBtn, False);
  191. #endif        
  192.     }/* else */
  193. }
  194.  
  195. fe_icon*
  196. XFE_AddrSearchView::getColumnIcon(int column)
  197. {
  198.   fe_icon *myIcon = 0;
  199. #if defined(USE_ABCOM)
  200.   switch (column) {
  201.   case OUTLINER_COLUMN_TYPE:
  202.       {
  203.           AB_EntryType type = getType(m_containerInfo, m_entryID);
  204.           if (type == AB_Person)
  205.               myIcon = &m_personIcon; /* shall call make/initialize icons */
  206.           else if (type == AB_MailingList)
  207.               myIcon = &m_listIcon;
  208.       }
  209.   break;
  210.   }/* switch () */
  211.  
  212. #else
  213.   switch (column) {
  214.   case OUTLINER_COLUMN_TYPE:
  215.       {
  216.         ABID type;
  217.         AB_GetType(m_dir, m_AddrBook, m_entryID, &type);
  218.         if (type == ABTypePerson)
  219.             myIcon = &m_personIcon; /* shall call make/initialize icons */
  220.         else if (type == ABTypeList)
  221.             myIcon = &m_listIcon;
  222.       }
  223.   break;
  224.   }/* switch () */
  225. #endif /* USE_ABCOM */
  226.   return myIcon;
  227. }
  228.  
  229. /* Methods for the outlinable interface.
  230.  */
  231.  
  232. /* The Outlinable interface.
  233.  */
  234. char *XFE_AddrSearchView::getCellTipString(int row, int column)
  235. {
  236.     char *tmp = 0;
  237.     static char tipstr[128];
  238.     tipstr[0] = '\0';
  239.  
  240.     if (row < 0) {
  241.         /* header
  242.          */
  243.         tmp = getColumnHeaderText(column);
  244.     }/* if */
  245.     else {
  246.         ABID orgID = m_entryID;
  247.  
  248.         /* content 
  249.          */
  250. #if defined(USE_ABCOM)
  251.         int error = AB_GetABIDForIndex(m_pane,
  252.                                        (MSG_ViewIndex) row,
  253.                                        &m_entryID);
  254. #else
  255.         m_entryID = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) row);
  256. #endif /* USE_ABCOM */
  257.         tmp = getColumnText(column);
  258.  
  259.         /* reset
  260.          */
  261.         m_entryID = orgID;
  262.     }/* else */
  263.     if (tmp && 
  264.         (!m_outliner->isColTextFit(tmp, row, column)))
  265.         XP_STRCPY(tipstr,tmp);
  266.     return tipstr;
  267. }
  268.  
  269. char *XFE_AddrSearchView::getCellDocString(int /* row */, 
  270.                                            int /* column */)
  271. {
  272.     return NULL;
  273. }
  274.  
  275. /* Returns the text and/or icon to display at the top of the column.
  276.  */
  277. char*
  278. XFE_AddrSearchView::getColumnHeaderText(int column)
  279. {
  280.     char *tmp = 0;
  281.     switch (column) {
  282.     case OUTLINER_COLUMN_NAME:
  283.         tmp = XP_GetString(XFE_AB_HEADER_NAME);
  284.         break;
  285.     case OUTLINER_COLUMN_EMAIL:
  286.         tmp = XP_GetString(XFE_AB_HEADER_EMAIL);
  287.       break;
  288.  
  289.     case OUTLINER_COLUMN_NICKNAME:
  290.         tmp = XP_GetString(XFE_AB_HEADER_NICKNAME);
  291.         break;
  292.  
  293.     case OUTLINER_COLUMN_PHONE:
  294.         tmp = XP_GetString(XFE_AB_HEADER_PHONE);
  295.         break;
  296.         
  297.     case OUTLINER_COLUMN_COMPANY:
  298.         tmp = XP_GetString(XFE_AB_HEADER_COMPANY);
  299.         break;
  300.         
  301.     case OUTLINER_COLUMN_LOCALITY:
  302.         tmp = XP_GetString(XFE_AB_HEADER_LOCALITY);
  303.         break;
  304.     }/* switch */
  305.     return tmp;
  306. }
  307.  
  308. char*
  309. XFE_AddrSearchView::getColumnText(int column)
  310. {
  311.  
  312.   static char a_line[AB_MAX_STRLEN];
  313.   a_line[0] = '\0';
  314. #if defined(USE_ABCOM)
  315.   AB_AttributeValue *value = 0;
  316.   AB_AttribID attrib = AB_attribEntryType;
  317.   XP_Bool isPhone = False;
  318.   switch (column) {
  319.   case OUTLINER_COLUMN_NAME:
  320.       attrib = AB_attribFullName; // shall be AB_attribDisplayName;
  321.       break;
  322.  
  323.   case OUTLINER_COLUMN_EMAIL:
  324.       attrib = AB_attribEmailAddress;
  325.       break;
  326.       
  327.   case OUTLINER_COLUMN_NICKNAME:
  328.       attrib = AB_attribNickName;
  329.       break;
  330.       
  331.   case OUTLINER_COLUMN_PHONE:
  332.       isPhone = True;
  333.       attrib = AB_attribWorkPhone;
  334.       break;
  335.  
  336.   case OUTLINER_COLUMN_COMPANY:
  337.       attrib = AB_attribCompanyName;
  338.       break;
  339.       
  340.   case OUTLINER_COLUMN_LOCALITY:
  341.        attrib = AB_attribLocality;
  342.       break;
  343.       
  344.   }/* switch () */
  345.   if (attrib != AB_attribEntryType) {
  346.       int error = AB_GetEntryAttribute(m_containerInfo, m_entryID, 
  347.                                        attrib, &value);
  348.  
  349.       if (isPhone && 
  350.           EMPTY_STRVAL(value)) {
  351.           error = AB_GetEntryAttribute(m_containerInfo, m_entryID, 
  352.                                        AB_attribHomePhone, &value);
  353.       }/* if */
  354.       XP_SAFE_SPRINTF(a_line, sizeof(a_line),
  355.                       "%s",
  356.                       EMPTY_STRVAL(value)?"":value->u.string);
  357.  
  358.       AB_FreeEntryAttributeValue(value);
  359.   }/* if */
  360. #else
  361.   switch (column) {
  362.   case OUTLINER_COLUMN_NAME:
  363.     AB_GetFullName(m_dir, m_AddrBook, m_entryID, a_line);
  364.     break;
  365.  
  366.   case OUTLINER_COLUMN_EMAIL:
  367.     AB_GetEmailAddress(m_dir, m_AddrBook, m_entryID, a_line);
  368.     break;
  369.  
  370.   case OUTLINER_COLUMN_NICKNAME:
  371.     AB_GetNickname(m_dir, m_AddrBook, m_entryID, a_line);
  372.     break;
  373.  
  374.   case OUTLINER_COLUMN_PHONE:
  375.     AB_GetWorkPhone(m_dir, m_AddrBook, m_entryID, a_line);
  376.     if (!a_line || !XP_STRLEN(a_line)) {
  377.         a_line[0] = '\0';
  378.         AB_GetHomePhone(m_dir, m_AddrBook, m_entryID, a_line);
  379.     }/* if */
  380.     break;
  381.  
  382.   case OUTLINER_COLUMN_COMPANY:
  383.     AB_GetCompanyName(m_dir, m_AddrBook, m_entryID, a_line);
  384.     break;
  385.  
  386.   case OUTLINER_COLUMN_LOCALITY:
  387.     AB_GetLocality(m_dir, m_AddrBook, m_entryID, a_line);
  388.     break;
  389.  
  390.   }/* switch () */
  391. #endif /* !USE_ABCOM */
  392.   return a_line;
  393. }
  394.  
  395. char*
  396. XFE_AddrSearchView::getColumnName(int column)
  397. {
  398.   switch (column) {
  399.   case OUTLINER_COLUMN_NAME:
  400.       return XP_GetString(XFE_AB_HEADER_NAME);
  401.  
  402.   case OUTLINER_COLUMN_EMAIL:
  403.       return XP_GetString(XFE_AB_HEADER_EMAIL);
  404.  
  405.   case OUTLINER_COLUMN_PHONE:    
  406.       return XP_GetString(XFE_AB_HEADER_PHONE);
  407.   case OUTLINER_COLUMN_NICKNAME:    
  408.       return XP_GetString(XFE_AB_HEADER_NICKNAME);
  409.   case OUTLINER_COLUMN_COMPANY:    
  410.       return XP_GetString(XFE_AB_HEADER_COMPANY);
  411.   case OUTLINER_COLUMN_LOCALITY:    
  412.       return XP_GetString(XFE_AB_HEADER_LOCALITY);
  413.   }/* switch () */
  414.   return "unDefined";
  415. }
  416.  
  417. #if defined(USE_ABCOM)
  418. EOutlinerTextStyle XFE_AddrSearchView::getColumnHeaderStyle(int column)
  419. {
  420.     AB_AttribID sortType = AB_attribUnknown;
  421.     switch (column) {
  422.     case OUTLINER_COLUMN_NAME:
  423.         sortType = AB_attribFullName;
  424.         break;
  425.         
  426.     case OUTLINER_COLUMN_EMAIL:
  427.         sortType = AB_attribEmailAddress;
  428.         break;
  429.         
  430.     case OUTLINER_COLUMN_NICKNAME:
  431.         sortType = AB_attribNickName;
  432.       break;
  433.       
  434.     case OUTLINER_COLUMN_COMPANY:
  435.         sortType = AB_attribCompanyName;
  436.         break;
  437.         
  438.     case OUTLINER_COLUMN_LOCALITY:
  439.         sortType = AB_attribLocality;
  440.         break;
  441.     }/* switch */
  442.     
  443.     if (sortType == getSortType())
  444.         return OUTLINER_Bold;
  445.     else
  446.         return OUTLINER_Default;
  447. }
  448.  
  449. void XFE_AddrSearchView::clickHeader(const OutlineButtonFuncData *data)
  450. {
  451.   int column = data->column; 
  452.   int invalid = True;
  453.   switch (column) {
  454. #if 0
  455.     case OUTLINER_COLUMN_TYPE:
  456.       setSortType(AB_attribEntryType);
  457.       break;
  458. #endif
  459.     case OUTLINER_COLUMN_NAME:
  460.       setSortType(AB_attribFullName);
  461.       break;
  462.  
  463.     case OUTLINER_COLUMN_NICKNAME:
  464.       setSortType(AB_attribNickName);
  465.       break;
  466.  
  467.     case OUTLINER_COLUMN_EMAIL:
  468.       setSortType(AB_attribEmailAddress);
  469.       break;
  470.  
  471.     case OUTLINER_COLUMN_COMPANY:
  472.       setSortType(AB_attribCompanyName);
  473.       break;
  474.  
  475.     case OUTLINER_COLUMN_LOCALITY:
  476.       setSortType(AB_attribLocality);
  477.       break;
  478.     default:
  479.       invalid = False;
  480.   }/* switch() */
  481.   if (invalid)
  482.     m_outliner->invalidate();
  483. }
  484. #else
  485. EOutlinerTextStyle XFE_AddrSearchView::getColumnHeaderStyle(int column)
  486. {
  487.     ABID sortType = 0;
  488.     switch (column) {
  489.     case OUTLINER_COLUMN_NAME:
  490.         sortType = ABFullName;
  491.         break;
  492.         
  493.     case OUTLINER_COLUMN_EMAIL:
  494.         sortType = ABEmailAddress;
  495.         break;
  496.         
  497.     case OUTLINER_COLUMN_NICKNAME:
  498.         sortType = ABNickname;
  499.       break;
  500.       
  501.     case OUTLINER_COLUMN_COMPANY:
  502.         sortType = ABCompany;
  503.         break;
  504.         
  505.     case OUTLINER_COLUMN_LOCALITY:
  506.         sortType = ABLocality;
  507.         break;
  508.     }/* switch */
  509.     
  510.     if (sortType == getSortType())
  511.         return OUTLINER_Bold;
  512.     else
  513.         return OUTLINER_Default;
  514. }
  515.  
  516. void XFE_AddrSearchView::clickHeader(const OutlineButtonFuncData *data)
  517. {
  518.   int column = data->column; 
  519.   int invalid = True;
  520.   switch (column) {
  521. #if 0
  522.     case OUTLINER_COLUMN_TYPE:
  523.       setSortType(AB_SortByTypeCmd);
  524.       break;
  525. #endif
  526.     case OUTLINER_COLUMN_NAME:
  527.       setSortType(AB_SortByFullNameCmd);
  528.       break;
  529.  
  530.     case OUTLINER_COLUMN_NICKNAME:
  531.       setSortType(AB_SortByNickname);
  532.       break;
  533.  
  534.     case OUTLINER_COLUMN_EMAIL:
  535.       setSortType(AB_SortByEmailAddress);
  536.       break;
  537.  
  538.     case OUTLINER_COLUMN_COMPANY:
  539.       setSortType(AB_SortByCompanyName);
  540.       break;
  541.  
  542.     case OUTLINER_COLUMN_LOCALITY:
  543.       setSortType(AB_SortByLocality);
  544.       break;
  545.     default:
  546.       invalid = False;
  547.   }/* switch() */
  548.   if (invalid)
  549.     m_outliner->invalidate();
  550. }
  551. #endif /* USE_ABCOM */
  552.  
  553. void XFE_AddrSearchView::doubleClickBody(const OutlineButtonFuncData */* data */)
  554. {
  555.     toCB(NULL, NULL);
  556. }
  557.  
  558. // callbacks
  559. void XFE_AddrSearchView::toCallback(Widget w, 
  560.                  XtPointer clientData, 
  561.                  XtPointer callData)
  562. {
  563.   XFE_AddrSearchView *obj = (XFE_AddrSearchView *) clientData;
  564.   obj->toCB(w, callData);
  565. }
  566.  
  567. void XFE_AddrSearchView::ccCallback(Widget w, 
  568.                  XtPointer clientData, 
  569.                  XtPointer callData)
  570. {
  571.   XFE_AddrSearchView *obj = (XFE_AddrSearchView *) clientData;
  572.   obj->ccCB(w, callData);
  573. }
  574.  
  575. void XFE_AddrSearchView::bccCallback(Widget w, 
  576.                  XtPointer clientData, 
  577.                  XtPointer callData)
  578. {
  579.   XFE_AddrSearchView *obj = (XFE_AddrSearchView *) clientData;
  580.   obj->bccCB(w, callData);
  581. }
  582.  
  583. StatusID_t*
  584. XFE_AddrSearchView::makePair(const int ind, SEND_STATUS status)
  585. {
  586.     ABID entry = MSG_VIEWINDEXNONE;
  587.     int error = AB_GetABIDForIndex(m_pane,
  588.                                    (MSG_ViewIndex) ind,
  589.                                    &entry);
  590.     StatusID_t *pair = (StatusID_t *) XP_CALLOC(1, sizeof(StatusID_t));
  591.     pair->status = status;
  592.     pair->dir = m_dir;
  593.     pair->id = entry;
  594.  
  595.     uint16      numItems = 4;
  596.     AB_AttribID *attribs = (AB_AttribID *) XP_CALLOC(numItems, 
  597.                                                      sizeof(AB_AttribID));
  598.     attribs[0] = AB_attribEntryType;
  599.     attribs[1] = AB_attribEmailAddress;
  600.     attribs[2] = AB_attribExpandedName;
  601.     attribs[3] = AB_attribFullName;
  602.  
  603.     AB_AttributeValue *values = NULL;
  604.     error = 
  605.         AB_GetEntryAttributesForPane(m_pane,
  606.                                      ind,
  607.                                      attribs,
  608.                                      &values,
  609.                                      &numItems);
  610.     XP_ASSERT(values);
  611.  
  612.     // AB_attribEntryType
  613.     int i = 0;
  614.     if (values[i].attrib == attribs[i])
  615.         pair->type = values[i].u.entryType;
  616.     i++;
  617.  
  618.     // AB_attribEmailAddress
  619.     if (values[i].attrib == attribs[i])
  620.         pair->emailAddr = values[i].u.string?XP_STRDUP(values[i].u.string)
  621.                                             :NULL;
  622.     i++;
  623.  
  624.     // AB_attribExpandedName
  625.     pair->dplyStr = NULL;
  626.     if (values[i].attrib == attribs[i])
  627.         pair->dplyStr = values[i].u.string?XP_STRDUP(values[i].u.string)
  628.                                           :NULL;
  629.     i++;
  630.  
  631.     if (!pair->dplyStr) {
  632.         // fullname
  633.         if (values[i].attrib == attribs[i])
  634.             pair->dplyStr = values[i].u.string?XP_STRDUP(values[i].u.string)
  635.                                               :NULL;
  636.         i++;
  637.     }/* if */
  638.     return pair;
  639. }
  640.  
  641. void
  642. XFE_AddrSearchView::toCB(Widget /*w*/,
  643.                XtPointer /* callData */)
  644. {
  645.   /* check which is selected
  646.    */
  647.   int count = 0;
  648.   const int *indices = 0;
  649.   m_outliner->getSelection(&indices, &count);
  650.   if (count > 0 && indices) {
  651. #if defined(USE_ABCOM)
  652.       StatusID_t *pair = makePair(indices[0], TO);
  653. #else
  654.     /* Take the first one 
  655.      */
  656.     ABID entry = AB_GetEntryIDAt((AddressPane *) m_abPane, 
  657.                  (uint32) indices[0]);
  658.     
  659.     if (entry == MSG_VIEWINDEXNONE) 
  660.       return;
  661.     
  662.  
  663.     StatusID_t *pair = (StatusID_t *) XP_CALLOC(1, sizeof(StatusID_t));
  664.     pair->status = TO;
  665.     pair->dir = m_dir;
  666.     pair->id = entry;
  667.     AB_GetType(m_dir, m_AddrBook, entry, &(pair->type));
  668.  
  669.     //email
  670.     char a_line[AB_MAX_STRLEN];
  671.     a_line[0] = '\0';
  672.     AB_GetEmailAddress(m_dir, m_AddrBook, entry, a_line);
  673.     pair->emailAddr = XP_STRDUP(a_line);
  674.  
  675.     // assemble
  676.     pair->dplyStr = NULL;
  677.     AB_GetExpandedName(m_dir, m_AddrBook, entry, &(pair->dplyStr));
  678.     if (!pair->dplyStr) {
  679.         // fullname
  680.         a_line[0] = '\0';
  681.         AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
  682.         pair->dplyStr = XP_STRDUP(a_line);
  683.     }/* if */
  684. #endif /* USE_ABCOM */
  685.       m_addresseeView->addEntry(pair);
  686.   }/* if */
  687.   
  688. }/* XFE_AddrSearchView::toCB() */
  689.  
  690. void
  691. XFE_AddrSearchView::ccCB(Widget /*w*/,
  692.                XtPointer /* callData */)
  693. {
  694.   /* check which is selected
  695.    */
  696.   int count = 0;
  697.   const int *indices = 0;
  698.   m_outliner->getSelection(&indices, &count);
  699.   if (count > 0 && indices) {
  700. #if defined(USE_ABCOM)
  701.       StatusID_t *pair = makePair(indices[0], CC);
  702. #else
  703.     /* Take the first one 
  704.      */
  705.     ABID entry = AB_GetEntryIDAt((AddressPane *) m_abPane, 
  706.                  (uint32) indices[0]);
  707.     
  708.     if (entry == MSG_VIEWINDEXNONE) 
  709.       return;
  710.     
  711.     StatusID_t *pair = (StatusID_t *) XP_CALLOC(1, sizeof(StatusID_t));
  712.     pair->status = CC;
  713.     pair->id = entry;
  714.     AB_GetType(m_dir, m_AddrBook, entry, &(pair->type));
  715.  
  716.     //email
  717.     char a_line[AB_MAX_STRLEN];
  718.     a_line[0] = '\0';
  719.     AB_GetEmailAddress(m_dir, m_AddrBook, entry, a_line);
  720.     pair->emailAddr = XP_STRDUP(a_line);
  721.  
  722.     // assemble
  723.     pair->dplyStr = NULL;
  724.     AB_GetExpandedName(m_dir, m_AddrBook, entry, &(pair->dplyStr));
  725.     if (!pair->dplyStr) {
  726.         // fullname
  727.         a_line[0] = '\0';
  728.         AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
  729.         pair->dplyStr = XP_STRDUP(a_line);
  730.     }/* if */
  731. #endif /* USE_ABCOM */
  732.     m_addresseeView->addEntry(pair);
  733.   }/* if */
  734.   
  735. }/* XFE_AddrSearchView::ccCB() */
  736.  
  737. void
  738. XFE_AddrSearchView::bccCB(Widget /*w*/,
  739.                XtPointer /* callData */)
  740. {
  741.   /* check which is selected
  742.    */
  743.   int count = 0;
  744.   const int *indices = 0;
  745.   m_outliner->getSelection(&indices, &count);
  746.   if (count > 0 && indices) {
  747. #if defined(USE_ABCOM)
  748.       StatusID_t *pair = makePair(indices[0], BCC);
  749. #else
  750.     /* Take the first one 
  751.      */
  752.     ABID entry = AB_GetEntryIDAt((AddressPane *) m_abPane, (uint32) indices[0]);
  753.     
  754.     if (entry == MSG_VIEWINDEXNONE) 
  755.       return;
  756.     
  757.     StatusID_t *pair = (StatusID_t *) XP_CALLOC(1, sizeof(StatusID_t));
  758.     pair->status = BCC;
  759.     pair->id = entry;
  760.     AB_GetType(m_dir, m_AddrBook, entry, &(pair->type));
  761.  
  762.     //email
  763.     char a_line[AB_MAX_STRLEN];
  764.     a_line[0] = '\0';
  765.     AB_GetEmailAddress(m_dir, m_AddrBook, entry, a_line);
  766.     pair->emailAddr = XP_STRDUP(a_line);
  767.  
  768.     // assemble
  769.     pair->dplyStr = NULL;
  770.     AB_GetExpandedName(m_dir, m_AddrBook, entry, &(pair->dplyStr));
  771.     if (!pair->dplyStr) {
  772.         // fullname
  773.         a_line[0] = '\0';
  774.         AB_GetFullName(m_dir, m_AddrBook, entry, a_line);
  775.         pair->dplyStr = XP_STRDUP(a_line);
  776.     }/* if */
  777. #endif /* USE_ABCOM */
  778.     m_addresseeView->addEntry(pair);
  779.   }/* if */
  780.   
  781. }/* XFE_AddrSearchView::bccCB() */
  782.  
  783. void XFE_AddrSearchView::addToAddressCallback(Widget w, 
  784.                  XtPointer clientData, 
  785.                  XtPointer callData)
  786. {
  787.   XFE_AddrSearchView *obj = (XFE_AddrSearchView *) clientData;
  788.   obj->addToAddressCB(w, callData);
  789. }
  790.  
  791. void
  792. XFE_AddrSearchView::addToAddressCB(Widget /*w*/,
  793.                XtPointer /* callData */)
  794. {
  795.     addToAddressBook();
  796. }/* XFE_AddrSearchView::bccCB() */
  797.