IMPSengine/utils/src/impsgroupprops.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:41:52 +0200
changeset 0 094583676ce7
permissions -rw-r--r--
Revision: 200949 Kit: 200951

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*     WV group properties.
*     WV CSP 1.1 recommends some properties and the classes here provide support
*     for them. Additionally is is possible to create and read extra properties
*     not mentioned in CSP 1.1.
*     Because of any of the predefined properties may be missing, we use
*     the value -1 to denote undefined value.
*
*     Notice that the mutators do not change the values immediately in a remote
*     service, but only after the properties have been assigned to the service
*     through SetGroupPropertiesL method in RImpsGroupClient interface.
*
*
*/


// INCLUDE FILES
#include    "ImpsGroupProps.h"


// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CImpsGroupProp::CImpsGroupProp
// ---------------------------------------------------------
//
CImpsGroupProp::CImpsGroupProp()
    {
    }

// ---------------------------------------------------------
// CImpsGroupProp::~CImpsGroupProp
// ---------------------------------------------------------
//
CImpsGroupProp::~CImpsGroupProp()
    {
    delete iKey;
    delete iValue; 
    iLink.Deque();   
    }

// ---------------------------------------------------------
// CImpsGroupProp::NewL
// ---------------------------------------------------------
//
CImpsGroupProp* CImpsGroupProp::NewL(
                const TDesC& aKey, 
                const TDesC& aValue )
    {
    CImpsGroupProp* self = new (ELeave) CImpsGroupProp;
    CleanupStack::PushL( self );
    self->ConstructL( aKey, aValue );
    CleanupStack::Pop();
    return self;
    }

// ---------------------------------------------------------
// CImpsGroupProp::Key
// ---------------------------------------------------------
//
TPtrC CImpsGroupProp::Key() const
    {
/*LDRA_NOANALYSIS*/
    return iKey ? TPtrC( *iKey ) : TPtrC();
/*LDRA_ANALYSIS*/
    }

// ---------------------------------------------------------
// CImpsGroupProp::Value
// ---------------------------------------------------------
//
TPtrC CImpsGroupProp::Value() const
    {
/*LDRA_NOANALYSIS*/
    return iValue ? TPtrC( *iValue ) : TPtrC();
/*LDRA_ANALYSIS*/
    }

// ---------------------------------------------------------
// CImpsGroupProp::ConstructL
// ---------------------------------------------------------
//
void CImpsGroupProp::ConstructL(
                const TDesC& aKey, 
                const TDesC& aValue )
    {
    HBufC* newAttrib = aKey.AllocL();
    iKey = newAttrib;
    newAttrib = aValue.AllocL();
    iValue = newAttrib;
    }

// ---------------------------------------------------------
// C++ default constructor can NOT contain any code, that
// might leave.
// ---------------------------------------------------------
//
CImpsGroupProps::CImpsGroupProps()
:   iReset( ETrue ),
    iPropertyList(_FOFF( CImpsGroupProp, iLink )),
    iIter( iPropertyList ),
    iPrivateMessages( EImpsPropUndef )
    {
    }

// ---------------------------------------------------------
// CImpsGroupProps::~CImpsGroupProps()
// ---------------------------------------------------------
//
CImpsGroupProps::~CImpsGroupProps()
    {
    // Delete all properties
    TDblQueIter<CImpsGroupProp> rIter( iPropertyList );

    rIter.SetToFirst();

    while ( rIter )
        {    
        CImpsGroupProp* pr = rIter;
        rIter++;
        delete pr;
        }  
    }

// ---------------------------------------------------------
// CImpsGroupProps::ConstructL
// ---------------------------------------------------------
//
void CImpsGroupProps::ConstructL()
    {
    }    

// ---------------------------------------------------------
// CImpsGroupProps::Count
// ---------------------------------------------------------
//
EXPORT_C TInt CImpsGroupProps::Count() 
    {
    // Count all properties
    TInt counter = 0;
    TDblQueIter<CImpsGroupProp> rIter( iPropertyList );
    rIter.SetToFirst();
    while ( rIter )
        {    
        rIter++;
        counter++;
        } 
    return counter;
    }
    
// ---------------------------------------------------------
// CImpsGroupProps::AddL
// ---------------------------------------------------------
//
EXPORT_C void CImpsGroupProps::AddL( const CImpsGroupProp& aProperty )
    {
    iReset =  EFalse;
    CImpsGroupProp* pr = CImpsGroupProp::NewL(
            aProperty.iKey->Des(), 
            aProperty.iValue->Des() );
    iPropertyList.AddLast( *pr );
    }

// ---------------------------------------------------------
// CImpsGroupProps::FirstL
// ---------------------------------------------------------
//
EXPORT_C const CImpsGroupProp& CImpsGroupProps::FirstL()
    {
    iReset = EFalse;
    iIter.SetToFirst();
    CImpsGroupProp* pr = iIter;
    if ( !pr )
        {
        User::Leave( KErrEof );
        }
    return *pr;
    }

