epoc32/include/cdmasmsaddr.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Declares the cdmau address classes and constants.
    15 // 
    16 //
    17 
    18 
    19 
    20 /**
    21  @file 
    22  @publishedAll
    23  @interim
    24 */
    25 
    26 #if !(defined __CDMASMSADDR_H__)
    27 #define __CDMASMSADDR_H__
    28 
    29 #include <smsuaddr.h>
    30 #include "tia637.h"
    31 
    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;
    38 
    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; 
    47 
    48 // Gsm Ioctl commands 0x0308-0x0310 are not supported for cdma
    49 
    50 /** Ioctl command for retrieving message identifier token object
    51 
    52 @capability NetworkServices
    53 @see RSocket::Ioctl(TUint aLevel,TUint aName,TDes8* aOption)
    54 */
    55 const TUint KIoctlGetMsgId=0x0311;
    56 
    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
    62 
    63 @capability NetworkServices
    64 @see RSocket::Ioctl(TUint aLevel,TUint aName,TDes8* aOption)
    65 */
    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;
    70 
    71 /** Maximum size of storage location */
    72 const TInt KCdmaMaxLocationStorageSize=256;
    73 
    74 typedef TBuf8<KCdmaMaxLocationStorageSize>	TCdmaSmsStorageLocation;
    75 
    76 
    77 // CDMA SMS PROT public constants end
    78 
    79 /**
    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.
    83 
    84 Each address must belong to a family.  The family must be one of the values 
    85 listed below.
    86 */
    87 enum TCdmaSmsAddrFamily
    88 	{
    89 	// as in GSMU
    90 	/** This indicates that the address's family has not been set
    91 	*/
    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.
    96 
    97 	Note that a socket bound to any address family except for 
    98 	ECdmaSmsAddrLocalOperation can be used to send messages; not just 
    99 	ECdmaSmsAddrSendOnly
   100 	*/
   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.
   106 	
   107 	Any socket kind of binded address and be used for writing and deleting messages.
   108 	Only LocalOperation can be used for enumerating messages.
   109 	*/
   110 	ECdmaSmsAddrLocalOperation=ESmsAddrLocalOperation,
   111 	/** 
   112 	Sockets bound to a ECdmaSmsWemtAddrMatchIEI address will receive messages 
   113 	on the WEMT teleservice that have a particular Information Element 
   114 	Identifier (IEI). 
   115 
   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..  
   119 
   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":
   122 
   123 	@code
   124 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrMatchIEI);	
   125 	smsaddr.SetPort(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication);
   126 	ret=socket.Bind(smsaddr);
   127 	@endcode
   128 	*/
   129 	ECdmaSmsWemtAddrMatchIEI=ESmsAddrMatchIEI,
   130 	/** 
   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.
   134 
   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 
   140 	characters.
   141 
   142 	@code
   143 	// match messages that start with 12345 
   144 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
   145 	smsaddr.SetTextMatch(_L8("12345"));
   146 	ret=socketMatchText.Bind(smsaddr);
   147 
   148 	// match messages that end with 12345
   149 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
   150 	smsaddr.SetTextMatch(_L8("*12345"));
   151 	ret=socketMatchText.Bind(smsaddr);
   152 
   153 	// match message that contain 12345
   154 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrMatchText);
   155 	smsaddr.SetTextMatch(_L8("*12345*"));
   156 	ret=socketMatchText.Bind(smsaddr);
   157 	@endcode
   158 	*/
   159 	ECdmaSmsAddrMatchText=ESmsAddrMatchText,
   160 	/**
   161 	Sockets bound to a ECdmaSmsWemtAddrApplication8BitPort address will 
   162 	receive messages on the WEMT teleservice that are from a particular 8 bit 
   163 	application port. 
   164 
   165 	As well as setting the address's family to ECdmaSmsWemtAddrMatchIEI, set 
   166 	the address's 'port' to an 8-bit  number.
   167 
   168 	The following example binds a socket so that it will receive messages on 
   169 	the WEMT teleservice that are on the port 83:
   170 
   171 	@code
   172 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrApplication8BitPort);	
   173 	smsaddr.SetPort(83);
   174 	ret=socket.Bind(smsaddr);
   175 	@endcode
   176 	*/
   177 	ECdmaSmsWemtAddrApplication8BitPort=ESmsAddrApplication8BitPort,
   178 	/**
   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:
   182 
   183 	@code
   184 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsWemtAddrApplication16BitPort);	
   185 	smsaddr.SetPort(1000);
   186 	ret=socket.Bind(smsaddr);
   187 	@endcode
   188 	*/
   189   	ECdmaSmsWemtAddrApplication16BitPort=ESmsAddrApplication16BitPort,
   190 
   191 	// new values
   192 
   193 	/** 
   194 	Sockets bound to a ECdmaSmsAddrTeleservice address will receive messages 
   195 	on a particular teleservice.
   196 
   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:
   200 
   201 	@code
   202 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrTeleservice);
   203 	smsaddr.SetTeleserviceId(KTeleserviceWEMT);
   204 	ret=socket.Bind(smsaddr);
   205 	@endcode
   206 	*/
   207 	ECdmaSmsAddrTeleservice =10,
   208 	/**
   209 	Sockets bound to a ECdmaSmsWemtAddrWdp address will receive messages on 
   210 	the WAP teleservice that are for a particular WDP port.
   211 
   212 	As well as setting the address's family to ECdmaSmsWemtAddrWdp, set the 
   213 	address's 'port' to a WDP port.  For example:
   214 
   215 	@code
   216 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrWdp);
   217 	smsaddr.SetPort(wdpPort);
   218 	ret=socket.Bind(smsaddr);
   219 	@endcode
   220 	*/
   221 	ECdmaSmsAddrWdp =11,
   222 	/** 
   223 	Sockets bound to a ECdmaSmsAddrBroadcast address will receive broadcast 
   224 	messages.  Note that broadcast messages cannot be received using other 
   225 	address family.
   226 
   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.
   231 
   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.
   235 	
   236 	@code
   237 	// Receive messages from the Emergency Broadcast service catagory
   238 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrBroadcast);
   239 	smsaddr.SetPort(KEmergencyBroadcasts);
   240 	ret=broadcastSocket.Bind(smsaddr);
   241 
   242 	// Receive messages from any service category by setting the port to zero
   243 	smsaddr.SetCdmaSmsAddrFamily(ECdmaSmsAddrBroadcast);
   244 	smsaddr.SetPort(0);
   245 	ret=broadcastSocket2.Bind(smsaddr);
   246 	@endcode
   247 	*/
   248 	ECdmaSmsAddrBroadcast=12
   249 	};
   250 
   251 
   252 /**
   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 
   259 appropriate socket.
   260 
   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.
   264 
   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.
   270 
   271 Two sockets cannot be bound to the same address - the second attempt to bind a 
   272 socket will fail.
   273 
   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.
   277 */
   278 class TCdmaSmsAddr : public TSockAddr
   279 	{
   280 public:
   281 	/** Maximum length of the text pattern used to match the incoming text. */
   282 	enum { EMaxTextMatchLength = 24 };
   283 public:
   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);
   294 	};
   295 
   296 #endif //__CDMASMSADDR_H__