|
1 /* |
|
2 * Copyright (c) 2007-2008 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: suite stack |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "hnsuitemodel.h" |
|
20 #include "hnsuitesstack.h" |
|
21 #include "hnsuitemodelcontainer.h" |
|
22 #include "hncontrollerinterface.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS ============================= |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 EXPORT_C CHnSuitesStack* CHnSuitesStack::NewL( MHnControllerInterface& aControllerInterface ) |
|
33 { |
|
34 CHnSuitesStack* self = new (ELeave) CHnSuitesStack( aControllerInterface ); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop( self ); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 void CHnSuitesStack::ConstructL() |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CHnSuitesStack::~CHnSuitesStack() |
|
54 { |
|
55 iStack.ResetAndDestroy(); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CHnSuitesStack::CHnSuitesStack( MHnControllerInterface& aControllerInterface ): |
|
63 iControllerInterface( aControllerInterface ) |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C TInt CHnSuitesStack::PushL( CHnSuiteModel* aSuiteModel ) |
|
72 { |
|
73 iStack.AppendL( aSuiteModel ); |
|
74 iControllerInterface.HandleSuiteEventL( ESuitePushedToStack, aSuiteModel ); |
|
75 return iStack.Count(); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CHnSuiteModel* CHnSuitesStack::PopL() |
|
83 { |
|
84 CHnSuiteModel* retSuite = NULL; |
|
85 TInt pos = iStack.Count() - 1; |
|
86 if ( pos >= 0 ) |
|
87 { |
|
88 retSuite = iStack[ pos ]; |
|
89 iStack.Remove( pos ); |
|
90 } |
|
91 iControllerInterface.HandleSuiteEventL( ESuitePoppedFromStack, retSuite ); |
|
92 |
|
93 return retSuite; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CHnSuiteModel* CHnSuitesStack::GetLast() |
|
101 { |
|
102 return ( iStack.Count() > 0 ) ? iStack[ iStack.Count() - 1 ] : NULL; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C CHnSuiteModel* CHnSuitesStack::Get( TInt aPosition ) |
|
110 { |
|
111 ASSERT( aPosition >= 0 ); |
|
112 ASSERT( aPosition < iStack.Count() ); |
|
113 |
|
114 return iStack[ aPosition ]; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 EXPORT_C TBool CHnSuitesStack::IsEmpty() |
|
122 { |
|
123 return ( iStack.Count() > 0 ) ? EFalse : ETrue; |
|
124 } |
|
125 |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 EXPORT_C CHnSuiteModel* CHnSuitesStack::GetRootSuite() |
|
132 { |
|
133 CHnSuiteModel* retSuite = NULL; |
|
134 |
|
135 if ( iStack.Count() > 0 ) |
|
136 { |
|
137 retSuite = iStack[ 0 ]; |
|
138 } |
|
139 |
|
140 return retSuite; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C TInt CHnSuitesStack::Count() |
|
148 { |
|
149 return iStack.Count(); |
|
150 } |
|
151 //End of file. |