uiservicetab/vimpstcmdprocess/src/cvimpstcmdunblockcontact.cpp
changeset 0 5e5d6b214f4f
child 9 9fdee5e1da30
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     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 #include "vimpstdebugprint.h" 
       
    24 
       
    25 #include <e32def.h>
       
    26 #include "mvimpstengine.h"
       
    27 #include "cvimpststoragemanagerfactory.h"
       
    28 #include "mvimpststorageserviceview.h"
       
    29 
       
    30 #include "mvimpstenginesubservice.h"
       
    31 #include "mvimpstenginepresencesubservice.h"
       
    32 #include "tvimpstconsts.h"
       
    33 // --------------------------------------------------------------------------
       
    34 // CVIMPSTCmdUnBlockContact::CVIMPSTCmdDeleteContact
       
    35 // --------------------------------------------------------------------------
       
    36 //
       
    37 CVIMPSTCmdUnBlockContact::CVIMPSTCmdUnBlockContact( 
       
    38         const TInt aCommandId ,  const TDesC& aContactId,
       
    39         MVIMPSTEngine& aEngine) :            
       
    40             iCommandId( aCommandId ),
       
    41             iContactId( aContactId ),
       
    42             iEngine(aEngine)
       
    43     {
       
    44     }
       
    45 
       
    46 // --------------------------------------------------------------------------
       
    47 // CVIMPSTCmdUnBlockContact::~CVIMPSTCmdUnBlockContact
       
    48 // --------------------------------------------------------------------------
       
    49 //
       
    50 CVIMPSTCmdUnBlockContact::~CVIMPSTCmdUnBlockContact()
       
    51     {    
       
    52     
       
    53     }
       
    54 
       
    55 // --------------------------------------------------------------------------
       
    56 // CVIMPSTCmdUnBlockContact::NewL
       
    57 // --------------------------------------------------------------------------
       
    58 //
       
    59 CVIMPSTCmdUnBlockContact* CVIMPSTCmdUnBlockContact::NewL( 
       
    60         const TInt aCommandId, const TDesC& aContactId,
       
    61         MVIMPSTEngine& aEngine)
       
    62     {
       
    63     CVIMPSTCmdUnBlockContact* self = new (ELeave ) CVIMPSTCmdUnBlockContact( aCommandId ,aContactId, aEngine);
       
    64     self->ConstructL(); //use contsurctL if necessary
       
    65     return self;
       
    66     }
       
    67 // --------------------------------------------------------------------------
       
    68 // CVIMPSTCmdUnBlockContact::ConstructL
       
    69 // --------------------------------------------------------------------------
       
    70 //
       
    71 void CVIMPSTCmdUnBlockContact::ConstructL()
       
    72     {    
       
    73     iError = KErrNotFound;
       
    74     }
       
    75 
       
    76 // --------------------------------------------------------------------------
       
    77 // CVIMPSTCmdUnBlockContact::ExecuteLD
       
    78 // --------------------------------------------------------------------------
       
    79 //
       
    80 void CVIMPSTCmdUnBlockContact::ExecuteLD()
       
    81     {
       
    82     CHAT_DP_FUNC_ENTER("CVIMPSTCmdUnBlockContact::ExecuteLD");
       
    83     //push to the cleanupstack
       
    84     CleanupStack::PushL( this );       
       
    85     if(iContactId.Length())
       
    86         {
       
    87         //Get Presence SubService           
       
    88         MVIMPSTEngineSubService* subService =          
       
    89         (iEngine.SubService(TVIMPSTEnums::EPresence));
       
    90         if (subService && iEngine.IsBlockSupportedL())
       
    91             {
       
    92             MVIMPSTEnginePresenceSubService& presence = 
       
    93             MVIMPSTEnginePresenceSubService::Cast (*subService);
       
    94             HBufC* userId = HBufC::NewLC(KPropertyMaxLength); //  2 onto cleanup stack
       
    95             TPtr userIdPtr = userId->Des();
       
    96             userIdPtr = iContactId;
       
    97           
       
    98             CHAT_DP( D_CHAT_LIT(" -> userId: %s" ), &userIdPtr);
       
    99             iError = presence.RemoveFromBlockListL(*userId);
       
   100             CHAT_DP( D_CHAT_LIT(" -> iError: %d" ), iError);
       
   101             CleanupStack::PopAndDestroy(userId);//2
       
   102           
       
   103             }
       
   104         }
       
   105 
       
   106     CHAT_DP_FUNC_ENTER("CVIMPSTCmdUnBlockContact:: CommandFinished");
       
   107 
       
   108     if(iObserver)
       
   109         {
       
   110         iObserver->CommandFinishedL(*this);
       
   111         }
       
   112     CHAT_DP_FUNC_ENTER("CVIMPSTCmdUnBlockContact:: CommandFinished"); 
       
   113     CleanupStack::PopAndDestroy();  
       
   114     CHAT_DP_FUNC_DONE("CVIMPSTCmdUnBlockContact::ExecuteLD"); 
       
   115     }
       
   116 
       
   117 
       
   118 // --------------------------------------------------------------------------
       
   119 // CVIMPSTCmdUnBlockContact::AddObserver
       
   120 // --------------------------------------------------------------------------
       
   121 //
       
   122 void CVIMPSTCmdUnBlockContact::AddObserver( MVIMPSTCmdObserver& aObserver )
       
   123     {
       
   124     // store the observer to notify the command completion
       
   125     iObserver = &aObserver;
       
   126     }
       
   127 
       
   128 
       
   129 // --------------------------------------------------------------------------
       
   130 // CVIMPSTCmdUnBlockContact::CommandId
       
   131 // --------------------------------------------------------------------------
       
   132 //
       
   133 TInt CVIMPSTCmdUnBlockContact::CommandId() const
       
   134 	{
       
   135 	return iCommandId;	
       
   136 	}
       
   137 
       
   138 // --------------------------------------------------------------------------
       
   139 // CVIMPSTCmdUnBlockContact::Result
       
   140 // --------------------------------------------------------------------------
       
   141 //
       
   142 TInt CVIMPSTCmdUnBlockContact::Result() const
       
   143 	{
       
   144 	//return valid data regd the command operation
       
   145 	return iError;
       
   146 	}
       
   147 
       
   148 // End of File