home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / sdk / mapi / win16 / dev / mdbview / mdbview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-11  |  153.7 KB  |  5,027 lines

  1. /*******************************************************************/
  2. /*
  3.  -  mdbview.cpp
  4.  -  Copyright (C) 1995 Microsoft Corporation
  5.  -
  6.  *  Purpose:
  7.  *      Main source module for MDB Viewer, a MFC windows application
  8.  *      that views properties of folders, messages, attachments, etc,
  9.  *      inside a MAPI 1.0 compliant message store.  It has the ability
  10.  *      to do several MAPI 1.0 message store, property, and table,
  11.  *      operations.
  12.  *      Currently this application works on both 32 bit NT and 16 bit
  13.  *      windows 3.1.
  14.  *
  15.  *      Contains member functions for CTheApp, CMainWindow, Utility
  16.  *      functions, CGetError, and global variables.
  17.  *
  18.  */
  19. /*******************************************************************/
  20.  
  21. #undef CTL3D
  22.  
  23. #ifdef WIN32
  24. #ifdef _WIN95
  25. #define _INC_OLE
  26. #endif
  27. #define INC_OLE2
  28. #define INC_RPC
  29. #endif
  30.  
  31. #include <afxwin.h>
  32. #include <windowsx.h>
  33. #include <string.h>
  34.  
  35. #ifdef WIN16
  36. #include <compobj.h>
  37. #endif
  38.  
  39. #ifdef WIN32
  40. #include <objbase.h>
  41. #include <objerror.h>
  42. #ifdef _WIN95
  43. #include <ole2.h>
  44. #endif
  45. #endif
  46.  
  47.  
  48. #ifdef WIN16
  49. #include <mapiwin.h>
  50. #endif
  51. #include <mapix.h>
  52. #include <mapiutil.h>   // for HrAllocAdviseSink
  53.  
  54. #ifdef CTL3D
  55. #include <ctl3d.h>
  56. #endif
  57. #include <strtbl.h>
  58. #include <misctool.h>
  59. #include <pvalloc.h>
  60. #include "resource.h"
  61. #include "mdbview.h"
  62. #include "fld.h"
  63. #include "oper.h"
  64.  
  65. #ifdef XVPORT
  66.  
  67. #include <xvport.h>     // for notification logging port
  68.  
  69. extern "C"
  70. {
  71. NOTIFCALLBACK LogNotifToXVPLog;
  72. }
  73.  
  74. #endif
  75.  
  76. typedef struct _NotifContext
  77. {
  78.     ULONG               ulCount;
  79.     char                szComment[COMMENT_SIZE];
  80. } NOTIFCONTEXT,FAR *LPNOTIFCONTEXT;
  81.  
  82.  
  83.  
  84. /********************** Function decls for Tablevu dll function *****/
  85.  
  86.  
  87. /* TBLVU functions */
  88.  
  89. extern  HINSTANCE    hlibTBLVU;
  90.  
  91. typedef BOOL (*LPFNVIEWMAPITABLE)(LPMAPITABLE FAR *lppMAPITable,HWND hWnd);
  92.  
  93. extern  LPFNVIEWMAPITABLE lpfnViewMapiTable;
  94.  
  95. #define TBLVUViewMapiTable (*lpfnViewMapiTable)
  96.  
  97.  
  98. /* PROPVU functions */
  99.  
  100. extern HINSTANCE    hlibPROPVU;
  101.  
  102. typedef BOOL (*LPFNVIEWMAPIPROP)(
  103.     LPSTR           lpszName,
  104.     LPMAPIPROP FAR *lppMAPIProp,
  105.     LPVOID          lpvDest,
  106.     HWND            hWnd);
  107.  
  108. extern LPFNVIEWMAPIPROP lpfnViewMapiProp;
  109.  
  110. #define PROPVUViewMapiProp (*lpfnViewMapiProp)
  111.  
  112.  
  113. /* STATVU functions */
  114.  
  115. extern HINSTANCE    hlibSTATVU;
  116.  
  117. typedef BOOL (*LPFNVIEWMAPISTAT)(
  118.         LPMAPISESSION FAR *lppMAPISession,
  119.         HWND hWnd);
  120.  
  121. extern LPFNVIEWMAPISTAT lpfnViewMapiStat;
  122.  
  123. #define STATVUViewMapiStat (*lpfnViewMapiStat)
  124.  
  125.  
  126. /********************** Global Variables ****************************/
  127.  
  128. // windows application globals
  129. CTheApp             theApp;                         // application framework
  130. HINSTANCE           hInst               = NULL;     // handle of instance for this application
  131.  
  132. // mapi session/mdb/adrbook globals
  133. LPMAPISESSION       lpSession           = NULL;     // global MAPI session handle
  134. LPMDB               lpMDB               = NULL;     // global pointer to open message store
  135. LPADRBOOK           lpAdrBook           = NULL;
  136.  
  137.  
  138. // Notification structures
  139. LPNOTIFS            lpMDBNotifs         = NULL;
  140. LPNOTIFS            lpSessionNotifs     = NULL;
  141. LPNOTIFS            lpStatusTblNotifs      = NULL;
  142. LPNOTIFS            lpStatusObjsNotifs  = NULL;
  143. LPNOTIFS            lpNotifStoresTable  = NULL;
  144. // XVPort id number
  145. UINT                xvpNum              = 0;
  146.  
  147. LPMAPIPROP          lpIdentityObj       = NULL;
  148. LPMAPITABLE         lpStoresTable       = NULL;
  149. LPMAPITABLE         lpStatusTable       = NULL;
  150. LPMAPITABLE         lpReceiveFolderTable = NULL;
  151.  
  152.  
  153. // Used for deterimining desination of CopyTo, CopyMessages,CopyFolder operations
  154. LPVOID              lpvCopyToDest       = NULL;
  155.  
  156.  
  157.  
  158.  
  159. // library/dll instances
  160. HINSTANCE           hlibTBLVU           = (HINSTANCE)NULL; // handle to library tablevu.dll
  161. LPFNVIEWMAPITABLE   lpfnViewMapiTable   = NULL;            // pointer to function in tablevu.dll
  162.  
  163. HINSTANCE           hlibPROPVU          = (HINSTANCE)NULL;
  164. LPFNVIEWMAPIPROP    lpfnViewMapiProp    = NULL;
  165.  
  166. HINSTANCE           hlibSTATVU          = (HINSTANCE)NULL;
  167. LPFNVIEWMAPISTAT    lpfnViewMapiStat    = NULL;
  168.  
  169. // session global hresult used for lpSession->GetLastError
  170. HRESULT             hResultSession      = hrSuccess;
  171.  
  172.  
  173. // search folder entrylist of what folders to search
  174. ULONG               cFolders                = 0;
  175. LPENTRYLIST         lpEntryListSearchFolder = NULL;
  176.  
  177. // access privileges on all OpenEntry calls, set on Opening of MDB
  178. ULONG               ulAccess            = MAPI_MODIFY;
  179.  
  180. /******************* CMainWindow Message Map ****************************/
  181.  
  182. BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
  183.  
  184.     ON_COMMAND( IDM_EXIT,           OnExit )
  185.     ON_COMMAND( IDM_ABOUT,          OnAbout )
  186.     ON_COMMAND( IDM_LOGON,          OnLogon )
  187.     ON_COMMAND( IDM_LOGOFF,         OnLogoff )
  188.     ON_COMMAND( IDM_OPENMDB,        OnOpenMDB )
  189.     ON_COMMAND( IDM_GETREC,         OnGetReceiveFolder )
  190.     ON_COMMAND( IDM_GETSTATUSTBL,   OnGetStatusTable )
  191.     ON_COMMAND( IDM_GETRECFLDTBL,   OnGetReceiveFolderTable )
  192.     ON_COMMAND( IDM_GETSTORESTBL,   OnGetStoresTable )
  193.     ON_COMMAND( IDM_OPENROOT,       OnOpenRootFolder )
  194.     ON_COMMAND( IDM_LOGOFFMDB,      OnStoreLogoff )
  195.     ON_COMMAND( IDM_QUERYIDENTITY,  OnQueryIdentity )
  196.     ON_COMMAND( IDM_QUERYDEFMSGOPTS,OnQueryDefaultMsgOptions )
  197.     ON_COMMAND( IDM_ENUMADRTYPES,   OnEnumAdrTypes )
  198.     ON_COMMAND( IDM_OPENSTATUS,     OnOpenStatusObj )
  199.     ON_COMMAND( IDM_MDBPROPS,       OnMDBProps )
  200.     ON_COMMAND( IDM_SUPPORTMASK,    OnMDBSupportMask )
  201.     ON_COMMAND( IDM_ABPROPS,        OnABProps )
  202.     ON_COMMAND( IDM_SESGETLASTERROR,OnGetLastError )
  203.     ON_COMMAND( IDM_ADDRESS,        OnAddress )
  204.     ON_COMMAND( IDM_CREATEONEOFF,   OnCreateOneOff )
  205.     ON_COMMAND( IDM_QUERYDEFRECIPOPT, OnQueryDefRecipOpts )
  206.     ON_COMMAND( IDM_RESOLVENAME,    OnResolveName )
  207.     ON_COMMAND( IDM_REGSTATUS,      OnStatusRegNotif )
  208.     ON_COMMAND( IDM_REGSESSION,     OnSessionRegNotif )
  209.     ON_COMMAND( IDM_REGMDB,         OnMDBRegNotif )
  210.     ON_COMMAND( IDM_REGTABLE,       OnTableRegNotif )
  211.     ON_COMMAND( IDM_REGAB,          OnABRegNotif )
  212.     ON_COMMAND( IDM_REGON,          OnNotifState )
  213.     ON_COMMAND( IDM_IPMSUBTREE,     OnIPMSubtree )
  214.     ON_COMMAND( IDM_IPMOUTBOX,      OnIPMOutbox )
  215.     ON_COMMAND( IDM_IPMWASTEBASKET, OnIPMWasteBasket )
  216.     ON_COMMAND( IDM_IPMSENTMAIL,    OnIPMSentMail )
  217.  
  218.     ON_WM_CLOSE()
  219.  
  220. END_MESSAGE_MAP()
  221.  
  222.  
  223. /********************************************************************/
  224. /********************** TOOLS ***************************************/
  225.  
  226. /********************************************************************/
  227. /*
  228.  -  UnadviseAll
  229.  -
  230.  *  Purpose:
  231.  *      Call Unadvise notification for all Advises in list'
  232.  *
  233.  *
  234.  *  Parameters:
  235.  *
  236.  */
  237. /********************************************************************/
  238.  
  239. void UnadviseAll(   LPUNKNOWN       lpUnk,
  240.                     ULONG           ulObjType,
  241.                     LPSTR           lpszDescription,
  242.                     LPNOTIFS FAR    *lppNotifs)
  243. {
  244.     HRESULT             hResult1    = hrSuccess;
  245.     ULONG               idx;
  246.     char                szBuff1[300];
  247.     char                szBuff2[300];
  248.     CGetError           E;
  249.  
  250.     if( (!lppNotifs) || !(*lppNotifs) )
  251.         return;
  252.  
  253.     if( !lpUnk)
  254.         return;
  255.  
  256.     for(idx = 0 ; idx < (*lppNotifs)->cConnect ; idx++)
  257.     {
  258.         switch(ulObjType)
  259.         {
  260.             case MAPI_STORE:
  261.                 hResult1 = ((LPMDB)lpUnk)->Unadvise((*lppNotifs)->Connect[idx].ulConnection);
  262.                 break;
  263.             case MAPI_TABLE:  // defined in mdbview.h
  264.                 hResult1 = ((LPMAPITABLE)lpUnk)->Unadvise((*lppNotifs)->Connect[idx].ulConnection);
  265.                 break;
  266.             case MAPI_SESSION:
  267.             case MAPI_STATUS:
  268.                 hResult1 = ((LPMAPISESSION)lpUnk)->Unadvise((*lppNotifs)->Connect[idx].ulConnection);
  269.                 break;
  270.             case MAPI_ADDRBOOK:
  271.                 hResult1 = ((LPADRBOOK)lpUnk)->Unadvise((*lppNotifs)->Connect[idx].ulConnection);
  272.                 break;
  273.             default:
  274.                 wsprintf(szBuff1,"[Error] Can't Advise on Object Type == %s, Description == %s",
  275.                         GetString("MAPIObjTypes",(LONG)ulObjType,szBuff2),lpszDescription );
  276.                 MessageBox(NULL, szBuff1, "Client", MBS_ERROR );
  277.                 break;
  278.         }
  279.  
  280.         if(HR_FAILED(hResult1) )
  281.         {
  282.             wsprintf(szBuff1,"%s->Unadvise()",lpszDescription);
  283.             MessageBox(NULL, E.SzError(szBuff1, hResult1),
  284.                   "Client", MBS_ERROR );
  285.         }
  286.     }
  287.     PvFree( *lppNotifs );
  288.     lppNotifs = NULL;
  289. }
  290.  
  291. /********************************************************************/
  292. /*
  293.  -  AdviseObj
  294.  -
  295.  *  Purpose:
  296.  *      Add an Advise Notification to List of Notifications registered
  297.  *      for this object.
  298.  *
  299.  *  Parameters:
  300.  *     [in]     lpUnk       - pointer to object(type determined by ulObjType)
  301.  *     [in]     ulObjType   - Object Type of lpUnk pointer
  302.  *     [in]     ulEventType - notification events to fire upon
  303.  *     [in]     lpfnNotifCallback - address of callback routine
  304.  *     [in]     cbEntryID   - Count Bytes in EntryID(not used for Table)
  305.  *     [in]     lpEntryID   - ponter to EntryID to Advise on
  306.  *     [in]     lpszComment - Comment that goes into lpvContext
  307.  *     [in]     lpvExplicitContext  - used to explicitly pass a lpvContext instead of LPNOTIFCONTEXT)
  308.  *                            if using LPNOTIFCONTEXT to log to window,
  309.  *                            pass in NULL for this parameter.  If != NULL,
  310.  *                            use this param instead of LPNOTIFCONTEXT
  311.  *     [in/out] lppNotifs   - Pointer to list of Advises already notified on this obj
  312.  *
  313.  */
  314. /********************************************************************/
  315.  
  316. void    AdviseObj(  LPUNKNOWN       lpUnk,
  317.                     ULONG           ulObjType,
  318.                     LPNOTIFCALLBACK lpfnNotifCallback,
  319.                     ULONG           ulEventType,
  320.                     ULONG           cbEntryID,
  321.                     LPENTRYID       lpEntryID,
  322.                     LPSTR           lpszComment,
  323.                     LPVOID          lpvExplicitContext,
  324.                     LPNOTIFS FAR    *lppNotifs)
  325. {
  326.     CGetError           E;
  327.     HRESULT             hResult1        = hrSuccess;
  328.     LPMAPIADVISESINK    lpAdviseSink    = NULL;
  329.     LPNOTIFCONTEXT      lpContext;
  330.     ULONG               ulConnection    = 0;
  331.     char                szBuff1[300];
  332.     char                szBuff2[300];
  333.     LPNOTIFS            lpNotifsTemp    = NULL;
  334.  
  335.     // setup lpvContext
  336.     lpContext = (LPNOTIFCONTEXT) PvAlloc( sizeof(NOTIFCONTEXT) );
  337.     lpContext->ulCount = 0;
  338.     if(lpszComment)
  339.         lstrcpy(lpContext->szComment,lpszComment);
  340.     else
  341.         lstrcpy(lpContext->szComment,"NULL");
  342.  
  343.  
  344.     // if pass in an explicit context pointer use it instead of my construted LPNOTIFCONTEXT
  345.     //   commonly the lpvExplicitContext is used on Redraws of listboxes and the
  346.     //   this pointer of the dialog is passed in.
  347.     if( !lpvExplicitContext)
  348.     {
  349.         hResult1 = HrAllocAdviseSink(   (LPNOTIFCALLBACK)       lpfnNotifCallback,
  350.                                         (LPVOID)                lpContext,
  351.                                         (LPMAPIADVISESINK FAR *) &lpAdviseSink);
  352.     }
  353.     else
  354.     {
  355.         hResult1 = HrAllocAdviseSink(   (LPNOTIFCALLBACK)       lpfnNotifCallback,
  356.                                         (LPVOID)                lpvExplicitContext,
  357.                                         (LPMAPIADVISESINK FAR *) &lpAdviseSink);
  358.     }
  359.  
  360.     if(HR_FAILED(hResult1) )
  361.     {
  362. #ifdef XVPORT
  363.             XVPLog(xvpNum,0,E.SzError("HrAllocAdviseSink()", hResult1));
  364. #else
  365.         MessageBox( NULL, E.SzError("HrAllocAdviseSink()", hResult1),
  366.                      "Client", MBS_ERROR );
  367. #endif
  368.         return;
  369.     }
  370.  
  371.  
  372.     switch(ulObjType)
  373.     {
  374.         case MAPI_STORE:
  375.             hResult1 = ((LPMDB)lpUnk)->Advise(
  376.                 cbEntryID,
  377.                 lpEntryID,
  378.                 ulEventType,
  379.                 lpAdviseSink,
  380.                 &ulConnection);
  381.             break;
  382.         case MAPI_TABLE:  // defined in mdbview.h
  383.             hResult1 = ((LPMAPITABLE)lpUnk)->Advise(
  384.                 ulEventType,
  385.                 lpAdviseSink,
  386.                 &ulConnection);
  387.             break;
  388.         case MAPI_SESSION:
  389.         case MAPI_STATUS:
  390.             hResult1 = ((LPMAPISESSION)lpUnk)->Advise(
  391.                 cbEntryID,
  392.                 lpEntryID,
  393.                 ulEventType,
  394.                 lpAdviseSink,
  395.                 &ulConnection);
  396.             break;
  397.         case MAPI_ADDRBOOK:
  398.             hResult1 = ((LPADRBOOK)lpUnk)->Advise(
  399.                 cbEntryID,
  400.                 lpEntryID,
  401.                 ulEventType,
  402.                 lpAdviseSink,
  403.                 &ulConnection);
  404.             break;
  405.         default:
  406.             wsprintf(szBuff1,"[Error] Can't Advise on Object Type == %s",
  407.                     GetString("MAPIObjTypes",(LONG)ulObjType,szBuff2) );
  408. #ifdef XVPORT
  409.             XVPLog(xvpNum,0,szBuff1);
  410. #else
  411.             MessageBox( NULL, szBuff1, "Client", MBS_ERROR );
  412. #endif
  413.             break;
  414.     }
  415.     if( HR_FAILED(hResult1 ) )
  416.     {
  417.         if(lpszComment)
  418.         {
  419.             wsprintf(szBuff1,"%s->Advise()",lpszComment);
  420.  
  421. #ifdef XVPORT
  422.             XVPLog(xvpNum,0,E.SzError(szBuff1, hResult1));
  423. #else
  424.             MessageBox(  NULL, E.SzError(szBuff1, hResult1), "Client", MBS_ERROR );
  425. #endif
  426.         }
  427.         else
  428.         {
  429. #ifdef XVPORT
  430.             XVPLog(xvpNum,0,E.SzError("lpObj->Advise()", hResult1));
  431. #else
  432.             MessageBox(  NULL, E.SzError("lpObj->Advise()", hResult1), "Client", MBS_ERROR );
  433. #endif
  434.         }        
  435.         return;
  436.     }
  437.  
  438.  
  439.  
  440.     // if no notif list is currently allocated, allocate it now
  441.     if(! (*lppNotifs) )
  442.     {
  443.         lpNotifsTemp  = (LPNOTIFS) PvAlloc(sizeof(NOTIFS) );
  444.         *lppNotifs    = lpNotifsTemp;
  445.         (*lppNotifs)->cConnect = 0;
  446.     }
  447.  
  448.  
  449.  
  450.     (*lppNotifs)->cConnect++;
  451.  
  452.     // now add to my list
  453.     (*lppNotifs)->Connect[(*lppNotifs)->cConnect - 1].ulConnection = ulConnection;
  454.     if(lpszComment)
  455.         lstrcpy((*lppNotifs)->Connect[(*lppNotifs)->cConnect - 1].szContext,lpszComment);
  456.     else
  457.         lstrcpy((*lppNotifs)->Connect[(*lppNotifs)->cConnect - 1].szContext,"NULL");
  458.  
  459.     if(lpAdviseSink)
  460.         lpAdviseSink->Release();
  461.  
  462.  
  463. //$ FUTURE NEED TO FREE THIS MEMORY FOR LPCONTEXT !!!!
  464.  
  465. //    if(lpContext)
  466. //        PvFree(lpContext);
  467.  
  468. }
  469.  
  470. #ifdef XVPORT
  471.  
  472. /********************************************************************/
  473. /*
  474.  -  AdviseAllStatusObjects
  475.  -
  476.  *  Purpose:
  477.  *      Advise notification for status object modified on all
  478.  *      current status objects
  479.  *
  480.  *
  481.  *  Parameters:
  482.  *
  483.  */
  484. /********************************************************************/
  485.  
  486. void AdviseAllStatusObjects(void)
  487. {
  488.     CGetError       E;
  489.     HRESULT         hResult1    = hrSuccess;
  490.     LPSRowSet       lpRows      = NULL;
  491.     LONG            lRowsSeeked = 0;
  492.     ULONG           ulRowCount  = 0;
  493.     ULONG           iRow;
  494.     LPSPropTagArray lpsptaAll   = NULL;
  495.     char            szBuffer[COMMENT_SIZE];
  496.  
  497.     SizedSPropTagArray(2,sptaDisplay) =
  498.     {
  499.         2,
  500.         {
  501.             PR_DISPLAY_NAME,
  502.             PR_ENTRYID
  503.         }
  504.     };
  505.  
  506.     // if anything is already advised in status table, unadvise them
  507.     UnadviseAll( lpSession,MAPI_SESSION,"Status Objects lpSession",&lpStatusObjsNotifs);
  508.  
  509.     // then determine which objets have a status table row and advise them.
  510.  
  511.     hResult1 = lpStatusTable->GetRowCount(0,&ulRowCount);
  512.     if( HR_FAILED(hResult1))
  513.     {
  514.         MessageBox(  NULL, E.SzError("lpStatusTable->GetRowCount()", hResult1), "Client", MBS_ERROR );
  515.         goto Error;
  516.     }
  517.  
  518.     if( !ulRowCount)
  519.         return;
  520.  
  521.     // set which columns are important to see in table
  522.     hResult1 = lpStatusTable->SetColumns( (LPSPropTagArray) &sptaDisplay, 0);
  523.     if( HR_FAILED(hResult1))
  524.     {
  525.         MessageBox(  NULL, E.SzError("lpStatusTable->SetColumns", hResult1),
  526.                             "Client", MBS_ERROR );
  527.         goto Error;
  528.     }
  529.  
  530.     hResult1 = lpStatusTable->SeekRow( BOOKMARK_BEGINNING,0,&lRowsSeeked);
  531.     if( HR_FAILED(hResult1))
  532.     {
  533.         MessageBox(  NULL, E.SzError("lpStatusTable->SeekRow", hResult1),
  534.                             "Client", MBS_ERROR );
  535.         goto Error;
  536.     }
  537.  
  538.     hResult1 = lpStatusTable->QueryRows( ulRowCount, 0, &lpRows );
  539.  
  540.     if( GetScode(hResult1) == S_OK )
  541.     {
  542.         for(iRow = 0; iRow < lpRows->cRows; iRow++)
  543.         {
  544.             wsprintf(szBuffer,"fnevStatusObjectModified, Status Object %s, lpSession",
  545.                             lpRows->aRow[iRow].lpProps[0].Value.lpszA);
  546.             AdviseObj(  lpSession,
  547.                         MAPI_SESSION,
  548.                         LogNotifToXVPLog,
  549.                         fnevStatusObjectModified,
  550.                         (ULONG)     lpRows->aRow[iRow].lpProps[1].Value.bin.cb,
  551.                         (LPENTRYID) lpRows->aRow[iRow].lpProps[1].Value.bin.lpb,
  552.                         szBuffer,
  553.                         NULL,
  554.                         &lpStatusObjsNotifs);
  555.         }
  556.     }
  557.  
  558. Error:
  559.  
  560.     // query columns all columns
  561.     hResult1 = lpStatusTable->QueryColumns(TBL_ALL_COLUMNS, &lpsptaAll);
  562.     if( HR_FAILED(hResult1))
  563.     {
  564.         MessageBox(  NULL, E.SzError("lpStatusTable->QueryColumns(TBL_ALL_COLUMNS)", hResult1),
  565.                             "Client", MBS_ERROR );
  566.     }
  567.  
  568.     // set columns all columns to get back to original state
  569.     hResult1 = lpStatusTable->SetColumns( (LPSPropTagArray) lpsptaAll, 0);
  570.     if( HR_FAILED(hResult1))
  571.     {
  572.         MessageBox(  NULL, E.SzError("lpStatusTable->SetColumns", hResult1),
  573.                             "Client", MBS_ERROR );
  574.     }
  575.  
  576.     // free Memory allocated
  577.     FreeRowSet(lpRows);
  578.  
  579.     if(lpsptaAll)
  580.         MAPIFreeBuffer(lpsptaAll);
  581.  
  582.     // NOTE: it should fire two notifications on table modified for status table
  583. }
  584.  
  585. #endif // XVPORT
  586.  
  587.  
  588. /********************************************************************/
  589. /*
  590.  -  FreeAdrList
  591.  -
  592.  *  Purpose:
  593.  *      Given an Address List, will free it.
  594.  *
  595.  *  Parameters:
  596.  *      LPADRLIST - Pointer to Address List to free.
  597.  *
  598.  */
  599. /********************************************************************/
  600.  
  601. void FreeAdrList( LPADRLIST lpadrlist )
  602. {
  603.     ULONG cEntries = 0;
  604.  
  605.     if (lpadrlist)
  606.     {
  607.         for (cEntries = 0; cEntries < lpadrlist->cEntries; cEntries++)
  608.         {
  609.             if(lpadrlist->aEntries[cEntries].rgPropVals)
  610.                 MAPIFreeBuffer(lpadrlist->aEntries[cEntries].rgPropVals);
  611.         }
  612.  
  613.         MAPIFreeBuffer(lpadrlist);
  614.     }
  615. }
  616.  
  617.  
  618. /********************************************************************/
  619. /********************** CMainWindow Member Functions ****************/
  620.  
  621. /******************************************************************/
  622. /*
  623.  -  CMainWindow::
  624.  -  OnAbout
  625.  -
  626.  *  Purpose:
  627.  *      We create a CModalDialog object using the "AboutBox" resource
  628.  *      (see mdbview.rc), and invoke it.  Describes what this application
  629.  *      is, and what version it is.
  630.  */
  631. /*******************************************************************/
  632.  
  633. void CMainWindow::OnAbout()
  634. {
  635.     CModalDialog about( "AboutBox", this );
  636.     about.DoModal();
  637. }
  638.  
  639. /*******************************************************************/
  640. /*
  641.  -  CMainWindow::
  642.  -  OnLogon
  643.  *
  644.  *  Purpose:
  645.  *      Have user logon to MAPI 1.0 to obtain a session handle for MAPI
  646.  *      user.  lpSession is a global variable used to reference the
  647.  *      session this application has logged onto.
  648.  */
  649. /*******************************************************************/
  650.  
  651. /*  Extended MAPI Logon function */
  652.  
  653. void CMainWindow::OnLogon()
  654. {
  655.     CGetError   E;
  656.     COperation  LogonDlg(this);
  657.     char        szBuff[80];
  658.     ULONG       ulUIParam   = 0;
  659.     ULONG       ulFlags     = 0;
  660.     DWORD       dRet        = 0;
  661.     HRESULT     hResult1    = hrSuccess;
  662.     CMenu       *menu       = GetMenu();
  663.  
  664.     if(lpSession)
  665.     {
  666.         lpSession->Release();
  667.         lpSession = NULL;
  668.     }
  669.  
  670.     menu->EnableMenuItem( IDM_EXIT,             MF_GRAYED  );
  671.     menu->EnableMenuItem( IDM_LOGON,            MF_GRAYED  );
  672.  
  673.     LogonDlg.m_CurrentOperation= "MAPILogonEx(MAPI_LOGON_UI)";
  674.     LogonDlg.m_CBText1         = "ulUIParam:";
  675.     LogonDlg.m_FlagText1       = "MAPI_FORCE_DOWNLOAD";
  676.     LogonDlg.m_FlagText2       = "MAPI_NEW_SESSION";
  677.     LogonDlg.m_FlagText3       = "MAPI_ALLOW_OTHERS";
  678.     LogonDlg.m_FlagText4       = "MAPI_EXPLICIT_PROFILE";
  679.     LogonDlg.m_FlagText5       = "MAPI_NO_MAIL";
  680.     LogonDlg.m_FlagText6       = "MAPI_UNICODE";
  681.  
  682.     dRet = LogonDlg.m_CBContents1.Add("NULL");
  683.     wsprintf(szBuff,"Parent hWnd == %X",this->m_hWnd);
  684.     dRet = LogonDlg.m_CBContents1.Add(szBuff);
  685.  
  686.  
  687.     // bring up modal dialog box, and if user hits OK, process operation
  688.     if( LogonDlg.DoModal() == IDOK )
  689.     {
  690.         // determine state/settings of data in dialog upon closing
  691.  
  692.         if( !lstrcmp(LogonDlg.m_szCB1,"NULL") )
  693.             ulUIParam = (ULONG)NULL;
  694.         else
  695.             ulUIParam = (ULONG)(void *)this->m_hWnd;
  696.  
  697.         ulFlags = MAPI_LOGON_UI;
  698.  
  699.         if( LogonDlg.m_bFlag1 )
  700.             ulFlags |= MAPI_FORCE_DOWNLOAD;
  701.  
  702.         if( LogonDlg.m_bFlag2 )
  703.             ulFlags |= MAPI_NEW_SESSION;
  704.  
  705.         if( LogonDlg.m_bFlag3 )
  706.             ulFlags |= MAPI_ALLOW_OTHERS;
  707.  
  708.         if( LogonDlg.m_bFlag4 )
  709.             ulFlags |= MAPI_EXPLICIT_PROFILE;
  710.  
  711.         if( LogonDlg.m_bFlag5)
  712.             ulFlags |= MAPI_NO_MAIL;
  713.  
  714.         if( LogonDlg.m_bFlag6)
  715.             ulFlags |= MAPI_UNICODE;
  716.  
  717.         hResultSession = MAPILogonEx(   ulUIParam,
  718.                                 NULL,
  719.                                 NULL,
  720.                                 ulFlags,
  721.                                 (LPMAPISESSION FAR *) &lpSession);
  722.         if( HR_FAILED(hResultSession ) )
  723.         {
  724.             MessageBox( E.SzError("MAPILogonEx", hResultSession), "Client", MBS_ERROR );
  725.             menu->EnableMenuItem( IDM_EXIT,             MF_ENABLED  );
  726.             goto Error;
  727.         }
  728.  
  729.         menu->EnableMenuItem( IDM_EXIT,             MF_ENABLED  );
  730.  
  731.         // open address book to lpSession->QueryIdentity() entryid
  732.         //   can be resolved as a oneoff, and for lpMessage->ModifyRecipients();
  733.  
  734.         hResultSession = lpSession->OpenAddressBook( NULL,
  735.                                 NULL,
  736.                                 0,
  737.                                 &lpAdrBook);
  738.         if( HR_FAILED(hResultSession ) )
  739.         {
  740.             MessageBox( E.SzError("lpSession->OpenAddressBook()", hResultSession), "Client", MBS_ERROR );
  741.             goto Error;
  742.         }
  743.  
  744.         hResultSession = lpSession->GetStatusTable(0, &lpStatusTable);
  745.         if(HR_FAILED(hResultSession) )
  746.         {
  747.             MessageBox( E.SzError("lpSession->GetStatusTable()", hResultSession),
  748.                      "Client", MBS_ERROR );
  749.             goto Error;
  750.         }
  751.  
  752.  
  753.  
  754.         hResultSession = lpSession->GetMsgStoresTable(0, &lpStoresTable);
  755.  
  756.         if(HR_FAILED(hResultSession) )
  757.         {
  758.             MessageBox( E.SzError("lpSession->GetMsgStoresTable()", hResultSession),
  759.                      "Client", MBS_ERROR );
  760.             return;
  761.         }
  762.  
  763.  
  764. #ifdef XVPORT
  765.         // ADVISE STATUS TABLE NOTIFICATON
  766.  
  767.         AdviseObj(  lpStoresTable,
  768.                     MAPI_TABLE,
  769.                     LogNotifToXVPLog,
  770.                     fnevTableModified,
  771.                     0,
  772.                     NULL,
  773.                     "fnevTableModified, lpSession->GetMsgStoresTable, lpSession",
  774.                     NULL,
  775.                     &lpNotifStoresTable);
  776.  
  777.         // if logon successfully, allow opening of store, etc.
  778.  
  779.         XVPShow(xvpNum, XVP_SHOW);
  780.         XVPShow(xvpNum, XVP_MIN);
  781.         XVPReset(xvpNum);
  782. #endif
  783.  
  784.         ToggleMenu( TRUE );
  785.  
  786.         return;
  787.     }
  788.  
  789. Error:
  790.  
  791. #ifdef XVPORT
  792.     UnadviseAll(lpStatusTable,  MAPI_TABLE,     "Status Table lpSession",    &lpStatusTblNotifs);
  793.     UnadviseAll(lpSession,      MAPI_SESSION,   "Session Objs lpSession",    &lpSessionNotifs);
  794.     UnadviseAll(lpStoresTable,  MAPI_TABLE,     "GetMsgStoresTable, lpTable",&lpNotifStoresTable);
  795. #endif
  796.  
  797.     // call OnLogoff
  798.  
  799.     if(lpSession)
  800.     {
  801.         lpSession->Release();
  802.         lpSession = NULL;
  803.     }
  804.  
  805.     if(lpAdrBook)
  806.     {
  807.         lpAdrBook->Release();
  808.         lpAdrBook = NULL;
  809.     }
  810.  
  811.     if(lpStatusTable)
  812.     {
  813.         lpStatusTable->Release();
  814.         lpStatusTable = NULL;
  815.     }
  816.  
  817.     if(lpEntryListSearchFolder)
  818.     {
  819.         PvFree(lpEntryListSearchFolder);
  820.         lpEntryListSearchFolder = NULL;
  821.     }
  822.  
  823.     if(lpStoresTable)
  824.     {
  825.         lpStoresTable->Release();
  826.         lpStoresTable = NULL;
  827.     }
  828.  
  829.     ToggleMenu( FALSE );
  830.  
  831. #ifdef XVPORT
  832.     XVPShow(xvpNum, XVP_HIDE);
  833.     XVPReset(xvpNum);
  834. #endif
  835.  
  836. }
  837.  
  838. /*******************************************************************/
  839. /*
  840.  -  CMainWindow::
  841.  -  OnLogoff
  842.  *
  843.  *  Purpose:
  844.  *      Logoff From MAPI session.   lpSession is a global variable
  845.  *      used to reference the session this application has logged onto.
  846.  *
  847.  */
  848. /*******************************************************************/
  849.  
  850. void CMainWindow::OnLogoff()
  851. {
  852.     CGetError   E;
  853.  
  854.     if(lpSession)
  855.     {
  856.  
  857. #ifdef XVPORT
  858.         UnadviseAll(lpStatusTable,  MAPI_TABLE,     "Status Table lpSession",   &lpStatusTblNotifs);
  859.         UnadviseAll(lpSession,      MAPI_SESSION,   "Session Objs lpSession",   &lpSessionNotifs);
  860.         UnadviseAll(lpMDB,          MAPI_STORE,     "MDB Objs lpMDB",           &lpMDBNotifs);
  861.         UnadviseAll(lpStoresTable,  MAPI_TABLE,     "GetMsgStoresTable, lpTable",&lpNotifStoresTable);
  862. #endif
  863.  
  864.         if(lpIdentityObj)
  865.         {
  866.             lpIdentityObj->Release();
  867.             lpIdentityObj = NULL;
  868.         }
  869.  
  870.         if(lpStoresTable)
  871.         {
  872.             lpStoresTable->Release();
  873.             lpStoresTable = NULL;
  874.         }
  875.  
  876.         if(lpReceiveFolderTable)
  877.         {
  878.             lpReceiveFolderTable->Release();
  879.             lpReceiveFolderTable = NULL;
  880.         }
  881.  
  882.         if(lpStatusTable)
  883.         {
  884.             lpStatusTable->Release();
  885.             lpStatusTable = NULL;
  886.         }
  887.  
  888.         if(lpAdrBook)
  889.         {
  890.             lpAdrBook->Release();
  891.             lpAdrBook = NULL;
  892.         }
  893.  
  894.         if(lpMDB)
  895.             OnStoreLogoff();
  896.  
  897.         hResultSession = lpSession->Logoff(
  898.                     (ULONG)(void *)m_hWnd,
  899.                     MAPI_LOGOFF_UI,
  900.                     0 );
  901.         if( HR_FAILED(hResultSession) )
  902.         {
  903.             MessageBox( E.SzError("Logoff", hResultSession), "Client", MBS_ERROR );
  904.             return;
  905.         }
  906.  
  907.         if(lpSession)
  908.         {
  909.             lpSession->Release();
  910.             lpSession = NULL;
  911.         }
  912.  
  913.         ToggleMenu( FALSE );
  914.     }
  915.  
  916.     if(lpEntryListSearchFolder)
  917.     {
  918.         PvFree(lpEntryListSearchFolder);
  919.         lpEntryListSearchFolder = NULL;
  920.     }
  921.  
  922. #ifdef XVPORT
  923.     XVPShow(xvpNum,XVP_HIDE);
  924.     XVPReset(xvpNum);
  925. #endif
  926. }
  927.  
  928. /********************************************************************/
  929. /*
  930.  -  CMainWindow::
  931.  -  OnMDBSupportMask
  932.  -
  933.  *  Purpose:
  934.  *
  935.  /********************************************************************/
  936.  
  937. void CMainWindow::OnMDBSupportMask()
  938. {
  939.     CStoreSupportMaskDlg    Support(this);
  940.     Support.DoModal();
  941. }
  942.  
  943. /********************************************************************/
  944. /*
  945.  -  CMainWindow::
  946.  -  OnIPMSubtree
  947.  -
  948.  *  Purpose:
  949.  *
  950.  /********************************************************************/
  951.  
  952. void CMainWindow::OnIPMSubtree()
  953. {
  954.     CFolderDlg      *lpIPMSubtreeFld        = NULL;
  955.     HRESULT         hResult1                = hrSuccess;
  956.     CGetError       E;
  957.     LPMAPIFOLDER        lpFolder                = NULL;
  958.     ULONG           ulObjType               = 0;
  959.     LPSPropValue    lpspva                  = NULL;
  960.     ULONG           cValues                 = 0;
  961.     char            szBuffer[80];
  962.  
  963.     // proptag array used by GetProps for getting entryid of IPM subtree
  964.     SPropTagArray   sptaIPMSubtree =
  965.     {
  966.         1,
  967.         {
  968.             PR_IPM_SUBTREE_ENTRYID
  969.         }
  970.     };
  971.  
  972.  
  973.     // open up the object described, determine if folder, and open folder dlg
  974.     hResult1 = lpMDB->GetProps( &sptaIPMSubtree,0,&cValues,&lpspva );
  975.     if(HR_FAILED(hResult1) )
  976.     {
  977.         MessageBox( E.SzError("lpMDB->GetProps() PR_IPM_SUBTREE_ENTRYID",hResult1),
  978.                         "Client", MBS_ERROR );
  979.         goto Error;
  980.     }
  981.  
  982.     if( ! (lpspva[0].ulPropTag == PR_IPM_SUBTREE_ENTRYID) )
  983.     {
  984.         MessageBox( "Message Store has no valid PR_IPM_SUBTREE_ENTRYID" ,"Client", MBS_ERROR );
  985.         goto Error;
  986.     }
  987.  
  988.     // open up the object described, determine if folder, and open folder dlg
  989.     hResult1 = lpMDB->OpenEntry(    (ULONG)     lpspva[0].Value.bin.cb,
  990.                                     (LPENTRYID) lpspva[0].Value.bin.lpb,
  991.                                     NULL,
  992.                                     ulAccess,
  993.                                     &ulObjType,
  994.                                     (LPUNKNOWN*)(LPMAPIPROP *) &lpFolder);
  995.     if( HR_FAILED(hResult1) )
  996.     {
  997.         MessageBox( E.SzError("lpMDB->OpenEntry() IPM SUBTREE",hResult1),
  998.                         "Client", MBS_ERROR );
  999.         goto Error;
  1000.     }
  1001.     if( ulObjType == MAPI_FOLDER )
  1002.     {
  1003.         wsprintf(szBuffer,"%s - %s", GetString("MAPIObjTypes",ulObjType,NULL),"IPM_SUBTREE");
  1004.         lpIPMSubtreeFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpFolder,this);
  1005.     }
  1006.     else
  1007.     {
  1008.         MessageBox("ulObjType of OpenEntry on lpFolder != MAPI_FOLDER","Client",MBS_ERROR);
  1009.         goto Error;
  1010.     }
  1011.  
  1012. Error:
  1013.  
  1014.     if(lpspva)
  1015.         MAPIFreeBuffer(lpspva);
  1016.  
  1017. }
  1018.  
  1019.  
  1020. /********************************************************************/
  1021. /*
  1022.  -  CMainWindow::
  1023.  -  OnIPMOutbox
  1024.  -
  1025.  *  Purpose:
  1026.  *
  1027.  /********************************************************************/
  1028.  
  1029. void CMainWindow::OnIPMOutbox()
  1030. {
  1031.     CFolderDlg      *lpIPMOutboxFld        = NULL;
  1032.     HRESULT         hResult1                = hrSuccess;
  1033.     CGetError       E;
  1034.     LPMAPIFOLDER        lpFolder                = NULL;
  1035.     ULONG           ulObjType               = 0;
  1036.     LPSPropValue    lpspva                  = NULL;
  1037.     ULONG           cValues                 = 0;
  1038.     char            szBuffer[80];
  1039.  
  1040.  
  1041.     // proptag array used by GetProps for getting entryid of IPM subtree
  1042.     SPropTagArray   sptaIPMOutbox =
  1043.     {
  1044.         1,
  1045.         {
  1046.             PR_IPM_OUTBOX_ENTRYID
  1047.         }
  1048.     };
  1049.  
  1050.     // open up the object described, determine if folder, and open folder dlg
  1051.     hResult1 = lpMDB->GetProps( &sptaIPMOutbox,0,&cValues,&lpspva );
  1052.     if(HR_FAILED(hResult1) )
  1053.     {
  1054.         MessageBox( E.SzError("lpMDB->GetProps() PR_IPM_OUTBOX_ENTRYID",hResult1),
  1055.                         "Client", MBS_ERROR );
  1056.         goto Error;
  1057.     }
  1058.  
  1059.     if( ! (lpspva[0].ulPropTag == PR_IPM_OUTBOX_ENTRYID) )
  1060.     {
  1061.         MessageBox( "Message Store has no valid PR_IPM_OUTBOX_ENTRYID" ,"Client", MBS_ERROR );
  1062.         goto Error;
  1063.     }
  1064.  
  1065.     // open up the object described, determine if folder, and open folder dlg
  1066.     hResult1 = lpMDB->OpenEntry(    (ULONG)     lpspva[0].Value.bin.cb,
  1067.                                         (LPENTRYID) lpspva[0].Value.bin.lpb,
  1068.                                         NULL,
  1069.                                         ulAccess,
  1070.                                         &ulObjType,
  1071.                                         (LPUNKNOWN*)(LPMAPIPROP *) &lpFolder);
  1072.     if(HR_FAILED(hResult1) )
  1073.     {
  1074.         MessageBox( E.SzError("lpMDB->OpenEntry() IPM OUTBOX",hResult1),
  1075.                         "Client", MBS_ERROR );
  1076.         goto Error;
  1077.     }
  1078.     if( ulObjType == MAPI_FOLDER )
  1079.     {
  1080.         wsprintf(szBuffer,"%s - %s", GetString("MAPIObjTypes",ulObjType,NULL),"IPM_OUTBOX");
  1081.         lpIPMOutboxFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpFolder,this);
  1082.     }
  1083.     else
  1084.     {
  1085.         MessageBox("ulObjType of OpenEntry on lpFolder != MAPI_FOLDER","Client",MBS_ERROR);
  1086.         goto Error;
  1087.     }
  1088.  
  1089. Error:
  1090.  
  1091.     if(lpspva)
  1092.         MAPIFreeBuffer(lpspva);
  1093.  
  1094. }
  1095.  
  1096.  
  1097. /********************************************************************/
  1098. /*
  1099.  -  CMainWindow::
  1100.  -  OnIPMWasteBasket
  1101.  -
  1102.  *  Purpose:
  1103.  *
  1104.  /********************************************************************/
  1105.  
  1106. void CMainWindow::OnIPMWasteBasket()
  1107. {
  1108.     CFolderDlg      *lpIPMWasteBasketFld        = NULL;
  1109.     HRESULT         hResult1                = hrSuccess;
  1110.     CGetError       E;
  1111.     ULONG           ulEntryID               = 0;
  1112.     LPENTRYID       lpEntryID               = NULL;
  1113.     LPMAPIFOLDER        lpFolder                = NULL;
  1114.     ULONG           ulObjType               = 0;
  1115.     LPSPropValue    lpspva                  = NULL;
  1116.     ULONG           cValues                 = 0;
  1117.     char            szBuffer[80];
  1118.  
  1119.     // proptag array used by GetProps for getting entryid of IPM subtree
  1120.     SPropTagArray   sptaIPMWasteBasket =
  1121.     {
  1122.         1,
  1123.         {
  1124.             PR_IPM_WASTEBASKET_ENTRYID
  1125.         }
  1126.     };
  1127.  
  1128.     // open up the object described, determine if folder, and open folder dlg
  1129.     hResult1 = lpMDB->GetProps( &sptaIPMWasteBasket,0,&cValues,&lpspva );
  1130.     if(HR_FAILED(hResult1) )
  1131.     {
  1132.         MessageBox( E.SzError("lpMDB->GetProps() PR_IPM_WASTEBASKET_ENTRYID",hResult1),
  1133.                         "Client", MBS_ERROR );
  1134.         goto Error;
  1135.     }
  1136.  
  1137.     if( ! (lpspva[0].ulPropTag == PR_IPM_WASTEBASKET_ENTRYID) )
  1138.     {
  1139.         MessageBox( "Message Store has no valid PR_IPM_WASTEBASKET_ENTRYID" ,"Client", MBS_ERROR );
  1140.         goto Error;
  1141.     }
  1142.  
  1143.     // open up the object described, determine if folder, and open folder dlg
  1144.     hResult1 = lpMDB->OpenEntry(    (ULONG)     lpspva[0].Value.bin.cb,
  1145.                                         (LPENTRYID) lpspva[0].Value.bin.lpb,
  1146.                                         NULL,
  1147.                                         ulAccess,
  1148.                                         &ulObjType,
  1149.                                         (LPUNKNOWN*)(LPMAPIPROP *) &lpFolder);
  1150.     if(HR_FAILED(hResult1) )
  1151.     {
  1152.         MessageBox( E.SzError("lpMDB->OpenEntry() IPM WASTEBASKET",hResult1),
  1153.                         "Client", MBS_ERROR );
  1154.         goto Error;
  1155.     }
  1156.     if( ulObjType == MAPI_FOLDER )
  1157.     {
  1158.         wsprintf(szBuffer,"%s - %s", GetString("MAPIObjTypes",ulObjType,NULL),"IPM_WASTEBASKET");
  1159.         lpIPMWasteBasketFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpFolder,this);
  1160.     }
  1161.     else
  1162.     {
  1163.         MessageBox("ulObjType of OpenEntry on lpFolder != MAPI_FOLDER","Client",MBS_ERROR);
  1164.         goto Error;
  1165.     }
  1166.  
  1167. Error:
  1168.  
  1169.     if(lpspva)
  1170.         MAPIFreeBuffer(lpspva);
  1171.  
  1172. }
  1173.  
  1174.  
  1175. /********************************************************************/
  1176. /*
  1177.  -  CMainWindow::
  1178.  -  OnIPMSentMail
  1179.  -
  1180.  *  Purpose:
  1181.  *
  1182.  /********************************************************************/
  1183.  
  1184. void CMainWindow::OnIPMSentMail()
  1185. {
  1186.     CFolderDlg      *lpIPMSentMailFld       = NULL;
  1187.     HRESULT         hResult1                = hrSuccess;
  1188.     CGetError       E;
  1189.     ULONG           ulEntryID               = 0;
  1190.     LPENTRYID       lpEntryID               = NULL;
  1191.     LPMAPIFOLDER        lpFolder                = NULL;
  1192.     ULONG           ulObjType               = 0;
  1193.     LPSPropValue    lpspva                  = NULL;
  1194.     ULONG           cValues                 = 0;
  1195.     char            szBuffer[80];
  1196.  
  1197.     // proptag array used by GetProps for getting entryid of IPM subtree
  1198.     SPropTagArray   sptaIPMSentMail =
  1199.     {
  1200.         1,
  1201.         {
  1202.             PR_IPM_SENTMAIL_ENTRYID
  1203.         }
  1204.     };
  1205.  
  1206.  
  1207.     // open up the object described, determine if folder, and open folder dlg
  1208.     hResult1 = lpMDB->GetProps( &sptaIPMSentMail,0,&cValues,&lpspva );
  1209.     if(HR_FAILED(hResult1) )
  1210.     {
  1211.         MessageBox( E.SzError("lpMDB->GetProps() PR_IPM_SENTMAIL_ENTRYID",hResult1),
  1212.                         "Client", MBS_ERROR );
  1213.         goto Error;
  1214.     }
  1215.  
  1216.     if( ! (lpspva[0].ulPropTag == PR_IPM_SENTMAIL_ENTRYID) )
  1217.     {
  1218.         MessageBox( "Message Store has no valid PR_IPM_SENTMAIL_ENTRYID" ,"Client", MBS_ERROR );
  1219.         goto Error;
  1220.     }
  1221.  
  1222.     // open up the object described, determine if folder, and open folder dlg
  1223.     hResult1 = lpMDB->OpenEntry(    (ULONG)     lpspva[0].Value.bin.cb,
  1224.                                         (LPENTRYID) lpspva[0].Value.bin.lpb,
  1225.                                         NULL,
  1226.                                         ulAccess,
  1227.                                         &ulObjType,
  1228.                                         (LPUNKNOWN*)(LPMAPIPROP *) &lpFolder);
  1229.     if(HR_FAILED(hResult1) )
  1230.     {
  1231.         MessageBox( E.SzError("lpMDB->OpenEntry() IPM SENTMAIL",hResult1),
  1232.                         "Client", MBS_ERROR );
  1233.         goto Error;
  1234.     }
  1235.     if( ulObjType == MAPI_FOLDER )
  1236.     {
  1237.         wsprintf(szBuffer,"%s - %s", GetString("MAPIObjTypes",ulObjType,NULL),"IPM_SENTMAIL");
  1238.         lpIPMSentMailFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpFolder,this);
  1239.     }
  1240.     else
  1241.     {
  1242.         MessageBox("ulObjType of OpenEntry on lpFolder != MAPI_FOLDER","Client",MBS_ERROR);
  1243.         goto Error;
  1244.     }
  1245.  
  1246. Error:
  1247.  
  1248.     if(lpspva)
  1249.         MAPIFreeBuffer(lpspva);
  1250.  
  1251. }
  1252.  
  1253. /********************************************************************/
  1254. /*
  1255.  -  CMainWindow::
  1256.  -  OnOpenStatusObj
  1257.  -
  1258.  *  Purpose:
  1259.  *
  1260.  /********************************************************************/
  1261.  
  1262. void CMainWindow::OnOpenStatusObj()
  1263. {
  1264.     // ADVISE ALL STATUS OBJECTS
  1265. #ifdef XVPORT
  1266.     AdviseAllStatusObjects();
  1267.  
  1268. #endif
  1269.     STATVUViewMapiStat(
  1270.                 (LPMAPISESSION FAR *)&lpSession, (HWND)this->m_hWnd );
  1271. }
  1272.  
  1273. /********************************************************************/
  1274. /*
  1275.  -  CMainWindow::
  1276.  -  OnGetLastError
  1277.  -
  1278.     hResultSession is Global(Session Objects Only)
  1279.  
  1280.  *  Purpose:
  1281.  *
  1282.  /********************************************************************/
  1283.  
  1284. void CMainWindow::OnGetLastError()
  1285. {
  1286.     COperation      GetLastErrorDlg(this);
  1287.     ULONG           ulFlags         = 0;
  1288.     CGetError       E;
  1289.     HRESULT         hResult1        = hrSuccess;
  1290.     char            szResult[80];
  1291.     char            szBuffer[128];
  1292.     LPMAPIERROR     lpMAPIError     = NULL;
  1293.  
  1294.     GetLastErrorDlg.m_CurrentOperation= "lpSession->GetLastError()";
  1295.     GetLastErrorDlg.m_EditText1       = "hResultSession(HEX)";
  1296.     GetLastErrorDlg.m_EditText2       = "hResultSession(STRING):";
  1297.     GetLastErrorDlg.m_FlagText1       = "MAPI_UNICODE";
  1298.     GetLastErrorDlg.m_FlagText2       = "Invalid Flag";
  1299.  
  1300.     wsprintf( szResult, "0x%08X", hResultSession );
  1301.     GetLastErrorDlg.m_EditDefault1    = szResult;
  1302.  
  1303.     if(!GetString( "MAPIErrors", GetScode(hResultSession), szResult ))
  1304.         wsprintf( szResult, "0x%08X", hResultSession );
  1305.     GetLastErrorDlg.m_EditDefault2    = szResult;
  1306.  
  1307.     if( GetLastErrorDlg.DoModal() == IDOK )
  1308.     {
  1309.         // determine state/settings of data in dialog upon closing
  1310.         if( GetLastErrorDlg.m_bFlag2 )
  1311.             ulFlags |= TEST_INVALID_FLAG;
  1312.  
  1313.         if( GetLastErrorDlg.m_bFlag1 )
  1314.         {
  1315.             ulFlags |= MAPI_UNICODE;
  1316.  
  1317.             hResult1 = lpSession->GetLastError(
  1318.                             hResultSession,
  1319.                             ulFlags,
  1320.                             &lpMAPIError );
  1321.  
  1322.             if(HR_FAILED(hResult1) )
  1323.             {
  1324.                 MessageBox( E.SzError("lpSession->GetLastError()",
  1325.                              hResultSession),"Client", MBS_ERROR );
  1326.                 return;
  1327.             }
  1328.  
  1329.             if(lpMAPIError)
  1330.             {
  1331.                 // CONVERT TO STRING 8 then display !!!
  1332.                 wsprintf(szBuffer,"lpObj->GetLastError()  ulLowLevelError == %lu,ulVersion == %lu lpszMessage == %s, lpszComponent == %s, ulContext == %lu",
  1333.                     lpMAPIError->ulLowLevelError,
  1334.                     lpMAPIError->ulVersion,
  1335.                     ((lpMAPIError->lpszError == NULL)     ? "NULL" : lpMAPIError->lpszError),
  1336.                     ((lpMAPIError->lpszComponent == NULL) ? "NULL" : lpMAPIError->lpszComponent),
  1337.                     lpMAPIError->ulContext);
  1338.  
  1339.                 MessageBox( szBuffer, "Client", MBS_INFO );
  1340.   
  1341.             }
  1342.         }          
  1343.         else
  1344.         {
  1345.  
  1346.             hResult1 = lpSession->GetLastError(
  1347.                             hResultSession,
  1348.                             ulFlags,
  1349.                             &lpMAPIError );
  1350.  
  1351.             if(HR_FAILED(hResult1) )
  1352.             {
  1353.                 MessageBox( E.SzError("lpSession->GetLastError()",
  1354.                              hResultSession),"Client", MBS_ERROR );
  1355.                 return;
  1356.             }
  1357.  
  1358.             if(lpMAPIError)
  1359.             {
  1360.                 // CONVERT TO STRING 8 then display !!!
  1361.                 wsprintf(szBuffer,"lpObj->GetLastError()  ulLowLevelError == %lu,ulVersion == %lu lpszMessage == %s, lpszComponent == %s, ulContext == %lu",
  1362.                     lpMAPIError->ulLowLevelError,
  1363.                     lpMAPIError->ulVersion,
  1364.                     ((lpMAPIError->lpszError == NULL)     ? "NULL" : lpMAPIError->lpszError),
  1365.                     ((lpMAPIError->lpszComponent == NULL) ? "NULL" : lpMAPIError->lpszComponent),
  1366.                     lpMAPIError->ulContext);
  1367.  
  1368.                 MessageBox( szBuffer, "Client", MBS_INFO );
  1369.             }
  1370.         }
  1371.  
  1372.         if(lpMAPIError)
  1373.             MAPIFreeBuffer(lpMAPIError);
  1374.  
  1375.         // reset global hResultSession
  1376.         hResultSession = hrSuccess;
  1377.     }
  1378. }
  1379.  
  1380. /********************************************************************/
  1381. /*
  1382.  -  CMainWindow::
  1383.  -  OnAddress
  1384.  -
  1385.  *  Purpose:
  1386.  *
  1387.  /********************************************************************/
  1388.  
  1389. void CMainWindow::OnAddress()
  1390. {
  1391.     HRESULT         hResult1         = hrSuccess;
  1392.     LPSTR           rglpszDestTitles[3];
  1393.     ULONG           rgulDestComps[3];
  1394.     ADRPARM         adrparm         = { 0 };
  1395.     LPADRLIST       lpAdrList       = NULL;
  1396.     ULONG           ulUIParam       = (ULONG)(void *)m_hWnd;
  1397.     CGetError       E;
  1398.     CAdrListDlg     AdrListDlg(this);
  1399.  
  1400.     // bring up UI for determining what the ADDRESS LIST will look like
  1401.  
  1402.     rglpszDestTitles[0] = "To:";
  1403.     rglpszDestTitles[1] = "Cc:";
  1404.     rglpszDestTitles[2] = "Bcc:";
  1405.  
  1406.     rgulDestComps[0]    = MAPI_TO;
  1407.     rgulDestComps[1]    = MAPI_CC;
  1408.     rgulDestComps[2]    = MAPI_BCC;
  1409.  
  1410.     adrparm.cbABContEntryID     = 0;
  1411.     adrparm.lpABContEntryID     = NULL;
  1412.     adrparm.ulFlags             = DIALOG_MODAL;
  1413.     adrparm.lpReserved          = NULL;
  1414.     adrparm.ulHelpContext       = 0;
  1415.     adrparm.lpszHelpFileName    = NULL;
  1416.     adrparm.lpfnABSDI           = NULL;
  1417.     adrparm.lpfnDismiss         = NULL;
  1418.     adrparm.lpvDismissContext   = NULL;
  1419.     adrparm.lpszCaption         = "AddressBook";
  1420.     adrparm.lpszNewEntryTitle   = "MDB Viewer New Entry";
  1421.     adrparm.lpszDestWellsTitle  = "Destinations";
  1422.     adrparm.cDestFields         = 3;
  1423.     adrparm.nDestFieldFocus     = 0;
  1424.     adrparm.lppszDestTitles     = rglpszDestTitles;
  1425.     adrparm.lpulDestComps       = rgulDestComps;
  1426.     adrparm.lpContRestriction   = NULL;
  1427.     adrparm.lpHierRestriction   = NULL;
  1428.     adrparm.cDestFields         = (ULONG) 3;
  1429.  
  1430.     hResult1 = lpAdrBook->Address(
  1431.                     &ulUIParam,
  1432.                     &adrparm,
  1433.                     &lpAdrList );
  1434.  
  1435.     if(HR_FAILED(hResult1) )
  1436.     {
  1437.         MessageBox( E.SzError("lpAdrBook->Address()", hResult1), "Client", MB_OK );
  1438.     }
  1439.  
  1440.  
  1441.  
  1442.     AdrListDlg.m_List       = "Address List Built with Address()";
  1443.     AdrListDlg.m_lpAdrList  = lpAdrList;
  1444.  
  1445.     AdrListDlg.DoModal();
  1446.  
  1447.     if(lpAdrList)
  1448.         MAPIFreeBuffer(lpAdrList);
  1449. }
  1450.  
  1451. /********************************************************************/
  1452. /*
  1453.  -  CMainWindow::
  1454.  -  OnCreateOneOff
  1455.  -
  1456.  *  Purpose:
  1457.  *
  1458.  /********************************************************************/
  1459.  
  1460. void CMainWindow::OnCreateOneOff()
  1461. {
  1462.     CPropDisplayDlg DisplayEID(this);
  1463.     COperation      CreateOneOffDlg(this);
  1464.     LPWSTR          lpNewBuffer1    = NULL;
  1465.     LPWSTR          lpNewBuffer2    = NULL;
  1466.     LPWSTR          lpNewBuffer3    = NULL;
  1467.     ULONG           ulFlags         = 0;
  1468.     ULONG           ulEntryID       = 0;
  1469.     LPENTRYID       lpEntryID       = 0;
  1470.     CGetError       E;
  1471.     HRESULT         hResult1        = hrSuccess;
  1472.  
  1473.     CreateOneOffDlg.m_CurrentOperation= "lpAdrBook->CreateOneOff()";
  1474.     CreateOneOffDlg.m_EditText1       = "lpszName:";
  1475.     CreateOneOffDlg.m_EditText2       = "lpszAdrType:";
  1476.     CreateOneOffDlg.m_EditText3       = "lpszAddress:";
  1477.     CreateOneOffDlg.m_FlagText1       = "MAPI_UNICODE";
  1478.     CreateOneOffDlg.m_FlagText2       = "Invalid Flag";
  1479.     CreateOneOffDlg.m_EditDefault1    = "Your Name";
  1480.     CreateOneOffDlg.m_EditDefault2    = "MSPEER";
  1481.     CreateOneOffDlg.m_EditDefault3    = "Your Address";
  1482.  
  1483.     if( CreateOneOffDlg.DoModal() == IDOK )
  1484.     {
  1485.         if( CreateOneOffDlg.m_bFlag2)
  1486.             ulFlags |= TEST_INVALID_FLAG;
  1487.  
  1488.         if( CreateOneOffDlg.m_bFlag1 )
  1489.         {
  1490.             ulFlags |= MAPI_UNICODE;
  1491.  
  1492.             String8ToUnicode(CreateOneOffDlg.m_szEdit1, &lpNewBuffer1, NULL);
  1493.             String8ToUnicode(CreateOneOffDlg.m_szEdit2, &lpNewBuffer2, NULL);
  1494.             String8ToUnicode(CreateOneOffDlg.m_szEdit3, &lpNewBuffer3, NULL);
  1495.  
  1496.             hResult1 = lpAdrBook->CreateOneOff(
  1497.                         (LPTSTR) lpNewBuffer1,
  1498.                         (LPTSTR) lpNewBuffer2,
  1499.                         (LPTSTR) lpNewBuffer3,
  1500.                         ulFlags,
  1501.                         &ulEntryID,
  1502.                         &lpEntryID);
  1503.             if( HR_FAILED(hResult1))
  1504.             {
  1505.                 MessageBox( E.SzError("lpAdrBook->CreateOneOff()", hResult1),
  1506.                             "Client", MBS_ERROR );
  1507.                 PvFree(lpNewBuffer1);
  1508.                 PvFree(lpNewBuffer2);
  1509.                 PvFree(lpNewBuffer3);
  1510.                 return;
  1511.             }
  1512.  
  1513.             PvFree(lpNewBuffer1);
  1514.             PvFree(lpNewBuffer2);
  1515.             PvFree(lpNewBuffer3);
  1516.         }
  1517.         else
  1518.         {
  1519.  
  1520.             hResult1 = lpAdrBook->CreateOneOff(
  1521.                         (LPTSTR) CreateOneOffDlg.m_szEdit1,
  1522.                         (LPTSTR) CreateOneOffDlg.m_szEdit2,
  1523.                         (LPTSTR) CreateOneOffDlg.m_szEdit3,
  1524.                         ulFlags,
  1525.                         &ulEntryID,
  1526.                         &lpEntryID);
  1527.             if( HR_FAILED(hResult1))
  1528.             {
  1529.                 MessageBox( E.SzError("lpAdrBook->CreateOneOff()", hResult1),
  1530.                                 "Client", MBS_ERROR );
  1531.                 return;
  1532.             }
  1533.         }
  1534.  
  1535.         if(lpEntryID)
  1536.         {
  1537.             DisplayEID.m_ulValues   = ulEntryID;
  1538.             DisplayEID.m_lpEntryID  = lpEntryID;
  1539.             DisplayEID.DoModal();
  1540.  
  1541.             MAPIFreeBuffer(lpEntryID);
  1542.         }
  1543.     }
  1544. }
  1545.  
  1546. /********************************************************************/
  1547. /*
  1548.  -  CMainWindow::
  1549.  -  OnQueryDefRecipOpts
  1550.  -
  1551.  *  Purpose:
  1552.  *
  1553.  /********************************************************************/
  1554.  
  1555. void CMainWindow::OnQueryDefRecipOpts()
  1556. {
  1557.     CGetError       E;
  1558.     CPropDisplayDlg DisplayProps(this);
  1559.     COperation      QueryDefaultRecipOptDlg(this);
  1560.     LPWSTR          lpNewBuffer1    = NULL;
  1561.     ULONG           ulFlags         = 0;
  1562.     ULONG           ulValues        = 0;
  1563.     LPSPropValue    lpspva          = 0;
  1564.     HRESULT         hResult1        = hrSuccess;
  1565.  
  1566.     QueryDefaultRecipOptDlg.m_CurrentOperation= "lpAdrBook->QueryDefaultRecipOpt()";
  1567.     QueryDefaultRecipOptDlg.m_EditText1       = "lpszAdrType:";
  1568.     QueryDefaultRecipOptDlg.m_FlagText1       = "MAPI_UNICODE";
  1569.     QueryDefaultRecipOptDlg.m_FlagText2       = "Invalid Flag";
  1570.     QueryDefaultRecipOptDlg.m_EditDefault1    = "MSPEER";
  1571.  
  1572.     if( QueryDefaultRecipOptDlg.DoModal() == IDOK )
  1573.     {
  1574.         if( QueryDefaultRecipOptDlg.m_bFlag2)
  1575.             ulFlags |= TEST_INVALID_FLAG;
  1576.  
  1577.         if( QueryDefaultRecipOptDlg.m_bFlag1 )
  1578.         {
  1579.             ulFlags |= MAPI_UNICODE;
  1580.  
  1581.             String8ToUnicode(QueryDefaultRecipOptDlg.m_szEdit1, &lpNewBuffer1, NULL);
  1582.  
  1583.             hResult1 = lpAdrBook->QueryDefaultRecipOpt(
  1584.                         (LPTSTR) lpNewBuffer1,
  1585.                         ulFlags,
  1586.                         &ulValues,
  1587.                         &lpspva);
  1588.  
  1589.             if( HR_FAILED(hResult1))
  1590.             {
  1591.                 MessageBox( E.SzError("lpAdrBook->QueryDefaultRecipOpt()", hResult1),
  1592.                             "Client", MBS_ERROR );
  1593.                 PvFree(lpNewBuffer1);
  1594.                 return;
  1595.             }
  1596.  
  1597.             PvFree(lpNewBuffer1);
  1598.         }
  1599.         else
  1600.         {
  1601.  
  1602.             hResult1 = lpAdrBook->QueryDefaultRecipOpt(
  1603.                         (LPTSTR) QueryDefaultRecipOptDlg.m_szEdit1,
  1604.                         ulFlags,
  1605.                         &ulValues,
  1606.                         &lpspva);
  1607.  
  1608.             if( HR_FAILED(hResult1))
  1609.             {
  1610.                 MessageBox( E.SzError("lpAdrBook->QueryDefaultRecipOpt()", hResult1),
  1611.                                 "Client", MBS_ERROR );
  1612.                 return;
  1613.             }
  1614.         }
  1615.  
  1616.         if(lpspva)
  1617.         {
  1618.             DisplayProps.m_ulValues   = ulValues;
  1619.             DisplayProps.m_lpspva     = lpspva;
  1620.             DisplayProps.DoModal();
  1621.  
  1622.             MAPIFreeBuffer(lpspva);
  1623.         }
  1624.     }
  1625. }
  1626.  
  1627. /********************************************************************/
  1628. /*
  1629.  -  CMainWindow::
  1630.  -  OnResolveName
  1631.  -
  1632.  *  Purpose:
  1633.  
  1634.  
  1635.  NOTE, later this should support UNICODE
  1636.  
  1637.  *
  1638. /********************************************************************/
  1639.  
  1640. void CMainWindow::OnResolveName()
  1641. {
  1642.     CAdrListDlg     AdrListDlg(this);
  1643.     COperation      ResolveNameDlg(this);
  1644.     ULONG           ulFlags         = 0;
  1645.     ULONG           ulUIParam       = 0;
  1646.     CGetError       E;
  1647.     HRESULT         hResult1        = hrSuccess;
  1648.     LPADRLIST       lpAdrList       = NULL;
  1649.     LONG            len1            = 0;
  1650.     LONG            len2            = 0;
  1651.     LONG            len3            = 0;
  1652.     ULONG           ulNumStrings    = 0;
  1653.     SCODE           sc              = S_OK;
  1654.     DWORD           dRet            = 0;
  1655.     char            szBuff[80];
  1656.     LPTSTR          lpszNewEntryTitle   = NULL;
  1657.  
  1658.     ResolveNameDlg.m_CurrentOperation= "lpAdrBook->ResolveName()";
  1659.     ResolveNameDlg.m_CBText1         = "ulUIParam:";
  1660.     ResolveNameDlg.m_CBText2         = "lpszNewEntryTitle:";
  1661.     ResolveNameDlg.m_EditText1       = "Name1 to Resolve:";
  1662.     ResolveNameDlg.m_EditText2       = "Name2 to Resolve:";
  1663.     ResolveNameDlg.m_EditText3       = "Name3 to Resolve:";
  1664.     ResolveNameDlg.m_FlagText1       = "MAPI_DIALOG";
  1665.     ResolveNameDlg.m_FlagText2       = "Invalid Flag";
  1666.     ResolveNameDlg.m_EditDefault1    = "Joe Smith";
  1667.     ResolveNameDlg.m_EditDefault2    = "Sue Jones";
  1668.     ResolveNameDlg.m_EditDefault3    = "Elvis";
  1669.  
  1670.     dRet = ResolveNameDlg.m_CBContents1.Add("NULL");
  1671.     wsprintf(szBuff,"Parent hWnd == %X",this->m_hWnd);
  1672.     dRet = ResolveNameDlg.m_CBContents1.Add(szBuff);
  1673.  
  1674.     dRet = ResolveNameDlg.m_CBContents2.Add("NULL");
  1675.     dRet = ResolveNameDlg.m_CBContents2.Add("Joe Smith");
  1676.  
  1677.     if( ResolveNameDlg.DoModal() == IDOK )
  1678.     {
  1679.         if( !lstrcmp(ResolveNameDlg.m_szCB1,"NULL") )
  1680.             ulUIParam = (ULONG)NULL;
  1681.         else
  1682.             ulUIParam = (ULONG)(void *)this->m_hWnd;
  1683.  
  1684.         if( !lstrcmp(ResolveNameDlg.m_szCB2,"NULL") )
  1685.             lpszNewEntryTitle = NULL;
  1686.         else
  1687.         {
  1688.             lpszNewEntryTitle = (LPTSTR) PvAlloc(30 * sizeof(char) );
  1689.             lstrcpy(lpszNewEntryTitle,"Joe Smith");
  1690.         }
  1691.         if( ResolveNameDlg.m_bFlag1 )
  1692.             ulFlags |= MAPI_DIALOG;
  1693.  
  1694.         if( ResolveNameDlg.m_bFlag2)
  1695.             ulFlags |= TEST_INVALID_FLAG;
  1696.  
  1697.  
  1698.  
  1699.         sc = MAPIAllocateBuffer( sizeof(ADRLIST) + 3*sizeof(ADRENTRY), (LPVOID *) &lpAdrList );
  1700.  
  1701.         ulNumStrings = 0;
  1702.         if( len1 = strlen(ResolveNameDlg.m_szEdit1) )
  1703.         {
  1704.             sc = MAPIAllocateBuffer( sizeof(SPropValue) ,
  1705.                         (LPVOID *) &(lpAdrList->aEntries[ulNumStrings].rgPropVals));
  1706.             lpAdrList->aEntries[ulNumStrings].rgPropVals->ulPropTag = PR_DISPLAY_NAME;
  1707.             lpAdrList->aEntries[ulNumStrings].rgPropVals->Value.lpszA = ResolveNameDlg.m_szEdit1;
  1708.             lpAdrList->aEntries[ulNumStrings].cValues = 1;
  1709.             ulNumStrings++;
  1710.         }
  1711.         if( len2 = strlen(ResolveNameDlg.m_szEdit2) )
  1712.         {
  1713.             sc = MAPIAllocateBuffer( sizeof(SPropValue) ,
  1714.                         (LPVOID *) &(lpAdrList->aEntries[ulNumStrings].rgPropVals));
  1715.             lpAdrList->aEntries[ulNumStrings].rgPropVals->ulPropTag = PR_DISPLAY_NAME;
  1716.             lpAdrList->aEntries[ulNumStrings].rgPropVals->Value.lpszA = ResolveNameDlg.m_szEdit2;
  1717.             lpAdrList->aEntries[ulNumStrings].cValues = 1;
  1718.             ulNumStrings++;
  1719.         }
  1720.         if( len3 = strlen(ResolveNameDlg.m_szEdit3) )
  1721.         {
  1722.             sc = MAPIAllocateBuffer( sizeof(SPropValue) ,
  1723.                         (LPVOID *) &(lpAdrList->aEntries[ulNumStrings].rgPropVals));
  1724.             lpAdrList->aEntries[ulNumStrings].rgPropVals[0].ulPropTag = PR_DISPLAY_NAME;
  1725.             lpAdrList->aEntries[ulNumStrings].rgPropVals->Value.lpszA = ResolveNameDlg.m_szEdit3;
  1726.             lpAdrList->aEntries[ulNumStrings].cValues = 1;
  1727.             ulNumStrings++;
  1728.         }
  1729.  
  1730.         lpAdrList->cEntries = ulNumStrings;
  1731.  
  1732.         // display entrylist before
  1733.         AdrListDlg.m_List       = "Address List Before ResolveName()";
  1734.         AdrListDlg.m_lpAdrList  = lpAdrList;
  1735.         AdrListDlg.DoModal();
  1736.  
  1737.  
  1738.         hResult1 = lpAdrBook->ResolveName(
  1739.                         ulUIParam,
  1740.                         ulFlags,
  1741.                         lpszNewEntryTitle,
  1742.                         lpAdrList);
  1743.  
  1744.         if( HR_FAILED(hResult1))
  1745.         {
  1746.             MessageBox( E.SzError("lpAdrBook->ResolveName()", hResult1),
  1747.                     "Client", MBS_ERROR );
  1748.         }
  1749.  
  1750.         // display entrylist after
  1751.         AdrListDlg.m_List       = "Address List After ResolveName()";
  1752.         AdrListDlg.m_lpAdrList  = lpAdrList;
  1753.         AdrListDlg.DoModal();
  1754.  
  1755.         if(lpszNewEntryTitle)
  1756.             PvFree(lpszNewEntryTitle);
  1757.  
  1758.         if(lpAdrList)
  1759.             FreeAdrList(lpAdrList);
  1760.     }
  1761. }
  1762. /********************************************************************/
  1763. /*
  1764.  -  CMainWindow::
  1765.  -  OnSessionRegNotif
  1766.  -
  1767.  *  Purpose:
  1768.  *
  1769.  /********************************************************************/
  1770.  
  1771. void CMainWindow::OnSessionRegNotif()
  1772. {
  1773.  
  1774.  
  1775.  
  1776.     MessageBox( "TEST, Not Yet Implemented", "Client", MBS_INFO );
  1777. }
  1778.  
  1779. /********************************************************************/
  1780. /*
  1781.  -  CMainWindow::
  1782.  -  OnStatusRegNotif
  1783.  -
  1784.  *  Purpose:
  1785.  *
  1786.  /********************************************************************/
  1787.  
  1788. void CMainWindow::OnStatusRegNotif()
  1789. {
  1790.     MessageBox( "TEST, Not Yet Implemented", "Client", MBS_INFO );
  1791. }
  1792.  
  1793.  
  1794. /***********************************************************************/
  1795. /********************** Callback Functions  ****************************/
  1796.  
  1797.  
  1798. /********************************************************************/
  1799. /*
  1800.  -  CMainWindow::
  1801.  -  OnMDBRegNotif
  1802.  -
  1803.  *  Purpose:
  1804.  *
  1805.  /********************************************************************/
  1806.  
  1807. void CMainWindow::OnMDBRegNotif()
  1808. {
  1809.     CNotifDlg   Notif(this);
  1810.  
  1811.     if(!lpMDB)
  1812.     {
  1813.         MessageBox( "Need an Open MDB to Advise Notification on Message Store", "Client", MBS_ERROR );
  1814.         return;
  1815.     }
  1816.     Notif.m_Description = "MessageStore Object Notification(via lpSession->Advise)";
  1817.     Notif.m_lpUnk       = lpSession;
  1818.     Notif.m_ulObjType   = MAPI_SESSION;
  1819.     Notif.m_lppNotifs   = &lpMDBNotifs;
  1820.     Notif.DoModal();
  1821. }
  1822.  
  1823. /********************************************************************/
  1824. /*
  1825.  -  CMainWindow::
  1826.  -  OnTableRegNotif
  1827.  -
  1828.  *  Purpose:
  1829.  *
  1830.  /********************************************************************/
  1831.  
  1832. void CMainWindow::OnTableRegNotif()
  1833. {
  1834.     MessageBox( "TEST, Not Yet Implemented", "Client", MBS_INFO );
  1835. }
  1836.  
  1837. /********************************************************************/
  1838. /*
  1839.  -  CMainWindow::
  1840.  -  OnABRegNotif
  1841.  -
  1842.  *  Purpose:
  1843.  *
  1844.  /********************************************************************/
  1845.  
  1846. void CMainWindow::OnABRegNotif()
  1847. {
  1848.     MessageBox( "TEST, Not Yet Implemented", "Client", MBS_INFO );
  1849. }
  1850.  
  1851.  
  1852. /********************************************************************/
  1853. /*
  1854.  -  CMainWindow::
  1855.  -  OnNotifState
  1856.  -
  1857.  *  Purpose:
  1858.  *
  1859.  /********************************************************************/
  1860.  
  1861. void CMainWindow::OnNotifState()
  1862. {
  1863.     CMenu           *menu   = GetMenu();
  1864.     UINT            uRet    = 0;
  1865.  
  1866.  
  1867.  
  1868.     uRet = menu->GetMenuState( IDM_REGON, MF_BYCOMMAND   );
  1869.  
  1870.     // if it is already checked, uncheck it
  1871.     if(uRet & MF_CHECKED )
  1872.     {
  1873.         menu->CheckMenuItem(   IDM_REGON, MF_UNCHECKED );
  1874. #ifdef XVPORT
  1875.         XVPShow(xvpNum, XVP_HIDE);
  1876. #endif
  1877.     }
  1878.     else
  1879.     {
  1880.         menu->CheckMenuItem(   IDM_REGON, MF_CHECKED );
  1881. #ifdef XVPORT
  1882.         XVPShow(xvpNum, XVP_SHOW);
  1883. #endif
  1884.     }
  1885. }
  1886.  
  1887.  
  1888.  
  1889. /*******************************************************************/
  1890. /*
  1891.  -  CMainWindow::
  1892.  -  OnGetStoresTable
  1893.  *
  1894.  *  Purpose:
  1895.  *      Bring up Table viewer interface used to view and perform
  1896.  *      operations on a table. In this case the table is the
  1897.  *      LPMAPITABLE obtained from lpSession->GetMsgStoresTable()
  1898.  *
  1899.  *  Comments:
  1900.  *      lpSession is global pointer to current session
  1901.  */
  1902. /*******************************************************************/
  1903.  
  1904. void CMainWindow::OnGetStoresTable()
  1905. {
  1906.     CGetError       E;
  1907.  
  1908.     hResultSession = lpStoresTable->SeekRow( BOOKMARK_BEGINNING, 0 , NULL );
  1909.     if( HR_FAILED(hResultSession) )
  1910.     {
  1911.         MessageBox( E.SzError("lpStoresTable->SeekRow", hResultSession),
  1912.                             "Client", MBS_ERROR );
  1913.         return;
  1914.     }
  1915.  
  1916.     TBLVUViewMapiTable( (LPMAPITABLE FAR *)&lpStoresTable, (HWND)this->m_hWnd );
  1917. }
  1918.  
  1919. /*******************************************************************/
  1920. /*
  1921.  -  CMainWindow::
  1922.  -  OnGetReceiveFolderTable
  1923.  *
  1924.  *  Purpose:
  1925.  *      Bring up Table viewer interface used to view and perform
  1926.  *      operations on a table. In this case the table is the
  1927.  *      LPMAPITABLE obtained from lpSession->GetReceiveFolderTable()
  1928.  *
  1929.  *  Comments:
  1930.  *      lpSession is global pointer to current session
  1931.  */
  1932. /*******************************************************************/
  1933.  
  1934. void CMainWindow::OnGetReceiveFolderTable()
  1935. {
  1936.     CGetError       E;
  1937.     HRESULT         hResult1        = hrSuccess;
  1938.  
  1939.     if(lpReceiveFolderTable)
  1940.     {
  1941.         lpReceiveFolderTable->Release();
  1942.         lpReceiveFolderTable = NULL;
  1943.     }
  1944.  
  1945.     hResult1 = lpMDB->GetReceiveFolderTable(0, &lpReceiveFolderTable);
  1946.  
  1947.     if(HR_FAILED(hResult1) )
  1948.     {
  1949.         MessageBox( E.SzError("lpSession->GetReceiveFolderTable()", hResult1),
  1950.                  "Client", MBS_ERROR );
  1951.         return;
  1952.     }
  1953.  
  1954.     hResult1 = lpReceiveFolderTable->SeekRow( BOOKMARK_BEGINNING, 0 , NULL );
  1955.     if( HR_FAILED(hResult1) )
  1956.     {
  1957.         MessageBox( E.SzError("lpReceiveFolderTable->SeekRow", hResult1),
  1958.                             "Client", MBS_ERROR );
  1959.         return;
  1960.     }
  1961.  
  1962.     TBLVUViewMapiTable( (LPMAPITABLE FAR *)&lpReceiveFolderTable, (HWND)this->m_hWnd );
  1963. }
  1964.  
  1965. /*******************************************************************/
  1966. /*
  1967.  -  CMainWindow::
  1968.  -  OnGetStatusTable
  1969.  *
  1970.  *  Purpose:
  1971.  *      Bring up Table viewer interface used to view and perform
  1972.  *      operations on a table. In this case the table is the
  1973.  *      LPMAPITABLE obtained from lpSession->GetStatusTable()
  1974.  *
  1975.  *  Comments:
  1976.  *      lpSession is global pointer to current session
  1977.  */
  1978. /*******************************************************************/
  1979.  
  1980. void CMainWindow::OnGetStatusTable()
  1981. {
  1982.     TBLVUViewMapiTable( (LPMAPITABLE FAR *)&lpStatusTable, (HWND)this->m_hWnd );
  1983. }
  1984.  
  1985. /*******************************************************************/
  1986. /*
  1987.  -  CMainWindow::
  1988.  -  OnEnumAdrTypes
  1989.  *
  1990.  *  Purpose:
  1991.  *
  1992.  *  Comments:
  1993.  *      lpSession is global pointer to current session
  1994.  */
  1995. /*******************************************************************/
  1996.  
  1997. void CMainWindow::OnEnumAdrTypes()
  1998. {
  1999.     CEnumAdrTypesDlg    Enum(this);
  2000.     Enum.DoModal();
  2001. }
  2002.  
  2003. /*******************************************************************/
  2004. /*
  2005.  -  CMainWindow::
  2006.  -  OnGetReceiveFolder
  2007.  *
  2008.  *  Purpose:
  2009.  *      Get the Receive folder for a specific message class.  This
  2010.  *      will bring up an operations dialog to determine what parameters
  2011.  *      the caller wishes to use for the call to lpMDB->GetReceiveFolder()
  2012.  *      This call will bring up a MessageBox and fail if the application
  2013.  *      does not have a vaild Message Store pointer
  2014.  *
  2015.  *  Comments:
  2016.  *      lpMDB is global pointer to open message store
  2017.  */
  2018. /*******************************************************************/
  2019.  
  2020. void CMainWindow::OnGetReceiveFolder()
  2021. {
  2022.     COperation      GetReceiveFldDlg(this);
  2023.     CGetError       E;
  2024.     char            szBuff[256];
  2025.     CString         OperName;
  2026.     DWORD           dwRet               = 0;
  2027.     ULONG           ulFlags             = 0;
  2028.     HRESULT         hResult1            = hrSuccess;
  2029.     LPSPropTagArray lpPTA               = NULL;
  2030.     CFolderDlg      *lpRecFld           = NULL;
  2031.     LPMAPIFOLDER        lpFolder            = NULL;
  2032.     LPSTR           lpszExplicitClass   = NULL;
  2033.     LPENTRYID       lpEntryID           = NULL;
  2034.     ULONG           ulEntryID           = 0;
  2035.     ULONG           ulObjType           = 0;
  2036.     char            szBuffer[128];
  2037.  
  2038.     if(!lpMDB)
  2039.     {
  2040.         MessageBox( "No Open Message Store","Client", MBS_ERROR );
  2041.         return;
  2042.     }
  2043.  
  2044.     // setup data members of COperation dialog to bring up
  2045.     OperName  = "lpMDB->GetReceiveFolder()";
  2046.  
  2047.     GetReceiveFldDlg.m_CurrentOperation= OperName;
  2048.     GetReceiveFldDlg.m_EditText1       = "lpszMessageClass";
  2049.     GetReceiveFldDlg.m_FlagText1       = "MAPI_UNICODE";
  2050.     GetReceiveFldDlg.m_FlagText2       = "Invalid Flag";
  2051.     GetReceiveFldDlg.m_EditDefault1    = "IPM";
  2052.  
  2053.     // bring up modal dialog box, and if user hits OK, process operation
  2054.     if( GetReceiveFldDlg.DoModal() == IDOK )
  2055.     {
  2056.         if( GetReceiveFldDlg.m_bFlag1 )
  2057.             ulFlags |= MAPI_UNICODE;
  2058.  
  2059.         if( GetReceiveFldDlg.m_bFlag2 )
  2060.             ulFlags |= TEST_INVALID_FLAG;
  2061.  
  2062.         hResult1 = lpMDB->GetReceiveFolder(
  2063.                         (LPSTR)GetReceiveFldDlg.m_szEdit1,
  2064.                         ulFlags,
  2065.                         &ulEntryID,
  2066.                         &lpEntryID,
  2067.                         &lpszExplicitClass );
  2068.         if(HR_FAILED(hResult1) )
  2069.         {
  2070.             MessageBox( E.SzError("lpMDB->GetReceiveFolder()", hResult1),
  2071.                             "Client", MBS_ERROR );
  2072.             return;
  2073.         }
  2074.  
  2075.         if(GetReceiveFldDlg.m_szEdit1)
  2076.            wsprintf(szBuff,"Receive Folder for Message class %s",
  2077.                     (LPSTR)GetReceiveFldDlg.m_szEdit1);
  2078.         else
  2079.            wsprintf(szBuff,"Receive Folder for Message class %s",
  2080.                     "Default Receive Folder");
  2081.  
  2082.         // open up the object described, determine if folder, and open folder dlg
  2083.         hResult1 = lpMDB->OpenEntry(
  2084.                             ulEntryID,
  2085.                             lpEntryID,
  2086.                             NULL,
  2087.                             ulAccess,
  2088.                             &ulObjType,
  2089.                             (LPUNKNOWN*)(LPMAPIPROP *) &lpFolder);
  2090.  
  2091.         if(HR_FAILED(hResult1) )
  2092.         {
  2093.             MessageBox( E.SzError("lpMDB->OpenEntry() GetReceiveFolder",hResult1),
  2094.                             "Client", MBS_ERROR );
  2095.             if(lpEntryID)
  2096.                 MAPIFreeBuffer(lpEntryID);
  2097.  
  2098.             if(lpszExplicitClass)
  2099.                 MAPIFreeBuffer(lpszExplicitClass);
  2100.  
  2101.             return;
  2102.         }
  2103.         if( ulObjType == MAPI_FOLDER )
  2104.         {
  2105.             if(lpszExplicitClass)
  2106.             {
  2107.                 wsprintf(szBuffer,"%s - Explicit Class == %s",
  2108.                     GetString("MAPIObjTypes",ulObjType,NULL),lpszExplicitClass);
  2109.             }
  2110.             else
  2111.             {
  2112.                 wsprintf(szBuffer,"%s - Explicit Class == %s",
  2113.                     GetString("MAPIObjTypes",ulObjType,NULL),"Default Receive Folder");
  2114.             }
  2115.             lpRecFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpFolder,this);
  2116.         }
  2117.         else
  2118.             MessageBox("ulObjType of OpenEntry on lpFolder != MAPI_FOLDER","Client",MBS_ERROR);
  2119.  
  2120.         if(lpEntryID)
  2121.             MAPIFreeBuffer(lpEntryID);
  2122.  
  2123.         if(lpszExplicitClass)
  2124.             MAPIFreeBuffer(lpszExplicitClass);
  2125.     }
  2126.  
  2127. }
  2128.  
  2129. /*******************************************************************/
  2130. /*
  2131.  -  CMainWindow::
  2132.  -  OnExit
  2133.  -
  2134.  *  Purpose:
  2135.  *      Asks the application to Close itself.
  2136.  */
  2137. /*******************************************************************/
  2138.  
  2139. void CMainWindow::OnExit()
  2140. {
  2141.     SendMessage( WM_CLOSE );
  2142. }
  2143.  
  2144. /*******************************************************************/
  2145. /*
  2146.  -  CMainWindow::
  2147.  -  OnClose
  2148.  *
  2149.  *  Purpose:
  2150.  *      Closes the application's main window from the system control
  2151.  *      or from the menu item selection of Exit.  It performs a logoff
  2152.  *      if user is still logged on, free's all dll's loaded during this
  2153.  *      instance, and Destroy's main window.
  2154.  */
  2155. /*******************************************************************/
  2156.  
  2157. void CMainWindow::OnClose()
  2158. {
  2159.     OnLogoff();
  2160.  
  2161.     if(hlibTBLVU)
  2162.     {
  2163.        FreeLibrary(hlibTBLVU);
  2164.        hlibTBLVU = (HINSTANCE) NULL;
  2165.     }
  2166.  
  2167.     if (hlibPROPVU)
  2168.     {
  2169.         FreeLibrary (hlibPROPVU);
  2170.         hlibPROPVU = (HINSTANCE) NULL;
  2171.     }
  2172.  
  2173.     if (hlibSTATVU)
  2174.     {
  2175.         FreeLibrary (hlibSTATVU);
  2176.         hlibSTATVU = (HINSTANCE) NULL;
  2177.     }
  2178.  
  2179.     MAPIUninitialize();
  2180.  
  2181.     DestroyWindow();
  2182.  
  2183. }
  2184.  
  2185. /*******************************************************************/
  2186. /*
  2187.  -  CMainWindow::
  2188.  -  PostNcDestroy
  2189.  *
  2190.  *  Purpose:
  2191.  *      In order to avoid an access violation when ending this application
  2192.  *      it it necessary to catch the WM_DESTROY window message.
  2193.  *
  2194.  *      Cleanup of the main window will occur in the OnClose function, with
  2195.  *      the DestroyWindow() call.
  2196.  *
  2197.  *      ExitInstance() will perform the remaining Cleanup.
  2198.  *
  2199.  */
  2200. /*******************************************************************/
  2201.  
  2202. void CMainWindow::PostNcDestroy()
  2203. {
  2204.     // don't delete
  2205.     // we need this stub so the MFC library doesn't perform Cleanup
  2206. }
  2207.  
  2208.  
  2209. /*******************************************************************/
  2210. /*
  2211.  -  CMainWindow::
  2212.  -  OnOpenMDB
  2213.  *
  2214.  *  Purpose:
  2215.  *
  2216.  */
  2217. /*******************************************************************/
  2218.  
  2219. void CMainWindow::OnOpenMDB()
  2220. {
  2221.     COpenStoreDlg   DlgStoreOpen(this);
  2222.     CMenu           *menu = GetMenu();
  2223.  
  2224.     if(lpMDB)
  2225.     {
  2226.         MessageBox("FOpenStore lpMDB != NULL, store already open","Client",MBS_ERROR);
  2227.         return;
  2228.     }
  2229.  
  2230.     if( DlgStoreOpen.DoModal() == IDOK)
  2231.     {
  2232.         menu->EnableMenuItem( IDM_OPENMDB,          MF_GRAYED   );
  2233.         menu->EnableMenuItem( IDM_LOGOFFMDB,        MF_ENABLED  );
  2234.         menu->EnableMenuItem( IDM_OPENROOT,         MF_ENABLED  );
  2235.         menu->EnableMenuItem( IDM_GETREC,           MF_ENABLED  );
  2236.         menu->EnableMenuItem( IDM_MDBPROPS,         MF_ENABLED  );
  2237.         menu->EnableMenuItem( IDM_SUPPORTMASK,      MF_ENABLED  );
  2238.  
  2239.  
  2240.         //$ NYI
  2241.         // need to lpMDB->GetProps( with PR_VALID_FOLDER_MASK ) to
  2242.         // determine if these values are valid or not.
  2243.         // ALSO, add PR_VIEWS_ENTRYID, PR_COMMON_VIEWS_ENTRYID, and PR_FINDER_ENTRYID
  2244.         // menu items to directly jump to those values.
  2245.  
  2246.         menu->EnableMenuItem( IDM_IPMSUBTREE,       MF_ENABLED  );
  2247.         menu->EnableMenuItem( IDM_IPMOUTBOX,        MF_ENABLED  );
  2248.         menu->EnableMenuItem( IDM_IPMWASTEBASKET,   MF_ENABLED  );
  2249.         menu->EnableMenuItem( IDM_IPMSENTMAIL,      MF_ENABLED  );
  2250.  
  2251.         if(!hlibTBLVU)
  2252.         {
  2253.             menu->EnableMenuItem( IDM_GETRECFLDTBL, MF_GRAYED );
  2254.         }
  2255.         else
  2256.         {
  2257.             menu->EnableMenuItem( IDM_GETRECFLDTBL, MF_ENABLED );
  2258.         }
  2259.     }
  2260. }
  2261.  
  2262.  
  2263. /*******************************************************************/
  2264. /*
  2265.  -  CMainWindow::
  2266.  -  OnMDBProps
  2267.  *
  2268.  *  Purpose:
  2269.  */
  2270. /*******************************************************************/
  2271.  
  2272. void CMainWindow::OnMDBProps()
  2273. {
  2274.     PROPVUViewMapiProp("MDB Properties",
  2275.                 (LPMAPIPROP FAR *)&lpMDB,lpvCopyToDest, (HWND)this->m_hWnd );
  2276. }
  2277.  
  2278.  
  2279. /*******************************************************************/
  2280. /*
  2281.  -  CMainWindow::
  2282.  -  OnABProps
  2283.  *
  2284.  *  Purpose:
  2285.  */
  2286. /*******************************************************************/
  2287.  
  2288. void CMainWindow::OnABProps()
  2289. {
  2290.     PROPVUViewMapiProp("AB Properties",
  2291.                 (LPMAPIPROP FAR *)&lpAdrBook,lpvCopyToDest, (HWND)this->m_hWnd );
  2292. }
  2293.  
  2294.  
  2295. /*******************************************************************/
  2296. /*
  2297.  -  CMainWindow::
  2298.  -  OnOpenRootFolder
  2299.  *
  2300.  *  Purpose:
  2301.  */
  2302. /*******************************************************************/
  2303.  
  2304. void CMainWindow::OnOpenRootFolder()
  2305. {
  2306.     CGetError       E;
  2307.     HRESULT         hResult1        = hrSuccess;
  2308.     ULONG           ulObjType       = 0;
  2309.     LPMAPIPROP      lpRootFolder    = NULL;
  2310.     CFolderDlg      *lpDlgChildFld  = NULL;
  2311.     CMenu           *menu = GetMenu();
  2312.     char            szBuffer[80];
  2313.  
  2314.     if(!lpMDB)
  2315.     {
  2316.         MessageBox("lpMDB == NULL, Need To Open Store before Opening Root Folder","Client",MBS_ERROR);
  2317.         goto Cleanup;
  2318.     }
  2319.  
  2320.     hResult1 = lpMDB->OpenEntry( 0, NULL, NULL, ulAccess, &ulObjType, (LPUNKNOWN*)&lpRootFolder);
  2321.     if(HR_FAILED(hResult1) )
  2322.     {
  2323.         MessageBox( E.SzError("lpMDB->OpenEntry(Root Fld)", hResult1), "Client", MBS_ERROR );
  2324.         goto Cleanup;
  2325.     }
  2326.  
  2327.     if( ulObjType == MAPI_FOLDER )
  2328.     {
  2329.         wsprintf(szBuffer,"%s - %s", GetString("MAPIObjTypes",ulObjType,NULL),"Root");
  2330.         lpDlgChildFld   =  new CFolderDlg(szBuffer,(LPMAPIFOLDER)lpRootFolder,this);
  2331.     }
  2332.     else
  2333.     {
  2334.         MessageBox("ulObjType of OpenEntry on lpMDB != MAPI_FOLDER","Client",MBS_ERROR);
  2335.         goto Cleanup;
  2336.     }
  2337.  
  2338.     return;
  2339.  
  2340. Cleanup:
  2341.  
  2342.     if(lpRootFolder)
  2343.     {
  2344.         lpRootFolder->Release();
  2345.         lpRootFolder = NULL;
  2346.     }
  2347. }
  2348.  
  2349.  
  2350. /*******************************************************************/
  2351. /*
  2352.  -  CMainWindow::
  2353.  -  OnQueryIdentity
  2354.  *
  2355.  *  Purpose:
  2356.  */
  2357. /*******************************************************************/
  2358.  
  2359. void CMainWindow::OnQueryIdentity()
  2360. {
  2361.     CGetError       E;
  2362.     ULONG           ulObjType       = 0;
  2363.     ULONG           cbEntryID       = 0;
  2364.     LPENTRYID       lpEntryID       = NULL;
  2365.  
  2366.  
  2367.     if(lpIdentityObj)
  2368.     {
  2369.         lpIdentityObj->Release();
  2370.         lpIdentityObj = NULL;
  2371.     }
  2372.  
  2373.     hResultSession = lpSession->QueryIdentity(&cbEntryID,&lpEntryID);
  2374.     if(HR_FAILED(hResultSession) )
  2375.     {
  2376.         MessageBox( E.SzError("lpSession->QueryIdentity()",
  2377.                  hResultSession), "Client", MBS_ERROR );
  2378.         return;
  2379.     }
  2380.  
  2381.     hResultSession = lpSession->OpenEntry(
  2382.                                     cbEntryID,
  2383.                                     lpEntryID,
  2384.                                     NULL,
  2385.                                     MAPI_BEST_ACCESS,
  2386.                                     &ulObjType,
  2387.                                     (LPUNKNOWN*)&lpIdentityObj);
  2388.     if(HR_FAILED(hResultSession) )
  2389.     {
  2390.         MessageBox( E.SzError("lpSession->OpenEntry(QueryIdentity)",
  2391.                  hResultSession), "Client", MBS_ERROR );
  2392.     }
  2393.  
  2394.     PROPVUViewMapiProp("Props From lpSess->QueryIdentity()",
  2395.                 (LPMAPIPROP FAR *)&lpIdentityObj,lpvCopyToDest, (HWND)this->m_hWnd );
  2396.  
  2397.     if(lpEntryID)
  2398.         MAPIFreeBuffer(lpEntryID);
  2399.  
  2400. }
  2401.  
  2402.  
  2403. /*******************************************************************/
  2404. /*
  2405.  -  CMainWindow::
  2406.  -  OnQueryDefaultMsgOptions
  2407.  *
  2408.  *  Purpose:
  2409.  */
  2410. /*******************************************************************/
  2411.  
  2412. void CMainWindow::OnQueryDefaultMsgOptions()
  2413. {
  2414.     CQueryDefaultMsgOptsDlg Default(this);
  2415.     COperation      QueryDefMsgOptsDlg(this);
  2416.     ULONG           ulFlags         = 0;
  2417.     ULONG           cValues         = 0;
  2418.     LPSPropValue    lpspvaDefault   = NULL;
  2419.     CGetError       E;
  2420.     LPWSTR          lpNewBuffer1    = NULL;
  2421.  
  2422.     QueryDefMsgOptsDlg.m_CurrentOperation= "lpSession->QueryDefaultMsgOptions()";
  2423.     QueryDefMsgOptsDlg.m_EditText1       = "lpszAdrType:";
  2424.     QueryDefMsgOptsDlg.m_FlagText1       = "MAPI_UNICODE";
  2425.     QueryDefMsgOptsDlg.m_FlagText2       = "Invalid Flag";
  2426.  
  2427.     QueryDefMsgOptsDlg.m_EditDefault1    = "MSPEER";
  2428.  
  2429.     if( QueryDefMsgOptsDlg.DoModal() == IDOK )
  2430.     {
  2431.  
  2432.         // determine state/settings of data in dialog upon closing
  2433.         if( QueryDefMsgOptsDlg.m_bFlag2 )
  2434.             ulFlags |= TEST_INVALID_FLAG;
  2435.  
  2436.         if( QueryDefMsgOptsDlg.m_bFlag1 )
  2437.         {
  2438.             ulFlags |= MAPI_UNICODE;
  2439.  
  2440.             String8ToUnicode(QueryDefMsgOptsDlg.m_szEdit1, &lpNewBuffer1, NULL);
  2441.  
  2442.             hResultSession = lpSession->QueryDefaultMessageOpt(
  2443.                             (LPTSTR) lpNewBuffer1,
  2444.                             ulFlags,
  2445.                             &cValues,
  2446.                             &lpspvaDefault );
  2447.             if(HR_FAILED(hResultSession) )
  2448.             {
  2449.                 MessageBox( E.SzError("m_lpMessage->QueryDefaultMessageOpt()",
  2450.                              hResultSession),"Client", MBS_ERROR );
  2451.                 PvFree(lpNewBuffer1);
  2452.                 goto Error;
  2453.             }
  2454.  
  2455.             PvFree(lpNewBuffer1);
  2456.         }
  2457.         else
  2458.         {
  2459.  
  2460.             hResultSession = lpSession->QueryDefaultMessageOpt(
  2461.                             (LPTSTR) QueryDefMsgOptsDlg.m_szEdit1,
  2462.                             ulFlags,
  2463.                             &cValues,
  2464.                             &lpspvaDefault );
  2465.             if(HR_FAILED(hResultSession) )
  2466.             {
  2467.                 MessageBox( E.SzError("m_lpMessage->QueryDefaultMessageOpt()",
  2468.                          hResultSession),"Client", MBS_ERROR );
  2469.                 goto Error;
  2470.             }
  2471.         }
  2472.  
  2473.         Default.m_cValues = cValues;
  2474.         Default.m_lpspva  = lpspvaDefault;
  2475.         Default.DoModal();
  2476.     }
  2477. Error:
  2478.  
  2479.     if(lpspvaDefault)
  2480.         MAPIFreeBuffer(lpspvaDefault);
  2481. }
  2482.  
  2483.  
  2484.  
  2485. /*******************************************************************/
  2486. /*
  2487.  -  CMainWindow::
  2488.  -  OnStoreLogoff
  2489.  *
  2490.  *  Purpose:
  2491.  */
  2492. /*******************************************************************/
  2493.  
  2494. void CMainWindow::OnStoreLogoff()
  2495. {
  2496.     CGetError       E;
  2497.     ULONG           ulObjType       = 0;
  2498.     CMenu           *menu = GetMenu();
  2499.     COperation      StoreLogoffDlg(this);
  2500.     ULONG           ulFlags         = 0;
  2501.     char            szBuffer[128];
  2502.  
  2503.     if(!lpMDB)
  2504.     {
  2505.         MessageBox("lpMDB == NULL, No Open Store to Logoff","Client",MBS_ERROR);
  2506.         return;
  2507.     }
  2508.  
  2509.     StoreLogoffDlg.m_CurrentOperation= "lpMDB->StoreLogoff()";
  2510.     StoreLogoffDlg.m_FlagText1       = "LOGOFF_NO_WAIT";
  2511.     StoreLogoffDlg.m_FlagText2       = "LOGOFF_ORDERLY";
  2512.     StoreLogoffDlg.m_FlagText3       = "LOGOFF_PURGE";
  2513.     StoreLogoffDlg.m_FlagText4       = "LOGOFF_ABORT";
  2514.     StoreLogoffDlg.m_FlagText5       = "LOGOFF_QUIET";
  2515.     StoreLogoffDlg.m_FlagText6       = "INVALID FLAG";
  2516.  
  2517.     if( StoreLogoffDlg.DoModal() == IDOK )
  2518.     {
  2519.  
  2520.         // determine state/settings of data in dialog upon closing
  2521.  
  2522.         if( StoreLogoffDlg.m_bFlag1 )
  2523.             ulFlags |= LOGOFF_NO_WAIT;
  2524.  
  2525.         if( StoreLogoffDlg.m_bFlag2 )
  2526.             ulFlags |= LOGOFF_ORDERLY;
  2527.  
  2528.         if( StoreLogoffDlg.m_bFlag3 )
  2529.             ulFlags |= LOGOFF_PURGE;
  2530.  
  2531.         if( StoreLogoffDlg.m_bFlag4 )
  2532.             ulFlags |= LOGOFF_ABORT;
  2533.  
  2534.         if( StoreLogoffDlg.m_bFlag5 )
  2535.             ulFlags |= LOGOFF_QUIET;
  2536.  
  2537.         if( StoreLogoffDlg.m_bFlag6 )
  2538.             ulFlags |= TEST_INVALID_FLAG;
  2539.  
  2540.         hResultSession = lpMDB->StoreLogoff( &ulFlags );
  2541.         if(HR_FAILED(hResultSession) )
  2542.         {
  2543.             MessageBox( E.SzError("lpMDB->StoreLogoff()", hResultSession),
  2544.                             "Client", MBS_ERROR );
  2545.             return;
  2546.         }
  2547.  
  2548.         wsprintf(szBuffer,"StoreLogoff() [out] ulFlags == %#08X, %s%s%s%s%s%s%s%s%s",ulFlags,
  2549.             ((ulFlags & LOGOFF_NO_WAIT)         ? "LOGOFF_NO_WAIT | "       : ""),
  2550.             ((ulFlags & LOGOFF_ORDERLY)         ? "LOGOFF_ORDERLY | "       : ""),
  2551.             ((ulFlags & LOGOFF_PURGE)           ? "LOGOFF_PURGE | "         : ""),
  2552.             ((ulFlags & LOGOFF_ABORT)           ? "LOGOFF_ABORT | "         : ""),
  2553.             ((ulFlags & LOGOFF_QUIET)           ? "LOGOFF_QUIET | "         : ""),
  2554.             ((ulFlags & LOGOFF_COMPLETE)        ? "LOGOFF_COMPLETE | "      : ""),
  2555.             ((ulFlags & LOGOFF_INBOUND)         ? "LOGOFF_INBOUND | "       : ""),
  2556.             ((ulFlags & LOGOFF_OUTBOUND)        ? "LOGOFF_OUTBOUND | "      : ""),
  2557.             ((ulFlags & LOGOFF_OUTBOUND_QUEUE)  ? "LOGOFF_OUTBOUND_QUEUE | ": ""));
  2558.  
  2559.         MessageBox(szBuffer,"Client",MBS_INFO);
  2560.  
  2561.  
  2562.         if(lpMDB)
  2563.         {
  2564.             lpMDB->Release();
  2565.             lpMDB = NULL;
  2566.         }
  2567.  
  2568.         menu->EnableMenuItem( IDM_OPENMDB,      MF_ENABLED );
  2569.         menu->EnableMenuItem( IDM_LOGOFFMDB,    MF_GRAYED  );
  2570.         menu->EnableMenuItem( IDM_OPENROOT,     MF_GRAYED  );
  2571.         menu->EnableMenuItem( IDM_GETREC,       MF_GRAYED  );
  2572.         menu->EnableMenuItem( IDM_GETRECFLDTBL, MF_GRAYED  );
  2573.         menu->EnableMenuItem( IDM_MDBPROPS,     MF_GRAYED  );
  2574.         menu->EnableMenuItem( IDM_SUPPORTMASK,  MF_GRAYED  );
  2575.         menu->EnableMenuItem( IDM_IPMSUBTREE,   MF_GRAYED  );
  2576.         menu->EnableMenuItem( IDM_IPMOUTBOX,    MF_GRAYED  );
  2577.         menu->EnableMenuItem( IDM_IPMWASTEBASKET,MF_GRAYED  );
  2578.         menu->EnableMenuItem( IDM_IPMSENTMAIL,  MF_GRAYED  );
  2579.     }
  2580. }
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586. /*******************************************************************/
  2587. /*
  2588.  -  CMainWindow
  2589.  -  ToggleMenu
  2590.  *
  2591.  *  Purpose:
  2592.  *      Toggles enable/disable of menu items for logon state
  2593.  *      TRUE means logon successful, FALSE means not logged on to MAPI
  2594.  *
  2595.  *  Parameters
  2596.  *      BOOL    TRUE == LOGGED ON  FALSE == NOT LOGGED ON
  2597.  *
  2598.  *  returns:
  2599.  *      Nothing
  2600.  *
  2601.  */
  2602. /*******************************************************************/
  2603.  
  2604. void CMainWindow::ToggleMenu(BOOL bState)
  2605. {
  2606.     CMenu   *menu = GetMenu();
  2607.  
  2608.     if(bState)
  2609.     {
  2610.         //Disable Status Viewer button if DLL is not present.
  2611.         if(!hlibSTATVU)
  2612.             menu->EnableMenuItem( IDM_OPENSTATUS,   MF_GRAYED );
  2613.         else
  2614.             menu->EnableMenuItem( IDM_OPENSTATUS,   MF_ENABLED );
  2615.  
  2616.         //Disable Status Viewer button if DLL is not present.
  2617.         if(!hlibTBLVU)
  2618.         {
  2619.             menu->EnableMenuItem( IDM_GETSTORESTBL, MF_GRAYED );
  2620.             menu->EnableMenuItem( IDM_GETSTATUSTBL, MF_GRAYED );
  2621.         }
  2622.         else
  2623.         {
  2624.             menu->EnableMenuItem( IDM_GETSTORESTBL, MF_ENABLED );
  2625.             menu->EnableMenuItem( IDM_GETSTATUSTBL, MF_ENABLED );
  2626.         }
  2627.  
  2628.         //Disable Property Viewer button if DLL is not present.
  2629.         if(!hlibPROPVU)
  2630.         {
  2631.             menu->EnableMenuItem( IDM_MDBPROPS,     MF_GRAYED );
  2632.             menu->EnableMenuItem( IDM_ABPROPS,      MF_GRAYED );
  2633.             menu->EnableMenuItem( IDM_QUERYIDENTITY,MF_GRAYED );
  2634.         }
  2635.         else
  2636.         {
  2637.             menu->EnableMenuItem( IDM_MDBPROPS,     MF_GRAYED );
  2638.             menu->EnableMenuItem( IDM_ABPROPS,      MF_ENABLED );
  2639.             menu->EnableMenuItem( IDM_QUERYIDENTITY,MF_ENABLED );
  2640.         }
  2641.  
  2642.         menu->EnableMenuItem( IDM_LOGON,            MF_GRAYED  );
  2643.         menu->EnableMenuItem( IDM_LOGOFF,           MF_ENABLED );
  2644.         menu->EnableMenuItem( IDM_OPENMDB,          MF_ENABLED );
  2645.         menu->EnableMenuItem( IDM_GETREC,           MF_GRAYED  );
  2646.         menu->EnableMenuItem( IDM_IPMSUBTREE,       MF_GRAYED  );
  2647.         menu->EnableMenuItem( IDM_SUPPORTMASK,      MF_GRAYED  );
  2648.         menu->EnableMenuItem( IDM_IPMOUTBOX,        MF_GRAYED  );
  2649.         menu->EnableMenuItem( IDM_IPMWASTEBASKET,   MF_GRAYED  );
  2650.         menu->EnableMenuItem( IDM_IPMSENTMAIL,      MF_GRAYED  );
  2651.         menu->EnableMenuItem( IDM_OPENROOT,         MF_GRAYED  );
  2652.         menu->EnableMenuItem( IDM_LOGOFFMDB,        MF_GRAYED  );
  2653.         menu->EnableMenuItem( IDM_GETRECFLDTBL,     MF_GRAYED  );
  2654.         menu->EnableMenuItem( IDM_ENUMADRTYPES,     MF_ENABLED );
  2655.         menu->EnableMenuItem( IDM_QUERYDEFMSGOPTS,  MF_ENABLED );
  2656.         menu->EnableMenuItem( IDM_SESGETLASTERROR,  MF_ENABLED );
  2657.         menu->EnableMenuItem( IDM_ADDRESS,          MF_ENABLED );
  2658.         menu->EnableMenuItem( IDM_CREATEONEOFF,     MF_ENABLED );
  2659.         menu->EnableMenuItem( IDM_QUERYDEFRECIPOPT, MF_ENABLED );
  2660.         menu->EnableMenuItem( IDM_RESOLVENAME,      MF_ENABLED );
  2661.         menu->EnableMenuItem( IDM_REGSTATUS,        MF_ENABLED );
  2662.         menu->EnableMenuItem( IDM_REGSESSION,       MF_ENABLED );
  2663.         menu->EnableMenuItem( IDM_REGMDB,           MF_ENABLED );
  2664.         menu->EnableMenuItem( IDM_REGTABLE,         MF_ENABLED );
  2665.         menu->EnableMenuItem( IDM_REGAB,            MF_ENABLED );
  2666.         menu->EnableMenuItem( IDM_REGON,            MF_ENABLED );
  2667.  
  2668.     }
  2669.     else
  2670.     {
  2671.         menu->EnableMenuItem( IDM_LOGON,            MF_ENABLED );
  2672.         menu->EnableMenuItem( IDM_LOGOFF,           MF_GRAYED  );
  2673.         menu->EnableMenuItem( IDM_OPENMDB,          MF_GRAYED  );
  2674.         menu->EnableMenuItem( IDM_MDBPROPS,         MF_GRAYED  );
  2675.         menu->EnableMenuItem( IDM_ABPROPS,          MF_GRAYED  );
  2676.         menu->EnableMenuItem( IDM_GETREC,           MF_GRAYED  );
  2677.         menu->EnableMenuItem( IDM_IPMSUBTREE,       MF_GRAYED  );
  2678.         menu->EnableMenuItem( IDM_SUPPORTMASK,      MF_GRAYED  );
  2679.         menu->EnableMenuItem( IDM_IPMOUTBOX,        MF_GRAYED  );
  2680.         menu->EnableMenuItem( IDM_IPMWASTEBASKET,   MF_GRAYED  );
  2681.         menu->EnableMenuItem( IDM_IPMSENTMAIL,      MF_GRAYED  );
  2682.         menu->EnableMenuItem( IDM_GETSTORESTBL,     MF_GRAYED  );
  2683.         menu->EnableMenuItem( IDM_GETSTATUSTBL,     MF_GRAYED  );
  2684.         menu->EnableMenuItem( IDM_OPENROOT,         MF_GRAYED  );
  2685.         menu->EnableMenuItem( IDM_LOGOFFMDB,        MF_GRAYED  );
  2686.         menu->EnableMenuItem( IDM_ENUMADRTYPES,     MF_GRAYED  );
  2687.         menu->EnableMenuItem( IDM_QUERYDEFMSGOPTS,  MF_GRAYED  );
  2688.         menu->EnableMenuItem( IDM_OPENSTATUS,       MF_GRAYED  );
  2689.         menu->EnableMenuItem( IDM_SESGETLASTERROR,  MF_GRAYED  );
  2690.         menu->EnableMenuItem( IDM_ADDRESS,          MF_GRAYED  );
  2691.         menu->EnableMenuItem( IDM_CREATEONEOFF,     MF_GRAYED  );
  2692.         menu->EnableMenuItem( IDM_QUERYDEFRECIPOPT, MF_GRAYED  );
  2693.         menu->EnableMenuItem( IDM_RESOLVENAME,      MF_GRAYED  );
  2694.         menu->EnableMenuItem( IDM_REGSTATUS,        MF_GRAYED  );
  2695.         menu->EnableMenuItem( IDM_REGSESSION,       MF_GRAYED  );
  2696.         menu->EnableMenuItem( IDM_REGMDB,           MF_GRAYED  );
  2697.         menu->EnableMenuItem( IDM_REGTABLE,         MF_GRAYED  );
  2698.         menu->EnableMenuItem( IDM_REGAB,            MF_GRAYED  );
  2699.         menu->EnableMenuItem( IDM_REGON,            MF_GRAYED  );
  2700.         menu->EnableMenuItem( IDM_QUERYIDENTITY,    MF_GRAYED  );
  2701.         menu->EnableMenuItem( IDM_GETRECFLDTBL,     MF_GRAYED  );
  2702.  
  2703.     }
  2704. }
  2705.  
  2706. /********************************************************************/
  2707. /********************** CTheApp Member Functions ****************/
  2708.  
  2709. /********************************************************************/
  2710. /*
  2711.  -  CTheApp::
  2712.  -  InitInstance
  2713.  -
  2714.  *  Purpose:
  2715.  *      When any CTheApp object is created, this member function is
  2716.  *      automatically  called.  The main window of the application
  2717.  *      is created and shown here.
  2718.  *
  2719.  *  Parameters:
  2720.  *      None
  2721.  *
  2722.  *  Returns:
  2723.  *      TRUE if the initialization is successful.
  2724.  *
  2725.  */
  2726. /********************************************************************/
  2727.  
  2728. BOOL CTheApp::InitInstance()
  2729. {
  2730.     CRect   rect;
  2731.     char   *szTableLibName;
  2732.     char    szMsgBuf[256];
  2733.  
  2734.     char   *szPropLibName;
  2735.     char    szPropMsgBuf[256];
  2736.  
  2737.     char   *szStatLibName;
  2738.     char    szStatMsgBuf[256];
  2739.  
  2740.     CString str = "MDB Viewer";
  2741.  
  2742.  
  2743.     hInst = m_hInstance;
  2744.  
  2745.     m_MainWnd.LoadAccelTable( "MainAccelTable" );
  2746.  
  2747.     rect.SetRect(MW_LEFT, MW_TOP, MW_RIGHT, MW_BOTTOM);
  2748.  
  2749. #ifdef CTL3D
  2750.     Ctl3dRegister(      AfxGetInstanceHandle() );   // Register Ctl3D controls
  2751.     Ctl3dAutoSubclass(  AfxGetInstanceHandle() );
  2752. #endif
  2753.  
  2754.     SetDialogBkColor();     // makes dialog background GREY
  2755.  
  2756.     if(!m_MainWnd.Create(   NULL,
  2757.                             "MDB Viewer Test Application",
  2758.                             WS_OVERLAPPEDWINDOW,
  2759.                             rect,
  2760.                             NULL,
  2761.                             MAKEINTRESOURCE(AFX_IDI_STD_FRAME) ) )
  2762.  
  2763.         return FALSE;
  2764.  
  2765.     m_pMainWnd = &m_MainWnd;
  2766.  
  2767.     m_MainWnd.m_bAutoMenuEnable = FALSE;        // MFC 2.0 specific data member
  2768.     m_MainWnd.ShowWindow( m_nCmdShow );
  2769.     m_MainWnd.UpdateWindow();
  2770.  
  2771.  
  2772.  
  2773. #ifdef XVPORT
  2774.     // NOTIFICATION VIEWPORT INITIALIZE, MINIMIZE ON DESKTOP
  2775.     if(!XVPInit(m_MainWnd.m_hWnd))
  2776.         return FALSE;
  2777.  
  2778.     if( !(xvpNum = XVPCreateViewport(str.GetBuffer(10)) ) )
  2779.         return FALSE;
  2780.  
  2781.     XVPReset(xvpNum);
  2782.     XVPShow(xvpNum, XVP_MIN);
  2783.  
  2784.     XVPSetLogLevel(xvpNum, 0);
  2785.  
  2786. #endif
  2787.  
  2788.  
  2789.  
  2790.  
  2791.     // LOAD LIBRARY TABLE OBJECT DLL
  2792.  
  2793. #ifdef WIN16
  2794.     szTableLibName = "tblvu.dll";
  2795.     if ((UINT)(hlibTBLVU = LoadLibrary (szTableLibName)) < 32)
  2796. #else
  2797.     szTableLibName = "tblvu32.dll";
  2798.     if ((hlibTBLVU = LoadLibrary (szTableLibName)) < (void *) 32)
  2799. #endif
  2800.     {
  2801.         wsprintf(szMsgBuf,"Cannot Load %s.  Make sure this DLL is available and in your path.",szTableLibName);
  2802.         MessageBox(m_MainWnd.m_hWnd,szMsgBuf,"Error", MBS_ERROR);
  2803.         goto out;
  2804.     }
  2805.  
  2806.     // get entrypoint for table viewer dll, and set it to global variable.
  2807.     if (!(lpfnViewMapiTable  =  (LPFNVIEWMAPITABLE)GetProcAddress (hlibTBLVU, "ViewMapiTable") ))
  2808.     {
  2809.         MessageBox(m_MainWnd.m_hWnd,"Cannot Load TBLVUViewMapiTable process address.","Error", MBS_ERROR);
  2810.         FreeLibrary(hlibTBLVU);
  2811.         hlibTBLVU = (HINSTANCE) NULL;
  2812.         goto out;
  2813.     }
  2814.  
  2815.  
  2816. out:
  2817.     // LOAD LIBRARY PROPERTY OBJECT DLL
  2818.  
  2819. #ifdef WIN16
  2820.     szPropLibName = "propvu.dll";
  2821.     if ((UINT)(hlibPROPVU = LoadLibrary (szPropLibName)) < 32)
  2822. #else
  2823.     szPropLibName = "propvu32.dll";
  2824.     if (!(hlibPROPVU = LoadLibrary (szPropLibName)))
  2825. #endif
  2826.     {
  2827.         wsprintf(szPropMsgBuf,"Cannot Load %s.  Make sure this DLL is available and in your path.",szPropLibName);
  2828.         MessageBox(m_MainWnd.m_hWnd,szPropMsgBuf,"Error", MB_ICONSTOP | MB_OK);
  2829.         goto out2;
  2830.     }
  2831.  
  2832.     if (!(lpfnViewMapiProp  =  (LPFNVIEWMAPIPROP)GetProcAddress (hlibPROPVU, "ViewMapiProp") ))
  2833.     {
  2834.         MessageBox(m_MainWnd.m_hWnd,"Cannot Load ViewMapiProp process address.","Error", MB_ICONSTOP | MB_OK);
  2835.         FreeLibrary(hlibPROPVU);
  2836.         hlibPROPVU = (HINSTANCE) NULL;
  2837.         goto out2;
  2838.     }
  2839.  
  2840.  
  2841.  
  2842. out2:
  2843.  
  2844.     // LOAD LIBRARY STATUS OBJECT DLL
  2845.  
  2846. #ifdef WIN16
  2847.     szStatLibName = "statvu.dll";
  2848.     if ((UINT)(hlibSTATVU = LoadLibrary (szStatLibName)) < 32)
  2849. #else
  2850.     szStatLibName = "statvu32.dll";
  2851.     if (!(hlibSTATVU = LoadLibrary (szStatLibName)))
  2852. #endif
  2853.     {
  2854.         wsprintf(szStatMsgBuf,"Cannot Load %s.  Make sure this DLL is available and in your path.",szStatLibName);
  2855.         MessageBox(m_MainWnd.m_hWnd,szStatMsgBuf,"Error", MB_ICONSTOP | MB_OK);
  2856.         goto logon;
  2857.     }
  2858.  
  2859.     if (!(lpfnViewMapiStat  =  (LPFNVIEWMAPISTAT)GetProcAddress (hlibSTATVU, "ViewStatusObj") ))
  2860.     {
  2861.         MessageBox(m_MainWnd.m_hWnd,"Cannot Load ViewStatusObj process address.","Error", MB_ICONSTOP | MB_OK);
  2862.         FreeLibrary(hlibSTATVU);
  2863.         hlibSTATVU = (HINSTANCE) NULL;
  2864.         goto logon;
  2865.     }
  2866.  
  2867. logon:
  2868.  
  2869.  
  2870.  
  2871.     MAPIInitialize(NULL);
  2872.  
  2873.     // Logon to Extended MAPI
  2874.     m_MainWnd.OnLogon();
  2875.  
  2876.     return TRUE;
  2877. }
  2878.  
  2879.  
  2880. /********************************************************************/
  2881. /*
  2882.  -  CTheApp::
  2883.  -  ExitInstance
  2884.  -
  2885.  *  Purpose:
  2886.  *     Unregister Control 3D and exit this instance of the application
  2887.  */
  2888. /********************************************************************/
  2889.  
  2890. int CTheApp::ExitInstance()
  2891. {
  2892.  
  2893. #ifdef XVPORT
  2894.     XVPReset(xvpNum);
  2895.  
  2896.     XVPDestroyViewport(xvpNum);
  2897.  
  2898.     XVPDeInit();
  2899. #endif
  2900.  
  2901. #ifdef CTL3D
  2902.     Ctl3dUnregister(AfxGetInstanceHandle());
  2903. #endif
  2904.     return CWinApp::ExitInstance();
  2905. }
  2906.  
  2907.  
  2908. /********************************************************************/
  2909. /********************** CGetError Member Functions ******************/
  2910.  
  2911. /********************************************************************/
  2912. /*
  2913.  -  CGetError::
  2914.  -  SzError       SCODE and ULONG
  2915.  -
  2916.  *  Purpose:
  2917.  *      For printable Error String.  Uses the stringtable
  2918.  *      technology from mapitest.
  2919.  *
  2920.  *  Parameters:
  2921.  *      szMsg       - Message Text
  2922.  *      scResult    - Error Code
  2923.  *
  2924.  *  Returns:
  2925.  *      szError     - Textized information
  2926.  *
  2927.  */
  2928. /********************************************************************/
  2929.  
  2930. LPSTR CGetError::SzError( LPSTR szMsg, SCODE scResult )
  2931. {
  2932.     wsprintf( m_szMessage, "%s: ", szMsg );
  2933.  
  2934.     if(!GetString( "MAPIErrors", scResult, m_szResult ))
  2935.     {
  2936.         lstrcpy(  m_szResult, "??" );
  2937.         wsprintf( m_szBuffer, " %04X", scResult );
  2938.         lstrcat(  m_szResult, m_szBuffer );
  2939.     }
  2940.  
  2941.     lstrcat( m_szMessage, m_szResult );
  2942.  
  2943.     return m_szMessage;
  2944. }
  2945.  
  2946. /********************************************************************/
  2947.  
  2948. #ifdef WIN16
  2949. LPSTR CGetError::SzError( LPSTR szMsg, HRESULT hResult )
  2950. {
  2951.     return( SzError(szMsg, GetScode(hResult) ) );
  2952. }
  2953. #endif
  2954.  
  2955.  
  2956. /*******************************************************************/
  2957. /*******************************************************************/
  2958. /*******************************************************************/
  2959. /*******************************************************************/
  2960.  
  2961.  
  2962. /******************* CMainWindow Message Map ****************************/
  2963.  
  2964. BEGIN_MESSAGE_MAP( COpenStoreDlg, CDialog )
  2965.  
  2966.     ON_COMMAND(     IDC_OPENSTORE,          OnOpen)
  2967.     ON_BN_CLICKED(  IDC_READONLY,           OnReadOnly)
  2968.     ON_COMMAND(     IDC_SETDEFAULTSTORE,    OnSetDefaultStore)
  2969.  
  2970. END_MESSAGE_MAP()
  2971.  
  2972.  
  2973. /*******************************************************************/
  2974. /*
  2975.  -  COpenStore::
  2976.  -  OnInitDialog
  2977.  *
  2978.  *  Purpose:
  2979.  *  Parameters
  2980.  *  Returns:
  2981.  *
  2982.  */
  2983. /*******************************************************************/
  2984.  
  2985. BOOL COpenStoreDlg::OnInitDialog()
  2986. {
  2987.     int             rgTabStops[5];
  2988.     DWORD           dwReturn        = 0;
  2989.     HRESULT         hResult1        = hrSuccess;
  2990.     CGetError       E;
  2991.  
  2992.     SizedSPropTagArray(4,sptaStores) =
  2993.     {
  2994.         4,
  2995.         {
  2996.             PR_DEFAULT_STORE,
  2997.             PR_DISPLAY_NAME,
  2998.             PR_PROVIDER_DISPLAY,
  2999.             PR_ENTRYID
  3000.         }
  3001.     };
  3002.  
  3003.  
  3004.     SetWindowText( "Select Message Store To Open" );
  3005.  
  3006.     CheckDlgButton(IDC_READONLY,    0);
  3007.  
  3008.     // load properties into listbox
  3009.     dwReturn = SendDlgItemMessage(IDC_ALL_STORES,LB_SETHORIZONTALEXTENT,
  3010.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  3011.  
  3012.     rgTabStops[0] = 15  ;
  3013.     rgTabStops[1] = 200 ;
  3014.     rgTabStops[2] = 200 ;
  3015.  
  3016.     dwReturn = SendDlgItemMessage(IDC_ALL_STORES,LB_SETTABSTOPS,
  3017.                     (WPARAM) 3,(LPARAM)rgTabStops );
  3018.  
  3019.     // find out what message stores are out there
  3020.     hResultSession = lpSession->GetMsgStoresTable(0,&m_lptblStores);
  3021.     if( HR_FAILED(hResultSession) )
  3022.     {
  3023.         MessageBox( E.SzError("lpSession->GetMsgStoresTable", hResultSession),
  3024.                             "Client", MBS_ERROR );
  3025.         return FALSE;
  3026.     }
  3027.  
  3028.     hResult1 = m_lptblStores->SetColumns( (LPSPropTagArray) &sptaStores, 0);
  3029.     if( HR_FAILED(hResult1) )
  3030.     {
  3031.         MessageBox( E.SzError("m_lptblStores->SetColumns", hResult1),
  3032.                             "Client", MBS_ERROR );
  3033.         return FALSE;
  3034.     }
  3035.  
  3036.     DisplayStores();
  3037.  
  3038.     return TRUE;
  3039. }
  3040.  
  3041. /*******************************************************************/
  3042.  
  3043. void COpenStoreDlg::OnReadOnly()
  3044. {
  3045.     CheckDlgButton(IDC_READONLY, !IsDlgButtonChecked(IDC_READONLY) );
  3046. }
  3047.  
  3048.  
  3049. /*******************************************************************/
  3050. /*
  3051.  -  COpenStore::
  3052.  -  OnOpen
  3053.  *
  3054.  *  Purpose:
  3055.  *  Parameters
  3056.  *  Returns:
  3057.  *
  3058.  */
  3059. /*******************************************************************/
  3060.  
  3061. void COpenStoreDlg::OnOpen()
  3062. {
  3063.     LONG            lSelection  = 0;
  3064.     ULONG           ulFlags     = 0;
  3065.     CGetError       E;
  3066.  
  3067.     if( (lSelection = SendDlgItemMessage(IDC_ALL_STORES,LB_GETCURSEL,0,0 )) < 0 )
  3068.     {
  3069.         MessageBox("Select a Store to open", "OnOpen", MBS_ERROR );
  3070.         return;
  3071.     }
  3072.  
  3073.     // determine access privileges
  3074.     if( IsDlgButtonChecked(IDC_READONLY) )
  3075.         ulAccess = 0;
  3076.     else
  3077.     {
  3078.         ulAccess = MAPI_MODIFY;
  3079.         ulFlags  = MDB_WRITE;
  3080.     }
  3081.  
  3082.     hResultSession = lpSession->OpenMsgStore( (ULONG)(void *)m_hWnd,
  3083.                     (ULONG)     m_lpRows->aRow[lSelection].lpProps[3].Value.bin.cb,
  3084.                     (LPENTRYID) m_lpRows->aRow[lSelection].lpProps[3].Value.bin.lpb,
  3085.                     NULL,
  3086.                     ulFlags,
  3087.                     &lpMDB );
  3088.     if( HR_FAILED( hResultSession ) )
  3089.     {
  3090.         MessageBox( E.SzError("lpSession->OpenMsgStore()", hResultSession),
  3091.                  "Client", MBS_ERROR );
  3092.         return;
  3093.     }
  3094.  
  3095. #ifdef XVPORT
  3096.     // advise for events on mdb object
  3097.     AdviseObj(  lpMDB,
  3098.                 MAPI_STORE,
  3099.                 LogNotifToXVPLog,
  3100.                 fnevNewMail,
  3101.                 0,
  3102.                 NULL,
  3103.                 "fnevNewMail, lpMDB , lpMDB",
  3104.                 NULL,
  3105.                 &lpMDBNotifs);
  3106.  
  3107.     AdviseObj(  lpMDB,
  3108.                 MAPI_STORE,
  3109.                 LogNotifToXVPLog,
  3110.                 fnevObjectCreated,
  3111.                 0,
  3112.                 NULL,
  3113.                 "fnevObjectCreated, lpMDB , lpMDB",
  3114.                 NULL,
  3115.                 &lpMDBNotifs);
  3116.  
  3117.     AdviseObj(  lpMDB,
  3118.                 MAPI_STORE,
  3119.                 LogNotifToXVPLog,
  3120.                 fnevObjectDeleted,
  3121.                 0,
  3122.                 NULL,
  3123.                 "fnevObjectDeleted, lpMDB , lpMDB",
  3124.                 NULL,
  3125.                 &lpMDBNotifs);
  3126.  
  3127.     AdviseObj(  lpMDB,
  3128.                 MAPI_STORE,
  3129.                 LogNotifToXVPLog,
  3130.                 fnevObjectModified,
  3131.                 0,
  3132.                 NULL,
  3133.                 "fnevObjectModified, lpMDB , lpMDB",
  3134.                 NULL,
  3135.                 &lpMDBNotifs);
  3136.  
  3137.     AdviseObj(  lpMDB,
  3138.                 MAPI_STORE,
  3139.                 LogNotifToXVPLog,
  3140.                 fnevObjectMoved,
  3141.                 0,
  3142.                 NULL,
  3143.                 "fnevObjectMoved, lpMDB , lpMDB",
  3144.                 NULL,
  3145.                 &lpMDBNotifs);
  3146.  
  3147.     AdviseObj(  lpMDB,
  3148.                 MAPI_STORE,
  3149.                 LogNotifToXVPLog,
  3150.                 fnevObjectCopied,
  3151.                 0,
  3152.                 NULL,
  3153.                 "fnevObjectCopied, lpMDB , lpMDB",
  3154.                 NULL,
  3155.                 &lpMDBNotifs);
  3156.  
  3157.     AdviseObj(  lpMDB,
  3158.                 MAPI_STORE,
  3159.                 LogNotifToXVPLog,
  3160.                 fnevCriticalError,
  3161.                 0,
  3162.                 NULL,
  3163.                 "fnevCriticalError, lpMDB , lpMDB",
  3164.                 NULL,
  3165.                 &lpMDBNotifs);
  3166.  
  3167. #endif
  3168.  
  3169.     // start default dest to be Message Store object for next copy to
  3170.     lpvCopyToDest = lpMDB;
  3171.  
  3172.     EndDialog(IDOK);
  3173. }
  3174.  
  3175.  
  3176. /*******************************************************************/
  3177. /*
  3178.  -  COpenStore::
  3179.  -  ~COpenStoreDlg
  3180.  *
  3181.  *  Purpose:
  3182.  *  Parameters
  3183.  *  Returns:
  3184.  *
  3185.  */
  3186. /*******************************************************************/
  3187.  
  3188. COpenStoreDlg::~COpenStoreDlg()
  3189. {
  3190.     // FREE MEMORY AND OBJECTS, and exit dialog
  3191.  
  3192.     FreeRowSet(m_lpRows);
  3193.  
  3194.     // release table
  3195.     if(m_lptblStores)
  3196.     {
  3197.         m_lptblStores->Release();
  3198.         m_lptblStores = NULL;
  3199.     }
  3200. }
  3201.  
  3202.  
  3203. /*******************************************************************/
  3204. /*
  3205.  -  COpenStore::
  3206.  -  OnDisplayStores
  3207.  *
  3208.  *  Purpose:
  3209.  *  Parameters
  3210.  *  Returns:
  3211.  *
  3212.  */
  3213. /*******************************************************************/
  3214.  
  3215. void COpenStoreDlg::DisplayStores()
  3216. {
  3217.     CGetError       E;
  3218.     LPSRowSet       lpRows          = NULL;
  3219.     ULONG           iRow            = 0;
  3220.     HRESULT         hResult1        = hrSuccess;
  3221.     ULONG           ulRows          = 0;
  3222.     char            szBuffer[512];
  3223.     DWORD           dwReturn        = 0;
  3224.     ULONG           ulDefault       = 0;
  3225.  
  3226.     if(m_lpRows)
  3227.     {
  3228.         FreeRowSet(m_lpRows);
  3229.         m_lpRows = NULL;
  3230.     }
  3231.  
  3232.     SendDlgItemMessage(IDC_ALL_STORES,LB_RESETCONTENT,0,0);
  3233.  
  3234.     hResult1 = m_lptblStores->GetRowCount(0,&ulRows);
  3235.     if( HR_FAILED(hResult1) )
  3236.     {
  3237.         MessageBox( E.SzError("m_lptblStores->GetRowCount", hResult1),
  3238.                             "Client", MBS_ERROR );
  3239.         return;
  3240.     }
  3241.  
  3242.     hResult1 = m_lptblStores->SeekRow( BOOKMARK_BEGINNING,0 , NULL );
  3243.     if( HR_FAILED(hResult1) )
  3244.     {
  3245.         MessageBox( E.SzError("m_lptblStores->SeekRow", hResult1),
  3246.                             "Client", MBS_ERROR );
  3247.         return;
  3248.     }
  3249.  
  3250.     if( !HR_FAILED(hResult1 = m_lptblStores->QueryRows( ulRows, TBL_NOADVANCE, &m_lpRows ) ) )
  3251.     {
  3252.         // if there is at least one row, find column of EntryID and Default Store
  3253.         if(m_lpRows->cRows)
  3254.         {
  3255.             // find out which row has the Default Store and open it
  3256.             for(iRow = 0; iRow < m_lpRows->cRows; iRow++)
  3257.             {
  3258.                 // if row is default store, display "D" in 1st column
  3259.                 if(m_lpRows->aRow[iRow].lpProps[0].Value.b == 1)
  3260.                 {
  3261.                     strcpy(szBuffer,"D");
  3262.                     strcat(szBuffer,"\t");
  3263.                     ulDefault  = iRow;
  3264.                 }
  3265.                 else
  3266.                 {
  3267.                     strcpy(szBuffer," ");
  3268.                     strcat(szBuffer,"\t");
  3269.                 }
  3270.  
  3271.                 strcat(szBuffer,m_lpRows->aRow[iRow].lpProps[1].Value.lpszA);
  3272.                 strcat(szBuffer,"\t");
  3273.  
  3274.                 strcat(szBuffer,m_lpRows->aRow[iRow].lpProps[2].Value.lpszA);
  3275.  
  3276.                 dwReturn = SendDlgItemMessage(IDC_ALL_STORES,LB_ADDSTRING,0,
  3277.                             (LPARAM)szBuffer);
  3278.             }
  3279.         }
  3280.     }
  3281.  
  3282.     dwReturn = SendDlgItemMessage(IDC_ALL_STORES,LB_SETCURSEL, (WPARAM) ulDefault, 0 );
  3283. }
  3284.  
  3285. /*******************************************************************/
  3286. /*
  3287.  -  COpenStore::
  3288.  -  OnSetDefaultStore
  3289.  *
  3290.  *  Purpose:
  3291.  *  Parameters
  3292.  *  Returns:
  3293.  *
  3294.  */
  3295. /*******************************************************************/
  3296.  
  3297. void COpenStoreDlg::OnSetDefaultStore()
  3298. {
  3299.     LONG    lSelection  = 0;
  3300.     CGetError       E;
  3301.  
  3302.     if( (lSelection = SendDlgItemMessage(IDC_ALL_STORES,LB_GETCURSEL,0,0 )) < 0 )
  3303.     {
  3304.         MessageBox("Select a store to set as default", "OnOpen", MBS_ERROR );
  3305.         return;
  3306.     }
  3307.  
  3308.     hResultSession = lpSession->SetDefaultStore(
  3309.                     MAPI_DEFAULT_STORE,
  3310.                     (ULONG)     m_lpRows->aRow[lSelection].lpProps[3].Value.bin.cb,
  3311.                     (LPENTRYID) m_lpRows->aRow[lSelection].lpProps[3].Value.bin.lpb );
  3312.  
  3313.     if( HR_FAILED(hResultSession) )
  3314.     {
  3315.         MessageBox( E.SzError("lpSession->SetDefaultStore()", hResultSession),
  3316.                  "Client", MBS_ERROR );
  3317.     }
  3318.     DisplayStores();
  3319. }
  3320.  
  3321. /*******************************************************************/
  3322. /*
  3323.  -  COpenStore::
  3324.  -  OnCancel
  3325.  -
  3326.  *  Purpose:
  3327.  *
  3328.  */
  3329. /*******************************************************************/
  3330.  
  3331. void COpenStoreDlg::OnCancel()
  3332. {
  3333.     EndDialog(IDCANCEL);
  3334. }
  3335.  
  3336.  
  3337.  
  3338. /*******************************************************************/
  3339. /**************************** ENUMADRTYPES **************************/
  3340.  
  3341. /********************************************************************/
  3342. /*
  3343.  -  CEnumAdrTypesDlg::
  3344.  -  OnInitDialog
  3345.  -
  3346.  *  Purpose:
  3347.  *
  3348.  */
  3349. /********************************************************************/
  3350.  
  3351. BOOL CEnumAdrTypesDlg::OnInitDialog()
  3352. {
  3353.     CGetError       E;
  3354.     DWORD           dwReturn        = 0;
  3355.     ULONG           cAdrTypes       = 0;
  3356.     char            szCTypes[80];
  3357.     ULONG           idx;
  3358.  
  3359.     SendDlgItemMessage(IDC_ENUM,LB_RESETCONTENT,0,0);
  3360.  
  3361.  
  3362.     //$ FUTURE OPerations dialog with flags UNICODE
  3363.     hResultSession = lpSession->EnumAdrTypes(
  3364.                     0,
  3365.                     &cAdrTypes,
  3366.                     &m_lppszAdrTypes);
  3367.     if( HR_FAILED(hResultSession) )
  3368.     {
  3369.         MessageBox( E.SzError("lpSession->EnumAdrTypes()", hResultSession),
  3370.                  "Client", MBS_ERROR );
  3371.         goto error;
  3372.     }
  3373.  
  3374.     wsprintf(szCTypes,"cAdrTypes:  %lu",cAdrTypes);
  3375.     SetDlgItemText(IDT_ENUM_CTYPES,szCTypes);
  3376.  
  3377.     for( idx = 0 ; idx < cAdrTypes; idx++)
  3378.         dwReturn = SendDlgItemMessage(IDC_ENUM,LB_ADDSTRING,0,
  3379.                             (LPARAM) m_lppszAdrTypes[idx] );
  3380.  
  3381.     return TRUE;
  3382.  
  3383. error:
  3384.  
  3385.     return FALSE;
  3386. }
  3387.  
  3388.  
  3389. /*******************************************************************/
  3390. /*
  3391.  -  CEnumAdrTypesDlg::
  3392.  -  ~CEnumAdrTypesDlg
  3393.  -
  3394.  *  Purpose:
  3395.  *      Destructor for class CEnumAdrTypesDlg. Releases and Frees memory
  3396.  *      allocated in this class
  3397.  *
  3398.  */
  3399. /*******************************************************************/
  3400.  
  3401. CEnumAdrTypesDlg::~CEnumAdrTypesDlg()
  3402. {
  3403.     if(m_lppszAdrTypes)
  3404.         MAPIFreeBuffer(m_lppszAdrTypes);
  3405. }
  3406.  
  3407.  
  3408. /*******************************************************************/
  3409. /*
  3410.  -  CEnumAdrTypesDlg::
  3411.  -  OnCancel
  3412.  -
  3413.  *  Purpose:
  3414.  *
  3415.  */
  3416. /*******************************************************************/
  3417.  
  3418. void CEnumAdrTypesDlg::OnCancel()
  3419. {
  3420.     EndDialog(IDCANCEL);
  3421. }
  3422.  
  3423.  
  3424. /*******************************************************************/
  3425. /*********************** StoreSupportMask **************************/
  3426.  
  3427. /********************************************************************/
  3428. /*
  3429.  -  CStoreSupportMaskDlg::
  3430.  -  OnInitDialog
  3431.  -
  3432.  *  Purpose:
  3433.  *
  3434.  */
  3435. /********************************************************************/
  3436.  
  3437. BOOL CStoreSupportMaskDlg::OnInitDialog()
  3438. {
  3439.     CGetError       E;
  3440.     DWORD           dwReturn        = 0;
  3441.     HRESULT         hResult         = hrSuccess;
  3442.     char            szBuff[80];
  3443.     int             rgTabStops[4];
  3444.     char            szBuffer1[200];
  3445.     
  3446.     SPropTagArray   sptaSupport =
  3447.     {
  3448.         1,
  3449.         {
  3450.             PR_STORE_SUPPORT_MASK
  3451.         }
  3452.     };
  3453.  
  3454.  
  3455.  
  3456.     SendDlgItemMessage(IDC_SUPPORT_MASK,LB_RESETCONTENT,0,0);
  3457.  
  3458.     rgTabStops[0] = 150 ;
  3459.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  3460.  
  3461.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_SETTABSTOPS,
  3462.                     (WPARAM) 2,(LPARAM)rgTabStops );
  3463.  
  3464.  
  3465.     hResult = lpMDB->GetProps((LPSPropTagArray)&sptaSupport,0,&m_cVals,&m_lpspva);
  3466.     if( HR_FAILED(hResult) )
  3467.     {
  3468.         MessageBox( E.SzError("lpMDB->GetProps(PR_STORE_SUPPORT_MASK)", hResult),
  3469.                  "Client", MBS_ERROR );
  3470.         goto error;
  3471.     }
  3472.  
  3473.     if(m_lpspva[0].ulPropTag != PR_STORE_SUPPORT_MASK )
  3474.         goto error;
  3475.         
  3476.     wsprintf(szBuff,"PR_STORE_SUPPORT_MASK == %lu",m_lpspva[0].Value.l);
  3477.     SetDlgItemText(IDT_SUPPORT_MASK,szBuff);
  3478.  
  3479.     // now logical or with all valid types and addstring each value YES or NO
  3480.  
  3481.     wsprintf(szBuffer1,"STORE_ENTRYID_UNIQUE\t%s", 
  3482.             ((m_lpspva[0].Value.l & STORE_ENTRYID_UNIQUE) ? "YES" : "NO") );
  3483.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3484.  
  3485.     wsprintf(szBuffer1,"STORE_READONLY\t%s", 
  3486.             ((m_lpspva[0].Value.l & STORE_READONLY) ? "YES" : "NO") );
  3487.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3488.  
  3489.     wsprintf(szBuffer1,"STORE_SEARCH_OK\t%s", 
  3490.             ((m_lpspva[0].Value.l & STORE_SEARCH_OK) ? "YES" : "NO") );
  3491.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3492.  
  3493.     wsprintf(szBuffer1,"STORE_MODIFY_OK\t%s", 
  3494.             ((m_lpspva[0].Value.l & STORE_MODIFY_OK) ? "YES" : "NO") );
  3495.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3496.  
  3497.     wsprintf(szBuffer1,"STORE_CREATE_OK\t%s", 
  3498.             ((m_lpspva[0].Value.l & STORE_CREATE_OK) ? "YES" : "NO") );
  3499.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3500.  
  3501.     wsprintf(szBuffer1,"STORE_ATTACH_OK\t%s", 
  3502.             ((m_lpspva[0].Value.l & STORE_ATTACH_OK) ? "YES" : "NO") );
  3503.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3504.  
  3505.     wsprintf(szBuffer1,"STORE_OLE_OK\t%s", 
  3506.             ((m_lpspva[0].Value.l & STORE_OLE_OK) ? "YES" : "NO") );
  3507.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3508.  
  3509.     wsprintf(szBuffer1,"STORE_NOTIFY_OK\t%s", 
  3510.             ((m_lpspva[0].Value.l & STORE_NOTIFY_OK) ? "YES" : "NO" ));
  3511.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3512.  
  3513.     wsprintf(szBuffer1,"STORE_MV_PROPS_OK\t%s", 
  3514.             ((m_lpspva[0].Value.l & STORE_MV_PROPS_OK) ? "YES" : "NO") );
  3515.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3516.  
  3517.     wsprintf(szBuffer1,"STORE_CATEGORIZE_OK\t%s", 
  3518.             ((m_lpspva[0].Value.l & STORE_CATEGORIZE_OK) ? "YES" : "NO") );
  3519.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3520.  
  3521.     wsprintf(szBuffer1,"STORE_RTF_OK\t%s", 
  3522.             ((m_lpspva[0].Value.l & STORE_RTF_OK) ? "YES" : "NO") );
  3523.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3524.  
  3525.     wsprintf(szBuffer1,"STORE_RESTRICTION_OK\t%s", 
  3526.             ((m_lpspva[0].Value.l & STORE_RESTRICTION_OK) ? "YES" : "NO") );
  3527.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3528.  
  3529.     wsprintf(szBuffer1,"STORE_SORT_OK\t%s", 
  3530.             ((m_lpspva[0].Value.l & STORE_SORT_OK) ? "YES" : "NO") );
  3531.     dwReturn = SendDlgItemMessage(IDC_SUPPORT_MASK,LB_ADDSTRING,0,(LPARAM) szBuffer1 );
  3532.     
  3533.     return TRUE;
  3534.  
  3535. error:
  3536.  
  3537.     return FALSE;
  3538. }
  3539.  
  3540.  
  3541. /*******************************************************************/
  3542. /*
  3543.  -  CStoreSupportMaskDlg::
  3544.  -  ~CStoreSupportMaskDlg
  3545.  -
  3546.  *  Purpose:
  3547.  *      Destructor for class CStoreSupportMaskDlg. Releases and Frees memory
  3548.  *      allocated in this class
  3549.  *
  3550.  */
  3551. /*******************************************************************/
  3552.  
  3553. CStoreSupportMaskDlg::~CStoreSupportMaskDlg()
  3554. {
  3555.     if(m_lpspva)
  3556.         MAPIFreeBuffer(m_lpspva);
  3557. }
  3558.  
  3559.  
  3560. /*******************************************************************/
  3561. /*
  3562.  -  CStoreSupportMaskDlg::
  3563.  -  OnCancel
  3564.  -
  3565.  *  Purpose:
  3566.  *
  3567.  */
  3568. /*******************************************************************/
  3569.  
  3570. void CStoreSupportMaskDlg::OnCancel()
  3571. {
  3572.     EndDialog(IDCANCEL);
  3573. }
  3574.  
  3575.  
  3576.  
  3577.  
  3578. /*******************************************************************/
  3579. /**************************** QUERYDEFAULTMESSAGEOPT****************/
  3580.  
  3581. /********************************************************************/
  3582. /*
  3583.  -  CQueryDefaultMsgOptssDlg::
  3584.  -  OnInitDialog
  3585.  -
  3586.  *  Purpose:
  3587.  *
  3588.  */
  3589. /********************************************************************/
  3590.  
  3591. BOOL CQueryDefaultMsgOptsDlg::OnInitDialog()
  3592. {
  3593.     DWORD           dwReturn        = 0;
  3594.     ULONG           cAdrTypes       = 0;
  3595.     char            szCValues[80];
  3596.     ULONG           idx;
  3597.     int             rgTabStops[4];
  3598.     char szID[50];
  3599.     char szData[512];
  3600.     char szType[32];      // Assumes no PropType string longer than 31 chars
  3601.     char            szBuffer[1024];
  3602.  
  3603.  
  3604.     SendDlgItemMessage(IDC_QD_PROPS,LB_RESETCONTENT,0,0);
  3605.  
  3606.     dwReturn = SendDlgItemMessage(IDC_QD_PROPS,LB_SETHORIZONTALEXTENT,
  3607.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  3608.  
  3609.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  3610.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  3611.  
  3612.     dwReturn = SendDlgItemMessage(IDC_QD_PROPS,LB_SETTABSTOPS,
  3613.                     (WPARAM) 2,(LPARAM)rgTabStops );
  3614.  
  3615.     wsprintf(szCValues,"cAdrTypes:  %lu",m_cValues);
  3616.     SetDlgItemText(IDT_QD_CVALS,szCValues);
  3617.  
  3618.     for( idx = 0 ; idx < m_cValues; idx++)
  3619.     {
  3620.         if(GetString("PropIDs", PROP_ID(m_lpspva[idx].ulPropTag), szID ) )
  3621.         {
  3622.             lstrcat(szBuffer, szID );
  3623.             lstrcat(szBuffer, "\t");
  3624.         }
  3625.         else
  3626.         {
  3627.             wsprintf(szBuffer,"%#04X\t", PROP_ID(m_lpspva[idx].ulPropTag) );
  3628.         }
  3629.  
  3630.         if( GetString("PropType", PROP_TYPE(m_lpspva[idx].ulPropTag), szType) )
  3631.         {
  3632.             lstrcat(szBuffer, szType);
  3633.             lstrcat(szBuffer,"\t");
  3634.         }
  3635.         else
  3636.         {
  3637.             wsprintf(szType,"%#04X\t", PROP_TYPE(m_lpspva[idx].ulPropTag) );
  3638.             lstrcat(szBuffer,szType);
  3639.         }
  3640.  
  3641.         SzGetPropValue(szData,(LPSPropValue) &m_lpspva[idx]);
  3642.         lstrcat(szBuffer,szData);
  3643.  
  3644.         dwReturn = SendDlgItemMessage(IDC_QD_PROPS,LB_ADDSTRING,0,
  3645.                             (LPARAM) szBuffer);
  3646.     }
  3647.  
  3648.     return TRUE;
  3649. }
  3650.  
  3651.  
  3652. /*******************************************************************/
  3653. /*
  3654.  -  CQueryDefaultMsgOptssDlg::
  3655.  -  ~CQueryDefaultMsgOptssDlg
  3656.  -
  3657.  *  Purpose:
  3658.  *      Destructor for class CQueryDefaultMsgOptssDlg. Releases and Frees memory
  3659.  *      allocated in this class
  3660.  *
  3661.  */
  3662. /*******************************************************************/
  3663.  
  3664. CQueryDefaultMsgOptsDlg::~CQueryDefaultMsgOptsDlg()
  3665. {
  3666.  
  3667. }
  3668.  
  3669.  
  3670. /*******************************************************************/
  3671. /*
  3672.  -  CQueryDefaultMsgOptssDlg::
  3673.  -  OnCancel
  3674.  -
  3675.  *  Purpose:
  3676.  *
  3677.  */
  3678. /*******************************************************************/
  3679.  
  3680. void CQueryDefaultMsgOptsDlg::OnCancel()
  3681. {
  3682.     EndDialog(IDCANCEL);
  3683. }
  3684.  
  3685.  
  3686.  
  3687. /*******************************************************************/
  3688. /**************************** ENTRYLIST **************************/
  3689.  
  3690.  
  3691. /******************* CMainWindow Message Map ****************************/
  3692.  
  3693. BEGIN_MESSAGE_MAP( CEntryListDlg, CModalDialog )
  3694.  
  3695.     ON_COMMAND( IDC_EL_CLEAR,        OnClearList )
  3696.  
  3697. END_MESSAGE_MAP()
  3698.  
  3699. /********************************************************************/
  3700. /*
  3701.  -  CEntryListDlg::
  3702.  -  OnInitDialog
  3703.  -
  3704.  *  Purpose:
  3705.  *
  3706.  */
  3707. /********************************************************************/
  3708.  
  3709. BOOL CEntryListDlg::OnInitDialog()
  3710. {
  3711.     DWORD   dwReturn = 0;
  3712.  
  3713.     SetWindowText( m_List.GetBuffer(30) );
  3714.  
  3715.     dwReturn = SendDlgItemMessage(IDC_EL_LIST,LB_SETHORIZONTALEXTENT,
  3716.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  3717.  
  3718.     DisplayList();
  3719.  
  3720.     return TRUE;
  3721. }
  3722.  
  3723.  
  3724. /*******************************************************************/
  3725. /*
  3726.  -  CEntryListDlg::
  3727.  -  ~CEntryListDlg
  3728.  -
  3729.  *  Purpose:
  3730.  *      Destructor for class CEntryListDlg. Releases and Frees memory
  3731.  *      allocated in this class
  3732.  *
  3733.  */
  3734. /*******************************************************************/
  3735.  
  3736. CEntryListDlg::~CEntryListDlg()
  3737. {
  3738.  
  3739. }
  3740.  
  3741.  
  3742. /*******************************************************************/
  3743. /*
  3744.  -  CEntryListDlg::
  3745.  -  OnCancel
  3746.  -
  3747.  *  Purpose:
  3748.  *
  3749.  */
  3750. /*******************************************************************/
  3751.  
  3752. void CEntryListDlg::OnCancel()
  3753. {
  3754.     EndDialog(IDCANCEL);
  3755. }
  3756.  
  3757.  
  3758. /*******************************************************************/
  3759. /*
  3760.  -  CEntryListDlg::
  3761.  -  DisplayList
  3762.  -
  3763.  *  Purpose:
  3764.  *
  3765.  */
  3766. /*******************************************************************/
  3767.  
  3768. void CEntryListDlg::DisplayList()
  3769. {
  3770.     char    szCVals[30];
  3771.     ULONG   iRow        = 0;
  3772.     DWORD   dwReturn    = 0;
  3773.     char    szBuffer[256];
  3774.  
  3775.     SendDlgItemMessage(IDC_EL_LIST,LB_RESETCONTENT,0,0);
  3776.  
  3777.     if( !(*m_lppEntryList))
  3778.     {
  3779.         // DISPLAY Expected lpPTA->cValues
  3780.         wsprintf(szCVals,"cValues:  %lu",0);
  3781.         SetDlgItemText(IDT_EL_CVALS,szCVals);
  3782.  
  3783.         return;
  3784.     }
  3785.     if((*m_lppEntryList)->cValues)
  3786.     {
  3787.         // DISPLAY Expected lpPTA->cValues
  3788.         wsprintf(szCVals,"cValues:  %lu",(*m_lppEntryList)->cValues);
  3789.         SetDlgItemText(IDT_EL_CVALS,szCVals);
  3790.  
  3791.         // find out which row has the Default Status and open it
  3792.         for(iRow = 0; iRow < (*m_lppEntryList)->cValues; iRow++)
  3793.         {
  3794.             // display PR_ENTRYID
  3795.             char    lpszHex[9];
  3796.             ULONG   cb      = 0;
  3797.             ULONG   cChars  = 0;
  3798.             LPBYTE  lpb     = (*m_lppEntryList)->lpbin[iRow].lpb;
  3799.  
  3800.             szBuffer[0] = '\0';
  3801.  
  3802.             while((cb < (*m_lppEntryList)->lpbin[iRow].cb) && (cChars < 255 -16 ) )
  3803.             {
  3804.                 wsprintf(lpszHex, "%02X ", *lpb);
  3805.                 lstrcat(szBuffer, lpszHex);
  3806.                 cChars += 3;
  3807.                 lpb++;
  3808.                 cb++;
  3809.             }
  3810.  
  3811.             dwReturn = SendDlgItemMessage(IDC_EL_LIST,LB_ADDSTRING,0,
  3812.                         (LPARAM)szBuffer);
  3813.         }
  3814.     }
  3815. }
  3816.  
  3817.  
  3818. /*******************************************************************/
  3819. /*
  3820.  -  CEntryListDlg::
  3821.  -  OnClearList
  3822.  -
  3823.  *  Purpose:
  3824.  *
  3825.  */
  3826. /*******************************************************************/
  3827.  
  3828. void CEntryListDlg::OnClearList()
  3829. {
  3830.     PvFree(*m_lppEntryList);
  3831.     *m_lppEntryList = NULL;
  3832.  
  3833.     DisplayList();
  3834. }
  3835.  
  3836.  
  3837.  
  3838. /***************************************************************/
  3839. /**************************** ADRLIST **************************/
  3840.  
  3841. /********************************************************************/
  3842. /*
  3843.  -  CAdrListDlg::
  3844.  -  OnInitDialog
  3845.  -
  3846.  *  Purpose:
  3847.  *
  3848.  */
  3849. /********************************************************************/
  3850.  
  3851. BOOL CAdrListDlg::OnInitDialog()
  3852. {
  3853.     DWORD           dwReturn = 0;
  3854.     int             rgTabStops[5];
  3855.  
  3856.     SetWindowText( m_List.GetBuffer(30) );
  3857.  
  3858.     dwReturn = SendDlgItemMessage(IDC_ADRLIST,LB_SETHORIZONTALEXTENT,
  3859.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  3860.  
  3861.     rgTabStops[0] = 20  ;   // first indent
  3862.     rgTabStops[1] = 150 ;   // for PropID space
  3863.     rgTabStops[2] = 210 ;   // for PropType space
  3864.     rgTabStops[3] = 270 ;   // for Data space
  3865.  
  3866.     dwReturn = SendDlgItemMessage(IDC_ADRLIST,LB_SETTABSTOPS,
  3867.                     (WPARAM) 4,(LPARAM)rgTabStops );
  3868.  
  3869.     DisplayAdrList();
  3870.  
  3871.     return TRUE;
  3872. }
  3873.  
  3874. /*******************************************************************/
  3875. /*
  3876.  -  CAdrListDlg::
  3877.  -  ~CAdrListDlg
  3878.  -
  3879.  *  Purpose:
  3880.  *      Destructor for class CAdrListDlg. Releases and Frees memory
  3881.  *      allocated in this class
  3882.  *
  3883.  */
  3884. /*******************************************************************/
  3885.  
  3886. CAdrListDlg::~CAdrListDlg()
  3887. {
  3888.  
  3889. }
  3890.  
  3891.  
  3892. /*******************************************************************/
  3893. /*
  3894.  -  CAdrListDlg::
  3895.  -  OnCancel
  3896.  -
  3897.  *  Purpose:
  3898.  *
  3899.  */
  3900. /*******************************************************************/
  3901.  
  3902. void CAdrListDlg::OnCancel()
  3903. {
  3904.     EndDialog(IDCANCEL);
  3905. }
  3906.  
  3907.  
  3908. /*******************************************************************/
  3909. /*
  3910.  -  CAdrListDlg::
  3911.  -  DisplayList
  3912.  -
  3913.  *  Purpose:
  3914.  *
  3915.  */
  3916. /*******************************************************************/
  3917.  
  3918. void CAdrListDlg::DisplayAdrList()
  3919. {
  3920.     char    szCVals[30];
  3921.     ULONG   cEntries        = 0;
  3922.     DWORD   dwReturn        = 0;
  3923.     char    szBuffer[1024];
  3924.     ULONG   idx;
  3925.  
  3926.     SendDlgItemMessage(IDC_ADRLIST,LB_RESETCONTENT,0,0);
  3927.  
  3928.     if( !m_lpAdrList)
  3929.     {
  3930.         // DISPLAY Expected lpPTA->cValues
  3931.         wsprintf(szCVals,"cEntries:  %lu",0);
  3932.         SetDlgItemText(IDT_CENTRIES,szCVals);
  3933.  
  3934.         return;
  3935.     }
  3936.     if(m_lpAdrList->cEntries)
  3937.     {
  3938.         // DISPLAY Expected lpPTA->cValues
  3939.         wsprintf(szCVals,"cEntries:  %lu",m_lpAdrList->cEntries);
  3940.         SetDlgItemText(IDT_CENTRIES,szCVals);
  3941.  
  3942.         // find out which row has the Default Status and open it
  3943.         for(cEntries = 0; cEntries < m_lpAdrList->cEntries; cEntries++)
  3944.         {
  3945.             wsprintf(szBuffer,"lpAdrList->aEntries[%lu].ulReserved1 = %lu",
  3946.                     cEntries,m_lpAdrList->aEntries[cEntries].ulReserved1 );
  3947.  
  3948.             dwReturn = SendDlgItemMessage(IDC_ADRLIST,LB_ADDSTRING,0,
  3949.                         (LPARAM)szBuffer);
  3950.  
  3951.             wsprintf(szBuffer,"lpAdrList->aEntries[%lu].cValues = %lu",
  3952.                     cEntries,m_lpAdrList->aEntries[cEntries].cValues );
  3953.  
  3954.             dwReturn = SendDlgItemMessage(IDC_ADRLIST,LB_ADDSTRING,0,
  3955.                         (LPARAM)szBuffer);
  3956.  
  3957.             for( idx = 0 ; idx < m_lpAdrList->aEntries[cEntries].cValues ; idx++)
  3958.             {
  3959.                 SzTextizeProp(szBuffer, &(m_lpAdrList->aEntries[cEntries].rgPropVals[idx]));
  3960.  
  3961.                 dwReturn = SendDlgItemMessage(IDC_ADRLIST,LB_ADDSTRING,0,
  3962.                         (LPARAM)szBuffer);
  3963.             }
  3964.         }
  3965.     }
  3966. }
  3967.  
  3968.  
  3969. /*******************************************************************/
  3970. /**************************** PROP_DISPLAY **************************/
  3971.  
  3972.  
  3973.  
  3974. /********************************************************************/
  3975. /*
  3976.  -  CPropDisplayDlg::
  3977.  -  OnInitDialog
  3978.  -
  3979.  *  Purpose:
  3980.  *
  3981.  */
  3982. /********************************************************************/
  3983.  
  3984. BOOL CPropDisplayDlg::OnInitDialog()
  3985. {
  3986.     DWORD           dwReturn = 0;
  3987.     int             rgTabStops[4];
  3988.  
  3989.     SetWindowText( m_List.GetBuffer(30) );
  3990.  
  3991.     // set size of horizontal scroll and tab stops in prop view listbox
  3992.     dwReturn = SendDlgItemMessage(IDC_PROP_DISPLAY,LB_SETHORIZONTALEXTENT,
  3993.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  3994.  
  3995.     rgTabStops[0] = PROP_LISTBOX_TAB1_SIZE ;
  3996.     rgTabStops[1] = PROP_LISTBOX_TAB2_SIZE ;
  3997.  
  3998.     dwReturn = SendDlgItemMessage(IDC_PROP_DISPLAY,LB_SETTABSTOPS,
  3999.                     (WPARAM) 2,(LPARAM)rgTabStops );
  4000.  
  4001.     DisplayProps();
  4002.  
  4003.     return TRUE;
  4004. }
  4005.  
  4006.  
  4007. /*******************************************************************/
  4008. /*
  4009.  -  CPropDisplayDlg::
  4010.  -  ~CPropDisplayDlg
  4011.  -
  4012.  *  Purpose:
  4013.  *      Destructor for class CPropDisplayDlg. Releases and Frees memory
  4014.  *      allocated in this class
  4015.  *
  4016.  */
  4017. /*******************************************************************/
  4018.  
  4019. CPropDisplayDlg::~CPropDisplayDlg()
  4020. {
  4021.  
  4022. }
  4023.  
  4024.  
  4025. /*******************************************************************/
  4026. /*
  4027.  -  CPropDisplayDlg::
  4028.  -  OnCancel
  4029.  -
  4030.  *  Purpose:
  4031.  *
  4032.  */
  4033. /*******************************************************************/
  4034.  
  4035. void CPropDisplayDlg::OnCancel()
  4036. {
  4037.     EndDialog(IDCANCEL);
  4038. }
  4039.  
  4040.  
  4041. /*******************************************************************/
  4042. /*
  4043.  -  CPropDisplayDlg::
  4044.  -  DisplayProps
  4045.  -
  4046.  *  Purpose:
  4047.  *
  4048.  */
  4049. /*******************************************************************/
  4050.  
  4051. void CPropDisplayDlg::DisplayProps()
  4052. {
  4053.     ULONG   idx         = 0;
  4054.     DWORD   dwReturn    = 0;
  4055.     char    szBuffer[256];
  4056.     char    szID[50];
  4057.     char    szData[512];
  4058.     char    szType[32];      // Assumes no PropType string longer than 31 chars
  4059.  
  4060.  
  4061.     SendDlgItemMessage(IDC_PROP_DISPLAY,LB_RESETCONTENT,0,0);
  4062.  
  4063.     if( (!m_lpEntryID) && (!m_lpspva) )
  4064.         return;
  4065.  
  4066.     if(m_lpEntryID)
  4067.     {
  4068.         wsprintf(szBuffer,"cbEntryID: %lu",m_ulValues);
  4069.         SetDlgItemText(IDT_PROP_DISPLAY_CVALS,szBuffer);
  4070.         SetDlgItemText(IDT_PROP_DISPLAY,"LPENTRYID:");
  4071.  
  4072.         // print out entryid
  4073.         char    lpszHex[9];
  4074.         ULONG   cb      = 0;
  4075.         ULONG   cChars  = 0;
  4076.         LPBYTE  lpb     = (LPBYTE)m_lpEntryID;
  4077.  
  4078.         szBuffer[0] = '\0';
  4079.  
  4080.         while( (cb < m_ulValues) && (cChars < 255 -16 ) )
  4081.         {
  4082.             wsprintf(lpszHex, "%02X ", *lpb);
  4083.             lstrcat(szBuffer, lpszHex);
  4084.             cChars += 3;
  4085.             lpb++;
  4086.             cb++;
  4087.         }
  4088.  
  4089.         dwReturn = SendDlgItemMessage(IDC_PROP_DISPLAY,LB_ADDSTRING,0,
  4090.                     (LPARAM)szBuffer);
  4091.     }
  4092.     else    // else print out lpspva
  4093.     {
  4094.  
  4095.         wsprintf(szBuffer,"cValues:  %lu",m_ulValues);
  4096.         SetDlgItemText(IDT_PROP_DISPLAY_CVALS,szBuffer);
  4097.  
  4098.         // determine if string, hex, or decimal and build row of listbox
  4099.         for(idx = 0; idx < m_ulValues; idx++)
  4100.         {
  4101.             szID[0]     = '\0' ;
  4102.             szData[0]   = '\0' ;
  4103.             szType[0]   = '\0' ;
  4104.             szBuffer[0] = '\0' ;
  4105.  
  4106.  
  4107.             if(GetString("PropIDs", PROP_ID(m_lpspva[idx].ulPropTag), szID ) )
  4108.             {
  4109.                 lstrcat(szBuffer, szID );
  4110.                 lstrcat(szBuffer, "\t");
  4111.             }
  4112.             else
  4113.             {
  4114.                 wsprintf(szBuffer,"%#04X\t", PROP_ID(m_lpspva[idx].ulPropTag) );
  4115.             }
  4116.  
  4117.  
  4118.             if( GetString("PropType", PROP_TYPE(m_lpspva[idx].ulPropTag), szType) )
  4119.             {
  4120.                 lstrcat(szBuffer, szType);
  4121.                 lstrcat(szBuffer,"\t");
  4122.             }
  4123.             else
  4124.             {
  4125.                 wsprintf(szType,"%#04X\t", PROP_TYPE(m_lpspva[idx].ulPropTag) );
  4126.                 lstrcat(szBuffer,szType);
  4127.  
  4128.             }
  4129.  
  4130.             SzGetPropValue(szData,(LPSPropValue) &m_lpspva[idx]);
  4131.             lstrcat(szBuffer,szData);
  4132.  
  4133.             dwReturn = SendDlgItemMessage(IDC_PROP_DISPLAY,LB_ADDSTRING,0,
  4134.                         (LPARAM)szBuffer);
  4135.         }
  4136.     }
  4137. }
  4138.  
  4139.  
  4140. /*******************************************************************/
  4141. /*
  4142.  -  CNotificationDlg::
  4143.  -  DisplayNotif
  4144.  -
  4145.  *  Purpose:
  4146.  *
  4147.  */
  4148. /*******************************************************************/
  4149. /*******************************************************************/
  4150. /*******************************************************************/
  4151.  
  4152. /*******************************************************************/
  4153. /*
  4154.  -  LogNotifToXVPLog CALLBACK
  4155.  -
  4156.  *  Purpose:
  4157.  *
  4158.  */
  4159. /*******************************************************************/
  4160.  
  4161. #ifdef XVPORT
  4162.  
  4163. SCODE STDAPICALLTYPE LogNotifToXVPLog(  LPVOID          lpvContext,
  4164.                                         ULONG           cNotif,
  4165.                                         LPNOTIFICATION  lpNotif)
  4166. {
  4167.  
  4168.  
  4169.     ULONG   idx         = 0;
  4170.     char    szBuffer[1024];
  4171.     char    szBuff1[1024];
  4172.     LPBYTE  lpb;
  4173.     char    lpszHex[9];
  4174.     ULONG   cb          = 0;
  4175.     ULONG   cChars      = 0;
  4176.     UINT    bFlags      = 0;
  4177.     ULONG   i;
  4178.  
  4179.     wsprintf(szBuffer,"NOTIFICATION #%lu : %s",
  4180.                         (ULONG) ( (LPNOTIFCONTEXT)lpvContext)->ulCount,
  4181.                         (char *)( (LPNOTIFCONTEXT)lpvContext)->szComment);
  4182.  
  4183.  
  4184.     XVPLog(xvpNum,0,szBuffer);
  4185.  
  4186.     wsprintf(szBuffer,"cNotification:       == %lu",cNotif);
  4187.     XVPLog(xvpNum,1,szBuffer);
  4188.  
  4189.     if( !lpNotif )
  4190.         return 1;
  4191.  
  4192.  
  4193.     ((LPNOTIFCONTEXT)lpvContext)->ulCount++;
  4194.     wsprintf(szBuffer,"lpvContext:          == 0x%08X, Count == %lu Comment == %s", lpvContext,
  4195.                         (ULONG) ( (LPNOTIFCONTEXT)lpvContext)->ulCount,
  4196.                         (char *)( (LPNOTIFCONTEXT)lpvContext)->szComment);
  4197.  
  4198.     XVPLog(xvpNum,1,szBuffer);
  4199.  
  4200.     for( idx = 0 ; idx < cNotif ; idx++)
  4201.     {
  4202.  
  4203.         wsprintf(szBuffer,"lpNotif[%lu]         == 0x%08X",idx,lpNotif );
  4204.         XVPLog(xvpNum,1,szBuffer);
  4205.  
  4206.         GetString("NotifEvents",lpNotif[idx].ulEventType, szBuff1);
  4207.         wsprintf(szBuffer,"lpNotif[%lu].ulEventType                == %lu, %s",idx,
  4208.                 lpNotif[idx].ulEventType,
  4209.                 szBuff1);
  4210.         XVPLog(xvpNum,2,szBuffer);
  4211.  
  4212.         switch(lpNotif[idx].ulEventType)
  4213.         {
  4214.             case fnevTableModified:
  4215.                 GetString("TableEvents",lpNotif[idx].info.tab.ulTableEvent, szBuff1);
  4216.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.ulTableEvent    == %lu, %s",idx,
  4217.                             lpNotif[idx].info.tab.ulTableEvent,
  4218.                             szBuff1);
  4219.                 XVPLog(xvpNum,2,szBuffer);
  4220.  
  4221.                 GetString("MAPIErrors", GetScode(lpNotif[idx].info.tab.hResult), szBuff1 );
  4222.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.hResult           == 0x%08X, %s",idx,
  4223.                             lpNotif[idx].info.tab.hResult,
  4224.                             szBuff1);
  4225.                 XVPLog(xvpNum,2,szBuffer);
  4226.  
  4227.                 SzTextizeProp((LPSTR)szBuff1, &(lpNotif[idx].info.tab.propIndex));
  4228.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.propIndex        == %s", idx, szBuff1);
  4229.                 XVPLog(xvpNum,2,szBuffer);
  4230.  
  4231.  
  4232.                 SzTextizeProp((LPSTR)szBuff1, &(lpNotif[idx].info.tab.propPrior));
  4233.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.propPrior         == %s", idx, szBuff1);
  4234.                 XVPLog(xvpNum,2,szBuffer);
  4235.  
  4236.  
  4237.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.row.ulAdrEntryPad == %lu",idx,
  4238.                                 lpNotif[idx].info.tab.row.ulAdrEntryPad);
  4239.                 XVPLog(xvpNum,2,szBuffer);
  4240.  
  4241.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.row.cValues     == %lu",idx,
  4242.                                 lpNotif[idx].info.tab.row.cValues);
  4243.                 XVPLog(xvpNum,2,szBuffer);
  4244.  
  4245.                 wsprintf(szBuffer,"lpNotif[%lu].info.tab.row.lpProps      == 0x%08X",idx,
  4246.                                 lpNotif[idx].info.tab.row.lpProps);
  4247.                 XVPLog(xvpNum,2,szBuffer);
  4248.  
  4249.                 if(lpNotif[idx].info.tab.row.lpProps)
  4250.                 {
  4251.                     for(i = 0; i < lpNotif[idx].info.tab.row.cValues ; i++)
  4252.                     {
  4253.  
  4254.                         SzTextizeProp(szBuff1, &lpNotif[idx].info.tab.row.lpProps[i] );
  4255.                         wsprintf(szBuffer,"lpNotif[%lu].info.tab.row.lpProps[%lu]  == %s",idx,i,szBuff1);
  4256.                         XVPLog(xvpNum,2,szBuffer);
  4257.                     }
  4258.                 }
  4259.  
  4260.                 break;
  4261.  
  4262.             case fnevCriticalError:
  4263.                 wsprintf(szBuffer,"lpNotif[%lu].info.err.cbEntryID         == %lu",idx,
  4264.                                 lpNotif[idx].info.err.cbEntryID);
  4265.                 XVPLog(xvpNum,2,szBuffer);
  4266.                 wsprintf(szBuffer,"lpNotif[%lu].info.err.lpEntryID         == 0x%08X",idx,
  4267.                                 lpNotif[idx].info.err.lpEntryID);
  4268.                 XVPLog(xvpNum,2,szBuffer);
  4269.  
  4270.  
  4271.                 if(lpNotif[idx].info.err.lpEntryID)
  4272.                 {
  4273.                     bFlags = (UINT)lpNotif[idx].info.err.lpEntryID->abFlags[0];         // might need to consider abFlags[1-3]
  4274.                     wsprintf(szBuffer,"lpNotif[%lu].info.err.lpEntryID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4275.                         bFlags,
  4276.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4277.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4278.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4279.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4280.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4281.                     XVPLog(xvpNum,2,szBuffer);
  4282.  
  4283.                     SzGetEntryID(szBuff1,lpNotif[idx].info.err.lpEntryID,lpNotif[idx].info.err.cbEntryID);
  4284.                     wsprintf(szBuffer,"lpNotif[%lu].info.err.lpEntryID         == %s",idx,szBuff1);
  4285.                     XVPLog(xvpNum,2,szBuffer);
  4286.                 }
  4287.  
  4288.                 GetString("MAPIErrors",lpNotif[idx].info.err.scode , szBuff1 );
  4289.                 wsprintf(szBuffer,"lpNotif[%lu].info.err,scode             == 0x%08X, %s",idx,
  4290.                             lpNotif[idx].info.err.scode,
  4291.                             szBuff1);
  4292.                 XVPLog(xvpNum,2,szBuffer);
  4293.  
  4294.                 wsprintf(szBuffer,"lpNotif[%lu].info.err.ulFlags           == %lu",idx,
  4295.                                 lpNotif[idx].info.err.ulFlags);
  4296.                 XVPLog(xvpNum,2,szBuffer);
  4297.  
  4298.                 wsprintf(szBuffer,"lpNotif[%lu].info.err.lpMAPIError->lpszError         == %s",idx,
  4299.                                 lpNotif[idx].info.err.lpMAPIError->lpszError);
  4300.                 XVPLog(xvpNum,2,szBuffer);
  4301.                 break;
  4302.  
  4303.             case fnevNewMail:
  4304.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.cbEntryID     == %lu",idx,
  4305.                                 lpNotif[idx].info.newmail.cbEntryID);
  4306.                 XVPLog(xvpNum,2,szBuffer);
  4307.  
  4308.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpEntryID     == 0x%08X",idx,
  4309.                                 lpNotif[idx].info.newmail.lpEntryID);
  4310.                 XVPLog(xvpNum,2,szBuffer);
  4311.  
  4312.  
  4313.                 if(lpNotif[idx].info.newmail.lpEntryID)
  4314.                 {
  4315.                     bFlags = (UINT)lpNotif[idx].info.newmail.lpEntryID->abFlags[0];         // might need to consider abFlags[1-3]
  4316.                     wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpEntryID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4317.                         bFlags,
  4318.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4319.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4320.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4321.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4322.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4323.                     XVPLog(xvpNum,2,szBuffer);
  4324.  
  4325.                     SzGetEntryID(szBuff1,
  4326.                                     lpNotif[idx].info.newmail.lpEntryID,
  4327.                                     lpNotif[idx].info.newmail.cbEntryID);
  4328.  
  4329.                     wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpEntryID     == %s", idx, szBuff1);
  4330.                     XVPLog(xvpNum,2,szBuffer);
  4331.                 }
  4332.  
  4333.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.cbParentID    == %lu",idx,
  4334.                                 lpNotif[idx].info.newmail.cbParentID);
  4335.                 XVPLog(xvpNum,2,szBuffer);
  4336.  
  4337.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpParentID    == 0x%08X",idx,
  4338.                                 lpNotif[idx].info.newmail.lpParentID);
  4339.                 XVPLog(xvpNum,2,szBuffer);
  4340.  
  4341.  
  4342.                 if(lpNotif[idx].info.newmail.lpParentID)
  4343.                 {
  4344.                     bFlags = (UINT)lpNotif[idx].info.newmail.lpParentID->abFlags[0];         // might need to consider abFlags[1-3]
  4345.                     wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpParentID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4346.                         bFlags,
  4347.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4348.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4349.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4350.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4351.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4352.                     XVPLog(xvpNum,2,szBuffer);
  4353.  
  4354.  
  4355.  
  4356.                     SzGetEntryID(szBuff1,lpNotif[idx].info.newmail.lpParentID,lpNotif[idx].info.newmail.cbParentID);
  4357.                     wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpParentID    == %s",idx,szBuff1);
  4358.                     XVPLog(xvpNum,2,szBuffer);
  4359.                 }
  4360.  
  4361.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.ulFlags       == %lu",idx,
  4362.                                 lpNotif[idx].info.newmail.ulFlags);
  4363.                 XVPLog(xvpNum,2,szBuffer);
  4364.  
  4365.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.lpszMessageClass == %s",idx,
  4366.                                 lpNotif[idx].info.newmail.lpszMessageClass);
  4367.                 XVPLog(xvpNum,2,szBuffer);
  4368.  
  4369.                 wsprintf(szBuffer,"lpNotif[%lu].info.newmail.ulMessageFlags   == %lu",idx,
  4370.                                 lpNotif[idx].info.newmail.ulMessageFlags);
  4371.                 XVPLog(xvpNum,2,szBuffer);
  4372.                 break;
  4373.  
  4374.             case fnevObjectCreated:
  4375.             case fnevObjectDeleted:
  4376.             case fnevObjectModified:
  4377.             case fnevObjectMoved:
  4378.             case fnevObjectCopied:
  4379.             case fnevSearchComplete:
  4380.  
  4381.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.cbEntryID         == %lu",idx,
  4382.                                 lpNotif[idx].info.obj.cbEntryID);
  4383.                 XVPLog(xvpNum,2,szBuffer);
  4384.  
  4385.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpEntryID         == 0x%08X",idx,
  4386.                                 lpNotif[idx].info.obj.lpEntryID);
  4387.                 XVPLog(xvpNum,2,szBuffer);
  4388.  
  4389.  
  4390.                 if(lpNotif[idx].info.obj.lpEntryID)
  4391.                 {
  4392.                     bFlags = (UINT)lpNotif[idx].info.obj.lpEntryID->abFlags[0];         // might need to consider abFlags[1-3]
  4393.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpEntryID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4394.                         bFlags,
  4395.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4396.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4397.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4398.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4399.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4400.                     XVPLog(xvpNum,2,szBuffer);
  4401.  
  4402.                     SzGetEntryID(szBuff1,lpNotif[idx].info.obj.lpEntryID,lpNotif[idx].info.obj.cbEntryID);
  4403.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpEntryID         == %s",idx,szBuff1);
  4404.                     XVPLog(xvpNum,2,szBuffer);
  4405.                 }
  4406.  
  4407.  
  4408.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.cbParentID        == %lu",idx,
  4409.                                 lpNotif[idx].info.obj.cbParentID);
  4410.                 XVPLog(xvpNum,2,szBuffer);
  4411.  
  4412.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpParentID        == 0x%08X",idx,
  4413.                                 lpNotif[idx].info.obj.lpParentID);
  4414.                 XVPLog(xvpNum,2,szBuffer);
  4415.  
  4416.  
  4417.                 if(lpNotif[idx].info.obj.lpParentID)
  4418.                 {
  4419.                     bFlags = (UINT)lpNotif[idx].info.obj.lpParentID->abFlags[0];         // might need to consider abFlags[1-3]
  4420.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpParentID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4421.                         bFlags,
  4422.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4423.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4424.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4425.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4426.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4427.                     XVPLog(xvpNum,2,szBuffer);
  4428.  
  4429.  
  4430.  
  4431.                     SzGetEntryID(szBuff1,lpNotif[idx].info.obj.lpParentID,lpNotif[idx].info.obj.cbParentID);
  4432.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpParentID        == %s",idx,szBuff1);
  4433.                     XVPLog(xvpNum,2,szBuffer);
  4434.                 }
  4435.  
  4436.  
  4437.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.cbOldID           == %lu",idx,
  4438.                                 lpNotif[idx].info.obj.cbOldID);
  4439.                 XVPLog(xvpNum,2,szBuffer);
  4440.  
  4441.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldID           == 0x%08X",idx,
  4442.                                 lpNotif[idx].info.obj.lpOldID);
  4443.                 XVPLog(xvpNum,2,szBuffer);
  4444.  
  4445.  
  4446.                 if(lpNotif[idx].info.obj.lpOldID)
  4447.                 {
  4448.                     bFlags = (UINT)lpNotif[idx].info.obj.lpOldID->abFlags[0];         // might need to consider abFlags[1-3]
  4449.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4450.                         bFlags,
  4451.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4452.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4453.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4454.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4455.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4456.                     XVPLog(xvpNum,2,szBuffer);
  4457.  
  4458.                     SzGetEntryID(szBuff1,lpNotif[idx].info.obj.lpOldID,lpNotif[idx].info.obj.cbOldID);
  4459.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldID           == %s",idx,szBuff1);
  4460.                     XVPLog(xvpNum,2,szBuffer);
  4461.                 }
  4462.  
  4463.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.cbOldParentID     == %lu",idx,
  4464.                                 lpNotif[idx].info.obj.cbOldParentID);
  4465.                 XVPLog(xvpNum,2,szBuffer);
  4466.  
  4467.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldParentID     == 0x%08X",idx,
  4468.                                 lpNotif[idx].info.obj.lpOldParentID);
  4469.                 XVPLog(xvpNum,2,szBuffer);
  4470.  
  4471.  
  4472.                 if(lpNotif[idx].info.obj.lpOldParentID)
  4473.                 {
  4474.                     bFlags = (UINT)lpNotif[idx].info.obj.lpOldParentID->abFlags[0];         // might need to consider abFlags[1-3]
  4475.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldParentID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4476.                         bFlags,
  4477.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4478.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4479.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4480.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4481.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4482.                     XVPLog(xvpNum,2,szBuffer);
  4483.  
  4484.                     SzGetEntryID(szBuff1,lpNotif[idx].info.obj.lpOldParentID,lpNotif[idx].info.obj.cbOldParentID);
  4485.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpOldParentID     == %s",idx,szBuff1);
  4486.                     XVPLog(xvpNum,2,szBuffer);
  4487.                 }
  4488.  
  4489.  
  4490.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.ulObjType         == %lu",idx,
  4491.                                 lpNotif[idx].info.obj.ulObjType);
  4492.                 XVPLog(xvpNum,2,szBuffer);
  4493.  
  4494.  
  4495.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpPropTagArray    == 0x%08X",idx,
  4496.                             lpNotif[idx].info.obj.lpPropTagArray);
  4497.                 XVPLog(xvpNum,2,szBuffer);
  4498.  
  4499.                 wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpPropTagArray    == 0x%08X",idx,
  4500.                         lpNotif[idx].info.obj.lpPropTagArray);
  4501.                 XVPLog(xvpNum,2,szBuffer);
  4502.  
  4503.                 if(lpNotif[idx].info.obj.lpPropTagArray)
  4504.                 {
  4505.  
  4506.                     wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpPropTagArray->cValues == %lu",idx,
  4507.                             lpNotif[idx].info.obj.lpPropTagArray->cValues);
  4508.                     XVPLog(xvpNum,2,szBuffer);
  4509.                     for(i = 0 ; i < lpNotif[idx].info.obj.lpPropTagArray->cValues ; i++)
  4510.                     {
  4511.                         SzGetPropTag(szBuff1, lpNotif[idx].info.obj.lpPropTagArray->aulPropTag[i] );
  4512.                         wsprintf(szBuffer,"lpNotif[%lu].info.obj.lpPropTagArray->aulPropTag[%lu] == %s",
  4513.                                     idx,i,szBuff1);
  4514.                         XVPLog(xvpNum,2,szBuffer);
  4515.                     }
  4516.                 }
  4517.  
  4518.                 break;
  4519.  
  4520.             case fnevExtended:
  4521.  
  4522.                 wsprintf(szBuffer,"lpNotif[%lu].info.ext.ulEvent           == %lu",idx,
  4523.                                 lpNotif[idx].info.ext.ulEvent);
  4524.                 XVPLog(xvpNum,2,szBuffer);
  4525.  
  4526.                 wsprintf(szBuffer,"lpNotif[%lu].info.ext.cb                == %lu",idx,
  4527.                                 lpNotif[idx].info.ext.cb);
  4528.                 XVPLog(xvpNum,2,szBuffer);
  4529.  
  4530.                 lpb = lpNotif[idx].info.ext.pbEventParameters;
  4531.                 wsprintf(szBuff1, "cb: %3lu   *lpNotif[%lu].info.ext.pbEventParameters: ",
  4532.                             lpNotif[idx].info.ext.cb, idx);
  4533.                 cChars += strlen(szBuff1);
  4534.  
  4535.                 while((cb < lpNotif[idx].info.ext.cb) && (cChars < (255 - 16) ) )
  4536.                 {
  4537.                     wsprintf(lpszHex, "%02X ", *lpb);
  4538.                     lstrcat(szBuff1, lpszHex);
  4539.                     cChars += 3;
  4540.                     lpb++;
  4541.                     cb++;
  4542.                 }
  4543.  
  4544.                 if( ((lpNotif[idx].info.ext.cb)*3) >  (255 - 16) )
  4545.                 {
  4546.                     lstrcat(szBuff1, " ...");
  4547.                 }
  4548.                 XVPLog(xvpNum,2,szBuffer);
  4549.                 break;
  4550.  
  4551.             case fnevStatusObjectModified:
  4552.  
  4553.                 wsprintf(szBuffer,"lpNotif[%lu].info.statobj.cbEntryID     == %lu",idx,
  4554.                                 lpNotif[idx].info.statobj.cbEntryID);
  4555.                 XVPLog(xvpNum,2,szBuffer);
  4556.  
  4557.                 wsprintf(szBuffer,"lpNotif[%lu].info.statobj.lpEntryID     == 0x%08X",idx,
  4558.                                 lpNotif[idx].info.statobj.lpEntryID);
  4559.                 XVPLog(xvpNum,2,szBuffer);
  4560.  
  4561.  
  4562.                 if(lpNotif[idx].info.statobj.lpEntryID)
  4563.                 {
  4564.                     bFlags = (UINT)lpNotif[idx].info.statobj.lpEntryID->abFlags[0];         // might need to consider abFlags[1-3]
  4565.                     wsprintf(szBuffer,"lpNotif[%lu].info.statobj.lpEntryID->abFlags[0] == %d,  %s%s%s%s%s",idx,
  4566.                         bFlags,
  4567.                       ((bFlags & MAPI_SHORTTERM)        ? "MAPI_SHORTTERM | "   : ""),
  4568.                       ((bFlags & MAPI_NOTRECIP)         ? "MAPI_NOTRECIP | "    : ""),
  4569.                       ((bFlags & MAPI_THISSESSION)      ? "MAPI_THISSESSION | " : ""),
  4570.                       ((bFlags & MAPI_NOW)              ? "MAPI_NOW | "         : ""),
  4571.                       ((bFlags & MAPI_NOTRESERVED)      ? "MAPI_NOTRESERVED "   : "0"));
  4572.                     XVPLog(xvpNum,2,szBuffer);
  4573.  
  4574.                     SzGetEntryID(szBuff1,lpNotif[idx].info.statobj.lpEntryID,lpNotif[idx].info.statobj.cbEntryID);
  4575.                     wsprintf(szBuffer,"lpNotif[%lu].info.statobj.lpEntryID     == %s",idx,szBuff1);
  4576.                     XVPLog(xvpNum,2,szBuffer);
  4577.                 }
  4578.  
  4579.                 wsprintf(szBuffer,"lpNotif[%lu].info.statobj.cValues       == %lu",idx,
  4580.                                 lpNotif[idx].info.statobj.cValues);
  4581.                 XVPLog(xvpNum,2,szBuffer);
  4582.  
  4583.                 if(lpNotif[idx].info.statobj.lpPropVals)
  4584.                 {
  4585.                     for(i = 0; i < lpNotif[idx].info.statobj.cValues ; i++)
  4586.                     {
  4587.  
  4588.                         SzTextizeProp(szBuff1, &lpNotif[idx].info.statobj.lpPropVals[i] );
  4589.                         wsprintf(szBuffer,"lpNotif[%lu].info.statobj.lpPropVals[%lu] == %s",idx,i,szBuff1);
  4590.                         XVPLog(xvpNum,2,szBuffer);
  4591.                     }
  4592.                 }
  4593.  
  4594.                 break;
  4595.  
  4596.             case fnevReservedForMapi:
  4597.  
  4598.                 wsprintf(szBuffer,"fnevReservedForMapi, You should not be here ");
  4599.                 XVPLog(xvpNum,2,szBuffer);
  4600.                 break;
  4601.  
  4602.             default:
  4603.                 wsprintf(szBuffer,"lpNotif[%lu].ulEventType UNRECOGNIZED", idx);
  4604.                 XVPLog(xvpNum,2,szBuffer);
  4605.                 break;
  4606.         } // end switch
  4607.  
  4608.     }  // end of for loop
  4609.  
  4610.     return(0);
  4611. }
  4612.  
  4613. #endif
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619. /********************************************************************/
  4620. /********************************************************************/
  4621.  
  4622. //#ifdef XVPORT
  4623. /******************* Notif Message Map ****************************/
  4624.  
  4625. BEGIN_MESSAGE_MAP(CNotifDlg, CDialog)
  4626.  
  4627.     ON_COMMAND(     IDC_N_NEWADVISE,    OnNewAdvise)
  4628.     ON_COMMAND(     IDC_N_UNADVISE,     OnUnadvise)
  4629.  
  4630. END_MESSAGE_MAP()
  4631.  
  4632.  
  4633. /********************************************************************/
  4634. /*
  4635.  -  CNotifDlg::
  4636.  -  OnInitDialog
  4637.  -
  4638.  *  Purpose:
  4639.  *
  4640.  */
  4641. /********************************************************************/
  4642.  
  4643. BOOL CNotifDlg::OnInitDialog()
  4644. {
  4645.     DWORD           dwReturn = 0;
  4646.     int             rgTabStops[4];
  4647.  
  4648.     SetWindowText( m_Description.GetBuffer(40) );
  4649.  
  4650.     // set size of horizontal scroll and tab stops in prop view listbox
  4651.     dwReturn = SendDlgItemMessage(IDC_N_DISPLAY,LB_SETHORIZONTALEXTENT,
  4652.                     (WPARAM) PROP_LISTBOX_HORIZONTAL_SIZE ,0 );
  4653.  
  4654.     rgTabStops[0] = 50  ;
  4655.     rgTabStops[1] = 100 ;
  4656.  
  4657.     dwReturn = SendDlgItemMessage(IDC_N_DISPLAY,LB_SETTABSTOPS,
  4658.                     (WPARAM) 2,(LPARAM)rgTabStops );
  4659.  
  4660.     Display();
  4661.  
  4662.     return TRUE;
  4663. }
  4664.  
  4665. /*******************************************************************/
  4666. /*
  4667.  -  CNotifDlg::
  4668.  -  ~CNotifDlg
  4669.  -
  4670.  *  Purpose:
  4671.  *      Destructor for class CNotifDlg. Releases and Frees memory
  4672.  *      allocated in this class
  4673.  *
  4674.  */
  4675. /*******************************************************************/
  4676.  
  4677. CNotifDlg::~CNotifDlg()
  4678. {
  4679.  
  4680. }
  4681.  
  4682. /*******************************************************************/
  4683. /*
  4684.  -  CNotifDlg::
  4685.  -  OnCancel
  4686.  -
  4687.  *  Purpose:
  4688.  *
  4689.  */
  4690. /*******************************************************************/
  4691.  
  4692.  
  4693. void CNotifDlg::OnUnadvise()
  4694. {
  4695.     HRESULT     hResult     = hrSuccess;
  4696.     LONG        lSelection  = -1;
  4697.     CGetError   E;
  4698.  
  4699.  
  4700.     if( (lSelection = SendDlgItemMessage(IDC_N_DISPLAY,LB_GETCURSEL,0,0 )) < 0 )
  4701.     {
  4702.         MessageBox("Select Connection to Unadvise", "OnUnadvise", MBS_ERROR );
  4703.         return;
  4704.     }
  4705.  
  4706.     switch(m_ulObjType)
  4707.     {
  4708.         case MAPI_STORE:
  4709.             hResult = ((LPMDB)m_lpUnk)->Unadvise(
  4710.                 (*m_lppNotifs)->Connect[lSelection].ulConnection);
  4711.             break;
  4712.         case MAPI_TABLE:  // defined in mdbview.h
  4713.             hResult = ((LPMAPITABLE)m_lpUnk)->Unadvise(
  4714.                 (*m_lppNotifs)->Connect[lSelection].ulConnection);
  4715.             break;
  4716.         case MAPI_SESSION:
  4717.         case MAPI_STATUS:
  4718.             hResult = ((LPMAPISESSION)m_lpUnk)->Unadvise(
  4719.                 (*m_lppNotifs)->Connect[lSelection].ulConnection);
  4720.             break;
  4721.         case MAPI_ADDRBOOK:
  4722.             hResult = ((LPADRBOOK)m_lpUnk)->Unadvise(
  4723.                 (*m_lppNotifs)->Connect[lSelection].ulConnection);
  4724.             break;
  4725.         default:
  4726.             MessageBox("UNKNOWN Obj Type", "OnUnadvise", MBS_ERROR );
  4727.             break;
  4728.     }
  4729.     if( HR_FAILED(hResult ) )
  4730.         MessageBox( E.SzError("lpObj->Unadvise()", hResult), "Client", MBS_ERROR );
  4731.  
  4732.     // removed from mapi, now remove from my list LPNOTIFS
  4733.     (*m_lppNotifs)->Connect[lSelection].ulConnection =
  4734.               (*m_lppNotifs)->Connect[(*m_lppNotifs)->cConnect -1].ulConnection;
  4735.  
  4736.     lstrcpy((*m_lppNotifs)->Connect[lSelection].szContext,
  4737.              (*m_lppNotifs)->Connect[(*m_lppNotifs)->cConnect -1].szContext);
  4738.  
  4739.     (*m_lppNotifs)->cConnect--;
  4740.  
  4741.     Display();
  4742. }
  4743.  
  4744. /*******************************************************************/
  4745. /*
  4746.  -  CNotifDlg::
  4747.  -  OnCancel
  4748.  -
  4749.  *  Purpose:
  4750.  *
  4751.  */
  4752. /*******************************************************************/
  4753.  
  4754.  
  4755. void CNotifDlg::OnNewAdvise()
  4756. {
  4757. #ifdef XVPORT
  4758.     CAdviseNotifDlg     NewAdvise(this);
  4759.  
  4760.     NewAdvise.m_Description     = "New Advise";
  4761.     NewAdvise.m_lppNotifs       = m_lppNotifs;
  4762.     NewAdvise.m_lpUnk           = m_lpUnk;
  4763.     NewAdvise.m_ulObjType       = m_ulObjType;
  4764.  
  4765.     NewAdvise.DoModal();
  4766.  
  4767.     Display();
  4768. #endif
  4769. }
  4770.  
  4771. /*******************************************************************/
  4772. /*
  4773.  -  CNotifDlg::
  4774.  -  DisplayNotif
  4775.  -
  4776.  *  Purpose:
  4777.  *
  4778.  */
  4779. /*******************************************************************/
  4780.  
  4781. void CNotifDlg::Display()
  4782. {
  4783.     ULONG       idx;
  4784.     char        szBuffer[256];
  4785.     DWORD       dwReturn    = 0;
  4786.  
  4787.     if( (!m_lppNotifs) || (!(*m_lppNotifs)) )
  4788.         return;
  4789.  
  4790.     SendDlgItemMessage(IDC_N_DISPLAY,LB_RESETCONTENT,0,0);
  4791.  
  4792.     // list all the connections currently registered
  4793.     for(idx = 0 ; idx < (*m_lppNotifs)->cConnect ; idx++)
  4794.     {
  4795.         wsprintf(szBuffer,"%lu\t",(*m_lppNotifs)->Connect[idx].ulConnection);
  4796.         lstrcat(szBuffer, (*m_lppNotifs)->Connect[idx].szContext);
  4797.  
  4798.         dwReturn = SendDlgItemMessage(IDC_N_DISPLAY,LB_ADDSTRING,0,
  4799.                             (LPARAM)szBuffer);
  4800.     }
  4801. }
  4802.  
  4803.  
  4804. /*******************************************************************/
  4805. /*
  4806.  -  CNotifDlg::
  4807.  -  OnCancel
  4808.  -
  4809.  *  Purpose:
  4810.  *
  4811.  */
  4812. /*******************************************************************/
  4813.  
  4814. void CNotifDlg::OnCancel()
  4815. {
  4816.     EndDialog(IDCANCEL);
  4817. }
  4818.  
  4819. //#endif
  4820.  
  4821.  
  4822.  
  4823.  
  4824.  
  4825. /********************************************************************/
  4826. /********************************************************************/
  4827. /**************** ADVISE NOTIF **************************************/
  4828.  
  4829. #ifdef XVPORT
  4830.  
  4831. /********************************************************************/
  4832. /*
  4833.  -  CAdviseNotifDlg::
  4834.  -  OnInitDialog
  4835.  -
  4836.  *  Purpose:
  4837.  *
  4838.  */
  4839. /********************************************************************/
  4840.  
  4841. BOOL CAdviseNotifDlg::OnInitDialog()
  4842. {
  4843.     ULONG   ulMax   = 0;
  4844.     ULONG   idx;
  4845.     DWORD   dwRet   = 0;
  4846.     char    szBuffer[80];
  4847.  
  4848.     SetWindowText( m_Description.GetBuffer(40) );
  4849.  
  4850.     ulMax = GetRowCount("NotifEvents");
  4851.  
  4852.     for(idx = 0; idx < ulMax ; idx++)
  4853.     {
  4854.         GetRowString("NotifEvents",(LONG) idx, (LPSTR) szBuffer);
  4855.         dwRet = SendDlgItemMessage(IDC_ADVISE_EVENT1, CB_ADDSTRING,0 ,(LPARAM)szBuffer );
  4856.         dwRet = SendDlgItemMessage(IDC_ADVISE_EVENT2, CB_ADDSTRING,0 ,(LPARAM)szBuffer );
  4857.         dwRet = SendDlgItemMessage(IDC_ADVISE_EVENT3, CB_ADDSTRING,0 ,(LPARAM)szBuffer );
  4858.         dwRet = SendDlgItemMessage(IDC_ADVISE_EVENT4, CB_ADDSTRING,0 ,(LPARAM)szBuffer );
  4859.         dwRet = SendDlgItemMessage(IDC_ADVISE_EVENT5, CB_ADDSTRING,0 ,(LPARAM)szBuffer );
  4860.     }
  4861.  
  4862.     SetDlgItemText(IDC_ADVISE_CONTEXT,"Your Context string here");
  4863.  
  4864.     return TRUE;
  4865. }
  4866.  
  4867. /*******************************************************************/
  4868. /*
  4869.  -  CAdviseNotifDlg::
  4870.  -  ~CAdviseNotifDlg
  4871.  -
  4872.  *  Purpose:
  4873.  *      Destructor for class CAdviseNotifDlg. Releases and Frees memory
  4874.  *      allocated in this class
  4875.  *
  4876.  */
  4877. /*******************************************************************/
  4878.  
  4879. CAdviseNotifDlg::~CAdviseNotifDlg()
  4880. {
  4881.  
  4882. }
  4883. /*******************************************************************/
  4884. /*
  4885.  -  CAdviseNotifDlg::
  4886.  -  OnCancel
  4887.  -
  4888.  *  Purpose:
  4889.  *
  4890.  */
  4891. /*******************************************************************/
  4892.  
  4893. void CAdviseNotifDlg::OnCancel()
  4894. {
  4895.     EndDialog(IDCANCEL);
  4896. }
  4897.  
  4898. /*******************************************************************/
  4899. /*
  4900.  -  CAdviseNotifDlg::
  4901.  -  OnOK
  4902.  -
  4903.  *  Purpose:
  4904.  *
  4905.  */
  4906. /*******************************************************************/
  4907.  
  4908. void CAdviseNotifDlg::OnOK()
  4909. {
  4910.     char                szBuffer[512];
  4911.     DWORD               dRet            = 0;
  4912.     LONG                lCurSelect      = -1;
  4913.     ULONG               ulEvents        = 0;
  4914.     HRESULT             hResult         = hrSuccess;
  4915.     LPMAPIADVISESINK    lpAdviseSink    = NULL;
  4916.     LPNOTIFCONTEXT      lpContext       = NULL;
  4917.     ULONG               ulConnection    = 0;
  4918.     CGetError   E;
  4919.     LPNOTIFS            lpNotifs        = NULL;
  4920.  
  4921.  
  4922.     if( (lCurSelect = SendDlgItemMessage(IDC_ADVISE_EVENT1,CB_GETCURSEL,0,0)) >= 0 )
  4923.         ulEvents |= GetRowID("NotifEvents",lCurSelect);
  4924.  
  4925.     if( (lCurSelect = SendDlgItemMessage(IDC_ADVISE_EVENT2,CB_GETCURSEL,0,0)) >= 0 )
  4926.         ulEvents |= GetRowID("NotifEvents",lCurSelect);
  4927.  
  4928.     if( (lCurSelect = SendDlgItemMessage(IDC_ADVISE_EVENT3,CB_GETCURSEL,0,0)) >= 0 )
  4929.         ulEvents |= GetRowID("NotifEvents",lCurSelect);
  4930.  
  4931.     if( (lCurSelect = SendDlgItemMessage(IDC_ADVISE_EVENT4,CB_GETCURSEL,0,0)) >= 0 )
  4932.         ulEvents |= GetRowID("NotifEvents",lCurSelect);
  4933.  
  4934.     if( (lCurSelect = SendDlgItemMessage(IDC_ADVISE_EVENT5,CB_GETCURSEL,0,0)) >= 0 )
  4935.         ulEvents |= GetRowID("NotifEvents",lCurSelect);
  4936.  
  4937.     *(WORD *)szBuffer = sizeof(szBuffer) -1;    // first char has buffer length
  4938.     dRet = SendDlgItemMessage(IDC_ADVISE_CONTEXT,EM_GETLINE,0,(LPARAM)szBuffer);
  4939.     szBuffer[dRet] = '\0';
  4940.  
  4941.     lpContext = (LPNOTIFCONTEXT) PvAlloc(sizeof(NOTIFCONTEXT) );
  4942.     lpContext->ulCount = 0;
  4943.     lstrcpy(lpContext->szComment,szBuffer);
  4944.  
  4945.     hResult = HrAllocAdviseSink(    (LPNOTIFCALLBACK)       LogNotifToXVPLog,
  4946.                                     (LPVOID)                lpContext,
  4947.                                     (LPMAPIADVISESINK FAR *) &lpAdviseSink);
  4948.     if(HR_FAILED(hResult) )
  4949.     {
  4950.         MessageBox( E.SzError("HrAllocAdviseSink()", hResult),
  4951.                  "Client", MBS_ERROR );
  4952.         return;
  4953.     }
  4954.  
  4955.     switch(m_ulObjType)
  4956.     {
  4957.         case MAPI_STORE:
  4958.             hResult = ((LPMDB)m_lpUnk)->Advise(
  4959.                 m_cbEntryID,
  4960.                 m_lpEntryID,
  4961.                 ulEvents,
  4962.                 lpAdviseSink,
  4963.                 &ulConnection);
  4964.             break;
  4965.         case MAPI_TABLE:  // defined in mdbview.h
  4966.             hResult = ((LPMAPITABLE)m_lpUnk)->Advise(
  4967.                 ulEvents,
  4968.                 lpAdviseSink,
  4969.                 &ulConnection);
  4970.             break;
  4971.         case MAPI_SESSION:
  4972.         case MAPI_STATUS:
  4973.             hResult = ((LPMAPISESSION)m_lpUnk)->Advise(
  4974.                 m_cbEntryID,
  4975.                 m_lpEntryID,
  4976.                 ulEvents,
  4977.                 lpAdviseSink,
  4978.                 &ulConnection);
  4979.             break;
  4980.         case MAPI_ADDRBOOK:
  4981.             hResult = ((LPADRBOOK)m_lpUnk)->Advise(
  4982.                 m_cbEntryID,
  4983.                 m_lpEntryID,
  4984.                 ulEvents,
  4985.                 lpAdviseSink,
  4986.                 &ulConnection);
  4987.             break;
  4988.         default:
  4989.             MessageBox( "UNKNOWN object type", "Client", MBS_ERROR );
  4990.             break;
  4991.     }
  4992.     if( HR_FAILED(hResult ) )
  4993.     {
  4994.         MessageBox( E.SzError("lpObj->Advise()", hResult), "Client", MBS_ERROR );
  4995.         return;
  4996.     }
  4997.  
  4998.     // if no notif list is currently allocated, allocate it now
  4999.     if(!m_lppNotifs)
  5000.     {
  5001.         lpNotifs = (LPNOTIFS) PvAlloc(sizeof(NOTIFS) );
  5002.         m_lppNotifs = &lpNotifs;
  5003.         (*m_lppNotifs)->cConnect = 0;
  5004.     }
  5005.  
  5006.     (*m_lppNotifs)->cConnect++;
  5007.  
  5008.     // now add to my list
  5009.     (*m_lppNotifs)->Connect[(*m_lppNotifs)->cConnect - 1].ulConnection = ulConnection;
  5010.     lstrcpy((*m_lppNotifs)->Connect[(*m_lppNotifs)->cConnect - 1].szContext,szBuffer);
  5011.  
  5012.     if(lpAdviseSink)
  5013.         lpAdviseSink->Release();
  5014.  
  5015. //    if(lpContext)
  5016. //        PvFree(lpContext);
  5017.  
  5018.     EndDialog(IDOK);
  5019.  
  5020. }
  5021.  
  5022. #endif
  5023.  
  5024.  
  5025.  
  5026.  
  5027.