/**
Auxilary function should be called only when we need to generate hash values from the screen and returns its hex format.
@param aHexString the output MD5 hash hex string obtained from iBitmapDevice
*/
EXPORT_C void CTHashReferenceImages::GenerateHashAndReturnInHexFormatL(TDes &aHexString)
	{
	TInt bufLen = CFbsBitmap::ScanLineLength(iBitmapDevice->SizeInPixels().iWidth, iBitmapDevice->DisplayMode());
	RBuf8 buff;
	buff.CreateL(bufLen);
	CleanupClosePushL(buff);	
	CMD5 *md = CMD5::NewL();
	CleanupStack::PushL(md);
	for (TPoint pos(0, 0); pos.iY < iBitmapDevice->SizeInPixels().iHeight; pos.iY++)
		{
		iBitmapDevice->GetScanLine(buff,pos,iBitmapDevice->SizeInPixels().iWidth,iBitmapDevice->DisplayMode());
		md->Update(buff);
		}

	TBuf8<KLengthOfHashValue> hashString;
	//md will be reset after calling CMD5::Final() as Final will call Reset.
	hashString.Copy(md->Final());
	aHexString.Zero();

	for(TInt icount=0; icount < hashString.Length(); icount++)
		{
		aHexString.AppendNumFixedWidth(hashString[icount], EHex, 4);
		}
	CleanupStack::PopAndDestroy(2, &buff);
	}
// -----------------------------------------------------------------------------
// Gets skin directory as descriptor based on drive type and array loc.
// -----------------------------------------------------------------------------
//
void CAknsSrvDriveMaster::SkinDirectoryOnDrive(
        TAknsSrvSkinDriveList aDriveType,
        TInt aLocation,
        TDes& aPath ) const
    {
    AKNS_TRACE_INFO("CAknsSrvDriveMaster::SkinDirectoryOnDrive");
    TInt driveNumber = KErrNotFound;
    aPath.Zero();
    if ( aDriveType == EAknsSrvStaticDrive )
        {
        if ( iStaticDriveArray.Count() == 0 )
            {
            return;
            }
        if ( aLocation >= 0 && aLocation <= iStaticDriveArray.Count() )
            {
            driveNumber = iStaticDriveArray[ aLocation ];
            AppendDriveLetterToDes( driveNumber, aPath );
            aPath.Append( KAknSkinSrvPrivateSkinPath );
            }
        }
    else if ( aDriveType == EAknsSrvRemovableDrive )
        {
        if ( iRemovableDriveArray.Count() == 0 )
            {
            return;
            }
        if ( aLocation >= 0 && aLocation <= iRemovableDriveArray.Count() )
            {
            driveNumber = iRemovableDriveArray[ aLocation ];
            AppendDriveLetterToDes( driveNumber, aPath );
            aPath.Append( KAknSkinSrvPrivateSkinPath );
            }
        }
    }
// ----------------------------------------------------
// CAlfExCalendarEngine::NumberOfEvents
// ----------------------------------------------------
void CAlfExCalendarEngine::GetEventInformation( 
    const TTime& aDate, 
    TInt aIndex, 
    TDes& aTextBuffer)
    {
    aTextBuffer.Zero();
    TInt count = KErrNotFound;
    TDateTime requestedDate = aDate.DateTime();
    const TInt arrayCount = iCalendarEventArray.Count();
    for(TInt loop = 0; loop < arrayCount; loop++ )
        {
        TDateTime eventDate = iCalendarEventArray[loop].iItemDay.DateTime();
        if(eventDate.Day() == requestedDate.Day() && 
           eventDate.Month() == requestedDate.Month() &&
           eventDate.Year() == requestedDate.Year())
            {
            count++;
            }
        if(aIndex == count)
            {
            aTextBuffer.Copy(iCalendarEventArray[loop].iItemText);
            loop = arrayCount;
            }
        }
    }
