|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Plugin for note information search. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 //SYSTEM INCLUDES |
|
22 #include <barsc.h> |
|
23 #include <f32file.h> |
|
24 #include <utf.h> |
|
25 |
|
26 //USER INCLUDES |
|
27 #include "notessearchpluginutils.h" |
|
28 #include "notessearchpluginpanic.h" |
|
29 |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // Performs the first phase of two phase construction. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CNotesSearchPluginUtils::CNotesSearchPluginUtils() |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // Destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CNotesSearchPluginUtils::~CNotesSearchPluginUtils() |
|
45 { |
|
46 delete iContentKey; |
|
47 iContentKey = NULL; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // Sets the Uid for mapping it with Description. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CNotesSearchPluginUtils::SetContentKeyL( const TDesC8& aContentKey) |
|
55 { |
|
56 iContentKey = HBufC8::NewL( aContentKey.Length() ); |
|
57 iContentKey->Des().Copy( aContentKey ); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // Sets the Uid for mapping it with Description. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CNotesSearchPluginUtils::SetKeywordPosition( const TInt& aKeywordPos ) |
|
65 { |
|
66 iKeywordPosition = aKeywordPos; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // Sets the content key. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CNotesSearchPluginUtils::SetContentKeyInt( const TInt & aKeyintvalue ) |
|
74 { |
|
75 iContentKeyInt = aKeyintvalue; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // Returns the content key . |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 HBufC8* CNotesSearchPluginUtils::ContentKey() |
|
83 { |
|
84 return iContentKey; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // Gives the KeyWordPosition for Snippet Creation. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 TInt CNotesSearchPluginUtils::KeywordPosition() |
|
92 { |
|
93 return iKeywordPosition; |
|
94 } |
|
95 |
|
96 |
|
97 TInt CNotesSearchPluginUtils::ContentKeyInt( ) |
|
98 { |
|
99 return iContentKeyInt; |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // PluginResourceReader::GetKeyWordPosition |
|
105 // static method to read text from resource file |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 HBufC8* PluginResourceReader::GetTextFromResourceL( TInt aResourceId , const TDesC& /*aResourecFilePath*/) |
|
109 { |
|
110 |
|
111 /*RFs fs; |
|
112 User::LeaveIfError(fs.Connect()); |
|
113 RResourceFile resourceFile; |
|
114 resourceFile.OpenL( fs , aResourecFilePath); */ |
|
115 |
|
116 RResourceFile resourceFile; |
|
117 HBufC8* readBuffer = resourceFile.AllocReadLC( aResourceId ); |
|
118 __ASSERT_DEBUG( (readBuffer->Length() % 2)==0, |
|
119 User::Panic(ECoePanicWrongResourceFormat,EPanicWrongResource) ); |
|
120 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(),(readBuffer->Length()+1)>>1); |
|
121 HBufC16* textBuffer = HBufC16::NewLC(ptrReadBuffer.Length()); |
|
122 *textBuffer=ptrReadBuffer; |
|
123 |
|
124 HBufC8* textBuffer8 = HBufC8::NewL( textBuffer->Length() ); |
|
125 TPtr8 ptr( textBuffer8->Des() ); |
|
126 CnvUtfConverter::ConvertFromUnicodeToUtf8( ptr ,*textBuffer); |
|
127 |
|
128 CleanupStack::PopAndDestroy( 3 ); |
|
129 /*resourceFile.Close(); |
|
130 fs.Close();*/ |
|
131 |
|
132 return textBuffer8; |
|
133 } |
|
134 |
|
135 //end of file |
|
136 |