First round at renaming to QtJolie and namespacing (also for headers).

svn path=/branches/work/~ervin/qtjolie/; revision=959005
This commit is contained in:
Kevin Ottens 2009-04-25 12:26:01 +00:00
parent fc1c740837
commit cac82a3792
26 changed files with 86 additions and 74 deletions

View File

@ -0,0 +1,9 @@
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
include(MacroLibrary)
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES})
add_subdirectory(qtjolie)
add_subdirectory(tests)

View File

@ -0,0 +1,4 @@
/** @mainpage SODEP
*/
// DOXYGEN_SET_PROJECT_NAME = Sodep

View File

@ -0,0 +1,24 @@
project(QtJolie)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDE_DIR})
set(qtjolie_LIB_SRCS sodepclient.cpp sodepclientthread.cpp sodepvalue.cpp sodepfault.cpp sodepmessage.cpp sodeppendingcall.cpp)
kde4_add_library(QtJolie SHARED ${qtjolie_LIB_SRCS})
target_link_libraries(QtJolie ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
install(TARGETS QtJolie
DESTINATION ${LIB_INSTALL_DIR})
set_target_properties(QtJolie PROPERTIES VERSION 1.0.0 SOVERSION 1)
install(FILES
sodepclient.h
sodepvalue.h
sodepfault.h
sodepmessage.h
sodeppendingcall.h
DESTINATION ${INCLUDE_INSTALL_DIR})

View File

@ -64,6 +64,11 @@ SodepMessage SodepClient::call(const SodepMessage &message)
return pending.reply();
}
void SodepClient::callNoReply(const SodepMessage &message)
{
d->readerThread->sendMessage(message);
}
void SodepClientPrivate::messageReceived(const SodepMessage &message)
{
QExplicitlySharedDataPointer<SodepPendingCallPrivate> pending = pendingCalls.take(message.id());

View File

@ -48,6 +48,7 @@ public:
SodepPendingCall asyncCall(const SodepMessage &message);
SodepMessage call(const SodepMessage &message);
void callNoReply(const SodepMessage &message);
private:
friend class SodepClientPrivate;

View File

@ -41,19 +41,19 @@ SodepClientThread::~SodepClientThread()
void SodepClientThread::sendMessage(const SodepMessage &message)
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_mutex);
m_messageQueue.enqueue(message);
QTimer::singleShot(0, this, SLOT(writeMessageQueue()));
m_messageQueue.enqueue(message);
QTimer::singleShot(0, this, SLOT(writeMessageQueue()));
}
void SodepClientThread::writeMessageQueue()
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_mutex);
while (!m_messageQueue.isEmpty()) {
sodepWrite(*m_socket, m_messageQueue.dequeue());
}
while (!m_messageQueue.isEmpty()) {
sodepWrite(*m_socket, m_messageQueue.dequeue());
}
}
void SodepClientThread::readMessage()
@ -80,9 +80,11 @@ void SodepClientThread::run()
m_client, SLOT(messageReceived(SodepMessage)));
m_socket->connectToHost(m_hostName, m_port);
m_socket->waitForConnected(-1);
m_socket->waitForConnected(30000);
exec();
writeMessageQueue();
m_socket->waitForBytesWritten(30000);
delete m_socket;
}

View File

@ -21,7 +21,7 @@
#ifndef SODEPFAULT_H
#define SODEPFAULT_H
#include <sodepvalue.h>
#include <qtjolie/sodepvalue.h>
class SodepFaultPrivate;

View File

@ -21,8 +21,8 @@
#ifndef SODEPMESSAGE_H
#define SODEPMESSAGE_H
#include <sodepvalue.h>
#include <sodepfault.h>
#include <qtjolie/sodepvalue.h>
#include <qtjolie/sodepfault.h>
class SodepMessagePrivate;

View File

