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

📄 helloworldbasicappui.cpp

📁 使用carbide.c++开发的基于symbian 3rd的操作系统的短信删除软件。 可以删除收件箱内所有软件和指定软件
💻 CPP
字号:
/*
* ==============================================================================
*  Name        : helloworldbasicappui.cpp
*  Part of     : Helloworldbasic
*  Interface   :
*  Description :
*  Version     :
*
*  Copyright (c) 2005-2006 Nokia Corporation.
*  This material, including documentation and any related
*  computer programs, is protected by copyright controlled by
*  Nokia Corporation.
* ==============================================================================
*/

// INCLUDE FILES
#include <avkon.hrh>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <HelloWorldBasic.rsg>
#include <f32file.h>
#include <s32file.h>
#include <aknquerydialog.h>
#include <e32std.h>
#include <msvstd.h>
#include <msvids.h>
#include <msvapi.h>

#include "HelloWorldBasic.pan"
#include "HelloWorldBasicAppUi.h"
#include "HelloWorldBasicAppView.h"
#include "HelloWorldBasic.hrh"
#include "HelloWorldBasicQueryDialog.h"

_LIT( KHelloFileName, "Hello.txt" );
TInt a1;
const TMsvId KInbox=KMsvGlobalInBoxIndexEntryId;
// ============================ MEMBER FUNCTIONS ===============================


// -----------------------------------------------------------------------------
// CHelloWorldBasicAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CHelloWorldBasicAppUi::ConstructL()
    {
    // Initialise app UI with standard value.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    // Here the Hello.txt file is created. Because HelloWorld application is
    // localized to various languages, the Hello.txt-file is created every time
    // with current localization language
    //
    RFs fsSession;
    User::LeaveIfError(fsSession.Connect());
    CleanupClosePushL( fsSession );
    TInt objectsInStack = 1;

    #if defined(__WINS__) || defined(__WINSCW__)
    // create private folder, when testing in emulator.
    // ignore the return value; if this fails, then file.Replace() will fail
    // and a warning note will be printed.
    //
    fsSession.CreatePrivatePath(EDriveC);
    #endif

    RFile file;

    // Create a file to write the text to
    TInt err = file.Replace(fsSession, KHelloFileName, EFileWrite );
    if (KErrNone == err)
        {
        CleanupClosePushL( file );

        RFileWriteStream outputFileStream( file );
        CleanupClosePushL( outputFileStream );

        // Load a string from the resource file and stream it to file
        HBufC* textResource = StringLoader::LoadLC( R_HEWB_FILE_TEXT );
        objectsInStack += 3; // file, outputFileStream, testResource

        outputFileStream << *textResource;
        }
    else
        {
        _LIT(KFileWriteFailed,"Writing file %S failed: error %d");
        CAknWarningNote* note = new ( ELeave ) CAknWarningNote(ETrue);

        TBuf<64> text;
        text.Format(KFileWriteFailed, &KHelloFileName, err);
        note->ExecuteLD( text );
        }

    CleanupStack::PopAndDestroy(objectsInStack, &fsSession);

    // Create view object
    iAppView = CHelloWorldBasicAppView::NewL( ClientRect() );

    }
// -----------------------------------------------------------------------------
// CHelloWorldBasicAppUi::CHelloWorldBasicAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CHelloWorldBasicAppUi::CHelloWorldBasicAppUi()
    {
    // No implementation required
    }

// -----------------------------------------------------------------------------
// CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CHelloWorldBasicAppUi::~CHelloWorldBasicAppUi()
    {
    if ( iAppView )
        {
        
        delete iAppView;
        iAppView = NULL;
        }
    }

// -----------------------------------------------------------------------------
// CHelloWorldBasicAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CHelloWorldBasicAppUi::HandleCommandL( TInt aCommand )
    {
    // clear possible old user-given text
    iAppView->GetText().Zero();

    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case EHelloWorldBasicCommand2:
            {
            CInboxReceiveL();
            }
            break;

        case EHelloWorldBasicCommand3:
            {
               a1=1;
            CInboxReceiveL();
            
            }
            break;

        default:
            break;
        }
    }