// ---------------------------------------------------------
// CImpsGroupProps::NextL
// ---------------------------------------------------------
//
EXPORT_C const CImpsGroupProp& CImpsGroupProps::NextL()
    {
    if ( iReset )
        {
        User::Leave( KErrEof );
        }
    iIter++;
    CImpsGroupProp* pr = iIter;
    if ( !pr )
        {
        User::Leave( KErrEof );
        }
    return *pr;
    }

// ---------------------------------------------------------
// CImpsGroupProps::Reset
// ---------------------------------------------------------
//
void CImpsGroupProps::Reset()
    {
    iReset = ETrue;
    // Delete all properties
    TDblQueIter<CImpsGroupProp> rIter( iPropertyList );

    rIter.SetToFirst();

    while ( rIter )
        {    
        CImpsGroupProp* pr = rIter;
        rIter++;
        delete pr;
        } 

    iPrivateMessages = EImpsPropUndef;
    }

// ---------------------------------------------------------
// CImpsGroupProps::IsPrivateAllowed
// ---------------------------------------------------------
//
TImpsPropertyBool CImpsGroupProps::IsPrivateAllowed() const
    {
    return iPrivateMessages;
    }

// ---------------------------------------------------------
// CImpsGroupProps::IsPrivateAllowed
// ---------------------------------------------------------
//
void CImpsGroupProps::SetPrivateAllowed( TImpsPropertyBool aValue )
    {
    iPrivateMessages = aValue;
    }


/************ PRIVATE PROPS ********************************/

