|
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, QTMSStream*& qstrm, |
|
37 TMS::TMSStream*& tmsstrm) |
|
38 { |
|
39 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
|
40 QTMSStreamImpl* self = new QTMSStreamImpl(); |
|
41 if (self) { |
|
42 ret = self->PostConstruct(callType, stype, *self); |
|
43 if (ret != QTMS_RESULT_SUCCESS) { |
|
44 delete self; |
|
45 self = NULL; |
|
46 } |
|
47 self->iStream = tmsstrm; |
|
48 self->AddObserver(*self, NULL); |
|
49 } |
|
50 qstrm = self; |
|
51 return ret; |
|
52 } |
|
53 |
|
54 gint QTMSStreamImpl::PostConstruct(QTMSCallType /*callType*/, QTMSStreamType /*stype*/, QTMSStream& /*parent*/) |
|
55 { |
|
56 gint status(QTMS_RESULT_SUCCESS); |
|
57 return status; |
|
58 } |
|
59 |
|
60 gint QTMSStreamImpl::AddObserver(TMS::TMSStreamObserver& obsrvr, gpointer user_data) |
|
61 { |
|
62 gint ret(QTMS_RESULT_SUCCESS); |
|
63 |
|
64 if (iStream) { |
|
65 iStream->AddObserver(obsrvr, user_data); |
|
66 } |
|
67 |
|
68 return ret; |
|
69 } |
|
70 |
|
71 gint QTMSStreamImpl::RemoveObserver(TMS::TMSStreamObserver& obsrvr) |
|
72 { |
|
73 gint ret(QTMS_RESULT_SUCCESS); |
|
74 |
|
75 if (iStream) { |
|
76 ret = iStream->RemoveObserver(obsrvr); |
|
77 } |
|
78 |
|
79 return ret; |
|
80 } |
|
81 |
|
82 void QTMSStreamImpl::TMSStreamEvent(const TMS::TMSStream& /*stream*/, TMS::TMSSignalEvent event) |
|
83 { |
|
84 QTMSSignalEvent qevent; |
|
85 |
|
86 qevent.type = event.type; |
|
87 qevent.reason = event.reason; |
|
88 qevent.curr_state = event.curr_state; |
|
89 qevent.prev_state = event.prev_state; |
|
90 qevent.event_data = event.event_data; |
|
91 qevent.user_data = event.user_data; |
|
92 |
|
93 emit QTMS::QTMSStream::TMSStreamEvent(static_cast<QTMSStream&> (*this), qevent); |
|
94 } |