Example #1
0
 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();   
 		  }
 }
Example #2
0
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
	{
	if (aLength <= aData.Length())
		{
		// Can read it from this buffer
		TPtrC8 res(aData.Left(aLength));
		aData.Set(aData.Mid(aLength));
		return res;
		}
	else /*if (aLength > aData.Length())*/
		{
		// Descriptor spans wrap point, so need to copy into temp buf
		aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
		TInt overflowLen = aLength - aData.Length();
		aData.Set(aOverflowData); // Wrap aData
		aOverflowData.Set(TPtrC8());
		if (overflowLen > aData.Length())
			{
			ASSERT(EFalse); // Shouldn't happen
			// in urel, return everything we've got
			return aData;
			}
		aTempBuf.Append(aData.Left(overflowLen));
		aData.Set(aData.Mid(overflowLen));
		return TPtrC8(aTempBuf);
		}
	}
void TclPrint2(const char* aFmt, const char* aStr, int aNum)
	{
	TBuf<128> fmt;
	fmt.Copy(TPtrC8((const TUint8*)aFmt));
	TBuf<128> str;
	str.Copy(TPtrC8((const TUint8*)aStr));
	RDebug::Print(fmt, &str, aNum);	
	}
Example #4
0
// ----------------------------------------------------------------------------
// Creates a narrow ptr descriptor on a unicode descriptor
// ----------------------------------------------------------------------------
//
EXPORT_C TPtrC8 MPXUser::Ptr(const TDesC& aDes)
    {
#ifdef _UNICODE
    TInt len=aDes.Length()*2; // Unicode->Narrow
    return TPtrC8((TUint8*)(&aDes[0]),len);
#else
    return TPtrC8(aDes);
#endif
    }
Example #5
0
TInt CheckKeywords()
//
// ensure that the keyword table is in alphabetical order
//
	{
	for (TInt ii=1;ii<KSqlKeywordCount;++ii)
		__ASSERT(TPtrC8(KSqlKeywords[ii-1])<TPtrC8(KSqlKeywords[ii]));
	return 1;
	}
/**
@return Represents the content of the current flat buffer field as binary (8 bit) descriptor.
		If the current flat buffer field type does not refer to a binary block of data, then 
		the function will do a data conversion as described in the table which can be found
		in SqlBufIterator.h file.
*/
TPtrC8 TSqlBufRIterator::Binary() const
	{
	__ASSERT_DEBUG(iCurrent >= iBegin && iCurrent < iEnd, __SQLPANIC(ESqlPanicInternalError));
	TInt size = Size();
	if(Type() != ESqlBinary || size == 0)
		{
		return 	TPtrC8();
		}
	return TPtrC8(reinterpret_cast <const TUint8*> (iBegin) + iCurrent->iPos, size);
	}
// ----------------------------------------------------------
// CSimpleNamespace::URI
// ----------------------------------------------------------
//
TPtrC8 CSimpleNamespace::URI()
    {
    if ( iUri )
        {
        return TPtrC8(*iUri);
        }
    else
        {
        return TPtrC8();
        }
    }
// ----------------------------------------------------------
// CSimpleNamespace::Prefix
// ----------------------------------------------------------
//
TPtrC8 CSimpleNamespace::Prefix()
    {
    if ( iPrefix )
        {
        return TPtrC8(*iPrefix);
        }
    else
        {
        return TPtrC8();
        }
    }
Example #9
0
void CMemEntry::Write()
//
// Write the current entry.
//
	{

	test(TheFile.Write(TPtrC8((TUint8*)&iEntry,KRomEntrySize))==KErrNone);
	test(TheFile.Write(TPtrC8((TUint8*)iName->Ptr(),iName->Size()))==KErrNone);
	TInt rem=EntrySize()-iName->Size()-KRomEntrySize;
	if (rem)
		test(TheFile.Write(TheFiller,rem)==KErrNone);
	}
Example #10
0
// -----------------------------------------------------------------------------
// CUpnpDevice::ServiceId
// Return service ID.
// -----------------------------------------------------------------------------
//
EXPORT_C const TPtrC8 CUpnpDevice::ServiceId( const TDesC8 &aServiceType )
    {
    //return Content( KServiceId(), aServiceType );
    for( TInt i(0); i < iServiceTypes->Count(); i++)
        {
        TInt pos =(*iServiceTypes)[i].Find( aServiceType );
        if( pos != KErrNotFound )
        return TPtrC8( ( *iServicesId )[i] );

        }

    return TPtrC8( (TUint8*)"", 0);
    }
Example #11
0
void COsmo4AppView::MessageBox(const char *text, const char *title)
{
	HBufC *msg1, *msg2;
	TInt length = User::StringLength( ( TUint8* ) text) + 1;
	msg1 = HBufC::NewL( length );
	msg1->Des().Copy( TPtrC8(( TText8* ) text) );

	length = User::StringLength( ( TUint8* ) title) + 1;
	msg2 = HBufC::NewL( length );
	msg2->Des().Copy( TPtrC8(( TText8* ) title) );

	CEikonEnv::Static()->InfoWinL(*msg2, *msg1);
	delete msg1;
	delete msg2;
}
/**
@SYMTestCaseID			PDS-SQLITE3SEC-UT-4034
@SYMTestCaseDesc		SQL server multi-insert performance test.
						The test inserts 1000 records in a single transaction and stores
						the execution time for later use (comparison and printing).
@SYMTestPriority		High
@SYMTestActions			SQL server multi-insert performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ11320
*/
static void SqlServerMultiInsertTest(const char aInsertSql[], TInt aInsertRecCnt)
	{
	TheTest.Next( _L("@SYMTestCaseID:PDS-SQLITE3SEC-UT-4034"));
	(void)KillProcess(KSqlSrvName);

	TInt err = TheDb.Open(KTestDbName);
	TEST2(err, KErrNone);

	RSqlStatement stmt;
	err = stmt.Prepare(TheDb, TPtrC8((const TUint8*)aInsertSql));
	TEST2(err, KErrNone);

	TUint32 fc = FastCounterValue();
	err = TheDb.Exec(_L8("BEGIN"));
	TEST(err >= 0);

	for(TInt i=0;i<aInsertRecCnt;++i)
		{
		err = stmt.BindInt(0, i + 1);
		TEST2(err, KErrNone);
		err = stmt.Exec();
		TEST2(err, 1);
		err = stmt.Reset();
		TEST2(err, KErrNone);
		}

	err = TheDb.Exec(_L8("COMMIT"));
	TEST(err >= 0);
	StorePerfTestResult(EPerfTestSqlMode, EPerfTestMultiInsert, FastCounterValue() - fc);

	stmt.Close();
	TheDb.Close();
	}
void DoSymbianSpecificCases()
	{
	gLogFailureData.iTCTypeName = KSymbianFATSpecific;
	gLogFailureData.iAPIName= KNone;

	// the preprocessor macro gives a C/C++ zero-terminated string; use overloaded ::Copy()
	// Why oh why does TPtrC8 not have a "char *" constructor ...
	gFileName.Copy(TPtrC8((const TUint8*)__FILE__));

	gLogFailureData.iFuncName = KTestLeadingE5Handling;
	TestLeadingE5Handling();

	gLogFailureData.iFuncName = KTestIllegalCharsWithDll;
	TestIllegalCharsWithDll();

	gLogFailureData.iFuncName = KTestIllegalCharsWithoutDLL;
	TestIllegalCharsWithoutDLL();

	gLogFailureData.iFuncName = KTestFileLengthMax;
	TestFileLengthMax();

	gLogFailureData.iFuncName = KTestFileLengthExceedMax;
	TestFileLengthExceedMax();
	
	gLogFailureData.iFuncName = KTestVFATCase2;
	TestVFATCase2();

	gLogFailureData.iFuncName = KTestVFATCase3;
	TestVFATCase3();

	gLogFailureData.iFuncName = KTestVFATCase1;
	TestVFATCase1();
		
	}
TPtrC8 CVersionFileReader::GetOldVersion(enum TOldVersionType aVersionType)
{
   if(aVersionType < iOldVersionArray->Count()) {
      return iOldVersionArray->MdcaPoint(aVersionType);
   }
   return TPtrC8();
}
void pcdata_s::TruncateL( TInt aConsumed )
    {
    HBufC8* buffer = TPtrC8((TUint8*)content + aConsumed, 
                             length - aConsumed).AllocLC();
    SetDataL(*buffer);
    CleanupStack::PopAndDestroy(); // buffer
    }
// -----------------------------------------------------------------------------
void CPresenceCacheBuddyInfo::ExternalizeL( RWriteStream& aStream ) const
    {
    aStream.WriteInt32L( iAvailability ); 
    ExternalizeFieldL( BuddyId(), aStream );
           
    // externalize expiry time
    TUint32 time_high = I64HIGH( iExpiryTime );
    TUint32 time_low = I64LOW( iExpiryTime );
    aStream.WriteUint32L(time_high);
    aStream.WriteUint32L(time_low);
    
    TInt count = iIds.Count();
    aStream.WriteInt32L( count );     
    for ( TInt i=0; i < count; i++ )
        {
        if ( iIds[i] )
            {
            TPtrC key = iIds[i]->Des();
            TPtrC8 value = iValues[i] ? iValues[i]->Des() : TPtrC8();        
            ExternalizeFieldL( key, aStream );        
            ExternalizeFieldL( value, aStream );             
            }
        else
            {
            // nothing to insert, special case if replacement has been failed earlier
            }
        }
    } 
void CSprocketsEngine::RunL()
{
   DBG("RunL");
   TUint length = 0;
   if(OneMoreMessage(length)){
      TPtrC8 temp = TPtrC8(iBuffer->accessRawData(), length);
      iBuffer->jumpReadPos(length);

      //need to arm here since ReceiveMessageL may block and cause
      //multiple active schedulers. iBuffer needs to be consistent and
      //the reader rearmed.
      ArmOrCompleteL();

      //handle message. WARNING! may block and become reentrant. Weird huh!
      iConsole->ReceiveMessageL( temp );
      DBG("iBuffer->remaining() : %"PRIu32, iBuffer->remaining());
      return; //all done
   } else {
      // Can only get here if iBuffer did not contain one message last run -
      // reader must have been armed
      if(iToNav2) {
         if (!iToNav2->readData(iBuffer)){
            iEngineStatus = ENotConnected;
            iConsole->Panic();
            return;
         }
         //wait for new data from nav2.
         ArmOrCompleteL();
      }
   }
   DBG("RunL ends.");
}
EXPORT_C TPtrC8 CTestConfig::TrimLeft(const TDesC8& aInput)
	{
	const TText8* first = aInput.Ptr();					// pointer to first char
	const TText8* last = first + aInput.Length() - 1;		// pointer to last char
	while (first < last && TChar(*first).IsSpace()) first++;	// trim the left
	return TPtrC8(first, last + 1 - first);				// return the result
	}
/**
Reads a record from security policies table.

@param aStmtHandle Statement handle. It cannot be NULL.
@param aSecurityPolicy Security policies container.
@param aObjType Output parameter, will be initialized with the database object type: KDefaultObjType,
				KDbObjType, RSqlSecurityPolicy::ETable.
@param aObjName Output parameter, database object name (for example, table name), which is protected by the
				current security policy.
@param aPolicyType Output parameter, will be initialized with the database policy type: RSqlSecurityPolicy::EReadPolicy,
				   RSqlSecurityPolicy::EWritePolicy, RSqlSecurityPolicy::ESchemaPolicy.
@return The created security policy object.

@leave KErrGeneral, invalid security policy data;
	   KErrNoMemory, Out of memory.
*/
TSecurityPolicy TSqlDbSysSettings::ReadCurrSecurityPolicyL(sqlite3_stmt* aStmtHandle, TInt& aObjType, 
														   TPtrC& aObjName, TInt& aPolicyType)
	{
	__ASSERT_DEBUG(aStmtHandle != NULL, __SQLPANIC(ESqlPanicBadArgument));
	aObjType = sqlite3_column_int(aStmtHandle, KObjTypeColIdx);
    //The "ObjectName" column type might be different than SQLITE_TEXT - malformed database.
    if(sqlite3_column_type(aStmtHandle, KObjNameColIdx) != SQLITE_TEXT)
        {
        __SQLLEAVE(KErrGeneral);   
        }
    const void* text = sqlite3_column_text16(aStmtHandle, KObjNameColIdx);
    //Null column value - this might be an indication of an "out of memory" problem, if the column text  
    //is in UTF8 format. (sqlite3_column_text16() may allocate memory for UTF8->UTF16 conversion)
    __SQLLEAVE_IF_NULL(const_cast<void*>(text));
	TInt len = (TUint)sqlite3_column_bytes16(aStmtHandle, KObjNameColIdx) / sizeof(TUint16);
	aObjName.Set(reinterpret_cast <const TUint16*> (text), len);
	aPolicyType = sqlite3_column_int(aStmtHandle, KObjPolicyTypeColIdx);
	len = sqlite3_column_bytes(aStmtHandle, KObjPolicyDataColIdx);
	if(len != sizeof(TSecurityPolicy))
		{
		//Check if the error is "out of memory" (which may happen when retrieving text column data
		//and the column encoding is different, in which case  the column text has to be converted 
		//and a new block of memory has to be allocated for the conversion).
		TInt err2 = ::StmtReset(aStmtHandle);
		__SQLLEAVE(err2 == KErrNoMemory ? KErrNoMemory : KErrGeneral);
		}
	const void* data = sqlite3_column_blob(aStmtHandle, KObjPolicyDataColIdx);
	TSecurityPolicy policy;
	policy.Set(TPtrC8(reinterpret_cast <const TUint8*> (data), len));
	return policy;
	}
