Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / MFC

Sinking connection points in C++ objects

Rate me:
Please Sign up or sign in to vote.
1.80/5 (2 votes)
5 Jun 2002CPOL5 min read 132.3K   1.2K   44  
Sometimes it would be nice to be able to use a simple C++ object as a sink for Connection Point notifications. This article shows you how.
///////////////////////////////////////////////////////////////////////////////
//
// File           : $Workfile: NMException.cpp $
// Version        : $Revision: 2 $
// Function       : 
//
// Author         : $Author: Len $
// Date           : $Date: 30/05/02 18:20 $
//
// Notes          : 
//
// Modifications  :
//
// $Log: /JetByteTools/NMTools/NMException.cpp $
// 
// 2     30/05/02 18:20 Len
// Lint issues.
// 
// 1     22/05/02 15:15 Len
// 
///////////////////////////////////////////////////////////////////////////////
//
// Copyright 1997 - 2002 JetByte Limited.
//
// JetByte Limited grants you ("Licensee") a non-exclusive, royalty free, 
// licence to use, modify and redistribute this software in source and binary 
// code form, provided that i) this copyright notice and licence appear on all 
// copies of the software; and ii) Licensee does not utilize the software in a 
// manner which is disparaging to JetByte Limited.
//
// This software is provided "as is" without a warranty of any kind. All 
// express or implied conditions, representations and warranties, including
// any implied warranty of merchantability, fitness for a particular purpose
// or non-infringement, are hereby excluded. JetByte Limited and its licensors 
// shall not be liable for any damages suffered by licensee as a result of 
// using, modifying or distributing the software or its derivatives. In no
// event will JetByte Limited be liable for any lost revenue, profit or data,
// or for direct, indirect, special, consequential, incidental or punitive
// damages, however caused and regardless of the theory of liability, arising 
// out of the use of or inability to use software, even if JetByte Limited 
// has been advised of the possibility of such damages.
//
// This software is not designed or intended for use in on-line control of 
// aircraft, air traffic, aircraft navigation or aircraft communications; or in 
// the design, construction, operation or maintenance of any nuclear 
// facility. Licensee represents and warrants that it will not use or 
// redistribute the Software for such purposes. 
//
///////////////////////////////////////////////////////////////////////////////

//lint +libh(NmInterfaces.h) "library" header that we can do nothing with
#include "NmInterfaces.h"
#include "NmException.h"

///////////////////////////////////////////////////////////////////////////////
// Lint options
//
//lint -save
//
//lint -e650 constant out of range in switch statement
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// Using directives
///////////////////////////////////////////////////////////////////////////////

using JetByteTools::Win32::_tstring;

///////////////////////////////////////////////////////////////////////////////
// Namespace: JetByteTools::NetMeeting
///////////////////////////////////////////////////////////////////////////////

namespace JetByteTools {
namespace NetMeeting {

///////////////////////////////////////////////////////////////////////////////
// CNmException
///////////////////////////////////////////////////////////////////////////////

CNmException::CNmException(
   const _tstring &where, 
   HRESULT hr)
   :  CException(where, hr)
{

}

_tstring CNmException::GetMessage() const 
{ 
	LPCTSTR pMessage = 0;

	switch (m_error)
	{
		case NM_S_NEXT_CONFERENCE :
			pMessage = _T("NM_S_NEXT_CONFERENCE");
		break;

		case NM_S_ON_RESTART :
			pMessage = _T("NM_S_ON_RESTART");
		break;

		case NM_CALLERR_NOT_INITIALIZED :
			pMessage = _T("NM_CALLERR_NOT_INITIALIZED");
		break;

		case NM_CALLERR_MEDIA :
			pMessage = _T("NM_CALLERR_MEDIA");
		break;

		case NM_CALLERR_NAME_RESOLUTION :
			pMessage = _T("NM_CALLERR_NAME_RESOLUTION");
		break;

		case NM_CALLERR_PASSWORD :
			pMessage = _T("NM_CALLERR_PASSWORD");
		break;

		case NM_CALLERR_CONFERENCE_NAME :
			pMessage = _T("NM_CALLERR_CONFERENCE_NAME");
		break;

		case NM_CALLERR_IN_CONFERENCE :
			pMessage = _T("NM_CALLERR_IN_CONFERENCE");
		break;

		case NM_CALLERR_NOT_FOUND :
			pMessage = __T("NM_CALLERR_NOT_FOUND");
		break;

		case NM_CALLERR_MCU :
			pMessage = _T("NM_CALLERR_MCU");
		break;

		case NM_CALLERR_REJECTED :
			pMessage = _T("NM_CALLERR_REJECTED");
		break;

		case NM_CALLERR_AUDIO :
			pMessage = _T("NM_CALLERR_AUDIO");
		break;

		case NM_CALLERR_AUDIO_LOCAL :
			pMessage = _T("NM_CALLERR_AUDIO_LOCAL");
		break;

		case NM_CALLERR_AUDIO_REMOTE :
			pMessage = _T("NM_CALLERR_AUDIO_REMOTE");
		break;

		case NM_CALLERR_UNKNOWN :
			pMessage = _T("NM_CALLERR_UNKNOWN");
		break;

		case NM_E_NOT_INITIALIZED :
			pMessage = _T("NM_E_NOT_INITIALIZED");
		break;

		case NM_E_CHANNEL_ALREADY_EXISTS :
			pMessage = _T("NM_E_CHANNEL_ALREADY_EXISTS");
		break;

		case NM_E_NO_T120_CONFERENCE :
			pMessage = _T("NM_E_NO_T120_CONFERENCE");
		break;

		case NM_E_NOT_ACTIVE :
			pMessage = _T("NM_E_NOT_ACTIVE");
		break;

      default :

         // do nothing
      
      break;
	}

	if (!pMessage)
	{
		pMessage = CException::GetMessage().c_str();
	}

	return pMessage;
}

///////////////////////////////////////////////////////////////////////////////
// Namespace: JetByteTools::NetMeeting
///////////////////////////////////////////////////////////////////////////////

} // End of namespace NetMeeting
} // End of namespace JetByteTools 

///////////////////////////////////////////////////////////////////////////////
// Lint options
//
//lint -restore
//
///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////
// End of file...
///////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) JetByte Limited
United Kingdom United Kingdom
Len has been programming for over 30 years, having first started with a Sinclair ZX-80. Now he runs his own consulting company, JetByte Limited and has a technical blog here.

JetByte provides contract programming and consultancy services. We can provide experience in COM, Corba, C++, Windows NT and UNIX. Our speciality is the design and implementation of systems but we are happy to work with you throughout the entire project life-cycle. We are happy to quote for fixed price work, or, if required, can work for an hourly rate.

We are based in London, England, but, thanks to the Internet, we can work 'virtually' anywhere...

Please note that many of the articles here may have updated code available on Len's blog and that the IOCP socket server framework is also available in a licensed, much improved and fully supported version, see here for details.

Comments and Discussions