diff -r 2b7283837edb -r 3104fc151679 uiservicetab/vimpstcmdprocess/src/cvimpstcmdaddcontact.cpp --- a/uiservicetab/vimpstcmdprocess/src/cvimpstcmdaddcontact.cpp Thu Aug 19 09:41:53 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,215 +0,0 @@ -/* -* Copyright (c) 2008 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: VIMPST command for add contact -* -*/ - - -// INCLUDE FILES -#include "cvimpstcmdaddcontact.h" - -#include "vimpstcmd.hrh" -#include "mvimpstcmdobserver.h" - - -#include -#include "mvimpstengine.h" -#include "mvimpstenginecontactmgmtextention.h" -#include "mvimpstengineextentionfeatures.h" -#include -#include -#include -#include - -#include "cvimpststoragemanagerfactory.h" -#include "mvimpststorageserviceview.h" -#include "mvimpststoragecontact.h" -#include "tvimpstenums.h" -#include "tvimpstconsts.h" -#include "mvimpstenginesubservice.h" -#include "mvimpstenginepresencesubservice.h" - -#include "uiservicetabtracer.h" - -// Constants -_LIT( KListNameAllBuddy ,"buddylist" ); - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::CVIMPSTCmdAddContact -// -------------------------------------------------------------------------- -// -CVIMPSTCmdAddContact::CVIMPSTCmdAddContact( - const TInt aCommandId ,const TDesC& aContactId, - MVIMPSTEngine& aEngine) : - iCommandId( aCommandId ), - iContactId( aContactId ), - iEngine(aEngine) - { - TRACER_AUTO; - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::~CVIMPSTCmdAddContact -// -------------------------------------------------------------------------- -// -CVIMPSTCmdAddContact::~CVIMPSTCmdAddContact() - { - TRACER_AUTO; - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::NewL -// -------------------------------------------------------------------------- -// -CVIMPSTCmdAddContact* CVIMPSTCmdAddContact::NewL( - const TInt aCommandId,const TDesC& aContactId, - MVIMPSTEngine& aEngine) - { - TRACER_AUTO; - CVIMPSTCmdAddContact* self = new (ELeave ) CVIMPSTCmdAddContact( aCommandId ,aContactId, aEngine); - self->ConstructL(); //use contsurctL if necessary - return self; - } -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::ConstructL -// -------------------------------------------------------------------------- -// -void CVIMPSTCmdAddContact::ConstructL() - { - TRACER_AUTO; - iError = KErrNone; - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::ExecuteLD -// -------------------------------------------------------------------------- -// -void CVIMPSTCmdAddContact::ExecuteLD() - { - - TRACER_AUTO; - //push to the cleanupstack - CleanupStack::PushL( this ); - MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iEngine.ServiceId()) ; - if(storage ) - { - if( !IsContactBlocked(iContactId) ) - { - MVIMPSTStorageContact* alreadyExist = storage->FindContactByUserId( iContactId ); - if( !alreadyExist ) - { - iError = KErrNone; - MVIMPSTEngineExtentionFeatures* feature = iEngine.ExtentionFeatures(TVIMPSTEnums::EContactManagement); - if (feature) - { - MVIMPSTEngineContactMgmtExtention& contactMgr = - MVIMPSTEngineContactMgmtExtention::Cast (*feature); - // if there is a scenario when the user enters only the firstname , then userid is null. - //In this case don't send it to the server, Add the contact to the servicetab and - //presence will not be visible. - // check if contact is in the blocked list. - // iError already exist - if( iContactId.Length() ) - { - iError = contactMgr.AddServerContactL(KListNameAllBuddy,iContactId, KNullDesC() ); - }//End if(iContactId) - } //End if(feature) - if(KErrNone == iError) - { - storage->CreateNewContactL( iContactId ); - } - }//End if(alreadyExist) - else - { - iError = EErrExistInContactList; - } - } - else - { - iError = EErrExistInBlockList; - } - }//End if(storage) - - - - if(iObserver) - { - iObserver->CommandFinishedL(*this); - } - - CleanupStack::PopAndDestroy(); - - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::IsContactBlocked -// -------------------------------------------------------------------------- -TBool CVIMPSTCmdAddContact::IsContactBlocked(const TDesC& aUserId) - { - TRACER_AUTO; - TRACE("userId: %S", &aUserId); - MVIMPSTEngineSubService* subService = - (iEngine.SubService(TVIMPSTEnums::EPresence)); - if(subService) - { - MVIMPSTEnginePresenceSubService& presence = - MVIMPSTEnginePresenceSubService::Cast (*subService); - - RPointerArray *blockedlist = presence .GetBlockedList(); - - if(blockedlist) - { - for(TInt i=0; iCount(); ++i) - { - if(0 == aUserId.CompareC((*blockedlist)[i]->Des())) - { - return ETrue; - } - } - } - } - return EFalse; - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::AddObserver -// -------------------------------------------------------------------------- -// -void CVIMPSTCmdAddContact::AddObserver( MVIMPSTCmdObserver& aObserver ) - { - // store the observer to notify the command completion - iObserver = &aObserver; - } - - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::CommandId -// -------------------------------------------------------------------------- -// -TInt CVIMPSTCmdAddContact::CommandId() const - { - return iCommandId; - } - -// -------------------------------------------------------------------------- -// CVIMPSTCmdAddContact::Result -// -------------------------------------------------------------------------- -// -TInt CVIMPSTCmdAddContact::Result() const - { - //return valid data regd the command operation - return iError; - } - -// End of File