📄 gdsms.cpp
字号:
{
TMsvEntry msvEntry( (iMtm->Entry()).Entry() );
TMsvId id = msvEntry.Id();
if (msvEntry.Parent() != aTarget)
{
TMsvSelectionOrdering sort;
sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries
// Take a handle to the parent entry
CMsvEntry* parentEntry = CMsvEntry::NewL(iMtm->Session(), msvEntry.Parent(), sort);
CleanupStack::PushL(parentEntry);
// Move original from the parent to the new location
CCommandAbsorbingControl::NewLC();
CMsvOperationWait* wait = CMsvOperationWait::NewLC();
wait->Start();
CMsvOperation* op = parentEntry->MoveL(msvEntry.Id(), aTarget, wait->iStatus);
CleanupStack::PushL(op);
CActiveScheduler::Start();
TMsvLocalOperationProgress prog=McliUtils::GetLocalProgressL(*op);
User::LeaveIfError(prog.iError);
id = prog.iId; // id of the moved entry
CleanupStack::PopAndDestroy(4);// op, wait, parentEntry, CCommandAbsorbingControl
}
return id;
}
/*
-----------------------------------------------------------------------------
void CGDSMSAppUi::SetScheduledSendingStateL
Schedules the message to be sent through the etel server.
Return values: none
-----------------------------------------------------------------------------
*/
void CGDSMSAppUi::SetScheduledSendingStateL(CMsvEntrySelection* aSelection)
{
CBaseMtm* smsMtm = iMtm;
// Add entry to task scheduler
TBuf8<1> dummyParams;
CCommandAbsorbingControl::NewLC();
CMsvOperationWait* waiter = CMsvOperationWait::NewLC();
waiter->Start();
// invoking async schedule copy command on our mtm
CMsvOperation* op= smsMtm->InvokeAsyncFunctionL(
ESmsMtmCommandScheduleCopy,
*aSelection,
dummyParams,
waiter->iStatus);
CleanupStack::PushL(op);
CActiveScheduler::Start();
CleanupStack::PopAndDestroy(3); // waiter, op, CCommandAbsorbingControl
}
/*
-----------------------------------------------------------------------------
CGDSMSAppUi::DeleteSentEntry()
Delete our message from the Sent folder. We are double checking that
the entry we are handling is indeed in the Sent folder - AND that it
is the same message entry that wsa sent by this application.
If so, the message will be deleted from the Sent folder.
Return values: ETrue or EFalse
-----------------------------------------------------------------------------
*/
TBool CGDSMSAppUi::DeleteSentEntry(TMsvId aEntryId)
{
// Load this entry to our mtm
SetEntryL( aEntryId );
TMsvEntry msvEntry( (iMtm->Entry()).Entry() );
if (msvEntry.Parent() == KMsvSentEntryId) // check again that our entry is in sent
{
if (msvEntry.iMtmData3 == KUidGDSMS.iUid) // this entry has been created by our app
{
// Taking a handle to the Sent folder...
TMsvSelectionOrdering sort;
sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries
// Take a handle to the parent entry
CMsvEntry* parentEntry = CMsvEntry::NewL(iMtm->Session(), msvEntry.Parent(), sort);
CleanupStack::PushL(parentEntry);
// here parentEntry is the Sent folder (must be so that we can call DeleteL)
parentEntry->DeleteL(msvEntry.Id());
CleanupStack::PopAndDestroy(parentEntry);
// information to the user
iEikonEnv->InfoMsg(_L("Message deleted in SENT folder."));
return ETrue; // entry was deleted
}
}
return EFalse; // no entries deleted
}
/*
-----------------------------------------------------------------------------
CGDSMSAppUi::MessageReceivedL()
Handle a new message entry that has been created on the messaging
server. This method checks if the message was targeted for this
application and then removes it from the server.
-----------------------------------------------------------------------------
*/
TBool CGDSMSAppUi::MessageReceivedL(TMsvId aEntryId)
{
TBool returnVal = EFalse;
CMsvEntry* entry = iSession->GetEntryL(aEntryId);
CleanupStack::PushL(entry);
TMsvEntry msvEntry = entry->Entry();
// first we create a new mtm to handle this message (in case our own mtm is in use)
CBaseMtm* smsMtm = iMtmReg->NewMtmL(msvEntry.iMtm);
smsMtm->SwitchCurrentEntryL(aEntryId);
smsMtm->LoadMessageL(); // load the message
if (smsMtm->Body().Read(0,4).Compare(KGDSMSTag)==0) // message is targeted to us
{
// Now we process the message
iEikonEnv->InfoMsg(smsMtm->Body().Read(0,4)); // this will flash our message text in the upper right corner of the screen
returnVal = ETrue;
/* As a change to the previous version of GDSMS, the message will not be deleted right
after reading it. Instead all messages that have been read by this app will be deleted
from the Inbox when this app is closed. See DeleteMessagesFromInboxL().
*/
}
// release allocated memory
delete smsMtm;
CleanupStack::Pop(); // entry
delete entry;
return returnVal;
}
/*
-----------------------------------------------------------------------------
CGDSMSAppUi::DeleteMessagesFromInboxL()
This method reads the Inbox and deletes all GDSM messages that are
invisible.
-----------------------------------------------------------------------------
*/
void CGDSMSAppUi::DeleteMessagesFromInboxL()
{
// information to the user
iEikonEnv->InfoMsg(_L("Deleting messages from Inbox."));
// then delete message from inbox, first take a handle to Inbox...
TMsvSelectionOrdering sort;
sort.SetShowInvisibleEntries(ETrue); // we want to handle also the invisible entries
// Take a handle to the Inbox entry
CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, sort);
CleanupStack::PushL(parentEntry);
CMsvEntrySelection* entries = parentEntry->ChildrenL(); // A selection of all the entries of the Inbox
CleanupStack::PushL(entries);
// go through all entries in the Inbox
for(TInt i = 0; i < entries->Count(); i++)
{
if( parentEntry->ChildDataL(entries->At(i)).iMtmData3 == KUidGDSMS.iUid ) // check that message is for GDSMS
{
// delete the current entry (message)
parentEntry->DeleteL(entries->At(i));
}
}
// information to the user
iEikonEnv->InfoMsg(_L("Done."));
CleanupStack::PopAndDestroy(2); // entries, parentEntry
}
//
// CGDSMSDocument
//
/*
-----------------------------------------------------------------------------
CGDSMSDocument::NewL(
2nd phase construction.
-----------------------------------------------------------------------------
*/
CGDSMSDocument* CGDSMSDocument::NewL(CEikApplication& aApp)
{
CGDSMSDocument* self = new(ELeave) CGDSMSDocument(aApp);
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(); //self.
return self;
}
/*
-----------------------------------------------------------------------------
CGDSMSDocument::CGDSMSDocument()
C++ constructor
-----------------------------------------------------------------------------
*/
CGDSMSDocument::CGDSMSDocument(CEikApplication& aApp)
: CEikDocument(aApp)
{
}
/*
-----------------------------------------------------------------------------
CGDSMSDocument::ConstructL()
2nd phase constructor.
-----------------------------------------------------------------------------
*/
void CGDSMSDocument::ConstructL()
{
}
/*
-----------------------------------------------------------------------------
CGDSMSDocument::CreateAppUiL()
Create new CGDSMSAppUi object
Return values: CEikAppUi*
-----------------------------------------------------------------------------
*/
CEikAppUi* CGDSMSDocument::CreateAppUiL()
{
return (new(ELeave) CGDSMSAppUi);
}
//
// CGDSMSApplication
//
/*
-----------------------------------------------------------------------------
CGDSMSApplication::AppDllUid()
Returns application UID of GDSMS application
-----------------------------------------------------------------------------
*/
TUid CGDSMSApplication::AppDllUid() const
{
return KUidGDSMS;
}
/*
-----------------------------------------------------------------------------
CGDSMSApplication::CreateDocumentL()
Create new application document
Return values: CApaDocument*
-----------------------------------------------------------------------------
*/
CApaDocument* CGDSMSApplication::CreateDocumentL()
{
return (CGDSMSDocument::NewL(*this));
}
//
// Functions for Application Architecture
//
EXPORT_C CApaApplication* NewApplication()
{
return (new CGDSMSApplication);
}
//
// DLL entry point
//
GLDEF_C TInt E32Dll(TDllReason)
{
return KErrNone;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -