1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Declares the cdmau address classes and constants.
26 #if !(defined __CDMASMSADDR_H__)
27 #define __CDMASMSADDR_H__
32 // CDMA SMS PROT public constants start
33 _LIT(KCdmaSmsDatagram,"CDMA SMS Datagram");
34 /** Cdma SMS sockets family identifier. */
35 const TUint KCdmaSMSAddrFamily = 0x012;
36 /** Cdmd SMS sockets protocol ID. */
37 const TUint KCdmaSMSDatagramProtocol = KSMSDatagramProtocol;
39 // Followings are the Ioctl commands used in cdmssmsprot
40 // Ioctl commands that are supported in both cdma and gsm include the following from smsuaddr.h:
41 // KIoctlDeleteSmsMessage = 0x0300;
42 // KIoctlEnumerateSmsMessages = 0x0301;
43 // KIoctlReadMessageSucceeded = 0x0304;
44 // KIoctlReadMessageFailed = 0x0305;
45 // KIoctlSendSmsMessage = 0x0306;
46 // KIoctlWriteSmsMessage = 0x0307;
48 // Gsm Ioctl commands 0x0308-0x0310 are not supported for cdma
50 /** Ioctl command for retrieving message identifier token object
52 @capability NetworkServices
53 @see RSocket::Ioctl(TUint aLevel,TUint aName,TDes8* aOption)
55 const TUint KIoctlGetMsgId=0x0311;
57 /** Ioctl command for retrieving the last transport layer acknowledgement cause code
58 This command is valid only after a KIoctlSendSmsMessage ioctl command and
59 aReqestStatus return one of the KErrCdmaSms extended errors and
60 bearer reply option parameter was present in the previous sent message.
61 Otherwise the cause error received will be meaningless
63 @capability NetworkServices
64 @see RSocket::Ioctl(TUint aLevel,TUint aName,TDes8* aOption)
66 const TUint KIoctlGetLastSendError=0x0312;
67 /** Value that aOptions could take when client demand traffic channel to stay open.
68 Used only for KIoctlSendSmsMessage Ioctl command */
69 const TUint KKeepChannelOpen=0x01;
71 /** Maximum size of storage location */
72 const TInt KCdmaMaxLocationStorageSize=256;
74 typedef TBuf8<KCdmaMaxLocationStorageSize> TCdmaSmsStorageLocation;
77 // CDMA SMS PROT public constants end
80 Sockets for CDMA SMS messages must be bound to an address. The 'address'
81 provides a rule that tells the CDMA SMS stack which received messages should
82 be given to the socket; see TCdmaSmsAddr for a more detailed explanation.
84 Each address must belong to a family. The family must be one of the values
87 enum TCdmaSmsAddrFamily
90 /** This indicates that the address's family has not been set
92 ECdmaSmsAddrUnbound=ESmsAddrUnbound,
93 /** Sockets bound to a ECdmaSmsAddrSendOnly address can only be for
94 sending CDMA SMS messages; they will not receive any messages until they
95 are bound to a different address.
97 Note that a socket bound to any address family except for
98 ECdmaSmsAddrLocalOperation can be used to send messages; not just
101 ECdmaSmsAddrSendOnly=ESmsAddrSendOnly,
102 /** Sockets bound to a ECdmaSmsAddrLocalOperation address can only be used
103 for local protocol operations such as enumerating, writing and deleting
104 messages. These sockets cannot be used for sending or receiving messages
105 until they are bound to a different address.
107 Any socket kind of binded address and be used for writing and deleting messages.
108 Only LocalOperation can be used for enumerating messages.
110 ECdmaSmsAddrLocalOperation=ESmsAddrLocalOperation,
112 Sockets bound to a ECdmaSmsWemtAddrMatchIEI address will receive messages
113 on the WEMT teleservice that have a particular Information Element
116 As well as setting the address's family to ECdmaSmsWemtAddrMatchIEI, set
117 the address's 'port'to one of the IEIs in TSmsInformationElementIdentifier;
118 see CSmsInformationElement..
120 The following example binds a socket so that it will receive messages on
121 the WEMT teleservice that have the IEI "Special SMS Message Indication":
124 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrMatchIEI);
125 smsaddr.SetPort(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication);
126 ret=socket.Bind(smsaddr);
129 ECdmaSmsWemtAddrMatchIEI=ESmsAddrMatchIEI,
131 Sockets bound to a ECdmaSmsAddrMatchText address will receive messages
132 whose user data matches contains particular text. The messages
133 teleservice does not matter.
135 As well as setting the address's family to ECdmaSmsAddrMatchText, use
136 TCdmaSmsAddr::SetTextMatch to specify an ASCII string. This string is
137 compared to the user data in the message. If the two match then the
138 message is delivered to the socket. The string can contain the wildcards
139 '?' to match one instance of any character and '*' to match any number of
143 // match messages that start with 12345
144 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
145 smsaddr.SetTextMatch(_L8("12345"));
146 ret=socketMatchText.Bind(smsaddr);
148 // match messages that end with 12345
149 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
150 smsaddr.SetTextMatch(_L8("*12345"));
151 ret=socketMatchText.Bind(smsaddr);
153 // match message that contain 12345
154 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
155 smsaddr.SetTextMatch(_L8("*12345*"));
156 ret=socketMatchText.Bind(smsaddr);
159 ECdmaSmsAddrMatchText=ESmsAddrMatchText,
161 Sockets bound to a ECdmaSmsWemtAddrApplication8BitPort address will
162 receive messages on the WEMT teleservice that are from a particular 8 bit
165 As well as setting the address's family to ECdmaSmsWemtAddrMatchIEI, set
166 the address's 'port' to an 8-bit number.
168 The following example binds a socket so that it will receive messages on
169 the WEMT teleservice that are on the port 83:
172 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrApplication8BitPort);
174 ret=socket.Bind(smsaddr);
177 ECdmaSmsWemtAddrApplication8BitPort=ESmsAddrApplication8BitPort,
179 This is similar to ECdmaSmsWemtAddrApplication8BitPort, except that the
180 WEMT message must be from a particular 16 bit application port. The
181 address's port must be set to a 16-bit number. For example:
184 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrApplication16BitPort);
185 smsaddr.SetPort(1000);
186 ret=socket.Bind(smsaddr);
189 ECdmaSmsWemtAddrApplication16BitPort=ESmsAddrApplication16BitPort,
194 Sockets bound to a ECdmaSmsAddrTeleservice address will receive messages
195 on a particular teleservice.
197 As well as setting the address's family to ECdmaSmsAddrTeleservice, use
198 TCdmaSmsAddr::SetTeleserviceId to set the required teleservice. For
199 example, to receive messages on the WEMT teleservice:
202 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrTeleservice);
203 smsaddr.SetTeleserviceId(KTeleserviceWEMT);
204 ret=socket.Bind(smsaddr);
207 ECdmaSmsAddrTeleservice =10,
209 Sockets bound to a ECdmaSmsWemtAddrWdp address will receive messages on
210 the WAP teleservice that are for a particular WDP port.
212 As well as setting the address's family to ECdmaSmsWemtAddrWdp, set the
213 address's 'port' to a WDP port. For example:
216 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrWdp);
217 smsaddr.SetPort(wdpPort);
218 ret=socket.Bind(smsaddr);
223 Sockets bound to a ECdmaSmsAddrBroadcast address will receive broadcast
224 messages. Note that broadcast messages cannot be received using other
227 Broadcast messages belong to a service category. A socket can
228 be bound so that it receives broadcast messages from a specified service
229 category. Alternatively it can receive all broadcast messages, whatever
230 the service category.
232 As well as setting the address's family to ECdmaSmsAddrBroadcast, use
233 TCdmaSmsAddr::SetPort to set the required service category from those in
234 tia637::TServiceCategory.
237 // Receive messages from the Emergency Broadcast service catagory
238 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrBroadcast);
239 smsaddr.SetPort(KEmergencyBroadcasts);
240 ret=broadcastSocket.Bind(smsaddr);
242 // Receive messages from any service category by setting the port to zero
243 smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrBroadcast);
245 ret=broadcastSocket2.Bind(smsaddr);
248 ECdmaSmsAddrBroadcast=12
253 Sockets for CDMA SMS messages must be bound to an address. A
254 socket's address can be thought of as a rule that tells the sockets server
255 which messages should be delivered to the socket. When the CDMA SMS stack
256 receives a message, it compares the message to the address (or rule) of each
257 of the CDMA SMS sockets. If the message's contents match one of the rules,
258 the SMS stack uses Symbian OS's sockets server to pass the message to an
261 The address is an instance of TCdmaSmsAddr. Create an instance then use its
262 setter methods to configure up the address. Before receiving SMS messages,
263 RSocket::Bind must be called to bind a socket to a appropriate address.
265 Each address must belong to a family. This broadly defines the type of rule
266 used to match messages to socket. Set an address's family with
267 SetCdmaSmsAddrFamily. Depending upon the family, call methods to set further
268 address variables, thus refining the rule further. To understand address
269 better, see the descriptions of the address families in TCdmaSmsAddrFamily.
271 Two sockets cannot be bound to the same address - the second attempt to bind a
274 Sometimes, a message is received matches several addresses, and so could
275 be sent to more than one socket. The messages are compared to address in a
276 particular order; see CdmaSmsAddressPriority below for more information.
278 class TCdmaSmsAddr : public TSockAddr
281 /** Maximum length of the text pattern used to match the incoming text. */
282 enum { EMaxTextMatchLength = 24 };
284 IMPORT_C TCdmaSmsAddr();
285 IMPORT_C TCdmaSmsAddrFamily CdmaSmsAddrFamily() const;
286 IMPORT_C void SetCdmaSmsAddrFamily(TCdmaSmsAddrFamily aFamily);
287 IMPORT_C TPtrC8 TextMatch() const;
288 IMPORT_C void SetTextMatch(const TDesC8& aText);
289 IMPORT_C TInt NumTextMatchChar() const;
290 IMPORT_C TBool operator==(const TCdmaSmsAddr& aAddr) const;
291 IMPORT_C TInt CdmaSmsAddressPriority()const;
292 IMPORT_C tia637::TTeleserviceId TeleserviceId() const;
293 IMPORT_C void SetTeleserviceId(tia637::TTeleserviceId aTeleserviceId);
296 #endif //__CDMASMSADDR_H__