telephonyserverplugins/simatktsy/src/CSatNotifyPollInterval.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        : CSatNotifyPollInterval.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 "CSatNotifyPollInterval.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 // -----------------------------------------------------------------------------
       
    38 // CSatNotifyPollInterval::NewL
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 //  
       
    42 CSatNotifyPollInterval* CSatNotifyPollInterval::NewL
       
    43         ( 
       
    44         CSatNotificationsTsy* aNotificationsTsy 
       
    45         )
       
    46     {
       
    47     TFLOGSTRING("CSAT: CSatNotifyPollInterval::NewL");
       
    48    	CSatNotifyPollInterval* const satNotifyPollInterval = 
       
    49         new ( ELeave ) CSatNotifyPollInterval( aNotificationsTsy );
       
    50     CleanupStack::PushL( satNotifyPollInterval );
       
    51     satNotifyPollInterval->ConstructL();
       
    52     CleanupStack::Pop( satNotifyPollInterval );
       
    53     TFLOGSTRING("CSAT: CSatNotifyPollInterval::NewL, end of method");
       
    54     return satNotifyPollInterval;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CSatNotifyPollInterval::~CSatNotifyPollInterval
       
    59 // Destructor
       
    60 // -----------------------------------------------------------------------------
       
    61 //  
       
    62 CSatNotifyPollInterval::~CSatNotifyPollInterval
       
    63         ( 
       
    64 		// None
       
    65         )
       
    66     {
       
    67     TFLOGSTRING("CSAT: CSatNotifyPollInterval::~CSatNotifyPollInterval");
       
    68     }
       
    69     
       
    70 // -----------------------------------------------------------------------------
       
    71 // CSatNotifyPollInterval::CSatNotifyPollInterval
       
    72 // Default C++ constructor
       
    73 // -----------------------------------------------------------------------------
       
    74 //  
       
    75 CSatNotifyPollInterval::CSatNotifyPollInterval
       
    76         ( 
       
    77         CSatNotificationsTsy* aNotificationsTsy 
       
    78         ) : iNotificationsTsy ( aNotificationsTsy )
       
    79     {
       
    80     // None
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSatNotifyPollInterval::ConstructL
       
    85 // Symbian 2nd phase constructor
       
    86 // -----------------------------------------------------------------------------
       
    87 //  
       
    88 void CSatNotifyPollInterval::ConstructL
       
    89         (
       
    90         // None
       
    91         )
       
    92     {
       
    93     TFLOGSTRING("CSAT: CSatNotifyPollInterval::ConstructL");
       
    94     }
       
    95     
       
    96 // -----------------------------------------------------------------------------
       
    97 // CSatNotifyPollInterval::CompleteNotifyL
       
    98 // This method completes an outstanding asynchronous 
       
    99 // PollInterval request. 
       
   100 // -----------------------------------------------------------------------------
       
   101 // 
       
   102 TInt CSatNotifyPollInterval::CompleteNotifyL
       
   103         ( 
       
   104         CSatDataPackage* aDataPackage,
       
   105         TInt /*aErrorCode*/  
       
   106         ) 
       
   107     {
       
   108     TFLOGSTRING("CSAT: CSatNotifyPollInterval::CompleteNotifyL");
       
   109     TInt returnValue( KErrNone );
       
   110     TPtrC8* data;
       
   111     aDataPackage->UnPackData( &data );
       
   112     // Get ber tlv 
       
   113     CBerTlv berTlv;
       
   114     berTlv.SetData( *data );
       
   115     CTlv commandDetails;
       
   116     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   117     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   118         commandDetails.Data() );
       
   119     // Duration of the interval
       
   120     CTlv duration;
       
   121     returnValue = berTlv.TlvByTagValue( &duration, KTlvDurationTag );
       
   122     
       
   123     TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   124     
       
   125     TUint16 anIntervalInSeconds( KDefaultPollInterval );
       
   126     
       
   127     if ( KErrNone == returnValue )
       
   128         {
       
   129         TUint8 timeIntv( duration.GetShortInfo( ETLV_TimeInterval ) );
       
   130         // Time Interval 0 is default value (25 seconds)
       
   131 		if ( 0 != timeIntv )
       
   132 			{
       
   133             iPollingIntervalRspV3.iGeneralResult = RSat::KSuccess;
       
   134             iPollingIntervalRspV3.iInfoType =  RSat::KPollingIntv;
       
   135 
       
   136             TUint8 durationTimeUnit( duration.GetShortInfo( ETLV_TimeUnit ) );
       
   137 
       
   138             switch ( durationTimeUnit )
       
   139                 {
       
   140                 case KMinutes:
       
   141                     {
       
   142                     anIntervalInSeconds = timeIntv * 60;
       
   143                     break;
       
   144                     }
       
   145                 case KSeconds:
       
   146                     {
       
   147                     anIntervalInSeconds = timeIntv;
       
   148                     break;
       
   149                     }
       
   150                 case KTenthsOfSeconds:
       
   151                     {
       
   152                     // Rounding
       
   153 	                if ( 5 >= ( timeIntv % 10 ) )
       
   154 	                    {
       
   155 	                    // If the intervals the ME can offer are equidistant
       
   156 	                    // (higher and lower) from the NAA's request, the ME 
       
   157 	                    // shall respond with the lower interval of the two.
       
   158 	                    anIntervalInSeconds = static_cast<TUint8>( 
       
   159 	                        timeIntv / 10 );
       
   160 	                    }
       
   161 	                else
       
   162 	                    {
       
   163 	                    anIntervalInSeconds = static_cast<TUint8> ( ( 
       
   164 	                        timeIntv / 10 ) + 1);
       
   165 	                    }
       
   166                     break;
       
   167                     }
       
   168                 default:
       
   169                 	{
       
   170                  	TFLOGSTRING("CSAT: CSatNotifyPollInterval::\
       
   171                  	    CompleteNotifyL, Time unit unknown.");
       
   172 	        		returnValue = KErrNotFound;
       
   173                  	// Command data not understood
       
   174                  	CreateTerminalRespL( pCmdNumber, 
       
   175                  	    RSat::KCmdDataNotUnderstood, 
       
   176                  	    RSat::KNoSpecificMeProblem, 0 );
       
   177                 	}
       
   178                 } // End of switch
       
   179         	
       
   180         	// Check interval limits
       
   181         	if ( KMinPollInterval > anIntervalInSeconds )
       
   182         	    {
       
   183         	    anIntervalInSeconds = KMinPollInterval;
       
   184         	    }
       
   185         	else if ( KMaxPollInterval < anIntervalInSeconds )
       
   186         	    {
       
   187         	    anIntervalInSeconds = KMaxPollInterval;
       
   188         	    }
       
   189 			}
       
   190         }
       
   191 	else
       
   192 		{
       
   193 		// Required values are missing
       
   194         CreateTerminalRespL( pCmdNumber, RSat::KErrorRequiredValuesMissing, 
       
   195         	RSat::KNoSpecificMeProblem, 0 );
       
   196 		}
       
   197 
       
   198     if ( KErrNone == returnValue )
       
   199 	    {
       
   200     	// A PCmd PollingOff may be executed. 	
       
   201         iNotificationsTsy->SetPollingOffStatus( EFalse );
       
   202         // Send SetPollInterval request to ISA CellMo side. The terminal response
       
   203         // will be sent to ISA CellMo side after SetPollInterval response.
       
   204         iNotificationsTsy->SetPollingIntervalL( static_cast<TUint8>( 
       
   205             anIntervalInSeconds ) );
       
   206 	    }
       
   207  
       
   208     return returnValue;
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CSatNotifyPollInterval::CreateTerminalRespL
       
   213 // Constructs PollInterval specific part of terminal response and calls 
       
   214 // DOS to send the actual message. 
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 TInt CSatNotifyPollInterval::CreateTerminalRespL
       
   218         ( 
       
   219         TUint8 aPCmdNumber,         
       
   220         TUint8 aGeneralResult,     
       
   221         TUint8 aAdditionalInfo,   
       
   222         TUint8 aDcs               	
       
   223 		)
       
   224     {
       
   225     TFLOGSTRING("CSAT: CSatNotifyPollInterval::CreateTerminalRespL");   
       
   226     TTlv tlvSpecificData;
       
   227     tlvSpecificData.AddTag( KTlvResultTag );     
       
   228     tlvSpecificData.AddByte( aGeneralResult );
       
   229     
       
   230     if ( !(iNotificationsTsy->CommandPerformedSuccessfully( 
       
   231             aGeneralResult ) ) )
       
   232         {
       
   233         switch ( aGeneralResult )
       
   234             {
       
   235             // Cases in which additional info is not required
       
   236             case RSat::KPSessionTerminatedByUser:
       
   237             case RSat::KBackwardModeRequestedByUser:
       
   238             case RSat::KNoResponseFromUser:
       
   239             case RSat::KErrorRequiredValuesMissing:
       
   240             case RSat::KHelpRequestedByUser:
       
   241                 {
       
   242                 break;
       
   243                 }
       
   244             default:
       
   245                 {
       
   246                 TFLOGSTRING2("CSAT: CSatNotifyPollInterval::\
       
   247                     CreateTerminalRespL, Additional Info: %d", 
       
   248                     aAdditionalInfo);  
       
   249                 tlvSpecificData.AddByte( aAdditionalInfo );
       
   250                 break;
       
   251                 }
       
   252             }
       
   253         }
       
   254     else 
       
   255         {
       
   256         tlvSpecificData.AddTag( KTlvDurationTag );
       
   257         tlvSpecificData.AddByte( KSeconds );
       
   258         tlvSpecificData.AddByte( aDcs );
       
   259         }
       
   260 
       
   261     // Prepare data
       
   262     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   263     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   264     // Pack data
       
   265     CSatDataPackage dataPackage;
       
   266 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   267 
       
   268     // Forward request to the DOS
       
   269     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   270 		ESatTerminalRsp, &dataPackage );
       
   271     }
       
   272 
       
   273 // End of file