harvesterplugins/media/audio/src/cpixmediaaudiodoc.cpp
changeset 9 4a2987baf8f7
parent 5 3bc31ad99ee7
child 13 0a2ec6860a93
child 17 7d8c8d8f5eab
equal deleted inserted replaced
8:2f67eb14d003 9:4a2987baf8f7
    27 #include "csearchdocument.h"
    27 #include "csearchdocument.h"
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    29 #include "cpixmediaaudiodocTraces.h"
    29 #include "cpixmediaaudiodocTraces.h"
    30 #endif
    30 #endif
    31 
    31 
    32 
    32 _LIT( KFormatDateTime, "%04d %02d %02d %02d %02d");    // yyyy mm dd hh mm
       
    33 _LIT( KExcerptFormat, "%04d/%02d/%02d %02d:%02d");
    33 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    34 // CCPIXDocFetcher::NewL()
    35 // CCPIXDocFetcher::NewL()
    35 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    36 //
    37 //
    37 CCPIXMediaAudioDoc* CCPIXMediaAudioDoc::NewL()
    38 CCPIXMediaAudioDoc* CCPIXMediaAudioDoc::NewL()
    99     TPtrC name = GetUri().Mid( (slashpos+1) );
   100     TPtrC name = GetUri().Mid( (slashpos+1) );
   100     AddToFieldExcerptL(name); //Add name to excerpt field
   101     AddToFieldExcerptL(name); //Add name to excerpt field
   101     //additional properties here 
   102     //additional properties here 
   102     CMdEProperty* property(NULL);
   103     CMdEProperty* property(NULL);
   103     CMdEPropertyDef& artistPropDef1 = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KArtistProperty );
   104     CMdEPropertyDef& artistPropDef1 = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KArtistProperty );
   104         if(aObject.Property( artistPropDef1, property ) != KErrNotFound)
   105     if(aObject.Property( artistPropDef1, property ) != KErrNotFound)
   105            {
   106        {
   106            //Add field to document
   107        //Add field to document
   107            CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   108        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   108            AddFiledtoDocumentL(*index_item,
   109        AddFiledtoDocumentL(*index_item,
   109                                  MdeConstants::MediaObject::KArtistProperty,
   110                              MdeConstants::MediaObject::KArtistProperty,
   110                                  textProperty->Value());
   111                              textProperty->Value(),
   111            AddToFieldExcerptL(textProperty->Value());//Add artist to excerpt
   112                              CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   112            }
   113        AddToFieldExcerptL(textProperty->Value());//Add artist to excerpt
       
   114        }
   113     CMdEPropertyDef& albumPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KAlbumProperty );
   115     CMdEPropertyDef& albumPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KAlbumProperty );
   114     if(aObject.Property( albumPropDef, property )!= KErrNotFound)
   116     if(aObject.Property( albumPropDef, property )!= KErrNotFound)
   115        {
   117        {
   116        //Add field to document
   118        //Add field to document
   117        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   119        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property);
   118        AddFiledtoDocumentL(*index_item,
   120        AddFiledtoDocumentL(*index_item,
   119                            MdeConstants::Audio::KAlbumProperty,
   121                            MdeConstants::Audio::KAlbumProperty,
   120                            textProperty->Value());
   122                            textProperty->Value(),
       
   123                            CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   121        AddToFieldExcerptL(textProperty->Value());//Add Album to excerpt
   124        AddToFieldExcerptL(textProperty->Value());//Add Album to excerpt
   122        }
   125        }
       
   126     
   123     CMdEPropertyDef& artistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KAlbumArtistProperty );
   127     CMdEPropertyDef& artistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KAlbumArtistProperty );
   124     if(aObject.Property( artistPropDef, property ) != KErrNotFound)
   128     if(aObject.Property( artistPropDef, property ) != KErrNotFound)
   125       {
   129        {
   126       //Add field to document
   130        //Add field to document
   127       CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   131        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   128       AddFiledtoDocumentL(*index_item,
   132        AddFiledtoDocumentL(*index_item,
   129                          MdeConstants::Audio::KAlbumArtistProperty,
   133                      MdeConstants::Audio::KAlbumArtistProperty,
   130                          textProperty->Value());
   134                      textProperty->Value(),
   131       AddToFieldExcerptL(textProperty->Value());//Add Albumartist to excerpt
   135                      CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   132       }
   136        AddToFieldExcerptL(textProperty->Value());//Add Albumartist to excerpt
       
   137        }
       
   138     //orginal artist property
   133     CMdEPropertyDef& origartistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KOriginalArtistProperty );
   139     CMdEPropertyDef& origartistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KOriginalArtistProperty );
   134     if(aObject.Property( origartistPropDef, property ) != KErrNotFound)
   140     if(aObject.Property( origartistPropDef, property ) != KErrNotFound)
   135      {
   141      {
   136      //Add field to document
   142      //Add field to document
   137      CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   143      CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   138      AddFiledtoDocumentL(*index_item,
   144      AddFiledtoDocumentL(*index_item,
   139                       MdeConstants::Audio::KOriginalArtistProperty,
   145                       MdeConstants::Audio::KOriginalArtistProperty,
   140                       textProperty->Value());
   146                       textProperty->Value(),
       
   147                       CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   141      AddToFieldExcerptL(textProperty->Value());//Add Original to excerpt
   148      AddToFieldExcerptL(textProperty->Value());//Add Original to excerpt
   142      }   
   149      }
       
   150     //Get composer property
   143     CMdEPropertyDef& composerPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KComposerProperty );
   151     CMdEPropertyDef& composerPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Audio::KComposerProperty );
   144     if(aObject.Property( composerPropDef, property ) != KErrNotFound)
   152     if(aObject.Property( composerPropDef, property ) != KErrNotFound)
   145     {
   153     {
   146     //Add field to document
   154     //Add field to document
   147     CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   155     CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   148     AddFiledtoDocumentL(*index_item,
   156     AddFiledtoDocumentL(*index_item,
   149                   MdeConstants::Audio::KComposerProperty,
   157                   MdeConstants::Audio::KComposerProperty,
   150                   textProperty->Value());
   158                   textProperty->Value(),
       
   159                   CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   151     AddToFieldExcerptL(textProperty->Value());//Add composer to excerpt
   160     AddToFieldExcerptL(textProperty->Value());//Add composer to excerpt
   152     }
   161     }
   153     index_item->AddExcerptL(*iExcerpt);   
   162     //Get author property
       
   163     CMdEPropertyDef& authorPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KAuthorProperty );
       
   164     if(aObject.Property( authorPropDef, property ) != KErrNotFound)
       
   165        {
       
   166        //Add field to document
       
   167        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   168        AddFiledtoDocumentL(*index_item,
       
   169                          MdeConstants::MediaObject::KAuthorProperty,
       
   170                          textProperty->Value(),
       
   171                          CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
       
   172        AddToFieldExcerptL(textProperty->Value());
       
   173        }    
       
   174      //Get comment property   
       
   175     CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty );
       
   176     if(aObject.Property( commentPropDef, property ) != KErrNotFound)
       
   177        {
       
   178        //Add field to document
       
   179        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   180        AddFiledtoDocumentL(*index_item,
       
   181                    MdeConstants::MediaObject::KCommentProperty,
       
   182                    textProperty->Value());
       
   183        AddToFieldExcerptL(textProperty->Value());
       
   184        }
       
   185         
       
   186     //Get description property
       
   187     CMdEPropertyDef& descriprionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDescriptionProperty );
       
   188     if(aObject.Property( descriprionPropDef, property ) != KErrNotFound)
       
   189        {
       
   190        //Add field to document
       
   191        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   192        AddFiledtoDocumentL(*index_item,
       
   193                    MdeConstants::MediaObject::KDescriptionProperty,
       
   194                    textProperty->Value());
       
   195        AddToFieldExcerptL(textProperty->Value());
       
   196        }
       
   197     //Copyright property    
       
   198     CMdEPropertyDef& copyrightPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCopyrightProperty );
       
   199     if(aObject.Property( copyrightPropDef, property ) != KErrNotFound)
       
   200        {
       
   201        //Add field to document
       
   202        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   203        AddFiledtoDocumentL(*index_item,
       
   204                       MdeConstants::MediaObject::KCopyrightProperty,
       
   205                       textProperty->Value());
       
   206        AddToFieldExcerptL(textProperty->Value());
       
   207        } 
       
   208     //Get genre property
       
   209     CMdEPropertyDef& genrePropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KGenreProperty );
       
   210     if(aObject.Property( genrePropDef, property ) != KErrNotFound)
       
   211        {
       
   212        //Add field to document
       
   213        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   214        AddFiledtoDocumentL(*index_item,
       
   215                    MdeConstants::MediaObject::KGenreProperty,
       
   216                    textProperty->Value());
       
   217        AddToFieldExcerptL(textProperty->Value());
       
   218        }
       
   219     
       
   220     //Size property
       
   221     CMdEPropertyDef& sizePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KSizeProperty);
       
   222     if(aObject.Property( sizePropDef, property )!= KErrNotFound)
       
   223        {
       
   224        //Add field to document
       
   225        if( property->Def().PropertyType() == EPropertyUint32 )
       
   226            {
       
   227            CMdEUint32Property& sizeProperty = static_cast < CMdEUint32Property& > (*property );
       
   228            TBuf<32> buf;
       
   229            buf.Format(_L("%u"), sizeProperty.Value());
       
   230            AddFiledtoDocumentL(*index_item,
       
   231                            MdeConstants::Object::KSizeProperty,
       
   232                            buf,
       
   233                            CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   234            AddToFieldExcerptL(buf);
       
   235            }
       
   236        }
       
   237     
       
   238     //Get legal property
       
   239     CMdEPropertyDef& legalPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KLegalProperty );
       
   240     if(aObject.Property( legalPropDef, property ) != KErrNotFound)
       
   241        {
       
   242        //Add field to document
       
   243        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   244        AddFiledtoDocumentL(*index_item,
       
   245                    MdeConstants::MediaObject::KLegalProperty,
       
   246                    textProperty->Value());
       
   247        AddToFieldExcerptL(textProperty->Value());
       
   248        }
       
   249     //Get track property
       
   250     CMdEPropertyDef& trackPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KTrackProperty );
       
   251     if(aObject.Property( trackPropDef, property ) != KErrNotFound)
       
   252        {
       
   253        //Add field to document       
       
   254        if( property->Def().PropertyType() == EPropertyUint16 )
       
   255            {
       
   256            CMdEUint16Property& trackProperty = static_cast < CMdEUint16Property& > (*property );               
       
   257            TBuf<32> buf;
       
   258            buf.Format(_L("%d"), trackProperty.Value());
       
   259            AddFiledtoDocumentL(*index_item,
       
   260                               MdeConstants::MediaObject::KTrackProperty,
       
   261                               buf);
       
   262            }       
       
   263        }
       
   264     // Capturedate property
       
   265     CMdEPropertyDef& captureDatePropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCaptureDateProperty);
       
   266     if(aObject.Property( captureDatePropDef, property ) != KErrNotFound)
       
   267       {
       
   268       //Add field to document
       
   269       if(EPropertyTime == property->Def().PropertyType())
       
   270           {
       
   271           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
       
   272           TDateTime time = timeProperty.Value().DateTime();
       
   273           TBuf<32> buf;
       
   274           buf.Format( KFormatDateTime, time.Year(), 
       
   275                                        time.Month() + 1, 
       
   276                                        time.Day() + 1, 
       
   277                                        time.Hour(), 
       
   278                                        time.Minute());
       
   279           
       
   280           AddFiledtoDocumentL(*index_item,
       
   281                              MdeConstants::MediaObject::KCaptureDateProperty,
       
   282                              buf,
       
   283                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   284           
       
   285           //Format for excerpt field
       
   286           buf.Format( KExcerptFormat, time.Year(), 
       
   287                                      time.Month() + 1, 
       
   288                                      time.Day() + 1, 
       
   289                                      time.Hour(), 
       
   290                                      time.Minute());
       
   291           AddToFieldExcerptL(buf);
       
   292           }
       
   293       }
       
   294     //Get LastModifiedDate property
       
   295     CMdEPropertyDef& dateTimePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KLastModifiedDateProperty);
       
   296     if(aObject.Property( dateTimePropDef, property ) != KErrNotFound)
       
   297       {
       
   298       //Add field to document
       
   299       if(EPropertyTime == property->Def().PropertyType())
       
   300           {
       
   301           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
       
   302           TDateTime time = timeProperty.Value().DateTime();
       
   303           TBuf<32> buf;
       
   304           buf.Format( KFormatDateTime, time.Year(),
       
   305                                        time.Month() + 1,
       
   306                                        time.Day() + 1,
       
   307                                        time.Hour(),
       
   308                                        time.Minute());
       
   309           
       
   310           AddFiledtoDocumentL(*index_item,
       
   311                              MdeConstants::Object::KLastModifiedDateProperty,
       
   312                              buf,
       
   313                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   314           //Format for excerpt field
       
   315           buf.Format( KExcerptFormat, time.Year(), 
       
   316                                    time.Month() + 1, 
       
   317                                    time.Day() + 1, 
       
   318                                    time.Hour(), 
       
   319                                    time.Minute());
       
   320           AddToFieldExcerptL(buf);
       
   321           }
       
   322       }
       
   323     //Get duration property
       
   324     CMdEPropertyDef& durationPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDurationProperty );
       
   325     if(aObject.Property( durationPropDef, property ) != KErrNotFound)
       
   326        {        
       
   327        //Add field to document
       
   328        if( property->Def().PropertyType() == EPropertyReal32 )
       
   329            {
       
   330            CMdEReal32Property& durationProperty = static_cast < CMdEReal32Property& > (*property );               
       
   331            TBuf<32> buf;
       
   332            buf.Format(_L("%f"), durationProperty.Value());
       
   333            AddFiledtoDocumentL(*index_item,
       
   334                           MdeConstants::MediaObject::KDurationProperty,
       
   335                           buf );
       
   336            }       
       
   337        }
       
   338     if( iExcerpt )
       
   339         {
       
   340         index_item->AddExcerptL(*iExcerpt);
       
   341         }
   154     CPIXLOGSTRING("END CCPIXMediaAudioDoc::GetCpixDocumentL");
   342     CPIXLOGSTRING("END CCPIXMediaAudioDoc::GetCpixDocumentL");
   155     OstTraceFunctionExit0( CCPIXMEDIAAUDIODOC_GETCPIXDOCUMENTL_EXIT );
   343     OstTraceFunctionExit0( CCPIXMEDIAAUDIODOC_GETCPIXDOCUMENTL_EXIT );
   156     return index_item;
   344     return index_item;
   157     }
   345     }
   158 //End of life
   346 //End of life