|
1 /* |
|
2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of PnPMS components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <apmrec.h> |
|
21 #include <apmstd.h> |
|
22 |
|
23 #include <f32file.h> |
|
24 #include <implementationproxy.h> |
|
25 |
|
26 #include "recnhwr.h" |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KNhwrRecognizerValue=0x1020433B; |
|
30 const TUid KUidNhwrRecognizer={KNhwrRecognizerValue}; |
|
31 _LIT8(KDataTypeNhwr, "application/vnd.nokia.headwrapper"); |
|
32 _LIT(KNhwrExtension,".wbf"); |
|
33 _LIT8(KHeader,"NHWR"); |
|
34 const TInt KHeaderLength = 4; |
|
35 |
|
36 // Constructor |
|
37 CApaNhwrRecognizer::CApaNhwrRecognizer() |
|
38 :CApaDataRecognizerType( KUidNhwrRecognizer,CApaDataRecognizerType::ENormal ) |
|
39 { |
|
40 //LOGSTRING( "Constructor" ); |
|
41 iCountDataTypes = 1; |
|
42 } |
|
43 |
|
44 // Destructor |
|
45 CApaNhwrRecognizer::~CApaNhwrRecognizer() |
|
46 { |
|
47 //LOGSTRING( "Destructor" ); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CApaNhwrRecognizer::PreferredBufSize |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 TUint CApaNhwrRecognizer::PreferredBufSize() |
|
55 { |
|
56 //LOGSTRING( "PreferredBufSize" ); |
|
57 return KHeaderLength; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CApaNhwrRecognizer::SupportedDataTypeL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 TDataType CApaNhwrRecognizer::SupportedDataTypeL( TInt aIndex ) const |
|
65 { |
|
66 //LOGSTRING( "SupportedDataTypeL" ); |
|
67 __ASSERT_DEBUG( aIndex >= 0 && aIndex < 1, User::Invariant() ); |
|
68 |
|
69 switch ( aIndex ) |
|
70 { |
|
71 case 0: |
|
72 //LOGSTRING( "SupportedDataTypeL - done" ); |
|
73 return TDataType(KDataTypeNhwr); |
|
74 default: |
|
75 //LOGSTRING( "SupportedDataTypeL - done" ); |
|
76 return TDataType(); |
|
77 } |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CApaNhwrRecognizer::DoRecognizeL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CApaNhwrRecognizer::DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer ) |
|
85 { |
|
86 //LOGSTRING( "DoRecognizeL" ); |
|
87 |
|
88 if(aName.Length()>0) |
|
89 { |
|
90 TParse parse; |
|
91 parse.Set(aName,NULL,NULL); |
|
92 if(parse.Ext().Compare(KNhwrExtension)==0) |
|
93 { |
|
94 iDataType = TDataType(KDataTypeNhwr); |
|
95 //LOGSTRING( "confidence EProbable" ); |
|
96 iConfidence = EProbable; |
|
97 } |
|
98 } |
|
99 |
|
100 // File content |
|
101 if (aBuffer.Length() >= KHeaderLength) |
|
102 { |
|
103 |
|
104 if ( aBuffer.FindF(KHeader) == 0) |
|
105 { |
|
106 iDataType = TDataType(KDataTypeNhwr); |
|
107 //LOGSTRING( "confidence ECertain" ); |
|
108 iConfidence = ECertain; |
|
109 //LOGSTRING( "DoRecognizeL - done" ); |
|
110 return; |
|
111 } |
|
112 } |
|
113 |
|
114 //LOGSTRING( "DoRecognizeL - done" ); |
|
115 return; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CApaNhwrRecognizer::CreateRecognizerL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CApaDataRecognizerType* CApaNhwrRecognizer::CreateRecognizerL() |
|
123 { |
|
124 //LOGSTRING( "CreateRecognizerL" ); |
|
125 return new (ELeave) CApaNhwrRecognizer(); |
|
126 } |
|
127 |
|
128 // CApaNhwrRecognizer::ImplementationTable |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 const TImplementationProxy ImplementationTable[] = |
|
132 { |
|
133 IMPLEMENTATION_PROXY_ENTRY( KNhwrRecognizerValue, CApaNhwrRecognizer::CreateRecognizerL) |
|
134 }; |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CApaNhwrRecognizer::ImplementationGroupProxy |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
141 { |
|
142 //LOGSTRING( "ImplementationGroupProxy" ); |
|
143 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
144 return ImplementationTable; |
|
145 } |