|
1 // Copyright (c) 2010 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 // This recognizer is part of the supporting test code for T_ForceRegStep.CPP |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent - Internal Symbian test code |
|
21 */ |
|
22 |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <apmstd.h> |
|
26 #include <apmrec.h> |
|
27 #include <f32file.h> |
|
28 |
|
29 #include <apfrec.h> |
|
30 #include <ecom/implementationproxy.h> |
|
31 |
|
32 _LIT8(KLit8_DataType_ForceRegApp1, "x-epoc/forcregapp1"); |
|
33 _LIT8(KLit8_DataType_ForceRegApp2, "x-epoc/forcregapp2"); |
|
34 _LIT8(KLit8_DataType_ForceRegApp3, "x-epoc/forcregapp3"); |
|
35 _LIT8(KLit8_DataType_ForceRegApp4, "x-epoc/forcregapp4"); |
|
36 |
|
37 const TUid KUidForceRegAppRecognizer={0xA0001010}; |
|
38 const TUint KImplForceRegAppRecognizer=0xA0001010; |
|
39 |
|
40 enum TMimeTypes |
|
41 { |
|
42 EMimeType1 = 0, |
|
43 EMimeType2, |
|
44 EMimeType3, |
|
45 EMimeType4, |
|
46 EMimeLast |
|
47 }; |
|
48 |
|
49 _LIT(KLitMimeExtension1, ".FRG1"); |
|
50 _LIT(KLitMimeExtension2, ".FRG2"); |
|
51 _LIT(KLitMimeExtension3, ".FRG3"); |
|
52 _LIT(KLitMimeExtension4, ".FRG4"); |
|
53 |
|
54 |
|
55 // CTForceRegAppRec definition |
|
56 |
|
57 class CTForceRegAppRec : public CApaDataRecognizerType |
|
58 { |
|
59 public: |
|
60 CTForceRegAppRec(); |
|
61 static CApaDataRecognizerType* CreateRecognizerL(); |
|
62 private: |
|
63 // from CApaDataRecognizerType |
|
64 virtual TUint PreferredBufSize(); |
|
65 virtual TDataType SupportedDataTypeL(TInt aIndex) const; |
|
66 virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer); |
|
67 }; |
|
68 |
|
69 |
|
70 // CTForceRegAppRec implementation |
|
71 |
|
72 CTForceRegAppRec::CTForceRegAppRec() |
|
73 :CApaDataRecognizerType(KUidForceRegAppRecognizer, EHigh) |
|
74 { |
|
75 iCountDataTypes = EMimeLast; |
|
76 } |
|
77 |
|
78 TUint CTForceRegAppRec::PreferredBufSize() |
|
79 { |
|
80 return 0; |
|
81 } |
|
82 |
|
83 TDataType CTForceRegAppRec::SupportedDataTypeL(TInt aIndex) const |
|
84 { |
|
85 if (aIndex == EMimeType1) |
|
86 return TDataType(KLit8_DataType_ForceRegApp1); |
|
87 |
|
88 else if (aIndex == EMimeType2) |
|
89 return TDataType(KLit8_DataType_ForceRegApp2); |
|
90 |
|
91 else if (aIndex == EMimeType3) |
|
92 return TDataType(KLit8_DataType_ForceRegApp3); |
|
93 |
|
94 else if (aIndex == EMimeType4) |
|
95 return TDataType(KLit8_DataType_ForceRegApp4); |
|
96 |
|
97 else |
|
98 return TDataType(KNullDesC8); |
|
99 } |
|
100 |
|
101 |
|
102 void CTForceRegAppRec::DoRecognizeL(const TDesC& aName, const TDesC8&) |
|
103 { |
|
104 |
|
105 // Compare if the file extension is known |
|
106 if (aName.Length() < 5) |
|
107 { |
|
108 iDataType = TDataType(KNullDesC8); |
|
109 iConfidence = ENotRecognized; |
|
110 return; |
|
111 } |
|
112 |
|
113 if (aName.Right(5).CompareF(KLitMimeExtension1) == 0) |
|
114 { |
|
115 iDataType = TDataType(KLit8_DataType_ForceRegApp1); |
|
116 iConfidence = ECertain; |
|
117 } |
|
118 else if (aName.Right(5).CompareF(KLitMimeExtension2) == 0) |
|
119 { |
|
120 iDataType = TDataType(KLit8_DataType_ForceRegApp2); |
|
121 iConfidence = ECertain; |
|
122 } |
|
123 else if (aName.Right(5).CompareF(KLitMimeExtension3) == 0) |
|
124 { |
|
125 iDataType = TDataType(KLit8_DataType_ForceRegApp3); |
|
126 iConfidence = ECertain; |
|
127 } |
|
128 else if (aName.Right(5).CompareF(KLitMimeExtension4) == 0) |
|
129 { |
|
130 iDataType = TDataType(KLit8_DataType_ForceRegApp4); |
|
131 iConfidence = ECertain; |
|
132 } |
|
133 else |
|
134 { |
|
135 iDataType = TDataType(KNullDesC8); |
|
136 iConfidence = ENotRecognized; |
|
137 } |
|
138 } |
|
139 |
|
140 // stand-alone functions |
|
141 |
|
142 CApaDataRecognizerType* CTForceRegAppRec::CreateRecognizerL() |
|
143 { |
|
144 return new (ELeave) CTForceRegAppRec(); |
|
145 } |
|
146 |
|
147 const TImplementationProxy ImplementationTable[] = |
|
148 { |
|
149 IMPLEMENTATION_PROXY_ENTRY(KImplForceRegAppRecognizer, CTForceRegAppRec::CreateRecognizerL) |
|
150 }; |
|
151 |
|
152 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
153 { |
|
154 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
155 return ImplementationTable; |
|
156 } |
|
157 |