コード例 #1
0
//Modify URI components
void CExampleInetProtUtil::ModifyUriComponentsL()
	{	
	TUriParser8 parser1;
	CUri8* aUri = CUri8::NewL(parser1);
	
	_LIT(KText3, "\n\n\nAdding Uri components one by one....");
	iConsole->Printf ( KText3 );

	// Adding components to the Uri
	
	//Setting and displaying SCHEME
	_LIT8(KScheme, "http");
	_LIT(KScheme1, "\nSCHEME : http");
	iConsole->Printf ( KScheme1 );
	aUri->SetComponentL(KScheme, EUriScheme);
	
	//Setting and displaying HOST
	_LIT8(KHost, "www.symbian.com");
	_LIT(KHost1, "\nHOST : www.symbian.com");
	iConsole->Printf ( KHost1 );
	aUri->SetComponentL(KHost, EUriHost);
	
	//Setting and displaying PORT
	_LIT8(KPort, "80");
	_LIT(KPort1, "\nPORT : 80");
	iConsole->Printf ( KPort1 );
	aUri->SetComponentL(KPort, EUriPort);
	
	//Setting and displaying PATH
	_LIT8(KPath, "/developer/techlib/turic8class.html");
	_LIT(KPath1, "\nPATH : /developer/techlib/turic8class.html");
	iConsole->Printf ( KPath1 );
	aUri->SetComponentL(KPath, EUriPath);
	
	//Display the constucted Uri
	_LIT(KText4, "\nThe fully constructed Uri....");
	iConsole->Printf ( KText4 );
	const TDesC8& desUriDisplay = aUri->Uri().UriDes();
	TBuf16<100> desFullUri;
	desFullUri.Copy (desUriDisplay);
	
	iConsole->Printf( KLeaveALine );
	iConsole->Printf ( desFullUri );
	
	// Removal of component from the Uri
	iConsole->Getch ();
	_LIT(KText5, "\n\nUri with the Port number removed....\n");
	iConsole->Printf ( KText5 );
	aUri->RemoveComponentL(EUriPort);

	//Display the modified Uri
	const TDesC8& desRemovedComponentDisplay =aUri->Uri().UriDes();
	TBuf16<100> desRemovedComponent;
	desRemovedComponent.Copy (desRemovedComponentDisplay);
	iConsole->Printf ( desRemovedComponent );
	
	delete aUri;
	
	iConsole->Getch ();
	}
コード例 #2
0
ファイル: TestCase.cpp プロジェクト: cdaffara/symbiandump-mw1
// From MTest:
void CTestCase::ExecuteL (TTestResult& aResult)
    {
    TInt error = ExecuteImplL();
    aResult.iResult = error;
    // add the possible failure or error to the result
    
    if (error == KErrCppUnitAssertionFailed)
        {
        CAssertFailure* assertFailure = AssertFailureFromTlsL ();
        CleanupStack::PushL(assertFailure);
        TBuf16 <0x80> convertBuf;
        TBuf16 <256> temporaryBuf;
        convertBuf.Copy(assertFailure->What());
        temporaryBuf.Append(convertBuf);
        temporaryBuf.AppendFormat(_L(" at Line %i of "), assertFailure->LineNumber()); 
        convertBuf.Copy(assertFailure->FileName());
        if (convertBuf.Length() + temporaryBuf.Length() >= 0x80)
            {
            TBuf <0x80> printBuf;
            printBuf = convertBuf.Right(0x80 - temporaryBuf.Length() - 1 -3 );
            convertBuf = _L("...");
            convertBuf.Append(printBuf);
            }
        temporaryBuf.Append(convertBuf);
        aResult.iResultDes = temporaryBuf;
        CleanupStack::PopAndDestroy(assertFailure); 
        }
    }
コード例 #3
0
//Encode and Decode the Uri
void CExampleInetProtUtil::EscapeEncodeDecodeL()
	{
	//Take an eg file to encode it and then decode it....
	_LIT(KFullUriName,"K:\\ws\\direct\\direct.mmp");
	TBuf<40> desFullUriName(KFullUriName);
	
	//UTF-8 defines a mapping from sequences of octets to sequences of chars
	HBufC8* convert = EscapeUtils::ConvertFromUnicodeToUtf8L(desFullUriName);

	//Encode the eg Uri and display it
	_LIT(KTextEncode, "\n\n\nThe Encoded Uri is....\n");
	iConsole->Printf ( KTextEncode );
	HBufC16* encode = EscapeUtils::EscapeEncodeL(desFullUriName,EscapeUtils::EEscapeNormal);
	TPtr uriEncoded = encode->Des();
	TBuf16<100> desEncodedUri;
	desEncodedUri.Copy (uriEncoded);
	iConsole->Printf ( _L("%S"), &desEncodedUri );

	//Decode the eg Uri and display it
	_LIT(KTextDecode, "\nThe Decoded Uri is....\n");
	iConsole->Printf ( KTextDecode );
	
	HBufC16* decode = EscapeUtils::EscapeDecodeL(desFullUriName);
	TPtr uriDecoded = decode->Des();
	TBuf16<100> desDecodedUri;
	desDecodedUri.Copy (uriDecoded);
	iConsole->Printf ( _L("%S"), &desDecodedUri );

	delete decode;
	delete encode;
	delete convert;

	iConsole->Getch();
	iConsole->Printf ( KLeaveALine );
	}
コード例 #4
0
//Create an URI
void CExampleInetProtUtil::CreateUriL()
	{
	//Set the physical path of the file
	
	_LIT(KText1, "\n\n\nThe Physical location of the file is....");
	iConsole->Printf ( KText1 );
	
	_LIT(KFullUriName, "K:\\ws\\direct\\direct.mmp");

	//display it 
	TBuf<40> desFullUriName(KFullUriName);
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( KFullUriName );
	
	//create the Uri for the path
	CUri8* uri8 = CUri8::CreateFileUriL(desFullUriName); 
	
	const TDesC8& desUriDisplay = uri8->Uri().UriDes();
	TBuf16<100> desCreateUri;
	desCreateUri.Copy (desUriDisplay);
	
	//display it 
	_LIT(KText2, "And its Uri is....");
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( KText2 );
	
	iConsole->Printf ( KLeaveALine );
	iConsole->Printf ( desCreateUri );
	
	delete uri8;
	
	iConsole->Getch ();
	}
