2019-09-01 19:46:12 +00:00
|
|
|
/*
|
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-04-05 15:12:59 +00:00
|
|
|
#ifndef MODELS_CONTACT_H
|
|
|
|
#define MODELS_CONTACT_H
|
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
#include <QMap>
|
2019-04-07 20:14:15 +00:00
|
|
|
#include <QIcon>
|
2023-03-17 20:59:51 +00:00
|
|
|
|
2019-04-09 22:01:25 +00:00
|
|
|
#include <deque>
|
2019-04-05 15:12:59 +00:00
|
|
|
|
2023-03-17 20:59:51 +00:00
|
|
|
#include "element.h"
|
|
|
|
#include "presence.h"
|
|
|
|
#include <shared/enums.h>
|
|
|
|
#include <shared/message.h>
|
|
|
|
#include <shared/icons.h>
|
|
|
|
#include <shared/global.h>
|
|
|
|
#include <shared/trustsummary.h>
|
|
|
|
|
2019-04-05 15:12:59 +00:00
|
|
|
namespace Models {
|
2019-04-12 05:51:36 +00:00
|
|
|
|
2020-08-11 22:49:51 +00:00
|
|
|
class Contact : public Element
|
2019-04-05 15:12:59 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-04-17 23:17:47 +00:00
|
|
|
Contact(const Account* acc, const QString& p_jid, const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
2019-04-05 15:12:59 +00:00
|
|
|
~Contact();
|
|
|
|
|
2019-04-07 20:14:15 +00:00
|
|
|
Shared::Availability getAvailability() const;
|
|
|
|
Shared::SubscriptionState getState() const;
|
2020-08-11 22:49:51 +00:00
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
QIcon getStatusIcon(bool big = false) const;
|
2019-04-05 15:12:59 +00:00
|
|
|
|
|
|
|
int columnCount() const override;
|
|
|
|
QVariant data(int column) const override;
|
|
|
|
|
2020-08-11 22:49:51 +00:00
|
|
|
void update(const QString& field, const QVariant& value) override;
|
2019-04-05 15:12:59 +00:00
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
void addPresence(const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removePresence(const QString& name);
|
2022-04-24 15:52:29 +00:00
|
|
|
Presence* getPresence(const QString& name);
|
2019-04-07 14:02:41 +00:00
|
|
|
|
2019-06-18 15:08:03 +00:00
|
|
|
QString getContactName() const;
|
2019-06-21 19:33:38 +00:00
|
|
|
QString getStatus() const;
|
2019-09-24 09:21:29 +00:00
|
|
|
QString getDisplayedName() const override;
|
2023-03-17 20:59:51 +00:00
|
|
|
Shared::TrustSummary getTrust() const;
|
2023-03-17 23:50:04 +00:00
|
|
|
bool hasKeys(Shared::EncryptionProtocol protocol) const;
|
2019-04-09 22:01:25 +00:00
|
|
|
|
2021-05-16 21:52:59 +00:00
|
|
|
void handleRecconnect(); //this is a special method Models::Roster calls when reconnect happens
|
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
protected:
|
|
|
|
void _removeChild(int index) override;
|
2020-04-18 12:02:01 +00:00
|
|
|
void _appendChild(Models::Item * child) override;
|
2019-04-07 14:02:41 +00:00
|
|
|
|
2019-04-09 15:04:08 +00:00
|
|
|
protected slots:
|
|
|
|
void refresh();
|
2019-06-23 11:31:03 +00:00
|
|
|
void toOfflineState() override;
|
2019-04-09 15:04:08 +00:00
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
protected:
|
2019-04-07 20:14:15 +00:00
|
|
|
void setAvailability(Shared::Availability p_state);
|
|
|
|
void setAvailability(unsigned int p_state);
|
|
|
|
void setState(Shared::SubscriptionState p_state);
|
|
|
|
void setState(unsigned int p_state);
|
2019-06-21 19:33:38 +00:00
|
|
|
void setStatus(const QString& p_state);
|
2023-03-17 20:59:51 +00:00
|
|
|
void setTrust(const Shared::TrustSummary& p_trust);
|
2019-04-07 14:02:41 +00:00
|
|
|
|
2019-04-05 15:12:59 +00:00
|
|
|
private:
|
2019-04-07 20:14:15 +00:00
|
|
|
Shared::Availability availability;
|
|
|
|
Shared::SubscriptionState state;
|
2023-03-27 18:45:29 +00:00
|
|
|
Shared::EncryptionProtocol encryption;
|
2023-03-17 20:59:51 +00:00
|
|
|
Shared::TrustSummary trust;
|
2019-04-07 14:02:41 +00:00
|
|
|
QMap<QString, Presence*> presences;
|
2019-06-21 19:33:38 +00:00
|
|
|
QString status;
|
2023-03-27 18:45:29 +00:00
|
|
|
|
2019-04-05 15:12:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MODELS_CONTACT_H
|