ocrsrv_stub/inc/language.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2002 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:  language manager definitions
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef OCRLANGUAGE_H
       
    20 #define OCRLANGUAGE_H
       
    21 
       
    22 // INCLUDES FILES
       
    23 #include "languageconvertor.h"
       
    24 #include "ocrthread.h"
       
    25 #include <ocrsrv.h>
       
    26 #include <f32file.h>
       
    27 
       
    28 // CONSTANTS
       
    29 const TInt KFileNameLength = 128;
       
    30 
       
    31 /** Pathes where the engine marks stores */
       
    32 _LIT(KDataPathZ, "z:\\resource\\ocrsrv\\*.dat");
       
    33 _LIT(KDataPathC, "c:\\resource\\ocrsrv\\*.dat");
       
    34 
       
    35 _LIT( KExtend, "dll" );
       
    36 
       
    37 /** Language Definitions */
       
    38 const TInt KEngineLangInvalid     ( 0 );
       
    39 const TInt KEngineLangChineseSimp ( 1 );
       
    40 const TInt KEngineLangChineseTrad ( 2 );
       
    41 const TInt KEngineLangJapanese    ( 3 );
       
    42 const TInt KEngineLangEnglish     ( 101 );
       
    43 const TInt KEngineLangFinish      ( 102 );
       
    44 
       
    45 /**
       
    46  *  Internal Language Structure
       
    47  *
       
    48  *  Map one language instance with an engine id
       
    49  *
       
    50  *  @lib ocrsrv.lib
       
    51  *  @since S60 v3.1
       
    52  */
       
    53 class TOCRLanguage
       
    54     {
       
    55 public:
       
    56 
       
    57     /**
       
    58     * Eninge id
       
    59     */
       
    60     TInt       iEngineId;
       
    61     
       
    62     /**
       
    63     * Language
       
    64     */
       
    65     TLanguage  iLanguage;
       
    66     };
       
    67 
       
    68 /**
       
    69  *  Internal Language Structure
       
    70  *
       
    71  *  Map two combined languages with an engine ID
       
    72  *
       
    73  *  @lib ocrsrv.lib
       
    74  *  @since S60 v3.1
       
    75  */
       
    76 class TOCRCombinedLanguage
       
    77     {
       
    78 public:
       
    79 
       
    80     /**
       
    81     * Eninge id
       
    82     */ 
       
    83     TInt       iEngineId;
       
    84     
       
    85     /**
       
    86     * Eastern language that the engine supports
       
    87     */
       
    88     TLanguage  iLanguageEast;
       
    89     
       
    90     /**
       
    91     * Western language that the engine supports
       
    92     */
       
    93     TLanguage  iLanguageWest;
       
    94     };
       
    95  
       
    96 /**
       
    97  *  OCR Engine Wrapper class
       
    98  *
       
    99  *  OCR Engine wrapper which offers the abstruct of all
       
   100  *  OCR engines
       
   101  *
       
   102  *  @lib ocrsrv.lib
       
   103  *  @since S60 v3.1
       
   104  */
       
   105 class COCREngine : public CBase
       
   106     {
       
   107 public:
       
   108 
       
   109     /**
       
   110     * Default C++ Destructor
       
   111     */
       
   112     virtual ~COCREngine();
       
   113 
       
   114     /**
       
   115     * Symbian Two-phased constructor
       
   116     */
       
   117     static COCREngine* NewL(const TDesC& aEnginePathAndName,const TInt aEngineId);
       
   118 
       
   119     /**
       
   120     * Initialize the analyze engine
       
   121     * @since S60 v3.1
       
   122     * @return None
       
   123     */
       
   124     void AnalyzeEngineL();
       
   125 
       
   126     /**
       
   127     * Empty data of current engine
       
   128     * @since S60 v3.1
       
   129     * @return none
       
   130     */
       
   131     void EmptyData();
       
   132 
       
   133     /**
       
   134     * Get engine Id
       
   135     * @since S60 v3.1
       
   136     * @return Engine id
       
   137     */
       
   138     inline const TInt GetEngineId() const ;
       
   139 
       
   140     /**
       
   141     * Get unique engine name
       
   142     * @since S60 v3.1
       
   143     * @param aEngineName A new engine name
       
   144     * @return None
       
   145     */
       
   146     void GetEngineName(TDes& aEngineName) const ;
       
   147 
       
   148     /**
       
   149     * Get languages the engine support
       
   150     * @since S60 v3.1
       
   151     * @return Supported language list
       
   152     */
       
   153     inline const RArray<TOCRLanguage>& GetSupportLanguage() const ;
       
   154 
       
   155     /**
       
   156     * Get language combinations the engine support
       
   157     * @since S60 v3.1
       
   158     * @return Supported language combination list
       
   159     */
       
   160     inline const RArray<TOCRCombinedLanguage>& GetSupportCombinedLanguage() const;
       
   161 
       
   162 private:
       
   163 
       
   164     /**
       
   165     * By default Symbian 2nd phase constructor is private
       
   166     * @since S60 v3.1
       
   167     * @param aEngineName Engine name to be constructed
       
   168     * @param aEngineId Engine Id to be constructed
       
   169     * @return None
       
   170     */
       
   171     void ConstructL(const TDesC& aEngineName,const TInt aEngineId);
       
   172 
       
   173     /**
       
   174     * Justify if given language is an eastern language
       
   175     * @since S60 v3.1
       
   176     * @param aLanguage A language to be tested
       
   177     * @return ETrue if it's an eastern language
       
   178     */
       
   179     inline TBool IsEast(const TLanguage aLanguage) const;
       
   180 
       
   181     /**
       
   182     * Combine eastern and western languages
       
   183     * @since S60 v3.1
       
   184     * @param aEast eastern language to be combined
       
   185     * @param aWest western language to be combined
       
   186     * @param aDestination An array which holds the result
       
   187     * @return None
       
   188     */
       
   189     void CombineLanguage(const RArray<TLanguage>& aEast, 
       
   190                          const RArray<TLanguage>& aWest, 
       
   191                          RArray<TOCRCombinedLanguage>& aDestination);
       
   192 
       
   193     /**
       
   194     * C++ default constructor
       
   195     */
       
   196     COCREngine();
       
   197 
       
   198 private:
       
   199 
       
   200     /**
       
   201     * Engine id
       
   202     */
       
   203     TInt iEngineId;
       
   204     
       
   205     /**
       
   206     * Enigne name
       
   207     */
       
   208     TBuf<KFileNameLength> iEngineName;
       
   209     
       
   210     /**
       
   211     * Languages that the engine support
       
   212     */
       
   213     RArray<TOCRLanguage>         iLanguageList;
       
   214     
       
   215     /**
       
   216     * Language combinations that the engine support
       
   217     */
       
   218     RArray<TOCRCombinedLanguage> iCombinedLanguageList;
       
   219     };
       
   220 
       
   221 /**
       
   222  *  OCR Engine Wrapper list
       
   223  *
       
   224  *  List of all loaded engines
       
   225  *
       
   226  *  @lib ocrsrv.lib
       
   227  *  @since S60 v3.1
       
   228  */
       
   229 class COCREngineList : public CBase
       
   230     {
       
   231 public:
       
   232 
       
   233     /**
       
   234     * Symbian Two-phased constructor
       
   235     */
       
   236     static COCREngineList* NewL();
       
   237 
       
   238     /**
       
   239     * Default C++ destructor
       
   240     */
       
   241     virtual ~COCREngineList();
       
   242 
       
   243     /**
       
   244     * Justify if the language is supported
       
   245     * @since S60 v3.1
       
   246     * @param aLanguage A language to be tested
       
   247     * @return ETrue if supported
       
   248     */
       
   249     TBool IsSupportLanguage(const TLanguage aLanguage);
       
   250 
       
   251     /**
       
   252     * Get all supported languages
       
   253     * @since S60 v3.1
       
   254     * @param aLanguages A list which holds all supported languages
       
   255     * @return None
       
   256     */
       
   257     void GetALLSupportLanguage(RArray<TLanguage> &aLanguages);
       
   258 
       
   259     /**
       
   260     * Refresh language databases, this method shall be always called
       
   261     * whenever databases changed
       
   262     * @since S60 v3.1
       
   263     * @return None
       
   264     */
       
   265     void RefreshL();
       
   266 
       
   267     /**
       
   268     * Get supported engine numbers
       
   269     * @since S60 v3.1
       
   270     * @return Num of engine detected
       
   271     */
       
   272     inline TInt GetEngineCount() const;
       
   273 
       
   274     /**
       
   275     * Get engine name by a given language
       
   276     * @since S60 v3.1
       
   277     * @param aLanguage A language supported by the engine
       
   278     * @param aEngineName The name of the engine
       
   279     * @return KErrNone if no error, otherwise system level error raised
       
   280     */
       
   281     TInt GetEngineName(const TLanguage aLanguage, TDes& aEngineName);
       
   282 
       
   283     /**
       
   284     * Get engine name by language combination
       
   285     * @since S60 v3.1
       
   286     * @param aLanguageFirst A language supported by the engine
       
   287     * @param aLanguageSecond Another language supported by the engine
       
   288     * @param aEngineName The name of the engine
       
   289     * @return KErrNone if no error, otherwise system level error raised
       
   290     */        
       
   291     TInt GetEngineName(const TLanguage aLanguageFirst,
       
   292                        const TLanguage aLanguageSecond, 
       
   293                        TDes& aEngineName);
       
   294 
       
   295 private:
       
   296 
       
   297     /**
       
   298     * Empty data of the engine
       
   299     * @since S60 v3.1
       
   300     * @return None
       
   301     */
       
   302     void EmptyData();
       
   303 
       
   304     /**
       
   305     * Analyze engines information
       
   306     * @since S60 v3.1
       
   307     * @return None
       
   308     */
       
   309     void DoAnalyzeEnginesInfoL();
       
   310 
       
   311     /**
       
   312     * Set engines information
       
   313     * @since S60 v3.1
       
   314     * @param aDir A directory information array
       
   315     * @param aCount A number of dirs of the array
       
   316     * @return None
       
   317     */
       
   318     void SetEngineInfoL(const CDir* aDir, const TInt aCount);
       
   319 
       
   320     /**
       
   321     * Default Symbian 2nd phase constructor
       
   322     * @since S60 v3.1
       
   323     * @return None
       
   324     */
       
   325     void ConstructL();
       
   326 
       
   327     /**
       
   328     * Add language array
       
   329     * @since S60 v3.1
       
   330     * @param aSource A src language array
       
   331     * @param aDestination A tar language array
       
   332     * @return None
       
   333     */
       
   334     void AddLanguageArray(const RArray<TOCRLanguage>& aSource, RArray<TOCRLanguage>& aDestination);
       
   335 
       
   336     /**
       
   337     * Add language combination array
       
   338     * @since S60 v3.1
       
   339     * @param aSource A src language array
       
   340     * @param aDestination A tar language array
       
   341     * @return None
       
   342     */
       
   343     void AddCombinedLanguageArray(const RArray<TOCRCombinedLanguage>& aSource, 
       
   344                                   RArray<TOCRCombinedLanguage>& aDestination);
       
   345 
       
   346     /**
       
   347     * Test if the language is within one array
       
   348     * @since S60 v3.1
       
   349     * @param aLanguage A language to be tested
       
   350     * @param aArray An array to be tested
       
   351     * @return ETrue if the language is in language list
       
   352     */
       
   353     TBool IsHaveLanguage(const TLanguage aLanguage, const RArray<TOCRLanguage>& aArray) const;
       
   354 
       
   355     /**
       
   356     * Test if the language is within one combined array
       
   357     * @since S60 v3.1
       
   358     * @param aLanguageFirst A language to be tested
       
   359     * @param aLanguageSecond Another language to be tested
       
   360     * @param aArray An array to be tested
       
   361     * @return ETrue if the language is in language list
       
   362     */
       
   363     TBool IsHaveCombinedLanguage(const TLanguage aLanguageFirst, 
       
   364                                  const TLanguage aLanguageSecond, 
       
   365                                  const RArray<TOCRCombinedLanguage>& aArray) const;
       
   366 
       
   367     /**
       
   368     * C++ default constructor
       
   369     */
       
   370     COCREngineList();
       
   371 
       
   372 private:
       
   373     
       
   374     /**
       
   375     * Pathes for searching the ocr libraries
       
   376     */
       
   377     RPointerArray<HBufC> iPathes;
       
   378     
       
   379     /**
       
   380     * List of all supported lanugages
       
   381     */
       
   382     RArray<TOCRLanguage> iLanguageList;
       
   383     
       
   384     /**
       
   385     * List of all combined languages, this generated from iLanguageList
       
   386     * e.g. if we support English and Japanese, then the iCombinedLanguageList
       
   387     * would have English, Japanese and EnglishJapanese languages. Note that
       
   388     * only one western language and one eastern language would be combined
       
   389     */
       
   390     RArray<TOCRCombinedLanguage> iCombinedLanguageList;
       
   391     
       
   392     /**
       
   393     * List of all loaded OCR engine instances
       
   394     */
       
   395     RPointerArray<COCREngine> iOCREngineList;
       
   396     
       
   397     /**
       
   398     * File session
       
   399     */
       
   400     RFs iFs;
       
   401     };
       
   402 
       
   403 #include "language.inl"
       
   404 
       
   405 #endif // OCRLANGUAGE_H
       
   406 
       
   407 // End Of File