serviceproviders/sapi_mediamanagement/src/mgservicethumbnailobserver.cpp
changeset 19 989d2f495d90
child 33 50974a8b132e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/serviceproviders/sapi_mediamanagement/src/mgservicethumbnailobserver.cpp	Fri Jul 03 15:51:24 2009 +0100
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "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:  This class is the observer of thumbanil generation
+*  *
+*/
+
+#include<Liwcommon.h>
+#include "serviceerrno.h"
+#include "mgservicethumbnailobserver.h"
+#include"mginterface.h"
+_LIT8(KResponse,"ReturnValue");
+_LIT8(KErrorCode,"ErrorCode");
+
+
+// -----------------------------------------------------------------------------
+// CServiceThumbanilObserver::NewL
+// Returns the instance of CServiceThumbanilObserver.
+// -----------------------------------------------------------------------------
+CServiceThumbnailObserver* CServiceThumbnailObserver::NewL( MLiwNotifyCallback* aCallBack )
+    {
+    CServiceThumbnailObserver* self = new( ELeave ) CServiceThumbnailObserver(aCallBack);
+    return self;
+    }
+// -----------------------------------------------------------------------------
+// CServiceThumbanilObserver::~CServiceThumbnailObserver
+// Destructor
+// -----------------------------------------------------------------------------
+CServiceThumbnailObserver::~CServiceThumbnailObserver()
+    {
+    iCallBack = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CServiceThumbnailObserver::ThumbnailReady
+//  This method is called when thumbnail gets generated
+// ---------------------------------------------------------------------------
+//
+void CServiceThumbnailObserver::ThumbnailReady(TInt aError, TDesC& aThumbnailURL,TInt32 aTransactionID)
+
+    {
+    CLiwGenericParamList* input = NULL;
+    CLiwGenericParamList* output = CLiwGenericParamList::NewLC();
+    
+    output->Reset();
+      
+    TInt sapiErr = SErrNone;
+        if (aError)
+            {
+            sapiErr = CMgInterface::SapiError( aError );
+            }
+
+    
+    
+        output->AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)sapiErr)));    
+     
+        output->AppendL( TLiwGenericParam ( KResponse, TLiwVariant ( aThumbnailURL ) ) );
+        
+        TRAP_IGNORE(iCallBack->HandleNotifyL ( aTransactionID, KLiwEventCompleted, *output,*input ));
+        
+ 
+     CleanupStack::PopAndDestroy( output );
+     delete this;
+    }
+
+// ---------------------------------------------------------------------------
+// CServiceThumbnailObserver::ThumbnailRequestCancel
+// Callback method gets called when thumbnail request is canceled
+// ---------------------------------------------------------------------------
+//
+
+void CServiceThumbnailObserver::ThumbnailRequestCancel(TInt aError,TInt32 aTransactionID)
+    {
+    CLiwGenericParamList* input = NULL;
+     CLiwGenericParamList* output = CLiwGenericParamList::NewLC();
+     
+     output->Reset();
+             
+         output->AppendL(TLiwGenericParam(KErrorCode,TLiwVariant((TInt32)SErrNone)));    
+         output->AppendL( TLiwGenericParam ( KResponse, TLiwVariant ( aError ) ) );
+         
+         TRAP_IGNORE(iCallBack->HandleNotifyL ( aTransactionID, KLiwEventCanceled, *output,*input ));
+         
+  
+      CleanupStack::PopAndDestroy( output );
+      delete this;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CServiceThumbnailObserver::CServiceThumbnailObserver
+//  Constructor
+// ---------------------------------------------------------------------------
+//
+CServiceThumbnailObserver::CServiceThumbnailObserver( MLiwNotifyCallback* aCallBack )
+    {
+     iCallBack = aCallBack;
+     
+    }