LeechCraft Azoth 0.6.70-18450-gabe19ee3b0
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 "imessage.h"
14
15class QDateTime;
16class QObject;
17
19{
20 enum class EntryKind : std::uint8_t
21 {
25 };
26
27 template<template<EntryKind K> typename Kinded>
28 using KindedGADT = std::variant<
29 Kinded<EntryKind::Chat>,
30 Kinded<EntryKind::MUC>,
31 Kinded<EntryKind::PrivateChat>
32 >;
33
34 template<EntryKind> struct EntryDescr;
35 template<> struct EntryDescr<EntryKind::Chat> { QString Nick_; };
36 template<> struct EntryDescr<EntryKind::MUC> { QString MucName_; };
37 template<> struct EntryDescr<EntryKind::PrivateChat> { QString MucName_; QString Nick_; std::optional<QByteArray> PersistentId_; };
38
40
41 template<template<EntryKind K> typename EntryKinded>
43 {
44 return static_cast<EntryKind> (gadt.index ());
45 }
46
47 template<EntryKind K>
48 struct Entry
49 {
50 QByteArray AccountId_;
51 QString AccountName_;
53
55 };
56
57 struct SelfEndpoint { QString Name_; std::optional<QString> Variant_; };
58
59 template<EntryKind> struct EntryEndpoint;
60 template<> struct EntryEndpoint<EntryKind::Chat> { std::optional<QString> Variant_; };
61 template<> struct EntryEndpoint<EntryKind::MUC> { QString Nick_; std::optional<QByteArray> PersistentId_; };
62 template<> struct EntryEndpoint<EntryKind::PrivateChat> {};
63
64 template<EntryKind K>
65 using Endpoint = std::variant<SelfEndpoint, EntryEndpoint<K>>;
66
67 template<EntryKind K>
74
75 template<EntryKind K>
77 {
79
80 QDateTime TS_;
81 QString Body_;
82 std::optional<QString> RichBody_;
83 };
84
85 template<EntryKind K>
86 using EntryWithMessages = std::pair<Entry<K>, QList<NewMessage<K>>>;
87
89}
90
91namespace LC::Azoth
92{
93 class IAccount;
94
102 {
103 protected:
104 virtual ~IHistoryPlugin () = default;
105 public:
114 virtual bool IsHistoryEnabledFor (ICLEntry& entry) const = 0;
115
130 virtual Util::ContextTask<void> RequestLastMessages (ICLEntry& entry, int count) = 0;
131
132 virtual Util::ContextTask<std::optional<QDateTime>> RequestMaxTimestamp (IAccount& acc) = 0;
133
137 protected:
152 virtual void gotLastMessages (QObject *entry, const QList<QObject*>& messages) = 0;
153 };
154}
155
156Q_DECLARE_INTERFACE (LC::Azoth::IHistoryPlugin,
157 "org.Deviant.LeechCraft.Azoth.IHistoryPlugin/1.0")
Interface representing a single account.
Definition iaccount.h:46
Represents a single entry in contact list.
Definition iclentry.h:57
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
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_
QString EntryHumanReadableId_
EntryDescr< K > Description_
QByteArray AccountId_
QString AccountName_
std::optional< QString > RichBody_
std::optional< QString > Variant_