~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to libkopete/kopeteonlinestatusmanager.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    kopeteonlinestatusmanager.h
 
3
 
 
4
    Copyright (c) 2004-2005 by Olivier Goffart  <ogoffart@kde.org>
 
5
 
 
6
    Kopete    (c) 2004-2005 by the Kopete developers  <kopete-devel@kde.org>
 
7
 
 
8
    *************************************************************************
 
9
    *                                                                       *
 
10
    * This library is free software; you can redistribute it and/or         *
 
11
    * modify it under the terms of the GNU Lesser General Public            *
 
12
    * License as published by the Free Software Foundation; either          *
 
13
    * version 2 of the License, or (at your option) any later version.      *
 
14
    *                                                                       *
 
15
    *************************************************************************
 
16
*/
 
17
 
 
18
#ifndef kopeteonlinestatusmanager_h__
 
19
#define kopeteonlinestatusmanager_h__
 
20
 
 
21
#include "kopete_export.h"
 
22
 
 
23
#include <QtCore/QObject>
 
24
#include <QtCore/QFlags>
 
25
#include <QtCore/QMap>
 
26
 
 
27
class QPixmap;
 
28
class QColor;
 
29
class KIcon;
 
30
 
 
31
namespace Kopete
 
32
{
 
33
        class OnlineStatus;
 
34
        class Protocol;
 
35
 
 
36
 
 
37
/**
 
38
 * OnlineStatusManager is a singleton which manage OnlineStatus
 
39
 *
 
40
 * @author Olivier Goffart
 
41
 */
 
42
class KOPETE_EXPORT OnlineStatusManager : public QObject
 
43
{
 
44
        Q_OBJECT
 
45
public:
 
46
        static OnlineStatusManager* self();
 
47
        ~OnlineStatusManager();
 
48
 
 
49
        /**
 
50
         * Kopete will uses categories to have a more general system than simply globally away.
 
51
         *
 
52
         * Idealy, in each protocol, there should be one status per categories (status may be in several or in none categories
 
53
         *
 
54
         * Idle is the status used for auto-away
 
55
         *
 
56
         * Status number are organised so that make a tree.
 
57
         */
 
58
        //please be carrefull when modifying values of status.  read comment in onlineStatus()
 
59
        enum Category
 
60
        {
 
61
                Idle=1<<8,  ExtendedAway=1<<9 , Invisible=1<<10,
 
62
                //  \     /             __________/
 
63
                  /*1<<4*/    Busy=1<<5,           FreeForChat=1<<6,         /* 1<<7*/
 
64
                //   \       /                         /
 
65
                     Away=1<<2,                   /* 1<<3 */
 
66
                //       \                           /
 
67
                                                Online=1<<1,
 
68
                Offline=1
 
69
        };
 
70
        Q_DECLARE_FLAGS(Categories, Category)
 
71
 
 
72
 
 
73
        /**
 
74
         * @see registerOnlineStatus
 
75
         */
 
76
        enum Option
 
77
        {
 
78
                /// The user may set status messages for this online status
 
79
                HasStatusMessage = 0x01,
 
80
                /// The action of the status will be disabled if the account is offline.
 
81
                /// use it if your protocol doesn't support connecting with the status as initial status.
 
82
                /// You praticaly shouldn't abuse of that, and automatically set status after connecting if possible
 
83
                DisabledIfOffline = 0x02,
 
84
                ///  The status will not appears in the action menu. Used if you want to register the status for e.g. autoaway,
 
85
                ///  without letting the user set itself that status
 
86
                HideFromMenu = 0x04
 
87
        };
 
88
        Q_DECLARE_FLAGS(Options, Option)
 
89
 
 
90
        /**
 
91
         * You need to register each status an account can be.
 
92
         * Registered statuses will appear in the account menu.
 
93
         *
 
94
         * You should use a special OnlineStatus constructor that call this function automatically
 
95
         * The Protocol constructor is a good place to construct the OnlineStatuses
 
96
         *
 
97
         * You can set the status to be in the predefined categories.
 
98
         * Ideally, each category should own one status.
 
99
         * A status may be in several categories, or in none.
 
100
         * There shouldn't be more than one status per protocol per categories.
 
101
         *
 
102
         * @param status The status to register
 
103
         */
 
104
        void registerOnlineStatus(const OnlineStatus& status);
 
105
 
 
106
        /**
 
107
         * return the status of the @p protocol which is in the category @p category
 
108
         *
 
109
         * If no status has been registered in this category, return the one in the category which is the most similair
 
110
         */
 
111
        OnlineStatus onlineStatus(Protocol *protocol, Categories category) const;
 
112
 
 
113
        /**
 
114
         * return the registered statuses for given @p protocol
 
115
         */
 
116
        QList<OnlineStatus> registeredStatusList( Protocol *protocol ) const;
 
117
 
 
118
        /**
 
119
         * return KIcon for given @p category
 
120
         */
 
121
        static KIcon pixmapForCategory( Categories category );
 
122
 
 
123
        /**
 
124
         * This returns status from config as Kopete::OnlineStatusManager::Category
 
125
         *
 
126
         * @return the desired initial status
 
127
         */
 
128
        Kopete::OnlineStatusManager::Category initialStatus() const;
 
129
 
 
130
private:
 
131
        friend class OnlineStatus;
 
132
        friend class OnlineStatusIconEngine;
 
133
        QPixmap cacheLookupByObject( const OnlineStatus &statusFor, const QString& icon, int size, QColor color, bool idle = false);
 
134
        QPixmap cacheLookupByMimeSource( const QString &mimeSource );
 
135
        QString fingerprint( const OnlineStatus &statusFor, const QString& icon, int size, QColor color, bool idle = false);
 
136
        QPixmap* renderIcon( const OnlineStatus &statusFor, const QString& baseicon, int size, QColor color, bool idle = false) const;
 
137
 
 
138
signals:
 
139
        void iconsChanged();
 
140
 
 
141
private slots:
 
142
        void slotIconsChanged();
 
143
 
 
144
private:
 
145
        OnlineStatusManager();
 
146
        class Private;
 
147
        Private * const d;
 
148
};
 
149
 
 
150
Q_DECLARE_OPERATORS_FOR_FLAGS(OnlineStatusManager::Categories)
 
151
Q_DECLARE_OPERATORS_FOR_FLAGS(OnlineStatusManager::Options)
 
152
 
 
153
}  //END namespace Kopete
 
154
 
 
155
#endif
 
156
 
 
157
// vim: set noet ts=4 sts=4 sw=4:
 
158