1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/PtiCore.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,458 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Predective text input engine core interface.
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +
1.26 +
1.27 +
1.28 +
1.29 +
1.30 +
1.31 +
1.32 +
1.33 +
1.34 +#ifndef _PTI_CORE_H
1.35 +#define _PTI_CORE_H
1.36 +
1.37 +// INCLUDES
1.38 +#include <badesca.h>
1.39 +#include "PtiDefs.h"
1.40 +#include "PtiLanguage.h"
1.41 +#include "PtiUserDictionary.h"
1.42 +
1.43 +// FORWARD DECLARATIONS
1.44 +class CPtiEngine;
1.45 +class MPtiEngineCompositionDataInterface;
1.46 +class MPtiUserDictionaryEntry;
1.47 +
1.48 +// CONSTANTS
1.49 +const TInt KDefaultCoresGran = 3;
1.50 +
1.51 +/**
1.52 +* This is abstract base class of all PtiEngine core objects. A PtiEngine core object implements set of
1.53 +* input modes and input related services for a set of languages. This class defines core side
1.54 +* PtiEngine API.
1.55 +*/
1.56 +class MPtiCore
1.57 + {
1.58 + //
1.59 + // General API
1.60 + //
1.61 + public:
1.62 + /**
1.63 + * Initialized core object. This method is called by PtiEngine framework when core object
1.64 + * is loaded.
1.65 + *
1.66 + * @since 2.6
1.67 + * @param aOwner Pointer to onwing PtiEngine framework instance.
1.68 + * @param aTextBuffer A pointer to PtiEngine main text buffer.
1.69 + * @param aLanguageList A language list to be filled with language bindings to this core
1.70 + * onbject
1.71 + * @param aUseDefautUserDictionary A boolean value indicating whether default user dictionary shoulkd be used
1.72 + * (in case this core object supports user dictionaries).
1.73 + */
1.74 + virtual void InitializeL(CPtiEngine* aOwner, TDes* aTextBuffer, CArrayPtrFlat<CPtiCoreLanguage>* aLanguageList, TBool aUseDefautUserDictionary) = 0;
1.75 +
1.76 + /**
1.77 + * Removes languages associated to this core object from given language list. Languages
1.78 + * not associated to this core abject are not touched.
1.79 + *
1.80 + * @since 2.6
1.81 + * @param aLanguageList A language list to be cleaned.
1.82 + */
1.83 + virtual void DropLanguages(CArrayPtrFlat<CPtiCoreLanguage>* aLanguageList) = 0;
1.84 +
1.85 + /**
1.86 + * Opens resources for given language and itinialized them.
1.87 + *
1.88 + * @since 2.6
1.89 + * @param aLanguage Symbian OS language code a language to be initialized.
1.90 + * @return KErrNone or a system wide error code.
1.91 + */
1.92 + virtual TInt OpenLanguageL(CPtiCoreLanguage *aLanguage) = 0;
1.93 +
1.94 + /**
1.95 + * Closes currently activate language and frees resources associated to it.
1.96 + *
1.97 + * @since 2.6
1.98 + * @return KErrNone of system wide error ocde.
1.99 + */
1.100 + virtual TInt CloseLanguageL() = 0;
1.101 +
1.102 + /**
1.103 + * Returns the contents of text buffer.
1.104 + *
1.105 + * @since 2.6
1.106 + * @return A constant pointer to text buffer.
1.107 + */
1.108 + virtual TPtrC GetCurrentWord() const = 0;
1.109 +
1.110 + /**
1.111 + * Commits current word. Commiting means that user has added current
1.112 + * word as part of text. Frequency information and other related attributes
1.113 + * can then be updated.
1.114 + *
1.115 + * @since 2.6
1.116 + * @return KErrNone or a system wide error code.
1.117 + */
1.118 + virtual TInt CommitCurrentWord() = 0;
1.119 +
1.120 + /**
1.121 + * Returns a pointer core info structure. Core info struct contains useful
1.122 + * information about core object and its features.
1.123 + *
1.124 + */
1.125 + virtual MPtiCoreInfo* GetCoreInfo() = 0;
1.126 +
1.127 + /**
1.128 + * Turns reoreding feature on or off. Reordering means that prediction engine
1.129 + * maintains frequency information for used words and modifys the order of candidate list
1.130 + * based on that information. This feature may not be supported by all prediction engines.
1.131 + *
1.132 + * @since 2.6
1.133 + * @param aStatus New status for reorderinf feature.
1.134 + * @return KErrNone or a system wide error code.
1.135 + */
1.136 + virtual TInt SetReordering(TBool aStatus) = 0;
1.137 +
1.138 + /**
1.139 + * This is the single most important core API method, most of the text input functionality
1.140 + * will be utilize this method. Call to this method indicates core object that a key was
1.141 + * pressed and it should act accordingly and fill the output buffer.
1.142 + *
1.143 + * @since 2.6
1.144 + * @param aKey Enum value for pressed key.
1.145 + */
1.146 + virtual void AppendKeyPress(TPtiKey aKey) = 0;
1.147 +
1.148 + /**
1.149 + * Indicates core object that it should perform 'delete key press'-operation.
1.150 + *
1.151 + * @since 2.6
1.152 + */
1.153 + virtual void DeleteKeyPress() = 0;
1.154 +
1.155 + /**
1.156 + * Call to this method notifys core object that input buffer was cleared.
1.157 + *
1.158 + * @since 2.6
1.159 + */
1.160 + virtual void ClearBuffer() = 0;
1.161 +
1.162 + /**
1.163 + * Sets current input sequence. The end result of this operation must be same as
1.164 + * if user had entered keys in input array as individual key presses.
1.165 + *
1.166 + * @since 2.6
1.167 + * @param aInput An array containing sequence of key presses (type TPtiKey).
1.168 + * @return KErrNone or a system wide error code.
1.169 + */
1.170 + virtual TInt SetCurrentInputSequence(TPtrC8 aInput) = 0;
1.171 +
1.172 + /**
1.173 + * Converts given string from one character set to another. Possible conversion types
1.174 + * are defined in PtiDefs.h
1.175 + *
1.176 + * @since 2.6
1.177 + * @param aType Conversion type.
1.178 + * @param aInput Pointer to input string to be converted.
1.179 + * @param aInputLength Length of input buffer.
1.180 + * @param aOutput pointer to output buffer.
1.181 + * @return KErrNone or a system wide error code.
1.182 + */
1.183 + virtual TInt Convert(TPtiCharConversion aType,
1.184 + TAny* aInput,
1.185 + TInt aInputLength,
1.186 + TAny* aOutput) = 0;
1.187 +
1.188 + /**
1.189 + * Re-defines keymappings for given key / input mode / case combination. Previous
1.190 + * keymapping will be deleted and new mappings will be used instead.
1.191 + *
1.192 + * @since 2.6
1.193 + * @param aMode Input mode for new key mapping.
1.194 + * @param aKey A key to be replaced.
1.195 + * @param aKeyMap New keymapping data for aKey.
1.196 + * @param aCase Text case to be replaced.
1.197 + * @return KErrNone or system wide error code.
1.198 + */
1.199 + virtual TInt SetExternalKeyMapL(TPtiEngineInputMode aMode,
1.200 + TPtiKey aKey,
1.201 + TDesC& aKeyMap,
1.202 + TPtiTextCase aCase) = 0;
1.203 + /**
1.204 + * Returns alternate spelling for given unicode characters. Possible conversion
1.205 + * types are defined in header PtiDefs.h.
1.206 + *
1.207 + * @sinec 2.6
1.208 + * @aInput A character to be converted.
1.209 + * @aOutput Resulting alternate spelling will be stored here.
1.210 + * @aType Spelling conversion type.
1.211 + * @return KErrNone or system wide error code.
1.212 + */
1.213 + virtual TInt GetSpelling(TUint16 aInput, TDes& aOutput, TPtiSpelling aType) = 0;
1.214 +
1.215 + /**
1.216 + * Cancels all on-going core obejct timner activity.
1.217 + *
1.218 + * @since 2.6
1.219 + * @return KErrNone or system wide error code.
1.220 + */
1.221 + virtual TInt CancelTimerActivity() = 0;
1.222 +
1.223 + /**
1.224 + * A generic command handling method for extending PtiEngine API without adding
1.225 + * new base class methods. It is recommended to use this only in force major
1.226 + * situations, where there is no other way.
1.227 + *
1.228 + * @since 2.6
1.229 + * @param aCommand A Command id value. Platform wide command ids are defined in PtiDefs.h.
1.230 + * @param aParams TAny pointer for passing any required parameters.
1.231 + * @return An integer containing possible return value related to command.
1.232 + */
1.233 + virtual TInt HandleCommandL(TPtiEngineCommand aCommand, TAny* aParams) = 0;
1.234 +
1.235 + //
1.236 + // Predictive latin API
1.237 + //
1.238 + public:
1.239 + /**
1.240 + * Returns number of candidates for currently entered key sequence.
1.241 + *
1.242 + * @since 2.6
1.243 + * @return Number of prediction candidates for currently entered key sequence.
1.244 + */
1.245 + virtual TInt NumberOfCandidates() = 0;
1.246 +
1.247 + /**
1.248 + * Returns a list of candidate words for currently entered key sequence.
1.249 + *
1.250 + * @since 2.6
1.251 + * @param aList A list to be filled with candidate words.
1.252 + * @return Number of candidate works in aList.
1.253 + */
1.254 + virtual TInt GetCandidateListL(CDesCArray& aList) = 0;
1.255 +
1.256 + /**
1.257 + * Returns next word candidate list. Next word candidates are words
1.258 + * potentially related to currently selected candidate. Next word prediction
1.259 + * feature must supported by the engine and turned on.
1.260 + *
1.261 + * @since 2.6
1.262 + */
1.263 + virtual TInt GetNextWordCandidateListL(CDesCArray& aList) = 0;
1.264 +
1.265 + /**
1.266 + * Returns first word in list of candidate words for current input sequence.
1.267 + *
1.268 + * @since 2.6
1.269 + * @param aResult A descriptor where resulting word will be stored.
1.270 + * @return KErrnNone or system wide error code.
1.271 + */
1.272 + virtual TInt GetFirstCandidate(TDes& aResult) = 0;
1.273 +
1.274 + /**
1.275 + * Returns next word in list of candidate words for current input sequence.
1.276 + *
1.277 + * @since 2.6
1.278 + * @param aResult A descriptor where resulting word will be stored.
1.279 + * @return KErrnNone or system wide error code.
1.280 + */
1.281 + virtual TInt GetNextCandidate(TDes& aResult) = 0;
1.282 +
1.283 + /**
1.284 + * Returns previous word in list of candidate words for current input sequence.
1.285 + *
1.286 + * @since 2.6
1.287 + * @param aResult A descriptor where resulting word will be stored.
1.288 + * @return KErrnNone or system wide error code.
1.289 + */
1.290 + virtual TInt GetPreviousCandidate(TDes& aResult) = 0;
1.291 +
1.292 + //
1.293 + // User dictionary API
1.294 + //
1.295 + public:
1.296 + virtual TInt AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry, CPtiUserDictionary* aDict) = 0;
1.297 + virtual TInt RemoveUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry, CPtiUserDictionary* aDict) = 0;
1.298 + virtual TInt NumberOfEntriesInUserDictionary(CPtiUserDictionary* aDict) = 0;
1.299 + virtual TInt GetUserDictionaryEntry(TInt aIndex, MPtiUserDictionaryEntry& aResult, CPtiUserDictionary* aDict) = 0;
1.300 + virtual CPtiUserDictionary* CreateEmptyUserDictionaryL(TInt aMaxSize) = 0;
1.301 + virtual TInt AttachUserDictionary(CPtiUserDictionary* aDict) = 0;
1.302 + virtual TBool DetachUserDictionary(CPtiUserDictionary* aDict) = 0;
1.303 +
1.304 + //
1.305 + // Chinese API
1.306 + //
1.307 + public:
1.308 + virtual TPtrC GetCandidatePage() = 0;
1.309 + virtual TBool NextCandidatePage() = 0;
1.310 + virtual TBool PreviousCandidatePage() = 0;
1.311 + virtual TBool MoreCandidatePages() = 0;
1.312 + virtual void SetCandidatePageLength(TInt aLength) = 0;
1.313 + virtual TPtrC GetPhoneticSpelling(TInt aIndex) const = 0;
1.314 + virtual TInt PhoneticSpellingCount() const = 0;
1.315 + virtual TBool SelectPhoneticSpelling(TInt aIndex) = 0;
1.316 + virtual TInt SelectedPhoneticSpelling() const = 0;
1.317 + virtual TBool ToneMark(TText& aToneMark) const = 0;
1.318 + virtual TBool IsToneMarkValidForSpelling() = 0;
1.319 + virtual TBool SetPredictiveChineseChar(const TDesC& aChar) = 0;
1.320 + virtual TBool SetToneMark(TInt aToneMark) = 0;
1.321 +
1.322 +
1.323 + //
1.324 + // Japanese API
1.325 + //
1.326 + public:
1.327 + virtual TPtrC ReadingTextL() = 0;
1.328 + virtual MPtiEngineCompositionDataInterface* CompositionData() = 0;
1.329 +
1.330 + //
1.331 + // Chinese API
1.332 + //
1.333 + public:
1.334 + virtual HBufC* GetCandidatesByInputString(const TDesC& aInputString,
1.335 + RPointerArray<HBufC>& aList,
1.336 + const TBool aIsPredictive) = 0;
1.337 + };
1.338 +
1.339 +
1.340 +/**
1.341 +* This class is a base class implementation for MPtiCore. It contains empty base implemenations
1.342 +* for core API methods and static methods for creating and listing PtiEngine core objects.
1.343 +*/
1.344 +class CPtiCore : public CBase, public MPtiCore
1.345 + {
1.346 + //
1.347 + // Plugin household methods
1.348 + //
1.349 + public:
1.350 + /**
1.351 + * Creates in instance of core object for given implemenation uid.
1.352 + *
1.353 + * @param aCoreUid An ecom implementation uid for core object to be created.
1.354 + * @return Pointer to new core object instance.
1.355 + */
1.356 + IMPORT_C static CPtiCore* CreateCoreL(TUid aCoreUid);
1.357 +
1.358 + /**
1.359 + * Lists all the available PtiEngine core onject implemenatations.
1.360 + *
1.361 + * @return Pointer to a list cantaining implementation uids for available core plugins.
1.362 + */
1.363 + IMPORT_C static CArrayFix<TInt>* ListCoresLC();
1.364 +
1.365 + public:
1.366 + IMPORT_C ~CPtiCore();
1.367 +
1.368 + //
1.369 + // General methods.
1.370 + //
1.371 + public:
1.372 + IMPORT_C TInt SetCurrentInputSequence(TPtrC8 aInput);
1.373 + IMPORT_C TInt Convert(TPtiCharConversion aType,
1.374 + TAny* aInput,
1.375 + TInt aInputLength,
1.376 + TAny* aOutput);
1.377 + IMPORT_C TInt GetSpelling(TUint16 aInput,
1.378 + TDes& aOutput,
1.379 + TPtiSpelling aType);
1.380 + IMPORT_C TInt SetExternalKeyMapL(TPtiEngineInputMode aMode,
1.381 + TPtiKey aKey,
1.382 + TDesC& aKeyMap,
1.383 + TPtiTextCase aCase);
1.384 + IMPORT_C TInt CommitCurrentWord();
1.385 + IMPORT_C TPtrC GetCurrentWord() const;
1.386 +
1.387 + //
1.388 + // Predictive latin API
1.389 + //
1.390 + public:
1.391 + IMPORT_C TInt NumberOfCandidates();
1.392 + IMPORT_C TInt GetCandidateListL(CDesCArray& aList);
1.393 + IMPORT_C TInt GetNextWordCandidateListL(CDesCArray& aList);
1.394 + IMPORT_C TInt GetFirstCandidate(TDes& aResult);
1.395 + IMPORT_C TInt GetNextCandidate(TDes& aResult);
1.396 + IMPORT_C TInt GetPreviousCandidate(TDes& aResult);
1.397 +
1.398 + //
1.399 + // User dictionary API
1.400 + //
1.401 + public:
1.402 + IMPORT_C TInt AddUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry, CPtiUserDictionary* aDict);
1.403 + IMPORT_C TInt RemoveUserDictionaryEntry(MPtiUserDictionaryEntry& aEntry, CPtiUserDictionary* aDict);
1.404 + IMPORT_C TInt NumberOfEntriesInUserDictionary(CPtiUserDictionary* aDict);
1.405 + IMPORT_C TInt GetUserDictionaryEntry(TInt aIndex, MPtiUserDictionaryEntry& aResult, CPtiUserDictionary* aDict);
1.406 + IMPORT_C CPtiUserDictionary* CreateEmptyUserDictionaryL(TInt aMaxSize);
1.407 + IMPORT_C TInt AttachUserDictionary(CPtiUserDictionary* aDict);
1.408 + IMPORT_C TBool DetachUserDictionary(CPtiUserDictionary* aDict);
1.409 +
1.410 + //
1.411 + // Chinese API
1.412 + //
1.413 + public:
1.414 + IMPORT_C TPtrC GetCandidatePage();
1.415 + IMPORT_C TBool NextCandidatePage();
1.416 + IMPORT_C TBool PreviousCandidatePage();
1.417 + IMPORT_C TBool MoreCandidatePages();
1.418 + IMPORT_C void SetCandidatePageLength(TInt aLength);
1.419 + IMPORT_C TPtrC GetPhoneticSpelling(TInt aIndex) const;
1.420 + IMPORT_C TInt PhoneticSpellingCount() const;
1.421 + IMPORT_C TBool SelectPhoneticSpelling(TInt aIndex);
1.422 + IMPORT_C TInt SelectedPhoneticSpelling() const;
1.423 + IMPORT_C TBool ToneMark(TText& aToneMark) const;
1.424 + IMPORT_C TBool IsToneMarkValidForSpelling();
1.425 + IMPORT_C TBool SetPredictiveChineseChar(const TDesC& aChar);
1.426 + IMPORT_C TBool SetToneMark(TInt aToneMark);
1.427 +
1.428 + //
1.429 + // Japanese API
1.430 + //
1.431 + public:
1.432 + IMPORT_C TPtrC ReadingTextL();
1.433 + IMPORT_C MPtiEngineCompositionDataInterface* CompositionData();
1.434 +
1.435 + //
1.436 + // Chinese API
1.437 + //
1.438 + public:
1.439 + IMPORT_C HBufC* GetCandidatesByInputString(const TDesC& aInputString,
1.440 + RPointerArray<HBufC>& aList,
1.441 + const TBool aIsPredictive);
1.442 +
1.443 + private:
1.444 + inline void SetDestructorKeyId(TInt aDtorKeyId);
1.445 +
1.446 + private:
1.447 + TInt iDtorKeyId;
1.448 + TInt Reserved_1;
1.449 + };
1.450 +
1.451 +
1.452 +inline void CPtiCore::SetDestructorKeyId(TInt aDtorKeyId)
1.453 + {
1.454 + iDtorKeyId = aDtorKeyId;
1.455 + }
1.456 +
1.457 +#endif _PTI_CORE_H
1.458 +
1.459 +// End of file
1.460 +
1.461 +