⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pgpgwserver.cpp

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 CPP
📖 第 1 页 / 共 3 页
字号:
////////////////////////////////////////////////////////////////////////////////
//  File : pgpgwServer.cpp
//
//  Copyright (C) 2002 PGP Corporation
//
//  ABSTRACT
//		Create and handle pgpgwServer Object
// 
//  Author: Satya S. Das
//
////////////////////////////////////////////////////////////////////////////////

// include files 
#include <stdio.h>
#include <ole2.h>
#include <shlwapi.h>

#include "gwc3po.h"
#include "gwc3cmd.h"
#include "pgpgwserver.h"
#include "CommandFactory.h"
#include "EventMonitor.h"
#include "IconFactory.h"
#include "classfactory.h"
#include "crtdbg.h"
#include "pgpdebug.h"
//#include "globals.h"
#include "globdefs.h"
#include "util.h"

// external functions 
extern IUnknown * BuildIUnkDispatch(REFCLSID libid, REFCLSID iid, 
									IUnknown *pIUnk, void *pIFac);
// private data 
//PgpNwClsFactory pncfPluginFatory;

// public functions 
IC3POManager *m_pIMgr;


///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::CPgpGwC3PO	
// 
//  Description:C3po constructor. 
// 
//  In:none
//
//  Out:none
// 
//  Comments:Init objects and set reference count to zero.
///////////////////////////////////////////////////////////////////
CPgpGwC3PO::CPgpGwC3PO()
{
	PgpGwTrace("CPgpGwC3PO::CPgpGwC3PO\n");	
	m_pICmdFact=NULL;//init command factory to null
	m_pIEventMonitor=NULL;//init event monitor to null
	m_pIIconFactory=NULL;//init icon factory to null
	m_pIMgr = NULL;//init C3po manager to null
	m_pIUnkDispServ=NULL;//init C3po IDispatch to null
	m_cRef = 0;//set reference count to zero
}

///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::~CPgpGwC3PO
// 
//  Description:CPgpGwC3PO destructor. See if we have IDispatch 
//				and release it if we do.delete command factory object.
// 
//  In:none
// 
//  Out:none
// 
//  Comments:
///////////////////////////////////////////////////////////////////
CPgpGwC3PO::~CPgpGwC3PO()
{
	PgpGwTrace("CPgpGwC3PO::~CPgpGwC3PO\n");	
	pgpAssert(NULL != m_pIUnkDispServ);
	if(NULL != m_pIUnkDispServ)
	{
		m_pIUnkDispServ->Release();
		m_pIUnkDispServ=NULL;
	}
	
	pgpAssert(NULL != m_pICmdFact);
	if(NULL != m_pICmdFact)
	{
		delete m_pICmdFact;
		m_pICmdFact=NULL;
	}

	pgpAssert(NULL != m_pIEventMonitor);
	if(NULL != m_pIEventMonitor)
	{
		delete m_pIEventMonitor;
		m_pIEventMonitor=NULL;
	}

	pgpAssert(NULL != m_pIIconFactory);
	if(NULL != m_pIIconFactory)
	{
		delete m_pIIconFactory;
		m_pIIconFactory=NULL;
	}
}

///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::Create
// 
//  Description:CPgpGwC3PO create. Create CommandFactory and EventMonitor. 
// 
//  In:none
//
//  Out:return success of create.
// 
//  Comments:
/////////////////////////////////////////////////////////////////////
BOOL CPgpGwC3PO::Create()
{
	PgpGwTrace("CPgpGwC3PO::Create\n");	
	BOOL bRet=TRUE;
	try
	{
		//allocate the member objects

		m_pICmdFact = new CCommandFactory(this);
		if(NULL == m_pICmdFact)
		{
			pgpAssert(FALSE);
			bRet=FALSE;
			throw;
		}

		m_pIEventMonitor = new EventMonitor(this);
		if(NULL == m_pIEventMonitor)
		{
			pgpAssert(FALSE);
			bRet=FALSE;
			throw;
		}

		m_pIIconFactory = new IconFactory(this);
		if(NULL == m_pIIconFactory)
		{
			pgpAssert(FALSE);
			bRet=FALSE;
			throw;
		}
	}
	catch(...)
	{
		bRet=FALSE;
	}

	return bRet;
}



