|
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 class is a handle to server-side landmark name index |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef RPOSLMLOCALNAMEINDEX_H |
|
21 #define RPOSLMLOCALNAMEINDEX_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <EPos_Landmarks.h> |
|
25 |
|
26 class CPosLandmark; |
|
27 class RPosLmLocalSubsession; |
|
28 class RPosLmLocalAccessSubsession; |
|
29 |
|
30 /** |
|
31 * This class is a handle to server-side landmark name index |
|
32 * |
|
33 * @lib eposlmlocalaccess.lib |
|
34 * @since S60 3.2 |
|
35 */ |
|
36 class RPosLmLocalNameIndex |
|
37 { |
|
38 public: |
|
39 |
|
40 class CIndexItem : public CBase |
|
41 { |
|
42 public: |
|
43 CIndexItem(); |
|
44 ~CIndexItem(); |
|
45 |
|
46 static CIndexItem* NewL( TPosLmItemId aId, const TDesC& aName ); |
|
47 static CIndexItem* NewL( RReadStream& aStream ); |
|
48 |
|
49 inline TPosLmItemId Id() const; |
|
50 inline TPtrC Name() const; |
|
51 |
|
52 private: |
|
53 TPosLmItemId iId; |
|
54 HBufC* iName; |
|
55 }; |
|
56 |
|
57 public: |
|
58 |
|
59 /** |
|
60 * C++ default constructor. |
|
61 * @param[in] aSession Parent session to server. |
|
62 */ |
|
63 RPosLmLocalNameIndex( RPosLmLocalAccessSubsession& aSession ); |
|
64 |
|
65 /** |
|
66 * Creates a local access subsession with the Landmarks Server. |
|
67 * |
|
68 * @return @p KErrNone if successful, otherwise one of the system-wide |
|
69 * error codes. |
|
70 */ |
|
71 TInt Open(); |
|
72 |
|
73 /** |
|
74 * Closes the subsession. |
|
75 */ |
|
76 void Close(); |
|
77 |
|
78 /** Returns amount of items in the index */ |
|
79 IMPORT_C TInt Count() const; |
|
80 |
|
81 /** Returns amount of items in the index */ |
|
82 IMPORT_C TInt Status() const; |
|
83 |
|
84 /** Reads part of sorted landmark ids from server's index |
|
85 * @param[out] aIdArray Target buffer for landmarks IDs |
|
86 * @param[in] aFirst index of first ID to read |
|
87 * @param[in] aCount amount of IDs to read (size of aIdArray buffer) |
|
88 * @param[out] aRemainder On completion contains number of IDs left |
|
89 * in the index |
|
90 * @return If negative - error code, otherwise - number of actual |
|
91 * IDs read to aIdArray. 0 means that no more IDs available */ |
|
92 IMPORT_C TInt ReadSortedIds( |
|
93 TPosLmItemId* aIdArray, |
|
94 TInt aFirst, |
|
95 TInt aCount, |
|
96 TInt& aRemainder ); |
|
97 |
|
98 /** Reads part of sorted landmarks from server's index. |
|
99 * Upon completion target array aArray will contain |
|
100 * partial landmark data: ID and Name. |
|
101 * @param[in] aFirst index of first landmark to read |
|
102 * @param[in] aCount amount of landmarks to read |
|
103 * @param[out] aArray Target buffer for landmarks |
|
104 * @param[out] aRemainder On completion contains number of landmarks left |
|
105 * in the index */ |
|
106 IMPORT_C void ReadSortedLandmarksL( |
|
107 TInt aFirst, |
|
108 TInt aCount, |
|
109 RPointerArray<CIndexItem>& aArray, |
|
110 TInt& aRemainder ); |
|
111 |
|
112 /** Starts transaction on server-side landmark name index. |
|
113 * Only used for modifications */ |
|
114 TInt BeginTransaction(); |
|
115 |
|
116 /** Commits transaction on server-side landmark name index */ |
|
117 TInt CommitTransaction(); |
|
118 |
|
119 /** Cancels transaction on server-side landmark name index */ |
|
120 TInt RollbackTransaction(); |
|
121 |
|
122 /** Informs server about newly added landmark |
|
123 * @param aLandmark Landmark data */ |
|
124 void AddL( const CPosLandmark& aLandmark ); |
|
125 |
|
126 /** Informs server about newly added landmarks |
|
127 * @param aLandmarks List of landmarks */ |
|
128 void AddL( RPointerArray<CPosLandmark>& aLandmarks ); |
|
129 |
|
130 /** Informs server about modified landmark |
|
131 * @param aLandmark Landmark data */ |
|
132 void UpdateL( const CPosLandmark& aLandmark ); |
|
133 |
|
134 /** Informs server about modified landmarks |
|
135 * @param aLandmarks List of landmarks */ |
|
136 void UpdateL( RPointerArray<CPosLandmark>& aLandmarks ); |
|
137 |
|
138 /** Informs server about removed landmark |
|
139 * @param aLmid ID of the landmark */ |
|
140 void RemoveL( TPosLmItemId aLmid ); |
|
141 |
|
142 /** Informs server about removed landmarks |
|
143 * @param aLmids List of landmark IDs */ |
|
144 void RemoveL( RArray<TPosLmItemId>& aLmids ); |
|
145 |
|
146 protected: |
|
147 |
|
148 /** Packs landmark IDs and Names and sends to server |
|
149 * @param aFunction IPC function, which is to handle the message |
|
150 * @param aLandmarks List of landmarks */ |
|
151 void SendLandmarkDataL( |
|
152 TInt aFunction, |
|
153 RPointerArray<CPosLandmark>& aLandmarks ); |
|
154 |
|
155 /** Returns size of basic landmark data in the array |
|
156 * size of total count + size of ID, name and name length per |
|
157 * each landmark */ |
|
158 TInt CalculateLandmarkBasicDataSize( |
|
159 RPointerArray<CPosLandmark>& aLandmarks ); |
|
160 |
|
161 private: |
|
162 |
|
163 // By default, prohibit copy constructor |
|
164 RPosLmLocalNameIndex( const RPosLmLocalNameIndex& ); |
|
165 // Prohibit assigment operator |
|
166 RPosLmLocalNameIndex& operator=( const RPosLmLocalNameIndex& ); |
|
167 |
|
168 private: // Data |
|
169 |
|
170 RPosLmLocalAccessSubsession& iSession; |
|
171 HBufC8* iBuffer; |
|
172 }; |
|
173 |
|
174 #include "epos_rposlmlocalnameindex.inl" |
|
175 |
|
176 #endif // RPOSLMLOCALNAMEINDEX_H |
|
177 |
|
178 |