Beispiel #1
0
//
/// Constructor to initialize the external storage and the maximum number of items
/// to save in the most-recently-used (MRU) list.
//
TRecentFiles::TRecentFiles(const tstring& iniName, int numSavedFiles,
                           int namelen, bool useRegistry)
:
  MaxFilesToSave(0),
  MaxDispLen(namelen),
  AddedSeparator(false),
  UseRegistry(useRegistry),
  LastHMenu(0),
  MruCount(0)
{
  int filestosave = std::min(numSavedFiles, (int)MaxMenuItems);
  MruName = iniName;
  if(UseRegistry){
    MruName += _T("\\");
    MruName += Section;
  }
  else
    MruName = TFileName(iniName).Canonical();

  if(filestosave < 0)
    filestosave = TRecentFiles__ReadMaxNum(UseRegistry, MruName, filestosave);

  SetMaxMruItems(filestosave);
  MruMessage = ::RegisterWindowMessage(MruFileMessage);

  Read();
}
Beispiel #2
0
void CFMSServer::CreateScheduledReminderL()
    {
    FLOG(_L("CFMSServer::CreateScheduledReminderL ()"));
    _LIT(KFotaScheduleExe, "Z:\\sys\\bin\\fotaschedulehandler.exe");

    RScheduler scheduler;
    TTsTime startTime;
    TTime time;
    time.HomeTime();
    time = time + (TTimeIntervalHours(1));
    startTime.SetLocalTime(time);

    User::LeaveIfError(scheduler.Connect());
    CleanupClosePushL(scheduler);
    //Creating a persistent daily schedule
    
    TSchedulerItemRef persistentScheduleItem;
    CArrayFixFlat<TScheduleEntryInfo2>* entries = new CArrayFixFlat<TScheduleEntryInfo2> (1);
    CleanupStack::PushL(entries);
    persistentScheduleItem.iName = TUid::Uid(KFMSServerUid).Name();

    //TScheduleEntryInfo2 scentry1(startTime, EDaily, 1, 1);
    TScheduleEntryInfo2 scentry1;
    scentry1.SetStartTime(startTime);
    scentry1.SetInterval(1);
    scentry1.SetIntervalType(TIntervalType(EHourly));
    scentry1.SetValidityPeriod((TTimeIntervalMinutes) 1440); //1440 min = 24 hrs or 1 day
    
    entries->AppendL(scentry1);

    scheduler.Register(TFileName( KFotaScheduleExe ), 0 );
    TInt ret = scheduler.CreatePersistentSchedule(persistentScheduleItem, *entries);

    FLOG(_L("created schedule %d  %d:%d"), persistentScheduleItem.iHandle,
            time.DateTime().Hour(), time.DateTime().Minute());

    if (ret == KErrNone)
        {
        TTaskInfo taskInfo;
        taskInfo.iName = TUid::Uid(KFMSServerUid).Name();
        taskInfo.iRepeat = 1; //Repeat once
        taskInfo.iPriority = 1;

        TFotaScheduledUpdate fotareminder(-1, -1);
        TPckg<TFotaScheduledUpdate> fotareminderpkg(fotareminder);

        HBufC* data = HBufC::NewLC(fotareminderpkg.Length());
        data->Des().Copy(fotareminderpkg);

        TInt err = scheduler.ScheduleTask(taskInfo, *data,  persistentScheduleItem.iHandle);

        FLOG(_L("Schedule creation error %d"), err);

        CleanupStack::PopAndDestroy(data);
        }
    CleanupStack::PopAndDestroy(entries);
    CleanupStack::PopAndDestroy(&scheduler); // xx
    }
