qtms/src/qtmsstreamimpl.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 <qtmseffect.h>
       
    20 #include <tmsstream.h>
       
    21 #include "tmsutility.h"
       
    22 #include "qtmsstreamimpl.h"
       
    23 
       
    24 using namespace QTMS;
       
    25 using namespace TMS;
       
    26 
       
    27 QTMSStreamImpl::QTMSStreamImpl()
       
    28     {
       
    29     }
       
    30 
       
    31 QTMSStreamImpl::~QTMSStreamImpl()
       
    32     {
       
    33     RemoveObserver(*this);
       
    34     }
       
    35 
       
    36 gint QTMSStreamImpl::Create(QTMSCallType callType, QTMSStreamType stype,
       
    37         QTMSStream*& qstrm, TMS::TMSStream*& tmsstrm)
       
    38     {
       
    39     gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
       
    40     QTMSStreamImpl* self = new QTMSStreamImpl();
       
    41     if (self)
       
    42         {
       
    43         ret = self->PostConstruct(callType, stype, *self);
       
    44         if (ret != QTMS_RESULT_SUCCESS)
       
    45             {
       
    46             delete self;
       
    47             self = NULL;
       
    48             }
       
    49         self->iStream = tmsstrm;
       
    50         self->AddObserver(*self, NULL);
       
    51         }
       
    52     qstrm = self;
       
    53     return ret;
       
    54     }
       
    55 
       
    56 gint QTMSStreamImpl::PostConstruct(QTMSCallType /*callType*/,
       
    57         QTMSStreamType /*stype*/, QTMSStream& /*parent*/)
       
    58     {
       
    59     gint status(QTMS_RESULT_SUCCESS);
       
    60     return status;
       
    61     }
       
    62 
       
    63 gint QTMSStreamImpl::AddObserver(TMS::TMSStreamObserver& obsrvr,
       
    64         gpointer user_data)
       
    65     {
       
    66     gint ret(QTMS_RESULT_SUCCESS);
       
    67 
       
    68     if (iStream)
       
    69         {
       
    70         iStream->AddObserver(obsrvr, user_data);
       
    71         }
       
    72 
       
    73     return ret;
       
    74     }
       
    75 
       
    76 gint QTMSStreamImpl::RemoveObserver(TMS::TMSStreamObserver& obsrvr)
       
    77     {
       
    78     gint ret(QTMS_RESULT_SUCCESS);
       
    79 
       
    80     if (iStream)
       
    81         {
       
    82         ret = iStream->RemoveObserver(obsrvr);
       
    83         }
       
    84 
       
    85     return ret;
       
    86     }
       
    87 
       
    88 void QTMSStreamImpl::TMSStreamEvent(const TMS::TMSStream& stream,
       
    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::QTMSStream::TMSStreamEvent(static_cast<QTMSStream&> (*this),
       
   101             qevent);
       
   102     }