|
1 // Copyright (c) 2008-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 #include "cupnpelement.h" |
|
17 |
|
18 CUPnPElement::CUPnPElement( MPnPObserver* aObserver ):iObserver( aObserver ) |
|
19 { |
|
20 } |
|
21 |
|
22 /* Destroy the contained RPointerArray but not the MPnPObserver |
|
23 * because its ownership is not with CUPnPElement |
|
24 */ |
|
25 CUPnPElement::~CUPnPElement() |
|
26 { |
|
27 iValueArray.ResetAndDestroy(); |
|
28 } |
|
29 |
|
30 /* Append the uri into the array and returns KErrNone if it succeeds or |
|
31 * returns a system wide error code if it fails |
|
32 * @param aUri The uri to be appended |
|
33 */ |
|
34 void CUPnPElement::AppendValueL(const TDesC8& aUri) |
|
35 { |
|
36 HBufC8* uri=aUri.AllocL(); |
|
37 CleanupStack::PushL(uri); |
|
38 iValueArray.AppendL(uri); |
|
39 CleanupStack::Pop(uri); |
|
40 } |
|
41 |
|
42 /* Matches the passed uri argument against the RArrayPointer and returns |
|
43 * the index value if present and KErrNotFound if not . |
|
44 * @param aUriArg The uri to be matched against |
|
45 */ |
|
46 TInt CUPnPElement::MatchValue(const TDesC8& aUriArg) |
|
47 { |
|
48 HBufC8* hbufPtr = NULL; |
|
49 for (TInt i=0 ; i<iValueArray.Count() ; i++) |
|
50 { |
|
51 hbufPtr = iValueArray[i]; |
|
52 if( (*hbufPtr).CompareF(aUriArg) == NULL) |
|
53 return i; |
|
54 } |
|
55 return KErrNotFound; |
|
56 } |
|
57 /* Removes the url passed |
|
58 */ |
|
59 |
|
60 TInt CUPnPElement::RemoveValue(const TDesC8& aUriArg) |
|
61 { |
|
62 TInt index=MatchValue(aUriArg); |
|
63 if(index != KErrNotFound) |
|
64 { |
|
65 HBufC8* data=iValueArray[index]; |
|
66 iValueArray.Remove(index); |
|
67 delete data; |
|
68 } |
|
69 return index; |
|
70 } |
|
71 |
|
72 |