symbian 短信的发送和监听

//试用方法:
CMtmEngine* iSmsHandler; //sms


//sms
iSmsHandler = CMtmEngine::NewL(*this);


//创建和发送短信
TBuf<256> bufCon(KNullDesC);
iMainView->GetNoticeValue(bufCon);

//创建短信
iSmsHandler->CreateDraftSMSL(aCallNumber, bufCon);
if (iSmsHandler->ValidateSMS())
    {
    iSmsHandler->SendSMSL();
    }






/*
 

=======================================================================

=====
 Name        : MtmEngine.h
 Author      : nana
 Version     : 1.0
 Copyright   : Your copyright notice
 Description : CMtmEngine declaration
 

=======================================================================

=====
 */

#ifndef MTMENGINE_H
#define MTMENGINE_H
//msgs.lib
//smcm.lib
//gsmu.lib
//euser.lib

#include <e32base.h>    // For CActive, link against:
#include <e32std.h>        // For RTimer, link against:
#include <msvapi.h>  // MMsvSessionObserver
class MMsvSessionObserver;
class CMsvOperation;
class CMsvEntrySelection;
class CClientMtmRegistry;
class CSmsClientMtm;
class CMsvSession;
class TMsvSessionEvent;
class CMsvId;

//  CONSTANTS
const TInt KSmsMessageLength = 512;
const TInt KAddressLength = 64;

class MMtmEngineObserver
    {
public:
    //发送短信
    virtual void HandleMessageSentL(TInt aError)=0;

    //接受短信
    virtual void MessageReceived(TDesC& aMsg, TDesC& aAddr) = 0;
    };

class CMtmEngine : public CActive, public MMsvSessionObserver
    {
public:
    // Cancel and destroy
    ~CMtmEngine();

    // Two-phased constructor.
    static CMtmEngine* NewL(MMtmEngineObserver & aObserver);

    // Two-phased constructor.
    static CMtmEngine* NewLC(MMtmEngineObserver & aObserver);

public:
    // New functions
    // Function for making the initial request
    void StartL(TTimeIntervalMicroSeconds32 aDelay);

private:
    // C++ constructor
    CMtmEngine(MMtmEngineObserver & aObserver);

    // Second-phase constructor
    void ConstructL();

private:
    // From CActive
    // Handle completion
    void RunL();

    // How to cancel me
    void DoCancel();

    // Override to handle leaves from RunL(). Default

implementation causes
    // the active scheduler to panic.
    TInt RunError(TInt aError);

private:
    enum TMtmEngineState
        {
        EUninitialized, // Uninitialized
        EInitialized, // Initalized
        EError
        // Error condition
        };

private:
    TInt iState; // State of the active object
    RTimer iTimer; // Provides async timing service

private:
    MMtmEngineObserver & iObserver;

    CMsvOperation * iOp;

    CMsvEntrySelection * iEntrySelection;

    CMsvSession * iSession;

    CClientMtmRegistry * iMtmReg;

    CSmsClientMtm * iSmsMtm;

    TMsvId iSmsId;

    CMsvEntry* iMsvEntry;

    TMsvId iNewMessageId;

    // Message body
    TBuf<KSmsMessageLength> iMessage;

    // Address (phonenumber)
    TBuf<KAddressLength> iAddress;

private:

    void CompleteConstructL();

    void HandleSessionEventL(TMsvSessionEvent aEvent, TAny *aArg1,

TAny *aArg2,
            TAny *aArg3);

public:

    void CreateDraftSMSL(const TDesC & aAddress, const TDesC &

aContent);

    TBool ValidateSMS();

    void SendSMSL();

    void SendSMS(const TDesC & aAddress, const TDesC & aContent);

    };

#endif // MTMENGINE_H

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值