/**
Loads the database system settings from the settings table.
If the settings table does not exist then it is created with the default settings
(the stored collation dll name will be empty and the stored database configuration 
file version will be 0).

@param aDbName Logical database name: "main" for the main database or attached database name,
@param aCollationDllName Output parameter, will contain the stored collation dll name,
@param aDbConfigFileVersion Output parameter, will contain the stored database config file version.
@param aCompactionMode Output parameter. Database compaction mode (one of TSqlCompactionMode enum item values except ESqlCompactionNotSet).
					   Note that the input value of this parameter might be ESqlCompactionManual if the this is a legacy database,
					   created not by the SQL server.

@see TSqlCompactionMode

@leave KErrNoMemory, an out of memory condition has occurred.
       Note that the function may also leave with some other database specific 
       errors categorised as ESqlDbError, and other system-wide error codes..
@panic SqlDb 2 In _DEBUG mode if iDbHandle is NULL (uninitialized TSqlDbSysSettings object).
@panic SqlDb 7 In _DEBUG mode if the stored compaction mode is invalid.
*/	
void TSqlDbSysSettings::LoadSettingsL(const TDesC& aDbName, TDes& aCollationDllName, TInt& aDbConfigFileVersion, TSqlCompactionMode& aCompactionMode)
	{
	__ASSERT_DEBUG(iDbHandle != NULL, __SQLPANIC(ESqlPanicInvalidObj));

	aCollationDllName.Zero();
	aDbConfigFileVersion = KSqlNullDbConfigFileVersion;	
	if(aCompactionMode == ESqlCompactionNotSet)
		{
		aCompactionMode = KSqlDefaultCompactionMode;
		}
		
	//If the system settings table does not exist then create it now.
	//For a database created by the SQL Server this will only occur 
	//when the database is being created in an application's private data cage -
	//as part of this create call it is now being opened by the server.
	//An externally created database is likely to not contain the settings table 
	//and adding it here makes the database 'SQL Server-compatible'
	if(!SettingsTableExistsL(aDbName))
		{
		StoreSettingsL(aDbName, aCollationDllName, KSqlNullDbConfigFileVersion, aCompactionMode); // store empty collation dll name, then reindexing will occur
		}
	else
		{
		//Get the settings from the existing table
		TInt settingsVersion = 0;
		GetSettingsL(aDbName, aCollationDllName, aDbConfigFileVersion, settingsVersion, aCompactionMode);
		if(settingsVersion < KSqlSystemVersion)
			{
			//Recreate the settings table using the last version number format (this is what the old code did during reindexing)
			StoreSettingsL(aDbName, aCollationDllName, aDbConfigFileVersion, aCompactionMode); // store empty collation dll name, then reindexing will occur
			}
		}
	__ASSERT_DEBUG(aCompactionMode == ESqlCompactionManual || aCompactionMode == ESqlCompactionBackground || aCompactionMode == ESqlCompactionAuto, __SQLPANIC(ESqlPanicInternalError));
	}
 /* if no length is specified, the whole string is converted */
 int ConvertStringToUnicode(const unsigned char* aText, TDes& aDesc,
                            int aLength)
 {
   if( aText != NULL ) {
     /* initialize variables */
     aDesc.Zero();
     int textlen;
       /* check the length of the string */
       if( aLength == -1 ) {
       textlen = strlen((char*)aText);
     } else {
         textlen = aLength;
      }
      /* start copying the string if it's not zero-length */
     if( textlen > 0 ) {
       /* compensate for longer text than descriptor */
        if( textlen >= aDesc.MaxLength() ){
          textlen = aDesc.MaxLength()-1;
       }
       /* copy the data */
       for( TInt j=0; j < textlen; j++ )
          {
             aDesc.Append( aText[j] );
          }
       aDesc.PtrZ();
       }
   }else{
       return(0);
    }
   return(aDesc.Length());
 }
void CDscDatabase::GetDscDescriptionL(const TUid &aDscId, TDes& aDescription) const
	{	
	RDbView view;
	CleanupClosePushL(view);

	RBuf sqlCmd;
	CleanupClosePushL(sqlCmd);
	sqlCmd.CreateL(KSqlSelectDscDescriptionLength);
	
	sqlCmd.Format(KSqlSelectDscDescription, &KDescriptionCol, &KDscTable, &KDscIdCol, aDscId);
	DebugPrint(sqlCmd);
	User::LeaveIfError(view.Prepare(iDatabase, sqlCmd));
	User::LeaveIfError(view.EvaluateAll());  
	CleanupStack::PopAndDestroy(&sqlCmd);
	
	if(view.IsEmptyL())
		{
		User::Leave(KErrNotFound);
		}
	
 	view.FirstL();
	view.GetL();
	
	//Check the length of aDescription
	TPtrC description(view.ColDes(1));
	if (description.Length() > aDescription.MaxLength())
		{
		User::Leave(KErrOverflow);
		}
	
	aDescription.Zero();	
	aDescription=description;
	
	CleanupStack::PopAndDestroy(&view);
	}
Beispiel #7
0
void FillRandomData(TDes& aData, TInt64 aSeed)
	{
	aData.Zero();
	for (TInt i=0; i<aData.MaxLength(); ++i)
		{
		// add next character (we stick to lowercase alphabet for now)
		aData.Append(TChar(Math::FRand(aSeed)*25 + 'a'));	
		}
	}
void CHlpFileEntry::GetFullNameAndPath(TDes& aName) const
	{
	TChar driveLetter = '?';
	RFs::DriveToChar(Drive(), driveLetter);
	aName.Zero();
	aName.Append(driveLetter);
	aName.Append(':');
	aName.Append(KHlpFileSearchPath);
	aName.Append(FileName());
	}
