Revision: 201033 RCL_3 PDK_3.0.3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 21:23:32 +0300
branchRCL_3
changeset 37 590f6f022902
parent 35 779871d1e4f4
child 40 7fb4a99d4b6b
Revision: 201033 Kit: 201035
vtuis/videotelui/data/videotelui.rss
vtuis/videotelui/inc/cvtuidtmfbuffer.h
vtuis/videotelui/inc/features/dialer/cvtuidialercontainer.h
vtuis/videotelui/src/cvtuidtmfbuffer.cpp
vtuis/videotelui/src/features/dialer/cvtuidialercontainer.cpp
--- a/vtuis/videotelui/data/videotelui.rss	Wed Sep 01 12:29:12 2010 +0100
+++ b/vtuis/videotelui/data/videotelui.rss	Tue Sep 14 21:23:32 2010 +0300
@@ -1761,6 +1761,35 @@
         {
         CBA_BUTTON
             {
+            id = EAknSoftkeyEmpty;
+            txt = text_softkey_empty;
+            },
+        CBA_BUTTON
+            {
+            id = EVtUiDialerExit;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id = EAknSoftkeyEmpty;
+            txt = text_softkey_empty;
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_videotelui_softkeys_emergcall_dialerexit
+// Dialer softkeys
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE CBA r_videotelui_softkeys_emergcall_dialerexit
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
             id = EVtUiCmdDialerEmergencyCall;
             txt = qtn_incal_softk_emergency_call;
             },
--- a/vtuis/videotelui/inc/cvtuidtmfbuffer.h	Wed Sep 01 12:29:12 2010 +0100
+++ b/vtuis/videotelui/inc/cvtuidtmfbuffer.h	Tue Sep 14 21:23:32 2010 +0300
@@ -29,12 +29,28 @@
 const TInt KVtUiDTMFBufferSize = 64;
 
 /**
-*  TVtUiBaseComponentState
+*  MVtUiDTMFBufferObserver
+*
+*  Observer of DTMF chaning.
+*/
+
+class MVtUiDTMFBufferObserver
+    {
+public:
+    /*
+     * Buffer changed callback
+     */
+    virtual void NotifyDTMFBufferChangedL() = 0;
+    };
+    
+/**
+*  CVtUiDTMFBuffer
 *
 *  Base componentstate definition.
 *
 *  @since S60 v5.0
 */
+
 class CVtUiDTMFBuffer : public CActive, public MVtUiNumberSource
     {
 
@@ -48,6 +64,14 @@
     static CVtUiDTMFBuffer* NewL( const CCoeEnv& aCoeEnv );
 
     /**
+    * Static construction method.
+    * @param aCoeEnv Reference to CoeEnv object.
+    * @param aObserver Pointer to buffer observer
+    * @return Pointer to newly created instance of CVtUiDTMFBuffer.
+    */
+    static CVtUiDTMFBuffer* NewL( const CCoeEnv& aCoeEnv, MVtUiDTMFBufferObserver* aObserver );
+
+    /**
     * C++ destructor.
     */
     ~CVtUiDTMFBuffer();
@@ -99,6 +123,11 @@
     * C++ constructor
     */
     CVtUiDTMFBuffer( const CCoeEnv& aCoeEnv );
+    
+    /**
+    * C++ constructor
+    */
+    CVtUiDTMFBuffer( const CCoeEnv& aCoeEnv, MVtUiDTMFBufferObserver* aObserver );
 
     /**
     * 2nd constructor, may leave.
@@ -132,6 +161,9 @@
 
     // DTMF buffer
     TBuf< KVtUiDTMFBufferSize > iBuffer;
+    
+    // DTMF buffer observer
+    MVtUiDTMFBufferObserver* iObserver;
 
     };
 
--- a/vtuis/videotelui/inc/features/dialer/cvtuidialercontainer.h	Wed Sep 01 12:29:12 2010 +0100
+++ b/vtuis/videotelui/inc/features/dialer/cvtuidialercontainer.h	Tue Sep 14 21:23:32 2010 +0300
@@ -20,12 +20,16 @@
 #define C_VTUIDIALERCONTAINER_H
 
 #include    <coecntrl.h>
+#include    <CPhCltEmergencyCall.h>
+#include    <RPhCltServer.h>
+#include    <MPhCltEmergencyCallObserver.h>
 #include    "CVtUiAppUi.h"
 #include    "mvtuicomponent.h"
 #include    "mvtuiresourcechangeobserver.h"
 #include    "mvtuikeyeventobserver.h"
 #include    "mvtuinumbersource.h"
 #include    "tvtuicomponentstate.h"
+#include    "cvtuidtmfbuffer.h"
 
 // FORWARD DECLARATIONS
 class MVtUiVideoWindow;
@@ -69,8 +73,12 @@
  *  @since S60 v5.0
  */
 class CVtUiDialerContainer : public CCoeControl,
-    public MVtUiResourceChangeObserver, public MVtUiComponent,
-    public MVtUiNumberSource, public MVtUiKeyEventObserver
+                             public MVtUiResourceChangeObserver, 
+                             public MVtUiComponent,
+                             public MVtUiNumberSource, 
+                             public MVtUiKeyEventObserver,
+                             public MVtUiDTMFBufferObserver,
+                             private MPhCltEmergencyCallObserver
     {
 
 public:
@@ -157,6 +165,18 @@
      */
     TKeyResponse OfferKeyEventL( const TKeyEvent& aEvent,
         TEventCode aCode );
+    
+private: // from MPhCltEmergencyCallObserver       
+    /**
+     * @see  MPhCltEmergencyCallObserver::HandleEmergencyDialL
+     */
+    virtual void HandleEmergencyDialL( const TInt aStatus );
+    
+private: // from MVtUiDTMFBufferObserver
+    /**
+     * @see MVtUiDTMFBufferObserver::NotifyDTMFBufferChanged
+     */
+    virtual void NotifyDTMFBufferChangedL();
 
 private: // from CCoeControl
 
@@ -257,6 +277,12 @@
 
     // Owned: background context.
     CAknsBasicBackgroundControlContext* iBgContext;
+    
+    // Phone Server session
+    RPhCltServer          iServer;
+    
+    // Emergency call handler
+    CPhCltEmergencyCall*  iEmergency;
 
     };
 
--- a/vtuis/videotelui/src/cvtuidtmfbuffer.cpp	Wed Sep 01 12:29:12 2010 +0100
+++ b/vtuis/videotelui/src/cvtuidtmfbuffer.cpp	Tue Sep 14 21:23:32 2010 +0300
@@ -41,6 +41,21 @@
     }
 
 // ---------------------------------------------------------------------------
+// CVtUiDTMFBuffer::NewL
+// ---------------------------------------------------------------------------
+//
+CVtUiDTMFBuffer* CVtUiDTMFBuffer::NewL( const CCoeEnv& aCoeEnv, MVtUiDTMFBufferObserver* aObserver )
+    {
+    __VTPRINTENTER( "CVtUiDTMFBuffer.NewL" )
+    CVtUiDTMFBuffer* self = new ( ELeave ) CVtUiDTMFBuffer( aCoeEnv, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    __VTPRINTEXIT( "CVtUiDTMFBuffer.NewL" )
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
 // CVtUiDTMFBuffer::~CVtUiDTMFBuffer
 // ---------------------------------------------------------------------------
 //
@@ -67,6 +82,10 @@
             iBuffer = iBuffer.Right( 1 );
             }
         iBuffer.Append( aChar );
+        if ( iObserver )
+            {
+            iObserver->NotifyDTMFBufferChangedL();
+            }
         StartTimer();
         result = ETrue;
         }
@@ -169,6 +188,18 @@
     }
 
 // ---------------------------------------------------------------------------
+// CVtUiDTMFBuffer::CVtUiDTMFBuffer
+// ---------------------------------------------------------------------------
+//
+CVtUiDTMFBuffer::CVtUiDTMFBuffer( const CCoeEnv& aCoeEnv, MVtUiDTMFBufferObserver* aObserver ) :
+    CActive( EPriorityStandard ), iCoeEnv( aCoeEnv ), iObserver( aObserver )
+    {
+    __VTPRINTENTER( "CVtUiDTMFBuffer.ctor" )
+    CActiveScheduler::Add( this );
+    __VTPRINTEXIT( "CVtUiDTMFBuffer.ctor" )
+    }
+
+// ---------------------------------------------------------------------------
 // CVtUiDTMFBuffer::ConstructL
 // ---------------------------------------------------------------------------
 //
@@ -214,5 +245,9 @@
     {
     __VTPRINTENTER( "CVtUiDTMFBuffer.ResetBuffer" )
     iBuffer.Zero();
+    if ( iObserver )
+        {
+        iObserver->NotifyDTMFBufferChangedL();
+        }
     __VTPRINTEXIT( "CVtUiDTMFBuffer.ResetBuffer" )
     }
--- a/vtuis/videotelui/src/features/dialer/cvtuidialercontainer.cpp	Wed Sep 01 12:29:12 2010 +0100
+++ b/vtuis/videotelui/src/features/dialer/cvtuidialercontainer.cpp	Tue Sep 14 21:23:32 2010 +0300
@@ -27,6 +27,7 @@
 #include    <AknsBasicBackgroundControlContext.h>
 #include    <akntoolbar.h>
 
