File indexing completed on 2024-04-28 15:29:24
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2010 Maksim Orlovich <maksim@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef kparts_scriptableextension_p_h 0009 #define kparts_scriptableextension_p_h 0010 0011 #include "liveconnectextension.h" 0012 #include "scriptableextension.h" 0013 0014 namespace KParts 0015 { 0016 // LiveConnectExtension -> ScriptableExtension adapter. 0017 class ScriptableLiveConnectExtension : public ScriptableExtension 0018 { 0019 Q_OBJECT 0020 public: 0021 ScriptableLiveConnectExtension(QObject *parent, LiveConnectExtension *old); 0022 0023 QVariant rootObject() override; 0024 // enclosingObject: not applicable, plugins wouldn't have children 0025 0026 // callAsFunction: we only have function rereferences. 0027 QVariant callFunctionReference(ScriptableExtension *callerPrincipal, quint64 objId, const QString &f, const ArgList &args) override; 0028 0029 // callAsConstructor: unsupported by LC 0030 0031 bool hasProperty(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName) override; 0032 0033 QVariant get(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName) override; 0034 0035 bool put(ScriptableExtension *callerPrincipal, quint64 objId, const QString &propName, const QVariant &value) override; 0036 0037 // removeProperty: unsupported by LC 0038 // enumerateProperties: unsupported by LC 0039 // setException: unsupported by LC 0040 // evaluateScript: unsupported by LC, though we have to 0041 // route LC evaluation requests to our parent 0042 // as appropriate 0043 0044 void acquire(quint64 objid) override; 0045 void release(quint64 objid) override; 0046 0047 private: 0048 // LC uses 0-1 refcounting, we use arbitrary, so we need to call 0049 // unregister when done. 0050 QHash<quint64, int> refCounts; 0051 LiveConnectExtension *wrapee; 0052 0053 // also registers when needed 0054 QVariant fromLC(const QString &name, LiveConnectExtension::Type type, unsigned long objId, const QString &value); 0055 0056 QString toLC(const QVariant &in, bool *ok); 0057 public Q_SLOTS: 0058 void liveConnectEvent(const unsigned long, const QString &, const KParts::LiveConnectExtension::ArgList &); 0059 }; 0060 0061 } // namespace KParts 0062 0063 #endif