forked from blue/squawk
first thought about forms, discovering contact pep support
This commit is contained in:
parent
c50cd1140e
commit
7b2b7ee5d5
@ -623,12 +623,13 @@ void Core::Account::onDiscoveryInfoReceived(const QXmppDiscoveryIq& info)
|
||||
bool pepSupported = false;
|
||||
for (const QXmppDiscoveryIq::Identity& identity : identities) {
|
||||
QString type = identity.type();
|
||||
qDebug() << " " << identity.category() << type;
|
||||
if (type == "pep") {
|
||||
QString category = identity.category();
|
||||
qDebug() << " " << category << type;
|
||||
if (type == "pep" && category == "pubsub") {
|
||||
pepSupported = true;
|
||||
}
|
||||
}
|
||||
rh->setPepSupport(pepSupported);
|
||||
rh->setPepSupport(pepSupported ? Shared::Support::supported : Shared::Support::unsupported);
|
||||
} else {
|
||||
qDebug() << "Received info for account" << name << "about" << from;
|
||||
QString node = info.queryNode();
|
||||
@ -651,6 +652,22 @@ void Core::Account::onDiscoveryInfoReceived(const QXmppDiscoveryIq& info)
|
||||
qDebug() << " " << feat;
|
||||
}
|
||||
emit infoDiscovered(from, node, identities, features);
|
||||
} else {
|
||||
Contact* cont = rh->getContact(from);
|
||||
if (cont != nullptr) {
|
||||
qDebug() << "Received info for account" << name << "about" << from;
|
||||
QList<QXmppDiscoveryIq::Identity> identities = info.identities();
|
||||
bool pepSupported = false;
|
||||
for (const QXmppDiscoveryIq::Identity& identity : identities) {
|
||||
QString type = identity.type();
|
||||
QString category = identity.category();
|
||||
qDebug() << " " << category << type;
|
||||
if (type == "pep" && category == "pubsub") {
|
||||
pepSupported = true;
|
||||
}
|
||||
}
|
||||
cont->setPepSupport(pepSupported ? Shared::Support::supported : Shared::Support::unsupported);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@
|
||||
Core::Contact::Contact(const QString& pJid, const QString& account, QObject* parent):
|
||||
RosterItem(pJid, account, parent),
|
||||
groups(),
|
||||
subscriptionState(Shared::SubscriptionState::unknown)
|
||||
subscriptionState(Shared::SubscriptionState::unknown),
|
||||
pep(Shared::Support::unknown)
|
||||
{
|
||||
}
|
||||
|
||||
@ -98,3 +99,15 @@ void Core::Contact::handlePresence(const QXmppPresence& pres)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Contact::setPepSupport(Shared::Support support) {
|
||||
if (pep != support) {
|
||||
pep = support;
|
||||
}
|
||||
}
|
||||
|
||||
Shared::Support Core::Contact::getPepSupport() const {
|
||||
return pep;}
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,11 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
|
||||
#include "rosteritem.h"
|
||||
|
||||
#include <shared/enums.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Contact : public RosterItem
|
||||
@ -38,6 +41,9 @@ public:
|
||||
|
||||
void setSubscriptionState(Shared::SubscriptionState state);
|
||||
Shared::SubscriptionState getSubscriptionState() const;
|
||||
void setPepSupport(Shared::Support support);
|
||||
Shared::Support getPepSupport() const;
|
||||
|
||||
void handlePresence(const QXmppPresence & pres) override;
|
||||
|
||||
signals:
|
||||
@ -48,6 +54,7 @@ signals:
|
||||
private:
|
||||
QSet<QString> groups;
|
||||
Shared::SubscriptionState subscriptionState;
|
||||
Shared::Support pep;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ Core::RosterHandler::RosterHandler(Core::Account* account):
|
||||
groups(),
|
||||
queuedContacts(),
|
||||
outOfRosterContacts(),
|
||||
pepSupport(false)
|
||||
pepSupport(Shared::Support::unknown)
|
||||
{
|
||||
connect(acc->rm, &QXmppRosterManager::rosterReceived, this, &RosterHandler::onRosterReceived);
|
||||
connect(acc->rm, &QXmppRosterManager::itemAdded, this, &RosterHandler::onRosterItemAdded);
|
||||
@ -111,6 +111,10 @@ void Core::RosterHandler::addedAccount(const QString& jid)
|
||||
if (grCount == 0) {
|
||||
emit acc->addContact(jid, "", cData);
|
||||
}
|
||||
if (pepSupport == Shared::Support::supported) {
|
||||
acc->dm->requestInfo(jid);
|
||||
//acc->dm->requestItems(jid);
|
||||
}
|
||||
handleNewContact(contact);
|
||||
}
|
||||
}
|
||||
@ -588,13 +592,21 @@ void Core::RosterHandler::handleOffline()
|
||||
pair.second->clearArchiveRequests();
|
||||
pair.second->downgradeDatabaseState();
|
||||
}
|
||||
setPepSupport(false);
|
||||
setPepSupport(Shared::Support::unknown);
|
||||
}
|
||||
|
||||
|
||||
void Core::RosterHandler::setPepSupport(bool support)
|
||||
void Core::RosterHandler::setPepSupport(Shared::Support support)
|
||||
{
|
||||
if (pepSupport != support) {
|
||||
pepSupport = support;
|
||||
|
||||
if (pepSupport == Shared::Support::supported) {
|
||||
for (const std::pair<const QString, Contact*>& pair : contacts) {
|
||||
if (pair.second->getPepSupport() == Shared::Support::unknown) {
|
||||
acc->dm->requestInfo(pair.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QXmppMucManager.h>
|
||||
#include <QXmppRosterIq.h>
|
||||
|
||||
#include <shared/enums.h>
|
||||
#include <shared/message.h>
|
||||
#include <core/contact.h>
|
||||
#include <core/conference.h>
|
||||
@ -64,7 +65,7 @@ public:
|
||||
|
||||
void storeConferences();
|
||||
void clearConferences();
|
||||
void setPepSupport(bool support);
|
||||
void setPepSupport(Shared::Support support);
|
||||
|
||||
private slots:
|
||||
void onRosterReceived();
|
||||
@ -108,7 +109,7 @@ private:
|
||||
std::map<QString, std::set<QString>> groups;
|
||||
std::map<QString, QString> queuedContacts;
|
||||
std::set<QString> outOfRosterContacts;
|
||||
bool pepSupport;
|
||||
Shared::Support pepSupport;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -22,4 +22,8 @@ target_sources(squawk PRIVATE
|
||||
clientinfo.cpp
|
||||
identity.h
|
||||
identity.cpp
|
||||
form.h
|
||||
form.cpp
|
||||
field.h
|
||||
field.cpp
|
||||
)
|
||||
|
@ -117,5 +117,12 @@ Q_ENUM_NS(AccountPassword)
|
||||
static const AccountPassword AccountPasswordHighest = AccountPassword::kwallet;
|
||||
static const AccountPassword AccountPasswordLowest = AccountPassword::plain;
|
||||
|
||||
enum class Support {
|
||||
unknown,
|
||||
supported,
|
||||
unsupported
|
||||
};
|
||||
Q_ENUM_NS(Support)
|
||||
|
||||
}
|
||||
#endif // SHARED_ENUMS_H
|
||||
|
28
shared/field.cpp
Normal file
28
shared/field.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
// 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/>.
|
||||
|
||||
#include "field.h"
|
||||
|
||||
Shared::Field::Field(Shared::Field::Type fieldTtype):
|
||||
type(fieldTtype),
|
||||
key(),
|
||||
label(),
|
||||
description(),
|
||||
required(false),
|
||||
options(),
|
||||
value()
|
||||
{
|
||||
}
|
61
shared/field.h
Normal file
61
shared/field.h
Normal file
@ -0,0 +1,61 @@
|
||||
// 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/>.
|
||||
|
||||
#ifndef SHARED_FIELD_H
|
||||
#define SHARED_FIELD_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class Field
|
||||
{
|
||||
public:
|
||||
enum class Type {
|
||||
boolean,
|
||||
fixed,
|
||||
hidden,
|
||||
jidMultiple,
|
||||
jidSingle,
|
||||
listMultiple,
|
||||
listSingle,
|
||||
textMultiple,
|
||||
textPrivate,
|
||||
textSingle
|
||||
};
|
||||
|
||||
Field(Type fieldType);
|
||||
|
||||
public:
|
||||
const Type type;
|
||||
QString key;
|
||||
QString label;
|
||||
QString description;
|
||||
bool required;
|
||||
std::list<std::pair<QString, QString>> options;
|
||||
QVariant value;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHARED_FIELD_H
|
23
shared/form.cpp
Normal file
23
shared/form.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// 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/>.
|
||||
|
||||
#include "form.h"
|
||||
|
||||
Shared::Form::Form(Shared::Form::Type formType):
|
||||
type(formType),
|
||||
title(),
|
||||
instructions(),
|
||||
fields() {}
|
48
shared/form.h
Normal file
48
shared/form.h
Normal file
@ -0,0 +1,48 @@
|
||||
// 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/>.
|
||||
|
||||
#ifndef SHARED_FORM_H
|
||||
#define SHARED_FORM_H
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <shared/field.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
class Form
|
||||
{
|
||||
public:
|
||||
enum class Type {
|
||||
none,
|
||||
form,
|
||||
submit,
|
||||
cancel,
|
||||
result
|
||||
};
|
||||
|
||||
Form(Type formType);
|
||||
|
||||
public:
|
||||
const Type type;
|
||||
QString title;
|
||||
QString instructions;
|
||||
std::list<Field> fields;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // SHARED_FORM_H
|
Loading…
Reference in New Issue
Block a user