/* ----------------------------------------------------------------------


	EZCONF sample for Microsoft ActiveX Conferencing

	Copyright (c) 1996, Microsoft Corporation
	All rights reserved.

	ezconf.c

  ---------------------------------------------------------------------- */

#define _OLE2_H_

// System Include files
#include <windows.h>
#include <msconf.h>

#define ClearStruct(lpv)		ZeroMemory((LPVOID) (lpv), sizeof(*(lpv)))
#define InitStruct(lpv)        {ClearStruct(lpv); (* (LPDWORD) lpv) = sizeof(*(lpv));}


/*  D L L  M A I N */
/*-------------------------------------------------------------------------
	%%Function: DllMain

	Avoid loading the default DllMain.
-------------------------------------------------------------------------*/
BOOL WINAPI DllMain(HANDLE hInst, ULONG ulReason, LPVOID lpvReserved)
{
	return TRUE;
}


/*  C O N F  C O N N E C T */
/*----------------------------------------------------------------------------
    %%Function: ConfConnect
 
    Accepts a machine name as a parameter & fills in the structure
    before making the API call.
----------------------------------------------------------------------------*/
DWORD WINAPI ConfConnect(LPCTSTR szUser)
{
	HCONF    hConf;
	CONFINFO confInfo;
	CONFADDR confAddr;

	InitStruct(&confInfo);
	if (CONFERR_SUCCESS == ConferenceGetInfo(NULL, CONF_ENUM_CONF, &confInfo))
	{
		hConf = confInfo.hConf;
	}
	else
	{
		hConf = NULL;
	}

	InitStruct(&confAddr);
	if ((NULL == szUser) || ('\0' == szUser[0]))
	{
		confAddr.dwAddrType = CONF_ADDR_UNKNOWN;
	}
	else
	{
		confAddr.dwAddrType = CONF_ADDR_MACHINENAME;
		confAddr.psz = (PTSTR)szUser;
	}

	InitStruct(&confInfo);
	confInfo.dwMediaType = CONF_MT_DATA;

	return ConferenceConnect(&hConf, &confAddr, &confInfo, NULL);
}



/* C O N F  S E N D  F I L E */
/*-------------------------------------------------------------------------
	%%Function: ConfSendFile

	Do ALL the work necessary to send a simple file.
-------------------------------------------------------------------------*/
DWORD WINAPI ConfSendFile(LPCTSTR szFile)
{
	if ((NULL == szFile) || ('\0' == szFile[0]))
		return CONFERR_SUCCESS;  // nothing to do?

	if (MAX_PATH <= lstrlen(szFile))
		return CONFERR_INVALID_PARAMETER;

	return ConferenceSendFile(NULL, NULL, szFile, CONF_SF_NOWAIT);
}	



/*  F  I N  D A T A  C O N F */
/*----------------------------------------------------------------------------
    %%Function: FInDataConf

	Return TRUE if in a data conference
----------------------------------------------------------------------------*/
BOOL WINAPI FInDataConf(VOID)
{
	DWORD  dwResult;
	CONFINFO confInfo;

	ZeroMemory(&confInfo, sizeof(confInfo));
	confInfo.dwSize = sizeof(confInfo);
	dwResult = ConferenceGetInfo(NULL, CONF_GET_CONF, &confInfo);
	if (CONFERR_SUCCESS != dwResult)
		return FALSE;
	return (0 != (confInfo.dwMediaType & CONF_MT_DATA));
}
