harvesterplugins/media/image/src/cpixmediaimagedoc.cpp
changeset 11 773be20e0a25
parent 7 51d10d255e92
child 13 0a2ec6860a93
child 17 7d8c8d8f5eab
equal deleted inserted replaced
7:51d10d255e92 11:773be20e0a25
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    28 #ifdef OST_TRACE_COMPILER_IN_USE
    29 #include "cpixmediaimagedocTraces.h"
    29 #include "cpixmediaimagedocTraces.h"
    30 #endif
    30 #endif
    31 
    31 
    32 
    32 
    33 _LIT( KFormatDateTime, "%04d %02d %02dT%02d:%02d:%02dZ");    // yyyy-mm-ddThh:mm:ssZ
    33 _LIT( KFormatDateTime, "%04d %02d %02d %02d %02d");    // yyyy mm dd hh mm
    34 
    34 _LIT( KExcerptFormat, "%04d/%02d/%02d %02d:%02d");   //yyyy/mm/dd hh:mm
    35 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    36 // CCPIXDocFetcher::NewL()
    36 // CCPIXDocFetcher::NewL()
    37 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    38 //
    38 //
    39 CCPIXMediaImageDoc* CCPIXMediaImageDoc::NewL()
    39 CCPIXMediaImageDoc* CCPIXMediaImageDoc::NewL()
    94     OstTraceFunctionEntry0( CCPIXMEDIAIMAGEDOC_GETCPIXDOCUMENTL_ENTRY );
    94     OstTraceFunctionEntry0( CCPIXMEDIAIMAGEDOC_GETCPIXDOCUMENTL_ENTRY );
    95     //Get basic document
    95     //Get basic document
    96     CPIXLOGSTRING("START CCPIXMediaImageDoc::GetCpixDocumentL");
    96     CPIXLOGSTRING("START CCPIXMediaImageDoc::GetCpixDocumentL");
    97     CSearchDocument* index_item = CCPIXDocFetcher::GetCpixDocumentL(aObject,aAppClass,aObjectDef);
    97     CSearchDocument* index_item = CCPIXDocFetcher::GetCpixDocumentL(aObject,aAppClass,aObjectDef);
    98     ResetExcerpt(); //Reset excerpt initially
    98     ResetExcerpt(); //Reset excerpt initially
    99     //URI and Excerpt is done add additional properties here 
    99     //URI and Excerpt is done add additional properties here
   100     CMdEProperty* property(NULL);
   100     CMdEProperty* property(NULL);
   101     //Title property
   101     
   102     CMdEPropertyDef& titlePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KTitleProperty );
   102     CMdEPropertyDef& titlePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KTitleProperty );
   103     if(aObject.Property( titlePropDef, property ) != KErrNotFound)
   103        if(aObject.Property( titlePropDef, property ) != KErrNotFound)
   104        {
   104           {
   105        //Add field to document
   105           //Add field to document excerpt.
   106        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   106           CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   107        AddFiledtoDocumentL(*index_item,
   107           AddToFieldExcerptL(textProperty->Value());
   108                            MdeConstants::Object::KTitleProperty,
   108           }
   109                            textProperty->Value());
   109     
   110        AddToFieldExcerptL(textProperty->Value());
       
   111        }
       
   112             
       
   113     //Get user comment field
   110     //Get user comment field
   114     CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty );
   111     CMdEPropertyDef& commentPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCommentProperty );
   115     if(aObject.Property( commentPropDef, property )!= KErrNotFound)
   112     if(aObject.Property( commentPropDef, property )!= KErrNotFound)
   116        {
   113        {
   117        //Add field to document
   114        //Add field to document
   118        CMdETextProperty* textProperty = ( CMdETextProperty* ) property;
   115        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
   119        AddFiledtoDocumentL(*index_item,
   116        AddFiledtoDocumentL(*index_item,
   120                            MdeConstants::MediaObject::KCommentProperty,
   117                            MdeConstants::MediaObject::KCommentProperty,
   121                            textProperty->Value());
   118                            textProperty->Value());
   122        AddToFieldExcerptL(textProperty->Value());
   119        AddToFieldExcerptL(textProperty->Value());
   123        }
   120        }
   124     CMdEPropertyDef& dateTimePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Image::KDateTimeOriginalProperty);
   121     
       
   122     //Get user description field
       
   123     CMdEPropertyDef& descriptionPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KDescriptionProperty );
       
   124     if(aObject.Property( descriptionPropDef, property )!= KErrNotFound)
       
   125        {
       
   126        //Add field to document
       
   127        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   128        AddFiledtoDocumentL(*index_item,
       
   129                            MdeConstants::MediaObject::KDescriptionProperty,
       
   130                            textProperty->Value());
       
   131        AddToFieldExcerptL(textProperty->Value());
       
   132        }
       
   133     
       
   134     //Get user copyright field
       
   135     CMdEPropertyDef& copyRightPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KCopyrightProperty );
       
   136     if(aObject.Property( copyRightPropDef, property )!= KErrNotFound)
       
   137        {
       
   138        //Add field to document
       
   139        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   140        AddFiledtoDocumentL(*index_item,
       
   141                            MdeConstants::MediaObject::KCopyrightProperty,
       
   142                            textProperty->Value());
       
   143        AddToFieldExcerptL(textProperty->Value());
       
   144        }
       
   145 
       
   146     //Get user genre field
       
   147     CMdEPropertyDef& genrePropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KGenreProperty );
       
   148     if(aObject.Property( genrePropDef, property )!= KErrNotFound)
       
   149        {
       
   150        //Add field to document
       
   151        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   152        AddFiledtoDocumentL(*index_item,
       
   153                            MdeConstants::MediaObject::KGenreProperty,
       
   154                            textProperty->Value()); 
       
   155        AddToFieldExcerptL(textProperty->Value());
       
   156        }
       
   157 
       
   158     //Get legal property field
       
   159     CMdEPropertyDef& legalPropDef = aObjectDef.GetPropertyDefL(MdeConstants::MediaObject::KLegalProperty );
       
   160     if(aObject.Property( legalPropDef, property )!= KErrNotFound)
       
   161        {
       
   162        //Add field to document
       
   163        CMdETextProperty* textProperty = static_cast< CMdETextProperty* > (property );
       
   164        AddFiledtoDocumentL(*index_item,
       
   165                            MdeConstants::MediaObject::KLegalProperty,
       
   166                            textProperty->Value());
       
   167        AddToFieldExcerptL(textProperty->Value());
       
   168        }
       
   169     //Size property
       
   170     CMdEPropertyDef& sizePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KSizeProperty);
       
   171     if(aObject.Property( sizePropDef, property )!= KErrNotFound)
       
   172        {
       
   173        //Add field to document
       
   174        if( property->Def().PropertyType() == EPropertyUint32 )
       
   175            {
       
   176            CMdEUint32Property& sizeProperty = static_cast < CMdEUint32Property& > (*property );
       
   177            TBuf<32> buf;
       
   178            buf.Format(_L("%u"), sizeProperty.Value());
       
   179            AddFiledtoDocumentL(*index_item,
       
   180                            MdeConstants::Object::KSizeProperty,
       
   181                            buf,
       
   182                            CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   183            AddToFieldExcerptL(buf);
       
   184            }
       
   185        }
       
   186     //Get DateTimeOrginal property
       
   187     CMdEPropertyDef& dateTimeOrgPropDef = aObjectDef.GetPropertyDefL(MdeConstants::Image::KDateTimeOriginalProperty);
       
   188     if(aObject.Property( dateTimeOrgPropDef, property ) != KErrNotFound)
       
   189       {
       
   190       //Add field to document
       
   191       if(EPropertyTime == property->Def().PropertyType())
       
   192           {
       
   193           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
       
   194           TDateTime time = timeProperty.Value().DateTime();
       
   195           TBuf<32> buf;
       
   196           buf.Format( KFormatDateTime, time.Year(),
       
   197                                        time.Month() + 1,
       
   198                                        time.Day() + 1,
       
   199                                        time.Hour(),
       
   200                                        time.Minute());
       
   201           AddFiledtoDocumentL(*index_item,
       
   202                              MdeConstants::Image::KDateTimeOriginalProperty,
       
   203                              buf,
       
   204                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   205           //Format for excerpt field
       
   206           buf.Format( KExcerptFormat, time.Year(), 
       
   207                                    time.Month() + 1, 
       
   208                                    time.Day() + 1, 
       
   209                                    time.Hour(), 
       
   210                                    time.Minute());
       
   211           AddToFieldExcerptL(buf);
       
   212           }
       
   213       }
       
   214     //Get LastModifiedDate property
       
   215     CMdEPropertyDef& dateTimePropDef = aObjectDef.GetPropertyDefL(MdeConstants::Object::KLastModifiedDateProperty);
   125     if(aObject.Property( dateTimePropDef, property ) != KErrNotFound)
   216     if(aObject.Property( dateTimePropDef, property ) != KErrNotFound)
   126       {
   217       {
   127       //Add field to document
   218       //Add field to document
   128       if(EPropertyTime == property->Def().PropertyType())
   219       if(EPropertyTime == property->Def().PropertyType())
   129           {
   220           {
   130           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
   221           CMdETimeProperty& timeProperty = static_cast < CMdETimeProperty& > (*property);
   131           TDateTime time = timeProperty.Value().DateTime();
   222           TDateTime time = timeProperty.Value().DateTime();
   132           TBuf<32> buf;
   223           TBuf<32> buf;
   133           buf.Format( KFormatDateTime, time.Year(), 
   224           buf.Format( KFormatDateTime, time.Year(),
   134                                        time.Month() + 1, 
   225                                        time.Month() + 1,
   135                                        time.Day() + 1, 
   226                                        time.Day() + 1,
   136                                        time.Hour(), 
   227                                        time.Hour(),
   137                                        time.Minute(), 
   228                                        time.Minute());
   138                                        time.Second() );
   229           
   139           AddFiledtoDocumentL(*index_item,
   230           AddFiledtoDocumentL(*index_item,
   140                              MdeConstants::Image::KDateTimeOriginalProperty,
   231                              MdeConstants::Object::KLastModifiedDateProperty,
   141                              buf,
   232                              buf,
   142                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
   233                              CDocumentField::EStoreYes | CDocumentField::EIndexUnTokenized);
       
   234           //Format for excerpt field
       
   235           buf.Format( KExcerptFormat, time.Year(), 
       
   236                                    time.Month() + 1, 
       
   237                                    time.Day() + 1, 
       
   238                                    time.Hour(), 
       
   239                                    time.Minute());
       
   240           AddToFieldExcerptL(buf);
   143           }
   241           }
   144       }
   242       }
   145     index_item->AddExcerptL(*iExcerpt);
   243     if( iExcerpt )
       
   244         {
       
   245         index_item->AddExcerptL(*iExcerpt);
       
   246         }
       
   247 
   146     //Latitude error currently 
   248     //Latitude error currently 
   147     /* TODO- Bhuvi Location is a seperate object for each image object if any such relation
   249     /* TODO- Bhuvi Location is a seperate object for each image object if any such relation
   148      * exist it has to be searched from Relation table and from there we have to open 
   250      * exist it has to be searched from Relation table and from there we have to open 
   149      * location object and query Longitude and Latitudes
   251      * location object and query Longitude and Latitudes
   150      */
   252      */