harvesterplugins/media/video/src/cpixmediavideodoc.cpp
changeset 11 773be20e0a25
parent 5 3bc31ad99ee7
child 12 993ab30e92fc
equal deleted inserted replaced
7:51d10d255e92 11:773be20e0a25
    27 #include "csearchdocument.h"
    27 #include "csearchdocument.h"
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    29 #include "cpixmediavideodocTraces.h"
    29 #include "cpixmediavideodocTraces.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");   //yyyy/mm/dd hh:mm
    33 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    34 // CCPIXDocFetcher::NewL()
    35 // CCPIXDocFetcher::NewL()
    35 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    36 //
    37 //
    37 CCPIXMediaVideoDoc* CCPIXMediaVideoDoc::NewL()
    38 CCPIXMediaVideoDoc* CCPIXMediaVideoDoc::NewL()
   101     CMdEProperty* property(NULL);
   102     CMdEProperty* property(NULL);
   102     CMdEPropertyDef& descriptionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDescriptionProperty );
   103     CMdEPropertyDef& descriptionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDescriptionProperty );
   103     if(aObject.Property( descriptionPropDef, property ) != KErrNotFound)
   104     if(aObject.Property( descriptionPropDef, property ) != KErrNotFound)
   104        {
   105        {
   105        //Add field to document
   106        //Add field to document
   106        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   107        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   107        AddFiledtoDocumentL(*index_item,
   108        AddFiledtoDocumentL(*index_item,
   108                   MdeConstants::MediaObject::KDescriptionProperty,
   109                   MdeConstants::MediaObject::KDescriptionProperty,
   109                   textProperty->Value());
   110                   textProperty->Value());
   110        AddToFieldExcerptL(textProperty->Value());
   111        AddToFieldExcerptL(textProperty->Value());
   111        }
   112        }
   112     CMdEPropertyDef& artistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KArtistProperty );
   113     CMdEPropertyDef& artistPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KArtistProperty );
   113     if(aObject.Property( artistPropDef, property )!= KErrNotFound)
   114     if(aObject.Property( artistPropDef, property )!= KErrNotFound)
   114        {
   115        {
   115        //Add field to document
   116        //Add field to document
   116        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   117        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   117        AddFiledtoDocumentL(*index_item,
   118        AddFiledtoDocumentL(*index_item,
   118                            MdeConstants::MediaObject::KArtistProperty,
   119                            MdeConstants::MediaObject::KArtistProperty,
   119                            textProperty->Value());
   120                            textProperty->Value(),
       
   121                            CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   120        AddToFieldExcerptL(textProperty->Value());
   122        AddToFieldExcerptL(textProperty->Value());
   121        }
   123        }
   122     CMdEPropertyDef& authorPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KAuthorProperty );
   124     CMdEPropertyDef& authorPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KAuthorProperty );
   123     if(aObject.Property( authorPropDef, property ) != KErrNotFound)
   125     if(aObject.Property( authorPropDef, property ) != KErrNotFound)
   124        {
   126        {
   125        //Add field to document
   127        //Add field to document
   126        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   128        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   127        AddFiledtoDocumentL(*index_item,
   129        AddFiledtoDocumentL(*index_item,
   128                          MdeConstants::MediaObject::KAuthorProperty,
   130                          MdeConstants::MediaObject::KAuthorProperty,
   129                          textProperty->Value());
   131                          textProperty->Value(),
   130        AddToFieldExcerptL(textProperty->Value());
   132                          CDocumentField::EStoreYes | CDocumentField::EIndexTokenized | CDocumentField::EIndexFreeText);
   131        }
   133        AddToFieldExcerptL(textProperty->Value());
       
   134        }      
       
   135     
       
   136     CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty );
       
   137     if(aObject.Property( commentPropDef, property ) != KErrNotFound)
       
   138        {
       
   139        //Add field to document
       
   140        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   141        AddFiledtoDocumentL(*index_item,
       
   142                    MdeConstants::MediaObject::KCommentProperty,
       
   143                    textProperty->Value());
       
   144        AddToFieldExcerptL(textProperty->Value());
       
   145        }
       
   146     
       
   147     //Get description property
       
   148     CMdEPropertyDef& descriprionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDescriptionProperty );
       
   149     if(aObject.Property( descriprionPropDef, property ) != KErrNotFound)
       
   150        {
       
   151        //Add field to document
       
   152        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   153        AddFiledtoDocumentL(*index_item,
       
   154                    MdeConstants::MediaObject::KDescriptionProperty,
       
   155                    textProperty->Value());
       
   156        AddToFieldExcerptL(textProperty->Value());
       
   157        }
       
   158     
   132     CMdEPropertyDef& copyrightPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCopyrightProperty );
   159     CMdEPropertyDef& copyrightPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCopyrightProperty );
   133     if(aObject.Property( copyrightPropDef, property ) != KErrNotFound)
   160     if(aObject.Property( copyrightPropDef, property ) != KErrNotFound)
   134        {
   161        {
   135        //Add field to document
   162        //Add field to document
   136        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   163        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   137        AddFiledtoDocumentL(*index_item,
   164        AddFiledtoDocumentL(*index_item,
   138                       MdeConstants::MediaObject::KCopyrightProperty,
   165                       MdeConstants::MediaObject::KCopyrightProperty,
   139                       textProperty->Value());
   166                       textProperty->Value());
   140        AddToFieldExcerptL(textProperty->Value());
   167        AddToFieldExcerptL(textProperty->Value());
   141        }   
   168        } 
   142     
   169     //Get genre property
   143     CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty );
   170     CMdEPropertyDef& genrePropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KGenreProperty );
   144     if(aObject.Property( commentPropDef, property ) != KErrNotFound)
   171     if(aObject.Property( genrePropDef, property ) != KErrNotFound)
   145        {
   172        {
   146        //Add field to document
   173        //Add field to document
   147        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   174        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   148        AddFiledtoDocumentL(*index_item,
   175        AddFiledtoDocumentL(*index_item,
   149                    MdeConstants::MediaObject::KCommentProperty,
   176                    MdeConstants::MediaObject::KGenreProperty,
   150                    textProperty->Value());
   177                    textProperty->Value());
   151        AddToFieldExcerptL(textProperty->Value());
   178        AddToFieldExcerptL(textProperty->Value());
   152        }
   179        }
   153     index_item->AddExcerptL(*iExcerpt);
   180     //Size property
       
   181     CMdEPropertyDef& sizePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KSizeProperty);
       
   182     if(aObject.Property( sizePropDef, property )!= KErrNotFound)
       
   183        {
       
   184        //Add field to document
       
   185        if( property->Def().PropertyType() == EPropertyUint32 )
       
   186            {
       
   187            CMdEUint32Property& sizeProperty = static_cast < CMdEUint32Property& > (*property );
       
   188            TBuf<32> buf;
       
   189            buf.Format(_L("%u"), sizeProperty.Value());
       
   190            AddFiledtoDocumentL(*index_item,
       
   191                            MdeConstants::Object::KSizeProperty,
       
   192                            buf,
       
   193                            CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   194            AddToFieldExcerptL(buf);
       
   195            }
       
   196        }    
       
   197     //Get resolution property
       
   198     CMdEPropertyDef& resolutionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KResolutionUnitProperty );
       
   199     if(aObject.Property( resolutionPropDef, property ) != KErrNotFound)
       
   200        {
       
   201        //Add field to document
       
   202        if( property->Def().PropertyType() == EPropertyUint16 )
       
   203            {
       
   204            CMdEUint16Property& resolutionProperty = static_cast < CMdEUint16Property& > (*property );               
       
   205            TBuf<32> buf;
       
   206            buf.Format(_L("%d"), resolutionProperty.Value());
       
   207            AddFiledtoDocumentL(*index_item,
       
   208                               MdeConstants::MediaObject::KResolutionUnitProperty,
       
   209                               buf,
       
   210                               CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   211            }       
       
   212        }    
       
   213     //Get legal property
       
   214     CMdEPropertyDef& legalPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KLegalProperty );
       
   215     if(aObject.Property( legalPropDef, property ) != KErrNotFound)
       
   216        {
       
   217        //Add field to document
       
   218        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   219        AddFiledtoDocumentL(*index_item,
       
   220                    MdeConstants::MediaObject::KLegalProperty,
       
   221                    textProperty->Value());       
       
   222        }
       
   223     //Get track property
       
   224     CMdEPropertyDef& trackPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KTrackProperty );
       
   225     if(aObject.Property( trackPropDef, property ) != KErrNotFound)
       
   226        {
       
   227        //Add field to document       
       
   228        if( property->Def().PropertyType() == EPropertyUint16 )
       
   229            {
       
   230            CMdEUint16Property& trackProperty = static_cast < CMdEUint16Property& > (*property );               
       
   231            TBuf<32> buf;
       
   232            buf.Format(_L("%d"), trackProperty.Value());
       
   233            AddFiledtoDocumentL(*index_item,
       
   234                               MdeConstants::MediaObject::KTrackProperty,
       
   235                               buf);
       
   236            }       
       
   237        }
       
   238     // Capturedate property
       
   239     CMdEPropertyDef& captureDatePropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCaptureDateProperty);
       
   240     if(aObject.Property( captureDatePropDef, property ) != KErrNotFound)
       
   241       {
       
   242       //Add field to document
       
   243       if(EPropertyTime == property->Def().PropertyType())
       
   244           {
       
   245           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
       
   246           TDateTime time = timeProperty.Value().DateTime();
       
   247           TBuf<32> buf;
       
   248           buf.Format( KFormatDateTime, time.Year(), 
       
   249                                        time.Month() + 1, 
       
   250                                        time.Day() + 1, 
       
   251                                        time.Hour(), 
       
   252                                        time.Minute());
       
   253           
       
   254           AddFiledtoDocumentL(*index_item,
       
   255                              MdeConstants::MediaObject::KCaptureDateProperty,
       
   256                              buf,
       
   257                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   258           //Format for excerpt field
       
   259           buf.Format( KExcerptFormat, time.Year(), 
       
   260                                  time.Month() + 1, 
       
   261                                  time.Day() + 1, 
       
   262                                  time.Hour(), 
       
   263                                  time.Minute());
       
   264           AddToFieldExcerptL(buf);
       
   265           }
       
   266       }
       
   267     //Get LastModifiedDate property
       
   268     CMdEPropertyDef& dateTimePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KLastModifiedDateProperty);
       
   269     if(aObject.Property( dateTimePropDef, property ) != KErrNotFound)
       
   270       {
       
   271       //Add field to document
       
   272       if(EPropertyTime == property->Def().PropertyType())
       
   273           {
       
   274           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
       
   275           TDateTime time = timeProperty.Value().DateTime();
       
   276           TBuf<32> buf;
       
   277           buf.Format( KFormatDateTime, time.Year(),
       
   278                                        time.Month() + 1,
       
   279                                        time.Day() + 1,
       
   280                                        time.Hour(),
       
   281                                        time.Minute());
       
   282           
       
   283           AddFiledtoDocumentL(*index_item,
       
   284                              MdeConstants::Object::KLastModifiedDateProperty,
       
   285                              buf,
       
   286                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   287           //Format for excerpt field
       
   288           buf.Format( KExcerptFormat, time.Year(), 
       
   289                                    time.Month() + 1, 
       
   290                                    time.Day() + 1, 
       
   291                                    time.Hour(), 
       
   292                                    time.Minute());
       
   293           AddToFieldExcerptL(buf);
       
   294           }
       
   295       }
       
   296     //Get duration property
       
   297     CMdEPropertyDef& durationPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDurationProperty );
       
   298     if(aObject.Property( durationPropDef, property ) != KErrNotFound)
       
   299        {
       
   300        //Add field to document       
       
   301        if( property->Def().PropertyType() == EPropertyReal32 )
       
   302            {
       
   303            CMdEReal32Property& durationProperty = static_cast < CMdEReal32Property& > (*property );               
       
   304            TBuf<32> buf;
       
   305            buf.Format(_L("%f"), durationProperty.Value());
       
   306            AddFiledtoDocumentL(*index_item,
       
   307                               MdeConstants::MediaObject::KDurationProperty,
       
   308                               buf,
       
   309                               CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   310            }       
       
   311        }
       
   312     if( iExcerpt )
       
   313         {
       
   314         index_item->AddExcerptL(*iExcerpt);
       
   315         }
   154     OstTraceFunctionExit0( CCPIXMEDIAVIDEODOC_GETCPIXDOCUMENTL_EXIT );
   316     OstTraceFunctionExit0( CCPIXMEDIAVIDEODOC_GETCPIXDOCUMENTL_EXIT );
   155     return index_item;
   317     return index_item;
   156     }
   318     }
   157