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

📄 smsmodifier.cpp

📁 手机短信开发的一个案例
💻 CPP
字号:
/*
* ============================================================================
*  Name     : SmsModifier.cpp
*  Part of  : Sms Modifier
*  Created  : 20.05.2006 by Artem Marchenko
*  Description:
*  Version  : 1.0
*  Copyright: Artem Marchenko 2006
* ============================================================================
*/
/*
Note! Normally you would have a separate file for each of these classes, but
here, for the sake of simplicity, they are all put in the same file. Having
the classes defined in separate files makes the source code easier to maintain.

*/

// INCLUDES
#include "SmsModifier.h"

#include "SMSEngine.h"		//sms messaging engine
#include <msvuids.h>		//Entry type constants
#include <msvids.h>			//Predefined entry IDs

// CONSTANTS
const TUid KUidSmsModifierApp = { 0x026be879 }; // Application UID

const TMsvId KInbox = KMsvGlobalInBoxIndexEntryId;


// MEMBER FUNCTIONS

//----------------------------------------------------------------------------
// Application entry point
//----------------------------------------------------------------------------

// GLOBAL FUNCTIONS

// DLL entry point, needed for DLL initialization.
// Usually there is no need to initialize anything, so we just
// return that everything is ok
GLDEF_C TInt E32Dll(TDllReason /*aReason*/) {
    return KErrNone;
}

// EXPORTED FUNCTIONS

// Static function for instantiating a new application object.
// Called by the Symbian application framework.
EXPORT_C CApaApplication* NewApplication() 
    {
    return new CSmsModifierApplication;
    }

//----------------------------------------------------------------------------
// CSmsModifierApplication
//----------------------------------------------------------------------------

// Creates the application document (model)
// Called by the Symbian application framework when the application is started.
// Needed for all Symbian applications.
CApaDocument* CSmsModifierApplication::CreateDocumentL() 
    {
    return new (ELeave) CSmsModifierDocument( *this );
    }

// Specifies the application UID, needed for all Symbian applications.
TUid CSmsModifierApplication::AppDllUid() const 
    {
    return KUidSmsModifierApp;
    }

//----------------------------------------------------------------------------
// CSmsModifierDocument (The Model of the MVC)
//----------------------------------------------------------------------------

// Creates the application document (Symbian terminology for model).
// Needed for all Symbian applications, even if the application doesn't
// save or load files.
CSmsModifierDocument::CSmsModifierDocument(CEikApplication& aApp) : CEikDocument(aApp) 
    {
    // empty
    }

// Creates the application UI class.
// Called by the application framework when the application needs to start
// handling events.
// Needed for all Symbian GUI applications.
CEikAppUi* CSmsModifierDocument::CreateAppUiL() 
    {
    return new (ELeave) CSmsModifierAppUi;
    }

//----------------------------------------------------------------------------
// CSmsModifierAppUi (The Controller of the MVC)
//----------------------------------------------------------------------------

// Second-phase construction function.
// Called by the Symbian application framework after calling
// the constructor from CSmsModifierDocument::CreateAppUiL().
// Needed for initialising the application views.
void CSmsModifierAppUi::ConstructL(void) 
    {
    // Load the application resources defined in the SmsModifier.rss, e.g.
    // application menus, dialogs etc.
    BaseConstructL();

	iEngine = CSmsEngine::NewL();	

    iAppContainer = new (ELeave) CSmsModifierContainer;
    iAppContainer->SetMopParent( this );
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );
    }

// Releases resources used by the application UI.
// Called when shutting down the application.
CSmsModifierAppUi::~CSmsModifierAppUi() {
	delete iEngine;
    if (iAppContainer)
    {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
    }
}

// Handles user commands such as those associated to the menu entries.
// Called by CEikAppUi::ProcessCommandL().
// Application commands are defined in the SmsModifier.hrh file.
// Common commands are defined for instance in the uikon.hrh file, located
// under the system include directory (%EPOCROOT%\epoc32\include).
void CSmsModifierAppUi::HandleCommandL(TInt aCommand) {
    switch (aCommand)
    {
    case EEikCmdFileOpen:
        {
        // The iEngine will be notified about the message creation via
        // HandleSessionEventL. Then it will "replace" it with the one
        // "coming" from the same number, but with the some text "additions"
		iEngine->CreateLocalMessageL( KInbox,
					_L("+923005924292"),
					_L("local generated message description"),
					_L("local generated message body")
					);
        break;
        }
    case EAknSoftkeyBack:
    case EEikCmdExit:
        {
        Exit();
        break;
        }
    default:
        break;
    }
}

//----------------------------------------------------------------------------
// CSmsModifierContainer (The View of the MVC)
//----------------------------------------------------------------------------

// Second-phase construction function.
// Initializes the container (creates a window, sets its bounds and activates
// it) and creates the child/nested controls (if any).
// Called from the AppUi after creating a new container object.
void CSmsModifierContainer::ConstructL(const TRect& aRect) 
    {
    CreateWindowL();

    SetRect(aRect);
    ActivateL();
    }

// Destructor used for releasing the resources used by his container.
// Called from the AppUi's destructor.
CSmsModifierContainer::~CSmsModifierContainer() 
    {
    // empty
    }

// Lays out the child controls (if any).
// Called when the control is resized.
void CSmsModifierContainer::SizeChanged() 
    {
    // nothing
    }

// Returns the number of child controls, 0 if none.
TInt CSmsModifierContainer::CountComponentControls() const 
    {
    return 0; // return nbr of controls inside this container
    }

// Returns the child control at the given index, NULL if none.
CCoeControl* CSmsModifierContainer::ComponentControl( TInt aIndex ) const 
    {
    switch ( aIndex )
        {
        default:
            return NULL;
        }
    }

// Draws to this controls canvas using graphics primitives.
// Note that the UI framework takes care of drawing the child controls.
void CSmsModifierContainer::Draw( const TRect& aRect ) const 
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

// Handles events generated by the child controls.
void CSmsModifierContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) 
    {
    // TODO: Add your control event handler code here
    }

⌨️ 快捷键说明

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