|
1 // Copyright (c) 2000-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 <apmrec.h> |
|
17 #include <apmstd.h> |
|
18 #include <f32file.h> |
|
19 #include "ebookmark.h" |
|
20 |
|
21 #ifdef __UI_FRAMEWORKS_V2__ |
|
22 #include <ecom/implementationproxy.h> |
|
23 #endif //__UI_FRAMEWORKS_V2__ |
|
24 |
|
25 const TInt KMimeEBookmarkRecognizerValue=0x10008ED4; |
|
26 const TUid KUidEBookmarkRecognizer={KMimeEBookmarkRecognizerValue}; |
|
27 const TInt KNumMimeTypes=1; // text/vnd.symbian.ebookmark |
|
28 |
|
29 _LIT8(KEBookmarkMimeType, "text/vnd.symbian.ebookmark"); |
|
30 |
|
31 |
|
32 // eBookmark datafields needed for recognition |
|
33 _LIT8(KFieldBeginMarker, "BEGIN:EBOOKMARK"); |
|
34 _LIT8(KFieldUrlMarker, "URL:"); |
|
35 |
|
36 _LIT(KEBookmarkFileExtension, ".eBm"); |
|
37 |
|
38 const TInt KUidEBookmarkRecognizerStringLength = 255; |
|
39 |
|
40 |
|
41 CEBookmarkRecognizer::CEBookmarkRecognizer() |
|
42 :CApaDataRecognizerType(KUidEBookmarkRecognizer,CApaDataRecognizerType::ENormal) |
|
43 { |
|
44 iConfidence = ENotRecognized; |
|
45 iCountDataTypes = KNumMimeTypes; |
|
46 } |
|
47 |
|
48 TUint CEBookmarkRecognizer::PreferredBufSize() |
|
49 { |
|
50 return KUidEBookmarkRecognizerStringLength; |
|
51 } |
|
52 |
|
53 TDataType CEBookmarkRecognizer::SupportedDataTypeL(TInt aIndex) const |
|
54 { |
|
55 __ASSERT_ALWAYS(aIndex>=0 && aIndex<KNumMimeTypes,User::Invariant()); |
|
56 return TDataType(KEBookmarkMimeType); |
|
57 } |
|
58 |
|
59 void CEBookmarkRecognizer::DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer) |
|
60 { |
|
61 iConfidence = ENotRecognized; |
|
62 |
|
63 |
|
64 TInt beginFieldPos = aBuffer.FindF(KFieldBeginMarker); |
|
65 TInt urlFieldPos = aBuffer.FindF(KFieldUrlMarker); |
|
66 |
|
67 if (beginFieldPos >= 0 && urlFieldPos > beginFieldPos) |
|
68 // must find fields BEGIN: and URL: |
|
69 { |
|
70 iDataType=TDataType(KEBookmarkMimeType); |
|
71 |
|
72 const TInt positionOfDot=aName.LocateReverse('.'); |
|
73 if ((positionOfDot>=0) && |
|
74 (aName.Mid(positionOfDot).CompareF(KEBookmarkFileExtension) == 0)) |
|
75 iConfidence = ECertain; |
|
76 else |
|
77 iConfidence = EProbable; |
|
78 |
|
79 } |
|
80 |
|
81 } |
|
82 |
|
83 |
|
84 #ifdef __UI_FRAMEWORKS_V2__ |
|
85 |
|
86 const TImplementationProxy ImplementationTable[]= |
|
87 { |
|
88 IMPLEMENTATION_PROXY_ENTRY(0x10008ED4,CEBookmarkRecognizer::NewL) |
|
89 }; |
|
90 |
|
91 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
92 { |
|
93 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
94 return ImplementationTable; |
|
95 } |
|
96 |
|
97 CApaDataRecognizerType* CEBookmarkRecognizer::NewL() |
|
98 { |
|
99 return new (ELeave) CEBookmarkRecognizer(); |
|
100 } |
|
101 |
|
102 #else |
|
103 |
|
104 EXPORT_C CApaDataRecognizerType* CreateRecognizer() |
|
105 // The gate function - ordinal 1 |
|
106 // |
|
107 { |
|
108 CApaDataRecognizerType* thing=new CEBookmarkRecognizer(); |
|
109 return thing; // NULL if new failed |
|
110 } |
|
111 |
|
112 #endif //__UI_FRAMEWORKS_V2__ |
|
113 |
|
114 |
|
115 #ifndef EKA2 |
|
116 GLDEF_C TInt E32Dll(TDllReason /*aReason*/) |
|
117 // |
|
118 // DLL entry point |
|
119 // |
|
120 { |
|
121 return KErrNone; |
|
122 } |
|
123 #endif // EKA2 |