⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 procinfobaseview.cpp

📁 索爱官方出品手机进程工具Productinfo
💻 CPP
字号:
/*****************************************************************************

 
 COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2006.

 

 The software is the copyrighted work of Sony Ericsson Mobile Communications AB.

 The use of the software is subject to the terms of the end-user license 

 agreement which accompanies or is included with the software. The software is 

 provided "as is" and Sony Ericsson specifically disclaim any warranty or 

 condition whatsoever regarding merchantability or fitness for a specific 

 purpose, title or non-infringement. No warranty of any kind is made in 

 relation to the condition, suitability, availability, accuracy, reliability, 

 merchantability and/or non-infringement of the software provided herein.

 

 *****************************************************************************/
 

//procinfoBaseView.cpp
#include "procinfoBaseView.h"
#include <QikCommand.h>

#include <QikListBox.h>


#include <MQikListBoxModel.h>
#include <QikListBoxData.h>

#include <APGWGNAM.H>
#include <APGCLI.H>



/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
CprocinfoBaseView* CprocinfoBaseView::NewLC(CQikAppUi& aAppUi)
{
	CprocinfoBaseView* self = new (ELeave) CprocinfoBaseView(aAppUi);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}


/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::ViewConstructL()
{
	ViewConstructFromResourceL(R_PROCINFO_BASEVIEW_UI_CONFIGURATIONS, 0);
}


/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
TVwsViewId CprocinfoBaseView::ViewId() const
{	
	return TVwsViewId(KUidprocinfoID, KUidprocinfoBaseViewID);	
}


/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::ConstructL()
{
	BaseConstructL();
  
    iThreadArr = new (ELeave) CArrayFixFlat<TThreadInformation>(200);    
    iProcArr = new (ELeave) CArrayFixFlat<TProcessInformation>(200);     
    iTaskArr = new (ELeave) CArrayFixFlat<TTaskInformation>(200);    
}


/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
CprocinfoBaseView::~CprocinfoBaseView() 
{
	if(iThreadArr)
    	delete iThreadArr;
	
	if(iProcArr)
    	delete iProcArr;
	
	if(iTaskArr)
    	delete iTaskArr;
}




/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
CprocinfoBaseView::CprocinfoBaseView(CQikAppUi& aAppUi) :  CQikMultiPageViewBase(aAppUi, KNullViewId), 
	iInitialized(EFalse) {}







/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::AddThreads()
{ 	
	CQikListBox* lbx = LocateControlByUniqueHandle<CQikListBox>(EThreadListBox);
    if(!lbx)
    {
    	return;
    }

			
	lbx->SetListBoxObserver(this);
   
    MQikListBoxModel& model(lbx->Model());
    model.ModelBeginUpdateLC(); 

	TFindThread f(_L("*"));
  	TFullName t;
  	RThread r;
  	while (f.Next(t)==KErrNone)
	{
    	r.Open(t);
       	
		TThreadPriority priority = r.Priority();       
		TInt requestcount = r.RequestCount();
	
		TInt aProcessHandleCount;
		TInt aThreadHandleCount;		

		r.HandleCount(aProcessHandleCount,aThreadHandleCount);
		CleanupClosePushL(r);

				
		TThreadInformation inf; 		
		inf.priority = priority;		
		inf.requestcount = requestcount;		
		inf.handlecount = aThreadHandleCount;
				    
	    iThreadArr->AppendL(inf); 
	    
	    
        MQikListBoxData* data = model.NewDataL(MQikListBoxModel::EDataNormal);
		CleanupClosePushL(*data);         
      	data->AddTextL(t, EQikListBoxSlotText1); 
      	CleanupStack::PopAndDestroy(data);   
           			      
  		CleanupStack::PopAndDestroy();
	}
  
    model.ModelEndUpdateL(); 	
}









/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::AddProcesses()
 { 	 
    CQikListBox* lbx = LocateControlByUniqueHandle<CQikListBox>(EProcessListBox);
	 if(!lbx)
     {
       	return;
     }
	
	
	lbx->SetListBoxObserver(this);      
      
         
    MQikListBoxModel& model(lbx->Model());
    model.ModelBeginUpdateLC();


	TFindProcess finder;
	TFullName name;
 
	while(finder.Next(name) == KErrNone)
  	{
	   	RProcess process;
	   	CleanupClosePushL(process); 
	   	TInt err = process.Open(finder);    
    	if(err == KErrNone)
    	{
  			TProcessInformation inf;
  			     
     		TBuf<100> aCommand;
	 		inf.command = aCommand;     
       
			inf.id = process.Id();
			inf.name = name;
			inf.filename = process.FileName();
			inf.priority = process.Priority();
			inf.exittype = process.ExitType();
			inf.uidtype = process.Type();

	    	iProcArr->AppendL(inf); 
    	}

     	CleanupStack::PopAndDestroy();
     				
    	MQikListBoxData* data = model.NewDataL(MQikListBoxModel::EDataNormal);
        CleanupClosePushL(*data);    	
    	data->AddTextL(name, EQikListBoxSlotText1); 
		CleanupStack::PopAndDestroy(data);    	
    
	}              

    model.ModelEndUpdateL();         
 }		




 







