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

📄 fetchmsgao.cpp

📁 symbian平台进程间通信代码
💻 CPP
字号:
#include <apgwgnam.h>

#include "FetchMsgAO.h"



CFetchMsgAO* CFetchMsgAO::NewLC()
{
    CFetchMsgAO *self = new (ELeave) CFetchMsgAO();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}


CFetchMsgAO* CFetchMsgAO::NewL()
{
    CFetchMsgAO *self = CFetchMsgAO::NewLC();
    CleanupStack::Pop(self);
    return self;
}


CFetchMsgAO::CFetchMsgAO()
 : CActive(CActive::EPriorityStandard)
{
    CActiveScheduler::Add(this);
}


CFetchMsgAO::~CFetchMsgAO()
{
    Cancel();
    iWindowGroup->Close();
    delete iWindowGroup;
    iWsSession.Close();
}


void CFetchMsgAO::ConstructL()
{
}
    
    
void CFetchMsgAO::StartL(RFileLogger* aLogger)
{
    iLogger = aLogger;
    iLogger->Write(_L("enter StartL"));
    User::LeaveIfError(iWsSession.Connect());
    
    iWindowGroup = new (ELeave) RWindowGroup(iWsSession);
    User::LeaveIfError(iWindowGroup->Construct(reinterpret_cast<TUint32>(iWindowGroup), EFalse));
    //User::LeaveIfError(iWindowGroup->SetName(_L("s60v22cmdas")));
    User::LeaveIfError(iWindowGroup->SetName(_L("______s60v22cmdas")));
    
    //好像只用把Name前面写为 200 打头, 就可以变为任务列表隐藏
    
    iLogger->WriteFormat(_L("iWindowGroup->Identifier is %d"), iWindowGroup->Identifier());
    TBuf<300> name;
    iWindowGroup->Name(name);
    iLogger->WriteFormat(_L("before hidden iWindowGroup->Name is %S"), &name);
    
    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWsSession, iWindowGroup->Identifier());
    wgName->SetHidden(ETrue);
    wgName->SetWindowGroupName(*iWindowGroup);
    CleanupStack::PopAndDestroy(wgName);
    
    name.Zero();
    iWindowGroup->Name(name);
    iLogger->WriteFormat(_L("after hidden iWindowGroup->Name is %S"), &name);
    
    iWsSession.EventReady(&iStatus);
    SetActive();
    iLogger->Write(_L("leave StartL"));
}


void CFetchMsgAO::RunL()
{
    TInt status = iStatus.Int();
    iLogger->WriteFormat(_L("in CFetchMsgAO::RunL, iStatus is %d"), status);
    if ( status == KErrNone )
    {
        TWsEvent evt;
        iWsSession.GetEvent(evt);
        iLogger->WriteFormat(_L("type is %d"), evt.Type());
        if ( evt.Type() == EEventMessageReady )
        {
            TUid uid;
            TPtr8 ptr(0, 0, 0);
            iWsSession.FetchMessage(uid, ptr, evt);
            HBufC8* buf = ptr.AllocLC();
            iLogger->WriteFormat(_L("uid is 0x%08x"), uid);
            iLogger->WriteFormat(_L8("msg is %S"), buf);
            CleanupStack::PopAndDestroy(buf);
        }
        
        iWsSession.EventReady(&iStatus);
        SetActive();
    }
}


void CFetchMsgAO::DoCancel()
{
    iLogger->Write(_L("enter CFetchMsgAO::DoCancel!"));
    iWsSession.EventReadyCancel();
    iLogger->Write(_L("leave CFetchMsgAO::DoCancel!"));
}


⌨️ 快捷键说明

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