// ---------------------------------------------------------
// CImpsCommonGroupProps::CImpsCommonGroupProps
// ---------------------------------------------------------
//
EXPORT_C CImpsCommonGroupProps::CImpsCommonGroupProps()
: CImpsGroupProps(),
  iAccessOpen( EImpsPropUndef), 
  iTypePublic( EImpsPropUndef ), 
  iSearchable( EImpsPropUndef ),  
  iNbrActive(0),  
  iMaxUsers(0),   
  iName(NULL),        
  iTopic(NULL),
  iWelcome(NULL),
  iAutoDelete( EImpsPropUndef )       
    {

    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::NewL
// ---------------------------------------------------------
//
EXPORT_C CImpsCommonGroupProps* CImpsCommonGroupProps::NewL()
    {
    CImpsCommonGroupProps* self = new (ELeave) CImpsCommonGroupProps;    
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::~CImpsCommonGroupProps
// ---------------------------------------------------------
//
EXPORT_C CImpsCommonGroupProps::~CImpsCommonGroupProps()
    {
    Reset();
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::Reset
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::Reset()
    {
    iAccessOpen = EImpsPropUndef;
    // iTypePublic = EImpsPropUndef;
    iSearchable = EImpsPropUndef;
    // iNbrActive = EImpsPropUndef;
    iMaxUsers = EImpsPropUndef;
    delete iName;
    iName = NULL;
    delete iTopic;
    iTopic = NULL;
    delete iWelcome;
    iWelcome = NULL;
    CImpsGroupProps::Reset();
    }


// ---------------------------------------------------------
// CImpsCommonGroupProps::Type
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyType CImpsCommonGroupProps::Type() const
    {
    return EImpsPropCommon;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::IsPrivateAllowed
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsCommonGroupProps::IsPrivateAllowed() const
    {
    return CImpsGroupProps::IsPrivateAllowed();
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetPrivateAllowed
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetPrivateAllowed( 
    TImpsPropertyBool aValue )
    {
    CImpsGroupProps::SetPrivateAllowed( aValue );
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::IsOpen
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsCommonGroupProps::IsOpen() const
    {
    return iAccessOpen;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetOpen
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetOpen( 
    TImpsPropertyBool aValue )
    {
    iAccessOpen = aValue;
    }


// ---------------------------------------------------------
// CImpsCommonGroupProps::IsPublic
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsCommonGroupProps::IsPublic() const
    {
    return iTypePublic;
    }


// ---------------------------------------------------------
// CImpsCommonGroupProps::IsSearchable
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsCommonGroupProps::IsSearchable() const
    {
    return iSearchable;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetSearchable
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetSearchable( 
    TImpsPropertyBool aValue )
    {
    iSearchable = aValue;
    }


// ---------------------------------------------------------
// CImpsCommonGroupProps::NbrOfUsers
// ---------------------------------------------------------
//
EXPORT_C TInt CImpsCommonGroupProps::NbrOfUsers() const
    {
    return iNbrActive;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::MaxNbrOfUsers
// ---------------------------------------------------------
//
EXPORT_C TInt CImpsCommonGroupProps::MaxNbrOfUsers() const
    {
    return iMaxUsers;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetMaxNbrOfUsers
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetMaxNbrOfUsers( 
    TInt aValue )
    {
    iMaxUsers = aValue;
    }


// ---------------------------------------------------------
// CImpsCommonGroupProps::GroupName
// ---------------------------------------------------------
//
EXPORT_C TPtrC CImpsCommonGroupProps::GroupName() const
    {
/*LDRA_NOANALYSIS*/
    return iName ? TPtrC( *iName ) : TPtrC();
/*LDRA_ANALYSIS*/
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetGroupNameL
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetGroupNameL( 
    const TDesC& aName )
    {
    HBufC* newAttrib = aName.AllocL();
    delete iName;
    iName = newAttrib;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::Topic
// ---------------------------------------------------------
//
EXPORT_C TPtrC CImpsCommonGroupProps::Topic() const
    {
/*LDRA_NOANALYSIS*/
    return iTopic ? TPtrC( *iTopic ) : TPtrC();
/*LDRA_ANALYSIS*/
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetTopicL
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetTopicL( 
    const TDesC& aTopic )
    {
    HBufC* newAttrib = aTopic.AllocL();
    delete iTopic;
    iTopic = newAttrib;
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::Welcome
// ---------------------------------------------------------
//
EXPORT_C TPtrC CImpsCommonGroupProps::Welcome() const
    {
/*LDRA_NOANALYSIS*/
    return iWelcome ? TPtrC( *iWelcome ) : TPtrC();
/*LDRA_ANALYSIS*/
    }

// ---------------------------------------------------------
// CImpsCommonGroupProps::SetWelcomeL
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetWelcomeL( 
    const TDesC& aText )
    {
    HBufC* newAttrib = aText.AllocL();
    delete iWelcome;
    iWelcome = newAttrib;
    }
// ---------------------------------------------------------
// CImpsCommonGroupProps::AutoDelete
// ---------------------------------------------------------
//    
EXPORT_C TImpsPropertyBool CImpsCommonGroupProps::AutoDelete() const
	 {
	 return iAutoDelete;	
	 }
// ---------------------------------------------------------
// CImpsCommonGroupProps::SetAutoDelete
// ---------------------------------------------------------
//
EXPORT_C void CImpsCommonGroupProps::SetAutoDelete( TImpsPropertyBool aValue )
	{
	iAutoDelete = aValue;		
	}
/************ PRIVATE PROPS ********************************/

// ---------------------------------------------------------
// CImpsPrivateGroupProps::CImpsPrivateGroupProps
// ---------------------------------------------------------
//
EXPORT_C CImpsPrivateGroupProps::CImpsPrivateGroupProps()
: CImpsGroupProps(),
  iMember( EImpsPropUndef ),
  iPrivilege( EImpsUserUndef )
    {

    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::NewL
// ---------------------------------------------------------
//
EXPORT_C CImpsPrivateGroupProps* CImpsPrivateGroupProps::NewL()
    {
    CImpsPrivateGroupProps* self = new (ELeave) CImpsPrivateGroupProps;
    
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop();

    return self;
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::~CImpsPrivateGroupProps
// ---------------------------------------------------------
//
EXPORT_C CImpsPrivateGroupProps::~CImpsPrivateGroupProps()
    {
    
    }

// Symbian OS default constructor can leave.
void CImpsPrivateGroupProps::ConstructL()
    {
    Reset( );
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::Reset
// ---------------------------------------------------------
//
EXPORT_C void CImpsPrivateGroupProps::Reset()
    {
    iMember = EImpsPropUndef;
    iPrivilege = EImpsUserUndef;
    CImpsGroupProps::Reset();    
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::Type
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyType CImpsPrivateGroupProps::Type() const
    {
    return EImpsPropPrivate;    
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::IsPrivateAllowed
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsPrivateGroupProps::IsPrivateAllowed() const
    {
    return CImpsGroupProps::IsPrivateAllowed();
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::SetPrivateAllowed
// ---------------------------------------------------------
//
EXPORT_C void CImpsPrivateGroupProps::SetPrivateAllowed( TImpsPropertyBool aValue )
    {
    CImpsGroupProps::SetPrivateAllowed( aValue );
    }

// ---------------------------------------------------------
// CImpsPrivateGroupProps::IsMember
// ---------------------------------------------------------
//
EXPORT_C TImpsPropertyBool CImpsPrivateGroupProps::IsMember() const
    {
    return iMember;
    }


// ---------------------------------------------------------
// CImpsPrivateGroupProps::Privileges
// ---------------------------------------------------------
//
EXPORT_C TImpsGroupUsers CImpsPrivateGroupProps::Privileges() const
    {
    return iPrivilege;
    }


// EPOC default constructor can leave.
void CImpsCommonGroupProps::ConstructL()
    {
    Reset( );
    }



// ================= OTHER EXPORTED FUNCTIONS ==============


//  End of File