|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 /* THIS IS A XQServiceChannel STUB used only for UNIT TEST */ |
|
23 |
|
24 #include <QThreadStorage> |
|
25 |
|
26 #include "xqservicechannel.h" |
|
27 #include "xqservicethreaddata.h" |
|
28 #include "xqsharablefile.h" |
|
29 |
|
30 static QThreadStorage<XQServiceChannelPrivate *> xqchannel; |
|
31 |
|
32 XQServiceChannel::XQServiceChannel(const QString& channel, bool isServer, QObject *parent) |
|
33 : QObject(parent) |
|
34 { |
|
35 d = new XQServiceChannelPrivate(this, channel, isServer); |
|
36 xqchannel.setLocalData(d); |
|
37 } |
|
38 |
|
39 |
|
40 XQServiceChannel::~XQServiceChannel() |
|
41 { |
|
42 } |
|
43 |
|
44 bool XQServiceChannel::connectChannel() |
|
45 { |
|
46 return true; |
|
47 } |
|
48 |
|
49 QString XQServiceChannel::channel() const |
|
50 { |
|
51 return d->channel; |
|
52 } |
|
53 |
|
54 QVariant XQServiceChannel::receive(const QString& msg, const QByteArray &data, const XQSharableFile &sf) |
|
55 { |
|
56 emit received(msg, data,sf); |
|
57 return QVariant(); |
|
58 } |
|
59 |
|
60 void XQServiceChannel::commandReceive(const XQServiceCommand cmd) |
|
61 { |
|
62 emit commandReceived(cmd); |
|
63 } |
|
64 |
|
65 bool XQServiceChannel::send(const QString& channel, const QString& msg, |
|
66 const QByteArray &data, QVariant &retValue, bool sync, XQServiceRequestCompletedAsync* rc) |
|
67 { |
|
68 return send(channel,msg,data,retValue,sync,rc,NULL); |
|
69 } |
|
70 |
|
71 bool XQServiceChannel::send(const QString& channel, const QString& msg, |
|
72 const QByteArray &data, QVariant &retValue, |
|
73 bool sync, XQServiceRequestCompletedAsync* rc, |
|
74 const void* userData) |
|
75 { |
|
76 XQServiceChannelPrivate* channelPrivate = xqchannel.localData(); |
|
77 XQSharableFile dummy; |
|
78 retValue = channelPrivate->object->receive(msg,data,dummy); |
|
79 return true; |
|
80 } |
|
81 |
|
82 bool XQServiceChannel::cancelPendingSend(const QString& channel) |
|
83 { |
|
84 return true ; |
|
85 } |
|
86 |
|
87 QVariant XQServiceChannel::sendLocally(const QString& ch, const QString& msg, |
|
88 const QByteArray &data, const XQSharableFile &sf) |
|
89 { |
|
90 /* |
|
91 // filter out internal events |
|
92 if (ch.isEmpty()) |
|
93 return; |
|
94 |
|
95 // feed local clients with received data |
|
96 XQServiceThreadData *td = XQService::serviceThreadData(); |
|
97 QList<XQServiceChannelPrivatePointer> clients = td->clientMap[ch]; |
|
98 for (int i = 0; i < clients.size(); ++i) { |
|
99 XQServiceChannelPrivate *channel = clients.at(i).data(); |
|
100 if (channel->object) |
|
101 channel->object->receive(msg, data); |
|
102 } |
|
103 */ |
|
104 return QVariant(); |
|
105 } |
|
106 |
|
107 int XQServiceChannel::latestError() |
|
108 { |
|
109 return -4998; |
|
110 } |
|
111 |