/**
Construct a descriptor containing the composite file name from the DLL to load

@param aSwp The swp to create the file name for
@param aLibraryFilename reference to object in which file name is returned
@leave KErrNotFound If the swp is not registered
*/
void CSsmSwpPolicyResolver::GetFileNameForSwpL(const TSsmSwp& aSwp, TDes& aLibraryFilename) const
	{
	aLibraryFilename.Zero();
	aLibraryFilename.Append(KRomDriveLetter);
	aLibraryFilename.Append(iSwpPolicyMap->FilenameL(aSwp.Key()));
	const TInt postfixLength = KDllFilenamePostfix().Length();
	if(KDllFilenamePostfix().CompareF(aLibraryFilename.Right(postfixLength)))
		{
		aLibraryFilename.Append(KDllFilenamePostfix);
		}
	}
// ---------------------------------------------------------------------------
// RPeninputServerImpl::GetServerEventData
// Retrieve server event data
// ---------------------------------------------------------------------------
//
TInt RPeninputServerImpl::GetServerEventData(TDes& aBuf)
    {
    if(iServerExit)  // ???
      return -1;
    
    TIpcArgs arg;
    aBuf.Zero();    
    arg.Set(KMsgSlot0,aBuf.MaxLength());
    arg.Set(KMsgSlot1,&aBuf);
    return SendReceive(EPeninputRequestGetServerEventData,arg);
    }
// -----------------------------------------------------------------------------
// Finds and appends skin server's private mass memory drive directory to a string.
// -----------------------------------------------------------------------------
//
void CAknsSrvDriveMaster::DefaultSkinDirectoryOnMemoryCard( TDes& aPath )
    {
    AKNS_TRACE_INFO("CAknsSrvDriveMaster::DefaultSkinDirectoryOnMemoryCard");
    aPath.Zero();
    TInt drive = KErrNotFound;
    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
    AppendDriveLetterToDes( drive, aPath );
    if ( aPath.Length() )
        {
        aPath.Append( KAknSkinSrvPrivateSkinPath );
        }
    }
EXPORT_C void GetCountryName(TInt aMcc, TDes& aInto)
{
	TMccItem i= { aMcc, _S("") };
	TMccKey k;
	k.SetPtr(&i);
	TInt pos;
	if ( User::BinarySearch(MCC_COUNT, k, pos)==0 ) {
		aInto = (TText16*)KMccItems[pos].iCountryName;
	} else {
		aInto.Zero();
	}
}
void CLocaLogicImpl::ConvertFromPythonString(TDes& aBuf, PyObject* aString)
{
	aBuf.Zero();
	if (PyString_Check(aString)) {
		TInt state=CCnvCharacterSetConverter::KStateDefault;
		TInt len=PyString_Size(aString);
		if (len > aBuf.MaxLength()) len=aBuf.MaxLength();
		iCC->ConvertToUnicode(aBuf, TPtrC8((TUint8*)PyString_AsString(aString), 
			len), state);
	} else if (PyUnicode_Check(aString)) {
		TInt len=PyUnicode_GetSize(aString)/2;
		if (len > aBuf.MaxLength()) len=aBuf.MaxLength();
		aBuf=TPtrC((TUint16*)PyUnicode_AsUnicode(aString), len);
	}
}
Beispiel #14
0
// -----------------------------------------------------------------------------
// Compelete file name with file path of the dll
// -----------------------------------------------------------------------------
//
EXPORT_C TInt MPXUser::CompleteWithDllPath(const TDesC& aDllName, TDes& aFileName)
    {
    MPX_DEBUG2("==>MPXUser::CompleteWithDllPath aFileName %S", &aFileName);
    TInt error(KErrNotSupported);
    MPX_DEBUG2("MPX Dll file path: %S", &aDllName);
    TPtrC driveAndPath = TParsePtrC(aDllName).DriveAndPath();
    TParse parse;
    error = parse.Set(aFileName, &driveAndPath, NULL);
    if (!error)
        {
        aFileName.Zero();
        aFileName.Append(parse.FullName());
        }
    MPX_DEBUG2("<==MPXUser::CompleteWithDllPath aFileName %S", &aFileName);
    return error;
    }
