コード例 #1
0
// -----------------------------------------------------------------------------
// RMediatorServer::CancelCommand
// Cancels ongoing command in Mediator
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt RMediatorServer::CancelCommand( TUid aDomain, 
                                     TUid aCategory, 
                                     TInt aCommandId )
    {
    LOG(_L("[Mediator Server]\t RMediatorServer::CancelCommand\n")); 
    
    //  Check that session is open.
    __ASSERT_DEBUG( Handle(), User::Panic( KMediatorServerPanic, 
                                           EMediatorClientNoSessionActive ));
    
    // Fill category
    TMediatorCategory category;
    category.iDomain = aDomain;
    category.iCategory = aCategory;
    TMediatorCategoryBuffer categoryBuffer( category );
        
    // And command
    TCommand command;
    command.iCommandId = aCommandId;
    //All the remaining parameters of TCommand are initiatilized to 0 as its not used on the server side.  
    //this is just to suppress the tool warnings.
	command.iVersion = TVersion(0,0,0);
	command.iCaps.SetEmpty();
    command.iTimeout = 0;

    TCommandBuffer commandBuffer( command );
        
    // Send the command                                 
    return SendReceive( ECancelCommand, 
                        TIpcArgs( &categoryBuffer, 
                                  &commandBuffer ) );
    }
コード例 #2
0
// -----------------------------------------------------------------------------
// RMediatorServer::IssueCommand
// Synchronous function to send command request to Mediator Server
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
TInt RMediatorServer::IssueCommand( TUid aDomain,
                                    TUid aCategory, 
                                    TInt aCommandId,
                                    TVersion aVersion, 
                                    const TDesC8& aData )
    {
    TRACE(Print(_L("[Mediator Server]\t RMediatorServer::IssueCommand\n"))); 
    
    //  Check that session is open.
    __ASSERT_DEBUG( Handle(), User::Panic( KMediatorServerPanic, 
                                           EMediatorClientNoSessionActive ));
    
    // Fill category
    TMediatorCategory category;
    category.iDomain = aDomain;
    category.iCategory = aCategory;
    TMediatorCategoryBuffer categoryBuffer( category );
        
    // And command
    TCommand command;
    command.iCommandId = aCommandId;
    command.iVersion = aVersion;
    //Time out is initiatilized to 0 as its not used on the server side.  
    //this is just to supress the tool warnings.
    command.iTimeout = 0;
    TCommandBuffer commandBuffer( command );
        
    // Send the command                                 
    return SendReceive( EIssueCommand, 
                        TIpcArgs( &categoryBuffer, 
                                  &commandBuffer, 
                                  &aData ) );
    
    }
コード例 #3
0
TInt CMMFDevSoundCIMuxUtility::SendSlaveSyncCommand(TInt aHandle, TInt aCommand, const TDesC8& aPackageBuf)
	{
	TA3FCustomInterfaceCommand command;
	command.iType = EMMFDevSoundCustomCommandCISendSlaveSyncCommand;
	command.iCommand = aCommand;
	command.iHandle = aHandle;
	TPckgBuf<TA3FCustomInterfaceCommand> commandBuffer(command);
	
	return iCustomChannel->SyncCustomCommand(KUidInterfaceMMFDevSound, commandBuffer, aPackageBuf, NULL);
	}
コード例 #4
0
void CMMFDevSoundCIMuxUtility::CloseSlave(TInt aHandle)
	{
	// 1. send closeslave custom command to remote side
	// 2. demuxplugin removes its handle for this interface
	TA3FCustomInterfaceCommand command;
	command.iType = EMMFDevSoundCustomCommandCICloseSlave;
	command.iCommand = 0; // No custom command passed on a CloseSlave
	command.iHandle = aHandle;
	TPckgBuf<TA3FCustomInterfaceCommand> commandBuffer(command);
	iCustomChannel->SyncCustomCommand(KUidInterfaceMMFDevSound, commandBuffer, KNullDesC8, NULL);
	}
