telephonyserverplugins/simatktsy/src/CSatNotifyPollingOff.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Name        : CSatNotifyPollingOff.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // Polling off notification functionality of Sat Tsy
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //INCLUDES
       
    23 #include <satcs.h>                  // Etel SAT IPC definitions
       
    24 #include "CSatTsy.h"                // Tsy class header
       
    25 #include "CSatNotifyPollingOff.h"   // Tsy class header
       
    26 #include "CSatNotificationsTsy.h"   // Class header
       
    27 #include "CBerTlv.h"                // Ber Tlv data handling
       
    28 #include "TTlv.h"					// TTlv class
       
    29 #include "CSatDataPackage.h"        // Parameter packing 
       
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
       
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
       
    33 #include "cmmmessagemanagerbase.h" 	// Message manager class for forwarding req.
       
    34 #include "MSatTsy_IPCDefs.h"        // Sat Tsy internal request types
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CSatNotifyPollingOff::NewL
       
    38 // Two-phased constructor.
       
    39 // -----------------------------------------------------------------------------
       
    40 //  
       
    41 CSatNotifyPollingOff* CSatNotifyPollingOff::NewL
       
    42         ( 
       
    43         CSatNotificationsTsy* aNotificationsTsy 
       
    44         )
       
    45     {
       
    46     TFLOGSTRING("CSAT: CSatNotifyPollingOff::NewL");
       
    47    	CSatNotifyPollingOff* const satNotifyPollingOff = 
       
    48         new ( ELeave ) CSatNotifyPollingOff( aNotificationsTsy );
       
    49     CleanupStack::PushL( satNotifyPollingOff );
       
    50     satNotifyPollingOff->ConstructL();
       
    51     CleanupStack::Pop( satNotifyPollingOff );
       
    52     TFLOGSTRING("CSAT: CSatNotifyPollingOff::NewL, end of method");
       
    53     return satNotifyPollingOff;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSatNotifyPollingOff::~CSatNotifyPollingOff
       
    58 // Destructor
       
    59 // -----------------------------------------------------------------------------
       
    60 //  
       
    61 CSatNotifyPollingOff::~CSatNotifyPollingOff
       
    62         ( 
       
    63 		// None
       
    64         )
       
    65     {
       
    66     TFLOGSTRING("CSAT: CSatNotifyPollingOff::~CSatNotifyPollingOff");
       
    67     }
       
    68     
       
    69 // -----------------------------------------------------------------------------
       
    70 // CSatNotifyPollingOff::CSatNotifyPollingOff
       
    71 // Default C++ constructor
       
    72 // -----------------------------------------------------------------------------
       
    73 //  
       
    74 CSatNotifyPollingOff::CSatNotifyPollingOff
       
    75         ( 
       
    76         CSatNotificationsTsy* aNotificationsTsy 
       
    77         ) : iNotificationsTsy ( aNotificationsTsy )
       
    78     {
       
    79     // None
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CSatNotifyPollingOff::ConstructL
       
    84 // Symbian 2nd phase constructor
       
    85 // -----------------------------------------------------------------------------
       
    86 //  
       
    87 void CSatNotifyPollingOff::ConstructL
       
    88         (
       
    89         // None
       
    90         )
       
    91     {
       
    92     TFLOGSTRING("CSAT: CSatNotifyPollingOff::ConstructL");
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CSatNotifyPollingOff::CompleteNotifyL
       
    97 // This method completes an outstanding asynchronous 
       
    98 // PollingOff request. 
       
    99 // -----------------------------------------------------------------------------
       
   100 // 
       
   101 TInt CSatNotifyPollingOff::CompleteNotifyL
       
   102         ( 
       
   103         CSatDataPackage* aDataPackage,
       
   104         TInt /*aErrorCode*/  
       
   105         ) 
       
   106     {
       
   107     TFLOGSTRING("CSAT: CSatNotifyPollingOff::CompleteNotifyL");
       
   108     TPtrC8* data;
       
   109     TBuf<1> additionalInfo;
       
   110     aDataPackage->UnPackData( &data );
       
   111     // Get ber tlv 
       
   112     CBerTlv berTlv;
       
   113     berTlv.SetData( *data );
       
   114     // Get command details tlv
       
   115     CTlv commandDetails;
       
   116     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );    
       
   117     // Store command details tlv
       
   118     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   119         commandDetails.Data() );	
       
   120 	TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   121 	
       
   122     if ( !( iNotificationsTsy->PollingOffStatus() ) )
       
   123         {
       
   124         iNotificationsTsy->SetPollingOffStatus( ETrue );
       
   125         iNotificationsTsy->SetPollingIntervalL( KDefaultPollInterval );
       
   126         // Terminal response is sent when the response 
       
   127         // from SIM server is received
       
   128         }
       
   129     else
       
   130         {
       
   131         // PollingOff is already off
       
   132         additionalInfo.Zero();
       
   133         additionalInfo.Append( RSat::KNoAdditionalInfo );
       
   134         CreateTerminalRespL( pCmdNumber, RSat::KSuccess, additionalInfo );
       
   135         }
       
   136     TInt returnValue( KErrNone );
       
   137     
       
   138     return returnValue;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CSatNotifyPollingOff::CreateTerminalRespL
       
   143 // Constructs PollingOff specific part of terminal response and calls 
       
   144 // DOS to send the actual message. 
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 TInt CSatNotifyPollingOff::CreateTerminalRespL
       
   148         ( 
       
   149         TUint8  aPCmdNumber,          
       
   150         TUint8  aGeneralResult,      
       
   151         TDesC16& aAdditionalInfo            
       
   152 		)
       
   153     {
       
   154     TFLOGSTRING("CSAT: CSatNotifyPollingOff::CreateTerminalRespL");    
       
   155     
       
   156     TTlv tlvSpecificData;
       
   157     tlvSpecificData.AddTag( KTlvResultTag );
       
   158     tlvSpecificData.AddByte( aGeneralResult );
       
   159 
       
   160     if ( !( iNotificationsTsy->CommandPerformedSuccessfully( 
       
   161             aGeneralResult ) ) )
       
   162         {
       
   163         switch ( aGeneralResult )
       
   164             {
       
   165             // Cases in which additional info is not required
       
   166             case RSat::KPSessionTerminatedByUser:
       
   167             case RSat::KBackwardModeRequestedByUser:
       
   168             case RSat::KNoResponseFromUser:
       
   169             case RSat::KErrorRequiredValuesMissing:
       
   170             case RSat::KHelpRequestedByUser:
       
   171                 {
       
   172                 break;
       
   173                 }
       
   174             default:
       
   175                 {
       
   176                 TFLOGSTRING2("CSAT: CSatNotifyPollingOff::\
       
   177                     CreateTerminalRespL, Additional Info: %d", 
       
   178                     aAdditionalInfo[0]);
       
   179                 tlvSpecificData.AddByte( static_cast<TUint8>( 
       
   180                 	aAdditionalInfo[0] ) );
       
   181                 break;
       
   182                 }
       
   183             }
       
   184         }
       
   185     // Prepare data
       
   186     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   187     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   188     // Pack data
       
   189     CSatDataPackage dataPackage;
       
   190 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   191 
       
   192     // Forward request to the DOS
       
   193     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   194 		ESatTerminalRsp, &dataPackage );
       
   195     }
       
   196 
       
   197 
       
   198 // End of file