├── .gitignore ├── CMakeLists.txt ├── README.md ├── examples ├── async_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── main.cpp │ ├── testobject.cpp │ └── testobject.h ├── async_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── auth_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── auth_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── basic_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── basic_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── data_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── dataservice.cpp │ ├── dataservice.h │ └── main.cpp ├── data_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── dataservice.cpp │ ├── dataservice.h │ └── main.cpp ├── discovery_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── main.cpp │ ├── testobject.cpp │ └── testobject.h ├── discovery_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── event_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── main.cpp │ ├── timeobject.cpp │ ├── timeobject.h │ ├── timeservice.cpp │ └── timeservice.h ├── event_server │ ├── CMakeLists.txt │ ├── main.cpp │ ├── timeservice.cpp │ └── timeservice.h ├── md5auth_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── md5auth_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── ssl_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── ssl_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ ├── examplecert.pem │ └── main.cpp ├── thread_client │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp └── thread_server │ ├── CMakeLists.txt │ ├── basicservice.cpp │ ├── basicservice.h │ └── main.cpp ├── include ├── AuthToken ├── AutomaticMetatypeRegistry ├── ClientMessageBus ├── ClientProtocolBase ├── ClientProtocolIODevice ├── ClientProtocolSocket ├── ClientProtocolTcp ├── ClientProtocolTest ├── ClientProtocolThread ├── ClientProxy ├── Message ├── ProxyBase ├── QtRpcGlobal ├── QxtPimpl ├── ReturnValue ├── Server ├── ServerProtocolInstanceBase ├── ServerProtocolInstanceIODevice ├── ServerProtocolInstanceSocket ├── ServerProtocolInstanceTcp ├── ServerProtocolListenerBase ├── ServerProtocolListenerProcess ├── ServerProtocolListenerSocket ├── ServerProtocolListenerTcp ├── ServerThread ├── ServiceFactory ├── ServiceFinder ├── ServiceProxy ├── ServicePublisher ├── Signature └── Sleeper ├── lib ├── CMakeLists.txt ├── authtoken.cpp ├── authtoken.h ├── authtoken_p.h ├── automaticmetatyperegistry.h ├── clientmessagebus.cpp ├── clientmessagebus.h ├── clientmessagebus_p.h ├── clientprotocolbase.cpp ├── clientprotocolbase.h ├── clientprotocolbase_p.h ├── clientprotocoliodevice.cpp ├── clientprotocoliodevice.h ├── clientprotocoliodevice_p.h ├── clientprotocolsocket.cpp ├── clientprotocolsocket.h ├── clientprotocolsocket_p.h ├── clientprotocoltcp.cpp ├── clientprotocoltcp.h ├── clientprotocoltcp_p.h ├── clientprotocoltest.cpp ├── clientprotocoltest.h ├── clientprotocoltest_p.h ├── clientprotocolthread.cpp ├── clientprotocolthread.h ├── clientprotocolthread_p.h ├── clientproxy.cpp ├── clientproxy.h ├── clientproxy_p.h ├── message.cpp ├── message.h ├── message_p.h ├── proxybase.cpp ├── proxybase.h ├── proxybase_p.h ├── qtrpcglobal.h ├── qtrpcprivate.h ├── qxtavahipoll.cpp ├── qxtavahipoll.h ├── qxtavahipoll_p.h ├── qxtdiscoverableservice.cpp ├── qxtdiscoverableservice.h ├── qxtdiscoverableservice_p.h ├── qxtdiscoverableservicename.cpp ├── qxtdiscoverableservicename.h ├── qxtmdns.h ├── qxtmdns_avahi.cpp ├── qxtmdns_avahi.h ├── qxtmdns_avahi_p.h ├── qxtmdns_bonjour.cpp ├── qxtmdns_bonjour.h ├── qxtpimpl.h ├── qxtservicebrowser.cpp ├── qxtservicebrowser.h ├── qxtservicebrowser_p.h ├── qxtzeroconf.h ├── returnvalue.cpp ├── returnvalue.h ├── returnvalue_p.h ├── server.cpp ├── server.h ├── server_p.h ├── serverprotocolinstancebase.cpp ├── serverprotocolinstancebase.h ├── serverprotocolinstancebase_p.h ├── serverprotocolinstanceiodevice.cpp ├── serverprotocolinstanceiodevice.h ├── serverprotocolinstanceiodevice_p.h ├── serverprotocolinstancesocket.cpp ├── serverprotocolinstancesocket.h ├── serverprotocolinstancesocket_p.h ├── serverprotocolinstancetcp.cpp ├── serverprotocolinstancetcp.h ├── serverprotocolinstancetcp_p.h ├── serverprotocollistenerbase.cpp ├── serverprotocollistenerbase.h ├── serverprotocollistenerbase_p.h ├── serverprotocollistenerprocess.cpp ├── serverprotocollistenerprocess.h ├── serverprotocollistenerprocess_p.h ├── serverprotocollistenersocket.cpp ├── serverprotocollistenersocket.h ├── serverprotocollistenersocket_p.h ├── serverprotocollistenertcp.cpp ├── serverprotocollistenertcp.h ├── serverprotocollistenertcp_p.h ├── serverthread.cpp ├── serverthread.h ├── serverthread_p.h ├── servicefactory.h ├── servicefactoryparent.cpp ├── servicefactoryparent_p.h ├── servicefinder.cpp ├── servicefinder.h ├── servicefinder_p.h ├── serviceproxy.cpp ├── serviceproxy.h ├── serviceproxy_p.h ├── servicepublisher.cpp ├── servicepublisher.h ├── servicepublisher_p.h ├── signature.cpp ├── signature.h ├── signature_p.h └── sleeper.h ├── qtrpc2.pro ├── testclient ├── CMakeLists.txt ├── main.cpp ├── testcaller.cpp ├── testcaller.h ├── testclient.cpp ├── testclient.h ├── testsyncro.cpp ├── testsyncro.h ├── testthread.cpp └── testthread.h └── testserver ├── CMakeLists.txt ├── callerservice.cpp ├── callerservice.h ├── main.cpp ├── testserver.cpp ├── testserver.h ├── testsyncroserver.cpp └── testsyncroserver.h /.gitignore: -------------------------------------------------------------------------------- 1 | ^[^/]*/bin/ 2 | ^[^/]*/[^/]*/.*\.so.* 3 | syntax: glob 4 | Makefile* 5 | *Makefile.in 6 | Makefile.in 7 | moc_*.cpp 8 | *.o 9 | ui_*.h 10 | *~ 11 | *.kdev* 12 | *.bak 13 | qrc_* 14 | *.a 15 | *.moc.* 16 | *.moc 17 | *.cxx 18 | autom4te.cache/* 19 | config.h 20 | config.log 21 | config.status 22 | libtool 23 | .deps/* 24 | stamp-h1 25 | index.cache.bz2 26 | *.pyc 27 | .nfs* 28 | CMakeFiles/* 29 | CMakeCache.txt 30 | *.cmake 31 | *.orig 32 | build*/ 33 | *.rej 34 | *.user 35 | *.autosave 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QtRpc2 - Simple to use Qt based RPC library. 2 | ============================================ 3 | QtRpc2 is a RPC library based on the Qt framework. It leverages Qt's meta object system to greatly simplify RPC calls, and significantly reduce boilerplate code. 4 | 5 | ##Features 6 | * Simple to use 7 | * Events and asynchronous function calls 8 | * Simple error checking 9 | * Token based authentication model 10 | * Multiple transport modes (TCP, SSL, Named Pipe) 11 | * Flexible threading model 12 | * Service discovery 13 | 14 | 15 | Documentation 16 | ---------------------- 17 | There really isn't any right now. Have a look at examples/basic_client and examples/basic_server for an example on how to get started. The other examples in the examples folder cover the major features of the library. 18 | 19 | Build Instructions 20 | ------------------------- 21 | ### Requirements 22 | * Qt 4.6 or above. 23 | * CMake 2.6 or above. 24 | * Bonjour, or Avahi on Linux. 25 | 26 | on Debian or Ubuntu, this command will install the required dependencies. 27 | ``` 28 | sudo apt-get install libqt4-dev cmake libavahi-client-dev libavahi-compat-libdnssd-dev 29 | ``` 30 | 31 | ### Building 32 | Check out the git repository with 33 | ``` 34 | git://github.com/brendan0powers/QtRpc2.git 35 | ``` 36 | 37 | to build, create a build directory, and then run CMake. 38 | 39 | #### Linux, OS X 40 | ``` 41 | cd QtRpc2/ 42 | mkdir build 43 | cd build/ 44 | cmake ../ 45 | make 46 | ``` 47 | 48 | #### Windows 49 | ``` 50 | cd QtRpc2/ 51 | mkdir build 52 | cd build/ 53 | cmake ../ -D 54 | nmake 55 | ``` 56 | 57 | If qmake is not in your path, add the qmake path to the CMake command line. 58 | ``` 59 | -DQT_QMAKE_EXECUTABLE=C:\path\to\qmake.exe 60 | ``` 61 | 62 | -------------------------------------------------------------------------------- /examples/async_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(async_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | testobject.cpp 10 | ) 11 | 12 | SET(HEADERS ${HEADERS} 13 | basicservice.h 14 | testobject.h 15 | ) 16 | 17 | # Include and link against qtrpc2 18 | SET(INCLUDES ${INCLUDES} 19 | ../../include/ 20 | ../../lib/ 21 | ) 22 | SET(LIBRARIES ${LIBRARIES} 23 | qtrpc2 24 | ) 25 | 26 | PROJECT_END() 27 | -------------------------------------------------------------------------------- /examples/async_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/async_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | 56 | ReturnValue pause(); 57 | //Adding a QObject *, const char * to the end of a function signals 58 | //QtRpc to make an asynchronous call, and to call the provided slot when 59 | //the function returns. 60 | ReturnValue pause(QObject *object, const char *slot); 61 | ReturnValue pauseAsync(QObject *obj, const char *slot); 62 | }; 63 | 64 | #endif // BASICSERVICE_H 65 | -------------------------------------------------------------------------------- /examples/async_client/testobject.cpp: -------------------------------------------------------------------------------- 1 | #include "testobject.h" 2 | #include 3 | 4 | TestObject::TestObject(QObject *parent) : 5 | QObject(parent) 6 | { 7 | } 8 | 9 | void TestObject::pause(uint id, ReturnValue ret) 10 | { 11 | if(ret.isError()) 12 | { 13 | qDebug() << "Async Pause returned with an error:" << ret; 14 | } 15 | else 16 | { 17 | qDebug() << "Async Pause returned."; 18 | } 19 | } 20 | 21 | void TestObject::pauseAsync(uint id, ReturnValue ret) 22 | { 23 | if(ret.isError()) 24 | { 25 | qDebug() << "Server Async Pause returned with an error:" << ret; 26 | } 27 | else 28 | { 29 | qDebug() << "Server Async Pause returned."; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/async_client/testobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTOBJECT_H 2 | #define TESTOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | class TestObject : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit TestObject(QObject *parent = 0); 12 | 13 | public slots: 14 | void pause(uint id, ReturnValue ret); 15 | void pauseAsync(uint id, ReturnValue ret); 16 | 17 | }; 18 | 19 | #endif // TESTOBJECT_H 20 | -------------------------------------------------------------------------------- /examples/async_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(async_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/async_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | ReturnValue pause(); 54 | ReturnValue pauseAsync(); 55 | 56 | void returnAsyncPause(); 57 | 58 | private: 59 | quint32 m_pauseId; 60 | }; 61 | 62 | #endif // BASICSERVICE_H 63 | -------------------------------------------------------------------------------- /examples/async_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "basicservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the BasicService class is created each time a client connects 57 | srv.registerService("MyService"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/auth_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(auth_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/auth_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/auth_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/auth_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(auth_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/auth_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /examples/auth_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "basicservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the BasicService class is created each time a client connects 57 | srv.registerService("MyService"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/basic_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(basic_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/basic_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/basic_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/basic_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(basic_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/basic_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /examples/basic_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "basicservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the BasicService class is created each time a client connects 57 | srv.registerService("MyService"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/data_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(data_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | dataservice.cpp 10 | ) 11 | 12 | SET(HEADERS ${HEADERS} 13 | basicservice.h 14 | dataservice.h 15 | ) 16 | 17 | # Include and link against qtrpc2 18 | SET(INCLUDES ${INCLUDES} 19 | ../../include/ 20 | ../../lib/ 21 | ) 22 | SET(LIBRARIES ${LIBRARIES} 23 | qtrpc2 24 | ) 25 | 26 | PROJECT_END() 27 | -------------------------------------------------------------------------------- /examples/data_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/data_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/data_client/dataservice.cpp: -------------------------------------------------------------------------------- 1 | #include "dataservice.h" 2 | #include 3 | 4 | QTRPC_REGISTER_METATYPE(DataService::CustomData) 5 | 6 | DataService::DataService(QObject *parent) : 7 | ClientProxy(parent) 8 | { 9 | } 10 | 11 | QDataStream& operator<<(QDataStream& d, const DataService::CustomData& object) 12 | { 13 | d << object.x; 14 | d << object.y; 15 | d << object.z; 16 | return(d); 17 | } 18 | 19 | QDataStream& operator>>(QDataStream& d, DataService::CustomData& object) 20 | { 21 | d >> object.x; 22 | d >> object.y; 23 | d >> object.z; 24 | return(d); 25 | } 26 | -------------------------------------------------------------------------------- /examples/data_client/dataservice.h: -------------------------------------------------------------------------------- 1 | #ifndef DATASERVICE_H 2 | #define DATASERVICE_H 3 | 4 | #include 5 | 6 | using namespace QtRpc; 7 | 8 | class DataService : public ClientProxy 9 | { 10 | Q_OBJECT 11 | //This macro declares a couple of operators for converting 12 | //ReturnValues to services. 13 | QTRPC_CLIENTPROXY(DataService) 14 | public: 15 | explicit DataService(QObject *parent = 0); 16 | 17 | //A custom data type returned by getData() 18 | struct CustomData 19 | { 20 | int x; 21 | int y; 22 | int z; 23 | }; 24 | 25 | signals: 26 | ReturnValue getData(); 27 | ReturnValue getBasicService(); 28 | }; 29 | 30 | //Declare QDataStream operators for any custom types to be passed over QtRpc. 31 | //These will serialize/deserialize the data for transport over the network. 32 | QDataStream& operator<<(QDataStream& d, const DataService::CustomData& object); 33 | QDataStream& operator>>(QDataStream& d, DataService::CustomData& object); 34 | 35 | //Register the custom type with the meta-object system. 36 | Q_DECLARE_METATYPE(DataService::CustomData) 37 | 38 | #endif // DATASERVICE_H 39 | -------------------------------------------------------------------------------- /examples/data_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(data_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | dataservice.cpp 10 | ) 11 | 12 | SET(HEADERS ${HEADERS} 13 | basicservice.h 14 | dataservice.h 15 | ) 16 | 17 | # Include and link against qtrpc2 18 | SET(INCLUDES ${INCLUDES} 19 | ../../include/ 20 | ../../lib/ 21 | ) 22 | SET(LIBRARIES ${LIBRARIES} 23 | qtrpc2 24 | ) 25 | 26 | PROJECT_END() 27 | -------------------------------------------------------------------------------- /examples/data_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /examples/data_server/dataservice.cpp: -------------------------------------------------------------------------------- 1 | #include "dataservice.h" 2 | #include "basicservice.h" 3 | #include 4 | 5 | //Register the custom data type, and it's QDataStream operators with Qt. 6 | QTRPC_REGISTER_METATYPE(DataService::CustomData) 7 | 8 | DataService::DataService(QObject *parent) : 9 | ServiceProxy(parent) 10 | { 11 | } 12 | 13 | ReturnValue DataService::auth(QString user, QString passwd) 14 | { 15 | return(true); 16 | } 17 | 18 | //Returns a custom data type. 19 | ReturnValue DataService::getData() 20 | { 21 | //Create the data type, and add some data. 22 | CustomData data; 23 | data.x = -1; 24 | data.y = 500; 25 | data.z = 52; 26 | 27 | //Pack the data type into a QVariant. 28 | return(QVariant::fromValue(data)); 29 | } 30 | 31 | //Returns an instance of BasicService. 32 | ReturnValue DataService::getBasicService() 33 | { 34 | //Simply return a pointer to a service. The service should have no parent. 35 | //QtRpc will take ownership of the service and remove it when the client no longer 36 | //needs it. 37 | // 38 | //Multiple clients can be passed the same service instance. In which case, the service 39 | //will be deleted once all clients are done using it. 40 | return(new BasicService()); 41 | } 42 | 43 | //Pack the custom data into a QDataStream 44 | QDataStream& operator<<(QDataStream& d, const DataService::CustomData& object) 45 | { 46 | d << object.x; 47 | d << object.y; 48 | d << object.z; 49 | return(d); 50 | } 51 | 52 | //Unpack the QDataStream into the custom data class. 53 | QDataStream& operator>>(QDataStream& d, DataService::CustomData& object) 54 | { 55 | d >> object.x; 56 | d >> object.y; 57 | d >> object.z; 58 | return(d); 59 | } 60 | -------------------------------------------------------------------------------- /examples/data_server/dataservice.h: -------------------------------------------------------------------------------- 1 | #ifndef DATASERVICE_H 2 | #define DATASERVICE_H 3 | 4 | #include 5 | 6 | using namespace QtRpc; 7 | 8 | class DataService : public ServiceProxy 9 | { 10 | Q_OBJECT 11 | public: 12 | //A custom data type returned by getData() 13 | struct CustomData 14 | { 15 | int x; 16 | int y; 17 | int z; 18 | }; 19 | 20 | explicit DataService(QObject *parent = 0); 21 | 22 | ReturnValue auth(QString user, QString passwd); 23 | 24 | public slots: 25 | ReturnValue getData(); 26 | ReturnValue getBasicService(); 27 | 28 | }; 29 | 30 | //Declare QDataStream operators for any custom types to be passed over QtRpc. 31 | //These will serialize/deserialize the data for transport over the network. 32 | QDataStream& operator<<(QDataStream& d, const DataService::CustomData& object); 33 | QDataStream& operator>>(QDataStream& d, DataService::CustomData& object); 34 | 35 | //Register the custom type with the meta-object system. 36 | Q_DECLARE_METATYPE(DataService::CustomData) 37 | 38 | #endif // DATASERVICE_H 39 | -------------------------------------------------------------------------------- /examples/data_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "dataservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the BasicService class is created each time a client connects 57 | srv.registerService("Data"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/discovery_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(discovery_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | testobject.cpp 10 | ) 11 | 12 | SET(HEADERS ${HEADERS} 13 | basicservice.h 14 | testobject.h 15 | ) 16 | 17 | # Include and link against qtrpc2 18 | SET(INCLUDES ${INCLUDES} 19 | ../../include/ 20 | ../../lib/ 21 | ) 22 | SET(LIBRARIES ${LIBRARIES} 23 | qtrpc2 24 | ) 25 | 26 | PROJECT_END() 27 | -------------------------------------------------------------------------------- /examples/discovery_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/discovery_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/discovery_client/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include "testobject.h" 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | QCoreApplication app(argc,argv); 35 | 36 | //Create the test object. 37 | TestObject object; 38 | 39 | //Service discovery requires an event loop. 40 | return(app.exec()); 41 | } 42 | -------------------------------------------------------------------------------- /examples/discovery_client/testobject.cpp: -------------------------------------------------------------------------------- 1 | #include "testobject.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "basicservice.h" 8 | 9 | TestObject::TestObject(QObject *parent) : 10 | QObject(parent) 11 | { 12 | //Create a service finder object that searches for MyService instances. 13 | ServiceFinder *finder = new ServiceFinder("MyService",this); 14 | //Connect the serviceEvent signal 15 | QObject::connect(finder, SIGNAL(serviceEvent(ServiceFinder::Service)), this, SLOT(serviceEvent(ServiceFinder::Service))); 16 | //Start scanning for services 17 | finder->scan(); 18 | } 19 | 20 | //This slot is called when a service is found 21 | void TestObject::serviceEvent(ServiceFinder::Service service) 22 | { 23 | //Bonjour may hand us bogus services. Skip them 24 | if(service.port() == 0) return; 25 | 26 | //Get the host and port of the service 27 | QString host = service.address().toString(); 28 | int port = service.port(); 29 | 30 | //Construct a URL 31 | QString url = QString("tcp://%1:%2/MyService").arg(host).arg(port); 32 | 33 | qDebug() << "Found Service:" << url; 34 | //Connect to the service 35 | connect(url); 36 | 37 | } 38 | 39 | //This is the code from the main() function of basic_client. 40 | void TestObject::connect(const QString &url) 41 | { 42 | //Create an instance of the service object 43 | BasicService service; 44 | 45 | qDebug() << "Connecting to:" << url; 46 | 47 | //Connect to the server, specifying the port, and the remove service to connect to 48 | ReturnValue ret = service.connect("tcp://localhost:10123/MyService"); 49 | //If the connection failes, ret.isError() will be true 50 | if(ret.isError()) 51 | { 52 | //You can use ReturnValues in qDebug() statements to quickly print error messages. 53 | qCritical() << "Failed to connect:" << ret; 54 | qApp->exit(1); 55 | return; 56 | } 57 | 58 | //Run the remove function. This will block untill the function returns, 59 | //Or untill the default time-out is reached 60 | ret = service.addNumbers(3,5); 61 | if(ret.isError()) 62 | { 63 | qCritical() << "Failed to call addNumbers():" << ret; 64 | qApp->exit(1); 65 | return; 66 | } 67 | 68 | //You can use ReturnValue just like a QVariant 69 | qDebug() << "Call to add() succeeded."; 70 | qDebug() << "Result:" << ret.toInt(); 71 | qDebug(); 72 | 73 | //Calling this function will return an error. 74 | ret = service.returnError(); 75 | if(ret.isError()) 76 | { 77 | //The ReturnValue class can be used to inspect the error. 78 | qDebug() << "Failed to call returnError():" << ret; 79 | qDebug() << "Error Number:" << ret.errNumber(); 80 | qDebug() << "Error String:" << ret.errString(); 81 | qDebug() << "This was expected"; 82 | } 83 | 84 | qApp->exit(0); 85 | } 86 | -------------------------------------------------------------------------------- /examples/discovery_client/testobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTOBJECT_H 2 | #define TESTOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | using namespace QtRpc; 8 | 9 | class TestObject : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit TestObject(QObject *parent = 0); 14 | 15 | public slots: 16 | void serviceEvent(ServiceFinder::Service service); 17 | 18 | public slots: 19 | void connect(const QString &url); 20 | }; 21 | 22 | #endif // TESTOBJECT_H 23 | -------------------------------------------------------------------------------- /examples/discovery_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(discovery_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/discovery_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /examples/event_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(event_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | timeservice.cpp 9 | timeobject.cpp 10 | ) 11 | 12 | SET(HEADERS ${HEADERS} 13 | timeservice.h 14 | timeobject.h 15 | ) 16 | 17 | # Include and link against qtrpc2 18 | SET(INCLUDES ${INCLUDES} 19 | ../../include/ 20 | ../../lib/ 21 | ) 22 | SET(LIBRARIES ${LIBRARIES} 23 | qtrpc2 24 | ) 25 | 26 | PROJECT_END() 27 | -------------------------------------------------------------------------------- /examples/event_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "timeservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | TimeService::TimeService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/event_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TIMESERVICE_H 29 | #define TIMESERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class TimeService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit TimeService(QObject *parent = 0); 42 | 43 | //Functions to be called over the network are signals with 44 | //a return value of ReturnValue. Running or calling this signal 45 | //Will call the remote services function, and return the result. 46 | // 47 | //Note that signals have been redeclared public, so you can call them 48 | //from outside the class... 49 | signals: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | }; 53 | 54 | #endif // TIMESERVICE_H 55 | -------------------------------------------------------------------------------- /examples/event_client/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include "timeservice.h" 31 | #include "timeobject.h" 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | QCoreApplication app(argc,argv); 36 | 37 | //Create an instance of the service object 38 | TimeService service; 39 | 40 | //Connect to the server, specifying the port, and the remove service to connect to 41 | ReturnValue ret = service.connect("tcp://localhost:10123/Time"); 42 | //If the connection failes, ret.isError() will be true 43 | if(ret.isError()) 44 | { 45 | //You can use ReturnValues in qDebug() statements to quickly print error messages. 46 | qCritical() << "Failed to connect:" << ret; 47 | return(1); 48 | } 49 | 50 | TimeObject object; 51 | 52 | //Connect the currentTime signal from the service to the currentTime signal of the test object 53 | //This will print the current time whenever the server emits the currentTIme signal. 54 | QObject::connect(&service, SIGNAL(currentTime(QDateTime)), &object, SLOT(currentTime(QDateTime))); 55 | 56 | //Event and asynchronous calls need an event loop. 57 | return(app.exec()); 58 | } 59 | -------------------------------------------------------------------------------- /examples/event_client/timeobject.cpp: -------------------------------------------------------------------------------- 1 | #include "timeobject.h" 2 | #include 3 | 4 | TimeObject::TimeObject(QObject *parent) : 5 | QObject(parent) 6 | { 7 | } 8 | 9 | void TimeObject::currentTime(QDateTime time) 10 | { 11 | qDebug() << "Current Time:" << time.toString(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/event_client/timeobject.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEOBJECT_H 2 | #define TIMEOBJECT_H 3 | 4 | #include 5 | #include 6 | 7 | class TimeObject : public QObject 8 | { 9 | Q_OBJECT 10 | public: 11 | explicit TimeObject(QObject *parent = 0); 12 | 13 | public slots: 14 | void currentTime(QDateTime time); 15 | 16 | }; 17 | 18 | #endif // TIMEOBJECT_H 19 | -------------------------------------------------------------------------------- /examples/event_client/timeservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "timeservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | TimeService::TimeService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/event_client/timeservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TIMESERVICE_H 29 | #define TIMESERVICE_H 30 | 31 | #include 32 | #include 33 | 34 | using namespace QtRpc; 35 | 36 | //Client service inherit from ClientProxy 37 | //Inheriting from another client service is also allowed 38 | class TimeService : public ClientProxy 39 | { 40 | Q_OBJECT 41 | //This macro declares a couple of operators for converting 42 | //ReturnValues to services. 43 | QTRPC_CLIENTPROXY(TimeService) 44 | public: 45 | explicit TimeService(QObject *parent = 0); 46 | 47 | //Functions to be called over the network are signals with 48 | //a return value of ReturnValue. Running or calling this signal 49 | //Will call the remote services function, and return the result. 50 | // 51 | //Signals with a return type of Event are events. And act like 52 | //normal Qt signals. You can connect to and emit them as normal 53 | //The events will be transfered over the network and re-emitted 54 | //on the client side. 55 | // 56 | //Note that signals have been redeclared public, so you can call them 57 | //from outside the class... 58 | signals: 59 | Event currentTime(QDateTime time); 60 | }; 61 | 62 | #endif // TIMESERVICE_H 63 | -------------------------------------------------------------------------------- /examples/event_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(event_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | timeservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | timeservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/event_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "timeservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the TimeService class is created each time a client connects 57 | srv.registerService("Time"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/event_server/timeservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "timeservice.h" 29 | #include 30 | 31 | //This is run after a client connects, but before authentication takes place. 32 | //You can do initializtion here, but do nothing that requires authentication. 33 | TimeService::TimeService(QObject *parent) : 34 | ServiceProxy(parent) 35 | { 36 | //Create the timer, and connec the slot, but do not start it untill authentication succeeds 37 | m_timer = new QTimer(this); 38 | connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout())); 39 | } 40 | 41 | //Authentication function. Currently allows anyone to connect 42 | //To return an authentication failure, use 43 | //return(ReturnValue(1,"Incorrect username or password")); 44 | //The first argument is the error number, the second is the error string. 45 | //Both values can be set to anything, and only have value to the application 46 | ReturnValue TimeService::auth(QString user, QString pass) 47 | { 48 | //Authentication will succeed, so start the timer. 49 | m_timer->start(1000); 50 | return(true); 51 | } 52 | 53 | void TimeService::timeout() 54 | { 55 | emit(currentTime(QDateTime::currentDateTime())); 56 | } 57 | -------------------------------------------------------------------------------- /examples/md5auth_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(md5auth_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/md5auth_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/md5auth_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | ReturnValue salt(); 56 | ReturnValue authenticate(const QString &hash); 57 | }; 58 | 59 | #endif // BASICSERVICE_H 60 | -------------------------------------------------------------------------------- /examples/md5auth_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(md5auth_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/md5auth_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(AuthToken token); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | ReturnValue salt(); 53 | ReturnValue authenticate(const QString &hash); 54 | 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/md5auth_server/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "basicservice.h" 33 | 34 | using namespace QtRpc; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | QCoreApplication app(argc,argv); 39 | 40 | //Create a server object with default threading options 41 | Server srv; 42 | 43 | //Create a TCP listener object 44 | ServerProtocolListenerTcp tcp(&srv); 45 | 46 | //Listen on port 10123 on all network interfaces 47 | if(!tcp.listen(QHostAddress::Any, 10123)) 48 | { 49 | //This function returns false if the port is busy 50 | qCritical() << "Failed to listen on port 10123!"; 51 | return(1); 52 | } 53 | 54 | //Register a service. The template argument is the ServiceProxy class to use 55 | //The string argument is the name used to connect to the service 56 | //A new instance of the BasicService class is created each time a client connects 57 | srv.registerService("MyService"); 58 | 59 | //Process Events 60 | return app.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /examples/ssl_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(ssl_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/ssl_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/ssl_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/ssl_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(ssl_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/ssl_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /examples/ssl_server/examplecert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQCsYc8DYLoW3ubdSywGgp30fOCSwlRDrPIgjTeNF8BCUp5uYX1J 3 | O03bRGMBt+TwDnQccMgxe/xwdtphbNmvxowqGnVmoiQg0TWR2a9oG1BgSSeY3f1d 4 | Gj+JrlV6JBjJg1aESFPArZ+biOeOKonSFJK5pd3ev66f5m3H6ok+8Xo8FwIDAQAB 5 | AoGBAJjH83c18pi0pH870eBPQfnf+BZ6v75feRXas4KMq2zc1uhT5XvTYPTWjr2G 6 | JBWTaduPJg+dqSZwYKr6k5FT8wMln2J67WuiT6CfhTY8uWMwbMl8OFBlYOXwx3B3 7 | EqFmKzLolDq/k9V+9LSRDeTIikbcHvOLFTdNSPt7ML1xNG05AkEA07V0IWrcinPJ 8 | 6a2nCHU1lVUkPum7tiZ8N1jKqOKfeKmoCOMj9TqQFyEiKbzt8NVzf8gH44lrJlKi 9 | otLG24RHcwJBANByH0MoeFdm/X6rJ9J2U896bIHo6o763GddpC7bxss4X8kiGlfo 10 | ItkqdQ6NudltUZ1qKpKcKsiBUmbSuwQLp80CQDprA5SFDD4YHUsh48ltrk96ovnJ 11 | PUbR78zF74YSoraE+h0ZsD5m3oPDXM3vmCiwfaJw69xZevukKcSMLNs98QkCQDqC 12 | jjvvtDf0dNuFd5wgEs5+cs7UbmLMD+oD4v40Osz4egqfQ/3A72c9/7WiGrTpdqtV 13 | DbYxl+DITDUIme48x1ECQQDFO2apgPBmq+2Bzf09KveGDBq2F3EbajmeNd1veDzz 14 | Mn0qoxgmXhDR1Dx1VoDzRRz2y8vX+jiEbar4g7zJ0ceM 15 | -----END RSA PRIVATE KEY----- 16 | 17 | -------------------------------------------------------------------------------- /examples/thread_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(thread_client EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/thread_client/basicservice.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "basicservice.h" 29 | 30 | //You don't have to do anything here. 31 | 32 | BasicService::BasicService(QObject *parent) : 33 | ClientProxy(parent) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /examples/thread_client/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //Client service inherit from ClientProxy 36 | //Inheriting from another client service is also allowed 37 | class BasicService : public ClientProxy 38 | { 39 | Q_OBJECT 40 | //This macro declares a couple of operators for converting 41 | //ReturnValues to services. 42 | QTRPC_CLIENTPROXY(BasicService) 43 | public: 44 | explicit BasicService(QObject *parent = 0); 45 | 46 | //Functions to be called over the network are signals with 47 | //a return value of ReturnValue. Running or calling this signal 48 | //Will call the remote services function, and return the result. 49 | // 50 | //Note that signals have been redeclared public, so you can call them 51 | //from outside the class... 52 | signals: 53 | ReturnValue addNumbers(int a, int b); 54 | ReturnValue returnError(); 55 | }; 56 | 57 | #endif // BASICSERVICE_H 58 | -------------------------------------------------------------------------------- /examples/thread_server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(thread_server EXECUTABLE) 2 | 3 | USE_QT_LIB(Network) 4 | USE_QT_LIB(Core) 5 | 6 | SET(SOURCES ${SOURCES} 7 | main.cpp 8 | basicservice.cpp 9 | ) 10 | 11 | SET(HEADERS ${HEADERS} 12 | basicservice.h 13 | ) 14 | 15 | # Include and link against qtrpc2 16 | SET(INCLUDES ${INCLUDES} 17 | ../../include/ 18 | ../../lib/ 19 | ) 20 | SET(LIBRARIES ${LIBRARIES} 21 | qtrpc2 22 | ) 23 | 24 | PROJECT_END() 25 | -------------------------------------------------------------------------------- /examples/thread_server/basicservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef BASICSERVICE_H 29 | #define BASICSERVICE_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | //All services must inherit from the ServiceProxy class. 36 | //Inheriting from another service is also supported. 37 | class BasicService : public ServiceProxy 38 | { 39 | Q_OBJECT 40 | public: 41 | explicit BasicService(QObject *parent = 0); 42 | 43 | //This is the authentication function called by QtRpc2 uppon connection 44 | virtual ReturnValue auth(QString user, QString pass); 45 | 46 | //To allow functions to be called over the network, they must be public 47 | //slots, and have a return type of ReturnValue. This automatically registers 48 | //them to be used for a QtRpc2 service. 49 | public slots: 50 | ReturnValue addNumbers(int a, int b); 51 | ReturnValue returnError(); 52 | 53 | }; 54 | 55 | #endif // BASICSERVICE_H 56 | -------------------------------------------------------------------------------- /include/AuthToken: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/AutomaticMetatypeRegistry: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientMessageBus: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolBase: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolIODevice: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolSocket: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolTcp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolTest: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProtocolThread: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ClientProxy: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/Message: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ProxyBase: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/QtRpcGlobal: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /include/QxtPimpl: -------------------------------------------------------------------------------- 1 | #include "qxtpimpl.h" 2 | 3 | -------------------------------------------------------------------------------- /include/ReturnValue: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | -------------------------------------------------------------------------------- /include/Server: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolInstanceBase: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolInstanceIODevice: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolInstanceSocket: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolInstanceTcp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolListenerBase: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolListenerProcess: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolListenerSocket: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerProtocolListenerTcp: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServerThread: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServiceFactory: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServiceFinder: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServiceProxy: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/ServicePublisher: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /include/Signature: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2008 by Brendan Powers * 3 | * brendan@resara.com * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify * 6 | * it under the terms of the GNU Library General Public License as * 7 | * published by the Free Software Foundation; either version 2 of the * 8 | * License, or (at your option) any later version. * 9 | * * 10 | * This program is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 | * GNU General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU Library General Public * 16 | * License along with this program; if not, write to the * 17 | * Free Software Foundation, Inc., * 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 | ***************************************************************************/ 20 | 21 | #include 22 | -------------------------------------------------------------------------------- /include/Sleeper: -------------------------------------------------------------------------------- 1 | #include "sleeper.h" 2 | -------------------------------------------------------------------------------- /lib/clientprotocolbase_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef CLIENTPROTOCOLBASE_P_H 33 | #define CLIENTPROTOCOLBASE_P_H 34 | 35 | #include 36 | #include 37 | #include "clientprotocolbase.h" 38 | #include 39 | 40 | namespace QtRpc 41 | { 42 | 43 | /** 44 | @author Chris Vickery 45 | */ 46 | class ClientProtocolBasePrivate : public QxtPrivate 47 | { 48 | public: 49 | ClientProtocolBasePrivate() : 50 | connectId(1), 51 | selectServiceId(3), 52 | version(0) 53 | { 54 | } 55 | 56 | QUrl url; 57 | quint32 connectId; 58 | quint32 selectServiceId; 59 | quint32 version; 60 | 61 | }; 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /lib/clientprotocolsocket_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCCLIENTPROTOCOLSOCKET_P_H 33 | #define QTRPCCLIENTPROTOCOLSOCKET_P_H 34 | 35 | #include 36 | #include 37 | #include "clientprotocolsocket.h" 38 | #include 39 | 40 | namespace QtRpc 41 | { 42 | 43 | /** 44 | @author Chris Vickery 45 | */ 46 | class ClientProtocolSocketPrivate : public QxtPrivate 47 | { 48 | public: 49 | ClientProtocolSocketPrivate() 50 | { 51 | } 52 | 53 | QLocalSocket socket; 54 | }; 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/clientprotocoltest_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCCLIENTPROTOCOLTEST_P_H 33 | #define QTRPCCLIENTPROTOCOLTEST_P_H 34 | 35 | #include 36 | #include "clientprotocoltest.h" 37 | #include 38 | 39 | namespace QtRpc 40 | { 41 | 42 | /** 43 | @author Chris Vickery 44 | */ 45 | class ClientProtocolTestPrivate : public QxtPrivate 46 | { 47 | public: 48 | ClientProtocolTestPrivate() 49 | { 50 | } 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /lib/clientprotocolthread_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef CLIENTPROTOCOLTHREAD_P_H 33 | #define CLIENTPROTOCOLTHREAD_P_H 34 | 35 | #include 36 | #include 37 | #include "clientprotocolthread.h" 38 | #include 39 | 40 | namespace QtRpc 41 | { 42 | 43 | /** 44 | @author Chris Vickery 45 | */ 46 | class ClientProtocolThreadPrivate : public QxtPrivate 47 | { 48 | public: 49 | ClientProtocolThreadPrivate() 50 | { 51 | } 52 | 53 | QWaitCondition waiter; 54 | 55 | }; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /lib/qtrpcglobal.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPC2GLOBAL_H 33 | #define QTRPC2GLOBAL_H 34 | 35 | #ifdef QTRPC2_BUILD_LIB 36 | #define USE_QTRPC_PRIVATE_API 37 | #define QTRPC2_EXPORT Q_DECL_EXPORT 38 | #else 39 | #define QTRPC2_EXPORT Q_DECL_IMPORT 40 | #endif 41 | 42 | #endif // QTRPC2GLOBAL_H 43 | -------------------------------------------------------------------------------- /lib/qtrpcprivate.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #include 33 | #ifndef USE_QTRPC_PRIVATE_API 34 | #error You have included headers to private API, this is not safe to do as ABI and API compatibility are not guarenteed. 35 | #error If you are sure you want to use this, define USE_QTRPC_PRIVATE_API to disable this error 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/qxtavahipoll.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTAVAHIPOLL_H 27 | #define QXTAVAHIPOLL_H 28 | 29 | #include 30 | /** 31 | @author Chris Vickery 32 | */ 33 | 34 | struct AvahiPoll; 35 | 36 | /** 37 | * This function makes the avahi and Qt get along nicely. 38 | * This function is only useful for programs using the Avahi library, otherwise it will effectively do nothing. 39 | * @return AvahiPoll structure for use with avahi 40 | */ 41 | const AvahiPoll* qxtAvahiPoll(void); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/qxtavahipoll_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTAVAHIPOLL_P_H 27 | #define QXTAVAHIPOLL_P_H 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | // Private QObject that does all the work 35 | 36 | /** 37 | @author Chris Vickery 38 | */ 39 | class AvahiWatch : public QObject 40 | { 41 | Q_OBJECT 42 | public: 43 | AvahiWatch(int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void* userdata); 44 | ~AvahiWatch(); 45 | void setEventType(AvahiWatchEvent event); 46 | AvahiWatchEvent lastEvent(); 47 | 48 | private slots: 49 | void activated(int); 50 | 51 | private: 52 | QSocketNotifier* _notifier; 53 | int _fd; 54 | AvahiWatchEvent _event; 55 | AvahiWatchEvent _lastEvent; 56 | AvahiWatchCallback _callback; 57 | void* _userdata; 58 | }; 59 | 60 | class AvahiTimeout : public QObject 61 | { 62 | Q_OBJECT 63 | public: 64 | AvahiTimeout(const struct timeval *tv, AvahiTimeoutCallback callback, void* userdata); 65 | ~AvahiTimeout(); 66 | void updateTimeout(const struct timeval *tv); 67 | 68 | private slots: 69 | void timeout(); 70 | private: 71 | QTimer _timer; 72 | AvahiTimeoutCallback _callback; 73 | void* _userdata; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /lib/qxtdiscoverableservicename.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTDISCOVERABLESERVICENAME_H 26 | #define QXTDISCOVERABLESERVICENAME_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | class QxtDiscoverableServiceNamePrivate; 35 | class QTRPC2_EXPORT QxtDiscoverableServiceName 36 | { 37 | QXT_DECLARE_PRIVATE(QxtDiscoverableServiceName) 38 | public: 39 | QxtDiscoverableServiceName(); 40 | QxtDiscoverableServiceName(const QByteArray& domainName); 41 | QxtDiscoverableServiceName(const QString& name, const QString& serviceType, const QString& domain, 42 | QAbstractSocket::SocketType socketType = QAbstractSocket::UnknownSocketType); 43 | 44 | QString serviceName() const; 45 | void setServiceName(const QString& name); 46 | 47 | QAbstractSocket::SocketType socketType() const; 48 | void setSocketType(QAbstractSocket::SocketType type); 49 | 50 | QString serviceType() const; 51 | void setServiceType(const QString& type); 52 | QByteArray fullServiceType() const; 53 | 54 | QString domain() const; 55 | void setDomain(const QString& domain); 56 | 57 | QString host() const; 58 | void setHost(const QString& host); 59 | 60 | QByteArray escapedFullDomainName() const; 61 | 62 | //mDNS stuff 63 | static int lookupHost(const QString name, QObject* receiver, const char* member); 64 | static void abortHostLookup(int id); 65 | }; 66 | 67 | #endif // QXTDISCOVERABLESERVICENAME_H 68 | -------------------------------------------------------------------------------- /lib/qxtmdns.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifdef Q_OS_LINUX 27 | #include 28 | #else 29 | #include 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/qxtmdns_avahi.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtZeroconf module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTMDNS_H 27 | #define QXTMDNS_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | class QxtMDNSPrivate; 34 | 35 | // This class just throws QHostInfo objects at the receiver... 36 | // The receiver slot should take 1 parameter, a QHostInfo... 37 | class QTRPC2_EXPORT QxtMDNS : public QObject 38 | { 39 | QXT_DECLARE_PRIVATE(QxtMDNS); 40 | Q_OBJECT 41 | public: 42 | QxtMDNS(int id = -1, QObject* parent = 0); 43 | 44 | void doLookup(QString name, QObject * receiver, const char * member); 45 | void cancelLookup(); 46 | }; 47 | 48 | #endif //#ifndef QXTMDNS_H 49 | -------------------------------------------------------------------------------- /lib/qxtmdns_avahi_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtZeroconf module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | 26 | #ifndef QXTMDNS_P_H 27 | #define QXTMDNS_P_H 28 | 29 | #include "qxtmdns_avahi.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | class QxtMDNSPrivate : public QxtPrivate 38 | { 39 | public: 40 | QxtMDNSPrivate() 41 | { 42 | } 43 | 44 | static void avahiClientCallback(AvahiClient *s, AvahiClientState state, void *userdata); 45 | static void avahiRecordBrowserCallback(AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata); 46 | 47 | QHostInfo info; 48 | QList addresses; 49 | 50 | QString name; 51 | QObject* receiver; 52 | QByteArray member; 53 | AvahiClient* client; 54 | AvahiRecordBrowser* recordbrowser; 55 | bool sent; 56 | int id; 57 | }; 58 | 59 | 60 | #endif //#ifndef QXTMDNS_H 61 | -------------------------------------------------------------------------------- /lib/qxtmdns_bonjour.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTMDNS_H 26 | #define QXTMDNS_H 27 | 28 | #include 29 | #include 30 | #include 31 | // This is because bonjour thinks that if you're on windows, you're using MSVC >.> 32 | #if defined(Q_CC_GNU) && defined(Q_OS_WIN32) 33 | #undef _WIN32 34 | #endif 35 | #include 36 | #if defined(Q_CC_GNU) && defined(Q_OS_WIN32) 37 | #define _WIN32 38 | #endif 39 | #include 40 | 41 | class QTRPC2_EXPORT QxtMDNS : public QObject 42 | { 43 | Q_OBJECT 44 | public: 45 | QxtMDNS(int id = -1, QObject* parent = 0); 46 | 47 | void doLookup(QString name, QObject * receiver, const char * member); 48 | void cancelLookup(); 49 | 50 | static void DNSSD_API DNSServiceQueryRecordCallback(DNSServiceRef DNSServiceRef, DNSServiceFlags flags, uint32_t interfaceIndex, DNSServiceErrorType errorCode, const char *fullname, uint16_t rrtype, uint16_t rrclass, uint16_t rdlen, const void *rdata, uint32_t ttl, void *context); 51 | 52 | QHostInfo info; 53 | QList addresses; 54 | QString name; 55 | QObject* receiver; 56 | QString member; 57 | DNSServiceRef ref; 58 | QSocketNotifier* notifier; 59 | int id; 60 | public Q_SLOTS: 61 | void socketData(); 62 | 63 | 64 | }; 65 | 66 | #endif //#ifndef QXTMDNS_H 67 | -------------------------------------------------------------------------------- /lib/qxtservicebrowser.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSERVICEBROWSER_H 26 | #define QXTSERVICEBROWSER_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "qxtdiscoverableservicename.h" 33 | 34 | class QxtServiceBrowserPrivate; 35 | class QTRPC2_EXPORT QxtServiceBrowser : public QObject, public QxtDiscoverableServiceName 36 | { 37 | Q_OBJECT 38 | QXT_DECLARE_PRIVATE(QxtServiceBrowser); 39 | public: 40 | QxtServiceBrowser(const QString& serviceType, QObject* parent = 0); 41 | QxtServiceBrowser(const QString& serviceType, QAbstractSocket::SocketType socketType, QObject* parent = 0); 42 | virtual ~QxtServiceBrowser(); 43 | 44 | bool isBrowsing() const; 45 | 46 | public slots: 47 | void browse(/* int iface */); 48 | void stopBrowsing(); 49 | 50 | public: 51 | QStringList serviceSubTypes() const; 52 | void setServiceSubTypes(const QStringList& subtypes); 53 | void addServiceSubType(const QString& subtype); 54 | void removeServiceSubType(const QString& subtype); 55 | bool hasServiceSubType(const QString& subtype); 56 | 57 | Q_SIGNALS: 58 | void browsingFailed(int errorCode); 59 | void serviceAdded(const QString& serviceName, const QString& domain); 60 | void serviceRemoved(const QString& serviceName, const QString& domain); 61 | }; 62 | 63 | #endif // QXTSERVICEBROWSER_H 64 | -------------------------------------------------------------------------------- /lib/qxtservicebrowser_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSERVICEBROWSER_P_H 26 | #define QXTSERVICEBROWSER_P_H 27 | 28 | #include "qxtservicebrowser.h" 29 | 30 | // This is because bonjour thinks that if you're on windows, you're using MSVC >.> 31 | #if defined(Q_CC_GNU) && defined(Q_OS_WIN32) 32 | #undef _WIN32 33 | #endif 34 | #include 35 | #if defined(Q_CC_GNU) && defined(Q_OS_WIN32) 36 | #define _WIN32 37 | #endif 38 | #include 39 | 40 | class QSocketNotifier; 41 | class QxtServiceBrowserPrivate : public QObject, public QxtPrivate 42 | { 43 | Q_OBJECT 44 | public: 45 | QXT_DECLARE_PUBLIC(QxtServiceBrowser) 46 | QxtServiceBrowserPrivate() 47 | : QObject(), 48 | service(0), 49 | iface(0), 50 | notifier(0) 51 | { 52 | } 53 | 54 | DNSServiceRef service; 55 | 56 | QString domain; 57 | QAbstractSocket::SocketType socketType; 58 | QString serviceType; 59 | QStringList serviceSubTypes; 60 | int iface; 61 | 62 | QSocketNotifier* notifier; 63 | 64 | static void DNSSD_API browseServiceCallback(DNSServiceRef service, DNSServiceFlags flags, quint32 iface, DNSServiceErrorType errCode, 65 | const char* serviceName, const char* regtype, const char* replyDomain, void* context); 66 | 67 | public Q_SLOTS: 68 | void socketData(); 69 | }; 70 | 71 | #endif // QXTSERVICEBROWSER_P_H 72 | -------------------------------------------------------------------------------- /lib/qxtzeroconf.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) Qxt Foundation. Some rights reserved. 4 | ** 5 | ** This file is part of the QxtWeb module of the Qxt library. 6 | ** 7 | ** This library is free software; you can redistribute it and/or modify it 8 | ** under the terms of the Common Public License, version 1.0, as published 9 | ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 | ** version 2.1, as published by the Free Software Foundation. 11 | ** 12 | ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 | ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 | ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 | ** FITNESS FOR A PARTICULAR PURPOSE. 16 | ** 17 | ** You should have received a copy of the CPL and the LGPL along with this 18 | ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 | ** included with the source distribution for more information. 20 | ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 | ** 22 | ** 23 | ** 24 | ****************************************************************************/ 25 | #ifndef QXTSERVICEBROWSER_H 26 | #define QXTSERVICEBROWSER_H 27 | 28 | #include "qxtdiscoverableservice.h" 29 | #include "qxtdiscoverableservicename.h" 30 | #include "qxtservicebrowser.h" 31 | 32 | #endif // QXTSERVICEBROWSER_H 33 | -------------------------------------------------------------------------------- /lib/server_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVER_P_H 33 | #define QTRPCSERVER_P_H 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | namespace QtRpc 44 | { 45 | 46 | /** 47 | @author Chris Vickery 48 | */ 49 | class ServerPrivate : public QxtPrivate 50 | { 51 | public: 52 | ServerPrivate() 53 | : threadMutex(QMutex::Recursive) 54 | { 55 | } 56 | QMutex servicemutex; 57 | Server::ThreadType threadType; 58 | QList threadCount; 59 | QList threads; 60 | QMutex threadMutex; 61 | 62 | }; 63 | 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /lib/serverprotocollistenerbase_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVERPROTOCOLLISTENERBASE_P_H 33 | #define QTRPCSERVERPROTOCOLLISTENERBASE_P_H 34 | 35 | #include 36 | #include "server.h" 37 | #include "serverprotocollistenerbase.h" 38 | #include 39 | 40 | namespace QtRpc 41 | { 42 | 43 | /** 44 | @author Chris Vickery 45 | */ 46 | class ServerProtocolListenerBasePrivate : public QxtPrivate 47 | { 48 | public: 49 | ServerProtocolListenerBasePrivate() 50 | { 51 | } 52 | 53 | Server* serv; 54 | }; 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lib/serverprotocollistenerprocess_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVERPROTOCOLLISTENERPROCESS_P_H 33 | #define QTRPCSERVERPROTOCOLLISTENERPROCESS_P_H 34 | 35 | #include 36 | #include 37 | #include "serverprotocollistenerprocess.h" 38 | #include 39 | 40 | namespace QtRpc 41 | { 42 | 43 | /** 44 | @author Chris Vickery 45 | */ 46 | class ServerProtocolListenerProcessPrivate : public QxtPrivate 47 | { 48 | public: 49 | ServerProtocolListenerProcessPrivate() 50 | { 51 | } 52 | 53 | QString cert; 54 | ServerProtocolListenerProcess::SslMode sslmode; 55 | 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /lib/serverprotocollistenersocket_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVERPROTOCOLLISTENERSOCKET_P_H 33 | #define QTRPCSERVERPROTOCOLLISTENERSOCKET_P_H 34 | 35 | #include 36 | #include "serverprotocollistenersocket.h" 37 | #include 38 | 39 | namespace QtRpc 40 | { 41 | 42 | /** 43 | @author Chris Vickery 44 | */ 45 | class ServerProtocolListenerSocketPrivate : public QxtPrivate 46 | { 47 | public: 48 | ServerProtocolListenerSocketPrivate() 49 | { 50 | } 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/serverthread.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #include "serverthread.h" 33 | #include "serverthread_p.h" 34 | 35 | #include 36 | 37 | namespace QtRpc 38 | { 39 | 40 | ServerThread::ServerThread(QObject *parent) : QThread(parent) 41 | { 42 | QXT_INIT_PRIVATE(ServerThread); 43 | connect(this, SIGNAL(finished()), this, SLOT(deleteLater())); 44 | } 45 | 46 | ServerThread::~ServerThread() 47 | { 48 | wait(); 49 | } 50 | 51 | void ServerThread::run() 52 | { 53 | exec(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /lib/serverthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVERTHREAD_H 33 | #define QTRPCSERVERTHREAD_H 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | namespace QtRpc 40 | { 41 | 42 | class ServerThreadPrivate; 43 | 44 | /** 45 | @author Brendan Powers 46 | */ 47 | class ServerThread : public QThread 48 | { 49 | QXT_DECLARE_PRIVATE(ServerThread); 50 | Q_OBJECT 51 | public: 52 | ServerThread(QObject *parent = 0); 53 | ~ServerThread(); 54 | 55 | protected: 56 | void run(); 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /lib/serverthread_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVERTHREAD_P_H 33 | #define QTRPCSERVERTHREAD_P_H 34 | 35 | #include 36 | #include "serverthread.h" 37 | #include 38 | 39 | namespace QtRpc 40 | { 41 | 42 | /** 43 | @author Chris Vickery 44 | */ 45 | class ServerThreadPrivate : public QxtPrivate 46 | { 47 | public: 48 | ServerThreadPrivate() 49 | { 50 | } 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /lib/servicefactoryparent_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVICEFACTORYPARENT_P_H 33 | #define QTRPCSERVICEFACTORYPARENT_P_H 34 | 35 | #include 36 | #include "servicefactory.h" 37 | 38 | namespace QtRpc 39 | { 40 | 41 | /** 42 | @author Chris Vickery 43 | */ 44 | class ServiceFactoryParentPrivate : public QxtPrivate 45 | { 46 | public: 47 | ServiceFactoryParentPrivate(); 48 | ~ServiceFactoryParentPrivate(); 49 | 50 | ServiceProxy* service; 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /lib/servicepublisher_p.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSERVICEPUBLISHER_P_H 33 | #define QTRPCSERVICEPUBLISHER_P_H 34 | 35 | #include 36 | #include 37 | #include "qxtdiscoverableservice.h" 38 | #include 39 | #include 40 | #include 41 | 42 | namespace QtRpc 43 | { 44 | 45 | /** 46 | @author Chris Vickery 47 | */ 48 | class ServicePublisherPrivate : public QxtPrivate 49 | { 50 | public: 51 | QXT_DECLARE_PUBLIC(ServicePublisher); 52 | QString friendlyName; 53 | QxtDiscoverableService* zeroconf; 54 | QMutex mutex; 55 | ServiceProxy* service; 56 | int port; 57 | 58 | }; 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/sleeper.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2011, Resara LLC * 3 | * All rights reserved. * 4 | * * 5 | * Redistribution and use in source and binary forms, with or without * 6 | * modification, are permitted provided that the following conditions are * 7 | * met: * 8 | * * Redistributions of source code must retain the above copyright * 9 | * notice, this list of conditions and the following disclaimer. * 10 | * * Redistributions in binary form must reproduce the above * 11 | * copyright notice, this list of conditions and the following * 12 | * disclaimer in the documentation and/or other materials * 13 | * provided with the distribution. * 14 | * * Neither the name of Resara LLC nor the names of its * 15 | * contributors may be used to endorse or promote products * 16 | * derived from this software without specific prior written * 17 | * permission. * 18 | * * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE * 23 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * 26 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * 27 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * 28 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * 29 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 30 | * * 31 | ***************************************************************************/ 32 | #ifndef QTRPCSLEEPER_H 33 | #define QTRPCSLEEPER_H 34 | 35 | #include 36 | #include 37 | 38 | namespace QtRpc 39 | { 40 | 41 | class QTRPC2_EXPORT Sleeper : private QThread 42 | { 43 | Q_DISABLE_COPY(Sleeper); 44 | public: 45 | using QThread::msleep; 46 | using QThread::sleep; 47 | using QThread::usleep; 48 | }; 49 | 50 | } 51 | 52 | 53 | #endif //#ifndef QTRPCSLEEPER_H 54 | -------------------------------------------------------------------------------- /testclient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(qtrpc2.testclient EXECUTABLE) 2 | 3 | 4 | SET(SOURCES ${SOURCES} 5 | main.cpp 6 | testclient.cpp 7 | testthread.cpp 8 | testcaller.cpp 9 | testsyncro.cpp 10 | ) 11 | 12 | USE_QT_LIB(Network) 13 | USE_QT_LIB(Core) 14 | 15 | SET(HEADERS ${HEADERS} 16 | testclient.h 17 | testthread.h 18 | testcaller.h 19 | testsyncro.h 20 | ) 21 | SET(INCLUDES ${INCLUDES} 22 | ../ 23 | ../include/ 24 | ) 25 | 26 | SET(LIBRARIES ${LIBRARIES} 27 | qtrpc2 28 | ) 29 | 30 | PROJECT_END() 31 | 32 | -------------------------------------------------------------------------------- /testclient/testcaller.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TESTCALLER_H 29 | #define TESTCALLER_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | using namespace QtRpc; 38 | 39 | /** 40 | @author Chris Vickery 41 | */ 42 | class TestCaller : public ClientProxy 43 | { 44 | Q_OBJECT 45 | public: 46 | TestCaller(QObject* parent = 0); 47 | TestCaller(const TestCaller& tc, QObject* parent = 0); 48 | ~TestCaller(); 49 | 50 | signals: 51 | void sendFunctionSignal(uint, Signature sig, Arguments args, QString type); 52 | Event testEvent(QString); 53 | Event testEvent(); 54 | ReturnValue largeValues(QString); 55 | ReturnValue somethingElse(QByteArray); 56 | 57 | public slots: 58 | void callMegaString(); 59 | void receiveEvent(QString); 60 | void receiveEvent(); 61 | void functionReturn(uint id, ReturnValue ret); 62 | ReturnValue testCallback(int num, QVariant rediculous); 63 | void callSomethingElse(QObject*, const char*, QByteArray); 64 | void serviceEvent(ServiceFinder::Service); 65 | 66 | protected: 67 | QString megaString; 68 | QMutex mutex; 69 | 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /testclient/testclient.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TESTCLIENT_H 29 | #define TESTCLIENT_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | using namespace QtRpc; 36 | 37 | /** 38 | @author Chris Vickery 39 | */ 40 | class TestClient : public ClientProxy 41 | { 42 | Q_OBJECT 43 | public: 44 | TestClient(QObject* parent = 0); 45 | ~TestClient(); 46 | 47 | signals: 48 | Event event_0(QString); 49 | ReturnValue syncfunction_1(QString); 50 | ReturnValue asyncfunction_3(QObject*, const char*, QByteArray); 51 | ReturnValue syncfunction_4(); 52 | ReturnValue default_param_function(QString arg1, int arg2 = 5); 53 | public slots: 54 | void call_syncfunction_1(); 55 | void receiveEvent(QString); 56 | void functionReturn(uint id, ReturnValue ret); 57 | ReturnValue callback_2(int num, QVariant rediculous); 58 | protected: 59 | QString megaString; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /testclient/testsyncro.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "testsyncro.h" 29 | 30 | using namespace QtRpc; 31 | 32 | TestSyncro::TestSyncro(QObject *parent) 33 | : ClientProxy(parent) 34 | { 35 | megaString = "zxcvbnmasdfghjklqwertyuiop"; 36 | for (int i = 0 ; i < 2 ; i++) 37 | { 38 | megaString += megaString; 39 | } 40 | } 41 | 42 | TestSyncro::~TestSyncro() 43 | { 44 | } 45 | 46 | void TestSyncro::callMegaString() 47 | { 48 | qDebug() << "String Iteration!"; 49 | ReturnValue ret = largeValues(megaString); 50 | QString value = ret.toString(); 51 | if (value != megaString) 52 | qFatal(qPrintable(QString("ERROR: Malformed megastring: %1 (%2)").arg(value).arg(ret.errString()))); 53 | } 54 | 55 | 56 | -------------------------------------------------------------------------------- /testclient/testsyncro.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TESTSYNCRO_H 29 | #define TESTSYNCRO_H 30 | 31 | #include 32 | #include 33 | 34 | using namespace QtRpc; 35 | 36 | /** 37 | @author Chris Vickery 38 | */ 39 | class TestSyncro : public ClientProxy 40 | { 41 | Q_OBJECT 42 | public: 43 | TestSyncro(QObject *parent = 0); 44 | ~TestSyncro(); 45 | QString megaString; 46 | void callMegaString(); 47 | signals: 48 | ReturnValue largeValues(QString); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /testclient/testthread.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "testthread.h" 29 | #include "sleeper.h" 30 | 31 | TestThread::TestThread(QObject *parent) : QThread(parent) 32 | { 33 | thisthing = "Still Alive"; 34 | megaString = "zxcvbnmasdfghjklqwertyuiop"; 35 | _tc = 0; 36 | _mb = 0; 37 | for (int i = 0 ; i < 2 ; i++) 38 | { 39 | megaString += megaString; 40 | } 41 | } 42 | 43 | void TestThread::setTestCaller(TestCaller* tc) 44 | { 45 | // _tc = new TestCaller(*tc, 0); 46 | // _tc->moveToThread(this); 47 | _tc = tc; 48 | } 49 | 50 | void TestThread::setMessageBus(ClientMessageBus* mb) 51 | { 52 | _mb = mb; 53 | } 54 | 55 | TestThread::~TestThread() 56 | { 57 | } 58 | 59 | void TestThread::run() 60 | { 61 | // _tc->init(); 62 | while (true) 63 | { 64 | qDebug() << "Iterate"; 65 | Sleeper::usleep(10); 66 | if (!_tc.isNull()) 67 | { 68 | _tc->callMegaString(); 69 | _tc->callSomethingElse(_tc, SLOT(functionReturn(uint, ReturnValue)), QByteArray("this is some text that will become binary data")); 70 | } 71 | if (!_mb.isNull()) 72 | { 73 | qDebug() << _mb->callFunction(Signature("megaString(QString)"), Arguments() << megaString); 74 | } 75 | } 76 | deleteLater(); 77 | } 78 | -------------------------------------------------------------------------------- /testclient/testthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TESTTHREAD_H 29 | #define TESTTHREAD_H 30 | 31 | #include 32 | #include 33 | #include 34 | #define USE_QTRPC_PRIVATE_API 35 | #include 36 | 37 | #include "testcaller.h" 38 | 39 | /** 40 | @author Chris Vickery 41 | */ 42 | class TestThread : public QThread 43 | { 44 | Q_OBJECT 45 | public: 46 | TestThread(QObject *parent = 0); 47 | ~TestThread(); 48 | void setTestCaller(TestCaller* tc); 49 | void setMessageBus(ClientMessageBus* mb); 50 | protected: 51 | QString megaString; 52 | QString thisthing; 53 | virtual void run(); 54 | QPointer _tc; 55 | QPointer _mb; 56 | 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /testserver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT_BEGIN(qtrpc2.testserver EXECUTABLE) 2 | 3 | SET(SOURCES ${SOURCES} 4 | main.cpp 5 | testserver.cpp 6 | callerservice.cpp 7 | testsyncroserver.cpp 8 | ) 9 | 10 | SET(HEADERS ${HEADERS} 11 | testserver.h 12 | callerservice.h 13 | testsyncroserver.h 14 | ) 15 | 16 | USE_QT_LIB(Network) 17 | USE_QT_LIB(Core) 18 | 19 | SET(INCLUDES ${INCLUDES} 20 | ../ 21 | ../include/ 22 | ) 23 | 24 | SET(LIBRARIES ${LIBRARIES} 25 | qtrpc2 26 | ) 27 | 28 | PROJECT_END() 29 | 30 | -------------------------------------------------------------------------------- /testserver/callerservice.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef CALLERSERVICE_H 29 | #define CALLERSERVICE_H 30 | 31 | #include 32 | #include 33 | 34 | using namespace QtRpc; 35 | 36 | /** 37 | @author Chris Vickery 38 | */ 39 | class CallerService : public ServiceProxy 40 | { 41 | Q_OBJECT 42 | public: 43 | CallerService(QObject *parent = 0); 44 | 45 | ~CallerService(); 46 | 47 | virtual QtRpc::ReturnValue auth(QString user, QString passwd); 48 | signals: 49 | Event testEvent(QString text); 50 | CallbackValue testCallback(QObject *obj, const char *slot, int num, QVariant rediculous); 51 | protected slots: 52 | ReturnValue largeValues(QString); 53 | ReturnValue somethingElse(QByteArray); 54 | public slots: 55 | void callbackReturned(uint id, ReturnValue ret); 56 | 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /testserver/testserver.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef QTRPCTESTSERVER_H 29 | #define QTRPCTESTSERVER_H 30 | 31 | #include 32 | #include 33 | 34 | using namespace QtRpc; 35 | 36 | /** 37 | @author Chris Vickery 38 | */ 39 | class TestServer : public ServiceProxy 40 | { 41 | Q_OBJECT 42 | public: 43 | TestServer(QObject *parent = 0); 44 | 45 | ~TestServer(); 46 | 47 | virtual QtRpc::ReturnValue auth(QString user, QString passwd); 48 | signals: 49 | Event event_0(QString); 50 | CallbackValue callback_2(QObject *obj, const char *slot, int num, QVariant rediculous); 51 | 52 | protected slots: 53 | ReturnValue syncfunction_1(QString); 54 | ReturnValue asyncfunction_3(QByteArray); 55 | ReturnValue syncfunction_4(); 56 | ReturnValue default_param_function(QString arg1, int arg2 = 5); 57 | void event_0(); 58 | 59 | public slots: 60 | void return_syncfunction_1(quint32 id); 61 | void callbackReturned(uint id, ReturnValue ret); 62 | private: 63 | QString megaString; 64 | bool doubleCall; 65 | 66 | }; 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /testserver/testsyncroserver.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #include "testsyncroserver.h" 29 | 30 | using namespace QtRpc; 31 | 32 | TestSyncroServer::TestSyncroServer(QObject *parent) 33 | : ServiceProxy(parent) 34 | { 35 | megaString = "zxcvbnmasdfghjklqwertyuiop"; 36 | for (int i = 0 ; i < 2 ; i++) 37 | { 38 | megaString += megaString; 39 | } 40 | } 41 | 42 | TestSyncroServer::~TestSyncroServer() 43 | { 44 | } 45 | 46 | ReturnValue TestSyncroServer::largeValues(QString value) 47 | { 48 | if (value != megaString) 49 | qFatal("ERROR: Malformed megastring: "); 50 | return megaString; 51 | } 52 | -------------------------------------------------------------------------------- /testserver/testsyncroserver.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (c) 2010, Resara LLC 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of Resara LLC nor the 13 | * names of its contributors may be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL RESARA LLC BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | ***************************************************************************/ 28 | #ifndef TESTSYNCROSERVER_H 29 | #define TESTSYNCROSERVER_H 30 | 31 | #include 32 | 33 | using namespace QtRpc; 34 | 35 | /** 36 | @author Chris Vickery 37 | */ 38 | class TestSyncroServer : public ServiceProxy 39 | { 40 | Q_OBJECT 41 | public: 42 | TestSyncroServer(QObject *parent = 0); 43 | ~TestSyncroServer(); 44 | QString megaString; 45 | public slots: 46 | ReturnValue largeValues(QString); 47 | }; 48 | 49 | #endif 50 | --------------------------------------------------------------------------------