@ -1,24 +0,0 @@
project(sodep)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDE_DIR})
set(sodep_LIB_SRCS sodepclient.cpp sodepclientthread.cpp sodepvalue.cpp sodepfault.cpp sodepmessage.cpp sodeppendingcall.cpp)
kde4_add_library(sodep SHARED ${sodep_LIB_SRCS})
target_link_libraries(sodep ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY})
install(TARGETS sodep
DESTINATION ${LIB_INSTALL_DIR})
set_target_properties(sodep PROPERTIES VERSION 1.0.0 SOVERSION 1)
install(FILES
sodepclient.h
sodepvalue.h
sodepfault.h
sodepmessage.h
sodeppendingcall.h
DESTINATION ${INCLUDE_INSTALL_DIR})

View File

@ -1,9 +1,9 @@
include_directories(${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../sodep)
include_directories(${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../)
MACRO(SODEP_UNIT_TESTS)
FOREACH(_testname ${ARGN})
kde4_add_unit_test(${_testname} NOGUI ${_testname}.cpp)
target_link_libraries(${_testname} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTNETWORK_LIBRARY} sodep)
target_link_libraries(${_testname} ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTNETWORK_LIBRARY} QtJolie)
add_definitions(-DDATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"")
ENDFOREACH(_testname)
ENDMACRO(SODEP_UNIT_TESTS)
@ -11,7 +11,7 @@ ENDMACRO(SODEP_UNIT_TESTS)
MACRO(SODEP_EXECUTABLE_TESTS)
FOREACH(_testname ${ARGN})
kde4_add_executable(${_testname} NOGUI TEST ${_testname}.cpp)
target_link_libraries(${_testname} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} sodep)
target_link_libraries(${_testname} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY} QtJolie)
add_definitions(-DDATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"")
ENDFOREACH(_testname)
ENDMACRO(SODEP_EXECUTABLE_TESTS)

View File

@ -21,7 +21,7 @@
#include <QtCore/QObject>
#include <QtTest/QtTest>
#include <sodepfault.h>
#include <qtjolie/sodepfault.h>
#include "sodeptesthelpers.h"
class SodepFaultTest : public QObject

View File

