uiservicetab/vimpstengine/src/cvimpstenginecvlistener.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
--- a/uiservicetab/vimpstengine/src/cvimpstenginecvlistener.cpp	Tue Feb 02 10:12:18 2010 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
-* Copyright (c) 2008-2009 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:  active object class for interacting with conversation view
-*
-*/
-
-// INCLUDE FILES
-
-#include "cvimpstenginecvlistener.h"
-#include "cvimpststoragemanagerfactory.h"
-#include "mvimpststorageserviceview.h"
-#include "mvimpststoragecontact.h"
-#include "cvimpstengineservicetablefetcher.h"
-#include "vimpstdebugtrace.h"
-
-//system includes
-#include <e32base.h>
-#include <MVPbkContactLink.h>
-
-// ================= MEMBER FUNCTIONS =======================
-
-// --------------------------------------------------------------------------
-// CVIMPSTEngineCVListener::CVIMPSTEngineCVListener
-// --------------------------------------------------------------------------
-//
-CVIMPSTEngineCVListener::CVIMPSTEngineCVListener(
-    CVIMPSTEngineServiceTableFetcher& aServiceTableFetcher ): 
-    CActive( CActive::EPriorityStandard ),
-    iServiceTableFetcher( aServiceTableFetcher )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-
-// --------------------------------------------------------------------------
-// CVIMPSTEngineCVListener::ConstructL
-// --------------------------------------------------------------------------
-//
-void CVIMPSTEngineCVListener::ConstructL()
-    {
-    TRACE( T_LIT("CVIMPSTEngineCVListener::ConstructL() start"));
-    // subscribing for the property published by conversation view.
-    // attach the properties.
-    User::LeaveIfError( iProperty.Attach(KConvViewUID,KXspIdServiceIDKey  ) );
-    //start listening property published by CV (to get Contact link and Display name.).
-    iProperty.Subscribe( iStatus );
-    SetActive();
-    TRACE( T_LIT("CVIMPSTEngineCVListener::ConstructL() end"));
-    }
-
-// --------------------------------------------------------------------------
-// CVIMPSTEngineCVListener::NewL
-// --------------------------------------------------------------------------
-//
-CVIMPSTEngineCVListener* CVIMPSTEngineCVListener::NewL(
-        CVIMPSTEngineServiceTableFetcher& aServiceTableFetcher )
-    {
-    CVIMPSTEngineCVListener* self = new(ELeave) CVIMPSTEngineCVListener( aServiceTableFetcher );
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;
-    }
-// ---------------------------------------------------------
-// CVIMPSTEngineCVListener::~CVIMPSTEngineCVListener()
-// C++ Destructor 
-// ---------------------------------------------------------
-//
-CVIMPSTEngineCVListener::~CVIMPSTEngineCVListener()
-    {
-    Cancel();
-    iProperty.Close();
-    }
-// ---------------------------------------------------------
-// CVIMPSTEngineCVListener::RunL()
-// ---------------------------------------------------------
-//
-void CVIMPSTEngineCVListener::RunL()
-    {
-    TRACE( T_LIT("CVIMPSTEngineCVListener::RunL() start"));
-    // resubscribe before processing new value to prevent missing updates
-    //TBuf <KMaxSerIdXspIdLen> serId_usrId;
-    HBufC16* serId_usrId = HBufC16::NewLC(KMaxSerIdXspIdLen);
-    TPtr serId_usrIdPtr(serId_usrId->Des());
-    
-    iProperty.Get(KConvViewUID,KXspIdServiceIDKey,serId_usrIdPtr);
-    // parse the service id and userid form the buf and get the 
-    // contactlink and first name and publish it.
-    TInt posOfDelimiter  = serId_usrId->Find(KDelimiter);
-    if(KErrNotFound != posOfDelimiter )
-        {
-        TInt serviceId = KErrNotFound;
-        TBuf<KMaxServiceIdLength> servIdBuf;
-        TPtrC ptr(serId_usrId->Left(posOfDelimiter));
-        servIdBuf = ptr;
-        TLex16 lex(servIdBuf);
-        lex.Val(serviceId);
-       
-        // Check if this service id belongs to us. If there is customized 
-        // service with own service tab, we MUST not handle this callback.
-        RArray<TUint32> supportedServices;
-        CleanupClosePushL( supportedServices );
-        iServiceTableFetcher.GetMasterServiceIdsL( supportedServices );
-        TInt ourService = supportedServices.Find( serviceId );
-        if( KErrNotFound != ourService )
-            {
-            MVIMPSTStorageServiceView* storage =  CVIMPSTStorageManagerFactory::ContactListInterfaceL((TUint32)serviceId);
-            __ASSERT_ALWAYS( storage, User::Leave( KErrGeneral ));
-            TPtrC useridPtr = serId_usrId->Right(serId_usrId->Length() - (posOfDelimiter+ 1) );
-            MVIMPSTStorageContact* contact = storage->FindContactByUserId(useridPtr);
-            if(contact)
-                {
-                TBuf8<KMaxPackedContactLinkLength> link;
-                link = contact->ContactLink()->PackLC()->Des();
-     
-                CleanupStack::PopAndDestroy(); //pop and destroy the hbufc8*
-                               
-                TInt length = KMaxServiceIdLength + useridPtr.Length() + link.Length()
-                               + contact->Name().Length() + (KDelimiter().Length() * 3);
-                TPtrC fullname = contact->Name();
-                HBufC* dispName = NULL;
-                posOfDelimiter = fullname.Find(KDelimiter);
-                TInt displayIndex = fullname.Length() - (posOfDelimiter+ 1);
-                if(KErrNotFound != posOfDelimiter && (displayIndex > 0))
-                    {
-                    dispName = fullname.Right( displayIndex  ).AllocLC() ;
-                    }
-                else
-                    {
-                    dispName= fullname.AllocLC();
-                    }
-                HBufC16* contactLink = HBufC16::NewLC(link.Length());
-                TPtr16 ptr = contactLink->Des();
-                ptr.Copy(link);
-                HBufC* userDetails = HBufC::NewLC(length);
-                TPtr userDetailsPtr = userDetails->Des();
-         
-                userDetailsPtr.Zero();
-                userDetailsPtr.AppendNum(serviceId);
-                userDetailsPtr.Append(KDelimiter());
-                userDetailsPtr.Append(useridPtr);
-                userDetailsPtr.Append(KDelimiter());
-                userDetailsPtr.Append(*dispName);
-                userDetailsPtr.Append(KDelimiter());
-                userDetailsPtr.Append( *contactLink );
-                
-                TRACE( T_LIT("CVIMPSTEngineCVListener::RunL publishing = %S"),&(*userDetails));        
-                
-                iProperty.Set(KConvViewUID,KContactLinkDisplayNameKey,*userDetails);
-                CleanupStack::PopAndDestroy(3);//userDetails,contactLink,dispName
-              
-                }
-            // contact not found
-            else
-                {
-                TRACE( T_LIT("CVIMPSTEngineCVListener::RunL publishing null display name"));        
-                iProperty.Set(KConvViewUID,KContactLinkDisplayNameKey,KNullDesC());
-                }
-            }
-        CleanupStack::PopAndDestroy( &supportedServices );
-        }
-    CleanupStack::PopAndDestroy( serId_usrId );
-    iProperty.Subscribe( iStatus );
-    SetActive();
-    TRACE( T_LIT("CVIMPSTEngineCVListener::RunL() end"));
-    }
-
-// ---------------------------------------------------------
-// CVIMPSTEngineCVListener::RunL()
-// ---------------------------------------------------------
-//
-void CVIMPSTEngineCVListener::DoCancel()
-    {    
-    TRACE( T_LIT("CVIMPSTEngineCVListener::DoCancel() start"));
-    iProperty.Cancel();
-    }
-  		     
-// ---------------------------------------------------------
-// CIMCVEngineStorageListener::StopListening()
-// ---------------------------------------------------------
-//
-TInt CVIMPSTEngineCVListener::RunError( TInt aError )
-    {
-    TRACE( T_LIT("CVIMPSTEngineCVListener::RunError() start"));
-    if ( KErrCancel != aError )
-        {
-        iProperty.Subscribe( iStatus );
-        SetActive();
-        }
-    return KErrNone;
-    }
-//  End of File  
-