phoneapp/phoneuiview/src/phonebubbleextensiondata.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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:  Contains call data.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "phonebubbleextensiondata.h"
       
    20 #include "tphonecmdparamcallheaderdata.h"
       
    21 #include "pevirtualengine.h"
       
    22 
       
    23 // --------------------------------------------------------------------------
       
    24 // Two-phased constructor.
       
    25 // --------------------------------------------------------------------------
       
    26 //
       
    27 CPhoneBubbleExtensionData* CPhoneBubbleExtensionData::NewL(
       
    28     TInt aBubbleId,
       
    29     TPhoneCmdParamCallHeaderData* aParams, 
       
    30     TBool aFirst )
       
    31     {
       
    32     CPhoneBubbleExtensionData* self =
       
    33         CPhoneBubbleExtensionData::NewLC( aBubbleId, aParams, aFirst );
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // --------------------------------------------------------------------------
       
    39 // Two-phased constructor.
       
    40 // --------------------------------------------------------------------------
       
    41 //
       
    42 CPhoneBubbleExtensionData* CPhoneBubbleExtensionData::NewLC(
       
    43     TInt aBubbleId,
       
    44     TPhoneCmdParamCallHeaderData* aParams, 
       
    45     TBool aFirst )
       
    46     {
       
    47     CPhoneBubbleExtensionData* self =
       
    48         new( ELeave ) CPhoneBubbleExtensionData( aBubbleId, aParams, aFirst );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL( aParams );
       
    51     return self;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Destructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CPhoneBubbleExtensionData::~CPhoneBubbleExtensionData()
       
    59     {
       
    60     delete iContactLink;
       
    61     delete iRemotePhoneNumber;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Sets the call state
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CPhoneBubbleExtensionData::SetState( TInt aState, TBool aFirst )
       
    69     {
       
    70     switch ( aState )
       
    71         {
       
    72         case EPEStateDialing:
       
    73             iState = MTelBubbleExtensionData::EOutgoing;
       
    74             break;
       
    75 
       
    76         case EPEStateRinging:
       
    77             if ( aFirst )
       
    78                 {
       
    79                 iState = MTelBubbleExtensionData::EIncoming;
       
    80                 }
       
    81             else
       
    82                 {
       
    83                 iState = MTelBubbleExtensionData::EWaiting;
       
    84                 }
       
    85             break;
       
    86 
       
    87         case EPEStateConnecting:
       
    88             iState = MTelBubbleExtensionData::EAlerting;
       
    89             break;
       
    90 
       
    91         case EPEStateHeld: // fall-through
       
    92         case EPEStateHeldConference:
       
    93             iState = MTelBubbleExtensionData::EOnHold;
       
    94             break;
       
    95 
       
    96         case EPEStateDisconnecting: // fall-through
       
    97         case EPEStateConferenceIdle: // fall-through
       
    98         case EPEStateIdle:
       
    99             iState = MTelBubbleExtensionData::EDisconnected;
       
   100             break;
       
   101 
       
   102         case EPEStateConnected: // fall-through
       
   103         case EPEStateConnectedConference:
       
   104             iState = MTelBubbleExtensionData::EActive;
       
   105             break;
       
   106 
       
   107         case EPEStateUnknown: // fall-through
       
   108         default:
       
   109             break;
       
   110         }
       
   111     
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // From class MTelBubbleExtensionData.
       
   116 // Bubble ID.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 inline TInt CPhoneBubbleExtensionData::BubbleId() const
       
   120     {
       
   121     return iBubbleId;
       
   122     }
       
   123 
       
   124 // --------------------------------------------------------------------------
       
   125 // From class MTelBubbleExtensionData.
       
   126 // Call state information.
       
   127 // --------------------------------------------------------------------------
       
   128 //
       
   129 inline CPhoneBubbleExtensionData::TCallState
       
   130     CPhoneBubbleExtensionData::State() const
       
   131     {
       
   132     return iState;
       
   133     }
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // From class MTelBubbleExtensionData.
       
   137 // Call type information
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 inline CPhoneBubbleExtensionData::TCallType
       
   141     CPhoneBubbleExtensionData::Type() const
       
   142     {
       
   143     return iType;
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // From class MTelBubbleExtensionData.
       
   148 // Call service id
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 inline TUint32 CPhoneBubbleExtensionData::ServiceId() const
       
   152     {
       
   153     return iService;
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // From class MTelBubbleExtensionData.
       
   158 // Contact Link related to this call.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 inline const TDesC8& CPhoneBubbleExtensionData::ContactLink() const
       
   162     {
       
   163     return *iContactLink;
       
   164     }
       
   165 
       
   166 // ---------------------------------------------------------------------------
       
   167 // From class MTelBubbleExtensionData.
       
   168 // Remote phone number related to this call.
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 const TDesC& CPhoneBubbleExtensionData::RemotePhoneNumber() const
       
   172     {
       
   173     return *iRemotePhoneNumber;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // First phase constructor
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 CPhoneBubbleExtensionData::CPhoneBubbleExtensionData( 
       
   181     TInt aBubbleId,
       
   182     TPhoneCmdParamCallHeaderData* aParams, 
       
   183     TBool aFirst )
       
   184     : iBubbleId(aBubbleId), iState(ENone), iType(EUninitialized), iService(0)
       
   185     {
       
   186     // call state
       
   187     SetState( aParams->CallState(), aFirst );
       
   188 
       
   189     // call type
       
   190     switch ( aParams->CallType() )
       
   191         {
       
   192         case EPECallTypeCSVoice:
       
   193             iType = MTelBubbleExtensionData::ECsVoice;
       
   194             break;
       
   195 
       
   196         case EPECallTypeVideo:
       
   197             iType = MTelBubbleExtensionData::ECsVideo;
       
   198             break;
       
   199         
       
   200         case EPECallTypeVoIP:
       
   201             iType = MTelBubbleExtensionData::EPsVoice;
       
   202             break;
       
   203         
       
   204         case EPECallTypeUninitialized:
       
   205         default:
       
   206             iType = MTelBubbleExtensionData::EUninitialized;
       
   207             break;
       
   208         }
       
   209     
       
   210     // service ID
       
   211     iService = aParams->ServiceId();
       
   212     }
       
   213 
       
   214 
       
   215 // ---------------------------------------------------------------------------
       
   216 // Second phase constructor
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 void CPhoneBubbleExtensionData::ConstructL( 
       
   220     TPhoneCmdParamCallHeaderData* aParams )
       
   221     {
       
   222     // Copy contact link to local buffer
       
   223     iContactLink = HBufC8::NewL( aParams->ContactLink().Length() );
       
   224     *iContactLink = aParams->ContactLink();
       
   225     
       
   226     // Copy phone number to local buffer
       
   227     iRemotePhoneNumber = aParams->RemotePhoneNumber().AllocL();
       
   228     }
       
   229 
       
   230