Beispiel #3
0
//
/// Returns the index of the MRU item containing text. Returns -1 if not found.
//
int
TRecentFiles::GetMruItemIndex(LPCTSTR text)
{
  TFileName filename(TFileName(text).Canonical());
  for (int i = 0; i < MruCount; i++) {
    if(MruNames[i] == filename)
      return i;
  }
  return -1;
}
CSupLoginServiceProvider::CSupLoginServiceProvider()
: CCoeStatic( KUidSupLoginController )
{
	iConnection = NULL;
	iMemberID = NULL;
	iUsername = NULL;
	iPassword = NULL;
	iLogged = EFalse;

	iSettingsFile = TFileName(KNullDesC);
}
Beispiel #5
0
//
/// Reads external information and adds the MRU items into the menu. Adds a
/// separator between the MRU items and the exit menu item.
//
void
TRecentFiles::InsertMruItemsToMenu(HMENU hMenu)
{
  TAPointer<tchar> menuItemBuffer(new tchar[MaxMenuItemLen+4]);

  TMenu menu(hMenu);
  int exitPos       = GetExitMenuPos(hMenu);
  //int count         = GetMruCount();
  int i;
  int numItemsAdded = 0;

  tstring curdir = TFileName(TFileName::CurrentDir).GetParts(FullPathName);

  for (i = 0; i < MruCount; i++) {
    //if(!MruNames[i].IsValid()) //?????????????
    //  break;

    numItemsAdded++;

    tstring curname = MruNames[i].GetParts(FullFileName);
    if(curdir == MruNames[i].GetParts(FullPathName))
      curname = MruNames[i].GetParts(TFileName::File|TFileName::Ext);
    curname = TFileName(curname).Squeezed(MaxDispLen, true);
    // insert mnemonic + the file name
    if((i+1) >= 10)
      wsprintf(menuItemBuffer, _T("%d&%d %s"), (i+1)/10, (i+1)%10, curname.c_str());
    else
      wsprintf(menuItemBuffer, _T("&%d %s"), (i+1), curname.c_str());

    menu.InsertMenu(exitPos + i, MF_BYPOSITION | MF_STRING, CM_MRU_FIRST + i, menuItemBuffer);
  }

  if (numItemsAdded > 0) {
    if (AddedSeparator == false) {
      LastHMenu = hMenu;
      AddedSeparator = true;
      menuItemBuffer[0] = 0;
      ::InsertMenu(hMenu, exitPos + numItemsAdded, MF_BYPOSITION|MF_SEPARATOR, 0, menuItemBuffer);
    }
  }
}
void CCellTowerDataSimulation::InternalizeL() {
	RFs aSession;
	RFile aFile;
	TFileName aFileName;
	TInt aFileSize;

	if(aSession.Connect() == KErrNone) {
		CleanupClosePushL(aSession);

#ifndef __SERIES60_3X__
		aFileName = TFileName(_L("CellTowerSimData.txt"));
		CompleteWithAppPath(aFileName);
#else
		if(aSession.PrivatePath(aFileName) == KErrNone) {
#ifndef __WINSCW__
			aFileName.Insert(0, _L(":"));
			CCommandLineArguments* pArguments;
			TFileName drive;
			pArguments = CCommandLineArguments::NewL();
			if (pArguments->Count() > 0) {
				drive.Append(pArguments->Arg(0)[0]);
				aFileName.Insert(0, drive);
				delete pArguments;
			}
#endif

			aFileName.Append(_L("CellTowerSimData.txt"));

#ifdef __WINSCW__
			aFileName.Insert(0, _L("z:"));
#endif
		}
#endif

		if(aFile.Open(aSession, aFileName, EFileStreamText|EFileRead) == KErrNone) {
			CleanupClosePushL(aFile);
			aFile.Size(aFileSize);

			// Creat buffer & read file
			iCellBuffer = HBufC8::NewL(aFileSize);
			TPtr8 pCellBuffer(iCellBuffer->Des());
			aFile.Read(pCellBuffer);
			aFile.Close();
			
			CleanupStack::PopAndDestroy(&aFile);
		}
		
		CleanupStack::PopAndDestroy(&aSession);
	}
}
/**
 * This function creates a datasource object based on either a descriptor
 * or a file.
 * @param aFile - If 'ETrue', datasource if file based, else it's descriptor based.
 * @param aFilename - If filebased, this is the file name passed to the DataSource
 *					  If descriptor based, the data is read from the file.
 * @param aOffset - The offset from the start of the file to read (for Descriptor
 *				     based DataSources only)
 */
