|
1 // Copyright (c) 2005-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 // This recognizer is part of the supporting test code for T_NonNativeAppsStep.CPP |
|
15 // This recognizer only exists to associate the document names defined in T_NonNativeAppsStep.h |
|
16 // with the TstNonNativeApp.exe application. |
|
17 // This enables T_NonNativeAppsSt ep.CPP to launch TstNonNativeApp.app by starting the document names. |
|
18 // |
|
19 // |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent - Internal Symbian test code |
|
24 */ |
|
25 |
|
26 #include <e32std.h> |
|
27 #include <e32base.h> |
|
28 #include <apmstd.h> |
|
29 #include <apmrec.h> |
|
30 #include <f32file.h> |
|
31 |
|
32 #include <apfrec.h> |
|
33 #include <ecom/implementationproxy.h> |
|
34 |
|
35 _LIT8(KLit8_DataType_Gif, "x-epoc/nna-gif"); |
|
36 _LIT8(KLit8_DataType_Html, "x-epoc/nna-html"); |
|
37 _LIT8(KLit8_DataType_Vcard, "x-epoc/nna-vcf"); |
|
38 _LIT8(KLit8_DataType_plainText, "x-epoc/nna-txt"); |
|
39 |
|
40 const TUid KUidNonNativeRecognizer={0x10207f95}; |
|
41 const TUint KImplNonNativeRecognizer=0x10207f96; |
|
42 |
|
43 enum TMimeTypes |
|
44 { |
|
45 EMimeTypeNnt1 = 0, |
|
46 EMimeTypeNnt2, |
|
47 EMimeTypeNnt3, |
|
48 EMimeTypeNnt4, |
|
49 EMimeLast |
|
50 }; |
|
51 |
|
52 _LIT(KLitMimeExtensionNnt1, ".NNA1"); |
|
53 _LIT(KLitMimeExtensionNnt2, ".NNA2"); |
|
54 _LIT(KLitMimeExtensionNnt3, ".NNA3"); |
|
55 _LIT(KLitMimeExtensionNnt4, ".NNA4"); |
|
56 |
|
57 |
|
58 // CTNonNativeRec definition |
|
59 |
|
60 class CTNonNativeRec : public CApaDataRecognizerType |
|
61 { |
|
62 public: |
|
63 CTNonNativeRec(); |
|
64 static CApaDataRecognizerType* CreateRecognizerL(); |
|
65 private: |
|
66 // from CApaDataRecognizerType |
|
67 virtual TUint PreferredBufSize(); |
|
68 virtual TDataType SupportedDataTypeL(TInt aIndex) const; |
|
69 virtual void DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer); |
|
70 }; |
|
71 |
|
72 |
|
73 // CTNonNativeRec implementation |
|
74 |
|
75 CTNonNativeRec::CTNonNativeRec() |
|
76 :CApaDataRecognizerType(KUidNonNativeRecognizer, EHigh) |
|
77 { |
|
78 iCountDataTypes = EMimeLast; |
|
79 } |
|
80 |
|
81 TUint CTNonNativeRec::PreferredBufSize() |
|
82 { |
|
83 return 0; |
|
84 } |
|
85 |
|
86 TDataType CTNonNativeRec::SupportedDataTypeL(TInt aIndex) const |
|
87 { |
|
88 if (aIndex == EMimeTypeNnt1) |
|
89 return TDataType(KLit8_DataType_Gif); |
|
90 |
|
91 else if (aIndex == EMimeTypeNnt2) |
|
92 return TDataType(KLit8_DataType_Html); |
|
93 |
|
94 else if (aIndex == EMimeTypeNnt3) |
|
95 return TDataType(KLit8_DataType_Vcard); |
|
96 |
|
97 else if (aIndex == EMimeTypeNnt4) |
|
98 return TDataType(KLit8_DataType_plainText); |
|
99 |
|
100 else |
|
101 return TDataType(KNullDesC8); |
|
102 } |
|
103 |
|
104 |
|
105 void CTNonNativeRec::DoRecognizeL(const TDesC& aName, const TDesC8&) |
|
106 { |
|
107 |
|
108 // Compare if the file extension is known |
|
109 if (aName.Length() < 5) |
|
110 { |
|
111 iDataType = TDataType(KNullDesC8); |
|
112 iConfidence = ENotRecognized; |
|
113 return; |
|
114 } |
|
115 |
|
116 if (aName.Right(5).CompareF(KLitMimeExtensionNnt1) == 0) |
|
117 { |
|
118 iDataType = TDataType(KLit8_DataType_Gif); |
|
119 iConfidence = ECertain; |
|
120 } |
|
121 else if (aName.Right(5).CompareF(KLitMimeExtensionNnt2) == 0) |
|
122 { |
|
123 iDataType = TDataType(KLit8_DataType_Html); |
|
124 iConfidence = ECertain; |
|
125 } |
|
126 else if (aName.Right(5).CompareF(KLitMimeExtensionNnt3) == 0) |
|
127 { |
|
128 iDataType = TDataType(KLit8_DataType_Vcard); |
|
129 iConfidence = ECertain; |
|
130 } |
|
131 else if (aName.Right(5).CompareF(KLitMimeExtensionNnt4) == 0) |
|
132 { |
|
133 iDataType = TDataType(KLit8_DataType_plainText); |
|
134 iConfidence = ECertain; |
|
135 } |
|
136 else |
|
137 { |
|
138 iDataType = TDataType(KNullDesC8); |
|
139 iConfidence = ENotRecognized; |
|
140 } |
|
141 } |
|
142 |
|
143 // stand-alone functions |
|
144 |
|
145 CApaDataRecognizerType* CTNonNativeRec::CreateRecognizerL() |
|
146 { |
|
147 return new (ELeave) CTNonNativeRec(); |
|
148 } |
|
149 |
|
150 const TImplementationProxy ImplementationTable[] = |
|
151 { |
|
152 IMPLEMENTATION_PROXY_ENTRY(KImplNonNativeRecognizer, CTNonNativeRec::CreateRecognizerL) |
|
153 }; |
|
154 |
|
155 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
156 { |
|
157 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
158 return ImplementationTable; |
|
159 } |
|
160 |