adaptationlayer/tsy/nokiatsy_dll/internal/test/nokiatsy_test_tool/sms/src/sms.cpp
changeset 0 63b37f68c1ce
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 
       
    22 // INCLUDE FILES
       
    23 #include <stiftestinterface.h>
       
    24 #include "sms.h"
       
    25 #if ( NCP_COMMON_S60_VERSION_SUPPORT == S60_VERSION_32 )
       
    26 #include <mmmmesshandlerbase.h>
       
    27 #endif
       
    28 
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CSMS::CSMS
       
    34 // C++ default constructor can NOT contain any code, that
       
    35 // might leave.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CSMS::CSMS(
       
    39     CTestModuleIf& aTestModuleIf ):
       
    40         CCore( aTestModuleIf ),
       
    41         iMsgAttribPckg( iMsgAttrib ),
       
    42         iSmsCapsPckg (iSmsCaps)
       
    43     {
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CSMS::ConstructL
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CSMS::ConstructL()
       
    52     {
       
    53 #if ( NCP_COMMON_S60_VERSION_SUPPORT == S60_VERSION_32 )
       
    54     BaseConstructL();
       
    55 #else
       
    56     BaseConstructL( this );
       
    57 #endif
       
    58     iSMSLog = CStifLogger::NewL( KSMSLogPath,
       
    59                           KSMSLogFile,
       
    60                           CStifLogger::ETxt,
       
    61                           CStifLogger::EFile,
       
    62                           EFalse );
       
    63 
       
    64     _LIT8(SMS, "SMS: ConstructL");
       
    65     iSMSLog->Log((TDesC8)SMS );
       
    66 
       
    67     iSMSMsgStorageRequestOngoing = EFalse;
       
    68     iSmsParameterCheck = EFalse;
       
    69     iTestCaseNumber = ETestCaseNotDefined;
       
    70 
       
    71     iSmspListArray = new ( ELeave ) CArrayPtrFlat<TSmsParameters>( 1 );
       
    72     InitializeIscControlL(KIscControlTestCaseFileSMS);
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CSMS::NewL
       
    77 // Two-phased constructor.
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CSMS* CSMS::NewL(
       
    81     CTestModuleIf& aTestModuleIf )
       
    82     {
       
    83     CSMS* self = new (ELeave) CSMS( aTestModuleIf );
       
    84 
       
    85     CleanupStack::PushL( (CScriptBase*)self );
       
    86     self->ConstructL();
       
    87     CleanupStack::Pop( self );
       
    88 
       
    89     return self;
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CSMS::~CSMS
       
    94 // Destructor.
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 CSMS::~CSMS()
       
    98     {
       
    99     // Delete resources allocated from test methods
       
   100     Delete();
       
   101     // Delete logger
       
   102     delete iSMSLog;
       
   103     }
       
   104 
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CCore::RouteCompletion
       
   108 // Completes a request or notification via the specific Tsy object, based on
       
   109 // IPC number and data package
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C void CSMS::RouteCompletion(
       
   113     TInt aIpc, //IPC value
       
   114     CMmDataPackage* aDataPackage,//pointer to DataPackage
       
   115     TInt aResult // Completion result
       
   116     )
       
   117     {
       
   118     _LIT8(KResult, "CSMS::RouteCompletion result: %d");
       
   119     iSMSLog->Log((TDesC8)KResult, aResult );
       
   120 
       
   121     if ( !iHandleSpecifiedRequests )
       
   122         {
       
   123         switch( aIpc )
       
   124             {
       
   125             case EMobileSmsMessagingSendMessage:
       
   126                 {
       
   127                 CompleteSendSMSMessage( aResult );
       
   128                 break;
       
   129                 }
       
   130             case EMobilePhoneStoreRead:
       
   131                 {
       
   132                 CompleteReadSMSMessage( aResult,aDataPackage );
       
   133                 break;
       
   134                 }
       
   135             case EMobilePhoneStoreDelete:
       
   136                 {
       
   137                 CompleteDeleteSMSMessage( aResult );
       
   138                 break;
       
   139                 }
       
   140             case EMobilePhoneStoreDeleteAll:
       
   141                 {
       
   142                 CompleteDeleteAllSMSMessages( aResult );
       
   143                 break;
       
   144                 }
       
   145             case EMobileSmsMessagingSetMoSmsBearer:
       
   146                 {
       
   147                 CompleteSetMoSmsBearer( aResult );
       
   148                 break;
       
   149                 }
       
   150             case EMobilePhoneStoreWrite:
       
   151                 {
       
   152                 CompleteWriteSMSMessage( aResult,aDataPackage );
       
   153                 break;
       
   154                 }
       
   155             case EMobileSmsMessagingReceiveMessage:
       
   156                 {
       
   157                 CompleteReceiveSMSMessage( aResult, aDataPackage );
       
   158                 break;
       
   159                 }
       
   160             case EMmTsyActivateSmsRouting:
       
   161                 {
       
   162                 CompleteActivateSMSRouting( aResult );
       
   163                 break;
       
   164                 }
       
   165             case EMobileSmsMessagingAckSmsStored :
       
   166                 {
       
   167                 CompleteAckSMS( aResult );
       
   168                 break;
       
   169                 }
       
   170             case EMmTsyDeactivateSmsRouting :
       
   171                 {
       
   172                 CompleteDeactivateSMSRouting( aResult );
       
   173                 break;
       
   174                 }
       
   175             case EMobileSmsMessagingResumeSmsReception :
       
   176                 {
       
   177                 CompleteResumeSMS ( aResult );
       
   178                 break;
       
   179                 }
       
   180             case EMobilePhoneStoreReadAllPhase1 :
       
   181                 {
       
   182                 CompleteReadAllSMSMessage ( aResult, aDataPackage );
       
   183                 break;
       
   184                 }
       
   185             case EMobileSmsMessagingNackSmsStored:
       
   186                 {
       
   187                 CompleteNackSMS( aResult );
       
   188                 break;
       
   189                 }
       
   190             case EMobileSmsMessagingGetMessageStoreInfo:
       
   191                 {
       
   192                 CompleteSIMMsgStorageInfo( aResult,aDataPackage );
       
   193                 break;
       
   194                 }
       
   195             case EMobileSmsMessagingGetSmspListPhase1:
       
   196                 {
       
   197                 CompleteReadSmsParameters( aResult, aDataPackage );
       
   198                 break;
       
   199                 }
       
   200             case EMobileSmsMessagingStoreSmspList:
       
   201                 {
       
   202                 CompleteStoreSmsParameters( aResult );
       
   203                 break;
       
   204                 }
       
   205             default:
       
   206                 break;
       
   207             }
       
   208         }
       
   209     else
       
   210         {
       
   211         TBool isIPCHandled = EFalse;
       
   212 
       
   213         switch(aIpc)
       
   214             {
       
   215             case EMobileSmsMessagingGetMessageStoreInfo:
       
   216                 {
       
   217                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   218                         ( _L( "EMobileSmsMessagingGetMessageStoreInfo" ) ) )
       
   219                     {
       
   220                     CompleteSIMMsgStorageInfo( aResult,aDataPackage );
       
   221                     CCore::GetNextExpectedCompleteIPC();
       
   222                     isIPCHandled = ETrue;
       
   223                     }
       
   224                 break;
       
   225                 }
       
   226             case EMmTsyBootNotifySimStatusReadyIPC:
       
   227                 {
       
   228                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   229                         ( _L( "EMmTsyBootNotifySimStatusReadyIPC" ) ) )
       
   230                     {
       
   231                     CompleteSMSCacheInitialization( aResult );
       
   232                     CCore::GetNextExpectedCompleteIPC();
       
   233                     isIPCHandled = ETrue;
       
   234                     }
       
   235                 break;
       
   236                 }
       
   237             case EMobilePhoneStoreGetInfo:
       
   238                 {
       
   239                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   240                         ( _L( "EMobilePhoneStoreGetInfo" ) ) )
       
   241                     {
       
   242                     CompleteMobilePhoneStoreGetInfo( aResult );
       
   243                     CCore::GetNextExpectedCompleteIPC();
       
   244                     isIPCHandled = ETrue;
       
   245                     }
       
   246                 break;
       
   247                 }
       
   248             case EMobilePhoneStoreWrite:
       
   249                 {
       
   250                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   251                         ( _L( "EMobilePhoneStoreWrite" ) ) )
       
   252                     {
       
   253                     CompleteWriteSMSMessage( aResult,aDataPackage );
       
   254                     CCore::GetNextExpectedCompleteIPC();
       
   255                     isIPCHandled = ETrue;
       
   256                     }
       
   257                 break;
       
   258                 }
       
   259             case EMmTsyActivateSmsRouting:
       
   260                 {
       
   261                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   262                         ( _L( "EMmTsyActivateSmsRouting" ) ) )
       
   263                     {
       
   264                     CompleteActivateSMSRouting( aResult, aDataPackage );
       
   265                     CCore::GetNextExpectedCompleteIPC();
       
   266                     isIPCHandled = ETrue;
       
   267                     }
       
   268                 break;
       
   269                 }
       
   270             case EMobileSmsMessagingReceiveMessage:
       
   271                 {
       
   272                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   273                         ( _L( "EMobileSmsMessagingReceiveMessage" ) ) )
       
   274                     {
       
   275                     CompleteReceiveSMSMessage( aResult, aDataPackage );
       
   276                     CCore::GetNextExpectedCompleteIPC();
       
   277                     isIPCHandled = ETrue;
       
   278                     }
       
   279                 break;
       
   280                 }
       
   281             case EMobileSmsMessagingAckSmsStored:
       
   282                 {
       
   283                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   284                         ( _L( "EMobileSmsMessagingAckSmsStored" ) ) )
       
   285                     {
       
   286                     CompleteAckSMS( aResult );
       
   287                     CCore::GetNextExpectedCompleteIPC();
       
   288                     isIPCHandled = ETrue;
       
   289                     }
       
   290                 break;
       
   291                 }
       
   292             case EMmTsyDeactivateSmsRouting:
       
   293                 {
       
   294                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   295                         ( _L( "EMmTsyDeactivateSmsRouting" ) ) )
       
   296                     {
       
   297                     CompleteDeactivateSMSRouting( aResult, aDataPackage );
       
   298                     CCore::GetNextExpectedCompleteIPC();
       
   299                     isIPCHandled = ETrue;
       
   300                     }
       
   301                 break;
       
   302                 }
       
   303             case EMobileSmsMessagingSendMessage:
       
   304             case EMmTsySmsSendSatMessage:
       
   305             case EMobileSmsMessagingSendMessageNoFdnCheck:
       
   306                 {
       
   307                 if ( ( 0 == iSavedIPCNameForComparison.Compare
       
   308                          ( _L( "EMobileSmsMessagingSendMessage" ) ) ) ||
       
   309                      ( 0 == iSavedIPCNameForComparison.Compare
       
   310                          ( _L( "EMmTsySmsSendSatMessage" ) ) ) ||
       
   311                      ( 0 == iSavedIPCNameForComparison.Compare
       
   312                          ( _L( "EMobileSmsMessagingSendMessageNoFdnCheck" ) ) ) )
       
   313                     {
       
   314                     // Check parameters from data package
       
   315                     if ( iSmsParameterCheck )
       
   316                         {
       
   317                         CompleteSendSMSMessage( aResult, aDataPackage );
       
   318                         iSmsParameterCheck = EFalse;
       
   319                         }
       
   320                     else
       
   321                         {
       
   322                         CompleteSendSMSMessage( aResult );
       
   323                         }
       
   324                     CCore::GetNextExpectedCompleteIPC();
       
   325                     isIPCHandled = ETrue;
       
   326                     }
       
   327                 break;
       
   328                 }
       
   329             case EMobileSmsMessagingGetSmspListPhase1:
       
   330                 {
       
   331                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   332                         ( _L( "EMobileSmsMessagingGetSmspListPhase1" ) ) )
       
   333                     {
       
   334                     CompleteReadSmsParameters( aResult, aDataPackage );
       
   335                     CCore::GetNextExpectedCompleteIPC();
       
   336                     isIPCHandled = ETrue;
       
   337                     }
       
   338                 break;
       
   339                 }
       
   340             case EMobilePhoneStoreReadAllPhase1:
       
   341                 {
       
   342                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   343                         ( _L( "EMobilePhoneStoreReadAllPhase1" ) ) )
       
   344                     {
       
   345                     CompleteReadAllSMSMessage ( aResult, aDataPackage );
       
   346                     CCore::GetNextExpectedCompleteIPC();
       
   347                     isIPCHandled = ETrue;
       
   348                     }
       
   349                 break;
       
   350                 }
       
   351             case EMobilePhoneStoreRead:
       
   352                 {
       
   353                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   354                         ( _L( "EMobilePhoneStoreRead" ) ) )
       
   355                     {
       
   356                     CompleteReadSMSMessage( aResult,aDataPackage );
       
   357                     CCore::GetNextExpectedCompleteIPC();
       
   358                     isIPCHandled = ETrue;
       
   359                     }
       
   360                 break;
       
   361                 }
       
   362             case EMobilePhoneStoreDelete:
       
   363                 {
       
   364                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   365                         ( _L( "EMobilePhoneStoreDelete" ) ) )
       
   366                     {
       
   367                     CompleteDeleteSMSMessage( aResult );
       
   368                     CCore::GetNextExpectedCompleteIPC();
       
   369                     isIPCHandled = ETrue;
       
   370                     }
       
   371                 break;
       
   372                 }
       
   373             case EMobilePhoneStoreDeleteAll:
       
   374                 {
       
   375                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   376                         ( _L( "EMobilePhoneStoreDeleteAll" ) ) )
       
   377                     {
       
   378                     CompleteDeleteAllSMSMessages( aResult );
       
   379                     CCore::GetNextExpectedCompleteIPC();
       
   380                     isIPCHandled = ETrue;
       
   381                     }
       
   382                 break;
       
   383                 }
       
   384             case EMobileSmsMessagingSetMoSmsBearer:
       
   385                 {
       
   386                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   387                         ( _L( "EMobileSmsMessagingSetMoSmsBearer" ) ) )
       
   388                     {
       
   389                     CompleteSetMoSmsBearer( aResult );
       
   390                     CCore::GetNextExpectedCompleteIPC();
       
   391                     isIPCHandled = ETrue;
       
   392                     }
       
   393                 break;
       
   394                 }
       
   395             case EMobileSmsMessagingStoreSmspList:
       
   396                 {
       
   397                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   398                         ( _L( "EMobileSmsMessagingStoreSmspList" ) ) )
       
   399                     {
       
   400                     CompleteStoreSmsParameters( aResult );
       
   401                     CCore::GetNextExpectedCompleteIPC();
       
   402                     isIPCHandled = ETrue;
       
   403                     }
       
   404                 break;
       
   405                 }
       
   406             case EMobileSmsMessagingNackSmsStored:
       
   407                 {
       
   408                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   409                         ( _L( "EMobileSmsMessagingNackSmsStored" ) ) )
       
   410                     {
       
   411                     CompleteNackSMS( aResult );
       
   412                     CCore::GetNextExpectedCompleteIPC();
       
   413                     isIPCHandled = ETrue;
       
   414                     }
       
   415                 break;
       
   416                 }
       
   417             case EMobileSmsMessagingResumeSmsReception:
       
   418                 {
       
   419                 if ( 0 == iSavedIPCNameForComparison.Compare
       
   420                         ( _L( "EMobileSmsMessagingResumeSmsReception" ) ) )
       
   421                     {
       
   422                     CompleteResumeSMS ( aResult );
       
   423                     CCore::GetNextExpectedCompleteIPC();
       
   424                     isIPCHandled = ETrue;
       
   425                     }
       
   426                 break;
       
   427                 }
       
   428             default:
       
   429                 {
       
   430                 break;
       
   431                 }
       
   432             }
       
   433         // Check whether the IPC received should had been exactly the expected one.
       
   434         // If not the KErrGeneral is set.
       
   435         if( ( iNextIPCMustBeSameAsNextExpected ) &&
       
   436             ( !isIPCHandled ) )
       
   437             {
       
   438             aResult = KErrUnknown;
       
   439             Signal( aResult );
       
   440             }
       
   441         }
       
   442     }
       
   443 
       
   444 
       
   445 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   446 
       
   447 // -----------------------------------------------------------------------------
       
   448 // LibEntryL is a polymorphic Dll entry point.
       
   449 // Returns: CScriptBase: New CScriptBase derived object
       
   450 // -----------------------------------------------------------------------------
       
   451 //
       
   452 EXPORT_C CScriptBase* LibEntryL(
       
   453     CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
       
   454     {
       
   455 
       
   456     return ( CScriptBase* ) CSMS::NewL( aTestModuleIf );
       
   457 
       
   458     }
       
   459 
       
   460 //  End of File