コード例 #5
0
ファイル: roadmap_main.cpp プロジェクト: NoamSheffer/WazeWP7
 void roadmap_internet_open_browser (char *url) {
 	  RApaLsSession apaLsSession;
 	  const TUid KOSSBrowserUidValue = {0x10008D39}; // 0x1020724D for S60 3rd Ed
 	  TUid id(KOSSBrowserUidValue);
 	  TApaTaskList taskList(CEikonEnv::Static()->WsSession());
 	  TApaTask task = taskList.FindApp(id);
 	  if(task.Exists())
 		  {
 		  task.BringToForeground();
 		  task.SendMessage(TUid::Uid(0), TPtrC8((TUint8 *)url,strlen(url))); // UID not used
 		  }
 	  else
 		  {
 		  if(!apaLsSession.Handle())
 			  {
 			  User::LeaveIfError(apaLsSession.Connect());
 			  }
 		  TThreadId thread;
 		  
 		  TBuf16<128> buf;
 		  buf.Copy(TPtrC8((TUint8 *)url,strlen(url)));
 		   		  
 		  User::LeaveIfError(apaLsSession.StartDocument(buf, KOSSBrowserUidValue, thread));
 		  apaLsSession.Close();   
 		  }
 }
コード例 #6
0
void ParseUriTestsDeprecated()
	{	
	test.Next(_L("Parsing 16 bit URIs (deprecated)"));
	gFullUri16.Copy(KUri0);
	TUriParser16 parser16;
	parser16.Parse(gFullUri16);
	gUriComponent16.Copy(KScheme0);
	TInt result = parser16.Extract(EUriScheme).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KUserInfo0);
	result = parser16.Extract(EUriUserinfo).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KHost0);
	result = parser16.Extract(EUriHost).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KPort0);
	result = parser16.Extract(EUriPort).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KParams0);
	result = parser16.Extract(EUriPath).Compare(gUriComponent16);
	test(!result);
	gUriComponent16.Copy(KHeaders0);
	result = parser16.Extract(EUriQuery).Compare(gUriComponent16);
	test(!result);
	}
コード例 #7
0
void GenarateUriTestsL()
	{
	test.Next(_L("@SYMTestCaseID IWS-APPPROTOCOLS-INETURILIST-TESTUTILS-0002 Generating 8 bit URIs"));
	CUri8* uri8 = CUri8::NewLC();
	uri8->SetComponentL(KScheme0, EUriScheme);
	uri8->SetComponentL(KHost0, EUriHost);
	uri8->SetComponentL(KUserInfo0, EUriUserinfo);
	uri8->SetComponentL(KPort0, EUriPort);
	uri8->SetComponentL(KParams0, EUriPath);
	uri8->SetComponentL(KHeaders0, EUriQuery);
	const TDesC8& des8 = uri8->Uri().UriDes();
	TInt result = des8.Compare(KUri0);
	test(!result);
	CleanupStack::PopAndDestroy(uri8);
	
	test.Next(_L("Generating 16 bit URIs"));
	CUri16* uri16 = CUri16::NewLC();
	gUriComponent16.Copy(KScheme0);
	uri16->SetComponentL(gUriComponent16, EUriScheme);
	gUriComponent16.Copy(KHost0);
	uri16->SetComponentL(gUriComponent16, EUriHost);
	gUriComponent16.Copy(KUserInfo0);
	uri16->SetComponentL(gUriComponent16, EUriUserinfo);
	gUriComponent16.Copy(KPort0);
	uri16->SetComponentL(gUriComponent16, EUriPort);
	gUriComponent16.Copy(KParams0);
	uri16->SetComponentL(gUriComponent16, EUriPath);
	gUriComponent16.Copy(KHeaders0);
	uri16->SetComponentL(gUriComponent16, EUriQuery);
	const TDesC16& des16 = uri16->Uri().UriDes();
	gFullUri16.Copy(KUri0);
	result = des16.Compare(gFullUri16);
	test(!result);
	CleanupStack::PopAndDestroy(uri16);
	}
コード例 #8
0
void EquivalenceTest(const TDesC8& aLhs, const TDesC8& aRhs, TInt aExpected)
	{
	TUriParser8 lhs8;
	lhs8.Parse(aLhs);
	TUriParser8 rhs8;
	rhs8.Parse(aRhs);
	TInt result = lhs8.Equivalent(rhs8);
	test(result == aExpected);
	
	TUriParser16 lhs16;
	gFullUri16.Copy(aLhs);
	lhs16.Parse(gFullUri16);
	TUriParser16 rhs16;
	gFullUriRhs16.Copy(aRhs);
	rhs16.Parse(gFullUriRhs16);
	
	result = lhs16.Equivalent(rhs16);
	test(result == aExpected);
	}
