📄 bioexample.cpp
字号:
-------------------------------------------------------------------------------
ReadMessageL();
Description: Read the message data. This could be done also in BIOexampleParser.
Return value: N/A
-------------------------------------------------------------------------------
*/
void CBIOexampleAppUi::ReadMessageL(TDes& aText, TDes& aSender)
{
// Using the Send As API to read message
CSendAs* sendAs=CSendAs::NewL(*this);
sendAs->SetMtmL(KUidMsgTypeSMS); // this implementation assumes that message arrived over SMS
CleanupStack::PushL(sendAs);
if (sendAs->AvailableServices().Count() < 1)
{
User::Leave(KErrNotFound);
}
sendAs->SetService(0);
CBaseMtm* smsMtm = sendAs->ClientRegistry().NewMtmL(KUidMsgTypeSMS);
CleanupStack::PushL(smsMtm);
smsMtm->SwitchCurrentEntryL(*iId);
smsMtm->LoadMessageL();
aText.Append( smsMtm->Body().Read(0) );
aSender.Append( smsMtm->Entry().Entry().iDetails );
CleanupStack::PopAndDestroy(2); // sendAs, smsMtm
}
/*
-------------------------------------------------------------------------------
HandleCommandL
Description: Handles a given command
Return value: N/A
-------------------------------------------------------------------------------
*/
void CBIOexampleAppUi::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EBIOexampleCmdSend:
SendMessageL();
break;
case EClose:
CBaActiveScheduler::Exit();
break;
default:
break;
}
}
/*
-------------------------------------------------------------------------------
SendMessageL();
Description: Sending a new BIO message. This is done using the SendAppUi API.
Return value: N/A
-------------------------------------------------------------------------------
*/
void CBIOexampleAppUi::SendMessageL()
{
//-- Sending a BIO message through the SendUi API: --
// create parameters for sendUi object
MDesC16Array* attachments = NULL; // no attachments
const TUid bioTypeUid = KNullUid; // Our message UID (defined in bioexamplebif.rss file) would go
// here but this type was not supported by SendUi so using KNullUid
CPtrC16Array* recipients = NULL; // define recipients later (through msg editor UI)
MDesC16Array* aliases = NULL; // no aliases
// create message body (insert our BIO message identifier in the beginning)
messageBodyContent->DeleteL( 0, messageBodyContent->DocumentLength() ); // first clear the document (the //BIOEX header of previous sending)
messageBodyContent->InsertL( 0, KBIOExampleTag ); // our tag ( "//BIOEX #" ) the # is not needed by the BIO header, it is only our own message separator
// Only "//BIOEX" is needed in the beginning for the system to recognize the message as 'BIOexample' message.
// Sending message over SMS bearer
sendAppUi->CreateAndSendMessageL(KUidMsgTypeSMS, messageBodyContent, attachments, bioTypeUid, recipients, aliases);
// The message could be deleted after the sending with the delete function...
// just get the newly created message id from somewhere (not implemented in this example)
//DeleteMessage(messageId);
}
/*
-------------------------------------------------------------------------------
DeleteMessageL();
Description: Delete message (with given id) from messaging server.
Return value: N/A
-------------------------------------------------------------------------------
*/
void CBIOexampleAppUi::DeleteMessageL(TMsvId aEntryId)
{
CSendAs* sendAs=CSendAs::NewL(*this);
sendAs->SetMtmL(KUidMsgTypeSMS);
CleanupStack::PushL(sendAs);
if (sendAs->AvailableServices().Count() < 1)
{
User::Leave(KErrNotFound);
}
sendAs->SetService(0);
CBaseMtm* smsMtm = sendAs->ClientRegistry().NewMtmL(KUidMsgTypeSMS);
CleanupStack::PushL(smsMtm);
smsMtm->Session().RemoveEntry(aEntryId); // remove message entry from the server
CleanupStack::PopAndDestroy(2); // sendAs, smsMtm
}
/*
-------------------------------------------------------------------------------
CapabilityOK
Description: Returns component control with a given index.
Return value: TBool
-------------------------------------------------------------------------------
*/
TBool CBIOexampleAppUi::CapabilityOK(TUid /*aCapabilty*/, TInt /*aResponse*/)
{
return ETrue;
}
//
// CBIOexampleDocument
//
/*
-----------------------------------------------------------------------------
CBIOexampleDocument
Creates new BIOexample document.
Return Values: N/A
-----------------------------------------------------------------------------
*/
CBIOexampleDocument::CBIOexampleDocument(CEikApplication& aApp)
: CEikDocument(aApp)
{}
/*
-----------------------------------------------------------------------------
CreateAppUiL
Creates new CBIOexampleAppUi and returns a pointer to it.
Return Values: pointer to CBIOexampleAppUi
-----------------------------------------------------------------------------
*/
CEikAppUi* CBIOexampleDocument::CreateAppUiL()
{
CBIOexampleAppUi* appui = new (ELeave) CBIOexampleAppUi;
return appui;
}
//
// CBIOexampleApplication
//
/*
-----------------------------------------------------------------------------
CreateDocumentL()
Description: Creates new BIOexample document.
Return Values: pointer to new CBIOexampleDocument object
-----------------------------------------------------------------------------
*/
CApaDocument* CBIOexampleApplication::CreateDocumentL()
{
return new (ELeave) CBIOexampleDocument(*this);
}
/*
-----------------------------------------------------------------------------
AppDllUid()
Return the UID of BIOexample application.
Return Values: UID
-----------------------------------------------------------------------------
*/
TUid CBIOexampleApplication::AppDllUid() const
{
return KUidBIOexampleApp;
}
// OTHER EXPORTED FUNCTIONS
//=============================================================================
/*
-----------------------------------------------------------------------------
NewApplication
Creates new CBIOexampleApplication application and returns a pointer to it.
Return Values: pointer to CApaApplication
-----------------------------------------------------------------------------
*/
EXPORT_C CApaApplication* NewApplication()
{
return new CBIOexampleApplication;
}
/*
-----------------------------------------------------------------------------
E32Dll
Called when the DLL is loaded and unloaded.
Return Values: KErrNone
-----------------------------------------------------------------------------
*/
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
{
return KErrNone;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -