|
1 // Copyright (c) 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 #include <f32file.h> |
|
18 #include <bautils.h> |
|
19 #include <s32file.h> |
|
20 #include <mtp/mmtpobjectmgr.h> |
|
21 #include <mtp/cmtpobjectmetadata.h> |
|
22 #include <mtp/mmtpdataproviderframework.h> |
|
23 #include <mtp/mmtpobjectmgr.h> |
|
24 #include <mtp/mmtpstoragemgr.h> |
|
25 #include <mtp/mtpprotocolconstants.h> |
|
26 #include <mtp/tmtptypeevent.h> |
|
27 #include "cmtppictbridgeenumerator.h" |
|
28 #include "mmtppictbridgeenumeratorcallback.h" |
|
29 #include "ptpdef.h" |
|
30 #include "cmtpdataprovidercontroller.h" |
|
31 #include <mtp/cmtptypefile.h> |
|
32 #include <pathinfo.h> |
|
33 |
|
34 //================================================================== |
|
35 // |
|
36 //================================================================== |
|
37 CMTPPictBridgeEnumerator* CMTPPictBridgeEnumerator::NewL(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback) |
|
38 { |
|
39 CMTPPictBridgeEnumerator* self = new (ELeave) CMTPPictBridgeEnumerator(aFramework, aCallback); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 //================================================================== |
|
47 // |
|
48 //================================================================== |
|
49 CMTPPictBridgeEnumerator::CMTPPictBridgeEnumerator(MMTPDataProviderFramework& aFramework, MMTPPictBridgeEnumeratorCallback& aCallback) |
|
50 :iFramework(aFramework), iCallback(aCallback) |
|
51 { |
|
52 } |
|
53 |
|
54 //================================================================== |
|
55 // |
|
56 //================================================================== |
|
57 void CMTPPictBridgeEnumerator::ConstructL() |
|
58 { |
|
59 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
60 __FLOG(_L8(">> CMTPPictBridgeEnumerator::ConstructL")); |
|
61 iSingletons.OpenL(); |
|
62 __FLOG(_L8("<< CMTPPictBridgeEnumerator::ConstructL")); |
|
63 } |
|
64 |
|
65 /** |
|
66 destructor |
|
67 */ |
|
68 CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator() |
|
69 { |
|
70 __FLOG(_L8(">> CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator")); |
|
71 // we keep the persistent handle |
|
72 iSingletons.Close(); |
|
73 __FLOG(_L8("<< CMTPPictBridgeEnumerator::~CMTPPictBridgeEnumerator")); |
|
74 __FLOG_CLOSE; |
|
75 } |
|
76 |
|
77 // -------------------------------------------------------------------------- |
|
78 // |
|
79 // -------------------------------------------------------------------------- |
|
80 // |
|
81 void CMTPPictBridgeEnumerator::EnumerateStoragesL() |
|
82 { |
|
83 iCallback.NotifyStorageEnumerationCompleteL(); |
|
84 } |
|
85 |
|
86 // -------------------------------------------------------------------------- |
|
87 // "handle of the file DDISCVRY.DPS" |
|
88 // -------------------------------------------------------------------------- |
|
89 TUint32 CMTPPictBridgeEnumerator::DeviceDiscoveryHandle() const |
|
90 { |
|
91 return iDpsDiscoveryHandle; |
|
92 } |
|
93 |
|
94 // -------------------------------------------------------------------------- |
|
95 // |
|
96 // -------------------------------------------------------------------------- |
|
97 void CMTPPictBridgeEnumerator::EnumerateObjectsL(TUint32 aStorageId) |
|
98 { |
|
99 __FLOG(_L8(">> CMTPPictBridgeEnumerator::EnumerateObjectsL")); |
|
100 const TUint storageId(iFramework.StorageMgr().DefaultStorageId()); |
|
101 |
|
102 if ((aStorageId==KMTPStorageAll) || (aStorageId==storageId)) |
|
103 { |
|
104 MMTPObjectMgr& objectMgr=iFramework.ObjectMgr(); |
|
105 |
|
106 //delete the files which maybe impact printing |
|
107 TFileName fullPath; |
|
108 fullPath = PathInfo::PhoneMemoryRootPath(); |
|
109 fullPath.Append(KHostDiscovery); |
|
110 __FLOG_VA((_L16("full path is %S "), &fullPath)); |
|
111 iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly); |
|
112 iFramework.Fs().Delete(fullPath); |
|
113 |
|
114 fullPath = PathInfo::PhoneMemoryRootPath(); |
|
115 fullPath.Append(KHostRequest); |
|
116 __FLOG_VA((_L16("full path is %S "), &fullPath)); |
|
117 iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly); |
|
118 iFramework.Fs().Delete(fullPath); |
|
119 |
|
120 fullPath = PathInfo::PhoneMemoryRootPath(); |
|
121 fullPath.Append(KHostResponse); |
|
122 __FLOG_VA((_L16("full path is %S "), &fullPath)); |
|
123 iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly); |
|
124 iFramework.Fs().Delete(fullPath); |
|
125 |
|
126 // enumerate device discovery file (create if not exist) |
|
127 CMTPTypeFile* discoveryFile; |
|
128 fullPath = PathInfo::PhoneMemoryRootPath(); |
|
129 fullPath.Append(KDeviceDiscovery); |
|
130 __FLOG_VA((_L16("full path is %S "), &fullPath)); |
|
131 iFramework.Fs().SetAtt(fullPath, KEntryAttNormal, KEntryAttReadOnly); |
|
132 iFramework.Fs().Delete(fullPath); |
|
133 |
|
134 discoveryFile = NULL; |
|
135 discoveryFile = CMTPTypeFile::NewLC(iFramework.Fs(), fullPath, EFileWrite); |
|
136 discoveryFile->SetSizeL(0); |
|
137 CleanupStack::PopAndDestroy(discoveryFile); |
|
138 |
|
139 CMTPObjectMetaData* objectP = CMTPObjectMetaData::NewLC(iSingletons.DpController().FileDpId(), EMTPFormatCodeScript, storageId, fullPath); |
|
140 |
|
141 objectP->SetUint(CMTPObjectMetaData::EParentHandle, KMTPHandleNoParent); |
|
142 objectMgr.InsertObjectL(*objectP); |
|
143 iDpsDiscoveryHandle = objectP->Uint( CMTPObjectMetaData::EHandle ); |
|
144 __FLOG_VA((_L8("added discovery file iDpsDiscoveryHandle is 0x%08X"), iDpsDiscoveryHandle)); |
|
145 |
|
146 CleanupStack::PopAndDestroy(objectP); |
|
147 } |
|
148 iCallback.NotifyEnumerationCompleteL(aStorageId, KErrNone); |
|
149 |
|
150 __FLOG(_L8("<< CMTPPictBridgeEnumerator::EnumerateObjectsL")); |
|
151 } |
|
152 |