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 <tmsbuffer.h> |
|
20 #include <tmsclientsink.h> |
|
21 #include <qtmsbuffer.h> |
|
22 #include "qtmsclientsinkimpl.h" |
|
23 |
|
24 using namespace QTMS; |
|
25 using namespace TMS; |
|
26 |
|
27 QTMSClientSinkImpl::QTMSClientSinkImpl() |
|
28 { |
|
29 } |
|
30 |
|
31 QTMSClientSinkImpl::~QTMSClientSinkImpl() |
|
32 { |
|
33 RemoveObserver(*this); |
|
34 } |
|
35 |
|
36 gint QTMSClientSinkImpl::Create(QTMSSink*& qsink, TMS::TMSSink*& tmssink) |
|
37 { |
|
38 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
|
39 QTMSClientSinkImpl* self = new QTMSClientSinkImpl(); |
|
40 if (self) { |
|
41 ret = self->PostConstruct(); |
|
42 if (ret != QTMS_RESULT_SUCCESS) { |
|
43 delete self; |
|
44 self = NULL; |
|
45 } |
|
46 self->iSink = tmssink; |
|
47 self->AddObserver(*self, NULL); |
|
48 } |
|
49 qsink = self; |
|
50 return ret; |
|
51 } |
|
52 |
|
53 gint QTMSClientSinkImpl::PostConstruct() |
|
54 { |
|
55 gint ret(QTMS_RESULT_SUCCESS); |
|
56 return ret; |
|
57 } |
|
58 |
|
59 gint QTMSClientSinkImpl::AddObserver(TMS::TMSClientSinkObserver& obsrvr, gpointer user_data) |
|
60 { |
|
61 gint ret(QTMS_RESULT_SUCCESS); |
|
62 if (iSink) { |
|
63 ret = static_cast<TMSClientSink*> (iSink)->AddObserver(obsrvr, user_data); |
|
64 } |
|
65 return ret; |
|
66 } |
|
67 |
|
68 gint QTMSClientSinkImpl::RemoveObserver(TMS::TMSClientSinkObserver& obsrvr) |
|
69 { |
|
70 gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT); |
|
71 if (iSink) { |
|
72 ret = static_cast<TMSClientSink*> (iSink)->RemoveObserver(obsrvr); |
|
73 } |
|
74 return ret; |
|
75 } |
|
76 |
|
77 gint QTMSClientSinkImpl::GetSink(TMS::TMSSink*& tmssink) |
|
78 { |
|
79 gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT); |
|
80 |
|
81 if (iSink) { |
|
82 tmssink = iSink; |
|
83 ret = QTMS_RESULT_SUCCESS; |
|
84 } |
|
85 return ret; |
|
86 } |
|
87 |
|
88 void QTMSClientSinkImpl::ProcessBuffer(const TMS::TMSBuffer* buffer) |
|
89 { |
|
90 TMSBuffer* buf(const_cast<TMSBuffer*> (buffer)); |
|
91 QTMSBuffer* qtbuf(reinterpret_cast<QTMSBuffer*> (buf)); |
|
92 emit QTMSClientSink::ProcessBuffer(qtbuf); |
|
93 } |
|
94 |
|
95 // End of file |
|