~phablet-team/messaging-framework/maintain-connection-state

« back to all changes in this revision

Viewing changes to include/messaging/group_manager.h

  • Committer: Tarmac
  • Author(s): Roberto Mier Escandon
  • Date: 2016-08-16 15:59:06 UTC
  • mfrom: (50.3.14 group-own-permissions)
  • Revision ID: tarmac-20160816155906-4t6hzw1055mr0450
Added flags generic type
Added permissions flags for groups in group_manager, so that every plugin has to fill them with the ones the current user has as participant in the group

NOTE: this MR should be landed along with https://code.launchpad.net/~ningbo-team/ningbo/group-own-permissions/+merge/302308.

Approved by system-apps-ci-bot, Tiago Salem Herrmann.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <messaging/interface.h>
24
24
#include <messaging/member.h>
25
25
#include <messaging/members.h>
 
26
#include <messaging/flags.h>
26
27
 
27
28
#include <memory>
28
29
#include <chrono>
29
30
 
30
31
namespace messaging
31
32
{
 
33
// Maintain sequence of 2 multiples if adding new values to preserve flags management
 
34
enum class GroupPermissions : uint
 
35
{
 
36
    CanChangeTitle  = 1 << 1, //1
 
37
    CanKick         = 1 << 2, //2
 
38
    CanSetAdmin     = 1 << 3, //4
 
39
    CanDissolve     = 1 << 4  //8
 
40
};
32
41
 
33
42
enum class CancelGroupReason
34
43
{
38
47
    Error
39
48
};
40
49
 
 
50
 
41
51
/// @brief GroupManager models a textual group conversation.
42
52
class MESSAGING_FW_PUBLIC GroupManager : public Interface, NonCopyable, NonMovable
43
53
{
56
66
                                            const Member& actor,
57
67
                                            const std::chrono::system_clock::time_point& when) = 0;
58
68
        virtual void on_members_updated(const Members& members) = 0;
 
69
        virtual void on_group_permissions_changed(const Flags<GroupPermissions> &permissions) = 0;
59
70
 
60
71
    protected:
61
72
        Observer() = default;
85
96
    /// @brief members returns current participants in the group.
86
97
    virtual Members members() = 0;
87
98
 
88
 
    /// @breive set_observer sets the observer to receive group manager callback notifications
 
99
    /// @brief set_observer sets the observer to receive group manager callback notifications
89
100
    void set_observer(const std::shared_ptr<Observer> &observer);
90
101
 
 
102
    /// @brief permissions returns the permissions flags for this group and current user
 
103
    Flags<GroupPermissions> &permissions();
 
104
 
 
105
    /// @brief set_permissions sets the permissions flags for this group and current user
 
106
    void set_permissions(const Flags<GroupPermissions> &permissions);
 
107
 
91
108
protected:
92
109
    /// @brief GroupManager constructs a new instance.
93
110
    GroupManager();
103
120
                                      const Member& actor = Member{std::string{}},
104
121
                                      const std::chrono::system_clock::time_point& when = std::chrono::system_clock::now());
105
122
    void announce_members_updated(const Members& members);
 
123
    void announce_group_permissions_changed(const Flags<GroupPermissions> &permissions);
106
124
 
107
125
    /// @cond
108
126
    struct Private;