diff -r ebc84c812384 -r 46218c8b8afa Symbian3/PDK/Source/GUID-3D1E5144-00BC-51AF-8887-4C97167E73FB.dita --- a/Symbian3/PDK/Source/GUID-3D1E5144-00BC-51AF-8887-4C97167E73FB.dita Thu Mar 11 15:24:26 2010 +0000 +++ b/Symbian3/PDK/Source/GUID-3D1E5144-00BC-51AF-8887-4C97167E73FB.dita Thu Mar 11 18:02:22 2010 +0000 @@ -1,133 +1,133 @@ - - - - - -SMS Stack TutorialThis tutorial describes how to send and receive messages using the SMS stack. Send SMS example -#include <e32std.h> -#include <es_sock.h> -#include <gsmubuf.h> -#include <gsmumsg.h> -#include <gsmuset.h> -#include <smsustrm.h> -#include <smsuaddr.h> - -_LIT(KSmsMessage, "Sample SMS message for illustration"); -_LIT(KDestination,"+44789456123"); -_LIT(KServiceCentre, "+44123456789"); -RFs fs; -RSocketServ socketServer; -RSocket socket; - -//connect to the file server -User::LeaveIfError(fs.Connect()); -CleanupClosePushL(fs); - -//connect to the socket server -User::LeaveIfError(socketServer.Connect()); -CleanupClosePushL(socketServer); - -//Open a SMS socket -User::LeaveIfError(socket.Open(socketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol)); -CleanupClosePushL(socket); -TSmsAddr smsAddr; - -//set the sockets to only send the messages -smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly); - -//Bind the socket -socket.Bind(smsAddr); - -//create a message and encoding scheme to be used -CSmsBuffer* buffer=CSmsBuffer::NewL(); -CSmsMessage* smsMessage=CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer); -CleanupStack::PushL(smsMessage); - -TSmsUserDataSettings smsSettings; -smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit); -smsMessage->SetUserDataSettingsL(smsSettings); - -smsMessage->SetToFromAddressL(KDestination); -smsMessage->SmsPDU().SetServiceCenterAddressL(KServiceCentre); -buffer->InsertL(0,KSmsMessage); - -TRequestStatus status; - -RSmsSocketWriteStream writestream(socket); - -writestream << *smsMessage; -writestream.CommitL(); - -TPckgBuf<TUint> sbuf; -socket.Ioctl(KIoctlSendSmsMessage, status, &sbuf, KSolSmsProv); -User::WaitForRequest(status); - -CleanupStack::PopAndDestroy(smsMessage); -CleanupStack::PopAndDestroy(&socket); -CleanupStack::PopAndDestroy(&socketServer); -CleanupStack::PopAndDestroy(&fs); -
Receive SMS example -#include <e32std.h> -#include <es_sock.h> -#include <gsmubuf.h> -#include <gsmumsg.h> -#include <gsmuset.h> -#include <smsustrm.h> -#include <smsuaddr.h> - -_LIT(KSmsMessage, "Sample SMS message for illustration"); -_LIT(KDestination,"+44789456123"); -_LIT(KServiceCentre, "+44123456789"); -RFs fs; -RSocketServ socketServer; -RSocket socket; - -//connect to the file server -User::LeaveIfError(fs.Connect()); -CleanupClosePushL(fs); - -//connect to the socket server -User::LeaveIfError(socketServer.Connect()); -CleanupClosePushL(socketServer); - -//Open a SMS socket -User::LeaveIfError(socket.Open(socketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol)); -CleanupClosePushL(socket); - -TSmsAddr smsAddr; - -//set the sockets to receive all SMS messages -smsAddr.SetSmsAddrFamily(ESmsAddrRecvAny); - -//Bind the socket -socket.Bind(smsAddr); -TRequestStatus status; -TPckgBuf<TUint> sbuf; - -socket.Ioctl(KIOctlSelect,status,&sbuf,KSOLSocket); -User::WaitForRequest(status); -CSmsBuffer* buffer=CSmsBuffer::NewL(); -CSmsMessage* smsMessage=CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer); -CleanupStack::PushL(smsMessage); - -//read from the stream -RSmsSocketReadStream readstream(socket); - -readstream >> *smsMessage; - -socket.Ioctl(KIoctlReadMessageSucceeded, status, &sbuf, KSolSmsProv); -User::WaitForRequest(status); -CleanupStack::Pop(smsMessage); - -//clear the contents from buffer -CleanupStack::PopAndDestroy(smsMessage); -CleanupStack::PopAndDestroy(&socket); -CleanupStack::PopAndDestroy(&socketServer); -CleanupStack::PopAndDestroy(&fs); + + + + + +SMS Stack TutorialThis tutorial describes how to send and receive messages using the SMS stack. Send SMS example +#include <e32std.h> +#include <es_sock.h> +#include <gsmubuf.h> +#include <gsmumsg.h> +#include <gsmuset.h> +#include <smsustrm.h> +#include <smsuaddr.h> + +_LIT(KSmsMessage, "Sample SMS message for illustration"); +_LIT(KDestination,"+44789456123"); +_LIT(KServiceCentre, "+44123456789"); +RFs fs; +RSocketServ socketServer; +RSocket socket; + +//connect to the file server +User::LeaveIfError(fs.Connect()); +CleanupClosePushL(fs); + +//connect to the socket server +User::LeaveIfError(socketServer.Connect()); +CleanupClosePushL(socketServer); + +//Open a SMS socket +User::LeaveIfError(socket.Open(socketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol)); +CleanupClosePushL(socket); +TSmsAddr smsAddr; + +//set the sockets to only send the messages +smsAddr.SetSmsAddrFamily(ESmsAddrSendOnly); + +//Bind the socket +socket.Bind(smsAddr); + +//create a message and encoding scheme to be used +CSmsBuffer* buffer=CSmsBuffer::NewL(); +CSmsMessage* smsMessage=CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer); +CleanupStack::PushL(smsMessage); + +TSmsUserDataSettings smsSettings; +smsSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit); +smsMessage->SetUserDataSettingsL(smsSettings); + +smsMessage->SetToFromAddressL(KDestination); +smsMessage->SmsPDU().SetServiceCenterAddressL(KServiceCentre); +buffer->InsertL(0,KSmsMessage); + +TRequestStatus status; + +RSmsSocketWriteStream writestream(socket); + +writestream << *smsMessage; +writestream.CommitL(); + +TPckgBuf<TUint> sbuf; +socket.Ioctl(KIoctlSendSmsMessage, status, &sbuf, KSolSmsProv); +User::WaitForRequest(status); + +CleanupStack::PopAndDestroy(smsMessage); +CleanupStack::PopAndDestroy(&socket); +CleanupStack::PopAndDestroy(&socketServer); +CleanupStack::PopAndDestroy(&fs); +
Receive SMS example +#include <e32std.h> +#include <es_sock.h> +#include <gsmubuf.h> +#include <gsmumsg.h> +#include <gsmuset.h> +#include <smsustrm.h> +#include <smsuaddr.h> + +_LIT(KSmsMessage, "Sample SMS message for illustration"); +_LIT(KDestination,"+44789456123"); +_LIT(KServiceCentre, "+44123456789"); +RFs fs; +RSocketServ socketServer; +RSocket socket; + +//connect to the file server +User::LeaveIfError(fs.Connect()); +CleanupClosePushL(fs); + +//connect to the socket server +User::LeaveIfError(socketServer.Connect()); +CleanupClosePushL(socketServer); + +//Open a SMS socket +User::LeaveIfError(socket.Open(socketServer, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol)); +CleanupClosePushL(socket); + +TSmsAddr smsAddr; + +//set the sockets to receive all SMS messages +smsAddr.SetSmsAddrFamily(ESmsAddrRecvAny); + +//Bind the socket +socket.Bind(smsAddr); +TRequestStatus status; +TPckgBuf<TUint> sbuf; + +socket.Ioctl(KIOctlSelect,status,&sbuf,KSOLSocket); +User::WaitForRequest(status); +CSmsBuffer* buffer=CSmsBuffer::NewL(); +CSmsMessage* smsMessage=CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer); +CleanupStack::PushL(smsMessage); + +//read from the stream +RSmsSocketReadStream readstream(socket); + +readstream >> *smsMessage; + +socket.Ioctl(KIoctlReadMessageSucceeded, status, &sbuf, KSolSmsProv); +User::WaitForRequest(status); +CleanupStack::Pop(smsMessage); + +//clear the contents from buffer +CleanupStack::PopAndDestroy(smsMessage); +CleanupStack::PopAndDestroy(&socket); +CleanupStack::PopAndDestroy(&socketServer); +CleanupStack::PopAndDestroy(&fs);
\ No newline at end of file