contentstorage/casrv/calocalizerscanner/src/calocalizerscannerproxy.cpp
changeset 96 5d243a69bdda
parent 94 dbb8300717f7
child 98 d2f833ab7940
equal deleted inserted replaced
95:c739008478cc 96:5d243a69bdda
    26 #include "calocalizerscannerproxy.h"
    26 #include "calocalizerscannerproxy.h"
    27 #include "castorageproxy.h"
    27 #include "castorageproxy.h"
    28 #include "cadef.h"
    28 #include "cadef.h"
    29 #include "cainnerquery.h"
    29 #include "cainnerquery.h"
    30 #include "cainnerentry.h"
    30 #include "cainnerentry.h"
    31 
    31 #include "casqlcommands.h"
    32 _LIT(KPathLoc,"z:/resource/qt/translations");
    32 
       
    33 
    33 
    34 
    34 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
    35 // CCaLocalizerScannerProxy::NewL
    36 // CCaLocalizerScannerProxy::NewL
    36 // Two-phased constructor.
    37 // Two-phased constructor.
    37 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
   133     HBufC16* localizedName;
   134     HBufC16* localizedName;
   134     for( TInt i = 0; i < locCount; i++ )
   135     for( TInt i = 0; i < locCount; i++ )
   135         {
   136         {
   136         localizedName = GetLocalizedNameLC( locals[i] );
   137         localizedName = GetLocalizedNameLC( locals[i] );
   137         
   138         
   138         if( localizedName->Compare(
   139         if( locals[i]->GetAttributeName().Compare( KColumnEnText) == 0
   139             GetEntryText( entries, locals[i]->GetRowId() ) ) )
   140                 && !localizedName->Compare(
   140             // translation different than text
   141                     GetEntryText( entries, locals[i]->GetRowId() ) ) == 0 
       
   142                 ||
       
   143             locals[i]->GetAttributeName().Compare( KColumnEnDescription) == 0
       
   144                 && !localizedName->Compare(
       
   145                     GetEntryDescription( entries, locals[i]->GetRowId() ) ) == 0 )
       
   146             // translations different than text
   141             {
   147             {
   142             locals[i]->SetLocalizedStringL( *localizedName );
   148             locals[i]->SetLocalizedStringL( *localizedName );
   143             iStorageProxy->LocalizeEntryL( *( locals[i] ) );
   149             iStorageProxy->LocalizeEntryL( *( locals[i] ) );
   144             }
   150             }
   145         CleanupStack::PopAndDestroy( localizedName );
   151         CleanupStack::PopAndDestroy( localizedName );
   158 HBufC* CCaLocalizerScannerProxy::GetLocalizedNameLC(
   164 HBufC* CCaLocalizerScannerProxy::GetLocalizedNameLC(
   159 		const CCaLocalizationEntry* aLocEntry)
   165 		const CCaLocalizationEntry* aLocEntry)
   160     {
   166     {
   161 	if( iRecentQmFile.Compare( aLocEntry->GetQmFilename() ) )
   167 	if( iRecentQmFile.Compare( aLocEntry->GetQmFilename() ) )
   162 		{
   168 		{
   163 	    HbTextResolverSymbian::Init( aLocEntry->GetQmFilename(), KPathLoc );
   169 	    
       
   170 	       if( !HbTextResolverSymbian::Init( aLocEntry->GetQmFilename(), KLocalizationFilepathC ) )
       
   171 	          {
       
   172 	          if( !HbTextResolverSymbian::Init( aLocEntry->GetQmFilename(), KLocalizationFilepathZ ) )
       
   173 	              {
       
   174 	              // this should not be called too often 
       
   175 	              TChar currentDriveLetter;
       
   176 	              TDriveList driveList;
       
   177 	              RFs fs;
       
   178 	              User::LeaveIfError( fs.Connect() );
       
   179 	              User::LeaveIfError( fs.DriveList( driveList ) );
       
   180 
       
   181 	              RBuf path;
       
   182 	              path.Create( KLocalizationFilepath().Length() + 1 );
       
   183 	              CleanupClosePushL( path );
       
   184 	              
       
   185 	              for ( TInt driveNr=EDriveY; driveNr >= EDriveA; driveNr-- )
       
   186 	                  {
       
   187 	                  if ( driveList[driveNr] )
       
   188 	                      {
       
   189 	                      User::LeaveIfError( fs.DriveToChar( driveNr,
       
   190 	                              currentDriveLetter ) );
       
   191 	                      path.Append( currentDriveLetter );
       
   192 	                      path.Append( KLocalizationFilepath );
       
   193 	                      if( HbTextResolverSymbian::Init( aLocEntry->GetQmFilename(), path ) )
       
   194 	                          {
       
   195 	                          break;
       
   196 	                          }
       
   197 	                      }
       
   198 	                  path.Zero();
       
   199 	                  }
       
   200 	              CleanupStack::PopAndDestroy( &path );
       
   201 	              fs.Close();
       
   202 	              }
       
   203 	           }
       
   204 	    
   164         // keeping last qm filename to avoid another initialization
   205         // keeping last qm filename to avoid another initialization
   165 	    iRecentQmFile.Close();
   206 	    iRecentQmFile.Close();
   166 	    iRecentQmFile.Create( aLocEntry->GetQmFilename().Length() );
   207 	    iRecentQmFile.Create( aLocEntry->GetQmFilename().Length() );
   167 	    iRecentQmFile.Copy( aLocEntry->GetQmFilename() );
   208 	    iRecentQmFile.Copy( aLocEntry->GetQmFilename() );
   168 		}
   209 		}
   184             return aEntries[i]->GetText();
   225             return aEntries[i]->GetText();
   185             }
   226             }
   186         }
   227         }
   187     return KNullDesC();
   228     return KNullDesC();
   188     }
   229     }
       
   230 
       
   231 // ---------------------------------------------------------------------------
       
   232 //  
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 const TDesC& CCaLocalizerScannerProxy::GetEntryDescription(
       
   236         const RPointerArray<CCaInnerEntry>& aEntries, TInt aId )
       
   237     {
       
   238     TInt entriesCount = aEntries.Count();
       
   239     for( TInt i=0; i < entriesCount; i++ )
       
   240         {
       
   241         if( aEntries[i]->GetId() == aId )
       
   242             {
       
   243             return aEntries[i]->GetDescription();
       
   244             }
       
   245         }
       
   246     return KNullDesC();
       
   247     }