mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp
changeset 17 aabe5387f5ce
child 31 a26669f87b46
equal deleted inserted replaced
0:d0791faffa3f 17:aabe5387f5ce
       
     1 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #include <mtp/mtpprotocolconstants.h>
       
    22 
       
    23 #include "cmtpimagedp.h"
       
    24 #include "mtpimagedpconst.h"
       
    25 #include "cmtpimagedpnewpicturesnotifier.h"
       
    26 
       
    27 CMTPImageDpNewPicturesNotifier* CMTPImageDpNewPicturesNotifier::NewL()
       
    28     {
       
    29     CMTPImageDpNewPicturesNotifier* self = new (ELeave) CMTPImageDpNewPicturesNotifier();
       
    30     CleanupStack::PushL(self);
       
    31     self->ConstructL();
       
    32     CleanupStack::Pop(self);
       
    33     return self;
       
    34     }
       
    35     
       
    36 /**
       
    37 Destructor.
       
    38 */
       
    39 CMTPImageDpNewPicturesNotifier::~CMTPImageDpNewPicturesNotifier()
       
    40     {
       
    41     Cancel();
       
    42     }
       
    43 
       
    44 void CMTPImageDpNewPicturesNotifier::SetNewPictures(TInt aValue)
       
    45     {
       
    46     iNewPictures = aValue;
       
    47     }
       
    48 
       
    49 void CMTPImageDpNewPicturesNotifier::IncreaseCount(TInt aValue)
       
    50     {
       
    51     Cancel();//cancel the latest timer if we have
       
    52     iNewPictures += aValue;       
       
    53     RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
       
    54     }
       
    55 
       
    56 void CMTPImageDpNewPicturesNotifier::DecreaseCount(TInt aValue)
       
    57     {
       
    58     iNewPictures -= aValue;
       
    59     
       
    60     Cancel();//cancel the latest timer if we have
       
    61     if (iNewPictures > 0)
       
    62         {
       
    63         After(KImageDpNotifyDelay);
       
    64         }
       
    65     else
       
    66         {
       
    67         /**
       
    68          * if the new pictures is equal to zero, then directly set RProperty' value
       
    69          */
       
    70         iNewPictures = 0;
       
    71         RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
       
    72         }    
       
    73     }
       
    74 
       
    75 void CMTPImageDpNewPicturesNotifier::RunL()
       
    76     {
       
    77     RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
       
    78     }
       
    79     
       
    80 /** 
       
    81 Constructor
       
    82 */
       
    83 CMTPImageDpNewPicturesNotifier::CMTPImageDpNewPicturesNotifier() : 
       
    84     CTimer(EPriorityNormal)    
       
    85     {
       
    86     
       
    87     }    
       
    88 
       
    89 /**
       
    90 Second phase constructor.
       
    91 */    
       
    92 void CMTPImageDpNewPicturesNotifier::ConstructL()
       
    93     {
       
    94     CTimer::ConstructL();
       
    95     CActiveScheduler::Add(this);
       
    96     }
       
    97