20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <e32base.h> |
21 #include <e32base.h> |
22 #include <f32file.h> |
22 #include <f32file.h> |
23 #include "DcfCommon.h" |
23 #include "DcfCommon.h" |
24 #include "Oma1Dcf.h" |
24 #include "Oma1Dcf.h" |
25 #include "Oma2Dcf.h" |
25 #include "oma2dcf.h" |
26 |
26 |
27 // ============================ MEMBER FUNCTIONS =============================== |
27 // ============================ MEMBER FUNCTIONS =============================== |
28 |
28 |
29 // ----------------------------------------------------------------------------- |
29 // ----------------------------------------------------------------------------- |
30 // CDcfCommon::CDcfCommon |
30 // CDcfCommon::CDcfCommon |
31 // |
31 // |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // |
33 // |
34 CDcfCommon::CDcfCommon(): |
34 CDcfCommon::CDcfCommon(): |
35 iData(NULL), |
35 iData(NULL), |
36 iMimeType(NULL), |
36 iMimeType(NULL), |
82 return self; |
82 return self; |
83 } |
83 } |
84 |
84 |
85 // ----------------------------------------------------------------------------- |
85 // ----------------------------------------------------------------------------- |
86 // CDcfCommon::NewL |
86 // CDcfCommon::NewL |
87 // |
87 // |
88 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
89 // |
89 // |
90 EXPORT_C CDcfCommon* CDcfCommon::NewL( |
90 EXPORT_C CDcfCommon* CDcfCommon::NewL( |
91 const TDesC& aFileName, |
91 const TDesC& aFileName, |
92 RFs* aFs) |
92 RFs* aFs) |
93 { |
93 { |
94 RFs* fs = NULL; |
94 RFs* fs = NULL; |
95 RFile file; |
95 RFile file; |
96 TInt r = KErrNone; |
96 TInt r = KErrNone; |
97 CDcfCommon* self = NULL; |
97 CDcfCommon* self = NULL; |
98 |
98 |
99 if (aFs == NULL) |
99 if (aFs == NULL) |
100 { |
100 { |
101 fs = new RFs(); |
101 fs = new RFs(); |
102 User::LeaveIfNull(fs); |
102 User::LeaveIfNull(fs); |
103 CleanupStack::PushL(fs); |
103 CleanupStack::PushL(fs); |
104 User::LeaveIfError(fs->Connect()); |
104 User::LeaveIfError(fs->Connect()); |
105 } |
105 } |
106 else |
106 else |
107 { |
107 { |
108 fs = aFs; |
108 fs = aFs; |
109 } |
109 } |
110 |
110 |
111 r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters ); |
111 r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters ); |
112 if( r == KErrInUse ) |
112 if( r == KErrInUse ) |
113 { |
113 { |
114 r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareAny); |
114 r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareAny); |
115 |
115 |
116 if (r == KErrInUse) |
116 if (r == KErrInUse) |
117 { |
117 { |
118 r = file.Open(*fs, aFileName, EFileStream | EFileRead | |
118 r = file.Open(*fs, aFileName, EFileStream | EFileRead | |
119 EFileShareReadersOnly); |
119 EFileShareReadersOnly); |
120 } |
120 } |
121 } |
121 } |
122 if(r == KErrNone) |
122 if(r == KErrNone) |
123 { |
123 { |
124 CleanupClosePushL(file); |
124 CleanupClosePushL(file); |
125 self = NewL(file); |
125 self = NewL(file); |
126 CleanupStack::PopAndDestroy(); |
126 CleanupStack::PopAndDestroy(); |
127 } |
127 } |
128 |
128 |
129 if (aFs == NULL) |
129 if (aFs == NULL) |
130 { |
130 { |
131 fs->Close(); |
131 fs->Close(); |
132 CleanupStack::PopAndDestroy(); |
132 CleanupStack::PopAndDestroy(); |