Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * ============================================================================
- * Name : CAppUidViewerEngine from AppUidViewerEngine.cpp
- * Part of : Application Uid viewer
- * Created : 09/26/2005 by Forum Nokia
- * Version : 1.0
- * Copyright: Nokia Corporation
- * ============================================================================
- */
- // INCLUDE FILES
- #include "AppUidViewerEngine.h"
- // CONSTANTS
- _LIT(KFileName, "c:\\Nokia\\applications.txt");
- _LIT(KFileName3rd, "c:\\Data\\Nokia\\applications.txt");
- _LIT(KFileDir3rd, "c:\\Data\\Nokia\\");
- const TInt KMaxSize = 512;
- const TInt KUidWidth = 8;
- // ================= MEMBER FUNCTIONS =======================
- // Constructor
- CAppUidViewerEngine::CAppUidViewerEngine(MAppUidObserver& aObserver)
- : iObserver(aObserver)
- {
- }
- // Destructor
- CAppUidViewerEngine::~CAppUidViewerEngine()
- {
- iLsSession.Close();
- iFs.Close();
- iApps.Close();
- }
- // ----------------------------------------------------
- // CAppUidViewerEngine::NewL()
- // Two-phased constructor.
- // ----------------------------------------------------
- //
- CAppUidViewerEngine* CAppUidViewerEngine::NewL(MAppUidObserver& aObserver)
- {
- CAppUidViewerEngine* self = new (ELeave) CAppUidViewerEngine(aObserver);
- CleanupStack::PushL(self);
- self->ConstructL();
- CleanupStack::Pop(self);
- return self;
- }
- // ----------------------------------------------------
- // CAppUidViewerEngine::ConstructL()
- // Symbian OS default constructor can leave.
- // ----------------------------------------------------
- //
- void CAppUidViewerEngine::ConstructL()
- {
- User::LeaveIfError(iFs.Connect());
- User::LeaveIfError(iLsSession.Connect());
- }
- // ----------------------------------------------------
- // CAppUidViewerEngine::AppsToFileL()
- // Writes applications and their uids in to a text file.
- // ----------------------------------------------------
- //
- void CAppUidViewerEngine::AppsToFileL()
- {
- RFile file;
- CleanupClosePushL(file);
- #ifdef __SERIES60_3X__ //////////// 3rd Ed
- // C:\Nokia Folder does not exist in S60 3.x,
- // PC Suite does not show other than C:\Data folders in S60 3.x devices
- iFs.MkDir( KFileDir3rd );
- User::LeaveIfError( file.Replace(iFs, KFileName3rd, EFileWrite | EFileStreamText) );
- #else
- User::LeaveIfError(file.Replace(iFs, KFileName, EFileWrite | EFileStreamText));
- #endif
- TBuf<KMaxSize> buf;
- TBuf8<KMaxSize> fileBuf;
- // Get info on all apps, then iterate through each app
- // and write its info (caption, name, uid) to file
- User::LeaveIfError(iLsSession.GetAllApps());
- TApaAppInfo* appInfo = new (ELeave) TApaAppInfo;
- CleanupStack::PushL( appInfo );
- while(iLsSession.GetNextApp(*appInfo) == KErrNone)
- {
- buf.Zero();
- buf.AppendNumFixedWidth(appInfo->iUid.iUid, EHex, KUidWidth);
- buf.Append(_L("\t"));
- buf.Append(appInfo->iCaption);
- buf.Append(_L("\t"));
- buf.Append(appInfo->iFullName);
- buf.Append(_L("\r\n"));
- fileBuf.Copy(buf);
- file.Write(fileBuf);
- }
- CleanupStack::PopAndDestroy( appInfo );
- CleanupStack::PopAndDestroy( &file );
- iObserver.DoneL();
- }
- // ----------------------------------------------------
- // CAppUidViewerEngine::AppsToUiL()
- // Collects all applications and their uids and passes
- // this list to an observer.
- // ----------------------------------------------------
- //
- void CAppUidViewerEngine::AppsToUiL()
- {
- TApaAppInfo apaAppInfo;
- TAppInfo appInfo;
- iApps.Reset();
- // Get info on all apps, then iterate through each app
- User::LeaveIfError(iLsSession.GetAllApps());
- while(iLsSession.GetNextApp(apaAppInfo) == KErrNone)
- {
- appInfo.iAppCaption = apaAppInfo.iCaption;
- appInfo.iAppUid = apaAppInfo.iUid.iUid;
- User::LeaveIfError(iApps.Append(appInfo));
- }
- iObserver.AppsFoundL(iApps);
- }
- // End of file
Add Comment
Please, Sign In to add comment