コード例 #9
0
ファイル: TTEXT.CPP プロジェクト: kuailexs/symbiandump-os1
void CTextWindow::Draw()
//This function is virtual and so cannot have an 'L' at the end of it's name
	{
	iGc->Clear();
	ResetPrintLine();
	switch(iDrawMode)
		{
	case EDrawModeWordJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawWordJustified(_L("Hello World"));
		DrawWordJustified(_L("One Two Three Four Five Six Seven"));
		DrawWordJustified(_L("AA    B        CC D"));
		DrawWordJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeCharJust:
		User::LeaveIfError(Client()->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iTmpFont, TFontSpec(KTestFontTypefaceName,200)));
		iGc->UseFont(iTmpFont);
		DrawCharJustified(_L("Hello World"));
		DrawCharJustified(_L("One Two Three Four Five Six Seven"));
		DrawCharJustified(_L("AA    B        CC D"));
		DrawCharJustified(_L("ONEWORD"));
		iGc->DiscardFont();
		Client()->iScreen->ReleaseFont(iTmpFont);
		iTmpFont=NULL;
		break;
	case EDrawModeFonts:
		{
		TTypefaceSupport typefaceSupport;
		Client()->iScreen->TypefaceSupport(typefaceSupport,iTypeFaceIndex);
		TBuf<0x40> title;
		TBuf16<KMaxTypefaceNameLength> tmpBuf;
		tmpBuf.Copy(typefaceSupport.iTypeface.iName);
		title.Append(tmpBuf);
		title.AppendFormat(TRefByValue<const TDesC>(_L(", Heights (Min=%d, Max=%d, Num=%d)")),typefaceSupport.iMinHeightInTwips,typefaceSupport.iMaxHeightInTwips,typefaceSupport.iNumHeights);
		PrintLine(iFont,title);
		PrintDivider();
		for (TInt tfHeight=0;tfHeight<typefaceSupport.iNumHeights;tfHeight++)
			{
			TFontSpec fspec(typefaceSupport.iTypeface.iName,Client()->iScreen->FontHeightInTwips(iTypeFaceIndex,tfHeight));
			PrintStylesL(_L("Normal, "), fspec, TFontStyle());
			PrintStylesL(_L("Bold, "), fspec, TFontStyle(EPostureUpright,EStrokeWeightBold,EPrintPosNormal));
			PrintStylesL(_L("Italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightNormal,EPrintPosNormal));
			PrintStylesL(_L("Bold/italic, "), fspec, TFontStyle(EPostureItalic,EStrokeWeightBold,EPrintPosNormal));
			if (iYpos>Size().iHeight)
				break;
			}
		}
		break;
		}
	}
コード例 #10
0
//Validate URI components
void CExampleInetProtUtil::ValidateUriComponentsL()
	{
	TUriParser8 parser1;
	CUri8* aUri = CUri8::NewL(parser1);
	
	_LIT(KTextf, "\n\n\nValidating the Uri....\n");
	iConsole->Printf ( KTextf );
	
	// Adding components to the Uri
	
	//Adding Scheme
	_LIT8(KScheme, "http");
	aUri->SetComponentL(KScheme,EUriScheme);
	
	//Adding Host
	_LIT8(KHost, "waterlang.org");
	aUri->SetComponentL(KHost,EUriHost);
	
	//Adding Port
	_LIT8(KPort, "90");
	aUri->SetComponentL(KPort,EUriPort);
	
	//Adding Path
	_LIT8(KPath, "/turic8class.html");
	aUri->SetComponentL(KPath,EUriPath);
	
	//Adding Query
	_LIT8(KQuery, "bar=2&x=3");
	aUri->SetComponentL(KQuery,EUriQuery);
	
	//Adding Fragment
	_LIT8(KFragment, "fragment");
	aUri->SetComponentL(KFragment,EUriFragment);
	
	//Display the constructed Uri
	const TDesC8& desUriDisplays =aUri->Uri().UriDes();
	TBuf16<100> desValidate;
	desValidate.Copy (desUriDisplays);
	iConsole->Printf ( desValidate );
	
	// Validate() is not supported for HTTP, but only SIP and SIPS. 
	//The Parse() function itself validates the components and returns the 
	//appropriate result.
	TInt res = parser1.Parse(desUriDisplays);
	if (res==KErrNone)
	{
		_LIT(KText8, "\nThis Uri is VALID");
		iConsole->Printf ( KText8 );
	}
	
	delete aUri;
	
	iConsole->Getch();
	}
コード例 #11
0
void ValidateTest(const TDesC8& aUri, TInt aErrorToAssert)
	{
	TUriParser8 parser8;
	TUriParser16 parser16;
	parser8.Parse(aUri);
	TInt result = parser8.Validate();
	test(result == aErrorToAssert);
	gFullUri16.Copy(aUri);
	parser16.Parse(gFullUri16);
	result = parser16.Validate();
	test(result == aErrorToAssert);
	}
コード例 #12
0
//Extract URI components
void CExampleInetProtUtil::RetrieveFileNameL()
	{
	_LIT(KTextRet, "\n\n\nRetrieving filename from....\n");
	iConsole->Printf ( KTextRet );
	
	//Create a Uri 
	_LIT(KUriRetName, "K:\\ws\\direct\\direct.mmp");
	TBuf<40> desUriRetName(KUriRetName);
	CUri8* uriRetName = CUri8::CreateFileUriL(desUriRetName);  
	
	//Display the Uri
	const TDesC8& uriDisp = uriRetName->Uri().UriDes();
	TBuf16<100> desRetrieve;
	desRetrieve.Copy (uriDisp);
	iConsole->Printf ( desRetrieve );
	
	//Parse the Uri
	TUriParser8* uriComp = new(ELeave) TUriParser8();
	uriComp->Parse(uriDisp);
	
	//Get or Extract the Filename from the Uri
	_LIT(KTextGetFilename, "\nGetting the filename....\n");
	iConsole->Printf ( KTextGetFilename );
	
	HBufC* fileName = uriComp->GetFileNameL();
	TPtr uriFileNameDisplay = fileName->Des();
	TBuf16<100> desFileName;
	desFileName.Copy (uriFileNameDisplay);
	iConsole->Printf ( desFileName );

	delete fileName;
	delete uriComp;
	delete uriRetName;
	
	iConsole->Getch();
	}
コード例 #13
0
//Extract URI components
void CExampleInetProtUtil::ExtractUriComponentsL()
	{
	_LIT(KTextExtract, "\n\n\nExtracting from....\n");
	iConsole->Printf ( KTextExtract );
	
	//Create a Uri 
	_LIT(KUriName, "K:\\ws\\direct\\direct.mmp");
	TBuf<40> desUriName(KUriName);
	CUri8* uriName = CUri8::CreateFileUriL(desUriName);  
	
	//Display the Uri
	const TDesC8& uriDisplay = uriName->Uri().UriDes();
	TBuf16<100> desExtract;
	desExtract.Copy (uriDisplay);
	iConsole->Printf ( desExtract );
	
	//Parse the Uri
	TUriParser8* uriComponent = new(ELeave) TUriParser8();
	uriComponent->Parse(uriDisplay);
	
	//Extract the Scheme component from this Uri
	const TDesC8& host = uriComponent->Extract(EUriScheme);
	TBuf16<100> desEx;
	desEx.Copy (host);
		
	//Display the Component extracted
	_LIT(KTextEx, "\nThe extracted Scheme component is....\n");
	iConsole->Printf ( KTextEx );
	iConsole->Printf ( desEx );
	
	//delete fileName;
	delete uriComponent;
	delete uriName;
	
	iConsole->Getch();
	}
コード例 #14
0
ファイル: DebLogRD.CPP プロジェクト: kuailexs/symbiandump-os1
void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
	{
	TBuf16<256> buf;
	TInt pos=aDes.LocateReverse(' ');
	if (pos<0)
		pos=0;
	buf.Copy(aDes.Mid(pos));
	buf.Append(' ');
	TInt bufLen=buf.Length();
	TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen);
	ptr.Copy(aDes2);
	buf.SetLength(bufLen+aDes2.Length());
	_LIT(KDebugFormatString, "%S");
	RDebug::Print(KDebugFormatString, &buf);	
	}