/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::AddTasks()
{ 	 
	CQikListBox* lbx = LocateControlByUniqueHandle<CQikListBox>(ETaskListBox);
    if(!lbx)
    {
        return;
    }
	
	
	lbx->SetListBoxObserver(this);
      
	MQikListBoxModel& model(lbx->Model());
	model.ModelBeginUpdateLC(); 

  
	CArrayFixFlat<TInt>* wgList = new CArrayFixFlat<TInt>(5);
	CleanupStack::PushL(wgList);	
	iEikonEnv->WsSession().WindowGroupList(wgList);
	
	CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(iEikonEnv->WsSession());
	CleanupStack::PushL(wgName);
	
	RApaLsSession session;
	session.Connect();
	
	TInt num(0);
	for (int posIndex = 0; posIndex < wgList->Count(); posIndex++)
	{
		wgName->ConstructFromWgIdL(wgList->At(posIndex));
		
		TBuf<100> cap;
		cap.AppendFormat(_L("%d"),num);
		
		cap.Append(_L("\t"));			
	  	cap.Append(wgName->Caption());
		cap.Append(_L(" - "));
		cap.Append(wgName->WindowGroupName());

		num++;
		
        MQikListBoxData* data = model.NewDataL(MQikListBoxModel::EDataNormal);
        CleanupClosePushL(*data);
        data->AddTextL(cap, EQikListBoxSlotText1); 
		CleanupStack::PopAndDestroy(data);
		
		TTaskInformation inf; 
		
		inf.caption = wgName->Caption();
		inf.docname = wgName->DocName();
		inf.isbusy = wgName->IsBusy();
		inf.issystem = wgName->IsSystem();
		inf.windowgroupname = wgName->WindowGroupName();
		inf.hidden = wgName->Hidden();
		
				
	    iTaskArr->AppendL(inf); 
	}
	
	
	session.Close();	
	CleanupStack::PopAndDestroy(); //wgName
	CleanupStack::PopAndDestroy(); //wgList
	
	model.ModelEndUpdateL();
}		 
 





/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::ViewActivatedL(const TVwsViewId& /* aPrevViewId */, const TUid /*aCustomMessageId */, 
				const TDesC8& /* aCustomMessage */)
{
	if(!iInitialized)
	{
		AddThreads();		
    	AddProcesses();
		AddTasks(); 
		iInitialized = ETrue;
	}
}











/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::HandleListBoxEventL(CQikListBox *aListBox, TQikListBoxEvent aEventType, 
		TInt /* aItemIndex */, TInt /* aSlotId */)
{
	if(aEventType == EEventItemTapped)
	{
	
		CQikListBox* threadlbx = LocateControlByUniqueHandle<CQikListBox>(EThreadListBox);
		CQikListBox* proclbx = LocateControlByUniqueHandle<CQikListBox>(EProcessListBox);
		CQikListBox* tasklbx = LocateControlByUniqueHandle<CQikListBox>(ETaskListBox);				
	
		if(aListBox == threadlbx)
		{
			TInt index = aListBox->CurrentItemIndex();
			TBuf<32> num;
			num.Num(index);
	
			ThreadClicked(index);
		}
		else if(aListBox == proclbx)
		{
			TInt index = aListBox->CurrentItemIndex();
			TBuf<32> num;
			num.Num(index);
	
			ProcessClicked(index);
		}
		else if(aListBox == tasklbx)
		{
			TInt index = aListBox->CurrentItemIndex();
			TBuf<32> num;
			num.Num(index);
	
			TaskClicked(index);
		}		
	}
};





/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::ThreadClicked(TInt num)
{
	TThreadInformation info = iThreadArr->At(num); 
                      	
  	TBuf<500> text_buffer; 
    
    text_buffer.Append( _L("Priority: "));

	switch(info.priority)
	{			
		case EPriorityNull:
    	text_buffer.Append( _L("EPriorityNull"));
		break;				

		case EPriorityMuchLess:
    	text_buffer.Append( _L("EPriorityMuchLess"));
		break;

		case EPriorityLess:
    	text_buffer.Append( _L("EPriorityLess"));
		break;

		case EPriorityNormal:
    	text_buffer.Append( _L("EPriorityNormal"));
		break;

		case EPriorityMore:
    	text_buffer.Append( _L("EPriorityMore"));
		break;

		case EPriorityMuchMore:
    	text_buffer.Append( _L("EPriorityMuchMore"));
		break;

		case EPriorityAbsoluteVeryLow:
    	text_buffer.Append( _L("EPriorityAbsoluteVeryLow"));
		break;

		case EPriorityAbsoluteLow:
    	text_buffer.Append( _L("EPriorityAbsoluteLow"));
		break;

		case EPriorityAbsoluteBackground:
    	text_buffer.Append( _L("EPriorityAbsoluteBackground"));
		break;

		case EPriorityAbsoluteForeground:
    	text_buffer.Append( _L("EPriorityAbsoluteForeground"));
		break;

		case EPriorityAbsoluteHigh:
    	text_buffer.Append( _L("EPriorityAbsoluteHigh"));
		break;

		case EPriorityRealTime:
    	text_buffer.Append( _L("EPriorityRealTime"));
		break;

		
		default:
    	text_buffer.Append( _L("Unknown"));	
	}
  
   
    text_buffer.Append(_L("\nRequestCount:"));
	text_buffer.AppendFormat(_L("%d"),info.requestcount);           
    text_buffer.Append(_L("\nHandleCount:"));
	text_buffer.AppendFormat(_L("%d"),info.handlecount);           
	  
  	iEikonEnv->InfoWinL(_L("Thread information"), text_buffer);  
}
  
  
  






