messagingapp/msgsettings/msginit/inc/simscnumberdetector.h
changeset 23 238255e8b033
child 46 b1f0785c289d
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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 Sms Settings.
       
    17  *
       
    18  */
       
    19 
       
    20 #ifndef __SIMSCNUMBERDETECTOR_H__
       
    21 #define __SIMSCNUMBERDETECTOR_H__
       
    22 
       
    23 //  INCLUDES
       
    24 #include <msvapi.h>     // for MsvSession
       
    25 #include <smsclnt.h>    // for CSmsClientMtm
       
    26 #include <e32base.h>
       
    27 #include <smutsimparam.h>   // for CSmsSimParamOperation
       
    28 
       
    29 // CONSTANTS
       
    30 const TInt KMaxNameLength = 60;
       
    31 const TInt KSmumGranularity = 4;
       
    32 const TInt KSmumRetryCount = 20;
       
    33 const TInt KSmumRetryDelay = 5000000; // 5 secs
       
    34 const TInt KSmumSMSPid = 50;
       
    35 const TInt KTestStringLength = 100;
       
    36 const TInt KDefDeliveryReport = 1;
       
    37 const TInt KDefValidityPeriod = 1440;
       
    38 const TInt KDefMessageConversion = 0;
       
    39 const TInt KDefPreferredConnection = 3;
       
    40 const TInt KDefReplyViaSameCentre = 0;
       
    41 
       
    42 // CONSTANTS
       
    43 _LIT( KSmsService,         "Sms Service" );
       
    44 _LIT( KSmscDefaultName,    "New service centre");
       
    45 _LIT( KSmscSimDefaultName, "New SIM service centre");
       
    46 _LIT( KFmtSpec,            "%S(%02d)");
       
    47 
       
    48 // FORWARD DECLARATIONS
       
    49 class CClientMtmRegistry;
       
    50 class CStartUpMonitor;
       
    51 class CRepository;
       
    52 
       
    53 /**
       
    54  * Observer to indicate when SIM operation has been completed.
       
    55  */
       
    56 class MSimOperationObserver
       
    57 {
       
    58 public:
       
    59     virtual void CompleteOperation()=0;
       
    60 };
       
    61 
       
    62 /**
       
    63  *  CMsgSimOperation
       
    64  *  Inherited from CBase, MMsvSessionObserver
       
    65  */
       
    66 class CMsgSimOperation : public CBase, public MMsvSessionObserver
       
    67 {
       
    68 public:
       
    69     
       
    70     /**
       
    71      * Constructor.
       
    72      */
       
    73     IMPORT_C static CMsgSimOperation* NewL(MSimOperationObserver& aObserver);
       
    74 
       
    75     /**
       
    76      * Destructor
       
    77      */
       
    78     ~CMsgSimOperation();
       
    79 
       
    80 public:
       
    81     
       
    82 
       
    83     /**
       
    84      * Callback function for startup state monitor object
       
    85      */
       
    86     void HandleStartupReadyL();
       
    87 
       
    88 private:
       
    89     
       
    90     /**
       
    91      * C++ constructor which initializes the active object with a 
       
    92      * default priority and adds it to the active scheduler.
       
    93      * @param TRequestStatus& aStatus, TInt aPriority
       
    94      * @return nothing
       
    95      */
       
    96     CMsgSimOperation(MSimOperationObserver& aObserver);
       
    97 
       
    98     /**
       
    99      * This function simulates issuing request, activates the object 
       
   100      * and starts to open Msv session
       
   101      * @param none
       
   102      * @return nothing
       
   103      */
       
   104     void StartL();
       
   105 
       
   106     /**
       
   107      * Complete the client's active object request status
       
   108      * @param TInt aValue
       
   109      * @return nothing
       
   110      */
       
   111     
       
   112     void CompleteClientRequest(TInt aValue);
       
   113     
       
   114     /**
       
   115      * Checks if the device has SIM when phone boots
       
   116      * @reutrn bool
       
   117      */  
       
   118     TBool IsSIMPresent();
       
   119 
       
   120     /**
       
   121      * Checks if the SIM has been changed in the next boot
       
   122      * @reutrn bool
       
   123      */
       
   124     TBool HasSIMChanged();
       
   125 
       
   126     /**
       
   127      * Checks if already SMSC setting is there
       
   128      * @reutrn bool
       
   129      */
       
   130     TBool HasNoSmscSettings();
       
   131     
       
   132     /**
       
   133      * Gets default name for SMSC, if SIM does not have one 
       
   134      */
       
   135     void FindNameForSCL(TDes& aName, TBool aNameIsForSCentreFromSIM,
       
   136                                CDesCArrayFlat* aSCNamesList);
       
   137 
       
   138     /**
       
   139      * Creates a SMS service, if not there
       
   140      */
       
   141     TMsvId CreateSmsServiceL();
       
   142     
       
   143     /**
       
   144      * Creates default settings for the SMS account
       
   145      */
       
   146     void CreateDefaultSettingsL(TMsvId aServiceId);
       
   147 
       
   148     /**
       
   149      * Reads default settings from the Cenrep
       
   150      */
       
   151     void ReadDefaultSettingsFromSharedDataL(CSmsSettings* aServiceSettings);
       
   152     
       
   153     /**
       
   154      * Gets the Service Id 
       
   155      */
       
   156     TMsvId ServiceIdL();
       
   157      
       
   158 private:
       
   159 
       
   160     /**
       
   161      *
       
   162      */
       
   163     enum TSimOperationPanic
       
   164     {
       
   165         ESimOperationPanicRequestAlreadyActive = 0,
       
   166         ESimOperationPanicClientsRequestAlreadyCompleted
       
   167     };
       
   168 
       
   169     /**
       
   170      * Panic the thread
       
   171      * @param TSimOperationPanic aPanic
       
   172      * @return nothing
       
   173      */
       
   174     static void Panic(TSimOperationPanic aPanic);
       
   175 
       
   176 private:
       
   177 
       
   178     void StartRunL(TInt aError);
       
   179     
       
   180     void DoStartRunL();
       
   181 
       
   182     /**
       
   183      * From MMsvSessionObserver 
       
   184      */
       
   185     void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2,
       
   186                              TAny* aArg3);
       
   187 
       
   188     /**
       
   189      * By default Symbian OS constructor is private.
       
   190      */
       
   191     void ConstructL();
       
   192 
       
   193 private:
       
   194     // Data
       
   195     CSmsSimParamOperation* iSimOperation;
       
   196     CMsvSession* iMsvSession;
       
   197     CSmsClientMtm* iSmsClientMtm;
       
   198     CClientMtmRegistry* iClientRegistry;
       
   199     TInt iRetryCount;
       
   200     CStartUpMonitor* iStartupMonitor;
       
   201     MSimOperationObserver& iObserver;
       
   202     CRepository* iCenRepSession;
       
   203 
       
   204 
       
   205 };
       
   206 
       
   207 #endif  // not defined __SIMSCNUMBERDETECTOR_H__
       
   208 // End of file