textinput/ptikoreanqwertycore/inc/PtiKoreanQwertyCore.h
branchRCL_3
changeset 3 f5a1e66df979
equal deleted inserted replaced
0:eb1f2e154e89 3:f5a1e66df979
       
     1 /*
       
     2 * Copyright (c) 2002-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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __PTIKOREANQWERTYCORE_H__
       
    20 #define __PTIKOREANQWERTYCORE_H__
       
    21 
       
    22 #include <e32base.h>	// CBase
       
    23 #include <e32std.h>	 // TBuf
       
    24 
       
    25 #include <PtiCore.h>
       
    26 #include <osscombination.h>
       
    27 
       
    28 class COssHangulInputContext;
       
    29 class CRepository;
       
    30 class CActiveCallback;
       
    31 
       
    32 class CPtiKoreanQwertyCore : public CPtiCore
       
    33     {
       
    34 public:
       
    35     static CPtiKoreanQwertyCore* NewLC(
       
    36         CPtiEngine* aOwner, 
       
    37         TDes* aTextBuffer);
       
    38     
       
    39     static CPtiKoreanQwertyCore* NewL(
       
    40         CPtiEngine* aOwner, 
       
    41         TDes* aTextBuffer);
       
    42     
       
    43     virtual ~CPtiKoreanQwertyCore();
       
    44 
       
    45 private:
       
    46     
       
    47     CPtiKoreanQwertyCore(
       
    48         CPtiEngine* aOwner, 
       
    49         TDes* aTextBuffer);
       
    50     
       
    51     void ConstructL();
       
    52     
       
    53 private: // from CPtiCore
       
    54 
       
    55     /**
       
    56     * Initialized core object. This method is called by PtiEngine framework when core object
       
    57     * is loaded.        
       
    58     *
       
    59     * @since 2.6
       
    60     * @param aOwner Pointer to onwing PtiEngine framework instance.
       
    61     * @param aTextBuffer A pointer to PtiEngine main text buffer.
       
    62     * @param aLanguageList A language list to be filled with language bindings to this core
       
    63     *                      onbject
       
    64     * @param aUseDefautUserDictionary A boolean value indicating whether default user dictionary shoulkd be used
       
    65     *                                 (in case this core object supports user dictionaries).
       
    66     */  
       
    67     virtual void InitializeL(
       
    68         CPtiEngine* aOwner, 
       
    69         TDes* aTextBuffer, 
       
    70         CArrayPtrFlat<CPtiCoreLanguage>* aLanguageList,
       
    71         TBool aUseDefautUserDictionary);
       
    72     
       
    73     /**
       
    74     * Removes languages associated to this core object from given language list. Languages
       
    75     * not associated to this core abject are not touched.
       
    76     * 
       
    77     * @since 2.6
       
    78     * @param aLanguageList A language list to be cleaned.
       
    79     */
       
    80     virtual void DropLanguages(CArrayPtrFlat<CPtiCoreLanguage>* aLanguageList);
       
    81     
       
    82     /**
       
    83     * Opens resources for given language and itinialized them.
       
    84     *
       
    85     * @since 2.6
       
    86     * @param aLanguage Symbian OS language code a language to be initialized.
       
    87     * @return KErrNone or a system wide error code.
       
    88     */
       
    89     virtual TInt OpenLanguageL(CPtiCoreLanguage *aLanguage);
       
    90     
       
    91     /**
       
    92     * Closes currently activate language and frees resources associated to it.
       
    93     *
       
    94     * @since 2.6
       
    95     * @return KErrNone of system wide error ocde.
       
    96     */
       
    97     virtual TInt CloseLanguageL();
       
    98     
       
    99     /**
       
   100     * Returns the contents of text buffer.
       
   101     * 
       
   102     * @since 2.6
       
   103     * @return A constant pointer to text buffer.
       
   104     */  
       
   105     virtual TPtrC GetCurrentWord() const;
       
   106     
       
   107     /**
       
   108     * Commits current word. Commiting means that user has added current
       
   109     * word as part of text. Frequency information and other related attributes
       
   110     * can then be updated.
       
   111     *
       
   112     * @since 2.6
       
   113     * @return KErrNone or a system wide error code.
       
   114     */
       
   115     virtual TInt CommitCurrentWord();       
       
   116     
       
   117     /**
       
   118     * Returns a pointer core info structure. Core info struct contains useful 
       
   119     * information about core object and its features.
       
   120     *
       
   121     */              
       
   122     virtual MPtiCoreInfo* GetCoreInfo();
       
   123             
       
   124     /**
       
   125     * Turns reoreding feature on or off. Reordering means that prediction engine
       
   126     * maintains frequency information for used words and modifys the order of candidate list
       
   127     * based on that information. This feature may not be supported by all prediction engines.
       
   128     * 
       
   129     * @since 2.6
       
   130     * @param aStatus New status for reorderinf feature.
       
   131     * @return KErrNone or a system wide error code.
       
   132     */
       
   133     virtual TInt SetReordering(TBool aStatus);
       
   134     
       
   135     /**
       
   136     * This is the single most important core API method, most of the text input functionality
       
   137     * will be utilize this method. Call to this method indicates core object that a key was
       
   138     * pressed and it should act accordingly and fill the output buffer.
       
   139     * 
       
   140     * @since 2.6
       
   141     * @param aKey Enum value for pressed key.
       
   142     */
       
   143     virtual void AppendKeyPress(TPtiKey aKey);
       
   144     
       
   145     /**
       
   146     * Indicates core object that it should perform 'delete key press'-operation.
       
   147     *
       
   148     * @since 2.6
       
   149     */
       
   150     virtual void DeleteKeyPress();
       
   151     
       
   152     /**
       
   153     * Call to this method notifys core object that input buffer was cleared.
       
   154     *
       
   155     * @since 2.6
       
   156     */
       
   157     virtual void ClearBuffer();
       
   158     
       
   159     /**
       
   160     * Sets current input sequence. The end result of this operation must be same as 
       
   161     * if user had entered keys in input array as individual key presses.
       
   162     *
       
   163     * @since 2.6
       
   164     * @param aInput An array containing sequence of key presses (type TPtiKey).
       
   165     * @return KErrNone or a system wide error code.
       
   166     */
       
   167     virtual TInt SetCurrentInputSequence(TPtrC8 aInput);
       
   168     
       
   169     /**
       
   170     * Converts given string from one character set to another. Possible conversion types
       
   171     * are defined in PtiDefs.h
       
   172     *
       
   173     * @since 2.6
       
   174     * @param aType        Conversion type.
       
   175     * @param aInput       Pointer to input string to be converted.
       
   176     * @param aInputLength Length of input buffer.
       
   177     * @param aOutput      pointer to output buffer.
       
   178     * @return KErrNone or a system wide error code.
       
   179     */
       
   180     virtual TInt Convert(
       
   181         TPtiCharConversion aType,
       
   182         TAny* aInput,
       
   183         TInt aInputLength,
       
   184         TAny* aOutput);
       
   185 
       
   186     /**
       
   187     * Re-defines keymappings for given key / input mode / case combination. Previous 
       
   188     * keymapping will be deleted and new mappings will be used instead.
       
   189     *
       
   190     * @since 2.6
       
   191     * @param aMode Input mode for new key mapping.
       
   192     * @param aKey  A key to be replaced.
       
   193     * @param aKeyMap New keymapping data for aKey.
       
   194     * @param aCase   Text case to be replaced.
       
   195     * @return KErrNone or system wide error code.
       
   196     */
       
   197     virtual TInt SetExternalKeyMapL(
       
   198         TPtiEngineInputMode aMode,
       
   199         TPtiKey aKey,
       
   200         TDesC& aKeyMap,
       
   201         TPtiTextCase aCase);
       
   202     /**
       
   203     * Returns alternate spelling for given unicode characters. Possible conversion
       
   204     * types are defined in header PtiDefs.h.
       
   205     *                                       
       
   206     * @sinec 2.6
       
   207     * @aInput A character to be converted.
       
   208     * @aOutput Resulting alternate spelling will be stored here.
       
   209     * @aType   Spelling conversion type.
       
   210     * @return  KErrNone or system wide error code.
       
   211     */                              
       
   212     virtual TInt GetSpelling(TUint16 aInput, TDes& aOutput, TPtiSpelling aType);
       
   213     
       
   214     /**
       
   215     * Cancels all on-going core obejct timner activity.
       
   216     *
       
   217     * @since 2.6
       
   218     * @return KErrNone or system wide error code.
       
   219     */
       
   220     virtual TInt CancelTimerActivity();
       
   221     
       
   222     /**
       
   223     * A generic command handling method for extending PtiEngine API without adding
       
   224     * new base class methods. It is recommended to use this only in force major
       
   225     * situations, where there is no other way.
       
   226     * 
       
   227     * @since 2.6
       
   228     * @param aCommand A Command id value. Platform wide command ids are defined in PtiDefs.h.
       
   229     * @param aParams  TAny pointer for passing any required parameters.
       
   230     * @return An integer containing possible return value related to command.
       
   231     */
       
   232     virtual TInt HandleCommandL(
       
   233         TPtiEngineCommand aCommand, 
       
   234         TAny* aParams);
       
   235 
       
   236 //
       
   237 // Predictive latin API
       
   238 //  
       
   239 private:    
       
   240     /**
       
   241     * Returns number of candidates for currently entered key sequence.
       
   242     *
       
   243     * @since 2.6
       
   244     * @return Number of prediction candidates for currently entered key sequence.
       
   245     */
       
   246     virtual TInt NumberOfCandidates();
       
   247     
       
   248     /**     
       
   249     * Returns a list of candidate words for currently entered key sequence.
       
   250     *
       
   251     * @since 2.6
       
   252     * @param aList A list to be filled with candidate words.
       
   253     * @return Number of candidate works in aList.
       
   254     */
       
   255     virtual TInt GetCandidateListL(CDesCArray& aList);
       
   256     
       
   257     /**
       
   258     * Returns next word candidate list. Next word candidates are words
       
   259     * potentially related to currently selected candidate. Next word prediction
       
   260     * feature must supported by the engine and turned on.
       
   261     *
       
   262     * @since 2.6
       
   263     */
       
   264     virtual TInt GetNextWordCandidateListL(CDesCArray& aList);
       
   265     
       
   266     /**
       
   267     * Returns first word in list of candidate words for current input sequence.
       
   268     * 
       
   269     * @since 2.6
       
   270     * @param aResult A descriptor where resulting word will be stored.
       
   271     * @return KErrnNone or system wide error code.
       
   272     */      
       
   273     virtual TInt GetFirstCandidate(TDes& aResult);
       
   274     
       
   275     /**
       
   276     * Returns next word in list of candidate words for current input sequence.
       
   277     * 
       
   278     * @since 2.6
       
   279     * @param aResult A descriptor where resulting word will be stored.
       
   280     * @return KErrnNone or system wide error code.
       
   281     */                      
       
   282     virtual TInt GetNextCandidate(TDes& aResult);
       
   283     
       
   284     /**
       
   285     * Returns previous word in list of candidate words for current input sequence.
       
   286     * 
       
   287     * @since 2.6
       
   288     * @param aResult A descriptor where resulting word will be stored.
       
   289     * @return KErrnNone or system wide error code.
       
   290     */                              
       
   291     virtual TInt GetPreviousCandidate(TDes& aResult);
       
   292 
       
   293 //
       
   294 // User dictionary API
       
   295 //
       
   296 private:
       
   297     virtual TInt AddUserDictionaryEntry(
       
   298         MPtiUserDictionaryEntry& aEntry, 
       
   299         CPtiUserDictionary* aDict);
       
   300     
       
   301     virtual TInt RemoveUserDictionaryEntry(
       
   302         MPtiUserDictionaryEntry& aEntry, 
       
   303         CPtiUserDictionary* aDict);
       
   304     
       
   305     virtual TInt NumberOfEntriesInUserDictionary(
       
   306         CPtiUserDictionary* aDict);
       
   307     
       
   308     virtual TInt GetUserDictionaryEntry(
       
   309         TInt aIndex, 
       
   310         MPtiUserDictionaryEntry& aResult, 
       
   311         CPtiUserDictionary* aDict);
       
   312     
       
   313     virtual CPtiUserDictionary* CreateEmptyUserDictionaryL(TInt aMaxSize);
       
   314     
       
   315     virtual TInt AttachUserDictionary(CPtiUserDictionary* aDict);
       
   316     
       
   317     virtual TBool DetachUserDictionary(CPtiUserDictionary* aDict);      
       
   318 
       
   319 //
       
   320 // Chinese API
       
   321 //
       
   322 private:
       
   323     
       
   324     virtual TPtrC GetCandidatePage();
       
   325     
       
   326     virtual TBool NextCandidatePage();
       
   327     
       
   328     virtual TBool PreviousCandidatePage();
       
   329     
       
   330     virtual TBool MoreCandidatePages();
       
   331     
       
   332     virtual void SetCandidatePageLength(TInt aLength);
       
   333     
       
   334     virtual TPtrC GetPhoneticSpelling(TInt aIndex) const; 
       
   335     
       
   336     virtual TInt PhoneticSpellingCount() const; 
       
   337     
       
   338     virtual TBool SelectPhoneticSpelling(TInt aIndex);
       
   339     
       
   340     virtual TInt SelectedPhoneticSpelling() const; 
       
   341     
       
   342     virtual TBool ToneMark(TText& aToneMark) const;
       
   343     
       
   344     virtual TBool IsToneMarkValidForSpelling();
       
   345     
       
   346     virtual TBool SetPredictiveChineseChar(const TDesC& aChar);
       
   347     
       
   348     virtual TBool SetToneMark(TInt aToneMark);
       
   349 
       
   350 
       
   351 //
       
   352 // Japanese API
       
   353 //
       
   354 private:
       
   355     
       
   356     virtual TPtrC ReadingTextL();
       
   357     
       
   358     virtual MPtiEngineCompositionDataInterface* CompositionData();
       
   359 
       
   360 //
       
   361 // Chinese API
       
   362 //
       
   363 private:
       
   364     
       
   365     virtual HBufC* GetCandidatesByInputString(
       
   366         const TDesC& aInputString, 
       
   367         RPointerArray<HBufC>& aList, 
       
   368         const TBool aIsPredictive);
       
   369     
       
   370     void UpdateFromRepositoryL();
       
   371     
       
   372     void UpdateDblConsonentL(
       
   373         const TInt& aCenRepId,
       
   374         const TOssCombinationItem& aCombination);
       
   375     
       
   376 public:
       
   377     
       
   378     static TInt CBSettingChanged(void* aSelf);
       
   379     
       
   380 private:
       
   381     
       
   382     CPtiEngine* iOwner;
       
   383     
       
   384     TDes* iTextBuffer;
       
   385     
       
   386     TBool iKoreanLanOpen;
       
   387     
       
   388     COssHangulInputContext* iHic;
       
   389     
       
   390     COssCombination* iCombination;
       
   391     
       
   392     TBool iLowerCase;
       
   393     
       
   394     CRepository* iRepository;
       
   395     
       
   396     CActiveCallback* iCRNotifier;
       
   397     
       
   398     };
       
   399 
       
   400 #endif  // __PTIKOREANQWERTYCORE_H__
       
   401