adaptationlayer/tsy/simatktsy_dll/src/satnotifications.cpp
changeset 0 63b37f68c1ce
child 5 8ccc39f9d787
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "satnotifications.h"   // sat notifications class
       
    23 #include "satmessaging.h"       // sat messaging class
       
    24 #include "satmesshandler.h"     // sat message handler class
       
    25 #include "sattimer.h"           // sat timer class
       
    26 #include "ber_tlv.h"            // sat ber-tlv classes
       
    27 #include "satutil.h"            // sat utility class
       
    28 
       
    29 #include <tisi.h>               // isi message
       
    30 #include <net_modemisi.h>       // net server
       
    31 #include <gssisi.h>             // gss server
       
    32 #include <atkisi.h>             // atk server
       
    33 #include <uiccisi.h>            // uicc server
       
    34 #include <satcs.h>
       
    35 #include "osttracedefinitions.h"
       
    36 #ifdef OST_TRACE_COMPILER_IN_USE
       
    37 #include "satnotificationstraces.h"
       
    38 #endif
       
    39 
       
    40 
       
    41 
       
    42 // CONSTANTS
       
    43 
       
    44 // Character code
       
    45 const TUint8 KPlusMarkCharacterCode                 = 0x2B;
       
    46 
       
    47 // Send SM
       
    48 const TUint8 KTPDUMandatoryFieldsSmsSubmitUdl       = 0x06;
       
    49 const TUint8 KTPDUMandatoryFieldsSmsCommandUdl      = 0x07;
       
    50 const TUint8 KTPDUMandatoryFieldsSmsSubmitDcs       = 0x05;
       
    51 const TUint8 KSmsVPFEnhanced                        = 0x01;
       
    52 const TUint8 KSmsVPFRelative                        = 0x02;
       
    53 const TUint8 KSmsVPFAbsolute                        = 0x03;
       
    54 const TUint8 KSmsVpFormatMask                       = 0x03;
       
    55 const TUint8 KSATSmsMTISubmitOrSubmitReport         = 0x01;
       
    56 const TUint8 KSmsDcsDefaultAlphabet                 = 0x00;
       
    57 const TUint8 KMinSmsTpduLength                      = 0x07;
       
    58 
       
    59 // Masks
       
    60 const TUint8 KMask0                                 = 0x00;
       
    61 const TUint8 KMask3                                 = 0x03;
       
    62 const TUint8 KMaskC0                                = 0xC0;
       
    63 const TUint8 KMaskF0                                = 0xF0;
       
    64 const TUint8 KMaskF3                                = 0xF3;
       
    65 const TUint8 KMaskFB                                = 0xFB;
       
    66 
       
    67 // Additional info
       
    68 const TUint8 KNoCause                               = 0x00;
       
    69 
       
    70 // SetUpCall
       
    71 const TUint8 KOnlyIfNotBusy                         = 0x00;
       
    72 const TUint8 KOnlyIfNotBusyWithRedial               = 0x01;
       
    73 const TUint8 KHoldOtherCalls                        = 0x02;
       
    74 const TUint8 KHoldOtherCallsWithRedial              = 0x03;
       
    75 const TUint8 KDisconnectOtherCalls                  = 0x04;
       
    76 const TUint8 KDisconnectOtherCallsWithRedial        = 0x05;
       
    77 
       
    78 // SetUpEventList
       
    79 const TUint8 KMTCall                                = 0x00;
       
    80 const TUint8 KCallConnected                         = 0x01;
       
    81 const TUint8 KCallDisconnected                      = 0x02;
       
    82 const TUint8 KLocationStatus                        = 0x03;
       
    83 const TUint8 KUserActivity                          = 0x04;
       
    84 const TUint8 KIdleScreenAvailable                   = 0x05;
       
    85 const TUint8 KCardReaderStatus                      = 0x06;
       
    86 const TUint8 KLanguageSelection                     = 0x07;
       
    87 const TUint8 KBrowserTermination                    = 0x08;
       
    88 const TUint8 KDataAvailable                         = 0x09;
       
    89 const TUint8 KChannelStatus                         = 0x0A;
       
    90 const TUint8 KAccessTechnologyChange                = 0x0B;
       
    91 const TUint8 KDisplayParamsChanges                  = 0x0C;
       
    92 const TUint8 KLocalConnection                       = 0x0D;
       
    93 
       
    94 
       
    95 // Timer management
       
    96 const TUint8 KMinTimerValue                         = 0;
       
    97 const TUint  KMaxTimerValueInSeconds                = 86400;
       
    98 
       
    99 // Launch browser
       
   100 const TUint8 KLaunchBrowserCmdQualifierNotUsed      = 0x01;
       
   101 const TUint8 KLaunchBrowserCmdQualifierReserved     = 0x04;
       
   102 const TUint8 KCsdBearer                             = 0x01;
       
   103 const TUint8 KGprsBearer                            = 0x03;
       
   104 const TUint8 KDefaultBrowser                        = 0x00;
       
   105 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
   106 const TUint8 KWMLBrowser                            = 0x01;
       
   107 const TUint8 KHTMLBrowser                           = 0x02;
       
   108 const TUint8 KXHTMLBrowser                          = 0x03;
       
   109 const TUint8 KCHTMLBrowser                          = 0x04;
       
   110 #endif
       
   111 
       
   112 // Bearer independent protocol
       
   113 const TUint8 KBipCsdBearer                          = 0x01;
       
   114 const TUint8 KBipGprsBearer                         = 0x02;
       
   115 const TUint8 KBipDefaultBearer                      = 0x03;
       
   116 const TUint8 KBipLocalLinkTechnologyIndependentBearer  = 0x04;
       
   117 const TUint8 KBipBluetoothBearer                    = 0x05;
       
   118 const TUint8 KBipIrDABearer                         = 0x06;
       
   119 const TUint8 KBipRS232Bearer                        = 0x07;
       
   120 const TUint8 KBipUSBBearer                          = 0x10;
       
   121 const TUint8 KBipSendDataImmediately                = 0x01;
       
   122 
       
   123 // Language notification
       
   124 const TUint8 KSpecificLanguage                      = 0x01;
       
   125 
       
   126 // Elementary files
       
   127 const TUint8 KRefresh1StLevelDedicatedFileHeader    = 0x7F;
       
   128 const TUint8 KRefresh2StLevelDedicatedFileHeader    = 0x5F;
       
   129 
       
   130 // SIM/ME Interface transport protocol type coding
       
   131 const TUint8 KProtocolUdp                           = 0x01;
       
   132 const TUint8 KProtocolTcp                           = 0x02;
       
   133 
       
   134 // Link Establishment
       
   135 const TUint8 KLinkEstablishmentMask                 = 0x01;
       
   136 
       
   137 // Reconnection mode
       
   138 const TUint8 KReconnectionModeMask                  = 0x02;
       
   139 
       
   140 
       
   141 // LOCAL FUNCTION PROTOTYPES
       
   142 
       
   143 // Declaration needed here for ARMV5 because method is used in Notifications
       
   144 // base, but method implementation is bit later.
       
   145 CSatNotificationsBase::TAllowedResults operator+(
       
   146     const RSat::TPCmdResult aResultA, const RSat::TPCmdResult aResultB );
       
   147 
       
   148 // ==================== MEMBER FUNCTIONS ====================================
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // CSatNotificationsBase::CSatNotificationsBase
       
   152 // C++ default constructor can NOT contain any code, that
       
   153 // might leave.
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 CSatNotificationsBase::CSatNotificationsBase
       
   157         (
       
   158         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
   159         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
   160         )
       
   161         :
       
   162         iSatMessHandler( aSatMessHandler ),
       
   163         iSatMessaging( aSatMessaging ),
       
   164         iTransId( KZero ),
       
   165         iReqHandle( NULL )
       
   166     {
       
   167     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_CSATNOTIFICATIONSBASE, "CSatNotificationsBase::CSatNotificationsBase" );
       
   168     iCommandDetails.Zero();
       
   169 
       
   170     // Following results are accepted by all commands
       
   171     iAllowedResults = RSat::KSuccess + RSat::KPartialComprehension
       
   172         + RSat::KMissingInformation + RSat::KMeUnableToProcessCmd
       
   173         + RSat::KCmdBeyondMeCapabilities + RSat::KCmdTypeNotUnderstood
       
   174         + RSat::KCmdDataNotUnderstood + RSat::KCmdNumberNotKnown;
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CSatNotificationsBase::~CSatNotificationsBase
       
   179 // Destructor
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 CSatNotificationsBase::~CSatNotificationsBase()
       
   183     {
       
   184     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFICATIONSBASE_CSATNOTIFICATIONSBASE, "CSatNotificationsBase::~CSatNotificationsBase" );
       
   185     // None
       
   186     }
       
   187 
       
   188 // -----------------------------------------------------------------------------
       
   189 // CSatNotificationsBase::CancelNotification
       
   190 // Cancels the current notification request
       
   191 // (other items were commented in a header).
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 TInt CSatNotificationsBase::CancelNotification
       
   195         (
       
   196         const TTsyReqHandle aReqHandle  // Request handle
       
   197         )
       
   198     {
       
   199     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_CANCELNOTIFICATION, "CSatNotificationsBase::CancelNotification" );
       
   200     TFLOGSTRING("TSY: CSatNotificationsBase::CancelNotification");
       
   201 
       
   202     // Check that the handle is valid
       
   203     if ( aReqHandle == iReqHandle )
       
   204         {
       
   205         iSatMessaging->ReqCompleted( aReqHandle, KErrCancel );
       
   206         }
       
   207     else
       
   208         {
       
   209         // Handle is not valid
       
   210         iSatMessaging->ReqCompleted( aReqHandle, KErrCorrupt );
       
   211         }
       
   212 
       
   213     iReqHandle = NULL;
       
   214 
       
   215     return KErrNone;
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CSatNotificationsBase::TerminalResponse
       
   220 // Handles the terminal response of a proactive command
       
   221 // (other items were commented in a header).
       
   222 // -----------------------------------------------------------------------------
       
   223 //
       
   224 TInt CSatNotificationsBase::TerminalResponse
       
   225         (
       
   226         TDes8* /* aRsp */   // Response
       
   227         )
       
   228     {
       
   229     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_TERMINALRESPONSE, "CSatNotificationsBase::TerminalResponse" );
       
   230     // Base class does not do anything
       
   231     return KErrNone;
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CSatNotificationsBase::GetCmdDetails
       
   236 // Returns a reference to member iCommandDetails
       
   237 // (other items were commented in a header).
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 TDes8& CSatNotificationsBase::GetCmdDetails()
       
   241     {
       
   242     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_GETCMDDETAILS, "CSatNotificationsBase::GetCmdDetails" );
       
   243     return iCommandDetails;
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CSatNotificationsBase::GetTransactionId
       
   248 // Returns the transaction identifier of the current PCmd.
       
   249 // This is a Nokia specific value found in ISI messages.
       
   250 // (other items were commented in a header).
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 TUint8 CSatNotificationsBase::GetTransactionId()
       
   254     {
       
   255     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_GETTRANSACTIONID, "CSatNotificationsBase::GetTransactionId" );
       
   256     return iTransId;
       
   257     }
       
   258 
       
   259 // -----------------------------------------------------------------------------
       
   260 // CSatNotificationsBase::TsyReqHandle
       
   261 // Returns the TsyReqHandle of a request
       
   262 // (other items were commented in a header).
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 TTsyReqHandle CSatNotificationsBase::TsyReqHandle()
       
   266     {
       
   267     OstTrace0( TRACE_NORMAL, CSATNOTIFICATIONSBASE_TSYREQHANDLE, "CSatNotificationsBase::TsyReqHandle" );
       
   268     return iReqHandle;
       
   269     }
       
   270 
       
   271 // -----------------------------------------------------------------------------
       
   272 // CSatNotificationsBase::CompleteRequest
       
   273 // Completes the Request notification
       
   274 // (other items were commented in a header).
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 void CSatNotificationsBase::CompleteRequest
       
   278         (
       
   279         const TInt aError   // Possible error
       
   280         )
       
   281     {
       
   282     OstTraceExt2( TRACE_NORMAL, CSATNOTIFICATIONSBASE_COMPLETEREQUEST, "CSatNotificationsBase::CompleteRequest, Handle: %d, Error: %d", (TInt)iReqHandle, aError );
       
   283     TFLOGSTRING3("CSatNotificationsBase::CompleteRequest. \n\t\t\t Handle:%d\n\t\t\t Error:%d",
       
   284                iReqHandle,
       
   285                aError);
       
   286     TTsyReqHandle tempReqHandle = iReqHandle;
       
   287     iReqHandle = NULL;
       
   288     iSatMessaging->ReqCompleted( tempReqHandle, aError );
       
   289     TFLOGSTRING("CSatNotificationsBase::CompleteRequest. Request is now completed");
       
   290     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFICATIONSBASE_COMPLETEREQUEST, "CSatNotificationsBase::CompleteRequest. Request is now completed" );
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CSatNotificationsBase::TAllowedResults::TAllowedResults
       
   295 // C++ default constructor of the nested class.
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 CSatNotificationsBase::TAllowedResults::TAllowedResults() : iResultField( 0 )
       
   299     {
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // TBool CSatNotificationsBase::TAllowedResults::operator==
       
   304 // The equality operator (==) for TAllowedResults
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 TBool CSatNotificationsBase::TAllowedResults::operator==
       
   308         (
       
   309         const RSat::TPCmdResult aResult
       
   310         ) const
       
   311     {
       
   312     // Create mask from result for comparation
       
   313     TAllowedResults mask;
       
   314     mask = aResult;
       
   315 
       
   316     // Compare with bit-wise AND operation
       
   317     TBool match( iResultField & mask.iResultField );
       
   318 
       
   319     // Unfortunately AND operator does not seem to work if the mask contains a
       
   320     // value in the high order 32 bits of a 64 bit number. This case has to be
       
   321     // checked with following macro.
       
   322     if ( I64HIGH( mask.iResultField ) )
       
   323         {
       
   324         // Mask value is in the high order of the number so compare these.
       
   325         match = I64HIGH( iResultField ) & I64HIGH( mask.iResultField );
       
   326         }
       
   327 
       
   328     // Open System Trace doesn't support tracing in nested classes
       
   329     TFLOGSTRING3( "TAllowedResults::operator==: Bit Field: %08x %08x",
       
   330         I64HIGH( iResultField ), I64LOW( iResultField ) );
       
   331     TFLOGSTRING2( "TAllowedResults::operator==: Match: %d",
       
   332         ( match ? 1 : 0 ) );
       
   333 
       
   334     return match;
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CSatNotificationsBase::TAllowedResults::operator!=
       
   339 // The not-equal operator (!=) for TAllowedResults.
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 TBool CSatNotificationsBase::TAllowedResults::operator!=
       
   343         (
       
   344         const RSat::TPCmdResult aResult
       
   345         ) const
       
   346     {
       
   347     // Return the value of equals-operation (==) as inverted.
       
   348     return !( *this == aResult );
       
   349     }
       
   350 
       
   351 // -----------------------------------------------------------------------------
       
   352 // CSatNotificationsBase::TAllowedResults::operator=
       
   353 // The assignment operator (=) for TAllowedResults
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 CSatNotificationsBase::TAllowedResults&
       
   357     CSatNotificationsBase::TAllowedResults::operator=
       
   358         (
       
   359         const RSat::TPCmdResult aResult
       
   360         )
       
   361     {
       
   362     // Convert result to bit field and assing internal field to it.
       
   363     iResultField = CreateBitField( aResult );
       
   364 
       
   365     // Return reference to this
       
   366     return *this;
       
   367     }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CSatNotificationsBase::operator+=
       
   371 // The increment operator (+=) for TAllowedResults.
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 CSatNotificationsBase::TAllowedResults&
       
   375     CSatNotificationsBase::TAllowedResults::operator+=
       
   376         (
       
   377         const RSat::TPCmdResult aResult
       
   378         )
       
   379     {
       
   380     // Append result to bit field by calling approriate plus operator
       
   381     // and return reference to this
       
   382     return *this = *this + aResult;
       
   383     }
       
   384 
       
   385 // -----------------------------------------------------------------------------
       
   386 // CSatNotificationsBase::operator+=
       
   387 // The increment operator (+=) for TAllowedResults.
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 CSatNotificationsBase::TAllowedResults&
       
   391     CSatNotificationsBase::TAllowedResults::operator+=
       
   392         (
       
   393         const CSatNotificationsBase::TAllowedResults aResults
       
   394         )
       
   395     {
       
   396     // Append result fields together
       
   397     iResultField = iResultField | aResults.iResultField;
       
   398 
       
   399     // Return reference to this
       
   400     return *this;
       
   401     }
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // CSatNotificationsBase::TAllowedResults::operator+
       
   405 // The increment operator (+) for TAllowedResults.
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 CSatNotificationsBase::TAllowedResults&
       
   409     CSatNotificationsBase::TAllowedResults::operator+
       
   410         (
       
   411         const RSat::TPCmdResult aResult
       
   412         )
       
   413     {
       
   414     // Convert to bit field and append to result field.
       
   415     iResultField = iResultField | CreateBitField( aResult );
       
   416 
       
   417     // Return reference to this
       
   418     return *this;
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // operator+
       
   423 // Friend increment operator (+) for adding two TPCmdResults together as
       
   424 // bitfield.
       
   425 // -----------------------------------------------------------------------------
       
   426 //
       
   427 CSatNotificationsBase::TAllowedResults operator+
       
   428         (
       
   429         const RSat::TPCmdResult aResultA,
       
   430         const RSat::TPCmdResult aResultB
       
   431         )
       
   432     {
       
   433     // Create temporary bit field and append values into it.
       
   434     // Because internal TAllowedResults is used, this method is declared as a
       
   435     // friend
       
   436     CSatNotificationsBase::TAllowedResults temp;
       
   437 
       
   438     temp = aResultA;
       
   439     temp += aResultB;
       
   440 
       
   441     return temp;
       
   442     }
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CSatNotificationsBase::CreateBitField
       
   446 // Converts result code into bitfield representation.
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 inline TUint64
       
   450     CSatNotificationsBase::TAllowedResults::CreateBitField
       
   451         (
       
   452         const RSat::TPCmdResult aResult
       
   453         ) const
       
   454     {
       
   455     // Create a bitfield from a result by shifting '1' to the left.
       
   456     // Number of shifts depend on the result number:
       
   457     // ...0000 0001 = KSuccess (0x00)
       
   458     // ...0000 0010 = KPartialComprehension(0x01)
       
   459     // ...0001 0000 = KSuccessRequestedIconNotDisplayed(0x04)
       
   460     // and so forth.
       
   461 
       
   462     return static_cast<TInt64>( 1 ) << ( aResult );
       
   463     }
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CSatNotifyDisplayText::CSatNotifyDisplayText
       
   467 // C++ default constructor can NOT contain any code, that
       
   468 // might leave.
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 CSatNotifyDisplayText::CSatNotifyDisplayText
       
   472         (
       
   473         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
   474         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
   475         )
       
   476         :
       
   477         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
   478         iDisplayTextV2Pckg( NULL )
       
   479     {
       
   480     OstTrace0( TRACE_NORMAL, CSATNOTIFYDISPLAYTEXT_CSATNOTIFYDISPLAYTEXT, "CSatNotifyDisplayText::CSatNotifyDisplayText" );
       
   481     // Following results are also allowed for this command:
       
   482     // (in addition to result declared in base class constructor)
       
   483     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
   484         + RSat::KPSessionTerminatedByUser + RSat::KBackwardModeRequestedByUser
       
   485         + RSat::KNoResponseFromUser + RSat::KErrorRequiredValuesMissing;
       
   486     }
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // CSatNotifyDisplayText::~CSatNotifyDisplayText
       
   490 // Destructor
       
   491 // -----------------------------------------------------------------------------
       
   492 //
       
   493 CSatNotifyDisplayText::~CSatNotifyDisplayText()
       
   494     {
       
   495     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYDISPLAYTEXT_CSATNOTIFYDISPLAYTEXT, "CSatNotifyDisplayText::~CSatNotifyDisplayText" );
       
   496     // None
       
   497     }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CSatNotifyDisplayText::MessageReceived
       
   501 // Handles a DisplayText proactive command ISI message,
       
   502 // and completes a pending ETel request.
       
   503 // (other items were commented in a header).
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 void CSatNotifyDisplayText::MessageReceived( const TIsiReceiveC& aIsiMessage )
       
   507     {
       
   508     OstTrace0( TRACE_NORMAL, CSATNOTIFYDISPLAYTEXT_MESSAGERECEIVED, "CSatNotifyDisplayText::MessageReceived" );
       
   509     TFLOGSTRING("TSY: CSatNotifyDisplayText::MessageReceived");
       
   510     // Completion return value
       
   511     TInt ret( KErrNone );
       
   512     // Get ber tlv
       
   513     CBerTlv berTlv;
       
   514     berTlv.BerTlv( aIsiMessage );
       
   515     // Get command details tlv
       
   516     CTlv commandDetails;
       
   517     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   518     // Store command details tlv
       
   519     iCommandDetails.Copy( commandDetails.Data() );
       
   520     // Get command qualifier
       
   521     TUint8 cmdQualifier(
       
   522         commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
   523     // Save ISA/CellMo transaction id
       
   524     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
   525     // Test if pending request
       
   526     if ( !iReqHandle )
       
   527         {
       
   528         TFLOGSTRING("TSY: CSatNotifyDisplayText::MessageReceived - Request Off");
       
   529         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYDISPLAYTEXT_MESSAGERECEIVED, "CSatNotifyDisplayText::MessageReceived - Request Off" );
       
   530 
       
   531         // Request not on, returning response immediately
       
   532         iSatMessHandler->DisplayTextTerminalResp(
       
   533             iTransId,                       // Transaction id
       
   534             iCommandDetails,                // Command details tlv
       
   535             RSat::KMeUnableToProcessCmd,    // Result
       
   536             RSat::KNoAdditionalInfo );      // Additional info
       
   537         }
       
   538     else
       
   539         {
       
   540         // Pending request, adapts the PCmd ISI message.
       
   541         // Let's fill the display text structure
       
   542         RSat::TDisplayTextV2& displayTextV2 = ( *iDisplayTextV2Pckg )();
       
   543         // Store command number
       
   544         displayTextV2.SetPCmdNumber(
       
   545             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   546         // Priority scheme
       
   547         if ( KPriorityMask & cmdQualifier )
       
   548             {
       
   549             // Display priority high
       
   550             displayTextV2.iPriority = RSat::EHighPriority;
       
   551             }
       
   552         else
       
   553             {
       
   554             // Display priority normal
       
   555             displayTextV2.iPriority = RSat::ENormalPriority;
       
   556             }
       
   557         // Clearing scheme
       
   558         if ( KMessageClearMask & cmdQualifier)
       
   559             {
       
   560             // Wait for user to clear the message
       
   561             displayTextV2.iClearScreenTrigger = RSat::EUserClear;
       
   562             }
       
   563         else
       
   564             {
       
   565             // Clear message after a delay
       
   566             displayTextV2.iClearScreenTrigger = RSat::EClearAfterDelay;
       
   567             }
       
   568         // Immediate response TLV
       
   569         CTlv immediateResponse;
       
   570         TInt returnValue( berTlv.TlvByTagValue(
       
   571             &immediateResponse,
       
   572             KTlvImmediateResponseTag ) );
       
   573         if ( KErrNotFound != returnValue )
       
   574             {
       
   575             // Respond immediately
       
   576             displayTextV2.iImmediateRsp = RSat::EImmediateRsp;
       
   577             }
       
   578         else
       
   579             {
       
   580             // Do not respond immediately
       
   581             displayTextV2.iImmediateRsp = RSat::ENoImmediateRsp;
       
   582             }
       
   583         // Text to display TLV
       
   584         displayTextV2.iText.Zero();
       
   585         CTlv textString;
       
   586         returnValue = berTlv.TlvByTagValue( &textString,
       
   587             KTlvTextStringTag );
       
   588         if ( KErrNone == returnValue )
       
   589             {
       
   590             // Check if Icon Id found
       
   591             // Iconid (optional)
       
   592             TSatUtility::FillIconStructure(
       
   593                 berTlv, displayTextV2.iIconId );
       
   594 
       
   595             // Text string tag is found, now
       
   596             // check if the text string is null.
       
   597             if ( textString.GetLength() )
       
   598                 {
       
   599                 // Convert and set text
       
   600                 TSatUtility::SetText( textString, displayTextV2.iText );
       
   601                 }
       
   602             else if ( RSat::ENoIconId != displayTextV2.iIconId.iQualifier )
       
   603                 {
       
   604                 // Text string is a null data object and there is icon qualifier
       
   605                 // presented
       
   606                 // Return terminal response immediately.
       
   607                 iSatMessHandler->DisplayTextTerminalResp(
       
   608                     iTransId,           // Transaction id
       
   609                     iCommandDetails,                    // Command details TLV
       
   610                     RSat::KCmdDataNotUnderstood,        // Result
       
   611                     KNoCause );                         // Additional info
       
   612                 ret = KErrCorrupt;
       
   613                 }
       
   614             }
       
   615         else
       
   616             {
       
   617             iSatMessHandler->DisplayTextTerminalResp(
       
   618                 iTransId,                           // Transaction id
       
   619                 iCommandDetails,                    // Command details TLV
       
   620                 RSat::KErrorRequiredValuesMissing,  // Result
       
   621                 KNoCause );                         // Additional info
       
   622             ret = KErrCorrupt;
       
   623             }
       
   624         // Duration,( optional ) see 3GPP TS 31.111
       
   625         TSatUtility::FillDurationStructure(
       
   626             berTlv, displayTextV2.iDuration );
       
   627 
       
   628         CompleteRequest( ret );
       
   629         }
       
   630     }
       
   631 
       
   632 // -----------------------------------------------------------------------------
       
   633 // CSatNotifyDisplayTextNotify
       
   634 // An ETel SAT client can call this method via ETel server to set a pending
       
   635 // request in SimAtkTsy for a DisplayText PCmd.
       
   636 // (other items were commented in a header).
       
   637 // -----------------------------------------------------------------------------
       
   638 //
       
   639 void CSatNotifyDisplayText::Notify
       
   640         (
       
   641         const TTsyReqHandle aReqHandle, // Request handle
       
   642         TDes8*              aDataPtr    // Pointer to data
       
   643         )
       
   644     {
       
   645     OstTrace1( TRACE_NORMAL, CSATNOTIFYDISPLAYTEXT_NOTIFY, "CSatNotifyDisplayText::Notify Handle: %u", aReqHandle );
       
   646     TFLOGSTRING2("CSatNotifyDisplayText::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
   647                aReqHandle );
       
   648     iReqHandle = aReqHandle;
       
   649     iDisplayTextV2Pckg = static_cast< RSat::TDisplayTextV2Pckg* >( aDataPtr );
       
   650     iSatMessaging->SatReady( KDisplayText );
       
   651     }
       
   652 
       
   653 // -----------------------------------------------------------------------------
       
   654 // CSatNotifyDisplayText::TerminalResponse
       
   655 // Handles a DisplayText terminal response provided by an ETel SAT client via
       
   656 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
   657 // (other items were commented in a header).
       
   658 // -----------------------------------------------------------------------------
       
   659 //
       
   660 TInt CSatNotifyDisplayText::TerminalResponse
       
   661         (
       
   662         TDes8* aRsp     // Response
       
   663         )
       
   664     {
       
   665     OstTrace0( TRACE_NORMAL, CSATNOTIFYDISPLAYTEXT_TERMINALRESPONSE, "CSatNotifyDisplayText::TerminalResponse" );
       
   666     TFLOGSTRING("CSatNotifyDisplayText::TerminalResponse");
       
   667     // Completion return value
       
   668     TInt   ret( KErrNone );
       
   669     // Additional info
       
   670     TUint8 additionalInfo( 0 );
       
   671     // Cast the input parameter to EtelSat data structure
       
   672     RSat::TDisplayTextRspV1Pckg* aRspPckg =
       
   673             reinterpret_cast<RSat::TDisplayTextRspV1Pckg*>( aRsp );
       
   674     RSat::TDisplayTextRspV1& rspV1 = ( *aRspPckg ) ();
       
   675     // Check that general result value is valid
       
   676 
       
   677     if ( iAllowedResults != rspV1.iGeneralResult )
       
   678         {
       
   679         // Invalid general result
       
   680         ret = KErrCorrupt;
       
   681         }
       
   682 
       
   683     // If there is Me (Mobile Equipment) error, additional info is needed
       
   684     if ( ( RSat::KMeProblem == rspV1.iInfoType ) )
       
   685         {
       
   686         // Check the length of additional info
       
   687         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
   688             {
       
   689             additionalInfo = static_cast<TUint8>( rspV1.iAdditionalInfo[0] );
       
   690             }
       
   691         else
       
   692             {
       
   693             // Invalid additional info field
       
   694             ret = KErrCorrupt;
       
   695             }
       
   696         }
       
   697     // Prepare and send the terminal response to ISA/CellMo sw.
       
   698     iSatMessHandler->DisplayTextTerminalResp(
       
   699         iTransId,                                     // Transaction id
       
   700         iCommandDetails,                             // Command details tlv
       
   701         static_cast< TUint8 >( rspV1.iGeneralResult ),  // Result
       
   702         additionalInfo );                            // Additional info
       
   703     // return completion value.
       
   704     return ret;
       
   705 
       
   706     }
       
   707 
       
   708 
       
   709 // -----------------------------------------------------------------------------
       
   710 // CSatNotifyGetInkey::CSatNotifyGetInkey
       
   711 // C++ default constructor can NOT contain any code, that
       
   712 // might leave.
       
   713 // -----------------------------------------------------------------------------
       
   714 //
       
   715 CSatNotifyGetInkey::CSatNotifyGetInkey
       
   716         (
       
   717         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
   718         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
   719         )
       
   720         :
       
   721         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
   722         iGetInkeyV2Pckg( NULL )
       
   723     {
       
   724     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINKEY_CSATNOTIFYGETINKEY, "CSatNotifyGetInkey::CSatNotifyGetInkey" );
       
   725     // Following results are also allowed for this command:
       
   726     // (in addition to result declared in base class constructor)
       
   727     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
   728         + RSat::KPSessionTerminatedByUser + RSat::KBackwardModeRequestedByUser
       
   729         + RSat::KNoResponseFromUser + RSat::KHelpRequestedByUser
       
   730         + RSat::KErrorRequiredValuesMissing;
       
   731     }
       
   732 
       
   733 // -----------------------------------------------------------------------------
       
   734 // CSatNotifyGetInkey::~CSatNotifyGetInkey
       
   735 // Destructor
       
   736 // -----------------------------------------------------------------------------
       
   737 //
       
   738 CSatNotifyGetInkey::~CSatNotifyGetInkey()
       
   739     {
       
   740     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYGETINKEY_CSATNOTIFYGETINKEY, "CSatNotifyGetInkey::~CSatNotifyGetInkey" );
       
   741     // None
       
   742     }
       
   743 
       
   744 // -----------------------------------------------------------------------------
       
   745 // CSatNotifyGetInkey::MessageReceived
       
   746 // Handles a GetInkey proactive command ISI message,
       
   747 // and completes a pending ETel request.
       
   748 // (other items were commented in a header).
       
   749 // -----------------------------------------------------------------------------
       
   750 //
       
   751 void CSatNotifyGetInkey::MessageReceived
       
   752         (
       
   753         const TIsiReceiveC& aIsiMessage // ISI message
       
   754         )
       
   755     {
       
   756     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINKEY_MESSAGERECEIVED, "CSatNotifyGetInkey::MessageReceived" );
       
   757     TFLOGSTRING( "TSY: CSatNotifyGetInkey::MessageReceived" );
       
   758 
       
   759     // Completion return value
       
   760     TInt ret( KErrNone );
       
   761 
       
   762     // Get ber tlv
       
   763     CBerTlv berTlv;
       
   764     berTlv.BerTlv( aIsiMessage );
       
   765 
       
   766     // Get command details
       
   767     CTlv cmdDetails;
       
   768     berTlv.TlvByTagValue( &cmdDetails, KTlvCommandDetailsTag );
       
   769     iCommandDetails.Copy( cmdDetails.Data() );
       
   770 
       
   771     // Save ISA/CellMo transaction id
       
   772     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
   773 
       
   774     // Get command qualifier
       
   775     TUint8 cmdQualifier( cmdDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
   776 
       
   777     // Test if pending request
       
   778     if ( !iReqHandle )
       
   779         {
       
   780         RSat::TGetInkeyRspV2 error;
       
   781         error.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
   782         error.iInfoType = RSat::KNoAdditionalInfo;
       
   783 
       
   784         iSatMessHandler->GetInkeyTerminalResp(
       
   785             iTransId,                    // Transaction Id
       
   786             iCommandDetails,             // Command details
       
   787             error                        // Error result
       
   788             );
       
   789         }
       
   790     else
       
   791         {
       
   792         // Fill the get inkey structure
       
   793         RSat::TGetInkeyV2& getInkeyV2 = ( *iGetInkeyV2Pckg )();
       
   794 
       
   795         // Store command number
       
   796         getInkeyV2.SetPCmdNumber(
       
   797             cmdDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   798         // Transfer command qualifier parameter to ETelSat data structure
       
   799         if ( KYesNoMask & cmdQualifier )
       
   800             {
       
   801             // The character set bits are disabled and yes/no response
       
   802             // is requested
       
   803             getInkeyV2.iRspFormat = RSat::EYesNo;
       
   804             }
       
   805         else
       
   806             {
       
   807             // The character set bits are enabled
       
   808             if ( KAlphabetMask & cmdQualifier )
       
   809                 {
       
   810                 // Character set selected
       
   811                 if ( KUCS2AlphabetMask & cmdQualifier )
       
   812                     {
       
   813                     // UCS2 alphabet selected
       
   814                     getInkeyV2.iRspFormat = RSat::ECharUcs2Alphabet;
       
   815                     }
       
   816                 else
       
   817                     {
       
   818                     // SMS default alphabet selected
       
   819                     getInkeyV2.iRspFormat = RSat::ECharSmsDefaultAlphabet;
       
   820                     }
       
   821                 }
       
   822             else
       
   823             {
       
   824             // Digits only selected
       
   825             getInkeyV2.iRspFormat = RSat::EDigitOnly;
       
   826             }
       
   827 
       
   828         }
       
   829         // Help information.
       
   830         if ( KHelpAvailabilityMask & cmdQualifier )
       
   831             {
       
   832             // Help information available
       
   833             getInkeyV2.iHelp = RSat::EHelpAvailable;
       
   834             }
       
   835         else
       
   836             {
       
   837             // No help
       
   838             getInkeyV2.iHelp = RSat::ENoHelpAvailable;
       
   839             }
       
   840         // Response Mode
       
   841         getInkeyV2.iMode = RSat::EGetInkeyRspModeNotSet;
       
   842         if ( KImmediateDigitResponse & cmdQualifier )
       
   843             {
       
   844             // an immediate digit response (0-9, * and #) is requested.
       
   845             getInkeyV2.iMode = RSat::EImmediateDigitRsp;
       
   846             }
       
   847         else
       
   848             {
       
   849             getInkeyV2.iMode = RSat::EUserRspDisplayed;
       
   850             }
       
   851         // Get Inkey text
       
   852         CTlv textString;
       
   853         if ( KErrNone == berTlv.TlvByTagValue(
       
   854                 &textString, KTlvTextStringTag ) )
       
   855             {
       
   856             // Convert and set text
       
   857             TSatUtility::SetText( textString, getInkeyV2.iText );
       
   858             }
       
   859         else
       
   860             {
       
   861             RSat::TGetInkeyRspV2 error;
       
   862             error.iGeneralResult = RSat::KErrorRequiredValuesMissing;
       
   863             error.iInfoType = RSat::KNoAdditionalInfo;
       
   864 
       
   865             iSatMessHandler->GetInkeyTerminalResp(
       
   866                 iTransId,                           // Transaction id
       
   867                 iCommandDetails,                    // Command details TLV
       
   868                 error );                            // Error Result
       
   869             ret = KErrCorrupt;
       
   870             }
       
   871         // IconId Optional
       
   872         TSatUtility::FillIconStructure( berTlv,
       
   873             getInkeyV2.iIconId );
       
   874         // Duration
       
   875         TSatUtility::FillDurationStructure( berTlv,
       
   876             getInkeyV2.iDuration );
       
   877         // Complete request to Etel
       
   878         CompleteRequest( ret );
       
   879         }
       
   880     }
       
   881 
       
   882 // -----------------------------------------------------------------------------
       
   883 // CSatNotifyGetInkey::Notify
       
   884 // An ETel SAT client can call this method via ETel server to set a pending
       
   885 // request in SimAtkTsy for a GetInkey PCmd.
       
   886 // (other items were commented in a header).
       
   887 // -----------------------------------------------------------------------------
       
   888 //
       
   889 void CSatNotifyGetInkey::Notify
       
   890         (
       
   891         const TTsyReqHandle aReqHandle, // Request handle
       
   892         TDes8*              aDataPtr    // Pointer to data
       
   893         )
       
   894     {
       
   895     OstTrace1( TRACE_NORMAL, CSATNOTIFYGETINKEY_NOTIFY, "CSatNotifyGetInkey::Notify Handle: %u", aReqHandle );
       
   896     TFLOGSTRING2( "TSY: CSatNotifyGetInkey::Notify. Handle: %d", aReqHandle );
       
   897 
       
   898     iReqHandle = aReqHandle;
       
   899     iGetInkeyV2Pckg = static_cast< RSat::TGetInkeyV2Pckg* >( aDataPtr );
       
   900     iSatMessaging->SatReady( KGetInkey );
       
   901     }
       
   902 
       
   903 
       
   904 // -----------------------------------------------------------------------------
       
   905 // CSatNotifyGetInkey::TerminalResponse
       
   906 // Handles a GetInkey terminal response provided by an ETel SAT client via
       
   907 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
   908 // (other items were commented in a header).
       
   909 // -----------------------------------------------------------------------------
       
   910 //
       
   911 TInt CSatNotifyGetInkey::TerminalResponse
       
   912         (
       
   913         TDes8* aRsp // Response packet from ETel
       
   914         )
       
   915     {
       
   916     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINKEY_TERMINALRESPONSE, "CSatNotifyGetInkey::TerminalResponse" );
       
   917     TFLOGSTRING("TSY: CSatNotifyGetInkey::TerminalResponse" );
       
   918 
       
   919     TInt ret( KErrNone );
       
   920 
       
   921     RSat::TGetInkeyRspV2Pckg& aRspPckg =
       
   922             reinterpret_cast<RSat::TGetInkeyRspV2Pckg&>( *aRsp );
       
   923     RSat::TGetInkeyRspV2& rspV2 = aRspPckg();
       
   924 
       
   925     // Checking that infotype is valid
       
   926     switch ( rspV2.iInfoType )
       
   927         {
       
   928         case RSat::KMeProblem:
       
   929         case RSat::KTextString:
       
   930             {
       
   931             if ( !rspV2.iAdditionalInfo.Length() )
       
   932                 {
       
   933                 // These info types require additional info
       
   934                 ret = KErrCorrupt;
       
   935                 }
       
   936             break;
       
   937             }
       
   938         case RSat::KNoAdditionalInfo:
       
   939             {
       
   940             if ( rspV2.iAdditionalInfo.Length() )
       
   941                 {
       
   942                 // For this type, AI shouldn't be present
       
   943                 ret = KErrCorrupt;
       
   944                 }
       
   945             break;
       
   946             }
       
   947         default:
       
   948             {
       
   949             // Unexpected value
       
   950             ret = KErrCorrupt;
       
   951             break;
       
   952             }
       
   953         }
       
   954 
       
   955     // Checking that the response type is valid
       
   956     switch ( rspV2.iRspFormat )
       
   957         {
       
   958         case RSat::EDigitOnly:
       
   959         case RSat::ECharSmsDefaultAlphabet:
       
   960         case RSat::ECharUcs2Alphabet:
       
   961         case RSat::EYesNo:
       
   962             {
       
   963             // Ok
       
   964             break;
       
   965             }
       
   966         default:
       
   967             {
       
   968             // Unexpected value
       
   969             ret = KErrCorrupt;
       
   970             break;
       
   971             }
       
   972         }
       
   973 
       
   974     // Check that general result value is valid
       
   975     if ( iAllowedResults != rspV2.iGeneralResult )
       
   976         {
       
   977         // Unexpected value
       
   978         ret = KErrCorrupt;
       
   979         }
       
   980 
       
   981     if ( ( RSat::ETimeUnitNotSet == rspV2.iDuration.iTimeUnit ) )
       
   982         {
       
   983         // Time should have been initialized
       
   984         ret = KErrCorrupt;
       
   985         }
       
   986 
       
   987     iSatMessHandler->GetInkeyTerminalResp(
       
   988         iTransId,                                  // Transaction id
       
   989         iCommandDetails,                           // Command details
       
   990         rspV2 );                                   // Response data
       
   991 
       
   992     return ret;
       
   993     }
       
   994 
       
   995 
       
   996 // -----------------------------------------------------------------------------
       
   997 // CSatNotifyGetInput::CSatNotifyGetInput
       
   998 // C++ default constructor can NOT contain any code, that
       
   999 // might leave.
       
  1000 // -----------------------------------------------------------------------------
       
  1001 //
       
  1002 CSatNotifyGetInput::CSatNotifyGetInput
       
  1003         (
       
  1004         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  1005         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  1006         )
       
  1007         :
       
  1008         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  1009         iGetInputV1Pckg( NULL )
       
  1010     {
       
  1011     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINPUT_CSATNOTIFYGETINPUT, "CSatNotifyGetInput::CSatNotifyGetInput" );
       
  1012     // Following results are also allowed for this command:
       
  1013     // (in addition to result declared in base class constructor)
       
  1014     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  1015         + RSat::KPSessionTerminatedByUser + RSat::KBackwardModeRequestedByUser
       
  1016         + RSat::KNoResponseFromUser + RSat::KHelpRequestedByUser
       
  1017         + RSat::KErrorRequiredValuesMissing;
       
  1018     }
       
  1019 
       
  1020 // -----------------------------------------------------------------------------
       
  1021 // CSatNotifyGetInput::~CSatNotifyGetInput
       
  1022 // Destructor
       
  1023 // -----------------------------------------------------------------------------
       
  1024 //
       
  1025 CSatNotifyGetInput::~CSatNotifyGetInput()
       
  1026     {
       
  1027     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYGETINPUT_CSATNOTIFYGETINPUT, "CSatNotifyGetInput::~CSatNotifyGetInput" );
       
  1028     // None
       
  1029     }
       
  1030 
       
  1031 // -----------------------------------------------------------------------------
       
  1032 // CSatNotifyGetInput::MessageReceived
       
  1033 // Handles a GetInput proactive command ISI message,
       
  1034 // and completes a pending ETel request.
       
  1035 // (other items were commented in a header).
       
  1036 // -----------------------------------------------------------------------------
       
  1037 //
       
  1038 void CSatNotifyGetInput::MessageReceived
       
  1039         (
       
  1040         const TIsiReceiveC& aIsiMessage // ISI message
       
  1041         )
       
  1042     {
       
  1043     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINPUT_MESSAGERECEIVED, "CSatNotifyGetInput::MessageReceived" );
       
  1044     TFLOGSTRING("CSatNotifyGetInput::MessageReceived");
       
  1045     TInt ret( KErrNone );
       
  1046     // Get ber tlv
       
  1047     CBerTlv berTlv;
       
  1048     berTlv.BerTlv( aIsiMessage );
       
  1049     // Get command details tlv
       
  1050     CTlv commandDetails;
       
  1051     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  1052     // Store command details tlv
       
  1053     iCommandDetails.Copy( commandDetails.Data() );
       
  1054     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  1055     if ( !iReqHandle )
       
  1056         {
       
  1057         TBuf<1> emptyString;
       
  1058         // Request not on, returning response immediately
       
  1059         iSatMessHandler->GetInputTerminalResp(
       
  1060             iTransId,                          // Transaction id
       
  1061             iCommandDetails,                    // Command details tlv
       
  1062             RSat::KMeUnableToProcessCmd,        // Result
       
  1063             KNoCause,                           // Additional info, KNoCause: 0
       
  1064             emptyString,                        // No string
       
  1065             RSat::ESmsDefaultAlphabetUnpacked );// data coding scheme
       
  1066 
       
  1067         }
       
  1068     else
       
  1069         {
       
  1070         // Fill the get input structure
       
  1071         RSat::TGetInputV1& getInputV1 = ( *iGetInputV1Pckg )();
       
  1072         // Store command number
       
  1073         getInputV1.SetPCmdNumber(
       
  1074             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  1075         // Get command qualifier
       
  1076         TUint8 cmdQualifier(
       
  1077             commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  1078         // First comes the user input display option
       
  1079         if ( KUserInputMask & cmdQualifier )
       
  1080             {
       
  1081             // User input hidden
       
  1082             getInputV1.iInputDisplayOption = RSat::EHideUserInput;
       
  1083             }
       
  1084         else
       
  1085             {
       
  1086             // User input shown
       
  1087             getInputV1.iInputDisplayOption = RSat::EDisplayUserInput;
       
  1088             }
       
  1089         // Next the response format expected
       
  1090         if ( KUCS2AlphabetMask & cmdQualifier )
       
  1091             {
       
  1092             getInputV1.iRspFormat = RSat::EUcs2Alphabet;
       
  1093             }
       
  1094         else if ( KAlphabetMask & cmdQualifier )
       
  1095             {
       
  1096             if ( KGetInputSmsPackedMask & cmdQualifier )
       
  1097                 {
       
  1098                 // SMS default alphabet
       
  1099                 getInputV1.iRspFormat = RSat::ESmsDefaultAlphabetPacked;
       
  1100                 }
       
  1101             else
       
  1102                 {
       
  1103                 getInputV1.iRspFormat = RSat::ESmsDefaultAlphabetUnpacked;
       
  1104                 }
       
  1105             }
       
  1106         else
       
  1107             {
       
  1108             if  ( KGetInputSmsPackedMask & cmdQualifier )
       
  1109                 {
       
  1110                 // Digit only
       
  1111                 getInputV1.iRspFormat = RSat::EDigitOnlyPacked;
       
  1112                 }
       
  1113             else
       
  1114                 {
       
  1115                 getInputV1.iRspFormat = RSat::EDigitOnlyUnpacked;
       
  1116                 }
       
  1117             }
       
  1118         // Help information.
       
  1119         if ( KHelpAvailabilityMask & cmdQualifier )
       
  1120             {
       
  1121             // Help information available
       
  1122             getInputV1.iHelp = RSat::EHelpAvailable;
       
  1123             }
       
  1124         else
       
  1125             {
       
  1126             // No help
       
  1127             getInputV1.iHelp = RSat::ENoHelpAvailable;
       
  1128             }
       
  1129 
       
  1130         // Get Input text
       
  1131         getInputV1.iText.Zero();
       
  1132         CTlv textString;
       
  1133         TInt returnValue( berTlv.TlvByTagValue( &textString,
       
  1134                                                 KTlvTextStringTag ) );
       
  1135          if ( KErrNone == returnValue )
       
  1136             {
       
  1137             // Set and conver text
       
  1138             TSatUtility::SetText( textString, getInputV1.iText );
       
  1139             }
       
  1140         else
       
  1141             {
       
  1142             TBuf<1> emptyString;
       
  1143             iSatMessHandler->GetInputTerminalResp(
       
  1144                 iTransId,                           // Transaction id
       
  1145                 iCommandDetails,                    // Command details tlv
       
  1146                 RSat::KErrorRequiredValuesMissing,  // Result
       
  1147                 KNoCause,                           // KNoCause: 0
       
  1148                 emptyString,                        // No string
       
  1149                 RSat::ESmsDefaultAlphabetUnpacked );// Data coding scheme
       
  1150 
       
  1151             ret = KErrCorrupt;
       
  1152             }
       
  1153         TFLOGSTRING2("TSY: GetInput, text: %S", &getInputV1.iText );
       
  1154         OstTraceExt1( TRACE_NORMAL, DUP1_CSATNOTIFYGETINPUT_MESSAGERECEIVED, "CSatNotifyGetInput::MessageReceived GetInput, text: %S", getInputV1.iText );
       
  1155 
       
  1156         // Response length expected
       
  1157         CTlv responseLength;
       
  1158         returnValue = berTlv.TlvByTagValue( &responseLength,
       
  1159                                             KTlvResponseLengthTag );
       
  1160         if ( KErrNone == returnValue )
       
  1161             {
       
  1162             // Set minimum response length
       
  1163             getInputV1.iRspLength.iMinRspLength =
       
  1164                 responseLength.GetShortInfo( ETLV_MinimumLengthOfResponse );
       
  1165 
       
  1166             if ( RSat::KGetInputTextMaxSize <
       
  1167                 getInputV1.iRspLength.iMinRspLength )
       
  1168                 {
       
  1169                 TBuf<1> emptyString;
       
  1170                 iSatMessHandler->GetInputTerminalResp(
       
  1171                     iTransId,                           // Transaction id
       
  1172                     iCommandDetails,                    // Command details tlv
       
  1173                     RSat::KCmdDataNotUnderstood,        // Result
       
  1174                     KNoCause,                           // KNoCause: 0
       
  1175                     emptyString,                        // No string
       
  1176                     RSat::ESmsDefaultAlphabetUnpacked );// Data coding scheme
       
  1177 
       
  1178                 ret = KErrCorrupt;
       
  1179                 }
       
  1180             // Set maximum response length
       
  1181             getInputV1.iRspLength.iMaxRspLength =
       
  1182                 responseLength.GetShortInfo( ETLV_MaximumLengthOfResponse );
       
  1183             }
       
  1184         else
       
  1185             {
       
  1186             // Mandatory reponse length tlv is missing
       
  1187             TBuf<1> emptyString;
       
  1188             iSatMessHandler->GetInputTerminalResp(
       
  1189                 iTransId,                           // Transaction id
       
  1190                 iCommandDetails,                    // Command details tlv
       
  1191                 RSat::KErrorRequiredValuesMissing,  // Result
       
  1192                 KNoCause,                           // KNoCause: 0
       
  1193                 emptyString,                        // No string
       
  1194                 RSat::ESmsDefaultAlphabetUnpacked );// Data coding scheme
       
  1195 
       
  1196             ret = KErrCorrupt;
       
  1197             }
       
  1198         // Default text to display (optional)
       
  1199         getInputV1.iDefaultText.Zero();
       
  1200         returnValue = berTlv.TlvByTagValue( &textString, KTlvDefaultTextTag );
       
  1201         // If default text exist
       
  1202         if ( KErrNone == returnValue )
       
  1203             {
       
  1204             TSatUtility::SetText( textString, getInputV1.iDefaultText );
       
  1205             }
       
  1206         // Iconid ( optional )
       
  1207         TSatUtility::FillIconStructure( berTlv, getInputV1.iIconId );
       
  1208         CompleteRequest( ret );
       
  1209         }
       
  1210     }
       
  1211 
       
  1212 // -----------------------------------------------------------------------------
       
  1213 // CSatNotifyGetInput::Notify
       
  1214 // An ETel SAT client can call this method via ETel server to set a pending
       
  1215 // request in SimAtkTsy for a GetInput PCmd.
       
  1216 // (other items were commented in a header).
       
  1217 // -----------------------------------------------------------------------------
       
  1218 //
       
  1219 void CSatNotifyGetInput::Notify
       
  1220         (
       
  1221         const TTsyReqHandle aReqHandle, // Request handle
       
  1222         TDes8*              aDataPtr    // Pointer to data
       
  1223         )
       
  1224     {
       
  1225     OstTrace1( TRACE_NORMAL, CSATNOTIFYGETINPUT_NOTIFY, "CSatNotifyGetInput::Notify Handle: %u", aReqHandle );
       
  1226     TFLOGSTRING2("CSatNotifyGetInput::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  1227                aReqHandle );
       
  1228     iReqHandle = aReqHandle;
       
  1229     iGetInputV1Pckg = static_cast< RSat::TGetInputV1Pckg* >( aDataPtr );
       
  1230     iSatMessaging->SatReady( KGetInput );
       
  1231     }
       
  1232 
       
  1233 // -----------------------------------------------------------------------------
       
  1234 // CSatNotifyGetInput::TerminalResponse
       
  1235 // Handles a GetInput terminal response provided by an ETel SAT client via
       
  1236 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  1237 // (other items were commented in a header).
       
  1238 // -----------------------------------------------------------------------------
       
  1239 //
       
  1240 TInt CSatNotifyGetInput::TerminalResponse
       
  1241         (
       
  1242         TDes8* aRsp // Response
       
  1243         )
       
  1244     {
       
  1245     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETINPUT_TERMINALRESPONSE, "CSatNotifyGetInput::TerminalResponse" );
       
  1246     TFLOGSTRING("CSatNotifyGetInput::TerminalResponse");
       
  1247     TInt ret( KErrNone );
       
  1248     TUint8 additionalInfo( 0 );
       
  1249 
       
  1250     RSat::TGetInputRspV1Pckg* aRspPckg =
       
  1251             reinterpret_cast< RSat::TGetInputRspV1Pckg* >( aRsp );
       
  1252     RSat::TGetInputRspV1& rspV1 = ( *aRspPckg ) ();
       
  1253 
       
  1254     // Checking that the response type is valid. If additional info contain
       
  1255     // a text string, response format has to be set.
       
  1256     if ( RSat::EGetInputRspFormatNotSet == rspV1.iRspFormat
       
  1257         && RSat::KTextString == rspV1.iInfoType )
       
  1258         {
       
  1259         ret = KErrCorrupt;
       
  1260         }
       
  1261 
       
  1262     // Check the additional info
       
  1263     if ( ( RSat::KTextString == rspV1.iInfoType )
       
  1264          || ( RSat::KSuccess  == rspV1.iGeneralResult ) )
       
  1265         {
       
  1266         // Making sure first that the string is not empty
       
  1267         if ( RSat::KNoAdditionalInfo != rspV1.iInfoType
       
  1268                 && 0 == rspV1.iAdditionalInfo.Length() )
       
  1269             {
       
  1270             ret = KErrCorrupt;
       
  1271             }
       
  1272         }
       
  1273     // Check that general result values are valid
       
  1274     if ( iAllowedResults != rspV1.iGeneralResult )
       
  1275         {
       
  1276         // Invalid general result
       
  1277         ret = KErrCorrupt;
       
  1278         }
       
  1279     // If there is Me (Mobile Entity) error, additional info is needed
       
  1280     if ( ( RSat::KMeProblem == rspV1.iInfoType ) )
       
  1281         {
       
  1282         // Check the length of additional info
       
  1283         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
  1284             {
       
  1285             additionalInfo = static_cast< TUint8 >( rspV1.iAdditionalInfo[0] );
       
  1286             }
       
  1287         else
       
  1288             {
       
  1289             // Invalid additional info field
       
  1290             ret = KErrCorrupt;
       
  1291             }
       
  1292         }
       
  1293     iSatMessHandler->GetInputTerminalResp(
       
  1294         iTransId,                                 // Transaction id
       
  1295         iCommandDetails,                          // Command details Tlv
       
  1296         static_cast< TUint8 >(
       
  1297         rspV1.iGeneralResult ),                   // Result
       
  1298         additionalInfo,                           // Additional info
       
  1299         rspV1.iAdditionalInfo,                    // Input text
       
  1300         static_cast< TUint8 >( rspV1.iRspFormat ) );    // Resp. format
       
  1301     return ret;
       
  1302     }
       
  1303 
       
  1304 
       
  1305 // -----------------------------------------------------------------------------
       
  1306 // CSatNotifyPlayTone::CSatNotifyPlayTone
       
  1307 // C++ default constructor can NOT contain any code, that
       
  1308 // might leave.
       
  1309 // -----------------------------------------------------------------------------
       
  1310 //
       
  1311 CSatNotifyPlayTone::CSatNotifyPlayTone
       
  1312         (
       
  1313         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  1314         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  1315         )
       
  1316         :
       
  1317         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  1318         iPlayToneV2Pckg( NULL )
       
  1319     {
       
  1320     OstTrace0( TRACE_NORMAL, CSATNOTIFYPLAYTONE_CSATNOTIFYPLAYTONE, "CSatNotifyPlayTone::CSatNotifyPlayTone" );
       
  1321     // Following results are also allowed for this command:
       
  1322     // (in addition to result declared in base class constructor)
       
  1323     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  1324         + RSat::KPSessionTerminatedByUser + RSat::KErrorRequiredValuesMissing;
       
  1325     }
       
  1326 
       
  1327 // -----------------------------------------------------------------------------
       
  1328 // CSatNotifyPlayTone::~CSatNotifyPlayTone
       
  1329 // Destructor
       
  1330 // -----------------------------------------------------------------------------
       
  1331 //
       
  1332 CSatNotifyPlayTone::~CSatNotifyPlayTone()
       
  1333     {
       
  1334     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYPLAYTONE_CSATNOTIFYPLAYTONE, "CSatNotifyPlayTone::~CSatNotifyPlayTone" );
       
  1335     // None
       
  1336     }
       
  1337 
       
  1338 // -----------------------------------------------------------------------------
       
  1339 // CSatNotifyPlayTone::MessageReceived
       
  1340 // Handles a PlayTone proactive command ISI message,
       
  1341 // and completes a pending ETel request.
       
  1342 // (other items were commented in a header).
       
  1343 // -----------------------------------------------------------------------------
       
  1344 //
       
  1345 void CSatNotifyPlayTone::MessageReceived
       
  1346         (
       
  1347         const TIsiReceiveC& aIsiMessage // ISI message
       
  1348         )
       
  1349     {
       
  1350     OstTrace0( TRACE_NORMAL, CSATNOTIFYPLAYTONE_MESSAGERECEIVED, "CSatNotifyPlayTone::MessageReceived" );
       
  1351     TFLOGSTRING("CSatNotifyPlayTone::MessageReceived");
       
  1352     //get ber tlv
       
  1353     CBerTlv berTlv;
       
  1354     TInt returnValue( KErrNone );
       
  1355     returnValue = berTlv.BerTlv( aIsiMessage );
       
  1356     //get command details tlv
       
  1357     CTlv commandDetails;
       
  1358     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  1359     iCommandDetails.Copy( commandDetails.Data() );
       
  1360     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  1361     if ( !iReqHandle )
       
  1362         {
       
  1363         // Request not on, returning response immediately
       
  1364         iSatMessHandler->PlayToneTerminalResp(
       
  1365             iTransId,
       
  1366             iCommandDetails,
       
  1367             RSat::KMeUnableToProcessCmd,
       
  1368             KNoCause ); // KNoCause: 0
       
  1369         }
       
  1370     else
       
  1371         {
       
  1372         // Fill the play tone structure
       
  1373         RSat::TPlayToneV2& playToneV2 = ( *iPlayToneV2Pckg )();
       
  1374         // command number
       
  1375         playToneV2.SetPCmdNumber(
       
  1376             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  1377 
       
  1378         // Alpha ID string (optional)
       
  1379         CTlv alphaIdentifier;
       
  1380         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  1381             KTlvAlphaIdentifierTag );
       
  1382         if ( KErrNotFound != returnValue )
       
  1383             {
       
  1384             TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  1385             if ( alphaIdLength )
       
  1386                 {
       
  1387                 // get the alpha id
       
  1388                 TPtrC8 sourceString;
       
  1389                 sourceString.Set(
       
  1390                     alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  1391                 // convert and set the alpha id
       
  1392                 TSatUtility::SetAlphaId( sourceString ,
       
  1393                     playToneV2.iAlphaId.iAlphaId );
       
  1394                 }
       
  1395             // Set Alpha ID status
       
  1396             if ( playToneV2.iAlphaId.iAlphaId.Length() )
       
  1397                 {
       
  1398                 playToneV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  1399                 }
       
  1400             else
       
  1401                 {
       
  1402                 playToneV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  1403                 }
       
  1404             }
       
  1405         else
       
  1406             {
       
  1407             playToneV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  1408             }
       
  1409 
       
  1410         // Tone selection (optional)
       
  1411         playToneV2.iTone = RSat::KToneNotSet;
       
  1412         CTlv tone;
       
  1413         returnValue = berTlv.TlvByTagValue( &tone, KTlvToneTag );
       
  1414         if (returnValue != KErrNotFound)
       
  1415             {
       
  1416             playToneV2.iTone = ( RSat::TTone ) tone.GetShortInfo( ETLV_Tone );
       
  1417             }
       
  1418         // Duration of the tone (optional)
       
  1419         TSatUtility::FillDurationStructure( berTlv,
       
  1420             playToneV2.iDuration );
       
  1421         // Icond Id (optional)
       
  1422         TSatUtility::FillIconStructure( berTlv,
       
  1423             playToneV2.iIconId );
       
  1424 
       
  1425         CompleteRequest( KErrNone );
       
  1426         }
       
  1427     }
       
  1428 
       
  1429 // -----------------------------------------------------------------------------
       
  1430 // CSatNotifyPlayTone::Notify
       
  1431 // An ETel SAT client can call this method via ETel server to set a pending
       
  1432 // request in SimAtkTsy for a PlayTone PCmd.
       
  1433 // (other items were commented in a header).
       
  1434 // -----------------------------------------------------------------------------
       
  1435 //
       
  1436 void CSatNotifyPlayTone::Notify
       
  1437         (
       
  1438         const TTsyReqHandle aReqHandle, // Request handle
       
  1439         TDes8*              aDataPtr    // Pointer to data
       
  1440         )
       
  1441     {
       
  1442     OstTrace1( TRACE_NORMAL, CSATNOTIFYPLAYTONE_NOTIFY, "CSatNotifyPlayTone::Notify Handle: %u", aReqHandle );
       
  1443 
       
  1444     TFLOGSTRING2("CSatNotifyPlayTone::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  1445                aReqHandle );
       
  1446     iReqHandle = aReqHandle;
       
  1447     iPlayToneV2Pckg = static_cast< RSat::TPlayToneV2Pckg* >( aDataPtr );
       
  1448     iSatMessaging->SatReady( KPlayTone );
       
  1449     }
       
  1450 
       
  1451 // -----------------------------------------------------------------------------
       
  1452 // CSatNotifyPlayTone::TerminalResponse
       
  1453 // Handles a PlayTone terminal response provided by an ETel SAT client via
       
  1454 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  1455 // (other items were commented in a header).
       
  1456 // -----------------------------------------------------------------------------
       
  1457 //
       
  1458 TInt CSatNotifyPlayTone::TerminalResponse
       
  1459         (
       
  1460         TDes8* aRsp     // Response
       
  1461         )
       
  1462     {
       
  1463     OstTrace0( TRACE_NORMAL, CSATNOTIFYPLAYTONE_TERMINALRESPONSE, "CSatNotifyPlayTone::TerminalResponse" );
       
  1464     TFLOGSTRING("CSatNotifyPlayTone::TerminalResponse");
       
  1465     TInt ret( KErrNone );
       
  1466     TUint8 additionalInfo( 0 );
       
  1467     RSat::TPlayToneRspV1Pckg* aRspPckg =
       
  1468             reinterpret_cast< RSat::TPlayToneRspV1Pckg* >( aRsp );
       
  1469     RSat::TPlayToneRspV1& rspV1 = ( *aRspPckg ) ();
       
  1470     // Check that general result value is valid.
       
  1471     // Note: When the phone is in silent mode, KMeUnableToProcessCmd
       
  1472     // is returned as a result, with no additional info.
       
  1473     if ( iAllowedResults != rspV1.iGeneralResult )
       
  1474         {
       
  1475         // Invalid general result
       
  1476         ret = KErrCorrupt;
       
  1477         }
       
  1478 
       
  1479     // If there is Me (Mobile Entity) error, additional info is needed
       
  1480     if ( RSat::KMeProblem == rspV1.iInfoType )
       
  1481         {
       
  1482         // Check the length of additional info
       
  1483         if ( rspV1.iAdditionalInfo.Length() )
       
  1484             {
       
  1485             additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  1486             }
       
  1487         else
       
  1488             {
       
  1489             // Invalid additional info field
       
  1490             ret = KErrCorrupt;
       
  1491             }
       
  1492         }
       
  1493     iSatMessHandler->PlayToneTerminalResp(
       
  1494         iTransId,                                       // Transaction Id
       
  1495         iCommandDetails,                                // Command number
       
  1496         TUint8( rspV1.iGeneralResult ),                 // Result
       
  1497         additionalInfo );                               // Additional info
       
  1498     return ret;
       
  1499     }
       
  1500 
       
  1501 
       
  1502 // -----------------------------------------------------------------------------
       
  1503 // CSatNotifyPollInterval::CSatNotifyPollInterval
       
  1504 // C++ default constructor can NOT contain any code, that
       
  1505 // might leave.
       
  1506 // -----------------------------------------------------------------------------
       
  1507 //
       
  1508 CSatNotifyPollInterval::CSatNotifyPollInterval
       
  1509         (
       
  1510         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  1511         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  1512         )
       
  1513         :
       
  1514         CSatNotificationsBase( aSatMessHandler, aSatMessaging )
       
  1515     {
       
  1516     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINTERVAL_CSATNOTIFYPOLLINTERVAL, "CSatNotifyPollInterval::CSatNotifyPollInterval" );
       
  1517     // Following results are also allowed for this command:
       
  1518     // (in addition to result declared in base class constructor)
       
  1519     iAllowedResults += RSat::KErrorRequiredValuesMissing;
       
  1520     }
       
  1521 
       
  1522 // -----------------------------------------------------------------------------
       
  1523 // CSatNotifyPollInterval::~CSatNotifyPollInterval
       
  1524 // Destructor
       
  1525 // -----------------------------------------------------------------------------
       
  1526 //
       
  1527 CSatNotifyPollInterval::~CSatNotifyPollInterval()
       
  1528     {
       
  1529     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYPOLLINTERVAL_CSATNOTIFYPOLLINTERVAL, "CSatNotifyPollInterval::~CSatNotifyPollInterval" );
       
  1530     // None
       
  1531     }
       
  1532 
       
  1533 // -----------------------------------------------------------------------------
       
  1534 // CSatNotifyPollInterval::MessageReceived
       
  1535 // Handles a PollInterval proactive command ISI message.
       
  1536 // No ETel pending request is required.
       
  1537 // (other items were commented in a header).
       
  1538 // -----------------------------------------------------------------------------
       
  1539 //
       
  1540 void CSatNotifyPollInterval::MessageReceived
       
  1541         (
       
  1542         const TIsiReceiveC& aIsiMessage // ISI message
       
  1543         )
       
  1544     {
       
  1545     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINTERVAL_MESSAGERECEIVED, "CSatNotifyPollInterval::MessageReceived" );
       
  1546     TFLOGSTRING("CSatNotifyPollInterval::MessageReceived");
       
  1547     //get ber tlv
       
  1548     CBerTlv berTlv;
       
  1549     TInt returnValue( KErrNone );
       
  1550     berTlv.BerTlv( aIsiMessage );
       
  1551     CTlv commandDetails;
       
  1552     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  1553     iCommandDetails.Copy( commandDetails.Data() );
       
  1554     TUint16 anIntervalInSeconds( KDefaultPollInterval );
       
  1555     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  1556     // Duration of the interval
       
  1557     CTlv duration;
       
  1558     returnValue = berTlv.TlvByTagValue( &duration, KTlvDurationTag );
       
  1559     if ( KErrNone != returnValue )
       
  1560         {
       
  1561         // Required values are missing
       
  1562         iSatMessHandler->PollIntervalTerminalResp( iTransId, iCommandDetails,
       
  1563             RSat::KErrorRequiredValuesMissing, RSat::KNoSpecificMeProblem, 0);
       
  1564         }
       
  1565     else
       
  1566         {
       
  1567         TUint8 timeIntv( duration.GetShortInfo( ETLV_TimeInteval ) );
       
  1568 
       
  1569         // Time Interval 0 is SIM server's default value (25 seconds)
       
  1570         if ( 0 != timeIntv )
       
  1571             {
       
  1572             TUint8 durationTimeUnit( duration.GetShortInfo( ETLV_TimeUnit ) );
       
  1573 
       
  1574             switch (durationTimeUnit)
       
  1575                 {
       
  1576                 case KMinutes:
       
  1577                     {
       
  1578                     anIntervalInSeconds = timeIntv * 60;
       
  1579                     break;
       
  1580                     }
       
  1581                 case KSeconds:
       
  1582                     {
       
  1583                     anIntervalInSeconds = timeIntv;
       
  1584                     break;
       
  1585                     }
       
  1586                 case KTenthsOfSeconds:
       
  1587                     {
       
  1588                         // Rounding
       
  1589                     if ( 5 >= ( timeIntv % 10 ) )
       
  1590                         {
       
  1591                         // if the intervals the ME can offer are equidistant
       
  1592                         // (higher and lower) from the SIM's request, the ME shall
       
  1593                         // respond with the lower interval of the two.
       
  1594                         anIntervalInSeconds = static_cast<TUint8> (timeIntv / 10 );
       
  1595                         }
       
  1596                     else
       
  1597                         {
       
  1598                         anIntervalInSeconds = static_cast<TUint8> ( (timeIntv / 10) + 1);
       
  1599                         }
       
  1600                     break;
       
  1601                     }
       
  1602                 default:
       
  1603                     {
       
  1604                     returnValue = KErrNotFound;
       
  1605                     TFLOGSTRING("TSY: CSatNotifyPollInterval::MessageReceived, Time unit did not match.");
       
  1606                     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYPOLLINTERVAL_MESSAGERECEIVED, "CSatNotifyPollInterval::MessageReceived, Time unit did not match." );
       
  1607                     // Command data not understood
       
  1608                     iSatMessHandler->PollIntervalTerminalResp( iTransId, iCommandDetails,
       
  1609                     RSat::KCmdDataNotUnderstood, RSat::KNoSpecificMeProblem, 0);
       
  1610                     break;
       
  1611                     }
       
  1612                 }//switch
       
  1613 
       
  1614             // Check interval limits
       
  1615             if ( KMinPollInterval > anIntervalInSeconds )
       
  1616                 {
       
  1617                 anIntervalInSeconds = KMinPollInterval;
       
  1618                 }
       
  1619             else if ( KMaxPollInterval < anIntervalInSeconds )
       
  1620                 {
       
  1621                 if ( iSatMessHandler->OldPollInterval() )
       
  1622                     {
       
  1623                     TFLOGSTRING("TSY: CSatNotifyPollInterval::MessageReceived MaxPolInterval");
       
  1624                     OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYPOLLINTERVAL_MESSAGERECEIVED, "CSatNotifyPollInterval::MessageReceived MaxPolInterval" );
       
  1625                     anIntervalInSeconds = KMaxPollInterval;
       
  1626                     }
       
  1627                 else
       
  1628                     {
       
  1629                     TFLOGSTRING("TSY: CSatNotifyPollInterval::MessageReceived, DefaultPollInterval");
       
  1630                     OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYPOLLINTERVAL_MESSAGERECEIVED, "CSatNotifyPollInterval::MessageReceived, DefaultPollInterval" );
       
  1631                     // Use SIM server's default value (0)
       
  1632                     anIntervalInSeconds = KDefaultPollInterval;
       
  1633                     }
       
  1634                 }
       
  1635             }
       
  1636         else
       
  1637             {
       
  1638             // Use SIM server's default value (0)
       
  1639             anIntervalInSeconds = KDefaultPollInterval;
       
  1640             }
       
  1641 
       
  1642         if ( KErrNone == returnValue )
       
  1643             {
       
  1644 
       
  1645             // A PCmd PollingOff may be executed.
       
  1646             iSatMessHandler->SetPollingOff( EFalse );
       
  1647             // Send SetPollInterval request to ISA CellMo side. The terminal response
       
  1648             // will be sent to ISA CellMo side after SetPollInterval response.
       
  1649             iSatMessHandler->SetPollingInterval(
       
  1650                 iTransId,
       
  1651                 static_cast<TUint8>( anIntervalInSeconds ) );
       
  1652             }
       
  1653         }
       
  1654     }
       
  1655 
       
  1656 // -----------------------------------------------------------------------------
       
  1657 // CSatNotifyPollInterval::Notify
       
  1658 // An ETel SAT client can call this method via ETel server to set a pending
       
  1659 // request in SimAtkTsy for a PollInterval PCmd.
       
  1660 // (other items were commented in a header).
       
  1661 // -----------------------------------------------------------------------------
       
  1662 //
       
  1663 void CSatNotifyPollInterval::Notify
       
  1664         (
       
  1665         const TTsyReqHandle /*aReqHandle*/, // Request handle
       
  1666         TDes8*              /*aDataPtr*/    // Pointer to data
       
  1667         )
       
  1668     {
       
  1669     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINTERVAL_NOTIFY, "CSatNotifyPollInterval::Notify" );
       
  1670     // PollInterval is completely implemented by SimAtkTsy. Client
       
  1671     // insn't notified about the command.
       
  1672     }
       
  1673 
       
  1674 
       
  1675 // -----------------------------------------------------------------------------
       
  1676 // CSatNotifySetUpMenu::CSatNotifySetUpMenu
       
  1677 // C++ default constructor can NOT contain any code, that
       
  1678 // might leave.
       
  1679 // -----------------------------------------------------------------------------
       
  1680 //
       
  1681 CSatNotifySetUpMenu::CSatNotifySetUpMenu
       
  1682         (
       
  1683         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  1684         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  1685         )
       
  1686         :
       
  1687         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  1688         iSetUpMenuV2Pckg( NULL ),
       
  1689         iSatIsiMsg( NULL ),
       
  1690         iItemsNextIndicatorRemoved( EFalse )
       
  1691     {
       
  1692     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPMENU_CSATNOTIFYSETUPMENU, "CSatNotifySetUpMenu::CSatNotifySetUpMenu" );
       
  1693     TFLOGSTRING("CSatNotifySetUpMenu::CSatNotifySetUpMenu");
       
  1694     iToolKitName.Zero();
       
  1695 
       
  1696     // Following results are also allowed for this command:
       
  1697     // (in addition to result declared in base class constructor)
       
  1698     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  1699         + RSat::KErrorRequiredValuesMissing;
       
  1700     }
       
  1701 
       
  1702 // -----------------------------------------------------------------------------
       
  1703 // CSatNotifySetUpMenu::~CSatNotifySetUpMenu
       
  1704 // Destructor
       
  1705 // -----------------------------------------------------------------------------
       
  1706 //
       
  1707 CSatNotifySetUpMenu::~CSatNotifySetUpMenu()
       
  1708     {
       
  1709     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPMENU_CSATNOTIFYSETUPMENU, "CSatNotifySetUpMenu::~CSatNotifySetUpMenu" );
       
  1710     TFLOGSTRING("CSatNotifySetUpMenu::~CSatNotifySetUpMenu");
       
  1711     if ( iSatIsiMsg )
       
  1712         {
       
  1713         delete iSatIsiMsg;
       
  1714         }
       
  1715     }
       
  1716 
       
  1717 // -----------------------------------------------------------------------------
       
  1718 // CSatNotifySetUpMenu::MessageReceived
       
  1719 // Handles a SetUpMenu proactive command ISI message,
       
  1720 // and completes a pending ETel request.
       
  1721 // (other items were commented in a header).
       
  1722 // -----------------------------------------------------------------------------
       
  1723 //
       
  1724 void CSatNotifySetUpMenu::MessageReceived
       
  1725         (
       
  1726         const TIsiReceiveC& aIsiMessage // ISI message
       
  1727         )
       
  1728     {
       
  1729     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived" );
       
  1730     TFLOGSTRING("TSY:CSatNotifySetUpMenu::MessageReceived");
       
  1731     TInt ret( KErrNone );
       
  1732     TInt returnValue( KErrNone );
       
  1733     // get ber tlv
       
  1734     CBerTlv berTlv;
       
  1735     returnValue = berTlv.BerTlv( aIsiMessage );
       
  1736      //get command details tlv
       
  1737     CTlv commandDetails;
       
  1738     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  1739     iCommandDetails.Copy( commandDetails.Data() );
       
  1740      // Get command qualifier
       
  1741     TUint8 cmdQualifier( commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  1742     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  1743     if ( !iReqHandle )
       
  1744         {
       
  1745         // Request is not pending. Store pcmd for later use
       
  1746         // This may happen e.g. when changing ME's language (warm reset)
       
  1747         if ( iSatIsiMsg )
       
  1748             {
       
  1749             // first clear buffer if there's already data
       
  1750             delete iSatIsiMsg;
       
  1751             iSatIsiMsg = NULL;
       
  1752             }
       
  1753         // Alloc memory
       
  1754         iSatIsiMsg = aIsiMessage.GetBuffer().Alloc();
       
  1755 
       
  1756         if ( iSatIsiMsg )
       
  1757             {
       
  1758             TFLOGSTRING("TSY:CSatNotifySetUpMenu::MessageReceived, pcmd saved");
       
  1759             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived, pcmd saved" );
       
  1760             }
       
  1761         else
       
  1762             {
       
  1763             TFLOGSTRING("TSY:CSatNotifySetUpMenu::MessageReceived, \
       
  1764                 out of memory unable to buffer received cmd");
       
  1765             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived, out of memory unable to buffer received cmd" );
       
  1766             iSatMessHandler->SetUpMenuTerminalResp( iTransId,
       
  1767                                                 iCommandDetails,
       
  1768                                                 RSat::KMeUnableToProcessCmd,
       
  1769                                                 NULL );
       
  1770             ret = KErrCorrupt;
       
  1771             }
       
  1772         }
       
  1773     RSat::TSetUpMenuV2 menu;
       
  1774     // Store command number
       
  1775     menu.SetPCmdNumber(
       
  1776         commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  1777     // Selection preference
       
  1778     menu.iPreference = RSat::ESelectionPreferenceNotSet;
       
  1779     if ( cmdQualifier & KSelectionUsingSoftKey )
       
  1780         {
       
  1781         menu.iPreference = RSat::ESoftKeyPreferred;
       
  1782         }
       
  1783     else
       
  1784         {
       
  1785         menu.iPreference = RSat::ENoSelectionPreference;
       
  1786         }
       
  1787     // Alpha Id string (optional)
       
  1788     menu.iAlphaId.iAlphaId.Zero();
       
  1789     //get alpha identifier tlv
       
  1790     CTlv alphaIdentifier;
       
  1791     returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  1792                                         KTlvAlphaIdentifierTag );
       
  1793     if ( KErrNone != returnValue )
       
  1794         {
       
  1795 
       
  1796         iSatMessHandler->SetUpMenuTerminalResp(
       
  1797                                     iTransId,
       
  1798                                     iCommandDetails,
       
  1799                                     RSat::KErrorRequiredValuesMissing,
       
  1800                                     RSat::KNoAdditionalInfo );
       
  1801         ret = KErrCorrupt;
       
  1802         }
       
  1803     else
       
  1804         {
       
  1805         TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  1806         TFLOGSTRING2("TSY: Alpha ID length:%d", alphaIdLength );
       
  1807         OstTraceExt1( TRACE_NORMAL, DUP3_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived Alpha ID: %hu", alphaIdLength );
       
  1808         if ( alphaIdLength > RSat::KAlphaIdMaxSize )
       
  1809             {
       
  1810             // String too long
       
  1811             ret = KErrCorrupt;
       
  1812             }
       
  1813         else if ( alphaIdLength )
       
  1814             {
       
  1815             TPtrC8 temp;
       
  1816             // get the alpha id
       
  1817             temp.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  1818             // convert and set the alpha id
       
  1819             TSatUtility::SetAlphaId( temp , menu.iAlphaId.iAlphaId );
       
  1820             // Set SAT toolikit name, send SAT SMS logging purpose
       
  1821             iToolKitName.Copy( menu.iAlphaId.iAlphaId );
       
  1822             TFLOGSTRING2("TSY: SetUpMenu iToolKitName:%S",
       
  1823                   &iToolKitName );
       
  1824             OstTraceExt1( TRACE_NORMAL, DUP4_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived SetUpMenu iToolKitName: %S", iToolKitName );
       
  1825             }
       
  1826         else
       
  1827             {
       
  1828             TFLOGSTRING("TSY: CSatNotifySetUpMenu::MessageReceived,\
       
  1829                 Wrong length of alpha id.");
       
  1830             OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived, Wrong length of alpha id." );
       
  1831             }
       
  1832         // Alpha Id status
       
  1833         if ( menu.iAlphaId.iAlphaId.Length() )
       
  1834             {
       
  1835             menu.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  1836             }
       
  1837         else
       
  1838             {
       
  1839             menu.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  1840             }
       
  1841         // Help information.
       
  1842         if ( commandDetails.GetShortInfo( ETLV_CommandQualifier )
       
  1843               & KHelpAvailabilityMask )
       
  1844             {
       
  1845             // Help information available
       
  1846             menu.iHelp = RSat::EHelpAvailable;
       
  1847             }
       
  1848         else
       
  1849             {
       
  1850             // No help
       
  1851             menu.iHelp = RSat::ENoHelpAvailable;
       
  1852             }
       
  1853         // Icon identifier
       
  1854         TSatUtility::FillIconStructure( berTlv, menu.iIconId );
       
  1855         // Item Icon identifier list
       
  1856         CTlv itemsIconIdentifierList;
       
  1857         TInt retValue = berTlv.TlvByTagValue( &itemsIconIdentifierList,
       
  1858                                          KTlvItemIconIdentifierListTag );
       
  1859         TPtrC8 iconIdList;
       
  1860         menu.iIconListQualifier = RSat::EIconQualifierNotSet;
       
  1861 
       
  1862         if( KErrNone == retValue )
       
  1863             {
       
  1864             TUint8 iIconListQualifier( itemsIconIdentifierList.GetShortInfo(
       
  1865                                              ETLV_IconListQualifier ) );
       
  1866             iconIdList.Set( itemsIconIdentifierList.GetData( ETLV_IconIdentifierList ));
       
  1867 
       
  1868             if( iIconListQualifier )
       
  1869                 {
       
  1870                 menu.iIconListQualifier = RSat::ENotSelfExplanatory;
       
  1871                 }
       
  1872             else
       
  1873                 {
       
  1874                 menu.iIconListQualifier = RSat::ESelfExplanatory;
       
  1875                 }
       
  1876             }
       
  1877         else if ( KErrNotFound == retValue )
       
  1878             {
       
  1879             menu.iIconListQualifier = RSat::ENoIconId;
       
  1880             }
       
  1881         else
       
  1882             {
       
  1883             TFLOGSTRING("TSY: CSatNotifySetUpMenu::MessageReceived, \
       
  1884                 Wrong return value of icon identifier list.");
       
  1885             OstTrace0( TRACE_NORMAL, DUP6_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived, Wrong return value of icon identifier list." );
       
  1886             }
       
  1887 
       
  1888         //Items Data
       
  1889         TInt itemNbr( 0 );
       
  1890         CTlv itemsData;
       
  1891         returnValue = berTlv.TlvByTagValue( &itemsData, KTlvItemTag,
       
  1892                                             itemNbr );
       
  1893         TUint8 numberOfItemData( 0 );
       
  1894         TUint16 stringLength( 0 );
       
  1895         if( !returnValue )
       
  1896             {
       
  1897             CTlv itemsDataTemp;
       
  1898             stringLength = ( itemsData.GetLength());
       
  1899             TInt ret(KErrNone);
       
  1900             // Set numberOfItemData
       
  1901             while ( KErrNone == ret )
       
  1902                 {
       
  1903                 numberOfItemData++;
       
  1904                 ret = berTlv.TlvByTagValue( &itemsDataTemp, KTlvItemTag,
       
  1905                                                 numberOfItemData );
       
  1906                 }
       
  1907             }
       
  1908 
       
  1909         //Item Next Action Indicator
       
  1910         CTlv itemNextActionIndicator;
       
  1911         retValue = berTlv.TlvByTagValue( &itemNextActionIndicator,
       
  1912                                          KTlvItemsNextActionIndicatorTag );
       
  1913         TPtrC8 itemNextIndicator;
       
  1914         if ( KErrNone == retValue )
       
  1915             {
       
  1916             TPtrC8 itemNextIndicatorTemp;
       
  1917             itemNextIndicatorTemp.Set(
       
  1918                  itemNextActionIndicator.GetData( ETLV_ItemsNextActionIndicator ));
       
  1919 
       
  1920             //In case the number of items in this list does not match the number
       
  1921             //of items in the menu the Items Next Action Indicator list is ignored by ME
       
  1922             if(itemNextIndicatorTemp.Length() != numberOfItemData )
       
  1923                 {
       
  1924                 iItemsNextIndicatorRemoved = ETrue;
       
  1925                 }
       
  1926             else
       
  1927                    {
       
  1928                 itemNextIndicator.Set(itemNextIndicatorTemp);
       
  1929                    }
       
  1930             }
       
  1931 
       
  1932         //if first item is NULL -> remove existing menu
       
  1933         if( stringLength != 0 )
       
  1934             {
       
  1935             for ( TInt8 i( 0 ) ; ( KErrNone == ret )
       
  1936                 && ( KErrNone == returnValue ) ; i++ )
       
  1937                 {
       
  1938                 // Filling up the menu items
       
  1939                 RSat::TItem newItem;
       
  1940                 // Suffle through all the menu items
       
  1941                 stringLength = 0;
       
  1942                 TFLOGSTRING2("TSY: item number:%d", i );
       
  1943                 OstTraceExt1( TRACE_NORMAL, DUP7_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived Item number: %hhd", i );
       
  1944                 // Fill the newitem
       
  1945                 newItem.iItemId = itemsData.GetShortInfo( ETLV_IdentifierOfItem );
       
  1946                 stringLength = itemsData.GetLength();
       
  1947                 stringLength--;
       
  1948                 TPtrC8 itemData = itemsData.GetData( ETLV_TextStringOfItem );
       
  1949                 // Menu item string, coded as EFadn (3gpp 11.11)
       
  1950                 newItem.iItemString.Zero();
       
  1951                 if ( ( KUCS2ArabicCoding == itemData[0] )
       
  1952                     || ( KUCS2GreekCoding == itemData[0] )
       
  1953                     || ( KUCS2TurkishCoding == itemData[0] ) )
       
  1954                     {
       
  1955                     TSatUtility::ConvertAlphaFieldsToUnicode( itemData,
       
  1956                         newItem.iItemString );
       
  1957                     }
       
  1958                 else
       
  1959                     {
       
  1960                     TSatUtility::ConvertSms7ToUnicode16( newItem.iItemString,
       
  1961                           itemData );
       
  1962                     }
       
  1963                 TFLOGSTRING2("TSY: SetUpMenu newItem.iItemString:%S",
       
  1964                     &newItem.iItemString );
       
  1965                 OstTraceExt1( TRACE_NORMAL, DUP8_CSATNOTIFYSETUPMENU_MESSAGERECEIVED, "CSatNotifySetUpMenu::MessageReceived, newItem.iItemString: %S", newItem.iItemString );
       
  1966                 // Adding the new menuitem
       
  1967                 if( NULL != iconIdList.Size()  && ( i < iconIdList.Length() ) )
       
  1968                     {
       
  1969                     if( ( NULL != itemNextIndicator.Size() )
       
  1970                         && ( i < itemNextIndicator.Length() ) )
       
  1971                         {
       
  1972                         //Menu item with item next idicator and icon identifier
       
  1973                         if ( KErrNoMemory == menu.AddItem( newItem,
       
  1974                              itemNextIndicator[i], iconIdList[i] ) )
       
  1975                             {
       
  1976                             // Too many or long menu items
       
  1977                             ret = KErrCorrupt;
       
  1978                             }
       
  1979                         }
       
  1980                     //menu item with icon identifier
       
  1981                     else if ( KErrNoMemory == menu.AddItemIcon( newItem,
       
  1982                                                                 iconIdList[i] ) )
       
  1983                         {
       
  1984                         // Too many or long menu items
       
  1985                         ret = KErrCorrupt;
       
  1986                         }
       
  1987                     else
       
  1988                         {
       
  1989                         // All ok
       
  1990                         }
       
  1991                     }
       
  1992                 else
       
  1993                     {
       
  1994                     if( ( NULL != itemNextIndicator.Size() )
       
  1995                         && ( i < itemNextIndicator.Length() ) )
       
  1996                         {
       
  1997                         //menu item with item next indicator
       
  1998                         if ( KErrNoMemory == menu.AddItem( newItem,
       
  1999                                                            itemNextIndicator[i] ) )
       
  2000                             {
       
  2001                             // Too many or long menu items
       
  2002                             ret = KErrCorrupt;
       
  2003                             }
       
  2004                         }
       
  2005                     //menu item
       
  2006                     else
       
  2007                         {
       
  2008                         TInt retAdd = menu.AddItem( newItem );
       
  2009                         if ( KErrNoMemory == retAdd )
       
  2010                             {
       
  2011                             // Too many or long menu items
       
  2012                             // // If there is not enough space left in the
       
  2013                             // buffer used
       
  2014                             // by the menu KErrNoMemory is returned.
       
  2015                             ret = KErrCorrupt;
       
  2016                             // send terminal response
       
  2017                             iSatMessHandler->SetUpMenuTerminalResp(
       
  2018                                     iTransId,
       
  2019                                     iCommandDetails,
       
  2020                                     RSat::KCmdDataNotUnderstood,
       
  2021                                     RSat::KNoAdditionalInfo );
       
  2022                             }
       
  2023                         }
       
  2024                     }
       
  2025                 itemNbr++;
       
  2026                 returnValue = berTlv.TlvByTagValue( &itemsData,
       
  2027                                                         KTlvItemTag,
       
  2028                                                         itemNbr );
       
  2029                 }
       
  2030             }
       
  2031         }
       
  2032     if ( iReqHandle )
       
  2033         {
       
  2034         RSat::TSetUpMenuV2& setUpMenuV2 = ( *iSetUpMenuV2Pckg )();
       
  2035         setUpMenuV2 = menu;
       
  2036         CompleteRequest( ret );
       
  2037         }
       
  2038     }
       
  2039 
       
  2040 // -----------------------------------------------------------------------------
       
  2041 // CSatNotifySetUpMenu::Notify
       
  2042 // An ETel SAT client can call this method via ETel server to set a pending
       
  2043 // request in SimAtkTsy for a SetUpMenu PCmd.
       
  2044 // (other items were commented in a header).
       
  2045 // -----------------------------------------------------------------------------
       
  2046 //
       
  2047 void CSatNotifySetUpMenu::Notify
       
  2048         (
       
  2049         const TTsyReqHandle aReqHandle, // Request handle
       
  2050         TDes8*              aDataPtr    // Pointer to data
       
  2051         )
       
  2052     {
       
  2053     OstTrace1( TRACE_NORMAL, CSATNOTIFYSETUPMENU_NOTIFY, "CSatNotifySetUpMenu::Notify Handle: %u", aReqHandle );
       
  2054     TFLOGSTRING2("CSatNotifySetUpMenu::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  2055                aReqHandle );
       
  2056     TInt ret( KErrNone );
       
  2057     iReqHandle = aReqHandle;
       
  2058     iSetUpMenuV2Pckg = static_cast< RSat::TSetUpMenuV2Pckg* >( aDataPtr );
       
  2059     ret = iSatMessaging->SatReady( KSetUpMenu );
       
  2060     if ( KErrNotFound == ret )
       
  2061         {
       
  2062         if ( iSatIsiMsg )
       
  2063             {
       
  2064             MessageReceived( TIsiReceiveC( iSatIsiMsg->Des() ) );
       
  2065             delete iSatIsiMsg;
       
  2066             iSatIsiMsg = NULL;
       
  2067             }
       
  2068         }
       
  2069     }
       
  2070 
       
  2071 // -----------------------------------------------------------------------------
       
  2072 // CSatNotifySetUpMenu::TerminalResponse
       
  2073 // Handles a SetUpMenu terminal response provided by an ETel SAT client via
       
  2074 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  2075 // (other items were commented in a header).
       
  2076 // -----------------------------------------------------------------------------
       
  2077 //
       
  2078 TInt CSatNotifySetUpMenu::TerminalResponse
       
  2079         (
       
  2080         TDes8* aRsp // Response
       
  2081         )
       
  2082     {
       
  2083     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPMENU_TERMINALRESPONSE, "CSatNotifySetUpMenu::TerminalResponse" );
       
  2084     TFLOGSTRING("CSatNotifySetUpMenu::TerminalResponse");
       
  2085     TInt ret( KErrNone );
       
  2086     TUint8 additionalInfo( 0 );
       
  2087     RSat::TSetUpMenuRspV1Pckg* aRspPckg =
       
  2088             reinterpret_cast<RSat::TSetUpMenuRspV1Pckg*>( aRsp );
       
  2089     RSat::TSetUpMenuRspV1& rspV1 = ( *aRspPckg ) ();
       
  2090 
       
  2091     // Check that general result value is valid
       
  2092     if ( iAllowedResults != rspV1.iGeneralResult )
       
  2093         {
       
  2094         // Invalid general result
       
  2095         ret = KErrCorrupt;
       
  2096         }
       
  2097     // If there is Me (Mobile Entity) error, additional info is needed
       
  2098     if ( RSat::KMeProblem == rspV1.iInfoType )
       
  2099         {
       
  2100         // Check the length of additional info
       
  2101         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
  2102             {
       
  2103             additionalInfo = static_cast<TUint8>( rspV1.iAdditionalInfo[0] );
       
  2104             }
       
  2105         else
       
  2106             {
       
  2107             // Invalid additional info field
       
  2108             ret = KErrCorrupt;
       
  2109             }
       
  2110         }
       
  2111 
       
  2112     if( RSat::KSuccess == rspV1.iGeneralResult && iItemsNextIndicatorRemoved )
       
  2113         {
       
  2114         TFLOGSTRING("CSatNotifySetUpMenu::TerminalResponseL, iItemsNextIndicatorRemoved");
       
  2115         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPMENU_TERMINALRESPONSE, "CSatNotifySetUpMenu::TerminalResponseL, iItemsNextIndicatorRemoved" );
       
  2116         rspV1.iGeneralResult = RSat::KPartialComprehension;
       
  2117         }
       
  2118     iItemsNextIndicatorRemoved = EFalse;
       
  2119 
       
  2120     // Creating the info message
       
  2121     iSatMessHandler->SetUpMenuTerminalResp(
       
  2122         iTransId,                                   // Transaction id
       
  2123         iCommandDetails,                            // Command number
       
  2124         static_cast<TUint8>( rspV1.iGeneralResult ),  // Result
       
  2125         additionalInfo );                           // additional info
       
  2126     return ret;
       
  2127     }
       
  2128 
       
  2129 // -----------------------------------------------------------------------------
       
  2130 // CSatNotifySetUpMenu::SatApplicationName
       
  2131 // Return a reference to sat application name.
       
  2132 // (other items were commented in a header).
       
  2133 // -----------------------------------------------------------------------------
       
  2134 //
       
  2135 TDes16& CSatNotifySetUpMenu::SatApplicationName()
       
  2136     {
       
  2137     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPMENU_SATAPPLICATIONNAME, "CSatNotifySetUpMenu::SatApplicationName" );
       
  2138     if ( 0x0 == iToolKitName.Length() )
       
  2139         {
       
  2140         // Default toolkit name
       
  2141         iToolKitName.Copy( KSatToolkit );
       
  2142         }
       
  2143     return iToolKitName;
       
  2144     }
       
  2145 
       
  2146 
       
  2147 // -----------------------------------------------------------------------------
       
  2148 // CSatNotifySelectItem::CSatNotifySelectItem
       
  2149 // C++ default constructor can NOT contain any code, that
       
  2150 // might leave.
       
  2151 // -----------------------------------------------------------------------------
       
  2152 //
       
  2153 CSatNotifySelectItem::CSatNotifySelectItem
       
  2154         (
       
  2155         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  2156         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  2157         )
       
  2158         :
       
  2159         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  2160         iSelectItemV2Pckg( NULL ),
       
  2161         iItemNextIndicatorRemoved( EFalse )
       
  2162     {
       
  2163     OstTrace0( TRACE_NORMAL, CSATNOTIFYSELECTITEM_CSATNOTIFYSELECTITEM, "CSatNotifySelectItem::CSatNotifySelectItem" );
       
  2164     // Following results are also allowed for this command:
       
  2165     // (in addition to result declared in base class constructor)
       
  2166     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  2167         + RSat::KPSessionTerminatedByUser + RSat::KBackwardModeRequestedByUser
       
  2168         + RSat::KNoResponseFromUser + RSat::KHelpRequestedByUser
       
  2169         + RSat::KErrorRequiredValuesMissing;
       
  2170     }
       
  2171 
       
  2172 // -----------------------------------------------------------------------------
       
  2173 // CSatNotifySelectItem::~CSatNotifySelectItem
       
  2174 // Destructor
       
  2175 // -----------------------------------------------------------------------------
       
  2176 //
       
  2177 CSatNotifySelectItem::~CSatNotifySelectItem()
       
  2178     {
       
  2179     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSELECTITEM_CSATNOTIFYSELECTITEM, "CSatNotifySelectItem::~CSatNotifySelectItem" );
       
  2180     // None
       
  2181     }
       
  2182 
       
  2183 // -----------------------------------------------------------------------------
       
  2184 // CSatNotifySelectItem::MessageReceived
       
  2185 // Handles a SelectItem proactive command ISI message,
       
  2186 // and completes a pending ETel request.
       
  2187 // (other items were commented in a header).
       
  2188 // -----------------------------------------------------------------------------
       
  2189 //
       
  2190 void CSatNotifySelectItem::MessageReceived
       
  2191         (
       
  2192         const TIsiReceiveC& aIsiMessage // ISI message
       
  2193         )
       
  2194     {
       
  2195     OstTrace0( TRACE_NORMAL, CSATNOTIFYSELECTITEM_MESSAGERECEIVED, "CSatNotifySelectItem::MessageReceived" );
       
  2196     TFLOGSTRING("CSatNotifySelectItem::MessageReceived");
       
  2197     TInt ret( KErrNone );
       
  2198     // Get ber tlv
       
  2199     CBerTlv berTlv;
       
  2200     berTlv.BerTlv( aIsiMessage );
       
  2201     // Get command details tlv
       
  2202     CTlv commandDetails;
       
  2203     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  2204     // Store command details tlv
       
  2205     iCommandDetails.Copy( commandDetails.Data() );
       
  2206     // Get command qualifier
       
  2207     TUint8 cmdQualifier(
       
  2208         commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  2209     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  2210     if ( !iReqHandle )
       
  2211         {
       
  2212         // Request not on, returning response immediately
       
  2213         iSatMessHandler->SelectItemTerminalResp(
       
  2214             iTransId,                       // Transaction id
       
  2215             iCommandDetails,                // Command details TLV
       
  2216             RSat::KMeUnableToProcessCmd,    // Result
       
  2217             KNoCause  );                    // Additional info
       
  2218         }
       
  2219     else
       
  2220         {
       
  2221          // Fill the select item structure
       
  2222          RSat::TSelectItemV2& selectItemV2 = ( *iSelectItemV2Pckg )();
       
  2223         // Store command number
       
  2224         selectItemV2.SetPCmdNumber(
       
  2225             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  2226         TPtrC8 sourceString; // Used in unicode conversions
       
  2227         // Alpha id string (optional)
       
  2228         selectItemV2.iAlphaId.iAlphaId.Zero();
       
  2229         CTlv alphaIdentifier;
       
  2230         TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifier,
       
  2231                                                 KTlvAlphaIdentifierTag ) );
       
  2232         // If alpha id string exist
       
  2233         if ( KErrNone == returnValue )
       
  2234             {
       
  2235             TUint16 alphaIdLength(
       
  2236                 alphaIdentifier.GetLength() );
       
  2237            if ( alphaIdLength )
       
  2238                 {
       
  2239                 // Get the alpha id
       
  2240                 sourceString.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  2241 
       
  2242                 // Convert and set the alpha id
       
  2243                 TSatUtility::SetAlphaId( sourceString ,
       
  2244                                          selectItemV2.iAlphaId.iAlphaId );
       
  2245                 }
       
  2246             // Check alpha tag (id) status
       
  2247            if ( alphaIdLength )
       
  2248                 {
       
  2249                 // Alpha tag present
       
  2250                 if ( selectItemV2.iAlphaId.iAlphaId.Length() )
       
  2251                     {
       
  2252                     selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  2253                     }
       
  2254                 else
       
  2255                     {
       
  2256                     selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  2257                     }
       
  2258                 }
       
  2259            }
       
  2260         // Alpha id not present
       
  2261         else
       
  2262             {
       
  2263             selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  2264             }
       
  2265         // Help information
       
  2266         if ( KHelpAvailabilityMask & cmdQualifier )
       
  2267             {
       
  2268             // Help information available
       
  2269             selectItemV2.iHelp = RSat::EHelpAvailable;
       
  2270             }
       
  2271         else
       
  2272             {
       
  2273             // No help
       
  2274             selectItemV2.iHelp = RSat::ENoHelpAvailable;
       
  2275             }
       
  2276 
       
  2277         // Presentation type
       
  2278         if ( KSelectItemPresentationTypeMask & cmdQualifier )
       
  2279             {
       
  2280             if ( KSelectItemChoiceOfNavigationMask & cmdQualifier )
       
  2281                 {
       
  2282                 // Presentation as a choice of navigation options
       
  2283                 selectItemV2.iPresentationType = RSat::ENavigationOptions;
       
  2284                 }
       
  2285             else
       
  2286                 {
       
  2287                 // Presentation as a choice of data values
       
  2288                 selectItemV2.iPresentationType = RSat::EDataValues;
       
  2289                 }
       
  2290             }
       
  2291         else
       
  2292             {
       
  2293             TFLOGSTRING("TSY: CSatNotifySelectItem::MessageReceived, \
       
  2294             Presentation type was not set.");
       
  2295             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSELECTITEM_MESSAGERECEIVED, "CSatNotifySelectItem::MessageReceived, Presentation type was not set" );
       
  2296 
       
  2297             selectItemV2.iPresentationType = RSat::ENotSpecified;
       
  2298             }
       
  2299         // Selection preference
       
  2300         if ( KSelectItemSelectUsingSoftKeyMask & cmdQualifier )
       
  2301             {
       
  2302             // Preference = soft key
       
  2303             selectItemV2.iPreference = RSat::ESoftKeyPreferred;
       
  2304             }
       
  2305         else
       
  2306             {
       
  2307             // Preference not set
       
  2308             selectItemV2.iPreference = RSat::ENoSelectionPreference;
       
  2309             }
       
  2310         // Default item id ( optional )
       
  2311         CTlv defaultItem;
       
  2312         returnValue = berTlv.TlvByTagValue( &defaultItem,
       
  2313                                             KTlvItemIdentifierTag );
       
  2314         if ( KErrNone == returnValue )
       
  2315             {
       
  2316             selectItemV2.iDefaultItemId =
       
  2317                 defaultItem.GetShortInfo( ETLV_IdentifierOfItemChosen );
       
  2318             }
       
  2319         // Icon qualifier list ( optional )
       
  2320         // Each item of a list of items has an icon identifier coded on one
       
  2321         // byte. The length of the Items icon identifier list shall be the
       
  2322         // number of items of the list of items (X-1 shall be the number of
       
  2323         // items in the list). The order of each item icon identifier,
       
  2324         // shall reflect the order of the items in the list of items.
       
  2325         // Each icon identifier addresses a record
       
  2326         // in EFIMG as defined in TS 11.11
       
  2327         CTlv itemsIconIdentifierList;
       
  2328         TInt retValue( berTlv.TlvByTagValue( &itemsIconIdentifierList,
       
  2329                                              KTlvItemIconIdentifierListTag ) );
       
  2330         selectItemV2.iIconListQualifier = RSat::EIconQualifierNotSet;
       
  2331         TPtrC8 iconIdList;
       
  2332         if ( KErrNone == retValue )
       
  2333             {
       
  2334             TUint8 iconListQualifier( itemsIconIdentifierList.GetShortInfo(
       
  2335                 ETLV_IconListQualifier ) );
       
  2336             // set iconIdList pointer
       
  2337             iconIdList.Set(
       
  2338                 itemsIconIdentifierList.GetData( ETLV_IconIdentifierList ));
       
  2339             // The icon list qualifier indicates to the ME how
       
  2340             // the icons are to be used
       
  2341             if( iconListQualifier )
       
  2342                 {
       
  2343                 // icon is not self-explanatory, i.e. if displayed,
       
  2344                 // it shall be displayed together with the item text
       
  2345                 selectItemV2.iIconListQualifier = RSat::ENotSelfExplanatory;
       
  2346                 }
       
  2347             else
       
  2348                 {
       
  2349                 // icon is self-explanatory, i.e. if displayed,
       
  2350                 // it replaces the item text
       
  2351                 selectItemV2.iIconListQualifier = RSat::ESelfExplanatory;
       
  2352                 }
       
  2353             }
       
  2354         else if ( KErrNotFound == retValue )
       
  2355             {
       
  2356             selectItemV2.iIconListQualifier = RSat::ENoIconId;
       
  2357             }
       
  2358         else
       
  2359             {
       
  2360             TFLOGSTRING("TSY: CSatNotifySelectItem::MessageReceived, \
       
  2361             Return value not valid.");
       
  2362             OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYSELECTITEM_MESSAGERECEIVED, "CSatNotifySelectItem::MessageReceived, Return value not valid." );
       
  2363 
       
  2364             }
       
  2365 
       
  2366         CTlv item;
       
  2367         // Get all items
       
  2368         returnValue = berTlv.TlvByTagValueMulti( &item, KTlvItemTag );
       
  2369         TPtrC8 itemData = item.Data();
       
  2370         TUint8 numberOfItemData( 0 );
       
  2371         TInt ind( 0 );
       
  2372         TUint16 tlvLength( 0 );
       
  2373         TInt currentTlv( 0 );
       
  2374         TInt i( 0 );
       
  2375         // Set numberOfItemData
       
  2376         for ( i = 0; i < itemData.Length(); i += TInt( tlvLength ) )
       
  2377             {
       
  2378             // First determine if the length of the TLV is
       
  2379             // coded with 1 or 2 bytes.
       
  2380             if ( KTwoByteLengthCoding == itemData[ind+1] )
       
  2381                 {
       
  2382                 // Length is coded with 2 bytes -> real length is in second
       
  2383                 // byte first byte is 81 and it is "tag" for 2 byte length
       
  2384                 // coding.
       
  2385                 tlvLength =
       
  2386                     TUint16( itemData[ind + 2] + KTlvHeaderLength + 1 );
       
  2387                 }
       
  2388             else
       
  2389                 {
       
  2390                 //TLV header bytes (2) must be added to total length
       
  2391                 tlvLength = TUint16( itemData[ind + 1]  + KTlvHeaderLength );
       
  2392                 }
       
  2393 
       
  2394             currentTlv = itemData[ind]&KTagValueMask;
       
  2395 
       
  2396             if ( KTlvItemTag == currentTlv )
       
  2397                 {
       
  2398                 numberOfItemData++;
       
  2399                 }
       
  2400 
       
  2401             ind += tlvLength;
       
  2402             }
       
  2403 
       
  2404         // See if itemnextindicator is included ( optional )
       
  2405         CTlv nextIndicator;
       
  2406 
       
  2407         returnValue = berTlv.TlvByTagValue( &nextIndicator,
       
  2408             KTlvItemsNextActionIndicatorTag );
       
  2409         TPtrC8 itemNextIndicator;
       
  2410         if ( KErrNone == returnValue )
       
  2411             {
       
  2412             TPtrC8 itemNextIndicatorTemp;
       
  2413             itemNextIndicatorTemp.Set(
       
  2414                 nextIndicator.GetData( ETLV_ItemsNextActionIndicator ) );
       
  2415 
       
  2416             //In case the number of items in this list does not match the number
       
  2417             //of items in the menu the Items Next Action Indicator list is ignored by ME
       
  2418             if( itemNextIndicatorTemp.Length() != numberOfItemData )
       
  2419                 {
       
  2420                 iItemNextIndicatorRemoved = ETrue;
       
  2421                 }
       
  2422             else
       
  2423                 {
       
  2424                 itemNextIndicator.Set(itemNextIndicatorTemp);
       
  2425                 }
       
  2426             }
       
  2427 
       
  2428         // Filling up the menu items
       
  2429         RSat::TItem newItem;
       
  2430         // Set string length and pos
       
  2431         TUint8 stringLength( 0 );
       
  2432         TUint8  pos( 2 );
       
  2433         // Transfers menu items to EtelSat data structure
       
  2434         for ( i = 0; ( i < numberOfItemData ) && ( KErrNone == ret ); i++ )
       
  2435             {
       
  2436             // Check if two byte length coding is used
       
  2437             if ( itemData[pos - 1] == KTwoByteLengthCoding )
       
  2438                 {
       
  2439                 // Set new offset
       
  2440                 pos++;
       
  2441                 }
       
  2442             // Fill item if TLV contains real data, length < 0
       
  2443             if ( KZero < itemData[pos - 1] )
       
  2444                 {
       
  2445                 // Fill the newitem
       
  2446                 newItem.iItemId = itemData[pos];
       
  2447                 stringLength = itemData[pos - 1];
       
  2448                 }
       
  2449             else
       
  2450                 {
       
  2451                 // No real ítem data in TLV
       
  2452                 newItem.iItemId = 0;
       
  2453                 stringLength = 0;
       
  2454                 }
       
  2455 
       
  2456             // Copying the string from 8-bit to 16-bit
       
  2457             if ( stringLength > RSat::KMenuItemMaxSize )
       
  2458                 {
       
  2459                 // String too long
       
  2460                 ret = KErrCorrupt;
       
  2461                 }
       
  2462             newItem.iItemString.Zero();
       
  2463             // ArabicCoding, GreekCoding and TurkishCoding have different
       
  2464             // coding method. There is a tag for each type of alphabet
       
  2465             // (resp. 80, 81 or 82) before the text, and there are base
       
  2466             // pointers used for expanding 1 byte to 2 bytes as required
       
  2467             // in UCS2
       
  2468             // Ref: 3gpp 11.11, Annex B
       
  2469 
       
  2470             //Check if string present
       
  2471             if ( 0 < ( stringLength - 1 ) )
       
  2472                 {
       
  2473                 TBuf8<RSat::KTextStringMaxSize> itemText;
       
  2474                 itemText = itemData.Mid( pos + 1, stringLength - 1 );
       
  2475 
       
  2476                 if ( ( itemText[0] == KUCS2ArabicCoding )
       
  2477                     || ( itemText[0] == KUCS2GreekCoding )
       
  2478                     || ( itemText[0] == KUCS2TurkishCoding ) )
       
  2479                     {
       
  2480                     TSatUtility::ConvertAlphaFieldsToUnicode( itemText,
       
  2481                     newItem.iItemString );
       
  2482                     }
       
  2483                 else
       
  2484                     {
       
  2485                     // 8-bit format
       
  2486                     TSatUtility::ConvertSms7ToUnicode16( newItem.iItemString,
       
  2487                                                          itemText );
       
  2488                     }
       
  2489                 }
       
  2490 
       
  2491             if( NULL != iconIdList.Size()
       
  2492                 && ( i < iconIdList.Length() ) )
       
  2493                 {
       
  2494                 if( ( NULL != itemNextIndicator.Size() )
       
  2495                     && ( i < itemNextIndicator.Length() ) )
       
  2496                     {
       
  2497                     // ADD ITEM WITH ITEM NEXT INDICATOR AND ICON IDENTIFIER
       
  2498                     if ( KErrNoMemory == selectItemV2.AddItem(
       
  2499                         newItem, itemNextIndicator[i], iconIdList[i] ) )
       
  2500                         {
       
  2501                         // Too many or long menu items
       
  2502                         ret = KErrCorrupt;
       
  2503                         }
       
  2504                     }
       
  2505                 // ADD ITEM WITH ICON
       
  2506                 else if ( KErrNoMemory == selectItemV2.AddItemIcon(
       
  2507                     newItem, iconIdList[i] ) )
       
  2508                     {
       
  2509                     // Too many or long menu items
       
  2510                     ret = KErrCorrupt;
       
  2511                     }
       
  2512                 else
       
  2513                     {
       
  2514                     TFLOGSTRING("TSY: CSatNotifySelectItem::MessageReceived,\
       
  2515                     Item with icon not valid.");
       
  2516                     OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSELECTITEM_MESSAGERECEIVED, "CSatNotifySelectItem::MessageReceived, Item with icon not valid." );
       
  2517                     }
       
  2518                 }
       
  2519             else
       
  2520                 {
       
  2521                 if( ( NULL != itemNextIndicator.Size() )
       
  2522                     && ( i < itemNextIndicator.Length() ) )
       
  2523                     {
       
  2524                     // ADD ITEM WITH ITEM NEXT INDICATOR
       
  2525                     if ( KErrNoMemory == selectItemV2.AddItem(
       
  2526                         newItem, itemNextIndicator[i] ) )
       
  2527                         {
       
  2528                         // Too many or long menu items
       
  2529                         ret = KErrCorrupt;
       
  2530                         }
       
  2531                     }
       
  2532                 //ADD ITEM
       
  2533                 else
       
  2534                     {
       
  2535                     TInt retAdd = selectItemV2.AddItem( newItem );
       
  2536                     if ( KErrNoMemory == retAdd )
       
  2537                         {
       
  2538                         // Too many or long menu items
       
  2539                         // If there is not enough space left in the buffer used
       
  2540                         // by the menu KErrNoMemory is returned.
       
  2541                         // Send terminal response
       
  2542                         iSatMessHandler->SelectItemTerminalResp(
       
  2543                             iTransId,                        // transaction id
       
  2544                             iCommandDetails,                // Command details TLV
       
  2545                             RSat::KCmdDataNotUnderstood,    // Result
       
  2546                             KNoCause );                     // Additional info
       
  2547                         ret = KErrCorrupt;
       
  2548                         }
       
  2549                     }
       
  2550                 }
       
  2551             // Calculating the new position
       
  2552             pos = TUint8( pos + itemData[pos - 1] + 2 );
       
  2553             }
       
  2554         // Iconid
       
  2555         TSatUtility::FillIconStructure( berTlv, selectItemV2.iIconId );
       
  2556         CompleteRequest( ret );
       
  2557         }
       
  2558     }
       
  2559 
       
  2560 // -----------------------------------------------------------------------------
       
  2561 // CSatNotifySelectItem::Notify
       
  2562 // An ETel SAT client can call this method via ETel server to set a pending
       
  2563 // request in SimAtkTsy for a SelectItem PCmd.
       
  2564 // (other items were commented in a header).
       
  2565 // -----------------------------------------------------------------------------
       
  2566 //
       
  2567 void CSatNotifySelectItem::Notify
       
  2568         (
       
  2569         const TTsyReqHandle aReqHandle, // Request handle
       
  2570         TDes8*              aDataPtr    // Pointer to data
       
  2571         )
       
  2572     {
       
  2573     OstTrace1( TRACE_NORMAL, CSATNOTIFYSELECTITEM_NOTIFY, "CSatNotifySelectItem::Notify Handle: %u", aReqHandle );
       
  2574     TFLOGSTRING2("CSatNotifySelectItem::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  2575                aReqHandle );
       
  2576     iReqHandle = aReqHandle;
       
  2577     iSelectItemV2Pckg = static_cast< RSat::TSelectItemV2Pckg* >( aDataPtr );
       
  2578     iSatMessaging->SatReady( KSelectItem );
       
  2579     }
       
  2580 
       
  2581 // -----------------------------------------------------------------------------
       
  2582 // CSatNotifySelectItem::TerminalResponse
       
  2583 // Handles a SelectItem terminal response provided by an ETel SAT client via
       
  2584 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  2585 // (other items were commented in a header).
       
  2586 // -----------------------------------------------------------------------------
       
  2587 //
       
  2588 TInt CSatNotifySelectItem::TerminalResponse
       
  2589         (
       
  2590         TDes8* aRsp // Response
       
  2591         )
       
  2592     {
       
  2593     OstTrace0( TRACE_NORMAL, CSATNOTIFYSELECTITEM_TERMINALRESPONSE, "CSatNotifySelectItem::TerminalResponse" );
       
  2594     TFLOGSTRING("CSatNotifySelectItem::TerminalResponse");
       
  2595     TInt   ret( KErrNone );
       
  2596     TUint8 additionalInfo( 0 );
       
  2597     RSat::TSelectItemRspV1Pckg* aRspPckg =
       
  2598             reinterpret_cast<RSat::TSelectItemRspV1Pckg*>( aRsp );
       
  2599     RSat::TSelectItemRspV1& rspV1 = ( *aRspPckg ) ();
       
  2600 
       
  2601     // Check that general result values are valid
       
  2602     if ( iAllowedResults != rspV1.iGeneralResult )
       
  2603         {
       
  2604         // Invalid general result
       
  2605         ret = KErrCorrupt;
       
  2606         }
       
  2607 
       
  2608     // If there is Me (Mobile Entity) error or there there should be
       
  2609     // item identifier or
       
  2610     // general result is success, additional info is needed
       
  2611     if ( ( RSat::KMeProblem == rspV1.iInfoType )
       
  2612         || ( RSat::KItemIdentifier == rspV1.iInfoType )
       
  2613         || ( RSat::KSuccess == rspV1.iGeneralResult ) )
       
  2614         {
       
  2615         // Check the length of additional info
       
  2616         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
  2617             {
       
  2618             additionalInfo = static_cast<TUint8>( rspV1.iAdditionalInfo[0] );
       
  2619             }
       
  2620         else
       
  2621             {
       
  2622             // Invalid additional info field
       
  2623             ret = KErrCorrupt;
       
  2624             }
       
  2625         }
       
  2626 
       
  2627     if( RSat::KSuccess == rspV1.iGeneralResult && iItemNextIndicatorRemoved )
       
  2628         {
       
  2629         TFLOGSTRING("CSatNotifySelectItem::TerminalResponseL, iItemNextIndicatorRemoved");
       
  2630         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSELECTITEM_TERMINALRESPONSE, "CSatNotifySelectItem::TerminalResponse, iItemNextIndicatorRemoved" );
       
  2631 
       
  2632         rspV1.iGeneralResult = RSat::KPartialComprehension;
       
  2633         }
       
  2634     iItemNextIndicatorRemoved = EFalse;
       
  2635 
       
  2636     iSatMessHandler->SelectItemTerminalResp(
       
  2637                                 iTransId,                    // Transaction id
       
  2638                                 iCommandDetails,            // Command details
       
  2639                                 static_cast< TUint8 >(
       
  2640                                     rspV1.iGeneralResult ), // General result
       
  2641                                 additionalInfo );           // Additional info
       
  2642     return ret;
       
  2643 
       
  2644     }
       
  2645 
       
  2646 
       
  2647 // -----------------------------------------------------------------------------
       
  2648 // CSatNotifySendSm::CSatNotifySendSm
       
  2649 // C++ default constructor can NOT contain any code, that
       
  2650 // might leave.
       
  2651 // -----------------------------------------------------------------------------
       
  2652 //
       
  2653 CSatNotifySendSm::CSatNotifySendSm
       
  2654         (
       
  2655         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  2656         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  2657         )
       
  2658         :
       
  2659         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  2660         iSendSmV1Pckg( NULL )
       
  2661     {
       
  2662     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_CSATNOTIFYSENDSM, "CSatNotifySendSm::CSatNotifySendSm" );
       
  2663     // Following results are also allowed for this command:
       
  2664     // (in addition to result declared in base class constructor)
       
  2665     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  2666         + RSat::KNetworkUnableToProcessCmd + RSat::KSmsRpError
       
  2667         + RSat::KErrorRequiredValuesMissing
       
  2668         + RSat::KInteractionWithCCPermanentError;
       
  2669     }
       
  2670 
       
  2671 // -----------------------------------------------------------------------------
       
  2672 // CSatNotifySendSm::~CSatNotifySendSm
       
  2673 // Destructor
       
  2674 // -----------------------------------------------------------------------------
       
  2675 //
       
  2676 CSatNotifySendSm::~CSatNotifySendSm()
       
  2677     {
       
  2678     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDSM_CSATNOTIFYSENDSM, "CSatNotifySendSm::~CSatNotifySendSm" );
       
  2679     // None
       
  2680     }
       
  2681 
       
  2682 // -----------------------------------------------------------------------------
       
  2683 // CSatNotifySendSm::MessageReceived
       
  2684 // Handles a SendSm proactive command ISI message,
       
  2685 // and completes a pending ETel request.
       
  2686 // (other items were commented in a header).
       
  2687 // -----------------------------------------------------------------------------
       
  2688 //
       
  2689 void CSatNotifySendSm::MessageReceived
       
  2690         (
       
  2691         const TIsiReceiveC& aIsiMessage // ISI message
       
  2692         )
       
  2693     {
       
  2694     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_MESSAGERECEIVED, "CSatNotifySendSm::MessageReceived" );
       
  2695     TFLOGSTRING("CSatNotifySendSm::MessageReceived");
       
  2696     TInt ret( KErrNone );
       
  2697     // Get ber tlv
       
  2698     CBerTlv berTlv;
       
  2699     berTlv.BerTlv( aIsiMessage );
       
  2700     // Get command details tlv
       
  2701     CTlv commandDetails;
       
  2702     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  2703     // Store command details tlv
       
  2704     iCommandDetails.Copy( commandDetails.Data() );
       
  2705     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  2706     if ( !iReqHandle )
       
  2707         {
       
  2708         // Request not on, returning response immediately
       
  2709         iSatMessHandler->SendSmTerminalResp(
       
  2710             iTransId,                       // Transaction id
       
  2711             iCommandDetails,                // Command details tlv
       
  2712             RSat::KMeUnableToProcessCmd,    // Result
       
  2713             KNoCause );                     // Additional info
       
  2714         }
       
  2715     else
       
  2716         {
       
  2717         // Fill the send sm structure
       
  2718         RSat::TSendSmV1& sendSmV1 = ( *iSendSmV1Pckg )();
       
  2719         // Store command number
       
  2720         sendSmV1.SetPCmdNumber(
       
  2721             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  2722         sendSmV1.iSmsTpdu.Zero();
       
  2723         CTlv smsTpduTlv;
       
  2724         // Get TPdu tlv
       
  2725         TInt returnValue( berTlv.TlvByTagValue( &smsTpduTlv,
       
  2726                                                 KTlvSmsTpduTag ) );
       
  2727         if ( KErrNone == returnValue )
       
  2728             {
       
  2729             // Tpdu TLV length
       
  2730             TUint16 smsTpduLength( smsTpduTlv.GetLength() );
       
  2731             // Set pointer to Tpdu
       
  2732             TPtrC8 smsTpdu = smsTpduTlv.GetData( ETLV_SmsTPdu );
       
  2733             // Check that TP-UDL is valid
       
  2734             ret = CheckTpdu( smsTpdu );
       
  2735             if ( KErrCorrupt == ret )
       
  2736                 {
       
  2737                 // Length of TPDU is invalid
       
  2738                 iSatMessHandler->SendSmTerminalResp(
       
  2739                          iTransId,                      // Transaction id
       
  2740                          iCommandDetails,               // Command details tlv
       
  2741                          RSat::KCmdDataNotUnderstood,   // Result
       
  2742                          KNoCause );                    // Additional info
       
  2743                 }
       
  2744             if ( smsTpduLength && KErrNone == ret )
       
  2745                 {
       
  2746                 // Copying the smsTpdu
       
  2747                 sendSmV1.iSmsTpdu.Append( smsTpdu );
       
  2748                 }
       
  2749             // Checking if packing is required for the SMS message or not
       
  2750             // Packing: see ETSI 3.38 and 3.40
       
  2751             if ( KSmsPackingRequiredMask & iCommandDetails[KCommandQualifier]
       
  2752                 && ( KErrNone == ret ) )
       
  2753                 {
       
  2754                 // Packing required
       
  2755                 if ( smsTpduLength )
       
  2756                     {
       
  2757                     // Call method to pack sms
       
  2758                     ret = PackSms( smsTpdu, sendSmV1.iSmsTpdu );
       
  2759                     if ( KErrNone != ret )
       
  2760                         {
       
  2761                         // tpdu is invalid or packing cannot be requested
       
  2762                         // if tpdu is something else than SMS-SUBMIT
       
  2763                         iSatMessHandler->SendSmTerminalResp(
       
  2764                             iTransId,                   // Transaction id
       
  2765                             iCommandDetails,            // Command details tlv
       
  2766                             RSat::KCmdDataNotUnderstood,// Result
       
  2767                             KNoCause );                 // Additional info
       
  2768                         ret = KErrCorrupt;
       
  2769                         }
       
  2770                     }
       
  2771                 }
       
  2772             }
       
  2773         else
       
  2774             {
       
  2775             // TPdu is missing, returning response immediately
       
  2776             iSatMessHandler->SendSmTerminalResp(
       
  2777                          iTransId,                      // Transaction id
       
  2778                          iCommandDetails,               // Command details tlv
       
  2779                          RSat::KErrorRequiredValuesMissing,// Result
       
  2780                          KNoCause );                    // Additional info
       
  2781             ret = KErrCorrupt;
       
  2782             }
       
  2783         if ( KErrNone == ret )
       
  2784             {
       
  2785             TPtrC8 sourceString; // Used in unicode conversions
       
  2786             // Alpha id string (optional)
       
  2787             sendSmV1.iAlphaId.iAlphaId.Zero();
       
  2788             CTlv alphaIdTlv;
       
  2789             returnValue = berTlv.TlvByTagValue( &alphaIdTlv,
       
  2790                                                 KTlvAlphaIdentifierTag ) ;
       
  2791             if ( KErrNone == returnValue )
       
  2792                 {
       
  2793                 // alpha id tlv found
       
  2794                 if ( alphaIdTlv.GetLength() )
       
  2795                     {
       
  2796                     // get alpha id text
       
  2797                     sourceString.Set(
       
  2798                         alphaIdTlv.GetData( ETLV_AlphaIdentifier ) );
       
  2799 
       
  2800                     // convert and set alpha id
       
  2801                     TSatUtility::SetAlphaId( sourceString,
       
  2802                                              sendSmV1.iAlphaId.iAlphaId );
       
  2803                     }
       
  2804                 // Alpha Tag present
       
  2805                 if ( sendSmV1.iAlphaId.iAlphaId.Length() )
       
  2806                     {
       
  2807                     sendSmV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  2808                     }
       
  2809                 else
       
  2810                     {
       
  2811                     sendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  2812                     }
       
  2813                 }
       
  2814             else
       
  2815                 {
       
  2816                 sendSmV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  2817                 }
       
  2818             // The address data object holds the RP_Destination_Address of the
       
  2819             // Service Centre. If no RP_Destination_Address is transferred,
       
  2820             // then the ME shall insert the default Service Centre address.
       
  2821             // Service centre address
       
  2822             sendSmV1.iAddress.iTelNumber.Zero();
       
  2823             CTlv addressTlv;
       
  2824             // Get address tlv. Includes SCA number. (optional)
       
  2825             returnValue = berTlv.TlvByTagValue( &addressTlv, KTlvAddressTag );
       
  2826             if ( KErrNone == returnValue )
       
  2827                 {
       
  2828                 if ( 0 < addressTlv.GetLength() )
       
  2829                     {
       
  2830                     // Initialize ton and npi
       
  2831                     RSat::TTypeOfNumber ton;
       
  2832                     RSat::TNumberingPlan npi;
       
  2833                     // Call utility function that maps received TON and NPI to
       
  2834                     // RSat values
       
  2835                     TSatUtility::GetTonAndNpi(
       
  2836                         addressTlv.GetShortInfo( ETLV_TonAndNpi ), &ton, &npi );
       
  2837                     // Set TON and NPI
       
  2838                     sendSmV1.iAddress.iTypeOfNumber = ton;
       
  2839                     sendSmV1.iAddress.iNumberPlan = npi;
       
  2840 
       
  2841                     TBuf8<RSat::KMaxMobileTelNumberSize> tempScaNumber;
       
  2842                     // set pointer to address tlv
       
  2843                     sourceString.Set(
       
  2844                         addressTlv.GetData( ETLV_DiallingNumberString ) );
       
  2845                     if ( sourceString.Length() )
       
  2846                         {
       
  2847                         // Semi-octet presentation used
       
  2848                         // Converting back to ASCII format
       
  2849                         TSatUtility::BCDToAscii( sourceString, tempScaNumber );
       
  2850 
       
  2851                         sendSmV1.iAddress.iTelNumber.Copy( tempScaNumber );
       
  2852 
       
  2853                         TFLOGSTRING2("TSY:SendSm, SCA number: %S",
       
  2854                         &sendSmV1.iAddress.iTelNumber );
       
  2855                         OstTraceExt1( TRACE_NORMAL, DUP1_CSATNOTIFYSENDSM_MESSAGERECEIVED, "CSatNotifySendSm::MessageReceived SCA number: %S", sendSmV1.iAddress.iTelNumber );
       
  2856                         }
       
  2857                     else
       
  2858                         {
       
  2859                         // Address TLV found, TON/NPI present, but number epmpty.
       
  2860                         sendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
       
  2861                         sendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
       
  2862                         }
       
  2863                     }
       
  2864                 else
       
  2865                     {
       
  2866                     // Address TLV found, but the Value part doesn't exist
       
  2867                     sendSmV1.iAddress.iTypeOfNumber = RSat::EUnknownNumber;
       
  2868                     sendSmV1.iAddress.iNumberPlan = RSat::EUnknownNumberingPlan;
       
  2869                     }
       
  2870                 }
       
  2871             else
       
  2872                 {
       
  2873                 // Addrress TLV not found
       
  2874                 sendSmV1.iAddress.iTypeOfNumber = RSat::ETypeOfNumberNotSet;
       
  2875                 sendSmV1.iAddress.iNumberPlan = RSat::ENumberingPlanNotSet;
       
  2876                 }
       
  2877             // Iconid
       
  2878             TSatUtility::FillIconStructure( berTlv, sendSmV1.iIconId );
       
  2879             }
       
  2880         CompleteRequest( ret );
       
  2881         }
       
  2882     }
       
  2883 
       
  2884 // -----------------------------------------------------------------------------
       
  2885 // CSatNotifySendSm::Notify
       
  2886 // An ETel SAT client can call this method via ETel server to set a pending
       
  2887 // request in SimAtkTsy for a SendSm PCmd.
       
  2888 // (other items were commented in a header).
       
  2889 // -----------------------------------------------------------------------------
       
  2890 //
       
  2891 void CSatNotifySendSm::Notify
       
  2892         (
       
  2893         const TTsyReqHandle aReqHandle, // Request handle
       
  2894         TDes8*              aDataPtr    // Pointer to data
       
  2895         )
       
  2896     {
       
  2897     OstTrace1( TRACE_NORMAL, CSATNOTIFYSENDSM_NOTIFY, "CSatNotifySendSm::Notify Handle: %u", aReqHandle );
       
  2898     TFLOGSTRING2("CSatNotifySendSm::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  2899                 aReqHandle );
       
  2900     iReqHandle = aReqHandle;
       
  2901     iSendSmV1Pckg = static_cast< RSat::TSendSmV1Pckg* >( aDataPtr );
       
  2902     iSatMessaging->SatReady( KSendShortMessage );
       
  2903     }
       
  2904 
       
  2905 // -----------------------------------------------------------------------------
       
  2906 // CSatNotifySendSm::TerminalResponse
       
  2907 // Handles a SendSm terminal response provided by an ETel SAT client via
       
  2908 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  2909 // (other items were commented in a header).
       
  2910 // -----------------------------------------------------------------------------
       
  2911 //
       
  2912 TInt CSatNotifySendSm::TerminalResponse
       
  2913         (
       
  2914         TDes8* aRsp // Response
       
  2915         )
       
  2916     {
       
  2917     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_TERMINALRESPONSE, "CSatNotifySendSm::TerminalResponse" );
       
  2918     TFLOGSTRING("CSatNotifySendSm::TerminalResponse");
       
  2919     TInt ret( KErrNone );
       
  2920     TUint8 additionalInfo( 0 );
       
  2921     RSat::TSendSmRspV1Pckg* aRspPckg =
       
  2922             reinterpret_cast< RSat::TSendSmRspV1Pckg* >( aRsp );
       
  2923     RSat::TSendSmRspV1& rspV1 = ( *aRspPckg ) ();
       
  2924     // Check that general result value is valid
       
  2925     if ( iAllowedResults != rspV1.iGeneralResult )
       
  2926         {
       
  2927         // Invalid general result
       
  2928         ret = KErrCorrupt;
       
  2929         }
       
  2930     // If there is Me (Mobile Entity) error or network error, additional info
       
  2931     // is needed
       
  2932     if ( ( RSat::KMeProblem == rspV1.iInfoType )
       
  2933         || ( RSat::KSatNetworkErrorInfo == rspV1.iInfoType )
       
  2934         || ( RSat::KControlInteraction == rspV1.iInfoType ) )
       
  2935         {
       
  2936         // Check the length of additional info
       
  2937         if ( 0 == rspV1.iAdditionalInfo.Length() )
       
  2938             {
       
  2939             // No info
       
  2940             ret = KErrCorrupt;
       
  2941             }
       
  2942         else
       
  2943             {
       
  2944             additionalInfo = static_cast< TUint8 >( rspV1.iAdditionalInfo[0] );
       
  2945             }
       
  2946         }
       
  2947     // Creating the info message
       
  2948     iSatMessHandler->SendSmTerminalResp(
       
  2949                         iTransId,                   // Transaction id
       
  2950                         iCommandDetails,            // Command details tlv
       
  2951                         static_cast< TUint8 >(
       
  2952                             rspV1.iGeneralResult ), // Result
       
  2953                         additionalInfo );           // Additional info
       
  2954     return ret;
       
  2955     }
       
  2956 
       
  2957 // -----------------------------------------------------------------------------
       
  2958 // CSatNotifySendSm::GetTpUdlIndex
       
  2959 // Returns respectively index of TP-UDL or TP-CDL field if sms type is
       
  2960 // respectively SMS-SUBMIT or SMS-COMMAND
       
  2961 // (other items were commented in a header).
       
  2962 // -----------------------------------------------------------------------------
       
  2963 //
       
  2964 TUint8 CSatNotifySendSm::GetTpUdlIndex
       
  2965     (
       
  2966     TPtrC8 aTpdu // Tpdu where to read TP-UDL or TP-CDL
       
  2967     )
       
  2968     {
       
  2969     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_GETTPUDLINDEX, "CSatNotifySendSm::GetTpUdlIndex" );
       
  2970     TFLOGSTRING("CSatNotifySendSm::GetTpUdlIndex");
       
  2971 
       
  2972     // Position on TP-UDL/TP-CDL field in SMS TPDU
       
  2973     TUint8 tpDlIndex( 0 );
       
  2974 
       
  2975     // SMS-SUBMIT
       
  2976     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
       
  2977         {
       
  2978         // Add mandatory fields at first: TP-MTI, TP-MR, TP-DA(address length,
       
  2979         // TON&NPI), TP-PID, DCS and TP-UDL.
       
  2980         // Index starts from [0]
       
  2981         tpDlIndex = KTPDUMandatoryFieldsSmsSubmitUdl;
       
  2982 
       
  2983         // Checking the TP-VP field existence and format
       
  2984         // bit4    bit3
       
  2985         // 0       0   TP-VP field not present
       
  2986         // 1       0   TP-VP field present - relative format
       
  2987         // 0       1   TP-VP field present - enhanced format
       
  2988         // 1       1   TP-VP field present - absolute format
       
  2989 
       
  2990         // Shift by 3 and mask for getting bits 3 and 4
       
  2991         TUint8 vpFormat( ( aTpdu[0] >> 3 ) & KSmsVpFormatMask );
       
  2992 
       
  2993         if ( KSmsVPFRelative == vpFormat )
       
  2994             {
       
  2995             // TP-Validity period comprises 1 octet
       
  2996             tpDlIndex++;
       
  2997             }
       
  2998         else if ( KSmsVPFEnhanced == vpFormat || KSmsVPFAbsolute == vpFormat )
       
  2999             {
       
  3000             // TP-Validity period comprises 7 octets
       
  3001             tpDlIndex += 7;
       
  3002             }
       
  3003 
       
  3004         // Calculate the address length in bytes, located in index 2
       
  3005         TUint8 addressLengthInBytes( aTpdu[2] );
       
  3006         // Address length is number of BCD characters.
       
  3007         // Two BCD string chars are coded in one byte =>
       
  3008         // divide by two (shitf to right). Before dividing, 1 is added
       
  3009         // for ensuring that result is rounded up in case of odd value
       
  3010         addressLengthInBytes++;
       
  3011         addressLengthInBytes >>= 1;
       
  3012 
       
  3013         // Add address length
       
  3014         tpDlIndex += addressLengthInBytes;
       
  3015         }
       
  3016     // SMS-COMMAND
       
  3017     else
       
  3018         {
       
  3019         // Add mandatory fields at first: TP-MTI, TP-MR, TP-PID, TP-CT, TP-MN,
       
  3020         // TP-DA(address length, TON&NPI) and TP-CDL.
       
  3021         // Index starts from [0]
       
  3022         tpDlIndex = KTPDUMandatoryFieldsSmsCommandUdl;
       
  3023         // Address length, located in index 5
       
  3024         TUint8 addressLengthInBytes( aTpdu[5] );
       
  3025         // Address length is number of BCD characters
       
  3026         // Two BCD string chars are coded in one byte =>
       
  3027         // divide by two (shitf to right). Before dividing, 1 is added
       
  3028         // for ensuring that result is rounded up in case of odd value
       
  3029         addressLengthInBytes++;
       
  3030         addressLengthInBytes >>= 1;
       
  3031 
       
  3032         // Add address length
       
  3033         tpDlIndex += addressLengthInBytes;
       
  3034         }
       
  3035 
       
  3036     return tpDlIndex; // Return TP-UDL/TP-CDL index
       
  3037     }
       
  3038 
       
  3039 // -----------------------------------------------------------------------------
       
  3040 // CSatNotifySendSm::GetTpDcsIndex
       
  3041 // Returns index of TP-DCS (data coding scheme) of the sms.
       
  3042 // SMS type is SMS-SUBMIT.
       
  3043 // (other items were commented in a header).
       
  3044 // -----------------------------------------------------------------------------
       
  3045 //
       
  3046 TUint8 CSatNotifySendSm::GetTpDcsIndex
       
  3047         (
       
  3048         TPtrC8 aTpdu // Tpdu
       
  3049         )
       
  3050     {
       
  3051     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_GETTPDCSINDEX, "CSatNotifySendSm::GetTpDcsIndex" );
       
  3052     TFLOGSTRING("CSatNotifySendSm::GetTpDcsIndex");
       
  3053 
       
  3054     // Position of TP-DCS field in SMS TPDU
       
  3055     // Add mandatory fields at first: TP-MTI, TP-MR, TP-DA(address length,
       
  3056     // TON/NPI), TP-PID and TP-DCS.
       
  3057     // Index starts from [0]
       
  3058     TUint8 tpDcsIndex( KTPDUMandatoryFieldsSmsSubmitDcs );
       
  3059     // Calculate the length of address, located in index 2
       
  3060     TUint8 addressLengthInBytes( aTpdu[2] );
       
  3061     // Address lenght is number of BCD characters.
       
  3062     // Add one for ensuring the rounding up after division in case of odd
       
  3063     // number
       
  3064     addressLengthInBytes++;
       
  3065     // Divide by two for getting length in bytes
       
  3066     addressLengthInBytes >>= 1;
       
  3067     // Add address length to dcs position
       
  3068     tpDcsIndex += addressLengthInBytes;
       
  3069 
       
  3070     return tpDcsIndex; // Return index of TP-DCS
       
  3071     }
       
  3072 
       
  3073 // -----------------------------------------------------------------------------
       
  3074 // CSatNotifySendSm::CheckTpdu
       
  3075 // Check TPDU validity
       
  3076 // (other items were commented in a header).
       
  3077 // -----------------------------------------------------------------------------
       
  3078 //
       
  3079 TInt CSatNotifySendSm::CheckTpdu
       
  3080         (
       
  3081         TPtrC8 aTpdu // TPDU
       
  3082         )
       
  3083     {
       
  3084     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu" );
       
  3085     TFLOGSTRING("CSatNotifySendSm::CheckTpdu");
       
  3086     TInt ret( KErrNone );
       
  3087     TUint8 tpUdlPos( 0 ); // UDL position
       
  3088     TUint8 tpUdl( 0 ); // User data length
       
  3089     TUint8 bufferLength( aTpdu.Length() ); // TPDU buffer length
       
  3090 
       
  3091     // At first check that TPDU length isn't under minimum
       
  3092     if ( KMinSmsTpduLength > bufferLength )
       
  3093         {
       
  3094         TFLOGSTRING("CSatNotifySendSm::CheckTpdu, error: invalid TPDU length");
       
  3095         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu, error: invalid TPDU length" );
       
  3096         ret = KErrCorrupt;
       
  3097         }
       
  3098     else
       
  3099         {
       
  3100         // Get index of UDL field
       
  3101         tpUdlPos = GetTpUdlIndex( aTpdu );
       
  3102         // Check that UDL index is valid
       
  3103         if ( tpUdlPos < bufferLength )
       
  3104             {
       
  3105             // Get user data length in 8-bit characters (without packing)
       
  3106             tpUdl = aTpdu[tpUdlPos];
       
  3107             }
       
  3108         else
       
  3109             {
       
  3110             TFLOGSTRING("CSatNotifySendSm::CheckTpdu, error: invalid UDL index");
       
  3111             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu, error: invalid UDL index" );
       
  3112             ret = KErrCorrupt;
       
  3113             }
       
  3114         }
       
  3115 
       
  3116     if ( KErrNone == ret )
       
  3117         {
       
  3118         // SMS-SUBMIT
       
  3119         if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
       
  3120             {
       
  3121             // Only user data bytes are remained
       
  3122             bufferLength -= ( tpUdlPos + 1 );
       
  3123             // Get index of TP-DCS field
       
  3124             TUint8 tpDcsPos( GetTpDcsIndex( aTpdu ) );
       
  3125             // Get data coding scheme
       
  3126             TUint8 dcs( aTpdu[tpDcsPos] );
       
  3127 
       
  3128             // Bits 2 and 3 are for coding scheme ( spec. 3GPP TS23.038 )
       
  3129             dcs = ( dcs >> 2 ) & 0x03;
       
  3130             // GSM 7 bit default alphabet
       
  3131             if ( KSmsDcsDefaultAlphabet == dcs )
       
  3132                 {
       
  3133                 // When 7 bit packing is used, number of characters is calculated
       
  3134                 // as follows (spec. 3GPP TS 23.038 V7.0.0 ):
       
  3135                 // number of characters = length of user data in bytes * 8 / 7
       
  3136                 bufferLength = ( bufferLength * 8 ) / 7;
       
  3137                 // Check the validity of user data length
       
  3138                 if ( KSmsMaxSize < tpUdl || bufferLength < tpUdl )
       
  3139                     {
       
  3140                     // Message is over 160 bytes or invalid user data length
       
  3141                     TFLOGSTRING("CSatNotifySendSm::CheckTpdu, error: invalid user data length");
       
  3142                     OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu, error: invalid user data length" );
       
  3143                     ret = KErrCorrupt;
       
  3144                     }
       
  3145                 }
       
  3146             else // 8-bit or 16-bit data
       
  3147                 {
       
  3148                 // Check if packing is required
       
  3149                 TBool isPackingRequired( KSmsPackingRequiredMask &
       
  3150                     iCommandDetails[KCommandQualifier] );
       
  3151                 TUint8 maxSmsSize( isPackingRequired ?
       
  3152                     KSmsMaxSize : KSmsMaxSizeWithoutPacking );
       
  3153                 // Check the validity of user data length
       
  3154                 if ( maxSmsSize < tpUdl || bufferLength < tpUdl )
       
  3155                     {
       
  3156                     // Message size is over the limit or invalid user data length
       
  3157                     TFLOGSTRING("CSatNotifySendSm::CheckTpdu, error: invalid user data length");
       
  3158                     OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu, error: invalid user data length" );
       
  3159                     ret = KErrCorrupt;
       
  3160                     }
       
  3161                 }
       
  3162             } // end of if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
       
  3163         else // SMS-COMMAND
       
  3164             {
       
  3165             if ( KSMSCommandMaxSize < tpUdl )
       
  3166                 {
       
  3167                 TFLOGSTRING("CSatNotifySendSm::CheckTpdu, error: user data length over maximum");
       
  3168                 OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYSENDSM_CHECKTPDU, "CSatNotifySendSm::CheckTpdu, error: user data length over maximum" );
       
  3169                 ret = KErrCorrupt;
       
  3170                 }
       
  3171             }
       
  3172         } // End of if ( KErrNone == ret )
       
  3173     return ret;
       
  3174     }
       
  3175 
       
  3176 // -----------------------------------------------------------------------------
       
  3177 // CSatNotifySendSm::PackSms
       
  3178 // Pack SMS content if it is required by the sim
       
  3179 // (other items were commented in a header).
       
  3180 // -----------------------------------------------------------------------------
       
  3181 //
       
  3182 TInt CSatNotifySendSm::PackSms
       
  3183         (
       
  3184         TPtrC8 aTpdu, // Received Tpdu
       
  3185         TTpdu& aSendSm // Where to store packed sms
       
  3186         )
       
  3187     {
       
  3188     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSM_PACKSMS, "CSatNotifySendSm::PackSms" );
       
  3189     TFLOGSTRING("CSatNotifySendSm::PackSms");
       
  3190     TInt ret( KErrNone );
       
  3191 
       
  3192     // Checking the message type, SMS-SUBMIT can be packed:
       
  3193     //
       
  3194     // Bit1 | Bit0 | Message type
       
  3195     // ------------------------------------------------------------
       
  3196     //   0  |   0  | SMS-DELIVER (in the direction SC to MS)
       
  3197     //   0  |   0  | SMS-DELIVER REPORT (in the direction MS to SC)
       
  3198     //   1  |   0  | SMS-STATUS-REPORT (in the direction SC to MS)
       
  3199     //   1  |   0  | SMS-COMMAND (in the direction MS to SC)
       
  3200     //   0  |   1  | SMS-SUBMIT (in the direction MS to SC)
       
  3201     //   0  |   1  | SMS-SUBMIT-REPORT (in the direction SC to MS)
       
  3202     //   1  |   1  | Reserved
       
  3203     //
       
  3204     if ( KSATSmsMTISubmitOrSubmitReport == ( aTpdu[0] & KMask3 ) )
       
  3205         {
       
  3206         // Message is a SMS-SUBMIT message.
       
  3207         //
       
  3208         // Get index of TP-UDL field and it is also starting position.
       
  3209         TUint8 startPosition( GetTpUdlIndex( aTpdu ) );
       
  3210         // Get number of characters what will be packed.
       
  3211         TUint8 charsToPack( aTpdu[startPosition] );
       
  3212         // Calculate end position.
       
  3213         TUint8 endPosition( startPosition + charsToPack );
       
  3214         // Get SMS TPDU length
       
  3215         TUint8 tpduLength( aTpdu.Length() );
       
  3216 
       
  3217         // Initialize values.
       
  3218         TInt i( 0 );
       
  3219         TInt x( startPosition + 1 );
       
  3220         TBool endOfTPDU( EFalse );
       
  3221         TUint8 move( 0 );
       
  3222 
       
  3223         // Lets pack all the characters in SMS Message (TP-UD), including header
       
  3224         // (TP-UD-Header) if exist.
       
  3225         //
       
  3226         // Go through the TP-UD.
       
  3227         for ( i = startPosition; i < endPosition; i++ )
       
  3228             {
       
  3229             // Check that index is not over SMS TPDU length.
       
  3230             if ( ( i + 1 ) < tpduLength )
       
  3231                 {
       
  3232                 TUint8 char1( TUint8( aTpdu[i + 1] >> move ) );
       
  3233 
       
  3234                 TUint8 char2( 0 );
       
  3235 
       
  3236                 if ( ( i + 2 ) <= endPosition )
       
  3237                     {
       
  3238                     // Check that index is not over SMS TPDU length.
       
  3239                     if ( ( i + 2 ) < tpduLength )
       
  3240                         {
       
  3241                         char2 = TUint8( aTpdu[i + 2] << ( 7 - move ) );
       
  3242                         }
       
  3243                     else
       
  3244                         {
       
  3245                         ret = KErrCorrupt;
       
  3246                         break;
       
  3247                         }
       
  3248                     }
       
  3249                 else
       
  3250                     {
       
  3251                     // No more characters to pack.
       
  3252                     endOfTPDU = ETrue;
       
  3253                     char2 = 0;
       
  3254                     }
       
  3255 
       
  3256                 // Append packed characters.
       
  3257                 aSendSm[x++] = TUint8( char1 | char2 );
       
  3258 
       
  3259                 // New values for next round.
       
  3260                 if ( ( 6 == move ) && !endOfTPDU )
       
  3261                     {
       
  3262                     i++;
       
  3263                     move = 0;
       
  3264                     }
       
  3265                 else
       
  3266                     {
       
  3267                     move++;
       
  3268                     }
       
  3269                 }
       
  3270             else
       
  3271                 {
       
  3272                 ret = KErrCorrupt;
       
  3273                 break;
       
  3274                 }
       
  3275             }
       
  3276 
       
  3277         // TP-UD is now packed
       
  3278         if ( KErrCorrupt != ret )
       
  3279             {
       
  3280             // New string length (number of characters)
       
  3281             //
       
  3282             // Calculate if string length is changed from orginal length.
       
  3283             // These lengths are aTpdu[] buffer length so it start from "0"
       
  3284             // > "i" includes old value
       
  3285             // > "x" is new value with packed TP-UD
       
  3286             // > "x - 1" because we needed to add one for start point earlier
       
  3287             //           to append characters to correct position.
       
  3288             TUint8 stringLengthChanged( i - ( x - 1 ) );
       
  3289 
       
  3290             if ( stringLengthChanged )
       
  3291                 {
       
  3292                 aSendSm.SetLength( aSendSm.Length() - stringLengthChanged );
       
  3293                 }
       
  3294 
       
  3295             // Change the DCS to default alphabet coding. See ETSI 3.38
       
  3296             //
       
  3297             // Get the position of TP-DCS
       
  3298             TUint8 posDCS( GetTpDcsIndex( aTpdu ) );
       
  3299 
       
  3300             // Coding Group Bits are 7..4 and Use of bits are 3..0
       
  3301             // We need to find out correct Coding Group.
       
  3302             //
       
  3303             // KMaskC0: 0xC0 = 1100 0000
       
  3304             // > This check include Coding Group:
       
  3305             // >> Bits:  7..4
       
  3306             // >> Group: 00xx
       
  3307             //
       
  3308             if ( KMask0 == ( aTpdu[posDCS] & KMaskC0 ) )
       
  3309                 {
       
  3310                 // Set bits 2 and 3 to 0.
       
  3311                 // Bits 3 and 2 indicate the alphabet being used, as follows:
       
  3312                 //
       
  3313                 // Bit3 | Bit2 | Alphabet:
       
  3314                 // ----------------------------------------
       
  3315                 //   0  |   0  | GSM 7 bit default alphabet
       
  3316                 //   0  |   1  | 8 bit data
       
  3317                 //   1  |   0  | UCS2 (16bit)
       
  3318                 //   1  |   1  | Reserved
       
  3319                 //
       
  3320                 // KMaskF3: 0xF3 = 1111 0011
       
  3321                 aSendSm[posDCS] = TUint8( aSendSm[posDCS] & KMaskF3 );
       
  3322                 }
       
  3323 
       
  3324             // KMaskF0: 0xF0 = 1111 0000
       
  3325             // > This check include Coding Group:
       
  3326             // >> Bits:  7..4
       
  3327             // >> Group: 1111
       
  3328             //
       
  3329             if ( KMaskF0 == ( aTpdu[posDCS] & KMaskF0 ) )
       
  3330                 {
       
  3331                 // Set bit 2 to 0.
       
  3332                 // Bit 3 is reserved, set to 0.
       
  3333                 //
       
  3334                 // Bit 2 indicate the alphabet being used, as follows:
       
  3335                 //
       
  3336                 // Bit2 | Message coding:
       
  3337                 // ---------------------------------
       
  3338                 //   0  | GSM 7 bit default alphabet
       
  3339                 //   1  | 8-bit data
       
  3340                 //
       
  3341                 // KMaskFB: 0xFB = 1111 1011
       
  3342                 aSendSm[posDCS] = TUint8( aSendSm[posDCS] & KMaskFB );
       
  3343                 }
       
  3344             }
       
  3345         }
       
  3346     else
       
  3347         {
       
  3348         // Packing cannot be requested if TPDU is something else
       
  3349         // than SMS submit.
       
  3350         ret = KErrCorrupt;
       
  3351         }
       
  3352 
       
  3353     return ret;
       
  3354     }
       
  3355 
       
  3356 // -----------------------------------------------------------------------------
       
  3357 // CSatNotifySendDtmf::CSatNotifySendDtmf
       
  3358 // C++ default constructor can NOT contain any code, that
       
  3359 // might leave.
       
  3360 // -----------------------------------------------------------------------------
       
  3361 //
       
  3362 CSatNotifySendDtmf::CSatNotifySendDtmf
       
  3363         (
       
  3364         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  3365         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  3366         )
       
  3367         :
       
  3368         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  3369         iSendDtmfV1Pckg( NULL )
       
  3370     {
       
  3371     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDTMF_CSATNOTIFYSENDDTMF, "CSatNotifySendDtmf::CSatNotifySendDtmf" );
       
  3372     // Following results are also allowed for this command:
       
  3373     // (in addition to result declared in base class constructor)
       
  3374     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  3375         + RSat::KPSessionTerminatedByUser + RSat::KErrorRequiredValuesMissing;
       
  3376     }
       
  3377 
       
  3378 // -----------------------------------------------------------------------------
       
  3379 // CSatNotifySendDtmf::~CSatNotifySendDtmf
       
  3380 // Destructor
       
  3381 // -----------------------------------------------------------------------------
       
  3382 //
       
  3383 CSatNotifySendDtmf::~CSatNotifySendDtmf()
       
  3384     {
       
  3385     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDDTMF_CSATNOTIFYSENDDTMF, "CSatNotifySendDtmf::~CSatNotifySendDtmf" );
       
  3386     // None
       
  3387     }
       
  3388 
       
  3389 // -----------------------------------------------------------------------------
       
  3390 // CSatNotifySendDtmf::MessageReceived
       
  3391 // Handles a SendDtmf proactive command ISI message,
       
  3392 // and completes a pending ETel request.
       
  3393 // (other items were commented in a header).
       
  3394 // -----------------------------------------------------------------------------
       
  3395 //
       
  3396 void CSatNotifySendDtmf::MessageReceived
       
  3397         (
       
  3398         const TIsiReceiveC& aIsiMessage // ISI message
       
  3399         )
       
  3400     {
       
  3401     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDTMF_MESSAGERECEIVED, "CSatNotifySendDtmf::MessageReceived" );
       
  3402     TFLOGSTRING("CSatNotifySendDtmf::MessageReceived");
       
  3403     // get ber tlv
       
  3404     CBerTlv berTlv;
       
  3405     berTlv.BerTlv( aIsiMessage );
       
  3406     // get command details tlv
       
  3407     CTlv commandDetails;
       
  3408     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  3409     iCommandDetails.Copy( commandDetails.Data() );
       
  3410     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  3411     if ( !iReqHandle )
       
  3412         {
       
  3413         iSatMessHandler->SendDtmfTerminalResp( iTransId,
       
  3414                                                 iCommandDetails,
       
  3415                                                 RSat::KMeUnableToProcessCmd,
       
  3416                                                 KNoCause );
       
  3417         }
       
  3418     else
       
  3419         {
       
  3420         TInt returnValue( KErrNone );
       
  3421         TInt ret( KErrNone );
       
  3422         // Fill the send ss structure
       
  3423         RSat::TSendDtmfV1& sendDtmfV1 = ( *iSendDtmfV1Pckg )();
       
  3424         // command number
       
  3425         sendDtmfV1.SetPCmdNumber(
       
  3426             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  3427          // Alpha id string (optional)
       
  3428         sendDtmfV1.iAlphaId.iAlphaId.Zero();
       
  3429         CTlv alphaIdentifier;
       
  3430         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  3431             KTlvAlphaIdentifierTag );
       
  3432         // if alpha id string exist
       
  3433         if( KErrNone == returnValue )
       
  3434             {
       
  3435             TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  3436 
       
  3437             if ( alphaIdLength > RSat::KAlphaIdMaxSize )
       
  3438                 {
       
  3439                 // String too long
       
  3440                 iSatMessHandler->SendDtmfTerminalResp( iTransId,
       
  3441                                     iCommandDetails,
       
  3442                                     RSat::KCmdBeyondMeCapabilities,
       
  3443                                     KNoCause );
       
  3444                 ret = KErrCorrupt;
       
  3445                 }
       
  3446             else if ( alphaIdLength )
       
  3447                 {
       
  3448                 TPtrC8 temp; // Used with Copy8to16
       
  3449                  // get the alpha id
       
  3450                 temp.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  3451                 // convert and set the alpha id
       
  3452                 TSatUtility::SetAlphaId( temp ,
       
  3453                     sendDtmfV1.iAlphaId.iAlphaId );
       
  3454 
       
  3455                 sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  3456                 }
       
  3457             else
       
  3458                 {
       
  3459                  sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  3460                 }
       
  3461             }
       
  3462         // Alpha id not present
       
  3463         else
       
  3464             {
       
  3465             sendDtmfV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  3466             }
       
  3467 
       
  3468         // Dtmf string length, 8-bit string, mandatory
       
  3469         CTlv sendDtmf;
       
  3470         returnValue = berTlv.TlvByTagValue( &sendDtmf,
       
  3471             KTlvDtmfStringTag );
       
  3472         if ( KErrNone == returnValue )
       
  3473             {
       
  3474             TUint8 generalResult( RSat::KSuccess );
       
  3475             // length - 1 for string
       
  3476             TUint16 dtmfStringLength = TUint16( sendDtmf.GetLength() );
       
  3477 
       
  3478             //If first byte of the dtmf string is 0xFF it means that dtmf string
       
  3479             //is empty and we have to return general result
       
  3480             if ( ( dtmfStringLength && ( sendDtmf.Data()[2] == 0xFF ) ) ||
       
  3481                 !dtmfStringLength )
       
  3482                 {
       
  3483                 generalResult = RSat::KCmdDataNotUnderstood;
       
  3484                 ret = KErrCorrupt;
       
  3485                 }
       
  3486             else if( RSat::KDtmfStringMaxSize < dtmfStringLength )
       
  3487                 {
       
  3488                 generalResult = RSat::KCmdBeyondMeCapabilities;
       
  3489                 ret = KErrCorrupt;
       
  3490                 }
       
  3491             else
       
  3492                 {
       
  3493                 sendDtmfV1.iDtmfString.Append( sendDtmf.GetData( ETLV_DtmfString ) );
       
  3494                 }
       
  3495 
       
  3496             if( KErrCorrupt == ret )
       
  3497                 {
       
  3498                 // String too long
       
  3499                 iSatMessHandler->SendDtmfTerminalResp( iTransId,
       
  3500                                     iCommandDetails,
       
  3501                                     generalResult,
       
  3502                                     KNoCause );
       
  3503                 }
       
  3504             }
       
  3505         else
       
  3506             {
       
  3507             iSatMessHandler->SendDtmfTerminalResp( iTransId,
       
  3508                                     iCommandDetails,
       
  3509                                     RSat::KErrorRequiredValuesMissing,
       
  3510                                     KNoCause );
       
  3511             ret = KErrCorrupt;
       
  3512             }
       
  3513 
       
  3514         // Iconid
       
  3515         if ( KErrNone == ret )
       
  3516             {
       
  3517             TSatUtility::FillIconStructure( berTlv,
       
  3518                 sendDtmfV1.iIconId );
       
  3519             }
       
  3520         CompleteRequest( ret );
       
  3521         }
       
  3522     }
       
  3523 
       
  3524 // -----------------------------------------------------------------------------
       
  3525 // CSatNotifySendDtmf::Notify
       
  3526 // An ETel SAT client can call this method via ETel server to set a pending
       
  3527 // request in SimAtkTsy for a SendDtmf PCmd.
       
  3528 // (other items were commented in a header).
       
  3529 // -----------------------------------------------------------------------------
       
  3530 //
       
  3531 void CSatNotifySendDtmf::Notify
       
  3532         (
       
  3533         const TTsyReqHandle aReqHandle, // Request handle
       
  3534         TDes8*              aDataPtr    // Pointer to data
       
  3535         )
       
  3536     {
       
  3537     OstTrace1( TRACE_NORMAL, CSATNOTIFYSENDDTMF_NOTIFY, "CSatNotifySendDtmf::Notify Handle: %u", aReqHandle );
       
  3538     TFLOGSTRING2("CSatNotifySendDtmf::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  3539                 aReqHandle );
       
  3540     iReqHandle = aReqHandle;
       
  3541     iSendDtmfV1Pckg = static_cast< RSat::TSendDtmfV1Pckg* >( aDataPtr );
       
  3542     iSatMessaging->SatReady( KSendDtmf );
       
  3543     }
       
  3544 
       
  3545 // -----------------------------------------------------------------------------
       
  3546 // CSatNotifySendDtmf::TerminalResponse
       
  3547 // Handles a SendDtmf terminal response provided by an ETel SAT client via
       
  3548 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  3549 // (other items were commented in a header).
       
  3550 // -----------------------------------------------------------------------------
       
  3551 //
       
  3552 TInt CSatNotifySendDtmf::TerminalResponse
       
  3553         (
       
  3554         TDes8* aRsp // Response
       
  3555         )
       
  3556     {
       
  3557     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDTMF_TERMINALRESPONSE, "CSatNotifySendDtmf::TerminalResponse" );
       
  3558     TFLOGSTRING("CSatNotifySendDtmf::TerminalResponse");
       
  3559     TInt ret( KErrNone );
       
  3560     TUint8 additionalInfo( 0 );
       
  3561     RSat::TSendDtmfRspV1Pckg* aRspPckg =
       
  3562             reinterpret_cast< RSat::TSendDtmfRspV1Pckg* >( aRsp );
       
  3563     RSat::TSendDtmfRspV1& rspV1 = ( *aRspPckg ) ();
       
  3564 
       
  3565     // Check that general result values are valid
       
  3566     if ( iAllowedResults != rspV1.iGeneralResult )
       
  3567         {
       
  3568         // Invalid general result
       
  3569         ret = KErrCorrupt;
       
  3570         }
       
  3571     if( RSat::KMeProblem == rspV1.iInfoType )
       
  3572         {
       
  3573         if ( rspV1.iAdditionalInfo.Length() )
       
  3574             {
       
  3575             additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  3576             }
       
  3577         else
       
  3578             {
       
  3579             // Invalid additional info field
       
  3580             ret = KErrCorrupt;
       
  3581             }
       
  3582         }
       
  3583     else
       
  3584         {
       
  3585         // Invalid additional info field
       
  3586         ret = KErrCorrupt;
       
  3587         }
       
  3588 
       
  3589     // Creating the info message
       
  3590     ret = iSatMessHandler->SendDtmfTerminalResp( iTransId, iCommandDetails,
       
  3591         TUint8( rspV1.iGeneralResult ), additionalInfo );
       
  3592     return ret;
       
  3593     }
       
  3594 
       
  3595 
       
  3596 // -----------------------------------------------------------------------------
       
  3597 // CSatNotifySendSs::CSatNotifySendSs
       
  3598 // C++ default constructor can NOT contain any code, that
       
  3599 // might leave.
       
  3600 // -----------------------------------------------------------------------------
       
  3601 //
       
  3602 CSatNotifySendSs::CSatNotifySendSs
       
  3603         (
       
  3604         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  3605         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  3606         )
       
  3607         :
       
  3608         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  3609         iSendSsV1Pckg( NULL )
       
  3610     {
       
  3611     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSS_CSATNOTIFYSENDSS, "CSatNotifySendSs::CSatNotifySendSs" );
       
  3612     // Following results are also allowed for this command:
       
  3613     // (in addition to result declared in base class constructor)
       
  3614     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  3615         + RSat::KModifiedByCallControl + RSat::KUssdTransactionTerminatedByUser
       
  3616         + RSat::KNetworkUnableToProcessCmd
       
  3617         + RSat::KInteractionWithCCTemporaryError + RSat::KSsReturnError
       
  3618         + RSat::KErrorRequiredValuesMissing
       
  3619         + RSat::KInteractionWithCCPermanentError;
       
  3620     }
       
  3621 
       
  3622 // -----------------------------------------------------------------------------
       
  3623 // CSatNotifySendSs::~CSatNotifySendSs
       
  3624 // Destructor
       
  3625 // -----------------------------------------------------------------------------
       
  3626 //
       
  3627 CSatNotifySendSs::~CSatNotifySendSs()
       
  3628     {
       
  3629     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDSS_CSATNOTIFYSENDSS, "CSatNotifySendSs::~CSatNotifySendSs" );
       
  3630     // None
       
  3631     }
       
  3632 
       
  3633 // -----------------------------------------------------------------------------
       
  3634 // CSatNotifySendSs::MessageReceived
       
  3635 // Handles a DisplayText proactive command ISI message,
       
  3636 // and completes a pending ETel request.
       
  3637 // (other items were commented in a header).
       
  3638 // -----------------------------------------------------------------------------
       
  3639 //
       
  3640 void CSatNotifySendSs::MessageReceived
       
  3641         (
       
  3642         const TIsiReceiveC& aIsiMessage // ISI message
       
  3643         )
       
  3644     {
       
  3645     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSS_MESSAGERECEIVED, "CSatNotifySendSs::MessageReceived" );
       
  3646     TFLOGSTRING("CSatNotifySendSs::MessageReceived");
       
  3647     TInt ret( KErrNone );
       
  3648     // Get ber tlv
       
  3649     CBerTlv berTlv;
       
  3650     berTlv.BerTlv( aIsiMessage );
       
  3651     // Get command details tlv
       
  3652     CTlv commandDetails;
       
  3653     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  3654     // Store command details tlv
       
  3655     iCommandDetails.Copy( commandDetails.Data() );
       
  3656     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  3657     if ( !iReqHandle )
       
  3658         {
       
  3659         TBuf8<1> noCause;
       
  3660         iSatMessHandler->SendSsTerminalResp( iTransId,
       
  3661                                               iCommandDetails,
       
  3662                                               RSat::KMeUnableToProcessCmd,
       
  3663                                               noCause );
       
  3664         }
       
  3665     else
       
  3666         {
       
  3667         // Fill the send ss structure
       
  3668         RSat::TSendSsV1& sendSsV1 = ( *iSendSsV1Pckg )();
       
  3669         // Store command number
       
  3670         sendSsV1.SetPCmdNumber(
       
  3671             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  3672         TPtrC8 sourceString; // Used with conversions
       
  3673          // Alpha id string (optional)
       
  3674         sendSsV1.iAlphaId.iAlphaId.Zero();
       
  3675         CTlv alphaIdentifier;
       
  3676         // Get alpha id tlv from berTlv
       
  3677         TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifier,
       
  3678                                                 KTlvAlphaIdentifierTag ) );
       
  3679         // if alpha id string exist
       
  3680         if ( KErrNone == returnValue )
       
  3681             {
       
  3682             if ( alphaIdentifier.GetLength() )
       
  3683                 {
       
  3684                 // 8-bit string to 16-bit string
       
  3685                 sourceString.Set(
       
  3686                     alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  3687 
       
  3688                 // Convert and set the alpha id
       
  3689                 TSatUtility::SetAlphaId(
       
  3690                     sourceString ,sendSsV1.iAlphaId.iAlphaId );
       
  3691                 // Set alpha id status
       
  3692                 sendSsV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  3693                 }
       
  3694             else
       
  3695                 {
       
  3696                 sendSsV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  3697                 }
       
  3698             }
       
  3699         // Alpha id not present
       
  3700         else
       
  3701             {
       
  3702             sendSsV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  3703             }
       
  3704         // SS string Tlv
       
  3705         sendSsV1.iSsString.iSsString.Zero();
       
  3706         CTlv ssString;
       
  3707         // Get SS string tlv
       
  3708         returnValue = berTlv.TlvByTagValue( &ssString,
       
  3709                                             KTlvSsStringTag );
       
  3710         if ( KErrNone == returnValue )
       
  3711             {
       
  3712             // Initialize ton and npi
       
  3713             RSat::TTypeOfNumber ton;
       
  3714             RSat::TNumberingPlan npi;
       
  3715 
       
  3716             iSatMessaging->SetTonNpi ( ssString.GetShortInfo( ETLV_TonAndNpi ) );
       
  3717 
       
  3718             // Call utility function that maps received TON and NPI
       
  3719             // to RSat values
       
  3720             TSatUtility::GetTonAndNpi(
       
  3721                 ssString.GetShortInfo( ETLV_TonAndNpi ), &ton, &npi );
       
  3722             // Set TON and NPI
       
  3723             sendSsV1.iSsString.iTypeOfNumber = ton;
       
  3724             sendSsV1.iSsString.iNumberPlan = npi;
       
  3725             // Check length of SS string.
       
  3726             // BCD format = two digits "packed" in one characher
       
  3727             if ( ssString.GetLength() * 2 <= RSat::KStringMaxSize )
       
  3728                 {
       
  3729                 TBuf8<RSat::KStringMaxSize> tempString;
       
  3730                 // Set pointer to the BCD SS string
       
  3731                 sourceString.Set( ssString.GetData( ETLV_SsOrUssdString ) );
       
  3732                 // Semi-octet presentation used
       
  3733                 // Converting back to ASCII format
       
  3734                 TSatUtility::BCDToAscii( sourceString, tempString );
       
  3735                 // Set pointer to the ASCII string.
       
  3736                 sourceString.Set( tempString );
       
  3737                 sendSsV1.iSsString.iSsString.Append( tempString );
       
  3738                 }
       
  3739             else
       
  3740                 {
       
  3741                 // SS string is too long
       
  3742                 ret = KErrCorrupt;
       
  3743                 }
       
  3744             if ( RSat::EInternationalNumber ==
       
  3745                 sendSsV1.iSsString.iTypeOfNumber )
       
  3746                 {
       
  3747                 // Append '+' character if the string is for call forwarding
       
  3748                 CheckCallForwarding( sourceString, sendSsV1.iSsString );
       
  3749                 }
       
  3750             }
       
  3751         else
       
  3752             {
       
  3753             // Mandatory tlv is missing, returning response immediately
       
  3754             TBuf8<1> noCause;
       
  3755             iSatMessHandler->SendSsTerminalResp(
       
  3756                 iTransId,                           // Transaction id
       
  3757                 iCommandDetails,                    // Command details TLV
       
  3758                 RSat::KErrorRequiredValuesMissing,  // Result
       
  3759                 noCause );                          // Additional info
       
  3760             ret = KErrCorrupt;
       
  3761             CompleteRequest( ret );
       
  3762             return;
       
  3763             }
       
  3764         if ( KErrCorrupt == CheckSsStringValidity( sourceString ) ||
       
  3765             KErrCorrupt == ret )
       
  3766             {
       
  3767             TBuf8<1> noCause;
       
  3768             iSatMessHandler->SendSsTerminalResp(
       
  3769                 iTransId,                           // Transaction id
       
  3770                 iCommandDetails,                    // Command details TLV
       
  3771                 RSat::KCmdDataNotUnderstood,        // Result
       
  3772                 noCause );                          // Additional info
       
  3773             ret = KErrCorrupt;
       
  3774             }
       
  3775 
       
  3776         // Icon (optional)
       
  3777         TSatUtility::FillIconStructure( berTlv, sendSsV1.iIconId );
       
  3778         CompleteRequest( ret );
       
  3779 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
  3780         // Notify NokiaTSY that next SS request is SAT originated
       
  3781         if ( KErrNone == ret )
       
  3782             {
       
  3783             TFLOGSTRING("TSY: Inform NokiaTSY SS request being SAT originated");
       
  3784             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDSS_MESSAGERECEIVED, "Inform NokiaTSY SS request being SAT originated" );
       
  3785             iSatMessaging->GetMessageRouter()->ExtFuncL(
       
  3786                 ESatNotifyCallControlRequest,
       
  3787                 NULL );
       
  3788             }
       
  3789 #endif
       
  3790         }
       
  3791     }
       
  3792 
       
  3793 // -----------------------------------------------------------------------------
       
  3794 // CSatNotifySendSs::Notify
       
  3795 // An ETel SAT client can call this method via ETel server to set a pending
       
  3796 // request in SimAtkTsy for a SendSs PCmd.
       
  3797 // (other items were commented in a header).
       
  3798 // -----------------------------------------------------------------------------
       
  3799 //
       
  3800 void CSatNotifySendSs::Notify
       
  3801         (
       
  3802         const TTsyReqHandle aReqHandle, // Request handle
       
  3803         TDes8*              aDataPtr    // Pointer to data
       
  3804         )
       
  3805     {
       
  3806     OstTrace1( TRACE_NORMAL, CSATNOTIFYSENDSS_NOTIFY, "CSatNotifySendSs::Notify Handle: %u", aReqHandle );
       
  3807     TFLOGSTRING2("CSatNotifySendSs::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  3808                 aReqHandle );
       
  3809     iReqHandle = aReqHandle;
       
  3810     iSendSsV1Pckg = static_cast< RSat::TSendSsV1Pckg* >( aDataPtr );
       
  3811     iSatMessaging->SatReady( KSendSs );
       
  3812     }
       
  3813 
       
  3814 // -----------------------------------------------------------------------------
       
  3815 // CSatNotifySendSs::TerminalResponse
       
  3816 // Handles a DisplayText terminal response provided by an ETel SAT client via
       
  3817 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  3818 // (other items were commented in a header).
       
  3819 // -----------------------------------------------------------------------------
       
  3820 //
       
  3821 TInt CSatNotifySendSs::TerminalResponse
       
  3822         (
       
  3823         TDes8* aRsp // Response
       
  3824         )
       
  3825     {
       
  3826     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSS_TERMINALRESPONSE, "CSatNotifySendSs::TerminalResponse" );
       
  3827     TFLOGSTRING("CSatNotifySendSs::TerminalResponse");
       
  3828 
       
  3829     TInt ret( KErrNone );
       
  3830 
       
  3831     // Buffer for additional information
       
  3832     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  3833 
       
  3834     RSat::TSendSsRspV2Pckg* aRspPckg =
       
  3835             reinterpret_cast<RSat::TSendSsRspV2Pckg*>( aRsp );
       
  3836     RSat::TSendSsRspV2& rspV2 = ( *aRspPckg ) ();
       
  3837 
       
  3838     // Check that general result value is valid
       
  3839     if ( iAllowedResults != rspV2.iGeneralResult )
       
  3840         {
       
  3841         // Invalid general result
       
  3842         ret = KErrCorrupt;
       
  3843         }
       
  3844 
       
  3845     // If no SS error, set additional info
       
  3846     if ( RSat::KSsReturnError != rspV2.iGeneralResult )
       
  3847         {
       
  3848         // iAdditionalInfo is 8-bit
       
  3849         additionalInfo.Copy( rspV2.iAdditionalInfo );
       
  3850 
       
  3851         if ( RSat::KSendSsInfo == rspV2.iInfoType && additionalInfo.Length() )
       
  3852             {
       
  3853             // Remove operation code.
       
  3854             // SATUI appends iOperationCode to additional info.
       
  3855             // RMmCustomAPI::TSsAdditionalInfo iAddtionalInfo includes
       
  3856             // correct SS Return Result Operation code, so fisrt byte of
       
  3857             // additionalInfo is not needed.
       
  3858             additionalInfo.Delete( 0, 1 );
       
  3859             }
       
  3860         }
       
  3861     else
       
  3862         {
       
  3863         // SS error code, one byte
       
  3864         // For the general result "SS Return Error", it is mandatory for the ME
       
  3865         // to provide additional information. The first byte shall be the error
       
  3866         // value given in the Facility (Return result) information element
       
  3867         // returned by the network (as defined in TS 24.080).
       
  3868         if ( 2 <= rspV2.iAdditionalInfo.Length() )
       
  3869             {
       
  3870             additionalInfo.Append( rspV2.iAdditionalInfo[1] );
       
  3871             }
       
  3872         else
       
  3873             {
       
  3874             additionalInfo.Append( 0x00 );
       
  3875             }
       
  3876         }
       
  3877 
       
  3878     // Creating the info message
       
  3879     iSatMessHandler->SendSsTerminalResp( iTransId,
       
  3880                                          iCommandDetails,
       
  3881                                          TUint8( rspV2.iGeneralResult ),
       
  3882                                           additionalInfo );
       
  3883     return ret;
       
  3884     }
       
  3885 
       
  3886 // -----------------------------------------------------------------------------
       
  3887 // CSatNotifySendSs::CheckCallForwarding
       
  3888 // Check SS string if it is for call forwarding. If it is
       
  3889 // append '+' character to pretending international number.
       
  3890 // (other items were commented in a header).
       
  3891 // -----------------------------------------------------------------------------
       
  3892 //
       
  3893 void CSatNotifySendSs::CheckCallForwarding
       
  3894         (
       
  3895         TPtrC8 aSource,                 // original string
       
  3896         RSat::TSsString& aSsString      // where to store modified string
       
  3897         )
       
  3898     {
       
  3899     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSS_CHECKCALLFORWARDING, "CSatNotifySendSs::CheckCallForwarding" );
       
  3900     TFLOGSTRING("CSatNotifySendSs::CheckCallForwarding");
       
  3901     _LIT8(KCFU,"*21*");    // Call forwarding unconditional (CFU)
       
  3902     _LIT8(KCFB,"*67*");    // Call forwarding on Mobile Subscriber Busy(CFB)
       
  3903     _LIT8(KCFNRy, "*61*"); // Call forwarding on No Reply (CFNRy)
       
  3904     _LIT8(KCFNRc, "*62*"); // Call forwarding on Mobile Subscriber Not
       
  3905                            // Reachable (CFNRc)
       
  3906     // Try to find call forwarding string
       
  3907     TInt pos( aSource.Find( KCFU ) );
       
  3908     if ( KErrNotFound == pos )
       
  3909         {
       
  3910         pos = aSource.Find( KCFB );
       
  3911         }
       
  3912     if ( KErrNotFound == pos )
       
  3913         {
       
  3914         pos = aSource.Find( KCFNRy );
       
  3915         }
       
  3916     if ( KErrNotFound == pos )
       
  3917         {
       
  3918         pos = aSource.Find( KCFNRc );
       
  3919         }
       
  3920     if ( KErrNotFound != pos )
       
  3921         {
       
  3922         // String is for call forwarding
       
  3923         aSsString.iSsString.Zero();
       
  3924         aSsString.iSsString.Append( aSource.Left( pos + 4 ) );
       
  3925         aSsString.iSsString.Append( KPlusMarkCharacterCode );
       
  3926         aSsString.iSsString.Append(
       
  3927             aSource.Right( aSource.Length() - ( pos + 4) ) );
       
  3928         }
       
  3929     }
       
  3930 
       
  3931 // -----------------------------------------------------------------------------
       
  3932 // CSatNotifySendSs::CheckSsStringValidity
       
  3933 // Checks validity of SS string.If string includes undefined SS
       
  3934 // characters or length is zero then return KErrCorrupt.
       
  3935 // (other items were commented in a header).
       
  3936 // -----------------------------------------------------------------------------
       
  3937 //
       
  3938 TInt CSatNotifySendSs::CheckSsStringValidity
       
  3939         (
       
  3940         TPtrC8 aSsString
       
  3941         )
       
  3942     {
       
  3943     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDSS_CHECKSSSTRINGVALIDITY, "CSatNotifySendSs::CheckSsStringValidity" );
       
  3944     TFLOGSTRING("CSatNotifySendSs::CheckSsStringValidity");
       
  3945     TInt ret( KErrNone );
       
  3946     if ( !aSsString.Length() )
       
  3947         {
       
  3948         // If length is zero
       
  3949         ret = KErrCorrupt;
       
  3950         }
       
  3951     _LIT8( KDtmf,            "p");
       
  3952     _LIT8( KWild,            "w");
       
  3953     _LIT8( KExpansionDigit,  ".");
       
  3954     // SS string can contain only digits, star '*' and dash '#' characters.
       
  3955     if ( KErrNotFound != aSsString.Find( KDtmf )
       
  3956         || KErrNotFound != aSsString.Find( KWild )
       
  3957         || KErrNotFound != aSsString.Find( KExpansionDigit ) )
       
  3958         {
       
  3959         // Incompatible character found
       
  3960         ret = KErrCorrupt;
       
  3961         }
       
  3962     return ret;
       
  3963     }
       
  3964 
       
  3965 
       
  3966 // -----------------------------------------------------------------------------
       
  3967 // CSatNotifySendUssd::CSatNotifySendUssd
       
  3968 // C++ default constructor can NOT contain any code, that
       
  3969 // might leave.
       
  3970 // -----------------------------------------------------------------------------
       
  3971 //
       
  3972 CSatNotifySendUssd::CSatNotifySendUssd
       
  3973         (
       
  3974         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  3975         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  3976         )
       
  3977         :
       
  3978         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  3979         iSendUssdV1Pckg( NULL )
       
  3980     {
       
  3981     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDUSSD_CSATNOTIFYSENDUSSD, "CSatNotifySendUssd::CSatNotifySendUssd" );
       
  3982     // Following results are also allowed for this command:
       
  3983     // (in addition to result declared in base class constructor)
       
  3984     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  3985         + RSat::KModifiedByCallControl + RSat::KUssdTransactionTerminatedByUser
       
  3986         + RSat::KNetworkUnableToProcessCmd
       
  3987         + RSat::KInteractionWithCCTemporaryError
       
  3988         + RSat::KErrorRequiredValuesMissing + RSat::KUssdReturnError
       
  3989         + RSat::KInteractionWithCCPermanentError;
       
  3990     }
       
  3991 
       
  3992 // -----------------------------------------------------------------------------
       
  3993 // CSatNotifySendUssd::~CSatNotifySendUssd
       
  3994 // Destructor
       
  3995 // -----------------------------------------------------------------------------
       
  3996 //
       
  3997 CSatNotifySendUssd::~CSatNotifySendUssd()
       
  3998     {
       
  3999     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDUSSD_CSATNOTIFYSENDUSSD, "CSatNotifySendUssd::~CSatNotifySendUssd" );
       
  4000     // None
       
  4001     }
       
  4002 
       
  4003 // -----------------------------------------------------------------------------
       
  4004 // CSatNotifySendUssd::MessageReceived
       
  4005 // Handles a SendUssd proactive command ISI message,
       
  4006 // and completes a pending ETel request.
       
  4007 // (other items were commented in a header).
       
  4008 // -----------------------------------------------------------------------------
       
  4009 //
       
  4010 void CSatNotifySendUssd::MessageReceived
       
  4011         (
       
  4012         const TIsiReceiveC& aIsiMessage // ISI message
       
  4013         )
       
  4014     {
       
  4015     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDUSSD_MESSAGERECEIVED, "CSatNotifySendUssd::MessageReceived" );
       
  4016     TFLOGSTRING("TSY:CSatNotifySendUssd::MessageReceived");
       
  4017     TInt ret( KErrNone );
       
  4018     TInt returnValue( KErrNone );
       
  4019     //get ber tlv
       
  4020     CBerTlv berTlv;
       
  4021     berTlv.BerTlv( aIsiMessage );
       
  4022     // get command details tlv
       
  4023     CTlv commandDetails;
       
  4024     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  4025     iCommandDetails.Copy( commandDetails.Data() );
       
  4026     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  4027     if ( !iReqHandle )
       
  4028         {
       
  4029         // Request not on, returning response immediately
       
  4030         TUint8 noCause( 0 );
       
  4031         TBuf<1>  noTextString;
       
  4032         TUint8  paramNotSet( 0 );
       
  4033         iSatMessHandler->SendUssdTerminalResp( iTransId,
       
  4034                                     iCommandDetails,
       
  4035                                     RSat::KMeUnableToProcessCmd,
       
  4036                                     noCause,
       
  4037                                     noTextString,
       
  4038                                     paramNotSet );
       
  4039         }
       
  4040     else
       
  4041         {
       
  4042         // Fill the Send Ussd structure
       
  4043         RSat::TSendUssdV1& sendUssdV1 = ( *iSendUssdV1Pckg )();
       
  4044         sendUssdV1.SetPCmdNumber(
       
  4045             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  4046         TPtrC8 sourceStr; // Used with Copy8to16 function
       
  4047         // Alpha id string (optional)
       
  4048         sendUssdV1.iAlphaId.iAlphaId.Zero();
       
  4049         CTlv alphaIdentifier;
       
  4050         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  4051             KTlvAlphaIdentifierTag );
       
  4052         if ( KErrNotFound != returnValue )
       
  4053             {
       
  4054             TUint16 alphaIdLength = alphaIdentifier.GetLength() ;
       
  4055             if ( RSat::KAlphaIdMaxSize < alphaIdLength )
       
  4056                 {
       
  4057                 // String too long
       
  4058                 TUint8 noCause( 0 );
       
  4059                 TBuf<1>  noTextString;
       
  4060                 TUint8  paramNotSet( 0 );
       
  4061                 iSatMessHandler->SendUssdTerminalResp( iTransId,
       
  4062                                 iCommandDetails,
       
  4063                                 RSat::KMeUnableToProcessCmd,
       
  4064                                 noCause,
       
  4065                                 noTextString,
       
  4066                                 paramNotSet );
       
  4067                 ret = KErrCorrupt;
       
  4068                 }
       
  4069             else if ( alphaIdLength )
       
  4070                 {
       
  4071                 // get the alpha id
       
  4072                 sourceStr.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  4073 
       
  4074                 // convert and set the alpha id
       
  4075                 TSatUtility::SetAlphaId( sourceStr ,
       
  4076                     sendUssdV1.iAlphaId.iAlphaId );
       
  4077                 }
       
  4078             // Check alpha id status
       
  4079             // Alpha Tag present
       
  4080             if ( sendUssdV1.iAlphaId.iAlphaId.Length() )
       
  4081                 {
       
  4082                 sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  4083                 }
       
  4084             else
       
  4085                 {
       
  4086                 sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  4087                 }
       
  4088             }
       
  4089         else
       
  4090             {
       
  4091             sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  4092             }
       
  4093         // Ussd string (mandatory)
       
  4094         CTlv ussdTlv;
       
  4095         sendUssdV1.iUssdString.iUssdString.Zero();
       
  4096         returnValue = berTlv.TlvByTagValue( &ussdTlv,
       
  4097             KTlvUssdStringTag );
       
  4098         if ( KErrNone == returnValue )
       
  4099             {
       
  4100             // Get the data coding scheme from the ISI msg
       
  4101             // and set the corresponding ETel Sat data field.
       
  4102             // The DCS is coded as for Cell Broadcast.
       
  4103             sendUssdV1.iUssdString.iDcs =
       
  4104                 ussdTlv.GetShortInfo( ETLV_DataCodingScheme );
       
  4105             // Decode DCS
       
  4106             TSmsDcs decodedDcs( ESmsUnknownOrReservedDcs );
       
  4107             decodedDcs = TSatUtility::DecodeCbsDcs( sendUssdV1.iUssdString.iDcs );
       
  4108             TPtrC8 ussdString = ussdTlv.GetData( ETLV_UssdString );
       
  4109             TUint16 ussdStringLengthInBytes = TUint16( ussdString.Length() );
       
  4110             if ( ( ( ESms16BitDcs==decodedDcs )
       
  4111                    && 2*RSat::KStringMaxSize<ussdStringLengthInBytes)
       
  4112                || ( ( ESms8BitDcs==decodedDcs )
       
  4113                   && RSat::KStringMaxSize<ussdStringLengthInBytes)
       
  4114                || ( ( ESms7BitDcs==decodedDcs )
       
  4115                   && RSat::KStringMaxSize<8*ussdStringLengthInBytes/7))
       
  4116                 {
       
  4117                 // The Ussd text string is too long.
       
  4118                 TFLOGSTRING("TSY:CSatNotifySendUssd::MessageReceived, \
       
  4119                 USSD String too long");
       
  4120                 OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDUSSD_MESSAGERECEIVED, "CSatNotifySendUssd::MessageReceived, USSD String too long" );
       
  4121                 ret = KErrCorrupt;
       
  4122                 TUint8 noCause( 0 );
       
  4123                 TBuf<1>  emptyTextString;
       
  4124                 TUint8  paramNotSet( 0 );
       
  4125                 iSatMessHandler->SendUssdTerminalResp( iTransId,
       
  4126                                     iCommandDetails,
       
  4127                                     RSat::KCmdDataNotUnderstood,
       
  4128                                     noCause,
       
  4129                                     emptyTextString,
       
  4130                                     paramNotSet );
       
  4131                 }
       
  4132             else
       
  4133                 {
       
  4134                 // Conversion to 16-bit following the DCS
       
  4135                 switch ( decodedDcs )
       
  4136                     {
       
  4137                     case ESms7BitDcs:
       
  4138                         {
       
  4139                         TBuf8<RSat::KStringMaxSize> ussdString8;
       
  4140                         TSatUtility::Packed7to8Unpacked( ussdString,
       
  4141                             ussdString8 );
       
  4142                         TSatUtility::ConvertSms7ToUnicode16(
       
  4143                             sendUssdV1.iUssdString.iUssdString, ussdString8 );
       
  4144                         break;
       
  4145                         }
       
  4146                     case ESms8BitDcs:
       
  4147                         {
       
  4148                         TSatUtility::ConvertSms7ToUnicode16(
       
  4149                             sendUssdV1.iUssdString.iUssdString, ussdString );
       
  4150                         break;
       
  4151                         }
       
  4152                     case ESms16BitDcs:
       
  4153                         {
       
  4154                         TIsiUtility::CopyFromBigEndian( ussdString , sendUssdV1.iUssdString.iUssdString );
       
  4155                         break;
       
  4156                         }
       
  4157                     default:
       
  4158                         {
       
  4159                         TFLOGSTRING("TSY:CSatNotifySendUssd::MessageReceived, \
       
  4160                         USSD DCS has a reserved value");
       
  4161                         OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSENDUSSD_MESSAGERECEIVED, "CSatNotifySendUssd::MessageReceived, USSD DCS has a reserved value" );
       
  4162                         // the DCS has a reserved value
       
  4163                         ret = KErrCorrupt;
       
  4164                         TUint8 noCause( 0 );
       
  4165                         TBuf<1>  emptyTextString;
       
  4166                         TUint8  paramNotSet( 0 );
       
  4167                         iSatMessHandler->SendUssdTerminalResp( iTransId,
       
  4168                                             iCommandDetails,
       
  4169                                             RSat::KCmdDataNotUnderstood,
       
  4170                                             noCause,
       
  4171                                             emptyTextString,
       
  4172                                             paramNotSet );
       
  4173                         break;
       
  4174                         }
       
  4175                     }
       
  4176                 }
       
  4177             }
       
  4178         else
       
  4179             {
       
  4180             TFLOGSTRING("TSY:CSatNotifySendUssd::MessageReceived, \
       
  4181             Mandatory field missing");
       
  4182             OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYSENDUSSD_MESSAGERECEIVED, "CSatNotifySendUssd::MessageReceived, Mandatory field missing" );
       
  4183             // Mandatory field missing
       
  4184             ret = KErrCorrupt;
       
  4185             TUint8 noCause( 0 );
       
  4186             TBuf<1>  noTextString;
       
  4187             TUint8  paramNotSet( 0 );
       
  4188             iSatMessHandler->SendUssdTerminalResp( iTransId,
       
  4189                                 iCommandDetails,
       
  4190                                 RSat::KErrorRequiredValuesMissing,
       
  4191                                 noCause,
       
  4192                                 noTextString,
       
  4193                                 paramNotSet );
       
  4194             }
       
  4195         if ( KErrNone == ret )
       
  4196             {
       
  4197             // Iconid
       
  4198             TSatUtility::FillIconStructure( berTlv,
       
  4199                 sendUssdV1.iIconId );
       
  4200             }
       
  4201         CompleteRequest( ret );
       
  4202         }
       
  4203     }
       
  4204 
       
  4205 // -----------------------------------------------------------------------------
       
  4206 // CSatNotifySendUssd::Notify
       
  4207 // An ETel SAT client can call this method via ETel server to set a pending
       
  4208 // request in SimAtkTsy for a SendUssd PCmd.
       
  4209 // (other items were commented in a header).
       
  4210 // -----------------------------------------------------------------------------
       
  4211 //
       
  4212 void CSatNotifySendUssd::Notify
       
  4213         (
       
  4214         const TTsyReqHandle aReqHandle, // Request handle
       
  4215         TDes8*              aDataPtr    // Pointer to data
       
  4216         )
       
  4217     {
       
  4218     OstTrace1( TRACE_NORMAL, CSATNOTIFYSENDUSSD_NOTIFY, "CSatNotifySendUssd::Notify Handle: %u", aReqHandle );
       
  4219     TFLOGSTRING2("TSY:CSatNotifySendUssd::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  4220                 aReqHandle );
       
  4221     iReqHandle = aReqHandle;
       
  4222     iSendUssdV1Pckg = static_cast< RSat::TSendUssdV1Pckg* >( aDataPtr );
       
  4223     iSatMessaging->SatReady( KSendUssd );
       
  4224     }
       
  4225 
       
  4226 // -----------------------------------------------------------------------------
       
  4227 // CSatNotifySendUssd::TerminalResponse
       
  4228 // Handles a SendUssd terminal response provided by an ETel SAT client via
       
  4229 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  4230 // (other items were commented in a header).
       
  4231 // -----------------------------------------------------------------------------
       
  4232 //
       
  4233 TInt CSatNotifySendUssd::TerminalResponse
       
  4234         (
       
  4235         TDes8* aRsp // Response
       
  4236         )
       
  4237     {
       
  4238     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDUSSD_TERMINALRESPONSE, "CSatNotifySendUssd::TerminalResponse" );
       
  4239     TFLOGSTRING("TSY:CSatNotifySendUssd::TerminalResponse");
       
  4240     TInt ret( KErrNone );
       
  4241     RSat::TSendUssdRspV1Pckg* aRspPckg =
       
  4242             reinterpret_cast< RSat::TSendUssdRspV1Pckg* >( aRsp );
       
  4243     RSat::TSendUssdRspV1& rspV1 = ( *aRspPckg ) ();
       
  4244     TUint8 additionalInfo( 0 );
       
  4245     // Check that general result values are valid
       
  4246     if ( iAllowedResults != rspV1.iGeneralResult )
       
  4247         {
       
  4248         // Invalid general result
       
  4249         ret = KErrCorrupt;
       
  4250         }
       
  4251     // If there is Me (Mobile Entity) error, network error or text string,
       
  4252     // additional info is needed
       
  4253     if ( ( RSat::KMeProblem == rspV1.iInfoType )
       
  4254         || ( RSat::KCallControlRequestedAction == rspV1.iInfoType )
       
  4255         || ( RSat::KSatNetworkErrorInfo == rspV1.iInfoType )
       
  4256         || ( RSat::KTextString == rspV1.iInfoType ) )
       
  4257         {
       
  4258         // Check the length of additional info:
       
  4259         if ( 0 == rspV1.iAdditionalInfo.Length() )
       
  4260             {
       
  4261             // No info
       
  4262             TFLOGSTRING("TSY:CSatNotifySendUssd::TerminalResponse, \
       
  4263             AdditionalInfoType set, but no additional info available");
       
  4264             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDUSSD_TERMINALRESPONSE, "CSatNotifySendUssd::TerminalResponse, AdditionalInfoType set, but no additional info available" );
       
  4265             ret = KErrCorrupt;
       
  4266             }
       
  4267         else if ( RSat::KTextString == rspV1.iInfoType )
       
  4268             {
       
  4269             // Text string - additional info for a
       
  4270             // successful GET INKEY, GET INPUT or SEND USSD.
       
  4271             // --> Not used by SAT Server when the command has been
       
  4272             // performed successfully, SAT Server uses the
       
  4273             // rspV1.iUssdString.iUssdString to return the USSD string
       
  4274             // sent by the network.
       
  4275             TFLOGSTRING("TSY:CSatNotifySendUssd::TerminalResponse, \
       
  4276             AdditionalInfoType set to TextString.");
       
  4277             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSENDUSSD_TERMINALRESPONSE, "CSatNotifySendUssd::TerminalResponse, AdditionalInfoType set to TextString." );
       
  4278             }
       
  4279         else
       
  4280             {
       
  4281             // For the general result "USSD Return Error",
       
  4282             // the ME shall provide additional information.
       
  4283             // The first byte shall be the error value given in
       
  4284             // the Facility (Return result) information element
       
  4285             // returned by the network (as defined in TS 24.080 [10]).
       
  4286             // One further value is defined:
       
  4287             // -    '00' = No specific cause can be given.
       
  4288             additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  4289             }
       
  4290         }
       
  4291     // Creating the info message
       
  4292     iSatMessHandler->SendUssdTerminalResp( iTransId, iCommandDetails,
       
  4293                                TUint8( rspV1.iGeneralResult ),
       
  4294                                additionalInfo,
       
  4295                                rspV1.iUssdString.iUssdString,
       
  4296                                rspV1.iUssdString.iDcs );
       
  4297     return ret;
       
  4298 
       
  4299     }
       
  4300 
       
  4301 // -----------------------------------------------------------------------------
       
  4302 // CSatNotifySetUpCall::CSatNotifySetUpCall
       
  4303 // C++ default constructor can NOT contain any code, that
       
  4304 // might leave.
       
  4305 // -----------------------------------------------------------------------------
       
  4306 //
       
  4307 CSatNotifySetUpCall::CSatNotifySetUpCall
       
  4308         (
       
  4309         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  4310         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  4311         )
       
  4312         :
       
  4313         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  4314         iSetUpCallV1Pckg( NULL )
       
  4315     {
       
  4316     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPCALL_CSATNOTIFYSETUPCALL, "CSatNotifySetUpCall::CSatNotifySetUpCall" );
       
  4317     TFLOGSTRING( "TSY:CSatNotifySetUpCall::CSatNotifySetUpCall" );
       
  4318     iCallConnectedEvent.Zero();
       
  4319 
       
  4320     // Following results are also allowed for this command:
       
  4321     // (in addition to result declared in base class constructor)
       
  4322     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  4323         + RSat::KModifiedByCallControl + RSat::KPSessionTerminatedByUser
       
  4324         + RSat::KUssdTransactionTerminatedByUser
       
  4325         + RSat::KNetworkUnableToProcessCmd + RSat::KPCmdNotAcceptedByUser
       
  4326         + RSat::KCallClearedBeforeConnectionOrReleased
       
  4327         + RSat::KInteractionWithCCTemporaryError + RSat::KSsReturnError
       
  4328         + RSat::KErrorRequiredValuesMissing
       
  4329         + RSat::KInteractionWithCCPermanentError;
       
  4330     }
       
  4331 
       
  4332 // -----------------------------------------------------------------------------
       
  4333 // CSatNotifySetUpCall::~CSatNotifySetUpCall
       
  4334 // Destructor
       
  4335 // -----------------------------------------------------------------------------
       
  4336 //
       
  4337 CSatNotifySetUpCall::~CSatNotifySetUpCall()
       
  4338     {
       
  4339     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPCALL_CSATNOTIFYSETUPCALL, "CSatNotifySetUpCall::~CSatNotifySetUpCall" );
       
  4340     // None
       
  4341     }
       
  4342 
       
  4343 // -----------------------------------------------------------------------------
       
  4344 // CSatNotifySetUpCall::MessageReceived
       
  4345 // Handles a SetUpCall proactive command ISI message,
       
  4346 // and completes a pending ETel request.
       
  4347 // (other items were commented in a header).
       
  4348 // -----------------------------------------------------------------------------
       
  4349 //
       
  4350 void CSatNotifySetUpCall::MessageReceived
       
  4351         (
       
  4352         const TIsiReceiveC& aIsiMessage // ISI message
       
  4353         )
       
  4354     {
       
  4355     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPCALL_MESSAGERECEIVED, "CSatNotifySetUpCall::MessageReceived" );
       
  4356     TFLOGSTRING("CSatNotifySetUpCall::MessageReceived");
       
  4357     TInt ret( KErrNone );
       
  4358     TInt returnValue( KErrNone );
       
  4359     // Get ber tlv
       
  4360     CBerTlv berTlv;
       
  4361     berTlv.BerTlv( aIsiMessage );
       
  4362     // Get command details tlv
       
  4363     CTlv commandDetails;
       
  4364     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  4365     // Store command details tlv
       
  4366     iCommandDetails.Copy( commandDetails.Data() );
       
  4367     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  4368     if ( !iReqHandle )
       
  4369         {
       
  4370         // Request not on, returning response immediately
       
  4371         iSatMessHandler->SetUpCallTerminalResp( iTransId,
       
  4372                                                  iCommandDetails,
       
  4373                                                  RSat::KMeUnableToProcessCmd,
       
  4374                                                  KNoCause );
       
  4375         }
       
  4376     else
       
  4377         {
       
  4378         // Fill the Set Up Call structure
       
  4379         RSat::TSetUpCallV1& setUpCallV1 = ( *iSetUpCallV1Pckg )();
       
  4380         // Store command number
       
  4381         setUpCallV1.SetPCmdNumber(
       
  4382             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  4383        switch ( iCommandDetails[KCommandQualifier] )
       
  4384             {
       
  4385             case KOnlyIfNotBusy:
       
  4386                 {
       
  4387                 // Set up call, if not busy on another call
       
  4388                 setUpCallV1.iType = RSat::EOnlyIfNotBusy;
       
  4389                 break;
       
  4390                 }
       
  4391             case KOnlyIfNotBusyWithRedial:
       
  4392                 {
       
  4393                 // Set up call, if not busy on another call, with redial
       
  4394                 setUpCallV1.iType = RSat::EOnlyIfNotBusyWithRedial;
       
  4395                 break;
       
  4396                 }
       
  4397             case KHoldOtherCalls:
       
  4398                 {
       
  4399                 // Set up call, put other calls (if any) on hold
       
  4400                 setUpCallV1.iType = RSat::EHoldOtherCalls;
       
  4401                 break;
       
  4402                 }
       
  4403             case KHoldOtherCallsWithRedial:
       
  4404                 {
       
  4405                 // Set up call, put other calls (if any) on hold, with redial
       
  4406                 setUpCallV1.iType = RSat::EHoldOtherCallsWithRedial;
       
  4407                 break;
       
  4408                 }
       
  4409             case KDisconnectOtherCalls:
       
  4410                 {
       
  4411                 // Set up call, disconnect other calls (if any)
       
  4412                 setUpCallV1.iType = RSat::EDisconnectOtherCalls;
       
  4413                 break;
       
  4414                 }
       
  4415             case KDisconnectOtherCallsWithRedial:
       
  4416                 {
       
  4417                 // Set up call, disconnect other calls (if any), with redial
       
  4418                 setUpCallV1.iType = RSat::EDisconnectOtherCallsWithRedial;
       
  4419                 break;
       
  4420                 }
       
  4421             default:
       
  4422                 {
       
  4423                 // Call type not set
       
  4424                 setUpCallV1.iType = RSat::ESetUpCallTypeNotSet;
       
  4425                 break;
       
  4426                 }
       
  4427             }
       
  4428         TPtrC8 sourceString; // Used with conversions
       
  4429         // Alpha id string (optional)
       
  4430         setUpCallV1.iAlphaIdConfirmationPhase.iAlphaId.Zero();
       
  4431          // Call setup phase alphaid (optional)
       
  4432         setUpCallV1.iAlphaIdCallSetUpPhase.iAlphaId.Zero();
       
  4433         CTlv alphaIdentifier;
       
  4434         // check alpha identifiers (for user confirmation phase and call set
       
  4435         // up phase )
       
  4436         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  4437                                             KTlvAlphaIdentifierTag );
       
  4438         // if alpha id string exist
       
  4439         if ( KErrNone == returnValue )
       
  4440             {
       
  4441             // fist alpha identifier is for user confirmation phase
       
  4442             if ( alphaIdentifier.GetLength() )
       
  4443                 {
       
  4444                 // set status
       
  4445                 setUpCallV1.iAlphaIdConfirmationPhase.iStatus =
       
  4446                     RSat::EAlphaIdProvided;
       
  4447 
       
  4448                  // get alpha id string
       
  4449                 sourceString.Set( alphaIdentifier.GetData(
       
  4450                     ETLV_AlphaIdentifier ) );
       
  4451 
       
  4452                 // convert and set the alpha id
       
  4453                 TSatUtility::SetAlphaId( sourceString ,
       
  4454                     setUpCallV1.iAlphaIdConfirmationPhase.iAlphaId );
       
  4455 
       
  4456                 }
       
  4457             // alpha id found for user confirmation phase, but length
       
  4458             // is zero
       
  4459             else
       
  4460                 {
       
  4461                 setUpCallV1.iAlphaIdConfirmationPhase.iStatus =
       
  4462                     RSat::EAlphaIdNull;
       
  4463                 }
       
  4464             }
       
  4465         // no alpha id for user confirmation phase
       
  4466         else
       
  4467             {
       
  4468             setUpCallV1.iAlphaIdConfirmationPhase.iStatus =
       
  4469                 RSat::EAlphaIdNotPresent;
       
  4470             }
       
  4471         // Get alpha identifier for call set up phase
       
  4472         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  4473                                             KTlvAlphaIdentifierTag, 1 );
       
  4474         // if alpha id string exist
       
  4475         if ( KErrNone == returnValue )
       
  4476             {
       
  4477             //second alpha identifier is for call set up phase
       
  4478             if ( alphaIdentifier.GetLength() )
       
  4479                 {
       
  4480                 // set status
       
  4481                 setUpCallV1.iAlphaIdCallSetUpPhase.iStatus =
       
  4482                     RSat::EAlphaIdProvided;
       
  4483                  // get alpha id string
       
  4484                 sourceString.Set( alphaIdentifier.GetData(
       
  4485                     ETLV_AlphaIdentifier ) );
       
  4486                 // convert and set the alpha id
       
  4487                 TSatUtility::SetAlphaId( sourceString,
       
  4488                     setUpCallV1.iAlphaIdCallSetUpPhase.iAlphaId );
       
  4489 
       
  4490                 }
       
  4491             // alpha id found for set up call phase,  but length is zero
       
  4492             else
       
  4493                 {
       
  4494                 setUpCallV1.iAlphaIdCallSetUpPhase.iStatus =
       
  4495                     RSat::EAlphaIdNull;
       
  4496                 }
       
  4497             }
       
  4498         // no alpha id set up call phase
       
  4499         else
       
  4500             {
       
  4501             setUpCallV1.iAlphaIdCallSetUpPhase.iStatus =
       
  4502                 RSat::EAlphaIdNotPresent;
       
  4503             }
       
  4504         // First icon for user confirmation phase
       
  4505         TSatUtility::FillIconStructure(
       
  4506             berTlv, setUpCallV1.iIconIdConfirmationPhase, 0 );
       
  4507         // Second icon for set up call phase
       
  4508         TSatUtility::FillIconStructure(
       
  4509             berTlv, setUpCallV1.iIconIdCallSetUpPhase, 1 );
       
  4510         // Expecting address
       
  4511         CTlv addressTlv;
       
  4512         returnValue = berTlv.TlvByTagValue( &addressTlv,
       
  4513                                             KTlvAddressTag );
       
  4514         if ( KErrNone == returnValue && addressTlv.GetLength() )
       
  4515             {
       
  4516             // Initialize ton and npi
       
  4517             RSat::TTypeOfNumber ton( RSat::EUnknownNumber );
       
  4518             RSat::TNumberingPlan npi( RSat::EUnknownNumberingPlan );
       
  4519             // Call utility function that maps received TON and NPI to
       
  4520             // RSat values
       
  4521             TSatUtility::GetTonAndNpi(
       
  4522                 addressTlv.GetShortInfo( ETLV_TonAndNpi ) , &ton, &npi );
       
  4523             // Set TON and NPI
       
  4524             setUpCallV1.iAddress.iTypeOfNumber = ton;
       
  4525             setUpCallV1.iAddress.iNumberPlan = npi;
       
  4526             // Address
       
  4527             setUpCallV1.iAddress.iTelNumber.Zero();
       
  4528             // length is number of BCD characters,
       
  4529             // multiply by two to get real length and - 2 for ton&npi
       
  4530             TInt dialNumberLength( ( ( addressTlv.GetLength() * 2 ) - 2 ) );
       
  4531 
       
  4532            if ( dialNumberLength )
       
  4533                 {
       
  4534                 // Semi-octet presentation used
       
  4535                 sourceString.Set(
       
  4536                     addressTlv.GetData( ETLV_DiallingNumberString ) );
       
  4537                 TBuf8<RSat::KMaxMobileTelNumberSize> tempNumber;
       
  4538                 // Convert BCD string to ascii
       
  4539                 TSatUtility::BCDToAscii( sourceString, tempNumber );
       
  4540                 sourceString.Set( tempNumber );
       
  4541                 //add '+' character to the preceding of international number
       
  4542                 if ( ( setUpCallV1.iAddress.iTypeOfNumber
       
  4543                     == RSat::EInternationalNumber )
       
  4544                         && (sourceString[0] != KPlusMarkCharacterCode )
       
  4545                         && RSat::KMaxMobileTelNumberSize > dialNumberLength )
       
  4546                     {
       
  4547                     _LIT8( KPlusMark, "+");
       
  4548                     tempNumber.Insert( 0, KPlusMark );
       
  4549                     sourceString.Set( tempNumber );
       
  4550                     }
       
  4551                 // The command may also include DTMF digits, which the ME shall
       
  4552                 // send to the network after the call has connected.
       
  4553                 // Remove expansion digits from it if present.
       
  4554                 TSatUtility::RemoveExpansionDigit( tempNumber );
       
  4555                 // Set actual number
       
  4556                 setUpCallV1.iAddress.iTelNumber.Copy( tempNumber );
       
  4557                 TFLOGSTRING2("TSY: SetUpCall, TelNumber: %S",
       
  4558                 &setUpCallV1.iAddress.iTelNumber );
       
  4559                 OstTraceExt1( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPCALL_MESSAGERECEIVED, "CSatNotifySetUpCall::MessageReceived TelNumber: %S", setUpCallV1.iAddress.iTelNumber );
       
  4560                 }
       
  4561             }
       
  4562         else
       
  4563             {
       
  4564             // address is missing, returning response immediately
       
  4565             iSatMessHandler->SetUpCallTerminalResp( iTransId,
       
  4566                                     iCommandDetails,
       
  4567                                     RSat::KCmdDataNotUnderstood,
       
  4568                                     KNoCause );
       
  4569             ret = KErrCorrupt;
       
  4570             }
       
  4571         // Bearer capability
       
  4572         setUpCallV1.iCapabilityConfigParams.Zero();
       
  4573         CTlv capabilityConfig;
       
  4574         returnValue = berTlv.TlvByTagValue( &capabilityConfig,
       
  4575             KTlvCapabilityConfigurationParametersTag );
       
  4576         if ( ( KErrNone == returnValue )
       
  4577             && ( capabilityConfig.GetLength() ) )
       
  4578             {
       
  4579             // iCapabilityConfigParams is 8-bit string
       
  4580             setUpCallV1.iCapabilityConfigParams.Append( capabilityConfig.
       
  4581                 GetData( ETLV_CapabilityConfigurationParameters ) );
       
  4582             }
       
  4583         // Called Party SubAddress
       
  4584         setUpCallV1.iSubAddress.Zero();
       
  4585         CTlv subAddress;
       
  4586         returnValue = berTlv.TlvByTagValue( &subAddress, KTlvSubaddressTag );
       
  4587         if ( KErrNone == returnValue )
       
  4588             {
       
  4589             if ( subAddress.GetLength()
       
  4590                 || subAddress.GetComprehensionRequired() )
       
  4591                 {
       
  4592                 TFLOGSTRING("TSY: SetUpCall, SubAddress is not supported!" );
       
  4593                 OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYSETUPCALL_MESSAGERECEIVED, "SetUpCall, SubAddress is not supported!" );
       
  4594                 iSatMessHandler->SetUpCallTerminalResp( iTransId,
       
  4595                                         iCommandDetails,
       
  4596                                         RSat::KCmdBeyondMeCapabilities,
       
  4597                                         KNoCause );
       
  4598                 ret = KErrCorrupt;
       
  4599                 }
       
  4600             }
       
  4601 
       
  4602         // Duration (optional, maximum duration for the redial mechanism)
       
  4603         TSatUtility::FillDurationStructure(
       
  4604             berTlv, setUpCallV1.iDuration );
       
  4605 
       
  4606         // Set SetUpCall flag on for Call connected event. To avoid situation
       
  4607         // that event is send before terminal response
       
  4608         if ( KErrNone == ret )
       
  4609             {
       
  4610             iSatMessaging->SetSetUpCallStatus( ETrue );
       
  4611             }
       
  4612         CompleteRequest( ret );
       
  4613         }
       
  4614     }
       
  4615 
       
  4616 // -----------------------------------------------------------------------------
       
  4617 // CSatNotifySetUpCall::Notify
       
  4618 // An ETel SAT client can call this method via ETel server to set a pending
       
  4619 // request in SimAtkTsy for a SetUpCall PCmd.
       
  4620 // (other items were commented in a header).
       
  4621 // -----------------------------------------------------------------------------
       
  4622 //
       
  4623 void CSatNotifySetUpCall::Notify
       
  4624         (
       
  4625         const TTsyReqHandle aReqHandle, // Request handle
       
  4626         TDes8*              aDataPtr    // Pointer to data
       
  4627         )
       
  4628     {
       
  4629     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPCALL_NOTIFY, "CSatNotifySetUpCall::Notify" );
       
  4630     TFLOGSTRING("CSatNotifySetUpCall::Notify");
       
  4631     iReqHandle = aReqHandle;
       
  4632     iSetUpCallV1Pckg = static_cast< RSat::TSetUpCallV1Pckg* >( aDataPtr );
       
  4633     iSatMessaging->SatReady( KSetUpCall );
       
  4634     }
       
  4635 
       
  4636 // -----------------------------------------------------------------------------
       
  4637 // CSatNotifySetUpCall::TerminalResponse
       
  4638 // Handles a SetUpCall terminal response provided by an ETel SAT client via
       
  4639 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  4640 // (other items were commented in a header).
       
  4641 // -----------------------------------------------------------------------------
       
  4642 //
       
  4643 TInt CSatNotifySetUpCall::TerminalResponse
       
  4644         (
       
  4645         TDes8* aRsp // Response
       
  4646         )
       
  4647     {
       
  4648     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPCALL_TERMINALRESPONSE, "CSatNotifySetUpCall::TerminalResponse" );
       
  4649     TFLOGSTRING("CSatNotifySetUpCall::TerminalResponse");
       
  4650     TInt    ret( KErrNone );
       
  4651     TUint8  additionalInfo( 0 );
       
  4652     RSat::TSetUpCallRspV2Pckg* aRspPckg =
       
  4653             reinterpret_cast< RSat::TSetUpCallRspV2Pckg* >( aRsp );
       
  4654     RSat::TSetUpCallRspV2& rspV2 = ( *aRspPckg ) ();
       
  4655 
       
  4656     // Check that general result values are valid
       
  4657     if ( iAllowedResults != rspV2.iGeneralResult )
       
  4658         {
       
  4659         // Invalid general result
       
  4660         ret = KErrCorrupt;
       
  4661         }
       
  4662 
       
  4663     // If there is Me (Mobile Entity) error or network error,
       
  4664     // additional info is needed
       
  4665     if ( ( RSat::KSatNetworkErrorInfo == rspV2.iInfoType )
       
  4666         || ( RSat::KMeProblem == rspV2.iInfoType ) )
       
  4667         {
       
  4668         // Check the length of additional info
       
  4669         if ( rspV2.iAdditionalInfo.Length() )
       
  4670             {
       
  4671             additionalInfo = static_cast<TUint8>( rspV2.iAdditionalInfo[0] );
       
  4672             }
       
  4673         else
       
  4674             {
       
  4675              // No info
       
  4676             ret = KErrCorrupt;
       
  4677             }
       
  4678         }
       
  4679 
       
  4680     // Creating the terminal response message
       
  4681     iSatMessHandler->SetUpCallTerminalResp( iTransId,
       
  4682         iCommandDetails, TUint8( rspV2.iGeneralResult ), additionalInfo );
       
  4683 
       
  4684     // Clear flag
       
  4685     iSatMessaging->SetSetUpCallStatus( EFalse );
       
  4686 
       
  4687     // In the case of a call initiated through a SET UP CALL proactive command
       
  4688     // while the call connected event is part of the current event list, the
       
  4689     // ME shall send both the TERMINAL RESPONSE related to the proactive
       
  4690     // command, and the EVENT DOWNLOAD command, in the order TERMINAL RESPONSE
       
  4691     // first, ENVELOPE(EVENT DOWNLOAD - call connected) second.
       
  4692     // Check if there is stored envelope in the buffer
       
  4693     if ( iCallConnectedEvent.Length() )
       
  4694         {
       
  4695         // Send envelope..
       
  4696         iSatMessHandler->UiccCatReqEnvelope( iSatMessaging->GetTransactionId(),
       
  4697                                              iCallConnectedEvent );
       
  4698         // ..and clear the buffer
       
  4699         iCallConnectedEvent.Zero();
       
  4700         }
       
  4701     return ret;
       
  4702     }
       
  4703 
       
  4704 // -----------------------------------------------------------------------------
       
  4705 // CSatNotifySetUpCall::StoreCallConnectedEvent
       
  4706 // Store a Call connected envelope to buffer
       
  4707 // (other items were commented in a header).
       
  4708 // -----------------------------------------------------------------------------
       
  4709 //
       
  4710 void CSatNotifySetUpCall::StoreCallConnectedEvent
       
  4711         (
       
  4712         const TDesC8& aEnvelope // envelope received from CSatEventDownload
       
  4713         )
       
  4714     {
       
  4715     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPCALL_STORECALLCONNECTEDEVENT, "CSatNotifySetUpCall::StoreCallConnectedEvent" );
       
  4716     // store it to the buffer
       
  4717     iCallConnectedEvent = aEnvelope;
       
  4718     }
       
  4719 
       
  4720 
       
  4721 // -----------------------------------------------------------------------------
       
  4722 // CSatNotifyRefresh::CSatNotifyRefresh
       
  4723 // C++ default constructor can NOT contain any code, that
       
  4724 // might leave.
       
  4725 // -----------------------------------------------------------------------------
       
  4726 //
       
  4727 CSatNotifyRefresh::CSatNotifyRefresh
       
  4728         (
       
  4729         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  4730         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  4731         )
       
  4732         :
       
  4733         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  4734         iRefreshV2Pckg( NULL ),
       
  4735         iRefreshRequiredV2Pckg( NULL ),
       
  4736         iReqHandleRefreshRequired( NULL ),
       
  4737         iInternalCache( KZero )
       
  4738     {
       
  4739     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_CSATNOTIFYREFRESH, "CSatNotifyRefresh::CSatNotifyRefresh" );
       
  4740     iFileList.Zero();
       
  4741     iAid.Zero();
       
  4742 
       
  4743     // Following results are also allowed for this command:
       
  4744     // (in addition to result declared in base class constructor)
       
  4745     iAllowedResults += RSat::KRefreshAdditionEFRead
       
  4746         + RSat::KRefreshUSIMNotActive + RSat::KErrorRequiredValuesMissing;
       
  4747     }
       
  4748 
       
  4749 // -----------------------------------------------------------------------------
       
  4750 // CSatNotifyRefresh::~CSatNotifyRefresh
       
  4751 // Destructor
       
  4752 // -----------------------------------------------------------------------------
       
  4753 //
       
  4754 CSatNotifyRefresh::~CSatNotifyRefresh()
       
  4755     {
       
  4756     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYREFRESH_CSATNOTIFYREFRESH, "CSatNotifyRefresh::~CSatNotifyRefresh" );
       
  4757     // None
       
  4758     }
       
  4759 
       
  4760 // -----------------------------------------------------------------------------
       
  4761 // CSatNotifyRefresh::MessageReceived
       
  4762 // Handles a Refresh proactive command ISI message,
       
  4763 // and completes a pending ETel request.
       
  4764 // (other items were commented in a header).
       
  4765 // -----------------------------------------------------------------------------
       
  4766 //
       
  4767 void CSatNotifyRefresh::MessageReceived
       
  4768         (
       
  4769         const TIsiReceiveC& aIsiMessage // ISI message
       
  4770         )
       
  4771     {
       
  4772     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived" );
       
  4773     TFLOGSTRING("TSY: CSatNotifyRefresh::MessageReceived");
       
  4774     // Get ber tlv
       
  4775     CBerTlv berTlv;
       
  4776     berTlv.BerTlv( aIsiMessage );
       
  4777      // Get command details tlv
       
  4778     CTlv commandDetails;
       
  4779     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  4780     // Store command details tlv. Returned to SIM card in terminal resp.
       
  4781     iCommandDetails.Copy( commandDetails.Data() );
       
  4782     // Store Transaction id
       
  4783     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  4784     if ( !iReqHandle || !iReqHandleRefreshRequired )
       
  4785         {
       
  4786         TFLOGSTRING3("TSY: CSatNotifyRefresh::MessageReceived, iReqHandle:%d,\
       
  4787         iReqHandleRefreshRequired:%d ", iReqHandle, iReqHandleRefreshRequired );
       
  4788         OstTraceExt2( TRACE_NORMAL, DUP1_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived iReqHandle: %u, iReqHandleRefreshRequired: %u", iReqHandle, iReqHandleRefreshRequired );
       
  4789 
       
  4790         // Some of the request were not on, returning response immediately
       
  4791         iSatMessHandler->RefreshTerminalResp(
       
  4792             iTransId,                       // Transaction id
       
  4793             iCommandDetails,                // Command details tlv
       
  4794             RSat::KMeUnableToProcessCmd,    // Result
       
  4795             RSat::KNoSpecificMeProblem );   // Additional info
       
  4796         }
       
  4797     else
       
  4798         {
       
  4799         // Fill the refresh structure
       
  4800         RSat::TRefreshV2& refreshV2 = ( *iRefreshRequiredV2Pckg )();
       
  4801         TInt returnValue( KErrNone );
       
  4802         // Is the command valid
       
  4803         TInt ret( KErrNone );
       
  4804          // File list
       
  4805         refreshV2.iFileList.Zero();
       
  4806         iFileList.Zero();
       
  4807         iInternalCache = 0;
       
  4808 
       
  4809         CTlv fileListTlv;
       
  4810         returnValue = berTlv.TlvByTagValue( &fileListTlv,
       
  4811                                             KTlvFileListTag );
       
  4812         if ( KErrNone == returnValue )
       
  4813             {
       
  4814             // Filelist found
       
  4815             // Check if file list really contains any files
       
  4816             if ( KZero < fileListTlv.GetLength() )
       
  4817                 {
       
  4818                 // File list length, -1 for number of files
       
  4819                 TUint8 fileLength( TUint8( fileListTlv.GetLength() - 1 ) );
       
  4820                 // Save file list with full path.
       
  4821                 // Needed when creating a SIM_ATK_REQ isi-message
       
  4822                 iFileList = fileListTlv.GetData( ETLV_Files );
       
  4823                 // Going through all files
       
  4824                 // Received as 8-bit, append to 16-bit
       
  4825                 TInt i( 0 );
       
  4826                 for ( i = 0; i < fileLength / 2; i++ )
       
  4827                     {
       
  4828                     TUint16 oneItem( 0 );
       
  4829                     // read 16-bit
       
  4830                     TSatUtility::GetWord( oneItem, iFileList, 2 * i );
       
  4831                     // File header 8-bit
       
  4832                     TUint8 header( oneItem >> 8 );
       
  4833                     // The TSY needs to strip the Refresh File List
       
  4834                     // provided by the ICC to remove the paths to the files.
       
  4835                     //'3FXX': Master File;
       
  4836                     //'7FXX': 1st level Dedicated File;
       
  4837                     //'5FXX': 2nd level Dedicated File;
       
  4838                     if ( ( KRefreshMasterFileHeader != header )
       
  4839                         && ( KRefresh1StLevelDedicatedFileHeader != header )
       
  4840                         && ( KRefresh2StLevelDedicatedFileHeader != header ) )
       
  4841                         {
       
  4842                         // Append file to the file list, without path
       
  4843                         refreshV2.iFileList.Append( oneItem );
       
  4844                         }
       
  4845                     }
       
  4846                 // Check if the file list contains the EF-SST file which is
       
  4847                 // cached in SIM ATK TSY
       
  4848                 if ( KErrNotFound != refreshV2.iFileList.Locate( RSat::KSstEf ) )
       
  4849                     {
       
  4850                     iInternalCache |= KCacheEFSST;
       
  4851                     }
       
  4852                 // Check EF-CBMID
       
  4853                 if ( KErrNotFound != refreshV2.iFileList.Locate( RSat::KCbmidEf ) )
       
  4854                     {
       
  4855                     iInternalCache |= KCacheEFCBMID;
       
  4856                     }
       
  4857                 }
       
  4858             }
       
  4859         else if ( iCommandDetails[KCommandQualifier] ==
       
  4860                 KFileChangeNotification )
       
  4861             {
       
  4862             // File list object is missing, return terminal resp immediately.
       
  4863             ret = KErrCorrupt;
       
  4864             iSatMessHandler->RefreshTerminalResp( iTransId,
       
  4865                                                    iCommandDetails,
       
  4866                                                    RSat::KErrorRequiredValuesMissing,
       
  4867                                                    RSat::KNoSpecificMeProblem );
       
  4868             }
       
  4869         else
       
  4870             {
       
  4871             TFLOGSTRING("TSY: CSatNotifyRefresh::MessageReceived, \
       
  4872             Return value of file list TLV not valid.");
       
  4873             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Return value of file list TLV not valid." );
       
  4874             }
       
  4875         if ( KErrNone == ret )
       
  4876             {
       
  4877             // Set refresh mode
       
  4878             switch ( iCommandDetails[KCommandQualifier] )
       
  4879                 {
       
  4880                 case KSimInitFullFileChangeNotification:
       
  4881                     {
       
  4882                     TFLOGSTRING("TSY: SAT, Refresh mode: Sim init and \
       
  4883                     full file change notification");
       
  4884                     OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: Sim init and full file change notification" );
       
  4885                     refreshV2.iType = RSat::ESimInitFullFileChangeNotification;
       
  4886                     iInternalCache = KCacheEFSST + KCacheEFCBMID;
       
  4887                     break;
       
  4888                     }
       
  4889                 case KFileChangeNotification:
       
  4890                     {
       
  4891                     TFLOGSTRING("TSY: SAT, refresh mode: File Change \
       
  4892                     Notification");
       
  4893                     TFLOGSTRING2("TSY: Number of files: %d",
       
  4894                     refreshV2.iFileList.Length() );
       
  4895 
       
  4896                     OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: File Change Notification" );
       
  4897                     OstTrace1( TRACE_NORMAL, DUP5_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Number of files: %d", refreshV2.iFileList.Length() );
       
  4898 
       
  4899                     refreshV2.iType = RSat::EFileChangeNotification;
       
  4900                     if ( KErrNotFound !=
       
  4901                         refreshV2.iFileList.Locate( RSat::KImsiEf )
       
  4902                             && !fileListTlv.GetComprehensionRequired() )
       
  4903                         {
       
  4904                         // IMSI was part of file list and the CR bit was cleared
       
  4905                         // This is done here because client does not have the CR
       
  4906                         // bit information available,
       
  4907                         // Other error values comes from Client
       
  4908                         ret = KErrCorrupt;
       
  4909                         iSatMessHandler->RefreshTerminalResp( iTransId,
       
  4910                             iCommandDetails,
       
  4911                             RSat::KErrorRequiredValuesMissing,
       
  4912                             RSat::KNoSpecificMeProblem );
       
  4913                         }
       
  4914                     break;
       
  4915                     }
       
  4916                 case KSimInitFileChangeNotification:
       
  4917                     {
       
  4918                     TFLOGSTRING("TSY: SAT, Refresh mode: Sim init and \
       
  4919                     file change notification");
       
  4920                     TFLOGSTRING2("TSY: Number of files: %d",
       
  4921                     refreshV2.iFileList.Length() );
       
  4922 
       
  4923                     OstTrace0( TRACE_NORMAL, DUP6_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: Sim init and file change notification" );
       
  4924                     OstTrace1( TRACE_NORMAL, DUP7_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Number of files: %d", refreshV2.iFileList.Length() );
       
  4925 
       
  4926                     refreshV2.iType = RSat::ESimInitFileChangeNotification;
       
  4927                     break;
       
  4928                     }
       
  4929                 case KSimInit:
       
  4930                     {
       
  4931                     TFLOGSTRING("TSY: SAT, Refresh mode: Sim init ");
       
  4932                     OstTrace0( TRACE_NORMAL, DUP8_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: Sim init" );
       
  4933                     refreshV2.iType = RSat::ESimInit;
       
  4934                     iInternalCache = KCacheEFSST + KCacheEFCBMID;
       
  4935                     break;
       
  4936                     }
       
  4937                 case KSimReset:
       
  4938                     {
       
  4939                     refreshV2.iType = RSat::ESimReset;
       
  4940                     TFLOGSTRING("TSY: SAT, Refresh mode: Reset");
       
  4941                     OstTrace0( TRACE_NORMAL, DUP9_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: Reset" );
       
  4942                     iInternalCache = KCacheEFSST + KCacheEFCBMID;
       
  4943                     break;
       
  4944                     }
       
  4945                 case KUSIMApplicationReset:
       
  4946                     {
       
  4947                     TFLOGSTRING("TSY: SAT, Refresh mode: USIM Application Reset");
       
  4948                     OstTrace0( TRACE_NORMAL, DUP10_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: USIM Application Reset" );
       
  4949                     refreshV2.iType = RSat::EUsimApplicationReset;
       
  4950                     iInternalCache = KCacheEFSST + KCacheEFCBMID;
       
  4951                     break;
       
  4952                     }
       
  4953                 case K3GSessionReset:
       
  4954                     {
       
  4955                     TFLOGSTRING("TSY: SAT, Refresh mode: 3G Session Reset");
       
  4956                     OstTrace0( TRACE_NORMAL, DUP11_CSATNOTIFYREFRESH_MESSAGERECEIVED, "CSatNotifyRefresh::MessageReceived, Refresh mode: 3G Session Reset" );
       
  4957                     refreshV2.iType = RSat::E3GSessionReset;
       
  4958                     break;
       
  4959                     }
       
  4960                 default:
       
  4961                     // This migth be an error case
       
  4962                     refreshV2.iType = RSat::ERefreshTypeNotSet;
       
  4963                     break;
       
  4964                 }
       
  4965             // Application identifies(optional)
       
  4966             // If an AID TLV is present, it indicates the USIM application which
       
  4967             // needs to be refreshed. If it is not present, the ME shall assume
       
  4968             // the current USIM application needs to be refreshed.
       
  4969             CTlv applicationId;
       
  4970             returnValue = berTlv.TlvByTagValue( &applicationId, KTlvAIDTag );
       
  4971             iAid.Zero();
       
  4972             if ( KErrNone == returnValue )
       
  4973                 {
       
  4974                 // Set application identifies
       
  4975                 refreshV2.iAid = applicationId.GetData( ETLV_AID );
       
  4976                 // Store aplication Id to member variable.
       
  4977                 iAid = refreshV2.iAid;
       
  4978                 }
       
  4979             }
       
  4980         // Copy parameters
       
  4981         (*iRefreshV2Pckg)() = ( *iRefreshRequiredV2Pckg )();
       
  4982         TTsyReqHandle tempReqHandle = iReqHandleRefreshRequired;
       
  4983         iReqHandleRefreshRequired = NULL;
       
  4984         // Ask permission from client
       
  4985         iSatMessaging->ReqCompleted( tempReqHandle, ret );
       
  4986         }
       
  4987     }
       
  4988 
       
  4989 // -----------------------------------------------------------------------------
       
  4990 // CSatNotifyRefresh::Notify
       
  4991 // An ETel SAT client can call this method via ETel server to set a pending
       
  4992 // request in SimAtkTsy for a Refresh PCmd.
       
  4993 // (other items were commented in a header).
       
  4994 // -----------------------------------------------------------------------------
       
  4995 //
       
  4996 void CSatNotifyRefresh::Notify
       
  4997         (
       
  4998         const TTsyReqHandle aReqHandle, // Request handle
       
  4999         TDes8*              aDataPtr    // Pointer to data
       
  5000         )
       
  5001     {
       
  5002     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_NOTIFY, "CSatNotifyRefresh::Notify" );
       
  5003     TFLOGSTRING("TSY: CSatNotifyRefresh::Notify");
       
  5004     iReqHandle = aReqHandle;
       
  5005     iRefreshV2Pckg = static_cast< RSat::TRefreshV2Pckg* >( aDataPtr );
       
  5006     if ( iReqHandleRefreshRequired )
       
  5007         {
       
  5008         // Check the command buffer, if both notifications are received
       
  5009         iSatMessaging->SatReady( KRefresh );
       
  5010         }
       
  5011 
       
  5012     }
       
  5013 
       
  5014 // -----------------------------------------------------------------------------
       
  5015 // CSatNotifyRefresh::NotifyRefreshRequired
       
  5016 // Notification requested by ETel server
       
  5017 // (other items were commented in a header).
       
  5018 // -----------------------------------------------------------------------------
       
  5019 //
       
  5020 void CSatNotifyRefresh::NotifyRefreshRequired
       
  5021         (
       
  5022         const TTsyReqHandle aReqHandle,  // Request handle
       
  5023         TDes8*              aDataPtr     // Pointer to data
       
  5024         )
       
  5025     {
       
  5026     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_NOTIFYREFRESHREQUIRED, "CSatNotifyRefresh::NotifyRefreshRequired" );
       
  5027     TFLOGSTRING("TSY: CSatNotifyRefresh::NotifyRefreshRequired");
       
  5028     iReqHandleRefreshRequired = aReqHandle;
       
  5029     iRefreshRequiredV2Pckg = static_cast< RSat::TRefreshV2Pckg* >( aDataPtr );
       
  5030     if ( iReqHandle )
       
  5031         {
       
  5032         // Check the command buffer, if both notifications are received
       
  5033         iSatMessaging->SatReady( KRefresh );
       
  5034         }
       
  5035     }
       
  5036 
       
  5037 // -----------------------------------------------------------------------------
       
  5038 // CSatNotifyRefresh::CancelRefreshRequiredNotification
       
  5039 // Cancels the current notification request
       
  5040 // (other items were commented in a header).
       
  5041 // -----------------------------------------------------------------------------
       
  5042 //
       
  5043 TInt CSatNotifyRefresh::CancelRefreshRequiredNotification
       
  5044         (
       
  5045         const TTsyReqHandle aReqHandle  // Request handle
       
  5046         )
       
  5047     {
       
  5048     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_CANCELREFRESHREQUIREDNOTIFICATION, "CSatNotifyRefresh::CancelRefreshRequiredNotification" );
       
  5049     TFLOGSTRING("TSY: CSatNotifyRefresh::CancelRefreshRequiredNotification");
       
  5050     // Check that the handle is valid
       
  5051     if ( aReqHandle == iReqHandleRefreshRequired )
       
  5052         {
       
  5053         iSatMessaging->ReqCompleted( aReqHandle, KErrCancel );
       
  5054         }
       
  5055     else
       
  5056         {
       
  5057         // Handle is not valid
       
  5058         iSatMessaging->ReqCompleted( aReqHandle, KErrCorrupt );
       
  5059         }
       
  5060     iReqHandleRefreshRequired = NULL;
       
  5061     return KErrNone;
       
  5062     }
       
  5063 
       
  5064 // -----------------------------------------------------------------------------
       
  5065 // CSatNotifyRefresh::TerminalResponse
       
  5066 // Handles a Refresh terminal response provided by an ETel SAT client via
       
  5067 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  5068 // (other items were commented in a header).
       
  5069 // -----------------------------------------------------------------------------
       
  5070 //
       
  5071 TInt CSatNotifyRefresh::TerminalResponse
       
  5072         (
       
  5073         TDes8* aRsp // Response
       
  5074         )
       
  5075     {
       
  5076     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_TERMINALRESPONSE, "CSatNotifyRefresh::TerminalResponse" );
       
  5077     TFLOGSTRING("TSY: CSatNotifyRefresh::TerminalResponse");
       
  5078     RSat::TRefreshRspV1Pckg* aRspPckg =
       
  5079             reinterpret_cast< RSat::TRefreshRspV1Pckg* >( aRsp );
       
  5080     RSat::TRefreshRspV1& rspV1 = ( *aRspPckg ) ();
       
  5081     TUint8 additionalInfo( 0x00 );
       
  5082     if ( RSat::KNoAdditionalInfo != rspV1.iInfoType )
       
  5083         {
       
  5084         additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  5085         }
       
  5086 
       
  5087     // Empty TR is sent to Simson, if refresh type was Reset or IMSI was
       
  5088     // changed during the SIM Init refresh. Empty TR is not sent to SIM,
       
  5089     if ( KSimReset == iCommandDetails[KCommandQualifier] )
       
  5090         {
       
  5091         TFLOGSTRING("TSY: CSatNotifyRefresh::TerminalResponse, Reset performed, send an empty TR");
       
  5092         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYREFRESH_TERMINALRESPONSE, "CSatNotifyRefresh::TerminalResponse, Reset performed, send an empty TR" );
       
  5093         TBuf8<1> emptyDescriptor( KNullDesC8 );
       
  5094         iSatMessHandler->UiccCatReqTerminalResponse(
       
  5095             emptyDescriptor, emptyDescriptor, iTransId );
       
  5096         }
       
  5097     else
       
  5098         {
       
  5099         TFLOGSTRING("TSY: CSatNotifyRefresh::TerminalResponse, S60 has done the Refresh" );
       
  5100         OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYREFRESH_TERMINALRESPONSE, "CSatNotifyRefresh::TerminalResponse, S60 has done the Refresh" );
       
  5101         // Send terminal response
       
  5102         iSatMessHandler->RefreshTerminalResp(
       
  5103                         iTransId,                        // Transaction id
       
  5104                         iCommandDetails,                 // Command number
       
  5105                         TUint8 ( rspV1.iGeneralResult ), // Result
       
  5106                         additionalInfo );                // Additinal info
       
  5107         }
       
  5108 
       
  5109     return iAllowedResults == rspV1.iGeneralResult ? KErrNone : KErrCorrupt;
       
  5110     }
       
  5111 
       
  5112 // -----------------------------------------------------------------------------
       
  5113 // CSatNotifyRefresh::RefreshAllowed
       
  5114 // Response to RefreshRequired notify. Tells if the refresh is allowed by
       
  5115 // the Client.
       
  5116 // (other items were commented in a header).
       
  5117 // -----------------------------------------------------------------------------
       
  5118 //
       
  5119 TInt CSatNotifyRefresh::RefreshAllowed
       
  5120         (
       
  5121         TDesC8* aDataPtr
       
  5122         )
       
  5123     {
       
  5124     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_REFRESHALLOWED, "CSatNotifyRefresh::RefreshAllowed" );
       
  5125     TFLOGSTRING("TSY: CSatNotifyRefresh::RefreshAllowed ");
       
  5126     RSat::TRefreshRspV1Pckg* aRspPckg =
       
  5127             reinterpret_cast< RSat::TRefreshRspV1Pckg* >( aDataPtr );
       
  5128     RSat::TRefreshRspV1& rspV1 = ( *aRspPckg ) ();
       
  5129     if ( ( RSat::KSuccess == rspV1.iGeneralResult )
       
  5130         || ( RSat::KRefreshAdditionEFRead == rspV1.iGeneralResult ) )
       
  5131         {
       
  5132         // Refresh allowed, send refresh request to UICC
       
  5133         iSatMessHandler->UiccCatReqRefresh(
       
  5134             iSatMessaging->GetTransactionId(),
       
  5135             Map3GppRefreshToUiccValues( iCommandDetails[KCommandQualifier] ),
       
  5136             iFileList,
       
  5137             iAid );
       
  5138         }
       
  5139     else
       
  5140         {
       
  5141         // Refresh not allowed by the client
       
  5142         TFLOGSTRING("TSY: CSatNotifyRefresh::RefreshAllowed, refresh was not \
       
  5143             allowed by the client");
       
  5144         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYREFRESH_REFRESHALLOWED, "CSatNotifyRefresh::RefreshAllowed, refresh was not allowed by the client" );
       
  5145         TUint8 additionalInfo( 0x00 );
       
  5146         if ( RSat::KNoAdditionalInfo != rspV1.iInfoType )
       
  5147             {
       
  5148             additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  5149             }
       
  5150         // Send terminal response
       
  5151         iSatMessHandler->RefreshTerminalResp( iTransId,
       
  5152                                               iCommandDetails,
       
  5153                                               TUint8( rspV1.iGeneralResult ),
       
  5154                                               additionalInfo );
       
  5155         }
       
  5156     return KErrNone;
       
  5157     }
       
  5158 
       
  5159 // -----------------------------------------------------------------------------
       
  5160 // CSatNotifyRefresh::Map3GppRefreshToUiccValues
       
  5161 // Maps 3GPP refresh values to match with UICC values.
       
  5162 // (other items were commented in a header).
       
  5163 // -----------------------------------------------------------------------------
       
  5164 //
       
  5165 TUint8 CSatNotifyRefresh::Map3GppRefreshToUiccValues
       
  5166         (
       
  5167         const TUint8 a3GppRefresh // 3GPP refresh level
       
  5168         )
       
  5169     {
       
  5170     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_MAP3GPPREFRESHTOUICCVALUES, "CSatNotifyRefresh::Map3GppRefreshToUiccValues" );
       
  5171     TFLOGSTRING("TSY: CSatNotifyRefresh::Map3GppRefreshToUiccValues ");
       
  5172 
       
  5173     TUint8 serviceType( a3GppRefresh );
       
  5174     switch ( serviceType )
       
  5175         {
       
  5176         case KSimInitFullFileChangeNotification:
       
  5177             {
       
  5178             serviceType = UICC_REFRESH_NAA_INIT_FULL_FILE_CHANGE;
       
  5179             break;
       
  5180             }
       
  5181         case KFileChangeNotification:
       
  5182             {
       
  5183             serviceType = UICC_REFRESH_NAA_FILE_CHANGE;
       
  5184             break;
       
  5185             }
       
  5186         case KSimInitFileChangeNotification:
       
  5187             {
       
  5188             serviceType = UICC_REFRESH_NAA_INIT_FILE_CHANGE;
       
  5189             break;
       
  5190             }
       
  5191         case KSimInit:
       
  5192             {
       
  5193             serviceType = UICC_REFRESH_NAA_INIT;
       
  5194             break;
       
  5195             }
       
  5196         case KSimReset:
       
  5197             {
       
  5198             serviceType = UICC_REFRESH_UICC_RESET;
       
  5199             break;
       
  5200             }
       
  5201         case KUSIMApplicationReset:
       
  5202             {
       
  5203             serviceType = UICC_REFRESH_NAA_APPLICATION_RESET;
       
  5204             break;
       
  5205             }
       
  5206         case K3GSessionReset:
       
  5207             {
       
  5208             serviceType = UICC_REFRESH_NAA_SESSION_RESET;
       
  5209             break;
       
  5210             }
       
  5211         default:
       
  5212             {
       
  5213             break;
       
  5214             }
       
  5215         }
       
  5216     return serviceType;
       
  5217     }
       
  5218 
       
  5219 // -----------------------------------------------------------------------------
       
  5220 // CSatNotifyRefresh::CompleteRequest
       
  5221 // Overloads original protected CompleteRequest method from Base class.
       
  5222 // (other items were commented in a header).
       
  5223 // -----------------------------------------------------------------------------
       
  5224 //
       
  5225 void CSatNotifyRefresh::CompleteRequest
       
  5226         (
       
  5227         const TInt aError
       
  5228         )
       
  5229     {
       
  5230     OstTraceExt2( TRACE_NORMAL, CSATNOTIFYREFRESH_COMPLETEREQUEST, "CSatNotifyRefresh::CompleteRequest Handle: %d, Error: %d", (TInt)iReqHandle, aError );
       
  5231     TFLOGSTRING3("CSatNotifyRefresh::CompleteRequest. \n\t\t\t Handle:%d\n\t\t\t Error:%d",
       
  5232                iReqHandle,
       
  5233                aError);
       
  5234     TTsyReqHandle tempReqHandle = iReqHandle;
       
  5235     iReqHandle = NULL;
       
  5236     iSatMessaging->ReqCompleted( tempReqHandle, aError );
       
  5237     TFLOGSTRING("CSatNotifyRefresh::CompleteRequest. Request is now completed");
       
  5238     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYREFRESH_COMPLETEREQUEST, "CSatNotifyRefresh::CompleteRequest Request is now completed" );
       
  5239 
       
  5240     }
       
  5241 
       
  5242 // -----------------------------------------------------------------------------
       
  5243 // CSatNotifyRefresh::CachedFiles
       
  5244 // Returns list of files that are cached in SIM ATK TSY
       
  5245 // (other items were commented in a header).
       
  5246 // -----------------------------------------------------------------------------
       
  5247 //
       
  5248 TUint16 CSatNotifyRefresh::CachedFiles() const
       
  5249     {
       
  5250     OstTrace0( TRACE_NORMAL, CSATNOTIFYREFRESH_CACHEDFILES, "CSatNotifyRefresh::CachedFiles" );
       
  5251     return iInternalCache;
       
  5252     }
       
  5253 
       
  5254 // -----------------------------------------------------------------------------
       
  5255 // CSatNotifySimSessionEnd::CSatNotifySimSessionEnd
       
  5256 // C++ default constructor can NOT contain any code, that
       
  5257 // might leave.
       
  5258 // -----------------------------------------------------------------------------
       
  5259 //
       
  5260 CSatNotifySimSessionEnd::CSatNotifySimSessionEnd
       
  5261         (
       
  5262         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  5263         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  5264         )
       
  5265         :
       
  5266         CSatNotificationsBase( aSatMessHandler, aSatMessaging )
       
  5267     {
       
  5268     OstTrace0( TRACE_NORMAL, CSATNOTIFYSIMSESSIONEND_CSATNOTIFYSIMSESSIONEND, "CSatNotifySimSessionEnd::CSatNotifySimSessionEnd" );
       
  5269     }
       
  5270 
       
  5271 // -----------------------------------------------------------------------------
       
  5272 // CSatNotifySimSessionEnd::~CSatNotifySimSessionEnd
       
  5273 // Destructor
       
  5274 // -----------------------------------------------------------------------------
       
  5275 //
       
  5276 CSatNotifySimSessionEnd::~CSatNotifySimSessionEnd()
       
  5277     {
       
  5278     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSIMSESSIONEND_CSATNOTIFYSIMSESSIONEND, "CSatNotifySimSessionEnd::~CSatNotifySimSessionEnd" );
       
  5279     // None
       
  5280     }
       
  5281 
       
  5282 
       
  5283 // -----------------------------------------------------------------------------
       
  5284 // CSatNotifySimSessionEnd::MessageReceived
       
  5285 // Handles a SimSessionEnd proactive command ISI message,
       
  5286 // and completes a pending ETel request.
       
  5287 // (other items were commented in a header).
       
  5288 // -----------------------------------------------------------------------------
       
  5289 //
       
  5290 void CSatNotifySimSessionEnd::MessageReceived
       
  5291         (
       
  5292         const TIsiReceiveC& /*aIsiMessage*/ // ISI message
       
  5293         )
       
  5294     {
       
  5295     OstTrace0( TRACE_NORMAL, CSATNOTIFYSIMSESSIONEND_MESSAGERECEIVED, "CSatNotifySimSessionEnd::MessageReceived" );
       
  5296     TFLOGSTRING("CSatNotifySimSessionEnd::MessageReceived");
       
  5297     if ( iReqHandle ) // If request on
       
  5298         {
       
  5299         CompleteRequest( KErrNone );
       
  5300         }
       
  5301     }
       
  5302 
       
  5303 // -----------------------------------------------------------------------------
       
  5304 // CSatNotifySimSessionEnd::Notify
       
  5305 // An ETel SAT client can call this method via ETel server to set a pending
       
  5306 // request in SimAtkTsy for a SimSessionEnd PCmd.
       
  5307 // (other items were commented in a header).
       
  5308 // -----------------------------------------------------------------------------
       
  5309 //
       
  5310 void CSatNotifySimSessionEnd::Notify
       
  5311         (
       
  5312         const TTsyReqHandle aReqHandle,     // Request handle
       
  5313         TDes8*           /* aDataPtr */     // Pointer to data
       
  5314         )
       
  5315     {
       
  5316     OstTrace0( TRACE_NORMAL, CSATNOTIFYSIMSESSIONEND_NOTIFY, "CSatNotifySimSessionEnd::Notify" );
       
  5317     TFLOGSTRING("CSatNotifySimSessionEnd::Notify");
       
  5318     iReqHandle = aReqHandle;
       
  5319     }
       
  5320 
       
  5321 
       
  5322 // -----------------------------------------------------------------------------
       
  5323 // CSatNotifySetUpIdleModeText::CSatNotifySetUpIdleModeText
       
  5324 // C++ default constructor can NOT contain any code, that
       
  5325 // might leave.
       
  5326 // -----------------------------------------------------------------------------
       
  5327 //
       
  5328 CSatNotifySetUpIdleModeText::CSatNotifySetUpIdleModeText
       
  5329         (
       
  5330         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  5331         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  5332         )
       
  5333         :
       
  5334         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  5335         iSetUpIdleModeTextV1Pckg( NULL )
       
  5336     {
       
  5337     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPIDLEMODETEXT_CSATNOTIFYSETUPIDLEMODETEXT, "CSatNotifySetUpIdleModeText::CSatNotifySetUpIdleModeText" );
       
  5338     // Following results are also allowed for this command:
       
  5339     // (in addition to result declared in base class constructor)
       
  5340     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  5341         + RSat::KErrorRequiredValuesMissing;
       
  5342     }
       
  5343 
       
  5344 // -----------------------------------------------------------------------------
       
  5345 // CSatNotifySetUpIdleModeText::~CSatNotifySetUpIdleModeText
       
  5346 // Destructor
       
  5347 // -----------------------------------------------------------------------------
       
  5348 //
       
  5349 CSatNotifySetUpIdleModeText::~CSatNotifySetUpIdleModeText()
       
  5350     {
       
  5351     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPIDLEMODETEXT_CSATNOTIFYSETUPIDLEMODETEXT, "CSatNotifySetUpIdleModeText::~CSatNotifySetUpIdleModeText" );
       
  5352     // None
       
  5353     }
       
  5354 
       
  5355 // -----------------------------------------------------------------------------
       
  5356 // CSatNotifySetUpIdleModeText::MessageReceived
       
  5357 // Handles a SetUpIdleModeText proactive command ISI message,
       
  5358 // and completes a pending ETel request.
       
  5359 // (other items were commented in a header).
       
  5360 // -----------------------------------------------------------------------------
       
  5361 //
       
  5362 void CSatNotifySetUpIdleModeText::MessageReceived
       
  5363         (
       
  5364         const TIsiReceiveC& aIsiMessage // ISI message
       
  5365         )
       
  5366     {
       
  5367     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPIDLEMODETEXT_MESSAGERECEIVED, "CSatNotifySetUpIdleModeText::MessageReceived" );
       
  5368     TFLOGSTRING("CSatNotifySetUpIdleModeText::MessageReceived");
       
  5369     TInt ret( KErrNone );
       
  5370     TInt returnValue( KErrNone );
       
  5371      //get ber tlv
       
  5372     CBerTlv berTlv;
       
  5373     berTlv.BerTlv( aIsiMessage );
       
  5374     //get command details tlv
       
  5375     CTlv commandDetails;
       
  5376     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  5377     iCommandDetails.Copy( commandDetails.Data() );
       
  5378     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  5379     if ( !iReqHandle )
       
  5380         {
       
  5381         // Request not on, returning response immediately
       
  5382         iSatMessHandler->SetUpIdleModeTextTerminalResp(
       
  5383              iTransId,
       
  5384              iCommandDetails,
       
  5385              RSat::KMeUnableToProcessCmd,
       
  5386              KNoCause );
       
  5387         }
       
  5388     else
       
  5389         {
       
  5390         // Fill the set up idle mode text structure
       
  5391         RSat::TSetUpIdleModeTextV1& setUpIdleModeTextV1
       
  5392             = ( *iSetUpIdleModeTextV1Pckg )();
       
  5393         setUpIdleModeTextV1.SetPCmdNumber(
       
  5394             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  5395         //Initialize Type to notSet, coding scheme to unicode and text to zero
       
  5396         setUpIdleModeTextV1.iType = RSat::ESetUpIdleModeTextTypeNotSet;
       
  5397         setUpIdleModeTextV1.iCodingScheme = RSat::E16bitUCS2;
       
  5398         setUpIdleModeTextV1.iText.Zero();
       
  5399         CTlv textString;
       
  5400         returnValue = berTlv.TlvByTagValue( &textString,
       
  5401             KTlvTextStringTag );
       
  5402         // If the returnValue is KErrNone
       
  5403         if ( KErrNone == returnValue )
       
  5404             {
       
  5405             if ( textString.GetLength() )
       
  5406                 {
       
  5407                 // Convert and set text
       
  5408                 TSatUtility::SetText( textString, setUpIdleModeTextV1.iText );
       
  5409                 //set type
       
  5410                 setUpIdleModeTextV1.iType = RSat::EUpdateIdleModeText;
       
  5411                 }
       
  5412             else
       
  5413                 {
       
  5414                 //set type
       
  5415                 setUpIdleModeTextV1.iType = RSat::ERemoveExistingIdleModeText;
       
  5416                 }
       
  5417             }
       
  5418         else
       
  5419             {
       
  5420             TFLOGSTRING("CSatNotifySetUpIdleModeText::MessageReceived \
       
  5421             No TLV text string found");
       
  5422             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPIDLEMODETEXT_MESSAGERECEIVED, "CSatNotifySetUpIdleModeText::MessageReceived No TLV text string found" );
       
  5423             iSatMessHandler->SetUpIdleModeTextTerminalResp(
       
  5424                 iTransId,
       
  5425                 iCommandDetails,
       
  5426                 RSat::KCmdDataNotUnderstood,
       
  5427                 KNoCause );
       
  5428             ret = KErrCorrupt;
       
  5429             }
       
  5430         // Iconid (optional)
       
  5431         TSatUtility::FillIconStructure( berTlv,
       
  5432             setUpIdleModeTextV1.iIconId );
       
  5433         CompleteRequest( ret );
       
  5434         }
       
  5435     }
       
  5436 
       
  5437 // -----------------------------------------------------------------------------
       
  5438 // CSatNotifySetUpIdleModeText::Notify
       
  5439 // An ETel SAT client can call this method via ETel server to set a pending
       
  5440 // request in SimAtkTsy for a SetUpIdleModeText PCmd.
       
  5441 // (other items were commented in a header).
       
  5442 // -----------------------------------------------------------------------------
       
  5443 //
       
  5444 void CSatNotifySetUpIdleModeText::Notify
       
  5445         (
       
  5446         const TTsyReqHandle aReqHandle, // Request handle
       
  5447         TDes8*              aDataPtr    // Pointer to data
       
  5448         )
       
  5449     {
       
  5450     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPIDLEMODETEXT_NOTIFY, "CSatNotifySetUpIdleModeText::Notify" );
       
  5451     TFLOGSTRING("CSatNotifySetUpIdleModeText::Notify");
       
  5452     iReqHandle = aReqHandle;
       
  5453     iSetUpIdleModeTextV1Pckg =
       
  5454      static_cast< RSat::TSetUpIdleModeTextV1Pckg* >( aDataPtr );
       
  5455     iSatMessaging->SatReady( KSetUpIdleModeText );
       
  5456     }
       
  5457 
       
  5458 // -----------------------------------------------------------------------------
       
  5459 // CSatNotifySetUpIdleModeText::TerminalResponse
       
  5460 // Handles a SetUpIdleModeText terminal response provided by an ETel SAT client via
       
  5461 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  5462 // (other items were commented in a header).
       
  5463 // -----------------------------------------------------------------------------
       
  5464 //
       
  5465 TInt CSatNotifySetUpIdleModeText::TerminalResponse
       
  5466         (
       
  5467         TDes8* aRsp // Response
       
  5468         )
       
  5469     {
       
  5470     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPIDLEMODETEXT_TERMINALRESPONSE, "CSatNotifySetUpIdleModeText::TerminalResponse" );
       
  5471     TFLOGSTRING("CSatNotifySetUpIdleModeText::TerminalResponse");
       
  5472     TInt   ret( KErrNone );
       
  5473     TUint8 additionalInfo( 0 );
       
  5474     RSat::TSetUpIdleModeTextRspV1Pckg* aRspPckg =
       
  5475             reinterpret_cast< RSat::TSetUpIdleModeTextRspV1Pckg* >( aRsp );
       
  5476     RSat::TSetUpIdleModeTextRspV1& rspV1 = ( *aRspPckg ) ();
       
  5477     // Check that general result value is valid
       
  5478     if ( iAllowedResults != rspV1.iGeneralResult )
       
  5479         {
       
  5480         // Invalid general result
       
  5481         ret = KErrCorrupt;
       
  5482         }
       
  5483     // If there is Me (Mobile Equipment) error, additional info is needed
       
  5484     if ( ( RSat::KMeProblem == rspV1.iInfoType ) )
       
  5485         {
       
  5486         // Check the length of additional info
       
  5487         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
  5488             {
       
  5489             additionalInfo = TUint8( rspV1.iAdditionalInfo[0] );
       
  5490             }
       
  5491         else
       
  5492             {
       
  5493             // Invalid additional info field
       
  5494             ret = KErrCorrupt;
       
  5495             }
       
  5496         }
       
  5497     // Creating the info message
       
  5498     iSatMessHandler->SetUpIdleModeTextTerminalResp(
       
  5499         iTransId,
       
  5500         iCommandDetails,
       
  5501         TUint8( rspV1.iGeneralResult ), additionalInfo );
       
  5502     return ret;
       
  5503     }
       
  5504 
       
  5505 
       
  5506 // -----------------------------------------------------------------------------
       
  5507 // CSatNotifyCallControlRequest::CSatNotifyCallControlRequest
       
  5508 // C++ default constructor can NOT contain any code, that
       
  5509 // might leave.
       
  5510 // -----------------------------------------------------------------------------
       
  5511 //
       
  5512 CSatNotifyCallControlRequest::CSatNotifyCallControlRequest
       
  5513         (
       
  5514         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  5515         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  5516         )
       
  5517         :
       
  5518         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  5519         iCallControlPckg( NULL )
       
  5520     {
       
  5521     OstTrace0( TRACE_NORMAL, CSATNOTIFYCALLCONTROLREQUEST_CSATNOTIFYCALLCONTROLREQUEST, "CSatNotifyCallControlRequest::CSatNotifyCallControlRequest" );
       
  5522     }
       
  5523 
       
  5524 // -----------------------------------------------------------------------------
       
  5525 // CSatNotifyCallControlRequest::~CSatNotifyCallControlRequest
       
  5526 // Destructor
       
  5527 // -----------------------------------------------------------------------------
       
  5528 //
       
  5529 CSatNotifyCallControlRequest::~CSatNotifyCallControlRequest()
       
  5530     {
       
  5531     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYCALLCONTROLREQUEST_CSATNOTIFYCALLCONTROLREQUEST, "CSatNotifyCallControlRequest::~CSatNotifyCallControlRequest" );
       
  5532     // None
       
  5533     }
       
  5534 
       
  5535 // -----------------------------------------------------------------------------
       
  5536 // CSatNotifyCallControlRequest::MessageReceived
       
  5537 // Handles a CallControlRequest proactive command ISI message,
       
  5538 // and completes a pending ETel request.
       
  5539 // (other items were commented in a header).
       
  5540 // -----------------------------------------------------------------------------
       
  5541 //
       
  5542 void CSatNotifyCallControlRequest::MessageReceived
       
  5543         (
       
  5544         const TIsiReceiveC& /*aIsiMessage*/ // ISI  message
       
  5545         )
       
  5546     {
       
  5547     OstTrace0( TRACE_NORMAL, CSATNOTIFYCALLCONTROLREQUEST_MESSAGERECEIVED, "CSatNotifyCallControlRequest::MessageReceived" );
       
  5548     // In S60 phones, the call control request is received via an ISI
       
  5549     // message coming from the ATK Guardian / Call server. That's why the body
       
  5550     // of this method is empty, see the class CSatCC. The Etel Sat API is used
       
  5551     // to pass to S60 Sat Server the alpha identifier provided by the SIM,
       
  5552     // if any. The SIM can provide such an alpha id to tell the user that the
       
  5553     // number to be called has been modified by the SIM.
       
  5554     }
       
  5555 
       
  5556 // -----------------------------------------------------------------------------
       
  5557 // CSatNotifyCallControlRequest::CompleteNotification
       
  5558 // Handles the Call Control notification received from ATK Guardian Server.
       
  5559 // Completes an Etel Sat API CallControlRequest pending request.
       
  5560 // (other items were commented in a header).
       
  5561 // -----------------------------------------------------------------------------
       
  5562 //
       
  5563 void CSatNotifyCallControlRequest::CompleteNotification
       
  5564         (
       
  5565         TDesC& aAlphaId,
       
  5566         RSat::TControlResult aResult
       
  5567         )
       
  5568     {
       
  5569     OstTrace0( TRACE_NORMAL, CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATION, "CSatNotifyCallControlRequest::CompleteNotification" );
       
  5570     TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotification");
       
  5571     //check that someone has requested this notifications
       
  5572     if ( iReqHandle )
       
  5573         {
       
  5574         // Temporary storage for Alpha Id
       
  5575         RSat::TAlphaId alphaId;
       
  5576         // Alpha ID validity
       
  5577         RSat::TAlphaIdValidity validity( RSat::EValidAlpaId );
       
  5578         alphaId.iStatus = RSat::EAlphaIdProvided;
       
  5579         alphaId.iAlphaId.Append( aAlphaId );
       
  5580         // Fill the call control structure
       
  5581         RSat::TCallControlV5& callControl = ( *iCallControlPckg )();
       
  5582 
       
  5583 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
  5584         if ( RSat::KSatV6 == callControl.ExtensionId() )
       
  5585             {
       
  5586             callControl = ( RSat::TCallControlV6& )callControl;
       
  5587             callControl = ( *iCallControlPckg )();
       
  5588             }
       
  5589 #endif
       
  5590 
       
  5591         // Set default control result
       
  5592         callControl.SetCcGeneralResult( aResult );
       
  5593         callControl.SetAlphaId( validity, alphaId );
       
  5594         // Complete notification
       
  5595         CompleteRequest( KErrNone );
       
  5596         }
       
  5597     }
       
  5598 
       
  5599 // -----------------------------------------------------------------------------
       
  5600 // CSatNotifyCallControlRequest::CompleteNotification
       
  5601 // Handles the Call Control GPRS notification received from ATK Guardian Server.
       
  5602 // Completes an Etel Sat API CallControlRequest pending request.
       
  5603 // (other items were commented in a header).
       
  5604 // -----------------------------------------------------------------------------
       
  5605 //
       
  5606 void CSatNotifyCallControlRequest::CompleteNotification
       
  5607         (
       
  5608         const TDesC& aAlphaId,
       
  5609         const RSat::TControlResult aResult
       
  5610         )
       
  5611     {
       
  5612     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATION, "CSatNotifyCallControlRequest::CompleteNotification" );
       
  5613     TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotification");
       
  5614     // Check that someone has requested this notifications
       
  5615     if ( iReqHandle )
       
  5616         {
       
  5617         // Create the call control structure
       
  5618         RSat::TCallControlV5& callControl = ( *iCallControlPckg )();
       
  5619 
       
  5620 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
  5621         // Check which version in use
       
  5622         if ( RSat::KSatV6 == callControl.ExtensionId() )
       
  5623             {
       
  5624             callControl = ( RSat::TCallControlV6& )callControl;
       
  5625             callControl = ( *iCallControlPckg )();
       
  5626             }
       
  5627 #endif
       
  5628 
       
  5629         // Check if the Alpha ID is present
       
  5630         if ( aAlphaId.Length() )
       
  5631             {
       
  5632             // Temporary storage for Alpha Id
       
  5633             RSat::TAlphaId alphaId;
       
  5634             // Alpha ID validity
       
  5635             RSat::TAlphaIdValidity validity( RSat::EValidAlpaId );
       
  5636             alphaId.iStatus = RSat::EAlphaIdProvided;
       
  5637             alphaId.iAlphaId.Append( aAlphaId );
       
  5638             // Set Alpha ID data
       
  5639             callControl.SetAlphaId( validity, alphaId );
       
  5640             }
       
  5641 
       
  5642         // The PDP Parameters need to be set even though they are not present.
       
  5643         // Otherwise the Call Control Type will not be set to ECcPDPParameters
       
  5644         // Temporary storage for PDP Context Parameters
       
  5645         TPdpParameters pdpParameters;
       
  5646         // Set empty PDP Parameters data
       
  5647         callControl.SetPdpParameters( pdpParameters );
       
  5648 
       
  5649         // Set call control result
       
  5650         callControl.SetCcGeneralResult( aResult );
       
  5651         // In Call control on GPRS, action originator is always modem
       
  5652         callControl.SetActionOriginator( RSat::EMeSideOriginator );
       
  5653         // Complete notification
       
  5654         CompleteRequest( KErrNone );
       
  5655         }
       
  5656     }
       
  5657 
       
  5658 // -----------------------------------------------------------------------------
       
  5659 // CSatNotifyCallControlRequest::CompleteNotificationL
       
  5660 // Completes an Etel Sat API CallControlRequest pending request.
       
  5661 // (other items were commented in a header).
       
  5662 // -----------------------------------------------------------------------------
       
  5663 //
       
  5664 void CSatNotifyCallControlRequest::CompleteNotificationL
       
  5665         (
       
  5666         const TUint8 aCcResult,
       
  5667         TPtrC8 aEnvelopeResponse
       
  5668         )
       
  5669     {
       
  5670     OstTrace0( TRACE_NORMAL, CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL" );
       
  5671     TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL");
       
  5672 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
  5673     // Check that someone has requested this notifications
       
  5674     if ( iReqHandle )
       
  5675         {
       
  5676         // When this method is used V6 structure is always used. Therefore
       
  5677         // casting is needed. Otherwise compiler gives errors.
       
  5678         // Create the call control structure.
       
  5679         RSat::TCallControlV6& callControl =
       
  5680             ( *(RSat::TCallControlV6Pckg*)iCallControlPckg )();
       
  5681 
       
  5682         switch ( aCcResult )
       
  5683             {
       
  5684             case KAllowed:
       
  5685                 {
       
  5686                 callControl.SetCcGeneralResult( RSat::EAllowedNoModification );
       
  5687                 // Cellmo continues with original operation
       
  5688                 callControl.SetActionOriginator( RSat::EMeSideOriginator );
       
  5689                 break;
       
  5690                 }
       
  5691             case KRejected:
       
  5692                 {
       
  5693                 callControl.SetCcGeneralResult( RSat::ENotAllowed );
       
  5694                 // original operation is rejected
       
  5695                 callControl.SetActionOriginator( RSat::EMeSideOriginator );
       
  5696                 break;
       
  5697                 }
       
  5698             case KModified:
       
  5699                 {
       
  5700                 callControl.SetCcGeneralResult(
       
  5701                     RSat::EAllowedWithModifications );
       
  5702                 // With cellmo value ATK_MODIFIED, same action is modified to
       
  5703                 // similar action and cellmo takes care of this
       
  5704                 callControl.SetActionOriginator( RSat::EMeSideOriginator );
       
  5705                 break;
       
  5706                 }
       
  5707             case KChanged:
       
  5708                 {
       
  5709                 callControl.SetCcGeneralResult(
       
  5710                     RSat::EAllowedWithModifications );
       
  5711                 // With cellmo value ATK_CHANGED, same action is modified to
       
  5712                 // another action and client is supposed to care of next action
       
  5713                 callControl.SetActionOriginator( RSat::EClientOriginator );
       
  5714                 break;
       
  5715                 }
       
  5716             default:
       
  5717                 {
       
  5718                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL\
       
  5719                     Not a valid call control result");
       
  5720                 OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Not a valid call control result" );
       
  5721                 break;
       
  5722                 }
       
  5723             }
       
  5724         TInt ret( KErrNotFound );
       
  5725         // Initialize ton and npi
       
  5726         RSat::TTypeOfNumber ton( RSat::EUnknownNumber );
       
  5727         RSat::TNumberingPlan npi( RSat::EUnknownNumberingPlan );
       
  5728         // incoming ber-tlv
       
  5729         CBerTlv response;
       
  5730         response.SetData( aEnvelopeResponse );
       
  5731 
       
  5732         CTlv ssString;
       
  5733         CTlv ussdTlv;
       
  5734 
       
  5735         if ( KErrNone == response.TlvByTagValue( &ssString, KTlvSsStringTag ) )
       
  5736             {
       
  5737             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5738                 Modified to SS");
       
  5739             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Modified to SS" );
       
  5740             // This SS related
       
  5741             RSat::TSsString tempSs;
       
  5742             // Call utility function that maps received TON and NPI
       
  5743             // to RSat values
       
  5744             TSatUtility::GetTonAndNpi(
       
  5745                 ssString.GetShortInfo( ETLV_TonAndNpi ), &ton, &npi );
       
  5746             // Set TON and NPI
       
  5747             tempSs.iTypeOfNumber = ton;
       
  5748             tempSs.iNumberPlan = npi;
       
  5749 
       
  5750             TBuf8<RSat::KStringMaxSize> tempString;
       
  5751             // Check length of SS string.
       
  5752             // BCD format = two digits "packed" in one characher
       
  5753             if ( ssString.GetLength() * 2 <= RSat::KStringMaxSize )
       
  5754                 {
       
  5755                 // Semi-octet presentation used
       
  5756                 // Converting back to ASCII format
       
  5757                 TSatUtility::BCDToAscii(
       
  5758                     ssString.GetData( ETLV_SsOrUssdString ),
       
  5759                     tempString );
       
  5760 
       
  5761                 tempSs.iSsString.Append( tempString );
       
  5762                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5763                     SetSendSsDetails");
       
  5764                 OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL SetSendSsDetails" );
       
  5765                 // Set SS string to struct
       
  5766                 callControl.SetSendSsDetails( tempSs );
       
  5767                 // Notify NokiaTSY that next SS request is SAT originated
       
  5768                 TFLOGSTRING("TSY: Inform NokiaTSY SS request being Call Control originated");
       
  5769                 OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "Inform NokiaTSY SS request being Call Control originated" );
       
  5770                 iSatMessaging->GetMessageRouter()->ExtFuncL(
       
  5771                     ESatNotifyCallControlRequest,
       
  5772                     NULL );
       
  5773                 }
       
  5774             else
       
  5775                 {
       
  5776                 // SS string is too long
       
  5777                 ret = KErrCorrupt;
       
  5778                 }
       
  5779             }
       
  5780         else if ( KErrNone ==
       
  5781                     response.TlvByTagValue( &ussdTlv, KTlvUssdStringTag ) )
       
  5782             {
       
  5783             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5784                 Modified to USSD");
       
  5785             OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Modified to USSD" );
       
  5786             // This is USSD related
       
  5787             RSat::TUssdString tempUssd;
       
  5788             // Get the data coding scheme from the ISI msg
       
  5789             // and set the corresponding ETel Sat data field.
       
  5790             tempUssd.iDcs = ussdTlv.GetShortInfo( ETLV_DataCodingScheme );
       
  5791 
       
  5792             // Check length of USSD string
       
  5793             if ( ussdTlv.GetLength() <= RSat::KStringMaxSize )
       
  5794                 {
       
  5795                 // Client wants USSD data as received from SIM
       
  5796                 tempUssd.iUssdString.Copy(
       
  5797                     ussdTlv.GetData( ETLV_UssdString ) );
       
  5798                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5799                     SetSendUssdDetails");
       
  5800                 OstTrace0( TRACE_NORMAL, DUP6_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL SetSendUssdDetails" );
       
  5801                 callControl.SetSendUssdDetails( tempUssd );
       
  5802                 }
       
  5803             else
       
  5804                 {
       
  5805                 // USSD string is too long
       
  5806                 ret = KErrCorrupt;
       
  5807                 }
       
  5808             }
       
  5809         else
       
  5810             {
       
  5811             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5812                 Modified to Call");
       
  5813             OstTrace0( TRACE_NORMAL, DUP7_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Modified to Call" );
       
  5814             // This must be call related response
       
  5815             CTlv addressTlv;
       
  5816 
       
  5817             RSat::TCallSetUpParams tempCallParams;
       
  5818 
       
  5819             ret = response.TlvByTagValue( &addressTlv, KTlvAddressTag );
       
  5820             if ( KErrNone == ret && addressTlv.GetLength() )
       
  5821                 {
       
  5822                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5823                     Address found");
       
  5824                 OstTrace0( TRACE_NORMAL, DUP8_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Address found" );
       
  5825 
       
  5826                 // Call utility function that maps received TON and NPI to
       
  5827                 // RSat values
       
  5828                 TSatUtility::GetTonAndNpi(
       
  5829                     addressTlv.GetShortInfo( ETLV_TonAndNpi ), &ton, &npi );
       
  5830                 // Set TON and NPI
       
  5831                 tempCallParams.iAddress.iTypeOfNumber = ton;
       
  5832                 tempCallParams.iAddress.iNumberPlan = npi;
       
  5833                 // Address
       
  5834                 tempCallParams.iAddress.iTelNumber.Zero();
       
  5835                 // length is number of BCD characters,
       
  5836                 // multiply by two to get real length and - 2 for ton&npi
       
  5837                 TInt dialNumberLength(
       
  5838                     ( ( addressTlv.GetLength() * 2 ) - 2 ) );
       
  5839 
       
  5840                 if ( dialNumberLength )
       
  5841                     {
       
  5842                     // Semi-octet presentation used
       
  5843                     TBuf8<RSat::KMaxMobileTelNumberSize> tempNumber;
       
  5844                     // Convert BCD string to ascii
       
  5845                     TSatUtility::BCDToAscii(
       
  5846                         addressTlv.GetData( ETLV_DiallingNumberString ),
       
  5847                         tempNumber );
       
  5848 
       
  5849                     // add '+' character to the preceding of international
       
  5850                     // number
       
  5851                     if ( ( tempCallParams.iAddress.iTypeOfNumber
       
  5852                         == RSat::EInternationalNumber )
       
  5853                         && ( tempNumber[ 0 ] != KPlusMarkCharacterCode )
       
  5854                         && RSat::KMaxMobileTelNumberSize > dialNumberLength )
       
  5855                         {
       
  5856                         _LIT8( KPlusMark, "+");
       
  5857                         tempNumber.Insert( 0, KPlusMark );
       
  5858                         }
       
  5859 
       
  5860                     // Set actual number
       
  5861                     tempCallParams.iAddress.iTelNumber.Copy( tempNumber );
       
  5862                     }
       
  5863                 }
       
  5864             // Check if Capability configuration parameters 1 are found
       
  5865             CTlv bcc1;
       
  5866             ret = response.TlvByTagValue(
       
  5867                 &bcc1,
       
  5868                 KTlvCapabilityConfigurationParametersTag );
       
  5869 
       
  5870             if ( KErrNone == ret )
       
  5871                 {
       
  5872                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5873                     bcc1 found");
       
  5874                 OstTrace0( TRACE_NORMAL, DUP9_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL bcc1 found" );
       
  5875                 // BC length is the first byte in BC data
       
  5876                 tempCallParams.iCcp1.Copy(
       
  5877                     bcc1.GetData( ETLV_CapabilityConfigurationParameters ) );
       
  5878                 }
       
  5879 
       
  5880             // Subaddress (optional)
       
  5881             CTlv subAddress;
       
  5882             ret = response.TlvByTagValue( &subAddress, KTlvSubaddressTag );
       
  5883             if ( KErrNone == ret )
       
  5884                 {
       
  5885                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5886                     subaddress found");
       
  5887                 OstTrace0( TRACE_NORMAL, DUP10_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL subaddress found" );
       
  5888                 tempCallParams.iSubAddress.Copy(
       
  5889                     subAddress.GetData( ETLV_SubAddress ) );
       
  5890                 }
       
  5891             // Capability configuration parameters 2
       
  5892             // --> BC repeat indicator is mandatory, only if BCC2 present
       
  5893             CTlv bcc2;
       
  5894             ret = response.TlvByTagValue(
       
  5895                 &bcc2,
       
  5896                 KTlvCapabilityConfigurationParametersTag,
       
  5897                 1 );
       
  5898 
       
  5899             if ( KErrNone == ret )
       
  5900                 {
       
  5901                 TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5902                     bcc2 found");
       
  5903                 OstTrace0( TRACE_NORMAL, DUP11_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL bcc2 found" );
       
  5904                 CTlv bcRepeat;
       
  5905                 ret = response.TlvByTagValue(
       
  5906                     &bcRepeat,
       
  5907                     KTlvBcRepeatIndicatorTag );
       
  5908 
       
  5909                 if ( KErrNone == ret )
       
  5910                     {
       
  5911                     // If bcc2 present, BC repeat indicator is mandatory
       
  5912                     if ( ATK_CIRCULAR_REPEAT_INDICATOR ==
       
  5913                         bcRepeat.GetShortInfo( ETLV_BcRepeatIndicatorValues ) )
       
  5914                         {
       
  5915                         callControl.SetBCRepeatIndicator(
       
  5916                             RSat::EBCAlternateMode );
       
  5917                         }
       
  5918                     else if ( ATK_SEQUENTIAL_REPEAT_INDICATOR ==
       
  5919                         bcRepeat.GetShortInfo( ETLV_BcRepeatIndicatorValues ) )
       
  5920                         {
       
  5921                         callControl.SetBCRepeatIndicator(
       
  5922                             RSat::EBCFallbackMode );
       
  5923                         }
       
  5924                     else
       
  5925                         {
       
  5926                         // repeat indicator not valid
       
  5927                         ret = KErrCorrupt;
       
  5928                         }
       
  5929                     // If mandatory BC repeat indicator present
       
  5930                     if ( ret != KErrCorrupt )
       
  5931                         {
       
  5932                         tempCallParams.iCcp2.Copy(
       
  5933                             bcc2.GetData(
       
  5934                             ETLV_CapabilityConfigurationParameters ) );
       
  5935                         }
       
  5936                     }
       
  5937                 }
       
  5938             // set call parameters
       
  5939             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5940                 SetCallSetUpDetails");
       
  5941             OstTrace0( TRACE_NORMAL, DUP12_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL SetCallSetUpDetails" );
       
  5942             callControl.SetCallSetUpDetails( tempCallParams );
       
  5943             }
       
  5944         // Check if alpha id present
       
  5945         TPtrC8 sourceString; // Used with conversions
       
  5946         RSat::TAlphaId tempAlphaId;
       
  5947         RSat::TAlphaIdValidity tempValidity( RSat::EAlphaIdValidityNotSet );
       
  5948         CTlv alphaIdentifier;
       
  5949         // Get alpha id tlv from berTlv
       
  5950         ret = response.TlvByTagValue(
       
  5951             &alphaIdentifier,
       
  5952             KTlvAlphaIdentifierTag );
       
  5953         // if alpha id string exist
       
  5954         if ( KErrNone == ret )
       
  5955             {
       
  5956             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5957                 Alpha id found");
       
  5958             OstTrace0( TRACE_NORMAL, DUP13_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Alpha id found" );
       
  5959             if ( alphaIdentifier.GetLength() )
       
  5960                 {
       
  5961                 // 8-bit string to 16-bit string
       
  5962                 sourceString.Set(
       
  5963                     alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  5964 
       
  5965                 // Convert and set the alpha id
       
  5966                 TSatUtility::SetAlphaId(
       
  5967                     sourceString, tempAlphaId.iAlphaId );
       
  5968                 // Set alpha id status
       
  5969                 tempAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  5970                 tempValidity = RSat::EValidAlpaId;
       
  5971                 }
       
  5972             else
       
  5973                 {
       
  5974                 tempAlphaId.iStatus = RSat::EAlphaIdNull;
       
  5975                 tempValidity = RSat::ENullAlphaId;
       
  5976                 }
       
  5977             }
       
  5978         // Alpha id not present
       
  5979         else
       
  5980             {
       
  5981             TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5982                 Alpha ID not present");
       
  5983             OstTrace0( TRACE_NORMAL, DUP14_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL Alpha ID not present" );
       
  5984             tempAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  5985             tempValidity = RSat::ENoAlphaId;
       
  5986             }
       
  5987         // Set alpha id values
       
  5988         TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5989             SetAlphaId");
       
  5990         OstTrace0( TRACE_NORMAL, DUP15_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATIONL, "CSatNotifyCallControlRequest::CompleteNotificationL SetAlphaId" );
       
  5991         callControl.SetAlphaId( tempValidity, tempAlphaId );
       
  5992         TFLOGSTRING("CSatNotifyCallControlRequest::CompleteNotificationL \
       
  5993             SetCallParamOrigin");
       
  5994         OstTrace0( TRACE_NORMAL, DUP18_CSATNOTIFYCALLCONTROLREQUEST_COMPLETENOTIFICATION, "CSatNotifyCallControlRequest::CompleteNotification SetCallParamOrigin" );
       
  5995 
       
  5996         CompleteRequest( KErrNone );
       
  5997         }
       
  5998 #endif
       
  5999     }
       
  6000 
       
  6001 // -----------------------------------------------------------------------------
       
  6002 // CSatNotifyCallControlRequest::Notify
       
  6003 // An ETel SAT client can call this method via ETel server to set a pending
       
  6004 // request in SimAtkTsy for a CallControlRequest PCmd.
       
  6005 // (other items were commented in a header).
       
  6006 // -----------------------------------------------------------------------------
       
  6007 //
       
  6008 void CSatNotifyCallControlRequest::Notify
       
  6009         (
       
  6010         const TTsyReqHandle aReqHandle,
       
  6011         TDes8* aDataPtr
       
  6012         )
       
  6013     {
       
  6014     OstTrace0( TRACE_NORMAL, CSATNOTIFYCALLCONTROLREQUEST_NOTIFY, "CSatNotifyCallControlRequest::Notify" );
       
  6015     TFLOGSTRING("CSatNotifyCallControlRequest::Notify");
       
  6016     iReqHandle = aReqHandle;
       
  6017 
       
  6018     iCallControlPckg = static_cast<RSat::TCallControlV5Pckg*>( aDataPtr );
       
  6019     }
       
  6020 
       
  6021 
       
  6022 // -----------------------------------------------------------------------------
       
  6023 // CSatNotifyLaunchBrowser::CSatNotifyLaunchBrowser
       
  6024 // C++ default constructor can NOT contain any code, that
       
  6025 // might leave.
       
  6026 // -----------------------------------------------------------------------------
       
  6027 //
       
  6028 CSatNotifyLaunchBrowser::CSatNotifyLaunchBrowser
       
  6029         (
       
  6030         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  6031         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  6032         )
       
  6033         :
       
  6034         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  6035         iLaunchBrowserV2Pckg( NULL )
       
  6036     {
       
  6037     OstTrace0( TRACE_NORMAL, CSATNOTIFYLAUNCHBROWSER_CSATNOTIFYLAUNCHBROWSER, "CSatNotifyLaunchBrowser::CSatNotifyLaunchBrowser" );
       
  6038     // Following results are also allowed for this command:
       
  6039     // (in addition to result declared in base class constructor)
       
  6040     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  6041         + RSat::KNetworkUnableToProcessCmd + RSat::KPCmdNotAcceptedByUser
       
  6042         + RSat::KLaunchBrowserError;
       
  6043     }
       
  6044 
       
  6045 // -----------------------------------------------------------------------------
       
  6046 // CSatNotifyLaunchBrowser::~CSatNotifyLaunchBrowser
       
  6047 // Destructor
       
  6048 // -----------------------------------------------------------------------------
       
  6049 //
       
  6050 CSatNotifyLaunchBrowser::~CSatNotifyLaunchBrowser()
       
  6051     {
       
  6052     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYLAUNCHBROWSER_CSATNOTIFYLAUNCHBROWSER, "CSatNotifyLaunchBrowser::~CSatNotifyLaunchBrowser" );
       
  6053     // None
       
  6054     }
       
  6055 
       
  6056 // -----------------------------------------------------------------------------
       
  6057 // CSatNotifyLaunchBrowser::MessageReceived
       
  6058 // Handles a LaunchBrowser proactive command ISI message,
       
  6059 // and completes a pending ETel request.
       
  6060 // (other items were commented in a header).
       
  6061 // -----------------------------------------------------------------------------
       
  6062 //
       
  6063 void CSatNotifyLaunchBrowser::MessageReceived
       
  6064         (
       
  6065         const TIsiReceiveC& aIsiMessage // ISI message
       
  6066         )
       
  6067     {
       
  6068     OstTrace0( TRACE_NORMAL, CSATNOTIFYLAUNCHBROWSER_MESSAGERECEIVED, "CSatNotifyLaunchBrowser::MessageReceived" );
       
  6069     TFLOGSTRING("CSatNotifyLaunchBrowser::MessageReceived");
       
  6070     //get ber tlv
       
  6071     CBerTlv berTlv;
       
  6072     berTlv.BerTlv( aIsiMessage );
       
  6073     //get command details tlv
       
  6074     CTlv commandDetails;
       
  6075     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  6076     iCommandDetails.Copy( commandDetails.Data() );
       
  6077     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  6078     // Get command qualifier
       
  6079     TUint8 cmdQualifier( commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  6080     if ( !iReqHandle )
       
  6081         {
       
  6082         // Request not on, returning response immediately
       
  6083         iSatMessHandler->LaunchBrowserTerminalResp(
       
  6084             iTransId, iCommandDetails,
       
  6085             RSat::KMeUnableToProcessCmd,
       
  6086             KNoCause );
       
  6087         }
       
  6088     else if ( CSatMessHandler::ENotBusy != iSatMessHandler->SsStatus() )
       
  6089         {
       
  6090         TUint8 additionalInfo( RSat::KMeBusyOnSs );
       
  6091         if( CSatMessHandler::EUssdBusy == iSatMessHandler->SsStatus() )
       
  6092             {
       
  6093             additionalInfo = RSat::KMeBusyOnUssd;
       
  6094             }
       
  6095         // Ss or Ussd transaction ongoing
       
  6096         iSatMessHandler->LaunchBrowserTerminalResp(
       
  6097             iTransId, iCommandDetails,
       
  6098             RSat::KMeUnableToProcessCmd,
       
  6099             additionalInfo );
       
  6100         }
       
  6101     else
       
  6102         {
       
  6103         TInt ret( KErrNone );
       
  6104         TInt returnValue( KErrNone );
       
  6105         // Launch browser structure
       
  6106         RSat::TLaunchBrowserV2& launchBrowserV2 = ( *iLaunchBrowserV2Pckg )();
       
  6107         launchBrowserV2.SetPCmdNumber(
       
  6108             commandDetails.GetShortInfo( ETLV_CommandNumber ));
       
  6109         switch ( cmdQualifier )
       
  6110             {
       
  6111             case KLaunchBrowserIfNotYetLaunched:
       
  6112                {
       
  6113                 launchBrowserV2.iBrowserSel =
       
  6114                     RSat::ELaunchBrowserIfNotAlreadyLaunched;
       
  6115                 }
       
  6116                 break;
       
  6117             case KUseExistingBrowser:
       
  6118                 {
       
  6119                 launchBrowserV2.iBrowserSel = RSat::EUseExistingBrowser;
       
  6120                 break;
       
  6121                 }
       
  6122             case KCloseAndLaunchNewBrowser:
       
  6123                 {
       
  6124                 launchBrowserV2.iBrowserSel =
       
  6125                     RSat::ECloseExistingLaunchNewBrowserSession;
       
  6126                 break;
       
  6127                 }
       
  6128             case KLaunchBrowserCmdQualifierNotUsed:
       
  6129             case KLaunchBrowserCmdQualifierReserved:
       
  6130                 {
       
  6131                 iSatMessHandler->LaunchBrowserTerminalResp(
       
  6132                     iTransId, iCommandDetails,
       
  6133                     RSat::KCmdTypeNotUnderstood, KNoCause );
       
  6134                 ret = KErrCorrupt;
       
  6135                 break;
       
  6136                 }
       
  6137             default:
       
  6138                 {
       
  6139                 launchBrowserV2.iBrowserSel = RSat::EBrowserSelectionNotSet;
       
  6140                 break;
       
  6141                 }
       
  6142             }
       
  6143         if ( KErrNone == ret )
       
  6144             {
       
  6145             CTlv browserId; // optional
       
  6146             returnValue = berTlv.TlvByTagValue( &browserId,
       
  6147                 KTlvBrowserIdentityTag );
       
  6148             if ( KErrNotFound != returnValue )
       
  6149                 {
       
  6150                 // Browser id 0x00-0x04 allowed, other values are RFU
       
  6151                 switch ( browserId.GetShortInfo( ETLV_BrowserIdentity ) )
       
  6152                     {
       
  6153                     case KDefaultBrowser:
       
  6154                         {
       
  6155                         launchBrowserV2.iBrowserId = RSat::EDefaultBrowser;
       
  6156                         break;
       
  6157                         }
       
  6158 #if ( NCP_COMMON_S60_VERSION_SUPPORT >= S60_VERSION_50 )
       
  6159                     case KWMLBrowser:
       
  6160                         {
       
  6161                         launchBrowserV2.iBrowserId = RSat::EWMLBrowser;
       
  6162                         break;
       
  6163                         }
       
  6164                     case KHTMLBrowser:
       
  6165                         {
       
  6166                         launchBrowserV2.iBrowserId = RSat::EHTMLBrowser;
       
  6167                         break;
       
  6168                         }
       
  6169                     case KXHTMLBrowser:
       
  6170                         {
       
  6171                         launchBrowserV2.iBrowserId = RSat::EXHTMLBrowser;
       
  6172                         break;
       
  6173                         }
       
  6174                     case KCHTMLBrowser:
       
  6175                         {
       
  6176                         launchBrowserV2.iBrowserId = RSat::ECHTMLBrowser;
       
  6177                         break;
       
  6178                         }
       
  6179 #endif
       
  6180                     default:
       
  6181                         {
       
  6182                         // Object present but does not identify a known
       
  6183                         // browser ID
       
  6184                         launchBrowserV2.iBrowserId =
       
  6185                             RSat::EBrowserIdNotSpecified;
       
  6186                         break;
       
  6187                         }
       
  6188                     }
       
  6189                 }
       
  6190             else
       
  6191                 {
       
  6192                 launchBrowserV2.iBrowserId = RSat::EBrowserIdNotPresent;
       
  6193                 }
       
  6194             }
       
  6195         if ( KErrNone == ret )
       
  6196             {
       
  6197             CTlv url; // mandatory
       
  6198             returnValue = berTlv.TlvByTagValue( &url, KTlvUrlTag );
       
  6199             if ( KErrNotFound != returnValue )
       
  6200                 {
       
  6201                 if ( RSat::KUrlMaxSize < url.GetLength() )
       
  6202                     {
       
  6203                     iSatMessHandler->LaunchBrowserTerminalResp(
       
  6204                         iTransId, iCommandDetails,
       
  6205                         RSat::KMeUnableToProcessCmd, KNoCause );
       
  6206                     ret = KErrCorrupt;
       
  6207                     }
       
  6208                 else
       
  6209                     {
       
  6210                     launchBrowserV2.iUrl.Copy( url.GetData( ETLV_Url ) );
       
  6211                     }
       
  6212                 }
       
  6213             else
       
  6214                 {
       
  6215                 iSatMessHandler->LaunchBrowserTerminalResp(
       
  6216                     iTransId, iCommandDetails,
       
  6217                     RSat::KErrorRequiredValuesMissing, KNoCause );
       
  6218                 ret = KErrCorrupt;
       
  6219                 }
       
  6220             }
       
  6221         if ( KErrNone == ret )
       
  6222             {
       
  6223             CTlv provisioningFileList; // optional
       
  6224             returnValue = berTlv.TlvByTagValueMulti( &provisioningFileList,
       
  6225                 KTlvProvisioningReferenceFileTag );
       
  6226             TPtrC8 fileRefData = provisioningFileList.Data();
       
  6227             TUint8 numberOfFileRefData( 0 );
       
  6228             TInt ind( 0 );
       
  6229             TInt tlvLength( 0 );
       
  6230             TInt currentTlv( 0 );
       
  6231             if ( KErrNotFound != returnValue )
       
  6232                 {
       
  6233                 // search for number of file references
       
  6234                 TInt i( 0 );
       
  6235                 for ( i = 0; i < fileRefData.Length(); i += tlvLength )
       
  6236                     {
       
  6237                     //first determine if the length of the TLV is coded
       
  6238                     // with 1 or 2 bytes.
       
  6239                     if ( KTwoByteLengthCoding == fileRefData[ind+1] )
       
  6240                         {
       
  6241                         //length is coded with 2 bytes -> 1 extra byte required
       
  6242                         // to be
       
  6243                         //added to total length. Also TLV header bytes (2)
       
  6244                         // must be added
       
  6245                         //to total length
       
  6246                         tlvLength = fileRefData[ind+2] + KTlvHeaderLength + 1;
       
  6247                         }
       
  6248                     else
       
  6249                         {
       
  6250                         //TLV header bytes (2) must be added to total length
       
  6251                         tlvLength = fileRefData[ind+1]  + KTlvHeaderLength;
       
  6252                         }
       
  6253 
       
  6254                     currentTlv = fileRefData[ind];
       
  6255                     if ( KTlvProvisioningReferenceFileTag == currentTlv )
       
  6256                         {
       
  6257                             numberOfFileRefData++;
       
  6258                         }
       
  6259 
       
  6260                     ind += tlvLength;
       
  6261                     }
       
  6262                 RSat::TProvisioningFileRef newFileRef;
       
  6263                 // Set string length and pos
       
  6264                 TUint8 stringLength( 0 );
       
  6265                 TUint  pos( 2 );
       
  6266                 // add FileReferences to the structure launchBrowserV2
       
  6267                 for ( i = 0; ( i < numberOfFileRefData ) && ( KErrNone == ret );
       
  6268                     i++ )
       
  6269                     {
       
  6270                     // Fill the newfileref
       
  6271                     stringLength = TUint8( fileRefData[pos - 1] );
       
  6272                     // Test whether the text contains more than "MF"
       
  6273                     if ( ( RSat::KFileRefMaxSize < stringLength )
       
  6274                         || ( 4 > stringLength ) )
       
  6275                         {
       
  6276                         iSatMessHandler->LaunchBrowserTerminalResp(
       
  6277                             iTransId, iCommandDetails,
       
  6278                             RSat::KLaunchBrowserError,
       
  6279                             RSat::KMeUnableToReadProvisioningData );
       
  6280                         ret = KErrCorrupt;
       
  6281                         break;
       
  6282                         }
       
  6283                     newFileRef.Zero();
       
  6284                     TUint8 x( 0 );
       
  6285                     for ( x = 0; x < stringLength; x++ )
       
  6286                         {
       
  6287                         newFileRef.Append( fileRefData[pos+x] );
       
  6288                         }
       
  6289                      // Adding the new fileref
       
  6290                     if ( KErrNoMemory ==
       
  6291                          launchBrowserV2.AddFileRef( newFileRef ) )
       
  6292                         {
       
  6293                         // Too many or long menuitems
       
  6294                         iSatMessHandler->LaunchBrowserTerminalResp(
       
  6295                             iTransId, iCommandDetails,
       
  6296                             RSat::KLaunchBrowserError,
       
  6297                             RSat::KMeUnableToReadProvisioningData );
       
  6298                         ret = KErrCorrupt;
       
  6299                         }
       
  6300                     // Calculating the new position
       
  6301                     pos = TUint( pos + fileRefData[pos - 1] + 2 );
       
  6302                     }
       
  6303                 }
       
  6304             }
       
  6305         if ( KErrNone == ret )
       
  6306             {
       
  6307             // Bearers (optional)
       
  6308             CTlv bearerList;
       
  6309             returnValue = berTlv.TlvByTagValue( &bearerList,
       
  6310                 KTlvBearerTag );
       
  6311             if ( KErrNotFound != returnValue )
       
  6312                 {
       
  6313                 if ( RSat::KBearerListMaxSize >= bearerList.GetLength() )
       
  6314                     {
       
  6315                     TBuf8<RSat::KBearerListMaxSize> brList =
       
  6316                         bearerList.GetData( ETLV_ListOfBearers );
       
  6317                     // SMS or USSD are not available bearers.
       
  6318                     TInt i( 0 );
       
  6319                     for ( i = 0; i < brList.Length() ; i++)
       
  6320                         {
       
  6321                         if ( KCsdBearer == brList[i]
       
  6322                             || KGprsBearer == brList[i] )
       
  6323                             {
       
  6324                             launchBrowserV2.iBearerList.Append( brList[i] );
       
  6325                             }
       
  6326                         }
       
  6327                     if ( 0x00 == launchBrowserV2.iBearerList.Length() )
       
  6328                         {
       
  6329                         iSatMessHandler->LaunchBrowserTerminalResp(
       
  6330                             iTransId, iCommandDetails,
       
  6331                             RSat::KLaunchBrowserError,
       
  6332                             RSat::KBearerUnvailable );
       
  6333                         ret = KErrCorrupt;
       
  6334                         }
       
  6335                     }
       
  6336                 else
       
  6337                     {
       
  6338                     iSatMessHandler->LaunchBrowserTerminalResp(
       
  6339                         iTransId, iCommandDetails,
       
  6340                         RSat::KCmdDataNotUnderstood, KNoCause );
       
  6341                     ret = KErrCorrupt;
       
  6342                     }
       
  6343                 }
       
  6344             }
       
  6345         if ( KErrNone == ret )
       
  6346             {
       
  6347             // Text string (Gateway/Proxy)
       
  6348             CTlv textString;
       
  6349             returnValue = berTlv.TlvByTagValue( &textString,
       
  6350                                                 KTlvTextStringTag );
       
  6351             if ( KErrNone == returnValue )
       
  6352                 {
       
  6353                 TSatUtility::SetText( textString, launchBrowserV2.iText );
       
  6354                 }
       
  6355             }
       
  6356         if ( KErrNone == ret )
       
  6357             {
       
  6358             // Alpha ID string (optional) for user confirmation phase
       
  6359             CTlv alphaIdentifier;
       
  6360             returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  6361                 KTlvAlphaIdentifierTag );
       
  6362             launchBrowserV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  6363             if ( KErrNotFound != returnValue )
       
  6364                 {
       
  6365                 TUint8 alphaIdLength( alphaIdentifier.GetLength() );
       
  6366                 if ( alphaIdLength )
       
  6367                     {
       
  6368                     TPtrC8 sourceString;
       
  6369 
       
  6370                     // get the alpha id
       
  6371                     sourceString.Set(
       
  6372                         alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  6373 
       
  6374                     // convert and set the alpha id
       
  6375                     TSatUtility::SetAlphaId( sourceString ,
       
  6376                         launchBrowserV2.iAlphaId.iAlphaId );
       
  6377 
       
  6378                     launchBrowserV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  6379                     }
       
  6380                 else
       
  6381                     {
       
  6382                     launchBrowserV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  6383                     }
       
  6384                 }
       
  6385             // Iconid
       
  6386             TSatUtility::FillIconStructure( berTlv,
       
  6387                 launchBrowserV2.iIconId );
       
  6388             CompleteRequest( ret );
       
  6389             }
       
  6390 
       
  6391         } // end else
       
  6392 
       
  6393     }
       
  6394 
       
  6395 // -----------------------------------------------------------------------------
       
  6396 // CSatNotifyLaunchBrowser::Notify
       
  6397 // An ETel SAT client can call this method via ETel server to set a pending
       
  6398 // request in SimAtkTsy for a LaunchBrowser PCmd.
       
  6399 // (other items were commented in a header).
       
  6400 // -----------------------------------------------------------------------------
       
  6401 //
       
  6402 void CSatNotifyLaunchBrowser::Notify
       
  6403         (
       
  6404         const TTsyReqHandle aReqHandle, // Request handle
       
  6405         TDes8*              aDataPtr    // Pointer to data
       
  6406         )
       
  6407     {
       
  6408     OstTrace1( TRACE_NORMAL, CSATNOTIFYLAUNCHBROWSER_NOTIFY, "CSatNotifyLaunchBrowser::Notify Handle :%u", aReqHandle );
       
  6409     TFLOGSTRING2("CSatNotifyLaunchBrowser::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  6410                aReqHandle );
       
  6411     iReqHandle = aReqHandle;
       
  6412     iLaunchBrowserV2Pckg = static_cast< RSat::TLaunchBrowserV2Pckg* >( aDataPtr );
       
  6413     iSatMessaging->SatReady( KLaunchBrowser );
       
  6414     }
       
  6415 
       
  6416 // -----------------------------------------------------------------------------
       
  6417 // CSatNotifyLaunchBrowser::TerminalResponse
       
  6418 // Handles a LaunchBrowser terminal response provided by an ETel SAT client via
       
  6419 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  6420 // (other items were commented in a header).
       
  6421 // -----------------------------------------------------------------------------
       
  6422 //
       
  6423 TInt CSatNotifyLaunchBrowser::TerminalResponse
       
  6424         (
       
  6425         TDes8* aRsp // Response
       
  6426         )
       
  6427     {
       
  6428     OstTrace0( TRACE_NORMAL, CSATNOTIFYLAUNCHBROWSER_TERMINALRESPONSE, "CSatNotifyLaunchBrowser::TerminalResponse" );
       
  6429     TFLOGSTRING("CSatNotifyLaunchBrowser::TerminalResponse");
       
  6430     TInt   ret( KErrNone );
       
  6431     TUint8 additionalInfo( 0 );
       
  6432     RSat::TLaunchBrowserRspV2Pckg* aRspPckg =
       
  6433             reinterpret_cast< RSat::TLaunchBrowserRspV2Pckg* >( aRsp );
       
  6434     RSat::TLaunchBrowserRspV2& rspV2 = ( *aRspPckg ) ();
       
  6435     // Check that general result value is valid
       
  6436     if ( iAllowedResults != rspV2.iGeneralResult )
       
  6437         {
       
  6438         // Invalid general result
       
  6439         ret = KErrCorrupt;
       
  6440         }
       
  6441     // Check that infotype is valid: from enum TBrowserError in etelsat.h
       
  6442     if ( ( RSat::KMeProblem != rspV2.iInfoType )
       
  6443         && ( RSat::KNoAdditionalInfo != rspV2.iInfoType )
       
  6444         && ( RSat::KBearerUnvailable != rspV2.iInfoType )
       
  6445         && ( RSat::KBrowserUnavailable != rspV2.iInfoType )
       
  6446         && ( RSat::KMeUnableToReadProvisioningData != rspV2.iInfoType )
       
  6447         && ( RSat::KNoSpecificBrowserError != rspV2.iInfoType )
       
  6448         )
       
  6449         {
       
  6450         ret = KErrCorrupt;
       
  6451         }
       
  6452     // If there is Me (Mobile Equipment) error, additional info is needed
       
  6453     if ( ( RSat::KMeProblem == rspV2.iInfoType ) )
       
  6454         {
       
  6455         // Check the length of additional info
       
  6456         if ( rspV2.iAdditionalInfo.Length() != 0 )
       
  6457             {
       
  6458             additionalInfo = TUint8( rspV2.iAdditionalInfo[0] );
       
  6459             }
       
  6460         else
       
  6461             {
       
  6462             // Invalid additional info field
       
  6463             ret = KErrCorrupt;
       
  6464             }
       
  6465         }
       
  6466     iSatMessHandler->LaunchBrowserTerminalResp(
       
  6467         iTransId,                                   // Transaction id
       
  6468         iCommandDetails,                            // Command number
       
  6469         TUint8( rspV2.iGeneralResult ),             // Result
       
  6470         additionalInfo );                           // Additional info
       
  6471     return ret;
       
  6472     }
       
  6473 
       
  6474 
       
  6475 // -----------------------------------------------------------------------------
       
  6476 // CSatNotifySetUpEventList::CSatNotifySetUpEventList
       
  6477 // C++ default constructor can NOT contain any code, that
       
  6478 // might leave.
       
  6479 // -----------------------------------------------------------------------------
       
  6480 //
       
  6481 CSatNotifySetUpEventList::CSatNotifySetUpEventList
       
  6482         (
       
  6483         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  6484         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  6485         )
       
  6486         :
       
  6487         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  6488         iSetUpEventListV1Pckg( NULL ),
       
  6489         iCmdQualifier( KZero ),
       
  6490         iEvents( KZero )
       
  6491     {
       
  6492     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPEVENTLIST_CSATNOTIFYSETUPEVENTLIST, "CSatNotifySetUpEventList::CSatNotifySetUpEventList" );
       
  6493     // Following results are also allowed for this command:
       
  6494     // (in addition to result declared in base class constructor)
       
  6495     iAllowedResults += RSat::KErrorRequiredValuesMissing;
       
  6496     }
       
  6497 
       
  6498 // -----------------------------------------------------------------------------
       
  6499 // CSatNotifySetUpEventList::~CSatNotifySetUpEventList
       
  6500 // Destructor
       
  6501 // -----------------------------------------------------------------------------
       
  6502 //
       
  6503 CSatNotifySetUpEventList::~CSatNotifySetUpEventList()
       
  6504     {
       
  6505     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPEVENTLIST_CSATNOTIFYSETUPEVENTLIST, "CSatNotifySetUpEventList::~CSatNotifySetUpEventList" );
       
  6506     // None
       
  6507     }
       
  6508 
       
  6509 // -----------------------------------------------------------------------------
       
  6510 // CSatNotifySetUpEventList::MessageReceived
       
  6511 // Handles a SetUpEventList proactive command ISI message,
       
  6512 // and completes a pending ETel request.
       
  6513 // (other items were commented in a header).
       
  6514 // -----------------------------------------------------------------------------
       
  6515 //
       
  6516 void CSatNotifySetUpEventList::MessageReceived
       
  6517         (
       
  6518         const TIsiReceiveC& aIsiMessage // ISI message
       
  6519         )
       
  6520     {
       
  6521     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPEVENTLIST_MESSAGERECEIVED, "CSatNotifySetUpEventList::MessageReceived" );
       
  6522     TFLOGSTRING("CSatNotifySetUpEventList::MessageReceived");
       
  6523     TInt ret( KErrNone );
       
  6524     TUint8 generalResult( RSat::KSuccess );
       
  6525     //get ber tlv
       
  6526     CBerTlv berTlv;
       
  6527     ret = berTlv.BerTlv( aIsiMessage );
       
  6528     //get command details tlv
       
  6529     CTlv commandDetails;
       
  6530     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  6531     iCommandDetails.Copy( commandDetails.Data() );
       
  6532     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  6533     if ( !iReqHandle )
       
  6534         {
       
  6535         generalResult = RSat::KMeUnableToProcessCmd;
       
  6536         }
       
  6537     else
       
  6538         {
       
  6539         // Let's fill the setup event list structure
       
  6540         RSat::TSetUpEventListV1& setUpEventListV1 = ( *iSetUpEventListV1Pckg )();
       
  6541         setUpEventListV1.SetPCmdNumber(
       
  6542             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  6543         CTlv eventListTlv;
       
  6544         ret = berTlv.TlvByTagValue( &eventListTlv, KTlvEventListTag );
       
  6545         //Initialize Type to Not set
       
  6546         setUpEventListV1.iType = RSat::ESetUpEventListTypeNotSet;
       
  6547         // If the returnValue is KErrNone
       
  6548         if ( KErrNone == ret )
       
  6549             {
       
  6550             iEvents = 0;
       
  6551             TPtrC8 setUpEventList = eventListTlv.GetData( ETLV_EventList );
       
  6552             TUint16 eventListLength = eventListTlv.GetLength();
       
  6553             if ( !eventListLength )
       
  6554                 {
       
  6555                  setUpEventListV1.iType = RSat::ERemoveExistingEventList;
       
  6556                  // remove events from TSY:s list
       
  6557                  iSatMessaging->SetUpEventList( 0 ); // no events = 0
       
  6558                 }
       
  6559             else
       
  6560                 {
       
  6561                 setUpEventListV1.iType = RSat::EUpdateEventList;
       
  6562                 TInt8 i( 0 );
       
  6563                 TBuf8<14> eventList;
       
  6564                 eventList.FillZ( 14 );
       
  6565                 for ( i = 0; i < eventListLength; i++ )
       
  6566                     {
       
  6567                     if(  KLocalConnection < setUpEventList[i] )
       
  6568                         {
       
  6569                         //Invalid event code
       
  6570                         generalResult = RSat::KCmdBeyondMeCapabilities;
       
  6571                         }
       
  6572                     else if( !eventList[setUpEventList[i]] )
       
  6573                         {
       
  6574                         //Each event type shall not appear more than ones
       
  6575                         eventList[ setUpEventList[i] ] = 0x01;
       
  6576                         switch( setUpEventList[i] )
       
  6577                             {
       
  6578                             case KMTCall:
       
  6579                                 iEvents += RSat::KMTCall;
       
  6580                                 break;
       
  6581                             case KCallConnected:
       
  6582                                 iEvents += RSat::KCallConnected;
       
  6583                                 break;
       
  6584                             case KCallDisconnected:
       
  6585                                 iEvents += RSat::KCallDisconnected;
       
  6586                                 break;
       
  6587                             case KLocationStatus:
       
  6588                                 iEvents += RSat::KLocationStatus;
       
  6589                                 break;
       
  6590                             case KUserActivity:
       
  6591                                 setUpEventListV1.iEvents
       
  6592                                     += RSat::KUserActivity;
       
  6593                                 iEvents += RSat::KUserActivity;
       
  6594                                 break;
       
  6595                             case KIdleScreenAvailable:
       
  6596                                 setUpEventListV1.iEvents
       
  6597                                     += RSat::KIdleScreenAvailable;
       
  6598                                 iEvents += RSat::KIdleScreenAvailable;
       
  6599                                 break;
       
  6600                             case KCardReaderStatus:
       
  6601                                 setUpEventListV1.iEvents
       
  6602                                     += RSat::KCardReaderStatus;
       
  6603                                 iEvents += RSat::KCardReaderStatus;
       
  6604                                 break;
       
  6605                             case KLanguageSelection:
       
  6606                                 setUpEventListV1.iEvents
       
  6607                                     += RSat::KLanguageSelection;
       
  6608                                 iEvents += RSat::KLanguageSelection;
       
  6609                                 break;
       
  6610                             case KBrowserTermination:
       
  6611                                 setUpEventListV1.iEvents
       
  6612                                     += RSat::KBrowserTermination;
       
  6613                                 iEvents += RSat::KBrowserTermination;
       
  6614                                 break;
       
  6615                             case KDataAvailable:
       
  6616                                 setUpEventListV1.iEvents
       
  6617                                     += RSat::KDataAvailable;
       
  6618                                 iEvents += RSat::KDataAvailable;
       
  6619                                 break;
       
  6620                             case KChannelStatus:
       
  6621                                 setUpEventListV1.iEvents
       
  6622                                     += RSat::KChannelStatus;
       
  6623                                 iEvents += RSat::KChannelStatus;
       
  6624                                 break;
       
  6625                             case KAccessTechnologyChange:
       
  6626                                 iEvents += RSat::KAccessTechnologyChange;
       
  6627                                 break;
       
  6628                             case KDisplayParamsChanges:
       
  6629                                 setUpEventListV1.iEvents
       
  6630                                     += RSat::KDisplayParamsChanges;
       
  6631                                 iEvents += RSat::KDisplayParamsChanges;
       
  6632                                 break;
       
  6633                             case KLocalConnection:
       
  6634                                 setUpEventListV1.iEvents
       
  6635                                     += RSat::KLocalConnection;
       
  6636                                 iEvents += RSat::KLocalConnection;
       
  6637                                 break;
       
  6638                             default:
       
  6639                                 break;
       
  6640                             }
       
  6641                         }
       
  6642                     else
       
  6643                         {
       
  6644                         TFLOGSTRING("TSY: \
       
  6645                         CSatNotifySetUpEventList::MessageReceived, \
       
  6646                         Event not recognized or not supported.");
       
  6647                         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSETUPEVENTLIST_MESSAGERECEIVED, "CSatNotifySetUpEventList::MessageReceived, Event not recognized or not supported." );
       
  6648                         }
       
  6649                     }
       
  6650                 }
       
  6651             }
       
  6652         else
       
  6653             {
       
  6654             //Event list is missing
       
  6655             generalResult = RSat::KErrorRequiredValuesMissing;
       
  6656             }
       
  6657         }
       
  6658     if( RSat::KSuccess != generalResult )
       
  6659         {
       
  6660         iSatMessHandler->SetUpEventListTerminalResp(
       
  6661                                 iTransId,
       
  6662                                 iCommandDetails,
       
  6663                                 generalResult,
       
  6664                                 KNoCause );  // KNoCause: 0
       
  6665         }
       
  6666     else
       
  6667         {
       
  6668         CompleteRequest( ret );
       
  6669         }
       
  6670     }
       
  6671 
       
  6672 // -----------------------------------------------------------------------------
       
  6673 // CSatNotifySetUpEventList::Notify
       
  6674 // An ETel SAT client can call this method via ETel server to set a pending
       
  6675 // request in SimAtkTsy for a SetUpEventList PCmd.
       
  6676 // (other items were commented in a header).
       
  6677 // -----------------------------------------------------------------------------
       
  6678 //
       
  6679 void CSatNotifySetUpEventList::Notify
       
  6680         (
       
  6681         const TTsyReqHandle aReqHandle, // Request handle
       
  6682         TDes8*              aDataPtr    // Pointer to data
       
  6683         )
       
  6684     {
       
  6685     OstTrace1( TRACE_NORMAL, CSATNOTIFYSETUPEVENTLIST_NOTIFY, "CSatNotifySetUpEventList::Notify Handle: %u", aReqHandle );
       
  6686     TFLOGSTRING2("CSatNotifySetUpEventList::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  6687                aReqHandle );
       
  6688     iReqHandle = aReqHandle;
       
  6689     iSetUpEventListV1Pckg = static_cast< RSat::TSetUpEventListV1Pckg* >( aDataPtr );
       
  6690     iSatMessaging->SatReady( KSetUpEventList );
       
  6691     }
       
  6692 
       
  6693 // -----------------------------------------------------------------------------
       
  6694 // CSatNotifySetUpEventList::TerminalResponse
       
  6695 // Handles a SetUpEventList terminal response provided by an ETel SAT client via
       
  6696 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  6697 // (other items were commented in a header).
       
  6698 // -----------------------------------------------------------------------------
       
  6699 //
       
  6700 TInt CSatNotifySetUpEventList::TerminalResponse
       
  6701         (
       
  6702         TDes8* aRsp // Response
       
  6703         )
       
  6704     {
       
  6705     OstTrace0( TRACE_NORMAL, CSATNOTIFYSETUPEVENTLIST_TERMINALRESPONSE, "CSatNotifySetUpEventList::TerminalResponse" );
       
  6706     TFLOGSTRING("CSatNotifySetUpEventList::TerminalResponse");
       
  6707     TInt   ret( KErrNone );
       
  6708     TUint8 additionalInfo( 0 );
       
  6709     RSat::TSetUpEventListRspV1Pckg* aRspPckg =
       
  6710             reinterpret_cast< RSat::TSetUpEventListRspV1Pckg* >( aRsp );
       
  6711     RSat::TSetUpEventListRspV1& rspV1 = ( *aRspPckg ) ();
       
  6712     // Check that general result value is valid
       
  6713     if ( iAllowedResults != rspV1.iGeneralResult )
       
  6714         {
       
  6715         // Invalid general result
       
  6716         ret = KErrCorrupt;
       
  6717         }
       
  6718     // If there is Me (Mobile Entity) error, additional info is needed
       
  6719     if ( ( RSat::KMeProblem == rspV1.iInfoType ) )
       
  6720         {
       
  6721         // Check the length of additional info
       
  6722         if ( NULL != rspV1.iAdditionalInfo.Length() )
       
  6723             {
       
  6724             additionalInfo = static_cast< TUint8 >( rspV1.iAdditionalInfo[0] );
       
  6725             }
       
  6726         else
       
  6727             {
       
  6728             // Invalid additional info field
       
  6729             ret = KErrCorrupt;
       
  6730             }
       
  6731         }
       
  6732     if( RSat::KSuccess == rspV1.iGeneralResult )
       
  6733         {
       
  6734         // set events to TSY:s list
       
  6735         iSatMessaging->SetUpEventList( iEvents );
       
  6736         }
       
  6737     iSatMessHandler->SetUpEventListTerminalResp(
       
  6738         iTransId,
       
  6739         iCommandDetails,
       
  6740         TUint8( rspV1.iGeneralResult ),
       
  6741         additionalInfo );
       
  6742     return ret;
       
  6743     }
       
  6744 
       
  6745 
       
  6746 // -----------------------------------------------------------------------------
       
  6747 // CSatNotifyPollingOff::CSatNotifyPollingOff
       
  6748 // C++ default constructor can NOT contain any code, that
       
  6749 // might leave.
       
  6750 // -----------------------------------------------------------------------------
       
  6751 //
       
  6752 CSatNotifyPollingOff::CSatNotifyPollingOff
       
  6753         (
       
  6754         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  6755         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  6756         )
       
  6757         :
       
  6758         CSatNotificationsBase( aSatMessHandler, aSatMessaging )
       
  6759     {
       
  6760     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINGOFF_CSATNOTIFYPOLLINGOFF, "CSatNotifyPollingOff::CSatNotifyPollingOff" );
       
  6761     // Following results are also allowed for this command:
       
  6762     // (in addition to result declared in base class constructor)
       
  6763     iAllowedResults += RSat::KErrorRequiredValuesMissing;
       
  6764     }
       
  6765 
       
  6766 // -----------------------------------------------------------------------------
       
  6767 // CSatNotifyPollingOff::~CSatNotifyPollingOff
       
  6768 // Destructor
       
  6769 // -----------------------------------------------------------------------------
       
  6770 //
       
  6771 CSatNotifyPollingOff::~CSatNotifyPollingOff()
       
  6772     {
       
  6773     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYPOLLINGOFF_CSATNOTIFYPOLLINGOFF, "CSatNotifyPollingOff::~CSatNotifyPollingOff" );
       
  6774     // None
       
  6775     }
       
  6776 
       
  6777 // -----------------------------------------------------------------------------
       
  6778 // CSatNotifyPollingOff::MessageReceived
       
  6779 // Handles a PollingOff proactive command ISI message,
       
  6780 // and completes a pending ETel request.
       
  6781 // (other items were commented in a header).
       
  6782 // -----------------------------------------------------------------------------
       
  6783 //
       
  6784 void CSatNotifyPollingOff::MessageReceived
       
  6785         (
       
  6786         const TIsiReceiveC& aIsiMessage // ISI message
       
  6787         )
       
  6788     {
       
  6789     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINGOFF_MESSAGERECEIVED, "CSatNotifyPollingOff::MessageReceived" );
       
  6790     TFLOGSTRING("CSatNotifyPollingOff::MessageReceived");
       
  6791     //get ber tlv
       
  6792     CBerTlv berTlv;
       
  6793     berTlv.BerTlv( aIsiMessage );
       
  6794     //get command details tlv
       
  6795     CTlv commandDetails;
       
  6796     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  6797     iCommandDetails.Copy( commandDetails.Data() );
       
  6798     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  6799     if ( !( iSatMessHandler->PollingOff() ) )
       
  6800         {
       
  6801         iSatMessHandler->SetPollingOff( ETrue );
       
  6802         iSatMessHandler->SetPollingInterval(
       
  6803             iTransId,
       
  6804             KDefaultPollInterval );
       
  6805         // Terminal response is sent when the response
       
  6806         //from SIM server is received
       
  6807         }
       
  6808     else
       
  6809         {
       
  6810          // PollingOff is already off
       
  6811         iSatMessHandler->PollingOffTerminalResp(
       
  6812             iTransId,
       
  6813             iCommandDetails,
       
  6814             RSat::KSuccess,
       
  6815             RSat::KNoAdditionalInfo );
       
  6816             }
       
  6817     }
       
  6818 
       
  6819 // -----------------------------------------------------------------------------
       
  6820 // CSatNotifyPollingOff::Notify
       
  6821 // An ETel SAT client can call this method via ETel server to set a pending
       
  6822 // request in SimAtkTsy for a PollingOff PCmd.
       
  6823 // (other items were commented in a header).
       
  6824 // -----------------------------------------------------------------------------
       
  6825 //
       
  6826 void CSatNotifyPollingOff::Notify
       
  6827         (
       
  6828         const TTsyReqHandle /*aReqHandle*/, // Request handle
       
  6829         TDes8*              /*aDataPtr*/    // Pointer to data
       
  6830         )
       
  6831     {
       
  6832     OstTrace0( TRACE_NORMAL, CSATNOTIFYPOLLINGOFF_NOTIFY, "CSatNotifyPollingOff::Notify" );
       
  6833     // PollingOff is completely implemented by SimAtkTsy. Client
       
  6834     // insn't notified about the command.
       
  6835     }
       
  6836 
       
  6837 
       
  6838 // -----------------------------------------------------------------------------
       
  6839 // CSatNotifyLocalInfo::CSatNotifyLocalInfo
       
  6840 // C++ default constructor can NOT contain any code, that
       
  6841 // might leave.
       
  6842 // -----------------------------------------------------------------------------
       
  6843 //
       
  6844 CSatNotifyLocalInfo::CSatNotifyLocalInfo
       
  6845         (
       
  6846         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  6847         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  6848         )
       
  6849         :
       
  6850         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  6851         iLocalInfoV3Pckg( NULL ),
       
  6852         iLocalInfoIsOngoing( EFalse )
       
  6853     {
       
  6854     OstTrace0( TRACE_NORMAL, CSATNOTIFYLOCALINFO_CSATNOTIFYLOCALINFO, "CSatNotifyLocalInfo::CSatNotifyLocalInfo" );
       
  6855     TFLOGSTRING("CSatNotifyLocalInfo::CSatNotifyLocalInfo");
       
  6856     // Initialize response structure
       
  6857     iLocalInfoRspV3 = RSat::TLocalInfoRspV3();
       
  6858 
       
  6859     // Following results are also allowed for this command:
       
  6860     // (in addition to result declared in base class constructor)
       
  6861     iAllowedResults += RSat::KSuccessLimitedService
       
  6862         + RSat::KErrorRequiredValuesMissing;
       
  6863     }
       
  6864 
       
  6865 // -----------------------------------------------------------------------------
       
  6866 // CSatNotifyLocalInfo::~CSatNotifyLocalInfo
       
  6867 // Destructor
       
  6868 // -----------------------------------------------------------------------------
       
  6869 //
       
  6870 CSatNotifyLocalInfo::~CSatNotifyLocalInfo()
       
  6871     {
       
  6872     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYLOCALINFO_CSATNOTIFYLOCALINFO, "CSatNotifyLocalInfo::~CSatNotifyLocalInfo" );
       
  6873     // None
       
  6874     }
       
  6875 
       
  6876 // -----------------------------------------------------------------------------
       
  6877 // CSatNotifyLocalInfo::MessageReceived
       
  6878 // Handles a LocalInfo proactive command ISI message,
       
  6879 // and completes a pending ETel request.
       
  6880 // (other items were commented in a header).
       
  6881 // -----------------------------------------------------------------------------
       
  6882 //
       
  6883 void CSatNotifyLocalInfo::MessageReceived
       
  6884         (
       
  6885         const TIsiReceiveC& aIsiMessage // ISI message
       
  6886         )
       
  6887     {
       
  6888     OstTrace0( TRACE_NORMAL, CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived" );
       
  6889     TFLOGSTRING("CSatNotifyLocalInfo::MessageReceived");
       
  6890     // Clear additional info
       
  6891     iLocalInfoRspV3.iAdditionalInfo.Zero();
       
  6892     // Get ber tlv
       
  6893     CBerTlv berTlv;
       
  6894     berTlv.BerTlv( aIsiMessage );
       
  6895     // Get command details tlv
       
  6896     CTlv commandDetails;
       
  6897     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  6898     // Store command details tlv
       
  6899     iCommandDetails.Copy( commandDetails.Data() );
       
  6900     // Trans id
       
  6901     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  6902     switch ( iCommandDetails[KCommandQualifier] )
       
  6903         {
       
  6904         case RSat::KProvideLocalInfo:
       
  6905             {
       
  6906             TFLOGSTRING("CSatNotifyLocalInfo:: request: LOCAL INFO");
       
  6907             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::Messagereceived Request: LOCAL INFO" );
       
  6908             iLocalInfoIsOngoing = ETrue;
       
  6909 
       
  6910             // Send a net cell info request to the net server.
       
  6911             // Use same transaction id what comes with proactive
       
  6912             // command and compare that when response is received
       
  6913             iSatMessHandler->NetCellInfoGetReq( iTransId );
       
  6914 
       
  6915             break;
       
  6916             }
       
  6917         case RSat::KProvideLocalInfoImei:
       
  6918             {
       
  6919             TFLOGSTRING("CSatNotifyLocalInfo:: request: IMEI");
       
  6920             OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::Messagereceived Request: IMEI" );
       
  6921             // Check if IMEI is received
       
  6922             if ( iSatMessHandler->ImeiAvailable() )
       
  6923                 {
       
  6924                 // IMEI is received from info server
       
  6925                 iLocalInfoRspV3.iGeneralResult = RSat::KSuccess;
       
  6926                 }
       
  6927             else
       
  6928                 {
       
  6929                 // No IMEI available at the moment
       
  6930                 iLocalInfoRspV3.iGeneralResult =
       
  6931                     RSat::KMeUnableToProcessCmd;
       
  6932                 iLocalInfoRspV3.iAdditionalInfo.Append(
       
  6933                     KNoSpecificCauseCanBeGiven );
       
  6934                 }
       
  6935             break;
       
  6936             }
       
  6937         case RSat::KProvideLocalInformationNmr:
       
  6938             {
       
  6939             // Check if UTRAN Measurement Qualifier TLV is present
       
  6940             CTlv utranMeasurement;
       
  6941             if ( KErrNone == berTlv.TlvByTagValue( &utranMeasurement,
       
  6942                                         KTlvUtranMeasurementQualifierTag ) )
       
  6943                 {
       
  6944                 // ME has to be connected to GERAN if UTRAN NMR's are requested
       
  6945                 if ( KNetworkModeUtran ==
       
  6946                     iSatMessHandler->CurrentAccessTechnology() )
       
  6947                     {
       
  6948                     TFLOGSTRING("CSatNotifyLocalInfo:: request: UTRAN NMR");
       
  6949                     OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::Messagereceived UTRAN NMR" );
       
  6950 
       
  6951                     switch( utranMeasurement.GetShortInfo(
       
  6952                                 ETLV_UtranMeasurementQualifier ) )
       
  6953                         {
       
  6954                         case KIntraFrequencyMeasurements:
       
  6955                             {
       
  6956                             iLocalInfoIsOngoing = ETrue;
       
  6957                             TFLOGSTRING("CSatNotifyLocalInfo::INTRA_FREQ_NMR");
       
  6958                             OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::Messagereceived INTRA_FREQ_NMR" );
       
  6959                             iSatMessHandler->NetNeighbourCellsReq(
       
  6960                                             iSatMessaging->GetTransactionId(),
       
  6961                                             NET_SIM_INTRA_FREQ_NMR );
       
  6962                             break;
       
  6963                             }
       
  6964                         case KInterFrequencyMeasurements:
       
  6965                             {
       
  6966                             iLocalInfoIsOngoing = ETrue;
       
  6967                             TFLOGSTRING("CSatNotifyLocalInfo::INTER_FREQ_NMR");
       
  6968                             OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived INTER_FREQ_NMR" );
       
  6969                             iSatMessHandler->NetNeighbourCellsReq(
       
  6970                                             iSatMessaging->GetTransactionId(),
       
  6971                                             NET_SIM_INTER_FREQ_NMR );
       
  6972                             break;
       
  6973                             }
       
  6974                         case KInterRatMeasurements:
       
  6975                             {
       
  6976                             iLocalInfoIsOngoing = ETrue;
       
  6977                             TFLOGSTRING("CSatNotifyLocalInfo::INTER_RAT_NMR");
       
  6978                             OstTrace0( TRACE_NORMAL, DUP6_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived INTER_RAT_NMR" );
       
  6979                             iSatMessHandler->NetNeighbourCellsReq(
       
  6980                                             iSatMessaging->GetTransactionId(),
       
  6981                                             NET_SIM_INTER_RAT_NMR );
       
  6982                             break;
       
  6983                             }
       
  6984                         default:
       
  6985                             {
       
  6986                             iLocalInfoRspV3.iGeneralResult =
       
  6987                             RSat::KCmdDataNotUnderstood;
       
  6988                             TerminalResponse();
       
  6989                             break;
       
  6990                             }
       
  6991                         }
       
  6992                     }
       
  6993                 else
       
  6994                     {
       
  6995                     // ME connected to GSM, cannot serve the requested command
       
  6996                     iLocalInfoRspV3.iGeneralResult =
       
  6997                     RSat::KMeUnableToProcessCmd;
       
  6998                     iLocalInfoRspV3.iAdditionalInfo.Append( KNoService );
       
  6999                     TerminalResponse();
       
  7000                     }
       
  7001                 }
       
  7002             else
       
  7003                 {
       
  7004                 TFLOGSTRING("CSatNotifyLocalInfo:: request: NMR");
       
  7005                 OstTrace0( TRACE_NORMAL, DUP7_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived Request: NMR" );
       
  7006                 iLocalInfoIsOngoing = ETrue;
       
  7007                 // Request NET_SIM_NMR
       
  7008                 iSatMessHandler->NetNeighbourCellsReq(
       
  7009                     iSatMessaging->GetTransactionId(),
       
  7010                     NET_SIM_NMR );
       
  7011                 }
       
  7012 
       
  7013             break;
       
  7014             }
       
  7015         case RSat::KProvideLocalInfoDateTimeTimeZone:
       
  7016             {
       
  7017             TFLOGSTRING("CSatNotifyLocalInfo:: request: DATE/TIME/TIMEZONE");
       
  7018             OstTrace0( TRACE_NORMAL, DUP8_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived Request: DATE/TIME/TIMEZONE" );
       
  7019             TTime time;
       
  7020             TLocale locale;
       
  7021             TDateTime dateTime;
       
  7022             // Get Universal time
       
  7023             time.UniversalTime();
       
  7024             // Get Universal time offset ( Time zone in seconds )
       
  7025             TTimeIntervalSeconds universalTimeOffset(
       
  7026                 locale.UniversalTimeOffset() );
       
  7027             // Add locale's universal time offset to universal time
       
  7028             // to get the local time
       
  7029             time += universalTimeOffset;
       
  7030             // Converts a TTime object into a TDateTime object
       
  7031             dateTime = time.DateTime();
       
  7032             // Get and conver year
       
  7033             TUint8 temp2( TSatUtility::ConvertToSemiOctet(
       
  7034                 dateTime.Year() ) );
       
  7035             // Append year to additional info
       
  7036             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7037             // Convert month
       
  7038             // Offset from zero. So adding one.
       
  7039             temp2 = TSatUtility::ConvertToSemiOctet(
       
  7040                 dateTime.Month() + 1 );
       
  7041             // Append month value to the additional info
       
  7042             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7043             // Convert day to the semi-octec presentation
       
  7044             // The day.Offset from zero, so add one before displaying
       
  7045             // the day number.
       
  7046             temp2 = TSatUtility::ConvertToSemiOctet(
       
  7047                 dateTime.Day() + 1 );
       
  7048             // Append the day value to the additional info
       
  7049             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7050             // Conver current time to the semi-octec presentation.
       
  7051             // First hour
       
  7052             temp2 = TSatUtility::ConvertToSemiOctet(
       
  7053                 dateTime.Hour() );
       
  7054             // Append the hour value to the additional info
       
  7055             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7056             // Minute value
       
  7057             temp2 = TSatUtility::ConvertToSemiOctet(
       
  7058                 dateTime.Minute() );
       
  7059             // Append the minute value to the additional info
       
  7060             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7061             // Seconds
       
  7062             temp2 = TSatUtility::ConvertToSemiOctet(
       
  7063                 dateTime.Second() );
       
  7064             // Append the seconds value to the additional info
       
  7065             iLocalInfoRspV3.iAdditionalInfo.Append( temp2 );
       
  7066             // Append time zone
       
  7067             // received from NET_TIME_IND isi-message
       
  7068             iLocalInfoRspV3.iAdditionalInfo.Append(
       
  7069                 iSatMessHandler->TimeZone() );
       
  7070             // Set generall result as Success
       
  7071             iLocalInfoRspV3.iGeneralResult = RSat::KSuccess;
       
  7072             break;
       
  7073             }
       
  7074         case RSat::KProvideLocalInfoLanguage:
       
  7075             {
       
  7076             TFLOGSTRING("CSatNotifyLocalInfo:: request: Language");
       
  7077             OstTrace0( TRACE_NORMAL, DUP9_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived Request: Language" );
       
  7078             if( !iReqHandle )
       
  7079                 {
       
  7080                 TFLOGSTRING("CSatNotifyLocalInfo:: No reqHandle");
       
  7081                 OstTrace0( TRACE_NORMAL, DUP10_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived No reqHandle" );
       
  7082 
       
  7083                 iLocalInfoRspV3.iGeneralResult = RSat::KMeUnableToProcessCmd;
       
  7084                 iLocalInfoRspV3.iAdditionalInfo.Append( RSat::KNoSpecificMeProblem );
       
  7085                 TerminalResponse();
       
  7086                 }
       
  7087             else
       
  7088                 {
       
  7089                 TFLOGSTRING("CSatNotifyLocalInfo:: reqHandle");
       
  7090                 OstTrace0( TRACE_NORMAL, DUP11_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived reqHandle" );
       
  7091                 // Fill the send sm structure
       
  7092                 RSat::TLocalInfoV3& localInfoV3 = ( *iLocalInfoV3Pckg )();
       
  7093                 // Get command details tlv
       
  7094                 CTlv deviceIdentities;
       
  7095                 berTlv.TlvByTagValue( &deviceIdentities, KTlvDeviceIdentityTag );
       
  7096                 localInfoV3.iDevideId = ( RSat::TDeviceId )
       
  7097                     deviceIdentities.GetShortInfo( ETLV_SourceDeviceIdentity );
       
  7098                 localInfoV3.iInfoType =
       
  7099                    ( RSat::TLocaInfomationType) iCommandDetails[KCommandQualifier];
       
  7100                 localInfoV3.SetPCmdNumber(
       
  7101                     commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  7102                 CompleteRequest( KErrNone );
       
  7103                 }
       
  7104             break;
       
  7105             }
       
  7106         case RSat::KProvideLocalInfoTimingAdv:
       
  7107             {
       
  7108             TFLOGSTRING("CSatNotifyLocalInfo:: request: TimingAdvance");
       
  7109             OstTrace0( TRACE_NORMAL, DUP12_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived Request: TimingAdvance" );
       
  7110             iLocalInfoIsOngoing = ETrue;
       
  7111             //request GSS_CS_SERVICE_REQ
       
  7112             iSatMessHandler->GssCsServiceReq(
       
  7113                              iSatMessaging->GetTransactionId(),
       
  7114                              GSS_ATK_TIMING_ADVANCE_GET );
       
  7115             break;
       
  7116             }
       
  7117         case RSat::KProvideLocalInfoAccTech:
       
  7118             {
       
  7119             TFLOGSTRING("CSatNotifyLocalInfo:: request: Access Technology");
       
  7120             OstTrace0( TRACE_NORMAL, DUP13_CSATNOTIFYLOCALINFO_MESSAGERECEIVED, "CSatNotifyLocalInfo::MessageReceived Request: Access Technology" );
       
  7121             iLocalInfoIsOngoing = ETrue;
       
  7122             //request NET_RAT_REQ
       
  7123             iSatMessHandler->NetRatReq( iSatMessaging->GetTransactionId() );
       
  7124             break;
       
  7125             }
       
  7126         // Currently not supported:
       
  7127         case RSat::KProvideLocalInfoESN:
       
  7128             {
       
  7129             iLocalInfoRspV3.iGeneralResult =
       
  7130                 RSat::KCmdBeyondMeCapabilities;
       
  7131             break;
       
  7132             }
       
  7133         default:
       
  7134             {
       
  7135             iLocalInfoRspV3.iGeneralResult = RSat::KCmdTypeNotUnderstood;
       
  7136             }
       
  7137         }
       
  7138     if ( RSat::KProvideLocalInformationNmr !=
       
  7139             iCommandDetails[KCommandQualifier]
       
  7140         && RSat::KProvideLocalInfo != iCommandDetails[KCommandQualifier]
       
  7141         && RSat::KProvideLocalInfoTimingAdv != iCommandDetails[KCommandQualifier]
       
  7142         && RSat::KProvideLocalInfoLanguage != iCommandDetails[KCommandQualifier]
       
  7143         && RSat::KProvideLocalInfoAccTech != iCommandDetails[KCommandQualifier] )
       
  7144         {
       
  7145         // Send terminal response to the sim
       
  7146         TerminalResponse();
       
  7147         }
       
  7148     }
       
  7149 
       
  7150 // -----------------------------------------------------------------------------
       
  7151 // CSatNotifyLocalInfo::Notify
       
  7152 // An ETel SAT client can call this method via ETel server to set a pending
       
  7153 // request in SimAtkTsy for a LocalInfo PCmd.
       
  7154 // (other items were commented in a header).
       
  7155 // -----------------------------------------------------------------------------
       
  7156 //
       
  7157 void CSatNotifyLocalInfo::Notify
       
  7158         (
       
  7159         const TTsyReqHandle aReqHandle, // Request handle
       
  7160         TDes8*              aDataPtr    // Pointer to data
       
  7161         )
       
  7162     {
       
  7163     OstTrace1( TRACE_NORMAL, CSATNOTIFYLOCALINFO_NOTIFY, "CSatNotifyLocalInfo::Notify Handle: %u", aReqHandle );
       
  7164     TFLOGSTRING2("CSatNotifyLocalInfo::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  7165                aReqHandle );
       
  7166     iReqHandle = aReqHandle;
       
  7167     iLocalInfoV3Pckg = static_cast< RSat::TLocalInfoV3Pckg* >( aDataPtr );
       
  7168     iSatMessaging->SatReady( KProvideLocalInformation );
       
  7169     }
       
  7170 
       
  7171 // -----------------------------------------------------------------------------
       
  7172 // CSatNotifyLocalInfo::TerminalResponse
       
  7173 // Handles a LocalInfo terminal response provided by an ETel SAT client via
       
  7174 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  7175 // (other items were commented in a header).
       
  7176 // -----------------------------------------------------------------------------
       
  7177 //
       
  7178 TInt CSatNotifyLocalInfo::TerminalResponse
       
  7179         (
       
  7180         TDes8* aRsp     // Response
       
  7181         )
       
  7182     {
       
  7183     OstTrace0( TRACE_NORMAL, CSATNOTIFYLOCALINFO_TERMINALRESPONSE, "CSatNotifyLocalInfo::TerminalResponse" );
       
  7184     TFLOGSTRING("CSatNotifyLocalInfo::TerminalResponse");
       
  7185     TInt ret( KErrNone );
       
  7186     if ( aRsp )
       
  7187         {
       
  7188         RSat::TLocalInfoRspV3Pckg* aRspPckg =
       
  7189                 reinterpret_cast< RSat::TLocalInfoRspV3Pckg* >( aRsp );
       
  7190         RSat::TLocalInfoRspV3& rspV1 = ( *aRspPckg ) ();
       
  7191         // Check that general result value is valid.
       
  7192         if ( iAllowedResults != rspV1.iGeneralResult )
       
  7193             {
       
  7194             // Invalid general result
       
  7195             ret = KErrCorrupt;
       
  7196             }
       
  7197         iLocalInfoRspV3.iGeneralResult = rspV1.iGeneralResult;
       
  7198         // If there is Me (Mobile Entity) error, additional info is needed
       
  7199         if ( RSat::KMeProblem == rspV1.iInfoType &&
       
  7200              NULL == rspV1.iAdditionalInfo.Length() )
       
  7201             {
       
  7202             // Invalid additional info field
       
  7203             ret = KErrCorrupt;
       
  7204             }
       
  7205         iLocalInfoRspV3.iAdditionalInfo = rspV1.iAdditionalInfo;
       
  7206         }
       
  7207     iSatMessHandler->LocalInfoTerminalResp(
       
  7208         iTransId,                            // Transaction id
       
  7209         iCommandDetails,                     // Command details tlv
       
  7210         TUint8( iLocalInfoRspV3.iGeneralResult ),  // Result
       
  7211         iLocalInfoRspV3.iAdditionalInfo );   // Additional info
       
  7212     return ret;
       
  7213     }
       
  7214 
       
  7215 // -----------------------------------------------------------------------------
       
  7216 // CSatNotifyLocalInfo::Status
       
  7217 // Method to check and set local info status. This is used when
       
  7218 // SIM request NMR or Local Info.
       
  7219 // (other items were commented in a header).
       
  7220 // -----------------------------------------------------------------------------
       
  7221 //
       
  7222 TBool CSatNotifyLocalInfo::Status
       
  7223         (
       
  7224         TBool aClearStatus
       
  7225         )
       
  7226     {
       
  7227     OstTrace0( TRACE_NORMAL, CSATNOTIFYLOCALINFO_STATUS, "CSatNotifyLocalInfo::Status" );
       
  7228     TFLOGSTRING("CSatNotifyLocalInfo::Status");
       
  7229     if ( aClearStatus )
       
  7230         {
       
  7231         iLocalInfoIsOngoing = EFalse;
       
  7232         }
       
  7233     return iLocalInfoIsOngoing;
       
  7234     }
       
  7235 
       
  7236 
       
  7237 // -----------------------------------------------------------------------------
       
  7238 // CSatNotifyTimerMgmt::CSatNotifyTimerMgmt
       
  7239 // C++ default constructor can NOT contain any code, that
       
  7240 // might leave.
       
  7241 // -----------------------------------------------------------------------------
       
  7242 //
       
  7243 CSatNotifyTimerMgmt::CSatNotifyTimerMgmt
       
  7244         (
       
  7245         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  7246         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  7247         )
       
  7248         :
       
  7249         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  7250         iCmdQualifier( KZero )
       
  7251     {
       
  7252     OstTrace0( TRACE_NORMAL, CSATNOTIFYTIMERMGMT_CSATNOTIFYTIMERMGMT, "CSatNotifyTimerMgmt::CSatNotifyTimerMgmt" );
       
  7253     // Following results are also allowed for this command:
       
  7254     // (in addition to result declared in base class constructor)
       
  7255     iAllowedResults += RSat::KContradictionWithTimerState
       
  7256         + RSat::KErrorRequiredValuesMissing;
       
  7257     }
       
  7258 
       
  7259 // -----------------------------------------------------------------------------
       
  7260 // CSatNotifyTimerMgmt::~CSatNotifyTimerMgmt
       
  7261 // Destructor
       
  7262 // -----------------------------------------------------------------------------
       
  7263 //
       
  7264 CSatNotifyTimerMgmt::~CSatNotifyTimerMgmt()
       
  7265     {
       
  7266     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYTIMERMGMT_CSATNOTIFYTIMERMGMT, "CSatNotifyTimerMgmt::~CSatNotifyTimerMgmt" );
       
  7267     // None
       
  7268     }
       
  7269 
       
  7270 // -----------------------------------------------------------------------------
       
  7271 // CSatNotifyTimerMgmt::MessageReceived
       
  7272 // Handles a TimerMgmt proactive command ISI message,
       
  7273 // and completes a pending ETel request.
       
  7274 // (other items were commented in a header).
       
  7275 // -----------------------------------------------------------------------------
       
  7276 //
       
  7277 void CSatNotifyTimerMgmt::MessageReceived
       
  7278         (
       
  7279         const TIsiReceiveC& aIsiMessage // ISI message
       
  7280         )
       
  7281     {
       
  7282     OstTrace0( TRACE_NORMAL, CSATNOTIFYTIMERMGMT_MESSAGERECEIVED, "CSatNotifyTimerMgmt::MessageReceived" );
       
  7283     TFLOGSTRING("CSatNotifyTimerMgmt::MessageReceived");
       
  7284     TInt ret( KErrNone );
       
  7285     TInt returnValue( KErrNone );
       
  7286     TUint8 generalResult ( RSat::KSuccess );
       
  7287     //get ber tlv
       
  7288     CBerTlv berTlv;
       
  7289     returnValue = berTlv.BerTlv( aIsiMessage );
       
  7290     //get command details tlv
       
  7291     CTlv commandDetails;
       
  7292     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  7293     iCommandDetails.Copy( commandDetails.Data() );
       
  7294     // Get command qualifier
       
  7295     TUint8 cmdQualifier(
       
  7296         commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  7297     // get timer id tlv
       
  7298     CTlv timerId;
       
  7299     returnValue = berTlv.TlvByTagValue( &timerId,
       
  7300                            KTlvTimerIdentifierTag );
       
  7301     // initalize
       
  7302     TUint8 timerIdentifier( 0 );
       
  7303     TUint8 time[3] = {0, 0, 0};
       
  7304     if ( KErrNone == returnValue )
       
  7305         {
       
  7306         timerIdentifier = timerId.GetShortInfo( ETLV_TimerIdentifier );
       
  7307         // The Timer Identifier can take 8 different values
       
  7308         if ( ( RSat::KTimer8 < timerIdentifier  )
       
  7309              || ( RSat::KTimer1 > timerIdentifier ) )
       
  7310             {
       
  7311             generalResult = RSat::KCmdDataNotUnderstood;
       
  7312             }
       
  7313         else
       
  7314             {
       
  7315             // if operation type is startTimer = 0x00
       
  7316             if ( !cmdQualifier )
       
  7317                 {
       
  7318                  //get timer value tlv
       
  7319                 CTlv timerValue;
       
  7320                 returnValue = berTlv.TlvByTagValue( &timerValue,
       
  7321                                                 KTlvTimerValueTag );
       
  7322                 if ( KErrNotFound != returnValue)
       
  7323                     {
       
  7324                     TPtrC8 temp;
       
  7325                     TUint32 timeValue( 0 );
       
  7326                     // value of a timer, expressed using
       
  7327                     // the format hour, minute, second
       
  7328                     // Semi-octec presentation used (23.040)
       
  7329                     temp.Set( timerValue.GetData( ETLV_TimerValue ) );
       
  7330                     //convert to seconds
       
  7331                     timeValue = ConvertToSeconds( temp );
       
  7332                     // The possible duration of a timer is
       
  7333                     // between 1 second and 24 hours
       
  7334                     if ( KMinTimerValue < timeValue &&
       
  7335                          KMaxTimerValueInSeconds >= timeValue )
       
  7336                         {
       
  7337                         ret = iSatMessaging->GetSatTimer()->
       
  7338                                    StartTimer( timerIdentifier, timeValue );
       
  7339                         if ( KErrNone != ret )
       
  7340                             {
       
  7341                             generalResult = RSat::KMeUnableToProcessCmd;
       
  7342                             }
       
  7343                         }
       
  7344                     else
       
  7345                         {
       
  7346                         generalResult = RSat::KCmdDataNotUnderstood;
       
  7347                         }
       
  7348                     }
       
  7349                 else
       
  7350                     {
       
  7351                     generalResult = RSat::KErrorRequiredValuesMissing;
       
  7352                     }
       
  7353                 }
       
  7354             // if operation type is KDeactivateTimer or KGetTimerValue
       
  7355             else if ( KDeactivateTimer == cmdQualifier ||
       
  7356                       KGetTimerValue == cmdQualifier )
       
  7357                 {
       
  7358                 TInt retValue( KErrNone );
       
  7359                 //get current value of the timer
       
  7360                 ret = iSatMessaging->GetSatTimer()->
       
  7361                           GetCurrentValueOfTimerById( timerIdentifier );
       
  7362                 if ( KDeactivateTimer == cmdQualifier && KErrNotFound != ret )
       
  7363                     {
       
  7364                     //deactivate timer
       
  7365                     retValue = iSatMessaging->GetSatTimer()->
       
  7366                                       DeleteTimerById( timerIdentifier );
       
  7367                     }
       
  7368                 //if timer is found convert timer value to semi-octets
       
  7369                 if ( KErrNotFound != ret && KErrNotFound != retValue )
       
  7370                     {
       
  7371                     generalResult = RSat::KSuccess;
       
  7372                     TInt num[3];
       
  7373                     num[0] = ret/3600;         //hours
       
  7374                     num[1] = ( ret%3600 )/60;  //minutes
       
  7375                     num[2] = ( ret%3600 )%60;  //seconds
       
  7376                     TInt i( 0 );
       
  7377                     for ( i = 0; i < 3; i++ )
       
  7378                         {
       
  7379                         //convert to semi-octet
       
  7380                         time[i] = TSatUtility::ConvertToSemiOctet( num[i] );
       
  7381                         }
       
  7382                     }
       
  7383                 else
       
  7384                     {
       
  7385                     generalResult = RSat::KContradictionWithTimerState;
       
  7386                     }
       
  7387                 }
       
  7388             else
       
  7389                 {
       
  7390                 generalResult = RSat::KCmdTypeNotUnderstood;
       
  7391                 }
       
  7392             }
       
  7393         }
       
  7394     else
       
  7395         {
       
  7396         generalResult = RSat::KErrorRequiredValuesMissing;
       
  7397         }
       
  7398     iSatMessHandler->TimerMgmtTerminalResp( aIsiMessage.Get8bit(
       
  7399         ISI_HEADER_OFFSET_TRANSID ), iCommandDetails, generalResult,
       
  7400         time, timerIdentifier, KNoCause );
       
  7401     }
       
  7402 
       
  7403 // -----------------------------------------------------------------------------
       
  7404 // CSatNotifyTimerMgmt::Notify
       
  7405 // An ETel SAT client can call this method via ETel server to set a pending
       
  7406 // request in SimAtkTsy for a TimerManagement PCmd.
       
  7407 // (other items were commented in a header).
       
  7408 // -----------------------------------------------------------------------------
       
  7409 //
       
  7410 void CSatNotifyTimerMgmt::Notify
       
  7411         (
       
  7412         const TTsyReqHandle /*aReqHandle*/, // Request handle
       
  7413         TDes8*              /*aDataPtr*/    // Pointer to data
       
  7414         )
       
  7415     {
       
  7416     OstTrace0( TRACE_NORMAL, CSATNOTIFYTIMERMGMT_NOTIFY, "CSatNotifyTimerMgmt::Notify" );
       
  7417     // TimerManagement is completely implemented by SimAtkTsy. Client
       
  7418     // insn't notified about the command.
       
  7419     }
       
  7420 
       
  7421 // -----------------------------------------------------------------------------
       
  7422 // CSatNotifyTimerMgmt::ConvertToSeconds
       
  7423 // Converts to seconds semi-octet presented value of timer,
       
  7424 // expressed using the format hour, minute, second
       
  7425 // (other items were commented in a header).
       
  7426 // -----------------------------------------------------------------------------
       
  7427 //
       
  7428 TUint32 CSatNotifyTimerMgmt::ConvertToSeconds
       
  7429          (
       
  7430          TPtrC8 time
       
  7431          )
       
  7432     {
       
  7433     OstTrace0( TRACE_NORMAL, CSATNOTIFYTIMERMGMT_CONVERTTOSECONDS, "CSatNotifyTimerMgmt::ConvertToSeconds" );
       
  7434     TFLOGSTRING("CSatNotifyTimerMgmt::ConvertToSeconds");
       
  7435      TUint32 timeValue( 0 );
       
  7436     // value of a timer, expressed using
       
  7437     // the format hour, minute, second
       
  7438     // Semi-octec presentation used (23.040)
       
  7439     // time[0] is hours
       
  7440     // time[1] is minutes
       
  7441     // time[2] is seconds
       
  7442      TInt i( 0 );
       
  7443     for ( i = 0; i < 3; i++ )
       
  7444         {
       
  7445         TUint value = ( time[i] & 0x0F )*10 + ( ( time[i] & 0xF0 ) >> 4 );
       
  7446         timeValue = timeValue * 60 + value;
       
  7447         }
       
  7448     return timeValue;
       
  7449 
       
  7450     }
       
  7451 
       
  7452 
       
  7453 // -----------------------------------------------------------------------------
       
  7454 // CSatNotifyMoreTime::CSatNotifyMoreTime
       
  7455 // C++ default constructor can NOT contain any code, that
       
  7456 // might leave.
       
  7457 // -----------------------------------------------------------------------------
       
  7458 //
       
  7459 CSatNotifyMoreTime::CSatNotifyMoreTime
       
  7460         (
       
  7461         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  7462         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  7463         )
       
  7464         :
       
  7465         CSatNotificationsBase( aSatMessHandler, aSatMessaging )
       
  7466     {
       
  7467     OstTrace0( TRACE_NORMAL, CSATNOTIFYMORETIME_CSATNOTIFYMORETIME, "CSatNotifyMoreTime::CSatNotifyMoreTime" );
       
  7468     // Following results are also allowed for this command:
       
  7469     // (in addition to result declared in base class constructor)
       
  7470     iAllowedResults += RSat::KErrorRequiredValuesMissing;
       
  7471     }
       
  7472 
       
  7473 // -----------------------------------------------------------------------------
       
  7474 // CSatNotifyMoreTime::~CSatNotifyMoreTime
       
  7475 // Destructor
       
  7476 // -----------------------------------------------------------------------------
       
  7477 //
       
  7478 CSatNotifyMoreTime::~CSatNotifyMoreTime()
       
  7479     {
       
  7480     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYMORETIME_CSATNOTIFYMORETIME, "CSatNotifyMoreTime::~CSatNotifyMoreTime" );
       
  7481     // None
       
  7482     }
       
  7483 
       
  7484 // -----------------------------------------------------------------------------
       
  7485 // CSatNotifyMoreTime::MessageReceived
       
  7486 // Handles a MoreTime proactive command ISI message,
       
  7487 // Etel SAT request not required.
       
  7488 // (other items were commented in a header).
       
  7489 // -----------------------------------------------------------------------------
       
  7490 //
       
  7491 void CSatNotifyMoreTime::MessageReceived
       
  7492         (
       
  7493         const TIsiReceiveC& aIsiMessage // ISI message
       
  7494         )
       
  7495     {
       
  7496     OstTrace0( TRACE_NORMAL, CSATNOTIFYMORETIME_MESSAGERECEIVED, "CSatNotifyMoreTime::MessageReceived" );
       
  7497     TFLOGSTRING("CSatNotifyMoreTime::MessageReceived");
       
  7498     //get ber tlv
       
  7499     CBerTlv berTlv;
       
  7500     berTlv.BerTlv( aIsiMessage );
       
  7501     //get command details tlv
       
  7502     CTlv commandDetails;
       
  7503     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  7504     iCommandDetails.Copy( commandDetails.Data() );
       
  7505     iSatMessHandler->MoreTimeTerminalResp(
       
  7506                         aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID ),
       
  7507                         iCommandDetails,
       
  7508                         RSat::KSuccess );
       
  7509     }
       
  7510 
       
  7511 // -----------------------------------------------------------------------------
       
  7512 // CSatNotifyMoreTime::Notify
       
  7513 // An ETel SAT client can call this method via ETel server to set a pending
       
  7514 // request in SimAtkTsy for a MoreTime PCmd.
       
  7515 // (other items were commented in a header).
       
  7516 // -----------------------------------------------------------------------------
       
  7517 //
       
  7518 void CSatNotifyMoreTime::Notify
       
  7519         (
       
  7520         const TTsyReqHandle /*aReqHandle*/, // Request handle
       
  7521         TDes8*              /*aDataPtr*/    // Pointer to data
       
  7522         )
       
  7523     {
       
  7524     OstTrace0( TRACE_NORMAL, CSATNOTIFYMORETIME_NOTIFY, "CSatNotifyMoreTime::Notify" );
       
  7525     // MoreTime is completely implemented by SimAtkTsy. Client
       
  7526     // insn't notified about the command.
       
  7527     }
       
  7528 
       
  7529 
       
  7530 // -----------------------------------------------------------------------------
       
  7531 // CSatNotifyLanguageNotification::CSatNotifyLanguageNotification
       
  7532 // C++ default constructor can NOT contain any code, that
       
  7533 // might leave.
       
  7534 // -----------------------------------------------------------------------------
       
  7535 //
       
  7536 CSatNotifyLanguageNotification::CSatNotifyLanguageNotification
       
  7537         (
       
  7538         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  7539         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  7540         )
       
  7541         :
       
  7542         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  7543         iLanguageNotificationV2Pckg( NULL )
       
  7544     {
       
  7545     OstTrace0( TRACE_NORMAL, CSATNOTIFYLANGUAGENOTIFICATION_CSATNOTIFYLANGUAGENOTIFICATION, "CSatNotifyLanguageNotification::CSatNotifyLanguageNotification" );
       
  7546     // Following results are also allowed for this command:
       
  7547     // (in addition to result declared in base class constructor)
       
  7548     iAllowedResults += RSat::KErrorRequiredValuesMissing;
       
  7549     }
       
  7550 
       
  7551 // -----------------------------------------------------------------------------
       
  7552 // CSatNotifyLanguageNotification::~CSatNotifyLanguageNotification
       
  7553 // Destructor
       
  7554 // -----------------------------------------------------------------------------
       
  7555 //
       
  7556 CSatNotifyLanguageNotification::~CSatNotifyLanguageNotification()
       
  7557     {
       
  7558     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYLANGUAGENOTIFICATION_CSATNOTIFYLANGUAGENOTIFICATION, "CSatNotifyLanguageNotification::~CSatNotifyLanguageNotification" );
       
  7559     // None
       
  7560     }
       
  7561 
       
  7562 // -----------------------------------------------------------------------------
       
  7563 // CSatNotifyLanguageNotification::MessageReceived
       
  7564 // Handles a LanguageNotification proactive command ISI message,
       
  7565 // and completes a pending ETel request.
       
  7566 // (other items were commented in a header).
       
  7567 // -----------------------------------------------------------------------------
       
  7568 //
       
  7569 void CSatNotifyLanguageNotification::MessageReceived
       
  7570         (
       
  7571         const TIsiReceiveC& aIsiMessage // ISI message
       
  7572         )
       
  7573     {
       
  7574     OstTrace0( TRACE_NORMAL, CSATNOTIFYLANGUAGENOTIFICATION_MESSAGERECEIVED, "CSatNotifyLanguageNotification::MessageReceived" );
       
  7575     TFLOGSTRING("TSY: CSatNotifyLanguageNotification::MessageReceived");
       
  7576     TInt ret( KErrNone );
       
  7577     TInt returnValue( KErrNone );
       
  7578     // Get ber tlv
       
  7579     CBerTlv berTlv;
       
  7580     returnValue = berTlv.BerTlv( aIsiMessage );
       
  7581     // Get command details tlv
       
  7582     CTlv commandDetails;
       
  7583     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  7584     iCommandDetails.Copy( commandDetails.Data() );
       
  7585     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  7586     if( !iReqHandle )
       
  7587         {
       
  7588         iSatMessHandler->LanguageNotificationTerminalResp(
       
  7589                             iTransId,
       
  7590                             iCommandDetails,
       
  7591                             RSat::KMeUnableToProcessCmd,
       
  7592                             KNoCause ); // KNoCause: 0
       
  7593         }
       
  7594     else
       
  7595         {
       
  7596 
       
  7597         RSat::TLanguageNotificationV2& languageNotificationV2 =
       
  7598                                     ( *iLanguageNotificationV2Pckg )();
       
  7599         // Command number
       
  7600         languageNotificationV2.SetPCmdNumber(
       
  7601             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  7602         // Initialisate
       
  7603         languageNotificationV2.iNotificationType = RSat::ENotificationTypeNotSet;
       
  7604         // Get command qualifier
       
  7605         TUint8 cmdQualifier(
       
  7606             commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  7607         if ( !cmdQualifier )
       
  7608            {
       
  7609             // No specific language used
       
  7610             languageNotificationV2.iNotificationType =
       
  7611                 RSat::ENonSpecificLangNotification;
       
  7612             }
       
  7613         else if ( KSpecificLanguage == cmdQualifier )
       
  7614             {
       
  7615             // Currently used language
       
  7616             languageNotificationV2.iNotificationType =
       
  7617                 RSat::ESpecificLangNotification;
       
  7618             }
       
  7619         else
       
  7620             {
       
  7621             TFLOGSTRING("TSY: \
       
  7622             CSatNotifyLanguageNotification::MessageReceived, \
       
  7623             Command qualifier did not match.");
       
  7624             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYLANGUAGENOTIFICATION_MESSAGERECEIVED, "CSatNotifyLanguageNotification::MessageReceived, Command qualifier did not match." );
       
  7625             }
       
  7626         CTlv language;
       
  7627         returnValue = berTlv.TlvByTagValue( &language,
       
  7628             KTlvLanguageTag );
       
  7629         // If the Language tag is found
       
  7630         if ( KErrNone == returnValue )
       
  7631             {
       
  7632             languageNotificationV2.iLanguage = language.GetLongInfo( ETLV_Language );
       
  7633             }
       
  7634         CompleteRequest( ret );
       
  7635         }
       
  7636     }
       
  7637 
       
  7638 // -----------------------------------------------------------------------------
       
  7639 // CSatNotifyLanguageNotification::Notify
       
  7640 // An ETel SAT client can call this method via ETel server to set a pending
       
  7641 // request in SimAtkTsy for a LanguageNotification PCmd.
       
  7642 // (other items were commented in a header).
       
  7643 // -----------------------------------------------------------------------------
       
  7644 //
       
  7645 void CSatNotifyLanguageNotification::Notify
       
  7646         (
       
  7647         const TTsyReqHandle aReqHandle, // Request handle
       
  7648         TDes8*              aDataPtr    // Pointer to data
       
  7649         )
       
  7650     {
       
  7651     OstTrace0( TRACE_NORMAL, CSATNOTIFYLANGUAGENOTIFICATION_NOTIFY, "CSatNotifyLanguageNotification::Notify" );
       
  7652     TFLOGSTRING("CSatNotifyLanguageNotification::Notify");
       
  7653     iReqHandle = aReqHandle;
       
  7654     iLanguageNotificationV2Pckg =
       
  7655         static_cast< RSat::TLanguageNotificationV2Pckg* >( aDataPtr );
       
  7656     iSatMessaging->SatReady( KLanguageNotification );
       
  7657     }
       
  7658 
       
  7659 // -----------------------------------------------------------------------------
       
  7660 // CSatNotifyLanguageNotification::TerminalResponse
       
  7661 // Handles a LanguageNotification terminal response provided by an ETel SAT
       
  7662 // client via
       
  7663 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  7664 // (other items were commented in a header).
       
  7665 // -----------------------------------------------------------------------------
       
  7666 //
       
  7667 TInt CSatNotifyLanguageNotification::TerminalResponse
       
  7668         (
       
  7669         TDes8* aRsp // Response
       
  7670         )
       
  7671     {
       
  7672     OstTrace0( TRACE_NORMAL, CSATNOTIFYLANGUAGENOTIFICATION_TERMINALRESPONSE, "CSatNotifyLanguageNotification::TerminalResponse" );
       
  7673     TFLOGSTRING("CSatNotifyLanguageNotification::TerminalResponse");
       
  7674     TUint8 additionalInfo( 0 );
       
  7675     RSat::TLanguageNotificationRspV2Pckg* aRspPckg =
       
  7676             reinterpret_cast< RSat::TLanguageNotificationRspV2Pckg* >( aRsp );
       
  7677     RSat::TLanguageNotificationRspV2& rspV1 = ( *aRspPckg ) ();
       
  7678     iSatMessHandler->LanguageNotificationTerminalResp(
       
  7679                             iTransId,
       
  7680                             iCommandDetails,
       
  7681                             rspV1.iGeneralResult,
       
  7682                             additionalInfo );
       
  7683 
       
  7684     return iAllowedResults == rspV1.iGeneralResult ? KErrNone : KErrCorrupt;
       
  7685     }
       
  7686 
       
  7687 
       
  7688 // -----------------------------------------------------------------------------
       
  7689 // CSatNotifyOpenChannel::CSatNotifyOpenChannel
       
  7690 // C++ default constructor can NOT contain any code, that
       
  7691 // might leave.
       
  7692 // -----------------------------------------------------------------------------
       
  7693 //
       
  7694 CSatNotifyOpenChannel::CSatNotifyOpenChannel
       
  7695         (
       
  7696         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  7697         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  7698         )
       
  7699         :
       
  7700         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  7701         iOpenBaseChannelV2Pckg( NULL ),
       
  7702         iOpenCsChannelV2Pckg( NULL ),
       
  7703         iOpenGprsChannelV4Pckg( NULL ),
       
  7704         iOpenLocalLinksChannelV2Pckg( NULL )
       
  7705     {
       
  7706     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_CSATNOTIFYOPENCHANNEL, "CSatNotifyOpenChannel::CSatNotifyOpenChannel" );
       
  7707     // Following results are also allowed for this command:
       
  7708     // (in addition to result declared in base class constructor)
       
  7709     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  7710         + RSat::KPerformedWithModifications+ RSat::KPSessionTerminatedByUser
       
  7711         + RSat::KNetworkUnableToProcessCmd + RSat::KPCmdNotAcceptedByUser
       
  7712         + RSat::KInteractionWithCCTemporaryError
       
  7713         + RSat::KErrorRequiredValuesMissing + RSat::KBearerIndepProtocolError
       
  7714         + RSat::KAccessTechUnableProcessCmd;
       
  7715     }
       
  7716 
       
  7717 // -----------------------------------------------------------------------------
       
  7718 // CSatNotifyOpenChannel::~CSatNotifyOpenChannel
       
  7719 // Destructor
       
  7720 // -----------------------------------------------------------------------------
       
  7721 //
       
  7722 CSatNotifyOpenChannel::~CSatNotifyOpenChannel()
       
  7723     {
       
  7724     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYOPENCHANNEL_CSATNOTIFYOPENCHANNEL, "CSatNotifyOpenChannel::~CSatNotifyOpenChannel" );
       
  7725     // None
       
  7726     }
       
  7727 
       
  7728 // -----------------------------------------------------------------------------
       
  7729 // CSatNotifyOpenChannel::MessageReceived
       
  7730 // Handles a OpenChannel proactive command ISI message,
       
  7731 // and completes a pending ETel request.
       
  7732 // (other items were commented in a header).
       
  7733 // -----------------------------------------------------------------------------
       
  7734 //
       
  7735 void CSatNotifyOpenChannel::MessageReceived
       
  7736         (
       
  7737         const TIsiReceiveC& aIsiMessage // ISI message
       
  7738         )
       
  7739     {
       
  7740     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived" );
       
  7741     TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived");
       
  7742     TInt ret( KErrNone );
       
  7743     // Get ber tlv
       
  7744     CBerTlv berTlv;
       
  7745     berTlv.BerTlv( aIsiMessage );
       
  7746     // Get command details tlv
       
  7747     CTlv commandDetails;
       
  7748     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  7749     iCommandDetails.Copy( commandDetails.Data() );
       
  7750     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  7751     if ( !iReqHandle )
       
  7752         {
       
  7753         TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - Request Off");
       
  7754         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Request Off" );
       
  7755         // Request not on, returning response immediately
       
  7756         TBuf8<1> noBearer( 0 );
       
  7757         TBuf8<1> noAdditionalInfo( 0 );
       
  7758         TUint16 noBufferSize( 0 );
       
  7759         iSatMessHandler->OpenChannelTerminalResp(
       
  7760              iTransId,
       
  7761              iCommandDetails,
       
  7762              RSat::KMeUnableToProcessCmd,
       
  7763              noAdditionalInfo,
       
  7764              TUint8( RSat::EBearerTypeNotSet ),
       
  7765              noBearer,
       
  7766              noBufferSize );
       
  7767         ret = KErrCorrupt;
       
  7768         }
       
  7769     else
       
  7770         {
       
  7771         RSat::TOpenChannelBaseV2& openChannelV2
       
  7772             = ( *iOpenBaseChannelV2Pckg ) ();
       
  7773 
       
  7774         // Bearer Description & Buffer Size ( Mandatory )
       
  7775         CTlv bearerDescriptionTlv;
       
  7776         CTlv bufferSizeTlv;
       
  7777 
       
  7778         if ( KErrNone == berTlv.TlvByTagValue( &bearerDescriptionTlv,
       
  7779              KTlvBearerDescriptionTag )
       
  7780             && KErrNone == berTlv.TlvByTagValue( &bufferSizeTlv,
       
  7781              KTlvBufferSizeTag ) )
       
  7782             {
       
  7783             // Command details
       
  7784             openChannelV2.SetPCmdNumber(
       
  7785                 commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  7786 
       
  7787             // Link Establishment, obtained
       
  7788             // from Command details Bit 1
       
  7789             // Get command qualifier
       
  7790             TUint8 cmdQualifier( commandDetails.GetShortInfo(
       
  7791                 ETLV_CommandQualifier ) );
       
  7792             if ( KLinkEstablishmentMask & cmdQualifier )
       
  7793                 {
       
  7794                 openChannelV2.iLinkEst = RSat::EImmediate;
       
  7795                 }
       
  7796             else
       
  7797                 {
       
  7798                 openChannelV2.iLinkEst = RSat::EOnDemand;
       
  7799                 }
       
  7800 
       
  7801             // Reconnection mode, obtained from Command
       
  7802             // details Bit 2
       
  7803             if ( KReconnectionModeMask & cmdQualifier )
       
  7804                 {
       
  7805                 openChannelV2.iReconnectionMode =
       
  7806                     RSat::EAutomaticReconnection;
       
  7807                 }
       
  7808             else
       
  7809                 {
       
  7810                 openChannelV2.iReconnectionMode =
       
  7811                     RSat::ENoAutomaticReconnection;
       
  7812                 }
       
  7813 
       
  7814             // Buffer size
       
  7815             openChannelV2.iBufferSize = bufferSizeTlv.GetLongInfo(
       
  7816                 ETLV_BufferSize );
       
  7817 
       
  7818             // Handling of
       
  7819             // Bearer type
       
  7820             // Bearer parameters
       
  7821             GetBearerTypeAndParams( bearerDescriptionTlv,
       
  7822                 openChannelV2.iBearer );
       
  7823 
       
  7824             // Alpha Identifier ( Optional )
       
  7825             TPtrC8 sourceString; // Used with conversions
       
  7826             CTlv alphaIdentifierTlv;
       
  7827             // Get Alpha Identifier tlv from berTlv
       
  7828             TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifierTlv,
       
  7829                 KTlvAlphaIdentifierTag ) );
       
  7830             // If Alpha Identifier string exist
       
  7831             if ( KErrNone == returnValue )
       
  7832                 {
       
  7833                 if ( alphaIdentifierTlv.GetLength() )
       
  7834                     {
       
  7835                     // 8-bit string to 16-bit string
       
  7836                     sourceString.Set(
       
  7837                         alphaIdentifierTlv.GetData( ETLV_AlphaIdentifier ) );
       
  7838                     // Convert and set the Alpha Identifier
       
  7839                     TSatUtility::SetAlphaId(
       
  7840                         sourceString, openChannelV2.iAlphaId.iAlphaId );
       
  7841                     // Set Alpha Identifier status
       
  7842                     openChannelV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  7843                     }
       
  7844                 else
       
  7845                     {
       
  7846                     openChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  7847                     }
       
  7848                 }
       
  7849             // Alpha Identifier not present
       
  7850             else
       
  7851                 {
       
  7852                 openChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  7853                 }
       
  7854 
       
  7855             // Icon Identifier ( optional )
       
  7856             TSatUtility::FillIconStructure( berTlv,
       
  7857                 openChannelV2.iIconId );
       
  7858 
       
  7859             // Handling of
       
  7860             // SIM/ME interface transport level ( Optional )
       
  7861             // Other Address - Set Destination Address
       
  7862             TInt retValueLocalAdd = SimMeInterfaceAndDataDestinationAddress(
       
  7863                 berTlv,
       
  7864                 openChannelV2.iSimMeInterface,
       
  7865                 openChannelV2.iDestinationAddress );
       
  7866 
       
  7867             // Switch according to bearer type
       
  7868             //
       
  7869             switch ( openChannelV2.iBearer.iType )
       
  7870                 {
       
  7871                 case RSat::EGPRSBearer:
       
  7872                     {
       
  7873                     TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - GPRS Bearer");
       
  7874                     OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - GPRS Bearer" );
       
  7875                     // Fill in TOpenGprsChannelV4
       
  7876                     RSat::TOpenGprsChannelV4& openGprsChannelV4
       
  7877                         = ( *iOpenGprsChannelV4Pckg )();
       
  7878                     openGprsChannelV4
       
  7879                         = static_cast<RSat::TOpenGprsChannelV4&>( openChannelV2 );
       
  7880                     openGprsChannelV4.iPCmdType = RSat::EGprsBearer;
       
  7881 
       
  7882                     // Handling of
       
  7883                     // Other Address - Local Address ( Optional )
       
  7884                     if ( KErrNone == retValueLocalAdd )
       
  7885                         {
       
  7886                         LocalAddress( berTlv, openGprsChannelV4.iLocalAddress );
       
  7887                         }
       
  7888                     else
       
  7889                         {
       
  7890                         TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived -\
       
  7891                             Local Adress - not present");
       
  7892                         OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Local Adress - not present" );
       
  7893                         openGprsChannelV4.iLocalAddress.iType =
       
  7894                             RSat::EAddressNotPresent;
       
  7895                         }
       
  7896 
       
  7897                     // Handling GPRS bearer specific data
       
  7898                     //
       
  7899                     // Network Access Point Name ( Optional )
       
  7900                     // Text string - User Login ( Optional )
       
  7901                     // Text string - User Password ( Optional )
       
  7902                     GprsBearerSpecific( berTlv, openGprsChannelV4 );
       
  7903                     break;
       
  7904                     }
       
  7905                 case RSat::EDefaultBearer:
       
  7906                     {
       
  7907                     TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - Default Bearer");
       
  7908                     OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Default Bearer" );
       
  7909                     // Fill in TOpenChannelBaseV2
       
  7910                     openChannelV2.iPCmdType = RSat::EAnyBearer;
       
  7911                     break;
       
  7912                     }
       
  7913                 case RSat::ECSDBearer:
       
  7914                 case RSat::EBTBearer:
       
  7915                 case RSat::EIrDaBearer:
       
  7916                 case RSat::ERS232Bearer:
       
  7917                 case RSat::EUSBBearer:
       
  7918                     {
       
  7919                     TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - Bearer not supported");
       
  7920                     OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Bearer not supported" );
       
  7921                     // Bearer not supported
       
  7922                     TBuf8<1> noAdditionalInfo( 0 );
       
  7923                     iSatMessHandler->OpenChannelTerminalResp(
       
  7924                          iTransId,
       
  7925                          iCommandDetails,
       
  7926                          RSat::KCmdBeyondMeCapabilities,
       
  7927                          noAdditionalInfo,
       
  7928                          openChannelV2.iBearer.iType,
       
  7929                          openChannelV2.iBearer.iParams,
       
  7930                          openChannelV2.iBufferSize );
       
  7931                     ret = KErrCorrupt;
       
  7932                     break;
       
  7933                     }
       
  7934                 default:
       
  7935                     {
       
  7936                     // Bearer not supported (RFU)
       
  7937                     TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - Bearer not supported");
       
  7938                     OstTrace0( TRACE_NORMAL, DUP6_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Bearer not supported" );
       
  7939                     // Required values missing
       
  7940                     TBuf8<1> noBearer( 0 );
       
  7941                     TBuf8<1> noAdditionalInfo( 0 );
       
  7942                     TUint16 noBufferSize( 0 );
       
  7943                     iSatMessHandler->OpenChannelTerminalResp(
       
  7944                          iTransId,
       
  7945                          iCommandDetails,
       
  7946                          RSat::KCmdDataNotUnderstood,
       
  7947                          noAdditionalInfo,
       
  7948                          TUint8( RSat::EBearerTypeNotSet ),
       
  7949                          noBearer,
       
  7950                          noBufferSize );
       
  7951                     ret = KErrCorrupt;
       
  7952                     break;
       
  7953                     }
       
  7954                 } // End of switch according to bearer type
       
  7955             }
       
  7956         else
       
  7957             {
       
  7958             TFLOGSTRING("TSY: CSatNotifyOpenChannel::MessageReceived - Required values missing");
       
  7959             OstTrace0( TRACE_NORMAL, DUP7_CSATNOTIFYOPENCHANNEL_MESSAGERECEIVED, "CSatNotifyOpenChannel::MessageReceived - Required values missing" );
       
  7960             // Required values missing
       
  7961             TBuf8<1> noBearer( 0 );
       
  7962             TBuf8<1> noAdditionalInfo( 0 );
       
  7963             TUint16 noBufferSize( 0 );
       
  7964             iSatMessHandler->OpenChannelTerminalResp(
       
  7965                  iTransId,
       
  7966                  iCommandDetails,
       
  7967                  RSat::KErrorRequiredValuesMissing,
       
  7968                  noAdditionalInfo,
       
  7969                  TUint8( RSat::EBearerTypeNotSet ),
       
  7970                  noBearer,
       
  7971                  noBufferSize );
       
  7972             ret = KErrCorrupt;
       
  7973             } // End of Bearer Description & Buffer Size ( Mandatory )
       
  7974 
       
  7975         CompleteRequest( ret );
       
  7976         }
       
  7977     }
       
  7978 
       
  7979 // -----------------------------------------------------------------------------
       
  7980 // CSatNotifyOpenChannel::Notify
       
  7981 // An ETel SAT client can call this method via ETel server to set a pending
       
  7982 // request in SimAtkTsy for a OpenChannel PCmd.
       
  7983 // (other items were commented in a header).
       
  7984 // -----------------------------------------------------------------------------
       
  7985 //
       
  7986 void CSatNotifyOpenChannel::Notify
       
  7987         (
       
  7988         const TTsyReqHandle aReqHandle, // Request handle
       
  7989         TDes8*              aDataPtr    // Pointer to data
       
  7990         )
       
  7991     {
       
  7992     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_NOTIFY, "CSatNotifyOpenChannel::Notify" );
       
  7993     TFLOGSTRING("CSatNotifyOpenChannel::Notify");
       
  7994     iReqHandle = aReqHandle;
       
  7995     iOpenBaseChannelV2Pckg =
       
  7996         static_cast< RSat::TOpenChannelBaseV2Pckg* >( aDataPtr );
       
  7997     iOpenCsChannelV2Pckg =
       
  7998         static_cast< RSat::TOpenCsChannelV2Pckg* >( aDataPtr );
       
  7999     iOpenGprsChannelV4Pckg =
       
  8000         static_cast< RSat::TOpenGprsChannelV4Pckg* >( aDataPtr );
       
  8001     iOpenLocalLinksChannelV2Pckg =
       
  8002         static_cast< RSat::TOpenLocalLinksChannelV2Pckg* >( aDataPtr );
       
  8003     iSatMessaging->SatReady( KOpenChannel );
       
  8004     }
       
  8005 
       
  8006 // -----------------------------------------------------------------------------
       
  8007 // CSatNotifyOpenChannel::TerminalResponse
       
  8008 // Handles a OpenChannel terminal response provided by an ETel SAT client via
       
  8009 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  8010 // (other items were commented in a header).
       
  8011 // -----------------------------------------------------------------------------
       
  8012 //
       
  8013 TInt CSatNotifyOpenChannel::TerminalResponse
       
  8014         (
       
  8015         TDes8* aRsp // Response
       
  8016         )
       
  8017     {
       
  8018     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_TERMINALRESPONSE, "CSatNotifyOpenChannel::TerminalResponse" );
       
  8019     TFLOGSTRING("CSatNotifyOpenChannel::TerminalResponse");
       
  8020     TInt   ret( KErrNone );
       
  8021     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  8022     additionalInfo.Zero();
       
  8023     RSat::TOpenChannelRspV2Pckg* aRspPckg =
       
  8024             reinterpret_cast< RSat::TOpenChannelRspV2Pckg* >( aRsp );
       
  8025     RSat::TOpenChannelRspV2& rspV2 = ( *aRspPckg ) ();
       
  8026     // Check that general result value is valid
       
  8027     if ( iAllowedResults != rspV2.iGeneralResult )
       
  8028         {
       
  8029         // Invalid general result
       
  8030         ret = KErrCorrupt;
       
  8031         }
       
  8032     // Check fo additional info type
       
  8033     // - If there is Me (Mobile Equipment) error, additional info is needed
       
  8034     // - Channel Status Info is sent through additional info
       
  8035     if ( ( RSat::KMeProblem == rspV2.iInfoType )
       
  8036         || ( RSat::KChannelStatusInfo == rspV2.iInfoType )
       
  8037         )
       
  8038         {
       
  8039         // Check the length of additional info
       
  8040         if ( !rspV2.iAdditionalInfo.Length() )
       
  8041             {
       
  8042             // Invalid additional info field
       
  8043             ret = KErrCorrupt;
       
  8044             }
       
  8045         else
       
  8046             {
       
  8047             TIsiUtility::CopyToBigEndian( rspV2.iAdditionalInfo, additionalInfo );
       
  8048             }
       
  8049         }
       
  8050     // Send Terminal Response
       
  8051     iSatMessHandler->OpenChannelTerminalResp(
       
  8052         iTransId,
       
  8053         iCommandDetails,
       
  8054         TUint8( rspV2.iGeneralResult ),
       
  8055         additionalInfo,
       
  8056         TUint8( rspV2.iBearer.iType ),
       
  8057         rspV2.iBearer.iParams,
       
  8058         rspV2.iBufferSize);
       
  8059     return ret;
       
  8060     }
       
  8061 
       
  8062 // -----------------------------------------------------------------------------
       
  8063 // CSatNotifyOpenChannel::GetBearerTypeAndParams
       
  8064 // Handles a OpenChannel Bearer type and parameters specific data.
       
  8065 // -----------------------------------------------------------------------------
       
  8066 //
       
  8067 void CSatNotifyOpenChannel::GetBearerTypeAndParams
       
  8068         (
       
  8069         CTlv& aBearerDescriptionTlv,
       
  8070         RSat::TBearer& aBearer
       
  8071         )
       
  8072     {
       
  8073     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_GETBEARERTYPEANDPARAMS, "CSatNotifyOpenChannel::GetBearerTypeAndParams" );
       
  8074     TFLOGSTRING("TSY: CSatNotifyOpenChannel::GetBearerTypeAndParams");
       
  8075     TUint8 bearerType( aBearerDescriptionTlv.GetShortInfo( ETLV_BearerType ) );
       
  8076 
       
  8077     // Switch for setting bearer type values
       
  8078     switch( bearerType )
       
  8079         {
       
  8080         case KBipCsdBearer:
       
  8081             {
       
  8082             aBearer.iType = RSat::ECSDBearer;
       
  8083             break;
       
  8084             }
       
  8085         case KBipGprsBearer:
       
  8086             {
       
  8087             aBearer.iType = RSat::EGPRSBearer;
       
  8088             break;
       
  8089             }
       
  8090         case KBipDefaultBearer:
       
  8091             {
       
  8092             aBearer.iType = RSat::EDefaultBearer;
       
  8093             break;
       
  8094             }
       
  8095         case KBipBluetoothBearer:
       
  8096             {
       
  8097             aBearer.iType = RSat::EBTBearer;
       
  8098             break;
       
  8099             }
       
  8100         case KBipIrDABearer:
       
  8101             {
       
  8102             aBearer.iType = RSat::EIrDaBearer;
       
  8103             break;
       
  8104             }
       
  8105         case KBipRS232Bearer:
       
  8106             {
       
  8107             aBearer.iType = RSat::ERS232Bearer;
       
  8108             break;
       
  8109             }
       
  8110         case KBipUSBBearer:
       
  8111             {
       
  8112             aBearer.iType = RSat::EUSBBearer;
       
  8113             break;
       
  8114             }
       
  8115         // Currently Local link technology independent bearer type is missing from
       
  8116         // Etel SAT API ( EtelSat.h)
       
  8117         case KBipLocalLinkTechnologyIndependentBearer:
       
  8118         default:
       
  8119             {
       
  8120             aBearer.iType = RSat::EBearerTypeNotSet;
       
  8121             break;
       
  8122             }
       
  8123         }
       
  8124 
       
  8125     // Bearer parameters
       
  8126     aBearer.iParams = aBearerDescriptionTlv.GetData( ETLV_BearerParameters );
       
  8127     }
       
  8128 
       
  8129 // -----------------------------------------------------------------------------
       
  8130 // CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress
       
  8131 // Handles a OpenChannel SIM/ME Interface transport level and Data Destination
       
  8132 // Address specific data.
       
  8133 // -----------------------------------------------------------------------------
       
  8134 //
       
  8135 TInt CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress
       
  8136         (
       
  8137         CBerTlv& aBerTlv,
       
  8138         RSat::TSimMeInterface& aSimMeInterface,
       
  8139         RSat::TOtherAddress& aDestinationAddress
       
  8140         )
       
  8141     {
       
  8142     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress" );
       
  8143     TFLOGSTRING("TSY: CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress");
       
  8144 
       
  8145     // SIM/ME Interface transport level ( Optional )
       
  8146     CTlv simMeInterfaceTlv;
       
  8147 
       
  8148     if ( KErrNone == aBerTlv.TlvByTagValue( &simMeInterfaceTlv,
       
  8149         KTlvSimMeTransportLevelTag ) )
       
  8150         {
       
  8151         TFLOGSTRING("CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress -\
       
  8152             SIM/ME Interface");
       
  8153         OstTrace0( TRACE_NORMAL, DUP5_CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress - SIM/ME Interface" );
       
  8154 
       
  8155         aSimMeInterface.iPrtNumber = simMeInterfaceTlv.GetLongInfo(
       
  8156             ETLV_PortNumber );
       
  8157         TUint8 protocol( simMeInterfaceTlv.GetShortInfo(
       
  8158             ETLV_TransportProtocolType ) );
       
  8159 
       
  8160         if ( KProtocolUdp == protocol )
       
  8161             {
       
  8162             aSimMeInterface.iTransportProto = RSat::EUdp;
       
  8163             }
       
  8164         else if ( KProtocolTcp == protocol )
       
  8165             {
       
  8166             aSimMeInterface.iTransportProto = RSat::ETcp;
       
  8167             }
       
  8168         else
       
  8169             {
       
  8170             aSimMeInterface.iTransportProto = RSat::EProtocolNotSet;
       
  8171             }
       
  8172         }
       
  8173     else
       
  8174         {
       
  8175         TFLOGSTRING("TSY: CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress -\
       
  8176             SIM/ME Interface - Not present");
       
  8177         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress -SIM/ME Interface - Not present" );
       
  8178         aSimMeInterface.iTransportProto = RSat::EProtocolNotPresent;
       
  8179         }
       
  8180 
       
  8181     // Data destination address
       
  8182     // The Data Destination Address is the end point destination
       
  8183     // address of sent data. This data destination address is
       
  8184     // requested when a SIM/ME Interface transport is present,
       
  8185     // otherwise it is ignored.
       
  8186 
       
  8187     // Determine the number of Other Address tags.
       
  8188     // - If there is one and no SIM/ME Interface then this is a Local Address.
       
  8189     // - If there is one and SIM/ME Interface, this is a Destination Address.
       
  8190     // - If there are two and SIM/ME Interface, then the last one is
       
  8191     //   the Destination Address.
       
  8192     CTlv* dataDestAddressTlv = NULL;
       
  8193     CTlv localAddress1;
       
  8194     CTlv localAddress2;
       
  8195 
       
  8196     TInt retValueLocalAdd( KErrNotFound );
       
  8197     TInt retValAddr1( aBerTlv.TlvByTagValue( &localAddress1,
       
  8198         KTlvOtherAddressTag ) );
       
  8199     TInt retValAddr2( aBerTlv.TlvByTagValue( &localAddress2,
       
  8200         KTlvOtherAddressTag, 1 ) );
       
  8201 
       
  8202     if ( ( RSat::EProtocolNotPresent !=
       
  8203            aSimMeInterface.iTransportProto )
       
  8204          && ( KErrNone == retValAddr1 )
       
  8205          && ( KErrNotFound == retValAddr2 ) )
       
  8206         {
       
  8207         // Destination Address is localAddress1
       
  8208         dataDestAddressTlv = &localAddress1;
       
  8209         // There can not be a Local Address
       
  8210         }
       
  8211     else if ( ( RSat::EProtocolNotPresent !=
       
  8212            aSimMeInterface.iTransportProto )
       
  8213          && ( KErrNone == retValAddr1 )
       
  8214          && ( KErrNone == retValAddr2 ) )
       
  8215         {
       
  8216         // Local Address is localAddress1
       
  8217         retValueLocalAdd = retValAddr1;
       
  8218         // Destination Address is localAddress2
       
  8219         dataDestAddressTlv = &localAddress2;
       
  8220         }
       
  8221     else if ( ( RSat::EProtocolNotPresent ==
       
  8222            aSimMeInterface.iTransportProto )
       
  8223          && ( KErrNone == retValAddr1 ) )
       
  8224         {
       
  8225         // There is only a Local Address
       
  8226         // Local Address is localAddress1
       
  8227         retValueLocalAdd = retValAddr1;
       
  8228         }
       
  8229     else
       
  8230         {
       
  8231         TFLOGSTRING("TSY: CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress,\
       
  8232             Transport protocol did not match.");
       
  8233         OstTrace0( TRACE_NORMAL, DUP2_CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress, Transport protocol did not match." );
       
  8234         }
       
  8235 
       
  8236     // Other Address - Set Destination Address
       
  8237     if( dataDestAddressTlv )
       
  8238         {
       
  8239         TFLOGSTRING("TSY: CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress -\
       
  8240             Destination Address");
       
  8241         OstTrace0( TRACE_NORMAL, DUP3_CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress - Destination Address" );
       
  8242         TUint8 typeOfAddress( dataDestAddressTlv->GetShortInfo(
       
  8243             ETLV_TypeOfAddress ) );
       
  8244         switch( typeOfAddress )
       
  8245             {
       
  8246             case KIPV4: // IPv4
       
  8247                 {
       
  8248                 aDestinationAddress.iType = RSat::EIPv4Address;
       
  8249                 break;
       
  8250                 }
       
  8251             case KIPV6: // IPv6
       
  8252                 {
       
  8253                 aDestinationAddress.iType = RSat::EIPv6Address;
       
  8254                 break;
       
  8255                 }
       
  8256             default:
       
  8257                 {
       
  8258                 aDestinationAddress.iType = RSat::EAddressNotSet;
       
  8259                 break;
       
  8260                 }
       
  8261             }
       
  8262         // Is there an address
       
  8263         if( dataDestAddressTlv->GetLength() - 1 )
       
  8264             {
       
  8265             aDestinationAddress.iAddress =
       
  8266                 dataDestAddressTlv->GetData( ETLV_Address );
       
  8267             }
       
  8268         }
       
  8269     else
       
  8270         {
       
  8271         TFLOGSTRING("TSY: CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress -\
       
  8272             Destination Address - Not present");
       
  8273         OstTrace0( TRACE_NORMAL, DUP4_CSATNOTIFYOPENCHANNEL_SIMMEINTERFACEANDDATADESTINATIONADDRESS, "CSatNotifyOpenChannel::SimMeInterfaceAndDataDestinationAddress - Destination Address - Not present" );
       
  8274         aDestinationAddress.iType = RSat::EAddressNotPresent;
       
  8275         } // End of Other Address - Set Destination Address
       
  8276 
       
  8277     return retValueLocalAdd;
       
  8278     }
       
  8279 
       
  8280 // -----------------------------------------------------------------------------
       
  8281 // CSatNotifyOpenChannel::LocalAddress
       
  8282 // Handles a OpenChannel Local Address specific data.
       
  8283 // -----------------------------------------------------------------------------
       
  8284 //
       
  8285 void CSatNotifyOpenChannel::LocalAddress
       
  8286         (
       
  8287         CBerTlv& aBerTlv,
       
  8288         RSat::TOtherAddress& aLocalAddress
       
  8289         )
       
  8290     {
       
  8291     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_LOCALADDRESS, "CSatNotifyOpenChannel::LocalAddress" );
       
  8292     TFLOGSTRING("TSY: CSatNotifyOpenChannel::LocalAddress");
       
  8293 
       
  8294     // Other Address - Set Local Address ( Optional )
       
  8295     CTlv localAddressTlv;
       
  8296 
       
  8297     if ( KErrNone == aBerTlv.TlvByTagValue( &localAddressTlv,
       
  8298         KTlvOtherAddressTag ) )
       
  8299         {
       
  8300         // If Other local address present
       
  8301         if ( localAddressTlv.GetLength() )
       
  8302             {
       
  8303             aLocalAddress.iAddress = localAddressTlv.GetData( ETLV_Address );
       
  8304             // Type of address
       
  8305             TUint8 typeOfAddress( localAddressTlv.GetShortInfo(
       
  8306                 ETLV_TypeOfAddress ) );
       
  8307 
       
  8308             if ( KIPV4 == typeOfAddress )
       
  8309                 {
       
  8310                 aLocalAddress.iType = RSat::EIPv4Address;
       
  8311                 }
       
  8312             else if ( KIPV6 == typeOfAddress )
       
  8313                 {
       
  8314                 aLocalAddress.iType = RSat::EIPv6Address;
       
  8315                 }
       
  8316             else
       
  8317                 {
       
  8318                 aLocalAddress.iType = RSat::EAddressNotSet;
       
  8319                 }
       
  8320             }
       
  8321         else
       
  8322             {
       
  8323             TFLOGSTRING("TSY: CSatNotifyOpenChannel::LocalAddress - not present");
       
  8324             OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYOPENCHANNEL_LOCALADDRESS, "CSatNotifyOpenChannel::LocalAddress - not present" );
       
  8325             aLocalAddress.iType = RSat::EAddressNotPresent;
       
  8326             } // End of If Other local address present
       
  8327         }
       
  8328     }
       
  8329 
       
  8330 // -----------------------------------------------------------------------------
       
  8331 // CSatNotifyOpenChannel::GprsBearerSpecific
       
  8332 // Handles a OpenChannel GPRS bearer specific data.
       
  8333 // -----------------------------------------------------------------------------
       
  8334 //
       
  8335 void CSatNotifyOpenChannel::GprsBearerSpecific
       
  8336         (
       
  8337         CBerTlv& aBerTlv,
       
  8338         RSat::TOpenGprsChannelV4& aOpenGprsChannelV4
       
  8339         )
       
  8340     {
       
  8341     OstTrace0( TRACE_NORMAL, CSATNOTIFYOPENCHANNEL_GPRSBEARERSPECIFIC, "CSatNotifyOpenChannel::GprsBearerSpecific" );
       
  8342     TFLOGSTRING("TSY: CSatNotifyOpenChannel::GprsBearerSpecific");
       
  8343 
       
  8344     // Network Access Point Name ( Optional )
       
  8345     CTlv nanTlv;
       
  8346     // If Network Access Point Name present
       
  8347     if ( KErrNone == aBerTlv.TlvByTagValue( &nanTlv,
       
  8348         KTlvNetworkAccessNameTag ) )
       
  8349         {
       
  8350         TFLOGSTRING("TSY: CSatNotifyOpenChannel::GprsBearerSpecific -\
       
  8351             Access Point name");
       
  8352         OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYOPENCHANNEL_GPRSBEARERSPECIFIC, "CSatNotifyOpenChannel::GprsBearerSpecific - Access Point name" );
       
  8353         aOpenGprsChannelV4.iAccessName =
       
  8354             nanTlv.GetData( ETLV_NetworkAccessName );
       
  8355         }
       
  8356 
       
  8357     // Text string - User Login ( Optional )
       
  8358     // Text string - User Password ( Optional )
       
  8359     TSatUtility::SetUserLoginAndUserPassword( aBerTlv,
       
  8360         aOpenGprsChannelV4.iUserLogin,
       
  8361         aOpenGprsChannelV4.iUserPassword );
       
  8362     }
       
  8363 
       
  8364 // -----------------------------------------------------------------------------
       
  8365 // CSatNotifyGetChannelStatus::CSatNotifyGetChannelStatus
       
  8366 // C++ default constructor can NOT contain any code, that
       
  8367 // might leave.
       
  8368 // -----------------------------------------------------------------------------
       
  8369 //
       
  8370 CSatNotifyGetChannelStatus::CSatNotifyGetChannelStatus
       
  8371         (
       
  8372         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  8373         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  8374         )
       
  8375         :
       
  8376         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  8377         iGetChannelStatusRspV2Pckg( NULL )
       
  8378     {
       
  8379     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETCHANNELSTATUS_CSATNOTIFYGETCHANNELSTATUS, "CSatNotifyGetChannelStatus::CSatNotifyGetChannelStatus" );
       
  8380     // Following results are also allowed for this command:
       
  8381     // (in addition to result declared in base class constructor)
       
  8382     iAllowedResults += RSat::KPSessionTerminatedByUser
       
  8383         + RSat::KErrorRequiredValuesMissing;
       
  8384     }
       
  8385 
       
  8386 // -----------------------------------------------------------------------------
       
  8387 // CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus
       
  8388 // Destructor
       
  8389 // -----------------------------------------------------------------------------
       
  8390 //
       
  8391 CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus()
       
  8392     {
       
  8393     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYGETCHANNELSTATUS_CSATNOTIFYGETCHANNELSTATUS, "CSatNotifyGetChannelStatus::~CSatNotifyGetChannelStatus" );
       
  8394     // None
       
  8395     }
       
  8396 
       
  8397 // -----------------------------------------------------------------------------
       
  8398 // CSatNotifyGetChannelStatus::MessageReceived
       
  8399 // Handles a GetChannelStatus proactive command ISI message,
       
  8400 // and completes a pending ETel request.
       
  8401 // (other items were commented in a header).
       
  8402 // -----------------------------------------------------------------------------
       
  8403 //
       
  8404 void CSatNotifyGetChannelStatus::MessageReceived
       
  8405         (
       
  8406         const TIsiReceiveC& aIsiMessage    // Received isi-message
       
  8407         )
       
  8408     {
       
  8409     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETCHANNELSTATUS_MESSAGERECEIVED, "CSatNotifyGetChannelStatus::MessageReceived" );
       
  8410     TFLOGSTRING("CSatNotifyGetChannelStatus::MessageReceived");
       
  8411     // Get ber tlv
       
  8412     CBerTlv berTlv;
       
  8413     berTlv.BerTlv( aIsiMessage );
       
  8414     // Get command details tlv
       
  8415     CTlv commandDetails;
       
  8416     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  8417     // Store command details TLV
       
  8418     iCommandDetails.Copy( commandDetails.Data() );
       
  8419     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  8420     if ( !iReqHandle )
       
  8421         {
       
  8422         // Request not on, returning response immediately
       
  8423         TBuf8<1> empty(0);
       
  8424         iSatMessHandler->GetChannelStatusTerminalResp( iTransId,
       
  8425                                                        iCommandDetails,
       
  8426                                                        RSat::KMeUnableToProcessCmd,
       
  8427                                                        empty );
       
  8428         }
       
  8429     else
       
  8430         {
       
  8431         // Fill the Get Channel status structure
       
  8432         RSat::TGetChannelStatusV2& channelStatusV2 =
       
  8433             ( *iGetChannelStatusRspV2Pckg )();
       
  8434         // Store transaction ID
       
  8435         channelStatusV2.SetPCmdNumber(
       
  8436             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  8437         // Complete request
       
  8438         CompleteRequest( KErrNone );
       
  8439         }
       
  8440     }
       
  8441 
       
  8442 // -----------------------------------------------------------------------------
       
  8443 // CSatNotifyGetChannelStatus::Notify
       
  8444 // An ETel SAT client can call this method via ETel server to set a pending
       
  8445 // request in SimAtkTsy for a GetChannelStatus PCmd.
       
  8446 // (other items were commented in a header).
       
  8447 // -----------------------------------------------------------------------------
       
  8448 //
       
  8449 void CSatNotifyGetChannelStatus::Notify
       
  8450         (
       
  8451         const TTsyReqHandle aReqHandle, // Request handle
       
  8452         TDes8*              aDataPtr    // Pointer to data
       
  8453         )
       
  8454     {
       
  8455     OstTrace1( TRACE_NORMAL, CSATNOTIFYGETCHANNELSTATUS_NOTIFY, "CSatNotifyGetChannelStatus::Notify Handle: %u", aReqHandle );
       
  8456     TFLOGSTRING2("CSatNotifyGetChannelStatus::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  8457                aReqHandle );
       
  8458     iReqHandle = aReqHandle;
       
  8459     iGetChannelStatusRspV2Pckg =
       
  8460         static_cast< RSat::TGetChannelStatusV2Pckg* >( aDataPtr );
       
  8461     iSatMessaging->SatReady( KGetChannelStatus );
       
  8462     }
       
  8463 
       
  8464 // -----------------------------------------------------------------------------
       
  8465 // CSatNotifyGetChannelStatus::TerminalResponse
       
  8466 // Handles a GetChannelStatus terminal response provided by an ETel SAT client
       
  8467 // via ETel server,
       
  8468 // transforms it into an ISI message, and passes it to domestic OS
       
  8469 // (other items were commented in a header).
       
  8470 // -----------------------------------------------------------------------------
       
  8471 //
       
  8472 TInt CSatNotifyGetChannelStatus::TerminalResponse
       
  8473         (
       
  8474         TDes8* aRsp     // Response package
       
  8475         )
       
  8476     {
       
  8477     OstTrace0( TRACE_NORMAL, CSATNOTIFYGETCHANNELSTATUS_TERMINALRESPONSE, "CSatNotifyGetChannelStatus::TerminalResponse" );
       
  8478     TFLOGSTRING("CSatNotifyGetChannelStatus::TerminalResponse");
       
  8479     TInt   ret( KErrNone );
       
  8480     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  8481     additionalInfo.Zero();
       
  8482     RSat::TGetChannelStatusRspV2Pckg* aRspPckg =
       
  8483             reinterpret_cast< RSat::TGetChannelStatusRspV2Pckg* >( aRsp );
       
  8484     RSat::TGetChannelStatusRspV2& rspV2 = ( *aRspPckg ) ();
       
  8485     // Check that general result value is valid
       
  8486     if ( iAllowedResults != rspV2.iGeneralResult )
       
  8487         {
       
  8488         // Invalid general result
       
  8489         ret = KErrCorrupt;
       
  8490         }
       
  8491     if ( ( RSat::KChannelStatusInfo == rspV2.iInfoType )
       
  8492         || ( RSat::KMeProblem == rspV2.iInfoType ) )
       
  8493         {
       
  8494         if( !rspV2.iAdditionalInfo.Length()
       
  8495             && rspV2.iAdditionalInfo.Length())
       
  8496             {
       
  8497             ret = KErrCorrupt;
       
  8498             }
       
  8499         else
       
  8500             {
       
  8501             TIsiUtility::CopyToBigEndian( rspV2.iAdditionalInfo, additionalInfo );
       
  8502             }
       
  8503         }
       
  8504     iSatMessHandler->GetChannelStatusTerminalResp(
       
  8505         iTransId,
       
  8506         iCommandDetails,
       
  8507         TUint8( rspV2.iGeneralResult ),
       
  8508         additionalInfo );
       
  8509     return ret;
       
  8510     }
       
  8511 
       
  8512 
       
  8513 // -----------------------------------------------------------------------------
       
  8514 // CSatNotifyCloseChannel::CSatNotifyCloseChannel
       
  8515 // C++ default constructor can NOT contain any code, that
       
  8516 // might leave.
       
  8517 // -----------------------------------------------------------------------------
       
  8518 //
       
  8519 CSatNotifyCloseChannel::CSatNotifyCloseChannel
       
  8520         (
       
  8521         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  8522         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  8523         )
       
  8524         :
       
  8525         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  8526         iCloseChannelRspV2Pckg( NULL )
       
  8527     {
       
  8528     OstTrace0( TRACE_NORMAL, CSATNOTIFYCLOSECHANNEL_CSATNOTIFYCLOSECHANNEL, "CSatNotifyCloseChannel::CSatNotifyCloseChannel" );
       
  8529     // Following results are also allowed for this command:
       
  8530     // (in addition to result declared in base class constructor)
       
  8531     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  8532         + RSat::KPSessionTerminatedByUser + RSat::KErrorRequiredValuesMissing
       
  8533         + RSat::KBearerIndepProtocolError;
       
  8534     }
       
  8535 
       
  8536 // -----------------------------------------------------------------------------
       
  8537 // CSatNotifyCloseChannel::~CSatNotifyCloseChannel
       
  8538 // Destructor
       
  8539 // -----------------------------------------------------------------------------
       
  8540 //
       
  8541 CSatNotifyCloseChannel::~CSatNotifyCloseChannel()
       
  8542     {
       
  8543     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYCLOSECHANNEL_CSATNOTIFYCLOSECHANNEL, "CSatNotifyCloseChannel::~CSatNotifyCloseChannel" );
       
  8544     // None
       
  8545     }
       
  8546 
       
  8547 // -----------------------------------------------------------------------------
       
  8548 // CSatNotifyCloseChannel::MessageReceived
       
  8549 // Handles a CloseChannel proactive command ISI message,
       
  8550 // and completes a pending ETel request.
       
  8551 // (other items were commented in a header).
       
  8552 // -----------------------------------------------------------------------------
       
  8553 //
       
  8554 void CSatNotifyCloseChannel::MessageReceived
       
  8555         (
       
  8556         const TIsiReceiveC& aIsiMessage    // Received isi-message
       
  8557         )
       
  8558     {
       
  8559     OstTrace0( TRACE_NORMAL, CSATNOTIFYCLOSECHANNEL_MESSAGERECEIVED, "CSatNotifyCloseChannel::MessageReceived" );
       
  8560     TFLOGSTRING("CSatNotifyCloseChannel::MessageReceived");
       
  8561     // Get ber tlv
       
  8562     CBerTlv berTlv;
       
  8563     berTlv.BerTlv( aIsiMessage );
       
  8564     // Get command details tlv
       
  8565     CTlv commandDetails;
       
  8566     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  8567     // Store command details TLV
       
  8568     iCommandDetails.Copy( commandDetails.Data() );
       
  8569     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  8570     if ( !iReqHandle )
       
  8571         {
       
  8572         // Request not on, returning response immediately
       
  8573         TBuf8<1> empty(0);
       
  8574         iSatMessHandler->CloseChannelTerminalResp( iTransId,
       
  8575                                                     iCommandDetails,
       
  8576                                                     RSat::KMeUnableToProcessCmd,
       
  8577                                                     empty );
       
  8578         }
       
  8579     else
       
  8580         {
       
  8581         // Fill the Close Channel structure
       
  8582         RSat::TCloseChannelV2& closeChannelV2 =
       
  8583             ( *iCloseChannelRspV2Pckg )();
       
  8584         // Store transaction ID
       
  8585         closeChannelV2.SetPCmdNumber(
       
  8586             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  8587         // Store Channel Id
       
  8588         CTlv deviceIds;
       
  8589         TInt returnValue( berTlv.TlvByTagValue( &deviceIds,
       
  8590             KTlvDeviceIdentityTag ) );
       
  8591         if ( KErrNotFound != returnValue )
       
  8592             {
       
  8593             closeChannelV2.iDestination = (RSat::TDeviceId) deviceIds.GetShortInfo(
       
  8594                 ETLV_DestinationDeviceIdentity );
       
  8595             }
       
  8596         // Alpha Id (Optional)
       
  8597         CTlv alphaIdentifier;
       
  8598         returnValue = berTlv.TlvByTagValue( &alphaIdentifier,
       
  8599             KTlvAlphaIdentifierTag ) ;
       
  8600         closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  8601         if ( KErrNotFound != returnValue )
       
  8602             {
       
  8603             TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  8604             if ( alphaIdLength )
       
  8605                 {
       
  8606                 // get the alpha id
       
  8607                 TPtrC8 sourceString;
       
  8608                 sourceString.Set(
       
  8609                     alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  8610                 // convert and set the alpha id
       
  8611                 TSatUtility::SetAlphaId( sourceString ,
       
  8612                     closeChannelV2.iAlphaId.iAlphaId );
       
  8613                 }
       
  8614 
       
  8615             // Set Alpha ID status
       
  8616             if ( closeChannelV2.iAlphaId.iAlphaId.Length() )
       
  8617                 {
       
  8618                 closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  8619                 }
       
  8620             else
       
  8621                 {
       
  8622                 closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  8623                 }
       
  8624             }
       
  8625         // Icon Id (Optional)
       
  8626         TSatUtility::FillIconStructure( berTlv,
       
  8627             closeChannelV2.iIconId );
       
  8628         // Complete request
       
  8629         CompleteRequest( KErrNone );
       
  8630         }
       
  8631     }
       
  8632 
       
  8633 // -----------------------------------------------------------------------------
       
  8634 // CSatNotifyCloseChannel::Notify
       
  8635 // An ETel SAT client can call this method via ETel server to set a pending
       
  8636 // request in SimAtkTsy for a CloseChannel PCmd.
       
  8637 // (other items were commented in a header).
       
  8638 // -----------------------------------------------------------------------------
       
  8639 //
       
  8640 void CSatNotifyCloseChannel::Notify
       
  8641         (
       
  8642         const TTsyReqHandle aReqHandle, // Request handle
       
  8643         TDes8*              aDataPtr    // Pointer to data
       
  8644         )
       
  8645     {
       
  8646     OstTrace1( TRACE_NORMAL, CSATNOTIFYCLOSECHANNEL_NOTIFY, "CSatNotifyCloseChannel::Notify Handle: %u", aReqHandle );
       
  8647     TFLOGSTRING2("CSatNotifyCloseChannel::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  8648                aReqHandle );
       
  8649     iReqHandle = aReqHandle;
       
  8650     iCloseChannelRspV2Pckg =
       
  8651         static_cast< RSat::TCloseChannelV2Pckg* >( aDataPtr );
       
  8652     iSatMessaging->SatReady( KCloseChannel );
       
  8653     }
       
  8654 
       
  8655 // -----------------------------------------------------------------------------
       
  8656 // CSatNotifyCloseChannel::TerminalResponse
       
  8657 // Handles a CloseChannel terminal response provided by an ETel SAT client via
       
  8658 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  8659 // (other items were commented in a header).
       
  8660 // -----------------------------------------------------------------------------
       
  8661 //
       
  8662 TInt CSatNotifyCloseChannel::TerminalResponse
       
  8663         (
       
  8664         TDes8* aRsp     // Response package
       
  8665         )
       
  8666     {
       
  8667     OstTrace0( TRACE_NORMAL, CSATNOTIFYCLOSECHANNEL_TERMINALRESPONSE, "CSatNotifyCloseChannel::TerminalResponse" );
       
  8668     TFLOGSTRING("CSatNotifyCloseChannel::TerminalResponse");
       
  8669     TInt   ret( KErrNone );
       
  8670     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  8671     additionalInfo.Zero();
       
  8672     RSat::TCloseChannelRspV2Pckg* aRspPckg =
       
  8673             reinterpret_cast< RSat::TCloseChannelRspV2Pckg* >( aRsp );
       
  8674     RSat::TCloseChannelRspV2& rspV2 = ( *aRspPckg ) ();
       
  8675 
       
  8676     // Check that general result value is valid
       
  8677     if ( iAllowedResults != rspV2.iGeneralResult )
       
  8678         {
       
  8679         // Invalid general result
       
  8680         ret = KErrCorrupt;
       
  8681         }
       
  8682     if ( RSat::KMeProblem == rspV2.iInfoType )
       
  8683         {
       
  8684         if( rspV2.iAdditionalInfo.Length() )
       
  8685             {
       
  8686             additionalInfo.Append( TUint8( rspV2.iAdditionalInfo[0] ) );
       
  8687             }
       
  8688         else
       
  8689             {
       
  8690             ret = KErrCorrupt;
       
  8691             }
       
  8692         }
       
  8693     iSatMessHandler->CloseChannelTerminalResp(
       
  8694         iTransId,
       
  8695         iCommandDetails,
       
  8696         TUint8( rspV2.iGeneralResult ),
       
  8697         additionalInfo );
       
  8698     return ret;
       
  8699     }
       
  8700 
       
  8701 
       
  8702 // -----------------------------------------------------------------------------
       
  8703 // CSatNotifySendData::CSatNotifySendData
       
  8704 // C++ default constructor can NOT contain any code, that
       
  8705 // might leave.
       
  8706 // -----------------------------------------------------------------------------
       
  8707 //
       
  8708 CSatNotifySendData::CSatNotifySendData
       
  8709         (
       
  8710         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  8711         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  8712         )
       
  8713         :
       
  8714         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  8715         iSendDataRspV2Pckg( NULL )
       
  8716     {
       
  8717     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDATA_CSATNOTIFYSENDDATA, "CSatNotifySendData::CSatNotifySendData" );
       
  8718     // Following results are also allowed for this command:
       
  8719     // (in addition to result declared in base class constructor)
       
  8720     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  8721         + RSat::KPSessionTerminatedByUser + RSat::KNetworkUnableToProcessCmd
       
  8722         + RSat::KErrorRequiredValuesMissing + RSat::KBearerIndepProtocolError;
       
  8723     }
       
  8724 
       
  8725 // -----------------------------------------------------------------------------
       
  8726 // CSatNotifySendData::~CSatNotifySendData
       
  8727 // Destructor
       
  8728 // -----------------------------------------------------------------------------
       
  8729 //
       
  8730 CSatNotifySendData::~CSatNotifySendData()
       
  8731     {
       
  8732     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYSENDDATA_CSATNOTIFYSENDDATA, "CSatNotifySendData::~CSatNotifySendData" );
       
  8733     // None
       
  8734     }
       
  8735 
       
  8736 // -----------------------------------------------------------------------------
       
  8737 // CSatNotifySendData::MessageReceived
       
  8738 // Handles a SendData proactive command ISI message,
       
  8739 // and completes a pending ETel request.
       
  8740 // (other items were commented in a header).
       
  8741 // -----------------------------------------------------------------------------
       
  8742 //
       
  8743 void CSatNotifySendData::MessageReceived
       
  8744         (
       
  8745         const TIsiReceiveC& aIsiMessage    // Received isi-message
       
  8746         )
       
  8747     {
       
  8748     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDATA_MESSAGERECEIVED, "CSatNotifySendData::MessageReceived" );
       
  8749     TFLOGSTRING("CSatNotifySendData::MessageReceived");
       
  8750     // return value for completion of the request
       
  8751     TInt ret( KErrNone );
       
  8752     // Get ber tlv
       
  8753     CBerTlv berTlv;
       
  8754     berTlv.BerTlv( aIsiMessage );
       
  8755     // Get command details tlv
       
  8756     CTlv commandDetails;
       
  8757     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  8758     // Store command details TLV
       
  8759     iCommandDetails.Copy( commandDetails.Data() );
       
  8760     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  8761     if ( !iReqHandle )
       
  8762         {
       
  8763         // Request not on, returning response immediately
       
  8764         TBuf8<1> empty(0);
       
  8765         TUint8 channelDataLength( 0 );
       
  8766         iSatMessHandler->SendDataTerminalResp(
       
  8767            iTransId,
       
  8768            iCommandDetails,
       
  8769            RSat::KMeUnableToProcessCmd,
       
  8770            empty,
       
  8771            channelDataLength );
       
  8772         }
       
  8773     else
       
  8774         {
       
  8775         // Fill the Send Data structure
       
  8776         RSat::TSendDataV2& sendDataV2 =
       
  8777             ( *iSendDataRspV2Pckg )();
       
  8778         // Store transaction ID
       
  8779         sendDataV2.SetPCmdNumber(
       
  8780             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  8781         // Store Channel Id
       
  8782         CTlv deviceIds;
       
  8783         if ( KErrNotFound != berTlv.TlvByTagValue( &deviceIds,
       
  8784             KTlvDeviceIdentityTag ) )
       
  8785             {
       
  8786             sendDataV2.iDestination = (RSat::TDeviceId) deviceIds.GetShortInfo(
       
  8787                 ETLV_DestinationDeviceIdentity );
       
  8788             }
       
  8789         // Channel data (Mandatory)
       
  8790         // When the length is greater than 127, the byte 0x81 is appended before
       
  8791         // the actual length.
       
  8792         CTlv channelData;
       
  8793         if ( KErrNone == berTlv.TlvByTagValue( &channelData,
       
  8794              KTlvChannelDataTag ) )
       
  8795             {
       
  8796             // Set channel data
       
  8797             sendDataV2.iChannelData.Copy(
       
  8798                 channelData.GetData( ETLV_ChannelDataString ) );
       
  8799             //Set Data mode using command qualifier
       
  8800             TUint8 cmdQualifier(
       
  8801                 commandDetails.GetShortInfo( ETLV_CommandQualifier ) );
       
  8802             if ( KBipSendDataImmediately & cmdQualifier )
       
  8803                 {
       
  8804                 // bit 1 = 1
       
  8805                 sendDataV2.iMode = RSat::ESendDataImmediately;
       
  8806                 }
       
  8807             else
       
  8808                 {
       
  8809                 // bit 1 = 0
       
  8810                 sendDataV2.iMode = RSat::EStoreDataInTxBuffer;
       
  8811                 }
       
  8812             // Alpha Id (Optional)
       
  8813             sendDataV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  8814             CTlv alphaIdentifier;
       
  8815             TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifier,
       
  8816                 KTlvAlphaIdentifierTag ) );
       
  8817             if ( KErrNotFound != returnValue )
       
  8818                 {
       
  8819                 TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  8820                 if ( alphaIdLength )
       
  8821                     {
       
  8822                     // get the alpha id
       
  8823                     TPtrC8 sourceString;
       
  8824                     sourceString.Set(
       
  8825                         alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  8826                     // convert and set the alpha id
       
  8827                     TSatUtility::SetAlphaId( sourceString ,
       
  8828                         sendDataV2.iAlphaId.iAlphaId );
       
  8829                     sendDataV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  8830                     }
       
  8831                 else
       
  8832                     {
       
  8833                     sendDataV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  8834                     }
       
  8835                 }
       
  8836             // Icon Id (Optional)
       
  8837             TSatUtility::FillIconStructure( berTlv,
       
  8838                 sendDataV2.iIconId );
       
  8839             }
       
  8840         else
       
  8841             {
       
  8842             // Required values missing
       
  8843             TBuf8<1> noAdditionalInfo( 0 );
       
  8844             TUint8 channelDataLength( 0 );
       
  8845             iSatMessHandler->SendDataTerminalResp(
       
  8846                  iTransId,
       
  8847                  iCommandDetails,
       
  8848                  RSat::KErrorRequiredValuesMissing,
       
  8849                  noAdditionalInfo,
       
  8850                  channelDataLength );
       
  8851             ret = KErrCorrupt;
       
  8852             }
       
  8853         // Complete request
       
  8854         CompleteRequest( ret );
       
  8855         }
       
  8856     }
       
  8857 
       
  8858 // -----------------------------------------------------------------------------
       
  8859 // CSatNotifySendData::Notify
       
  8860 // An ETel SAT client can call this method via ETel server to set a pending
       
  8861 // request in SimAtkTsy for a SendData PCmd.
       
  8862 // (other items were commented in a header).
       
  8863 // -----------------------------------------------------------------------------
       
  8864 //
       
  8865 void CSatNotifySendData::Notify
       
  8866         (
       
  8867         const TTsyReqHandle aReqHandle, // Request handle
       
  8868         TDes8*              aDataPtr    // Pointer to data
       
  8869         )
       
  8870     {
       
  8871     OstTrace1( TRACE_NORMAL, CSATNOTIFYSENDDATA_NOTIFY, "CSatNotifySendData::Notify Handle: %u", aReqHandle );
       
  8872     TFLOGSTRING2("CSatNotifySendData::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  8873                aReqHandle );
       
  8874     iReqHandle = aReqHandle;
       
  8875     iSendDataRspV2Pckg =
       
  8876         static_cast< RSat::TSendDataV2Pckg* >( aDataPtr );
       
  8877     iSatMessaging->SatReady( KSendData );
       
  8878     }
       
  8879 
       
  8880 // -----------------------------------------------------------------------------
       
  8881 // CSatNotifySendData::TerminalResponse
       
  8882 // Handles a SendData terminal response provided by an ETel SAT client via
       
  8883 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  8884 // (other items were commented in a header).
       
  8885 // -----------------------------------------------------------------------------
       
  8886 //
       
  8887 TInt CSatNotifySendData::TerminalResponse
       
  8888         (
       
  8889         TDes8* aRsp     // Response package
       
  8890         )
       
  8891     {
       
  8892     OstTrace0( TRACE_NORMAL, CSATNOTIFYSENDDATA_TERMINALRESPONSE, "CSatNotifySendData::TerminalResponse" );
       
  8893     TFLOGSTRING("CSatNotifySendData::TerminalResponse");
       
  8894     TInt   ret( KErrNone );
       
  8895     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  8896     additionalInfo.Zero();
       
  8897     RSat::TSendDataRspV2Pckg* aRspPckg =
       
  8898             reinterpret_cast< RSat::TSendDataRspV2Pckg* >( aRsp );
       
  8899     RSat::TSendDataRspV2& rspV2 = ( *aRspPckg ) ();
       
  8900     // Check that general result value is valid
       
  8901     if ( iAllowedResults != rspV2.iGeneralResult )
       
  8902         {
       
  8903         // Invalid general result
       
  8904         ret = KErrCorrupt;
       
  8905         }
       
  8906 
       
  8907     if ( RSat::KMeProblem == rspV2.iInfoType )
       
  8908         {
       
  8909         if( rspV2.iAdditionalInfo.Length() )
       
  8910             {
       
  8911             additionalInfo.Append( TUint8( rspV2.iAdditionalInfo[0] ) );
       
  8912             }
       
  8913         else
       
  8914             {
       
  8915             ret = KErrCorrupt;
       
  8916             }
       
  8917         }
       
  8918     iSatMessHandler->SendDataTerminalResp(
       
  8919         iTransId,
       
  8920         iCommandDetails,
       
  8921         TUint8( rspV2.iGeneralResult ),
       
  8922         additionalInfo,
       
  8923         rspV2.iChannelDataLength );
       
  8924     return ret;
       
  8925     }
       
  8926 
       
  8927 
       
  8928 // -----------------------------------------------------------------------------
       
  8929 // CSatNotifyReceiveData::CSatNotifyReceiveData
       
  8930 // C++ default constructor can NOT contain any code, that
       
  8931 // might leave.
       
  8932 // -----------------------------------------------------------------------------
       
  8933 //
       
  8934 CSatNotifyReceiveData::CSatNotifyReceiveData
       
  8935         (
       
  8936         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  8937         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  8938         )
       
  8939         :
       
  8940         CSatNotificationsBase( aSatMessHandler, aSatMessaging ),
       
  8941         iReceiveDataRspV2Pckg( NULL )
       
  8942     {
       
  8943     OstTrace0( TRACE_NORMAL, CSATNOTIFYRECEIVEDATA_CSATNOTIFYRECEIVEDATA, "CSatNotifyReceiveData::CSatNotifyReceiveData" );
       
  8944     // Following results are also allowed for this command:
       
  8945     // (in addition to result declared in base class constructor)
       
  8946     iAllowedResults += RSat::KSuccessRequestedIconNotDisplayed
       
  8947         + RSat::KPSessionTerminatedByUser + RSat::KErrorRequiredValuesMissing
       
  8948         + RSat::KBearerIndepProtocolError;
       
  8949     }
       
  8950 
       
  8951 // -----------------------------------------------------------------------------
       
  8952 // CSatNotifyReceiveData::~CSatNotifyReceiveData
       
  8953 // Destructor
       
  8954 // -----------------------------------------------------------------------------
       
  8955 //
       
  8956 CSatNotifyReceiveData::~CSatNotifyReceiveData()
       
  8957     {
       
  8958     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYRECEIVEDATA_CSATNOTIFYRECEIVEDATA, "CSatNotifyReceiveData::~CSatNotifyReceiveData" );
       
  8959     // None
       
  8960     }
       
  8961 
       
  8962 // -----------------------------------------------------------------------------
       
  8963 // CSatNotifyReceiveData::MessageReceived
       
  8964 // Handles a ReceiveData proactive command ISI message,
       
  8965 // and completes a pending ETel request.
       
  8966 // (other items were commented in a header).
       
  8967 // -----------------------------------------------------------------------------
       
  8968 //
       
  8969 void CSatNotifyReceiveData::MessageReceived
       
  8970         (
       
  8971         const TIsiReceiveC& aIsiMessage    // Received isi-message
       
  8972         )
       
  8973     {
       
  8974     OstTrace0( TRACE_NORMAL, CSATNOTIFYRECEIVEDATA_MESSAGERECEIVED, "CSatNotifyReceiveData::MessageReceived" );
       
  8975     TFLOGSTRING("CSatNotifyReceiveData::MessageReceived");
       
  8976     // return value for completion of the request
       
  8977     TInt ret( KErrNone );
       
  8978     // Get ber tlv
       
  8979     CBerTlv berTlv;
       
  8980     berTlv.BerTlv( aIsiMessage );
       
  8981     // Get command details tlv
       
  8982     CTlv commandDetails;
       
  8983     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
  8984     // Store command details TLV
       
  8985     iCommandDetails.Copy( commandDetails.Data() );
       
  8986     iTransId = aIsiMessage.Get8bit( ISI_HEADER_OFFSET_TRANSID );
       
  8987     if ( !iReqHandle )
       
  8988         {
       
  8989         // Request not on, returning response immediately
       
  8990         TBuf8<1> empty(0);
       
  8991         TUint8 channelDataLength( 0 );
       
  8992         iSatMessHandler->ReceiveDataTerminalResp( iTransId,
       
  8993                                                     iCommandDetails,
       
  8994                                                     RSat::KMeUnableToProcessCmd,
       
  8995                                                     empty,
       
  8996                                                     channelDataLength );
       
  8997         }
       
  8998     else
       
  8999         {
       
  9000         // Fill the Receive Data structure
       
  9001         RSat::TReceiveDataV2& receiveDataV2 =
       
  9002             ( *iReceiveDataRspV2Pckg )();
       
  9003         // Store transaction ID
       
  9004         receiveDataV2.SetPCmdNumber(
       
  9005             commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
  9006         // Store Channel Id
       
  9007         CTlv deviceIds;
       
  9008         if ( KErrNotFound != berTlv.TlvByTagValue( &deviceIds,
       
  9009             KTlvDeviceIdentityTag ) )
       
  9010             {
       
  9011             receiveDataV2.iDestination = (RSat::TDeviceId) deviceIds.GetShortInfo(
       
  9012                 ETLV_DestinationDeviceIdentity );
       
  9013             }
       
  9014         // Channel data length (Mandatory)
       
  9015         CTlv channelDataLengthTlv;
       
  9016         if ( KErrNone == berTlv.TlvByTagValue( &channelDataLengthTlv,
       
  9017              KTlvChannelDataLengthTag ) )
       
  9018             {
       
  9019             receiveDataV2.iChannelDataLength =
       
  9020                 channelDataLengthTlv.GetShortInfo( ETLV_ChannelDataLength );
       
  9021             // Alpha Id (Optional)
       
  9022             receiveDataV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
  9023             CTlv alphaIdentifier;
       
  9024             TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifier,
       
  9025                 KTlvAlphaIdentifierTag ) );
       
  9026             if ( KErrNotFound != returnValue )
       
  9027                 {
       
  9028                 TUint16 alphaIdLength = alphaIdentifier.GetLength();
       
  9029                 if ( alphaIdLength )
       
  9030                     {
       
  9031                     // get the alpha id
       
  9032                     TPtrC8 sourceString;
       
  9033                     sourceString.Set(
       
  9034                         alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
  9035                     // convert and set the alpha id
       
  9036                     TSatUtility::SetAlphaId( sourceString ,
       
  9037                         receiveDataV2.iAlphaId.iAlphaId );
       
  9038                     receiveDataV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  9039                     }
       
  9040                 else
       
  9041                     {
       
  9042                     receiveDataV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  9043                     }
       
  9044                 }
       
  9045             // Icon Id (Optional)
       
  9046             TSatUtility::FillIconStructure( berTlv,
       
  9047                 receiveDataV2.iIconId );
       
  9048             }
       
  9049         else
       
  9050             {
       
  9051             // Required values missing
       
  9052             TBuf8<1> noAdditionalInfo( 0 );
       
  9053             TUint8 channelDataLength( 0 );
       
  9054             iSatMessHandler->ReceiveDataTerminalResp(
       
  9055                  iTransId,
       
  9056                  iCommandDetails,
       
  9057                  RSat::KErrorRequiredValuesMissing,
       
  9058                  noAdditionalInfo,
       
  9059                  channelDataLength );
       
  9060             ret = KErrCorrupt;
       
  9061             }
       
  9062         // Complete request
       
  9063         CompleteRequest( ret );
       
  9064         }
       
  9065     }
       
  9066 
       
  9067 // -----------------------------------------------------------------------------
       
  9068 // CSatNotifyReceiveData::Notify
       
  9069 // An ETel SAT client can call this method via ETel server to set a pending
       
  9070 // request in SimAtkTsy for a ReceiveData PCmd.
       
  9071 // (other items were commented in a header).
       
  9072 // -----------------------------------------------------------------------------
       
  9073 //
       
  9074 void CSatNotifyReceiveData::Notify
       
  9075         (
       
  9076         const TTsyReqHandle aReqHandle, // Request handle
       
  9077         TDes8*              aDataPtr    // Pointer to data
       
  9078         )
       
  9079     {
       
  9080     OstTrace1( TRACE_NORMAL, CSATNOTIFYRECEIVEDATA_NOTIFY, "CSatNotifyReceiveData::Notify Handle: %u", aReqHandle );
       
  9081     TFLOGSTRING2("CSatNotifyReceiveData::Notify. \n\t\t\t Handle:%d\n\t\t\t",
       
  9082                aReqHandle );
       
  9083     iReqHandle = aReqHandle;
       
  9084     iReceiveDataRspV2Pckg =
       
  9085         static_cast< RSat::TReceiveDataV2Pckg* >( aDataPtr );
       
  9086     iSatMessaging->SatReady( KReceiveData );
       
  9087     }
       
  9088 
       
  9089 // -----------------------------------------------------------------------------
       
  9090 // CSatNotifyReceiveData::TerminalResponse
       
  9091 // Handles a ReceiveData terminal response provided by an ETel SAT client via
       
  9092 // ETel server, transforms it into an ISI message, and passes it to domestic OS
       
  9093 // (other items were commented in a header).
       
  9094 // -----------------------------------------------------------------------------
       
  9095 //
       
  9096 TInt CSatNotifyReceiveData::TerminalResponse
       
  9097         (
       
  9098         TDes8* aRsp     // Response package
       
  9099         )
       
  9100     {
       
  9101     OstTrace0( TRACE_NORMAL, CSATNOTIFYRECEIVEDATA_TERMINALRESPONSE, "CSatNotifyReceiveData::TerminalResponse" );
       
  9102     TFLOGSTRING("CSatNotifyReceiveData::TerminalResponse");
       
  9103     TInt   ret( KErrNone );
       
  9104     TBuf8<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
  9105     additionalInfo.Zero();
       
  9106     RSat::TReceiveDataRspV2Pckg* aRspPckg =
       
  9107             reinterpret_cast< RSat::TReceiveDataRspV2Pckg* >( aRsp );
       
  9108     RSat::TReceiveDataRspV2& rspV2 = ( *aRspPckg ) ();
       
  9109     // Check that general result value is valid
       
  9110     if ( iAllowedResults != rspV2.iGeneralResult )
       
  9111         {
       
  9112         // Invalid general result
       
  9113         ret = KErrCorrupt;
       
  9114         }
       
  9115     if ( ( RSat::KMeProblem == rspV2.iInfoType )
       
  9116         || ( RSat::KChannelData == rspV2.iInfoType ) )
       
  9117         {
       
  9118         if( rspV2.iAdditionalInfo.Length() )
       
  9119             {
       
  9120             // Channel Data available and sent using Additional info
       
  9121             // Data are received in unicode format: 0x00XX where XX is
       
  9122             // meaningful.
       
  9123             additionalInfo.Copy( rspV2.iAdditionalInfo );
       
  9124             }
       
  9125         else
       
  9126             {
       
  9127             ret = KErrCorrupt;
       
  9128             }
       
  9129         }
       
  9130     iSatMessHandler->ReceiveDataTerminalResp(
       
  9131         iTransId,
       
  9132         iCommandDetails,
       
  9133         TUint8( rspV2.iGeneralResult ),
       
  9134         additionalInfo,
       
  9135         rspV2.iChannelDataLength );
       
  9136     return ret;
       
  9137     }
       
  9138 
       
  9139 
       
  9140 // -----------------------------------------------------------------------------
       
  9141 // CSatNotifyMoSmControlRequest::CSatNotifyMoSmControlRequest
       
  9142 // C++ default constructor can NOT contain any code, that
       
  9143 // might leave.
       
  9144 // -----------------------------------------------------------------------------
       
  9145 //
       
  9146 CSatNotifyMoSmControlRequest::CSatNotifyMoSmControlRequest
       
  9147         (
       
  9148         CSatMessHandler*    aSatMessHandler, //Pointer to the message handler
       
  9149         CTsySatMessaging*   aSatMessaging    //Pointer to satmessaging class
       
  9150         ) : CSatNotificationsBase( aSatMessHandler, aSatMessaging )
       
  9151     {
       
  9152     OstTrace0( TRACE_NORMAL, CSATNOTIFYMOSMCONTROLREQUEST_CSATNOTIFYMOSMCONTROLREQUEST, "CSatNotifyMoSmControlRequest::CSatNotifyMoSmControlRequest" );
       
  9153     }
       
  9154 
       
  9155 // -----------------------------------------------------------------------------
       
  9156 // CSatNotifyMoSmControlRequest::~CSatNotifyMoSmControlRequest
       
  9157 // Destructor
       
  9158 // -----------------------------------------------------------------------------
       
  9159 //
       
  9160 CSatNotifyMoSmControlRequest::~CSatNotifyMoSmControlRequest()
       
  9161     {
       
  9162     OstTrace0( TRACE_NORMAL, DUP1_CSATNOTIFYMOSMCONTROLREQUEST_CSATNOTIFYMOSMCONTROLREQUEST, "CSatNotifyMoSmControlRequest::~CSatNotifyMoSmControlRequest" );
       
  9163     // None
       
  9164     }
       
  9165 
       
  9166 // -----------------------------------------------------------------------------
       
  9167 // CSatNotifyMoSmControlRequest::MessageReceived
       
  9168 // Handles a MoSmControlRequest proactive command ISI message,
       
  9169 // and completes a pending ETel request.
       
  9170 // (other items were commented in a header).
       
  9171 // -----------------------------------------------------------------------------
       
  9172 //
       
  9173 void CSatNotifyMoSmControlRequest::MessageReceived
       
  9174         (
       
  9175         const TIsiReceiveC& /*aIsiMessage*/    // ISI  message
       
  9176         )
       
  9177     {
       
  9178     OstTrace0( TRACE_NORMAL, CSATNOTIFYMOSMCONTROLREQUEST_MESSAGERECEIVED, "CSatNotifyMoSmControlRequest::MessageReceived" );
       
  9179     // In S60 phones, the MoSm control request is received via an ISI
       
  9180     // message coming from the SMS server. That's why the body
       
  9181     // of this method is empty, see the class CSatMoSmCtrl. The Etel Sat API is used
       
  9182     // to pass to S60 Sat Server the alpha identifier provided by the SIM,
       
  9183     // if any. The SIM can provide such an alpha id to tell the user that the
       
  9184     // number to which the SMS has to be sent, has been modified by the SIM.
       
  9185     }
       
  9186 
       
  9187 // -----------------------------------------------------------------------------
       
  9188 // CSatNotifyMoSmControlRequest::CompleteNotification
       
  9189 // Completes an ETel server Mo-Sms Control notification
       
  9190 // (other items were commented in a header).
       
  9191 // -----------------------------------------------------------------------------
       
  9192 //
       
  9193 void CSatNotifyMoSmControlRequest::CompleteNotification
       
  9194         (
       
  9195         TDesC& aAlphaId,                // Alpha Id
       
  9196         RSat::TControlResult aResult    // Call Control result
       
  9197         )
       
  9198     {
       
  9199     OstTrace0( TRACE_NORMAL, CSATNOTIFYMOSMCONTROLREQUEST_COMPLETENOTIFICATION, "CSatNotifyMoSmControlRequest::CompleteNotification" );
       
  9200     TFLOGSTRING("CSatNotifyMoSmControlRequest::CompleteNotification");
       
  9201     //check that a client has requested this notifications
       
  9202     if ( iReqHandle )
       
  9203         {
       
  9204         // Fill the call control structure
       
  9205         RSat::TMoSmControlV1& moSmControlV1 = ( *iMoSmControlV1Pckg )();
       
  9206         // Set Alpha id status
       
  9207         if ( aAlphaId. Length() )
       
  9208             {
       
  9209             moSmControlV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
  9210             }
       
  9211         else
       
  9212             {
       
  9213             moSmControlV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
  9214             }
       
  9215         //set control result
       
  9216         moSmControlV1.iResult = aResult;
       
  9217         // set alpha id
       
  9218         moSmControlV1.iAlphaId.iAlphaId.Append( aAlphaId );
       
  9219         //Complete notification
       
  9220         CompleteRequest( KErrNone );
       
  9221         }
       
  9222     }
       
  9223 
       
  9224 // -----------------------------------------------------------------------------
       
  9225 // CSatNotifyMoSmControlRequest::Notify
       
  9226 // An ETel SAT client can call this method via ETel server to set a pending
       
  9227 // request in SimAtkTsy for a MoSmControlRequest PCmd.
       
  9228 // (other items were commented in a header).
       
  9229 // -----------------------------------------------------------------------------
       
  9230 //
       
  9231 void CSatNotifyMoSmControlRequest::Notify
       
  9232         (
       
  9233         const TTsyReqHandle aReqHandle, // Request handle
       
  9234         TDes8*              aDataPtr    // Pointer to data
       
  9235         )
       
  9236     {
       
  9237     OstTrace0( TRACE_NORMAL, CSATNOTIFYMOSMCONTROLREQUEST_NOTIFY, "CSatNotifyMoSmControlRequest::Notify" );
       
  9238     TFLOGSTRING("CSatNotifyMoSmControlRequest::Notify");
       
  9239     iReqHandle = aReqHandle;
       
  9240     iMoSmControlV1Pckg = static_cast< RSat::TMoSmControlV1Pckg* >( aDataPtr );
       
  9241     }
       
  9242 
       
  9243 //  End of File