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 
14 #ifndef DISCOHANDLER_H__
15 #define DISCOHANDLER_H__
16 
17 #include "macros.h"
18 #include "disco.h"
19 
20 #include <string>
21 
22 namespace gloox
23 {
24 
25   class IQ;
26 
27   /**
28    * @brief A virtual interface that enables objects to receive Service Discovery (@xep{0030}) events.
29    *
30    * A class implementing this interface can receive the results of sent disco queries.
31    *
32    * @author Jakob Schröter <js@camaya.net>
33    */
34   class GLOOX_API DiscoHandler
35   {
36     public:
37       /**
38        * Virtual Destructor.
39        */
~DiscoHandler()40       virtual ~DiscoHandler() {}
41 
42       /**
43        * Reimplement this function if you want to be notified about the result
44        * of an disco#info query.
45        * @param from The sender of the disco#info result.
46        * @param info The Info.
47        * @param context A context identifier.
48        * @since 1.0
49        */
50       virtual void handleDiscoInfo( const JID& from, const Disco::Info& info, int context ) = 0;
51 
52       /**
53        * Reimplement this function if you want to be notified about the result
54        * of a disco#items query.
55        * @param from The sender of the disco#items result.
56        * @param items The Items.
57        * @param context A context identifier.
58        * @since 1.0
59        */
60       virtual void handleDiscoItems( const JID& from, const Disco::Items& items, int context ) = 0;
61 
62       /**
63        * Reimplement this function to receive disco error notifications.
64        * @param from The sender of the error result.
65        * @param error The Error. May be 0.
66        * @param context A context identifier.
67        * @since 1.0
68        */
69       virtual void handleDiscoError( const JID& from, const Error* error, int context ) = 0;
70 
71       /**
72        * Reimplement this function to receive notifications about incoming IQ
73        * stanzas of type 'set' in the disco namespace.
74        * @param iq The full IQ.
75        * @return Returns @b true if the stanza was handled and answered, @b false otherwise.
76        */
handleDiscoSet(const IQ & iq)77       virtual bool handleDiscoSet( const IQ& iq ) { (void)iq; return false; }
78 
79   };
80 
81 }
82 
83 #endif // DISCOHANDLER_H__
84