2020-04-02 03:30:02 +02:00
|
|
|
// The Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_M_USER_DEVICES_H
|
|
|
|
|
|
|
|
struct ircd::m::user::devices
|
|
|
|
{
|
2023-04-27 20:58:37 +02:00
|
|
|
struct send;
|
|
|
|
|
2020-04-02 03:30:02 +02:00
|
|
|
using closure = std::function<void (const event::idx &, const string_view &)>;
|
|
|
|
using closure_bool = std::function<bool (const event::idx &, const string_view &)>;
|
|
|
|
|
|
|
|
m::user user;
|
|
|
|
|
|
|
|
bool for_each(const closure_bool &) const; // each device_id
|
|
|
|
bool for_each(const string_view &id, const closure_bool &) const; // each property
|
|
|
|
|
|
|
|
bool has(const string_view &id, const string_view &prop) const;
|
|
|
|
bool has(const string_view &id) const;
|
|
|
|
|
|
|
|
bool get(std::nothrow_t, const string_view &id, const string_view &prop, const closure &) const;
|
|
|
|
bool get(const string_view &id, const string_view &prop, const closure &) const;
|
|
|
|
|
|
|
|
bool put(const string_view &id, const string_view &prop, const string_view &val) const;
|
|
|
|
bool set(const string_view &id, const string_view &prop, const string_view &val) const;
|
|
|
|
bool set(const device &) const;
|
|
|
|
|
|
|
|
bool del(const string_view &id) const;
|
|
|
|
|
|
|
|
///TODO: XXX junk
|
|
|
|
static std::map<std::string, long> count_one_time_keys(const m::user &, const string_view &);
|
|
|
|
static bool update(const device_list_update &);
|
|
|
|
|
|
|
|
devices(const m::user &user)
|
|
|
|
:user{user}
|
|
|
|
{}
|
|
|
|
};
|
2023-04-27 20:58:37 +02:00
|
|
|
|
|
|
|
/// Broadcast m.device_list_update.
|
|
|
|
///
|
|
|
|
struct ircd::m::user::devices::send
|
|
|
|
{
|
|
|
|
send(const m::user::devices &,
|
|
|
|
const m::id::device &,
|
|
|
|
const string_view = {});
|
|
|
|
};
|