|
1 /* |
|
2 * Copyright (c) 2003-2005 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 the License "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 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #include "liwbinding.h" |
|
24 |
|
25 |
|
26 CLiwBinding* CLiwBinding::NewL() |
|
27 { |
|
28 return new (ELeave) CLiwBinding(); |
|
29 } |
|
30 |
|
31 |
|
32 |
|
33 CLiwBinding* CLiwBinding::NewLC() |
|
34 { |
|
35 CLiwBinding* bind = new (ELeave) CLiwBinding(); |
|
36 CleanupStack::PushL(bind); |
|
37 return bind; |
|
38 } |
|
39 |
|
40 |
|
41 void CLiwBinding::AddProviderL(CLiwServiceIfBase* aProvider, TBool aIsDefault) |
|
42 { |
|
43 if (aIsDefault) |
|
44 { |
|
45 // Default provider will be the first item in array. |
|
46 User::LeaveIfError(iProviders.Insert(aProvider, 0)); |
|
47 } |
|
48 else |
|
49 { |
|
50 User::LeaveIfError(iProviders.Append(aProvider)); |
|
51 } |
|
52 } |
|
53 |
|
54 |
|
55 |
|
56 TInt CLiwBinding::HasCriteriaItem(CLiwCriteriaItem& aItem) const |
|
57 { |
|
58 const TInt count = iInterest.Count(); |
|
59 for (TInt index = 0; index < count; index++) |
|
60 { |
|
61 if ((*iInterest[index]) == aItem) |
|
62 { |
|
63 return index; |
|
64 } |
|
65 } |
|
66 |
|
67 return KErrNotFound; |
|
68 } |
|
69 |
|
70 |
|
71 TBool CLiwBinding::HasProvider(CLiwServiceIfBase* aProvider) const |
|
72 { |
|
73 for (TInt index = 0; index < iProviders.Count(); index++) |
|
74 { |
|
75 if (iProviders[index] == aProvider) |
|
76 { |
|
77 return ETrue; |
|
78 } |
|
79 } |
|
80 |
|
81 return EFalse; |
|
82 } |
|
83 |
|
84 |
|
85 void CLiwBinding::RemoveCriteria(TInt aIndex) |
|
86 { |
|
87 iInterest.Remove( aIndex ); |
|
88 } |
|
89 |
|
90 |
|
91 |
|
92 TBool CLiwBinding::RemoveProvider(TInt aImplUid) |
|
93 { |
|
94 for (TInt index = 0; index < iProviders.Count(); index++) |
|
95 { |
|
96 if (iProviders[index]->ImplementationUid().iUid == aImplUid) |
|
97 { |
|
98 iProviders.Remove( index ); |
|
99 return ETrue; |
|
100 } |
|
101 } |
|
102 |
|
103 return EFalse; |
|
104 } |
|
105 |
|
106 TBool CLiwBinding::HasServiceCmd(TInt aServiceCmd) const |
|
107 { |
|
108 for (TInt index = 0; index < iInterest.Count(); index++) |
|
109 { |
|
110 if(iInterest[index]->ServiceCmd() == aServiceCmd) |
|
111 { |
|
112 return ETrue; |
|
113 } |
|
114 } |
|
115 return EFalse; |
|
116 } |
|
117 // End of file |