1 /*
2   Copyright (c) 2005-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 FLEXOFFHANDLER_H__
15 #define FLEXOFFHANDLER_H__
16 
17 #include "disco.h"
18 #include "gloox.h"
19 
20 namespace gloox
21 {
22 
23   /**
24    * Describes the possible results of a message retrieval or deletion request.
25    */
26   enum FlexibleOfflineResult
27   {
28     FomrRemoveSuccess,           /**< Message(s) were removed successfully. */
29     FomrRequestSuccess,          /**< Message(s) were fetched successfully. */
30     FomrForbidden,               /**< The requester is a JID other than an authorized resource of the
31                                   * user. Something wnet serieously wrong */
32     FomrItemNotFound,            /**< The requested node (message ID) does not exist. */
33     FomrUnknownError             /**< An error occurred which is not specified in @xep{0013}. */
34   };
35 
36   /**
37    * @brief Implementation of this virtual interface allows for retrieval of offline messages following
38    * @xep{0030}.
39    *
40    * @author Jakob Schröter <js@camaya.net>
41    * @since 0.7
42    */
43   class GLOOX_API FlexibleOfflineHandler
44   {
45     public:
46       /**
47        * Virtual Destructor.
48        */
~FlexibleOfflineHandler()49       virtual ~FlexibleOfflineHandler() {}
50 
51       /**
52        * This function is called to indicate whether the server supports @xep{0013} or not.
53        * Call @ref FlexibleOffline::checkSupport() to trigger the check.
54        * @param support Whether the server support @xep{0013} or not.
55        */
56       virtual void handleFlexibleOfflineSupport( bool support ) = 0;
57 
58       /**
59        * This function is called to announce the number of available offline messages.
60        * Call @ref FlexibleOffline::getMsgCount() to trigger the check.
61        * @param num The number of stored offline messages.
62        */
63       virtual void handleFlexibleOfflineMsgNum( int num ) = 0;
64 
65       /**
66        * This function is called when the offline message headers arrive.
67        * Call @ref FlexibleOffline::fetchHeaders() to trigger the check.
68        * @param headers A map of ID/sender pairs describing the offline messages.
69        */
70       virtual void handleFlexibleOfflineMessageHeaders( const Disco::ItemList& headers ) = 0;
71 
72       /**
73        * This function is called to indicate the result of a fetch or delete instruction.
74        * @param foResult The result of the operation.
75        */
76       virtual void handleFlexibleOfflineResult( FlexibleOfflineResult foResult ) = 0;
77 
78   };
79 
80 }
81 
82 #endif // FLEXOFFHANDLER_H__
83