inputmethods_pub/ptiengine_iti_api/inc/PtiUserDictionary.h
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2003-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:               Predective text input engine user dictionary 
       
    15 *               class definition.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 #ifndef _PTI_USER_DICTIONARY_H
       
    33 #define _PTI_USER_DICTIONARY_H
       
    34 
       
    35 // INCLUDES
       
    36 #include <e32base.h>
       
    37 
       
    38 /**
       
    39 * A base class for PtiEngine user dictionary implementations. Normally
       
    40 * not needed by a client side application.
       
    41 */
       
    42 class MPtiUserDictionary
       
    43 	{
       
    44 	public:
       
    45 		/**
       
    46 		* Returns user dictionary id value.
       
    47 		*
       
    48 		* @since S60 V2.6 
       
    49 		* @return User dictionary id value.
       
    50 		*/
       
    51 		virtual TInt Id() const = 0;
       
    52 
       
    53 		/**
       
    54 		* Returns size of user dictionary.
       
    55 		*
       
    56 		* @since S60 V2.6 		
       
    57 		* @return Size of user dictionary.
       
    58 		*/
       
    59 		virtual TInt Size() const = 0;
       
    60 
       
    61 		/**
       
    62 		* Returns Uid for core DLL.
       
    63 		*
       
    64 		* @since S60 V2.6 		
       
    65 		* @return Uid value for core DLL.
       
    66 		*/
       
    67 		virtual TInt32 CoreUID() const = 0;
       
    68 
       
    69 		/**
       
    70 		* Returns a boolean value indicating whether this is the default user dictionary. 
       
    71 		*
       
    72 		* @since S60 V2.6 		
       
    73 		* @return ETrue if this user dictionary is default user dictionary.
       
    74 		*         EFalse if not.  
       
    75 		*/
       
    76 		virtual TBool IsDefault() const = 0;
       
    77 
       
    78 		/**
       
    79 		* Reuturns user dictionary file name.
       
    80 		*
       
    81 		* @since S60 V2.6 		
       
    82 		* @return   User dictionary file name.
       
    83 		*/
       
    84 		virtual TPtrC FileName() const = 0;
       
    85 		
       
    86 		/**
       
    87 		* Returns the amount of free space in user dictionary.
       
    88 		*
       
    89 		* @since S60 V2.6 		
       
    90 		* @return  The Amount of free space in dictionary.
       
    91 		*          Negative value if the amount of free space
       
    92 		*          value couldn't be found out.
       
    93 		*/		
       
    94 		virtual TInt SpaceLeft() const = 0;
       
    95 
       
    96 		/**
       
    97 		* If this flag is set, PtiEngine framework calls
       
    98 		* WriteL before exiting.
       
    99 		*
       
   100 		* @since S60 V2.6 		
       
   101 		* @return A boolean valua indicating status of the update flag.
       
   102 		*/
       
   103 		virtual TBool UpdateFlag() const = 0;
       
   104 
       
   105 		/**
       
   106 		* Set update flag to given value. If update flag is set, PtiEngine tries
       
   107 		* to save user dictionary when PtiEngine destructor is called.
       
   108 		*  
       
   109 		* @since S60 V2.6 				
       
   110 		* @param aFlag New status for the update flag.
       
   111 		*/
       
   112 		virtual void SetUpdateFlag(TBool aFlag) = 0;	
       
   113 	};
       
   114 
       
   115 
       
   116 class CPtiUserDictionary : public CBase, public MPtiUserDictionary
       
   117 	{
       
   118 	public:
       
   119 		IMPORT_C static CPtiUserDictionary* NewL(TInt aMaxSize);
       
   120 		IMPORT_C static CPtiUserDictionary* NewL(TDesC& aFileName, TInt aMaxSize);
       
   121 		IMPORT_C virtual ~CPtiUserDictionary();
       
   122 
       
   123 		IMPORT_C virtual TInt OpenL(TDesC& aFileName, TInt aMaxSize);
       
   124 		IMPORT_C virtual TInt WriteL(TDesC& aFileName);
       
   125 		IMPORT_C virtual TInt WriteL();
       
   126 		inline void SetFileName(TDesC& aFileName);
       
   127 		inline TInt Id() const;
       
   128 		inline void SetId(TInt aId);
       
   129 		inline TInt Size() const;
       
   130 		inline TInt32 CoreUID() const;
       
   131 		inline void SetCoreUID(TInt32 aUid);
       
   132 		inline virtual TPtr8 Data();
       
   133 		inline TBool IsDefault() const;
       
   134 		inline void SetDefault(TBool aValue);
       
   135 		inline TPtrC FileName() const;
       
   136 		inline TBool UpdateFlag() const;
       
   137 		inline void SetUpdateFlag(TBool aFlag);	
       
   138 		inline TInt SymbolClass() const;
       
   139 		inline void SetSymbolClass(TInt aSymbolClass);
       
   140 		IMPORT_C virtual TInt SpaceLeft() const;
       
   141 		IMPORT_C virtual void SetDataL(TAny* aData, TInt aLength);
       
   142 
       
   143 	protected:
       
   144 		IMPORT_C CPtiUserDictionary();
       
   145 
       
   146 	private:
       
   147 		void ConstructL(TInt aMaxSize);
       
   148 		void ConstructL(TDesC& aFileName, TInt aMaxSize);
       
   149 
       
   150 	protected:	
       
   151 		TFileName iFileName;
       
   152 		HBufC8* iData;
       
   153 		TInt    iId;
       
   154 		TInt32  iCoreUID;
       
   155 		TBool   iDefault;
       
   156 		TBool   iUpdateFlag;
       
   157 		TInt    iSymbolClass;
       
   158 		TUint32 iChecksum;   // Holds checksum of lastest version that was saved to disk.
       
   159 	};
       
   160 
       
   161 #include "PtiUserDictionary.inl"
       
   162 
       
   163 #endif
       
   164 
       
   165 // End of file