uiservicetab/vimpstcmdprocess/src/cvimpstcmdchangeownstatus.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     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:  command process for change status
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cvimpstcmdchangeownstatus.h"
       
    21 #include "mvimpstenginepresencesubservice.h"
       
    22 
       
    23 #include "vimpstcmd.hrh"
       
    24 #include "mvimpstcmdobserver.h"
       
    25 #include "vimpstdebugprint.h" 
       
    26 
       
    27 #include <e32def.h>
       
    28 #include "mvimpstengine.h"
       
    29 #include "mvimpstenginesubservice.h"
       
    30 
       
    31 // Constants
       
    32 
       
    33 // --------------------------------------------------------------------------
       
    34 // CVIMPSTCmdChangeOwnStatus::CVIMPSTCmdChangeOwnStatus
       
    35 // --------------------------------------------------------------------------
       
    36 //
       
    37 CVIMPSTCmdChangeOwnStatus::CVIMPSTCmdChangeOwnStatus( 
       
    38         const TInt aCommandId ,TStatusAndStatusText aStatus,
       
    39         MVIMPSTEngine& aEngine) :            
       
    40             iCommandId( aCommandId ),
       
    41             iStatus(aStatus.iStatus),
       
    42             iEngine(aEngine)
       
    43     {
       
    44     iStatusText.Copy(aStatus.iStatusText);
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // CVIMPSTCmdChangeOwnStatus::~CVIMPSTCmdChangeOwnStatus
       
    49 // --------------------------------------------------------------------------
       
    50 //
       
    51 CVIMPSTCmdChangeOwnStatus::~CVIMPSTCmdChangeOwnStatus()
       
    52     {    
       
    53     
       
    54     }
       
    55 
       
    56 // --------------------------------------------------------------------------
       
    57 // CVIMPSTCmdChangeOwnStatus::NewL
       
    58 // --------------------------------------------------------------------------
       
    59 //
       
    60 CVIMPSTCmdChangeOwnStatus* CVIMPSTCmdChangeOwnStatus::NewL( 
       
    61         const TInt aCommandId,TStatusAndStatusText aStatus,
       
    62         MVIMPSTEngine& aEngine)
       
    63     {
       
    64     CVIMPSTCmdChangeOwnStatus* self = new (ELeave ) CVIMPSTCmdChangeOwnStatus( aCommandId ,aStatus, aEngine);
       
    65     self->ConstructL(); //use contsurctL if necessary
       
    66     return self;
       
    67     }
       
    68 // --------------------------------------------------------------------------
       
    69 // CVIMPSTCmdChangeOwnStatus::ConstructL
       
    70 // --------------------------------------------------------------------------
       
    71 //
       
    72 void CVIMPSTCmdChangeOwnStatus::ConstructL()
       
    73     {    
       
    74     iError = KErrNone;
       
    75     }
       
    76 
       
    77 // --------------------------------------------------------------------------
       
    78 // CVIMPSTCmdChangeOwnStatus::ExecuteLD
       
    79 // --------------------------------------------------------------------------
       
    80 //
       
    81 void CVIMPSTCmdChangeOwnStatus::ExecuteLD()
       
    82     {
       
    83     CHAT_DP_FUNC_ENTER("CVIMPSTCmdChangeOwnStatus::ExecuteLD");
       
    84     //push to the cleanupstack
       
    85     CleanupStack::PushL( this );   
       
    86 	
       
    87 	//Get Presence SubService  			
       
    88    	MVIMPSTEngineSubService* subService =    	   
       
    89    	   			(iEngine.SubService(TVIMPSTEnums::EPresence));
       
    90     
       
    91     if(subService)
       
    92         {
       
    93         MVIMPSTEnginePresenceSubService& presence = 
       
    94         		MVIMPSTEnginePresenceSubService::Cast (*subService);
       
    95                         
       
    96    	    if ( iStatus == TVIMPSTEnums::EInvisible)
       
    97    	        {
       
    98 			// Status set to Appear Offline
       
    99    	        iError = presence.PublishOwnPresenceL(iStatus, KNullDesC);
       
   100    	        }
       
   101    	    else
       
   102    	        {
       
   103    	        iError = presence.PublishOwnPresenceL(iStatus, iStatusText);
       
   104    	        }
       
   105    	    }       
       
   106    	
       
   107     if(iObserver)
       
   108         {
       
   109         iObserver->CommandFinishedL(*this);
       
   110         }
       
   111         
       
   112 	
       
   113     
       
   114 	CHAT_DP_FUNC_ENTER("CVIMPSTCmdChangeOwnStatus:: CommandFinished");	
       
   115 	CleanupStack::PopAndDestroy();	
       
   116 	CHAT_DP_FUNC_DONE("CVIMPSTCmdChangeOwnStatus::ExecuteLD");	
       
   117     }
       
   118 
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CVIMPSTCmdChangeOwnStatus::AddObserver
       
   122 // --------------------------------------------------------------------------
       
   123 //
       
   124 void CVIMPSTCmdChangeOwnStatus::AddObserver( MVIMPSTCmdObserver& aObserver )
       
   125     {
       
   126     // store the observer to notify the command completion
       
   127     iObserver = &aObserver;
       
   128     }
       
   129 
       
   130 
       
   131 // --------------------------------------------------------------------------
       
   132 // CVIMPSTCmdChangeOwnStatus::CommandId
       
   133 // --------------------------------------------------------------------------
       
   134 //
       
   135 TInt CVIMPSTCmdChangeOwnStatus::CommandId() const
       
   136 	{
       
   137 	return iCommandId;	
       
   138 	}
       
   139 
       
   140 // --------------------------------------------------------------------------
       
   141 // CVIMPSTCmdChangeOwnStatus::Result
       
   142 // --------------------------------------------------------------------------
       
   143 //
       
   144 TInt CVIMPSTCmdChangeOwnStatus::Result() const
       
   145 	{
       
   146 	//return valid data regd the command operation
       
   147 	return iError;
       
   148 	}
       
   149 
       
   150 // End of File