|
1 // Copyright (c) 2006-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 // Table/Record Protection |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @deprecated since v9.1. Functionality is replaced with commsdat. |
|
21 */ |
|
22 |
|
23 #include "protectcpdb.h" |
|
24 #include "CDBSTD.H" |
|
25 #include "commdb_impl.H" |
|
26 #include "Commsdat_Log.h" |
|
27 |
|
28 CCommsDbProtectConnectPrefTableView* CCommsDbProtectConnectPrefTableView::NewL(CCommsDatabase& /*aDb*/,const TDbQuery& /*aQuery*/) |
|
29 /** |
|
30 Allocates and constructs a new communications database connection preference view object. |
|
31 aUseTemplate defaults to ETrue |
|
32 |
|
33 @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
34 |
|
35 @param aDb reference to the database to use. |
|
36 @param aQuery Query to perform |
|
37 @return A pointer to a communications database connection preference view object . |
|
38 */ |
|
39 { |
|
40 // Never instantiated in the code, |
|
41 // Object of this class is used after casting. There is no need for constructing it! |
|
42 User::Leave(KErrNotSupported); |
|
43 return NULL; |
|
44 } |
|
45 |
|
46 CCommsDbProtectConnectPrefTableView::CCommsDbProtectConnectPrefTableView(CCommsDatabase& aDb) |
|
47 : CCommsDbConnectionPrefTableView(aDb) |
|
48 /** |
|
49 Default Constructor |
|
50 */ |
|
51 {} |
|
52 |
|
53 |
|
54 void CCommsDbProtectConnectPrefTableView::ConstructL(const TDbQuery& /*aQuery*/) |
|
55 /** |
|
56 Prepares and evaluates the table view using the SQL query aQuery |
|
57 |
|
58 @deprecated This method is deprecated from 9.1 and always returns/leaves with KErrNotSupported instead of describing past operation/parameters. |
|
59 |
|
60 @param aQuery Query to perform |
|
61 */ |
|
62 { |
|
63 User::Leave(KErrNotSupported); |
|
64 } |
|
65 |
|
66 EXPORT_C CCommsDbProtectConnectPrefTableView::~CCommsDbProtectConnectPrefTableView() |
|
67 /** |
|
68 Destructor |
|
69 */ |
|
70 {} |
|
71 |
|
72 void CCommsDbProtectConnectPrefTableView::DoProtectionL(CMDBSession* aSession, CMDBElement* aElement, TBool aProtect) |
|
73 { |
|
74 TBool showHidden = aSession->IsSetAttributeMask(ECDHidden); |
|
75 |
|
76 // set all attribute masks as must be able to see every record (already set for ECD Private) |
|
77 aSession->SetAttributeMask(ECDHidden | ECDNoWriteButDelete | ECDProtectedWrite ); |
|
78 |
|
79 aProtect ? aElement->SetAttributes(ECDProtectedWrite) : aElement->ClearAttributes(ECDProtectedWrite); |
|
80 aElement->ModifyL(*aSession); |
|
81 |
|
82 if (showHidden) |
|
83 { |
|
84 aSession->ClearAttributeMask(ECDNoWriteButDelete | ECDProtectedWrite); |
|
85 } |
|
86 else |
|
87 { |
|
88 aSession->ClearAttributeMask(ECDHidden | ECDNoWriteButDelete | ECDProtectedWrite); |
|
89 } |
|
90 } |
|
91 |
|
92 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::ProtectTable() |
|
93 /** |
|
94 Protects table |
|
95 Protection of settings |
|
96 @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
97 @capability Dependent on table, see the guide page referenced below. |
|
98 */ |
|
99 { |
|
100 CMDBRecordSetBase* rs(NULL); |
|
101 TInt err = iTableExt->GetRecordSet(rs); |
|
102 |
|
103 if(err == KErrNone) |
|
104 { |
|
105 TRAP(err, DoProtectionL(iDb.iImpl->iDbs, rs, KProtectTable)); |
|
106 } |
|
107 |
|
108 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("CCommsDbProtectConnectPrefTableView::ProtectTable, Err:%d"), err); |
|
109 return err; |
|
110 } |
|
111 |
|
112 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::UnprotectTable() |
|
113 /** |
|
114 Unprotects table |
|
115 |
|
116 @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
117 @capability Dependent on table, see the guide page referenced below. |
|
118 */ |
|
119 { |
|
120 CMDBRecordSetBase* rs(NULL); |
|
121 TInt err = iTableExt->GetRecordSet(rs); |
|
122 |
|
123 if(err == KErrNone) |
|
124 { |
|
125 TRAP(err, DoProtectionL(iDb.iImpl->iDbs, rs, KUnprotectTable)); |
|
126 } |
|
127 |
|
128 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("CCommsDbProtectConnectPrefTableView::UnprotectTable, Err:%d"), err); |
|
129 return err; |
|
130 } |
|
131 |
|
132 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::ProtectRecord() |
|
133 /** |
|
134 Marks record as read-only so that it cannot be modified |
|
135 This does not protect it from deletion. |
|
136 |
|
137 @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
138 @capability Dependent on table, see the guide page referenced below. |
|
139 */ |
|
140 { |
|
141 CMDBRecordBase* record(NULL); |
|
142 TInt err = iTableExt->GetCurrentRecord(record); |
|
143 |
|
144 if(err == KErrNone) |
|
145 { |
|
146 TRAP(err, DoProtectionL(iDb.iImpl->iDbs, record, KProtectRecord)); |
|
147 } |
|
148 |
|
149 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("CCommsDbProtectTableView::ProtectRecord, Err:%d"), err); |
|
150 return err; |
|
151 } |
|
152 |
|
153 |
|
154 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::UnprotectRecord() |
|
155 /** |
|
156 Marks record as not read-only so that it can be modified or deleted |
|
157 |
|
158 @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
159 @capability Dependent on table, see the guide page referenced below. |
|
160 */ |
|
161 { |
|
162 CMDBRecordBase* record(NULL); |
|
163 TInt err = iTableExt->GetCurrentRecord(record); |
|
164 |
|
165 if(err == KErrNone) |
|
166 { |
|
167 TRAP(err, DoProtectionL(iDb.iImpl->iDbs, record, KUnprotectRecord)); |
|
168 } |
|
169 |
|
170 __FLOG_STATIC1(KLogComponent, KCommDbShim, _L("CCommsDbProtectTableView::UnprotectRecord, Err:%d"), err); |
|
171 return err; |
|
172 } |
|
173 |
|
174 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::GetTableAccess(RDbRowSet::TAccess& aAccessType) |
|
175 /** |
|
176 Checks table's ReadOnly Setting |
|
177 |
|
178 @param aAccessType Access type |
|
179 @return KErrNone if successful, otherwise another of the system-wide error codes. |
|
180 @capability Dependent on table, see the guide page referenced below. |
|
181 */ |
|
182 { |
|
183 return iTableExt->GetTableAccess(aAccessType); |
|
184 } |
|
185 |
|
186 |
|
187 EXPORT_C TInt CCommsDbProtectConnectPrefTableView::GetRecordAccess(TInt& aAccess) |
|
188 /** |
|
189 Checks record's protection setting |
|
190 Currently a record can be Writable (0) or Read Only (1). |
|
191 Read Only records cannot be amended until they are unprotected via this API. |
|
192 |
|
193 From v9.1 there is behavioural change. Column ordinal value is replaced with ElementID |
|
194 |
|
195 @param aAccess On return contains the value of the column ordinal(look line above) |
|
196 @return KErrNone |
|
197 @capability Dependent on table, see the guide page referenced below. |
|
198 */ |
|
199 { |
|
200 CMDBRecordBase* record(NULL); |
|
201 TInt err = iTableExt->GetCurrentRecord(record); |
|
202 |
|
203 if(err == KErrNone) |
|
204 { |
|
205 if(record->IsSetAttribute(ECDProtectedWrite)) |
|
206 { |
|
207 aAccess = RDbRowSet::EReadOnly; |
|
208 } |
|
209 else |
|
210 { |
|
211 aAccess = RDbRowSet::EUpdatable; |
|
212 } |
|
213 } |
|
214 |
|
215 |
|
216 return err; |
|
217 } |
|
218 |
|
219 //EOF |