LeechCraft Azoth  0.6.70-15082-g543737046d
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_;
63 
64  QString Description_ = {};
65  QString Help_ = {};
66  };
67 
69 
70  class IProvideCommands
71  {
72  public:
73  virtual ~IProvideCommands () {}
74 
76  };
77 }
78 }
79 
80 Q_DECLARE_INTERFACE (LC::Azoth::IProvideCommands, "org.LeechCraft.Azoth.IProvideCommands/1.0")
LC::Azoth::StaticCommands_t
QList< StaticCommand > StaticCommands_t
Definition: iprovidecommands.h:80
LC::Azoth::IProvideCommands::GetStaticCommands
virtual StaticCommands_t GetStaticCommands(ICLEntry *)=0
LC::Azoth::StringCommandResult::Message_
QString Message_
Definition: iprovidecommands.h:38
QList
Definition: iaccountactionsprovider.h:16
LC::Azoth::CommandException::CommandException
CommandException(const QString &error, bool canTryOthers=false)
Definition: iprovidecommands.h:53
LC::Azoth::StaticCommand::Names_
QStringList Names_
Definition: iprovidecommands.h:73
LC::Azoth::StaticCommand::Description_
QString Description_
Definition: iprovidecommands.h:76
LC::Azoth::ICLEntry
Represents a single entry in contact list.
Definition: iclentry.h:120
LC::Azoth::CommandException
Definition: iprovidecommands.h:48
LC::Azoth::Command_f
std::function< CommandResult_t(ICLEntry *, QString &)> Command_f
Definition: iprovidecommands.h:46
LC::Azoth::IProvideCommands::~IProvideCommands
virtual ~IProvideCommands()
Definition: iprovidecommands.h:85
LC::Azoth::CommandException::CanTryOtherCommands
bool CanTryOtherCommands() const
Definition: iprovidecommands.h:65
LC::Azoth::StaticCommand::Help_
QString Help_
Definition: iprovidecommands.h:77
LC::Azoth::StringCommandResult::StopProcessing_
bool StopProcessing_
Definition: iprovidecommands.h:37
LC::Azoth::CommandResult_t
std::variant< bool, StringCommandResult, TextMorphResult > CommandResult_t
Definition: iprovidecommands.h:44
LC
Definition: activityinfo.h:13
LC::Azoth::StaticCommand::Command_
Command_f Command_
Definition: iprovidecommands.h:74
LC::Azoth::CommandException::GetError
const QString & GetError() const
Definition: iprovidecommands.h:60
LC::Azoth::IProvideCommands
Definition: iprovidecommands.h:82
LC::Azoth::TextMorphResult::NewText_
QString NewText_
Definition: iprovidecommands.h:42