adaptationlayer/tsy/nokiatsy_dll/inc/cmmphonebookstoreoperationbase.h
changeset 8 6295dc2169f3
parent 7 fa67e03b87df
equal deleted inserted replaced
7:fa67e03b87df 8:6295dc2169f3
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    23 #include "cmmstaticutility.h"
    23 #include "cmmstaticutility.h"
    24 #include <ctsy/serviceapi/cmmgsmphonestorageutility.h>
    24 #include <ctsy/serviceapi/cmmgsmphonestorageutility.h>
    25 #include <badesca.h>    //for arrays
    25 #include <badesca.h>    //for arrays
    26 #include <e32base.h>
    26 #include <e32base.h>
    27 
    27 
    28 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    29 #include <ctsy/rmmcustomapi.h>
       
    30 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    31 
       
    32 #include "cmmphonetsender.h"
    28 #include "cmmphonetsender.h"
    33 #include "cmmphonetreceiver.h"
    29 #include "cmmphonetreceiver.h"
    34 #include "cmmphonebookstoremesshandler.h"
    30 #include "cmmphonebookstoremesshandler.h"
    35 
    31 
    36 
    32 
    48 const TUint8 KLengthWithOutSFI = 2;
    44 const TUint8 KLengthWithOutSFI = 2;
    49 
    45 
    50 _LIT(KInternalPhoneBookType,"Init");
    46 _LIT(KInternalPhoneBookType,"Init");
    51 
    47 
    52 const TUint8 KPadding = 0;
    48 const TUint8 KPadding = 0;
    53 
       
    54 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    55 const TUint8 SIM_AAS  = 0x10;
       
    56 const TUint8 SIM_GAS  = 0x11;
       
    57 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    58 
    49 
    59 // Mask that is used to separate phonebooktype from transaction Id
    50 // Mask that is used to separate phonebooktype from transaction Id
    60 const TUint8 KMaskPhonebookType = 0xF0;
    51 const TUint8 KMaskPhonebookType = 0xF0;
    61 
    52 
    62 // Mask that is used to separate operation from transaction Id
    53 // Mask that is used to separate operation from transaction Id
    67 const TUint8 KMaskFdnType = 0x20;       //0010 0000 = FDN
    58 const TUint8 KMaskFdnType = 0x20;       //0010 0000 = FDN
    68 const TUint8 KMaskSdnType = 0x30;       //0011 0000 = SDN
    59 const TUint8 KMaskSdnType = 0x30;       //0011 0000 = SDN
    69 const TUint8 KMaskBdnType = 0x40;       //0100 0000 = BDN
    60 const TUint8 KMaskBdnType = 0x40;       //0100 0000 = BDN
    70 const TUint8 KMaskMbdnType = 0x50;      //0101 0000 = MBDN
    61 const TUint8 KMaskMbdnType = 0x50;      //0101 0000 = MBDN
    71 const TUint8 KMaskVoiceMailBox = 0x60;  //0110 0000 = VMBX
    62 const TUint8 KMaskVoiceMailBox = 0x60;  //0110 0000 = VMBX
    72 
       
    73 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    74 const TUint8 KMaskAasType = 0x70; //0111 0000 = Additional Alpha String
       
    75 const TUint8 KMaskGasType = 0x80;     //1000 0000 = Group Alpha String
       
    76 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
    77 
    63 
    78 //const TUint8 KMaskFreeType = 0x09;  //1001 0000 = Free
    64 //const TUint8 KMaskFreeType = 0x09;  //1001 0000 = Free
    79 //const TUint8 KMaskFreeType = 0xA0;  //1010 0000 = Free
    65 //const TUint8 KMaskFreeType = 0xA0;  //1010 0000 = Free
    80 //const TUint8 KMaskFreeType = 0xB0;  //1011 0000 = Free
    66 //const TUint8 KMaskFreeType = 0xB0;  //1011 0000 = Free
    81 //const TUint8 KMaskFreeType = 0xC0;  //1100 0000 = Free
    67 //const TUint8 KMaskFreeType = 0xC0;  //1100 0000 = Free
   119 const TUint8 KRecordLength   = 0;
   105 const TUint8 KRecordLength   = 0;
   120 const TUint8 KNoOfRecords    = 1;
   106 const TUint8 KNoOfRecords    = 1;
   121 const TUint8 KFileSize1       = 2;
   107 const TUint8 KFileSize1       = 2;
   122 const TUint8 KFileIdentifier1 = 3;
   108 const TUint8 KFileIdentifier1 = 3;
   123 const TUint8 KFileStatus1     = 4;
   109 const TUint8 KFileStatus1     = 4;
       
   110 const TUint8 KStartRecord = 1; // Record numbering starts from 1
   124 
   111 
   125 const TUint8 KAdditionalData  = 0x02;
   112 const TUint8 KAdditionalData  = 0x02;
   126 const TUint8 KExtRecordSize  = 13;
   113 const TUint8 KExtRecordSize  = 13;
   127 const TUint8 KAdnMandatoryBytes = 13;
   114 const TUint8 KAdnMandatoryBytes = 13;
   128 const TUint8 KAnrExtRecIdOffset = 14;
   115 const TUint8 KAnrExtRecIdOffset = 14;
   129 const TUint8 KExtRecLenWithoutRecId = 12;
   116 const TUint8 KExtRecLenWithoutRecId = 12;
   130 const TUint8 KIapRecordsToBeSearched        = 0 ;     // constant to find unused bytes
   117 const TUint8 KIapRecordsToBeSearched        = 0 ;     // constant to find unused bytes
   131 const TUint8 KMaxNoOfRecInOneEf = 254;
   118 const TUint8 KMaxNoOfRecInOneEf = 254;
   132 
   119 
   133 
   120 const TUint8 KAdditionalNoType = 0x02;
   134 // UICC constants
   121 // UICC constants
   135 #define MF_FILE                             0x3F00 //Master file
   122 #define MF_FILE                             0x3F00 //Master file
   136 #define DF_CURRENT_APP                      0x7FFF //
   123 #define DF_CURRENT_APP                      0x7FFF //
   137 #define DF_PHONEBOOK                        0x5F3A
   124 #define DF_PHONEBOOK                        0x5F3A
   138 #define APPL_FILE_ID                        0x7F10  // Address for DFphonebook
   125 #define APPL_FILE_ID                        0x7F10  // Address for DFphonebook
   148 #define PB_MSISDN_FID                       0x6F40
   135 #define PB_MSISDN_FID                       0x6F40
   149 #define PB_VMBX_FID                         0x6F17
   136 #define PB_VMBX_FID                         0x6F17
   150 #define PB_EXT1_FID                         0x6F4A
   137 #define PB_EXT1_FID                         0x6F4A
   151 #define PB_EXT2_FID                         0x6F4B
   138 #define PB_EXT2_FID                         0x6F4B
   152 #define PB_EXT3_FID                         0x6F4C
   139 #define PB_EXT3_FID                         0x6F4C
   153 #define PB_EXT4_FID                         0x6F4E
   140 #define PB_EXT4_FID                         0x6F55
   154 #define PB_EXT5_FID                         0x6F55
   141 #define PB_EXT5_FID                         0x6F4E
   155 #define PB_EXT6_FID                         0x6FC8
   142 #define PB_EXT6_FID                         0x6FC8
   156 #define PB_EXT7_FID                         0x6FCC
   143 #define PB_EXT7_FID                         0x6FCC
   157 #define PB_PBR_FID                          0x4F30
   144 #define PB_PBR_FID                          0x4F30
   158 #define DF_PB_FILE_PATH                     0x3F007FFF5F3A
   145 #define DF_PB_FILE_PATH                     0x3F007FFF5F3A
   159 #define UICC_SFI_NOT_PRESENT                0x00
   146 #define UICC_SFI_NOT_PRESENT                0x00
   276 #define UICC_TYPE1_FILE                     1
   263 #define UICC_TYPE1_FILE                     1
   277 #define UICC_TYPE2_FILE                     2
   264 #define UICC_TYPE2_FILE                     2
   278 #define UICC_TYPE3_FILE                     3
   265 #define UICC_TYPE3_FILE                     3
   279 
   266 
   280 
   267 
       
   268 const TIapInfo iapinfo = { UICC_ILLEGAL_FILE_ID, 0x00, 0x00, 0x00};
       
   269 
   281 // end UICC constants
   270 // end UICC constants
   282 
   271 
   283 
   272 
   284 //  MACROS
   273 //  MACROS
   285     //none
   274     //none
   302     EPhonebookTypeUnknown
   291     EPhonebookTypeUnknown
   303     };
   292     };
   304 
   293 
   305 enum TTypeOfFileToBeRead
   294 enum TTypeOfFileToBeRead
   306     {
   295     {
       
   296     EStartRead,
   307     EBasicEfRead,
   297     EBasicEfRead,
   308     EExtensionRead,
   298     EExtensionRead,
   309     EMailboxIdRead
   299     EMailboxIdRead,
       
   300     EFileInfoRead,
       
   301     EBasicEfReadToGetUsedFileCount
   310     };
   302     };
   311 
   303 
   312 // Struct data
   304 // Struct data
   313 
   305 
   314 struct TPrimitiveTag
   306 struct TPrimitiveTag
   324 //  FORWARD DECLARATIONS
   316 //  FORWARD DECLARATIONS
   325 class CMmPhoneBookStoreExtInterface;
   317 class CMmPhoneBookStoreExtInterface;
   326 class CPhoneBookStoreEntry;
   318 class CPhoneBookStoreEntry;
   327 class CStorageInfoData;
   319 class CStorageInfoData;
   328 class CMmUiccMessHandler;
   320 class CMmUiccMessHandler;
   329 
       
   330 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   331     class CAlphaString;
       
   332 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   333 
   321 
   334 // CLASS DECLARATION
   322 // CLASS DECLARATION
   335 /**
   323 /**
   336 * CMmPhoneBookStoreOperationBase is base class for all operations
   324 * CMmPhoneBookStoreOperationBase is base class for all operations
   337 */
   325 */
   349         * Destructor.
   337         * Destructor.
   350         */
   338         */
   351         ~CMmPhoneBookStoreOperationBase();
   339         ~CMmPhoneBookStoreOperationBase();
   352 
   340 
   353         // Second phase constructor
   341         // Second phase constructor
   354         static CMmPhoneBookStoreOperationBase* NewL(CMmUiccMessHandler* aUiccMessHandler);
   342         static CMmPhoneBookStoreOperationBase* NewL(
       
   343                            CMmUiccMessHandler* aUiccMessHandler);
   355         /**
   344         /**
   356         * Basic implementation to handling request if operation not found.
   345         * Basic implementation to handling request if operation not found.
   357         *
   346         *
   358         * @param aIpc not  used
   347         * @param aIpc not  used
   359         * @param aDataPackage not used
   348         * @param aDataPackage not used
   369         * Cancels the operation.
   358         * Cancels the operation.
   370         */
   359         */
   371         virtual void CancelReq( TName& aPhoneBook );
   360         virtual void CancelReq( TName& aPhoneBook );
   372 
   361 
   373         /**
   362         /**
   374         * Prepares the operation (makes it ready to be launched).
       
   375         *
       
   376         * @param aIpc IPC request
       
   377         * @param aDataPackage parameters to prepare request with
       
   378         * @return TInt KErrNotReady on attempt to prepare prepared operation
       
   379         */
       
   380         virtual TInt PrepareReq( TInt aIpc, const CMmDataPackage* aDataPackage );
       
   381 
       
   382         /**
       
   383         * Checks if operation is ready to be launched.
       
   384         * Base implementation returns EFalse
       
   385         *
       
   386         * @return TBool ETrue - operation is ready to be launched
       
   387         */
       
   388         virtual TBool IsPrepared() const;
       
   389 
       
   390         /**
       
   391         * Launches activated operation.
       
   392         *
       
   393         * @return TInt KErrNotReady on attempt to launch not prepared operation;
       
   394         * or system-wide error code
       
   395         */
       
   396         virtual TInt LaunchReq();
       
   397 
       
   398         /**
       
   399         * Completes the request.
   363         * Completes the request.
   400         *
   364         *
   401         * @param aErrorCode error code to be completed with
   365         * @param aErrorCode error code to be completed with
   402         * @return TInt KErrNone or KErrNotSupported if operation is not prepared
   366         * @return TInt KErrNone or KErrNotSupported if operation is not prepared
   403         */
   367         */
   404         virtual TInt CompleteReq( TInt aErrorCode );
   368         virtual TInt CompleteReq( TInt aErrorCode );
   405 
       
   406         /**
       
   407         * Basic implementation to handling response if operation not found.
       
   408         *
       
   409         * @param aIsiMessage not used
       
   410         * @param aComplete not used
       
   411         * @return KErrNotSupported.
       
   412         */
       
   413         virtual TInt HandleSimPbRespL(
       
   414         const TIsiReceiveC& /*aIsiMessage*/, TBool& /*aComplete*/ )
       
   415             {TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::HandleSimPbResp - Return KErrNotSupported");
       
   416             return KErrNotSupported; };
       
   417 
       
   418 
   369 
   419         /**
   370         /**
   420         * Basic implementation to handling request if operation not found in UICC.
   371         * Basic implementation to handling request if operation not found in UICC.
   421         *
   372         *
   422         * @param aComplete not used
   373         * @param aComplete not used
   423         * @param aStatus not used
   374         * @param aStatus not used
   424         * @param aFileData KErrNotSupported
   375         * @param aFileData KErrNotSupported
   425         * @return KErrNotSupported.
   376         * @return KErrNotSupported.
   426         */
   377         */
   427 
   378 
   428         virtual TBool HandleUICCPbRespL( TInt /*aStatus*/, TUint8 /*aDetails*/, const TDesC8& /*aFileData*/, TInt /*aTransId*/)
   379         virtual TBool HandleUICCPbRespL(
   429             {TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::HandleUICCPbRespL - Return KErrNotSupported");
   380                         TInt /*aStatus*/,
       
   381                         TUint8 /*aDetails*/,
       
   382                         const TDesC8& /*aFileData*/,
       
   383                         TInt /*aTransId*/)
       
   384             {
       
   385             TFLOGSTRING("TSY: CMmPhoneBookStoreOperationBase::HandleUICCPbRespL - Return KErrNotSupported");
   430             return ETrue;
   386             return ETrue;
   431             };
   387             };
   432 
   388 
   433         /**
   389         /**
   434         * Basic implementation to handling request if operation not found in UICC.
   390         * Basic implementation to handling request if operation not found in UICC.
   460         * Converts client phonebook to phonebook mask.
   416         * Converts client phonebook to phonebook mask.
   461         *
   417         *
   462         * @param aPBType
   418         * @param aPBType
   463         * @return TUint8
   419         * @return TUint8
   464         */
   420         */
   465         static TUint16 ConvertToPBfileId( const TName& aPBType, TUint16& aFileIdExt,TUint8 aCardType );
   421         static TUint16 ConvertToPBfileId(
       
   422                        const TName& aPBType,
       
   423                        TUint16& aFileIdExt,
       
   424                        TUint8 aCardType );
   466 
   425 
   467 
   426 
   468         /**
   427         /**
   469         * Converts File ID to Index
   428         * Converts File ID to Index
   470         *
   429         *
   471         * @param aFileId
   430         * @param aFileId
   472         * @return TUint8
   431         * @return TUint8
   473         */
   432         */
   474         static TUint8 ConvertToConfArrayIndex( const TUint16 aFileId );
   433         static TUint8 ConvertToConfArrayIndex( const TUint16 aFileId );
   475         /**
   434         
   476         * Give return value for the transactio id According to operation and Phoenbook type
       
   477         *
       
   478         * @param aPBType
       
   479         * @param aOperation
       
   480         * @return TUint8
       
   481         */
       
   482         static TUint8 GetTransId( const TName& aPBType, const TUint8 aOperation );
       
   483 
       
   484 
       
   485         /**
   435         /**
   486         * Converts client phonebook to phonebook mask.
   436         * Converts client phonebook to phonebook mask.
   487         *
   437         *
   488         * @param aPBType
   438         * @param aPBType
   489         * @return TUint8
   439         * @return TUint8
   495         * Converts client phonebooktype to client phonebook name.
   445         * Converts client phonebooktype to client phonebook name.
   496         *
   446         *
   497         * @param aPBType
   447         * @param aPBType
   498         * @return TUint8
   448         * @return TUint8
   499         */
   449         */
   500         void ConvertPBTypeToPbName(const TUint aPhonebookType, TName& aName );
   450         void ConvertPBTypeToPbName(
       
   451                       const TUint aPhonebookType,
       
   452                       TName& aName );
   501 
   453 
   502         /**
   454         /**
   503         * Converts client phonebook to phonebook mask.
   455         * Converts client phonebook to phonebook mask.
   504         *
   456         *
   505         * @param aPBType
   457         * @param aPBType
   506         * @return TUint8
   458         * @return TUint8
   507         */
   459         */
   508         void ConvertToPBname( const TUint8 aTrans, TName& aName );
   460         void ConvertToPBname(
       
   461                      const TUint8 aTrans,
       
   462                      TName& aName );
   509 
   463 
   510         /**
   464         /**
   511         * Gets PhoneBookName.
   465         * Gets PhoneBookName.
   512         *
   466         *
   513         * @param None
   467         * @param None
   521         * @param aPbMask Phonebook mask
   475         * @param aPbMask Phonebook mask
   522         * @return Server phonebook type.
   476         * @return Server phonebook type.
   523         */
   477         */
   524         TUint16 ConvertToSimPhoneBookType(
   478         TUint16 ConvertToSimPhoneBookType(
   525             const TUint8 aPbMask );
   479             const TUint8 aPbMask );
   526 
       
   527         /**
       
   528         * Handle number to convert in Ascii Format
       
   529         * @param const TDesC8& aSource: Message to be converted in Ascii
       
   530         * @param TDes16 aTarget : After conversion data to be staored in
       
   531         */
       
   532         //void ConvertToUcs2FromBCD(const TDesC8 &aSource, TDes16 &aTarget );
       
   533 
   480 
   534         /**
   481         /**
   535         * Handle to Find the Empty Entry
   482         * Handle to Find the Empty Entry
   536         * @param const TDesC8& aFileData: Entry data to checked entry is empty or not
   483         * @param const TDesC8& aFileData: Entry data to checked entry is empty or not
   537         * @return TInt: KErrNone or KErrNotFound
   484         * @return TInt: KErrNone or KErrNotFound
   538         */
   485         */
   539         TInt EmptyEntryCheck( const TDesC8 &aFileData );
   486         TInt EmptyEntryCheck( const TDesC8 &aFileData );
   540 
   487 
   541         /**
   488         /**
   542         * Searches wanted file list from EFpbr  
   489         * Searches wanted file list from EFpbr
   543         * @param aFileData: data of EFpbr record
   490         * @param aFileData: data of EFpbr record
   544         * @param aTag: Tag for file list to be search
   491         * @param aTag: Tag for file list to be search
   545         * @param aFileList: parameter where file list is inserted
   492         * @param aFileList: parameter where file list is inserted
   546         * @return TInt: KErrNone or KErrNotFound
   493         * @return TInt: KErrNone or KErrNotFound
   547         */
   494         */
   548         TInt FetchFileListFromPBR( 
   495         TInt FetchFileListFromPBR(
   549             const TDesC8 &aFileData, 
   496             const TDesC8 &aFileData,
   550             const TUint8 aTag, 
   497             const TUint8 aTag,
   551             RArray <TPrimitiveTag>& aFileList );
   498             RArray <TPrimitiveTag>& aFileList );
   552 
   499 
   553     protected:
   500     protected:
   554 
   501 
   555 
   502 
   556 
   503 
   557     private:
   504     private:
   558 
   505 
   559         /**
       
   560         * Converts operation mask to IPC
       
   561         *
       
   562         * @param aDestination Operation mask
       
   563         * @param aSource Client IPC
       
   564         * @return None
       
   565         */
       
   566         void ConvertOperationToClientIPCType(
       
   567             TInt& aDestination,
       
   568             const TUint8 aSource );
       
   569 
       
   570 
       
   571         // ConstructL
   506         // ConstructL
   572 
   507 
   573         void ConstructL();
   508         void ConstructL();
   574         /**
       
   575         * Collects all needed data together.
       
   576         *
       
   577         * @param aSbStartOffSet Offset
       
   578         * @param aNumOfSubBlocks Number of subblocks
       
   579         * @param aIsiMessage ISI message
       
   580         * @param aEntry Phonebook entry
       
   581         * @param aEmailFound Flag indicate if email found or not
       
   582         * @param aAnrFound Flag indicate if anr found or not
       
   583         * @param aSneFound Flag indicate if sne found or not
       
   584         * @param aGrpFound Flag indicate if grp found or not
       
   585         * @return None
       
   586         */
       
   587         void CollectAvailableDataL(
       
   588             TUint& aSbStartOffSet,
       
   589             TInt& aNumOfSubBlocks,
       
   590             const TIsiReceiveC& aIsiMessage,
       
   591             CPhoneBookStoreEntry& aEntry,
       
   592             TBool& aEmailFound,
       
   593             TBool& aAnrFound,
       
   594             TBool& aSneFound
       
   595 #ifdef INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   596             ,TBool& aGrpFound
       
   597 #endif // INTERNAL_RD_USIM_PHONEBOOK_GAS_AND_AAS
       
   598             );
       
   599 
       
   600         /**
       
   601         * Construct a SIM_READ_FIELD_REQ message and send it through phonet.
       
   602         *
       
   603         * @param aTransId Transaction Id
       
   604         * @return KErrNone / Error value from phonet
       
   605         */
       
   606         TInt SimReadFieldReq( TUint8 aTransId );
       
   607 
       
   608         /**
       
   609         * Breaks received SIM_READ_FIELD_RESP ISI message
       
   610         *
       
   611         * @param aIsiMessage Received ISI message
       
   612         * @param aComplete Indicates if request can remove from
       
   613         *        operationlist or not.
       
   614         * @return None
       
   615         */
       
   616         void SimReadFieldRespL(
       
   617             const TIsiReceiveC& aIsiMessage,
       
   618             TBool& aComplete );
       
   619 
       
   620 
       
   621 
   509 
   622     public:     // Data
   510     public:     // Data
   623         // None
   511         // None
   624 
   512 
   625     protected:  // Data
   513     protected:  // Data
   646         //slot where SIM contact has been written.
   534         //slot where SIM contact has been written.
   647         TUint16 iWriteLocation;
   535         TUint16 iWriteLocation;
   648 
   536 
   649         // Attribute to hold the information what index to be read
   537         // Attribute to hold the information what index to be read
   650         TInt iIndexToRead;
   538         TInt iIndexToRead;
   651 
       
   652         // Is there any mailbox id
       
   653         TBool iMailboxIdExist;
       
   654 
   539 
   655         // Attribute to store record length
   540         // Attribute to store record length
   656         TInt iRecordLength;
   541         TInt iRecordLength;
   657 
   542 
   658         // Keeps track of error value if write completed only partially.
   543         // Keeps track of error value if write completed only partially.