1 /* |
|
2 * Copyright (c) 2009-2010 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 * Class representing any kind on connection method, including embedded |
|
16 * destination. Used for priority based ordering of connection methods inside |
|
17 * destinations. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 #include <cmmanagerdef.h> |
|
23 #include <cmpluginembdestinationdef.h> |
|
24 |
|
25 #include "cmmconnmethoditem.h" |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Constructor. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 TCmmConnMethodItem::TCmmConnMethodItem() |
|
33 : |
|
34 iId( 0 ), |
|
35 iBearerType( 0 ), |
|
36 iBearerPriority( 0 ), |
|
37 iPriority( 0 ), |
|
38 iIsVirtual( 0 ), |
|
39 iLinkedIapId( 0 ), |
|
40 iLinkedSnapId( 0 ) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Constructor. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 TCmmConnMethodItem::TCmmConnMethodItem( |
|
49 TUint32 aId, |
|
50 TUint32 aBearerType, |
|
51 TUint aBearerPriority, |
|
52 TUint aPriority, |
|
53 TBool aIsVirtual, |
|
54 TUint32 aLinkedIapId, |
|
55 TUint32 aLinkedSnapId ) |
|
56 : |
|
57 iId( aId ), |
|
58 iBearerType( aBearerType ), |
|
59 iBearerPriority( aBearerPriority ), |
|
60 iPriority( aPriority ), |
|
61 iIsVirtual( aIsVirtual ), |
|
62 iLinkedIapId( aLinkedIapId ), |
|
63 iLinkedSnapId( aLinkedSnapId ) |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // A comparison function. Uses priority since items are in priority order. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 TInt TCmmConnMethodItem::Compare( |
|
72 const TCmmConnMethodItem& aFirst, |
|
73 const TCmmConnMethodItem& aSecond ) |
|
74 { |
|
75 // Zero if match, negative if first is smaller, positive otherwise. |
|
76 TInt result = ( TInt )aFirst.iPriority - ( TInt )aSecond.iPriority; |
|
77 |
|
78 if ( result == 0 && |
|
79 aFirst.iPriority == CMManager::KDataMobilitySelectionPolicyPriorityWildCard ) |
|
80 { |
|
81 // Embedded destination and virtual IAPs linking to SNAP have wildcard |
|
82 // priority. |
|
83 // If both connection methods have wildcard priority, only need to |
|
84 // ensure that an embedded destination looses in priority to everything |
|
85 // else. |
|
86 if ( aFirst.iBearerType == KUidEmbeddedDestination ) |
|
87 { |
|
88 result = 1; // Positive. |
|
89 } |
|
90 else if ( aSecond.iBearerType == KUidEmbeddedDestination ) |
|
91 { |
|
92 result = -1; // Negative. |
|
93 } |
|
94 } |
|
95 |
|
96 return result; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // A comparison function to find a specific item by ID. |
|
101 // (Items are not sorted by ID in the array.) |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TBool TCmmConnMethodItem::FindCompare( |
|
105 const TUint32* aKey, |
|
106 const TCmmConnMethodItem& aEntry ) |
|
107 { |
|
108 // True if match, false otherwise. |
|
109 TBool result( EFalse ); |
|
110 if ( *aKey == aEntry.iId ) |
|
111 { |
|
112 result = ETrue; |
|
113 } |
|
114 return result; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // Return ETrue if this connection method item represents a virtual |
|
119 // destination. |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 TBool TCmmConnMethodItem::IsVirtual() const |
|
123 { |
|
124 return iIsVirtual; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Return ETrue if this connection method item represents an embedded |
|
129 // destination. |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 TBool TCmmConnMethodItem::IsEmbedded() const |
|
133 { |
|
134 // No traces. |
|
135 TBool result( EFalse ); |
|
136 if ( iBearerType == KUidEmbeddedDestination ) |
|
137 { |
|
138 result = ETrue; |
|
139 } |
|
140 return result; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // If this is a virtual IAP that points to an IAP, returns the ID of that IAP, |
|
145 // 0 otherwise. |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 TUint32 TCmmConnMethodItem::LinkedIapId() const |
|
149 { |
|
150 return iLinkedIapId; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // If this is a virtual IAP that points to a SNAP, returns the ID of that SNAP, |
|
155 // 0 otherwise. |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 TUint32 TCmmConnMethodItem::LinkedSnapId() const |
|
159 { |
|
160 return iLinkedSnapId; |
|
161 } |
|
162 |
|
163 // End of file |
|