/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::ProcessClicked(TInt num)
{
	TProcessInformation info = iProcArr->At(num); 
    TInt len = 100;                      
           
  	TBuf<500> text_buffer;   
    
    text_buffer.Append( _L("Name: "));
    text_buffer.Append(info.name.Left(len));
    text_buffer.Append(_L("\nFilename:"));
    text_buffer.Append(info.filename.Left(len));



    text_buffer.Append(_L("\nPriority:"));

	switch(info.priority)
	{
		case EPriorityLow:	
 	    text_buffer.Append(_L("EPriorityLow"));
 	    break;

		case EPriorityBackground:	
 	    text_buffer.Append(_L("EPriorityBackground"));
 	    break;

		case EPriorityForeground:	
 	    text_buffer.Append(_L("EPriorityForeground"));
 	    break;

		case EPriorityHigh:	
 	    text_buffer.Append(_L("EPriorityHigh"));
 	    break;

		case EPriorityWindowServer:	
 	    text_buffer.Append(_L("EPriorityWindowServer"));
 	    break;

		case EPriorityFileServer:	
 	    text_buffer.Append(_L("EPriorityFileServer"));
 	    break;

		case EPriorityRealTimeServer:	
 	    text_buffer.Append(_L("EPriorityRealTimeServer"));
 	    break;

		case EPrioritySupervisor:	
 	    text_buffer.Append(_L("EPrioritySupervisor"));
 	    break;

 	    
 	    default:
   	    text_buffer.Append(_L("Unknown"));
	}
	

    text_buffer.Append(_L("\nExit type:"));

	switch(info.exittype)
	{
		case EExitKill:	
 	    text_buffer.Append(_L("EExitKill"));
 	    break;

		case EExitTerminate:	
 	    text_buffer.Append(_L("EExitTerminate"));
 	    break;

		case EExitPanic:	
 	    text_buffer.Append(_L("EExitPanic"));
 	    break;

		case EExitPending:	
 	    text_buffer.Append(_L("EExitPending"));
 	    break;
 	    
 	    default:
   	    text_buffer.Append(_L("Unknown"));
	}
	

    text_buffer.Append(_L("\nUid0:"));

	TUid uid0 = info.uidtype[0];
	TUidName uidname0 = uid0.Name();
	
    text_buffer.Append(uidname0.Left(len));

    text_buffer.Append(_L("\nUid1:"));	
	
	TUid uid1 = info.uidtype[1];
	TUidName uidname1 = uid1.Name();

    text_buffer.Append(uidname1.Left(len));
    text_buffer.Append(_L("\nUid2:"));
		
	TUid uid2 = info.uidtype[2];
	TUidName uidname2 = uid2.Name();

    text_buffer.Append(uidname2.Left(len));
  
  	iEikonEnv->InfoWinL(_L("Process information"), text_buffer);  
}
  
  





/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
void CprocinfoBaseView::TaskClicked(TInt num)
{
	TTaskInformation info = iTaskArr->At(num); 
                        
             
   	TBuf<500> text_buffer;  
    text_buffer.Append( _L("Docname: "));
    text_buffer.Append(info.docname);
   	text_buffer.Append( _L("\nIsBusy: "));
	if(info.isbusy)
	{
    	text_buffer.Append(_L("Yes"));
	}
	else
	{
    	text_buffer.Append(_L("No"));		
	}


   	text_buffer.Append( _L("\nIsSystem: "));
	if(info.issystem)
	{
    	text_buffer.Append(_L("Yes"));
	}
	else
	{
    	text_buffer.Append(_L("No"));		
	}
  
    text_buffer.Append( _L("\nWgrpname: "));
    text_buffer.Append(info.windowgroupname);
    text_buffer.Append( _L("\nHidden: "));
	
	if(info.hidden)
	{
    	text_buffer.Append(_L("Yes"));
	}
	else
	{
    	text_buffer.Append(_L("No"));		
	}
      

  	iEikonEnv->InfoWinL(_L("Task information"), text_buffer);
}
  
  



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -