LeechCraft Azoth
0.6.70-15082-g543737046d
Modular multiprotocol IM plugin for LeechCraft
azothutil.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 <QDateTime>
13
#include <QtDebug>
14
#include <
interfaces/azoth/imessage.h
>
15
16
namespace
LC
17
{
18
namespace
Azoth
19
{
20
namespace
AzothUtil
21
{
22
namespace
detail
23
{
24
inline
IMessage*
GetIMessage
(IMessage *msg)
25
{
26
return
msg;
27
}
28
29
template
<
typename
T>
30
IMessage*
GetIMessage
(T *msgObj)
31
{
32
return
qobject_cast<IMessage*> (msgObj);
33
}
34
}
35
58
template
<
typename
T>
59
void
StandardPurgeMessages
(
QList<T*>
& messages,
const
QDateTime& before)
60
{
61
if
(!before.isValid ())
62
{
63
qDeleteAll (messages);
64
messages.clear ();
65
return
;
66
}
67
68
while
(!messages.isEmpty ())
69
{
70
const
auto
msg =
detail::GetIMessage
(messages.at (0));
71
if
(!msg)
72
{
73
qWarning () << Q_FUNC_INFO
74
<<
"unable to cast"
75
<< messages.at (0)
76
<<
"to IMessage; just blindly removing it and hoping for the best"
;
77
messages.removeAt (0);
78
continue
;
79
}
80
if
(msg->GetDateTime () < before)
81
delete
messages.takeAt (0);
82
else
83
break
;
84
}
85
}
86
}
87
}
88
}
QList
Definition:
iaccountactionsprovider.h:16
LC::Azoth::AzothUtil::detail::GetIMessage
IMessage * GetIMessage(IMessage *msg)
Definition:
azothutil.h:48
LC::Azoth::AzothUtil::StandardPurgeMessages
void StandardPurgeMessages(QList< T * > &messages, const QDateTime &before)
Standard function to purge messages before the given date.
Definition:
azothutil.h:77
LC
Definition:
activityinfo.h:13
imessage.h
src
plugins
azoth
interfaces
azoth
azothutil.h
Generated by
1.8.17