1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| namespace PhoneSpector
{
/* ScriptInterface allows various script handlers to be developped as plugins.
As an example, look at the rubyhandler project. It handles both .rb and .rbw
scripts, and when started, will run a ruby process while extracting all infos.
The scriptEnded() signal is emitted once all data have been retrieved, or an
error has occured.
*/
class ScriptInterface : public QObject
{
Q_OBJECT
public:
ScriptInterface(QObject *parent)
:QObject(parent)
{
}
virtual ~ScriptInterface() {}
// Calling this function will launch the given scriptFile
virtual void startHandlingScript(const QString& scriptFile, const QString& proxy = QString::null,
bool needAuth = false, const QString &username = QString(), const QString &password = QString()) = 0;
virtual void stopExporter(unsigned int timeout) = 0;
/* This return all stored results. Obviously, the better moment to call it is when
you've received the scriptEnded() signal :)
The only reason why it may be empty is when an error has occured. You should
call getError() in turn then.
*/
virtual const QString& getResults() = 0;
/* This return all stored error. Obviously, the better moment to call it is when
you've received the scriptEnded() signal :)
*/
virtual const QString& getError() = 0;
signals:
// Signal must be emitted as soon
void scriptEnded(bool success);
};
/* ScriptBuilderInterface has the role of an abstract factory.
Each factory is capable of handling a given amount of file extensions, and is able
to create new ScriptInterface descendant instances.
Basically, such a factory is used to be able to create as much ScriptInterface as needed.
*/
class ScriptBuilderInterface
{
public:
// Calling this method will return a new ScriptInterface-derived instance
virtual ScriptInterface* getNewScriptInterface(QObject *parent) = 0;
// This return all extensions handled by the script plugin
virtual const QStringList& getManagedExtensions() const = 0;
};
}
Q_DECLARE_INTERFACE(PhoneSpector::ScriptBuilderInterface, "PhoneSpector.ScriptBuilderInterface/1.8") |
Partager