KParts
scriptableextension_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2010 Maksim Orlovich <maksim@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef kparts_scriptableextension_p_h 00021 #define kparts_scriptableextension_p_h 00022 00023 #include "browserextension.h" 00024 00025 namespace KParts { 00026 00027 // LiveConnectExtension -> ScriptableExtension adapter. 00028 class ScriptableLiveConnectExtension: public ScriptableExtension 00029 { 00030 Q_OBJECT 00031 public: 00032 ScriptableLiveConnectExtension(QObject* parent, LiveConnectExtension* old); 00033 00034 QVariant rootObject(); 00035 // enclosingObject: not applicable, plugins wouldn't have children 00036 00037 // callAsFunction: we only have function rereferences. 00038 QVariant callFunctionReference(ScriptableExtension* callerPrincipal, quint64 objId, 00039 const QString& f, const ArgList& args); 00040 00041 // callAsConstructor: unsupported by LC 00042 00043 bool hasProperty(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName); 00044 00045 QVariant get(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName); 00046 00047 bool put(ScriptableExtension* callerPrincipal, quint64 objId, const QString& propName, const QVariant& value); 00048 00049 // removeProperty: unsupported by LC 00050 // enumerateProperties: unsupported by LC 00051 // setException: unsupported by LC 00052 // evaluateScript: unsupported by LC, though we have to 00053 // route LC evaluation requests to our parent 00054 // as appropriate 00055 00056 void acquire(quint64 objid); 00057 void release(quint64 objid); 00058 private: 00059 // LC uses 0-1 refcounting, we use arbitrary, so we need to call 00060 // unregister when done. 00061 QHash<quint64, int> refCounts; 00062 LiveConnectExtension* wrapee; 00063 00064 // also registers when needed 00065 QVariant fromLC(const QString& name, LiveConnectExtension::Type type, 00066 unsigned long objId, const QString& value); 00067 00068 QString toLC(const QVariant& in, bool* ok); 00069 public Q_SLOTS: 00070 void liveConnectEvent(const unsigned long, const QString&, const KParts::LiveConnectExtension::ArgList&); 00071 }; 00072 00073 00074 } // namespace KParts 00075 00076 #endif 00077 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
KDE 4.6 API Reference