1 /*
2 * Copyright (c) 2004-2019 by Jakob Schröter <js@camaya.net>
3 * This file is part of the gloox library. http://camaya.net/gloox
4 *
5 * This software is distributed under a license. The full license
6 * agreement can be found in the file LICENSE in this distribution.
7 * This software may not be copied, modified, sold or distributed
8 * other than expressed in the named license agreement.
9 *
10 * This software is distributed without any warranty.
11 */
12
13 #include "../../tag.h"
14 #include "../../iq.h"
15 #include "../../iqhandler.h"
16 #include "../../base64.h"
17 #include "../../stanzaextensionfactory.h"
18 #include "../../disco.h"
19 #include "../../flexoffhandler.h"
20 using namespace gloox;
21
22 #include <stdio.h>
23 #include <locale.h>
24 #include <string>
25 #include <cstdio> // [s]print[f]
26
27 gloox::JID g_jid( "foof" );
28
29 namespace gloox
30 {
31 class Disco;
32
33 class ClientBase
34 {
35 public:
ClientBase()36 ClientBase() : m_disco( new Disco( this ) ) {}
~ClientBase()37 virtual ~ClientBase() { delete m_disco; }
38 Disco* disco();
jid() const39 const JID& jid() const { return m_jid; }
40 const std::string getID();
41 virtual void send( IQ& ) = 0;
42 virtual void send( const IQ&, IqHandler*, int ) = 0;
43 virtual void trackID( IqHandler *ih, const std::string& id, int context ) = 0;
44 void removeIqHandler( IqHandler* ih, int exttype );
45 void registerIqHandler( IqHandler* ih, int exttype );
46 void registerStanzaExtension( StanzaExtension* ext );
47 void removeStanzaExtension( int ext );
removeIDHandler(IqHandler *)48 void removeIDHandler( IqHandler* ) {}
49 private:
50 Disco* m_disco;
51 JID m_jid;
52 };
disco()53 Disco* ClientBase::disco() { return m_disco; }
removeIqHandler(IqHandler *,int)54 void ClientBase::removeIqHandler( IqHandler*, int ) {}
registerIqHandler(IqHandler *,int)55 void ClientBase::registerIqHandler( IqHandler*, int ) {}
registerStanzaExtension(StanzaExtension * se)56 void ClientBase::registerStanzaExtension( StanzaExtension* se ) { delete se; }
removeStanzaExtension(int)57 void ClientBase::removeStanzaExtension( int ) {}
getID()58 const std::string ClientBase::getID() { return "id"; }
59 }
60 using namespace gloox;
61
62 #define CLIENTBASE_H__
63 #define FLEXOFF_TEST
64 #include "../../disco.cpp"
65 #include "../../flexoff.h"
66 #include "../../flexoff.cpp"
67
main(int,char **)68 int main( int /*argc*/, char** /*argv*/ )
69 {
70 int fail = 0;
71 std::string name;
72
73 // -------
74 {
75 name = "empty tag() test";
76 FlexibleOffline::Offline foo;
77 if( false )
78 {
79 ++fail;
80 fprintf( stderr, "test '%s' failed\n", name.c_str() );
81 }
82 }
83
84
85 StanzaExtensionFactory sef;
86 sef.registerExtension( new FlexibleOffline::Offline() );
87 // -------
88 {
89 name = "FlexibleOffline::Offline/SEFactory test";
90 Tag* f = new Tag( "iq" );
91 new Tag( f, "offline", "xmlns", XMLNS_OFFLINE );
92 IQ iq( IQ::Set, JID(), "" );
93 sef.addExtensions( iq, f );
94 const FlexibleOffline::Offline* se = iq.findExtension<FlexibleOffline::Offline>( ExtFlexOffline );
95 if( se == 0 )
96 {
97 ++fail;
98 fprintf( stderr, "test '%s' failed\n", name.c_str() );
99 }
100 delete f;
101 }
102
103
104 printf( "FlexibleOffline::Offline: " );
105 if( fail == 0 )
106 {
107 printf( "OK\n" );
108 return 0;
109 }
110 else
111 {
112 fprintf( stderr, "%d test(s) failed\n", fail );
113 return 1;
114 }
115
116 }
117