phoneuis/BubbleManager/Src/BMConfHeader.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Conf Header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "BMConfHeader.h"
       
    21 #include    "BMCallHeader.h"
       
    22 #include    "BMPanic.h"
       
    23 
       
    24 // ========================= MEMBER FUNCTIONS ================================
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CBubbleConfHeader::CBubbleConfHeader
       
    28 // Default constructor
       
    29 // 
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CBubbleConfHeader::CBubbleConfHeader()
       
    33     {
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CBubbleConfHeader::NewL
       
    38 // Symbian OS two phased constructor
       
    39 // 
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CBubbleConfHeader* CBubbleConfHeader::NewL( 
       
    43                                  const CBubbleManager::TBubbleId& aBubbleId )
       
    44     {
       
    45     CBubbleConfHeader* self = new( ELeave )CBubbleConfHeader( );    
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL( aBubbleId );
       
    48     CleanupStack::Pop( );    // self
       
    49     return self;
       
    50     }
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CBubbleConfHeader::ConstructL
       
    55 // 
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CBubbleConfHeader::ConstructL( 
       
    59     const CBubbleManager::TBubbleId& aBubbleId )
       
    60     {
       
    61     CBubbleHeader::ConstructL( aBubbleId ); // call to parent's ConstructL
       
    62     
       
    63     iCalls = new ( ELeave ) 
       
    64         CArrayPtrFlat<CBubbleCallHeader>( KBubbleMaxCallsInConf );    
       
    65     iCalls->SetReserveL( KBubbleMaxCallsInConf );
       
    66     
       
    67     Reset();
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CBubbleConfHeader::~CBubbleConfHeader
       
    72 // Destructor
       
    73 // 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CBubbleConfHeader::~CBubbleConfHeader()
       
    77     {
       
    78     if ( iCalls )
       
    79         {
       
    80         iCalls->Reset();
       
    81         delete iCalls;
       
    82         }
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CBubbleConfHeader::IsConference
       
    87 // 
       
    88 // 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 TBool CBubbleConfHeader::IsConference( ) const
       
    92     {
       
    93     return ETrue;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CBubbleConfHeader::Reset
       
    98 // Puts everything in initial state
       
    99 // 
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CBubbleConfHeader::Reset()
       
   103     {
       
   104     iIsUsed = EFalse;
       
   105     iIsExpanded = EFalse;
       
   106     iSelection = KBubbleNoHighlightRow;
       
   107     
       
   108     TInt callCount = iCalls->Count();
       
   109     for ( TUint8 i = 0 ; i < callCount; i++ )
       
   110         {
       
   111         iCalls->At( i )->SetIsInConference( EFalse );
       
   112         }
       
   113     
       
   114     iCalls->Delete( 0 , callCount );
       
   115     ResetParent( ); // call to parent's Reset
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CBubbleConfHeader::AddRow
       
   120 // Adds new call to conference
       
   121 // If max calls are already set to conference function, panics
       
   122 // 
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CBubbleConfHeader::AddRow( CBubbleCallHeader& aCall )
       
   126     {
       
   127     __ASSERT_ALWAYS( iCalls->Count() < KBubbleMaxCallsInConf, 
       
   128                      Panic( EBMPanicTooManyCallsInConference ) );
       
   129     
       
   130     iCalls->InsertL( iCalls->Count( ) , &aCall ); //space pre-reserved
       
   131     aCall.SetIsInConference( ETrue );
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CBubbleConfHeader::RemoveRow
       
   136 // Removes specified row from the conference call
       
   137 // If BubbleId doesn't exist in conference call function panics
       
   138 // 
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CBubbleConfHeader::RemoveRow( const CBubbleManager::TBubbleId& aCallId )
       
   142     {
       
   143     // Search the element.
       
   144     TUint8 index = 0;
       
   145     __ASSERT_ALWAYS( iCalls->Count() > 0, 
       
   146                      Panic( EBMPanicConferenceCallEmpty ) );
       
   147 
       
   148     if ( iCalls->Count() == 0 )
       
   149         {
       
   150         // Own panic function may not Panic the thread.
       
   151         return;
       
   152         }
       
   153 
       
   154     while ( iCalls->At( index )->BubbleId() != aCallId )
       
   155         {
       
   156         index++;
       
   157         __ASSERT_ALWAYS( index != iCalls->Count(), 
       
   158                          Panic( EBMPanicBubbleIdDoesNotExist ) );
       
   159         if ( index == iCalls->Count() )
       
   160             {
       
   161             // Own panic implementation does not panic the thread in every case
       
   162             return;
       
   163             }
       
   164         }
       
   165     
       
   166     CBubbleManager::TBubbleId oldhighlightid = HighlightId();
       
   167     
       
   168     iCalls->At( index )->SetIsInConference( EFalse );
       
   169     
       
   170     iCalls->Delete( index );
       
   171     
       
   172     // move highlight to new position
       
   173     if ( oldhighlightid != aCallId )
       
   174         {
       
   175         SetHighlightId( oldhighlightid );
       
   176         }
       
   177     else if ( iSelection >= iCalls->Count( ) )
       
   178         {
       
   179         iSelection = static_cast<TUint8>( iCalls->Count() );
       
   180         }
       
   181     }
       
   182 
       
   183 // ---------------------------------------------------------------------------
       
   184 // CBubbleConfHeader::GetRows
       
   185 // 
       
   186 // 
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CBubbleConfHeader::GetRows( 
       
   190                            CArrayPtrFlat<CBubbleCallHeader>& aCalls ) const
       
   191     {
       
   192     aCalls.Delete( 0 , aCalls.Count() );
       
   193     TInt callCount = iCalls->Count();
       
   194     
       
   195     for ( TUint8 outIndex = 0; outIndex < callCount ; outIndex++ )
       
   196         {
       
   197         aCalls.InsertL( outIndex , iCalls->At( outIndex ) ); // can't leave.
       
   198         }
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // CBubbleConfHeader::RowCount
       
   203 // 
       
   204 // 
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 TUint8 CBubbleConfHeader::RowCount( ) const
       
   208     {
       
   209     return static_cast<TUint8>( iCalls->Count() );
       
   210     }
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // CBubbleConfHeader::IsUsed
       
   214 // 
       
   215 // 
       
   216 // ---------------------------------------------------------------------------
       
   217 //
       
   218 TBool CBubbleConfHeader::IsUsed( ) const
       
   219     {
       
   220     return iIsUsed;
       
   221     }
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // CBubbleConfHeader::SetIsUsed
       
   225 // If set not used, reset the header.
       
   226 // 
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 void CBubbleConfHeader::SetIsUsed( const TBool& aIsUsed )
       
   230     {
       
   231     iIsUsed = aIsUsed;
       
   232     if ( !iIsUsed )
       
   233         {
       
   234         Reset( );
       
   235         }       
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------------------------
       
   239 // CBubbleConfHeader::SetIsExpanded
       
   240 //
       
   241 // 
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 void CBubbleConfHeader::SetIsExpanded( TBool aIsExpanded )
       
   245     {
       
   246     iIsExpanded = aIsExpanded;
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // CBubbleConfHeader::IsExpanded
       
   251 // 
       
   252 // 
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 TBool CBubbleConfHeader::IsExpanded( ) const
       
   256     {
       
   257     return iIsExpanded;
       
   258     }
       
   259 
       
   260 // ---------------------------------------------------------------------------
       
   261 // CBubbleConfHeader::SetHighlight
       
   262 // 
       
   263 // 
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 void CBubbleConfHeader::SetHighlight( const CBubbleManager::TRowNumber& aRow )
       
   267     {
       
   268     __ASSERT_ALWAYS( aRow <= iCalls->Count(),
       
   269                      Panic( EBMPanicInvalidConfRowNumber ) );
       
   270     
       
   271     iSelection = aRow;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // CBubbleConfHeader::SetHighlightId
       
   276 // 
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 void CBubbleConfHeader::SetHighlightId( 
       
   280                                 const CBubbleManager::TBubbleId& aBubbleId )
       
   281     {
       
   282     if ( aBubbleId == KBubbleInvalidId )
       
   283         {
       
   284         iSelection = KBubbleNoHighlightRow;
       
   285         return;
       
   286         }
       
   287     
       
   288     for ( TInt i = 0 ; i < iCalls->Count() ; i++ )
       
   289         {
       
   290         if ( iCalls->At(i)->BubbleId() == aBubbleId )
       
   291             {
       
   292             iSelection = static_cast<CBubbleManager::TRowNumber>( i+1 );
       
   293             return;
       
   294             }
       
   295         }
       
   296     __ASSERT_DEBUG( EFalse , Panic( EBMPanicBubbleIdDoesNotExist ) );
       
   297     }
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // CBubbleConfHeader::Highlight
       
   301 // 
       
   302 // 
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 CBubbleManager::TRowNumber CBubbleConfHeader::Highlight() const
       
   306     {
       
   307     return iSelection;
       
   308     }
       
   309 
       
   310 // ---------------------------------------------------------------------------
       
   311 // CBubbleConfHeader::HighlightId
       
   312 // 
       
   313 // 
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 CBubbleManager::TBubbleId CBubbleConfHeader::HighlightId() const
       
   317     {
       
   318     if ( iSelection == KBubbleNoHighlightRow || iSelection > iCalls->Count() )
       
   319         {
       
   320         return KBubbleInvalidId;
       
   321         }  
       
   322     return iCalls->At( iSelection - 1 )->BubbleId();
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CBubbleConfHeader::MoveHighlightOneUp
       
   327 // 
       
   328 // 
       
   329 // ---------------------------------------------------------------------------
       
   330 //
       
   331 void CBubbleConfHeader::MoveHighlightOneUp()
       
   332     {
       
   333     if( iSelection == KBubbleNoHighlightRow || iSelection == 1 )
       
   334         {
       
   335         return;
       
   336         }
       
   337     
       
   338     iSelection--;
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // CBubbleConfHeader::MoveHighlightOneDown
       
   343 // 
       
   344 // 
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CBubbleConfHeader::MoveHighlightOneDown()
       
   348     {
       
   349     if ( iSelection == KBubbleNoHighlightRow || 
       
   350         iSelection >= iCalls->Count() )
       
   351         {
       
   352         return;
       
   353         }
       
   354     iSelection++;
       
   355     }
       
   356 
       
   357 // End of File