// -----------------------------------------------------------------------------
// RCbsTopicMessages::GetMessageContents
// Returns the message contents.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
// 
TInt RCbsTopicMessages::GetMessageContents( 
    const TCbsMessageHandle& aHandle, 
    TDes& aBuffer )
    {
    // Send request to get the message contents
    TPckgBuf< TCbsMessageHandle > pckgHandle( aHandle );
    TInt length = aBuffer.MaxLength();
    const TIpcArgs args( &pckgHandle, length, &aBuffer );

    TInt result( SendReceive( ECbsGetMessageContents, args ) );
    if ( result != KErrNone )
        {
        aBuffer.Zero();
        }
    return result;
    }
   /* returns the complete path to a file located in the application's
      folder */
   int GetCompletePath(const TDesC& fileName, TDes& fullPath) {
      /* zero out the destination descriptor */
      fullPath.Zero();
      
      /* get our application's path using the CEikApplication */
      /* the trailing slash is present after the folder name */
      fullPath.Copy(
         BaflUtils::DriveAndPathFromFullName(
            CEikonEnv::Static()->EikAppUi()->Application()->AppFullName()));

      /* append the filename to the path */
      fullPath.Append(fileName);
      
      /* success */
      return(0);
   }
// ---------------------------------------------------------------------------
// CMmPacketContextList::GenerateNewContextName
// This function generates new proxy id and context name.
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
TInt CMmPacketContextList::GenerateNewContextName(
        TDes& aNewName,     //name of the context
        TUint8& aProxyId )    //proxy id of the context
    {

    TInt ret( KErrOverflow );

    // Find first free proxy id from the list
    for ( TInt i = 0; i < KMmMaxNumberOfContexts; i++ )
        {
        if ( iProxyIdList[i].iIsFree )
            {
            // Set proxy id to the iChannelId
            aProxyId = ( TUint8 )iProxyIdList[i].iChannelId;
   
            aNewName.Zero();

            TInfoName contextName;

            do
                {
                contextName.Zero();
                // Make sure number to add is between 100 and 255 (TUint8)
                if ( 100 > iIndividualNameForContext )
                    {
                    iIndividualNameForContext = 100;
                    }
                contextName.AppendNum( ( TInt )iIndividualNameForContext++ );
                // Internally created context name
                _LIT( KContextNameInt, "Int_" );
                contextName.Append( KContextNameInt );
                contextName.AppendNum( ( TInt )aProxyId );
                }
            while ( NULL != CMmPacketContextList::PacketContextByName( 
					&contextName ) );
            
            aNewName = contextName;
            // Proxy id selected, set ret to KErrNone
            ret = KErrNone;
            
            i = KMmMaxNumberOfContexts;
            }
        }

    return ret;
        
    }
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CMainContainer::GetValuesL(CDictionaryFileStore* aDStore,TInt aUID,TDes& aValue)
{
	aValue.Zero();
	
	if(aDStore == NULL)
		return;
		
	TUid FileUid = {0x10};
	FileUid.iUid = aUID;

	if(aDStore->IsPresentL(FileUid))
	{
		RDictionaryReadStream in;
		in.OpenLC(*aDStore,FileUid);
		in >> aValue;
		CleanupStack::PopAndDestroy(1);// in
	}
Beispiel #19
0
/*
-------------------------------------------------------------------------
-------------------------------------------------------------------------
*/
void CTraceContainer::GetInfoBufferL(TExampleItem& aItem,TDes& aBuffer)
{
	aBuffer.Zero();

	
	aBuffer.Append(_L("\n"));
	aBuffer.Append(_L("Time:\n"));
	aBuffer.AppendNum(aItem.iTime.DateTime().Hour());
	aBuffer.Append(_L(":"));
	if(aItem.iTime.DateTime().Minute() < 10)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Minute());
	aBuffer.Append(_L(":"));
	if(aItem.iTime.DateTime().Second() < 10)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Second());
	
	aBuffer.Append(_L(" - "));

	if(aItem.iTime.DateTime().Day() < 9)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Day() + 1);
	aBuffer.Append(_L("/"));
	
	TMonthNameAbb ThisMonth(aItem.iTime.DateTime().Month());
	aBuffer.Append(ThisMonth);
	aBuffer.Append(_L("/"));
	
	TInt Yearrr = aItem.iTime.DateTime().Year();
	TInt Hudreds = Yearrr / 100;
	
	Yearrr = (Yearrr - (Hudreds * 100));
	if(Yearrr < 10)
	{
		aBuffer.AppendNum(0);	
	}
	
	aBuffer.AppendNum(Yearrr);
	aBuffer.Append(_L("\n"));
}
//*******************************************************************************
// Method      : CTestAppConsole::GetAddrFromConsole()
// Purpose     : 
// Parameters  : 
// Return Value: 
//*******************************************************************************
TKeyCode CTestAppConsole::GetStringFromConsole(TDes &aAddr)
    {
	// Get a line from console
    TKeyCode input = EKeyNull;
    const TInt start_pos = iConsole->WhereX();
    aAddr.Zero();

    // loop until descriptor full or EKeyEnter or EKeyEscape entered
    do {
        // get one character
        input = iConsole->Getch();
        // process it
        if(input == EKeyBackspace  ||  input == EKeyDelete)
            {
            // backspace or delete
            if(iConsole->WhereX() > start_pos)
                {
				iConsole->SetPos(iConsole->WhereX() - 1);
				iConsole->ClearToEndOfLine();
				if(aAddr.Length() > 0) 
                    {
					aAddr.SetLength(aAddr.Length() - 1);
                    }
                }
            }
        else
            {
            // other than backspace or delete
            TChar ch(input);
            if(ch.IsPrint())
                {
                aAddr.Append(ch);
                iConsole->Printf(_L("%c"), input);
                }
            }   
        } 
    while(aAddr.Length() < aAddr.MaxLength()  &&  input != EKeyEnter  &&  input != EKeyEscape);

    DisplayMsg(KTxtLineBreak);
    return input;
    }
