|
1 // Copyright (c) 2005-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 // Internal class for manipulating bookmark extended properties. |
|
15 // @internalComponent |
|
16 // |
|
17 // |
|
18 |
|
19 #include "bkmrk.h" |
|
20 #include <cauthentication.h> |
|
21 |
|
22 CBkmrkExtendedProperties* CBkmrkExtendedProperties::NewL(CBookmarkBase& aParent, CBookmarkDb& aDb, CRepository& aRepository) |
|
23 { |
|
24 CBkmrkExtendedProperties* self = new (ELeave) CBkmrkExtendedProperties(aParent, aDb, aRepository); |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(); |
|
27 CleanupStack::Pop(self); |
|
28 return self; |
|
29 } |
|
30 |
|
31 CBkmrkExtendedProperties::CBkmrkExtendedProperties(CBookmarkBase& aParent, CBookmarkDb& aDb, CRepository& aRepository) |
|
32 : CBkmrkProperties(aParent, aDb, aRepository) |
|
33 { |
|
34 } |
|
35 |
|
36 CBkmrkExtendedProperties::~CBkmrkExtendedProperties() |
|
37 { |
|
38 delete iAuthentication; |
|
39 } |
|
40 |
|
41 void CBkmrkExtendedProperties::ConstructL() |
|
42 { |
|
43 CBkmrkProperties::ConstructL(); |
|
44 } |
|
45 |
|
46 void CBkmrkExtendedProperties::SetAuthenticationL(const CAuthentication& aAuthentication) |
|
47 { |
|
48 iParent.LeaveIfNotWritableL(); |
|
49 delete iAuthentication; |
|
50 iAuthentication = NULL; |
|
51 iAuthentication = CAuthentication::NewL(aAuthentication.Name(), aAuthentication.Password(), aAuthentication.Method()); |
|
52 SetDirty(); |
|
53 } |
|
54 |
|
55 const CAuthentication& CBkmrkExtendedProperties::AuthenticationL() |
|
56 { |
|
57 if (!iAuthentication) |
|
58 { |
|
59 // Create an empty authentication object |
|
60 iAuthentication = CAuthentication::NewL(KNullDesC8, KNullDesC8); |
|
61 } |
|
62 |
|
63 return *iAuthentication; |
|
64 } |
|
65 |
|
66 TUint32 CBkmrkExtendedProperties::Proxy() const |
|
67 { |
|
68 return iProxy; |
|
69 } |
|
70 |
|
71 void CBkmrkExtendedProperties::SetProxyL(TUint32 aProxy) |
|
72 { |
|
73 iParent.LeaveIfNotWritableL(); |
|
74 iProxy = aProxy; |
|
75 SetDirty(); |
|
76 } |
|
77 |
|
78 TUint32 CBkmrkExtendedProperties::Nap() const |
|
79 { |
|
80 return iNap; |
|
81 } |
|
82 |
|
83 void CBkmrkExtendedProperties::SetNapL(TUint32 aNap) |
|
84 { |
|
85 iParent.LeaveIfNotWritableL(); |
|
86 iNap = aNap; |
|
87 SetDirty(); |
|
88 } |
|
89 |
|
90 void CBkmrkExtendedProperties::TransNewL() |
|
91 { |
|
92 CBkmrkProperties::TransNewL(); |
|
93 TUint32 indexBase = IndexBase(); |
|
94 // create entries in the repository |
|
95 iRepository->Create(indexBase + KBkmrkAuthNameIndex, AuthenticationL().Name()); |
|
96 iRepository->Create(indexBase + KBkmrkAuthPasswordIndex, AuthenticationL().Password()); |
|
97 iRepository->Create(indexBase + KBkmrkAuthMethodIndex, AuthenticationL().Method()); |
|
98 iRepository->Create(indexBase + KBkmrkProxyIndex, static_cast<TInt>(iProxy)); |
|
99 iRepository->Create(indexBase + KBkmrkNapIndex, static_cast<TInt>(iNap)); |
|
100 } |
|
101 |
|
102 void CBkmrkExtendedProperties::TransSaveL() |
|
103 { |
|
104 CBkmrkProperties::TransSaveL(); |
|
105 TUint32 indexBase = IndexBase(); |
|
106 iRepository->Set(indexBase + KBkmrkAuthNameIndex, AuthenticationL().Name()); |
|
107 iRepository->Set(indexBase + KBkmrkAuthPasswordIndex, AuthenticationL().Password()); |
|
108 iRepository->Set(indexBase + KBkmrkAuthMethodIndex, AuthenticationL().Method()); |
|
109 iRepository->Set(indexBase + KBkmrkProxyIndex, static_cast<TInt>(iProxy)); |
|
110 iRepository->Set(indexBase + KBkmrkNapIndex, static_cast<TInt>(iNap)); |
|
111 } |
|
112 |
|
113 void CBkmrkExtendedProperties::TransLoadL() |
|
114 { |
|
115 CBkmrkProperties::TransLoadL(); |
|
116 |
|
117 TUint32 indexBase = IndexBase(); |
|
118 HBufC8* buffer = HBufC8::NewL(Bookmark::KMaxDataLength); |
|
119 CleanupStack::PushL(buffer); |
|
120 TPtr8 bufPtr = buffer->Des(); |
|
121 if (!iAuthentication) |
|
122 { |
|
123 // Create an empty authentication object |
|
124 iAuthentication = CAuthentication::NewL(KNullDesC8, KNullDesC8); |
|
125 } |
|
126 User::LeaveIfError(iRepository->Get(indexBase + KBkmrkAuthNameIndex, bufPtr)); |
|
127 iAuthentication->SetNameL(bufPtr); |
|
128 User::LeaveIfError(iRepository->Get(indexBase + KBkmrkAuthPasswordIndex, bufPtr)); |
|
129 iAuthentication->SetPasswordL(bufPtr); |
|
130 TInt method; |
|
131 User::LeaveIfError(iRepository->Get(indexBase + KBkmrkAuthMethodIndex, method)); |
|
132 iAuthentication->SetMethod(static_cast<CAuthentication::TMethod>(method)); |
|
133 CleanupStack::PopAndDestroy(buffer); |
|
134 |
|
135 TInt retVal; |
|
136 User::LeaveIfError(iRepository->Get(indexBase + KBkmrkProxyIndex, retVal)); |
|
137 iProxy = static_cast<TUint32>(retVal); |
|
138 User::LeaveIfError(iRepository->Get(indexBase + KBkmrkNapIndex, retVal)); |
|
139 iNap = static_cast<TUint32>(retVal); |
|
140 SetClean(); |
|
141 } |
|
142 |
|
143 void CBkmrkExtendedProperties::TransRemoveL() |
|
144 { |
|
145 CBkmrkProperties::TransRemoveL(); |
|
146 |
|
147 TUint32 indexBase = IndexBase(); |
|
148 iRepository->Delete(indexBase + KBkmrkAuthNameIndex); |
|
149 iRepository->Delete(indexBase + KBkmrkAuthPasswordIndex); |
|
150 iRepository->Delete(indexBase + KBkmrkAuthMethodIndex); |
|
151 iRepository->Delete(indexBase + KBkmrkProxyIndex); |
|
152 iRepository->Delete(indexBase + KBkmrkNapIndex); |
|
153 iCustomProperties->TransRemoveL(); |
|
154 } |
|
155 |