189 iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack, |
189 iAsyncHandleQueryCompleteCaller = new (ELeave) CAsyncCallBack( callBack, |
190 CActive::EPriorityStandard ); |
190 CActive::EPriorityStandard ); |
191 |
191 |
192 iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL( |
192 iMdsShutdownMonitor = CVcxMdsShutdownMonitor::NewL( |
193 *this, KHarvesterPSShutdown, KMdSShutdown, EFalse ); |
193 *this, KHarvesterPSShutdown, KMdSShutdown, EFalse ); |
|
194 |
|
195 iEvents.Reset(); |
194 |
196 |
195 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" ); |
197 MPX_DEBUG1( "CVcxMyVideosMdsDb::ConstructL exit" ); |
196 } |
198 } |
197 |
199 |
198 // --------------------------------------------------------------------------- |
200 // --------------------------------------------------------------------------- |
254 // |
256 // |
255 void CVcxMyVideosMdsDb::HandleObjectPresentNotification( CMdESession& /*aSession*/, |
257 void CVcxMyVideosMdsDb::HandleObjectPresentNotification( CMdESession& /*aSession*/, |
256 TBool aPresent, const RArray<TItemId>& aObjectIdArray) |
258 TBool aPresent, const RArray<TItemId>& aObjectIdArray) |
257 { |
259 { |
258 MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." ); |
260 MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------." ); |
259 MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %3d) |", aPresent, aObjectIdArray.Count() ); |
261 MPX_DEBUG3( "CVcxMyVideosMdsDb::HandleObjectPresentNotification( aPresent = %1d, count = %4d) |", aPresent, aObjectIdArray.Count() ); |
260 MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" ); |
262 MPX_DEBUG1( "CVcxMyVideosMdsDb::--------------------------------------------------------------'" ); |
261 |
263 |
262 TObserverNotificationType type; |
264 TObserverNotificationType type; |
263 if ( aPresent ) |
265 if ( aPresent ) |
264 { |
266 { |
1602 { |
1607 { |
1603 MPX_FUNC( "CVcxMyVideosMdsDb::DoHandleObjectNotificationL" ); |
1608 MPX_FUNC( "CVcxMyVideosMdsDb::DoHandleObjectNotificationL" ); |
1604 |
1609 |
1605 if ( iMdsDbObserver ) |
1610 if ( iMdsDbObserver ) |
1606 { |
1611 { |
1607 RArray<TUint32> idArray; |
1612 // Let delete events bypass buffer only if it empty. |
1608 CleanupClosePushL( idArray ); // 1-> |
1613 // This assures that event arriving order stays the same. |
1609 |
1614 if ( aType & ENotifyRemove && iEvents.Count() == 0 ) |
1610 for ( TInt i = 0; i < aObjectIdArray.Count(); i++ ) |
1615 { |
1611 { |
1616 // Delete handling is so fast that we dont buffer them at all. |
1612 idArray.Append( aObjectIdArray[i] ); |
1617 // Modify and add require fetch from mds -> they are slow. |
1613 } |
1618 RArray<TUint32> idArray; |
|
1619 CleanupClosePushL( idArray ); // 1-> |
|
1620 |
|
1621 for ( TInt i = 0; i < aObjectIdArray.Count(); i++ ) |
|
1622 { |
|
1623 idArray.Append( aObjectIdArray[i] ); |
|
1624 } |
|
1625 |
|
1626 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemDeleted, idArray, iEvents.Count() ); |
|
1627 |
|
1628 CleanupStack::PopAndDestroy( &idArray ); // <-1 |
|
1629 } |
|
1630 else |
|
1631 { |
|
1632 // Buffer modify & add events, since their handling is slow. |
|
1633 // Process them on background. |
|
1634 TInt count = aObjectIdArray.Count(); |
1614 |
1635 |
1615 if ( aType & ENotifyAdd ) |
1636 if ( iEvents.Count() == 0 ) |
1616 { |
1637 { |
1617 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemInserted, idArray ); |
1638 iEvents.ReserveL( count ); |
1618 } |
1639 } |
1619 else if ( aType & ENotifyModify ) |
|
1620 { |
|
1621 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemModified, idArray ); |
|
1622 } |
|
1623 else if ( aType & ENotifyRemove ) |
|
1624 { |
|
1625 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemDeleted, idArray ); |
|
1626 } |
|
1627 |
|
1628 CleanupStack::PopAndDestroy( &idArray ); // <-1 |
|
1629 } |
|
1630 |
1640 |
|
1641 TEvent event; |
|
1642 for ( TInt i = 0; i < count; i++ ) |
|
1643 { |
|
1644 event.iMdsId = aObjectIdArray[i]; |
|
1645 event.iEventType = aType; |
|
1646 iEvents.AppendL( event ); |
|
1647 } |
|
1648 |
|
1649 if ( !iEventProcessor ) |
|
1650 { |
|
1651 iEventProcessor = CIdle::NewL( CActive::EPriorityIdle ); |
|
1652 } |
|
1653 |
|
1654 if ( !iEventProcessor->IsActive() ) |
|
1655 { |
|
1656 iEventProcessor->Start( TCallBack( ProcessEvents, this )); |
|
1657 } |
|
1658 } |
|
1659 } |
|
1660 } |
|
1661 |
|
1662 // --------------------------------------------------------------------------- |
|
1663 // CVcxMyVideosMdsDb::ProcessEvents |
|
1664 // --------------------------------------------------------------------------- |
|
1665 // |
|
1666 TInt CVcxMyVideosMdsDb::ProcessEvents( TAny* aPtr ) |
|
1667 { |
|
1668 return static_cast<CVcxMyVideosMdsDb*>(aPtr)->DoProcessEvents(); |
|
1669 } |
|
1670 |
|
1671 // --------------------------------------------------------------------------- |
|
1672 // CVcxMyVideosMdsDb::DoProcessEvents |
|
1673 // --------------------------------------------------------------------------- |
|
1674 // |
|
1675 TInt CVcxMyVideosMdsDb::DoProcessEvents() |
|
1676 { |
|
1677 TInt sent = 0; |
|
1678 TInt currentEventType = -1; |
|
1679 const TInt sendAtOnce = 10; |
|
1680 |
|
1681 RArray<TUint32> idArray; |
|
1682 CleanupClosePushL( idArray ); // 1-> |
|
1683 |
|
1684 idArray.Reserve( sendAtOnce ); // may fail, it's ok |
|
1685 |
|
1686 while ( sent < sendAtOnce ) |
|
1687 { |
|
1688 if ( iEvents.Count() == 0 ) |
|
1689 { |
|
1690 break; |
|
1691 } |
|
1692 |
|
1693 if ( iEvents[0].iEventType != currentEventType && |
|
1694 currentEventType != -1 ) |
|
1695 { |
|
1696 break; |
|
1697 } |
|
1698 currentEventType = iEvents[0].iEventType; |
|
1699 idArray.Append( iEvents[0].iMdsId ); // this may fail, it is ok, we can't do anything for it |
|
1700 iEvents.Remove( 0 ); |
|
1701 sent++; |
|
1702 } |
|
1703 |
|
1704 iEvents.Compress(); |
|
1705 |
|
1706 if ( currentEventType & ENotifyAdd ) |
|
1707 { |
|
1708 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemInserted, idArray, iEvents.Count() ); |
|
1709 } |
|
1710 else if ( currentEventType & ENotifyModify ) |
|
1711 { |
|
1712 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemModified, idArray, iEvents.Count() ); |
|
1713 } |
|
1714 else if ( currentEventType & ENotifyRemove ) |
|
1715 { |
|
1716 iMdsDbObserver->HandleMyVideosDbEvent( EMPXItemDeleted, idArray, iEvents.Count() ); |
|
1717 } |
|
1718 |
|
1719 CleanupStack::PopAndDestroy( &idArray ); // <-1 |
|
1720 |
|
1721 return iEvents.Count(); |
1631 } |
1722 } |
1632 |
1723 |
1633 // --------------------------------------------------------------------------- |
1724 // --------------------------------------------------------------------------- |
1634 // CVcxMyVideosMdsDb::SetCreationAndModifiedDatesL |
1725 // CVcxMyVideosMdsDb::SetCreationAndModifiedDatesL |
1635 // --------------------------------------------------------------------------- |
1726 // --------------------------------------------------------------------------- |