LeechCraft Azoth
0.6.70-14771-g9d21b0f8ad
Modular multiprotocol IM plugin for LeechCraft
iprovidecommands.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 <variant>
12
#include <functional>
13
#include <stdexcept>
14
#include <QStringList>
15
#include <QtPlugin>
16
17
namespace
LC
18
{
19
namespace
Azoth
20
{
21
class
ICLEntry;
22
23
struct
StringCommandResult
24
{
25
bool
StopProcessing_
;
26
QString
Message_
;
27
};
28
struct
TextMorphResult
29
{
30
QString
NewText_
;
31
};
32
typedef
std::variant<bool, StringCommandResult, TextMorphResult>
CommandResult_t
;
33
34
typedef
std::function<
CommandResult_t
(
ICLEntry
*, QString&)>
Command_f
;
35
36
class
CommandException
:
public
std::runtime_error
37
{
38
const
QString Error_;
39
const
bool
TryOtherCommands_;
40
public
:
41
CommandException
(
const
QString& error,
bool
canTryOthers =
false
)
42
: std::runtime_error { error.toUtf8 ().constData () }
43
, Error_ { error }
44
, TryOtherCommands_ { canTryOthers }
45
{
46
}
47
48
const
QString&
GetError
()
const
49
{
50
return
Error_;
51
}
52
53
bool
CanTryOtherCommands
()
const
54
{
55
return
TryOtherCommands_;
56
}
57
};
58
59
struct
StaticCommand
60
{
61
QStringList
Names_
;
62
Command_f
Command_
;
63
64
QString
Description_
;
65
QString
Help_
;
66
67
StaticCommand
() =
default
;
68
StaticCommand
(
const
StaticCommand
&) =
default
;
69
70
StaticCommand
(
const
QStringList& names,
const
Command_f
& command)
71
:
Names_
{ names }
72
,
Command_
{ command }
73
{
74
}
75
76
StaticCommand
(
const
QStringList& names,
const
Command_f
& command,
77
const
QString& descr,
const
QString& help)
78
:
Names_
{ names }
79
,
Command_
{ command }
80
,
Description_
{ descr }
81
,
Help_
{ help }
82
{
83
}
84
};
85
86
typedef
QList<StaticCommand>
StaticCommands_t
;
87
88
class
IProvideCommands
89
{
90
public
:
91
virtual
~IProvideCommands
() {}
92
93
virtual
StaticCommands_t
GetStaticCommands
(
ICLEntry
*) = 0;
94
};
95
}
96
}
97
98
Q_DECLARE_INTERFACE (
LC::Azoth::IProvideCommands
,
"org.LeechCraft.Azoth.IProvideCommands/1.0"
)
LC::Azoth::CommandException
Definition:
iprovidecommands.h:37
LC::Azoth::CommandException::GetError
const QString & GetError() const
Definition:
iprovidecommands.h:48
LC::Azoth::CommandException::CanTryOtherCommands
bool CanTryOtherCommands() const
Definition:
iprovidecommands.h:53
LC::Azoth::CommandException::CommandException
CommandException(const QString &error, bool canTryOthers=false)
Definition:
iprovidecommands.h:41
LC::Azoth::ICLEntry
Represents a single entry in contact list.
Definition:
iclentry.h:121
LC::Azoth::IProvideCommands
Definition:
iprovidecommands.h:89
LC::Azoth::IProvideCommands::GetStaticCommands
virtual StaticCommands_t GetStaticCommands(ICLEntry *)=0
LC::Azoth::IProvideCommands::~IProvideCommands
virtual ~IProvideCommands()
Definition:
iprovidecommands.h:91
QList
Definition:
iaccountactionsprovider.h:16
LC::Azoth::CommandResult_t
std::variant< bool, StringCommandResult, TextMorphResult > CommandResult_t
Definition:
iprovidecommands.h:32
LC::Azoth::Command_f
std::function< CommandResult_t(ICLEntry *, QString &)> Command_f
Definition:
iprovidecommands.h:34
LC::Azoth::StaticCommands_t
QList< StaticCommand > StaticCommands_t
Definition:
iprovidecommands.h:86
LC
Definition:
activityinfo.h:14
LC::Azoth::StaticCommand
Definition:
iprovidecommands.h:60
LC::Azoth::StaticCommand::StaticCommand
StaticCommand(const QStringList &names, const Command_f &command)
Definition:
iprovidecommands.h:70
LC::Azoth::StaticCommand::Names_
QStringList Names_
Definition:
iprovidecommands.h:61
LC::Azoth::StaticCommand::Command_
Command_f Command_
Definition:
iprovidecommands.h:62
LC::Azoth::StaticCommand::StaticCommand
StaticCommand()=default
LC::Azoth::StaticCommand::StaticCommand
StaticCommand(const QStringList &names, const Command_f &command, const QString &descr, const QString &help)
Definition:
iprovidecommands.h:76
LC::Azoth::StaticCommand::Help_
QString Help_
Definition:
iprovidecommands.h:65
LC::Azoth::StaticCommand::Description_
QString Description_
Definition:
iprovidecommands.h:64
LC::Azoth::StaticCommand::StaticCommand
StaticCommand(const StaticCommand &)=default
LC::Azoth::StringCommandResult
Definition:
iprovidecommands.h:24
LC::Azoth::StringCommandResult::StopProcessing_
bool StopProcessing_
Definition:
iprovidecommands.h:25
LC::Azoth::StringCommandResult::Message_
QString Message_
Definition:
iprovidecommands.h:26
LC::Azoth::TextMorphResult
Definition:
iprovidecommands.h:29
LC::Azoth::TextMorphResult::NewText_
QString NewText_
Definition:
iprovidecommands.h:30
src
plugins
azoth
interfaces
azoth
iprovidecommands.h
Generated by
1.9.1