LeechCraft Azoth 0.6.70-19424-g027e980fd1
Modular multiprotocol IM plugin for LeechCraft
Loading...
Searching...
No Matches
ihistoryplugin.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QList>
12#include <util/threads/coro/taskfwd.h>
13#include "azothcommon.h"
14#include "imessage.h"
15
16class QDateTime;
17class QObject;
18
20{
21 enum class EntryKind : std::uint8_t
22 {
26 };
27
28 template<template<EntryKind K> typename Kinded>
29 using KindedGADT = std::variant<
30 Kinded<EntryKind::Chat>,
31 Kinded<EntryKind::MUC>,
32 Kinded<EntryKind::PrivateChat>
33 >;
34
35 template<EntryKind> struct EntryDescr;
36 template<> struct EntryDescr<EntryKind::Chat> { QString Nick_; };
37 template<> struct EntryDescr<EntryKind::MUC> { QString MucName_; };
38 template<> struct EntryDescr<EntryKind::PrivateChat> { QString MucName_; QString Nick_; std::optional<QByteArray> PersistentId_; };
39
41
42 template<template<EntryKind K> typename EntryKinded>
44 {
45 return static_cast<EntryKind> (gadt.index ());
46 }
47
48 template<EntryKind K>
57
58 struct SelfEndpoint { QString Name_; std::optional<QString> Variant_; };
59
60 template<EntryKind> struct EntryEndpoint;
61 template<> struct EntryEndpoint<EntryKind::Chat> { std::optional<QString> Variant_; };
62 template<> struct EntryEndpoint<EntryKind::MUC> { QString Nick_; std::optional<QByteArray> PersistentId_; };
63 template<> struct EntryEndpoint<EntryKind::PrivateChat> {};
64
65 template<EntryKind K>
66 using Endpoint = std::variant<SelfEndpoint, EntryEndpoint<K>>;
67
68 template<EntryKind K>
75
76 template<EntryKind K>
78 {
80
81 QDateTime TS_;
82 QString Body_;
83 std::optional<QString> RichBody_;
84 };
85
86 template<EntryKind K>
87 using EntryWithMessages = std::pair<Entry<K>, QList<NewMessage<K>>>;
88
90}
91
92namespace LC::Azoth
93{
94 class IAccount;
95
103 {
104 protected:
105 virtual ~IHistoryPlugin () = default;
106 public:
115 virtual bool IsHistoryEnabledFor (ICLEntry& entry) const = 0;
116
131 virtual Util::ContextTask<void> RequestLastMessages (ICLEntry& entry, int count) = 0;
132
133 virtual Util::ContextTask<std::optional<QDateTime>> RequestMaxTimestamp (IAccount& acc) = 0;
134
138 protected:
153 virtual void gotLastMessages (QObject *entry, const QList<QObject*>& messages) = 0;
154 };
155}
156
157Q_DECLARE_INTERFACE (LC::Azoth::IHistoryPlugin,
158 "org.Deviant.LeechCraft.Azoth.IHistoryPlugin/1.0")
Interface representing a single account.
Definition iaccount.h:47
Represents a single entry in contact list.
Definition iclentry.h:49
Interface for plugins storing chat history.
virtual Util::ContextTask< std::optional< QDateTime > > RequestMaxTimestamp(IAccount &acc)=0
virtual Util::ContextTask< void > RequestLastMessages(ICLEntry &entry, int count)=0
Requests last messages for the given entry.
virtual bool IsHistoryEnabledFor(ICLEntry &entry) const =0
Whether history is enabled for the given entry.
virtual ~IHistoryPlugin()=default
virtual void AddMessages(const History::SomeEntryWithMessages &)=0
Adds a set of messages to the history.
virtual void gotLastMessages(QObject *entry, const QList< QObject * > &messages)=0
Notifies about last messages for the given entry.
KindedGADT< EntryWithMessages > SomeEntryWithMessages
KindedGADT< EntryDescrWithEndpoint > SomeEntryDescrWithEndpoint
std::variant< Kinded< EntryKind::Chat >, Kinded< EntryKind::MUC >, Kinded< EntryKind::PrivateChat > > KindedGADT
KindedGADT< EntryDescr > SomeEntryDescr
EntryKind GetEntryKind(const KindedGADT< EntryKinded > &gadt)
std::pair< Entry< K >, QList< NewMessage< K > > > EntryWithMessages
std::variant< SelfEndpoint, EntryEndpoint< K > > Endpoint
EntryId< IdKind::Conventional > EntryConventionalId
Definition azothcommon.h:45
QString Nick_
QString MucName_
std::optional< QByteArray > PersistentId_
QString Nick_
QString MucName_
Endpoint< K > Endpoint_
EntryDescr< K > Description_
std::optional< QString > Variant_
QString Nick_
std::optional< QByteArray > PersistentId_
EntryConventionalId ConventionalId_
EntryDescr< K > Description_
QByteArray AccountId_
QString AccountName_
std::optional< QString > RichBody_
std::optional< QString > Variant_