qtms/src/qtmsringtoneimpl.cpp
branchRCL_3
changeset 56 63223d4fd956
parent 55 6c1dfe4da5dd
child 59 666f9a5a90a9
equal deleted inserted replaced
55:6c1dfe4da5dd 56:63223d4fd956
     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 <tmsringtone.h>
       
    19 #include <qtmseffect.h>
       
    20 #include "tmsutility.h"
       
    21 #include "qtmsringtoneimpl.h"
       
    22 
       
    23 using namespace QTMS;
       
    24 using namespace TMS;
       
    25 
       
    26 QTMSRingToneImpl::QTMSRingToneImpl()
       
    27 {
       
    28 }
       
    29 
       
    30 QTMSRingToneImpl::~QTMSRingToneImpl()
       
    31 {
       
    32     RemoveObserver(*this);
       
    33 }
       
    34 
       
    35 gint QTMSRingToneImpl::Create(QTMSRingTone*& qrt, TMS::TMSRingTone*& tmsrt)
       
    36 {
       
    37     gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
       
    38     QTMSRingToneImpl* self = new QTMSRingToneImpl();
       
    39     if (self) {
       
    40         ret = self->PostConstruct();
       
    41         if (ret != QTMS_RESULT_SUCCESS) {
       
    42             delete self;
       
    43             self = NULL;
       
    44         }
       
    45         self->iRingTone = tmsrt;
       
    46         ret = self->AddObserver(*self, NULL);
       
    47     }
       
    48     qrt = self;
       
    49     return ret;
       
    50 }
       
    51 
       
    52 gint QTMSRingToneImpl::PostConstruct()
       
    53 {
       
    54     gint ret(QTMS_RESULT_SUCCESS);
       
    55     return ret;
       
    56 }
       
    57 
       
    58 gint QTMSRingToneImpl::AddObserver(TMS::TMSRingToneObserver& obsrvr, gpointer user_data)
       
    59 {
       
    60     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    61     if (iRingTone) {
       
    62         ret = iRingTone->AddObserver(obsrvr, user_data);
       
    63     }
       
    64     return ret;
       
    65 }
       
    66 
       
    67 gint QTMSRingToneImpl::RemoveObserver(TMS::TMSRingToneObserver& obsrvr)
       
    68 {
       
    69     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    70     if (iRingTone) {
       
    71         ret = iRingTone->RemoveObserver(obsrvr);
       
    72     }
       
    73     return ret;
       
    74 }
       
    75 
       
    76 void QTMSRingToneImpl::RingtoneEvent(const TMS::TMSRingTone& /*rt*/, TMS::TMSSignalEvent event)
       
    77 {
       
    78     QTMSSignalEvent qevent;
       
    79     qevent.type = event.type;
       
    80     qevent.reason = event.reason;
       
    81     qevent.curr_state = event.curr_state;
       
    82     qevent.prev_state = event.prev_state;
       
    83     qevent.event_data = event.event_data;
       
    84     qevent.user_data = event.user_data;
       
    85 
       
    86     emit QTMS::QTMSRingTone::RingtoneEvent(static_cast<QTMSRingTone&> (*this), qevent);
       
    87 }
       
    88 
       
    89 // End of file