コード例 #15
0
// -----------------------------------------------------------------------------
// CSdDisk::ReleaseFiles
// This method deletes files created for filling the drive C
// 
// -----------------------------------------------------------------------------
void CSdDisk::ReleaseDisk(RFs& aFs)
    {
	// RDebug::Print(_L("Shareddatatest ## ReleaseDisk"));
	TInt i = 0;
	TInt err = KErrNone;
		
	do
	    {
		TBuf16<35> str;
		str.Copy(KFileName);
		str.AppendNum(i,EDecimal);
		
		err = aFs.Delete (str) ;
		
		i++;
	    }
	while ( err == KErrNone );
}
コード例 #16
0
/** Load and initialise an audio file.
 */
TVerdict CTestMmfAclntCaps0014::DoTestStepL( void )
	{
	INFO_PRINTF1( _L("TestPlayerUtils : Caps"));
	iVerdict = EFail;

	iServerMonitor = CServerMonitor::NewL(this);
	
	// TSI_MMF_SDEVSOUND, MM-MMF-SDEVSOUND-I-0010-HP runs before this 
	// this step does, I-0010-HP creates and uses 
	// rectest1.wav and rectest2.wav 
	// So we need to delete these to avoid errors In this test.
	RFs fsSession;
	fsSession.Connect();
	TRAPD(err,fsSession.Delete(_L("c:\\rectest1.wav")));
	TRAP(err,fsSession.Delete(_L("c:\\rectest2.wav")));
	fsSession.Close();
	
	// Start Server to play back from another process
	RTestServ server;
	User::LeaveIfError(server.Connect(_L("CapTestServer")));
	CleanupClosePushL(server);
	RTestSession session1;
	User::LeaveIfError(session1.Open(server,_L("CapTestStep0014")));
	TRequestStatus* status = &iServerMonitor->ActiveStatus();
	// Start Server playback. The RunL of the CServerMonitor class will be called by the server when
	// playback has started
	session1.StartProcessing(*status);
	// Begin activescheduler loop. This will only exit when the whole test is complete 
	CActiveScheduler::Start();
	
	// The test is complete. Now shut down the server and get any errors /messages from the server
	TBuf8<256> message;
	TVerdict verdict = session1.EndProcessingAndReturnResult(message);
	if (verdict != EPass)
		iVerdict = verdict;
	TBuf16<256> copymess;
	copymess.Copy(message);
	INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);

	CleanupStack::PopAndDestroy(&server);
	return iVerdict;
	}
コード例 #17
0
void ParseUriTests16BitL()
	{	
	test.Next(_L("Parsing 16 bit URIs"));
	gFullUri16.Copy(KUri0);
	CUri8* uri = UriUtils::CreateUriL(gFullUri16);
	CleanupStack::PushL(uri);
	
	gUriComponent16.Copy(KScheme0);
	HBufC* text = uri->Uri().DisplayFormL(EUriScheme);
	TInt result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentScheme;
	delete text;
	User::LeaveIfError(result);

	gUriComponent16.Copy(KUserInfo0);
	text = uri->Uri().DisplayFormL(EUriUserinfo);
	result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentUserInfo;
	delete text;
	User::LeaveIfError(result);
	
	gUriComponent16.Copy(KHost0);
	text = uri->Uri().DisplayFormL(EUriHost);
	result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentHost;
	delete text;
	User::LeaveIfError(result);
	
	gUriComponent16.Copy(KPort0);
	text = uri->Uri().DisplayFormL(EUriPort);
	result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentPort;
	delete text;
	User::LeaveIfError(result);

	gUriComponent16.Copy(KParams0);
	text = uri->Uri().DisplayFormL(EUriPath);
	result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentPath;
	delete text;
	User::LeaveIfError(result);

	gUriComponent16.Copy(KHeaders0);
	text = uri->Uri().DisplayFormL(EUriQuery);
	result = text->Compare(gUriComponent16) == 0? KErrNone : KUriUtilsErrDifferentQuery;
	delete text;
	User::LeaveIfError(result);
	CleanupStack::PopAndDestroy(uri);
	}
