|
1 /* |
|
2 * Copyright (c) 2007 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: This file defines class CIpsPlgMruList. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef IPSPLGMRULIST_H |
|
20 #define IPSPLGMRULIST_H |
|
21 |
|
22 |
|
23 const TUid KCRUidIpsSosMru = { 0x20010128 }; |
|
24 |
|
25 /** |
|
26 * Most recent used name and address store |
|
27 * |
|
28 * Reads and writes most recent used email addresses to central |
|
29 * repository. Central repository stores key - value -pairs. In this |
|
30 * case, first 16 bits of a key is used to identify mailbox and last 16 |
|
31 * bits makes key unique for name and address information. Example: |
|
32 * |
|
33 * Key Value |
|
34 * 0000 0000 <mailboxId1> : integer |
|
35 * 0000 0001 <1. name of mailboxid1> : descriptor |
|
36 * 0000 0002 <1. email addr of mailboxid1> : descriptor |
|
37 * 0000 0003 <2. name of mailboxid1> : descriptor |
|
38 * 0000 0004 <2. email addr of mailbodid1> : descriptor |
|
39 * .... .... |
|
40 * .... .... |
|
41 * 0001 0000 <mailboxId2> : integer |
|
42 * 0001 0001 <1. email addr of mailboxid2> : descriptor |
|
43 * 0001 0002 <1. email addr of mailboxid2> : descriptor |
|
44 * .... .... |
|
45 * .... .... |
|
46 * FFFF 0000 <mailboxIdFFFF+1> : integer |
|
47 * FFFF 0001 <1. email addr of mailboxIdNNNN> : descriptor |
|
48 * FFFF 0002 <1. email addr of mailboxIdNNNN> : descriptor |
|
49 * |
|
50 * @lib ipssosplugin.lib |
|
51 * @since |
|
52 */ |
|
53 class CIpsPlgMruList : public CBase |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 */ |
|
59 static CIpsPlgMruList* NewL( ); |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 virtual ~CIpsPlgMruList(); |
|
65 |
|
66 /** |
|
67 * Reads last used contacts from centrep and return |
|
68 * array of descriptors that contains data. Data is read |
|
69 * from cache if not changed in centrep. On error situation |
|
70 * return empty descriptor array. |
|
71 * |
|
72 * @param aMailbox unique mailbox id |
|
73 * @return descriptor array |
|
74 * @since FS 1.0 |
|
75 */ |
|
76 CDesCArrayFlat* GetMruListL( const TFSMailMsgId& aMailbox ); |
|
77 |
|
78 /** |
|
79 * Writes last used contacts to centrep. |
|
80 * On error all data consern mailbox is cleared from centrep |
|
81 * |
|
82 * @param aMailbox unique mailbox id |
|
83 * @param aNewMruList contact descriptor array |
|
84 * @since FS 1.0 |
|
85 */ |
|
86 void SetMruListL( const TFSMailMsgId& aMailBoxId, |
|
87 MDesCArray* aNewMruList ); |
|
88 |
|
89 /** |
|
90 * Cleares all data stored under mailbox id |
|
91 * |
|
92 * @param aMailbox unique mailbox id |
|
93 * @since FS 1.0 |
|
94 */ |
|
95 void ClearDataL( const TFSMailMsgId& aMailBoxId ); |
|
96 |
|
97 private: |
|
98 |
|
99 /** |
|
100 * Constructor |
|
101 */ |
|
102 CIpsPlgMruList( ); |
|
103 |
|
104 /** |
|
105 * Constructor for leaving methods |
|
106 */ |
|
107 void ConstructL( ); |
|
108 |
|
109 /** |
|
110 * Reads descriptor identified by aKey from centrep |
|
111 * |
|
112 * @param aKey centrep key for descriptor |
|
113 * @return KErrCorrupt or error from centrep transaction |
|
114 */ |
|
115 TInt StoreToArrayL(TUint32 aKey); |
|
116 |
|
117 /** |
|
118 * Read all mailbox keys from centrep to array |
|
119 * finds key that contains mailboxid |
|
120 * |
|
121 * @param aMboxId mailbox id key to be finded |
|
122 * @param aMboxKey correct key or invalid key if mailbox id not |
|
123 * founded from centrep |
|
124 * @param aArray array where all mailbox keys will be stored |
|
125 * @return KErrNone or KErrNotFound |
|
126 */ |
|
127 TInt GetMailboxKeyFromRepositoryL( |
|
128 TInt aMboxId, |
|
129 TUint32& aMboxKey, |
|
130 RArray<TUint32>& aArray ); |
|
131 |
|
132 /** |
|
133 * inline for creating iRepository, for performance reasons |
|
134 * not created in constructl |
|
135 */ |
|
136 inline static void CreateRepositoryL( CRepository*& aRep ); |
|
137 |
|
138 /** |
|
139 * Find smallest key that not founded in array |
|
140 * |
|
141 * @param aKeys set of keys which is sorted in fuction |
|
142 * @return unique key |
|
143 */ |
|
144 TUint32 GetUnusedMboxKey( RArray<TUint32>& aKeys ); |
|
145 |
|
146 /** |
|
147 * Find smallest key that not founded in array |
|
148 * |
|
149 * @param aMboxKey mailbox key which data error conserns |
|
150 * @param aError system wide error code |
|
151 */ |
|
152 void HandleRepositoryError( TUint32 aMboxKey, TInt aError ); |
|
153 |
|
154 private: // data |
|
155 |
|
156 // Mru list repository instance |
|
157 CRepository* iRepository; |
|
158 |
|
159 // array for repository data |
|
160 RPointerArray<HBufC> iHbufArray; |
|
161 |
|
162 // array for repository keys |
|
163 RArray<TUint32> iKeys; |
|
164 |
|
165 }; |
|
166 |
|
167 |
|
168 |
|
169 // inline for centrep object creation |
|
170 inline void CIpsPlgMruList::CreateRepositoryL( CRepository*& aRep ) |
|
171 { |
|
172 if ( !aRep ) |
|
173 { |
|
174 // real uid needed |
|
175 aRep = CRepository::NewL( KCRUidIpsSosMru ); |
|
176 } |
|
177 } |
|
178 |
|
179 #endif // IPSPLGMRULIST_H |
|
180 |
|
181 // End of file |