2009-04-13 14:39:26 +02:00
|
|
|
/**
|
|
|
|
* This file is part of the KDE project
|
2009-06-02 20:02:06 +02:00
|
|
|
* Copyright (C) 2009 Kevin Ottens <ervin@kde.org>
|
2009-04-13 14:39:26 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public License
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
#include "pendingcall.h"
|
|
|
|
#include "pendingcall_p.h"
|
2009-06-02 20:02:06 +02:00
|
|
|
#include "pendingcallwatcher.h"
|
2009-04-13 14:39:26 +02:00
|
|
|
|
2009-09-02 04:27:16 +02:00
|
|
|
#define QT_NO_CAST_FROM_ASCII
|
|
|
|
#define QT_NO_CAST_TO_ASCII
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
using namespace Jolie;
|
2009-04-13 14:39:26 +02:00
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::PendingCall(const PendingCall &other)
|
2009-04-13 14:39:26 +02:00
|
|
|
: d(other.d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::PendingCall(QExplicitlySharedDataPointer<PendingCallPrivate> dd)
|
2009-04-13 14:39:26 +02:00
|
|
|
: d(dd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall::~PendingCall()
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
PendingCall &PendingCall::operator=(const PendingCall &other)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
d = other.d;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void PendingCallPrivate::setReply(const Message &message)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
|
|
|
Q_ASSERT(message.id()==id);
|
|
|
|
isFinished = true;
|
|
|
|
reply = message;
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
foreach (PendingCallWaiter *waiter, waiters) {
|
2009-04-13 14:39:26 +02:00
|
|
|
waiter->eventLoop.quit();
|
|
|
|
}
|
|
|
|
waiters.clear();
|
2009-06-02 20:02:06 +02:00
|
|
|
|
|
|
|
foreach (PendingCallWatcher *watcher, watchers) {
|
|
|
|
emit watcher->finished(watcher);
|
|
|
|
}
|
|
|
|
watchers.clear();
|
2009-04-13 14:39:26 +02:00
|
|
|
}
|
|
|
|
|
2009-04-25 15:50:35 +02:00
|
|
|
void PendingCallWaiter::waitForFinished(PendingCallPrivate *pendingCall)
|
2009-04-13 14:39:26 +02:00
|
|
|
{
|
2009-06-02 22:52:56 +02:00
|
|
|
if (pendingCall==0) return;
|
2009-04-13 14:39:26 +02:00
|
|
|
pendingCall->waiters << this;
|
|
|
|
eventLoop.exec();
|
|
|
|
}
|
2009-04-25 15:50:35 +02:00
|
|
|
|