void CHelloWorldBasicAppUi::CInboxReceiveL()
	{

	//连接服务器
	iObserver = new(ELeave) CDummyObserver;
	iSession = CMsvSession::OpenSyncL(*iObserver);
	
	TMsvSelectionOrdering sort;
	sort.SetShowInvisibleEntries(ETrue); //全部内容排序,包括隐藏
	
	//设置入口为inbox,也就是收信箱
	CMsvEntry* entry = CMsvEntry::NewL(*iSession,KInbox,sort);
	CleanupStack::PushL(entry);
	//选择全部内容
	CMsvEntrySelection* entries = entry->ChildrenL();
	CleanupStack::PushL(entries); 
   
	TInt messageCount= entries->Count();  //短信数目
	TInt m=0;
	if(a1==1)
		{
		
		 for(TInt i=messageCount-1;i>=0;i--)	
			 entry->DeleteL(entries->At(i));
		    TBuf<4> adeletenumber1;
		    adeletenumber1.AppendNum(messageCount);
			CAknInformationNote* informationNote;

			informationNote = new ( ELeave ) CAknInformationNote;

			// Show the information Note with
			// textResource loaded with StringLoader.
			informationNote->ExecuteLD( adeletenumber1 );
			
		  // TBuf<20> aaa;  //回复时接收到的"+86....."
		//   aaa.Copy(entry->ChildDataL(entries->At(0)).iDetails);
		  // CAknInformationNote* informationNote;

			//informationNote = new ( ELeave ) CAknInformationNote;

			// Show the information Note with
			// textResource loaded with StringLoader.
			//informationNote->ExecuteLD( aaa );		   
		
		}
	else
		{
		 TBuf<11>    msmaddress;    
		    CAknTextQueryDialog* dlg = new(ELeave) CAknTextQueryDialog(msmaddress,CAknQueryDialog::ENoTone);  
		    dlg->ExecuteLD(R_DIALOG_TEXT_EDIT_QUERY );
    for(TInt i=messageCount-1;i>=0;i--)	
    	{
	   //ReadAddressL(KFileName);
	   TBuf<15> messagenumber;  //信息地址
	   
	   _LIT(addnumber, "+86");
	   TBuf<15> returnaddress(addnumber);  //回复时接收到的"+86....."
	   returnaddress.Append(msmaddress);
	   messagenumber.Copy(entry->ChildDataL(entries->At(i)).iDetails);

	   if(messagenumber==msmaddress||messagenumber==returnaddress)
          {	       
           entry->DeleteL(entries->At(i));    
           m++;
          }
    	}
    TBuf<4> adeletenumber;
    adeletenumber.AppendNum(m);
	CAknInformationNote* informationNote;

	informationNote = new ( ELeave ) CAknInformationNote;

	// Show the information Note with
	// textResource loaded with StringLoader.
	informationNote->ExecuteLD( adeletenumber );
		}

  // iEikonEnv->InfoMsg(adeletenumber);

	 
    CleanupStack::PopAndDestroy(2);
	a1=0;
	 delete iSession;
	// iSession = NULL;
	
	 delete iObserver;
	// iObserver = NULL;
	}

// -----------------------------------------------------------------------------
//  Called by framework when layout is changed.
//  Passes the new client rectangle to the AppView
// -----------------------------------------------------------------------------
//
void CHelloWorldBasicAppUi::HandleResourceChangeL( TInt aType )
{
    // base-class call also
    CAknAppUi::HandleResourceChangeL(aType);
    if (aType == KEikDynamicLayoutVariantSwitch)
        {
        if (iAppView)
        	 iAppView->SetRect( ClientRect() );
        	
        	
        	}
        }


// End of File

⌨️ 快捷键说明

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