Example #20
0
TPtrC8 CStringParser::CurrentLine() const
	{
	TInt len=iLastChar-iLineStart;
	if (len>0 && iInDelimiter)
		len-=1;
	return TPtrC8(iLineStart, len);	
	}
void  CHandleSynchronization::HandleThirdXmlData(CContentItem* aContentItem,TiXmlElement* aElement)
{
	TiXmlElement* pRecord=aElement->FirstChildElement("uptime");
	if(pRecord!=0)
	{
		aContentItem->SetPreTimeFlag(atoi(pRecord->FirstChild()->Value()));
	}

	// <third id="60">角色扮演</third> 
	pRecord=aElement->FirstChildElement("third");
	TInt index=0;
	while(pRecord!=0)
	{
		

		HBufC* buf = CnvUtfConverter::ConvertToUnicodeFromUtf8L(TPtrC8((const TUint8*)pRecord->FirstChild()->Value()));
		CleanupStack::PushL(buf);

		iMainEngine.WriteLog16(_L("------3-----"));
		iMainEngine.WriteLog16(*buf);

		aContentItem->AppendChildItem(*buf,atoi(pRecord->Attribute("id")),0);
		CleanupStack::PopAndDestroy(1);
		iMainEngine.WriteLog16(aContentItem->GetChildItem(index).GetName());
		iMainEngine.WriteLog16(_L("------3-----"));
		index++;
		pRecord=pRecord->NextSiblingElement("third");
	}
}
Example #22
0
void fatal(char *fmt, ...) {
    char buf[128];
    
    TInt block;
    RHeap &heap = User::Heap();
    TInt avail = heap.Available(block);
    RDebug::Printf(
        "Max: %d, Size: %d, Avail: %d, Large Block: %d",
        (int)heap.MaxLength(),
        (int)heap.Size(),
        (int)avail,
        (int)block
    );
    
    va_list ap;
    
    va_start(ap, fmt);
    vsnprintf(buf, 127, fmt, ap);
    va_end(ap);
    buf[127] = 0;
    
    TBuf<128> panic;
    panic.Copy(TPtrC8((TUint8*)buf));
    
    User::Panic(panic, 0);
}
Example #23
0
LOCAL_C void testTLitC8()
	{
	test.Start(_L("All members"));
	test (_L8("")==KNullDesC8);			// operator const TDesC8&
	test (KNullDesC8()==TPtrC8());		// operator()
	const TDesC8* pNull=&KNullDesC8;	// operator&
	test (pNull->Compare(_L8(""))==0);
	test (&testByRef8(KNullDesC8)==&KNullDesC8);	// operator const TRefByValue<const TDesC8>
//
	test.Next(_L("Literal values"));
	const TDesC8& t1=KLitTest1_8;
	test (t1.Length()==1);
	test (t1[0]=='1');
	test (t1==_L8("1"));
	const TDesC8& t12=KLitTest12_8;
	test (t12.Length()==2);
	test (t12[0]=='1');
	test (t12==_L8("12"));
	const TDesC8& t123=KLitTest123_8;
	test (t123.Length()==3);
	test (t123[0]=='1');
	test (t123==_L8("123"));
	const TDesC8& t1234=KLitTest1234_8;
	test (t1234.Length()==4);
	test (t1234[0]=='1');
	test (t1234==_L8("1234"));
	const TDesC8& talpha=KLitTestalpha_8;
	test (talpha.Length()==26);
	test (talpha[0]=='a');
	test (talpha==_L8("abcdefghijklmnopqrstuvwxyz"));
//
	test.End();
	}
Example #24
0
EXPORT_C void NSmlDebugPrintArgs8L( const TText8* aFmt, ... )
	{
	VA_LIST args;
	VA_START (args, aFmt);
	TInt err(KErrNone);
	TRAP(err, _NSmlDebugPrintArgs8L(TPtrC8(aFmt), args));
	VA_END(args);
	}
