LeechCraft Azoth  0.6.70-10870-g558588d6ec
Modular multiprotocol IM plugin for LeechCraft
ihaveserverhistory.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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <QList>
33 #include <QtPlugin>
34 #include <util/sll/eitherfwd.h>
35 #include "imessage.h"
36 #include "ihistoryplugin.h"
37 
38 class QModelIndex;
39 class QAbstractItemModel;
40 
41 template<typename>
42 class QFuture;
43 
44 namespace LeechCraft
45 {
46 namespace Azoth
47 {
49  {
51  QByteArray ID_;
52  QString Nick_;
53  QString Body_;
54  QDateTime TS_;
55 
56  QString RichBody_;
57  };
58 
60 
62  {
63  LastMessageDate = Qt::UserRole + 1,
66  };
67 
69  {
73  };
74 
76  {
77  int Column_;
78  int Role_;
79  Qt::SortOrder Order_;
80  };
81 
83  {
84  public:
85  virtual ~IHaveServerHistory () {}
86 
87  virtual bool HasFeature (ServerHistoryFeature) const = 0;
88 
89  virtual void OpenServerHistoryConfiguration () = 0;
90 
91  virtual QAbstractItemModel* GetServerContactsModel () const = 0;
92 
126  virtual void FetchServerHistory (const QModelIndex& contact,
127  const QByteArray& startId, int count) = 0;
128 
129  virtual DefaultSortParams GetSortParams () const = 0;
130 
132  {
133  QString VisibleName_;
135  };
136  using MessagesSyncMap_t = QHash<QString, UserHistorySyncInfo>;
137  using DatedFetchResult_t = Util::Either<QString, MessagesSyncMap_t>;
138 
139  virtual QFuture<DatedFetchResult_t> FetchServerHistory (const QDateTime& since) = 0;
140  protected:
159  virtual void serverHistoryFetched (const QModelIndex& contact,
160  const QByteArray& startId, const SrvHistMessages_t& messages) = 0;
161  };
162 }
163 }
164 
165 Q_DECLARE_INTERFACE (LeechCraft::Azoth::IHaveServerHistory,
166  "org.LeechCraft.Azoth.IHaveServerHistory/1.0")
virtual void FetchServerHistory(const QModelIndex &contact, const QByteArray &startId, int count)=0
Fetches the given history with the given contact.
virtual QAbstractItemModel * GetServerContactsModel() const =0
virtual bool HasFeature(ServerHistoryFeature) const =0
virtual DefaultSortParams GetSortParams() const =0
Direction
Represents the direction of the message.
Definition: imessage.h:70
virtual void OpenServerHistoryConfiguration()=0
QHash< QString, UserHistorySyncInfo > MessagesSyncMap_t
Util::Either< QString, MessagesSyncMap_t > DatedFetchResult_t
virtual void serverHistoryFetched(const QModelIndex &contact, const QByteArray &startId, const SrvHistMessages_t &messages)=0
Emitted when messages are fetched.