Example #1
0
void Pen::activating()
{
  KDEBUG1(KDEBUG_INFO, 3000, "Pen::activating() hook called canvas=%p\n", canvas);
  drawing= FALSE;

  canvas->setCursor(crossCursor);
}
Example #2
0
// ------------------------------------------------------------------------- //
//	*�Write( const void*, KUInt32* )
// ------------------------------------------------------------------------- //
void
TDCLBufferedPipe::Write( const void* inBuffer, KUInt32* ioCount )
{
	KDEBUG1( "Write( inBuffer, ioCount = %u)", (unsigned int) *ioCount );

	// On remplit la m�moire tampon.
	KUInt32 toWrite = *ioCount;
	const KUInt8* theBuffer = (const KUInt8*) inBuffer;
	try {
		while (toWrite > 0)
		{
			// Remplissage de la m�moire tampon.
			KUInt32 copyAmount = toWrite;
			if (copyAmount + mBufferSize > mBufferCapacity)
			{
				copyAmount = mBufferCapacity - mBufferSize;
			}
			
			(void) ::memcpy(
				&((KUInt8*) mBuffer)[mBufferSize], theBuffer, copyAmount );
			
			mBufferSize += copyAmount;
			
			// Envoi des donn�es si la m�moire tampon est pleine.
			if (mBufferSize == mBufferCapacity)
			{
				KUInt32 actualAmountWritten = mBufferSize;
				try {
					GetSubPipe()->Write( mBuffer, &actualAmountWritten );
				} catch (...) {
					if (mBufferSize != actualAmountWritten)
					{
						// D�placement des donn�es.
						(void) ::memmove(
									(void*) mBuffer,
									&((const KUInt8*) mBuffer)
													[actualAmountWritten],
									mBufferSize - actualAmountWritten );
						mBufferSize -= actualAmountWritten;
					}
					throw;
				}

				mBufferSize = 0;
			}
			
			toWrite -= copyAmount;
			theBuffer += copyAmount;
		}
	} catch ( ... ) {
		// Mise � jour de ce qu'on a r�ussi � �crire.
		*ioCount -= toWrite;
		throw;	// On relance.
	}
}
Example #3
0
// ------------------------------------------------------------------------- //
//  * BytesAvailable( void )
// ------------------------------------------------------------------------- //
Boolean
TDCLBSDSocket::TBSDSocketPipe::BytesAvailable( void )
{
	timeval timeout;
	fd_set socketSet;

	FD_ZERO( &socketSet );
	FD_SET( mClientSocket, &socketSet );

	timeout.tv_sec = 0;		// secondes
	timeout.tv_usec = 0;	// microsecondes

	// D�lai de temporisation � 0 pour savoir si on peut lire maintenant.
	int readySockets =
		::select( mClientSocket + 1, &socketSet, NULL, NULL, &timeout );

	if (readySockets == -1)
	{
		// Erreur.
		int theErr = errno;

		switch (theErr)
		{
			case EINVAL:
				throw DCLPlatformBadParamError( theErr );
			
			case EBADF:
				KDEBUG( "BytesAvailable: EBADF" );
				break;

			case EINTR:
				KDEBUG( "BytesAvailable: EINTR" );
				break;
			
			default:
				throw DCLPlatformUnknownError( theErr );
 		}
	}

	KDEBUG1( "BytesAvailable: %i", readySockets );

	return (readySockets > 0);
}
Example #4
0
// ------------------------------------------------------------------------- //
//  * WaitForIncomingData( void )
// ------------------------------------------------------------------------- //
Boolean
TDCLBSDSocket::TBSDSocketPipe::WaitForIncomingData( void )
{
	Boolean theResult = false;
	
	// Petit select pour attendre.
	fd_set socketSet;
	FD_ZERO( &socketSet );
	FD_SET( mClientSocket, &socketSet );
	FD_SET( mPrivatePairMember, &socketSet );

	int maxSocketNb =
		mClientSocket > mPrivatePairMember
			? mClientSocket : mPrivatePairMember;

	KDEBUG3(
		"WaitForIncomingData::before select (max= %i, client=%i, prv=%i)",
		maxSocketNb, mClientSocket, mPrivatePairMember );

	int readySockets = ::select(
							maxSocketNb + 1, &socketSet, NULL, NULL, NULL );

	if (readySockets == -1)
	{
		// Erreur.
		int theErr = errno;

		switch (theErr)
		{
			case EINVAL:
				throw DCLPlatformBadParamError( theErr );
			
			case EBADF:
				KDEBUG( "WaitForIncomingData: EBADF" );
				break;

			case EINTR:
				KDEBUG( "WaitForIncomingData: EINTR" );
				break;
						
			default:
				throw DCLPlatformUnknownError( theErr );
 		}
	} else if (readySockets > 0) {
		if (FD_ISSET( mPrivatePairMember, &socketSet ))
		{
			KDEBUG( "WaitForIncomingData: private isset" );

			// On vide la paire.
			char someByte;
			while (
				::recv(
						mPrivatePairMember,
						&someByte,
						sizeof(someByte), 0 ) >= 0)
			{
				// Kilroy was here.
			};
		} else {
			KDEBUG( "WaitForIncomingData: theResult = true" );
			theResult = true;
		}
	}
	
	KDEBUG1( "...WaitForIncomingData: theResult = %c", theResult );

	return theResult;
}