+#include    <videotelui.rsg>
 #include    "VtUiUtility.h"
 #include    "VtUiLayout.h"
 #include    "mvtuicomponentmanager.h"
@@ -90,6 +91,9 @@
 CVtUiDialerContainer::~CVtUiDialerContainer()
     {
     __VTPRINTENTER( "DialContainer.~" )
+    delete iEmergency;
+    iServer.Close();    
+        
     delete iAsyncDeactivate;
     delete iVideoControl;
     delete iDialer;
@@ -360,7 +364,7 @@
     SetExtent( TPoint(), TSize() );
     ActivateL();
     MakeVisible( EFalse );
-    iInputBuffer = CVtUiDTMFBuffer::NewL( *iCoeEnv );
+    iInputBuffer = CVtUiDTMFBuffer::NewL( *iCoeEnv, this );
     iVideoControl = CVtUiDialerVideoControl::NewL( aBitmapManager );
     iDialer = CVideoDTMFDialer::NewL( *this, *iVideoControl, DialerRect() );
     
@@ -372,6 +376,10 @@
         }
     iAsyncDeactivate = new ( ELeave ) CAsyncCallBack(
         TCallBack( ASyncDoDeactivate, this ), CActive::EPriorityLow );
+    
+    // PhClt initialization
+    User::LeaveIfError( iServer.Connect() );
+    iEmergency = CPhCltEmergencyCall::NewL( this );
     __VTPRINTEXIT( "DialContainer.ConstructL" )
     }
 
@@ -504,17 +512,17 @@
 // ---------------------------------------------------------------------------
 //
 TTypeUid::Ptr CVtUiDialerContainer::MopSupplyObject( TTypeUid aId )
- {
+    {
      __VTPRINTENTER( "CVtUiDialerContainer.MopSupplyObject" )
- // Required during rendering of the background skin in Draw()
- if (aId.iUid == MAknsControlContext::ETypeId)
-     {
-      __VTPRINTEXIT( "CVtUiDialerContainer.MopSupplyObject.1" )
-     return MAknsControlContext::SupplyMopObject( aId, iBgContext );
-     }
+    // Required during rendering of the background skin in Draw()
+    if (aId.iUid == MAknsControlContext::ETypeId)
+        {
+        __VTPRINTEXIT( "CVtUiDialerContainer.MopSupplyObject.1" )
+        return MAknsControlContext::SupplyMopObject( aId, iBgContext );
+        }
     __VTPRINTEXIT( "CVtUiDialerContainer.MopSupplyObject.2" )
- return CCoeControl::MopSupplyObject( aId );
- }
+    return CCoeControl::MopSupplyObject( aId );
+    }
 
 // ---------------------------------------------------------------------------
 // CVtUiDialerContainer::ASyncDoDeactivate
