summaryrefslogtreecommitdiffstats
path: root/konversation/src/channelnick.h
blob: 3e109195845ca8a76ff1516ffd354827b82d94f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
*/

/*
  channelnick.h - There is an instance of this for each nick in each channel.  So for a person in multiple channels, they will have one NickInfo, and multiple ChannelNicks.
  begin:     Wed Aug 04 2004
  copyright: (C) 2002,2003,2004 by Dario Abatianni
  email:     eisfuchs@tigress.com
*/

#ifndef CHANNEL_NICK_H
#define CHANNEL_NICK_H

#include "nickinfo.h"

#include <ksharedptr.h>


class ChannelNick :  public TQObject, public TDEShared
{
    TQ_OBJECT
  

        public:
        ChannelNick(const NickInfoPtr& nickInfo, const bool& isop, const bool& isadmin,
            const bool& isowner, const bool& ishalfop, const bool& hasvoice);
        ~ChannelNick();
        bool isOp() const;
        bool isAdmin() const;
        bool isOwner() const;
        bool isHalfOp() const;

        /** Return true if the may have any privillages at all
         * @return true if isOp() || isAdmin() || isOwner() || isHalfOp()
         */
        bool isAnyTypeOfOp() const;
        bool hasVoice() const;
        uint timeStamp() const;
        uint recentActivity() const;
        void moreActive();

        bool setVoice(bool state);
        bool setOp(bool state);
        bool setHalfOp(bool state);
        bool setAdmin(bool state);
        bool setOwner(bool state);
        bool setMode(char mode, bool plus);
        bool setMode(int mode);
        bool setMode(bool admin,bool owner,bool op,bool halfop,bool voice);
        void setTimeStamp(uint stamp);

        NickInfoPtr getNickInfo() const;
        //Purely provided for convenience because they are used so often.
        //Just calls nickInfo->getNickname() etc
        TQString getNickname() const;
        TQString loweredNickname() const;
        TQString getHostmask() const;
        TQString tooltip();
    private:
        NickInfoPtr nickInfo;
        bool isop;
        bool isadmin;
        bool isowner;
        bool ishalfop;
        bool hasvoice;
        uint m_timeStamp;
        uint m_recentActivity;

    signals:
        void channelNickChanged();

    public slots:
        void lessActive();
};

/** A ChannelNickPtr is a pointer to a ChannelNick.  Since it is a TDESharedPtr,
 *  the ChannelNick object is automatically destroyed when all references are destroyed.
 */
typedef TDESharedPtr<ChannelNick> ChannelNickPtr;

/** A ChannelNickMap is a list of ChannelNick pointers, indexed and sorted by
 *  lowercase nickname.
 */
typedef TQMap<TQString,ChannelNickPtr> ChannelNickMap;

typedef TQValueList<ChannelNickPtr> ChannelNickList;

/** A ChannelMembershipMap is a list of ChannelNickMap pointers, indexed and
 *  sorted by lowercase channel name.
 */
typedef TQMap<TQString,ChannelNickMap *> ChannelMembershipMap;
#endif                                            /* CHANNEL_NICK_H */