@ -21,7 +21,7 @@
#include <QtCore/QObject>
#include <QtTest/QtTest>
#include <sodepmessage.h>
#include <qtjolie/sodepmessage.h>
#include "sodeptesthelpers.h"
class SodepMessageTest : public QObject
@ -31,12 +31,12 @@ class SodepMessageTest : public QObject
private slots:
void shouldVerifyInitialState()
{
SodepMessage m1("/foo", "bar");
SodepMessage m1("/foo", "bar", 1);
SodepMessage m2("/pata/pata", "pon", 2);
QCOMPARE(m1.resourcePath(), QString("/foo"));
QCOMPARE(m1.operationName(), QString("bar"));
QCOMPARE(m1.id(), qint64(0));
QCOMPARE(m1.id(), qint64(1));
QCOMPARE(m2.resourcePath(), QString("/pata/pata"));
QCOMPARE(m2.operationName(), QString("pon"));
@ -60,18 +60,18 @@ private slots:
QTest::addColumn<SodepMessage>("original");
QTest::addColumn<QByteArray>("serialized");
QTest::newRow("no payload message") << SodepMessage("/pata", "pon")
<< QByteArray::fromHex("0000000000000000")
QTest::newRow("no payload message") << SodepMessage("/pata", "pon", 1)
<< QByteArray::fromHex("0000000000000001")
+ QByteArray::fromHex("00000005")+QByteArray("/pata")
+ QByteArray::fromHex("00000003")+QByteArray("pon")
+ QByteArray::fromHex("00")
+ QByteArray::fromHex("0000000000");
SodepMessage payload("/pata", "pon");
SodepMessage payload("/pata", "pon", 1);
payload.setFault(f);
payload.setData(v);
QTest::newRow("payload message") << payload
<< QByteArray::fromHex("0000000000000000")
<< QByteArray::fromHex("0000000000000001")
+ QByteArray::fromHex("00000005")+QByteArray("/pata")
+ QByteArray::fromHex("00000003")+QByteArray("pon")
+ fSerial

View File

@ -18,14 +18,13 @@
* Boston, MA 02110-1301, USA.
*/
#include <QtCore/QEventLoop>
#include <QtCore/QObject>
#include <QtCore/QProcess>
#include <QtNetwork/QTcpSocket>
#include <QtTest/QtTest>
#include <sodepclient.h>
#include <sodepmessage.h>
#include <qtjolie/sodepclient.h>
#include <qtjolie/sodepmessage.h>
#include <qtjolie/sodeppendingcall.h>
#include "sodeptesthelpers.h"
#ifndef DATA_DIR
@ -67,7 +66,7 @@ class SodepMetaServiceTest : public QObject
Q_OBJECT
QProcess m_metaserviceProcess;
QTcpSocket m_socket;
SodepClient *m_client;
public:
SodepMetaServiceTest()
@ -83,17 +82,14 @@ private slots:
QVERIFY2(m_metaserviceProcess.waitForStarted(), "Looks like you don't have Jolie's metaservice command");
QTest::qWait(1000);
m_socket.connectToHost("localhost", 9000);
QVERIFY(m_socket.waitForConnected(-1));
m_client = new SodepClient("localhost", 9000);
}
void cleanupTestCase()
{
SodepMessage message("/", "shutdown");
sodepWrite(m_socket, message);
QTest::qWait(1000);
m_socket.close();
m_client->callNoReply(message);
delete m_client;
m_metaserviceProcess.waitForFinished();
}
@ -117,9 +113,8 @@ private slots:
value.children("resourcePrefix") << SodepValue(resourcePrefix);
value.children("filepath") << SodepValue(QString(DATA_DIR"/")+fileName);
message.setData(value);
sodepWrite(m_socket, message);
SodepMessage reply = sodepReadMessage(m_socket);
SodepMessage reply = m_client->call(message);
SodepMessage expected("/", "loadEmbeddedJolieService");
expected.setData(SodepValue(resourcePrefix));
@ -129,11 +124,9 @@ private slots:
void shouldListServices()
{
SodepClient client("localhost", 9000);
SodepMessage message("/", "getServices");
SodepMessage reply = client.call(message);
SodepMessage reply = m_client->call(message);
SodepMessage expected("/", "getServices");
SodepValue value;
@ -170,9 +163,8 @@ private slots:
SodepMessage message(path, method);
message.setData(data);
sodepWrite(m_socket, message);
SodepMessage reply = sodepReadMessage(m_socket);
SodepMessage reply = m_client->call(message);
SodepMessage expected("/", method);
expected.setData(replyData);
@ -195,9 +187,8 @@ private slots:
SodepMessage message("/", "unloadEmbeddedService");
SodepValue value(serviceName);
message.setData(value);
sodepWrite(m_socket, message);
SodepMessage reply = sodepReadMessage(m_socket);
SodepMessage reply = m_client->call(message);
SodepMessage expected("/", "unloadEmbeddedService");

View File

@ -25,9 +25,9 @@
#include <QtGui/QPushButton>
#include <QtNetwork/QTcpSocket>
#include <sodepmessage.h>
#include <sodepvalue.h>
#include <sodephelpers_p.h>
#include <qtjolie/sodepmessage.h>
#include <qtjolie/sodepvalue.h>
#include <qtjolie/sodephelpers_p.h>
class MainWindow : public QWidget
{

View File

@ -23,10 +23,10 @@
#include <QtTest/QtTest>
#include <sodepfault.h>
#include <sodepmessage.h>
#include <sodepvalue.h>
#include <sodephelpers_p.h>
#include <qtjolie/sodepfault.h>
#include <qtjolie/sodepmessage.h>
#include <qtjolie/sodepvalue.h>
#include <qtjolie/sodephelpers_p.h>
Q_DECLARE_METATYPE(SodepValue);

View File

@ -21,7 +21,7 @@
#include <QtCore/QObject>
#include <QtTest/QtTest>
#include <sodepvalue.h>
#include <qtjolie/sodepvalue.h>
#include "sodeptesthelpers.h"