@@ -533,3 +541,75 @@
     __VTPRINTEXIT( "DialContainer.ASyncDoDeactivate" )
     return KErrNone;
     }
+
+// -----------------------------------------------------------------------------
+// CVtUiDialerContainer::HandleEmergencyDialL
+// -----------------------------------------------------------------------------
+//
+void CVtUiDialerContainer::HandleEmergencyDialL(
+    const TInt )
+    {
+    __VTPRINTENTER( "CVtUiDialerContainer.HandleEmergencyDialL" )
+    // do nothing
+    __VTPRINTEXIT( "CVtUiDialerContainer.HandleEmergencyDialL" )
+    }
+
+// -----------------------------------------------------------------------------
+// CVtUiDialerContainer::NotifyDTMFBufferChanged
+// -----------------------------------------------------------------------------
+//
+void CVtUiDialerContainer::NotifyDTMFBufferChangedL()
+    {
+    __VTPRINTENTER( "CVtUiDialerContainer.NotifyDTMFBufferChanged" )
+    CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
+    
+    // Get the buffer
+    TBuf<KVtUiDTMFBufferSize> dtmfBuffer;
+    GetContents( dtmfBuffer );
+    
+    // If buffer is empty
+    if ( !dtmfBuffer.Length() )
+        {
+        __VTPRINT( DEBUG_GEN, "CVtUiDialerContainer.NotifyDTMFBufferChanged, buffer is emtpy")
+        cba->SetCommandSetL( R_VIDEOTELUI_SOFTKEYS_EMPTY_DIALEREXIT );
+        }
+    else
+        {
+        // First we have to see if current buffer is a EC number
+        AknTextUtils::ConvertDigitsTo( dtmfBuffer, EDigitTypeWestern );
+        if ( !iEmergency )
+            {
+            iEmergency = CPhCltEmergencyCall::NewL( this );
+            }
+        TBool isEmergencyNumber = EFalse;
+        const TInt err =
+            iEmergency->FindEmergencyPhoneNumber( dtmfBuffer, isEmergencyNumber );
+        
+        __VTPRINT3( DEBUG_GEN, 
+                "CVtUiDialerContainer.NotifyDTMFBufferChanged, err=%d, isEC=%d",
+                err, isEmergencyNumber )
+        
+        // No error and It's EC number
+        if ( err == KErrNone && isEmergencyNumber )
+            {
+            __VTPRINT( DEBUG_GEN, "CVtUiDialerContainer.NotifyDTMFBufferChanged, is EC")
+            // change CBA to 'EC-Back'
+            cba->SetCommandSetL( R_VIDEOTELUI_SOFTKEYS_EMERGCALL_DIALEREXIT );
+            }
+        // Error happened, but it's EC number
+        else if ( err != KErrNone && isEmergencyNumber )
+            {
+            __VTPRINT( DEBUG_GEN, "CVtUiDialerContainer.NotifyDTMFBufferChanged, err happened")
+            cba->SetCommandSetL( R_VIDEOTELUI_SOFTKEYS_EMPTY_DIALEREXIT );
+            }
+        else // not EC number and we don't care about the error
+            {
+            __VTPRINT( DEBUG_GEN, "CVtUiDialerContainer.NotifyDTMFBufferChanged, not EC")
+            // change CBA to digitl we have on hand
+            // but at the moment we dont need this, so comment it out
+            //cba->SetCommandL( EAknSoftkeyEmpty, dtmfBuffer );
+            }
+        }
+    cba->DrawNow();
+    __VTPRINTEXIT( "CVtUiDialerContainer.NotifyDTMFBufferChanged" )
+    }