mobilemessaging/smum/src/MsgSimSCNumberDetectorCDMA.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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 "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 *     An active object class which takes care of reading the possible new
       
    16 *     service centres from SIM and adds them to pda-side Sms Settings.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include "MsgSimSCNumberDetector.h"
       
    24 #include "SmumLogging.h"
       
    25 #include "smsui.pan"    // for panics
       
    26 #include <FeatMgr.h>                    // FeatureManager
       
    27 #include <bldvariant.hrh>
       
    28 
       
    29 // ================= MEMBER FUNCTIONS =======================
       
    30 
       
    31 /*
       
    32 * Symbian OS 2 phase construction and initialization. Note that operation that is returned is already active.
       
    33 * A client will be notified via aClientStatus when the operation terminates.
       
    34 */
       
    35 EXPORT_C CMsgSimOperation* CMsgSimOperation::NewL( TRequestStatus& aClientStatus )
       
    36     {
       
    37     SMUMLOGGER_ENTERFN("CMsgSimOperation::NewL")
       
    38 
       
    39     CMsgSimOperation* self = new ( ELeave ) CMsgSimOperation( aClientStatus );
       
    40     CleanupStack::PushL( self );
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop( self );
       
    43     SMUMLOGGER_LEAVEFN("CMsgSimOperation::NewL")
       
    44 
       
    45     return self;
       
    46     }
       
    47 
       
    48 // C++ constructor which initializes the active object with a default priority and adds it to the active scheduler.
       
    49 // C++ constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 CMsgSimOperation::CMsgSimOperation( TRequestStatus& aStatus, TInt aPriority )
       
    52 : CActive( aPriority ), iClientStatus( &aStatus ), iRetryCount( 0 )
       
    53     {
       
    54     SMUMLOGGER_ENTERFN("CMsgSimOperation::CMsgSimOperation")
       
    55 
       
    56     SMUMLOGGER_LEAVEFN("CMsgSimOperation::CMsgSimOperation")
       
    57     }
       
    58 
       
    59 // Symbian OS default constructor can leave.
       
    60 void CMsgSimOperation::ConstructL()
       
    61     {
       
    62     SMUMLOGGER_ENTERFN("CMsgSimOperation::ConstructL")
       
    63 /*    
       
    64 	RSystemAgent sysAgent;
       
    65 	if( sysAgent.Connect() == KErrNone )
       
    66 		{
       
    67 		if ( sysAgent.GetState(KUidSimCStatus) == ESACSimNotSupported )
       
    68 			{
       
    69 			// Sim Card not supported
       
    70 			// Complete the Active Object request returning that this is not supported.
       
    71 			// Since we cannot insert a sim card when the device is operating, 
       
    72 			// the Flag cannot change, the request is just completed without doing anything
       
    73 			//
       
    74 			CompleteRequest(KErrNotSupported);
       
    75 			}
       
    76 		else
       
    77 			{
       
    78 			CompleteRequest(KErrNone);
       
    79 			}
       
    80 		sysAgent.Close();
       
    81 		}
       
    82 	// Default not supported
       
    83 	// 
       
    84 	else
       
    85 		{
       
    86 		CompleteRequest(KErrNotSupported);
       
    87 		}
       
    88 */
       
    89     SMUMLOGGER_LEAVEFN("CMsgSimOperation::ConstructL")
       
    90     }
       
    91 
       
    92 // C++ virtual destructor
       
    93 CMsgSimOperation::~CMsgSimOperation()
       
    94     {
       
    95     SMUMLOGGER_ENTERFN("CMsgSimOperation::~CMsgSimOperation")
       
    96 
       
    97     Cancel(); // make sure that this object is not left on the active scheduler.
       
    98     iClientStatus = NULL;
       
    99     
       
   100     SMUMLOGGER_LEAVEFN("CMsgSimOperation::~CMsgSimOperation")
       
   101     }
       
   102 
       
   103 // ----------------------------------------------------
       
   104 // CMsgSimOperation::StartL
       
   105 // This function issues request and activates the object
       
   106 //
       
   107 // ----------------------------------------------------
       
   108 void CMsgSimOperation::StartL()
       
   109     {
       
   110     SMUMLOGGER_ENTERFN("CMsgSimOperation::StartL")
       
   111 
       
   112 
       
   113     SMUMLOGGER_LEAVEFN("CMsgSimOperation::StartL")
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------
       
   117 // CMsgSimOperation::CompleteRequest
       
   118 //
       
   119 // ----------------------------------------------------
       
   120 void CMsgSimOperation::CompleteRequest( TInt aValue )
       
   121     {
       
   122     SMUMLOGGER_ENTERFN("CMsgSimOperation::CompleteRequest")
       
   123     
       
   124     __ASSERT_DEBUG( !IsActive(), Panic( ESimOperationPanicRequestAlreadyActive ));
       
   125     TRequestStatus* myRequestStatus = &iStatus;
       
   126     User::RequestComplete( myRequestStatus, aValue );
       
   127     if( !IsActive() )
       
   128         {
       
   129         SetActive();
       
   130         }
       
   131 
       
   132     SMUMLOGGER_LEAVEFN("CMsgSimOperation::CompleteRequest")
       
   133     }
       
   134 
       
   135 // ----------------------------------------------------
       
   136 // CMsgSimOperation::CompleteClientRequest
       
   137 //
       
   138 // ----------------------------------------------------
       
   139 void CMsgSimOperation::CompleteClientRequest( TInt aValue )
       
   140     {
       
   141     SMUMLOGGER_ENTERFN("CMsgSimOperation::CompleteClientRequest")
       
   142     
       
   143     TBool haveClientRequestStatus = HaveClientRequestStatus();
       
   144     __ASSERT_DEBUG( haveClientRequestStatus, Panic( ESimOperationPanicClientsRequestAlreadyCompleted ));
       
   145     // So that we don't attempt to complete the clients request again in the future
       
   146     if ( haveClientRequestStatus )
       
   147         {
       
   148         User::RequestComplete( iClientStatus, aValue );
       
   149         iClientStatus = NULL;
       
   150         }
       
   151 
       
   152     SMUMLOGGER_LEAVEFN("CMsgSimOperation::CompleteClientRequest")
       
   153     }
       
   154 
       
   155 // ----------------------------------------------------
       
   156 // CMsgSimOperation::HaveClientRequestStatus
       
   157 //
       
   158 // ----------------------------------------------------
       
   159 TBool CMsgSimOperation::HaveClientRequestStatus() const
       
   160     {
       
   161     SMUMLOGGER_WRITE("CMsgSimOperation::HaveClientRequestStatus")
       
   162     return (iClientStatus != NULL);
       
   163     }
       
   164 
       
   165 // ----------------------------------------------------
       
   166 // CMsgSimOperation::Panic
       
   167 //
       
   168 // ----------------------------------------------------
       
   169 void CMsgSimOperation::Panic(TSimOperationPanic aPanic)
       
   170     {
       
   171     SMUMLOGGER_ENTERFN("CMsgSimOperation::Panic")
       
   172 
       
   173     _LIT(KSimOpPanicCategory, "SIMOP");
       
   174     SMUMLOGGER_WRITE_FORMAT("Panic - Panic :%d", aPanic)
       
   175     User::Panic(KSimOpPanicCategory, aPanic);
       
   176     
       
   177     SMUMLOGGER_LEAVEFN("CMsgSimOperation::Panic")
       
   178     }
       
   179 
       
   180 // ----------------------------------------------------
       
   181 // CMsgSimOperation::RunL
       
   182 // Active object RunL method is called when the request (sim params reading operation) has been completed
       
   183 //
       
   184 // ----------------------------------------------------
       
   185 void CMsgSimOperation::RunL()
       
   186     {
       
   187     SMUMLOGGER_ENTERFN("CMsgSimOperation::RunL")
       
   188 
       
   189     TInt error = iStatus.Int();
       
   190     SMUMLOGGER_WRITE_FORMAT("RunL - 1st error check :%d", error)
       
   191 
       
   192 	if ( error == KErrNotSupported)
       
   193 		{
       
   194 		// Sim Card Not Supported in the platform
       
   195 		// Should be KErrNotSupported if constructL fails!
       
   196 		//
       
   197 		CompleteClientRequest(error);
       
   198 		}
       
   199     
       
   200     SMUMLOGGER_LEAVEFN("CMsgSimOperation::RunL")
       
   201     }
       
   202 
       
   203 // ----------------------------------------------------
       
   204 // CCMsgSimOperation::DoRunL
       
   205 //
       
   206 // ----------------------------------------------------
       
   207 void CMsgSimOperation::DoRunL()
       
   208     {
       
   209     SMUMLOGGER_ENTERFN("CMsgSimOperation::DoRunL")
       
   210 
       
   211     SMUMLOGGER_LEAVEFN("CMsgSimOperation::DoRunL")
       
   212     }
       
   213 
       
   214 // ----------------------------------------------------
       
   215 // CMsgSimOperation::RunError
       
   216 // Called when AO RunL leaves. Handle the leave and return
       
   217 //
       
   218 // ----------------------------------------------------
       
   219  
       
   220 TInt CMsgSimOperation::RunError( TInt )
       
   221     {
       
   222     SMUMLOGGER_ENTERFN("CMsgSimOperation::RunError")
       
   223     DoCancel();
       
   224     SMUMLOGGER_LEAVEFN("CMsgSimOperation::RunError")
       
   225     return KErrNone;
       
   226     }
       
   227 
       
   228 // ----------------------------------------------------
       
   229 // CMsgSimOperation::DoCancel
       
   230 // called by active object's Cancel method
       
   231 //
       
   232 // ----------------------------------------------------
       
   233 void CMsgSimOperation::DoCancel()
       
   234     {
       
   235     SMUMLOGGER_ENTERFN("CMsgSimOperation::DoCancel")
       
   236 
       
   237     if ( iSimOperation )  // if the real Sim reading operation was started:
       
   238         {
       
   239         iSimOperation->Cancel();    // cancel it
       
   240         }
       
   241 
       
   242     // We don't need to complete our own request status as this function will never
       
   243     // be called if our own request status has already been completed previously.
       
   244     // 
       
   245     // We do need to complete the client's request status however.
       
   246     if  (iClientStatus)
       
   247         {
       
   248         CompleteClientRequest(KErrCancel);
       
   249         }
       
   250 
       
   251     SMUMLOGGER_LEAVEFN("CMsgSimOperation::DoCancel")
       
   252     }
       
   253 
       
   254 
       
   255 // ----------------------------------------------------
       
   256 // CMsgSimOperation::HandleSessionEventL
       
   257 // called when there is a Msv session event. 
       
   258 //
       
   259 // ----------------------------------------------------
       
   260 void CMsgSimOperation::HandleSessionEventL(
       
   261     TMsvSessionEvent /*aEvent*/, 
       
   262     TAny* /*aArg1*/, 
       
   263     TAny* /*aArg2*/, 
       
   264     TAny* /*aArg3*/) 
       
   265     {
       
   266     SMUMLOGGER_ENTERFN("CMsgSimOperation::HandleSessionEventL")
       
   267 
       
   268     SMUMLOGGER_LEAVEFN("CMsgSimOperation::HandleSessionEventL")
       
   269     }
       
   270 
       
   271 // ----------------------------------------------------
       
   272 // CMsgSimOperation::HandleStartupReadyL
       
   273 // Handles events from startup state observer
       
   274 // 
       
   275 // ----------------------------------------------------
       
   276 //
       
   277 void CMsgSimOperation::HandleStartupReadyL()
       
   278     {
       
   279 	SMUMLOGGER_WRITE( "BootState Ready" )
       
   280 	// Boot ready, start the real SimOperation
       
   281 	StartL();
       
   282     }
       
   283 
       
   284 //  End of File