File indexing completed on 2024-05-19 04:56:04

0001 /**
0002  * \file iusercommandprocessor.h
0003  * Interface for user command processor.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 21 Feb 2015
0008  *
0009  * Copyright (C) 2015-2018  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #pragma once
0028 
0029 #include <QtPlugin>
0030 #include <QStringList>
0031 #include "kid3api.h"
0032 
0033 class Kid3Application;
0034 
0035 /**
0036  * Interface for user command processor.
0037  */
0038 class KID3_CORE_EXPORT IUserCommandProcessor {
0039 public:
0040   /**
0041    * Destructor.
0042    */
0043   virtual ~IUserCommandProcessor();
0044 
0045   /**
0046    * Get keys of available user commands.
0047    * @return list of keys.
0048    */
0049   virtual QStringList userCommandKeys() const = 0;
0050 
0051   /**
0052    * Initialize processor.
0053    * This method can be used to initialize the processor before it is used.
0054    * @param app application context
0055    */
0056   virtual void initialize(Kid3Application* app);
0057 
0058   /**
0059    * Cleanup processor.
0060    * This method can be used to clean up resources for which the plugin
0061    * destruction time is too late.
0062    */
0063   virtual void cleanup();
0064 
0065   /**
0066    * Start user command.
0067    * @param key user command name
0068    * @param arguments arguments to pass to command
0069    * @param showOutput true to enable output in output viewer
0070    * @return true if command is started.
0071    *
0072    * @remarks If @a showOutput is true, command output is emitted using a signal
0073    * "void commandOutput(QString)". Objects implementing this interface have to
0074    * be QObjects providing such a signal and a signal "void finished(int)".
0075    * @see qobject()
0076    */
0077   virtual bool startUserCommand(
0078       const QString& key, const QStringList& arguments, bool showOutput) = 0;
0079 
0080   /**
0081    * Return object which emits commandOutput() and finished() signals.
0082    *
0083    * @return object which emits signals.
0084    */
0085   virtual QObject* qobject() = 0;
0086 };
0087 
0088 Q_DECLARE_INTERFACE(IUserCommandProcessor,
0089                     "org.kde.kid3.IUserCommandProcessor")