コード例 #18
0
// Wraps LookupName() to provide a Python method interface.
// Arguments:
//  - address of the device to look up. Note that the address 
//    is expected without colons!! e.g. "000D9319C868"
//  - True/False - if True, performs a remote name request even if the device
//    name is known in the cache from a previous request.
//
// Returns the name (a Python unicode string).
static PyObject* LightBlue_LookupName(PyObject* self, PyObject* args)
{   
    const char *addr;
    bool ignoreCache;
    if (!PyArg_ParseTuple(args, "sb", &addr, &ignoreCache))
        return NULL;

    THostName deviceName;
    TBTDevAddr wantedAddr;
    
    TBuf16<128> buf;
    buf.Copy(_L8(addr));
    wantedAddr.SetReadable(buf);
    
    TInt err = LookupName(wantedAddr, &deviceName, ignoreCache);
  
    if (err) 
        return SPyErr_SetFromSymbianOSErr(err);    
        
    return Py_BuildValue("u#", deviceName.Ptr(), deviceName.Length());
}
コード例 #19
0
TVerdict CTestStepSDevSoundPlayDataCap::DoTestStepL( void )
{
    INFO_PRINTF1( _L("CTestStepSDevSoundPlayDataCap : DevSoundMP"));
    iVerdict = EFail;

    iServerMonitor = CServerMonitor::NewL(this);

    // Start Server to play back from another process
    RTestServ server;
    User::LeaveIfError(server.Connect(_L("SDSCapTestServer")));
    CleanupClosePushL(server);

    RTestSession session1;
    User::LeaveIfError(session1.Open(server,_L("SecDevSndTS0008")));
    TRequestStatus* status = &iServerMonitor->ActiveStatus();
    // Start Server playback. The RunL of the CServerMonitor class will be called by the server when
    // playback has started
    session1.StartProcessing(*status);
    // Begin activescheduler loop. This will only exit when the whole test is complete
    CActiveScheduler::Start();

    User::After(2000000);
    iVerdict = DoPlayData();

    // The test is complete. Now shut down the server and get any errors /messages from the server
    TBuf8<256> message;
    TVerdict verdict = session1.EndProcessingAndReturnResult(message);
    if (verdict != EPass)
        iVerdict = verdict;
    TBuf16<256> copymess;
    copymess.Copy(message);
    INFO_PRINTF2(_L("end processing and return result: %S"),&copymess);

    CleanupStack::PopAndDestroy(&server);
    return iVerdict;
}
コード例 #20
0
void CCmdConnect::HandleWspEvent(TRequestStatus aStatus)
{
	TBool fail = EFalse;
	
	if (aStatus == THTTPSessionEvent::EConnect)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EConnect"));
		} 
	else if (aStatus == THTTPSessionEvent::EConnectedOK)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EConnectedOK"));
		}
	else if (aStatus == THTTPSessionEvent::EConnectedWithReducedCapabilities)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EConnectedWithReducedCapabilities"));
		}
	else if (aStatus == THTTPSessionEvent::EDisconnected)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EDisconnected"));
		fail = ETrue;
		}
	else if (aStatus == THTTPSessionEvent::EAuthenticatedOK)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EAuthenticatedOK"));
		} 
	else if (aStatus == THTTPSessionEvent::EAuthenticationFailure)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EAuthenticationFailure"));
		}
	else if (aStatus == THTTPSessionEvent::EConnectionTimedOut)
		{
		Log(_L("CFrmwrkSession::HandleWspEvent, event EConnectionTimedOut"));
		fail = ETrue;
		}
	else
		{
	    Log(_L("CFrmwrkSession::HandleWspEvent, Unrecognised event [%d]"), aStatus.Int());
		fail = ETrue;
		}

	if (fail)
		{
		CObjCatalogue *sessions = Machine()->Domains();

		for (TInt i = 0; i < sessions->Count(); ++i)
			{
			CAnyObject *obj = (CAnyObject *)sessions->At(i);
			if (obj->Tag() == THA_KHTTP_Connect)
				{
				CFrmwrkSession *frmwk = (CFrmwrkSession *) obj->Ptr();

				if (frmwk->UseWSPProtocol() && (frmwk->iState == CFrmwrkSession::EWSPDisconnected))
				{
					TBuf16<256> myNameBuf;
	
					myNameBuf.Copy(frmwk->Name());
		
					Log(_L("CCmdConnect::HandleWspEvent() : Delete %S\r\n"), &myNameBuf);
					Delete(myNameBuf);
					Machine()->Domains()->Delete(myNameBuf);
		
					}
				}
			}
		}
		
	WaitForNextEvent (THTTPSessionEvent::EDisconnected);
}
コード例 #21
0
ファイル: Listener.cpp プロジェクト: cdaffara/symbiandump-os1
void CListener::RunL()
	{
	if(iListenerState == EWaitingForConnection)
		{
		// We are here when incoming connection detected and Accepted on Listener.
		if(iStatus != KErrNone)
			{
			// Something went wrong when accepting a remote connection
			// Not much we can do at this point.
			LOGLINE2(_L("Accept returns error! %d"), iStatus.Int());
			LOGLINE1(_L("Leaving....!"))
			DoCancel();
			User::Leave(KErrCommsLineFail);
			}
			
		// iBlankSocket is now ready to communicate with the incoming connection.
		LOGLINE1(_L("Remote connection detected!"));
			
		// Wait for data from remote port
		IssueRead();
		}
	else if(iListenerState == EWaitingForData)
		{
		
		// Check status of Recv operation
		if(iStatus != KErrNone)
			{
			if(iStatus == KErrEof)
				{
				LOGLINE1(_L("Remote party may have closed the connection"));
				}
			// Terminate the active socket
			LOGLINE1(_L("Closing active socket"));
			iBlankSocket.Close();
			
			// Set listening socket to accept new connection
			AcceptL();
			return;
			}

		// Print received data!!!!
		TBuf16<KReqstSocketPreReadSize> Buffer;
		Buffer.Copy(iBufferPreRead);

		// Get msg length from pre-read
		TUint msgLen = CReqstParser::ExtractMsgLenL(iBufferPreRead);
		__ASSERT_ALWAYS(msgLen > KReqstSocketPreReadSize, User::Panic(KPanicMsgFormat, KIncorrectPreReadSize)); 
		
		
		// Now read the rest of msg by creating an Rbuf just large enough according to the msg length
		iBuffer.Close();

		// Create a buffer to recv exact amount of remaining reqst msg
		iBuffer.CreateL(msgLen - KReqstSocketPreReadSize);
		
		// Read remaining msg data.
		// Recv operation should complete immediately if msg has been formatted correctly
		iBlankSocket.Recv(iBuffer, 0, iStatus);
		User::WaitForRequest(iStatus);
		// Check status of Recv operation
		if(iStatus != KErrNone)
			{
			if(iStatus == KErrEof)
				{
				LOGLINE1(_L("Remote party may have closed the connection during 2nd Recv"));
				}
			// Terminate the active socket
			LOGLINE1(_L("Error during 2nd Recv!!"));
			LOGLINE1(_L("Closing active socket"));
			iBlankSocket.Close();
			
			// Set listening socket to accept new connection
			AcceptL();
			return;
			}
		
		// Tell reqst hndlr we have a msg. That thread will parse msg and build the reply which we
		// want to send back to master. The call to ETEL to process the actual reqst
		// will have to be done asynchronously in HandleRequestL().
		iBufferAll.Close();
		iBufferAll.CreateL(msgLen);		// Give HandleRequestL the entire msg!
		iBufferAll += iBufferPreRead;
		iBufferAll += iBuffer;
		const TDesC8& response = iRqstHndlr.HandleRequestL(iBufferAll);
		
		if(response == KNullDesC8)
			{
			LOGLINE1(_L("Response msg is NULL"));
			}
		else
			{
			// Send back the reply msg
			TRequestStatus status;
			//convert to 16 bit
			TBuf16<4*KMaxElementSize> responsebuf16;
			responsebuf16.Copy(response);
			LOGLINE2(_L("Sending data back to sender...%S"), &responsebuf16);
			iBlankSocket.Send(response, 0, status);
			User::WaitForRequest(status);
			// There's a slim chance the remote party has closed the connection since the time a msg 
			// was received
			if(status != KErrNone)
				{
				if(status == KErrEof)
					{
					LOGLINE1(_L("Remote party may have closed the connection before we could send the response"));
					}
				// Terminate the active socket
				LOGLINE1(_L("Closing active socket"));
				iBlankSocket.Close();
				
				// Set listening socket to accept new connection
				AcceptL();
				return;
				}
			
			LOGLINE2(_L("Data sent. Status = %d"), status.Int());
			}
		
		// Wait for data from remote port
		IssueRead();
		}
	}