///////////////////////////////////////////////////////////////////
//
//  Name:CPgpGwC3PO::QueryInterface	
// 
//  Description:QueryInterface for CPgpGwC3PO object. 
// 
//  In:REFIID riid - reference id.
//	   LPVOID FAR* ppv - return reference looked for.
// 
//  Out:return Interface, CommandFactory, or build IDispatch object.
// 		If riid not found return no interface found.
//
//  Comments:
///////////////////////////////////////////////////////////////////
STDMETHODIMP CPgpGwC3PO::QueryInterface(REFIID riid, LPVOID FAR* ppv)
{
	PgpGwTrace("CPgpGwC3PO::QueryInterface\n");	
	if(NULL == ppv)
		return E_INVALIDARG;

    *ppv=NULL;

	if((IID_IUnknown == riid) || (IID_IC3POServer == riid))
	{
		*ppv  = this;
		((LPUNKNOWN)*ppv)->AddRef();
		return S_OK;
	}

	if((IID_ICommandFactory == riid) && (NULL != m_pICmdFact))
	{
		*ppv  = m_pICmdFact;
		((LPUNKNOWN)*ppv)->AddRef();
		return S_OK;
	}

	if((IID_IEventMonitor == riid) && (NULL != m_pIEventMonitor))
	{
		*ppv  = m_pIEventMonitor;
		((LPUNKNOWN)*ppv)->AddRef();
		return S_OK;
	}

	if((IID_IIconFactory == riid) && (NULL != m_pIIconFactory))
	{
		*ppv  = m_pIIconFactory;
		((LPUNKNOWN)*ppv)->AddRef();
		return S_OK;
	}

	if(IID_IDispatch == riid)
	{
		if (NULL == m_pIUnkDispServ)
		{
			m_pIUnkDispServ = BuildIUnkDispatch( 
							LIBID_PgpGwTypeLibrary,
							IID_IC3POServer,
							(IUnknown *)(IC3POServer *)this,
							(void *)(IC3POServer *)this);
		}

		pgpAssert(NULL != m_pIUnkDispServ);
		if (NULL != m_pIUnkDispServ)
			return m_pIUnkDispServ->QueryInterface(IID_IDispatch, ppv);
	}

	return E_NOINTERFACE;
}

///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::AddRef	
//
//  Description:Bump reference count.
//
//  In:none
//
//  Out:reference count
//
//  Comments:
/////////////////////////////////////////////////////////////////////
STDMETHODIMP_(ULONG) CPgpGwC3PO::AddRef()
{
	PgpGwTrace("CPgpGwC3PO::AddRef\n");	
	return ++m_cRef;
}

///////////////////////////////////////////////////////////////////
//  Name:			CPgpGwC3PO::Release	
//
//  Description:	decrement reference count. If count goest to zero delete object.
//
//  In:			none
//
//  Out:			reference count
//
//  Comments:
/////////////////////////////////////////////////////////////////////
STDMETHODIMP_(ULONG) CPgpGwC3PO::Release()
{
	PgpGwTrace("CPgpGwC3PO::Release\n");	
	ULONG cRef = --m_cRef;
	if(0 == m_cRef)
	{
		delete this;
	}
	return cRef;
}


// IC3POServer methods

///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::get_CommandFactory	
//
//  Description:This property returns the CommandFactory for the 
//				C3PO. The C3PO server may return NULL.
//
//  In:	IDispatch * FAR* ppIDispCommandFactory - return the IDispatch 
//		pointer
//
//  Out:CommandFactory object or null in not supported
//
//  Comments:If CommandFactory has not been created return S_FALSE.
//
///////////////////////////////////////////////////////////////////
STDMETHODIMP CPgpGwC3PO::get_CommandFactory(IDispatch * FAR* ppIDispCommandFactory)
{
	PgpGwTrace("CPgpGwC3PO::get_CommandFactory\n");	

	//check parameters passed
	pgpAssert(NULL != ppIDispCommandFactory);
	if(NULL == ppIDispCommandFactory)
		return 	E_INVALIDARG;

	//nullify the param before writing anything
	*ppIDispCommandFactory=NULL;

	if(NULL != m_pICmdFact)//if we have inited the command factory
	{
		//return the dispatch interface to the object
		return m_pICmdFact->QueryInterface(IID_IDispatch, 
					(void**)ppIDispCommandFactory);
	}

	return S_FALSE;
}

///////////////////////////////////////////////////////////////////
//
//  Name:CPgpGwC3PO::get_Description	
//
//  Description:Returns a human readable description of the C3PO server.
//
//  In:BSTR FAR* pbstrDescription - pointer to description.
//
//  Out:return string description
//
//  Comments:
/////////////////////////////////////////////////////////////////////
STDMETHODIMP CPgpGwC3PO::get_Description(BSTR FAR* pbstrDescription)
{
	PgpGwTrace("CPgpGwC3PO::get_Description\n");		

	//check parameters passed to us
	pgpAssert(NULL != pbstrDescription);
	if(NULL == pbstrDescription)
		return E_INVALIDARG;
	
	*pbstrDescription = SysAllocString(L"PGP plugin for GroupWise");
	if(NULL == *pbstrDescription)
		return E_OUTOFMEMORY;

	pgpAssert(NULL != *pbstrDescription);
	return S_OK;
}

///////////////////////////////////////////////////////////////////
//  Name:CPgpGwC3PO::get_EventMonitor	
//
//  Description:This property returns the event monitor for the C3PO.  
//				The C3PO server may return NULL. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -