home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / mapi / peer.xp / xpdialog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-11  |  19.6 KB  |  616 lines

  1. /*
  2.  -  X P D I A L O G . C
  3.  -
  4.  *  Purpose:
  5.  *      Logon UI code for use by the MAPI Sample Transport Provider.
  6.  *
  7.  *  Copyright 1992-1995 Microsoft Corporation.  All Rights Reserved.
  8.  */
  9.  
  10. #include "xppch.h"
  11. #include "xpresrc.h"
  12. #include <stdlib.h>
  13. #include <mapiutil.h>
  14.  
  15. #ifdef DEBUG_DLGITEMS
  16. #ifndef DEBUG
  17. #define DEBUG
  18. #endif
  19. #endif
  20.  
  21. #define PropIndex(PROP)         (PROP_ID(PROP) - BASE_PROVIDER_ID - 1)
  22.  
  23. /* Generic control structures */
  24.  
  25. DTBLLABEL dtbllabel =
  26. {sizeof(DTBLLABEL), 0};
  27. DTBLPAGE dtblpage =
  28. {sizeof(DTBLPAGE), 0, 0, 0};
  29. TCHAR szNoFilter[] = TEXT("*");
  30. TCHAR szDigitFilter[] = TEXT("[0-9]");
  31.  
  32. /* Display table control structures for the General property sheet. */
  33.  
  34. DTBLEDIT editWgapFname =
  35. {sizeof(DTBLEDIT), fMapiUnicode, MAX_PATH,
  36.     PR_SAMPLE_FILENAME};
  37. DTBLEDIT editWgapDir =
  38. {sizeof(DTBLEDIT), fMapiUnicode, MAX_PATH,
  39.     PR_SAMPLE_DIRECTORY};
  40. DTBLCHECKBOX chkLogEvents =
  41. {sizeof(DTBLCHECKBOX), fMapiUnicode,
  42.     PR_TEMP_LOG_EVENTS};
  43. DTBLCHECKBOX chkPeer =
  44. {sizeof(DTBLCHECKBOX), fMapiUnicode,
  45.     PR_TEMP_PEER_TO_PEER};
  46. DTBLCHECKBOX chkLogonUI =
  47. {sizeof(DTBLCHECKBOX), fMapiUnicode,
  48.     PR_TEMP_UI_ALWAYS};
  49. DTBLCHECKBOX chkSaveDialog =
  50. {sizeof(DTBLCHECKBOX), fMapiUnicode,
  51.     PR_TEMP_SAVE_DATA};
  52.  
  53. DTCTL rgdtctlGeneral[] =
  54. {
  55.     {DTCT_PAGE, 0, NULL, 0, NULL, 0, &dtblpage},
  56.     {DTCT_CHECKBOX, DT_EDITABLE, NULL, 0, NULL, IDC_LOG_EVENTS, &chkLogEvents},
  57.     {DTCT_CHECKBOX, DT_EDITABLE, NULL, 0, NULL, IDC_PEER, &chkPeer},
  58.     {DTCT_CHECKBOX, DT_EDITABLE, NULL, 0, NULL, IDC_LOGON_UI, &chkLogonUI},
  59.     {DTCT_CHECKBOX, DT_EDITABLE, NULL, 0, NULL, IDC_SAVE_DIALOG, &chkSaveDialog},
  60.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_WGAP_FNAME, &dtbllabel},
  61.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_WGAP_FNAME, &editWgapFname},
  62.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_WGAP_DIR, &dtbllabel},
  63.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_WGAP_DIR, &editWgapDir}
  64. };
  65.  
  66. /* Display table control structures for the Peer to Peer property sheet. */
  67.  
  68. DTBLEDIT editDisplay =
  69. {sizeof(DTBLEDIT), fMapiUnicode, MAX_TEXTFIELD,
  70.     PR_SAMPLE_DISPLAY_NAME};
  71. DTBLEDIT editEmailType =
  72. {sizeof(DTBLEDIT), fMapiUnicode, 32,
  73.     PR_SAMPLE_EMAIL_ADDR_TYPE};
  74. DTBLEDIT editEmailAddress =
  75. {sizeof(DTBLEDIT), fMapiUnicode, MAX_TEXTFIELD,
  76.     PR_SAMPLE_EMAIL_ADDRESS};
  77. DTBLEDIT editInboundDir =
  78. {sizeof(DTBLEDIT), fMapiUnicode, MAX_PATH,
  79.     PR_SAMPLE_INBOUND_DIR};
  80. DTBLEDIT editOutboundDir =
  81. {sizeof(DTBLEDIT), fMapiUnicode, MAX_PATH,
  82.     PR_SAMPLE_OUTBOUND_DIR};
  83.  
  84. DTCTL rgdtctlPeer[] =
  85. {
  86.     {DTCT_PAGE, 0, NULL, 0, NULL, 0, &dtblpage},
  87.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_DISPLAY, &dtbllabel},
  88.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_DISPLAY, &editDisplay},
  89.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_EMAIL_TYPE, &dtbllabel},
  90.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_EMAIL_TYPE, &editEmailType},
  91.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_EMAIL_ADDR, &dtbllabel},
  92.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_EMAIL_ADDR, &editEmailAddress},
  93.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_IN_DIR, &dtbllabel},
  94.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_IN_DIR, &editInboundDir},
  95.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_OUT_DIR, &dtbllabel},
  96.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_OUT_DIR, &editOutboundDir}
  97. };
  98.  
  99. /* Display table control structures for the Logging property sheet. */
  100.  
  101. DTBLEDIT editLogFile =
  102. {sizeof(DTBLEDIT), fMapiUnicode, MAX_PATH,
  103.     PR_SAMPLE_LOGFILE};
  104. DTBLEDIT editLogHigh =
  105. {sizeof(DTBLEDIT), fMapiUnicode, 11,
  106.     PR_TEMP_LOGHIGHWATER};
  107. DTBLEDIT editLogLow =
  108. {sizeof(DTBLEDIT), fMapiUnicode, 11,
  109.     PR_TEMP_LOGLOWWATER};
  110. DTCTL rgdtctlLogging[] =
  111. {
  112.     {DTCT_PAGE, 0, NULL, 0, NULL, 0, &dtblpage},
  113.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_LOG_NAME, &dtbllabel},
  114.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szNoFilter, IDE_LOG_NAME, &editLogFile},
  115.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_LOG_HIGH, &dtbllabel},
  116.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szDigitFilter, IDE_LOG_HIGH, &editLogHigh},
  117.     {DTCT_LABEL, 0, NULL, 0, NULL, IDT_LOG_LOW, &dtbllabel},
  118.     {DTCT_EDIT, DT_EDITABLE, NULL, 0, szDigitFilter, IDE_LOG_LOW, &editLogLow}
  119. };
  120.  
  121. /* Display table pages */
  122.  
  123. DTPAGE rgdtpage[] =
  124. {
  125.     {
  126.         sizeof(rgdtctlGeneral) / sizeof(DTCTL),
  127.         (LPTSTR) MAKEINTRESOURCE(GeneralPage),
  128.         "",
  129.         rgdtctlGeneral
  130.     },
  131.     {
  132.         sizeof(rgdtctlPeer) / sizeof(DTCTL),
  133.         (LPTSTR) MAKEINTRESOURCE(PeerPage),
  134.         "",
  135.         rgdtctlPeer
  136.     },
  137.     {
  138.         sizeof(rgdtctlLogging) / sizeof(DTCTL),
  139.         (LPTSTR) MAKEINTRESOURCE(LoggingPage),
  140.         "",
  141.         rgdtctlLogging
  142.     }
  143. };
  144.  
  145. #ifdef DEBUG_DLGITEMS
  146. static void
  147.  DLGDump(LPXPDLG lpXPDialog);
  148. #endif
  149.  
  150.  
  151. /*
  152.  -  ScDoLogonDlg
  153.  -
  154.  *  Purpose:
  155.  *      Called by the TransportLogon code to present logon UI to the user.
  156.  *
  157.  *  Parameters:
  158.  *      lpXPDialog          Structure through which we communicate
  159.  *
  160.  *  Returns:
  161.  *      0                   Dialog came up, pLogonStruct->lppPropArray
  162.  *                          contains a PropValueArray if OK, NULL if CANCEL
  163.  *
  164.  *      (Failure)           Some error occurred. lppPropArray will have
  165.  *                          either the original array or NULL.
  166.  *
  167.  *  Operation:
  168.  *      Gets the necessary information from Windows and activates the logon
  169.  *      dialog box.
  170.  */
  171.  
  172. SCODE
  173. ScDoLogonDlg(LPXPDLG lpXPDialog)
  174. {
  175.     SCODE sc = S_OK;
  176.     HRESULT hr;
  177.     LPMAPITABLE ptable = NULL;
  178.     LPPROPDATA pTempProps = NULL;
  179.     ULONG flT = 0L;
  180.     LPSPropValue rgprop;
  181.     LPSPropValue pprop;
  182.     LPSPropTagArray ptags;
  183.     ULONG cprop;
  184.     TCHAR szDialogTitle[128];
  185.     TCHAR szLogHigh[12];
  186.     TCHAR szLogLow[12];
  187.     UINT i;
  188.  
  189.     /* Take ownership of the property value array, so calling code
  190.        will not leak memory. */
  191.  
  192.     rgprop = *(lpXPDialog->lppPropArray);
  193.     *(lpXPDialog->lppPropArray) = NULL;
  194.     ptags = lpXPDialog->lpPTArray;
  195.  
  196.     /* Retrieve the dialog title string */
  197.  
  198.     if (!LoadString(lpXPDialog->hInst, IDS_CONFIG_TITLE, 
  199.         szDialogTitle, sizeof(szDialogTitle)))
  200.     {
  201.         sc = MAPI_E_NOT_ENOUGH_MEMORY;
  202.         DebugTrace("LoadString failed in ScDoLogonDlg.\n");
  203.         goto ret;
  204.     }
  205.  
  206.     /* Create the configuration data interface.
  207.        First, split the PR_SAMPLE_FLAGS property into four individual
  208.        Boolean properties. */
  209.  
  210.     pprop = rgprop + (MAX_LOGON_PROPERTIES - TEMP_LOGON_PROPERTIES);
  211.  
  212.     if (rgprop[PropIndex(PR_SAMPLE_FLAGS)].ulPropTag == PR_SAMPLE_FLAGS)
  213.         flT = rgprop[PropIndex(PR_SAMPLE_FLAGS)].Value.ul;
  214.     else
  215.     {
  216.         /*  The Peer to Peer and Save Data flags default to TRUE */
  217.         rgprop[PropIndex(PR_SAMPLE_FLAGS)].ulPropTag = PR_SAMPLE_FLAGS;
  218.         flT = PR_SAMPLE_FLAG_PEER_TO_PEER | PR_SAMPLE_FLAG_SAVE_DATA;
  219.         rgprop[PropIndex(PR_SAMPLE_FLAGS)].Value.ul = flT;
  220.     }
  221.  
  222.     pprop[0].ulPropTag = PR_TEMP_PEER_TO_PEER;
  223.     pprop[0].Value.b = !!(flT & PR_SAMPLE_FLAG_PEER_TO_PEER);
  224.     pprop[1].ulPropTag = PR_TEMP_UI_ALWAYS;
  225.     pprop[1].Value.b = !!(flT & PR_SAMPLE_FLAG_UI_ALWAYS);
  226.     pprop[2].ulPropTag = PR_TEMP_LOG_EVENTS;
  227.     pprop[2].Value.b = !!(flT & PR_SAMPLE_FLAG_LOG_EVENTS);
  228.     pprop[3].ulPropTag = PR_TEMP_SAVE_DATA;
  229.     pprop[3].Value.b = !!(flT & PR_SAMPLE_FLAG_SAVE_DATA);
  230.  
  231.     /* Next, make strings out of the two numeric logging parameters */
  232.  
  233.     if (rgprop[PropIndex(PR_SAMPLE_LOGHIGHWATER)].ulPropTag == PR_SAMPLE_LOGHIGHWATER)
  234.         wsprintf(szLogHigh, "%ld",
  235.             rgprop[PropIndex(PR_SAMPLE_LOGHIGHWATER)].Value.l);
  236.     else
  237.         szLogHigh[0] = '\0';
  238.  
  239.     pprop[4].ulPropTag = PR_TEMP_LOGHIGHWATER;
  240.     pprop[4].Value.LPSZ = szLogHigh;
  241.  
  242.     if (rgprop[PropIndex(PR_SAMPLE_LOGLOWWATER)].ulPropTag == PR_SAMPLE_LOGLOWWATER)
  243.         wsprintf(szLogLow, "%ld",
  244.             rgprop[PropIndex(PR_SAMPLE_LOGLOWWATER)].Value.l);
  245.     else
  246.         szLogLow[0] = '\0';
  247.  
  248.     pprop[5].ulPropTag = PR_TEMP_LOGLOWWATER;
  249.     pprop[5].Value.LPSZ = szLogLow;
  250.  
  251.     /* Now make a temporary property interface and feed it the data. */
  252.  
  253.     sc = CreateIProp((LPIID) &IID_IMAPIPropData,
  254.             lpXPDialog->AllocateBuffer,
  255.             lpXPDialog->AllocateMore,
  256.             lpXPDialog->FreeBuffer,
  257.             lpXPDialog->lpMalloc,
  258.             &pTempProps);
  259.  
  260.     if (FAILED(sc))
  261.     {
  262.         DebugTrace("CreateIProp failed in ScDoLogonDlg.\n");
  263.         goto ret;
  264.     }
  265.  
  266.     hr = pTempProps->lpVtbl->SetProps(pTempProps, MAX_LOGON_PROPERTIES, rgprop, NULL);
  267.  
  268.     if (HR_FAILED(hr))
  269.     {
  270.         sc = GetScode(hr);
  271.         DebugTrace("SetProps failed in ScDoLogonDlg.\n");
  272.         goto ret;
  273.     }
  274.     
  275.     /* If the UI_READONLY flag is set, then we are being called from
  276.        the SettingDialog() method in Read Only mode.  Disable all of
  277.        the controls on the three property sheets, else Enable them.  */
  278.  
  279.     if (lpXPDialog->ulFlags & UI_READONLY)
  280.     {
  281.         /* Disable controls on the General PropSheet */
  282.         rgdtpage[0].lpctl[1].ulCtlFlags &= ~DT_EDITABLE;
  283.         rgdtpage[0].lpctl[2].ulCtlFlags &= ~DT_EDITABLE;
  284.         rgdtpage[0].lpctl[3].ulCtlFlags &= ~DT_EDITABLE;
  285.         rgdtpage[0].lpctl[4].ulCtlFlags &= ~DT_EDITABLE;
  286.         rgdtpage[0].lpctl[6].ulCtlFlags &= ~DT_EDITABLE;
  287.         rgdtpage[0].lpctl[8].ulCtlFlags &= ~DT_EDITABLE;
  288.  
  289.         /* Disable controls on the Peer-To-Peer PropSheet */
  290.         rgdtpage[1].lpctl[2].ulCtlFlags &= ~DT_EDITABLE;
  291.         rgdtpage[1].lpctl[4].ulCtlFlags &= ~DT_EDITABLE;
  292.         rgdtpage[1].lpctl[6].ulCtlFlags &= ~DT_EDITABLE;
  293.         rgdtpage[1].lpctl[8].ulCtlFlags &= ~DT_EDITABLE;
  294.         rgdtpage[1].lpctl[10].ulCtlFlags &= ~DT_EDITABLE;
  295.  
  296.         /* Disable controls on the Logging PropSheet */
  297.         rgdtpage[2].lpctl[2].ulCtlFlags &= ~DT_EDITABLE;
  298.         rgdtpage[2].lpctl[4].ulCtlFlags &= ~DT_EDITABLE;
  299.         rgdtpage[2].lpctl[6].ulCtlFlags &= ~DT_EDITABLE;
  300.     }
  301.     else
  302.     {
  303.         /* Enable controls on the General PropSheet */
  304.         rgdtpage[0].lpctl[1].ulCtlFlags |= DT_EDITABLE;
  305.         rgdtpage[0].lpctl[2].ulCtlFlags |= DT_EDITABLE;
  306.         rgdtpage[0].lpctl[3].ulCtlFlags |= DT_EDITABLE;
  307.         rgdtpage[0].lpctl[4].ulCtlFlags |= DT_EDITABLE;
  308.         rgdtpage[0].lpctl[6].ulCtlFlags |= DT_EDITABLE;
  309.         rgdtpage[0].lpctl[8].ulCtlFlags |= DT_EDITABLE;
  310.  
  311.         /* Enable controls on the Peer-To-Peer PropSheet */
  312.         rgdtpage[1].lpctl[2].ulCtlFlags |= DT_EDITABLE;
  313.         rgdtpage[1].lpctl[4].ulCtlFlags |= DT_EDITABLE;
  314.         rgdtpage[1].lpctl[6].ulCtlFlags |= DT_EDITABLE;
  315.         rgdtpage[1].lpctl[8].ulCtlFlags |= DT_EDITABLE;
  316.         rgdtpage[1].lpctl[10].ulCtlFlags |= DT_EDITABLE;
  317.  
  318.         /* Enable controls on the Logging PropSheet */
  319.         rgdtpage[2].lpctl[2].ulCtlFlags |= DT_EDITABLE;
  320.         rgdtpage[2].lpctl[4].ulCtlFlags |= DT_EDITABLE;
  321.         rgdtpage[2].lpctl[6].ulCtlFlags |= DT_EDITABLE;
  322.     }
  323.  
  324.     /* Check if we are being called at Logon time or from a call to
  325.        SettingsDialog().  If from SettingsDialog() then disable the
  326.        IDE_EMAIL_TYPE edit control reguardless of ulFlags setting. */
  327.  
  328.     if (!lpXPDialog->fLogon)
  329.         rgdtpage[1].lpctl[4].ulCtlFlags &= ~DT_EDITABLE;
  330.  
  331.     /* Create the display table for the logon dialog. It is based on dialog
  332.        resources plus the static information at the head of this module. */
  333.  
  334.     hr = BuildDisplayTable(
  335.         lpXPDialog->AllocateBuffer,
  336.         lpXPDialog->AllocateMore,
  337.         lpXPDialog->FreeBuffer,
  338.         lpXPDialog->lpMalloc,
  339.         lpXPDialog->hInst,
  340.         sizeof(rgdtpage) / sizeof(DTPAGE),
  341.         rgdtpage,
  342.         0,
  343.         &ptable,
  344.         NULL);
  345.  
  346.     if (HR_FAILED(hr))
  347.     {
  348.         sc = GetScode(hr);
  349.         DebugTrace("BuildDisplayTable failed in ScDoLogonDlg.\n");
  350.         goto ret;
  351.     }
  352.  
  353.     /* Run the dialog */
  354.  
  355.     hr = lpXPDialog->lpMAPISup->lpVtbl->DoConfigPropsheet(lpXPDialog->lpMAPISup,
  356.         (ULONG) lpXPDialog->hwnd,
  357.         0,
  358.         szDialogTitle,
  359.         ptable,
  360.         (LPMAPIPROP) pTempProps,
  361.         1);
  362.  
  363.     if (HR_FAILED(hr))
  364.     {
  365.         sc = GetScode(hr);
  366.         DebugTrace("DoConfigPropsheet failed in ScDoLogonDlg.\n");
  367.         goto ret;
  368.     }
  369.  
  370.     /* Retrieve the altered data */
  371.  
  372.     (*(lpXPDialog->FreeBuffer)) (rgprop);
  373.     rgprop = NULL;
  374.  
  375.     hr = pTempProps->lpVtbl->GetProps(pTempProps, ptags, 0, /* ansi */
  376.             &cprop, &rgprop);
  377.  
  378.     if (HR_FAILED(hr))
  379.     {
  380.         sc = GetScode(hr);
  381.         DebugTrace("GetProps failed in ScDoLogonDlg.\n");
  382.         goto ret;
  383.     }
  384.  
  385.     Assert(cprop == MAX_LOGON_PROPERTIES);
  386.  
  387.     /* Supply default values for any unfilled fields.
  388.        Also ensure that the directory name fields end in a slash. */
  389.  
  390.     for (i = 0; i < MAX_LOGON_PROPERTIES - TEMP_LOGON_PROPERTIES; ++i)
  391.     {
  392.         ULONG tagT = rgprop[i].ulPropTag;
  393.         UINT cch;
  394.         LPTSTR lpszT;
  395.  
  396.         if (tagT != ptags->aulPropTag[i])
  397.         {
  398.             /* This property did not make it. Integer properties default
  399.                to 0, and string properties default to empty. */
  400.  
  401.             tagT = ptags->aulPropTag[i];
  402.  
  403.             if (PROP_TYPE(tagT) == PT_LONG)
  404.             {
  405.                 rgprop[i].Value.l = 0;
  406.                 rgprop[i].ulPropTag = tagT;
  407.             }
  408.             else if (PROP_TYPE(tagT) == PT_TSTRING)
  409.             {
  410.                 if (FAILED((*(lpXPDialog->AllocateMore)) (sizeof(TCHAR),
  411.                             rgprop, (LPVOID FAR *) &rgprop[i].Value.LPSZ)))
  412.                 {
  413.                     rgprop[i].ulPropTag = PROP_TAG(PT_ERROR, PROP_ID(tagT));
  414.                     rgprop[i].Value.err = MAPI_E_NOT_ENOUGH_MEMORY;
  415.                 }
  416.                 else
  417.                 {
  418.                     rgprop[i].Value.LPSZ[0] = '\0';
  419.                     rgprop[i].ulPropTag = tagT;
  420.                 }
  421.             }
  422.         }
  423.         else if (tagT == PR_SAMPLE_INBOUND_DIR ||
  424.                 tagT == PR_SAMPLE_OUTBOUND_DIR ||
  425.             tagT == PR_SAMPLE_DIRECTORY)
  426.         {
  427.             cch = lstrlen(rgprop[i].Value.LPSZ);
  428.  
  429.             if (cch && rgprop[i].Value.LPSZ[cch - 1] != '\\')
  430.             {
  431.                 if (FAILED((*(lpXPDialog->AllocateMore)) (
  432.                             (cch + 2) * sizeof(TCHAR), rgprop, (LPVOID FAR *) &lpszT)))
  433.                 {
  434.                     rgprop[i].ulPropTag = PROP_TAG(PT_ERROR, PROP_ID(tagT));
  435.                     rgprop[i].Value.err = MAPI_E_NOT_ENOUGH_MEMORY;
  436.                 }
  437.                 else
  438.                 {
  439.                     lstrcpy(lpszT, rgprop[i].Value.LPSZ);
  440.                     lpszT[cch] = '\\';
  441.                     lpszT[cch + 1] = '\0';
  442.                     rgprop[i].Value.LPSZ = lpszT;
  443.                 }
  444.             }
  445.         }
  446.     }
  447.  
  448.     /* Reassemble the PR_SAMPLE_FLAGS property */
  449.  
  450.     pprop = rgprop + (MAX_LOGON_PROPERTIES - TEMP_LOGON_PROPERTIES);
  451.     flT = 0L;
  452.  
  453.     if (pprop[0].ulPropTag == PR_TEMP_PEER_TO_PEER && pprop[0].Value.b)
  454.         flT |= PR_SAMPLE_FLAG_PEER_TO_PEER;
  455.     if (pprop[1].ulPropTag == PR_TEMP_UI_ALWAYS && pprop[1].Value.b)
  456.         flT |= PR_SAMPLE_FLAG_UI_ALWAYS;
  457.     if (pprop[2].ulPropTag == PR_TEMP_LOG_EVENTS && pprop[2].Value.b)
  458.         flT |= PR_SAMPLE_FLAG_LOG_EVENTS;
  459.     if (pprop[3].ulPropTag == PR_TEMP_SAVE_DATA && pprop[3].Value.b)
  460.         flT |= PR_SAMPLE_FLAG_SAVE_DATA;
  461.  
  462.     rgprop[PropIndex(PR_SAMPLE_FLAGS)].ulPropTag = PR_SAMPLE_FLAGS;
  463.     rgprop[PropIndex(PR_SAMPLE_FLAGS)].Value.ul = flT;
  464.  
  465.     /* Reassemble the high and low water marks for logging */
  466.  
  467.     if (rgprop[PropIndex(PR_TEMP_LOGHIGHWATER)].ulPropTag == PR_TEMP_LOGHIGHWATER)
  468.         rgprop[PropIndex(PR_SAMPLE_LOGHIGHWATER)].Value.l =
  469.             atoi(rgprop[PropIndex(PR_TEMP_LOGHIGHWATER)].Value.LPSZ);
  470.  
  471.     if (rgprop[PropIndex(PR_TEMP_LOGLOWWATER)].ulPropTag == PR_TEMP_LOGLOWWATER)
  472.         rgprop[PropIndex(PR_SAMPLE_LOGLOWWATER)].Value.l =
  473.             atoi(rgprop[PropIndex(PR_TEMP_LOGLOWWATER)].Value.LPSZ);
  474.  
  475.     /* Return the new property array */
  476.  
  477.     *(lpXPDialog->lppPropArray) = rgprop;
  478.     rgprop = NULL;              /* do not free this in cleanup code */
  479.     sc = S_OK;                  /* no warnings */
  480.  
  481. #ifdef DEBUG_DLGITEMS
  482.     DLGDump(lpXPDialog);        /* dump debug data. */
  483. #endif
  484.  
  485. ret:
  486.     DebugTraceSc(ScDoLogonDialog(), sc);
  487.  
  488.     UlRelease(ptable);
  489.     UlRelease(pTempProps);
  490.  
  491.     lpXPDialog->FreeBuffer(rgprop);
  492.  
  493.     return sc;
  494. }
  495.  
  496.  
  497. #ifdef DEBUG_DLGITEMS
  498.  
  499. /*
  500.  -  DLGDump
  501.  -
  502.  *  Purpose:
  503.  *      Called by ScDoLogonDlg to dump the contents
  504.  *      of the logon property array to the debugger.
  505.  *
  506.  *  Parameters:
  507.  *      lpXPDialog      Pointer to logon parameter structure
  508.  *
  509.  *  Returns:
  510.  *      none.
  511.  *
  512.  *  Operation:
  513.  *      Walks through the property array inside the logon structure, and
  514.  *      dumps its contents through DebugTrace().
  515.  *
  516.  *      This function only exists in the debug version.
  517.  */
  518.  
  519. static void
  520. DLGDump(LPXPDLG lpXPDialog)
  521. {
  522.  
  523.     ULONG ulT, flT, ptT, ptT2;
  524.     LPSPropValue lpPropArray;
  525.     LPSPropTagArray lpPTArray;
  526.     SPropValue propT;
  527.     ULONG ulCount;
  528.  
  529.     if (!lpXPDialog)
  530.     {
  531.         DebugTrace("lpXPDialog is NULL");
  532.         goto ret;
  533.     }
  534.  
  535.     DebugTrace("LogonStruct:");
  536.  
  537.     lpPropArray = *(lpXPDialog->lppPropArray);
  538.     lpPTArray = lpXPDialog->lpPTArray;
  539.  
  540.     if (!lpPropArray)
  541.     {
  542.         DebugTrace("NULL\n");
  543.         goto ret;
  544.     }
  545.  
  546.     ulCount = lpPTArray->cValues;
  547.  
  548.     for (ulT = 0; ulT < ulCount; ulT++)
  549.     {
  550.         propT = lpPropArray[ulT];
  551.         ptT = lpPTArray->aulPropTag[ulT];
  552.         ptT2 = propT.ulPropTag;
  553.  
  554.         switch (ptT)
  555.         {
  556.         case PR_SAMPLE_DISPLAY_NAME:
  557.             DebugTrace("  DisplayName: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  558.             break;
  559.  
  560.         case PR_SAMPLE_EMAIL_ADDR_TYPE:
  561.             DebugTrace("  EmailAddressType: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  562.             break;
  563.  
  564.         case PR_SAMPLE_EMAIL_ADDRESS:
  565.             DebugTrace("  EmailAddress: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  566.             break;
  567.  
  568.         case PR_SAMPLE_INBOUND_DIR:
  569.             DebugTrace("  Inbound Directory: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  570.             break;
  571.  
  572.         case PR_SAMPLE_OUTBOUND_DIR:
  573.             DebugTrace("  Outbound Directory: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  574.             break;
  575.  
  576.         case PR_SAMPLE_FILENAME:
  577.             DebugTrace("  WGApp Filename: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  578.             break;
  579.  
  580.         case PR_SAMPLE_DIRECTORY:
  581.             DebugTrace("  WGApp Directory: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  582.             break;
  583.  
  584.         case PR_SAMPLE_FLAGS:
  585.  
  586.             flT = (ptT == ptT2) ? propT.Value.ul : 0;
  587.  
  588.             DebugTrace("  Peer-To-Peer: %s", (flT & PR_SAMPLE_FLAG_PEER_TO_PEER) ? "TRUE" : "FALSE");
  589.             DebugTrace("  Always show UI: %s", (flT & PR_SAMPLE_FLAG_UI_ALWAYS) ? "TRUE" : "FALSE");
  590.             DebugTrace("  Log Events: %s", (flT & PR_SAMPLE_FLAG_LOG_EVENTS) ? "TRUE" : "FALSE");
  591.             DebugTrace("  Save Logon Input: %s", (flT & PR_SAMPLE_FLAG_SAVE_DATA) ? "TRUE" : "FALSE");
  592.             break;
  593.  
  594.         case PR_SAMPLE_LOGFILE:
  595.             DebugTrace("  Log File Name: %s", (ptT == ptT2) ? propT.Value.LPSZ : "NULL");
  596.             break;
  597.  
  598.         case PR_SAMPLE_LOGHIGHWATER:
  599.             DebugTrace("  Log File HighWater: %ld", (ptT == ptT2) ? propT.Value.ul : 0);
  600.             break;
  601.  
  602.         case PR_SAMPLE_LOGLOWWATER:
  603.             DebugTrace("  Log File LowWater: %ld", (ptT == ptT2) ? propT.Value.ul : 0);
  604.             break;
  605.             
  606.         default:
  607.             DebugTrace("  Unknown Logon Property: %08X", ptT);
  608.             break;
  609.         }
  610.     }
  611. ret:
  612.     return;
  613. }
  614.  
  615. #endif                          /* DEBUG_DLGITEMS */
  616.