eventsui/eventsengine/src/evtaction.cpp
branchRCL_3
changeset 17 1fc85118c3ae
parent 16 8173571d354e
child 18 870918037e16
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
     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:  Class for the Location Events Action.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includesc
       
    20 #include <s32mem.h>
       
    21 
       
    22 // User Includes
       
    23 #include "evtaction.h"
       
    24 #include "evtdebug.h"
       
    25 
       
    26 // ================ Member funtions for CEvtAction class ======================
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CEvtAction::CEvtAction
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CEvtAction::CEvtAction():iId(0),
       
    33 	iType( EAlarm )
       
    34     {    
       
    35     }
       
    36     
       
    37 // ---------------------------------------------------------------------------
       
    38 // CEvtAction::~CEvtAction
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CEvtAction::~CEvtAction()
       
    42     {
       
    43     delete iActionString;
       
    44     
       
    45     } 
       
    46     
       
    47 // ---------------------------------------------------------------------------
       
    48 // CEvtAction::NewL
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CEvtAction* CEvtAction::NewL()
       
    52     {
       
    53 	CEvtAction* self = NewLC( );
       
    54 	CleanupStack::Pop( self );
       
    55 	return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CEvtAction::NewLC
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CEvtAction* CEvtAction::NewLC()
       
    63     {
       
    64 	CEvtAction* self = new ( ELeave )CEvtAction( );
       
    65 	CleanupStack::PushL( self );
       
    66 	self->ConstructL( );
       
    67 	return self;
       
    68     } 
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CEvtAction::ConstructL
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C void CEvtAction::ConstructL()
       
    75     {
       
    76     // Allocate the Null string by default
       
    77     iActionString = KNullDesC().AllocL();
       
    78     } 
       
    79     
       
    80 // ---------------------------------------------------------------------------
       
    81 // CEvtAction::Id
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 TInt64 CEvtAction::Id() const
       
    85     {
       
    86     return iId;
       
    87     } 
       
    88     
       
    89 // ---------------------------------------------------------------------------
       
    90 // CEvtAction::SetId
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CEvtAction::SetId( const TInt64 aId )
       
    94     {
       
    95     iId = aId;
       
    96     } 
       
    97     
       
    98 // ---------------------------------------------------------------------------
       
    99 // CEvtAction::EvtId
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 TEvtEventId CEvtAction::EvtId() const
       
   103     {
       
   104     return iEvtId;
       
   105     } 
       
   106     
       
   107 // ---------------------------------------------------------------------------
       
   108 // CEvtAction::SetEvtId
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CEvtAction::SetEvtId( const TEvtEventId aEvtId )
       
   112     {
       
   113     iEvtId = aEvtId;
       
   114     } 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CEvtAction::Action
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 TPtrC CEvtAction::Action() const
       
   121     {
       
   122     return iActionString->Des();
       
   123     } 
       
   124     
       
   125 // ---------------------------------------------------------------------------
       
   126 // CEvtAction::SetActionL
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void CEvtAction::SetActionL( const TDesC& aAction )
       
   130     {
       
   131     delete iActionString;
       
   132     iActionString = NULL;
       
   133     iActionString = aAction.AllocL();
       
   134     
       
   135     // return, if the String length is 0.
       
   136     // Since we can not retrieve type of Action
       
   137     if( 0 == iActionString->Length() )
       
   138         return;
       
   139     
       
   140 	// Retrieve action type
       
   141     CBufFlat* lengthBuf = CBufFlat::NewL( iActionString->Length() );
       
   142     CleanupStack::PushL( lengthBuf );
       
   143     lengthBuf->InsertL( 0, iActionString->Ptr(), iActionString->Length() );
       
   144     
       
   145     // Create a stream to buffer
       
   146     RBufReadStream writeStream( *lengthBuf, 0 );
       
   147     CleanupClosePushL( writeStream ); 
       
   148     
       
   149     // Extract action type info
       
   150     iType = static_cast<TEvtActionType>( writeStream.ReadInt8L() );
       
   151     
       
   152     CleanupStack::PopAndDestroy(); // writeStream
       
   153     CleanupStack::PopAndDestroy( lengthBuf ); // lengthBuf
       
   154       
       
   155     } 
       
   156     
       
   157 // ---------------------------------------------------------------------------
       
   158 // CEvtAction::Type
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 EXPORT_C TEvtActionType CEvtAction::Type() const
       
   162     {
       
   163     return iType;
       
   164     } 
       
   165     
       
   166 // ---------------------------------------------------------------------------
       
   167 // CEvtAction::SetType
       
   168 // ---------------------------------------------------------------------------
       
   169 //
       
   170 void CEvtAction::SetType( const TEvtActionType aType )
       
   171     {
       
   172     iType = aType;
       
   173     } 
       
   174     
       
   175 // End of File