コード例 #22
0
// -----------------------------------------------------------------------------
// CSdDisk::FillDisk()
// Fills the diskspace 
// 
// -----------------------------------------------------------------------------
void CSdDisk::FillDisk(RFs& aFs, TInt& aFreeDiskSpaceToLeave)
    {
	RFile iEaterFile;
	TInt fileSize(0);	
	TInt err(KErrNone);
	
	TReal64 diskFree = CheckDiskSpace(aFs);
	// RDebug::Print(_L("Shareddatatest ## Eat disk space") );
	
	// For loop to create eaterfiles
	for ( TInt i = 0 ; diskFree != 0 ; i++ )
	    {	
		TBuf16<30> str;
		str.Copy(KFileName);
		str.AppendNum(i,EDecimal);
			
		// RDebug::Print(_L("Shareddatatest ## Open file %s"), &str);
	
		err = iEaterFile.Open( aFs, str, EFileShareAny | EFileWrite );

		if ( err == KErrNotFound )	// file does not exist - create it
		    {
			err = iEaterFile.Create( aFs, str, EFileShareAny | EFileWrite );
		    }

		if ( err == KErrNone )
		    {
			// Create maximum size eaterfile if there is more disk space available than the maximum file size
			if ( diskFree > TReal64(KMaxTInt) )
			    {
				// RDebug::Print( _L("Shareddatatest ## Creating %d. EaterFile"), i+1);
				err = iEaterFile.SetSize( KMaxTInt );
				
				diskFree = diskFree - TReal64(KMaxTInt);
			    }
			
			// ... And if available disk space is less than maximum file size
			else
			    {
				// If aFreeDiskSpaceToLeave parameter says we have to leave some free disk
				if ( aFreeDiskSpaceToLeave != 0 )
				    {
					// RDebug::Print( _L("Shareddatatest ## Creating %d. EaterFile"), i+1);
					TInt sizeToSet = STATIC_CAST(TInt, I64INT(diskFree));
					err = iEaterFile.SetSize( sizeToSet - aFreeDiskSpaceToLeave * 1024 );
					iEaterFile.Size( fileSize );
					// RDebug::Print( _L("Shareddatatest ## Last EaterFileSize: %d"), fileSize);
					diskFree = 0;	
				    }
				
				// Otherwise try to eat all the disk space
				else
				    {
					// RDebug::Print( _L("Shareddatatest ## Creating %d. EaterFile"), i+1);
					TInt sizeToSet = STATIC_CAST(TInt, I64INT(diskFree));
					// RDebug::Print( _L("Shareddatatest ## Filesize in the end should be around %d bytes"), sizeToSet);
					
					for ( TInt j = 64 ; err != KErrDiskFull ; j-- )
					    {	
						err = iEaterFile.SetSize( sizeToSet - j * 1024 );
					    }
					iEaterFile.Size( fileSize );
					// RDebug::Print( _L("Shareddatatest ## Last EaterFileSize: %d bytes"), fileSize);
					// RDebug::Print( _L("Shareddatatest ## There should be %d bytes of free disk"),sizeToSet - fileSize);
					diskFree = 0;
				    }
			    }
		    }
		
		else
		    {
			RDebug::Print(_L("Shareddatatest ## Error = %d"), err);
			diskFree = 0;
		    }

		// RDebug::Print(_L("Shareddatatest ## Close file"));
		iEaterFile.Close();
	    }
    }
