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