|
1 // Copyright (c) 1998-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 "UT_STD.H" |
|
17 |
|
18 // Class CDbRestrictStage |
|
19 CDbRestrictStage::CDbRestrictStage(TDbTextComparison aComparison) |
|
20 : iTextOp(TTextOps::Ops(aComparison)) |
|
21 {} |
|
22 |
|
23 CDbRestrictStage::~CDbRestrictStage() |
|
24 { |
|
25 delete iRestriction; |
|
26 } |
|
27 |
|
28 TInt CDbRestrictStage::CountL() |
|
29 { |
|
30 return KDbUndefinedCount; |
|
31 } |
|
32 |
|
33 TBool CDbRestrictStage::FilterRowL(TDbRecordId aRecordId) |
|
34 { |
|
35 CDbDataStage::ReadRowL(aRecordId); |
|
36 return Restriction().EvaluateL(iTextOp); |
|
37 } |
|
38 |
|
39 CDbRestrictStage::TGoto CDbRestrictStage::GotoL(TInt& aWork,TDbPosition aPosition,TDbRecordId& aRecordId) |
|
40 { |
|
41 TGoto go=CDbDataStage::GotoL(aWork,aPosition,aRecordId); |
|
42 if (go==ESuccess) |
|
43 { |
|
44 switch (aPosition) |
|
45 { |
|
46 case EDbFirst: |
|
47 aPosition=EDbNext; |
|
48 break; |
|
49 case EDbLast: |
|
50 aPosition=EDbPrevious; |
|
51 break; |
|
52 default: |
|
53 break; |
|
54 } |
|
55 do |
|
56 { |
|
57 TBool inSet=FilterRowL(aRecordId); |
|
58 aWork-=EWorkToRead; |
|
59 if (inSet) |
|
60 break; |
|
61 } while ((go=CDbDataStage::GotoL(aWork,aPosition,aRecordId))==ESuccess); |
|
62 } |
|
63 return go; |
|
64 } |
|
65 |
|
66 TBool CDbRestrictStage::GotoL(TDbRecordId aRecordId) |
|
67 // |
|
68 // If the record exists, check the restriction |
|
69 // |
|
70 { |
|
71 return CDbDataStage::GotoL(aRecordId) ? FilterRowL(aRecordId) : EFalse; |
|
72 } |
|
73 |
|
74 CDbRestrictStage::TDelete CDbRestrictStage::DeleteRowL(TDbRecordId& aRecordId,TSynch aSynch) |
|
75 // |
|
76 // If trying to synchronise, and we find EDeletedAtNext, then we must check it is really in the rowset |
|
77 // |
|
78 { |
|
79 TDelete r=CDbDataStage::DeleteRowL(aRecordId,aSynch); |
|
80 if (aSynch==ESynch && r==EDeletedAtNext && !FilterRowL(aRecordId)) |
|
81 r=EDeletedInLimbo; // not a member, this cursor is now "in limbo" |
|
82 return r; |
|
83 } |