diff options
Diffstat (limited to 'Documentation')
25 files changed, 774 insertions, 619 deletions
diff --git a/Documentation/API/Doxyfile b/Documentation/API/Doxyfile index dcc6286..0634800 100644 --- a/Documentation/API/Doxyfile +++ b/Documentation/API/Doxyfile @@ -65,7 +65,6 @@ GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = NO -SHOW_DIRECTORIES = NO SHOW_FILES = NO SHOW_NAMESPACES = NO FILE_VERSION_FILTER = @@ -90,18 +89,18 @@ INPUT = \ Swiften/Base \ Swiften/Chat \ Swiften/Client/Client.h \ - Swiften/Client/CoreClient.h \ Swiften/Client/ClientError.h \ - Swiften/Client/StanzaChannel.h \ + Swiften/Client/CoreClient.h \ + Swiften/Client/MemoryStorages.h \ Swiften/Client/NickResolver.h \ + Swiften/Client/StanzaChannel.h \ Swiften/Client/Storages.h \ - Swiften/Client/MemoryStorages.h \ - Swiften/Client/FileStorages.h \ Swiften/Component/Component.h \ Swiften/Component/CoreComponent.h \ Swiften/Disco \ Swiften/Elements \ Swiften/EventLoop \ + Swiften/FileTransfer \ Swiften/JID \ Swiften/MUC \ Swiften/Presence \ @@ -154,7 +153,6 @@ HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES HTML_DYNAMIC_SECTIONS = YES GENERATE_DOCSET = YES DOCSET_FEEDNAME = "Swiften API Documentation" @@ -173,7 +171,6 @@ TOC_EXPAND = NO #QHG_LOCATION = DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = YES TREEVIEW_WIDTH = 250 FORMULA_FONTSIZE = 10 @@ -216,8 +213,6 @@ MAN_LINKS = NO #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- @@ -262,7 +257,6 @@ CLASS_DIAGRAMS = YES MSCGEN_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES -DOT_FONTNAME = FreeSans DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = YES @@ -287,4 +281,4 @@ DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- -SEARCHENGINE = YES +SEARCHENGINE = NO 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 27ac55e..0000000 --- a/Documentation/BuildingGenerics.txt +++ /dev/null @@ -1,2 +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 diff --git a/Documentation/BuildingOnUnix.txt b/Documentation/BuildingOnUnix.txt deleted file mode 100644 index ef74387..0000000 --- a/Documentation/BuildingOnUnix.txt +++ /dev/null @@ -1,36 +0,0 @@ -Prerequisites ------------- -- GCC -- Python -- OpenSSL (and development package) -- Qt Open Source Edition (and development package. Optional; not needed for Swiften) - -Building --------- -- Create a file 'config.py' with the following contents, reflecting your local - setup: - qt = "path/to/qt" - (e.g. qt = "/usr/share/qt4") -- 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 73b6906..0000000 --- a/Documentation/BuildingOnWindows.txt +++ /dev/null @@ -1,55 +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 -- No OpenSSL -- WiX -- config.py should contain: - qt = "c:\\qt\\4.7.4" - vcredist = "c:\\Program Files\\Common Files\\Merge Modules" - debug = 1 - optimize = 1 - wix_bindir = "c:\\program files\\Windows Installer XML v3.5\\bin" -- run - scons dist=1 diff --git a/Documentation/SConscript b/Documentation/SConscript index 03305a7..e2f6393 100644 --- a/Documentation/SConscript +++ b/Documentation/SConscript @@ -1,4 +1,4 @@ Import("env") if env["SCONS_STAGE"] == "build" : - SConscript(dirs = ["SwiftenDevelopersGuide", "SwiftUserGuide", "API"]) + SConscript(dirs = ["SwiftenDevelopersGuide", "SwiftUserGuide", "API", "SwiftAPI"]) diff --git a/Documentation/SwiftAPI/.gitignore b/Documentation/SwiftAPI/.gitignore new file mode 100644 index 0000000..1936cc1 --- /dev/null +++ b/Documentation/SwiftAPI/.gitignore @@ -0,0 +1 @@ +html diff --git a/Documentation/SwiftAPI/Doxyfile b/Documentation/SwiftAPI/Doxyfile new file mode 100644 index 0000000..f092c99 --- /dev/null +++ b/Documentation/SwiftAPI/Doxyfile @@ -0,0 +1,285 @@ +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = Swift +PROJECT_NUMBER = +OUTPUT_DIRECTORY = Documentation/SwiftAPI +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 2 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +BUILTIN_STL_SUPPORT = YES +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +TYPEDEF_HIDES_STRUCT = NO +#SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = NO +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = NO +SHOW_FILES = NO +SHOW_NAMESPACES = NO +FILE_VERSION_FILTER = +#LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text " +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = \ + Swiften/Avatars \ + Swiften/Base \ + Swiften/Chat \ + Swiften/Client/Client.h \ + Swiften/Client/CoreClient.h \ + Swiften/Client/ClientError.h \ + Swiften/Client/StanzaChannel.h \ + Swiften/Client/NickResolver.h \ + Swiften/Client/Storages.h \ + Swiften/Client/MemoryStorages.h \ + Swiften/Component/Component.h \ + Swiften/Component/CoreComponent.h \ + Swiften/Disco \ + Swiften/Elements \ + Swiften/EventLoop \ + Swiften/JID \ + Swiften/MUC \ + Swiften/Presence \ + Swiften/Queries \ + Swiften/Roster/XMPPRoster.h \ + Swiften/StringCodecs \ + Swiften/TLS/BlindCertificateTrustChecker.h \ + Swiften/TLS/Certificate.h \ + Swiften/TLS/CertificateTrustChecker.h \ + Swiften/VCards \ + Swift/Controllers \ + Swift/QtUI +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.h +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = */3rdParty/* */UnitTest/* */QA/* +EXCLUDE_SYMBOLS = Ui_* +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_DYNAMIC_SECTIONS = YES +GENERATE_DOCSET = YES +DOCSET_FEEDNAME = "Swift XMPP Client Documentation" +DOCSET_BUNDLE_ID = im.swift.Swiften +GENERATE_HTMLHELP = YES +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +#GENERATE_QHP = NO +#QCH_FILE = +#QHP_NAMESPACE = im.swift.Swiften +#QHP_VIRTUAL_FOLDER = doc +#QHG_LOCATION = +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +TREEVIEW_WIDTH = 250 +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = YES +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = +MAN_EXTENSION = .3 +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +MSCGEN_PATH = +HIDE_UNDOC_RELATIONS = YES +HAVE_DOT = YES +DOT_FONTPATH = +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = NO +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/Documentation/SwiftAPI/SConscript b/Documentation/SwiftAPI/SConscript new file mode 100644 index 0000000..a8a8b1b --- /dev/null +++ b/Documentation/SwiftAPI/SConscript @@ -0,0 +1,6 @@ +Import("env") + +if "doc" in ARGUMENTS : + 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/SwiftUserGuide/Swift Users Guide.xml b/Documentation/SwiftUserGuide/Swift Users Guide.xml index 7cbec60..b83b578 100644 --- a/Documentation/SwiftUserGuide/Swift Users Guide.xml +++ b/Documentation/SwiftUserGuide/Swift Users Guide.xml @@ -91,4 +91,4 @@ </author> </biblioentry> </bibliography> -</book>
\ No newline at end of file +</book> diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore index aca6fe1..ef95cc1 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/.gitignore @@ -1,4 +1,5 @@ EchoBot? +EchoBot0x *.cpp.xml *.h.xml EchoComponent diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp index 11773ae..9a7301a 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot0x.cpp @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <Swiften/Swiften.h> @@ -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 8a64b56..6e04eee 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot1.cpp @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #include <Swiften/Swiften.h> @@ -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 8b81489..d928db8 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot2.cpp @@ -1,10 +1,11 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 e3e3560..470753d 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot3.cpp @@ -1,10 +1,11 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 c8d8c84..9ab7864 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot4.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 810424c..3475a6c 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot5.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 92a2ab6..e1d5528 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoBot6.cpp @@ -1,13 +1,14 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 a6e6ca0..16d7e4e 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoComponent.cpp @@ -1,10 +1,11 @@ /* - * Copyright (c) 2010-2013 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 62ea495..1e5fc98 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ //... #pragma once @@ -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 33a8c41..48d08bd 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h @@ -1,7 +1,7 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * Copyright (c) 2010 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. */ #pragma once @@ -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 068113c..faf1080 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h @@ -1,19 +1,20 @@ /* - * Copyright (c) 2010 Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. + * 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 aa9f691..268ab9a 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/SConscript @@ -6,27 +6,12 @@ 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" +# 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" 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 -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 c50641f..95e5c87 100644 --- a/Documentation/SwiftenDevelopersGuide/SConscript +++ b/Documentation/SwiftenDevelopersGuide/SConscript @@ -9,87 +9,56 @@ 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() + # 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("//...", "]]>…<![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() - 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 = "<calloutlist>" + "\n".join(calloutLines) + "</calloutlist>" if len(calloutLines) > 0 else "" - 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("//...", "]]>…<![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() : + document = "<foo><programlisting><![CDATA[" + program.strip() + "]]></programlisting></foo>" - for programName, program in programs.items() : - program = stripEmptyLines(program) - (program, callouts) = createCallouts(program, filenameBase + "-" + programName) - - 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"]) |