コード例 #1
0
// ClientCDKey::CreateSymmetricKey
// Creates a symmetric key from product name used to save/load CD-Key to/from
// the registry.  Symmetric key is created via a series of CRCs on the product.
void
ClientCDKey::CreateSymmetricKey(BFSymmetricKey& theSymKeyR) const
{
	WTRACE("ClientCDKey::CreateSymmetricKey");
	WDBG_LL("ClientCDKey::CreateSymmetricKey from product=" << mProduct);
	CRC16     aCRC;
	RawBuffer aBuf;

	// CRC the product and use it as 1st 2 bytes of key
	aCRC.Put(mProduct);
	unsigned short aCheckSum = aCRC.GetCRC();
	WDBG_LL("ClientCDKey::CreateSymmetricKey First CRC=" << aCheckSum);
	aBuf.assign(reinterpret_cast<unsigned char*>(&aCheckSum), sizeof(aCheckSum));

	// CRC each of 1st 3 chars of product and add them to key.
	for (int i=0; (i < 3) && (i < mProduct.size()); i++)
	{
		aCRC.Put(static_cast<unsigned char>(mProduct[i]));
		aCheckSum = aCRC.GetCRC();
		WDBG_LL("ClientCDKey::CreateSymmetricKey Add CRC=" << aCheckSum);
		aBuf.append(reinterpret_cast<unsigned char*>(&aCheckSum), sizeof(aCheckSum));
	}

	// Create the key
	WDBG_LL("ClientCDKey::CreateSymmetricKey Buf=" << aBuf);
	theSymKeyR.Create(aBuf.size(), aBuf.data());
}
コード例 #2
0
ファイル: ChatView.cpp プロジェクト: vgck/opendr2
void CChatView::CreateBoard(const CString& theRoomName)
{
	// Our Document
	CWhiteBoardDoc* pDoc = (CWhiteBoardDoc*)GetDocument();

	// Construct the objects for CreateDataObjectEx
	RawBuffer aObjectName(OBJ_GAMEPREFIX + (unsigned char*)(LPCSTR)theRoomName);
	RawBuffer aObject;

	pDoc->mObserverIds[0] = pDoc->mRoutingServer.GetClientId();
	pDoc->mNumObservers = 1;						/* only 1 since we just created it */
	aObject.assign((unsigned char*)pDoc->mObserverIds);

	pDoc->mRoutingServer.CreateDataObjectEx(RoutingServerClient::GROUPID_ALLUSERS, aObjectName, pDoc->mRoutingServer.GetClientId(), 0, aObject, (void(*)(short, CChatView*))CreateDataObjectCallback, this);
}
コード例 #3
0
ファイル: WhiteBoardView.cpp プロジェクト: vgck/opendr2
/********************************************************************************
 * Whenever the mouse moves. We need to track the path of each stroke			*
 ********************************************************************************/
void CWhiteBoardView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// Our Document
	CWhiteBoardDoc* pDoc = GetDocument();

	// If we're not drawing we don't need to process a mouse release
	if (bIsDrawing==false)
	{
		CScrollView::OnLButtonUp(nFlags, point);
		return;
	}

	// Finish the stroke
	

	// If we're connected to a board room let's relay this stroke to any observers
	if (pDoc->bOnBoard)
	{
		// Allocate a linear buffer for data storage (5 = size of message header)
		int buf_size = pDoc->m_pCurStroke->GetSize();
		unsigned char* pDataBuffer = new unsigned char[buf_size];

		// Store the stroke data into the buffer
		pDoc->m_pCurStroke->StoreToBuffer(pDataBuffer);

		// Copy the character buffer into a server readable rawbuffer for net transfer
		RawBuffer theRawBuf;
		theRawBuf.assign(pDataBuffer, buf_size);
		
		// Relay the stroke to all observers
		pDoc->mRoutingServer.SendData(pDoc->mObserverIds, pDoc->mNumObservers, true, theRawBuf, false);

		// delete our linear buffer
		delete[] pDataBuffer;
	}

	// Release the mouse, we don't need it anymore
	ReleaseCapture();

	// No Longer Drawing
	bIsDrawing = false;
	pDoc->m_pCurStroke = NULL;

	// Call the base class implementation
	CScrollView::OnLButtonUp(nFlags, point);
}