コード例 #23
0
EXPORT_C char * setlocale(int category, const char* locale)
{
	CLocale* loc = CLocale::GetInstance();
	
	//Query the current locale
	if(NULL == locale)	
	{
		char* ret = NULL;
		switch(category)
		{
			case LC_CTYPE: 	if(!*LC_CTYPE_LocaleName)
							{
								LC_CTYPE_LocaleName[0] = 'C';
								LC_CTYPE_LocaleName[1] = '\0';
							}
							ret = (char*) LC_CTYPE_LocaleName;
							break;
						
			case LC_COLLATE:if(!*LC_COLLATE_LocaleName)
							{
								LC_COLLATE_LocaleName[0] = 'C';
								LC_COLLATE_LocaleName[1] = '\0';
							} 
							ret = (char*) LC_COLLATE_LocaleName;
							break;
							
			case LC_TIME:	if(!*LC_TIME_LocaleName)
							{
								LC_TIME_LocaleName[0] = 'C';
								LC_TIME_LocaleName[1] = '\0';
								_time_using_locale = 0;
							} 
							ret = (char*) LC_TIME_LocaleName;
							break;	
						
			case LC_NUMERIC:if(!*LC_NUMERIC_LocaleName)
							{
								LC_NUMERIC_LocaleName[0] = 'C';
								LC_NUMERIC_LocaleName[1] = '\0';
								_numeric_using_locale = 0;
							}  
							ret = (char*) LC_NUMERIC_LocaleName;
							break;
							
			case LC_MONETARY:if(!*LC_MONETARY_LocaleName)
							{
								LC_MONETARY_LocaleName[0] = 'C';
								LC_MONETARY_LocaleName[1] = '\0';
								_monetary_using_locale = 0;
							}  
							ret = (char*) LC_MONETARY_LocaleName;
							break;
				
			case LC_MESSAGES:
						break;
			
			case LC_ALL :if(!*LC_ALL_LocaleName)
							{
								_time_using_locale = 0;
								_numeric_using_locale = 0;
								_monetary_using_locale = 0;
								
								LC_CTYPE_LocaleName[0] = 'C';
								LC_CTYPE_LocaleName[1] = '\0';
								LC_COLLATE_LocaleName[0] = 'C';
								LC_COLLATE_LocaleName[1] = '\0';
								LC_TIME_LocaleName[0] = 'C';
								LC_TIME_LocaleName[1] = '\0';
								LC_NUMERIC_LocaleName[0] = 'C';
								LC_NUMERIC_LocaleName[1] = '\0';
								LC_MONETARY_LocaleName[0] = 'C';
								LC_MONETARY_LocaleName[1] = '\0';
								LC_ALL_LocaleName[0] =  'C';
								LC_ALL_LocaleName[1] = '\0';
							}  
						 ret = (char*) LC_ALL_LocaleName;
						 break;
			default:
				errno = EINVAL;
				return (NULL);
		}
		return ret;
	}

	//If locale is  "" set each category(LC_CTYPE, LC_COLLATE, LC_NUMERIC, LC_TIME, LC_MONETARY) to C locale
	if(strcmp(locale, "") == 0 )
	{
		_time_using_locale = 0;
		_numeric_using_locale = 0;
		_monetary_using_locale = 0;
		__nlocale_changed = 1;
		__mlocale_changed = 1;
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
		__clocale_set = 1;
		__applocale_changed = 1;
#endif
		
		LC_CTYPE_LocaleName[0] = 'C';
		LC_CTYPE_LocaleName[1] = '\0';
		LC_COLLATE_LocaleName[0] = 'C';
		LC_COLLATE_LocaleName[1] = '\0';
		LC_TIME_LocaleName[0] = 'C';
		LC_TIME_LocaleName[1] = '\0';
		LC_NUMERIC_LocaleName[0] = 'C';
		LC_NUMERIC_LocaleName[1] = '\0';
		LC_MONETARY_LocaleName[0] = 'C';
		LC_MONETARY_LocaleName[1] = '\0';
		LC_ALL_LocaleName[0] =  'C';
		LC_ALL_LocaleName[1] = '\0';
				
		return "C";
	}
	
	if (strcmp(locale, "C") == 0 || strcmp(locale, "POSIX") == 0)
	{
		if(LC_ALL == category)
		{
			_time_using_locale = 0;
			_numeric_using_locale = 0;
			_monetary_using_locale = 0;
			__nlocale_changed = 1;
			__mlocale_changed = 1;
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
			__clocale_set = 1;
			__applocale_changed = 1;
#endif
			
			strcpy((char*) LC_ALL_LocaleName, locale);
			LC_ALL_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_CTYPE_LocaleName, locale);
			LC_CTYPE_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_COLLATE_LocaleName, locale);
			LC_COLLATE_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_NUMERIC_LocaleName, locale);
			LC_NUMERIC_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_MONETARY_LocaleName, locale);
			LC_MONETARY_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_TIME_LocaleName, locale);
			LC_TIME_LocaleName[strlen(locale)] = '\0';
			return (char*) locale;	
		}
		
		switch(category)
		{
			case LC_CTYPE: 	strcpy((char*) LC_CTYPE_LocaleName, locale);
							LC_CTYPE_LocaleName[strlen(locale)] = '\0';
							break;
						
			case LC_COLLATE: strcpy((char*) LC_COLLATE_LocaleName, locale);
							 LC_COLLATE_LocaleName[strlen(locale)] = '\0';
							 break;
							
			case LC_TIME:	_time_using_locale = 0;
							strcpy((char*) LC_TIME_LocaleName, locale);
							LC_TIME_LocaleName[strlen(locale)] = '\0';
							break;	
						
			case LC_NUMERIC: _numeric_using_locale = 0;
							 __nlocale_changed = 1;
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
							 __applocale_changed = 1;
#endif
							 strcpy((char*) LC_NUMERIC_LocaleName, locale);
							 LC_NUMERIC_LocaleName[strlen(locale)] = '\0';
							 break;
							
			case LC_MONETARY: _monetary_using_locale = 0;
							  __mlocale_changed = 1;
#ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
							  __applocale_changed = 1;
#endif
							  strcpy((char*) LC_MONETARY_LocaleName, locale);
							  LC_MONETARY_LocaleName[strlen(locale)] = '\0';	
							  break;

			case LC_MESSAGES:
			default:
				errno = EINVAL;
				return (NULL);	
		}
		return ((char*) locale);
	}

	//If locale is other than C or POSIX
	TPtrC8 src((const TUint8*)locale);
	TBuf16 <LOCALE_LENGTH> localeString;
	localeString.Copy(src);
	TText* retVal = loc->SetLocale(localeString);
	if(NULL == retVal)
	{
		return NULL;
	}
			
	if(LC_ALL == category)
	{
		TInt retVal =0;
		
		if( __numeric_load_locale(locale) == -1)
		{
			retVal = -1;
		}
		if(__monetary_load_locale(locale) == -1)
		{
			retVal = -1;
		}
		if (__time_load_locale(locale) == -1)
		{
			retVal = -1;
		}	
				
		if(!retVal)
		{
			strcpy((char*) LC_ALL_LocaleName, locale);
			LC_ALL_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_CTYPE_LocaleName, locale);
			LC_CTYPE_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_COLLATE_LocaleName, locale);
			LC_COLLATE_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_NUMERIC_LocaleName, locale);
			LC_NUMERIC_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_MONETARY_LocaleName, locale);
			LC_MONETARY_LocaleName[strlen(locale)] = '\0';
			strcpy((char*) LC_TIME_LocaleName, locale);
			LC_TIME_LocaleName[strlen(locale)] = '\0';
			return (char*) locale;
		}
		else
		{
			return NULL;
		}
	}

	switch (category)
	{
		case LC_CTYPE: 	strcpy((char*) LC_CTYPE_LocaleName, locale);
						LC_CTYPE_LocaleName[strlen(locale)] = '\0';
						break;
						
		case LC_COLLATE: strcpy((char*) LC_COLLATE_LocaleName, locale);
						 LC_COLLATE_LocaleName[strlen(locale)] = '\0';
						 break;
						
		case LC_TIME:	if(!__time_load_locale(locale))
						{
							strcpy((char*) LC_TIME_LocaleName, locale);
							LC_TIME_LocaleName[strlen(locale)] = '\0';
						}
						else
						{
							return NULL;	
						}	
						break;	
					
		case LC_NUMERIC: if(!__numeric_load_locale(locale))
						 {
						 	strcpy((char*) LC_NUMERIC_LocaleName, locale);
							LC_NUMERIC_LocaleName[strlen(locale)] = '\0';
						 }
						 else
						 {
						 	return NULL;	
						 }	
						 break;
						
		case LC_MONETARY: if(!__monetary_load_locale(locale))
						 {
						 	strcpy((char*) LC_MONETARY_LocaleName, locale);
							LC_MONETARY_LocaleName[strlen(locale)] = '\0';	
						 }
						 else
						 {
						 	return NULL;
						 }	
						 break;

		case LC_MESSAGES:
		default:
			errno = EINVAL;
			return (NULL);
	}
	return ((char*) locale);
}
コード例 #24
0
//Resolve the Uri w.r.t a Base and a refernce Uri
void CExampleInetProtUtil::ResolveUriL()
	{
	_LIT(KTextResolve1, "\n\n\nThe Base and reference Uris are\n");
	iConsole->Printf ( KTextResolve1 );
	
	TUriParser8 parserResolve1;
	CUri8* aUriBase = CUri8::NewL(parserResolve1);

	//Adding Scheme
	_LIT8(KScheme, "http");
	aUriBase->SetComponentL(KScheme,EUriScheme);
	
	//Adding Host
	_LIT8(KHost, "symbian.com");
	aUriBase->SetComponentL(KHost,EUriHost);
	
	//Adding Port
	_LIT8(KPort, "90");
	aUriBase->SetComponentL(KPort,EUriPort);
	
	//Adding Path
	_LIT8(KPath, "/resolve.aspx");
	aUriBase->SetComponentL(KPath,EUriPath);
	
	const TDesC8& desBaseUri =aUriBase->Uri().UriDes();
	TBuf16<100> desBase;
	desBase.Copy (desBaseUri);
	iConsole->Printf ( desBase );
	
	iConsole->Printf( KLeaveALine );
	
	CUri8* aUriRef = CUri8::NewL(parserResolve1);
	
	//Adding Path
	_LIT8(KPath1, "/uris/base/reference/resolve.aspx");
	aUriRef->SetComponentL(KPath1,EUriPath);
	
	//Adding Query
	_LIT8(KQuery1, "bar=2&x=3");
	aUriRef->SetComponentL(KQuery1,EUriQuery);
	
	const TDesC8& desRefUri =aUriRef->Uri().UriDes();
	TBuf16<100> desRef;
	desRef.Copy (desRefUri);
	iConsole->Printf ( desRef );
	
	_LIT(KTextResolve, "\nThe Resolved Uri is....\n");
	iConsole->Printf ( KTextResolve );
	
	//Resolve the 2 Uri's to get a resultant uri
	CUri8* Uri8 = CUri8::ResolveL(aUriBase->Uri(),aUriRef->Uri());
	
	// Display the resultant Uri
	const TDesC8& desDisplayReslovedUri = Uri8->Uri().UriDes();
	TBuf16<100> desResolve;
	desResolve.Copy (desDisplayReslovedUri);
	iConsole->Printf ( desResolve );
	
	delete Uri8;
	delete aUriRef;
	delete aUriBase; 
	
	iConsole->Getch ();
	}