uiservicetab/vimpstcmdprocess/src/cvimpstcmdunblockcontact.cpp
branchRCL_3
changeset 29 9a48e301e94b
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  execute command for unblocking contact
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "cvimpstcmdunblockcontact.h"
       
    20 
       
    21 #include "vimpstcmd.hrh"
       
    22 #include "mvimpstcmdobserver.h"
       
    23 
       
    24 #include "uiservicetabtracer.h"
       
    25 
       
    26 #include <e32def.h>
       
    27 #include "mvimpstengine.h"
       
    28 #include "cvimpststoragemanagerfactory.h"
       
    29 #include "mvimpststorageserviceview.h"
       
    30 
       
    31 #include "mvimpstenginesubservice.h"
       
    32 #include "mvimpstenginepresencesubservice.h"
       
    33 #include "tvimpstconsts.h"
       
    34 // --------------------------------------------------------------------------
       
    35 // CVIMPSTCmdUnBlockContact::CVIMPSTCmdDeleteContact
       
    36 // --------------------------------------------------------------------------
       
    37 //
       
    38 CVIMPSTCmdUnBlockContact::CVIMPSTCmdUnBlockContact( 
       
    39         const TInt aCommandId ,  const TDesC& aContactId,
       
    40         MVIMPSTEngine& aEngine) :            
       
    41             iCommandId( aCommandId ),
       
    42             iContactId( aContactId ),
       
    43             iEngine(aEngine)
       
    44     {
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // CVIMPSTCmdUnBlockContact::~CVIMPSTCmdUnBlockContact
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 CVIMPSTCmdUnBlockContact::~CVIMPSTCmdUnBlockContact()
       
    52     {    
       
    53     
       
    54     }
       
    55 
       
    56 // --------------------------------------------------------------------------
       
    57 // CVIMPSTCmdUnBlockContact::NewL
       
    58 // --------------------------------------------------------------------------
       
    59 //
       
    60 CVIMPSTCmdUnBlockContact* CVIMPSTCmdUnBlockContact::NewL( 
       
    61         const TInt aCommandId, const TDesC& aContactId,
       
    62         MVIMPSTEngine& aEngine)
       
    63     {
       
    64     CVIMPSTCmdUnBlockContact* self = new (ELeave ) CVIMPSTCmdUnBlockContact( aCommandId ,aContactId, aEngine);
       
    65     self->ConstructL(); //use contsurctL if necessary
       
    66     return self;
       
    67     }
       
    68 // --------------------------------------------------------------------------
       
    69 // CVIMPSTCmdUnBlockContact::ConstructL
       
    70 // --------------------------------------------------------------------------
       
    71 //
       
    72 void CVIMPSTCmdUnBlockContact::ConstructL()
       
    73     {    
       
    74     iError = KErrNotFound;
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------
       
    78 // CVIMPSTCmdUnBlockContact::ExecuteLD
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 void CVIMPSTCmdUnBlockContact::ExecuteLD()
       
    82     {
       
    83    
       
    84     TRACER_AUTO;
       
    85     //push to the cleanupstack
       
    86     CleanupStack::PushL( this );       
       
    87     if(iContactId.Length())
       
    88         {
       
    89         //Get Presence SubService           
       
    90         MVIMPSTEngineSubService* subService =          
       
    91         (iEngine.SubService(TVIMPSTEnums::EPresence));
       
    92         if (subService && iEngine.IsBlockSupportedL())
       
    93             {
       
    94             MVIMPSTEnginePresenceSubService& presence = 
       
    95             MVIMPSTEnginePresenceSubService::Cast (*subService);
       
    96             HBufC* userId = HBufC::NewLC(KPropertyMaxLength); //  2 onto cleanup stack
       
    97             TPtr userIdPtr = userId->Des();
       
    98             userIdPtr = iContactId;
       
    99             TRACE("userId: %s", &userIdPtr);            
       
   100             iError = presence.RemoveFromBlockListL(*userId);
       
   101             TRACE("iError: %d", iError);           
       
   102             CleanupStack::PopAndDestroy(userId);//2
       
   103           
       
   104             }
       
   105         }
       
   106    
       
   107 
       
   108     if(iObserver)
       
   109         {
       
   110         iObserver->CommandFinishedL(*this);
       
   111         }   
       
   112     CleanupStack::PopAndDestroy();  
       
   113   
       
   114     }
       
   115 
       
   116 
       
   117 // --------------------------------------------------------------------------
       
   118 // CVIMPSTCmdUnBlockContact::AddObserver
       
   119 // --------------------------------------------------------------------------
       
   120 //
       
   121 void CVIMPSTCmdUnBlockContact::AddObserver( MVIMPSTCmdObserver& aObserver )
       
   122     {
       
   123     // store the observer to notify the command completion
       
   124     iObserver = &aObserver;
       
   125     }
       
   126 
       
   127 
       
   128 // --------------------------------------------------------------------------
       
   129 // CVIMPSTCmdUnBlockContact::CommandId
       
   130 // --------------------------------------------------------------------------
       
   131 //
       
   132 TInt CVIMPSTCmdUnBlockContact::CommandId() const
       
   133 	{
       
   134 	return iCommandId;	
       
   135 	}
       
   136 
       
   137 // --------------------------------------------------------------------------
       
   138 // CVIMPSTCmdUnBlockContact::Result
       
   139 // --------------------------------------------------------------------------
       
   140 //
       
   141 TInt CVIMPSTCmdUnBlockContact::Result() const
       
   142 	{
       
   143 	//return valid data regd the command operation
       
   144 	return iError;
       
   145 	}
       
   146 
       
   147 // End of File