/**
Copies the content of a text column, identified by aColumnIndex, to the place refered by aDest parameter.

If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.

@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.

@return KErrNone, if the function completes successfully,
                  otherwise one of the other system-wide error codes.

@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/	
TInt CSqlStatementImpl::ColumnText(TInt aColumnIndex, TDes& aDest)
	{
	__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
	__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
	iColumnValBufIt.MoveTo(aColumnIndex);		
	TInt err = KErrNone;
	//The text column value has not been transferred to the client side if its length is >= KSqlMaxDesLen characters.
	//In this case an additional call to the server is made to get the column value.
	if(!iColumnValBufIt.IsPresent())
		{
		if(iColumnValBufIt.Type() != ESqlText)
			{
			aDest.Zero();
			return err;
			}
		TPtr8 ptr(reinterpret_cast <TUint8*> (const_cast <TUint16*> (aDest.Ptr())), aDest.MaxLength() * sizeof(TUint16));
		err = iSqlStmtSession.ReadColumnValue(aColumnIndex, ptr);
		switch(err)
		    {
	        case KErrNone:
	        case KErrOverflow:
	            aDest.SetLength(ptr.Length() / sizeof(TUint16));
	            break;
	        default:
	            break;
		    }
		}
	else
		{
		TPtrC src = iColumnValBufIt.Text();
		TInt len = src.Length();
		if(len > aDest.MaxLength())
			{
			len = aDest.MaxLength();
			err = KErrOverflow;
			}
		aDest.Copy(src.Ptr(), len);
		}
	return err;
	}
// Convert decoded buffer to Unicode
//
EXPORT_C TInt CImConvertCharconv::ConvertToOurCharsetL(const TDesC8& aBufIn, TDes& rBufOut, 
										TInt& rNumUnconvertedChars,
										TInt& rIndexOfFirstUnconvertedChar)
	{
	// Conversion is not needed if iCharsetUid is any of UTF-16(UCS2), UTF-16LE(LittleEndian), UTF-16BE
	// just do a straight copy.
	if (!iCharsetUid || iCharsetUid==KUidMsvCharsetNone  || iCharsetUid == KCharacterSetIdentifierUcs2
	    || iCharsetUid == KCharacterSetIdentifierUnicodeLittle || iCharsetUid == KCharacterSetIdentifierUnicodeBig)
		{
		return StraightCopy(aBufIn, rBufOut);
		}
	else
		{
		rNumUnconvertedChars=0;
		rIndexOfFirstUnconvertedChar=-1;
		TInt err = iConverter.ConvertToUnicode(rBufOut, aBufIn, iCharconvState, 
							rNumUnconvertedChars, rIndexOfFirstUnconvertedChar);
		if (err<0 && rBufOut.Length()>0)
			rBufOut.Zero();
		return err;
		}
	}
Beispiel #23
0
/*
 * ActiveCall() detects if there's a connected call. Only in that case aNumber is meaningfull; and only 
 * in that case, if aNumber.Length() == 0, then aNumber is a private number.
 */
TBool CPhoneCallMonitor::ActiveCall(TDes& aNumber)
	{
	CTelephony::TRemotePartyInfoV1 remInfoUse;
	CTelephony::TCallInfoV1		   callInfoUse;
	CTelephony::TCallSelectionV1   callSelectionUse;
	  		
	// we are interested only voice lines
	callSelectionUse.iLine = CTelephony::EVoiceLine;
	// and calls that are currently connected
	callSelectionUse.iSelect = CTelephony::EActiveCall;  //EHeldCall, EInProgressCall
	  		
	CTelephony::TRemotePartyInfoV1Pckg 	remParty(remInfoUse);
	CTelephony::TCallInfoV1Pckg 		callInfo(callInfoUse);
	CTelephony::TCallSelectionV1Pckg 	callSelection(callSelectionUse);
	  	
	// TCallRemoteIdentityStatus::ERemoteIdentityUnknown, ERemoteIdentityAvailable, ERemoteIdentitySuppressed
	if(iTelephony->GetCallInfo(callSelection,callInfo,remParty) == KErrNone)
		{
		if(remInfoUse.iDirection == CTelephony::EMobileOriginated) //outgoing call
			{
			aNumber.Copy(callInfoUse.iDialledParty.iTelNumber);
			}
		else   //incoming call
			{
			if(remInfoUse.iRemoteIdStatus == CTelephony::ERemoteIdentityAvailable)
				{
				aNumber.Copy(remInfoUse.iRemoteNumber.iTelNumber);
				}
			else  // private number
				{
				aNumber.Zero();
				}
			}
		return ETrue;
		}
	
	return EFalse;
	}
