Rabbit Remote Control 0.1.0-bate14
Loading...
Searching...
No Matches
Plugin interfaces

Plugin interfaces. More...

Collaboration diagram for Plugin interfaces:

Topics

 Desktop class
 Server class
 Terminal class

Classes

class  CBackend
 Backend interface. More...
class  CManager
 Manage plugins. More...
class  COperate
 Operate interface. More...
class  CParameter
 Parameter interface. More...
class  CPlugin
 Plugin interface. More...

Detailed Description

Plugin interfaces.

  • Thread module
  • Class relationship
  • Sequence diagram
  • Generate plugin from template using a script: Script/create_plugin.sh
    ./create_plugin.sh -h
    create_plugin.sh - Generate plugin from template
    Usage: ./Script/create_plugin.sh [OPTION] PluginName
    Options:
    -h, --help Show this help message
    -v, --verbose[=LEVEL] Set verbose mode. [LEVEL: ON, OFF]
    Directory options:
    --install=DIR Set installation directory
    Other options:
    --name=NAME Plugin name
    --template=NAME Template name. [NAME: Base(Default), Desktop, Server, QtEvent]
    Examples:
    ./Script/create_plugin.sh --name=Server
  • Write a plugin:
    • The format of the generated plug-in target name is: PluginClient${PROJECT_NAME}
      # Author: Kang Lin <kl222@126.com>
      project(FreeRDP
      DESCRIPTION "FreeRDP client plugin"
      )
      SET(FreeRDP_LIBS freerdp-client freerdp winpr Plugin)
      SET(FreeRDP_SOURCE_FILES
      ParameterFreeRDP.cpp
      PluginFreeRDP.cpp
      BackendFreeRDP.cpp
      OperateFreeRDP.cpp
      DlgSetFreeRDP.cpp
      ConvertKeyCode.cpp
      CursorFreeRDP.cpp
      ClipboardFreeRDP.cpp
      ClipboardMimeData.cpp
      DlgGetUserPasswordFreeRDP.cpp
      DlgDesktopSize.cpp
      )
      SET(FreeRDP_HEADER_FILES
      ParameterFreeRDP.h
      PluginFreeRDP.h
      BackendFreeRDP.h
      OperateFreeRDP.h
      DlgSetFreeRDP.h
      ConvertKeyCode.h
      CursorFreeRDP.h
      ClipboardFreeRDP.h
      ClipboardMimeData.h
      DlgGetUserPasswordFreeRDP.h
      DlgDesktopSize.h
      )
      SET(FreeRDP_UI_FILES
      DlgSetFreeRDP.ui
      DlgGetUserPasswordFreeRDP.ui
      DlgDesktopSize.ui
      )
      find_package(FreeRDP)
      if(FreeRDP_VERSION_MAJOR VERSION_GREATER_EQUAL 3)
      list(APPEND FreeRDP_HEADER_FILES ConnectLayer.h ConnectLayerQTcpSocket.h)
      list(APPEND FreeRDP_SOURCE_FILES ConnectLayer.cpp ConnectLayerQTcpSocket.cpp)
      find_package(libssh)
      if(libssh_FOUND)
      list(APPEND FreeRDP_HEADER_FILES ConnectLayerSSHTunnel.h)
      list(APPEND FreeRDP_SOURCE_FILES ConnectLayerSSHTunnel.cpp)
      endif()
      endif()
      if(WIN32)
      list(APPEND FreeRDP_LIBS Credui.dll)
      endif()
      if(MINGW)
      set(FreeRDP_OPTIONS -fpermissive)
      endif()
      set(FreeRDP_QT_COMPONENTS Widgets Multimedia PrintSupport SerialPort)
      find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS ${FreeRDP_QT_COMPONENTS})
      if(Qt${QT_VERSION_MAJOR}_FOUND)
      FOREACH(_COMPONENT ${FreeRDP_QT_COMPONENTS})
      list(APPEND FreeRDP_LIBS Qt${QT_VERSION_MAJOR}::${_COMPONENT})
      ENDFOREACH()
      endif()
      ADD_PLUGIN_TARGET(NAME PluginClient${PROJECT_NAME}
      ISPLUGIN
      SOURCE_FILES ${FreeRDP_SOURCE_FILES} ${FreeRDP_HEADER_FILES} ${FreeRDP_UI_FILES}
      PRIVATE_LIBS ${FreeRDP_LIBS}
      PRIVATE_INCLUDE_DIRS ${FreeRDP-Client_INCLUDE_DIR} ${FreeRDP_INCLUDE_DIR} ${WinPR_INCLUDE_DIR}
      PRIVATE_DEFINITIONS ${FreeRDP_DEFINITIONS}
      PluginFreeDP_VERSION="${RabbitRemoteControl_VERSION}"
      PRIVATE_OPTIONS ${FreeRDP_OPTIONS}
      INSTALL_DIR ${PLUGIN_PATH}
      OUTPUT_DIR ${CMAKE_BINARY_DIR}/${PLUGIN_PATH}
      INSTALL_RPATH ${INSTALL_RPATH}
      VERSION ${RabbitRemoteControl_VERSION}
      )
    • Implement CPlugin.
      • No background thread or Blocked background thread (A background thread handles a connection. The connection is blocked.). E.g. FreeRDP
        • Derive from CPlugin. For example: CPluginFreeRDP
          • Implement the Qt interface in the class declaration:
            Q_INTERFACES(CPlugin)
            #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
            Q_PLUGIN_METADATA(IID CPlugin_iid)
            #endif
          • Initialize the operation in the constructor. For example: initializing resources, loading translation resources, etc.
          • Release resources in the destructor.
          • Implement properties and functions
            • Plugin name: This name must be the same as the project name (${PROJECT_NAME}). The translation file (${PROJECT_NAME}_*.ts)) name is associated with it. E.g. CPluginFreeRDP::Name()
              // Author: Kang Lin <kl222@126.com>
              #include "PluginFreeRDP.h"
              #include "winpr/wlog.h"
              #include "freerdp/version.h"
              #include <QLoggingCategory>
              #ifdef HAVE_LIBSSH
              #include "ChannelSSHTunnel.h"
              #endif
              #include "OperateFreeRDP.h"
              static Q_LOGGING_CATEGORY(log, "FreeRDP.Plugin")
              static Q_LOGGING_CATEGORY(LoggerFreeRDP, "FreeRDP.Log")
              static Q_LOGGING_CATEGORY(LoggerFreeRDPTrace, "FreeRDP.Log.Trace")
              static Q_LOGGING_CATEGORY(LoggerFreeRDPFatal, "FreeRDP.Log.Fatal")
              CPluginFreeRDP::CPluginFreeRDP(QObject *parent)
              : CPlugin(parent)
              {
              qDebug(log) << Q_FUNC_INFO;
              qInfo(log) << "FreeRDP version:" << freerdp_get_version_string()
              << "revision:" << freerdp_get_build_revision();
              static wLogCallbacks* pCbLog = new wLogCallbacks;
              BOOL bRet = WLog_SetLogAppenderType(WLog_GetRoot(), WLOG_APPENDER_CALLBACK);
              if(bRet && pCbLog)
              {
              memset(pCbLog, 0, sizeof(wLogCallbacks));
              pCbLog->message = [](const wLogMessage* msg)->BOOL{
              switch(msg->Level)
              {
              case WLOG_TRACE:
              qDebug(LoggerFreeRDPTrace) /*<< msg->PrefixString */ << msg->TextString;
              break;
              case WLOG_DEBUG:
              qDebug(LoggerFreeRDP) /*<< msg->PrefixString */ << msg->TextString;
              break;
              case WLOG_INFO:
              qInfo(LoggerFreeRDP) /*<< msg->PrefixString*/ << msg->TextString;
              break;
              case WLOG_WARN:
              qWarning(LoggerFreeRDP) /*<< msg->PrefixString */<< msg->TextString;
              case WLOG_ERROR:
              qCritical(LoggerFreeRDP) /*<< msg->PrefixString*/ << msg->TextString;
              break;
              case WLOG_FATAL:
              case WLOG_OFF:
              qCritical(LoggerFreeRDPFatal) /*<< msg->PrefixString*/ << msg->TextString;
              break;
              default:
              break;
              }
              return TRUE;
              };
              WLog_ConfigureAppender(WLog_GetLogAppender(WLog_GetRoot()), "callbacks", pCbLog);
              }
              WLog_SetLogLevel(WLog_GetRoot(), WLOG_TRACE);
              }
              {
              qDebug(log) << Q_FUNC_INFO;
              }
              const CPlugin::TYPE CPluginFreeRDP::Type() const
              {
              return TYPE::RemoteDesktop;
              }
              const QString CPluginFreeRDP::Name() const
              {
              return "FreeRDP";
              }
              const QString CPluginFreeRDP::DisplayName() const
              {
              return tr("Free remote desktop protocol");
              }
              const QString CPluginFreeRDP::Description() const
              {
              return tr("RDP(Remote desktop Protocol): Access remote desktops such as windows.") + "\n"
              + tr("It uses FreeRDP: https://github.com/FreeRDP/FreeRDP/");
              }
              const QString CPluginFreeRDP::Protocol() const
              {
              return "RDP";
              }
              const QIcon CPluginFreeRDP::Icon() const
              {
              return QIcon::fromTheme("windows");
              }
              const QString CPluginFreeRDP::Version() const
              {
              return PluginFreeDP_VERSION;
              }
              const QString CPluginFreeRDP::Details() const
              {
              QString szDetails;
              szDetails += "- " + tr("Dependency libraries") + "\n";
              szDetails += " - " + tr("FreeRDP") + "\n";
              szDetails += " - " + tr("version: ");
              szDetails += freerdp_get_version_string();
              szDetails += "\n";
              szDetails += " - " + tr("Build version: ");
              szDetails += freerdp_get_build_revision();
              szDetails += ":";
              szDetails += freerdp_get_build_revision();
              szDetails += "\n";
              #if FREERDP_VERSION_MAJOR < 3
              szDetails += " - " + tr("Build date: ");
              szDetails += freerdp_get_build_date();
              szDetails += "\n";
              #endif
              szDetails += " - ";
              szDetails += freerdp_get_build_config();
              szDetails += "\n";
              #ifdef HAVE_LIBSSH
              CChannelSSH channel(nullptr, nullptr);
              szDetails += channel.GetDetails();
              #endif
              return szDetails;
              }
              COperate *CPluginFreeRDP::OnCreateOperate(const QString &szId)
              {
              if(Id() == szId)
              return new COperateFreeRDP(this);
              return nullptr;
              }
              Operate interface.
              Definition Operate.h:51
              virtual const QString DisplayName() const override
              The plugin display name.
              virtual const TYPE Type() const override
              [Clean resource]
              virtual const QString Version() const override
              Version.
              virtual const QString Name() const override
              This name must be the same as the project name (${PROJECT_NAME}). The translation file (${PROJECT_NAM...
              virtual const QString Description() const override
              Plugin description.
              virtual const QString Details() const override
              Show the plugin depends on the freerdp version.
              virtual const QString Protocol() const override
              Plugin Protocol.
              virtual ~CPluginFreeRDP() override
              [Initialize resource]
              Plugin interface.
              Definition Plugin.h:15
              virtual const QString Id() const
              ID. Default: Type() + ":" + Protocol() + ":" + Name().
              Definition Plugin.cpp:71
      • No-blocking background thread: One background thread handles multiple connections.(Not used yet) The connection is non-blocking.
        • Derive from CPluginClientThread.
          • Implement the Qt interface in the class declaration:
            Q_INTERFACES(CPlugin)
            #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
            Q_PLUGIN_METADATA(IID CPlugin_iid)
            #endif
          • Initialize the operation in the constructor. For example: initializing resources, loading translation resources, etc.
            //rfb::SecurityClient::setDefaults();
          • Release resources in the destructor.
          • Implement properties and functions
    • Implement COperate.
      • Implement remote desktop
        • Blocked: Implements a remote desktop background thread to handle a remote desktop connection, which can be derived from COperateThread. Eg: COperateFreeRDP
        • No-blocking: Implements a background thread to handle multiple remote desktop connections, which can be derived from COperateDesktop.
      • Implement remote console, which can be derived from COperateTerminal
      • Implement server, which can be derived from COperateServer
      • If the above two cannot meet your needs, you can be derived from COperate
    • Implement a specific connection, derived from COperate. For example: COperateFreeRDP