|
1 // Copyright (c) 2007-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 "cmtpextensionmapping.h" |
|
17 |
|
18 CMTPExtensionMapping* CMTPExtensionMapping::NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode) |
|
19 { |
|
20 CMTPExtensionMapping* self = new (ELeave) CMTPExtensionMapping(aFormatCode); |
|
21 CleanupStack::PushL(self); |
|
22 self->ConstructL(aExtension,KNullDesC); |
|
23 CleanupStack::Pop(self); |
|
24 return self; |
|
25 } |
|
26 |
|
27 CMTPExtensionMapping* CMTPExtensionMapping::NewL(const TDesC& aExtension, TMTPFormatCode aFormatCode,const TDesC& aMIMEType) |
|
28 { |
|
29 CMTPExtensionMapping* self = new (ELeave) CMTPExtensionMapping(aFormatCode); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(aExtension,aMIMEType); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CMTPExtensionMapping::CMTPExtensionMapping(TMTPFormatCode aFormatCode) : |
|
37 iFormatCode(aFormatCode) |
|
38 { |
|
39 } |
|
40 |
|
41 void CMTPExtensionMapping::ConstructL(const TDesC& aExtension,const TDesC& aMIMEType) |
|
42 { |
|
43 iExtension = aExtension.AllocL(); |
|
44 iMIMEType = aMIMEType.AllocL(); |
|
45 } |
|
46 |
|
47 CMTPExtensionMapping::~CMTPExtensionMapping() |
|
48 { |
|
49 delete iExtension; |
|
50 delete iMIMEType; |
|
51 } |
|
52 |
|
53 const TDesC& CMTPExtensionMapping::Extension() const |
|
54 { |
|
55 return *iExtension; |
|
56 } |
|
57 |
|
58 const TDesC& CMTPExtensionMapping::MIMEType() const |
|
59 { |
|
60 return *iMIMEType; |
|
61 } |
|
62 |
|
63 TMTPFormatCode CMTPExtensionMapping::FormatCode() const |
|
64 { |
|
65 return iFormatCode; |
|
66 } |
|
67 |
|
68 TUint32 CMTPExtensionMapping::DpId() const |
|
69 { |
|
70 return iDpId; |
|
71 } |
|
72 |
|
73 TUint CMTPExtensionMapping::EnumerationFlag() const |
|
74 { |
|
75 return iNeedFileDp; |
|
76 } |
|
77 |
|
78 void CMTPExtensionMapping::SetExtensionL(const TDesC& aExtension) |
|
79 { |
|
80 delete iExtension; |
|
81 iExtension = NULL; |
|
82 |
|
83 iExtension = aExtension.AllocL(); |
|
84 } |
|
85 |
|
86 void CMTPExtensionMapping::SetMIMETypeL(const TDesC& aMIMEType) |
|
87 { |
|
88 delete iMIMEType; |
|
89 iMIMEType = NULL; |
|
90 |
|
91 iMIMEType = aMIMEType.AllocL(); |
|
92 } |
|
93 |
|
94 void CMTPExtensionMapping::SetDpId(const TUint32 aDpId) |
|
95 { |
|
96 iDpId = aDpId; |
|
97 } |
|
98 |
|
99 void CMTPExtensionMapping::SetFormatCode(const TMTPFormatCode aFormatCode) |
|
100 { |
|
101 iFormatCode = aFormatCode; |
|
102 } |
|
103 |
|
104 void CMTPExtensionMapping::SetEnumerationFlag(const TUint aNeedFileDp) |
|
105 { |
|
106 iNeedFileDp = aNeedFileDp; |
|
107 } |
|
108 |
|
109 TInt CMTPExtensionMapping::Compare(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond) |
|
110 { |
|
111 return (aFirst.Extension().CompareF(aSecond.Extension())); |
|
112 } |
|
113 |
|
114 TInt CMTPExtensionMapping::ComparewithMIME(const CMTPExtensionMapping& aFirst, const CMTPExtensionMapping& aSecond) |
|
115 { |
|
116 TInt i = Compare(aFirst,aSecond); |
|
117 if ( 0==i ) |
|
118 { |
|
119 return aFirst.MIMEType().CompareF(aSecond.MIMEType()); |
|
120 } |
|
121 return i; |
|
122 } |