void DegAndMinutesToGeo(const TDesC& aMin, TDes& aInto, TInt aSign)
{
	aInto.Zero();
	if (aMin.Compare(_L("0000.0000"))==0  || aMin.Compare(_L("00000.0000"))==0  || aMin.Length()<3) {
		return;
	}
	TInt decpos=aMin.Locate('.');
	if (decpos==KErrNotFound || decpos<3) return;

	TReal deg, min;
	{
		TLex lex(aMin.Left(decpos-2));
		if (lex.Val(deg)!=KErrNone) {
			return;
		}
	}

	{
		TLex lex(aMin.Mid(decpos-2));
		if (lex.Val(min)!=KErrNone) {
			return;
		}
		if (deg==TReal(0) && min==TReal(0)) return;
		min/=TReal(60);
	}

	deg+=min;

	if (deg > TReal(180)) return;

	deg*=aSign;
	TRealFormat fmt; fmt.iTriLen=0;
	fmt.iPoint='.'; fmt.iPlaces=8;
	fmt.iType=KRealFormatCalculator;
	aInto.Num(deg, fmt);
}
// -----------------------------------------------------------------------------
// COMASuplFallBackHandler::GetNextSLPAddressL
// -----------------------------------------------------------------------------
//    TODO: Merge if conditions...
TInt COMASuplFallBackHandler::GetNextSLPAddressL(TInt64& aSLPId, TDes& aHslpToBeUsedAddress,TDes& aIAPName,TBool& aTls,
        TBool& aPskTls,TInt aLastErrorCode,TBool& aIsIapDialogShown)
{
    iTrace->Trace(_L("COMASuplFallBackHandler::GetNextSLPAddressL"),KTraceFileName, __LINE__);

    _LIT(KFormatTxt,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");

    TBuf<256> LogBuffer;

    if( aLastErrorCode != KErrNone)// If its KErrNone then its means server name is asked first time and no need for Tls failure check
    {

        if( CheckErrorCodeL(aLastErrorCode) )
        {

            if( iTLSAuthenticationFailed )
            {
                if(iErrorCode == KErrNone)
                {
                    aHslpToBeUsedAddress.Copy(iGenratedHslpAddress);
                    aIAPName.Zero();
                    aIAPName.Copy(iDefaultIAPName);
                    aTls = ETrue;
                    aPskTls = EFalse;
                    aIsIapDialogShown = ETrue;

                    CServerParams* param = CServerParams::NewL();
                    CleanupStack::PushL(param);

                    //Find out if this alternative generated SUPL server is in the SUPL Settings list
                    TInt err = iSuplSettings.GetSlpInfoAddress(iGenratedHslpAddress, param);
                    if(err == KErrNotFound)
                    {
                        //Server does not exist
                        iTrace->Trace(_L("Server does not exist in list so adding it in."),KTraceFileName, __LINE__);
                        CServerParams* newParam=CServerParams::NewL();
                        CleanupStack::PushL(newParam);
                        User::LeaveIfError(newParam->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse ));

                        err = iSuplSettings.AddNewServer( newParam, aSLPId ); //Ignore error
                        LogBuffer.Copy(_L("AddNewServer() completed with err: "));
                        LogBuffer.AppendNum(err);
                        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                        CleanupStack::PopAndDestroy(newParam);
                    }
                    else
                    {
                        //Server exists, get the SLP ID and the IAP Access point for this server
                        HBufC* hslpAddress =  HBufC::NewL(KHSLPAddressLength);
                        HBufC* iapName =  HBufC::NewL(KMaxIapNameLength);
                        TBool serverEnabled;
                        TBool simChangeRemove;
                        TBool usageInHomeNw;
                        TBool editable;

                        iTrace->Trace(_L("Server already exists, getting the SLP ID and Access Point."),KTraceFileName, __LINE__);

                        param->Get(aSLPId,hslpAddress->Des(),iapName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
                        aIAPName.Copy(iapName->Des());

                        delete hslpAddress;
                        delete iapName;
                    }

                    CleanupStack::PopAndDestroy(param);

                    iTrace->Trace(_L("Fallback allowed & TLSAuth failed"),KTraceFileName, __LINE__);
                    iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
                    LogBuffer.Copy(aHslpToBeUsedAddress);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                    iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
                    LogBuffer.Copy(aIAPName);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

                    iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
                    LogBuffer.Delete(0,256);
                    LogBuffer.AppendNum(aIsIapDialogShown);
                    iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
                    return KErrNone;
                }
                else
                {
                    return KErrArgument;
                }
            }
        }

        else
        {
            return KErrNotFound;
        }
    }

    //Check to see if the server list is empty.  If it is create the HSLP Address from the IMSI and use that
    // as the server address.  This does not add the server to the list and this functionality should only
    // be tried once
    if(iSLPList->Count() <= 0 && (!iAttemptedBackupServer))
    {
        iTrace->Trace(_L("Going to create and use alternative HSLP Address from IMSI"),KTraceFileName, __LINE__);

        iAttemptedBackupServer = ETrue;

        //Generate the HSLP Address
        GenerateHslpAddressFromIMSIL();

        //Copy the generated address into the supplied function arguments
        aHslpToBeUsedAddress.Copy(iGenratedHslpAddress);
        aIAPName.Zero();
        aIAPName.Copy(iDefaultIAPName);
        aTls = ETrue;
        aPskTls = EFalse;
        aIsIapDialogShown = ETrue;

        iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aHslpToBeUsedAddress);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aIAPName);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        //Add the server to the list for future connections
        CServerParams* param=CServerParams::NewL();
        CleanupStack::PushL(param);
        User::LeaveIfError(param->Set( iGenratedHslpAddress,iDefaultIAPName,ETrue,ETrue,ETrue,EFalse ));

        TInt err = iSuplSettings.AddNewServer( param, aSLPId ); //Ignore error
        LogBuffer.Copy(_L("AddNewServer() completed with err: "));
        LogBuffer.AppendNum(err);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        CleanupStack::PopAndDestroy(&param);

        return KErrNone;
    }

    if( iSLPList->Count() <= 0 || iCurrentServerCounter >= iSLPList->Count() )
    {
        LogBuffer.Copy(_L("No more servers available..."));
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
        return KErrNotFound;
    }

    iTrace->Trace(_L("Trying next server..."),KTraceFileName, __LINE__);

    //Fallback Timer...
    if(aLastErrorCode == KErrNone) //This means, server name is asked for first time only...
    {
        iTrace->Trace(_L("Start Time: "),KTraceFileName, __LINE__);
        iFallBackStartTime.HomeTime();
        LogBuffer.Zero();
        iFallBackStartTime.FormatL(LogBuffer,KFormatTxt);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
    }
    else
    {
        TTime currentTime;
        currentTime.HomeTime();
        TTimeIntervalMicroSeconds diff = currentTime.MicroSecondsFrom(iFallBackStartTime);


        iTrace->Trace(_L("Current Time: "),KTraceFileName, __LINE__);
        LogBuffer.Zero();
        currentTime.FormatL(LogBuffer,KFormatTxt);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        LogBuffer.Copy(_L("Difference between time: "));
        LogBuffer.AppendNum(diff.Int64());
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        if( diff.Int64() > iAllowedFallBackTimerValue)
        {
            LogBuffer.Copy(_L("Timeout happened..."));
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            return KErrTimedOut;
        }
    }

    if(aLastErrorCode == KErrNone)  //This will be called only once...for first time only
    {
        aSLPId = (*iSLPList)[0].iSLPId;
        aHslpToBeUsedAddress.Copy((*iSLPList)[0].iHSLPAddress);
        aIAPName.Copy((*iSLPList)[0].iIapName);
        aTls = (*iSLPList)[0].iTls;
        aPskTls = (*iSLPList)[0].iPskTls;
        aIsIapDialogShown = (*iSLPList)[0].iIsIAPDialgShown;
        iCurrentServerCounter++;

        iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aHslpToBeUsedAddress);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
        LogBuffer.Copy(aIAPName);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
        LogBuffer.Delete(0,256);
        LogBuffer.AppendNum(aIsIapDialogShown);
        iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

        return KErrNone;
    }
    else
    {
        if(iIsFallBackAllowed && CheckErrorCodeL(aLastErrorCode))// Do not fallback in case if IMSI generated address failed for previous try.
        {
            aSLPId = (*iSLPList)[iCurrentServerCounter].iSLPId;
            aHslpToBeUsedAddress.Copy((*iSLPList)[iCurrentServerCounter].iHSLPAddress);
            aIAPName.Copy((*iSLPList)[iCurrentServerCounter].iIapName);
            aTls = (*iSLPList)[iCurrentServerCounter].iTls;
            aPskTls = (*iSLPList)[iCurrentServerCounter].iPskTls;
            aIsIapDialogShown = (*iSLPList)[iCurrentServerCounter].iIsIAPDialgShown;
            iCurrentServerCounter++;
            iTrace->Trace(_L("Fallback allowed & TLSAuth passed"),KTraceFileName, __LINE__);
            iTrace->Trace(_L("Server being used:"),KTraceFileName, __LINE__);
            LogBuffer.Copy(aHslpToBeUsedAddress);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            iTrace->Trace(_L("iap being used:"),KTraceFileName, __LINE__);
            LogBuffer.Copy(aIAPName);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);

            iTrace->Trace(_L("iap dlg configuration:"),KTraceFileName, __LINE__);
            LogBuffer.Delete(0,256);
            LogBuffer.AppendNum(aIsIapDialogShown);
            iTrace->Trace(LogBuffer,KTraceFileName, __LINE__);
            return KErrNone;
        }
        else
        {
            return KErrNotFound;
        }
    }

}
LOCAL_C void FormatDateTime(TDes& aBuffer, const TTime& aTime)
	{ 
	aBuffer.Zero();
	_LIT(KFormat4,"%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");
	aTime.FormatL(aBuffer,KFormat4); 
	}
