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

📄 pgpgwtph.cpp

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 CPP
📖 第 1 页 / 共 4 页
字号:
			PgpGwTrace("(BFTKN_SPELLER)\n");
			break;
		case BFTKN_SHOW_LOOKER:
			PgpGwTrace("(BFTKN_SHOW_LOOKER)\n");
			break;
		case BFTKN_VIEW_ATTACH:
			PgpGwTrace("(BFTKN_VIEW_ATTACH)\n");
			break;
		case BFTKN_OPEN_ATTACH:
			PgpGwTrace("(BFTKN_OPEN_ATTACH)\n");
			break;
		case BFTKN_VIEW_HTML:
			PgpGwTrace("(BFTKN_VIEW_HTML)\n");
			break;
		case BFTKN_VIEW_RTF:
			PgpGwTrace("(BFTKN_VIEW_RTF)\n");
			break;
		default:
			PgpGwTrace("(unknown)\n");
			break;
	}
	PgpGwTrace("                      cParam=%#x\n", lpTokenData->lpToken->cParam);
	PgpGwTrace("                      dwFlags=%#x\n", lpTokenData->lpToken->dwFlags);
	PgpGwTrace("                      dwReserved=%#x\n", lpTokenData->lpToken->dwReserved);

	//if there are any parameters
	if(lpTokenData->lpToken->cParam > 0)
	{
		for(unsigned int uiParamCount=0; uiParamCount < lpTokenData->lpToken->cParam; uiParamCount++)
		{
			PgpGwTrace("\n                      param%d:", uiParamCount+1);	
			PgpGwTrace("flags=%#x:type=%#x,", lpTokenData->lpToken->rgParam[uiParamCount].eType,
						lpTokenData->lpToken->rgParam[uiParamCount].wFlags);
			switch(lpTokenData->lpToken->rgParam[uiParamCount].eType)
			{
				case eParmBoolean://'C' BOOL type
					PgpGwTrace("eParmBoolean,value=%#x",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue);
					break;
				case eParmByteSigned://signed 8-bit value
					PgpGwTrace("eParmByteSigned, value=%#x",
						*(LPBYTE)(lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr));
					break;
				case eParmByteUnsigned://unsigned 8-bit value
					PgpGwTrace("eParmByteUnsigned, value=%#x",
						*(LPBYTE)(lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr));
					break;
				case eParmCentimeters://double
					PgpGwTrace("eParmCentimeters, value=%f",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.drValue);
					break;
				case eParmDwordSigned://signed 32-bit value
					PgpGwTrace("eParmDwordSigned, value=%#x",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue);
					break;
				case eParmDwordUnsigned://unsigned 32-bit value
					PgpGwTrace("eParmDwordUnsigned, value=%#x",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue);
					break;
				case eParmDWPUSigned://signed 32-bit unit (WPU)
					PgpGwTrace("eParmDWPUSigned, value=%#x",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue);
					break;
				case eParmDWPUUnsigned://unsigned 32-bit unit (WPU)
					PgpGwTrace("eParmDWPUUnsigned, value=%#x",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue);
					break;
				case eParmEnumeration://enumeration 16-bit value
					PgpGwTrace("eParmEnumeration, value=%#x",
						*(LPWORD)&(lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue));
					break;
				case eParmFloat://double
					PgpGwTrace("eParmFloat, value=%f",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.drValue);
					break;
				case eParmInches://double
					PgpGwTrace("eParmInches, value=%f",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.drValue);
					break;
				case eParmMillimeters://double
					PgpGwTrace("eParmMillimeters, value=%f",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.drValue);
					break;
				case eParmPoints://double
					PgpGwTrace("eParmPoints, value=%f",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.drValue);
					break;
				case eParmStringAnsi://ANSI string (zero terminated)
					PgpGwTrace("eParmStringAnsi, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmStringLabel://WPCORP Word STring (zero terminated) containing a label reference.
					PgpGwTrace("eParmStringLabel, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmStringOem://OEM string (zero terminated)
					PgpGwTrace("eParmStringOem, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmStringWord://WPCORP Word String (zero terminated)
					PgpGwTrace("eParmStringWord, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmStringVariable://word string containing a variable name
					PgpGwTrace("eParmStringVariable, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmTokenID://unsigned 16-bit value
					PgpGwTrace("eParmTokenID, value=%#x",
						*(LPWORD)(lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr));
					break;
				case eParmWordSigned://signed 16-bit value
					PgpGwTrace("eParmWordSigned, value=%#x",
						*(LPWORD)&(lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue));
					break;
				case eParmWordUnsigned://unsigned 16-bit value
					PgpGwTrace("eParmWordUnsigned, value=%#x",
						*(LPWORD)&(lpTokenData->lpToken->rgParam[uiParamCount].uData.dwValue));
					break;
				case eParmWPFname://ANSI string (zero terminated) containing a file name.
					PgpGwTrace("eParmWPFname, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmWPUSigned:// signed 16-bit unit (WPU)
					PgpGwTrace("eParmWPUSigned, value=%#x",
						*(LPWORD)(lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr));
					break;
				case eParmWPUUnsigned://unsigned 16-bit unit (WPU)
					PgpGwTrace("eParmWPUUnsigned, value=%#x",
						*(LPWORD)(lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr));
					break;
				case eParmUserDialog://user dialog buffer (like a string)
					PgpGwTrace("eParmUserDialog, value=%s",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eParmStringWide://Wide/Unicode (zero terminated)
					PgpGwTrace("eParmStringWide, value=%S",
						lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr);
					break;
				case eValArrayDefinition://definition of an array
					PgpGwTrace("eValArrayDefinition, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValBoolean://'C' BOOL type
					PgpGwTrace("eValBoolean, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValCentimeters://double
					PgpGwTrace("eValCentimeters, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValFloat://double
					PgpGwTrace("eValFloat, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValInches://double
					PgpGwTrace("eValInches, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValInteger://signed 32-bit value
					PgpGwTrace("eValInteger, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValMillimeters://double
					PgpGwTrace("eValMillimeters, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValOLEObject://???
					PgpGwTrace("eValOLEObject, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValPoints://double
					PgpGwTrace("eValPoints, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValString://WPCORP Word String (zero terminated)
					PgpGwTrace("eValString, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValStringAnsi://ANSI string (zero terminated)
					PgpGwTrace("eValStringAnsi, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValStringOem://OEM string (zero terminated)
					PgpGwTrace("eValStringOem, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValWPUnits://signed 32-bit unit (WPU)
					PgpGwTrace("eValWPUnits, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValAlias://used for reference parameters
					PgpGwTrace("eValAlias, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValRecord://definition of a record
					PgpGwTrace("eValRecord, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValDateTime://unsigned 32-bit value
					PgpGwTrace("eValDateTime, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValRawBinary://raw binary data type
					PgpGwTrace("eValRawBinary, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				case eValStringWide://Wide/Unicode (zero terminated)
					PgpGwTrace("eValStringWide, value=???"	
						/*lpTokenData->lpToken->rgParam[uiParamCount].uData.lpvPtr*/);
					break;
				default:
					PgpGwTrace("unknown/unexpected, value=???");
					break;
			}
		}
		PgpGwTrace("\n");	
	}

	PgpGwTrace("\n");
#endif
}


BOOL PrepareMsgRecipientsArray(BSTR bstrMessageId, char ***pppszRecipients, DWORD& dwNoOfRecips)
{
	char szTokenBuf[255]={0};
	UINT uiRecipIndex=0;
	UINT uiElemsAlloced=0;
	BSTR bstrRecipients=NULL;
	char *pszRecipients=NULL, **ppszRecipArray=NULL;
	char *pTmpToken=NULL;
	char *pszToRecips=NULL, *pszCcRecips=NULL, *pszBccRecips=NULL;
	char *pszRecipSeparator=NULL;
	DWORD dwLenReqd=0;
	HRESULT hrRet=S_OK;
	BOOL bRet=FALSE;

	//check parameters passed
	pgpAssert((NULL != bstrMessageId) && (0 != bstrMessageId[0]));//not null message id string
	pgpAssert(NULL != pppszRecipients);//should be not null pointer since we are gonna dereference it
	if((NULL == bstrMessageId) || (0 == bstrMessageId[0]) || 
	   (NULL == pppszRecipients))
		goto cleanup;

	//get the "TO" recipient(s)
	ZeroMemory(szTokenBuf, sizeof(szTokenBuf));
	sprintf(szTokenBuf, "ItemGetText(\"%S\";0)", bstrMessageId); 
	hrRet=Publish(szTokenBuf, &bstrRecipients);
	if(FAILED(hrRet))
	{
		pgpAssert(FALSE);
		goto cleanup;
	}
	
	//if there are invalid recipients in the TO list or no recipients at all
	if(L'\0' == bstrRecipients[0])
	{
		//groupwise does not allow mails without any to addresses.
		//invalid addresses always lead to prompting the user with 
		//the address book. so let us bail out of doing our stuff.
		goto cleanup;
	}

	//copy the recipients to an ansi string
	pszToRecips=ConvertToAnsi(bstrRecipients);
	pgpAssert(NULL != pszToRecips);

	//get the CC recipients
	ZeroMemory(szTokenBuf, sizeof(szTokenBuf));
	sprintf(szTokenBuf, "ItemGetText(\"%S\";2)", bstrMessageId); 
	hrRet=Publish(szTokenBuf, &bstrRecipients);
	if(FAILED(hrRet))
	{
		pgpAssert(FALSE);
		goto cleanup;
	}

	//copy the carbon copy recipients to an ansi string
	pszCcRecips=ConvertToAnsi(bstrRecipients);
	pgpAssert(NULL != pszCcRecips);

	//get the BCC recipients
	ZeroMemory(szTokenBuf, sizeof(szTokenBuf));
	sprintf(szTokenBuf, "ItemGetText(\"%S\";3)", bstrMessageId); 
	hrRet=Publish(szTokenBuf, &bstrRecipients);
	if(FAILED(hrRet))
	{
		pgpAssert(FALSE);
		goto cleanup;
	}

	//copy the blind carbon copy recipients to an ansi string
	pszBccRecips=ConvertToAnsi(bstrRecipients);
	pgpAssert(NULL != pszBccRecips);

	//figure out the length of the string that has all these recipients
	dwLenReqd += strlen(pszToRecips);
	dwLenReqd += strlen(pszCcRecips);
	dwLenReqd += strlen(pszBccRecips);

	//if we need to allocate
	if(dwLenReqd > 0)
	{
		//allocate buffer for the combined recipients string
		pszRecipients=(char *)calloc(dwLenReqd+10, 1);
		pgpAssert(NULL != pszRecipients);
		if(NULL == pszRecipients)
			goto cleanup;

		//get the character that separates the recipients
		_VERIFY(TRUE == SafeLoadString(IDS_RECIPIENT_SEPARATOR, &pszRecipSeparator));
		if(NULL == pszRecipSeparator)
			goto cleanup;

		//copy the strings to the buffer. 
		strcat(pszRecipients, pszToRecips);//add the to recipients

		if('\0' != pszCcRecips[0])//if there are cc recipients
		{
			//if there are any recipients in the master list already
			if((NULL != pszRecipients[0]) && 
			   (pszRecipSeparator[0] != pszRecipients[strlen(pszRecipients)]))//and there is no semicolon at the end
			   strcat(pszRecipients, pszRecipSeparator);

			//add the cc recipients
			strcat(pszRecipients, pszCcRecips);
		}

		if('\0' != pszBccRecips[0])//if there are bcc recipients
		{
			//if there are any recipients in the master list already
			if((NULL != pszRecipients[0]) && 
			   (pszRecipSeparator[0] != pszRecipients[strlen(pszRecipients)]))//and there is no semicolon at the end
			   strcat(pszRecipients, pszRecipSeparator);

			//add the bcc recipients
			strcat(pszRecipients, pszBccRecips);
		}

		//get the recipients as tokens from this string
		while(NULL != (pTmpToken=strtok(pTmpToken?NULL:pszRecipients, pszRecipSeparator)))
		{
			//if we are trying to write just beyond our current allocation
			if(uiRecipIndex == uiElemsAlloced)
			{
				UINT uiChunkSize=32;//everytime we run out of space we allocate space for 32 more pointers
				char **ppchTmpPtr=(char **)realloc(ppszRecipArray, (uiElemsAlloced+uiChunkSize)*sizeof(char *));
				pgpAssert(NULL != ppchTmpPtr);
				if(NULL == ppchTmpPtr)
					goto cleanup;//realloc failed !!
				
				//zero out the newly allocated bytes
				ZeroMemory(ppchTmpPtr+uiElemsAlloced, uiChunkSize*sizeof(char *));
				ppszRecipArray=ppchTmpPtr;
				uiElemsAlloced += uiChunkSize;
			}

			//trim the token of any leading or trailing spaces. our pgp stuff
			//gets fooled by spaces in the names.
			StrTrim(pTmpToken, " ");

			//remember the pointer 
			ppszRecipArray[uiRecipIndex++]=pTmpToken;
		}
	}

	//copy the array to the out param passed to us
	*pppszRecipients=ppszRecipArray;
	dwNoOfRecips=uiRecipIndex;
	bRet=TRUE;//all success

	cleanup:
	if(NULL != bstrRecipients)
	{
		SysFreeString(bstrRecipients);
		bstrRecipients=NULL;
	}
	if(NULL != pszToRecips)
	{
		delete pszToRecips;
		pszToRecips=NULL;
	}
	if(NULL != pszCcRecips)
	{
		delete pszCcRecips;
		pszCcRecips=NULL;
	}
	if(NULL != pszBccRecips)
	{
		delete pszBccRecips;
		pszBccRecips=NULL;
	}
	if(NULL != pszRecipSeparator)
	{
		free(pszRecipSeparator);
		pszRecipSeparator=NULL;
	}
	if(FALSE == bRet)//if we failed
	{
		//free the recipient array
		if(NULL != pszRecipients)
		{
			free(pszRecipients);
			pszRecipients=NULL;
		}

		if(NULL != ppszRecipArray)
		{
			free(ppszRecipArray);
			ppszRecipArray=NULL;
		}
	}
	return bRet;
}

⌨️ 快捷键说明

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