phonebookengines/contactsmodel/cntsrv/inc/CntSpeedDials.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CNTSERVERSPEEDDIALS_H__
       
    17 #define __CNTSERVERSPEEDDIALS_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <cntdef.h>
       
    21 
       
    22 const TUid KUidCntSpeedDialStream = { 0x10009EF7 };
       
    23 
       
    24 class CDictionaryFileStore;
       
    25 class CCntServerSpeedDialTable;
       
    26 
       
    27 /** Manages a collection of speed-dial tables. */
       
    28 class CCntServerSpeedDialManager : public CBase
       
    29 	{
       
    30 public:
       
    31 	CCntServerSpeedDialManager();
       
    32 	~CCntServerSpeedDialManager();
       
    33 	CCntServerSpeedDialTable& TableL(const TDesC& aDatabase);
       
    34 	TBool DeleteTable(const TDesC& aDatabase);
       
    35 
       
    36 	void StoreL(CDictionaryFileStore& aStore) const;
       
    37 	void RestoreL(CDictionaryFileStore& aStore);
       
    38 	static TUid SpeedDialFieldUidFromSpeedDialPosition(TInt aSpeedDialPosition);
       
    39 private: 
       
    40 	RPointerArray<CCntServerSpeedDialTable> iSpeedDials;
       
    41 	};
       
    42 
       
    43 
       
    44 /** A speed-dial table. */
       
    45 class CCntServerSpeedDialTable : public CBase
       
    46 	{
       
    47 public:
       
    48 	static CCntServerSpeedDialTable* NewL(const TDesC& aDatabase);
       
    49 	~CCntServerSpeedDialTable();
       
    50 	inline const TDesC& Database() const;
       
    51 	TContactItemId SpeedDialContactItem(TInt aIndex, TDes& aPhoneNumber) const;
       
    52 	CArrayFix<TInt>* SpeedDialIndicesForContactIdLC(TContactItemId aContactId);
       
    53 	void SetSpeedDialL(TInt aIndex, TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber);
       
    54 		
       
    55 	void InternalizeL(RReadStream& aStream);
       
    56 	void ExternalizeL(RWriteStream& aStream) const;
       
    57 private:
       
    58 	CCntServerSpeedDialTable();
       
    59 	void ConstructL(const TDesC& aDatabase);
       
    60 private: 
       
    61 	/** An individual speed-dial entry. */
       
    62 	class CSpeedDial : public CBase
       
    63 		{
       
    64 	public:
       
    65 		CSpeedDial();
       
    66 		static CSpeedDial* NewL(TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber);
       
    67 		~CSpeedDial();
       
    68 		inline TContactItemId ContactId() const;
       
    69 		void PhoneNumber(TSpeedDialPhoneNumber& aSpeedNumber) const;
       
    70 		void InternalizeL(RReadStream& aStream);
       
    71 		void ExternalizeL(RWriteStream& aStream) const;
       
    72 		void Reset();
       
    73 		void SetL(TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber);
       
    74 	private: 
       
    75 		CSpeedDial(TContactItemId aContactId, const TSpeedDialPhoneNumber& aPhoneNumber);
       
    76 		void ConstructL();
       
    77 	private: 
       
    78 		TContactItemId iContactId;
       
    79 		HBufC* iPhoneNumber;
       
    80 		};
       
    81 private:
       
    82 	TFixedArray<CSpeedDial,KCntMaxSpeedDialIndex> iSpeedDialTable;
       
    83 	HBufC* iDatabaseFile;
       
    84 	};
       
    85 
       
    86 
       
    87 inline const TDesC& CCntServerSpeedDialTable::Database() const { return *iDatabaseFile; }
       
    88 inline TContactItemId CCntServerSpeedDialTable::CSpeedDial::ContactId() const { return iContactId; }
       
    89 
       
    90 
       
    91 
       
    92 #endif