// ---------------------------------------------------------------------------
// From base class CRFSPlugin
// ---------------------------------------------------------------------------
//
void CIRRfsPlugin::GetScriptL( const TRfsReason /*aType*/, TDes& aPath )
    {
    aPath.Zero();
	return;
	}
Beispiel #28
0
/*
-------------------------------------------------------------------------
-------------------------------------------------------------------------
*/
void CCrashContainer::GetInfoBufferL(CExampleItem& aItem,TDes& aBuffer)
{
	aBuffer.Zero();
	
/*	if(aItem.iProcess)
	{
		aBuffer.Append(_L("Executable:\n"));
		aBuffer.Append(*aItem.iProcess);
	
		aBuffer.Append(_L("\n"));
	}
*/	
	if(aItem.iName)
	{
		aBuffer.Append(_L("Thread name:\n"));
		aBuffer.Append(*aItem.iName);
	
		aBuffer.Append(_L("\n"));
	}
	
	if(aItem.iExitCatogory)
	{
		aBuffer.Append(_L("Exit category:\n"));
		aBuffer.Append(*aItem.iExitCatogory);
	
		aBuffer.Append(_L("\n"));
	}
	
	aBuffer.Append(_L("Exit type:\n"));

	switch(aItem.iExitType)
	{
	case EExitKill:
		aBuffer.Append(_L("Kill"));
		break;
	case EExitTerminate:
		aBuffer.Append(_L("Terminate"));
		break;
	case EExitPanic:
		aBuffer.Append(_L("Panic"));
		break;
	case EExitPending:
		aBuffer.Append(_L("Pend"));
		break;
	}

	aBuffer.Append(_L("\n"));
	aBuffer.Append(_L("Exit reason:\n"));
	aBuffer.AppendNum(aItem.iExitReason);
	
	aBuffer.Append(_L("\n"));
	aBuffer.Append(_L("Time:\n"));
	aBuffer.AppendNum(aItem.iTime.DateTime().Hour());
	aBuffer.Append(_L(":"));
	if(aItem.iTime.DateTime().Minute() < 10)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Minute());
	aBuffer.Append(_L(":"));
	if(aItem.iTime.DateTime().Second() < 10)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Second());
	
	aBuffer.Append(_L(" - "));

	if(aItem.iTime.DateTime().Day() < 9)
	{
		aBuffer.AppendNum(0);	
	}
	aBuffer.AppendNum(aItem.iTime.DateTime().Day() + 1);
	aBuffer.Append(_L("/"));
	
	TMonthNameAbb ThisMonth(aItem.iTime.DateTime().Month());
	aBuffer.Append(ThisMonth);
	aBuffer.Append(_L("/"));
	
	TInt Yearrr = aItem.iTime.DateTime().Year();
	TInt Hudreds = Yearrr / 100;
	
	Yearrr = (Yearrr - (Hudreds * 100));
	if(Yearrr < 10)
	{
		aBuffer.AppendNum(0);	
	}
	
	aBuffer.AppendNum(Yearrr);
	aBuffer.Append(_L("\n"));
}
Beispiel #29
0
TErrorHandlerResponse CErrorHandlerWithState::HandleError(TDes& aErrorText,TDes& aContextText)
	{
	aErrorText.Num(iState);
	aContextText.Zero();
	return(iState? EInfoDisplay: ENoDisplay);
	}
// Default functions if functions cannot be resolved
static void defaultTimeFormatL(TTime&, TDes& des, const TDesC&, const TLocale&)
{
    des.Zero();
}