qtms/src/qtmsvolumeeffectimpl.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 <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         {
       
    40         ret = self->PostConstruct();
       
    41         if (ret != QTMS_RESULT_SUCCESS)
       
    42             {
       
    43             delete self;
       
    44             self = NULL;
       
    45             }
       
    46         self->iEffect = tmsvol;
       
    47         ret = self->AddObserver(*self, NULL);
       
    48         }
       
    49     qvol = self;
       
    50     return ret;
       
    51     }
       
    52 
       
    53 gint QTMSVolumeEffectImpl::PostConstruct()
       
    54     {
       
    55     gint ret(QTMS_RESULT_SUCCESS);
       
    56     return ret;
       
    57     }
       
    58 
       
    59 gint QTMSVolumeEffectImpl::AddObserver(TMS::TMSEffectObserver& obsrvr,
       
    60         gpointer /*user_data*/)
       
    61     {
       
    62     gint ret(QTMS_RESULT_SUCCESS);
       
    63 
       
    64     if (iEffect)
       
    65         {
       
    66         ret = static_cast<TMSVolumeEffect*> (iEffect)->AddObserver(obsrvr,
       
    67                 NULL);
       
    68         }
       
    69     return ret;
       
    70     }
       
    71 
       
    72 gint QTMSVolumeEffectImpl::RemoveObserver(TMS::TMSEffectObserver& obsrvr)
       
    73     {
       
    74     gint ret(QTMS_RESULT_SUCCESS);
       
    75 
       
    76     if (iEffect)
       
    77         {
       
    78         ret = static_cast<TMSVolumeEffect*> (iEffect)->RemoveObserver(obsrvr);
       
    79         }
       
    80     return ret;
       
    81     }
       
    82 
       
    83 gint QTMSVolumeEffectImpl::GetEffect(TMS::TMSEffect*& tmseffect)
       
    84     {
       
    85     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    86 
       
    87     if (iEffect)
       
    88         {
       
    89         tmseffect = iEffect;
       
    90         ret = QTMS_RESULT_SUCCESS;
       
    91         }
       
    92     return ret;
       
    93     }
       
    94 
       
    95 void QTMSVolumeEffectImpl::EffectsEvent(const TMS::TMSEffect& /*tmseffect*/,
       
    96         TMS::TMSSignalEvent event)
       
    97     {
       
    98     QTMSSignalEvent qevent;
       
    99 
       
   100     qevent.type = event.type;
       
   101     qevent.reason = event.reason;
       
   102     qevent.curr_state = event.curr_state;
       
   103     qevent.prev_state = event.prev_state;
       
   104     qevent.event_data = event.event_data;
       
   105     qevent.user_data = event.user_data;
       
   106 
       
   107     emit QTMS::QTMSVolumeEffect::EffectsEvent(
       
   108             static_cast<QTMSEffect&> (*this), qevent);
       
   109     }
       
   110 
       
   111 // End of file