void CTestStep_MMF_AFMT::CreateDataSource(const TBool& aFile, const TDesC& aFilename,
        const TUint& aOffset)
{
    if (aFile)
    {   // File based DataSource (making a CMMFFile object)
        TMMFFileParams fileParams ;
        fileParams.iPath = TFileName(aFilename) ;
        TMMFFileConfig fileConfig( fileParams ) ;

        // Create the iDataSource object.
        iDataSource = STATIC_CAST(CMMFFile*, MDataSource::NewSourceL( KUidMmfFileSource,
                                  *STATIC_CAST(TDesC8*,&fileConfig)));
    }
    else
    {   // Descriptor based DataSource
Beispiel #8
0
//
/// Adds an item to the top of the MRU list. If there is a duplicate, the item is
/// moved from its current position to the top of the list.
//
void
TRecentFiles::AddMruItem(LPCTSTR text)
{
  if (MaxFilesToSave <= 0)
    return;
  if(MruCount < MaxFilesToSave)
    MruCount++;
  if (MruCount > 1){
    // Shuffle items down to make room at index 0
    //
    for (int i = MruCount - 2; i >= 0; i--)
       MruNames[i+1] = MruNames[i];
  }

  // Add item to the top of the list
  //
   MruNames[0] = TFileName(text).Canonical();
}
void CAafAppFileBrowserView::ShowFileProperties()
{
	__LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() begins");

	if (!IsCurrentItemDir())
	{
		TEntry fileEntry;
		TFileName folderPath;

		__LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() step 01");

		// File description
		iBrowserEngine->GetFileDescription2L(iListBox->CurrentItemIndex(), fileEntry, folderPath);

		// Load dialog from resources
		CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog(); 
		dlg->PrepareLC(R_FILEPROPERTIES_DIALOG);
	
		// Set dialog title
		dlg->QueryHeading()->SetTextL(fileEntry.iName);		

		// Form dialog body text
		folderPath = TFileName(KNullDesC);
		_LIT(KSizeString, "Size:\t%d Kb\n\nDate,\ntime:\t");
		folderPath.Format(KSizeString, fileEntry.iSize/(1 << 10));

		TBuf<30> dateString(KNullDesC);
		_LIT(KDateString, "%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B");

		fileEntry.iModified.FormatL(dateString, KDateString);		

		folderPath.Append(dateString);		

		dlg->SetMessageTextL(folderPath);

		__LOGSTR_TOFILE("CAafAppFileBrowserView::ShowFileProperties() step 02");

		// Run dialog
		dlg->RunLD(); 
	}

	__LOGSTR_TOFILE("CSupAppFileBrowserView::ShowFileProperties() ends");
}
TInt CFileBrowserEngine::OpenOrLaunchCurrentL(TInt aPosition)
{
	__LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() begins aPosition == %d", aPosition);

	// Return value
	TInt retValue = KErrNone;

	// Shift correction to the item position,
	// for the case when '...' item is used
	TInt posShift = 0;

	if (iCurrentDirectory.Length() > 0 && aPosition > 0)
	{
		posShift = 1;
	}	

	// If passed index is valid
	if(aPosition >= 0 && (aPosition < (iCurrentFiles.Count() + iCurrentFolders.Count() + posShift) || (iCurrentFolders.Count() + iCurrentFiles.Count()) == 0))
	{
		TFileName descr = iCurrentDirectory;

		// Open the file
		if (aPosition > iCurrentFolders.Count() && aPosition <= iCurrentFiles.Count()+iCurrentFiles.Count())
		{
			__LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() opens file");

			// Add filename to be launched
			descr.Append(iCurrentFiles[aPosition-iCurrentFolders.Count()-1].iName);

			// Create nullType. This makes the DocumentHandler to figure out the posfix for us.
			TDataType nullType;
			// Launch the appropriate application for this file
			iDocHandler->OpenFileEmbeddedL(descr, nullType);
			iDocHandler->SetExitObserver(this);
			iDocEmbedded = ETrue;
		}
		// Open folder
		else
		{
			// Go to upper level
			if (aPosition == 0 && iCurrentDirectory.Length() > 0)
			{
				// If we are in the KDirPictures directory
				// Go to first level
				TFileName phoneRoot =  PathInfo::PhoneMemoryRootPath();
				TFileName cardRoot = PathInfo::MemoryCardRootPath();

				phoneRoot.Append(KDirPictures);
				cardRoot.Append(KDirPictures);

				// Open root directory
				if (iCurrentDirectory == phoneRoot || iCurrentDirectory == cardRoot)
				{
					__LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() goes upper to root directory");

					TFileName firstDirectory = TFileName(KNullDesC);
					GetEntriesL(firstDirectory);
				}
				// Otherwise
				// just go the upper level
				else
				{
					// Delete the last one directory in the path
					iCurrentDirectory.Delete(iCurrentDirectory.Length()-1, 1);

					TInt slashPos = iCurrentDirectory.LocateReverse('\\');

					if (slashPos >= 0 && slashPos < iCurrentDirectory.Length()-1)
					{
						iCurrentDirectory.Delete(slashPos+1, iCurrentDirectory.Length()-slashPos-1);
					}							

					__LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() goes upper to directory %S", &iCurrentDirectory);

					RDebug::Print(_L("Formed folder: %S"), &iCurrentDirectory);

					GetEntriesL(iCurrentDirectory);
				}
			}
			// Open directory
			else
			{	// If the current directory is the first folder
				if (iCurrentDirectory.Length() == 0)
				{
					TFileName folderPath = TFileName(KNullDesC);

					if (aPosition == 0)
					{
						folderPath = PathInfo::PhoneMemoryRootPath();
					}
					else if (aPosition == 1)
					{
						folderPath = PathInfo::MemoryCardRootPath();										
					}

					folderPath.Append(iCurrentFolders[aPosition].iName);

					folderPath.Append(KSlash);

					__LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() opens folder %S", &folderPath);

					RDebug::Print(_L("Formed folder: %S"), &folderPath);

					GetEntriesL(folderPath);
				}
				// Otherwise
				else
				{
					TFileName folderPath = iCurrentDirectory;

					folderPath.Append(iCurrentFolders[aPosition-1].iName);

					folderPath.Append(KSlash);

					__LOGSTR_TOFILE1("CFileBrowserEngine::OpenOrLaunchCurretnL() opens folder %S", &folderPath);

					RDebug::Print(_L("Formed folder: %S"), &folderPath);

					GetEntriesL(folderPath);
				}				
			}
		}
	}
	// Otherwise
	else
	{
		retValue = KErrUnknown;
	}	

	__LOGSTR_TOFILE("CFileBrowserEngine::OpenOrLaunchCurretnL() ends");

	return retValue;
}
void CFileBrowserEngine::GetEntriesL(TFileName &aFolder)
{	
	__LOGSTR_TOFILE1("CFileBrowserEngine::GetEntriesL() begins with aFolder == %S", &aFolder);

	// If passed argument is empty
	// retrieve first level folders (i.e. memory root and flash images start folders)
	if (aFolder.Length() == 0)
	{
		iCurrentDirectory = TFileName(KNullDesC);

		iCurrentFiles.Reset();
		iCurrentFolders.Reset();

		TFileName phoneRoot =  PathInfo::PhoneMemoryRootPath();
		TFileName cardRoot = PathInfo::MemoryCardRootPath();

		phoneRoot.Append(KDirPictures);
		cardRoot.Append(KDirPictures);


		if (BaflUtils::PathExists(iFsSession, phoneRoot))
		{
			RDebug::Print(_L("Phone images root: %S"), &phoneRoot);

			TEntry phoneEntry;

			iFsSession.Entry(phoneRoot, phoneEntry);

			iCurrentFolders.Append(phoneEntry);
		}

		if (BaflUtils::PathExists(iFsSession, cardRoot))
		{
			RDebug::Print(_L("Card images root: %S"), &cardRoot);

			TEntry cardEntry;

			iFsSession.Entry(cardRoot, cardEntry);

			iCurrentFolders.Append(cardEntry);
		}
	}
	// Otherwise
	else
	{
		// If specified folder doesn't exist - just return
		if(!BaflUtils::PathExists(iFsSession, aFolder))
		{
			__LOGSTR_TOFILE1("CFileBrowserEngine::GetEntriesL() specifed folder doesn't exist: %S", &aFolder);

			RDebug::Print(_L("Specified folder doesn't exist: %S"), &aFolder);

			return;
		}

		// Otherwise retrieve lists of directories and files inside
		CDir* folders = 0;
		CDir* files = 0;

		iCurrentFolders.Reset();
		iCurrentFiles.Reset();

		// Get directory KEntryAttNormal means that no hidden files or directories are included
		User::LeaveIfError(iFsSession.GetDir(aFolder, KEntryAttNormal, ESortByName, files, folders));

		CleanupStack::PushL(folders);
		CleanupStack::PushL(files);

		// Get folders in the specified folder
		for( TInt i = 0; i < folders->Count(); i++ )
		{
			// Exclude directories beginning with '_' as they can
			// contain system-generated thumbnails etc.
			if( (*folders)[i].iName[0] != '_')
			{
				iCurrentFolders.Append( (*folders)[i] );
			}
		}

		// Get files in the specified folder
		for( TInt i = 0; i < files->Count(); i++ )
		{
#if USE_FILEBROWSER_FILTER
			if ((*files)[i].iName.Right(4) == KPngExt || (*files)[i].iName.Right(4) == KJpgExt)
			{
#endif
				iCurrentFiles.Append( (*files)[i] );

#if USE_FILEBROWSER_FILTER
			}
#endif
		}

		CleanupStack::PopAndDestroy( 2, folders);

		iCurrentDirectory = aFolder;
	}	

	__LOGSTR_TOFILE("CFileBrowserEngine::GetEntriesL() ends");
}
Beispiel #12
0
TFileName CExampleApplication::ResourceFileName() const
{
	return TFileName(); // this app doesn't have a resource file
}
TFileName CMulScreensTestApp::ResourceFileName() const
	{
	return TFileName(); // this app doesn't have a resource file
	}
// Called by the UI framework to get the name of the resource file.
// This returns an empty filename as there is no resource file.
TFileName CExampleApplication::ResourceFileName() const
	{
	return TFileName();
	}
// -----------------------------------------------------------------------------
// CAafAppFileBrowserView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CAafAppFileBrowserView::ConstructL( const TRect& aRect )
{
	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() begins");

	// Create a window for this application view
	CreateWindowL();

	// Instantiate listbox control
	iListBox = new (ELeave)CAknSingleGraphicStyleListBox;

	iListBox->ConstructL( this, EAknListBoxSelectionList);

	iListBox->SetContainerWindowL( *this );

	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before setting icon array");

	// Creates a GUI icon array
	CAknIconArray* icons = new (ELeave)CAknIconArray(5);

	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before CleanupStack::PushL(icons)");

	CleanupStack::PushL(icons);
	icons->ConstructFromResourceL(R_BROWSERVIEW_ICONS);
	// Sets graphics as listbox icons
	iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);

	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() before CleanupStack::Pop()");

	CleanupStack::Pop(); // icons

	// Enable marquee effect
	iListBox->ItemDrawer()->ColumnData()->SetMarqueeParams(3, 20, 1000000, 200000);
	iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue);

	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() after setting icon array");

	// Create the scroll indicator
	iListBox->CreateScrollBarFrameL(ETrue);
	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);

	iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );

	iListBox->ActivateL();

	// Create the FileBrowserEngine
	iBrowserEngine = new (ELeave) CFileBrowserEngine;

#ifdef __SERIES60_3X__
	iBrowserEngine->ConstructL();
#else
	iBrowserEngine->ConstructL((CEikProcess*)(((CEikAppUi*)iCoeEnv->AppUi())->Application()->Process()));
#endif

	// Set file browser to display only picture files
	//SetFileListL(EFileBrowserPictures, EFileBrowserDate);

	TFileName aFolder = TFileName(KNullDesC);
	SetFileListL(aFolder);

	// Set the windows size
	SetRect( aRect );

	// Activate the window, which makes it ready to be drawn
	ActivateL();

	__LOGSTR_TOFILE("CAafAppFileBrowserView::ConstructL() begins");
}