photosgallery/collectionframework/datasource/plugins/glxdatasourcemde2.5/src/glxdatasourcetaskmdsidlist.cpp
branchRCL_3
changeset 35 420f6808bf21
parent 18 bcb43dc84c44
child 47 f9e827349359
equal deleted inserted replaced
32:78ad99c24f08 35:420f6808bf21
    23  */
    23  */
    24 
    24 
    25 #include "glxdatasourcetaskmdsidlist.h"
    25 #include "glxdatasourcetaskmdsidlist.h"
    26 
    26 
    27 #include <glxcollectionplugincamera.hrh>
    27 #include <glxcollectionplugincamera.hrh>
    28 #include <glxcollectionplugindownloads.hrh>
       
    29 #include <glxcollectionpluginmonths.hrh>
       
    30 #include <glxcollectionpluginalbums.hrh>
    28 #include <glxcollectionpluginalbums.hrh>
    31 #include <glxcollectionpluginall.hrh>
    29 #include <glxcollectionpluginall.hrh>
    32 #include <glxcollectionplugintags.hrh>
    30 #include <glxcollectionplugintags.hrh>
    33 #include <glxcollectionpluginimageviewer.hrh>
    31 #include <glxcollectionpluginimageviewer.hrh>
    34 
    32 
    70 
    68 
    71 // CONSTANTS
    69 // CONSTANTS
    72 const TInt KGlxCameraAlbumPromotionPosition = 0;
    70 const TInt KGlxCameraAlbumPromotionPosition = 0;
    73 const TInt KGlxfavoritesAlbumPromotionPosition = 1;
    71 const TInt KGlxfavoritesAlbumPromotionPosition = 1;
    74 
    72 
    75 _LIT(KPropertyDefNameCreationDate, "CreationDate");
       
    76 
    73 
    77 // ----------------------------------------------------------------------------
    74 // ----------------------------------------------------------------------------
    78 //  Constructor
    75 //  Constructor
    79 // ----------------------------------------------------------------------------
    76 // ----------------------------------------------------------------------------
    80 //	
    77 //	
   144                 {
   141                 {
   145                 isContent = EFalse;
   142                 isContent = EFalse;
   146                 objectDef = &DataSource()->TagDef();
   143                 objectDef = &DataSource()->TagDef();
   147                 break;
   144                 break;
   148                 }
   145                 }
   149             case KGlxCollectionPluginMonthsImplementationUid:
       
   150                 {
       
   151                 iFilterProperties.iOrigin = EGlxFilterOriginAll;          
       
   152                 container = TGlxMediaId(KGlxCollectionRootId);
       
   153                 resultMode = EQueryResultModeItem;
       
   154                 break;
       
   155                 }
       
   156             case KGlxCollectionPluginImageViewerImplementationUid:
   146             case KGlxCollectionPluginImageViewerImplementationUid:
   157                 {
   147                 {
   158                 RArray<TGlxMediaId> list;
   148                 RArray<TGlxMediaId> list;
   159                 CleanupClosePushL(list);
   149                 CleanupClosePushL(list);
   160                 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid));
   150                 list.AppendL(TGlxMediaId(request->CollectionPluginUid().iUid));
   179                 break;
   169                 break;
   180                 }
   170                 }
   181             case KGlxTagCollectionPluginImplementationUid: 
   171             case KGlxTagCollectionPluginImplementationUid: 
   182                 {
   172                 {
   183                 objectDef = &DataSource()->TagDef();
   173                 objectDef = &DataSource()->TagDef();
   184                 break;
       
   185                 }
       
   186             case KGlxCollectionPluginMonthsImplementationUid: 
       
   187                 {
       
   188 				iFilterProperties.iOrigin = EGlxFilterOriginAll;
       
   189                 AddMonthFilterL(container, iFilterProperties);
       
   190                 container = TGlxMediaId(KGlxCollectionRootId);
       
   191                 break;
   174                 break;
   192                 }
   175                 }
   193             default:
   176             default:
   194                 {
   177                 {
   195                 User::Leave(KErrNotSupported);
   178                 User::Leave(KErrNotSupported);
   222 // ----------------------------------------------------------------------------
   205 // ----------------------------------------------------------------------------
   223 //  
   206 //  
   224 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()
   207 void CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()
   225     {
   208     {
   226     TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()")
   209     TRACER("CGlxDataSourceTaskMdeIdList::DoHandleListQueryCompletedL()")
   227     if(iQueries[0]->ResultMode() == EQueryResultModeItem)
   210     RArray<TGlxMediaId> localList;
   228         {
   211     CleanupClosePushL(localList);
   229         DoMonthListCreationL(*iQueries[0], iFilterProperties);
   212     NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList,
   230         }
   213             iQueries[0]->ResultIds());
   231     else // only id or item supported
   214     PostFilterL(localList, iFilterProperties);
   232         {
   215     CleanupStack::PopAndDestroy(&localList);
   233 
       
   234         RArray<TGlxMediaId> localList;
       
   235         CleanupClosePushL(localList);
       
   236         NGlxDataSourceMdsUtility::CopyItemIdArrayL(localList,iQueries[0]->ResultIds());
       
   237         PostFilterL(localList, iFilterProperties);
       
   238         CleanupStack::PopAndDestroy(&localList);
       
   239         }
       
   240     }     
   216     }     
   241 
       
   242 // ----------------------------------------------------------------------------
       
   243 // CGlxDataSourceTaskMdeIdList::DoMonthListCreationL
       
   244 // ----------------------------------------------------------------------------
       
   245 //      
       
   246 void CGlxDataSourceTaskMdeIdList::DoMonthListCreationL(CMdEQuery& aQuery,
       
   247                                   const TGlxFilterProperties& aFilterProperties)
       
   248     {
       
   249     TRACER("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL()")
       
   250     CMdEProperty* time;
       
   251     CMdEPropertyDef& creationDateDef = DataSource()->ObjectDef().GetPropertyDefL(KPropertyDefNameCreationDate);
       
   252     if (creationDateDef.PropertyType() != EPropertyTime)
       
   253         {
       
   254         User::Leave(KErrCorrupt);
       
   255         }
       
   256     RArray<TGlxMediaId> monthList;
       
   257     CleanupClosePushL(monthList);
       
   258     TTime lastMonth;
       
   259     TTime currentMonth;
       
   260     TInt count = aQuery.Count();
       
   261     GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL count=%d", count);    
       
   262     for( TInt i = 0 ; i < count ; i++ )
       
   263         {
       
   264         CMdEObject& object = (CMdEObject&)aQuery.ResultItem(i);
       
   265         TInt timeIndex = object.Property(creationDateDef, time);
       
   266         if( KErrNotFound == timeIndex )
       
   267             {
       
   268             User::Leave(KErrCorrupt);
       
   269             }
       
   270         currentMonth = static_cast<CMdETimeProperty*>(time)->Value();
       
   271 
       
   272         // Also Checking for a Valid Month Entry Based on a Year Greater than 0000.
       
   273         if( !DataSource()->SameMonth(lastMonth, currentMonth) && (currentMonth.DateTime().Year() > 0) )
       
   274             {
       
   275             const TGlxMediaId monthId = DataSource()->GetMonthIdL(currentMonth);
       
   276             monthList.AppendL(monthId);
       
   277             GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL monthId=%d", monthId.Value());    
       
   278             lastMonth = currentMonth;
       
   279             }
       
   280         }
       
   281     GLX_DEBUG2("CGlxDataSourceTaskMdeIdList::DoMonthListCreationL monthList.Count=%d", monthList.Count());    
       
   282     PostFilterL(monthList, aFilterProperties);
       
   283     CleanupStack::PopAndDestroy(&monthList);
       
   284     }
       
   285 
   217 
   286 // ----------------------------------------------------------------------------
   218 // ----------------------------------------------------------------------------
   287 //  CGlxDataSourceTaskMdeIdList::DoPostFilterComplete
   219 //  CGlxDataSourceTaskMdeIdList::DoPostFilterComplete
   288 // ----------------------------------------------------------------------------
   220 // ----------------------------------------------------------------------------
   289 //
   221 //
   342 			}
   274 			}
   343 					
   275 					
   344 		DoPostFilterComplete(list, KErrNone);
   276 		DoPostFilterComplete(list, KErrNone);
   345 		}
   277 		}
   346 	else
   278 	else
   347             {
   279         {
   348             DoPostFilterComplete(aFilteredList, KErrNone);
   280         DoPostFilterComplete(aFilteredList, KErrNone);
   349             }
   281         }
   350     }
   282     }