logsui/logsserviceextension/src/clogspresencestatustableentry.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Triplet that contains the service id, presentity id and the
       
    15 *                presence status.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "clogspresencestatustableentry.h"
       
    23 #include "simpledebug.h"
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // NewL
       
    27 // ---------------------------------------------------------------------------
       
    28 //
       
    29 CLogsPresenceStatusTableEntry* CLogsPresenceStatusTableEntry::NewL(
       
    30         const TUint32 aServiceId, 
       
    31         const TDesC& aPresentityId,
       
    32         TBool aDisplayStatus, 
       
    33         TDesC* aPresenceStatusString )
       
    34     {
       
    35     CLogsPresenceStatusTableEntry* self = 
       
    36         CLogsPresenceStatusTableEntry::NewLC(
       
    37             aServiceId,
       
    38             aPresentityId,
       
    39             aDisplayStatus,
       
    40             aPresenceStatusString );
       
    41     CleanupStack::Pop( self );
       
    42     return self;    
       
    43     }
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // NewLC
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CLogsPresenceStatusTableEntry* CLogsPresenceStatusTableEntry::NewLC(
       
    51         const TUint32 aServiceId, 
       
    52         const TDesC& aPresentityId,
       
    53         TBool aDisplayStatus,
       
    54         TDesC* aPresenceStatusString )
       
    55     {
       
    56     CLogsPresenceStatusTableEntry* self = 
       
    57         new( ELeave ) CLogsPresenceStatusTableEntry( aServiceId, 
       
    58                                                      aDisplayStatus );
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL( aPresentityId, aPresenceStatusString );
       
    61     return self;    
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // Symbian Second Phase Constructor.
       
    67 // ---------------------------------------------------------------------------
       
    68 // 
       
    69 void CLogsPresenceStatusTableEntry::ConstructL( const TDesC& aPresentityId,
       
    70                                                 TDesC* aPresenceStatusString )
       
    71     {
       
    72     _LOG("CLogsPresenceStatusTableEntry::ConstructL: begin")
       
    73     iPresentityId = aPresentityId.AllocL();
       
    74     if ( aPresenceStatusString )
       
    75         {
       
    76         iPresenceStatusString = aPresenceStatusString->AllocL();
       
    77         }
       
    78     else
       
    79         {
       
    80         iPresenceStatusString = NULL;
       
    81         }
       
    82     _LOG("CLogsPresenceStatusTableEntry::ConstructL: end")    
       
    83     }
       
    84     
       
    85     
       
    86 // ---------------------------------------------------------------------------
       
    87 // Destructor
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CLogsPresenceStatusTableEntry::~CLogsPresenceStatusTableEntry()
       
    91     {
       
    92     _LOG("CLogsPresenceStatusTableEntry::~CLogsPresenceStatusTableEntry: beg")
       
    93     delete iPresentityId;
       
    94     delete iPresenceStatusString;
       
    95     _LOG("CLogsPresenceStatusTableEntry::~CLogsPresenceStatusTableEntry: end")
       
    96     }
       
    97 
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // Constructor
       
   101 // ---------------------------------------------------------------------------
       
   102 //    
       
   103 CLogsPresenceStatusTableEntry::CLogsPresenceStatusTableEntry( 
       
   104         const TUint32 aServiceId, TBool aDisplayStatus ): 
       
   105             iServiceId( aServiceId ), 
       
   106             iDisplayStatus( aDisplayStatus )
       
   107     {
       
   108     _LOGP("CLogsPresenceStatusTableEntry::CLogsPresenceStatusTableEntry=%d",
       
   109         iServiceId)
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Returns the service id of this status table entry
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TUint32 CLogsPresenceStatusTableEntry::ServiceId() const
       
   118     {
       
   119     _LOGP("CLogsPresenceStatusTableEntry::ServiceId(): serviceId=%d",
       
   120         iServiceId)
       
   121     return iServiceId;
       
   122     }
       
   123 
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // Returns the presense display status of this status table entry
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 TBool CLogsPresenceStatusTableEntry::DisplayPresence()
       
   130     {
       
   131     _LOG("CLogsPresenceStatusTableEntry::DisplayPresence(): ...")
       
   132     _LOGP("...iDisplayStatus = %d ", (TInt)iDisplayStatus )
       
   133     return iDisplayStatus;
       
   134     }
       
   135 
       
   136 
       
   137 // ---------------------------------------------------------------------------
       
   138 // Sets presense display status of this status table entry
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CLogsPresenceStatusTableEntry::SetDisplayPresence(
       
   142           TBool aDisplayStatus )
       
   143     {
       
   144     _LOG("CLogsPresenceStatusTableEntry::SetDisplayPresence():...")
       
   145     _LOGP("... aDisplayStatus = %d ", (TInt)aDisplayStatus )
       
   146     
       
   147     iDisplayStatus = aDisplayStatus;
       
   148     }
       
   149 
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // Returns the presentity id of this status table entry.
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 const TDesC& CLogsPresenceStatusTableEntry::PresentityId()
       
   156     {
       
   157     if ( iPresentityId )
       
   158         {        
       
   159         _LOGDES(*iPresentityId)
       
   160         return *iPresentityId;
       
   161         }            
       
   162     return KNullDesC();
       
   163     }
       
   164     
       
   165     
       
   166 // ---------------------------------------------------------------------------
       
   167 // Returns the presence status of this status table entry.
       
   168 // ---------------------------------------------------------------------------
       
   169 //    
       
   170 TDesC* CLogsPresenceStatusTableEntry::PresenceStatusString()
       
   171     {   
       
   172     if ( iPresenceStatusString )
       
   173         {        
       
   174         _LOGDES(*iPresenceStatusString)        
       
   175         }
       
   176     return iPresenceStatusString;
       
   177     }
       
   178  
       
   179  
       
   180 // ---------------------------------------------------------------------------
       
   181 // Sets the presence status string of this status table entry.
       
   182 // ---------------------------------------------------------------------------
       
   183 //    
       
   184 TInt CLogsPresenceStatusTableEntry::SetPresenceStatusString( 
       
   185         const TDesC& aPresenceStatusString )
       
   186     {    
       
   187     _LOG("CLogsPresenceStatusTableEntry::SetPresenceStatusStringL(): begin")
       
   188     _LOGDES(aPresenceStatusString)
       
   189     
       
   190     TInt error( KErrGeneral );
       
   191         
       
   192     delete iPresenceStatusString;
       
   193     iPresenceStatusString = NULL;
       
   194     iPresenceStatusString = aPresenceStatusString.Alloc();    
       
   195     
       
   196     if ( iPresenceStatusString )
       
   197         {
       
   198         error = KErrNone;        
       
   199         _LOGDES(*iPresenceStatusString)
       
   200         }
       
   201     else
       
   202         {
       
   203         error = KErrNoMemory;
       
   204         _LOG("CLogsPresenceStatusTableEntry::SetPresenceStatusStringL():...")
       
   205         _LOG("... creation of descriptor failed!")
       
   206         }    
       
   207     _LOG("CLogsPresenceStatusTableEntry::SetPresenceStatusStringL(): end")
       
   208     return error;
       
   209     }
       
   210 
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // Resets the presence status string of this status table entry.
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 void CLogsPresenceStatusTableEntry::ResetPresenceStatusString()
       
   217     {
       
   218     _LOG("CLogsPresenceStatusTableEntry::ResetPresenceStatusString(): begin")
       
   219     
       
   220     delete iPresenceStatusString;
       
   221     iPresenceStatusString = NULL;    
       
   222     
       
   223     _LOG("CLogsPresenceStatusTableEntry::ResetPresenceStatusString(): end")
       
   224     }
       
   225