mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp
changeset 17 aabe5387f5ce
child 31 a26669f87b46
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mtpdataproviders/mtpimagedp/src/cmtpimagedpnewpicturesnotifier.cpp	Fri Mar 19 09:40:39 2010 +0200
@@ -0,0 +1,97 @@
+// 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);
+    }
+