File indexing completed on 2023-12-03 05:01:58
0001 /* 0002 * Global Presence - wrap Tp::Presence with KDE functionality 0003 * 0004 * Copyright (C) 2011 David Edmundson <kde@davidedmundson.co.uk> 0005 * Copyright (C) 2012 Daniele E. Domenichelli <daniele.domenichelli@gmail.com> 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Lesser General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2.1 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library; if not, write to the Free Software 0019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0020 */ 0021 0022 #ifndef PRESENCE_H 0023 #define PRESENCE_H 0024 0025 #include <TelepathyQt/Presence> 0026 0027 #include <KTp/ktpcommoninternals_export.h> 0028 0029 namespace KTp 0030 { 0031 0032 class KTPCOMMONINTERNALS_EXPORT Presence : public Tp::Presence 0033 { 0034 public: 0035 Presence(); 0036 Presence(const Tp::Presence &presence); 0037 0038 /** 0039 * \brief Get the icon for the presence. 0040 * 0041 * \param useImIcons Use im-user-* icons instead of the user-* (i.e. the "pawn" icons instead of the "circles"). 0042 * \return The icon for the current presence. 0043 */ 0044 QIcon icon(bool useImIcons = false) const; 0045 0046 /** 0047 * \brief Get the icon for the presence with the specified overlays. 0048 * 0049 * \param overlays The overlays to apply at the icon. 0050 * \param useImIcons Use im-user-* icons instead of the user-* (i.e. the "pawn" icons instead of the "circles"). 0051 * \return The icon for the current presence. 0052 */ 0053 QIcon icon(QStringList overlays, bool useImIcons = false) const; 0054 0055 /** 0056 * \brief Get the name of the icon for the presence. 0057 * 0058 * This is useful for example if you want to create an icon using the presence as overlay. 0059 * \param useImIcons Use im-user-* icons instead of the user-* (i.e. the "pawn" icons instead of the "circles"). 0060 * \return The name of the icon for the current presence. 0061 */ 0062 QString iconName(bool useImIcons = false) const; 0063 0064 /** 0065 * \brief Get a i18n string representing the presence. 0066 * 0067 * \return An i18n string representing the presence. 0068 */ 0069 QString displayString() const; 0070 0071 /** 0072 * \brief Returns if the presences are equivalent 0073 */ 0074 bool operator ==(const Presence &other) const; 0075 0076 /** 0077 * \brief Returns if the presences are not equivalent 0078 */ 0079 bool operator !=(const Presence &other) const; 0080 0081 /** 0082 * \brief Returns which presence is "less available" 0083 */ 0084 bool operator <(const Presence &other) const; 0085 0086 /** 0087 * \brief Returns which presence is "more available" 0088 */ 0089 bool operator >(const Presence &other) const; 0090 0091 /** 0092 * \brief Returns an int representation of the presence type sorted by priority. 0093 * 0094 * 0 - most online, 7 - offline 0095 */ 0096 static int sortPriority(const Tp::ConnectionPresenceType &type); 0097 }; 0098 0099 } 0100 0101 Q_DECLARE_METATYPE(KTp::Presence); 0102 0103 #endif // PRESENCE_H