home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / ABNameFolderDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  16.6 KB  |  599 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.    ABNameFolderDlg.cpp -- class definition for ABNameFolderDlg
  20.    Created: Tao Cheng <tao@netscape.com>, 12-nov-96
  21.  */
  22.  
  23. #include "ABNameFolderDlg.h"
  24. #include "PropertySheetView.h"
  25.  
  26. #include "ABNameGenTab.h"
  27. #include "ABNameConTab.h"
  28.  
  29. #if 0
  30. /* out for 4.x and 5.0
  31.  */
  32. #include "ABNameSecuTab.h"
  33. #endif
  34.  
  35. #include "ABNameCTalkTab.h"
  36.  
  37. #include "AddrBookView.h"
  38.  
  39. extern "C" {
  40. XP_List* FE_GetDirServers();
  41. ABook*   fe_GetABook(MWContext *context);
  42. };
  43.  
  44. #include "xpgetstr.h"
  45.  
  46. extern int XFE_AB_NAME_CARD_FOR;
  47. extern int XFE_AB_NAME_NEW_CARD;
  48. extern int XFE_ADDR_ENTRY_ALREADY_EXISTS;
  49. extern int MK_ADDR_ENTRY_ALREADY_EXISTS;
  50. //
  51. // This is the dialog it self
  52. //
  53. XFE_ABNameFolderDlg::XFE_ABNameFolderDlg(Widget    parent,
  54.                                          char     *name,
  55.                                          Boolean   modal,
  56.                                          MWContext *context):
  57.     XFE_PropertySheetDialog((XFE_View *)0, parent, name,
  58.                         context,
  59.                         TRUE,    /* ok */
  60.                         TRUE,    /* cancel */
  61.                         TRUE,    /* help */
  62.                         FALSE,   /* apply */
  63.                         FALSE,   /* separator */
  64.                         modal)
  65. {
  66.   m_newUser = True;
  67.   m_entry = MSG_VIEWINDEXNONE;
  68.  
  69.   //
  70.   m_personEntry.Initialize();
  71.  
  72.   /*  protected: m_view == folder view
  73.    */
  74.   XFE_PropertySheetView* folderView = (XFE_PropertySheetView *) m_view;
  75.  
  76.   /* Add tabs
  77.    */
  78.   /* Gen
  79.    */
  80.   folderView->addTab(new XFE_ABNameGenTabView((XFE_Component *)this, 
  81.                           folderView));
  82.   folderView->addTab(new XFE_ABNameConTabView((XFE_Component *)this, 
  83.                           folderView));
  84. #if 0
  85.   /* out for 4.x and 5.0
  86.    */
  87.   folderView->addTab(new XFE_ABNameSecuTabView((XFE_Component *)this, 
  88.                            folderView));
  89. #endif
  90.   folderView->addTab(new XFE_ABNameCTalkTabView((XFE_Component *)this, 
  91.                         folderView));
  92. }
  93.  
  94. #if defined(USE_ABCOM)
  95. XFE_ABNameFolderDlg::XFE_ABNameFolderDlg(MSG_Pane *personPane,
  96.                                          MWContext *context):
  97.     XFE_PropertySheetDialog((XFE_View *)0, 
  98.                         CONTEXT_WIDGET(context), 
  99.                         "abCardProperties",
  100.                         context,
  101.                         TRUE,    /* ok */
  102.                         TRUE,    /* cancel */
  103.                         TRUE,    /* help */
  104.                         FALSE,   /* apply */
  105.                         FALSE,   /* separator */
  106.                         TRUE)
  107.  
  108. {
  109.     m_newUser = True;
  110.     m_entry = MSG_VIEWINDEXNONE;
  111.     
  112.     /*  protected: m_view == folder view
  113.      */
  114.     XFE_PropertySheetView* folderView = (XFE_PropertySheetView *) m_view;
  115.  
  116.     /* Add tabs
  117.      */
  118.     /* Gen
  119.      */
  120.     folderView->addTab(new XFE_ABNameGenTabView((XFE_Component *)this, 
  121.                                                 folderView));
  122.     folderView->addTab(new XFE_ABNameConTabView((XFE_Component *)this, 
  123.                                                 folderView));
  124.     folderView->addTab(new XFE_ABNameCTalkTabView((XFE_Component *)this, 
  125.                                                   folderView));
  126.  
  127.     setDlgValues(personPane);
  128. }
  129. #endif /* USE_ABCOM */
  130.  
  131. XFE_ABNameFolderDlg::~XFE_ABNameFolderDlg()
  132. {
  133. #if defined(USE_ABCOM)
  134.   int error = AB_ClosePane(((XFE_MNView *) m_view)->getPane());
  135. #else
  136.   m_personEntry.CleanUp();
  137.  
  138. #endif /* USE_ABCOM */
  139. }
  140.  
  141. #if defined(USE_ABCOM)
  142. void 
  143. XFE_ABNameFolderDlg::setDlgValues(MSG_Pane *pane)
  144. {
  145.     /* super class' */
  146.     ((XFE_MNView *) m_view)->setPane(pane);
  147.     m_entry = AB_GetABIDForPerson(pane);
  148.     m_newUser = m_entry?False:True;
  149.  
  150.     XFE_PropertySheetDialog::setDlgValues();
  151. }
  152. #endif /* USE_ABCOM */
  153.  
  154. void XFE_ABNameFolderDlg::setDlgValues(ABID entry, PersonEntry* pPerson,
  155.                                        Boolean newUser)
  156. {
  157.   m_newUser = newUser;
  158.   m_entry = entry;
  159.  
  160.   /* copy person data
  161.    */
  162.   if (pPerson) {
  163.       if (pPerson->pNickName)
  164.           m_personEntry.pNickName = XP_STRDUP(pPerson->pNickName);
  165.  
  166.       if (pPerson->pGivenName)
  167.           m_personEntry.pGivenName = XP_STRDUP(pPerson->pGivenName);
  168.  
  169.       if (pPerson->pMiddleName)
  170.           m_personEntry.pMiddleName = XP_STRDUP(pPerson->pMiddleName);
  171.       
  172.       if (pPerson->pFamilyName)
  173.           m_personEntry.pFamilyName = XP_STRDUP(pPerson->pFamilyName);
  174.       
  175.       if (pPerson->pCompanyName)
  176.           m_personEntry.pCompanyName = XP_STRDUP(pPerson->pCompanyName);
  177.       
  178.       if (pPerson->pLocality)
  179.           m_personEntry.pLocality = XP_STRDUP(pPerson->pLocality);
  180.  
  181.       if (pPerson->pRegion)
  182.           m_personEntry.pRegion = XP_STRDUP(pPerson->pRegion);
  183.  
  184.       if (pPerson->pEmailAddress)
  185.           m_personEntry.pEmailAddress = XP_STRDUP(pPerson->pEmailAddress);
  186.  
  187.       if (pPerson->pInfo)
  188.           m_personEntry.pInfo = XP_STRDUP(pPerson->pInfo);
  189.  
  190.       m_personEntry.HTMLmail = pPerson->HTMLmail;
  191.  
  192.       if (pPerson->pTitle)
  193.           m_personEntry.pTitle = XP_STRDUP(pPerson->pTitle);
  194.  
  195.       if (pPerson->pAddress)
  196.           m_personEntry.pAddress = XP_STRDUP(pPerson->pAddress);
  197.  
  198.       if (pPerson->pPOAddress)
  199.           m_personEntry.pPOAddress = XP_STRDUP(pPerson->pPOAddress);
  200.       
  201.       if (pPerson->pZipCode)
  202.           m_personEntry.pZipCode = XP_STRDUP(pPerson->pZipCode);
  203.  
  204.       if (pPerson->pCountry)
  205.           m_personEntry.pCountry = XP_STRDUP(pPerson->pCountry);
  206.  
  207.       if (pPerson->pWorkPhone)
  208.           m_personEntry.pWorkPhone = XP_STRDUP(pPerson->pWorkPhone);
  209.  
  210.       if (pPerson->pFaxPhone)
  211.           m_personEntry.pFaxPhone = XP_STRDUP(pPerson->pFaxPhone);
  212.  
  213.       if (pPerson->pHomePhone)
  214.           m_personEntry.pHomePhone = XP_STRDUP(pPerson->pHomePhone);
  215.  
  216.       m_personEntry.Security = pPerson->Security;
  217.  
  218.       if (pPerson->pCoolAddress)
  219.           m_personEntry.pCoolAddress = XP_STRDUP(pPerson->pCoolAddress);
  220.  
  221.       m_personEntry.UseServer = pPerson->UseServer;
  222.   }/* if */
  223.  
  224.   if (!m_newUser && m_entry != MSG_VIEWINDEXNONE) {
  225.  
  226.       DIR_Server *dir = getABDir();
  227.       ABook      *aBook = fe_GetABook(0);
  228.       char        a_line[AB_MAX_STRLEN];
  229.       a_line[0] = '\0';
  230.       if (AB_GetFullName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE) {
  231.           char tmp[AB_MAX_STRLEN];
  232.           XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  233.                           XP_GetString(XFE_AB_NAME_CARD_FOR),
  234.                           a_line);
  235.           setCardName(tmp);
  236.       }/* if AB_GetFullName */
  237.   }/* if !m_newUser && m_entry != MSG_VIEWINDEXNONE */
  238.   else {
  239.       setCardName(XP_GetString(XFE_AB_NAME_NEW_CARD));
  240.   }/* else */
  241.   
  242.   XFE_PropertySheetDialog::setDlgValues();
  243. }
  244.  
  245. void XFE_ABNameFolderDlg::setDlgValues(ABID entry, Boolean newUser)
  246. {
  247.   m_newUser = newUser;
  248.   m_entry = entry;
  249.  
  250.   if (!m_newUser && m_entry != MSG_VIEWINDEXNONE) {
  251.       DIR_Server *dir = getABDir();
  252.       ABook      *aBook = fe_GetABook(0);
  253.  
  254.       char        a_line[AB_MAX_STRLEN];
  255.  
  256.       a_line[0] = '\0';
  257.       if (AB_GetNickname(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  258.           m_personEntry.pNickName = XP_STRDUP(a_line);
  259.       
  260.       a_line[0] = '\0';
  261.       if (AB_GetGivenName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  262.           m_personEntry.pGivenName = XP_STRDUP(a_line);
  263.       
  264.       a_line[0] = '\0';
  265.       if (AB_GetMiddleName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  266.           m_personEntry.pMiddleName = XP_STRDUP(a_line);
  267.       
  268.       a_line[0] = '\0';
  269.       if (AB_GetFamilyName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  270.           m_personEntry.pFamilyName = XP_STRDUP(a_line);
  271.       
  272.       a_line[0] = '\0';
  273.       if (AB_GetCompanyName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  274.           m_personEntry.pCompanyName = XP_STRDUP(a_line);
  275.       
  276.       a_line[0] = '\0';
  277.       if (AB_GetLocality(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  278.           m_personEntry.pLocality = XP_STRDUP(a_line);
  279.       
  280.       a_line[0] = '\0';
  281.       if (AB_GetRegion(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  282.           m_personEntry.pRegion = XP_STRDUP(a_line);
  283.       
  284.       a_line[0] = '\0';
  285.       if (AB_GetEmailAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  286.           m_personEntry.pEmailAddress = XP_STRDUP(a_line);
  287.       
  288.       a_line[0] = '\0';
  289.       if (AB_GetInfo(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  290.           m_personEntry.pInfo = XP_STRDUP(a_line);
  291.       
  292.       AB_GetHTMLMail(dir, aBook, entry, &(m_personEntry.HTMLmail));
  293.       
  294.       a_line[0] = '\0';
  295.       if (AB_GetTitle(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  296.           m_personEntry.pTitle = XP_STRDUP(a_line);
  297.       
  298.       a_line[0] = '\0';
  299.       if (AB_GetStreetAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  300.           m_personEntry.pAddress = XP_STRDUP(a_line);
  301.  
  302.       a_line[0] = '\0';
  303.       if (AB_GetPOAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  304.           m_personEntry.pPOAddress = XP_STRDUP(a_line);
  305.  
  306.       a_line[0] = '\0';
  307.       if (AB_GetZipCode(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  308.           m_personEntry.pZipCode = XP_STRDUP(a_line);
  309.       
  310.       a_line[0] = '\0';
  311.       if (AB_GetCountry(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  312.           m_personEntry.pCountry = XP_STRDUP(a_line);
  313.       
  314.       a_line[0] = '\0';
  315.       if (AB_GetWorkPhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  316.           m_personEntry.pWorkPhone = XP_STRDUP(a_line);
  317.       
  318.       a_line[0] = '\0';
  319.       if (AB_GetFaxPhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  320.           m_personEntry.pFaxPhone = XP_STRDUP(a_line);
  321.       
  322.       a_line[0] = '\0';
  323.       if (AB_GetHomePhone(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  324.           m_personEntry.pHomePhone = XP_STRDUP(a_line);
  325. #if 0
  326.       a_line[0] = '\0';
  327.       if (AB_GetDistName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  328.           m_personEntry.pDistName = XP_STRDUP(a_line);
  329. #endif
  330.       AB_GetSecurity(dir, aBook, entry, &m_personEntry.Security);
  331.       
  332.       a_line[0] = '\0';
  333.       if (AB_GetCoolAddress(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE)
  334.           m_personEntry.pCoolAddress = XP_STRDUP(a_line);
  335.       short use;
  336.       AB_GetUseServer(dir, aBook, entry, &use);
  337.       m_personEntry.UseServer = use;
  338.       a_line[0] = '\0';
  339.       if (AB_GetFullName(dir, aBook, entry, a_line) != MSG_VIEWINDEXNONE) {
  340.           char tmp[AB_MAX_STRLEN];
  341.           XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  342.                           XP_GetString(XFE_AB_NAME_CARD_FOR),
  343.                           a_line);
  344.           setCardName(tmp);
  345.       }/* if AB_GetFullName */
  346.   }/* if !m_newUser && m_entry != MSG_VIEWINDEXNONE */
  347.   else {
  348.       m_personEntry.Initialize();
  349.       setCardName(XP_GetString(XFE_AB_NAME_NEW_CARD));
  350.   }/* else */
  351.   
  352.   XFE_PropertySheetDialog::setDlgValues();
  353. }
  354.  
  355. void XFE_ABNameFolderDlg::apply()
  356. {
  357.   getDlgValues();
  358.  
  359. #if defined(USE_ABCOM)
  360.  
  361.   MSG_Pane *pane = ((XFE_MNView *) m_view)->getPane();
  362.   uint16 numItems = 1;
  363.   AB_AttributeValue *values = 
  364.       (AB_AttributeValue *) XP_CALLOC(numItems, 
  365.                                       sizeof(AB_AttributeValue));
  366.   values[0].attrib = AB_attribWinCSID;
  367.   values[0].u.shortValue = m_context->fe.data->xfe_doc_csid;
  368.  
  369.   m_okToDestroy = TRUE;
  370.   int error = AB_SetPersonEntryAttributes(pane, 
  371.                                           values, 
  372.                                           numItems);
  373.   AB_FreeEntryAttributeValues(values, numItems);
  374.  
  375.   if (error != AB_SUCCESS)
  376.       m_okToDestroy = False;
  377.  
  378.   error = AB_CommitChanges(pane);
  379.   if (error != AB_SUCCESS)
  380.       m_okToDestroy = False;
  381.  
  382. #else
  383.   DIR_Server *dir = getABDir();
  384.   ABook      *aBook = fe_GetABook(0);
  385.  
  386.   // assign win_csid
  387.   m_personEntry.WinCSID = m_context->fe.data->xfe_doc_csid;
  388.   int errorID;
  389.   m_okToDestroy = TRUE;
  390.   if (m_newUser) {
  391.       /* eEntryAlreadyExists ; MK_ADDR_ENTRY_ALREADY_EXISTS
  392.        */
  393.       int errorID = AB_AddUser(dir, aBook, &m_personEntry, &m_entry);
  394.       if (errorID != 0 ||
  395.           m_entry == MSG_VIEWINDEXNONE) {
  396.           if (MK_ADDR_ENTRY_ALREADY_EXISTS == errorID)
  397.               fe_Alert_2(getBaseWidget(),
  398.                          XP_GetString(XFE_ADDR_ENTRY_ALREADY_EXISTS));
  399.           else {
  400.               char tmp[128];
  401.               XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  402.                               "%s",
  403.                               XP_GetString(errorID));
  404.               fe_Alert_2(getBaseWidget(), tmp);
  405.           }/* else */
  406.           m_okToDestroy = FALSE;
  407.       }/* if */
  408.   }/* if */
  409.   else {
  410.       errorID = AB_ModifyUser(dir, aBook, m_entry, &m_personEntry);
  411.       if (errorID != 0 ||
  412.           m_entry == MSG_VIEWINDEXNONE) {
  413.           if (MK_ADDR_ENTRY_ALREADY_EXISTS == errorID)
  414.               fe_Alert_2(getBaseWidget(), 
  415.                          XP_GetString(XFE_ADDR_ENTRY_ALREADY_EXISTS));
  416.           else {
  417.               char tmp[128];
  418.               XP_SAFE_SPRINTF(tmp, sizeof(tmp),
  419.                               "%s",
  420.                               XP_GetString(errorID));
  421.               fe_Alert_2(getBaseWidget(), tmp);
  422.           }/* else */
  423.           m_okToDestroy = FALSE;
  424.       }/* if */
  425.   }/* else */
  426. #endif /* USE_ABCOM */
  427. }
  428.  
  429. char* XFE_ABNameFolderDlg::getFullname()
  430. {
  431.     char a_line[AB_MAX_STRLEN];
  432.  
  433.     a_line[0] = '\0';
  434.  
  435.     static char *firstName = 0;
  436.     static char *lastName = 0;
  437.     static XP_Bool changed = False;
  438.  
  439. #if defined(USE_ABCOM)
  440.     uint16       numItems = 3;
  441.     AB_AttribID *attribs = (AB_AttribID *) XP_CALLOC(numItems, 
  442.                                                       sizeof(AB_AttribID));
  443.     attribs[0] = AB_attribGivenName;
  444.     attribs[1] = AB_attribFamilyName;
  445.     attribs[2] = AB_attribFullName;
  446.  
  447.     AB_AttributeValue *values = NULL;
  448.     int error =
  449.         AB_GetPersonEntryAttributes(((XFE_MNView *) m_view)->getPane(), 
  450.                                     attribs,
  451.                                     &values, 
  452.                                     &numItems);
  453.     char *tmp0 = values[0].u.string,
  454.          *tmp1 = values[1].u.string,
  455.          *tmp2 = values[2].u.string;
  456.  
  457.     if (!changed &&    (firstName && tmp0 && XP_STRCMP(firstName, tmp0)) ||
  458.         (lastName && tmp1 && XP_STRCMP(lastName, tmp1)))
  459.         changed = True;
  460.  
  461.     if (tmp2)
  462.         XP_SAFE_SPRINTF(a_line, sizeof(a_line),
  463.                         "%s",
  464.                         tmp2);
  465.     if ((m_entry == MSG_VIEWINDEXNONE) ||
  466.         changed ||
  467.         (tmp2 == NULL)) {
  468.         if (tmp0 || tmp1) {
  469.             XP_SAFE_SPRINTF(a_line, sizeof(a_line),
  470.                             "%s %s",
  471.                             tmp0?
  472.                             tmp0:"", 
  473.                             tmp1?
  474.                             tmp1:"");
  475.         }/* if */
  476.     }/* if FullName */
  477.     firstName = tmp0;
  478.     lastName = tmp1;
  479.  
  480.     // free
  481.     XP_FREEIF(attribs);
  482.     AB_FreeEntryAttributeValues(values, numItems);
  483. #else
  484.     DIR_Server *dir = getABDir();
  485.     ABook      *aBook = fe_GetABook(0);
  486.  
  487.  
  488.     if (!changed &&
  489.         (firstName && XP_STRCMP(firstName, m_personEntry.pGivenName)) ||
  490.         (lastName && XP_STRCMP(lastName, m_personEntry.pFamilyName)))
  491.         changed = True;
  492.  
  493.     if ((m_entry == MSG_VIEWINDEXNONE) ||
  494.         changed ||
  495.         (AB_GetFullName(dir, aBook, m_entry, a_line) == MSG_VIEWINDEXNONE)) {
  496.         if (m_personEntry.pGivenName || m_personEntry.pFamilyName) {
  497.             XP_SAFE_SPRINTF(a_line, sizeof(a_line),
  498.                             "%s %s",
  499.                             m_personEntry.pGivenName?
  500.                             m_personEntry.pGivenName:"", 
  501.                             m_personEntry.pFamilyName?
  502.                             m_personEntry.pFamilyName:"");
  503.         }/* if */
  504.     }/* if AB_GetFullName */
  505.     firstName = m_personEntry.pGivenName;
  506.     lastName = m_personEntry.pFamilyName;
  507. #endif /* USE_ABCOM */
  508.     return XP_STRLEN(a_line)?XP_STRDUP(a_line):0;
  509. }
  510.  
  511. void XFE_ABNameFolderDlg::setCardName(char *name)
  512. {
  513.     if (name)
  514.         XtVaSetValues(XtParent(m_chrome), XmNtitle, name, NULL);
  515. }
  516.  
  517. DIR_Server* XFE_ABNameFolderDlg::getABDir()
  518. {
  519.   XP_List    *directories = FE_GetDirServers();
  520.   
  521.   DIR_Server *pabDir = NULL;
  522.   DIR_GetPersonalAddressBook(directories, &pabDir);
  523.   return pabDir;
  524. }/* XFE_ABNameFolderDlg::getABDir() */
  525.  
  526. extern "C" void fe_showABCardPropertyDlg(Widget parent,
  527.                                          MWContext *context,
  528.                                          ABID entry = MSG_VIEWINDEXNONE, 
  529.                                          XP_Bool newuser = True)
  530. {
  531.     XFE_ABNameFolderDlg* nameDlg = 
  532.         new XFE_ABNameFolderDlg(parent,
  533.                                 "abCardProperties", 
  534.                                 True, 
  535.                                 context);
  536.     nameDlg->setDlgValues(entry, newuser);
  537.  
  538.     nameDlg->show();
  539. }
  540.  
  541. extern "C" int FE_ShowPropertySheetFor(MWContext* context, 
  542.                                        ABID entryID, PersonEntry* pPerson)
  543. {
  544.     // need a context
  545.     XP_ASSERT(context);
  546.  
  547.     // Get ABook
  548.     ABook *addr_book = fe_GetABook(0);
  549.  
  550.     // Get ABDir
  551.     DIR_Server *dir;
  552.     DIR_GetPersonalAddressBook(FE_GetDirServers(), &dir);
  553.  
  554.     int result = -1;
  555.     if (dir) {
  556.         XFE_ABNameFolderDlg* nameDlg = 
  557.             new XFE_ABNameFolderDlg(CONTEXT_WIDGET(context),
  558.                                     "abCardProperties", 
  559.                                     True, 
  560.                                     context);
  561.         if (entryID != MSG_MESSAGEIDNONE) {
  562.             nameDlg->setDlgValues(entryID, pPerson, False);
  563.         }/* if */
  564.         else {
  565.             /* new user 
  566.              */
  567.             nameDlg->setDlgValues(entryID, pPerson, True);
  568.         }/* else */
  569.     
  570.         XFE_PropertySheetDialog::ANS_t ans = XFE_PropertySheetDialog::eWAITING;
  571.         nameDlg->setClientData(&ans);
  572.         nameDlg->show();
  573.  
  574.         while (ans == XFE_PropertySheetDialog::eWAITING)
  575.             fe_EventLoop ();
  576.  
  577. #if defined(DEBUG_tao)
  578.         printf("\n THE ANSWER is %d\n", ans);
  579. #endif
  580.         if (ans == XFE_PropertySheetDialog::eCANCEL)
  581.             result = FALSE;
  582.         else if (ans == XFE_PropertySheetDialog::eAPPLY)
  583.             result = TRUE;
  584.         else
  585.             result = -1;
  586.     }/* if dir */
  587.     return result;
  588. }
  589.  
  590. #if defined(USE_ABCOM)
  591. extern "C" int 
  592. fe_ShowPropertySheetForEntry(MSG_Pane *pane, MWContext *context)
  593. {
  594.     XFE_ABNameFolderDlg* nameDlg = 
  595.         new XFE_ABNameFolderDlg(pane, context);
  596.     nameDlg->show();
  597. }
  598. #endif /* USE_ABCOM */
  599.