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