|
1 /* |
|
2 * Copyright (c) 2002 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 * Defines methods for CMceSessionHolder |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <msvapi.h> |
|
23 |
|
24 #include "MceSessionHolder.h" |
|
25 #include "McePanic.h" |
|
26 |
|
27 #include <bldvariant.hrh> |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KMceDefaultNumberOfSessionObservers = 1; |
|
31 const TInt KMceMessageSessionPriority = CActive::EPriorityStandard - 10; |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 CMceSessionHolder::CMceSessionHolder() : |
|
36 iClientCount( KMceDefaultNumberOfSessionObservers ) |
|
37 { |
|
38 } |
|
39 |
|
40 CMceSessionHolder* CMceSessionHolder::NewL( MMsvSessionObserver& aSessionObserver ) |
|
41 { |
|
42 CMceSessionHolder* self = new ( ELeave ) CMceSessionHolder(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aSessionObserver ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 void CMceSessionHolder::ConstructL( MMsvSessionObserver& aSessionObserver ) |
|
51 { |
|
52 iSession = CMsvSession::OpenAsyncL( aSessionObserver, KMceMessageSessionPriority ); |
|
53 } |
|
54 |
|
55 |
|
56 CMceSessionHolder::~CMceSessionHolder() |
|
57 { |
|
58 __ASSERT_DEBUG( !iClientCount, Panic( EMceSessionHolderDeletedWhenClients ) ); |
|
59 delete iSession; |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------- |
|
63 // CMceSessionHolder::AddClient |
|
64 // ---------------------------------------------------- |
|
65 void CMceSessionHolder::AddClient() |
|
66 { |
|
67 iClientCount++; |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------- |
|
71 // CMceSessionHolder::RemoveClient |
|
72 // ---------------------------------------------------- |
|
73 void CMceSessionHolder::RemoveClient() |
|
74 { |
|
75 iClientCount--; |
|
76 if ( iClientCount == 0 ) |
|
77 { |
|
78 delete iSession; |
|
79 iSession = NULL; |
|
80 delete this; |
|
81 } |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------- |
|
85 // CMceSessionHolder::ClientCount |
|
86 // ---------------------------------------------------- |
|
87 TInt CMceSessionHolder::ClientCount() const |
|
88 { |
|
89 return iClientCount; |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------- |
|
93 // CMceSessionHolder::Session |
|
94 // ---------------------------------------------------- |
|
95 CMsvSession* CMceSessionHolder::Session() const |
|
96 { |
|
97 return iSession; |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------- |
|
101 // CMceSessionHolder::SetSession |
|
102 // Sets session pointer |
|
103 // ---------------------------------------------------- |
|
104 void CMceSessionHolder::SetSession( CMsvSession* aSession ) |
|
105 { |
|
106 iSession = aSession; |
|
107 } |
|
108 |
|
109 // End of File |