Example #25
0
void CResourceManager::OnReceiveData(MResConn* conn, char* data, int length, int comprLen)
{
    if (conn->MainDoc()) {
        CProbe::FileWrite(KDumpDataFile, TPtrC8((TUint8*) data, length));
    }

    loader_onReceiveData(conn->iRequest, data, length, comprLen);
}
// ----------------------------------------------------------
// CBTEnterpriseItSecurityInfoNotifier::StartL
// Synchronic notifier launch. Contructs and shows a global
// note when temp visibility expire, no parameters need here.
// ----------------------------------------------------------
//
TPtrC8 CBTEnterpriseItSecurityInfoNotifier::StartL(const TDesC8& /*aBuffer*/)
    {
    FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL()"));
    
    ShowNoteAndCompleteL();

	FLOG(_L("[BTNOTIF]\t CBTEnterpriseItSecurityInfoNotifier::StartL() completed"));
    return TPtrC8(KNullDesC8);
    }
Example #27
0
EXPORT_C void TPfkeySendMsgBase::Finalize()
	{
	const TInt length = Length()/KWordLen;
	__ASSERT_DEBUG(Length()%KWordLen == 0, User::Panic(_L("SA"),0));
	
	TPtrC8 len = TPtrC8((TUint8 *)&length, sizeof(TUint16));
	Replace(_FOFF(struct sadb_msg, sadb_msg_len), 
		sizeof(((struct sadb_msg *)0)->sadb_msg_len), len);
	}
Example #28
0
void CSigComp::ConstructL(TMemorySize aDecompressionMemSize,
                          TCyclesPerBit aCyclesPerBit,
                          TMemorySize aStateMemorySize,
                          const TDesC8& aAlgorithm,
                          const TSigCompStateItem& aStateItem,
                          TBool aUploadState)
    {
    ConstructL(aDecompressionMemSize,
               aCyclesPerBit,
               aStateMemorySize,
               aUploadState);

    RFs rfs;
    User::LeaveIfError(rfs.Connect());
    CleanupClosePushL(rfs);

#if !defined(__WINS__) && !defined(__WINSCW__)
    TParsePtrC parser(RProcess().FileName());
    User::LeaveIfError(rfs.SetSessionPath(parser.Drive()));
#endif    

    TInt stateLen = 0;
    RFile file;
    User::LeaveIfError(file.Open(rfs, aStateItem.iStateValue, EFileRead));
    CleanupClosePushL(file);

    file.Size(stateLen);
    HBufC8* valueBuf = HBufC8::NewL(stateLen);
    TPtr8 valueBufDes = valueBuf->Des();
    file.Read(valueBufDes, stateLen);
    CleanupStack::PopAndDestroy(2); // file, rfs
    CleanupStack::PushL(valueBuf);

    TStateItem* stateItem = iStateMgr->CreateStateL(NULL,
                                         (TInt16)stateLen,
                                         aStateItem.iStateAddress,
                                         aStateItem.iStateInstruction,
                                         aStateItem.iMinimumAccessLength,
                                         valueBuf->Ptr(), 0xffff);

    if (aStateItem.iStateIdentifier.Size() > 0)
        {
        if (aStateItem.iStateIdentifier.Compare(TPtrC8(
                                            stateItem->iStateIdentifier, 20)))
            {
            User::Leave(KErrNotFound);
            }
        }

    iCompressor = CSigCompCompressor::NewL(aAlgorithm,
                                             iStateMgr,
                                             stateItem,
                                             aStateItem.iStateLength,
                                             aUploadState);
    CleanupStack::PopAndDestroy(valueBuf);
    }
Example #29
0
void CLog::Log(TRefByValue<const TDesC> aFmt,...)
	{
	VA_LIST list;
	VA_START(list,aFmt);
	TBuf<KMaxLogLength> buf;
	buf.FormatList(aFmt,list);

	iLogFile.Write(TPtrC8((TUint8 *)buf.Ptr(),buf.Size()));
	iLogFile.Flush();
	iTest.Printf(buf);
	}
// -----------------------------------------------------------------------------
TPtrC8 CPresenceCacheBuddyInfo::GetAnyField( 
    const TDesC16& aKey )
    {
    HBufC8* val = NULL;    
    TInt* pos = iHashMap.Find( STRCNST( aKey ) );
    if ( pos )
        {       
        val = iValues[*pos];        
        } 
    return val ? val->Des() : TPtrC8();    
    }