qtms/src/qtmsclientsourceimpl.cpp
changeset 27 cbb1bfb7ebfb
child 40 4a1905d205a2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qtms/src/qtmsclientsourceimpl.cpp	Fri May 14 16:21:14 2010 +0300
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: QT Bindings for TMS
+ *
+ */
+
+#include <qtms.h>
+#include <tmsbuffer.h>
+#include <tmsclientsource.h>
+#include "qtmsclientsourceimpl.h"
+
+using namespace QTMS;
+using namespace TMS;
+
+QTMSClientSourceImpl::QTMSClientSourceImpl()
+    {
+    }
+
+QTMSClientSourceImpl::~QTMSClientSourceImpl()
+    {
+    RemoveObserver(*this);
+    }
+
+gint QTMSClientSourceImpl::Create(QTMSSource*& qsource,
+        TMS::TMSSource*& tmssource)
+    {
+    gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY);
+    QTMSClientSourceImpl* self = new QTMSClientSourceImpl();
+    if (self)
+        {
+        ret = self->PostConstruct();
+        if (ret != QTMS_RESULT_SUCCESS)
+            {
+            delete self;
+            self = NULL;
+            }
+        self->iSource = tmssource;
+        self->AddObserver(*self, NULL);
+        }
+    qsource = self;
+    return ret;
+    }
+
+gint QTMSClientSourceImpl::PostConstruct()
+    {
+    gint ret(QTMS_RESULT_SUCCESS);
+    return ret;
+    }
+
+gint QTMSClientSourceImpl::AddObserver(TMS::TMSClientSourceObserver& obsrvr,
+        gpointer user_data)
+    {
+    gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
+    if (iSource)
+        {
+        ret = static_cast<TMSClientSource*> (iSource)->AddObserver(obsrvr,
+                user_data);
+        }
+    return ret;
+    }
+
+gint QTMSClientSourceImpl::RemoveObserver(TMS::TMSClientSourceObserver& obsrvr)
+    {
+    gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
+    if (iSource)
+        {
+        ret = static_cast<TMSClientSource*> (iSource)->RemoveObserver(obsrvr);
+        }
+    return ret;
+    }
+
+gint QTMSClientSourceImpl::GetSource(TMS::TMSSource*& tmssource)
+    {
+    gint ret(QTMS_RESULT_UNINITIALIZED_OBJECT);
+
+    if (iSource)
+        {
+        tmssource = iSource;
+        ret = QTMS_RESULT_SUCCESS;
+        }
+    return ret;
+    }
+
+void QTMSClientSourceImpl::FillBuffer(TMS::TMSBuffer& buffer)
+    {
+    emit QTMS::QTMSClientSource::FillBuffer(buffer);
+    }
+
+void QTMSClientSourceImpl::BufferProcessed(const TMS::TMSBuffer* buffer,
+        gint reason)
+    {
+    emit QTMS::QTMSClientSource::BufferProcessed(buffer, reason);
+    }
+
+// End of file