|
1 /* |
|
2 * Copyright (c) 2009 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: Array to store the CUpnpCdsLiteObject objects |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_UPNP_CDS_LITE_OBJECT_ARRAY_H |
|
19 #define C_UPNP_CDS_LITE_OBJECT_ARRAY_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class CUpnpCdsLiteObject; |
|
26 class CUpnpObject; |
|
27 |
|
28 /** |
|
29 * Defines the CUpnpCdsLiteObjectArray class. Used to store container/item |
|
30 * structure of the CDS. |
|
31 * |
|
32 * @lib upnpsharingalgorithm.lib |
|
33 * @since S60 5.2 |
|
34 */ |
|
35 class CUpnpCdsLiteObjectArray : public CBase |
|
36 { |
|
37 |
|
38 public: // Constructors and destructors |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. Leaves in case of out-of-memory. |
|
42 * |
|
43 * @since S60 5.2 |
|
44 * @return array of cdsliteobjects |
|
45 */ |
|
46 IMPORT_C static CUpnpCdsLiteObjectArray* NewL(); |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 * |
|
51 * @since S60 5.2 |
|
52 */ |
|
53 IMPORT_C virtual ~CUpnpCdsLiteObjectArray(); |
|
54 |
|
55 public: // Business logic methods |
|
56 |
|
57 /** |
|
58 * Adds one object to the array. Ownership of the object is transfered. |
|
59 * Leaves with KErrArgument if the given object is not valid. |
|
60 * |
|
61 * @since S60 5.2 |
|
62 * @param aObject, the object |
|
63 */ |
|
64 IMPORT_C void AppendL( CUpnpCdsLiteObject *aObject ); |
|
65 |
|
66 /** |
|
67 * Adds one object to the array. Leaves with KErrArgument if the given |
|
68 * object is not valid. |
|
69 * |
|
70 * @since S60 5.2 |
|
71 * @param aObject, the UPnPObject object |
|
72 */ |
|
73 IMPORT_C void AppendL( const CUpnpObject *aObject ); |
|
74 |
|
75 /** |
|
76 * Finds a CUpnpCdsLiteObject object from the array. Returns |
|
77 * KErrNotFound if object not found. |
|
78 * |
|
79 * @since S60 5.2 |
|
80 * @param aName, title of a container / filename |
|
81 * @return index of the array where the object resides |
|
82 */ |
|
83 IMPORT_C TInt FindByName( TDesC8& aName ); |
|
84 |
|
85 /** |
|
86 * Finds a CUpnpCdsLiteObject object with defined parent id |
|
87 * from the array. Returns KErrNotFound if object not found. |
|
88 * |
|
89 * @since S60 5.2 |
|
90 * @param aName, title of a container / filename |
|
91 * @param aParentId, parent id of a container / filename |
|
92 * @return index of the array where the object resides |
|
93 */ |
|
94 IMPORT_C TInt FindByNameAndParentId( const TDesC8& aName, |
|
95 const TDesC8& aParentId ); |
|
96 |
|
97 /** |
|
98 * Finds a CUpnpCdsLiteObject object that have defined media |
|
99 * class and parent id. Returns KErrNotFound if object not found. |
|
100 * |
|
101 * @since S60 5.2 |
|
102 * @param aMediaClass, class type of a container / filename |
|
103 * @param aParentId, parent id of a container / filename |
|
104 * @return index of the array where the object resides |
|
105 */ |
|
106 IMPORT_C TInt FindByMediaClassAndParentId( const TDesC8& aMediaClass, |
|
107 const TDesC8& aParentId ); |
|
108 |
|
109 /** |
|
110 * Finds a CUpnpCdsLiteObject object from the array. Returns |
|
111 * KErrNotFound if object not found. |
|
112 * |
|
113 * @since S60 5.2 |
|
114 * @param aObjectId, the object ID |
|
115 * @return index of the array where the object resides |
|
116 */ |
|
117 IMPORT_C TInt FindByObjectId( const TDesC8& aObjectId ); |
|
118 |
|
119 /** |
|
120 * Finds a CUpnpCdsLiteObject object index from the array using |
|
121 * original item's id as a search parameter. Returns KErrNotFound |
|
122 * if object not found. |
|
123 * Can leave with symbian error codes. |
|
124 * |
|
125 * @since S60 5.2 |
|
126 * @param aOriginalId, original item id |
|
127 * @return index of the array where the object resides |
|
128 */ |
|
129 IMPORT_C TInt FindRefItemIdByOriginalIdL( |
|
130 const TDesC8& aOriginalId ); |
|
131 |
|
132 /** |
|
133 * Returns the child count of a container |
|
134 * |
|
135 * @since S60 5.2 |
|
136 * @param aParentId, parent object id |
|
137 * @return child count |
|
138 */ |
|
139 IMPORT_C TInt ChildCount( const TDesC8& aParentId ); |
|
140 |
|
141 /** |
|
142 * Returns the object count of the array |
|
143 * |
|
144 * @since S60 5.2 |
|
145 * @return item count |
|
146 */ |
|
147 IMPORT_C TInt Count( ); |
|
148 |
|
149 /** |
|
150 * Returns an object from the array. Does not remove the object from |
|
151 * the array. Leaves with KErrArgument if the given index is out of |
|
152 * bounds. |
|
153 * |
|
154 * @since S60 5.2 |
|
155 * @param aIndex, index of the array |
|
156 * @return the object |
|
157 */ |
|
158 IMPORT_C CUpnpCdsLiteObject& ObjectAtL( TUint aIndex ); |
|
159 |
|
160 /** |
|
161 * Removes an object from the array. Leaves with KErrArgument if the |
|
162 * given index is out of bounds. |
|
163 * |
|
164 * @since S60 5.2 |
|
165 * @param aIndex, index of the array |
|
166 */ |
|
167 IMPORT_C void RemoveObjectAtL( TUint aIndex ); |
|
168 |
|
169 /** |
|
170 * Searches the array looking for the matching item, if one is found |
|
171 * it is removed from the array. Leaves with KErrArgument if the given |
|
172 * object is not valid. |
|
173 * |
|
174 * @since S60 5.2 |
|
175 * @param aObject, the UPnPObject object |
|
176 */ |
|
177 IMPORT_C void RemoveL( const CUpnpObject *aObject ); |
|
178 |
|
179 private: // Private business logic methods |
|
180 |
|
181 /** |
|
182 * Creates an CUpnpCdsLiteObject. Leaves with KErrArgument if the |
|
183 * given object is not valid. |
|
184 * |
|
185 * @since S60 5.2 |
|
186 * @param aObject, the UPnPObject object |
|
187 * @return a new CUpnpCdsLiteObject |
|
188 */ |
|
189 CUpnpCdsLiteObject* CreateUpnpCdsLiteObjectL( |
|
190 const CUpnpObject *aObject ); |
|
191 |
|
192 /** |
|
193 * Resolves the filename information from the given UpnpObject. Leaves |
|
194 * with KErrArgument if the given object is not valid. |
|
195 * Allocates memory for the returned descriptor. Does not handle the |
|
196 * freeing of the allocation. |
|
197 * |
|
198 * @since S60 5.2 |
|
199 * @param aObject, the UPnPObject object |
|
200 * @return the filename (including path) |
|
201 */ |
|
202 HBufC8* ResolveFileNameL( const CUpnpObject *aObject ); |
|
203 |
|
204 private: // Constructors |
|
205 |
|
206 /** |
|
207 * Default c++ constructor |
|
208 * |
|
209 * @since S60 5.2 |
|
210 */ |
|
211 CUpnpCdsLiteObjectArray() {}; |
|
212 |
|
213 /** |
|
214 * Second-phase constructor. |
|
215 * |
|
216 * @since S60 5.2 |
|
217 */ |
|
218 void ConstructL() {}; |
|
219 |
|
220 private: // Data members |
|
221 |
|
222 /** |
|
223 * The array of objects. Owned. |
|
224 */ |
|
225 RPointerArray<CUpnpCdsLiteObject> iArray; |
|
226 |
|
227 }; |
|
228 |
|
229 #endif /* C_UPNP_CDS_LITE_OBJECT_ARRAY_H */ |
|
230 // End of File |