|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 #include "rmtpproxydpsingletons.h" |
|
19 #include "cmtpproxydpconfigmgr.h" |
|
20 |
|
21 |
|
22 /** |
|
23 Constructor. |
|
24 */ |
|
25 RMTPProxyDpSingletons::RMTPProxyDpSingletons() : |
|
26 iSingletons(NULL) |
|
27 { |
|
28 } |
|
29 |
|
30 /** |
|
31 Opens the singletons reference. |
|
32 */ |
|
33 void RMTPProxyDpSingletons::OpenL(MMTPDataProviderFramework& aFramework) |
|
34 { |
|
35 iSingletons = &CSingletons::OpenL(aFramework); |
|
36 } |
|
37 |
|
38 /** |
|
39 Closes the singletons reference. |
|
40 */ |
|
41 void RMTPProxyDpSingletons::Close() |
|
42 { |
|
43 if (iSingletons) |
|
44 { |
|
45 iSingletons->Close(); |
|
46 iSingletons = NULL; |
|
47 } |
|
48 } |
|
49 |
|
50 /** |
|
51 Provides a handle to the MTP proxy data provider's configuration manager. |
|
52 @return The proxy data provider configuration manager. |
|
53 */ |
|
54 CMTPProxyDpConfigMgr& RMTPProxyDpSingletons::FrameworkConfig() |
|
55 { |
|
56 __ASSERT_DEBUG(iSingletons, User::Invariant()); |
|
57 __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant()); |
|
58 return *iSingletons->iConfigMgr; |
|
59 } |
|
60 |
|
61 RMTPProxyDpSingletons::CSingletons* RMTPProxyDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework) |
|
62 { |
|
63 CSingletons* self(new(ELeave) CSingletons()); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(aFramework); |
|
66 CleanupStack::Pop(self); |
|
67 return self; |
|
68 } |
|
69 |
|
70 RMTPProxyDpSingletons::CSingletons& RMTPProxyDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework) |
|
71 { |
|
72 CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls())); |
|
73 if (!self) |
|
74 { |
|
75 self = CSingletons::NewL(aFramework); |
|
76 Dll::SetTls(reinterpret_cast<TAny*>(self)); |
|
77 } |
|
78 else |
|
79 { |
|
80 self->Inc(); |
|
81 } |
|
82 return *self; |
|
83 } |
|
84 |
|
85 void RMTPProxyDpSingletons::CSingletons::Close() |
|
86 { |
|
87 CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls())); |
|
88 if (self) |
|
89 { |
|
90 self->Dec(); |
|
91 if (self->AccessCount() == 0) |
|
92 { |
|
93 delete self; |
|
94 Dll::SetTls(NULL); |
|
95 } |
|
96 } |
|
97 } |
|
98 |
|
99 RMTPProxyDpSingletons::CSingletons::~CSingletons() |
|
100 { |
|
101 delete iConfigMgr; |
|
102 } |
|
103 |
|
104 void RMTPProxyDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework) |
|
105 { |
|
106 iConfigMgr = CMTPProxyDpConfigMgr::NewL(aFramework); |
|
107 } |