home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / conf_sdk / conf_sdk.exe / TEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-30  |  21.6 KB  |  792 lines

  1. /* ----------------------------------------------------------------------
  2.  
  3.     CNFTEST sample for Microsoft ActiveX Conferencing
  4.  
  5.     Unpublished work.
  6.     Copyright (c) 1996, Microsoft Corporation
  7.     All rights reserved.
  8.  
  9.     MODULE: test.c
  10.  
  11.     PURPOSE: This file calls the Scrapi APIs to establish the 
  12.     meeting connection and to perform other operations such as
  13.     information exchange. Selecting function names from the menu 
  14.     or using the toolbar buttons tests each function.
  15.     
  16.     COMMENTS: Following structures are used by the function.
  17.  
  18.         CONFADDR: Describes the meeting connection address.
  19.         CONFINFO: Describes the meeting settings.
  20.         CONFERECDIR: Describes the default receive directory
  21.                      for transferred files.
  22.         CONFNOTIFY: Describes the notification callback.
  23.         CONFUSERINFO: Describes a user within a meeting.
  24.     
  25.     Log1, Log2, Log3, Log4 are all macros defined in global.h
  26.     These functions call the Log function to print the messages
  27.     to the message window.
  28.  
  29.  
  30.     FUNCTIONS:
  31.     LONG CALLBACK MyNotifyProc()- Callback function will take
  32.         care of the meeting events    by the notification codes
  33.     VOID CmdCancelTransfer()-  Cancel a file tranfer action.
  34.         Calls ConferenceCancelTransfer
  35.     VOID CmdConnect()-  Establishes the connection. Calls
  36.         ConferenceConnect. 
  37.     VOID CmdDisconnect()-  Disconnects the meeting. Calls
  38.         ConferenceDisconnect. 
  39.     VOID CmdGetInfo()- Calls ConferenceGetInfo
  40.     VOID CmdLaunchRemote()- Calls ConferenceLaunchRemote
  41.     VOID CmdListen()- Calls ConferenceListen
  42.     VOID CmdRemoveNotify()- Calls ConferenceRemoveNotify
  43.     VOID CmdSendData()- Calls ConferenceSetInfo
  44.     VOID CmdSendFile()- Calls ConferenceSendFile
  45.     VOID CmdSetInfo()- Calls ConferenceSetInfo
  46.     VOID CmdSetNotify()- Calls ConferenceSetNotify
  47.     VOID CmdShareWindow()- Calls ConferenceShareWindow
  48.     VOID CmdUnShareWindow()- Calls ConferenceShareWindow
  49.         with the CONF_WINDOW_UNSHARED code
  50.     VOID CmdIsWindowShared()- Calls ConferenceShareWindow with
  51.         the CONF_SW_IS_SHARED code
  52.  
  53.     VOID CmdEnumUser()- Calls ConferenceGetInfo
  54.     VOID CmdEnumConf()- Calls ConferenceGetInfo
  55.     VOID CmdSetGuid()- Calls ConferenceSetInfo
  56.     VOID MyNotifyProc()- The notification procedure
  57.  
  58. ----------------------------------------------------------------------- */
  59.  
  60. #include "main.h"
  61.  
  62. // Static Strings
  63. static char _szCancelTransfer[] = "CancelTransfer";
  64. static char _szConnect[]        = "Connect";
  65. static char _szDisconnect[]     = "Disconnect";
  66. static char _szGetInfo[]        = "GetInfo";
  67. static char _szLaunchRemote[]   = "LaunchRemote";
  68. static char _szListen[]         = "Listen";
  69. static char _szRemoveNotify[]   = "RemoveNotify";
  70. static char _szSetInfo[]        = "SetInfo";
  71. static char _szSetNotify[]      = "SetNotify";
  72. static char _szSendData[]       = "SendData";
  73. static char _szSendFile[]       = "SendFile";
  74. static char _szShareWindow[]    = "ShareWindow";
  75.  
  76. static char _szUnShareWindow[]  = "UnShareWindow";
  77. static char _szIsWindowShared[] = "IsWindowShared";
  78. static char _szSetGuid[]        = "SetGuid";
  79. static char _szEnumUsers[]      = "EnumUsers";
  80. static char _szEnumConfs[]      = "EnumConfs";
  81.  
  82. LONG CALLBACK MyNotifyProc(HCONF hConf, DWORD dwCode, DWORD dwParam, LPVOID lpv1, LPVOID lpv2, DWORD dwUser);
  83.  
  84. VOID DumpUserInfo(LPCONFUSERINFO lpUserInfo);
  85. VOID DumpConfInfo(LPCONFINFO lpConfInfo);
  86.  
  87.  
  88.  
  89. /*  C M D  C A N C E L  T R A N S F E R */
  90. /*----------------------------------------------------------------------------
  91.     %%Function: CmdCancelTransfer
  92.  
  93.     CmdCancelTransfer function executes when the user selects 
  94.     ConferenceCancelTransfer from the Test menu. 
  95.  
  96.     This function stops the current file transfer (if one is running)
  97.     
  98. ----------------------------------------------------------------------------*/
  99. VOID CmdCancelTransfer(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  100. {
  101.     CONFERR dwResult;
  102.  
  103.     LogTestStart(_szCancelTransfer);
  104.  
  105.     dwResult = ConferenceCancelTransfer(gPref.hConf, gdwFileId);
  106.     LogResult(_szCancelTransfer, 1, dwResult);
  107.     
  108.     LogTestStop(_szCancelTransfer);
  109. }
  110.  
  111.  
  112.  
  113. /*  C M D  C O N N E C T */
  114. /*----------------------------------------------------------------------------
  115.     %%Function: CmdConnect
  116.  
  117.     CmdConnect function executes when the user selects ConferenceConnect 
  118.     from the Test menu. 
  119.  
  120.     This function reads the conference connection address from 
  121.     the user and takes the initial conference settings information 
  122.     and then calls the ConferenceConnect function to establish a 
  123.     meeting between two systems.
  124.  
  125. ----------------------------------------------------------------------------*/
  126. VOID CmdConnect(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  127. {
  128.     CONFERR dwResult;
  129.     CONFADDR confAddr;
  130.     CONFINFO confInfo;
  131.  
  132.     if (!DlgConferenceConnect())
  133.     {
  134.         LogTestCancel(_szConnect);
  135.         return;
  136.     }
  137.  
  138.     LogTestStart(_szConnect);
  139.  
  140.     InitStruct(&confAddr);
  141.  
  142.     confAddr.dwAddrType = gPref.iAddrType;
  143.     confAddr.psz = gPref.szDefName;    // default name
  144.     switch (gPref.iAddrType)
  145.         {
  146.     case CONF_ADDR_IP:
  147.         confAddr.dwIp = DwIpAddrFromSz(gPref.szDefName);
  148.         Log4(LOG_ALWAYS, "IPAddr=%d.%d.%d.%d",
  149.                 HIBYTE(HIWORD(confAddr.dwIp)),
  150.                 LOBYTE(HIWORD(confAddr.dwIp)),
  151.                 HIBYTE(LOWORD(confAddr.dwIp)),
  152.                 LOBYTE(LOWORD(confAddr.dwIp)) );
  153.         break;
  154.     case CONF_ADDR_MACHINENAME:
  155.         Log1(LOG_ALWAYS, "Machine Name [%s]", confAddr.psz);
  156.         break;
  157.     case CONF_ADDR_PSTN:
  158.         Log1(LOG_ALWAYS, "Telephone number [%s]", confAddr.psz);
  159.         break;
  160.     default:
  161.         Log2(LOG_ALWAYS, "Unknown string [%s] (addrType=%d)", 
  162.             (confAddr.psz == NULL) ? "<null>" : confAddr.psz, gPref.iAddrType);
  163.         break;
  164.         }
  165.  
  166.     InitStruct(&confInfo);
  167.     confInfo.dwMediaType = gPref.dwMediaType;
  168.     lstrcpy(confInfo.szConferenceName, gPref.szConferenceName);
  169.  
  170.     dwResult = ConferenceConnect(&gPref.hConf, &confAddr, &confInfo, NULL);
  171.     LogResult(_szConnect, 1, dwResult);
  172.     Log1(LOG_ALWAYS, "hConf = %08X", gPref.hConf);
  173.     LogTestStop(_szConnect);
  174. }
  175.  
  176.  
  177.  
  178. /*  C M D  D I S C O N N E C T */
  179. /*----------------------------------------------------------------------------
  180.     %%Function: CmdDisconnect
  181.  
  182.     This function executes when the user selects ConferenceDisconnect
  183.     from the Test menu.
  184.  
  185.     Function disconnects the meeting by calling the 
  186.     ConferenceDisconnect function.  
  187.  
  188. ----------------------------------------------------------------------------*/
  189. VOID CmdDisconnect(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  190. {
  191.     CONFERR dwResult;
  192.  
  193.     LogTestStart(_szDisconnect);
  194.  
  195.     dwResult = ConferenceDisconnect(gPref.hConf);
  196.     LogResult(_szDisconnect, 1, dwResult);
  197.  
  198.     gPref.hConf = NULL;
  199.  
  200.     LogTestStop(_szDisconnect);
  201. }
  202.  
  203.  
  204.  
  205. /*  C M D  G E T  I N F O */
  206. /*----------------------------------------------------------------------------
  207.     %%Function: CmdGetInfo
  208.  
  209.     Returns information about the specified meeting.
  210.  
  211.     This example calls the ConferenceGetInfo API twice to 
  212.     display the current meeting name and number of users
  213.     and to display the current receive directory for the local
  214.     machine.
  215.  
  216. ----------------------------------------------------------------------------*/
  217. VOID CmdGetInfo(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  218. {
  219.     CONFERR dwResult;
  220.     CONFINFO confInfo;
  221.     CONFRECDIR confRecDir;
  222.  
  223.     LogTestStart(_szGetInfo);
  224.  
  225.     InitStruct(&confInfo);
  226.     dwResult = ConferenceGetInfo(gPref.hConf, CONF_ENUM_CONF, &confInfo);
  227.     LogResult(_szGetInfo, 1, dwResult);
  228.     if (CONFERR_SUCCESS == dwResult)
  229.     {
  230.         DumpConfInfo(&confInfo);
  231.     }
  232.  
  233.     InitStruct(&confRecDir);
  234.     dwResult = ConferenceGetInfo(gPref.hConf, CONF_GET_RECDIR, &confRecDir);
  235.     LogResult(_szGetInfo, 2, dwResult);
  236.     if (CONFERR_SUCCESS == dwResult)
  237.     {
  238.         Log1(LOG_ALWAYS, "  Receive Directory [%s]", confRecDir.szRecDir);
  239.     }
  240.  
  241.     LogTestStop(_szGetInfo);
  242. }
  243.  
  244.  
  245. /*  C M D  L A U N C H  R E M O T E */
  246. /*----------------------------------------------------------------------------
  247.     %%Function: CmdLaunchRemote
  248.  
  249. ----------------------------------------------------------------------------*/
  250. VOID CmdLaunchRemote(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  251. {
  252.     CONFDEST confDest;
  253.     CONFUSERINFO confUserInfo;
  254.     BOOL fFound = fFalse;
  255.     CONFERR dwResult;
  256.  
  257.     LogTestStart(_szLaunchRemote);
  258.  
  259.     if (!DlgLaunchRemote())
  260.     {
  261.         LogTestCancel(_szLaunchRemote);
  262.         return;
  263.     }
  264.  
  265.     InitStruct(&confDest);
  266.     InitStruct(&confUserInfo);
  267.  
  268.     if(0 == lstrcmp("<everyone>", gPref.szUserName))
  269.         confDest.dwUserId = 0;
  270.     else
  271.     {
  272.         // scan the array of users and match the name to a UserId 
  273.         for( ; ; )
  274.         {
  275.             dwResult = ConferenceGetInfo(gPref.hConf, CONF_ENUM_USER, &confUserInfo);
  276.             if(dwResult != CONFERR_SUCCESS)
  277.             {
  278.                 if(dwResult != CONFERR_ENUM_COMPLETE)
  279.                 {
  280.                     Log1(LOG_ERROR, "ConferenceGetInfo returns %08x", dwResult);
  281.                     break;
  282.                 }
  283.                 break;
  284.             }
  285.             if(0 == lstrcmp(confUserInfo.szUserName, gPref.szUserName))
  286.             {
  287.                 confDest.dwUserId = confUserInfo.dwUserId;
  288.                 fFound = fTrue;
  289.                 break;
  290.             }
  291.         }
  292.     Assert(fFound);
  293.     }
  294.  
  295.     confDest.guid = gPref.guidRemote;
  296.  
  297.     dwResult = ConferenceLaunchRemote(gPref.hConf, &confDest, 0);
  298.     LogResult(_szLaunchRemote, 1, dwResult);
  299.  
  300.     LogTestStop(_szLaunchRemote);
  301. }
  302.  
  303.  
  304. /*  C M D  L I S T E N */
  305. /*----------------------------------------------------------------------------
  306.     %%Function: CmdListen
  307.  
  308.     Launchs NetMeeting in the background.
  309.     
  310. ----------------------------------------------------------------------------*/
  311. VOID CmdListen(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  312. {
  313.     CONFERR dwResult;
  314.     
  315.     LogTestStart(_szListen);
  316.  
  317.     dwResult = ConferenceListen(0);
  318.     LogResult(_szListen, 1, dwResult);
  319.     
  320.     LogTestStop(_szListen);
  321. }
  322.  
  323. /*  C M D  R E M O V E  N O T I F Y */
  324. /*----------------------------------------------------------------------------
  325.     %%Function: CmdRemoveNotify
  326.  
  327.     Removes the specified callback routine
  328.  
  329. ----------------------------------------------------------------------------*/
  330. VOID CmdRemoveNotify(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  331. {
  332.     CONFERR dwResult;
  333.     int i;
  334.  
  335.     LogTestStart(_szRemoveNotify);
  336.     
  337.     if (!DlgRemoveNotify())
  338.     {
  339.         LogTestCancel(_szRemoveNotify);
  340.         return;
  341.     }
  342.     
  343.     dwResult = ConferenceRemoveNotify(gPref.hConf, gPref.hConfNotify);
  344.     LogResult(_szRemoveNotify, 1, dwResult);
  345.     
  346.     if(dwResult == CONFERR_SUCCESS)
  347.     {
  348.         Log1(LOG_NORMAL, "Removed hConfNotify %d", gPref.hConfNotify);
  349.         // Walk array & remove the one we just killed
  350.         for( i = 0; i < giCount; i++)
  351.         {
  352.             if(gPref.hConfNotify == grhConfNotify[i])
  353.             {
  354.                 grhConfNotify[i] = grhConfNotify[giCount-1];
  355.                 giCount--;
  356.                 break;
  357.             }
  358.         }
  359.     }
  360.  
  361.     LogTestStop(_szRemoveNotify);
  362. }
  363.  
  364.  
  365. /*  C M D  S E N D  D A T A */
  366. /*----------------------------------------------------------------------------
  367.     %%Function: CmdSendData
  368.  
  369.     Sends data to other meeting participants.
  370.  
  371.     This example uses the ConferenceSendData API to transmit
  372.     application specific data to all other meeting members.
  373.  
  374.     Note: currently all members of a meeting will receive
  375.     any data transmitted by this API. 
  376.  
  377. ----------------------------------------------------------------------------*/
  378. VOID CmdSendData(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  379. {
  380.     CONFERR dwResult;
  381.     CONFDEST confDest;
  382.  
  383.     LogTestStart(_szSendData);
  384.  
  385.     if (!DlgSendData())
  386.     {
  387.         LogTestCancel(_szSendData);
  388.         return;
  389.     }
  390.  
  391.     InitStruct(&confDest);
  392.     confDest.guid = gPref.guid;
  393.     confDest.dwUserId = gPref.dwRemoteId;
  394.  
  395.     dwResult = ConferenceSendData(gPref.hConf, &confDest,
  396.         gPref.szData, CbSz(gPref.szData), 0);
  397.  
  398.     LogResult(_szSendData, 1, dwResult);
  399.     LogTestStop(_szSendData);
  400.     return;
  401. }
  402.  
  403.  
  404. /*  C M D  S E N D  F I L E */
  405. /*----------------------------------------------------------------------------
  406.     %%Function: CmdSendFile
  407.  
  408.     Sends a file to other meeting participants.
  409.  
  410.     This example uses the ConferenceSendData API to transmit
  411.     application specific data to all other meeting members.
  412.  
  413.     Note: currently all members of a meeting will receive
  414.     any data transmitted by this API. 
  415.  
  416. ----------------------------------------------------------------------------*/
  417. VOID CmdSendFile(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  418. {
  419.     CONFERR dwResult;
  420.     CONFDEST confDest;
  421.     CONFUSERINFO confUserInfo;
  422.     
  423.     LogTestStart(_szSendFile);
  424.  
  425.     if (!DlgSendFile())
  426.     {
  427.         LogTestCancel(_szSendFile);
  428.         return;
  429.     }
  430.  
  431.     InitStruct(&confDest);
  432.     InitStruct(&confUserInfo);
  433.     
  434.     if(0== lstrcmp("<everyone>", gPref.szUserName))
  435.         confDest.dwUserId = 0;
  436.     else
  437.     {
  438.         // scan the array of users and match the name to a UserId 
  439.         for( ; ; )
  440.         {
  441.             dwResult= ConferenceGetInfo(gPref.hConf, CONF_ENUM_USER, &confUserInfo);
  442.             if(dwResult != CONFERR_SUCCESS)
  443.             {
  444.                 if(dwResult != CONFERR_ENUM_COMPLETE)
  445.                 {
  446.                     Log1(LOG_ERROR, "ConferenceGetInfo result=%d -- could not find UserId", dwResult);
  447.                     break;
  448.                 }
  449.                 break;
  450.             }
  451.             if(0 == lstrcmp(confUserInfo.szUserName, gPref.szUserName))
  452.             {
  453.                 confDest.dwUserId = confUserInfo.dwUserId;
  454.                 break;
  455.             }
  456.         }
  457.     }
  458.     
  459.     dwResult = ConferenceSendFile(gPref.hConf, &confDest, gPref.szFileName, CONF_SF_NOWAIT);
  460.     LogResult(_szSendFile, 1, dwResult);
  461.  
  462.     LogTestStop(_szSendFile);
  463. }
  464.  
  465. /*  C M D  S E T  I N F O */
  466. /*----------------------------------------------------------------------------
  467.     %%Function: CmdSetInfo
  468.  
  469.     Set the file transfer receive directory on the local machine
  470.  
  471. ----------------------------------------------------------------------------*/
  472. VOID CmdSetInfo(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  473. {
  474.     CONFERR dwResult;
  475.     CONFRECDIR confRecDir;
  476.  
  477.     LogTestStart(_szSetInfo);
  478.  
  479.     InitStruct(&confRecDir);
  480.  
  481.     if (!FGetDirectory(confRecDir.szRecDir))
  482.     {
  483.         LogTestCancel(_szSetInfo);
  484.         return;
  485.     }
  486.  
  487.     dwResult = ConferenceSetInfo(gPref.hConf, CONF_SET_RECDIR, &confRecDir);
  488.     LogResult(_szSetInfo, 1, dwResult);
  489.  
  490.     dwResult = ConferenceGetInfo(gPref.hConf, CONF_GET_RECDIR, &confRecDir);
  491.     LogResult(_szSetInfo, 2, dwResult);
  492.  
  493.     Log1(LOG_ALWAYS, "Receive Directory [%s]", confRecDir.szRecDir);
  494.  
  495.     LogTestStop(_szSetInfo);
  496. }
  497.  
  498. /*  C M D  S E T  N O T I F Y */
  499. /*----------------------------------------------------------------------------
  500.     %%Function: CmdSetNotify
  501.  
  502.     Sets the notification callback routine
  503.  
  504. ----------------------------------------------------------------------------*/
  505. VOID CmdSetNotify(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  506. {
  507.     CONFERR dwResult;
  508.     CONFNOTIFY confNotify;
  509.     HCONFNOTIFY hConfNotify;
  510.  
  511.     LogTestStart(_szSetNotify);
  512.  
  513.     InitStruct(&confNotify);
  514.  
  515.     confNotify.pfnNotifyProc = MyNotifyProc;
  516.     confNotify.guid = gPref.guid;
  517.  
  518.     dwResult = ConferenceSetNotify(gPref.hConf, &confNotify, &hConfNotify);
  519.     
  520.     if( giCount < 10 )
  521.         grhConfNotify[giCount++] = hConfNotify;
  522.  
  523.     LogResult(_szSetNotify, 1, dwResult);
  524.     Log1(LOG_NORMAL, "Set hConfNotify %d", hConfNotify);
  525.     
  526.     LogTestStop(_szSetNotify);
  527. }
  528.  
  529.  
  530.  
  531. /*  C M D  S H A R E  W I N D O W */
  532. /*----------------------------------------------------------------------------
  533.     %%Function: CmdShareWindow
  534.  
  535.     Shares this test application with other meeting participants.
  536.  
  537.     The coolest API in the world!  This example uses the 
  538.     ConferenceShareWindow API to share this test application 
  539.     with all other meeting participants.
  540.  
  541. ----------------------------------------------------------------------------*/
  542. VOID CmdShareWindow(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  543. {
  544.     CONFERR dwResult;
  545.  
  546.     LogTestStart(_szShareWindow);
  547.  
  548.     dwResult = ConferenceShareWindow(gPref.hConf, hwnd, CONF_SW_SHARE);
  549.     LogResult(_szShareWindow, 1, dwResult);
  550.  
  551.     LogTestStop(_szShareWindow);
  552. }
  553.  
  554.  
  555. /*  C M D  U N  S H A R E  W I N D O W */
  556. /*----------------------------------------------------------------------------
  557.     %%Function: CmdUnShareWindow
  558.  
  559.     Unshares this test application with other meeting participants.
  560.  
  561.     The 2nd coolest API in the world!  This example uses the 
  562.     ConferenceShareWindow API to stop sharing this test application 
  563.     with all other meeting participants.
  564.  
  565. ----------------------------------------------------------------------------*/
  566. VOID CmdUnShareWindow(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  567. {
  568.     CONFERR dwResult;
  569.  
  570.     LogTestStart(_szUnShareWindow);
  571.  
  572.     dwResult = ConferenceShareWindow(gPref.hConf, hwnd, CONF_SW_UNSHARE);
  573.     LogResult(_szUnShareWindow, 1, dwResult);
  574.  
  575.     LogTestStop(_szUnShareWindow);
  576. }
  577.  
  578. /*  C M D  I S  W I N D O W  S H A R E D */
  579. /*----------------------------------------------------------------------------
  580.     %%Function: CmdIsWindowShared
  581.  
  582.     Checks to see if the specified window has been shared successfully.
  583.  
  584.     This example uses the ConferenceIsWindowShared API to check the
  585.     shared status of this test application.  The ConferenceIsWindowShared
  586.     API returns TRUE if the window is currently shared, FALSE if not.
  587.  
  588. ----------------------------------------------------------------------------*/
  589. VOID CmdIsWindowShared(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  590. {
  591.     CONFERR dwResult;
  592.  
  593.     LogTestStart(_szIsWindowShared);
  594.  
  595.     dwResult = ConferenceShareWindow(gPref.hConf, hwnd, CONF_SW_IS_SHARED);
  596.     LogResult(_szIsWindowShared, 1, dwResult);
  597.  
  598.     LogTestStop(_szIsWindowShared);
  599. }
  600.  
  601.  
  602.  
  603.  
  604. /*  C M D  E N U M  U S E R */
  605. /*----------------------------------------------------------------------------
  606.     %%Function: CmdEnumUser
  607.  
  608.     Walk the roster of meeting participants and display user info
  609.  
  610.     This example uses the ConferenceGetInfo API in a loop to display
  611.     user information for all meeting attendees.
  612.  
  613. ----------------------------------------------------------------------------*/
  614. VOID CmdEnumUser(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  615. {
  616.     CONFERR dwResult;
  617.     CONFUSERINFO confUserInfo;
  618.  
  619.     LogTestStart(_szEnumUsers);
  620.  
  621.     InitStruct(&confUserInfo);
  622.  
  623.     for ( ; ; )
  624.     {
  625.         dwResult = ConferenceGetInfo(gPref.hConf, CONF_ENUM_USER, &confUserInfo);
  626.         if (CONFERR_SUCCESS != dwResult)
  627.         {
  628.             if (CONFERR_ENUM_COMPLETE != dwResult)
  629.                 Log1(LOG_ALWAYS, "ConferenceGetInfo result=%d", dwResult);
  630.             break;
  631.         }
  632.         DumpUserInfo(&confUserInfo);
  633.     }
  634.     LogTestStop(_szEnumUsers);
  635. }
  636.  
  637.  
  638. /*  C M D  E N U M  C O N F */
  639. /*----------------------------------------------------------------------------
  640.     %%Function: CmdEnumConf
  641.  
  642.     Enumerate all conferences on the current machine.
  643.  
  644.     Not a very interesting example since we only allow one conference
  645.     at a time right now.  But this example shows how to list all
  646.     conferences on the machine.
  647.  
  648. ----------------------------------------------------------------------------*/
  649. VOID CmdEnumConf(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  650. {
  651.     CONFERR dwResult;
  652.     CONFINFO confInfo;
  653.  
  654.     LogTestStart(_szEnumConfs);
  655.  
  656.     InitStruct(&confInfo);
  657.  
  658.     for ( ; ; )
  659.     {
  660.         dwResult = ConferenceGetInfo(gPref.hConf, CONF_ENUM_CONF, &confInfo);
  661.         if (CONFERR_SUCCESS != dwResult)
  662.         {
  663.             if (CONFERR_ENUM_COMPLETE != dwResult)
  664.                 Log1(LOG_ALWAYS, "ConferenceGetInfo result=%d", dwResult);
  665.             break;
  666.         }
  667.         DumpConfInfo(&confInfo);
  668.         if (0 == confInfo.hConf)
  669.         {
  670.             Log(LOG_ALWAYS, "Null hConf field!");
  671.             break;
  672.         }
  673.     }
  674.     LogTestStop(_szEnumConfs);
  675. }
  676.  
  677.  
  678. /*  C M D  S E T  G U I D */
  679. /*----------------------------------------------------------------------------
  680.     %%Function: CmdSetGuid
  681.  
  682. ----------------------------------------------------------------------------*/
  683. VOID CmdSetGuid(HWND hwnd, WORD wCmd, WORD wNotify, HWND hwndCtrl)
  684. {
  685.     DWORD dwResult;
  686.     CONFGUID confGuid;
  687.  
  688.     LogTestStart(_szSetGuid);
  689.  
  690.     if (!DlgGuid())
  691.         return;
  692.  
  693.     InitStruct(&confGuid);
  694.     confGuid.guid = gPref.guid;
  695.     confGuid.pszApplication  = gPref.szAppName;
  696.     confGuid.pszCommandLine  = gPref.szCmdLine;
  697.     confGuid.pszDirectory  = gPref.szCurrDir;
  698.  
  699.     dwResult = ConferenceSetInfo(gPref.hConf, CONF_SET_GUID, &confGuid);
  700.     LogResult(_szSetGuid, 1, dwResult);
  701.  
  702.     LogTestStop(_szSetGuid);
  703. }
  704.  
  705.  
  706. /*  M Y  N O T I F Y  P R O C */
  707. /*----------------------------------------------------------------------------
  708.     %%Function: MyNotifyProc
  709.  
  710.     The conference notification handler.
  711.  
  712.     Currently this callback sinmply displays the notification messages
  713.     and relevant information in the message window.  
  714.  
  715. ----------------------------------------------------------------------------*/
  716. LONG CALLBACK MyNotifyProc(HCONF hConf, DWORD dwCode, DWORD dwParam, LPVOID lpv1, LPVOID lpv2, DWORD dwUser)
  717. {
  718.     // print the text of the notification message
  719.     Log4(LOG_ALWAYS, "[%s]     [%08X] (%08X, %08X)", GetConfnString(dwCode), dwParam, lpv1, lpv2);
  720.  
  721.  
  722.     // display user or meeting information in the message box.
  723.     switch (dwCode)
  724.         {
  725.     case CONFN_CONFERENCE_INIT:
  726.     case CONFN_CONFERENCE_START:
  727.     case CONFN_CONFERENCE_STOP:
  728.     case CONFN_CONFERENCE_ERROR:
  729.         DumpConfInfo(lpv2);
  730.         break;
  731.  
  732.     case CONFN_USER_ADDED:
  733.     case CONFN_USER_REMOVED:
  734.         DumpUserInfo(lpv2);
  735.         break;
  736.  
  737.     case CONFN_PEER_ADDED:
  738.         Log2(LOG_NORMAL, "Peer Added: dwUserId=%X (%d)", dwParam, dwParam);
  739.         break;
  740.     case CONFN_PEER_REMOVED:
  741.         Log2(LOG_NORMAL, "Peer Removed: dwUserId=%X (%d)", dwParam, dwParam);
  742.         break;
  743.  
  744.     case CONFN_WINDOW_SHARED:
  745.     case CONFN_WINDOW_UNSHARED:
  746.         break;
  747.  
  748.     case CONFN_DATA_SENT:
  749.         Log2(LOG_NORMAL, "Data Send: [%s] %d bytes", lpv2, dwParam);
  750.         break;
  751.     case CONFN_DATA_RECEIVED:
  752.         Log2(LOG_NORMAL, "Data Recv: [%s] %d bytes", lpv2, dwParam);
  753.         break;
  754.  
  755.     case CONFN_FILESEND_START:
  756.         gdwFileId = dwParam;
  757.         break;
  758.     case CONFN_FILESEND_PROGRESS:
  759.         {
  760.             LPCONFFILEINFO lpFile = lpv2;
  761.             Log2(LOG_NORMAL, "File transfer: sent %d of %d bytes", 
  762.                 lpFile->dwBytesTransferred, 
  763.                 lpFile->dwFileSize);
  764.         break;
  765.         }
  766.     case CONFN_FILESEND_COMPLETE:
  767.     case CONFN_FILESEND_ERROR:
  768.         gdwFileId = FileIdNil;
  769.         break;
  770.     case CONFN_FILERECEIVE_START:
  771.         gdwFileId = dwParam;
  772.         break;
  773.     case CONFN_FILERECEIVE_PROGRESS:
  774.         {
  775.             LPCONFFILEINFO lpFile = lpv2;
  776.             Log2(LOG_NORMAL, "File transfer: received %d of %d bytes", 
  777.                 lpFile->dwBytesTransferred, 
  778.                 lpFile->dwFileSize);
  779.         break;
  780.         }
  781.     case CONFN_FILERECEIVE_COMPLETE:
  782.     case CONFN_FILERECEIVE_ERROR:
  783.         gdwFileId = FileIdNil;
  784.         break;
  785.  
  786.     default:
  787.         break;
  788.         } /* dwCode */
  789.  
  790.     return 0;
  791. }
  792.