|
1 // Copyright (c) 2006-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 #include "rmtpfiledpsingletons.h" |
|
17 |
|
18 #include <mtp/mmtpdataproviderframework.h> |
|
19 #include <mtp/cmtpobjectmetadata.h> |
|
20 |
|
21 #include "cmtpfiledpconfigmgr.h" |
|
22 |
|
23 // Class constants. |
|
24 __FLOG_STMT(_LIT8(KComponent,"FileDpSingletons");) |
|
25 |
|
26 /** |
|
27 Constructor. |
|
28 */ |
|
29 RMTPFileDpSingletons::RMTPFileDpSingletons() : |
|
30 iSingletons(NULL) |
|
31 { |
|
32 } |
|
33 |
|
34 /** |
|
35 Opens the singletons reference. |
|
36 */ |
|
37 void RMTPFileDpSingletons::OpenL(MMTPDataProviderFramework& aFramework) |
|
38 { |
|
39 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
40 __FLOG(_L8("OpenL - Entry")); |
|
41 iSingletons = &CSingletons::OpenL(aFramework); |
|
42 __FLOG(_L8("OpenL - Exit")); |
|
43 } |
|
44 |
|
45 /** |
|
46 Closes the singletons reference. |
|
47 */ |
|
48 void RMTPFileDpSingletons::Close() |
|
49 { |
|
50 __FLOG(_L8("Close - Entry")); |
|
51 if (iSingletons) |
|
52 { |
|
53 iSingletons->Close(); |
|
54 iSingletons = NULL; |
|
55 } |
|
56 __FLOG(_L8("Close - Exit")); |
|
57 __FLOG_CLOSE; |
|
58 } |
|
59 |
|
60 /** |
|
61 Provides a handle to the MTP file data provider's configuration manager. |
|
62 @return The file data provider configuration manager. |
|
63 */ |
|
64 |
|
65 CMTPFileDpConfigMgr& RMTPFileDpSingletons::FrameworkConfig() |
|
66 { |
|
67 __FLOG(_L8("FrameworkConfig - Entry")); |
|
68 __ASSERT_DEBUG(iSingletons, User::Invariant()); |
|
69 __ASSERT_DEBUG(iSingletons->iConfigMgr, User::Invariant()); |
|
70 __FLOG(_L8("FrameworkConfig - Exit")); |
|
71 return *iSingletons->iConfigMgr; |
|
72 } |
|
73 |
|
74 RMTPFileDpSingletons::CSingletons* RMTPFileDpSingletons::CSingletons::NewL(MMTPDataProviderFramework& aFramework) |
|
75 { |
|
76 CSingletons* self(new(ELeave) CSingletons()); |
|
77 CleanupStack::PushL(self); |
|
78 self->ConstructL(aFramework); |
|
79 CleanupStack::Pop(self); |
|
80 return self; |
|
81 } |
|
82 |
|
83 RMTPFileDpSingletons::CSingletons& RMTPFileDpSingletons::CSingletons::OpenL(MMTPDataProviderFramework& aFramework) |
|
84 { |
|
85 __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Entry")); |
|
86 CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls())); |
|
87 if (!self) |
|
88 { |
|
89 self = CSingletons::NewL(aFramework); |
|
90 Dll::SetTls(reinterpret_cast<TAny*>(self)); |
|
91 } |
|
92 else |
|
93 { |
|
94 self->Inc(); |
|
95 } |
|
96 __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("CSingletons::OpenL - Exit")); |
|
97 return *self; |
|
98 } |
|
99 |
|
100 void RMTPFileDpSingletons::CSingletons::Close() |
|
101 { |
|
102 CSingletons* self(reinterpret_cast<CSingletons*>(Dll::Tls())); |
|
103 if (self) |
|
104 { |
|
105 __FLOG(_L8("CSingletons::Close - Entry")); |
|
106 self->Dec(); |
|
107 if (self->AccessCount() == 0) |
|
108 { |
|
109 __FLOG(_L8("CSingletons::Close - Exit")); |
|
110 delete self; |
|
111 Dll::SetTls(NULL); |
|
112 } |
|
113 else |
|
114 { |
|
115 __FLOG(_L8("CSingletons::Close - Exit")); |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 RMTPFileDpSingletons::CSingletons::~CSingletons() |
|
121 { |
|
122 __FLOG(_L8("CSingletons::~CSingletons - Entry")); |
|
123 delete iConfigMgr; |
|
124 __FLOG(_L8("CSingletons::~CSingletons - Exit")); |
|
125 __FLOG_CLOSE; |
|
126 } |
|
127 |
|
128 void RMTPFileDpSingletons::CSingletons::ConstructL(MMTPDataProviderFramework& aFramework) |
|
129 { |
|
130 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
131 __FLOG(_L8("CSingletons::ConstructL - Entry")); |
|
132 iConfigMgr = CMTPFileDpConfigMgr::NewL(aFramework); |
|
133 __FLOG(_L8("CSingletons::ConstructL - Exit")); |
|
134 } |
|
135 |
|
136 |
|
137 |