|
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 <tmsglobalrouting.h> |
|
20 #include "tmsutility.h" |
|
21 #include "qtmsglobalroutingimpl.h" |
|
22 |
|
23 using namespace QTMS; |
|
24 using namespace TMS; |
|
25 |
|
26 QTMSGlobalRoutingImpl::QTMSGlobalRoutingImpl() |
|
27 { |
|
28 } |
|
29 |
|
30 QTMSGlobalRoutingImpl::~QTMSGlobalRoutingImpl() |
|
31 { |
|
32 RemoveObserver(*this); |
|
33 } |
|
34 |
|
35 gint QTMSGlobalRoutingImpl::Create(QTMSGlobalRouting*& qrouting, |
|
36 TMS::TMSGlobalRouting*& tmsrouting) |
|
37 { |
|
38 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
|
39 QTMSGlobalRoutingImpl* self = new QTMSGlobalRoutingImpl(); |
|
40 if (self) |
|
41 { |
|
42 ret = self->PostConstruct(); |
|
43 if (ret != QTMS_RESULT_SUCCESS) |
|
44 { |
|
45 delete self; |
|
46 self = NULL; |
|
47 } |
|
48 self->iRouting = tmsrouting; |
|
49 ret = self->AddObserver(*self, NULL); |
|
50 } |
|
51 qrouting = self; |
|
52 return ret; |
|
53 } |
|
54 |
|
55 gint QTMSGlobalRoutingImpl::PostConstruct() |
|
56 { |
|
57 gint ret(QTMS_RESULT_SUCCESS); |
|
58 return ret; |
|
59 } |
|
60 |
|
61 gint QTMSGlobalRoutingImpl::AddObserver(TMS::TMSGlobalRoutingObserver& obsrvr, |
|
62 gpointer user_data) |
|
63 { |
|
64 gint ret(QTMS_RESULT_SUCCESS); |
|
65 |
|
66 if (iRouting) |
|
67 { |
|
68 ret = iRouting->AddObserver(obsrvr, user_data); |
|
69 } |
|
70 return ret; |
|
71 } |
|
72 |
|
73 gint QTMSGlobalRoutingImpl::RemoveObserver( |
|
74 TMS::TMSGlobalRoutingObserver& obsrvr) |
|
75 { |
|
76 gint ret(QTMS_RESULT_SUCCESS); |
|
77 |
|
78 if (iRouting) |
|
79 { |
|
80 ret = iRouting->RemoveObserver(obsrvr); |
|
81 } |
|
82 return ret; |
|
83 } |
|
84 |
|
85 void QTMSGlobalRoutingImpl::GlobalRoutingEvent( |
|
86 const TMS::TMSGlobalRouting& /*routing*/, TMS::TMSSignalEvent event, |
|
87 TMS::TMSAudioOutput output) |
|
88 { |
|
89 QTMSSignalEvent qevent; |
|
90 QTMSAudioOutput qoutput; |
|
91 |
|
92 qevent.type = event.type; |
|
93 qevent.reason = event.reason; |
|
94 qevent.curr_state = event.curr_state; |
|
95 qevent.prev_state = event.prev_state; |
|
96 qevent.event_data = event.event_data; |
|
97 qevent.user_data = event.user_data; |
|
98 qoutput = output; |
|
99 |
|
100 emit QTMS::QTMSGlobalRouting::GlobalRoutingEvent( |
|
101 static_cast<QTMSGlobalRouting&> (*this), qevent, qoutput); |
|
102 } |
|
103 |
|
104 // End of file |