Skip to content

Commit

Permalink
Fixed publish options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Jun 13, 2024
1 parent c8cd2fd commit dccdff2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion iris
2 changes: 0 additions & 2 deletions src/avatars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ class AvatarCache : public FileCache {
return; // doesn't look like sha1 hash. just ignore it
}

VCardFactory::instance()->ensureVCardPhotoUpdated(pa, jid, {}, hash);

for (; !info.isNull(); info = info.nextSiblingElement(QLatin1String("info"))) {
if (info.attribute(QLatin1String("type")).toLower() != QLatin1String("image/png")) {
continue; // TODO add support for QImageReader::supportedMimeTypes() (requires usage of qnam)
Expand Down
41 changes: 15 additions & 26 deletions src/pepmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,39 +183,28 @@ class PEPPublishTask : public Task {
publish.appendChild(item);

if (access != PEPManager::DefaultAccess || persisteItems) {
QDomElement conf = doc()->createElement("configure");
QDomElement conf_x = doc()->createElementNS("jabber:x:data", "x");

// Form type
QDomElement conf_x_field_type = doc()->createElement("field");
conf_x_field_type.setAttribute("var", "FORM_TYPE");
conf_x_field_type.setAttribute("type", "hidden");
QDomElement conf_x_field_type_value = doc()->createElement("value");
conf_x_field_type_value.appendChild(doc()->createTextNode("http://jabber.org/protocol/pubsub#node_config"));
conf_x_field_type.appendChild(conf_x_field_type_value);
conf_x.appendChild(conf_x_field_type);

// Access model
QDomElement conf = doc()->createElement("publish-options");
XData form(XData::Data_Submit);
form.setRegistrarType(QLatin1String("http://jabber.org/protocol/pubsub#publish-options"));
XMPP::XData::FieldList fields;
if (access != PEPManager::DefaultAccess) {
QDomElement access_model = doc()->createElement("field");
access_model.setAttribute("var", "pubsub#access_model");
QDomElement access_model_value = doc()->createElement("value");
access_model.appendChild(access_model_value);
XMPP::XData::Field f;
f.setVar(QLatin1String("pubsub#access_model"));
if (access == PEPManager::PublicAccess) {
access_model_value.appendChild(doc()->createTextNode("open"));
f.setValue({ QLatin1String("open") });
} else if (access == PEPManager::PresenceAccess) {
access_model_value.appendChild(doc()->createTextNode("presence"));
f.setValue({ QLatin1String("presence") });
}
conf_x.appendChild(access_model);
fields << f;
}
if (persisteItems) {
QDomElement pi = doc()->createElement("field");
pi.setAttribute("var", "pubsub#persist_items");
QDomElement pi_value = doc()->createElement("value");
pi.appendChild(pi_value);
pi_value.appendChild(doc()->createTextNode("true"));
conf_x.appendChild(pi);
XMPP::XData::Field f;
f.setVar(QLatin1String("pubsub#persist_items"));
f.setValue({ QLatin1String("true") });
fields << f;
}
form.setFields(fields);
auto conf_x = form.toXml(doc(), true);

conf.appendChild(conf_x);
pubsub.appendChild(conf);
Expand Down
8 changes: 8 additions & 0 deletions src/pepmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class PEPManager : public QObject {
public:
enum Access { DefaultAccess, PresenceAccess, PublicAccess };

/* Implement all
* <option><value>authorize</value></option>
<option><value>open</value></option>
<option><value>presence</value></option>
<option><value>roster</value></option>
<option><value>whitelist</value></option>
*/

PEPManager(XMPP::Client *client, ServerInfoManager *serverInfo);

// void registerNode(const QString&);
Expand Down
10 changes: 7 additions & 3 deletions src/vcardfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,12 @@ Task *VCardRequest::execute()

bool doTemp = (d->flags & VCardFactory::ForceVCardTemp) || (d->flags & VCardFactory::MucRoom)
|| (d->flags & VCardFactory::MucUser);
auto client = (*paIt)->client();
auto pa = (*paIt);
auto client = pa->client();

// auto cm = client->capsManager();
// if (!doTemp) {
// if (d->jid.compare((*paIt)->jid(), false)) {
// if (d->jid.compare(pa->jid(), false)) {
// // we can assume persistent storage is always there
// doTemp = !client->serverInfoManager()->hasPersistentStorage();
// } else {
Expand All @@ -373,7 +374,10 @@ Task *VCardRequest::execute()
// }
// }
if (!doTemp) {
auto task = (*paIt)->pepManager()->get(d->jid, PEP_VCARD4_NODE, QLatin1String("current"));
auto isSelf = pa->jid().compare(d->jid, false);
auto node = isSelf ? CONTACTS_NODE : PEP_VCARD4_NODE;
auto id = isSelf ? pa->jid().bare() : QString::fromLatin1("current");
auto task = pa->pepManager()->get(d->jid, QLatin1String(node), id);
task->connect(task, &PEPGetTask::finished, this, [this, task]() {
if (task->success()) {
if (!task->items().empty()) {
Expand Down

0 comments on commit dccdff2

Please sign in to comment.