1/* This file is part of the KDE project
2 Copyright (C) 2010 Maksim Orlovich <maksim@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef kparts_scriptableextension_p_h
21#define kparts_scriptableextension_p_h
22
23#include "browserextension.h"
24
25namespace KParts {
26
27// LiveConnectExtension -> ScriptableExtension adapter.
28class ScriptableLiveConnectExtension: public ScriptableExtension
29{
30 Q_OBJECT
31public:
32 ScriptableLiveConnectExtension(QObject* parent, LiveConnectExtension* old);
33
34 QVariant rootObject();
35 // enclosingObject: not applicable, plugins wouldn't have children
36
37 // callAsFunction: we only have function rereferences.
38 QVariant callFunctionReference(ScriptableExtension* callerPrincipal, quint64 objId,
39 const QString& f, const ArgList& args);
40
41 // callAsConstructor: unsupported by LC
42
43 bool hasProperty(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName);
44
45 QVariant get(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName);
46
47 bool put(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName, const QVariant& value);
48
49 // removeProperty: unsupported by LC
50 // enumerateProperties: unsupported by LC
51 // setException: unsupported by LC
52 // evaluateScript: unsupported by LC, though we have to
53 // route LC evaluation requests to our parent
54 // as appropriate
55
56 void acquire(quint64 objid);
57 void release(quint64 objid);
58private:
59 // LC uses 0-1 refcounting, we use arbitrary, so we need to call
60 // unregister when done.
61 QHash<quint64, int> refCounts;
62 LiveConnectExtension* wrapee;
63
64 // also registers when needed
65 QVariant fromLC(const QString& name, LiveConnectExtension::Type type,
66 unsigned long objId, const QString& value);
67
68 QString toLC(const QVariant& in, bool* ok);
69public Q_SLOTS:
70 void liveConnectEvent(const unsigned long, const QString&, const KParts::LiveConnectExtension::ArgList&);
71};
72
73
74} // namespace KParts
75
76#endif
77// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
78