summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/API/SConscript6
-rw-r--r--Documentation/BuildingGenerics.txt6
-rw-r--r--Documentation/BuildingOnAndroid.txt97
-rw-r--r--Documentation/BuildingOnIOS.txt44
-rw-r--r--Documentation/BuildingOnUnix.txt35
-rw-r--r--Documentation/BuildingOnWindows.txt66
-rw-r--r--Documentation/SConscript2
-rw-r--r--Documentation/SwiftAPI/SConscript6
-rw-r--r--Documentation/SwiftUserGuide/SConscript2
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp32
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp14
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp33
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp75
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp133
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp149
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp179
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp89
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h20
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h50
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h17
-rw-r--r--Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript29
-rw-r--r--Documentation/SwiftenDevelopersGuide/SConscript138
22 files changed, 481 insertions, 741 deletions
diff --git a/Documentation/API/SConscript b/Documentation/API/SConscript
index df20b27..a8a8b1b 100644
--- a/Documentation/API/SConscript
+++ b/Documentation/API/SConscript
@@ -1,6 +1,6 @@
Import("env")
if "doc" in ARGUMENTS :
- myenv = env.Clone()
- myenv.Tool("DoxyGen", toolpath = ["#/BuildTools/SCons/Tools"])
- myenv.DoxyGen("Doxyfile")
+ myenv = env.Clone()
+ myenv.Tool("DoxyGen", toolpath = ["#/BuildTools/SCons/Tools"])
+ myenv.DoxyGen("Doxyfile")
diff --git a/Documentation/BuildingGenerics.txt b/Documentation/BuildingGenerics.txt
deleted file mode 100644
index 284cf45..0000000
--- a/Documentation/BuildingGenerics.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-To cause scons to search for dependencies instead of using cached results, add force-configure=1 to the commandline:
-scons force-configure=1
-
-Swift is usually built with Qt5. If you want to build it against Qt4, add the line
-qt5 = 0
-to your config.py. However, Qt4 support is no longer actively maintained.
diff --git a/Documentation/BuildingOnAndroid.txt b/Documentation/BuildingOnAndroid.txt
deleted file mode 100644
index 8a29895..0000000
--- a/Documentation/BuildingOnAndroid.txt
+++ /dev/null
@@ -1,97 +0,0 @@
-Prerequisites
--------------
-- Android SDK
-- Android NDK
-- Python
-- Other requirements that are obtained during this guide
- - LDNS
- - Unbound
- - OpenSSL
-
-Supported Components
---------------------
-- Swiften
- Note: File-transfer support has not been tested on Android. Link-local features are not supported under Android.
-
-Supported Android NDK Level
----------------------------
-The minimal supported Android NDK API level is 14 (see --platform parameter of make-standalone-toolchain.sh).
-This is the NDK API level associated with Android 4.0. Higher Android NDK API levels however should work.
-
-Preparation of Build Environment
---------------------------------
-1. Fetch 3rd-party dependencies
-
-1.1 LDNS
- cd 3rdParty/Ldns
- bash prepare_ldns.sh
-
-1.2 Unbound
- cd 3rdParty/Unbound
- bash prepare_unbound.sh
-
-1.3 OpenSSL
- cd 3rdParty/OpenSSL
- curl -O http://www.openssl.org/source/openssl-1.0.1j.tar.gz
- tar -xf openssl-1.0.1j.tar.gz
- mv openssl-1.0.1j openssl
-
-2. Patch 3rd-party dependencies
- patch -p0 < 3rdParty/Ldns/01_andoird_compilation_fixes.diff
- patch -p1 < 3rdParty/LibMiniUPnPc/01_android_compilation_fixes.diff
- patch -p1 < 3rdParty/Unbound/01_android_fixes.diff
-
-3. Create Android NDK Toolchain
- cd $ANDROID_NDK_ROOT (this is the folder where you extracted Android NDK)
- bash ./build/tools/make-standalone-toolchain.sh --platform=android-14 --install-dir=$HOME/android-14-tc
-
-Configuring Swift Build
------------------------
-1. Set config.py to (probably other paths, replace $NDK_TOOLCHAIN_INSTALL_DIR with the expanded path of the install dir used in the previous step):
- > android_toolchain=$NDK_TOOLCHAIN_INSTALL_DIR
- > android_sdk_bin="/usr/local/bin"
- > target = "android"
- > unbound = 1
-
-Building
---------
-./scons test=none Swiften Swift/Controllers QA max_jobs=1
-
-Testing
--------
-Running Swift's test suite on Android requires a one time preparation of a testing environment.
-This creates an Android VM where the test will be deployed to and run on.
-
-1. Preparation of test environment (one time)
-
-1.1 Starting AVD (Android Device Manager)
- android avd
-
-1.2 Create a test VM
- Click "Create..." button
-
-1.3 Fill out dialog
- AVD Name: swift_test
- Device: Nexus 4
- Target: Anything with API level equal or greater than your toolchain you build
- CPU/ABI: ARM (unless you build a different toolchain)
-
- Click "Ok" button
-
-1.4 Close AVD
-
-2. Running integration and unit tests
-
-To run the unit tests you need to have an Android VM running while the test suite is running.
-This requires to leave the command under step 2.1 running while you execute step 2.2.
-
-Running the test suite on Android can take quite some time ( >30 minutes ) compared to a native run.
-This is due to
- a) the slow transfer speed from host machine to VM (~ 2 MB/s) and
- b) the test environment being emulated for an different CPU architecture.
-
-2.1 Start Android VM with resized /system partition
- emulator -partition-size 2048 @swift_test
-
-2.2 Run integration and unit tests (wait until the android boot screen is gone)
- env SWIFT_CLIENTTEST_JID="some jabber id" SWIFT_CLIENTTEST_PASS="password for the jabber id" ./scons test=all Swiften Swift/Controllers QA
diff --git a/Documentation/BuildingOnIOS.txt b/Documentation/BuildingOnIOS.txt
deleted file mode 100644
index e310ca1..0000000
--- a/Documentation/BuildingOnIOS.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Prerequisites
-------------
-- XCode
-- Python
-- Other requirements that are obtained during this guide
- - OpenSSL
-
-Supported Components
---------------------
-- Swiften
- Note: File-transfer support has not been tested on iOS. Link-local features are not supported under iOS.
-- Swift/Controllers
-
-Preparation of Build Environment
---------------------------------
-1. Fetch 3rd-party dependencies
-
-1.1 OpenSSL
- cd 3rdParty/OpenSSL
- curl -O http://www.openssl.org/source/openssl-1.0.1j.tar.gz
- tar -xf openssl-1.0.1j.tar.gz
- mv openssl-1.0.1j openssl
-
-Building
---------
-1. Switch to iOS directory
- cd BuildTools/IOS
-
-2. Look up installed SDKs
- xcodebuild -showsdks
-
- Note: Here the iOS SDKs and iOS Simulator SDKs are of interest.
-
-3. Build Swiften (adjust the sdk parameter to one of the installed SDKs)
- xcodebuild build -arch i386 -sdk iphonesimulator8.1
-
- Note: When not specifying the architecture (-arch flag) XCode will try an universal build which is not supported.
- Only specify one architecture at a time and if you require a universal lib you can create one using the lipo tool.
-
-4. The final libSwiften.a is located at $SWIFT/build/current/Swiften/libSwiften.a.
-
-Testing
--------
-Integration and unit tests are not supported on iOS.
diff --git a/Documentation/BuildingOnUnix.txt b/Documentation/BuildingOnUnix.txt
deleted file mode 100644
index b9f31ea..0000000
--- a/Documentation/BuildingOnUnix.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-Prerequisites
-------------
-- GCC
-- Python
-- OpenSSL (and development package)
-- Qt Open Source Edition (and development package. Optional; not needed for Swiften)
-
-Building
---------
-- Swift uses Qt5 for the UI and on Unix-like platforms it is automatically detected
- using pkg-config.
- - The dependencies can be installed by running ./BuildTools/InstallSwiftDependencies.sh
-- Run
- ./scons
-- To build only a subdir, add the path as a target to scons. E.g., for Swift:
- ./scons Swift
-
-Running tests
--------------
-If you want to run the unit tests (only interesting if you're doing development work)
-- Run
- ./scons test=unit
- for running the unit tests.
-
-Installing
-----------
-- To install swift in /usr/local, run
- ./scons SWIFT_INSTALLDIR=/usr/local /usr/local
-
-Swiften-only
-------------
-- To compile just Swiften, add Swiften to the end of the scons command
- ./scons Swiften
-- To compile and install only Swiften, use SWIFTEN_INSTALLDIR
- ./scons SWIFTEN_INSTALLDIR=/usr/local /usr/local
diff --git a/Documentation/BuildingOnWindows.txt b/Documentation/BuildingOnWindows.txt
deleted file mode 100644
index d296241..0000000
--- a/Documentation/BuildingOnWindows.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-Prerequisites
-------------
-- Microsoft Visual C++ Express Edition
-- Windows SDK
-- Python (2.5 <= version < 3)
-- OpenSSL
- * OpenSSL is optional - without it the Windows platform crypto will be used
- * Download and extract the Windows binary version of OpenSSL from
- http://www.slproweb.com/products/Win32OpenSSL.html
-- Qt Open Source Edition (optional; not needed for Swiften)
-
-Building Qt for Microsoft Visual C++
-------------------------------------
-- These steps are optional - the pre-packaged Qt is fine
-- From the 'Visual C++' 'Programs' group, launch the Visual C++ command prompt
-- Go to the dir where you installed Qt
-- Configure Qt:
- configure
-- Build Qt:
- nmake
-
-Building Swift
---------------
-- From the 'Visual C++' 'Programs' group, launch the Visual C++ command prompt
-- Go to the Swift source dir
-- Create a file 'config.py' with the following contents, reflecting your local
- setup:
- openssl = "path\to\openssl" #optional
- qt = "path\to\qt"
-- Run 'scons'
-- To build only a subdir, add the path as a target to scons. E.g., for Swift:
- scons Swift
-
-Running tests
--------------
-- Run
- scons test=unit
- for running the unit tests, or
- scons test=all
- for running all tests.
-
-Packaging Swift
----------------
-For packaging use:
-- Microsoft Visual C++ Express 2008 or Microsoft VS 2013 Express
-- No OpenSSL
-- WiX
-- Download the C++ redistributable package from Microsoft and put it at C:\Program Files (x86)\Common Files\Merge Modules\
-- config.py should contain:
- qt = "c:\\qt\\5.4.2"
- vcredist = "C:\\Program Files (x86)\\Common Files\\Merge Modules\\vcredist_x86.exe"
- debug = 1
- optimize = 1
- wix_bindir = "c:\\program files\\Windows Installer XML v3.5\\bin"
-- run the following commands. Two scons runs are required as 'scons dist=1' requires the Swift.exe to be in place.
- scons
- scons dist=1
-
-Notes
------
-- The settings debug = 1 and optimize = 1 are strictly required if you use
- a precompiled Qt release from the Qt Project; otherwise you will get linker
- errors
-- On 64-bit Windows it's "Program Files (x86)" instead of "Program Files" in the
- paths
-- Currently only 32-bit builds of the Swift client are supported
diff --git a/Documentation/SConscript b/Documentation/SConscript
index 161cd83..e2f6393 100644
--- a/Documentation/SConscript
+++ b/Documentation/SConscript
@@ -1,4 +1,4 @@
Import("env")
if env["SCONS_STAGE"] == "build" :
- SConscript(dirs = ["SwiftenDevelopersGuide", "SwiftUserGuide", "API", "SwiftAPI"])
+ SConscript(dirs = ["SwiftenDevelopersGuide", "SwiftUserGuide", "API", "SwiftAPI"])
diff --git a/Documentation/SwiftAPI/SConscript b/Documentation/SwiftAPI/SConscript
index df20b27..a8a8b1b 100644
--- a/Documentation/SwiftAPI/SConscript
+++ b/Documentation/SwiftAPI/SConscript
@@ -1,6 +1,6 @@
Import("env")
if "doc" in ARGUMENTS :
- myenv = env.Clone()
- myenv.Tool("DoxyGen", toolpath = ["#/BuildTools/SCons/Tools"])
- myenv.DoxyGen("Doxyfile")
+ myenv = env.Clone()
+ myenv.Tool("DoxyGen", toolpath = ["#/BuildTools/SCons/Tools"])
+ myenv.DoxyGen("Doxyfile")
diff --git a/Documentation/SwiftUserGuide/SConscript b/Documentation/SwiftUserGuide/SConscript
index 50f60bc..1577b83 100644
--- a/Documentation/SwiftUserGuide/SConscript
+++ b/Documentation/SwiftUserGuide/SConscript
@@ -11,5 +11,5 @@ import sys, re, os.path
################################################################################
if "doc" in ARGUMENTS :
- env.DocBook("Swift Users Guide.xml")
+ env.DocBook("Swift Users Guide.xml")
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp
index 912ba07..9a7301a 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp
@@ -9,23 +9,23 @@
using namespace Swift;
int main(int, char**) {
- // Set up the event loop and network classes
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ // Set up the event loop and network classes
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- Client client("echobot@wonderland.lit", "mypass", &networkFactories);
- client.setAlwaysTrustCertificates();
- client.onConnected.connect([&] {
- std::cout << "Connected" << std::endl;
- });
- client.onMessageReceived.connect([&] (Message::ref message) {
- message->setTo(message->getFrom());
- message->setFrom(JID());
- client.sendMessage(message);
- });
- client.connect();
+ Client client("echobot@wonderland.lit", "mypass", &networkFactories);
+ client.setAlwaysTrustCertificates();
+ client.onConnected.connect([&] {
+ std::cout << "Connected" << std::endl;
+ });
+ client.onMessageReceived.connect([&] (Message::ref message) {
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ client.sendMessage(message);
+ });
+ client.connect();
- eventLoop.run();
+ eventLoop.run();
- return 0;
+ return 0;
}
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp
index 15d1a77..6e04eee 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp
@@ -9,14 +9,14 @@
using namespace Swift;
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- Client client("echobot@wonderland.lit", "mypass", &networkFactories);
- client.setAlwaysTrustCertificates();
- client.connect();
+ Client client("echobot@wonderland.lit", "mypass", &networkFactories);
+ client.setAlwaysTrustCertificates();
+ client.connect();
- eventLoop.run();
+ eventLoop.run();
- return 0;
+ return 0;
}
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp
index 356a115..d928db8 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp
@@ -1,10 +1,11 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <iostream>
+
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
@@ -18,28 +19,28 @@ void handleConnected();
void handleMessageReceived(Message::ref message);
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- client = new Client("echobot@wonderland.lit", "mypass", &networkFactories);
- client->setAlwaysTrustCertificates();
- client->onConnected.connect(&handleConnected);
- client->onMessageReceived.connect(bind(&handleMessageReceived, _1));
- client->connect();
+ client = new Client("echobot@wonderland.lit", "mypass", &networkFactories);
+ client->setAlwaysTrustCertificates();
+ client->onConnected.connect(&handleConnected);
+ client->onMessageReceived.connect(bind(&handleMessageReceived, _1));
+ client->connect();
- eventLoop.run();
+ eventLoop.run();
- delete client;
- return 0;
+ delete client;
+ return 0;
}
void handleConnected() {
- std::cout << "Connected" << std::endl;
+ std::cout << "Connected" << std::endl;
}
void handleMessageReceived(Message::ref message) {
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(JID());
- client->sendMessage(message);
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ client->sendMessage(message);
}
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp
index 8334b2f..470753d 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp
@@ -1,10 +1,11 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <iostream>
+
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
@@ -13,45 +14,45 @@ using namespace Swift;
using namespace boost;
class EchoBot {
- public:
- EchoBot(NetworkFactories* networkFactories) {
- client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
- client->setAlwaysTrustCertificates();
- client->onConnected.connect(bind(&EchoBot::handleConnected, this));
- client->onMessageReceived.connect(
- bind(&EchoBot::handleMessageReceived, this, _1));
- tracer = new ClientXMLTracer(client);
- client->connect();
- }
-
- ~EchoBot() {
- delete tracer;
- delete client;
- }
-
- private:
- void handleConnected() {
- std::cout << "Connected" << std::endl;
- }
-
- void handleMessageReceived(Message::ref message) {
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(JID());
- client->sendMessage(message);
- }
-
- private:
- Client* client;
- ClientXMLTracer* tracer;
+ public:
+ EchoBot(NetworkFactories* networkFactories) {
+ client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
+ client->setAlwaysTrustCertificates();
+ client->onConnected.connect(bind(&EchoBot::handleConnected, this));
+ client->onMessageReceived.connect(
+ bind(&EchoBot::handleMessageReceived, this, _1));
+ tracer = new ClientXMLTracer(client);
+ client->connect();
+ }
+
+ ~EchoBot() {
+ delete tracer;
+ delete client;
+ }
+
+ private:
+ void handleConnected() {
+ std::cout << "Connected" << std::endl;
+ }
+
+ void handleMessageReceived(Message::ref message) {
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ client->sendMessage(message);
+ }
+
+ private:
+ Client* client;
+ ClientXMLTracer* tracer;
};
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- EchoBot bot(&networkFactories);
+ EchoBot bot(&networkFactories);
- eventLoop.run();
- return 0;
+ eventLoop.run();
+ return 0;
}
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp
index 1432677..9ab7864 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
//...
#include <iostream>
+
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
@@ -14,80 +15,80 @@ using namespace Swift;
using namespace boost;
//...
class EchoBot {
- public:
- EchoBot(NetworkFactories* networkFactories) {
- //...
- client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
- client->setAlwaysTrustCertificates();
- client->onConnected.connect(bind(&EchoBot::handleConnected, this));
- client->onMessageReceived.connect(
- bind(&EchoBot::handleMessageReceived, this, _1));
- //...
- client->onPresenceReceived.connect(
- bind(&EchoBot::handlePresenceReceived, this, _1));
- //...
- tracer = new ClientXMLTracer(client);
- client->connect();
- //...
- }
+ public:
+ EchoBot(NetworkFactories* networkFactories) {
+ //...
+ client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
+ client->setAlwaysTrustCertificates();
+ client->onConnected.connect(bind(&EchoBot::handleConnected, this));
+ client->onMessageReceived.connect(
+ bind(&EchoBot::handleMessageReceived, this, _1));
+ //...
+ client->onPresenceReceived.connect(
+ bind(&EchoBot::handlePresenceReceived, this, _1));
+ //...
+ tracer = new ClientXMLTracer(client);
+ client->connect();
+ //...
+ }
+
+ //...
+ ~EchoBot() {
+ delete tracer;
+ delete client;
+ }
+
+ private:
+ //...
+ void handlePresenceReceived(Presence::ref presence) {
+ // Automatically approve subscription requests
+ if (presence->getType() == Presence::Subscribe) {
+ Presence::ref response = Presence::create();
+ response->setTo(presence->getFrom());
+ response->setType(Presence::Subscribed);
+ client->sendPresence(response);
+ }
+ }
- //...
- ~EchoBot() {
- delete tracer;
- delete client;
- }
-
- private:
- //...
- void handlePresenceReceived(Presence::ref presence) {
- // Automatically approve subscription requests
- if (presence->getType() == Presence::Subscribe) {
- Presence::ref response = Presence::create();
- response->setTo(presence->getFrom());
- response->setType(Presence::Subscribed);
- client->sendPresence(response);
- }
- }
+ void handleConnected() {
+ // Request the roster
+ GetRosterRequest::ref rosterRequest =
+ GetRosterRequest::create(client->getIQRouter());
+ rosterRequest->onResponse.connect(
+ bind(&EchoBot::handleRosterReceived, this, _2));
+ rosterRequest->send();
+ }
- void handleConnected() {
- // Request the roster
- GetRosterRequest::ref rosterRequest =
- GetRosterRequest::create(client->getIQRouter());
- rosterRequest->onResponse.connect(
- bind(&EchoBot::handleRosterReceived, this, _2));
- rosterRequest->send();
- }
+ void handleRosterReceived(ErrorPayload::ref error) {
+ if (error) {
+ std::cerr << "Error receiving roster. Continuing anyway.";
+ }
+ // Send initial available presence
+ client->sendPresence(Presence::create("Send me a message"));
+ }
+ //...
- void handleRosterReceived(ErrorPayload::ref error) {
- if (error) {
- std::cerr << "Error receiving roster. Continuing anyway.";
- }
- // Send initial available presence
- client->sendPresence(Presence::create("Send me a message"));
- }
- //...
-
- void handleMessageReceived(Message::ref message) {
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(JID());
- client->sendMessage(message);
- }
+ void handleMessageReceived(Message::ref message) {
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ client->sendMessage(message);
+ }
- private:
- Client* client;
- ClientXMLTracer* tracer;
- //...
+ private:
+ Client* client;
+ ClientXMLTracer* tracer;
+ //...
};
//...
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- EchoBot bot(&networkFactories);
+ EchoBot bot(&networkFactories);
- eventLoop.run();
- return 0;
+ eventLoop.run();
+ return 0;
}
//...
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp
index ace3b7f..3475a6c 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
//...
#include <iostream>
+
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
@@ -14,88 +15,88 @@ using namespace Swift;
using namespace boost;
//...
class EchoBot {
- public:
- EchoBot(NetworkFactories* networkFactories) {
- //...
- client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
- client->setAlwaysTrustCertificates();
- client->onConnected.connect(bind(&EchoBot::handleConnected, this));
- client->onMessageReceived.connect(
- bind(&EchoBot::handleMessageReceived, this, _1));
- client->onPresenceReceived.connect(
- bind(&EchoBot::handlePresenceReceived, this, _1));
- tracer = new ClientXMLTracer(client);
- //...
- softwareVersionResponder = new SoftwareVersionResponder(client->getIQRouter());
- softwareVersionResponder->setVersion("EchoBot", "1.0");
- softwareVersionResponder->start();
- //...
- client->connect();
- //...
- }
+ public:
+ EchoBot(NetworkFactories* networkFactories) {
+ //...
+ client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
+ client->setAlwaysTrustCertificates();
+ client->onConnected.connect(bind(&EchoBot::handleConnected, this));
+ client->onMessageReceived.connect(
+ bind(&EchoBot::handleMessageReceived, this, _1));
+ client->onPresenceReceived.connect(
+ bind(&EchoBot::handlePresenceReceived, this, _1));
+ tracer = new ClientXMLTracer(client);
+ //...
+ softwareVersionResponder = new SoftwareVersionResponder(client->getIQRouter());
+ softwareVersionResponder->setVersion("EchoBot", "1.0");
+ softwareVersionResponder->start();
+ //...
+ client->connect();
+ //...
+ }
+
+ ~EchoBot() {
+ softwareVersionResponder->stop();
+ delete softwareVersionResponder;
+ //...
+ delete tracer;
+ delete client;
+ //...
+ }
+ //...
+
+ private:
+ void handlePresenceReceived(Presence::ref presence) {
+ // Automatically approve subscription requests
+ if (presence->getType() == Presence::Subscribe) {
+ Presence::ref response = Presence::create();
+ response->setTo(presence->getFrom());
+ response->setType(Presence::Subscribed);
+ client->sendPresence(response);
+ }
+ }
- ~EchoBot() {
- softwareVersionResponder->stop();
- delete softwareVersionResponder;
- //...
- delete tracer;
- delete client;
- //...
- }
- //...
-
- private:
- void handlePresenceReceived(Presence::ref presence) {
- // Automatically approve subscription requests
- if (presence->getType() == Presence::Subscribe) {
- Presence::ref response = Presence::create();
- response->setTo(presence->getFrom());
- response->setType(Presence::Subscribed);
- client->sendPresence(response);
- }
- }
+ void handleConnected() {
+ // Request the roster
+ GetRosterRequest::ref rosterRequest =
+ GetRosterRequest::create(client->getIQRouter());
+ rosterRequest->onResponse.connect(
+ bind(&EchoBot::handleRosterReceived, this, _2));
+ rosterRequest->send();
+ }
- void handleConnected() {
- // Request the roster
- GetRosterRequest::ref rosterRequest =
- GetRosterRequest::create(client->getIQRouter());
- rosterRequest->onResponse.connect(
- bind(&EchoBot::handleRosterReceived, this, _2));
- rosterRequest->send();
- }
+ void handleRosterReceived(ErrorPayload::ref error) {
+ if (error) {
+ std::cerr << "Error receiving roster. Continuing anyway.";
+ }
+ // Send initial available presence
+ client->sendPresence(Presence::create("Send me a message"));
+ }
- void handleRosterReceived(ErrorPayload::ref error) {
- if (error) {
- std::cerr << "Error receiving roster. Continuing anyway.";
- }
- // Send initial available presence
- client->sendPresence(Presence::create("Send me a message"));
- }
-
- void handleMessageReceived(Message::ref message) {
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(JID());
- client->sendMessage(message);
- }
+ void handleMessageReceived(Message::ref message) {
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ client->sendMessage(message);
+ }
- //...
- private:
- //...
- Client* client;
- ClientXMLTracer* tracer;
- //...
- SoftwareVersionResponder* softwareVersionResponder;
+ //...
+ private:
+ //...
+ Client* client;
+ ClientXMLTracer* tracer;
+ //...
+ SoftwareVersionResponder* softwareVersionResponder;
};
//...
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- EchoBot bot(&networkFactories);
+ EchoBot bot(&networkFactories);
- eventLoop.run();
- return 0;
+ eventLoop.run();
+ return 0;
}
//...
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp
index 609b005..e1d5528 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp
@@ -1,13 +1,14 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
//...
#include <iostream>
+#include <memory>
+
#include <boost/bind.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/Swiften.h>
@@ -19,104 +20,104 @@ using namespace boost;
#include "EchoPayloadSerializer.h"
class EchoBot {
- public:
- EchoBot(NetworkFactories* networkFactories) {
- //...
- client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
- client->setAlwaysTrustCertificates();
- client->onConnected.connect(bind(&EchoBot::handleConnected, this));
- client->onMessageReceived.connect(
- bind(&EchoBot::handleMessageReceived, this, _1));
- client->onPresenceReceived.connect(
- bind(&EchoBot::handlePresenceReceived, this, _1));
- tracer = new ClientXMLTracer(client);
+ public:
+ EchoBot(NetworkFactories* networkFactories) {
+ //...
+ client = new Client("echobot@wonderland.lit", "mypass", networkFactories);
+ client->setAlwaysTrustCertificates();
+ client->onConnected.connect(bind(&EchoBot::handleConnected, this));
+ client->onMessageReceived.connect(
+ bind(&EchoBot::handleMessageReceived, this, _1));
+ client->onPresenceReceived.connect(
+ bind(&EchoBot::handlePresenceReceived, this, _1));
+ tracer = new ClientXMLTracer(client);
+
+ softwareVersionResponder = new SoftwareVersionResponder(client->getIQRouter());
+ softwareVersionResponder->setVersion("EchoBot", "1.0");
+ softwareVersionResponder->start();
+ //...
+ client->addPayloadParserFactory(&echoPayloadParserFactory);
+ client->addPayloadSerializer(&echoPayloadSerializer);
+ //...
+ client->connect();
+ //...
+ }
- softwareVersionResponder = new SoftwareVersionResponder(client->getIQRouter());
- softwareVersionResponder->setVersion("EchoBot", "1.0");
- softwareVersionResponder->start();
- //...
- client->addPayloadParserFactory(&echoPayloadParserFactory);
- client->addPayloadSerializer(&echoPayloadSerializer);
- //...
- client->connect();
- //...
- }
+ ~EchoBot() {
+ client->removePayloadSerializer(&echoPayloadSerializer);
+ client->removePayloadParserFactory(&echoPayloadParserFactory);
+ //...
+ softwareVersionResponder->stop();
+ delete softwareVersionResponder;
+ delete tracer;
+ delete client;
+ //...
+ }
+ //...
- ~EchoBot() {
- client->removePayloadSerializer(&echoPayloadSerializer);
- client->removePayloadParserFactory(&echoPayloadParserFactory);
- //...
- softwareVersionResponder->stop();
- delete softwareVersionResponder;
- delete tracer;
- delete client;
- //...
- }
- //...
-
- private:
- void handlePresenceReceived(Presence::ref presence) {
- // Automatically approve subscription requests
- if (presence->getType() == Presence::Subscribe) {
- Presence::ref response = Presence::create();
- response->setTo(presence->getFrom());
- response->setType(Presence::Subscribed);
- client->sendPresence(response);
- }
- }
+ private:
+ void handlePresenceReceived(Presence::ref presence) {
+ // Automatically approve subscription requests
+ if (presence->getType() == Presence::Subscribe) {
+ Presence::ref response = Presence::create();
+ response->setTo(presence->getFrom());
+ response->setType(Presence::Subscribed);
+ client->sendPresence(response);
+ }
+ }
- void handleConnected() {
- // Request the roster
- GetRosterRequest::ref rosterRequest =
- GetRosterRequest::create(client->getIQRouter());
- rosterRequest->onResponse.connect(
- bind(&EchoBot::handleRosterReceived, this, _2));
- rosterRequest->send();
- }
+ void handleConnected() {
+ // Request the roster
+ GetRosterRequest::ref rosterRequest =
+ GetRosterRequest::create(client->getIQRouter());
+ rosterRequest->onResponse.connect(
+ bind(&EchoBot::handleRosterReceived, this, _2));
+ rosterRequest->send();
+ }
- void handleRosterReceived(ErrorPayload::ref error) {
- if (error) {
- std::cerr << "Error receiving roster. Continuing anyway.";
- }
- // Send initial available presence
- client->sendPresence(Presence::create("Send me a message"));
- }
+ void handleRosterReceived(ErrorPayload::ref error) {
+ if (error) {
+ std::cerr << "Error receiving roster. Continuing anyway.";
+ }
+ // Send initial available presence
+ client->sendPresence(Presence::create("Send me a message"));
+ }
- //...
- void handleMessageReceived(Message::ref message) {
- //...
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(JID());
- //...
- if (!message->getPayload<EchoPayload>()) {
- boost::shared_ptr<EchoPayload> echoPayload = boost::make_shared<EchoPayload>();
- echoPayload->setMessage("This is an echoed message");
- message->addPayload(echoPayload);
- client->sendMessage(message);
- }
- }
- //...
+ //...
+ void handleMessageReceived(Message::ref message) {
+ //...
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(JID());
+ //...
+ if (!message->getPayload<EchoPayload>()) {
+ std::shared_ptr<EchoPayload> echoPayload = std::make_shared<EchoPayload>();
+ echoPayload->setMessage("This is an echoed message");
+ message->addPayload(echoPayload);
+ client->sendMessage(message);
+ }
+ }
+ //...
- //...
- private:
- //...
- Client* client;
- ClientXMLTracer* tracer;
- SoftwareVersionResponder* softwareVersionResponder;
- //...
- EchoPayloadParserFactory echoPayloadParserFactory;
- EchoPayloadSerializer echoPayloadSerializer;
+ //...
+ private:
+ //...
+ Client* client;
+ ClientXMLTracer* tracer;
+ SoftwareVersionResponder* softwareVersionResponder;
+ //...
+ EchoPayloadParserFactory echoPayloadParserFactory;
+ EchoPayloadSerializer echoPayloadSerializer;
};
//...
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- EchoBot bot(&networkFactories);
+ EchoBot bot(&networkFactories);
- eventLoop.run();
- return 0;
+ eventLoop.run();
+ return 0;
}
//...
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp
index ad51eb9..16d7e4e 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp
@@ -1,10 +1,11 @@
/*
- * Copyright (c) 2010-2013 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <iostream>
+
#include <boost/bind.hpp>
#include <Swiften/Swiften.h>
@@ -13,56 +14,56 @@ using namespace Swift;
using namespace boost;
class EchoComponent {
- public:
- EchoComponent(NetworkFactories* networkFactories) : jid("echo.wonderland.lit") {
- component = new Component(jid, "EchoSecret", networkFactories);
- component->onConnected.connect(bind(&EchoComponent::handleConnected, this));
- component->onMessageReceived.connect(
- bind(&EchoComponent::handleMessageReceived, this, _1));
- component->onPresenceReceived.connect(
- bind(&EchoComponent::handlePresenceReceived, this, _1));
- tracer = new ComponentXMLTracer(component);
- component->connect("wonderland.lit", 5347);
- }
+ public:
+ EchoComponent(NetworkFactories* networkFactories) : jid("echo.wonderland.lit") {
+ component = new Component(jid, "EchoSecret", networkFactories);
+ component->onConnected.connect(bind(&EchoComponent::handleConnected, this));
+ component->onMessageReceived.connect(
+ bind(&EchoComponent::handleMessageReceived, this, _1));
+ component->onPresenceReceived.connect(
+ bind(&EchoComponent::handlePresenceReceived, this, _1));
+ tracer = new ComponentXMLTracer(component);
+ component->connect("wonderland.lit", 5347);
+ }
+
+ ~EchoComponent() {
+ delete tracer;
+ delete component;
+ }
- ~EchoComponent() {
- delete tracer;
- delete component;
- }
-
- private:
- void handlePresenceReceived(Presence::ref presence) {
- // Automatically approve subscription requests
- if (presence->getType() == Presence::Subscribe) {
- Presence::ref response = Presence::create();
- response->setTo(presence->getFrom());
- response->setType(Presence::Subscribed);
- component->sendPresence(response);
- }
- }
+ private:
+ void handlePresenceReceived(Presence::ref presence) {
+ // Automatically approve subscription requests
+ if (presence->getType() == Presence::Subscribe) {
+ Presence::ref response = Presence::create();
+ response->setTo(presence->getFrom());
+ response->setType(Presence::Subscribed);
+ component->sendPresence(response);
+ }
+ }
- void handleConnected() {
- }
+ void handleConnected() {
+ }
- void handleMessageReceived(Message::ref message) {
- // Echo back the incoming message
- message->setTo(message->getFrom());
- message->setFrom(jid);
- component->sendMessage(message);
- }
+ void handleMessageReceived(Message::ref message) {
+ // Echo back the incoming message
+ message->setTo(message->getFrom());
+ message->setFrom(jid);
+ component->sendMessage(message);
+ }
- private:
- JID jid;
- Component* component;
- ComponentXMLTracer* tracer;
+ private:
+ JID jid;
+ Component* component;
+ ComponentXMLTracer* tracer;
};
int main(int, char**) {
- SimpleEventLoop eventLoop;
- BoostNetworkFactories networkFactories(&eventLoop);
+ SimpleEventLoop eventLoop;
+ BoostNetworkFactories networkFactories(&eventLoop);
- EchoComponent bot(&networkFactories);
+ EchoComponent bot(&networkFactories);
- eventLoop.run();
- return 0;
+ eventLoop.run();
+ return 0;
}
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h
index c93b78b..1e5fc98 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h
@@ -10,17 +10,17 @@
//...
class EchoPayload : public Swift::Payload {
- public:
- EchoPayload() {}
+ public:
+ EchoPayload() {}
- const std::string& getMessage() const {
- return message;
- }
+ const std::string& getMessage() const {
+ return message;
+ }
- void setMessage(const std::string& message) {
- this->message = message;
- }
+ void setMessage(const std::string& message) {
+ this->message = message;
+ }
- private:
- std::string message;
+ private:
+ std::string message;
};
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h
index 9d66204..48d08bd 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h
@@ -10,32 +10,32 @@
#include "EchoPayload.h"
class EchoPayloadParser : public Swift::GenericPayloadParser<EchoPayload> {
- public:
- EchoPayloadParser() : currentDepth(0) {}
-
- void handleStartElement(
- const std::string& /* element */, const std::string& /* ns */, const AttributeMap&) {
- currentDepth++;
- }
-
- void handleEndElement(const std::string& /* element */, const std::string& /* ns */) {
- currentDepth--;
- if (currentDepth == 0) {
- getPayloadInternal()->setMessage(currentText);
- }
- }
-
- void handleCharacterData(const std::string& data) {
- currentText += data;
- }
-
- private:
- int currentDepth;
- std::string currentText;
+ public:
+ EchoPayloadParser() : currentDepth(0) {}
+
+ void handleStartElement(
+ const std::string& /* element */, const std::string& /* ns */, const AttributeMap&) {
+ currentDepth++;
+ }
+
+ void handleEndElement(const std::string& /* element */, const std::string& /* ns */) {
+ currentDepth--;
+ if (currentDepth == 0) {
+ getPayloadInternal()->setMessage(currentText);
+ }
+ }
+
+ void handleCharacterData(const std::string& data) {
+ currentText += data;
+ }
+
+ private:
+ int currentDepth;
+ std::string currentText;
};
class EchoPayloadParserFactory : public Swift::GenericPayloadParserFactory<EchoPayloadParser> {
- public:
- EchoPayloadParserFactory() :
- GenericPayloadParserFactory<EchoPayloadParser>("echo", "http://swift.im/echo") {}
+ public:
+ EchoPayloadParserFactory() :
+ GenericPayloadParserFactory<EchoPayloadParser>("echo", "http://swift.im/echo") {}
};
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h
index abc4760..faf1080 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h
@@ -1,19 +1,20 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <Swiften/Swiften.h>
#include "EchoPayload.h"
+#include <Swiften/Swiften.h>
+
class EchoPayloadSerializer : public Swift::GenericPayloadSerializer<EchoPayload> {
- public:
- std::string serializePayload(boost::shared_ptr<EchoPayload> payload) const {
- XMLElement element("echo", "http://swift.im/protocol/echo");
- element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getMessage())));
- return element.serialize();
- }
+ public:
+ std::string serializePayload(std::shared_ptr<EchoPayload> payload) const {
+ XMLElement element("echo", "http://swift.im/protocol/echo");
+ element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getMessage())));
+ return element.serialize();
+ }
};
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
index 5d27b70..268ab9a 100644
--- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
+++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript
@@ -7,30 +7,11 @@ example_env.UseFlags(example_env["SWIFTEN_DEP_FLAGS"])
# Precompile Swiften header
# This is useful to slightly speed up compilation.
# if example_env["PLATFORM"] == "win32":
-# example_env.WriteVal("Swiften.cpp", example_env.Value("#include <Swiften/Swiften.h>\n"))
-# example_env["PCH"] = example_env.PCH("Swiften.cpp")[0]
-# example_env["PCHSTOP"] = "Swiften/Swiften.h"
+# example_env.WriteVal("Swiften.cpp", example_env.Value("#include <Swiften/Swiften.h>\n"))
+# example_env["PCH"] = example_env.PCH("Swiften.cpp")[0]
+# example_env["PCHSTOP"] = "Swiften/Swiften.h"
for i in range(1,7) :
- example_env.Program("EchoBot" + str(i), ["EchoBot" + str(i) + ".cpp"])
+ example_env.Program("EchoBot" + str(i), ["EchoBot" + str(i) + ".cpp"])
+example_env.Program("EchoBot0x", "EchoBot0x.cpp")
example_env.Program("EchoComponent", "EchoComponent.cpp")
-
-# C++0x
-cpp0x = False
-cpp0x_env = example_env.Clone()
-if env["PLATFORM"] == "win32" :
- if int(env["MSVS_VERSION"].split(".")[0]) >= 10 :
- cpp0x = True
-elif env["PLATFORM"] == "hpux" :
- pass
-elif env["PLATFORM"] == "sunos" :
- pass
-else :
- if env["CCVERSION"].split(".") >= ["4", "5", "0"] :
- # Temporarily disabling c++0x mode because of problems with boost::thread
- # on some platforms
- #cpp0x = True
- cpp0x_env.Replace(CXXFLAGS = [flag for flag in env["CXXFLAGS"] if flag != "-Werror"])
- cpp0x_env.Append(CXXFLAGS = ["-std=c++0x"])
-if cpp0x :
- cpp0x_env.Program("EchoBot0x", "EchoBot0x.cpp")
diff --git a/Documentation/SwiftenDevelopersGuide/SConscript b/Documentation/SwiftenDevelopersGuide/SConscript
index ba0eb0b..ac7c67a 100644
--- a/Documentation/SwiftenDevelopersGuide/SConscript
+++ b/Documentation/SwiftenDevelopersGuide/SConscript
@@ -9,89 +9,89 @@ env.Tool("DocBook", toolpath = ["#/BuildTools/DocBook/SCons"])
import sys, re, os.path
def generateDocBookCode(env, target, source) :
- # Strips empty lines from the beginning & end of a program
- def stripEmptyLines(program) :
- programLines = program.split('\n')
- newProgramLines = []
- inProgram = False
- for line in programLines :
- if not re.match("^\s*$", line) or inProgram :
- inProgram = True
- newProgramLines.append(line)
- return '\n'.join(newProgramLines).rstrip()
+ # Strips empty lines from the beginning & end of a program
+ def stripEmptyLines(program) :
+ programLines = program.split('\n')
+ newProgramLines = []
+ inProgram = False
+ for line in programLines :
+ if not re.match("^\s*$", line) or inProgram :
+ inProgram = True
+ newProgramLines.append(line)
+ return '\n'.join(newProgramLines).rstrip()
- def createCallouts(program, calloutPrefix) :
- newProgramLines = []
- calloutLines = []
- nextID = 0
- for line in program.split("\n") :
- # FIXME: Takes the largest match
- m = re.match(".*\/* \(\*\) (.*) \*/.*", line)
- if m :
- cobID = "cob-" + calloutPrefix + "-" + str(nextID)
- coID = "co-" + calloutPrefix + "-" + str(nextID)
- nextID += 1
- line = re.sub("/\*.*\*/", "]]><co id=\"%(cobID)s\" linkends=\"%(coID)s\"/><![CDATA[" % {"cobID" : cobID, "coID" : coID}, line)
- calloutLines.append("<callout arearefs=\"%(cobID)s\" id=\"%(coID)s\"><para>%(text)s</para></callout>" % {"cobID": cobID, "coID": coID, "text": m.group(1)})
- newProgramLines.append(line)
- callouts = ""
- if len(calloutLines) > 0 :
- callouts = "<calloutlist>" + "\n".join(calloutLines) + "</calloutlist>"
- return ("\n".join(newProgramLines), callouts)
+ def createCallouts(program, calloutPrefix) :
+ newProgramLines = []
+ calloutLines = []
+ nextID = 0
+ for line in program.split("\n") :
+ # FIXME: Takes the largest match
+ m = re.match(".*\/* \(\*\) (.*) \*/.*", line)
+ if m :
+ cobID = "cob-" + calloutPrefix + "-" + str(nextID)
+ coID = "co-" + calloutPrefix + "-" + str(nextID)
+ nextID += 1
+ line = re.sub("/\*.*\*/", "]]><co id=\"%(cobID)s\" linkends=\"%(coID)s\"/><![CDATA[" % {"cobID" : cobID, "coID" : coID}, line)
+ calloutLines.append("<callout arearefs=\"%(cobID)s\" id=\"%(coID)s\"><para>%(text)s</para></callout>" % {"cobID": cobID, "coID": coID, "text": m.group(1)})
+ newProgramLines.append(line)
+ callouts = ""
+ if len(calloutLines) > 0 :
+ callouts = "<calloutlist>" + "\n".join(calloutLines) + "</calloutlist>"
+ return ("\n".join(newProgramLines), callouts)
- # Parse program
- filename = source[0].abspath
- filenameBase = os.path.basename(filename).replace(".cpp", "")
- inputfile = open(filename)
- program = ""
- programs = {}
- programName = ""
- inEllipsis = False
- for line in inputfile.readlines() :
- if inEllipsis :
- if "//..." in line :
- inEllipsis = False
- else :
- if line.startswith("/*") or line.startswith(" *") :
- continue
- if "//..." in line :
- inEllipsis = True
- line = line.replace("//...", "]]>&#x2026;<![CDATA[")
- else :
- m = re.match("^/// (.*)", line)
- if m :
- if programName :
- programs[programName] = program
- program = ""
- programName = m.group(1).strip().replace(" ", "")
- continue
- line = re.sub("\t", " ", line)
- program += line
- programs[programName] = program
- inputfile.close()
+ # Parse program
+ filename = source[0].abspath
+ filenameBase = os.path.basename(filename).replace(".cpp", "")
+ inputfile = open(filename)
+ program = ""
+ programs = {}
+ programName = ""
+ inEllipsis = False
+ for line in inputfile.readlines() :
+ if inEllipsis :
+ if "//..." in line :
+ inEllipsis = False
+ else :
+ if line.startswith("/*") or line.startswith(" *") :
+ continue
+ if "//..." in line :
+ inEllipsis = True
+ line = line.replace("//...", "]]>&#x2026;<![CDATA[")
+ else :
+ m = re.match("^/// (.*)", line)
+ if m :
+ if programName :
+ programs[programName] = program
+ program = ""
+ programName = m.group(1).strip().replace(" ", "")
+ continue
+ line = re.sub("\t", " ", line)
+ program += line
+ programs[programName] = program
+ inputfile.close()
- for programName, program in programs.items() :
- program = stripEmptyLines(program)
- (program, callouts) = createCallouts(program, filenameBase + "-" + programName)
+ for programName, program in programs.items() :
+ program = stripEmptyLines(program)
+ (program, callouts) = createCallouts(program, filenameBase + "-" + programName)
- document = "<foo><programlisting><![CDATA[" + program + "]]></programlisting>" + callouts + "</foo>"
+ document = "<foo><programlisting><![CDATA[" + program + "]]></programlisting>" + callouts + "</foo>"
- # Generate code
- output = open(target[0].abspath, 'w')
- output.write(document)
- output.close()
+ # Generate code
+ output = open(target[0].abspath, 'w')
+ output.write(document)
+ output.close()
################################################################################
if "doc" in ARGUMENTS :
- env.DocBook("Swiften Developers Guide.xml")
+ env.DocBook("Swiften Developers Guide.xml")
sources = []
for i in range(1, 7) :
- sources.append("Examples/EchoBot/EchoBot" + str(i) + ".cpp")
+ sources.append("Examples/EchoBot/EchoBot" + str(i) + ".cpp")
sources.append("Examples/EchoBot/EchoBot0x.cpp")
sources += ["Examples/EchoBot/" + i for i in ["EchoPayloadParserFactory.h", "EchoPayloadSerializer.h", "EchoPayload.h", "EchoComponent.cpp"]]
for source in sources :
- env.Command(source + ".xml", source, Action(generateDocBookCode, cmdstr = "$GENCOMSTR"))
+ env.Command(source + ".xml", source, Action(generateDocBookCode, cmdstr = "$GENCOMSTR"))
SConscript(dirs = ["Examples"])