コード例 #5
0
// from MMMFDevSoundCustomInterfaceMux interface
TInt CMMFDevSoundCIMuxUtility::OpenSlave(TUid aInterface, const TDesC8& aPackageBuf)
	{
	// 1. send openslave custom command to remote side
	// 2. devsoundsession intercepts this custom command
	//    and creates / opens interface
	TA3FCustomInterfaceCommand command;
	command.iType = EMMFDevSoundCustomCommandCIOpenSlave;
	command.iCommand = 0; // No custom command passed on an OpenSlave
	command.iHandle = aInterface.iUid;
	TPckgBuf<TA3FCustomInterfaceCommand> commandBuffer(command);
	return iCustomChannel->SyncCustomCommand(KUidInterfaceMMFDevSound, commandBuffer, aPackageBuf, NULL);
	}
コード例 #6
0
int main()
{
	printf("  WI  \n");
	printf("------\n");
	printf("\n");

	std::vector<WCHAR> commandBuffer(1000 + 1, L'\0');
	std::vector<WCHAR> trashBuffer(1000 + 1, L'\0');
	std::vector<WCHAR> textBuffer(1024 + 1, L'\0');

	int lineNumber = 1;

	size_t linePositionInText = 0;

	for (;;)
	{
		printf("%d: ", lineNumber);

		std::fill(commandBuffer.begin(), commandBuffer.end(), L'\0');
		wscanf(L"%1000[a-zA-Z0-9?,.!()%:- ]", commandBuffer.data());

		std::fill(trashBuffer.begin(), trashBuffer.end(), L'\0');
		fgetws(trashBuffer.data(), trashBuffer.size(), stdin); //NORMAL MAY BE

		if (wcscmp(commandBuffer.data(), L":done") == 0)
			break;

		if (wcsncmp(commandBuffer.data(), L":line ", 6) == 0)
		{
			swscanf(commandBuffer.data() + 6, L"%d", &lineNumber);

			if (lineNumber < 0 || lineNumber > 1000) return -1;

			if (lineNumber == 0)
			{
				lineNumber = 1;
			}

			linePositionInText = 0;

			for (int i = 0; i < lineNumber && linePositionInText < textBuffer.size(); linePositionInText++)
			{
				if (textBuffer[linePositionInText] == L'\n')
				{
					i++;
				}
			}

			continue;
		}

		// replace arguments
		int cnt = 0;

		for (WCHAR* ptr2 = commandBuffer.data();;)
		{
			ptr2 = wcschr(ptr2, L'%');
			if (ptr2 == NULL)
				break;

			if (ptr2[1] == L'%')  //%%???
			{
				if (ptr2[2] == L'x' || ptr2[2] == L's' || ptr2[2] == L'i' || ptr2[2] == L'd' || ptr2[2] == L'u' || ptr2[2] == L'l') break;
				for (int i = 0; i < wcslen(ptr2); i++)
				{
					ptr2[i] = ptr2[i + 1];  //1????
				}

				ptr2--;

				if (ptr2 < commandBuffer.data()) break;  //!!!!
			}
			else if (ptr2[1] == L'l')
			{
				cnt++;

				ptr2[1] = L'd';
			}
			else
			{
				for (int i = wcslen(ptr2) - 1; i >= 0; i--)
				{
					ptr2[i + 1] = ptr2[i];
				}
			}

			if (ptr2 >= commandBuffer.data() + commandBuffer.size() - 1) break;	//!!
			ptr2 += 2;
		}

		std::vector<int> arg_list(cnt, lineNumber);

		int space = _vsnwprintf(NULL, 0, commandBuffer.data(), reinterpret_cast<va_list>(arg_list.data()));

		textBuffer.insert(textBuffer.begin() + linePositionInText, space + 1, L'\0');

		_vsnwprintf(&textBuffer[linePositionInText], space, commandBuffer.data(), reinterpret_cast<va_list>(arg_list.data()));

		textBuffer[linePositionInText + space] = L'\n';
		
		linePositionInText += space + 1;

		lineNumber++;
	}

	wprintf(L"\n\n");
	wprintf(L"THE FINAL TEXT\n");
	wprintf(L"==============\n");

	wprintf(L"%s\n\n", textBuffer.data());

	return -14;
}