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