|
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: |
|
15 * |
|
16 */ |
|
17 #include "menusrvobjectfilter.h" |
|
18 #include "mcsmenufilter.h" |
|
19 #include "menuengobject.h" |
|
20 |
|
21 // ================= MEMBER FUNCTIONS ======================= |
|
22 |
|
23 // --------------------------------------------------------- |
|
24 // TMenuSrvObjectFilter::MatchesObject() |
|
25 // --------------------------------------------------------- |
|
26 // |
|
27 TBool TMenuSrvObjectFilter::MatchesObject( const CMenuEngObject& aObject ) const |
|
28 { |
|
29 if ( ( iFilter.FlagsOn() & aObject.Flags() ) != iFilter.FlagsOn() ) |
|
30 { |
|
31 return EFalse; |
|
32 } |
|
33 if ( ( iFilter.FlagsOff() & ~aObject.Flags() ) != iFilter.FlagsOff() ) |
|
34 { |
|
35 return EFalse; |
|
36 } |
|
37 if ( iFilter.Type().Length() && iFilter.Type() != aObject.Type() ) |
|
38 { |
|
39 return EFalse; |
|
40 } |
|
41 TBool needAttr; |
|
42 TBool haveAttr; |
|
43 TPtrC name; |
|
44 TPtrC needVal; |
|
45 TPtrC haveVal; |
|
46 TBool dummy; |
|
47 for ( TInt i = 0; i < iFilter.NumAttributes(); i++ ) |
|
48 { |
|
49 needAttr = iFilter.GetAttribute( i, name, needVal ); |
|
50 haveAttr = aObject.FindAttribute( name, haveVal, dummy ); |
|
51 if( needAttr != haveAttr ) |
|
52 { |
|
53 return EFalse; |
|
54 } |
|
55 if ( haveAttr ) |
|
56 { |
|
57 __ASSERT_DEBUG( needAttr, User::Invariant() ); // Checked above. |
|
58 if ( needVal != haveVal ) |
|
59 { |
|
60 return EFalse; |
|
61 } |
|
62 } |
|
63 } |
|
64 return ETrue; |
|
65 } |
|
66 |
|
67 // End of File |