phoneuis/bubblemanager2/tsrc/bubbletest2/bubbletestview.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*!
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtGui>
       
    19 #include <QDebug>
       
    20 #include <hbaction.h>
       
    21 #include <hbtoolbar.h>
       
    22 #include <bubblemanager2.h>
       
    23 #include <hbmenu.h>
       
    24 #include <hbmainwindow.h>
       
    25 
       
    26 #include "bubbletestview.h"
       
    27 #include "bubbletester.h"
       
    28 
       
    29 BubbleTestView::BubbleTestView(HbMainWindow& window, QGraphicsItem *parent) :
       
    30     HbView (parent), mMainWindow(window), mMuted(0), mConfBubbleId(-1),
       
    31     mProvideJoin(false)
       
    32 {
       
    33     setFlags (QGraphicsItem::ItemIsFocusable);
       
    34     setFocusPolicy (Qt::StrongFocus);
       
    35     setTitle("BubbleTest2");
       
    36     
       
    37     // the widget under the test
       
    38     mBubbleManager = new BubbleManager (this);
       
    39     setWidget(mBubbleManager);
       
    40 
       
    41     // init toolbar
       
    42     createToolBarActions();
       
    43     //toolBar()->setOrientation(mMainWindow.orientation());
       
    44     connect( &mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)),
       
    45              this,SLOT(handleOrientationChange(Qt::Orientation)));
       
    46     
       
    47     // init menu
       
    48     createMenuActions();
       
    49 
       
    50     // create actions for push buttons
       
    51     createBubbleActions();
       
    52 
       
    53     // tester
       
    54     mBubbleTester = new BubbleTester();
       
    55     connect(mBubbleTester,SIGNAL(dataChanged()),this,SLOT(handleTesterDataChanged()));
       
    56     mBubbleTester->connectToServer();
       
    57 
       
    58     // create state map
       
    59     mStateMap.insert("Idle", BubbleManagerIF::None );
       
    60     mStateMap.insert("Incoming", BubbleManagerIF::Incoming );
       
    61     mStateMap.insert("Active", BubbleManagerIF::Active );
       
    62     mStateMap.insert("Disconnected", BubbleManagerIF::Disconnected );
       
    63     mStateMap.insert("Outgoing", BubbleManagerIF::Outgoing );
       
    64     mStateMap.insert("Waiting", BubbleManagerIF::Waiting );
       
    65     mStateMap.insert("OnHold", BubbleManagerIF::OnHold );
       
    66     // create label map
       
    67     mLabelMap.insert("Idle", "" );
       
    68     mLabelMap.insert("Incoming", "calling" );
       
    69     mLabelMap.insert("Active", "" );
       
    70     mLabelMap.insert("Disconnected", "disconnected" );
       
    71     mLabelMap.insert("Outgoing", "Calling" );
       
    72     mLabelMap.insert("Waiting", "waiting" );
       
    73     mLabelMap.insert("OnHold", "on hold" );
       
    74 }
       
    75 
       
    76 BubbleTestView::~BubbleTestView()
       
    77 {
       
    78     toolBar()->clearActions();
       
    79     delete mBubbleTester;
       
    80 }
       
    81 
       
    82 void BubbleTestView::keyPressEvent(QKeyEvent *event)
       
    83 {
       
    84     switch( event->key() )
       
    85     {
       
    86     case '1': // create incoming call
       
    87     {
       
    88         if ( mEmergencyCall->isChecked() ) {
       
    89             return; // not supported
       
    90         }
       
    91 
       
    92         if ( mCalls.count() == 0 ) {
       
    93             bubbleManager().startChanges();
       
    94             int bubbleId = bubbleManager().createCallHeader();
       
    95             setBubbleData(bubbleId, BubbleManager::Incoming);
       
    96             setBubbleActions(bubbleId, BubbleManager::Incoming);
       
    97             bubbleManager().endChanges();
       
    98             
       
    99             // store this call
       
   100             TestCall call;
       
   101             call.bubbleId = bubbleId;
       
   102             call.callState = BubbleManager::Incoming;
       
   103             mCalls.append( call );
       
   104 
       
   105             updateToolBarActions();
       
   106 
       
   107         } else if ( !initializingCallExists() ) {
       
   108             // waiting call
       
   109             bubbleManager().startChanges();
       
   110             int bubbleId = bubbleManager().createCallHeader();
       
   111             setBubbleData(bubbleId, BubbleManager::Waiting);
       
   112             setBubbleActions( bubbleId, BubbleManager::Waiting );
       
   113             bubbleManager().setExpandedConferenceCallHeader(false);
       
   114             bubbleManager().endChanges();
       
   115 
       
   116             // store this call
       
   117             TestCall call;
       
   118             call.bubbleId = bubbleId;
       
   119             call.callState = BubbleManager::Waiting;
       
   120             mCalls.append( call );
       
   121 
       
   122             setExpandActions();
       
   123             updateToolBarActions();
       
   124         }
       
   125         break;
       
   126     }
       
   127     
       
   128     case '2': // create outgoing call
       
   129     {
       
   130         if ( !initializingCallExists() && (callCount()<3) ) {
       
   131             bubbleManager().startChanges();
       
   132             int bubbleId = bubbleManager().createCallHeader();
       
   133             setBubbleData(bubbleId, BubbleManager::Outgoing);
       
   134             setBubbleActions( bubbleId, BubbleManager::Outgoing );
       
   135             bubbleManager().endChanges();
       
   136 
       
   137             // store this call
       
   138             TestCall call;
       
   139             call.bubbleId = bubbleId;
       
   140             call.callState = BubbleManager::Outgoing;
       
   141             mCalls.append( call );
       
   142 
       
   143             bubbleManager().setBubbleSelectionDisabled(false);
       
   144             updateToolBarActions();
       
   145        }
       
   146        break;
       
   147     }
       
   148     
       
   149     case '3': // connect
       
   150     {
       
   151         int i,j;
       
   152 
       
   153         if (callIndexByState(BubbleManagerIF::Outgoing, i)) {
       
   154             // outgoing to alerting
       
   155             bubbleManager().startChanges();
       
   156             setBubbleData(mCalls[i].bubbleId, BubbleManager::Alerting);
       
   157             bubbleManager().endChanges();
       
   158             mCalls[i].callState = BubbleManager::Alerting;
       
   159             return;
       
   160         }
       
   161 
       
   162         if (callCount()==3) {
       
   163             // replace active call
       
   164             bubbleManager().startChanges();
       
   165             Q_ASSERT(callIndexByState(BubbleManagerIF::Active, j));
       
   166             bubbleManager().removeCallHeader(mCalls[j].bubbleId);
       
   167             mCalls.removeAt(j);
       
   168             Q_ASSERT(callIndexByState(BubbleManagerIF::Waiting, i));
       
   169             setBubbleData(mCalls[i].bubbleId, BubbleManager::Active);
       
   170             setBubbleActions(mCalls[i].bubbleId, BubbleManager::Active);
       
   171             bubbleManager().endChanges();
       
   172             mCalls[i].callState = BubbleManager::Active;
       
   173             setExpandActions();
       
   174             updateToolBarActions();
       
   175             bubbleManager().setBubbleSelectionDisabled(false);
       
   176         } else if (callIndexByState(BubbleManagerIF::Incoming, i)||
       
   177                    callIndexByState(BubbleManagerIF::Alerting, i)||
       
   178                    callIndexByState(BubbleManagerIF::Waiting, i)) {
       
   179             bubbleManager().startChanges();
       
   180             setBubbleData(mCalls[i].bubbleId, BubbleManager::Active);
       
   181             mProvideJoin = true; // bit hackish
       
   182             setBubbleActions(mCalls[i].bubbleId, BubbleManager::Active);
       
   183             mProvideJoin = false;
       
   184             if (callIndexByState(BubbleManagerIF::Active, j)) {
       
   185                 setBubbleData(mCalls[j].bubbleId, BubbleManager::OnHold);
       
   186                 setBubbleActions(mCalls[j].bubbleId, BubbleManager::OnHold);
       
   187                 mCalls[j].callState = BubbleManager::OnHold;
       
   188             }
       
   189             bubbleManager().endChanges();
       
   190             mCalls[i].callState = BubbleManager::Active;
       
   191             setExpandActions();
       
   192             updateToolBarActions();
       
   193             bubbleManager().setBubbleSelectionDisabled(false);
       
   194         }
       
   195         break;
       
   196     }
       
   197 
       
   198     case '4': // hold
       
   199     {
       
   200         int i,j;
       
   201 
       
   202         if (bubbleManager().isConferenceExpanded()) {
       
   203             toggleHoldConference();
       
   204         } else if (callCount()==1) {
       
   205             // toggle hold
       
   206             bubbleManager().startChanges();
       
   207             if (callIndexByState(BubbleManagerIF::Active, i)||
       
   208                 callIndexByState(BubbleManagerIF::OnHold, i)) {
       
   209                 BubbleManagerIF::PhoneCallState state =
       
   210                     mCalls[i].callState == BubbleManagerIF::Active ?
       
   211                     BubbleManagerIF::OnHold : BubbleManagerIF::Active;
       
   212 
       
   213                 setBubbleData(mCalls[i].bubbleId, state);
       
   214                 setBubbleActions(mCalls[i].bubbleId, state );
       
   215                 mCalls[i].callState=state;
       
   216             }
       
   217             bubbleManager().endChanges();
       
   218             updateToolBarActions();
       
   219         } else if (callIndexByState(BubbleManagerIF::Active, i)) {
       
   220             // swap calls
       
   221             bubbleManager().startChanges();
       
   222             if (callIndexByState(BubbleManagerIF::OnHold, j)) {
       
   223                 setBubbleData(mCalls[j].bubbleId, BubbleManager::Active);
       
   224                 setBubbleActions(mCalls[j].bubbleId, BubbleManager::Active );
       
   225                 mCalls[j].callState=BubbleManager::Active;
       
   226             }
       
   227             setBubbleData(mCalls[i].bubbleId, BubbleManager::OnHold);
       
   228             setBubbleActions(mCalls[i].bubbleId, BubbleManager::OnHold );
       
   229             mCalls[i].callState=BubbleManager::OnHold;
       
   230             if (conferenceCallExists()) {
       
   231                 bubbleManager().setExpandedConferenceCallHeader(
       
   232                     bubbleIdByState(BubbleManager::Active)==mConfBubbleId);
       
   233             }
       
   234             bubbleManager().endChanges();
       
   235             setExpandActions();
       
   236             updateToolBarActions();
       
   237         } else if (callIndexByState(BubbleManagerIF::Waiting, i)) {
       
   238             // activate held call
       
   239             bubbleManager().startChanges();
       
   240             if (callIndexByState(BubbleManagerIF::OnHold, j)) {
       
   241                 setBubbleData(mCalls[j].bubbleId, BubbleManager::Active);
       
   242                 setBubbleActions(mCalls[j].bubbleId, BubbleManager::Active );
       
   243                 mCalls[j].callState=BubbleManager::Active;
       
   244             }
       
   245             bubbleManager().endChanges();
       
   246             setExpandActions();
       
   247             updateToolBarActions();
       
   248         }
       
   249         break;
       
   250     }
       
   251     
       
   252     case '5': // disconnect
       
   253     {
       
   254         int i,j;
       
   255 
       
   256         if (callIndexByState(BubbleManagerIF::Disconnected, i)) {
       
   257             bubbleManager().startChanges();
       
   258             bubbleManager().removeCallHeader(mCalls[i].bubbleId);
       
   259             // remove call
       
   260             mCalls.removeAt(i);
       
   261 
       
   262             if (mMuted) {
       
   263                 setMuted(); // unmute
       
   264             }
       
   265 
       
   266             bool expand = true;
       
   267             QListIterator<TestCall> calls(mCalls);
       
   268             while(calls.hasNext()) {
       
   269                 TestCall call = calls.next();
       
   270                   if (!call.isConf && !call.isInConf) {
       
   271                       expand = false;
       
   272                   }
       
   273             }
       
   274             bubbleManager().setExpandedConferenceCallHeader(expand);
       
   275             bubbleManager().endChanges();
       
   276 
       
   277             updateToolBarActions();
       
   278             return;
       
   279         }
       
   280 
       
   281         if (callCount()) {
       
   282             int expanded = bubbleManager().expandedBubble();
       
   283             callIndexByBubbleId(expanded,i);
       
   284             bubbleManager().startChanges();
       
   285 
       
   286             if (mCalls.at(i).isConf) {
       
   287                 bubbleManager().removeConference();
       
   288                 mConfBubbleId = -1;
       
   289                 mCalls.removeAt(i);
       
   290 
       
   291                 QMutableListIterator<TestCall> calls(mCalls);
       
   292                 j=0;
       
   293                 while(calls.hasNext()) {                  
       
   294                     if (mCalls[j].isInConf) {
       
   295                         bubbleManager().removeCallHeader(mCalls[j].bubbleId);
       
   296                         mCalls.removeAt(j);
       
   297                     } else {
       
   298                         j++;
       
   299                     }
       
   300                     calls.next();
       
   301                 }
       
   302             } else {
       
   303                 setBubbleData(mCalls[i].bubbleId, BubbleManager::Disconnected);
       
   304                 setBubbleActions(mCalls[i].bubbleId, BubbleManager::Disconnected);
       
   305                 mCalls[i].callState=BubbleManager::Disconnected;
       
   306             }
       
   307             bubbleManager().endChanges();
       
   308             updateToolBarActions();
       
   309         }
       
   310         break;
       
   311     }
       
   312     
       
   313     case '7': // create/join conference
       
   314     {
       
   315         int activeCallId = bubbleIdByState(BubbleManagerIF::Active);
       
   316         int heldCallId = bubbleIdByState(BubbleManagerIF::OnHold);
       
   317         int i;
       
   318 
       
   319         if (conferenceCallExists()&&(activeCallId!=-1)) {
       
   320             int j;
       
   321             callIndexByBubbleId(mConfBubbleId,j);
       
   322             callIndexByBubbleId(activeCallId,i);
       
   323             mCalls[i].isInConf = true;
       
   324             mCalls[i].callState = BubbleManagerIF::Active;
       
   325             mCalls[j].callState = BubbleManagerIF::Active;
       
   326             bubbleManager().startChanges();
       
   327             bubbleManager().addRowToConference(activeCallId);
       
   328             bubbleManager().setExpandedConferenceCallHeader(true);
       
   329             bubbleManager().setState(mConfBubbleId,BubbleManagerIF::Active);
       
   330             setBubbleActions(mConfBubbleId,BubbleManagerIF::Active);
       
   331             bubbleManager().endChanges();            
       
   332         } else if (activeCallId!=-1 && heldCallId!=-1) {
       
   333             bubbleManager().startChanges();
       
   334             mConfBubbleId = bubbleManager().createConference(heldCallId, activeCallId);
       
   335             bubbleManager().setExpandedConferenceCallHeader(true);
       
   336             bubbleManager().setState(mConfBubbleId,BubbleManagerIF::Active);
       
   337             bubbleManager().setCli(mConfBubbleId,"Conference call",Qt::ElideRight);
       
   338             if (mCallTimer->isChecked()) {
       
   339                 bubbleManager().setCallTime( mConfBubbleId, "0:00" );
       
   340             }
       
   341             bubbleManager().addAction(mConfBubbleId, mHold);
       
   342             bubbleManager().addAction(mConfBubbleId, mEndConference);
       
   343             bubbleManager().clearParticipantListActions();
       
   344             bubbleManager().addParticipantListAction(mPrivate);
       
   345             bubbleManager().addParticipantListAction(mDrop);
       
   346             bubbleManager().setState(heldCallId,BubbleManagerIF::Active);
       
   347             bubbleManager().setCallFlag(mConfBubbleId, BubbleManager::NoCiphering,
       
   348                                         mCipheringOff->isChecked());
       
   349             bubbleManager().endChanges();
       
   350 
       
   351             callIndexByBubbleId(activeCallId,i);
       
   352             mCalls[i].isInConf = true;
       
   353             mCalls[i].callState = BubbleManagerIF::Active;
       
   354             callIndexByBubbleId(heldCallId,i);
       
   355             mCalls[i].isInConf = true;
       
   356             mCalls[i].callState = BubbleManagerIF::Active;
       
   357 
       
   358             // store the call
       
   359             TestCall call;
       
   360             call.bubbleId = mConfBubbleId;
       
   361             call.callState = BubbleManagerIF::Active;
       
   362             call.isConf = true;
       
   363             call.isInConf = false;
       
   364             mCalls.append(call);
       
   365         }
       
   366         break;
       
   367     }
       
   368 
       
   369     case '9': // conference shortcut
       
   370     {
       
   371         conferenceWizard();
       
   372         break;
       
   373     }
       
   374 
       
   375     case '0': // updates
       
   376     case Qt::Key_Space: // updates
       
   377     {
       
   378         if (mCallTimer->isChecked()) {
       
   379             foreach (TestCall call, mCalls) {
       
   380                 if ( call.callState == BubbleManager::Active ||
       
   381                      call.callState == BubbleManager::OnHold ) {
       
   382                     bubbleManager().updateCallTime(call.bubbleId,"0:01");
       
   383                 }
       
   384             }
       
   385         }
       
   386     }
       
   387     
       
   388     default:
       
   389     break;
       
   390     }
       
   391 }
       
   392 
       
   393 bool BubbleTestView::initializingCallExists() const
       
   394 {
       
   395     bool result = false;
       
   396     foreach(TestCall call, mCalls) {
       
   397         if (call.callState>=BubbleManagerIF::Incoming) {
       
   398             result = true;
       
   399             break;
       
   400         }
       
   401     }
       
   402 
       
   403     return result;
       
   404 }
       
   405 
       
   406 bool BubbleTestView::conferenceCallExists() const
       
   407 {
       
   408     bool result = false;
       
   409     QListIterator<TestCall> i(mCalls);
       
   410     while (i.hasNext()) {
       
   411         if (i.next().isConf) {
       
   412             result = true;
       
   413             break;
       
   414         }
       
   415     }
       
   416     return result;
       
   417 }
       
   418 
       
   419 int BubbleTestView::callCount() const
       
   420 {
       
   421     int count = 0;
       
   422     foreach(TestCall call, mCalls) {
       
   423         if (!call.isInConf) {
       
   424             count++;
       
   425         }
       
   426     }
       
   427 
       
   428     return count;
       
   429 }
       
   430 
       
   431 bool BubbleTestView::callIndexByState(
       
   432     BubbleManagerIF::PhoneCallState state, int& index)
       
   433 {
       
   434     bool result = false;
       
   435     int i = 0;
       
   436     foreach(TestCall call, mCalls) {
       
   437         if (call.callState==state && !call.isInConf) {
       
   438             result = true;
       
   439             index = i;
       
   440             break;
       
   441         }
       
   442         i++;
       
   443     }
       
   444 
       
   445     return result;
       
   446 }
       
   447 
       
   448 bool BubbleTestView::callIndexByBubbleId(int bubbleId, int& index)
       
   449 {
       
   450     bool result = false;
       
   451     int i = 0;
       
   452     foreach(TestCall call, mCalls) {
       
   453         if (call.bubbleId==bubbleId) {
       
   454             result = true;
       
   455             index = i;
       
   456             break;
       
   457         }
       
   458         i++;
       
   459     }
       
   460 
       
   461     return result;
       
   462 }
       
   463 
       
   464 BubbleManagerIF& BubbleTestView::bubbleManager()
       
   465 {
       
   466     return *mBubbleManager;
       
   467 }
       
   468 
       
   469 void BubbleTestView::setBubbleData(int bubble, BubbleManagerIF::PhoneCallState state)
       
   470 {
       
   471     bubbleManager().setState(bubble, state);
       
   472 
       
   473     switch (state) {
       
   474     case BubbleManager::Incoming:
       
   475         {
       
   476         if ( mContactName->isChecked() ) {
       
   477             bubbleManager().setCli(bubble, "Gloria Andersson", Qt::ElideRight);
       
   478             bubbleManager().setSecondaryCli( bubble, "+35850123456789" );
       
   479             mPhoneNumber.clear();
       
   480         } else {
       
   481             mPhoneNumber.append("+35850123456789");
       
   482             bubbleManager().setCli(bubble, mPhoneNumber, Qt::ElideRight);
       
   483         }
       
   484 
       
   485         setCallObject(bubble, ":resources/contactpic.jpg");
       
   486         bubbleManager().setNumberType(bubble, BubbleManager::Mobile);
       
   487         bubbleManager().setCallFlag(bubble, BubbleManager::Diverted, mCallDivert->isChecked());
       
   488         bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked());
       
   489         bubbleManager().setLabel(bubble, "calling", Qt::ElideRight);
       
   490         break;
       
   491         }
       
   492 
       
   493     case BubbleManager::Waiting:
       
   494         {
       
   495         if ( mContactName->isChecked() ) {
       
   496             if (callCount()==2) {
       
   497                 bubbleManager().setCli(bubble, "Mary Poppins", Qt::ElideRight);
       
   498                 bubbleManager().setSecondaryCli(bubble, "+35840987654321");
       
   499             } else {
       
   500                 bubbleManager().setCli(bubble, "John Doe", Qt::ElideRight);
       
   501                 bubbleManager().setSecondaryCli(bubble, "+35840987654321");
       
   502             }
       
   503             mPhoneNumber.clear();
       
   504         } else {
       
   505             if (callCount()==2) {
       
   506                 mPhoneNumber.append("+35850232323232");
       
   507             } else {
       
   508                 mPhoneNumber.append("+35840987654321");
       
   509             }
       
   510             bubbleManager().setCli(bubble, mPhoneNumber, Qt::ElideRight);
       
   511         }
       
   512         setCallObject(bubble, ":resources/contactpic3.png");
       
   513         bubbleManager().setNumberType(bubble, BubbleManager::Mobile);
       
   514         bubbleManager().setCallFlag(bubble, BubbleManager::Diverted, mCallDivert->isChecked());
       
   515         bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked());
       
   516         bubbleManager().setLabel(bubble, "waiting", Qt::ElideRight);
       
   517         break;
       
   518         }
       
   519 
       
   520     case BubbleManager::Outgoing:
       
   521         {
       
   522         bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked());
       
   523 
       
   524         if (mEmergencyCall->isChecked()) {
       
   525             bubbleManager().setCli( bubble, "emergency call", Qt::ElideRight );
       
   526             bubbleManager().setLabel( bubble, "Attempting", Qt::ElideRight );
       
   527         } else {
       
   528             if ( mContactName->isChecked() ) {
       
   529                 bubbleManager().setCli( bubble, "Bart Simpson", Qt::ElideRight );
       
   530                 bubbleManager().setSecondaryCli( bubble, "+35890987654321" );
       
   531                 mPhoneNumber.clear();
       
   532             } else {
       
   533                 mPhoneNumber.append("+35890987654321");
       
   534                 bubbleManager().setCli( bubble, mPhoneNumber, Qt::ElideRight );
       
   535             }
       
   536             setCallObject(bubble, ":resources/contactpic2.jpg");
       
   537             bubbleManager().setLabel( bubble, "Calling", Qt::ElideRight );
       
   538         }
       
   539         break;
       
   540         }
       
   541 
       
   542     case BubbleManager::Alerting:
       
   543         {
       
   544         if ( mPhoneNumber.length() ) {
       
   545             QString cli("Call %1");
       
   546             QString index;
       
   547             index.setNum(bubble+1);
       
   548             cli = cli.arg(index);
       
   549             bubbleManager().setCli( bubble, cli, Qt::ElideRight );
       
   550             bubbleManager().setSecondaryCli( bubble, mPhoneNumber );
       
   551             mPhoneNumber.clear();
       
   552         }
       
   553 
       
   554         if ( mEmergencyCall->isChecked() ) {
       
   555             bubbleManager().setCli( bubble, "Emergency call", Qt::ElideRight );
       
   556         }
       
   557         break;
       
   558         }
       
   559 
       
   560     case BubbleManager::Active:
       
   561         {
       
   562         if ( mPhoneNumber.length() && bubble!=mConfBubbleId ) {
       
   563             QString cli("Call %1");
       
   564             QString index;
       
   565             index.setNum(bubble+1);
       
   566             cli = cli.arg(index);
       
   567             bubbleManager().setCli( bubble, cli, Qt::ElideRight );
       
   568             bubbleManager().setSecondaryCli( bubble, mPhoneNumber );
       
   569             mPhoneNumber.clear();
       
   570         }
       
   571 
       
   572         if ( mCallTimer->isChecked() ) {
       
   573             bubbleManager().setCallTime( bubble, "0:00" );
       
   574         }
       
   575         break;
       
   576         }
       
   577 
       
   578     case BubbleManager::OnHold:
       
   579         {
       
   580         bubbleManager().setLabel( bubble, "on hold", Qt::ElideRight );
       
   581         break;
       
   582         }
       
   583 
       
   584     case BubbleManager::Disconnected:
       
   585         {
       
   586         bubbleManager().setLabel( bubble, "disconnected", Qt::ElideRight );
       
   587         break;
       
   588         }
       
   589 
       
   590     default:
       
   591         {
       
   592         break;
       
   593         }
       
   594     }
       
   595 }
       
   596 
       
   597 void BubbleTestView::setCallObject(int bubble, const QString& filename)
       
   598 {
       
   599     if (mContactPicture->isChecked()) {
       
   600         bubbleManager().setCallObjectImage(bubble, filename);
       
   601     } else {
       
   602         bubbleManager().setCallObjectFromTheme(bubble);
       
   603     }
       
   604 }
       
   605 
       
   606 void BubbleTestView::setBubbleActions(int bubble, BubbleManagerIF::PhoneCallState state )
       
   607 {
       
   608     if (bubble==mConfBubbleId) {
       
   609         // check, if all call are in conference
       
   610         bool swapButton = false;
       
   611         QListIterator<TestCall> calls(mCalls);
       
   612         while(calls.hasNext()) {
       
   613             TestCall call = calls.next();
       
   614             if (!call.isConf && !call.isInConf) {
       
   615                 swapButton = true;
       
   616             }
       
   617         }
       
   618 
       
   619         bubbleManager().clearActions(bubble);
       
   620 
       
   621         if (swapButton) {
       
   622             bubbleManager().addAction(bubble, mSwap);
       
   623         } else {
       
   624             if (state == BubbleManager::OnHold)
       
   625                 bubbleManager().addAction(bubble, mUnhold);
       
   626             else
       
   627                 bubbleManager().addAction(bubble, mHold);
       
   628         }
       
   629 
       
   630         bubbleManager().addAction(bubble, mEndConference);
       
   631         return;
       
   632     }
       
   633 
       
   634     bubbleManager().clearActions(bubble);
       
   635 
       
   636     switch (state) {
       
   637     case BubbleManager::Incoming:
       
   638     case BubbleManager::Waiting:
       
   639         {
       
   640         if (callCount()==2) {
       
   641             bubbleManager().addAction( bubble, mReplace );
       
   642         } else {
       
   643             bubbleManager().addAction( bubble, mAnswer );
       
   644             bubbleManager().addAction( bubble, mReject );
       
   645         }
       
   646         break;
       
   647         }
       
   648     case BubbleManager::Outgoing:
       
   649     case BubbleManager::Alerting: // flow through
       
   650         {
       
   651         bubbleManager().addAction( bubble, mEndCall );
       
   652         break;
       
   653         }
       
   654     case BubbleManager::OnHold:
       
   655         {
       
   656         bubbleManager().addAction( bubble, mUnhold );
       
   657         bubbleManager().addAction( bubble, mEndCall );
       
   658         }
       
   659         break;
       
   660     default: // Active call
       
   661         {
       
   662         HbAction* action;
       
   663 
       
   664         if (!mEmergencyCall->isChecked()) {
       
   665             int i;
       
   666             if ( (mCalls.count()>1 && !callIndexByState(BubbleManagerIF::Waiting,i))
       
   667                   || (mCalls.count()> 1 && mProvideJoin) ) {
       
   668                 action = mJoin;
       
   669             } else {
       
   670                 action = mHold;
       
   671             }
       
   672 
       
   673             bubbleManager().addAction( bubble, action );
       
   674         }
       
   675                     
       
   676         bubbleManager().addAction( bubble, mEndCall );
       
   677         break;
       
   678         }
       
   679     }
       
   680 }
       
   681 
       
   682 void BubbleTestView::setExpandActions()
       
   683 {
       
   684     if (callCount() >= 2) {
       
   685         int i;
       
   686         int j;
       
   687         int heldBubble = -1;
       
   688         if (callIndexByState(BubbleManagerIF::Active,i) &&
       
   689             callIndexByState(BubbleManagerIF::OnHold,j)) {
       
   690             heldBubble = mCalls[j].bubbleId;
       
   691             bubbleManager().setExpandAction(heldBubble, mSwap);
       
   692         } else if (callIndexByState(BubbleManagerIF::Waiting,i) &&
       
   693                    callIndexByState(BubbleManagerIF::OnHold,j)) {
       
   694             heldBubble = mCalls[j].bubbleId;
       
   695             bubbleManager().setExpandAction(heldBubble, mUnhold);
       
   696         }
       
   697 
       
   698         // for rest set update toolbar action
       
   699         QListIterator<TestCall> calls(mCalls);
       
   700         while (calls.hasNext()) {
       
   701             TestCall call = calls.next();
       
   702             if (!call.isInConf && call.bubbleId!=heldBubble) {
       
   703                 bubbleManager().setExpandAction(call.bubbleId, mUpdateUiControls);
       
   704             }
       
   705         }
       
   706     }
       
   707 }
       
   708 
       
   709 void BubbleTestView::answerCall()
       
   710 {
       
   711     QKeyEvent event( QEvent::KeyPress, '3', 0 );
       
   712     keyPressEvent(&event);
       
   713 }
       
   714 
       
   715 void BubbleTestView::endCall()
       
   716 {
       
   717     QKeyEvent event( QEvent::KeyPress, '5', 0 );
       
   718     keyPressEvent(&event);
       
   719     keyPressEvent(&event);
       
   720 }
       
   721 
       
   722 void BubbleTestView::endConferenceCall()
       
   723 {
       
   724     QKeyEvent event( QEvent::KeyPress, '5', 0 );
       
   725     keyPressEvent(&event);
       
   726 }
       
   727 
       
   728 void BubbleTestView::rejectCall()
       
   729 {
       
   730     QKeyEvent event( QEvent::KeyPress, '5', 0 );
       
   731     keyPressEvent(&event);
       
   732     keyPressEvent(&event);
       
   733 }
       
   734 
       
   735 void BubbleTestView::toggleHold()
       
   736 {
       
   737     if (callCount() > 1) {
       
   738         QTimer::singleShot(1000, this, SLOT(toggleHoldDelayed()));
       
   739     } else {
       
   740         QKeyEvent event( QEvent::KeyPress, '4', 0 );
       
   741         keyPressEvent(&event);
       
   742     }
       
   743 }
       
   744 
       
   745 void BubbleTestView::toggleHoldDelayed()
       
   746 {
       
   747     QKeyEvent event( QEvent::KeyPress, '4', 0 );
       
   748     keyPressEvent(&event);
       
   749 }
       
   750 
       
   751 void BubbleTestView::createIncomingCall()
       
   752 {
       
   753     QKeyEvent event( QEvent::KeyPress, '1', 0 );
       
   754     keyPressEvent(&event);
       
   755     setFocus(); // hack because toolbar steals the focus
       
   756 }
       
   757 
       
   758 void BubbleTestView::createOutgoingCall()
       
   759 {
       
   760     QKeyEvent event( QEvent::KeyPress, '2', 0 );
       
   761     keyPressEvent(&event);
       
   762     setFocus(); // hack because toolbar steals the focus
       
   763 }
       
   764 
       
   765 void BubbleTestView::setMuted()
       
   766 {
       
   767     mMuted = !mMuted;
       
   768     updateToolBarActions();
       
   769     bubbleManager().setPhoneMuted( mMuted );
       
   770     setFocus(); // hack because toolbar steals the focus
       
   771 }
       
   772 
       
   773 void BubbleTestView::joinToConference()
       
   774 {
       
   775     QKeyEvent event( QEvent::KeyPress, '7', 0 );
       
   776     keyPressEvent(&event);
       
   777 }
       
   778 
       
   779 void BubbleTestView::handlePrivate()
       
   780 {
       
   781     int i;
       
   782     qDebug() << "Handle private";
       
   783     int selection = bubbleManager().selectionIdInConference();
       
   784     qDebug() << "bubble:" << selection;
       
   785     bubbleManager().startChanges();
       
   786     if (bubbleManager().conferenceRowCount()>2) {
       
   787         bubbleManager().removeRowFromConference(selection);
       
   788         bubbleManager().setExpandedConferenceCallHeader(false);
       
   789         callIndexByBubbleId(selection,i);
       
   790         mCalls[i].isInConf = false;
       
   791         setBubbleActions(mCalls[i].bubbleId,BubbleManagerIF::Active);
       
   792         setBubbleData(mConfBubbleId,BubbleManagerIF::OnHold);
       
   793         setExpandActions();
       
   794     } else {
       
   795         bubbleManager().removeConference();
       
   796         callIndexByBubbleId(mConfBubbleId,i);
       
   797         mCalls.removeAt(i);
       
   798         mConfBubbleId = -1;
       
   799         callIndexByBubbleId(selection,i);
       
   800         int held = (i==0) ? 1 : 0;
       
   801         setBubbleActions(selection,BubbleManagerIF::Active);
       
   802         setBubbleData(selection,BubbleManagerIF::Active);
       
   803         setBubbleActions(held,BubbleManagerIF::OnHold);
       
   804         setBubbleData(held,BubbleManagerIF::OnHold);
       
   805         mCalls[0].isInConf = false;
       
   806         mCalls[1].isInConf = false;
       
   807         setExpandActions();
       
   808     }
       
   809     bubbleManager().endChanges();
       
   810 }
       
   811 
       
   812 void BubbleTestView::handleDrop()
       
   813 {
       
   814     int i;
       
   815     qDebug() << "Handle drop";
       
   816     int selection = bubbleManager().selectionIdInConference();
       
   817     qDebug() << "bubble:" << selection;
       
   818     bubbleManager().startChanges();
       
   819     if (bubbleManager().conferenceRowCount()>2) {
       
   820         bubbleManager().removeRowFromConference(selection);
       
   821         bubbleManager().removeCallHeader(selection);
       
   822         callIndexByBubbleId(selection,i);
       
   823         mCalls.removeAt(i);
       
   824     } else {
       
   825         bubbleManager().removeConference();
       
   826         callIndexByBubbleId(mConfBubbleId,i);
       
   827         mCalls.removeAt(i);
       
   828         mConfBubbleId = -1;
       
   829         bubbleManager().removeCallHeader(selection);
       
   830         callIndexByBubbleId(selection,i);
       
   831         mCalls.removeAt(i);
       
   832         mCalls[0].isInConf = false;
       
   833         setBubbleActions(mCalls[0].bubbleId,BubbleManagerIF::Active);
       
   834         setExpandActions();
       
   835     }
       
   836     bubbleManager().endChanges();
       
   837 }
       
   838 
       
   839 void BubbleTestView::replaceActiveCall()
       
   840 {
       
   841     QKeyEvent event( QEvent::KeyPress, '3', 0 );
       
   842     keyPressEvent(&event);
       
   843 }
       
   844 
       
   845 void BubbleTestView::updateUiControls()
       
   846 {
       
   847     if (conferenceCallExists()) {
       
   848         bubbleManager().startChanges();
       
   849         bubbleManager().setExpandedConferenceCallHeader(
       
   850             bubbleManager().expandedBubble()==mConfBubbleId );
       
   851         bubbleManager().endChanges();
       
   852     }
       
   853 
       
   854     updateToolBarActions();
       
   855 }
       
   856 
       
   857 void BubbleTestView::createToolBarActions()
       
   858 {
       
   859     mCallIn = new HbAction("Call in", this);
       
   860     connect( mCallIn, SIGNAL(triggered()), this, SLOT(createIncomingCall()), Qt::QueuedConnection );
       
   861 
       
   862     mCallOut = new HbAction("Call out", this);
       
   863     connect( mCallOut, SIGNAL(triggered()), this, SLOT(createOutgoingCall()), Qt::QueuedConnection );
       
   864 
       
   865     mMute = new HbAction(HbIcon("qtg_mono_mic_mute"), "", this);
       
   866     connect( mMute, SIGNAL(triggered()), this, SLOT(setMuted()), Qt::QueuedConnection );
       
   867 
       
   868     mUnmute = new HbAction(HbIcon("qtg_mono_mic_unmute"), "", this);
       
   869     connect( mUnmute, SIGNAL(triggered()), this, SLOT(setMuted()), Qt::QueuedConnection );
       
   870 
       
   871     // not connected to anywhere
       
   872     mActivateLoudspeaker = new HbAction(HbIcon("qtg_mono_speaker"), "", this);
       
   873     mActivateHandset = new HbAction(HbIcon("qtg_mono_mobile"), "", this);
       
   874     mSendMessage = new HbAction(HbIcon("qtg_mono_send"), "", this);
       
   875     mSilence = new HbAction(HbIcon("qtg_mono_speaker_off"), "", this);
       
   876     mOpenDialer = new HbAction(HbIcon("qtg_mono_dialer"), "", this);
       
   877     mOpenContacts = new HbAction(HbIcon("qtg_mono_contacts"), "", this);
       
   878 
       
   879     updateToolBarActions();
       
   880 }
       
   881 
       
   882 void BubbleTestView::createMenuActions()
       
   883 {
       
   884     // HbMenu* typeMenu = menu()->addMenu("Call type"); current submenu layout sucks
       
   885     menu()->addAction("Switch orientation",this,SLOT(switchOrientation()));
       
   886     mCallDivert = menu()->addAction("Diverted call");
       
   887     mCallTimer = menu()->addAction("Call timer");
       
   888     mContactName = menu()->addAction("Contact name");
       
   889     mContactPicture = menu()->addAction("Contact picture");
       
   890     mCipheringOff = menu()->addAction("Ciphering off");
       
   891     mEmergencyCall = menu()->addAction( "Emergency call" );    
       
   892     HbAction* exit = menu()->addAction( "Exit" );
       
   893     mCallDivert->setCheckable(true);
       
   894     mCallTimer->setCheckable(true);
       
   895     mContactPicture->setCheckable(true);
       
   896     mContactName->setCheckable(true);
       
   897     mCipheringOff->setCheckable(true);
       
   898     mEmergencyCall->setCheckable(true);
       
   899     connect( exit, SIGNAL(triggered()), qApp, SLOT(quit()) );
       
   900 }
       
   901 
       
   902 void BubbleTestView::updateToolBarActions()
       
   903 {
       
   904     toolBar()->clearActions();
       
   905 
       
   906     if (!mCalls.count()) {
       
   907         toolBar()->addAction(mCallIn);
       
   908         toolBar()->addAction(mCallOut);
       
   909         return;
       
   910     }
       
   911 
       
   912     int bubble = bubbleManager().expandedBubble();
       
   913     int i;
       
   914     callIndexByBubbleId(bubble,i);
       
   915     int state = mCalls[i].callState;
       
   916 
       
   917     if ( state == BubbleManagerIF::Incoming ||
       
   918          state == BubbleManagerIF::Waiting ) {
       
   919         toolBar()->addAction(mSendMessage);
       
   920         toolBar()->addAction(mSilence);
       
   921     } else {
       
   922         toolBar()->addAction(mOpenDialer);
       
   923         if (!mMuted) {
       
   924             toolBar()->addAction(mMute);
       
   925         } else if (mMuted) {
       
   926             toolBar()->addAction(mUnmute);
       
   927         }
       
   928         toolBar()->addAction(mActivateLoudspeaker);
       
   929         toolBar()->addAction(mOpenContacts);
       
   930     }
       
   931 }
       
   932 
       
   933 void BubbleTestView::createBubbleActions()
       
   934 {
       
   935     mAnswer = new HbAction( HbIcon("qtg_mono_call"),"Answer", this);
       
   936     mAnswer->setSoftKeyRole(QAction::PositiveSoftKey);
       
   937     connect( mAnswer, SIGNAL( triggered() ), this, SLOT( answerCall() ) );
       
   938 
       
   939     mReject= new HbAction( HbIcon("qtg_mono_reject_call"),"Reject", this);
       
   940     mReject->setSoftKeyRole(QAction::NegativeSoftKey);
       
   941     connect( mReject, SIGNAL( triggered() ), this, SLOT( rejectCall() ) );
       
   942 
       
   943     mHold = new HbAction( HbIcon("qtg_mono_hold_call"),"Hold", this);
       
   944     connect( mHold, SIGNAL( triggered() ), this, SLOT( toggleHold() ) );
       
   945 
       
   946     mUnhold = new HbAction( HbIcon("qtg_mono_call"),"Activate", this);
       
   947     connect( mUnhold, SIGNAL( triggered() ), this, SLOT( toggleHold() ) );
       
   948 
       
   949     mSwap = new HbAction( HbIcon("qtg_mono_hold_call"),"Swap", this);
       
   950     connect( mSwap, SIGNAL( triggered() ), this, SLOT( toggleHold() ) );
       
   951 
       
   952     mEndCall = new HbAction(HbIcon("qtg_mono_end_call"),"End call", this);
       
   953     mEndCall->setSoftKeyRole(QAction::NegativeSoftKey);
       
   954     connect( mEndCall, SIGNAL( triggered() ), this, SLOT( endCall() ) );
       
   955 
       
   956     mEndConference = new HbAction(HbIcon("qtg_mono_end_all_call"),"End conference", this);
       
   957     mEndConference->setSoftKeyRole(QAction::NegativeSoftKey);
       
   958     connect( mEndConference, SIGNAL( triggered() ), this, SLOT( endConferenceCall() ) );
       
   959 
       
   960     mJoin = new HbAction(HbIcon("qtg_mono_join_call"),"Join", this);
       
   961     connect( mJoin, SIGNAL( triggered() ), this, SLOT(joinToConference()) );
       
   962 
       
   963     mPrivate = new HbAction(HbIcon("qtg_mono_private_call"),"Private", this);
       
   964     connect( mPrivate, SIGNAL( triggered() ), this, SLOT(handlePrivate()) );
       
   965 
       
   966     mDrop = new HbAction(HbIcon("qtg_mono_drop_call"),"Drop", this);
       
   967     connect( mDrop, SIGNAL( triggered() ), this, SLOT(handleDrop()) );
       
   968 
       
   969     mReplace = new HbAction(HbIcon("qtg_mono_replace_call"),"Replace", this);
       
   970     connect( mReplace, SIGNAL( triggered() ), this, SLOT(replaceActiveCall()) );
       
   971 
       
   972     mUpdateUiControls = new HbAction(QString(), this);
       
   973     connect( mUpdateUiControls, SIGNAL(triggered()), this, SLOT(updateUiControls()) );
       
   974 }
       
   975 
       
   976 int BubbleTestView::bubbleIdByState(BubbleManagerIF::PhoneCallState state)
       
   977 {
       
   978     int bubbleId=-1;
       
   979     foreach(TestCall call, mCalls) {
       
   980         if ((call.callState==state) && !call.isInConf) {
       
   981             bubbleId = call.bubbleId;
       
   982             break;
       
   983         }
       
   984     }
       
   985 
       
   986     return bubbleId;
       
   987 }
       
   988 
       
   989 void BubbleTestView::conferenceWizard() {
       
   990     bubbleManager().startChanges();
       
   991 
       
   992     for (int i=0; i<5; i++) {
       
   993         sendKeyEvent('1');
       
   994         sendKeyEvent('3');
       
   995         sendKeyEvent('7');
       
   996     }
       
   997 
       
   998     bubbleManager().endChanges();
       
   999 }
       
  1000 
       
  1001 void BubbleTestView::sendKeyEvent(int key)
       
  1002 {
       
  1003     QKeyEvent event( QEvent::KeyPress, key, 0 );
       
  1004     keyPressEvent(&event);
       
  1005 }
       
  1006 
       
  1007 void BubbleTestView::switchOrientation()
       
  1008 {
       
  1009     if (mMainWindow.orientation()==Qt::Vertical) {
       
  1010         mMainWindow.setOrientation(Qt::Horizontal);
       
  1011 
       
  1012     } else {
       
  1013         mMainWindow.setOrientation(Qt::Vertical);
       
  1014     }
       
  1015 }
       
  1016 
       
  1017 void BubbleTestView::handleOrientationChange(Qt::Orientation orientation)
       
  1018 {
       
  1019     if (orientation==Qt::Horizontal) {
       
  1020         toolBar()->setOrientation(Qt::Horizontal);
       
  1021     }
       
  1022 
       
  1023     mBubbleManager->handleOrientationChange(orientation);
       
  1024 }
       
  1025 
       
  1026 void BubbleTestView::toggleHoldConference()
       
  1027 {
       
  1028     int i;
       
  1029     if (callIndexByBubbleId(mConfBubbleId, i) ) {
       
  1030         BubbleManagerIF::PhoneCallState state =
       
  1031             (mCalls[i].callState == BubbleManagerIF::Active) ?
       
  1032             BubbleManagerIF::OnHold : BubbleManagerIF::Active;
       
  1033         bubbleManager().startChanges();
       
  1034         setBubbleData(mCalls[i].bubbleId, state);
       
  1035         setBubbleActions(mCalls[i].bubbleId, state );
       
  1036         qDebug() << "toggleHoldConference:" << state;
       
  1037         mCalls[i].callState=state;
       
  1038         bubbleManager().endChanges();
       
  1039         // update participants
       
  1040         QTimer::singleShot(500, this, SLOT(toggleConferenceHoldDelayed()));
       
  1041     }
       
  1042 }
       
  1043 
       
  1044 void BubbleTestView::toggleConferenceHoldDelayed()
       
  1045 {
       
  1046     int i;
       
  1047     callIndexByBubbleId(mConfBubbleId, i);
       
  1048     BubbleManagerIF::PhoneCallState confState =
       
  1049         (BubbleManagerIF::PhoneCallState)mCalls[i].callState;
       
  1050     qDebug() << "toggleConferenceHoldDelayed state:" << confState;
       
  1051 
       
  1052     QListIterator<TestCall> calls(mCalls);
       
  1053     int j=0;
       
  1054     while(calls.hasNext()) {
       
  1055         TestCall call = calls.next();
       
  1056         qDebug() << "toggleConferenceHoldDelayed callState:" << call.callState;
       
  1057         if (call.isInConf && call.callState!=confState) {
       
  1058             bubbleManager().startChanges();
       
  1059             setBubbleData(call.bubbleId, confState);
       
  1060             setBubbleActions(call.bubbleId, confState);
       
  1061             mCalls[j].callState=confState;
       
  1062             bubbleManager().endChanges();
       
  1063             // next
       
  1064             QTimer::singleShot(500, this, SLOT(toggleConferenceHoldDelayed()));
       
  1065             break;
       
  1066         }
       
  1067         j++;
       
  1068     }
       
  1069 }
       
  1070 
       
  1071 void BubbleTestView::connectToTester()
       
  1072 {
       
  1073     mBubbleTester->connectToServer();
       
  1074 }
       
  1075 
       
  1076 void BubbleTestView::handleTesterDataChanged()
       
  1077 {
       
  1078     bubbleManager().startChanges();
       
  1079 
       
  1080     QString mute = mBubbleTester->dataField("mute");
       
  1081     bubbleManager().setPhoneMuted( mute == "On" );
       
  1082 
       
  1083     QList<QString> testBubbles = mBubbleTester->bubbles();
       
  1084 
       
  1085     foreach (QString bubbleId, testBubbles) {
       
  1086         QString state = mBubbleTester->dataField(bubbleId,"state");
       
  1087 
       
  1088         // create or remove bubble
       
  1089         if ( mTestBubbleIds.contains(bubbleId) && state=="Idle" ) {
       
  1090             bubbleManager().removeCallHeader(mTestBubbleIds.value(bubbleId));
       
  1091             mTestBubbleIds.remove(bubbleId);
       
  1092         } else if (!mTestBubbleIds.contains(bubbleId) && state!="Idle" ) {
       
  1093             int id = bubbleManager().createCallHeader();
       
  1094             mTestBubbleIds.insert(bubbleId,id);
       
  1095         }
       
  1096 
       
  1097         // set data
       
  1098         if (mTestBubbleIds.contains(bubbleId)) {
       
  1099             int id = mTestBubbleIds.value(bubbleId);
       
  1100 
       
  1101             QString name = mBubbleTester->dataField(bubbleId,"name");
       
  1102             QString number = mBubbleTester->dataField(bubbleId,"number");
       
  1103             QString divert = mBubbleTester->dataField(bubbleId,"divert");
       
  1104 
       
  1105             bubbleManager().setState(id, mStateMap.value(state));
       
  1106             bubbleManager().setCli(id, name, Qt::ElideRight);
       
  1107             bubbleManager().setSecondaryCli(id, number );
       
  1108             bubbleManager().setLabel(id, mLabelMap.value(state), Qt::ElideRight);
       
  1109 
       
  1110             bubbleManager().setCallFlag(id, BubbleManager::Diverted, (divert == "On") );
       
  1111 
       
  1112             setCallObject(id,":resources/contactpic.jpg");
       
  1113 
       
  1114             setBubbleActions(id, mStateMap.value(state) );
       
  1115         }
       
  1116     }
       
  1117 
       
  1118     bubbleManager().endChanges();
       
  1119 }