qtms/src/qtmsvolumeeffectimpl.cpp
branchRCL_3
changeset 24 6c1dfe4da5dd
equal deleted inserted replaced
23:e42293e811d8 24:6c1dfe4da5dd
       
     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 <qtms.h>
       
    19 #include <tmsvolumeeffect.h>
       
    20 #include "qtmsvolumeeffectimpl.h"
       
    21 
       
    22 using namespace QTMS;
       
    23 using namespace TMS;
       
    24 
       
    25 QTMSVolumeEffectImpl::QTMSVolumeEffectImpl()
       
    26 {
       
    27 }
       
    28 
       
    29 QTMSVolumeEffectImpl::~QTMSVolumeEffectImpl()
       
    30 {
       
    31     RemoveObserver(*this);
       
    32 }
       
    33 
       
    34 gint QTMSVolumeEffectImpl::Create(QTMSEffect*& qvol, TMS::TMSEffect*& tmsvol)
       
    35 {
       
    36     gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
       
    37     QTMSVolumeEffectImpl* self = new QTMSVolumeEffectImpl();
       
    38     if (self) {
       
    39         ret = self->PostConstruct();
       
    40         if (ret != QTMS_RESULT_SUCCESS) {
       
    41             delete self;
       
    42             self = NULL;
       
    43         }
       
    44         self->iEffect = tmsvol;
       
    45         ret = self->AddObserver(*self, NULL);
       
    46     }
       
    47     qvol = self;
       
    48     return ret;
       
    49 }
       
    50 
       
    51 gint QTMSVolumeEffectImpl::PostConstruct()
       
    52 {
       
    53     gint ret(QTMS_RESULT_SUCCESS);
       
    54     return ret;
       
    55 }
       
    56 
       
    57 gint QTMSVolumeEffectImpl::AddObserver(TMS::TMSEffectObserver& obsrvr, gpointer user_data)
       
    58 {
       
    59     gint ret(QTMS_RESULT_SUCCESS);
       
    60 
       
    61     if (iEffect) {
       
    62         ret = static_cast<TMSVolumeEffect*> (iEffect)->AddObserver(obsrvr, user_data);
       
    63     }
       
    64     return ret;
       
    65 }
       
    66 
       
    67 gint QTMSVolumeEffectImpl::RemoveObserver(TMS::TMSEffectObserver& obsrvr)
       
    68 {
       
    69     gint ret(QTMS_RESULT_SUCCESS);
       
    70 
       
    71     if (iEffect) {
       
    72         ret = static_cast<TMSVolumeEffect*> (iEffect)->RemoveObserver(obsrvr);
       
    73     }
       
    74     return ret;
       
    75 }
       
    76 
       
    77 gint QTMSVolumeEffectImpl::GetEffect(TMS::TMSEffect*& tmseffect)
       
    78 {
       
    79     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    80 
       
    81     if (iEffect) {
       
    82         tmseffect = iEffect;
       
    83         ret = QTMS_RESULT_SUCCESS;
       
    84     }
       
    85     return ret;
       
    86 }
       
    87 
       
    88 void QTMSVolumeEffectImpl::EffectsEvent(const TMS::TMSEffect& /*tmseffect*/,
       
    89     TMS::TMSSignalEvent event)
       
    90 {
       
    91     QTMSSignalEvent qevent;
       
    92 
       
    93     qevent.type = event.type;
       
    94     qevent.reason = event.reason;
       
    95     qevent.curr_state = event.curr_state;
       
    96     qevent.prev_state = event.prev_state;
       
    97     qevent.event_data = event.event_data;
       
    98     qevent.user_data = event.user_data;
       
    99 
       
   100     emit QTMS::QTMSVolumeEffect::EffectsEvent(static_cast<QTMSEffect&> (*this), qevent);
       
   101 }
       
   102 
       
   103 // End of file