For some reason, I just not using Carbide++ IDE.
I edit in notepad++, and compile in command line.
What happened is the program just disappear, nothing for hint.
What I need is a simple action to send SMS, why it's so complicated?
I like the RSendAs api, but it doesn't work for non-7bit SMS.
Code:
RSendAs saSrv;
saSrv.Connect();
CleanupClosePushL(saSrv);
RSendAsMessage msg;
msg.CreateL(saSrv, KUidMsgTypeSMS);
CleanupClosePushL(msg);
msg.AddRecipientL(strRecipient,RSendAsMessage::ESendAsRecipientTo);
msg.SetBodyTextL(strContent);
msg.SendMessageAndCloseL();
CleanupStack::Pop(&msg);
CleanupStack::PopAndDestroy(&saSrv);
MsgHandler.h
Code:
#ifndef MUIP_WS_MSG_S60_H
#define MUIP_WS_MSG_S60_H
#include "SMShandler.h"
class MsgHandler
{
public:
MsgHandler();
virtual ~MsgHandler();
int nInit();
int nFini();
bool bInitialized();
int nAddRecipient( const char* strRecipient_utf8 );
int nSetBodyText( const char* strContent_utf8 );
int nSend();
private:
CSmsHandler* iSmsHandler;
};
#endif //end MUIP_WS_MSG_S60_H
MsgHandler.cpp
Code:
#include "MUIP_WS_msg_s60.h"
#include <string.h>
#include <utf.h>
#define DEBUG_ONLY
MsgHandler::MsgHandler()
:iSmsHandler(NULL)
{
}
MsgHandler::~MsgHandler()
{
this->nFini();
}
int MsgHandler::nInit()
{
this->nFini();
TRAPD( iErr, (this->iSmsHandler = CSmsHandler::NewL()) );
return 0;
}
int MsgHandler::nFini()
{
#ifndef DEBUG_ONLY
if ( this->bInitialized() )
{
delete this->iSmsHandler;
this->iSmsHandler = NULL;
}
#endif //end DEBUG_ONLY
return 0;
}
bool MsgHandler::bInitialized()
{
return (this->iSmsHandler != NULL);
}
int MsgHandler::nAddRecipient( const char* strRecipient_utf8 )
{
if ( ! this->bInitialized() )
{
return -1;
}
//TODO
return 0;
}
int MsgHandler::nSetBodyText( const char* strContent_utf8 )
{
if ( ! this->bInitialized() )
{
return -1;
}
//TODO
return 0;
}
int MsgHandler::nSend()
{
if ( ! this->bInitialized() )
{
return -1;
}
TBuf16<32> strRecipient;
TBuf16<256> strContent;
strRecipient.Copy( _L("13957167942") );
strContent.Copy( _L("test SMS from Nokia 6110N - qt for s60") );
TRAPD( iErr, this->iSmsHandler->SendL( strRecipient, strContent ) );
return 0;
}