telephonyserverplugins/simatktsy/src/CSatNotifyPlayTone.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 0 3553901f7fa8
child 66 07a122eea281
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 //
    18 //
    19 
    19 
    20 
    20 
    21 
    21 
    22 //INCLUDES
    22 //INCLUDES
       
    23 
       
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "CSatNotifyPlayToneTraces.h"
       
    27 #endif
       
    28 
    23 #include <satcs.h>                  // Etel SAT IPC definitions
    29 #include <satcs.h>                  // Etel SAT IPC definitions
    24 #include "CSatTsy.h"                // Tsy class header
    30 #include "CSatTsy.h"                // Tsy class header
    25 #include "CSatNotifyPlayTone.h"     // Tsy class header
    31 #include "CSatNotifyPlayTone.h"     // Tsy class header
    26 #include "CSatNotificationsTsy.h"   // Class header
    32 #include "CSatNotificationsTsy.h"   // Class header
    27 #include "CBerTlv.h"                // Ber Tlv data handling
    33 #include "CBerTlv.h"                // Ber Tlv data handling
    28 #include "TTlv.h"					// TTlv class
    34 #include "TTlv.h"					// TTlv class
    29 #include "CSatDataPackage.h"        // Parameter packing 
    35 #include "CSatDataPackage.h"        // Parameter packing 
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
    36 #include "TSatUtility.h"            // Utilities
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
    37 #include "CSatTsyReqHandleStore.h"  // Request handle class
    33 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
    38 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
    34 
    39 
    35 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    40 CSatNotifyPlayTone* CSatNotifyPlayTone::NewL
    45 CSatNotifyPlayTone* CSatNotifyPlayTone::NewL
    41         ( 
    46         ( 
    42         CSatNotificationsTsy* aNotificationsTsy 
    47         CSatNotificationsTsy* aNotificationsTsy 
    43         )
    48         )
    44     {
    49     {
    45     TFLOGSTRING("CSAT: CSatNotifyPlayTone::NewL");
    50     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_NEWL_1, "CSAT: CSatNotifyPlayTone::NewL");
    46    	CSatNotifyPlayTone* const satNotifyPlayTone = 
    51    	CSatNotifyPlayTone* const satNotifyPlayTone = 
    47         new ( ELeave ) CSatNotifyPlayTone( aNotificationsTsy );
    52         new ( ELeave ) CSatNotifyPlayTone( aNotificationsTsy );
    48     CleanupStack::PushL( satNotifyPlayTone );
    53     CleanupStack::PushL( satNotifyPlayTone );
    49     satNotifyPlayTone->ConstructL();
    54     satNotifyPlayTone->ConstructL();
    50     CleanupStack::Pop( satNotifyPlayTone );
    55     CleanupStack::Pop( satNotifyPlayTone );
    51     TFLOGSTRING("CSAT: CSatNotifyPlayTone::NewL, end of method");
    56     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_NEWL_2, "CSAT: CSatNotifyPlayTone::NewL, end of method");
    52     return satNotifyPlayTone;
    57     return satNotifyPlayTone;
    53     }
    58     }
    54 
    59 
    55 // -----------------------------------------------------------------------------
    60 // -----------------------------------------------------------------------------
    56 // CSatNotifyPlayTone::~CSatNotifyPlayTone
    61 // CSatNotifyPlayTone::~CSatNotifyPlayTone
    60 CSatNotifyPlayTone::~CSatNotifyPlayTone
    65 CSatNotifyPlayTone::~CSatNotifyPlayTone
    61         ( 
    66         ( 
    62 		// None
    67 		// None
    63         )
    68         )
    64     {
    69     {
    65     TFLOGSTRING("CSAT: CSatNotifyPlayTone::~CSatNotifyPlayTone");
    70     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_DTOR_1, "CSAT: CSatNotifyPlayTone::~CSatNotifyPlayTone");
    66     }
    71     }
    67     
    72     
    68 // -----------------------------------------------------------------------------
    73 // -----------------------------------------------------------------------------
    69 // CSatNotifyPlayTone::CSatNotifyPlayTone
    74 // CSatNotifyPlayTone::CSatNotifyPlayTone
    70 // Default C++ constructor
    75 // Default C++ constructor
    86 void CSatNotifyPlayTone::ConstructL
    91 void CSatNotifyPlayTone::ConstructL
    87         (
    92         (
    88         // None
    93         // None
    89         )
    94         )
    90     {
    95     {
    91     TFLOGSTRING("CSAT: CSatNotifyPlayTone::ConstructL, does nothing");
    96     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_CONSTRUCTL_1, "CSAT: CSatNotifyPlayTone::ConstructL, does nothing");
    92     }
    97     }
    93 
    98 
    94 // -----------------------------------------------------------------------------
    99 // -----------------------------------------------------------------------------
    95 // CSatNotifyPlayTone::Notify
   100 // CSatNotifyPlayTone::Notify
    96 // Save the request handle type for notification requested by ETel server
   101 // Save the request handle type for notification requested by ETel server
   100         (
   105         (
   101         const TTsyReqHandle aTsyReqHandle,
   106         const TTsyReqHandle aTsyReqHandle,
   102         const TDataPackage& aPackage
   107         const TDataPackage& aPackage
   103         )
   108         )
   104     {
   109     {
   105     TFLOGSTRING("CSAT: CSatNotifyPlayTone::Notify");
   110     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_NOTIFY_1, "CSAT: CSatNotifyPlayTone::Notify");
   106     // Save data pointer to client side for completion
   111     // Save data pointer to client side for completion
   107     iPlayToneV2Pckg = reinterpret_cast<RSat::TPlayToneV2Pckg*>( 
   112     iPlayToneV2Pckg = reinterpret_cast<RSat::TPlayToneV2Pckg*>( 
   108         aPackage.Des1n() );
   113         aPackage.Des1n() );
   109     // Save the request handle
   114     // Save the request handle
   110     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
   115     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
   125 TInt CSatNotifyPlayTone::CancelNotification
   130 TInt CSatNotifyPlayTone::CancelNotification
   126         (
   131         (
   127         const TTsyReqHandle aTsyReqHandle
   132         const TTsyReqHandle aTsyReqHandle
   128         )
   133         )
   129     {
   134     {
   130     TFLOGSTRING("CSAT: CSatNotifyPlayTone::CancelNotification");    
   135     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_CANCELNOTIFICATION_1, "CSAT: CSatNotifyPlayTone::CancelNotification");
   131     // Reset the request handle
   136     // Reset the request handle
   132     iNotificationsTsy->iSatReqHandleStore->
   137     iNotificationsTsy->iSatReqHandleStore->
   133         ResetTsyReqHandle( CSatTsy::ESatNotifyPlayTonePCmdReqType );
   138         ResetTsyReqHandle( CSatTsy::ESatNotifyPlayTonePCmdReqType );
   134 	iPlayToneV2Pckg = NULL;
   139 	iPlayToneV2Pckg = NULL;
   135 	iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
   140 	iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
   148         ( 
   153         ( 
   149         CSatDataPackage* aDataPackage, 
   154         CSatDataPackage* aDataPackage, 
   150 		TInt aErrorCode  
   155 		TInt aErrorCode  
   151         ) 
   156         ) 
   152     {
   157     {
   153 	TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL");
   158 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_COMPLETENOTIFYL_1, "CSAT: CSatNotifyPlayTone::CompleteNotifyL");
   154 	TInt returnValue( KErrNone );
   159 	TInt returnValue( KErrNone );
   155     TInt ret( KErrNone );
   160     TInt ret( KErrNone );
   156     
   161     
   157     // Unpack parameters
   162     // Unpack parameters
   158     TPtrC8* data;
   163     TPtrC8* data;
   189 			returnValue = berTlv.TlvByTagValue( &alphaIdentifier, 
   194 			returnValue = berTlv.TlvByTagValue( &alphaIdentifier, 
   190             KTlvAlphaIdentifierTag );
   195             KTlvAlphaIdentifierTag );
   191             
   196             
   192 			if ( KErrNotFound != returnValue )
   197 			if ( KErrNotFound != returnValue )
   193 				{
   198 				{
   194 				TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
   199 				OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_COMPLETENOTIFYL_2, "CSAT: CSatNotifyPlayTone::CompleteNotifyL, Alpha ID present");
   195 				    Alpha ID present");
       
   196 				TUint16 alphaIdLength = alphaIdentifier.GetLength();
   200 				TUint16 alphaIdLength = alphaIdentifier.GetLength();
   197 				if ( alphaIdLength )
   201 				if ( alphaIdLength )
   198 					{
   202 					{
   199 					// Get the alpha id
   203 					// Get the alpha id
   200 					TPtrC8 sourceString;
   204 					TPtrC8 sourceString;
   210 					{
   214 					{
   211 					playToneV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
   215 					playToneV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
   212 					}
   216 					}
   213 				else
   217 				else
   214 					{
   218 					{
   215 					TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
   219 					OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_COMPLETENOTIFYL_3, "CSAT: CSatNotifyPlayTone::CompleteNotifyL, Alpha ID is NULL");
   216 					    Alpha ID is NULL");
       
   217 					playToneV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
   220 					playToneV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
   218 					}
   221 					}
   219 				}
   222 				}
   220 
   223 
   221 			// Tone selection (optional)
   224 			// Tone selection (optional)
   224 			returnValue = berTlv.TlvByTagValue( &tone, KTlvToneTag );
   227 			returnValue = berTlv.TlvByTagValue( &tone, KTlvToneTag );
   225 			if ( KErrNotFound != returnValue )
   228 			if ( KErrNotFound != returnValue )
   226 				{
   229 				{
   227 				playToneV2.iTone = ( RSat::TTone ) tone.GetShortInfo( 
   230 				playToneV2.iTone = ( RSat::TTone ) tone.GetShortInfo( 
   228 				    ETLV_Tone );
   231 				    ETLV_Tone );
   229 			    TFLOGSTRING2("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
   232 			    OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_COMPLETENOTIFYL_4, "CSAT: CSatNotifyPlayTone::CompleteNotifyL, Tone Selection: %d", playToneV2.iTone);
   230 				    Tone Selection: %d", playToneV2.iTone);
       
   231 				}
   233 				}
   232         
   234         
   233 			// Duration of the tone (optional)
   235 			// Duration of the tone (optional)
   234 			TSatUtility::FillDurationStructure( berTlv, 
   236 			TSatUtility::FillDurationStructure( berTlv, 
   235 			    playToneV2.iDuration );
   237 			    playToneV2.iDuration );
   246 
   248 
   247 		iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
   249 		iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
   248 		}// End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )			
   250 		}// End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )			
   249 	else 
   251 	else 
   250 		{
   252 		{
   251 		TFLOGSTRING("CSAT: CSatNotifyPlayTone::CompleteNotifyL,\
   253 		OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_COMPLETENOTIFYL_5, "CSAT: CSatNotifyPlayTone::CompleteNotifyL, Request not ongoing");
   252 		    Request not ongoing");
       
   253 		// Request not on, returning response immediately
   254 		// Request not on, returning response immediately
   254 		additionalInfo.Zero();
   255 		additionalInfo.Zero();
   255 		additionalInfo.Append( KNoCause );
   256 		additionalInfo.Append( KNoCause );
   256 		CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
   257 		CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,
   257 			additionalInfo );					
   258 			additionalInfo );					
   270 TInt CSatNotifyPlayTone::TerminalResponseL
   271 TInt CSatNotifyPlayTone::TerminalResponseL
   271         ( 
   272         ( 
   272         TDes8* aRsp
   273         TDes8* aRsp
   273         )
   274         )
   274 	{    
   275 	{    
   275 	TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL" );
   276 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_TERMINALRESPONSEL_1,  "CSAT: CSatNotifyPlayTone::TerminalResponseL" );
   276 
   277 
   277     TInt ret( KErrNone );
   278     TInt ret( KErrNone );
   278     TBuf<1>additionalInfo;
   279     TBuf<1>additionalInfo;
   279     additionalInfo.Append( 0 );
   280     additionalInfo.Append( 0 );
   280     RSat::TPlayToneRspV1Pckg* aRspPckg = 
   281     RSat::TPlayToneRspV1Pckg* aRspPckg = 
   291 		 ( RSat::KPSessionTerminatedByUser  != rspV1.iGeneralResult ) && 
   292 		 ( RSat::KPSessionTerminatedByUser  != rspV1.iGeneralResult ) && 
   292 		 ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) && 
   293 		 ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) && 
   293 		 ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) && 
   294 		 ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) && 
   294 		 ( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult ) )
   295 		 ( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult ) )
   295         {
   296         {
   296         TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL,\
   297         OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_TERMINALRESPONSEL_2,  "CSAT: CSatNotifyPlayTone::TerminalResponseL, Invalid General Result" );
   297             Invalid General Result" );
       
   298         // Invalid general result
   298         // Invalid general result
   299         ret = KErrCorrupt;
   299         ret = KErrCorrupt;
   300         }
   300         }
   301 
   301 
   302     // If there is ME (Mobile Equipment) error, additional info is needed
   302     // If there is ME (Mobile Equipment) error, additional info is needed
   308             additionalInfo.Zero();
   308             additionalInfo.Zero();
   309             additionalInfo.Append( rspV1.iAdditionalInfo[0] ); 
   309             additionalInfo.Append( rspV1.iAdditionalInfo[0] ); 
   310 			}
   310 			}
   311         else
   311         else
   312             {
   312             {
   313             TFLOGSTRING( "CSAT: CSatNotifyPlayTone::TerminalResponseL,\
   313             OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_TERMINALRESPONSEL_3,  "CSAT: CSatNotifyPlayTone::TerminalResponseL, Invalid Additional Info" );
   314                 Invalid Additional Info" );
       
   315             // Invalid additional info field
   314             // Invalid additional info field
   316             ret = KErrCorrupt;
   315             ret = KErrCorrupt;
   317             }
   316             }
   318         }
   317         }
   319 	TFLOGSTRING2( "CSAT: CSatNotifyPlayTone::TerminalResponseL: \
   318 	OstTraceDefExt1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_TERMINALRESPONSEL_4,  "CSAT: CSatNotifyPlayTone::TerminalResponseL: AdditionalInfo: %S", additionalInfo );
   320 		AdditionalInfo: %s", &additionalInfo );
       
   321 
   319 
   322     CreateTerminalRespL( pCmdNumber, static_cast< TUint8 >( 
   320     CreateTerminalRespL( pCmdNumber, static_cast< TUint8 >( 
   323     	rspV1.iGeneralResult ), additionalInfo );                            
   321     	rspV1.iGeneralResult ), additionalInfo );                            
   324 
   322 
   325     return ret;
   323     return ret;
   336         TUint8	 aPCmdNumber,		    
   334         TUint8	 aPCmdNumber,		    
   337         TUint8	 aGeneralResult,	    
   335         TUint8	 aGeneralResult,	    
   338         TDesC16&  aAdditionalInfo            
   336         TDesC16&  aAdditionalInfo            
   339 	    )    	
   337 	    )    	
   340 	{
   338 	{
   341 	TFLOGSTRING("CSAT: CSatNotifyPlayTone::CreateTerminalRespL");
   339 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYPLAYTONE_CREATETERMINALRESPL_1, "CSAT: CSatNotifyPlayTone::CreateTerminalRespL");
   342     TTlv tlvSpecificData;
   340     TTlv tlvSpecificData;
   343     tlvSpecificData.AddTag( KTlvResultTag );
   341     tlvSpecificData.AddTag( KTlvResultTag );
   344 	//General result
   342 	//General result
   345     tlvSpecificData.AddByte( aGeneralResult );
   343     tlvSpecificData.AddByte( aGeneralResult );
   346     
   344