qtms/src/qtmsdtmfimpl.cpp
changeset 27 cbb1bfb7ebfb
child 32 edd273b3192a
equal deleted inserted replaced
25:d881023c13eb 27:cbb1bfb7ebfb
       
     1 /*
       
     2  * Copyright (c) 2010 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: QT Bindings for TMS
       
    15  *
       
    16  */
       
    17 
       
    18 #include <tmsdtmf.h>
       
    19 #include "tmsutility.h"
       
    20 #include "qtmsdtmfimpl.h"
       
    21 
       
    22 using namespace QTMS;
       
    23 using namespace TMS;
       
    24 
       
    25 QTMSDTMFImpl::QTMSDTMFImpl()
       
    26     {
       
    27     }
       
    28 
       
    29 QTMSDTMFImpl::~QTMSDTMFImpl()
       
    30     {
       
    31     RemoveObserver(*this);
       
    32     }
       
    33 
       
    34 gint QTMSDTMFImpl::Create(QTMSDTMF*& qdtmf, TMS::TMSDTMF*& tmsdtmf)
       
    35     {
       
    36     gint ret(TMS_RESULT_INSUFFICIENT_MEMORY);
       
    37     QTMSDTMFImpl* self = new QTMSDTMFImpl();
       
    38     if (self)
       
    39         {
       
    40         ret = self->PostConstruct();
       
    41         if (ret != QTMS_RESULT_SUCCESS)
       
    42             {
       
    43             delete self;
       
    44             self = NULL;
       
    45             }
       
    46         self->iDtmf = tmsdtmf;
       
    47         ret = self->AddObserver(*self, NULL);
       
    48         }
       
    49     qdtmf = self;
       
    50     return ret;
       
    51     }
       
    52 
       
    53 gint QTMSDTMFImpl::PostConstruct()
       
    54     {
       
    55     gint ret(QTMS_RESULT_SUCCESS);
       
    56     return ret;
       
    57     }
       
    58 
       
    59 gint QTMSDTMFImpl::AddObserver(TMS::TMSDTMFObserver& obsrvr,
       
    60         gpointer /*user_data*/)
       
    61     {
       
    62     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    63 
       
    64     if (iDtmf)
       
    65         {
       
    66         ret = iDtmf->AddObserver(obsrvr, NULL);
       
    67         }
       
    68     return ret;
       
    69     }
       
    70 
       
    71 gint QTMSDTMFImpl::RemoveObserver(TMS::TMSDTMFObserver& obsrvr)
       
    72     {
       
    73     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    74 
       
    75     if (iDtmf)
       
    76         {
       
    77         ret = iDtmf->RemoveObserver(obsrvr);
       
    78         }
       
    79     return ret;
       
    80     }
       
    81 
       
    82 void QTMSDTMFImpl::DTMFEvent(const TMS::TMSDTMF& /*dtmf*/,
       
    83         TMS::TMSSignalEvent event)
       
    84     {
       
    85     QTMSSignalEvent qevent;
       
    86 
       
    87     qevent.type = event.type;
       
    88     qevent.reason = event.reason;
       
    89     qevent.curr_state = event.curr_state;
       
    90     qevent.prev_state = event.prev_state;
       
    91     qevent.event_data = event.event_data;
       
    92     qevent.user_data = event.user_data;
       
    93 
       
    94     emit QTMS::QTMSDTMF::DTMFEvent(static_cast<QTMSDTMF&> (*this), qevent);
       
    95     }
       
    96 
       
    97 // End of file