qtms/src/qtmsringtoneimpl.cpp
changeset 27 cbb1bfb7ebfb
child 50 762d760dcfdf
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 <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         {
       
    41         ret = self->PostConstruct();
       
    42         if (ret != QTMS_RESULT_SUCCESS)
       
    43             {
       
    44             delete self;
       
    45             self = NULL;
       
    46             }
       
    47         self->iRingTone = tmsrt;
       
    48         ret = self->AddObserver(*self, NULL);
       
    49         }
       
    50     qrt = self;
       
    51     return ret;
       
    52     }
       
    53 
       
    54 gint QTMSRingToneImpl::PostConstruct()
       
    55     {
       
    56     gint ret(QTMS_RESULT_SUCCESS);
       
    57     return ret;
       
    58     }
       
    59 
       
    60 gint QTMSRingToneImpl::AddObserver(TMS::TMSRingToneObserver& obsrvr,
       
    61         gpointer user_data)
       
    62     {
       
    63     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    64     if (iRingTone)
       
    65         {
       
    66         ret = iRingTone->AddObserver(obsrvr, user_data);
       
    67         }
       
    68     return ret;
       
    69     }
       
    70 
       
    71 gint QTMSRingToneImpl::RemoveObserver(TMS::TMSRingToneObserver& obsrvr)
       
    72     {
       
    73     gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
       
    74     if (iRingTone)
       
    75         {
       
    76         ret = iRingTone->RemoveObserver(obsrvr);
       
    77         }
       
    78     return ret;
       
    79     }
       
    80 
       
    81 void QTMSRingToneImpl::RingtoneEvent(const TMS::TMSRingTone& /*rt*/,
       
    82         TMS::TMSSignalEvent event)
       
    83     {
       
    84     QTMSSignalEvent qevent;
       
    85     qevent.type = event.type;
       
    86     qevent.reason = event.reason;
       
    87     qevent.curr_state = event.curr_state;
       
    88     qevent.prev_state = event.prev_state;
       
    89     qevent.event_data = event.event_data;
       
    90     qevent.user_data = event.user_data;
       
    91 
       
    92     emit QTMS::QTMSRingTone::RingtoneEvent(static_cast<QTMSRingTone&> (*this),
       
    93             qevent);
       
    94     }
       
    95 
       
    96 // End of file