mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 16 Apr 2010 15:51:48 +0300
changeset 18 1b39655331a3
parent 17 aabe5387f5ce
child 31 a26669f87b46
permissions -rw-r--r--
Revision: 201005 Kit: 201015

// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

/**
 @file
 @internalTechnology
*/

#include <mtp/mtpprotocolconstants.h>

#include "cmtpimagedp.h"
#include "mtpimagedpconst.h"
#include "cmtpimagedpnewpicturesnotifier.h"

CMTPImageDpNewPicturesNotifier* CMTPImageDpNewPicturesNotifier::NewL()
    {
    CMTPImageDpNewPicturesNotifier* self = new (ELeave) CMTPImageDpNewPicturesNotifier();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }
    
/**
Destructor.
*/
CMTPImageDpNewPicturesNotifier::~CMTPImageDpNewPicturesNotifier()
    {
    Cancel();
    }

void CMTPImageDpNewPicturesNotifier::SetNewPictures(TInt aValue)
    {
    iNewPictures = aValue;
    }

void CMTPImageDpNewPicturesNotifier::IncreaseCount(TInt aValue)
    {
    Cancel();//cancel the latest timer if we have
    iNewPictures += aValue;       
    RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
    }

void CMTPImageDpNewPicturesNotifier::DecreaseCount(TInt aValue)
    {
    iNewPictures -= aValue;
    
    Cancel();//cancel the latest timer if we have
    if (iNewPictures > 0)
        {
        After(KImageDpNotifyDelay);
        }
    else
        {
        /**
         * if the new pictures is equal to zero, then directly set RProperty' value
         */
        iNewPictures = 0;
        RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
        }    
    }

void CMTPImageDpNewPicturesNotifier::RunL()
    {
    RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, iNewPictures);
    }
    
/** 
Constructor
*/
CMTPImageDpNewPicturesNotifier::CMTPImageDpNewPicturesNotifier() : 
    CTimer(EPriorityNormal)    
    {
    
    }    

/**
Second phase constructor.
*/    
void CMTPImageDpNewPicturesNotifier::ConstructL()
    {
    CTimer::ConstructL();
    CActiveScheduler::Add(this);
    }