summaryrefslogtreecommitdiffstats
path: root/kjsembed/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'kjsembed/bindings')
-rw-r--r--kjsembed/bindings/Makefile.am29
-rw-r--r--kjsembed/bindings/bindingobject.cpp18
-rw-r--r--kjsembed/bindings/bindingobject.h61
-rw-r--r--kjsembed/bindings/bindings.pro35
-rw-r--r--kjsembed/bindings/brush_imp.cpp121
-rw-r--r--kjsembed/bindings/brush_imp.h57
-rw-r--r--kjsembed/bindings/dcop_imp.cpp1020
-rw-r--r--kjsembed/bindings/dcop_imp.h152
-rw-r--r--kjsembed/bindings/iconset_imp.cpp167
-rw-r--r--kjsembed/bindings/iconset_imp.h59
-rw-r--r--kjsembed/bindings/image_imp.cpp259
-rw-r--r--kjsembed/bindings/image_imp.h95
-rw-r--r--kjsembed/bindings/kconfig_imp.cpp536
-rw-r--r--kjsembed/bindings/kconfig_imp.h135
-rw-r--r--kjsembed/bindings/movie_imp.cpp158
-rw-r--r--kjsembed/bindings/movie_imp.h77
-rw-r--r--kjsembed/bindings/netaccess_imp.cpp156
-rw-r--r--kjsembed/bindings/netaccess_imp.h62
-rw-r--r--kjsembed/bindings/painter_imp.cpp521
-rw-r--r--kjsembed/bindings/painter_imp.h127
-rw-r--r--kjsembed/bindings/pen_imp.cpp127
-rw-r--r--kjsembed/bindings/pen_imp.h57
-rw-r--r--kjsembed/bindings/pixmap_imp.cpp180
-rw-r--r--kjsembed/bindings/pixmap_imp.h87
-rw-r--r--kjsembed/bindings/point_imp.cpp92
-rw-r--r--kjsembed/bindings/point_imp.h56
-rw-r--r--kjsembed/bindings/rect_imp.cpp111
-rw-r--r--kjsembed/bindings/rect_imp.h56
-rw-r--r--kjsembed/bindings/size_imp.cpp133
-rw-r--r--kjsembed/bindings/size_imp.h56
-rw-r--r--kjsembed/bindings/sql_imp.cpp310
-rw-r--r--kjsembed/bindings/sql_imp.h141
32 files changed, 5251 insertions, 0 deletions
diff --git a/kjsembed/bindings/Makefile.am b/kjsembed/bindings/Makefile.am
new file mode 100644
index 00000000..95b634bd
--- /dev/null
+++ b/kjsembed/bindings/Makefile.am
@@ -0,0 +1,29 @@
+
+INCLUDES= -I$(srcdir)/.. -I$(srcdir)/../.. $(all_includes)
+KDE_CXXFLAGS = -DQT_NO_ASCII_CAST -DQT_CLEAN_NAMESPACE -Wno-unused
+
+noinst_LTLIBRARIES = libkjsembedbindings.la
+
+libkjsembedbindings_la_SOURCES = image_imp.cpp \
+ dcop_imp.cpp \
+ painter_imp.cpp \
+ pixmap_imp.cpp \
+ netaccess_imp.cpp \
+ kconfig_imp.cpp \
+ bindingobject.cpp \
+ movie_imp.cpp \
+ sql_imp.cpp \
+ pen_imp.cpp \
+ brush_imp.cpp \
+ iconset_imp.cpp \
+ point_imp.cpp \
+ rect_imp.cpp \
+ size_imp.cpp
+
+libkjsembedbindings_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+libkjsembedbindings_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) \
+ $(LIB_KFILE) $(LIBSOCKET)
+
+libkjsembedbindings_la_METASOURCES = AUTO
+
+
diff --git a/kjsembed/bindings/bindingobject.cpp b/kjsembed/bindings/bindingobject.cpp
new file mode 100644
index 00000000..4477c336
--- /dev/null
+++ b/kjsembed/bindings/bindingobject.cpp
@@ -0,0 +1,18 @@
+#include "bindingobject.h"
+#ifndef QT_ONLY
+#include "bindingobject.moc"
+#endif
+namespace KJSEmbed {
+namespace Bindings {
+
+BindingObject::BindingObject( QObject *parent, const char *name )
+ : QObject( parent, name )
+{
+}
+
+BindingObject::~BindingObject()
+{
+}
+
+}
+}
diff --git a/kjsembed/bindings/bindingobject.h b/kjsembed/bindings/bindingobject.h
new file mode 100644
index 00000000..1516ade2
--- /dev/null
+++ b/kjsembed/bindings/bindingobject.h
@@ -0,0 +1,61 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_BINDING_OBJECT_H
+#define KJSEMBED_BINDING_OBJECT_H
+
+#include <qobject.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * A baseclass for QObject bindings. This class is currently just a
+ * stub, but I hope it will contain utilities for QObject wrapper
+ * classes.
+ *
+ * @author Richard Moore, rich@kde.org
+ * @version $Id$
+ */
+class BindingObject : public QObject
+{
+ Q_OBJECT
+
+public:
+ BindingObject( QObject *parent, const char *name=0 );
+ virtual ~BindingObject();
+
+ const char *jsClassName() const { return jsClazz; }
+
+protected:
+ void setJSClassName( const char *clazz ) { jsClazz = clazz; }
+
+private:
+ QCString jsClazz;
+ class BindingObjectPrivate *d;
+};
+
+}
+}
+
+#endif // KJSEMBED_BINDING_OBJECT_H
+
+
diff --git a/kjsembed/bindings/bindings.pro b/kjsembed/bindings/bindings.pro
new file mode 100644
index 00000000..d83d3ba5
--- /dev/null
+++ b/kjsembed/bindings/bindings.pro
@@ -0,0 +1,35 @@
+include(../qjsembed.pri)
+
+INCLUDEPATH += .. . ../..
+CONFIG += staticlib
+TEMPLATE = lib
+
+
+# Input
+HEADERS += bindingobject.h \
+ brush_imp.h \
+ iconset_imp.h \
+ image_imp.h \
+ movie_imp.h \
+ painter_imp.h \
+ pen_imp.h \
+ pixmap_imp.h \
+ sql_imp.h \
+ kconfig_imp.h \
+ point_imp.h \
+ rect_imp.h \
+ size_imp.h
+
+SOURCES += bindingobject.cpp \
+ brush_imp.cpp \
+ iconset_imp.cpp \
+ image_imp.cpp \
+ movie_imp.cpp \
+ painter_imp.cpp \
+ pen_imp.cpp \
+ pixmap_imp.cpp \
+ sql_imp.cpp \
+ kconfig_imp.cpp \
+ point_imp.cpp \
+ rect_imp.cpp \
+ size_imp.cpp
diff --git a/kjsembed/bindings/brush_imp.cpp b/kjsembed/bindings/brush_imp.cpp
new file mode 100644
index 00000000..061dc1f4
--- /dev/null
+++ b/kjsembed/bindings/brush_imp.cpp
@@ -0,0 +1,121 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <qvariant.h>
+#include <qbrush.h>
+
+#include "brush_imp.h"
+
+namespace KJSEmbed {
+namespace Bindings {
+
+BrushImp::BrushImp( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+BrushImp::~BrushImp()
+{
+}
+
+void BrushImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QBrush") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodstyle, "style"},
+ { MethodsetStyle, "setStyle"},
+ { MethodColor, "color"},
+ { MethodsetColor, "setColor"},
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<BrushImp>(exec, methods, object );
+
+ JSProxy::EnumTable enums[] = {
+ // BrushType
+ { "NoBrush", 0 },
+ { "SolidBrush", 1 },
+ { "Dense1Pattern", 2 },
+ { "Dense2Pattern", 3 },
+ { "Dense3Pattern", 4 },
+ { "Dense4Pattern", 5 },
+ { "Dense5Pattern", 6 },
+ { "Dense6Pattern", 7 },
+ { "Dense7Pattern", 8 },
+ { "HorPattern", 9 },
+ { "VerPattern", 10 },
+ { "CrossPattern", 11},
+ { "BDiagPattern", 12 },
+ { "FDiagPattern", 13 },
+ { "DiagCrossPattern", 14},
+
+ { 0, 0 }
+ };
+
+ JSProxy::addEnums(exec, enums, object);
+
+}
+
+KJS::Value BrushImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QBrush") ) return KJS::Value();
+ JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
+ QBrush brush = op->toVariant().toBrush();
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case Methodstyle:
+ {
+ return KJS::Number((int) brush.style() );
+ break;
+ }
+ case MethodsetStyle:
+ {
+ int style = extractInt(exec, args, 0);
+ brush.setStyle((Qt::BrushStyle)style);
+ break;
+ }
+ case MethodColor:
+ {
+ return convertToValue(exec, brush.color());
+ break;
+ }
+ case MethodsetColor:
+ {
+ QColor color = extractQColor(exec, args, 0);
+ brush.setColor(color);
+ break;
+ }
+ default:
+ kdWarning() << "Brush has no method " << mid << endl;
+ break;
+ }
+
+ op->setValue(brush);
+ return retValue;
+}
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
diff --git a/kjsembed/bindings/brush_imp.h b/kjsembed/bindings/brush_imp.h
new file mode 100644
index 00000000..040c73b6
--- /dev/null
+++ b/kjsembed/bindings/brush_imp.h
@@ -0,0 +1,57 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_BRUSH_PLUGIN_H
+#define KJSEMBED_BRUSH_PLUGIN_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+class BrushImp : public JSProxyImp {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { Methodstyle, MethodsetStyle, MethodColor, MethodsetColor };
+
+public:
+ BrushImp( KJS::ExecState *exec, int id );
+ virtual ~BrushImp();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const {
+ return true;
+ }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+private:
+ int mid;
+};
+
+} // namespace
+} // namespace
+
+#endif // KJSEMBED_IMAGE_IMP_H
diff --git a/kjsembed/bindings/dcop_imp.cpp b/kjsembed/bindings/dcop_imp.cpp
new file mode 100644
index 00000000..caa47313
--- /dev/null
+++ b/kjsembed/bindings/dcop_imp.cpp
@@ -0,0 +1,1020 @@
+// $Id$
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include <kapplication.h>
+#include <dcopref.h>
+#include <dcopclient.h>
+#include <kdebug.h>
+#include <qregexp.h>
+
+#include "dcop_imp.h"
+#include "dcop_imp.moc"
+
+#include <kdatastream.h>
+#include <kurl.h>
+#include <qvariant.h>
+#include <qstring.h>
+#include <qmap.h>
+#include <qfont.h>
+#include <qpixmap.h>
+#include <qbrush.h>
+#include <qrect.h>
+#include <qsize.h>
+#include <qcolor.h>
+#include <qimage.h>
+#include <qpoint.h>
+#include <qvaluelist.h>
+#include <qiconset.h>
+#include <qpointarray.h>
+#include <qbitmap.h>
+#include <qcursor.h>
+#include <qdatetime.h>
+#include <qmemarray.h>
+#include <qkeysequence.h>
+#include <qbitarray.h>
+
+#include <kjs/interpreter.h>
+#include <kjs/identifier.h>
+#include <kjs/types.h>
+#include <kjs/ustring.h>
+#include <kjs/value.h>
+
+#include "../jsbinding.h"
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsobjectproxy.h>
+#include <kjsembed/kjsembedpart.h>
+namespace KJSEmbed {
+namespace Bindings {
+KJS::Object JSDCOPRefLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const
+{
+ QString application = extractQString(exec, args, 0);
+ QString object = extractQString(exec, args, 1);
+ JSOpaqueProxy * prx;
+ if( application.isEmpty() )
+ prx= new JSOpaqueProxy( new DCOPRef(), "DCOPRef" );
+ else
+ prx= new JSOpaqueProxy( new DCOPRef(application.latin1(),object.latin1()), "DCOPRef" );
+
+ KJS::Object proxyObj( prx );
+ prx->setOwner( JSProxy::JavaScript );
+ addBindings(jspart,exec,proxyObj);
+ return proxyObj;
+}
+
+void JSDCOPRefLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const
+{
+ JSDCOPRef::addBindings( exec, proxy );
+}
+
+JSDCOPRef::JSDCOPRef(KJS::ExecState *exec, int id)
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+JSDCOPRef::~JSDCOPRef()
+{
+}
+
+void JSDCOPRef::addBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( object.imp() );
+ if ( !op ) {
+ kdWarning() << "JSDCOPRef::addBindings() failed, not a JSOpaqueProxy" << endl;
+ return;
+ }
+
+ if ( op->typeName() != "DCOPRef" ) {
+ kdWarning() << "JSDCOPRef::addBindings() failed, type is " << op->typeName() << endl;
+ return;
+ }
+
+ DCOPRef *ref = op->toNative<DCOPRef>();
+
+ JSProxy::MethodTable methods[] = {
+ { Methodcall, "call"},
+ { Methodsend, "send" },
+ { Methodapp, "app" },
+ { Methodobj, "obj" },
+ { Methodtype, "type" },
+ { MethodsetRef, "setRef" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ JSDCOPRef *meth = new JSDCOPRef( exec, methods[idx].id );
+ object.put( exec, methods[idx].name, KJS::Object(meth) );
+ ++idx;
+ } while( methods[idx].id );
+
+}
+
+KJS::Value JSDCOPRef::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+
+
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+ if ( !op ) {
+ kdWarning() << "JSDCOPRef::call() failed, not a JSOpaqueProxy" << endl;
+ return KJS::Boolean(false);
+ }
+
+ if ( op->typeName() != "DCOPRef" ) {
+ kdWarning() << "JSDCOPRef::call() failed, type is " << op->typeName() << endl;
+ return KJS::Boolean(false);
+ }
+ DCOPRef *ref = op->toNative<DCOPRef>();
+ kdDebug() << "Ref valid" << ref << endl;
+ if( !ref )
+ {
+ kdWarning() << "Ref invalid" << ref << endl;
+ return KJS::Null();
+ }
+ kdDebug() << "DCOPRef call. " << mid << endl;
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case Methodcall:
+ {
+ if ( args.size() < 1 )
+ {
+ kdWarning() << "Not enough args..." << endl;
+ return KJS::Boolean(false);
+ }
+ QByteArray data, replyData;
+ QDataStream ds( replyData, IO_ReadOnly);
+ QCString type;
+
+ QString app = ref->app();
+ QString interface = ref->obj();
+ QString function = extractQString(exec, args, 0);
+ QStringList argTypes = JSDCOPClient::getTypes( function );
+
+ if( args.size() > 1)
+ for( int idx = 1; idx < args.size(); ++idx)
+ {
+ JSDCOPClient::marshall(convertToVariant(exec,args[idx] ), argTypes[idx - 1], data);
+ }
+ if( !kapp->dcopClient()->call(app.local8Bit(), interface.local8Bit(), function.local8Bit(), data, type, replyData))
+ retValue = KJS::Boolean(false);
+ else
+ retValue = JSDCOPClient::demarshall(exec, type, ds);
+ break;
+ }
+ case Methodsend:
+ {
+ if ( args.size() < 1 )
+ return KJS::Boolean(false);
+
+ QByteArray data;
+ QString app = ref->app();
+ QString interface = ref->obj();
+ QString function = extractQString(exec, args, 0);
+
+ QStringList argTypes = JSDCOPClient::getTypes( function );
+
+ if( args.size() > 1)
+ for( int idx = 1; idx < args.size(); ++idx)
+ {
+ JSDCOPClient::marshall(convertToVariant(exec,args[idx] ), argTypes[idx - 1], data);
+ }
+ retValue = KJS::Boolean( kapp->dcopClient()->send(app.local8Bit(), interface.local8Bit(),
+ function.local8Bit(), data));
+ break;
+ }
+ case Methodapp:
+ {
+ retValue = convertToValue( exec, ref->app() );
+ break;
+ }
+ case Methodobj:
+ {
+ retValue = convertToValue( exec, ref->obj() );
+ break;
+ }
+ case Methodtype:
+ {
+ retValue = convertToValue( exec, ref->type() );
+ break;
+ }
+ case MethodsetRef:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ QString arg2 = extractQString(exec, args, 0);
+ ref->setRef(arg0.latin1(), arg1.latin1(), arg2.latin1() );
+ break;
+ }
+ default:
+ {
+ kdWarning() << "JSDCOPClient has no method " << mid << endl;
+ break;
+ }
+ }
+ op->setValue( ref, "DCOPRef" );
+ return retValue;
+}
+
+KJS::Object JSDCOPClientLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &/*args*/) const
+{
+ JSOpaqueProxy * prx = new JSOpaqueProxy( kapp->dcopClient(), "DCOPClient" );
+ prx->setOwner( JSProxy::Native );
+ KJS::Object proxyObj( prx );
+ addBindings( jspart, exec, proxyObj );
+ return proxyObj;
+}
+
+void JSDCOPClientLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const
+{
+ JSDCOPClient::addBindings( exec, proxy );
+}
+
+JSDCOPClient::JSDCOPClient( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+JSDCOPClient::~JSDCOPClient()
+{
+}
+
+
+void JSDCOPClient::addBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ if( !JSProxy::checkType(object, JSProxy::OpaqueProxy, "DCOPClient") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodattach, "attach"},
+ { Methoddetach, "detach"},
+ { MethodisAttached, "isAttached" },
+ { MethodregisteredApplications, "registeredApplications" },
+ { MethodremoteObjects, "remoteObjects" },
+ { MethodremoteInterfaces, "remoteInterfaces" },
+ { MethodremoteFunctions, "remoteFunctions" },
+ { MethodconnectDCOPSignal, "connectDCOPSignal" },
+ { MethoddisconnectDCOPSignal, "disconnectDCOPSignal"},
+ { Methodcall, "call"},
+ { Methodsend, "send"},
+ { MethodDCOPStart, "dcopStart"},
+ { MethodappId, "appId"},
+ { MethodisApplicationRegistered, "isApplicationRegistered" },
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<JSDCOPClient>(exec, methods, object );
+}
+
+KJS::Value JSDCOPClient::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::OpaqueProxy, "DCOPClient") ) return KJS::Value();
+
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case Methodattach: {
+ retValue = KJS::Boolean(attach( ));
+ break;
+ }
+ case Methoddetach: {
+ retValue = KJS::Boolean(detach( ));
+ break;
+ }
+ case MethodisAttached: {
+ retValue = KJS::Boolean(isAttached( ));
+ break;
+ }
+ case MethodregisteredApplications: {
+ retValue = convertToValue(exec, registeredApplications());
+ break;
+ }
+ case MethodremoteObjects: {
+ QString arg0 = extractQString(exec, args, 0);
+ retValue = convertToValue( exec, remoteObjects(arg0));
+ break;
+ }
+ case MethodremoteInterfaces: {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ this->remoteInterfaces(arg0, arg1);
+ break;
+ }
+ case MethodremoteFunctions: {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ remoteFunctions(arg0, arg1);
+ break;
+ }
+ case MethodconnectDCOPSignal: {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ QString arg2 = extractQString(exec, args, 2);
+ QString arg3 = extractQString(exec, args, 3);
+ QString arg4 = extractQString(exec, args, 4);
+ bool arg5 = (args.size() > 5) ? args[5].toBoolean(exec) : false;
+ connectDCOPSignal( arg0, arg1, arg2, arg3, arg4, arg5);
+ break;
+ }
+ case MethoddisconnectDCOPSignal: {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ QString arg2 = extractQString(exec, args, 2);
+ QString arg3 = extractQString(exec, args, 3);
+ QString arg4 = extractQString(exec, args, 4);
+ disconnectDCOPSignal(arg0, arg1, arg2, arg3, arg4);
+ break;
+ }
+ case MethodDCOPStart: {
+ QString arg0 = extractQString(exec, args, 0);
+
+ retValue = KJS::String( dcopStart( arg0, QStringList() ) );
+ break;
+ }
+ case MethodappId:
+ retValue = KJS::String( kapp->dcopClient()->appId().data() );
+ break;
+ case MethodisApplicationRegistered: {
+ QString arg0 = extractQString(exec, args, 0);
+ retValue = KJS::Boolean( kapp->dcopClient()->isApplicationRegistered( arg0.latin1() ) );
+ break;
+ }
+ case Methodsend:
+ return dcopSend( exec, self, args );
+ break;
+ case Methodcall:
+ return dcopCall( exec, self, args );
+ break;
+ default:
+ kdWarning() << "JSDCOPClient has no method " << mid << endl;
+ break;
+ }
+ return retValue;
+}
+
+bool JSDCOPClient::attach() const
+{
+ if( !kapp->dcopClient()->isAttached() )
+ return kapp->dcopClient()->attach();
+ return true;
+}
+bool JSDCOPClient::detach() const
+{ return kapp->dcopClient()->detach();
+
+}
+
+bool JSDCOPClient::isAttached() const
+{
+ return kapp->dcopClient()->isAttached();
+}
+
+KJS::Value JSDCOPClient::dcopCall( KJS::ExecState * exec, KJS::Object &, const KJS::List & args )
+{
+ if ( args.size() < 3 )
+ return KJS::Boolean(false);
+
+ QStringList types;
+ QByteArray data, replyData;
+ QDataStream ds( replyData, IO_ReadOnly);
+ QCString type;
+
+ QString app = extractQString(exec, args, 0);
+ QString interface = extractQString(exec, args, 1);
+ QString function = extractQString(exec, args, 2);
+ QStringList argTypes = getTypes( function );
+
+ if( args.size() > 3)
+ for( int idx = 3; idx < args.size(); ++idx)
+ {
+ QVariant var = convertToVariant(exec,args[idx] );
+ marshall(var, argTypes[idx -3 ], data);
+ }
+ if( !kapp->dcopClient()->call(app.local8Bit(), interface.local8Bit(), function.local8Bit(), data, type, replyData))
+ return KJS::Boolean(false);
+ else
+ return demarshall(exec, type, ds);
+}
+
+KJS::Value JSDCOPClient::dcopSend( KJS::ExecState * exec, KJS::Object &, const KJS::List & args )
+{
+ if ( args.size() < 3 )
+ return KJS::Boolean(false);
+
+ QByteArray data;
+ QString app = extractQString(exec, args, 0);
+ QString interface = extractQString(exec, args, 1);
+ QString function = extractQString(exec, args, 2);
+ QStringList argTypes = getTypes( function );
+
+ if( args.size() > 3)
+ for( int idx = 3; idx < args.size(); ++idx)
+ {
+ QVariant var = convertToVariant(exec,args[idx] );
+ marshall(var, argTypes[idx - 3], data);
+ }
+ return KJS::Boolean( kapp->dcopClient()->send(app.local8Bit(), interface.local8Bit(),
+ function.local8Bit(), data));
+}
+
+KJS::Value JSDCOPClient::demarshall( KJS::ExecState * exec, const QCString& type, QDataStream& data)
+{
+ kdDebug() << "Demarshall " << type << endl;
+
+ if( type == "DCOPRef" )
+ {
+ DCOPRef *ref = new DCOPRef();
+ data >> *ref;
+ JSOpaqueProxy *prx = new JSOpaqueProxy(ref, "DCOPRef" );
+
+ KJS::Object proxyObj(prx);
+ kdDebug() << "DCOPRef " << ref->app() << endl;
+ Bindings::JSDCOPRef::addBindings( exec, proxyObj );
+ return proxyObj;
+ }
+ else
+ return convertToValue(exec, demarshall(type, data));
+}
+
+QStringList JSDCOPClient::getTypes( const QString& function )
+{
+ QCString myFunction = DCOPClient::normalizeFunctionSignature (function.latin1());
+ QString args = myFunction.mid( myFunction.find('(') + 1 );
+ args = args.left( args.length() - 1);
+ return QStringList::split(',', args);
+}
+
+void JSDCOPClient::marshall( const QVariant& data, const QString& typeName, QByteArray& buffer )
+{
+ QDataStream stream(buffer, IO_WriteOnly | IO_Append);
+
+ if ( typeName == "QString" )
+ {
+ stream << data.toString();
+ }
+ else if ( typeName == "QCString")
+ {
+ stream << data.toCString();
+ }
+ else if ( typeName == "int")
+ {
+ stream << data.toInt();
+ }
+ else if ( typeName == "uint")
+ {
+ stream << data.toUInt();
+ }
+ else if ( typeName == "bool")
+ {
+ stream << data.toBool();
+ }
+ else if ( typeName == "double")
+ {
+ stream << data.toDouble();
+ }
+ else if ( typeName == "QMap" )
+ {
+ stream << data.toMap();
+ }
+ else if ( typeName == "QValueList")
+ {
+ stream << data.toList();
+ }
+ else if ( typeName == "QFont")
+ {
+ stream << data.toFont();
+ }
+ else if ( typeName == "QPixmap")
+ {
+ stream << data.toPixmap();
+ }
+ else if ( typeName == "QBrush")
+ {
+ stream << data.toBrush();
+ }
+ else if ( typeName == "QRect")
+ {
+ stream << data.toRect();
+ }
+ else if ( typeName == "QSize")
+ {
+ stream << data.toSize();
+ }
+ else if ( typeName == "QColor")
+ {
+ stream << data.toColor();
+ }
+ else if ( typeName == "QPalette")
+ {
+ stream << data.toPalette();
+ }
+ else if ( typeName == "QColorGroup")
+ {
+ stream << data.toColorGroup();
+ }
+ /*else if ( typeName == "QIconSet")
+ {
+ stream << data.toIconSet();
+ }*/
+ else if ( typeName == "QPoint")
+ {
+ stream << data.toPoint();
+ }
+ else if ( typeName == "QImage")
+ {
+ stream << data.toImage();
+ }
+ else if ( typeName == "QPointArray")
+ {
+ stream << data.toPointArray();
+ }
+ else if ( typeName == "QRegion")
+ {
+ stream << data.toRegion();
+ }
+ else if ( typeName == "QBitmap")
+ {
+ stream << data.toBitmap();
+ }
+ else if ( typeName == "QCursor")
+ {
+ stream << data.toCursor();
+ }
+ /*else if ( typeName == "QSizePolicy")
+ {
+ stream << data.toSizePolicy();
+ }*/
+ else if ( typeName == "QDate")
+ {
+ stream << data.toDate();
+ }
+ else if ( typeName == "QTime")
+ {
+ stream << data.toTime();
+ }
+ else if ( typeName == "QDateTime")
+ {
+ stream << data.toDateTime();
+ }
+ else if ( typeName == "QByteArray")
+ {
+ stream << data.toByteArray();
+ }
+ else if ( typeName == "QBitArray")
+ {
+ stream << data.toBitArray();
+ }
+ else if ( typeName == "QKeySequence")
+ {
+ stream << data.toKeySequence();
+ }
+ else if ( typeName == "KURL" )
+ {
+ KURL url = data.toString();
+ stream << url;
+ }
+ else
+ stream << 0;
+
+}
+
+QString JSDCOPClient::dcopStart( const QString &appName, const QStringList& args )
+{
+ QString error;
+ QString startFunction;
+ if (appName.endsWith(".desktop"))
+ startFunction = "start_service_by_desktop_path(QString,QStringList)";
+ else
+ startFunction = "start_service_by_desktop_name(QString,QStringList)";
+
+ QByteArray data, replyData;
+ QCString replyType;
+ QDataStream arg(data, IO_WriteOnly);
+ arg << appName << args;
+
+ if ( !kapp->dcopClient()->call( "klauncher", "klauncher", startFunction.latin1(), data, replyType, replyData) )
+ {
+ kdWarning() << "Error: Dcop call failed" << endl;
+ }
+ else
+ {
+ QDataStream reply(replyData, IO_ReadOnly);
+
+ if ( replyType != "serviceResult" )
+ {
+ kdWarning() << "Error: No serviceResult " << endl;
+ }
+ else
+ {
+ int result;
+ QCString dcopName;
+ QString error;
+ reply >> result >> dcopName >> error;
+ if (result != 0)
+ {
+ kdWarning() << "Error: " << error.local8Bit().data() << endl;
+ }
+ else if (!dcopName.isEmpty())
+ {
+ return dcopName;
+ }
+ else
+ kdWarning() << "Error: no app name returned." << endl;
+ }
+ }
+
+ return "";
+
+}
+
+QStringList JSDCOPClient::remoteFunctions( const QString & remApp, const QString & remObj )
+{
+ QStringList returnList;
+ QCStringList lst = kapp->dcopClient()->remoteFunctions(remApp.local8Bit(), remObj.local8Bit());
+ for(uint idx = 0; idx < lst.count(); ++idx)
+ returnList += lst[idx];
+ return returnList;
+}
+
+QStringList JSDCOPClient::remoteInterfaces( const QString & remApp, const QString & remObj )
+{
+ QStringList returnList;
+ QCStringList lst = kapp->dcopClient()->remoteInterfaces(remApp.local8Bit(), remObj.local8Bit());
+ for(uint idx = 0; idx < lst.count(); ++idx)
+ returnList += lst[idx];
+ return returnList;
+}
+
+QStringList JSDCOPClient::remoteObjects( const QString & remApp )
+{
+ QStringList returnList;
+ QCStringList lst = kapp->dcopClient()->remoteObjects(remApp.local8Bit());
+ for(uint idx = 0; idx < lst.count(); ++idx)
+ returnList += lst[idx];
+ return returnList;
+}
+
+QStringList JSDCOPClient::registeredApplications( )
+{
+ QStringList returnList;
+ QCStringList lst = kapp->dcopClient()->registeredApplications( );
+ for(uint idx = 0; idx < lst.count(); ++idx)
+ returnList += lst[idx];
+ return returnList;
+}
+
+bool JSDCOPClient::connectDCOPSignal (const QString &sender, const QString &senderObj, const QString &signal, const QString &receiverObj, const QString &slot, bool Volatile)
+{
+ return kapp->dcopClient()->connectDCOPSignal(sender.latin1(), senderObj.latin1(), signal.latin1(), receiverObj.latin1(), slot.latin1(), Volatile);
+}
+
+bool JSDCOPClient::disconnectDCOPSignal (const QString &sender, const QString &senderObj, const QString &signal, const QString &receiverObj, const QString &slot)
+{
+ return kapp->dcopClient()->disconnectDCOPSignal(sender.latin1(), senderObj.latin1(), signal.latin1(), receiverObj.latin1(), slot.latin1());
+}
+
+KJS::Object JSDCOPInterfacerLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const
+{
+ QObject *parent = extractQObject(exec, args, 0);
+ QString name = extractQString(exec, args, 1);
+ QObject *obj = new JSDCOPInterface(jspart->interpreter(),parent, name.latin1() );
+ JSObjectProxy *prxy = new JSObjectProxy(jspart, obj);
+ KJS::Object object(prxy);
+ addBindings(jspart,exec,object);
+ return object;
+}
+
+void JSDCOPInterfacerLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const
+{
+ JSObjectProxy *prx = JSProxy::toObjectProxy( proxy.imp() );
+ if( prx )
+ prx->addBindings( exec, proxy );
+}
+
+void JSDCOPInterface::publish( const QString & signature )
+{
+ if( m_Members.find(signature.latin1() ) == m_Members.end())
+ m_Members.append(signature.latin1() );
+}
+
+JSDCOPInterface::~ JSDCOPInterface( )
+{
+}
+
+JSDCOPInterface::JSDCOPInterface( KJS::Interpreter *js, QObject * parent, const char * name )
+ : BindingObject( parent, name ),DCOPObject(name), m_js(js)
+{
+ m_Members.clear();
+}
+
+QCStringList JSDCOPInterface::functionsDynamic( )
+{
+ return m_Members;
+}
+
+bool JSDCOPInterface::processDynamic( const QCString & rawFunction, const QByteArray & data, QCString & replyType, QByteArray & replyData )
+{
+ bool isOkay = false;
+
+ QRegExp reg = QRegExp("([_\\d\\w]+)(\\()(.*)(\\))");
+ reg.search(rawFunction);
+
+ kdDebug() << "Raw function: " << rawFunction << endl;
+ kdDebug() << "Reply type: " << replyType << endl;
+ kdDebug() << "Signature: " << reg.cap(1) << endl;
+ kdDebug() << "Args: " << reg.cap(3) << endl;
+
+ QString signature = reg.cap(1);
+
+ QStringList argStrings = QStringList::split(',', reg.cap(3), false);
+ kdDebug() << argStrings.count() << " args..." << endl;
+
+ KJS::ExecState *exec = m_js->globalExec();
+ KJS::Object obj = m_js->globalObject();
+ KJS::Identifier id( KJS::UString( signature.latin1() ) );
+ KJS::Object fun = obj.get(exec, id ).toObject( exec );
+ KJS::Value retValue;
+
+
+ if ( fun.implementsCall() )
+ {
+ QDataStream ds( data, IO_ReadOnly );
+ KJS::List args;
+ for( uint idx = 0; idx < argStrings.count(); ++idx)
+ {
+ kdDebug() << "Get arg: " << argStrings[idx] << endl;
+ args.append( JSDCOPClient::demarshall( exec, argStrings[idx].latin1(), ds));
+ }
+
+ retValue = fun.call(exec, obj, args);
+
+ if( exec->hadException() )
+ {
+ kdWarning() << "Got error: " << exec->exception().toString(exec).qstring() << endl;
+ }
+ else
+ {
+ kdDebug() << "Returned type is a " << retValue.type() << endl;
+ if( retValue.isA(KJS::UndefinedType) )
+ {
+ replyType = "void";
+ isOkay = true;
+ }
+ else if( retValue.isA(KJS::ObjectType) )
+ {
+ JSOpaqueProxy *oprx = JSProxy::toOpaqueProxy( retValue.imp() );
+ if( oprx )
+ {
+ replyType = "DCOPRef";
+ QDataStream refStream( replyData, IO_WriteOnly );
+ if( oprx->typeName() == "DCOPRef" )
+ {
+ DCOPRef ref(*oprx->toNative<DCOPRef>());
+ refStream << ref;
+ isOkay = true;
+ }
+ }
+ }
+ else
+ {
+ QVariant returnVariant = convertToVariant(exec, retValue);
+ JSDCOPClient::marshall(returnVariant,returnVariant.typeName(), replyData);
+ replyType = returnVariant.typeName();
+ isOkay = true;
+ }
+ }
+ }
+ return isOkay;
+}
+
+QVariant JSDCOPClient::demarshall( const QCString & type, QDataStream & reply )
+{
+ kdDebug() << "Type: '" << type << "'"<< endl;
+ /*if ( type == "QMap" ) // ? dont handle?
+ {
+ QMap<QVariant, QVariant> result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QValueList") // ? dont handle?
+ {
+ QValueList<QVariant> result;
+ reply >> result;
+ return QVariant(result);
+ }else if ( type == "QVariantList")
+ {
+ QVariantList result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else */
+ if ( type == "QString")
+ {
+ QString result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "int")
+ {
+ int result;
+ reply >> result;
+ kdDebug() << "Result: " << result << endl;
+ return QVariant(result);
+ }
+ else if ( type == "uint")
+ {
+ uint result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "bool")
+ {
+ bool result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "double")
+ {
+ double result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QCString")
+ {
+ QCString result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QVariant")
+ {
+ QVariant result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QFont")
+ {
+ QFont result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QPixmap")
+ {
+ QPixmap result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QBrush")
+ {
+ QBrush result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QRect")
+ {
+ QRect result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QSize")
+ {
+ QSize result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QColor")
+ {
+ QColor result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QPalette")
+ {
+ QPalette result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QColorGroup")
+ {
+ QColorGroup result;
+ reply >> result;
+ return QVariant(result);
+ }
+ /*else if ( type == "QIconSet")
+ {
+ QIconSet result;
+ reply >> result;
+ return QVariant(result);
+ }*/
+ else if ( type == "QPoint")
+ {
+ QPoint result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QImage")
+ {
+ QImage result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QPointArray")
+ {
+ QPointArray result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QRegion")
+ {
+ QRegion result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QBitmap")
+ {
+ QBitmap result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QCursor")
+ {
+ QCursor result;
+ reply >> result;
+ return QVariant(result);
+ }
+ /*else if ( type == "QSizePolicy")
+ {
+ QSizePolicy result;
+ reply >> result;
+ return QVariant(result);
+ }*/
+ else if ( type == "QDate")
+ {
+ QDate result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QTime")
+ {
+ QTime result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QDateTime")
+ {
+ QDateTime result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QByteArray")
+ {
+ QByteArray result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QBitArray")
+ {
+ QBitArray result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QKeySequence")
+ {
+ QKeySequence result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QStringList")
+ {
+ QStringList result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else if ( type == "QCStringList")
+ {
+ QStringList result;
+ reply >> result;
+ return QVariant(result);
+ }
+ else
+ return QVariant();
+
+}
+} // namespace Bindings
+} // namespace KJSEmbed
+
+
+
+
diff --git a/kjsembed/bindings/dcop_imp.h b/kjsembed/bindings/dcop_imp.h
new file mode 100644
index 00000000..56466a11
--- /dev/null
+++ b/kjsembed/bindings/dcop_imp.h
@@ -0,0 +1,152 @@
+// $Id$
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_DCOP_IMP_H
+#define KJSEMBED_DCOP_IMP_H
+
+#include "bindingobject.h"
+#include <kjsembed/jsobjectproxy_imp.h>
+#include <kjsembed/jsbindingbase.h>
+#include <dcopobject.h>
+
+class DCOPClient;
+#include <kdatastream.h>
+#include <qvariant.h>
+#include <qstring.h>
+
+namespace KJS
+{
+ class Interpreter;
+}
+
+namespace KJSEmbed {
+namespace Bindings {
+class JSDCOPInterfacerLoader : public JSBindingBase
+{
+ public:
+ KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const;
+ void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const;
+};
+
+/**
+* QObject Binding for a DCOP interface
+*/
+class JSDCOPInterface : public BindingObject, public DCOPObject
+{
+ Q_OBJECT
+
+public:
+ JSDCOPInterface( KJS::Interpreter *js, QObject *parent, const char *name=0 );
+ virtual ~JSDCOPInterface();
+ QCStringList functionsDynamic();
+ bool processDynamic (const QCString &fun, const QByteArray &data, QCString &replyType, QByteArray &replyData);
+public slots:
+ void publish(const QString& signature);
+
+private:
+ QCStringList m_Members;
+ KJS::Interpreter *m_js;
+};
+
+class JSDCOPRefLoader : public JSBindingBase
+{
+ public:
+ KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const;
+ void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const;
+};
+
+/**
+ * DCOPRef binding.
+*/
+class JSDCOPRef : public JSProxyImp
+{
+ enum MethodId { Methodcall, Methodsend, Methodapp, Methodobj, Methodtype, MethodsetRef };
+
+public:
+ JSDCOPRef( KJS::ExecState *exec, int id );
+ virtual ~JSDCOPRef();
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+private:
+ int mid;
+
+};
+
+class JSDCOPClientLoader : public JSBindingBase
+{
+ public:
+ KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const;
+ void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const;
+};
+
+/**
+ * Binding for DCOPClient.
+ */
+class JSDCOPClient : public JSProxyImp
+{
+ enum MethodId { Methodattach, Methoddetach, MethodisAttached, MethodregisteredApplications, MethodremoteObjects, MethodremoteInterfaces, MethodremoteFunctions, MethodconnectDCOPSignal, MethoddisconnectDCOPSignal, Methodcall, Methodsend, MethodDCOPStart, MethodappId, MethodisApplicationRegistered };
+
+public:
+ JSDCOPClient( KJS::ExecState *exec, int id );
+ virtual ~JSDCOPClient();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+ static KJS::Value demarshall( KJS::ExecState * exec, const QCString& type, QDataStream& data);
+ static QVariant demarshall( const QCString &type, QDataStream &ds);
+ static void marshall( const QVariant& data, const QString &typeName, QByteArray& buffer );
+ static QStringList getTypes( const QString& function);
+
+ bool attach() const;
+ bool detach() const;
+
+ bool isAttached() const;
+
+ QString dcopStart( const QString& appName, const QStringList& args);
+ QStringList registeredApplications();
+ QStringList remoteObjects( const QString& remApp);
+ QStringList remoteInterfaces( const QString& remApp, const QString& remObj );
+ QStringList remoteFunctions( const QString& remApp, const QString& remObj);
+ bool connectDCOPSignal (const QString &sender, const QString &senderObj, const QString &signal, const QString &receiverObj, const QString &slot, bool Volatile = false);
+ bool disconnectDCOPSignal (const QString &sender, const QString &senderObj, const QString &signal, const QString &receiverObj, const QString &slot);
+ KJS::Value dcopCall(KJS::ExecState *exec, KJS::Object &, const KJS::List &args);
+ KJS::Value dcopSend(KJS::ExecState *exec, KJS::Object &, const KJS::List &args);
+ private:
+ int mid;
+};
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_TEXTSTREAM_IMP_H
diff --git a/kjsembed/bindings/iconset_imp.cpp b/kjsembed/bindings/iconset_imp.cpp
new file mode 100644
index 00000000..3575cc94
--- /dev/null
+++ b/kjsembed/bindings/iconset_imp.cpp
@@ -0,0 +1,167 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <qvariant.h>
+#include <qiconset.h>
+#include <qpixmap.h>
+
+#include "iconset_imp.h"
+
+namespace KJSEmbed {
+namespace Bindings {
+
+IconsetImp::IconsetImp( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+IconsetImp::~IconsetImp()
+{
+}
+
+void IconsetImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ JSValueProxy *op = JSProxy::toValueProxy( object.imp() );
+ if ( !op ) {
+ kdWarning() << "IconsetImp::addBindings() failed, not a JSValueProxy" << endl;
+ return;
+ }
+
+ if ( op->typeName() != "QIconset" ) {
+ kdWarning() << "IconsetImp::addBindings() failed, type is " << op->typeName() << endl;
+ return;
+ }
+
+ JSProxy::MethodTable methods[] = {
+ { MethodReset, "reset"},
+ { MethodSetPixmap, "setPixmap"},
+ { MethodPixmap, "pixmap"},
+ { MethodIsGenerated, "isGenerated"},
+ { MethodClearGenerated, "clearGenerated"},
+ { MethodIsNull, "isNull"},
+ { MethodDetach, "detach"},
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ IconsetImp *meth = new IconsetImp( exec, methods[idx].id );
+ object.put( exec , methods[idx].name, KJS::Object(meth) );
+ ++idx;
+ } while( methods[idx].id );
+
+ //
+ // Define the enum constants
+ //
+ struct EnumValue {
+ const char *id;
+ int val;
+ };
+
+ EnumValue enums[] = {
+ // Size
+ { "Automatic", 0 },
+ { "Small", 1 },
+ { "Large", 2 },
+ // Mode
+ { "Normal", 0 },
+ { "Disabled", 1 },
+ { "Active", 2 },
+ // State
+ { "On", 0 },
+ { "Off", 1 },
+ { 0, 0 }
+ };
+
+ int enumidx = 0;
+ do {
+ object.put( exec, enums[enumidx].id, KJS::Number(enums[enumidx].val), KJS::ReadOnly );
+ ++enumidx;
+ } while( enums[enumidx].id );
+}
+
+KJS::Value IconsetImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+
+ JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
+ if ( !op ) {
+ kdWarning() << "IconsetImp::call() failed, not a JSValueProxy" << endl;
+ return KJS::Value();
+ }
+
+ if ( op->typeName() != "QIconSet" ) {
+ kdWarning() << "IconsetImp::call() failed, type is " << op->typeName() << endl;
+ return KJS::Value();
+ }
+
+ QIconSet iconset = op->toVariant().toIconSet();
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case MethodReset:
+ {
+ QPixmap pix = extractQPixmap(exec, args, 0);
+ QIconSet::Size size = (QIconSet::Size) extractInt(exec, args, 1 );
+ iconset.reset(pix,size);
+ break;
+ }
+ case MethodSetPixmap:
+ {
+ QPixmap pix = extractQPixmap( exec, args, 0);
+ QString fname = extractQString( exec, args, 0);
+ QIconSet::Size size = (QIconSet::Size) extractInt(exec, args, 1 );
+ QIconSet::Mode mode = (QIconSet::Mode) extractInt( exec, args, 2 );
+ QIconSet::State state = (QIconSet::State) extractInt( exec, args, 3);
+ if( pix.isNull() )
+ iconset.setPixmap( fname, size, mode, state );
+ else
+ iconset.setPixmap( pix, size, mode, state );
+ break;
+ }
+ case MethodPixmap:
+ {
+ QPixmap pix;
+
+ if( args.size() == 3 )
+ {
+ QIconSet::Size size = (QIconSet::Size)extractInt( exec, args, 0 );
+ QIconSet::Mode mode = (QIconSet::Mode)extractInt( exec, args, 1 );
+ QIconSet::State state = (QIconSet::State)extractInt( exec, args, 1 );
+ pix = iconset.pixmap( size, mode, state );
+ }
+ else
+ pix = iconset.pixmap();
+
+ break;
+ }
+ default:
+ kdWarning() << "Iconset has no method " << mid << endl;
+ break;
+ }
+
+ op->setValue(iconset);
+ return retValue;
+}
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
diff --git a/kjsembed/bindings/iconset_imp.h b/kjsembed/bindings/iconset_imp.h
new file mode 100644
index 00000000..d758f0b5
--- /dev/null
+++ b/kjsembed/bindings/iconset_imp.h
@@ -0,0 +1,59 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_ICONSET_H
+#define KJSEMBED_ICONSET_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+class IconsetImp : public JSProxyImp {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { MethodReset, MethodSetPixmap, MethodPixmap,
+ MethodIsGenerated, MethodClearGenerated, MethodIsNull,
+ MethodDetach };
+
+public:
+ IconsetImp( KJS::ExecState *exec, int id );
+ virtual ~IconsetImp();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const {
+ return true;
+ }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+private:
+ int mid;
+};
+
+} // namespace
+} // namespace
+
+#endif // KJSEMBED_IMAGE_IMP_H
diff --git a/kjsembed/bindings/image_imp.cpp b/kjsembed/bindings/image_imp.cpp
new file mode 100644
index 00000000..7f6abdca
--- /dev/null
+++ b/kjsembed/bindings/image_imp.cpp
@@ -0,0 +1,259 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qfile.h>
+#include <kjsembed/global.h>
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <qvariant.h>
+
+#include "image_imp.h"
+
+namespace KJSEmbed {
+namespace Bindings {
+
+
+ImageImp::ImageImp( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+ImageImp::~ImageImp()
+{
+}
+
+void ImageImp::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QImage") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodwidth, "width" },
+ { Methodheight, "height" },
+ { Methoddepth, "depth" },
+ { MethodisOk, "isOk" },
+ { Methodpixmap, "pixmap" },
+ { Methodload, "load" },
+ { Methodsave, "save" },
+ { MethodsetFormat, "setFormat" },
+ { MethodsmoothScale, "smoothScale" },
+ { MethodsmoothScaleMin, "smoothScaleMin" },
+ { MethodsetPixmap, "setPixmap" },
+ { MethodinvertPixels, "invertPixels" },
+ { Methodpixel, "pixel"},
+ { MethodsetPixel, "setPixel"},
+ { Methodmirror, "mirror" },
+ { 0, 0 }
+ };
+ JSProxy::addMethods<ImageImp>(exec, methods, object);
+
+}
+
+KJS::Value ImageImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QImage") ) return KJS::Value();
+ JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
+ img = op->toVariant().toImage();
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+// case Methodfilename:
+// retValue = KJS::String(filename());
+// break;
+// case Methodformat:
+// retValue = KJS::String(format());
+// break;
+ case Methodwidth:
+ retValue = KJS::Number(width());
+ break;
+ case Methodheight:
+ retValue = KJS::Number(height());
+ break;
+ case Methoddepth:
+ retValue = KJS::Number(depth());
+ break;
+ case MethodisOk:
+ retValue = KJS::Boolean(isOk());
+ break;
+ case Methodpixmap:
+ {
+ retValue = convertToValue(exec, pixmap());
+ break;
+ }
+
+ case Methodload: {
+ QString arg0 = extractQString( exec, args, 0);
+ retValue = KJS::Boolean( load( arg0 ));
+ break;
+ }
+ case Methodsave: {
+ QString arg0 = extractQString( exec, args, 0);
+ QString arg1 = extractQString( exec, args, 1);
+ retValue = KJS::Boolean( save( arg0, arg1 ));
+ break;
+ }
+ case MethodsetFormat: {
+ QString arg0 = extractQString( exec, args, 0);
+ setFormat( arg0 );
+ break;
+ }
+ case MethodsmoothScale: {
+ int arg0 = extractInt( exec, args, 0);
+ int arg1 = extractInt( exec, args, 1);
+ smoothScale(arg0, arg1);
+ break;
+ }
+ case MethodsmoothScaleMin: {
+ int arg0 = extractInt( exec, args, 0);
+ int arg1 = extractInt( exec, args, 1);
+ smoothScaleMin(arg0, arg1);
+ break;
+ }
+ case MethodsetPixmap: {
+ QPixmap pix = extractQPixmap(exec, args, 0);
+ setPixmap(pix);
+ break;
+ }
+ case MethodinvertPixels: {
+ bool alpha = extractBool( exec, args, 0);
+ img.invertPixels(alpha);
+ break;
+ }
+ case Methodpixel: {
+ int x = extractInt(exec, args, 0);
+ int y = extractInt(exec, args, 1);
+ retValue = KJS::Number( img.pixel(x, y) );
+ break;
+ }
+ case MethodsetPixel: {
+ int x = extractInt(exec, args, 0);
+ int y = extractInt(exec, args, 1);
+ uint col = extractUInt(exec, args, 2);
+ img.setPixel(x, y, col);
+ break;
+ }
+ case Methodmirror:
+ {
+ if ( img.isNull())
+ break;
+
+ bool arg0 = extractBool( exec, args, 0);
+ bool arg1 = extractBool( exec, args, 1);
+ img = img.mirror( arg0, arg1 );
+ }
+ default:
+ kdWarning() << "Image has no method " << mid << endl;
+ break;
+ }
+
+ op->setValue(img);
+ return retValue;
+}
+
+int ImageImp::width() const {
+
+ return !img.isNull() ? img.width() : 0;
+}
+
+int ImageImp::height() const {
+ return !img.isNull() ? img.height() : 0;
+}
+
+int ImageImp::depth() const {
+ return !img.isNull() ? img.depth() : 0;
+}
+
+bool ImageImp::isOk() const {
+ return !img.isNull();
+}
+
+QPixmap ImageImp::pixmap() const {
+ if ( img.isNull() )
+ return QPixmap();
+
+ QPixmap pix;
+ pix.convertFromImage( img );
+ return pix;
+}
+
+void ImageImp::setPixmap( const QPixmap &pix ) {
+ if ( img.isNull() )
+ img = QImage();
+
+ img = pix.convertToImage();
+}
+
+QString ImageImp::format() const {
+ return fmt;
+}
+
+QString ImageImp::filename() const {
+ return nm;
+}
+
+void ImageImp::setFormat( const QString &f ) {
+ fmt = f;
+}
+
+bool ImageImp::load( const QString &filename ) {
+
+ if ( !img.isNull() )
+ img = QImage();
+
+ nm = filename;
+ fmt = QImageIO::imageFormat( filename );
+ bool ok = img.load( filename );
+ if ( !ok ) {
+ kdWarning() << "Error loading " << filename << endl;
+ img = QImage();
+ }
+ return ok;
+}
+
+bool ImageImp::save( const QString &filename, const QString &fmt ) {
+
+ if ( img.isNull() ) {
+ kdWarning() << "Attempt to save a null image to '" << filename << "'" << endl;
+ return false;
+ }
+
+ bool ok = img.save( filename, fmt.isNull() ? "PNG" : fmt.ascii() );
+ if ( ok )
+ nm = filename;
+
+ return ok;
+}
+
+void ImageImp::smoothScale( int w, int h ) {
+ if ( img.isNull())
+ return;
+ img = img.smoothScale( w, h );
+}
+
+void ImageImp::smoothScaleMin( int w, int h ) {
+ if ( img.isNull())
+ return;
+ img = img.smoothScale( w, h, QImage::ScaleMin );
+}
+
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
diff --git a/kjsembed/bindings/image_imp.h b/kjsembed/bindings/image_imp.h
new file mode 100644
index 00000000..4104d3b5
--- /dev/null
+++ b/kjsembed/bindings/image_imp.h
@@ -0,0 +1,95 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_IMAGE_IMP_H
+#define KJSEMBED_IMAGE_IMP_H
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+#include <qimage.h>
+#include <qpixmap.h>
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * Methods for the QImage binding.
+ *
+ * @author Richard Moore, rich@kde.org
+ * @version $Id$
+ */
+
+class ImageImp : public JSProxyImp {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId {
+ /*Methodfilename, Methodformat,*/Methodwidth, Methodheight, Methoddepth,
+ MethodisOk, Methodpixmap, Methodload, Methodsave,MethodsetFormat,
+ MethodsmoothScale, MethodsmoothScaleMin, MethodsetPixmap, MethodinvertPixels,
+ Methodpixel, MethodsetPixel, Methodmirror
+ };
+
+
+public:
+ ImageImp( KJS::ExecState *exec, int id );
+ virtual ~ImageImp();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const {
+ return true;
+ }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+private:
+
+ QString filename() const;
+ QString format() const;
+ int width() const;
+ int height() const;
+ int depth() const;
+
+ bool isOk() const;
+ QPixmap pixmap() const;
+
+ bool load( const QString &filename );
+ bool save( const QString &filename, const QString &fmt );
+ void setFormat( const QString &fmt );
+ void smoothScale( int w, int h );
+ void smoothScaleMin( int w, int h );
+ void setPixmap( const QPixmap &pix );
+
+
+ int mid;
+ QImage img; // this is a temp!!!
+ QString nm;
+ QString fmt;
+};
+
+} // namespace
+} // namespace
+
+#endif // KJSEMBED_IMAGE_IMP_H
diff --git a/kjsembed/bindings/kconfig_imp.cpp b/kjsembed/bindings/kconfig_imp.cpp
new file mode 100644
index 00000000..f45e4d42
--- /dev/null
+++ b/kjsembed/bindings/kconfig_imp.cpp
@@ -0,0 +1,536 @@
+/*
+* Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kconfig_imp.h"
+
+#include <kjsembed/global.h>
+
+#ifndef QT_ONLY
+#include <kconfig.h>
+#include <kstddirs.h>
+#include <kapplication.h>
+#include "kconfig_imp.moc"
+#else
+#include <qsettings.h>
+#endif
+namespace KJSEmbed {
+namespace Bindings {
+
+Config::Config( QObject *parent, const char *name)
+ : BindingObject(parent, name)
+{
+
+#ifndef QT_ONLY
+ if( name == 0)
+ m_config = kapp->config();
+ else
+ m_config = new KConfig(name);
+ if( !m_config->checkConfigFilesWritable(true) )
+ {
+ kdWarning( 80001 ) << "Could not write to config file." << endl;
+ }
+#else
+ m_config = new QSettings();
+ if( name == 0)
+ m_name = "qjcmd";
+ else
+ m_name = name;
+ m_config->setPath( "QJSEmbed",m_name, QSettings::User );
+ m_forceGlobal = false;
+#endif
+}
+
+/*
+Config::Config( QObject *parent, const char *name , const QString& confName)
+ : BindingObject(parent, name)
+{
+ QString fileName = ::locate("kde_config", confName);
+ m_config = new KConfig(fileName);
+}
+*/
+Config::~Config()
+{
+#ifndef QT_ONLY
+ if( kapp->config() != m_config )
+#endif
+ delete m_config;
+}
+
+void Config::setDesktopGroup()
+{
+#ifndef QT_ONLY
+ m_config->setDesktopGroup();
+#else
+ m_config->resetGroup();
+ m_config->beginGroup("/Desktop Entry");
+#endif
+}
+
+void Config::setGroup(const QString& group)
+{
+#ifndef QT_ONLY
+ m_config->setGroup(group);
+#else
+ m_config->resetGroup();
+ m_config->beginGroup(group);
+#endif
+}
+
+QString Config::group()
+{
+ return m_config->group();
+}
+
+QStringList Config::groupList()
+{
+#ifndef QT_ONLY
+ return m_config->groupList();
+#else
+ m_config->resetGroup();
+ return m_config->subkeyList(group());
+#endif
+}
+
+QString Config::locale()
+{
+#ifndef QT_ONLY
+ return m_config->locale();
+#else
+ return "C";
+#endif
+}
+
+void Config::setForceGlobal( bool force )
+{
+#ifndef QT_ONLY
+ m_config->setForceGlobal(force);
+#else
+ m_forceGlobal = force;
+ m_config->setPath( "QJSEmbed",m_name, (force)?QSettings::Global:QSettings::User );
+#endif
+}
+
+bool Config::forceGlobal( ) const
+{
+#ifndef QT_ONLY
+ return m_config->forceGlobal();
+#else
+ return m_forceGlobal;
+#endif
+}
+
+void Config::setDollarExpansion( bool _bExpand )
+{
+#ifndef QT_ONLY
+ m_config->setDollarExpansion(_bExpand);
+#else
+ Q_UNUSED(_bExpand);
+#endif
+}
+
+bool Config::isDollarExpansion() const
+{
+#ifndef QT_ONLY
+ return m_config->isDollarExpansion();
+#else
+ return false;
+#endif
+}
+
+void Config::setReadOnly(bool _ro)
+{
+#ifndef QT_ONLY
+ m_config->setReadOnly(_ro);
+#else
+ Q_UNUSED(_ro);
+#endif
+}
+
+bool Config::isReadOnly() const
+{
+#ifndef QT_ONLY
+ return m_config->isReadOnly();
+#else
+ return false;
+#endif
+}
+
+void Config::setReadDefaults(bool b)
+{
+#ifndef QT_ONLY
+ m_config->setReadDefaults(b);
+#else
+ Q_UNUSED(b);
+#endif
+}
+
+bool Config::readDefaults() const
+{
+#ifndef QT_ONLY
+ return m_config->readDefaults();
+#else
+ return false;
+#endif
+}
+
+void Config::rollback( bool bDeep )
+{
+#ifndef QT_ONLY
+ m_config->rollback(bDeep);
+#else
+ Q_UNUSED(bDeep);
+#endif
+}
+
+void Config::sync()
+{
+ m_config->sync();
+}
+
+bool Config::hasKey( const QString& key ) const
+{
+#ifndef QT_ONLY
+ return m_config->hasKey(key);
+#else
+ return false;
+#endif
+}
+
+bool Config::entryIsImmutable(const QString &key) const
+{
+#ifndef QT_ONLY
+ return m_config->entryIsImmutable(key);
+#else
+ Q_UNUSED( key );
+ return false;
+#endif
+}
+
+void Config::revertToDefault(const QString &key)
+{
+#ifndef QT_ONLY
+ m_config->revertToDefault(key);
+#else
+ Q_UNUSED(key);
+#endif
+}
+
+bool Config::hasDefault(const QString &key) const
+{
+#ifndef QT_ONLY
+ return m_config->hasDefault(key);
+#else
+ Q_UNUSED(key);
+ return false;
+#endif
+}
+
+void Config::setFileWriteMode(int mode)
+{
+#ifndef QT_ONLY
+ m_config->setFileWriteMode(mode);
+#else
+ Q_UNUSED(mode);
+#endif
+}
+
+QString Config::readEntry(const QString& pKey, const QString& aDefault ) const
+{
+ return m_config->readEntry(pKey,aDefault);
+}
+
+QVariant Config::readPropertyEntry( const QString& pKey, const QVariant &pDefault) const
+{
+#ifndef QT_ONLY
+ return m_config->readPropertyEntry(pKey,pDefault);
+#else
+ QVariant returnVariant;
+ returnVariant = m_config->readEntry(pKey, pDefault.toString());
+ return returnVariant;
+#endif
+}
+
+QStringList Config::readListEntry( const QString& pKey ) const
+{
+ return m_config->readListEntry(pKey);
+}
+
+QString Config::readPathEntry( const QString& pKey, const QString & aDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readPathEntry(pKey,aDefault);
+#else
+ return readEntry(pKey,aDefault);
+#endif
+}
+
+QStringList Config::readPathListEntry( const QString& pKey ) const
+{
+#ifndef QT_ONLY
+ return m_config->readPathListEntry(pKey);
+#else
+ return readListEntry(pKey);
+#endif
+
+}
+
+int Config::readNumEntry( const QString& pKey, int nDefault) const
+{
+ return m_config->readNumEntry(pKey,nDefault);
+}
+
+uint Config::readUnsignedNumEntry( const QString& pKey, uint nDefault) const
+{
+#ifndef QT_ONLY
+ return m_config->readUnsignedNumEntry(pKey,nDefault);
+#else
+ return (uint)readNumEntry(pKey,nDefault);
+#endif
+}
+
+long Config::readLongNumEntry( const QString& pKey, long nDefault) const
+{
+#ifndef QT_ONLY
+ return m_config->readLongNumEntry(pKey,nDefault);
+#else
+ return (long)readNumEntry(pKey,nDefault);
+#endif
+}
+
+double Config::readDoubleNumEntry( const QString& pKey, double nDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readDoubleNumEntry(pKey,nDefault);
+#else
+ return m_config->readDoubleEntry(pKey,nDefault);
+#endif
+}
+
+QFont Config::readFontEntry( const QString& pKey, const QFont* pDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readFontEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toFont();
+#endif
+}
+
+bool Config::readBoolEntry( const QString& pKey, const bool bDefault ) const
+{
+ return m_config->readBoolEntry(pKey,bDefault);
+}
+
+QRect Config::readRectEntry( const QString& pKey, const QRect* pDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readRectEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toRect();
+#endif
+}
+
+QPoint Config::readPointEntry( const QString& pKey, const QPoint* pDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readPointEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toPoint();
+#endif
+}
+
+QSize Config::readSizeEntry( const QString& pKey, const QSize* pDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readSizeEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toSize();
+#endif
+}
+
+QColor Config::readColorEntry( const QString& pKey, const QColor* pDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readColorEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toColor();
+#endif
+}
+
+QDateTime Config::readDateTimeEntry( const QString& pKey, const QDateTime* pDefault) const
+{
+#ifndef QT_ONLY
+ return m_config->readDateTimeEntry(pKey,pDefault);
+#else
+ return readPropertyEntry(pKey,QVariant(*pDefault)).toDateTime();
+#endif
+}
+
+QString Config::readEntryUntranslated( const QString& pKey, const QString& aDefault ) const
+{
+#ifndef QT_ONLY
+ return m_config->readEntryUntranslated(pKey,aDefault);
+#else
+ return m_config->readEntry(pKey,aDefault);
+#endif
+}
+void Config::writeEntry( const QString& pKey, const QString& pValue )
+{
+ m_config->writeEntry(pKey,pValue);
+}
+
+void Config::writePropertyEntry( const QString& pKey, const QVariant& pValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, pValue );
+#else
+ m_config->writeEntry(pKey,pValue.toString());
+#endif
+}
+
+void Config::writeListEntry( const QString& pKey, const QStringList &rValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rValue );
+#else
+ m_config->writeEntry(pKey,rValue);
+#endif
+}
+
+void Config::writeNumEntry( const QString& pKey, int nValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, nValue );
+#else
+ m_config->writeEntry(pKey,nValue);
+#endif
+}
+void Config::writeUnsignedNumEntry( const QString& pKey, uint nValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, nValue );
+#else
+ writeNumEntry(pKey, (int)nValue );
+#endif
+}
+void Config::writeLongNumEntry( const QString& pKey, unsigned long nValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, nValue );
+#else
+ writeNumEntry(pKey, (int)nValue);
+#endif
+}
+void Config::writeDoubleNumEntry( const QString& pKey, double nValue )
+{
+ m_config->writeEntry(pKey,nValue);
+}
+void Config::writeBoolEntry( const QString& pKey, bool bValue )
+{
+ m_config->writeEntry(pKey,bValue);
+}
+void Config::writeFontEntry( const QString& pKey, const QFont& rFont )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rFont );
+#else
+ writePropertyEntry(pKey,rFont);
+#endif
+
+}
+void Config::writeColorEntry( const QString& pKey, const QColor& rColor )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rColor );
+#else
+ writePropertyEntry(pKey,rColor);
+#endif
+
+}
+void Config::writeDateTimeEntry( const QString& pKey, const QDateTime& rDateTime )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rDateTime );
+#else
+ writePropertyEntry(pKey,rDateTime);
+#endif
+
+}
+void Config::writeRectEntry( const QString& pKey, const QRect& rValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rValue );
+#else
+ writePropertyEntry(pKey,rValue);
+#endif
+
+}
+void Config::writePointEntry( const QString& pKey, const QPoint& rValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rValue );
+#else
+ writePropertyEntry(pKey,rValue);
+#endif
+
+}
+void Config::writeSizeEntry( const QString& pKey, const QSize& rValue )
+{
+#ifndef QT_ONLY
+ m_config->writeEntry(pKey, rValue );
+#else
+ writePropertyEntry(pKey,rValue);
+#endif
+}
+void Config::writePathEntry( const QString& pKey, const QString & path )
+{
+#ifndef QT_ONLY
+ m_config->writePathEntry(pKey,path);
+#else
+ writeEntry(pKey,path);
+#endif
+}
+void Config::writePathListEntry( const QString& pKey, const QStringList &rValue )
+{
+#ifndef QT_ONLY
+ m_config->writePathEntry(pKey,rValue);
+#else
+ writeListEntry(pKey,rValue);
+#endif
+}
+void Config::deleteEntry( const QString& pKey, bool bNLS , bool bGlobal )
+{
+#ifndef QT_ONLY
+ m_config->deleteEntry(pKey,bNLS,bGlobal);
+#else
+ Q_UNUSED(bNLS);
+ Q_UNUSED(bGlobal);
+ m_config->removeEntry(pKey);
+#endif
+}
+bool Config::deleteGroup( const QString& group, bool bDeep , bool bGlobal )
+{
+#ifndef QT_ONLY
+ return m_config->deleteGroup(group,bDeep,bGlobal);
+#else
+ return false;
+#endif
+}
+
+}
+}
diff --git a/kjsembed/bindings/kconfig_imp.h b/kjsembed/bindings/kconfig_imp.h
new file mode 100644
index 00000000..55f58e34
--- /dev/null
+++ b/kjsembed/bindings/kconfig_imp.h
@@ -0,0 +1,135 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_CONFIG_IMP_H
+#define KJSEMBED_CONFIG_IMP_H
+
+#include <qdatetime.h>
+#include <qfont.h>
+#include <qvariant.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsize.h>
+#include <qcolor.h>
+#include <qstringlist.h>
+
+#include "bindingobject.h"
+
+#ifndef QT_ONLY
+class KConfig;
+#else
+class QSettings;
+#endif
+
+namespace KJSEmbed {
+namespace Bindings {
+
+class Config : public BindingObject
+{
+ Q_OBJECT
+ Q_PROPERTY( bool forceGlobal READ forceGlobal WRITE setForceGlobal )
+ Q_PROPERTY( bool dollarExpansion READ isDollarExpansion WRITE setDollarExpansion )
+ Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
+ Q_PROPERTY( bool readDefaults READ readDefaults WRITE setReadDefaults )
+
+public:
+ Config( QObject *parent=0, const char *name=0);
+ /*
+ Config( QObject *parent, const char *name, const QString& confName );
+ */
+ virtual ~Config();
+
+ void setForceGlobal( bool force );
+ bool forceGlobal() const;
+ void setDollarExpansion( bool _bExpand );
+ bool isDollarExpansion() const;
+ void setReadOnly(bool _ro);
+ bool isReadOnly() const;
+ void setReadDefaults(bool b);
+ bool readDefaults() const;
+
+public slots:
+
+ // Group
+ void setDesktopGroup();
+ void setGroup(const QString&);
+ QString group();
+ QStringList groupList();
+ QString locale();
+
+ void rollback( bool bDeep );
+ void sync();
+ bool hasKey( const QString& key ) const;
+ bool entryIsImmutable(const QString &key) const;
+ void revertToDefault(const QString &key);
+ bool hasDefault(const QString &key) const;
+
+ void setFileWriteMode(int mode);
+ QString readEntry(const QString& pKey, const QString& aDefault ) const;
+ QVariant readPropertyEntry( const QString& pKey, const QVariant &var) const;
+ QStringList readListEntry( const QString& pKey ) const;
+ QString readPathEntry( const QString& pKey, const QString & aDefault) const;
+ QStringList readPathListEntry( const QString& pKey ) const;
+ int readNumEntry( const QString& pKey, int nDefault ) const;
+ uint readUnsignedNumEntry( const QString& pKey, uint nDefault ) const;
+ long readLongNumEntry( const QString& pKey, long nDefault ) const;
+ double readDoubleNumEntry( const QString& pKey, double nDefault ) const;
+ QFont readFontEntry( const QString& pKey, const QFont* pDefault) const;
+ bool readBoolEntry( const QString& pKey, const bool bDefault ) const;
+ QRect readRectEntry( const QString& pKey, const QRect* pDefault) const;
+ QPoint readPointEntry( const QString& pKey, const QPoint* pDefault) const;
+ QSize readSizeEntry( const QString& pKey, const QSize* pDefault) const;
+ QColor readColorEntry( const QString& pKey, const QColor* pDefault) const;
+ QDateTime readDateTimeEntry( const QString& pKey, const QDateTime* pDefault) const;
+ QString readEntryUntranslated( const QString& pKey, const QString& aDefault ) const;
+
+ void writeEntry( const QString& pKey, const QString& pValue );
+ void writePropertyEntry( const QString& pKey, const QVariant& pValue );
+ void writeListEntry( const QString& pKey, const QStringList &rValue );
+ void writeNumEntry( const QString& pKey, int nValue );
+ void writeUnsignedNumEntry( const QString& pKey, uint nValue );
+ void writeLongNumEntry( const QString& pKey, unsigned long nValue );
+ void writeDoubleNumEntry( const QString& pKey, double nValue );
+ void writeBoolEntry( const QString& pKey, bool bValue );
+ void writeFontEntry( const QString& pKey, const QFont& rFont );
+ void writeColorEntry( const QString& pKey, const QColor& rColor );
+ void writeDateTimeEntry( const QString& pKey, const QDateTime& rDateTime );
+ void writeRectEntry( const QString& pKey, const QRect& rValue );
+ void writePointEntry( const QString& pKey, const QPoint& rValue );
+ void writeSizeEntry( const QString& pKey, const QSize& rValue );
+ void writePathEntry( const QString& pKey, const QString & path );
+ void writePathListEntry( const QString& pKey, const QStringList &rValue);
+ void deleteEntry( const QString& pKey, bool bNLS , bool bGlobal );
+ bool deleteGroup( const QString& group, bool bDeep , bool bGlobal );
+
+private:
+#ifndef QT_ONLY
+ KConfig *m_config;
+#else
+ QSettings *m_config;
+ QString m_name;
+ bool m_forceGlobal;
+#endif
+};
+}
+}
+
+#endif
diff --git a/kjsembed/bindings/movie_imp.cpp b/kjsembed/bindings/movie_imp.cpp
new file mode 100644
index 00000000..8a5ced01
--- /dev/null
+++ b/kjsembed/bindings/movie_imp.cpp
@@ -0,0 +1,158 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qpixmap.h>
+#include <kjsembed/global.h>
+#include "movie_imp.h"
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+Movie::Movie( QObject *parent, const char *name ) : BindingObject(parent, name)
+{
+ movie = QMovie();
+}
+Movie::~Movie()
+{
+
+}
+QColor Movie::backgroundColor() const
+{
+ if( movie.isNull() )
+ return QColor();
+ return movie.backgroundColor();
+}
+void Movie::setBackgroundColor( const QColor &c )
+{
+ if( movie.isNull() )
+ return;
+ movie.setBackgroundColor(c);
+}
+int Movie::speed() const
+{
+ if( movie.isNull() )
+ return 0;
+ return movie.speed();
+}
+void Movie::setSpeed( int percent )
+{
+ if( movie.isNull() )
+ return;
+ movie.setSpeed(percent);
+}
+bool Movie::load( const QString &filename, int bufsize)
+{
+ movie = QMovie( filename, bufsize);
+ if ( movie.isNull() )
+ return false;
+ else
+ return true;
+}
+QRect Movie::getValidRect()
+{
+ if( movie.isNull() )
+ return QRect();
+ return movie.getValidRect();
+}
+QPixmap Movie::framePixmap()
+{
+ if( movie.isNull() )
+ return QPixmap();
+ return movie.framePixmap();
+}
+QImage Movie::frameImage()
+{
+ if( movie.isNull() )
+ return QImage();
+ return movie.frameImage();
+}
+bool Movie::isNull()
+{
+ return movie.isNull();
+}
+int Movie::frameNumber()
+{
+ if( movie.isNull() )
+ return 0;
+ return movie.frameNumber();
+}
+int Movie::steps()
+{
+ if( movie.isNull() )
+ return 0;
+ return movie.steps();
+}
+bool Movie::paused()
+{
+ if( movie.isNull() )
+ return false;
+ return movie.paused();
+}
+bool Movie::finished()
+{
+ if( movie.isNull() )
+ return false;
+ return movie.finished();
+}
+bool Movie::running()
+{
+ if( movie.isNull() )
+ return false;
+ return movie.running();
+}
+void Movie::unpause()
+{
+ if( movie.isNull() )
+ return;
+ movie.unpause();
+}
+void Movie::pause()
+{
+ if( movie.isNull() )
+ return;
+ movie.pause();
+}
+void Movie::step()
+{
+ if( movie.isNull() )
+ return;
+ movie.step();
+}
+void Movie::step( int steps )
+{
+ if( movie.isNull() )
+ return;
+ movie.step(steps);
+}
+void Movie::restart()
+{
+ if( movie.isNull() )
+ return;
+ movie.restart();
+}
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
+#ifndef QT_ONLY
+#include "movie_imp.moc"
+#endif
diff --git a/kjsembed/bindings/movie_imp.h b/kjsembed/bindings/movie_imp.h
new file mode 100644
index 00000000..2b3024e4
--- /dev/null
+++ b/kjsembed/bindings/movie_imp.h
@@ -0,0 +1,77 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_MOVIE_IMP_H
+#define KJSEMBED_MOVIE_IMP_H
+
+#include "bindingobject.h"
+#include <qmovie.h>
+#include <qimage.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * QObject Binding for QMovie.
+ *
+ * @author Ian Reinhart Geiser, geiseri@kde.org
+ * @version $Id$
+ */
+class Movie : public BindingObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY( QColor setBackgroundColor READ backgroundColor )
+ Q_PROPERTY( int setSpeed READ speed )
+
+public:
+ Movie( QObject *parent=0, const char *name=0 );
+ virtual ~Movie();
+ QColor backgroundColor() const;
+ void setBackgroundColor( const QColor &c );
+ int speed() const;
+ void setSpeed ( int percent );
+
+public slots:
+ bool load( const QString &filename, int bufsize = 1024);
+ QRect getValidRect();
+ QPixmap framePixmap();
+ QImage frameImage();
+ bool isNull();
+ int frameNumber();
+ int steps();
+ bool paused();
+ bool finished();
+ bool running();
+ void unpause();
+ void pause();
+ void step();
+ void step( int steps );
+ void restart();
+
+private:
+ QMovie movie;
+};
+
+} // namespace
+} // namespace
+
+#endif // KJSEMBED_MOVIE_IMP_H
diff --git a/kjsembed/bindings/netaccess_imp.cpp b/kjsembed/bindings/netaccess_imp.cpp
new file mode 100644
index 00000000..b2d6cce7
--- /dev/null
+++ b/kjsembed/bindings/netaccess_imp.cpp
@@ -0,0 +1,156 @@
+// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+/**
+ * netaccess_imp.cpp
+ *
+ * Copyright (C) 2003 Zack Rusin <zack@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include "netaccess_imp.h"
+
+#include <kio/netaccess.h>
+#include <kpropertiesdialog.h>
+
+#include <kurl.h>
+#include <kdebug.h>
+#include <kdeversion.h>
+#include <ktempfile.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+NetAccess::NetAccess( QObject *parent, const char *name )
+ : BindingObject( parent, name )
+{
+}
+
+NetAccess::~NetAccess()
+{
+}
+
+bool NetAccess::download( const KURL& src, const QString& loc )
+{
+ QString mloc = loc;
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::download( src, mloc, 0 );
+#else
+ return KIO::NetAccess::download( src, mloc );
+#endif
+}
+
+QString NetAccess::createTempFile( const QString& prefix, const QString& ext, uint mode )
+{
+ KTempFile tmpFile = KTempFile(prefix, ext, mode);
+ tmpFile.setAutoDelete(false);
+ return tmpFile.name();
+}
+
+void NetAccess::removeTempFile( const QString& name )
+{
+ KIO::NetAccess::removeTempFile( name );
+}
+
+bool NetAccess::upload( const QString& src, const KURL& dest )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::upload( src, dest, 0 );
+#else
+ return KIO::NetAccess::upload( src, dest );
+#endif
+}
+
+bool NetAccess::copy( const KURL& src, const KURL& target )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::copy( src, target, 0 );
+#else
+ return KIO::NetAccess::copy( src, target );
+#endif
+}
+
+bool NetAccess::dircopy( const KURL& src, const KURL& target )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::dircopy( src, target, 0 );
+#else
+ return KIO::NetAccess::dircopy( src, target );
+#endif
+}
+
+bool NetAccess::move( const KURL& src, const KURL& target )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::move( src, target, 0 );
+#else
+ kdWarning() << "NetAccess::move(src,target) is not supported on 3.1" << endl;
+ return false;
+#endif
+}
+
+bool NetAccess::exists( const KURL& url, bool source )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::exists( url, source, 0 );
+#else
+ return KIO::NetAccess::exists( url, source );
+#endif
+}
+
+bool NetAccess::del( const KURL & url )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::del( url, 0 );
+#else
+ return KIO::NetAccess::del( url );
+#endif
+}
+
+int NetAccess::propertiesDialog( const KURL &url )
+{
+ KPropertiesDialog dlg( url, 0, "file_properties", true, false );
+ return dlg.exec();
+}
+
+QString NetAccess::fish_execute( const KURL& url, const QString& command )
+{
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::fish_execute( url, command, 0 );
+#else
+ kdWarning() << "NetAccess::fish_execute(url,command) is not supported on 3.1" << endl;
+ return QString::null;
+#endif
+}
+
+QString NetAccess::mimetype( const KURL& url )
+{
+ kdDebug()<<"mimetype CALLED "<<endl;
+
+#if KDE_IS_VERSION(3,1,90)
+ return KIO::NetAccess::mimetype( url, 0 );
+#else
+ return KIO::NetAccess::mimetype( url );
+#endif
+}
+
+QString NetAccess::lastErrorString()
+{
+ return KIO::NetAccess::lastErrorString();
+}
+
+}
+}
+
+#include "netaccess_imp.moc"
diff --git a/kjsembed/bindings/netaccess_imp.h b/kjsembed/bindings/netaccess_imp.h
new file mode 100644
index 00000000..c2c01bfe
--- /dev/null
+++ b/kjsembed/bindings/netaccess_imp.h
@@ -0,0 +1,62 @@
+// -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+/**
+ * netaccess.h
+ *
+ * Copyright (C) 2003 Zack Rusin <zack@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef KJSEMBED_NETACCESS_IMP_H
+#define KJSEMBED_NETACCESS_IMP_H
+
+#include <qstring.h>
+#include "bindingobject.h"
+
+class KURL;
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * Provides a binding to KIO::NetAccess.
+ */
+class NetAccess : public BindingObject
+{
+ Q_OBJECT
+public:
+ NetAccess( QObject *parent, const char *name=0 );
+ virtual ~NetAccess();
+public slots:
+ bool download( const KURL& src, const QString & loc );
+ QString createTempFile(const QString& prefix, const QString& ext, uint mode );
+ void removeTempFile( const QString& name );
+ bool upload( const QString& src, const KURL& dest );
+ bool copy( const KURL& src, const KURL& target );
+ bool dircopy( const KURL& src, const KURL& target );
+ bool move( const KURL& src, const KURL& target );
+ bool exists( const KURL& url, bool source );
+ bool del( const KURL& url );
+ int propertiesDialog( const KURL &url );
+
+ QString fish_execute( const KURL& url, const QString& command );
+ QString mimetype( const KURL& url );
+ QString lastErrorString();
+};
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif
diff --git a/kjsembed/bindings/painter_imp.cpp b/kjsembed/bindings/painter_imp.cpp
new file mode 100644
index 00000000..8fa77de0
--- /dev/null
+++ b/kjsembed/bindings/painter_imp.cpp
@@ -0,0 +1,521 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qimage.h>
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsobjectproxy.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <qfont.h>
+#include <kjsembed/global.h>
+
+#include "painter_imp.h"
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ KJS::Object PainterLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const
+ {
+ PainterRef * p = new PainterRef();
+ /*
+ QWidget *w = extractQWidget(exec, args, 0);
+ QPixmap pix = extractQPixmap(exec, args, 0);
+ if( w )
+ {
+ p->setDevice(w);
+ p->setCanDelete(false);
+ }
+ else if( !pix.isNull() )
+ p->setDevice( new QPixmap(pix) );
+ */
+ JSOpaqueProxy *prx = new JSOpaqueProxy( p, "Painter" );
+ prx->setOwner( JSProxy::JavaScript );
+ KJS::Object proxyObj( prx );
+ Painter::addBindings( exec, proxyObj );
+ return proxyObj;
+ }
+
+ void PainterLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const
+ {
+ Painter::addBindings( exec, proxy );
+ }
+
+PainterRef::PainterRef()
+{
+ m_device = 0L;
+ m_painter = new QPainter;
+ m_canDelete = true;
+}
+PainterRef::~PainterRef()
+{
+ kdDebug() << "Painter ref going away..." << endl;
+ if( m_device && m_canDelete)
+ delete m_device;
+ delete m_painter;
+}
+
+QPainter *PainterRef::painter()
+{
+ return m_painter;
+}
+
+QPaintDevice *PainterRef::device()
+{
+ return m_device;
+}
+
+void PainterRef::setDevice(QPaintDevice *d)
+{
+ if( m_device && m_canDelete)
+ {
+ delete m_device;
+ m_device = 0L;
+ }
+ m_device = d;
+
+}
+
+void Painter::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::OpaqueProxy, "Painter") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodbegin, "begin" },
+ { Methodend, "end" },
+ { Methodpixmap, "pixmap" },
+ { MethodsetPixmap, "setPixmap" },
+ { MethodsetPen, "setPen" },
+ { Methodpen, "pen" },
+ { MethodtextBox, "textBox" },
+ { MethodmoveTo, "moveTo" },
+ { MethodlineTo, "lineTo" },
+ { MethoddrawPoint, "drawPoint" },
+ { MethoddrawLine, "drawLine" },
+ { MethoddrawRect, "drawRect" },
+ { MethoddrawRoundRect, "drawRoundRect" },
+ { MethoddrawEllipse, "drawEllipse" },
+ { MethoddrawText, "drawText" },
+ { MethoddrawArc, "drawArc" },
+ { MethoddrawPie, "drawPie" },
+ { MethoddrawPixmap, "drawPixmap" },
+ { MethoddrawImage, "drawImage" },
+ { MethoddrawTiledPixmap, "drawTiledPixmap" },
+ { Methodscale, "scale" },
+ { Methodshear, "shear" },
+ { Methodrotate, "rotate" },
+ { Methodtranslate, "translate" },
+ { MethodsetFont, "setFont" },
+ { Methodfont, "font" },
+ { MethodsetBrush, "setBrush" },
+ { Methodbrush, "brush" },
+ { MethodbackgroundColor, "backgroundColor" },
+ { MethodsetBackgroundColor, "setBackgroundColor" },
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<Painter>(exec, methods, object );
+
+}
+
+KJS::Value Painter::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::OpaqueProxy, "Painter") ) return KJS::Boolean(false);
+
+ KJS::Value retValue = KJS::Boolean(false);
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+
+ pr = op->toNative<PainterRef>();
+
+ switch ( mid ) {
+ case Methodbegin:
+ {
+ if ( args.size() == 1 ) {
+ JSObjectProxy *objp = JSProxy::toObjectProxy(args[0].imp() );
+ JSValueProxy *vp = JSProxy::toValueProxy(args[0].imp() );
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy(args[0].imp() );
+ if ( objp )
+ {
+ if( objp->widget() )
+ {
+ pr->setDevice( objp->widget() );
+ pr->setCanDelete(false);
+ retValue = KJS::Boolean( begin() );
+ }
+ else
+ {
+ QString msg = i18n( "Paintdevice was not a valid widget." );
+ throwError(exec,msg);
+ retValue = KJS::Boolean(false);
+ }
+ }
+ else if ( vp )
+ {
+ QPixmap *p = new QPixmap(vp->toVariant().toPixmap());
+ if( p->isNull() )
+ {
+ QString msg = i18n( "Cannto paint to a null pixmap." ).arg( op->typeName() );
+ throwError(exec,msg);
+ retValue = KJS::Boolean(false);
+ }
+ else
+ {
+ pr->setDevice( p );
+ pr->setCanDelete(true);
+ retValue = KJS::Boolean( begin() );
+ }
+ }
+ else if ( op && op->typeName() == "QPaintDevice" )
+ {
+ pr->setDevice( op->toNative<QPaintDevice>() );
+ pr->setCanDelete(false);
+ retValue = KJS::Boolean( begin() );
+ }
+ else
+ {
+ QString msg = i18n( "Paintdevice of type '%1' is not supported." ).arg( op->typeName() );
+ throwError(exec,msg);
+ retValue = KJS::Boolean(false);
+ }
+ }
+ else
+ {
+ QString msg = i18n( "Incorrect number of arguements '%1'." ).arg( args.size() );
+ throwError(exec,msg);
+ retValue = KJS::Boolean(false);
+ }
+ break;
+ }
+ case Methodend:
+ retValue = KJS::Boolean( end() );
+ break;
+ case Methodpixmap:
+ {
+ retValue = convertToValue(exec, pixmap());
+ break;
+ }
+ case MethodsetPixmap:
+ break;
+ case MethodsetPen:
+ {
+ QPen pn = extractQPen(exec, args, 0);
+ setPen(pn);
+ break;
+ }
+ case Methodpen:
+ {
+ retValue = convertToValue(exec, pen());
+ break;
+ }
+ case MethodtextBox:
+ {
+ retValue = convertToValue(exec, textBox(extractQString(exec, args, 0)));
+ break;
+ }
+ case MethodmoveTo:
+ {
+ moveTo(extractInt(exec, args, 0), extractInt(exec, args, 1));
+ break;
+ }
+ case MethodlineTo:
+ {
+ lineTo(extractInt(exec, args, 0), extractInt(exec, args, 1));
+ break;
+ }
+ case MethoddrawPoint:
+ {
+ drawPoint(extractInt(exec, args, 0), extractInt(exec, args, 1));
+ break;
+ }
+ case MethoddrawLine:
+ {
+ drawLine(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3));
+ break;
+ }
+ case MethoddrawRect:
+ {
+ drawRect(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3));
+ break;
+ }
+ case MethoddrawRoundRect:
+ {
+ drawRoundRect(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3),extractInt(exec, args, 4), extractInt(exec, args, 5));
+ break;
+ }
+ case MethoddrawEllipse:
+ {
+ drawEllipse(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3));
+ break;
+ }
+ case MethoddrawText:
+ {
+ drawText(extractInt(exec, args, 0), extractInt(exec, args, 1), extractQString(exec, args, 2));
+ break;
+ }
+ case MethoddrawArc:
+ {
+ drawArc(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3),extractInt(exec, args, 4), extractInt(exec, args, 5));
+ break;
+ }
+ case MethoddrawPie:
+ {
+ drawPie(extractInt(exec, args, 0), extractInt(exec, args, 1),extractInt(exec, args, 2), extractInt(exec, args, 3),extractInt(exec, args, 4), extractInt(exec, args, 5));
+ break;
+ }
+ case MethoddrawPixmap:
+ {
+ drawPixmap(extractInt(exec, args, 0), extractInt(exec, args, 1), extractQPixmap(exec, args, 2), extractInt(exec, args, 3), extractInt(exec, args, 4), extractInt(exec, args, 5), extractInt(exec, args, 6));
+ break;
+ }
+ case MethoddrawImage:
+ {
+ drawImage( extractInt(exec, args, 0), extractInt(exec, args, 1), extractQImage(exec, args, 2), extractInt(exec, args, 3), extractInt(exec, args, 4), extractInt(exec, args, 5), extractInt(exec, args, 6), extractInt(exec, args, 7) );
+ break;
+ }
+ case MethoddrawTiledPixmap:
+ {
+ drawTiledPixmap(extractInt(exec, args, 0), extractInt(exec, args, 1), extractInt(exec, args, 2), extractInt(exec, args, 3), extractQPixmap(exec, args, 4), extractInt(exec, args, 5), extractInt(exec, args, 6));
+ break;
+ }
+ case Methodscale:
+ {
+ scale(extractDouble(exec, args, 0), extractDouble(exec, args, 1));
+ break;
+ }
+ case Methodshear:
+ {
+ shear(extractDouble(exec, args, 0), extractDouble(exec, args, 1));
+ break;
+ }
+ case Methodrotate:
+ {
+ rotate(extractDouble(exec, args, 0));
+ break;
+ }
+ case Methodtranslate:
+ {
+ translate(extractDouble(exec, args, 0), extractDouble(exec, args, 1));
+ break;
+ }
+ case MethodsetFont:
+ {
+ setFont(extractQFont(exec, args, 0));
+ break;
+ }
+ case Methodfont:
+ {
+ retValue = convertToValue(exec, font());
+ break;
+ }
+ case MethodsetBrush:
+ {
+ pr->painter()->setBrush(extractQBrush(exec, args, 0));
+ break;
+ }
+ case Methodbrush:
+ {
+ retValue = convertToValue(exec, brush());
+ break;
+ }
+ case MethodbackgroundColor:
+ {
+ retValue = convertToValue(exec, backgroundColor());
+ break;
+ }
+ case MethodsetBackgroundColor:
+ {
+ setBackgroundColor(extractQColor(exec, args, 0));
+ break;
+ }
+ default:
+ kdWarning() << "Painter has no method " << mid << endl;
+ break;
+ }
+
+ //op->setValue(pr, "Painter");
+ return retValue;
+}
+
+Painter::Painter( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id), pr(0)
+{
+}
+
+Painter::~Painter()
+{
+}
+
+bool Painter::begin()
+{
+ return pr->painter()->begin(pr->device());
+}
+bool Painter::begin(QPaintDevice *dev)
+{
+ return pr->painter()->begin(dev);
+}
+
+bool Painter::end()
+{
+ return pr->painter()->end();
+}
+
+QPixmap Painter::pixmap() const
+{
+ QPixmap *pix = dynamic_cast<QPixmap *>(pr->device());
+ if( pix )
+ {
+ return *pix;
+ }
+ return QPixmap();
+}
+
+void Painter::setPen( const QPen& pn )
+{
+ pr->painter()->setPen(pn);
+}
+
+QPen Painter::pen() const
+{
+ return pr->painter()->pen();
+}
+
+QRect Painter::textBox(const QString &text)
+{
+ QFontMetrics fnt = pr->painter()->fontMetrics();
+ return fnt.boundingRect(text);
+}
+
+void Painter::moveTo( int x, int y )
+{
+ pr->painter()->moveTo( x, y );
+}
+
+void Painter::lineTo( int x, int y )
+{
+ pr->painter()->lineTo( x, y );
+}
+
+void Painter::drawPoint( int x, int y )
+{
+ pr->painter()->drawPoint( x, y );
+}
+
+void Painter::drawLine( int x1, int y1, int x2, int y2 )
+{
+ pr->painter()->drawLine( x1, y1, x2, y2 );
+}
+
+void Painter::drawRect( int x, int y, int w, int h )
+{
+ pr->painter()->drawRect( x, y, w, h );
+}
+
+void Painter::drawRoundRect( int x, int y, int w, int h, int xrnd, int yrnd )
+{
+ pr->painter()->drawRoundRect( x, y, w, h, xrnd, yrnd );
+}
+
+void Painter::drawEllipse( int x, int y, int w, int h )
+{
+ pr->painter()->drawEllipse( x, y, w, h );
+}
+
+void Painter::drawText( int x, int y, const QString &txt )
+{
+ pr->painter()->drawText( x, y, txt );
+}
+
+void Painter::drawArc ( int x, int y, int w, int h, int a, int alen )
+{
+ pr->painter()->drawArc( x, y, w, h, a, alen );
+}
+void Painter::drawPie ( int x, int y, int w, int h, int a, int alen )
+{
+ pr->painter()->drawPie( x, y, w, h, a, alen);
+}
+void Painter::drawPixmap ( int x, int y, const QPixmap & pixmap, int sx, int sy, int sw, int sh )
+{
+ pr->painter()->drawPixmap( x, y, pixmap, sx, sy, sw, sh );
+}
+void Painter::drawImage ( int x, int y, const QImage &image, int sx , int sy, int sw , int sh, int conversionFlags)
+{
+ pr->painter()->drawImage( x, y, image, sx, sy, sw, sh, conversionFlags );
+}
+void Painter::drawTiledPixmap ( int x, int y, int w, int h, const QPixmap & pixmap, int sx, int sy )
+{
+ pr->painter()->drawTiledPixmap( x, y, w, h, pixmap, sx, sy );
+}
+
+void Painter::scale ( double sx, double sy )
+{
+ pr->painter()->scale( sx,sy );
+}
+void Painter::shear ( double sh, double sv )
+{
+ pr->painter()->shear( sh, sv );
+}
+void Painter::rotate ( double a )
+{
+ pr->painter()->rotate( a );
+}
+void Painter::translate ( double dx, double dy )
+{
+ pr->painter()->translate( dx, dy );
+}
+
+void KJSEmbed::Bindings::Painter::setFont( const QFont & font )
+{
+ pr->painter()->setFont(font);
+}
+
+QFont KJSEmbed::Bindings::Painter::font( ) const
+{
+ return pr->painter()->font();
+}
+
+QColor KJSEmbed::Bindings::Painter::backgroundColor( ) const
+{
+ return pr->painter()->backgroundColor();
+}
+
+void KJSEmbed::Bindings::Painter::setBackgroundColor( const QColor & color )
+{
+ pr->painter()->setBackgroundColor(color);
+}
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+
+void KJSEmbed::Bindings::Painter::setBrush( const QColor & brush )
+{
+ pr->painter()->setBrush(brush);
+}
+
+QColor KJSEmbed::Bindings::Painter::brush( ) const
+{
+ return pr->painter()->brush().color();
+}
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/bindings/painter_imp.h b/kjsembed/bindings/painter_imp.h
new file mode 100644
index 00000000..0660a7ba
--- /dev/null
+++ b/kjsembed/bindings/painter_imp.h
@@ -0,0 +1,127 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_PAINTER_IMP_H
+#define KJSEMBED_PAINTER_IMP_H
+
+#include <kjsembed/jsbindingbase.h>
+#include <kjsembed/jsproxy_imp.h>
+#include <qpen.h>
+#include <qpainter.h>
+
+class QPixmap;
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ class PainterLoader : public JSBindingBase
+ {
+ public:
+ KJS::Object createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const;
+ void addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy) const;
+ };
+
+
+class PainterRef
+{
+ public:
+ PainterRef();
+ ~PainterRef();
+
+ QPainter *painter();
+
+ QPaintDevice *device();
+ void setDevice(QPaintDevice *d);
+
+ void setCanDelete(bool can ) {m_canDelete = can;}
+ bool canDelete() const { return m_canDelete;}
+
+ private:
+ QPainter *m_painter;
+ QPaintDevice *m_device;
+ bool m_canDelete;
+};
+
+/**
+ * JSProxyImp binding for painting on a QPixmap.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+
+class Painter : public JSProxyImp
+{
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId {Methodbegin, Methodend, Methodpixmap, MethodsetPixmap, MethodsetPen, Methodpen, MethodtextBox, MethodmoveTo, MethodlineTo, MethoddrawPoint, MethoddrawLine, MethoddrawRect, MethoddrawRoundRect, MethoddrawEllipse, MethoddrawText, MethoddrawArc, MethoddrawPie, MethoddrawPixmap, MethoddrawImage, MethoddrawTiledPixmap, Methodscale, Methodshear, Methodrotate, Methodtranslate, MethodsetFont, Methodfont, MethodsetBrush, Methodbrush, MethodbackgroundColor, MethodsetBackgroundColor};
+public:
+ Painter( KJS::ExecState *exec, int id );
+ virtual ~Painter();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+private:
+
+ bool begin();
+ bool begin(QPaintDevice *dev);
+ bool end();
+ QPixmap pixmap() const;
+ void setPen( const QPen& pn);
+ QPen pen() const;
+ QRect textBox(const QString &text);
+ void moveTo( int x, int y );
+ void lineTo( int x, int y );
+ void drawPoint( int x, int y );
+ void drawLine( int x1, int y1, int x2, int y2 );
+ void drawRect( int x, int y, int w, int h );
+ void drawRoundRect( int x, int y, int w, int h, int, int);
+ void drawEllipse( int x, int y, int w, int h );
+ void drawText( int x, int y, const QString &txt );
+ void drawArc( int x, int y, int w, int h, int a, int alen );
+ void drawPie( int x, int y, int w, int h, int a, int alen );
+ void drawPixmap ( int x, int y, const QPixmap &pixmap, int sx, int sy, int sw, int sh );
+ void drawImage ( int x, int y, const QImage &image, int sx, int sy, int sw, int sh, int conversionFlags );
+ void drawTiledPixmap ( int x, int y, int w, int h, const QPixmap &pixmap, int sx, int sy);
+ void scale ( double sx, double sy );
+ void shear ( double sh, double sv );
+ void rotate ( double a );
+ void translate ( double dx, double dy );
+ void setFont( const QFont &font);
+ QFont font() const;
+ void setBrush( const QColor &brush );
+ QColor brush() const;
+ QColor backgroundColor() const;
+ void setBackgroundColor(const QColor &color);
+
+private:
+ int mid;
+ PainterRef *pr; // temps now
+
+};
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_PAINTER_IMP_H
+
diff --git a/kjsembed/bindings/pen_imp.cpp b/kjsembed/bindings/pen_imp.cpp
new file mode 100644
index 00000000..67ada965
--- /dev/null
+++ b/kjsembed/bindings/pen_imp.cpp
@@ -0,0 +1,127 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <kjsembed/global.h>
+#include <qpen.h>
+#include "pen_imp.h"
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+Pen::Pen( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+Pen::~Pen()
+{
+}
+void Pen::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QPen") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodwidth, "width"},
+ { MethodsetWidth, "setWidth"},
+ { MethodColor, "color"},
+ { MethodsetColor, "setColor"},
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<Pen>(exec, methods, object );
+
+ JSProxy::EnumTable enums[] = {
+ // PenStyle
+ { "NoPen", 0 },
+ { "SolidLine", 1 },
+ { "DashLine", 2 },
+ { "DotLine", 3 },
+ { "DashDotLine", 4 },
+ { "DashDotDotLine", 5 },
+ { "MPenStyle", 6 },
+ // Pen Join Style
+ { "MiterJoin", 7 },
+ { "BevelJoin", 8 },
+ { "RoundJoin", 9 },
+ { "MPenJoinStyle", 10 },
+ // Pen Cap Style
+ { "FlatCap", 11},
+ { "SquareCap", 12 },
+ { "RoundCap", 13 },
+ { "MPenCapStyle", 14},
+
+ { 0, 0 }
+ };
+
+ JSProxy::addEnums(exec, enums, object);
+}
+
+KJS::Value Pen::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QPen") ) return KJS::Value();
+ JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
+ QPen pen = op->toVariant().toPen();
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case Methodwidth:
+ {
+ return KJS::Number((int) pen.width() );
+ break;
+ }
+ case MethodsetWidth:
+ {
+ uint w = extractUInt(exec, args, 0);
+ pen.setWidth(w);
+ break;
+ }
+ case MethodColor:
+ {
+ return convertToValue(exec, pen.color());
+ break;
+ }
+ case MethodsetColor:
+ {
+ QColor color = extractQColor(exec, args, 0);
+ pen.setColor(color);
+ break;
+ }
+ default:
+ kdWarning() << "Pen has no method " << mid << endl;
+ break;
+ }
+
+ op->setValue(pen);
+ return retValue;
+}
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/bindings/pen_imp.h b/kjsembed/bindings/pen_imp.h
new file mode 100644
index 00000000..2068a6a5
--- /dev/null
+++ b/kjsembed/bindings/pen_imp.h
@@ -0,0 +1,57 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_PEN_IMP_H
+#define KJSEMBED_PEN_IMP_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+class Pen : public JSProxyImp
+{
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { Methodwidth, MethodsetWidth, MethodColor, MethodsetColor };
+public:
+ Pen( KJS::ExecState *exec, int id );
+ virtual ~Pen();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+private:
+ int mid;
+};
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_PEN_IMP_H
+
diff --git a/kjsembed/bindings/pixmap_imp.cpp b/kjsembed/bindings/pixmap_imp.cpp
new file mode 100644
index 00000000..68e93658
--- /dev/null
+++ b/kjsembed/bindings/pixmap_imp.cpp
@@ -0,0 +1,180 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <qpixmap.h>
+#include <qbitmap.h>
+
+#include <kjsembed/global.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <qvariant.h>
+
+#include "pixmap_imp.h"
+
+namespace KJSEmbed {
+namespace Bindings {
+
+Pixmap::Pixmap( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+Pixmap::~Pixmap()
+{
+}
+
+void Pixmap::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType( object, JSProxy::ValueProxy, "QPixmap") )
+ return;
+
+ JSProxy::MethodTable methods[] = {
+ { MethodisNull, "isNull" },
+ { Methodwidth, "width" },
+ { Methodheight, "height" },
+ { Methodsize, "size" },
+ { Methodrect, "rect" },
+ { Methoddepth, "depth" },
+ { Methodresize, "resize" },
+ { Methodfill, "fill" },
+ { Methodmask, "mask" },
+ { MethodsetMask, "setMask" },
+ { MethodcreateHeuristicMask, "createHeuristicMask" },
+ { MethodgrabWindow, "grabWindow" },
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<Pixmap>(exec, methods, object);
+
+}
+
+KJS::Value Pixmap::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+
+ if( !JSProxy::checkType( self, JSProxy::ValueProxy, "QPixmap") )
+ return KJS::Value();
+
+ JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
+ pix = op->toVariant().toPixmap();
+
+ KJS::Value retValue = KJS::Value();
+ switch ( mid ) {
+ case Methodwidth:
+ retValue = KJS::Number(width());
+ break;
+ case Methodheight:
+ retValue = KJS::Number(height());
+ break;
+ case Methoddepth:
+ retValue = KJS::Number(depth());
+ break;
+ case MethodisNull:
+ retValue = KJS::Boolean(isNull());
+ break;
+ case Methodsize:
+ retValue = convertToValue(exec, size());
+ break;
+ case Methodrect:
+ retValue = convertToValue(exec, rect());
+ break;
+ case Methodresize:
+ {
+ if( args.size() == 2)
+ resize(extractInt(exec, args, 0), extractInt(exec, args, 1));
+ else if( args.size() == 1)
+ resize(extractQSize(exec, args, 0) );
+ break;
+ }
+ case Methodfill:
+ fill( extractQColor(exec, args, 0));
+ break;
+ case Methodmask:
+ {
+ retValue = convertToValue(exec, mask() );
+ break;
+ }
+ case MethodsetMask:
+ {
+ setMask(extractQPixmap(exec, args, 0));
+ break;
+ }
+ case MethodcreateHeuristicMask:
+ {
+ retValue = convertToValue(exec, createHeuristicMask(extractBool(exec, args, 0)));
+ break;
+ }
+ case MethodgrabWindow:
+ {
+ int winid = extractInt(exec, args,0);
+ int x = extractInt(exec, args,1);
+ int y = extractInt(exec, args,2);
+ int w = extractInt(exec, args,3);
+ int h = extractInt(exec, args,4);
+ grabWindow(winid,x,y,w,h);
+ break;
+ }
+ default:
+ kdWarning() << "Image has no method " << mid << endl;
+ break;
+ }
+
+ op->setValue(pix);
+ return retValue;
+}
+
+void Pixmap::resize( int w, int h )
+{
+ pix.resize( w, h );
+}
+
+void Pixmap::resize( const QSize &size )
+{
+ pix.resize( size );
+}
+
+void Pixmap::fill( const QColor &c )
+{
+ pix.fill( c );
+}
+
+void Pixmap::grabWindow(int winID, int x, int y, int w, int h)
+{
+ pix = QPixmap::grabWindow((WId)winID, x, y, w, h);
+}
+
+QPixmap Pixmap::mask()
+{
+ return *(pix.mask());
+}
+void Pixmap::setMask(const QPixmap& mask)
+{
+ QBitmap bm;
+ bm = mask;
+ pix.setMask(bm);
+}
+
+QPixmap Pixmap::createHeuristicMask ( bool clipTight )
+{
+ return (QPixmap)pix.createHeuristicMask(clipTight);
+}
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
diff --git a/kjsembed/bindings/pixmap_imp.h b/kjsembed/bindings/pixmap_imp.h
new file mode 100644
index 00000000..994c2699
--- /dev/null
+++ b/kjsembed/bindings/pixmap_imp.h
@@ -0,0 +1,87 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Richard J. Moore <rich@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_PIXMAP_IMP_H
+#define KJSEMBED_PIXMAP_IMP_H
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+#include <qpixmap.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * QObject Binding for QPixmap.
+ *
+ * @author Richard Moore, rich@kde.org
+ * @version $Id$
+ */
+class Pixmap : public JSProxyImp
+{
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { MethodisNull, Methodwidth, Methodheight, Methodsize, Methodrect, Methoddepth, Methodresize, Methodfill, Methodmask, MethodsetMask, MethodcreateHeuristicMask, MethodgrabWindow };
+
+public:
+ Pixmap( KJS::ExecState *exec, int id );
+ virtual ~Pixmap();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+
+private:
+ bool isNull() const { return pix.isNull(); }
+
+ int width() const { return pix.width(); }
+ int height() const { return pix.height(); }
+ QSize size() const { return pix.size(); }
+ QRect rect() const { return pix.rect(); }
+
+ int depth() const { return pix.depth(); }
+
+ void resize( int w, int h );
+ void resize( const QSize &size );
+ void fill( const QColor &color );
+
+ QPixmap mask();
+ void setMask(const QPixmap& mask);
+ QPixmap createHeuristicMask ( bool clipTight );
+
+ // Image Capture
+ void grabWindow(int winID, int x =0, int y = 0, int w = -1, int h = -1);
+
+private:
+ int mid;
+ QPixmap pix;
+};
+
+} // namespace
+} // namespace
+
+#endif // KJSEMBED_PIXMAP_IMP_H
diff --git a/kjsembed/bindings/point_imp.cpp b/kjsembed/bindings/point_imp.cpp
new file mode 100644
index 00000000..9eeb5c6a
--- /dev/null
+++ b/kjsembed/bindings/point_imp.cpp
@@ -0,0 +1,92 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include "point_imp.h"
+#include <qpoint.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ Point::Point( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+ {
+ }
+
+ Point::~Point()
+ {
+ }
+ void Point::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QPoint") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodx, "x"},
+ { MethodsetX, "setX"},
+ { Methody, "y"},
+ { MethodsetY, "setY"},
+ { MethodmanhattanLength, "manhattanLength"},
+ { 0, 0 }
+ };
+ JSProxy::addMethods<Point>(exec, methods, object);
+
+ }
+
+ KJS::Value Point::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QPoint") ) return KJS::Value();
+ JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
+ KJS::Value retValue = KJS::Value();
+ QPoint val = vp->toVariant().toPoint();
+
+ switch ( mid ) {
+ case Methodx:
+ retValue = KJS::Number(val.x());
+ break;
+ case MethodsetX:
+ val.setX(extractInt(exec,args,0));
+ break;
+ case Methody:
+ retValue = KJS::Number(val.y());
+ break;
+ case MethodsetY:
+ val.setY(extractInt(exec,args,0));
+ break;
+ case MethodmanhattanLength:
+ retValue = KJS::Number(val.manhattanLength());
+ break;
+ default:
+ QString msg = i18n( "Point has no method %1" ).arg(mid);
+ return throwError(exec, msg);
+ break;
+ }
+
+ vp->setValue(val);
+ return retValue;
+ }
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/bindings/point_imp.h b/kjsembed/bindings/point_imp.h
new file mode 100644
index 00000000..950cce7d
--- /dev/null
+++ b/kjsembed/bindings/point_imp.h
@@ -0,0 +1,56 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_POINT_IMP_H
+#define KJSEMBED_POINT_IMP_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ class Point : public JSProxyImp
+ {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { Methodx, MethodsetX, Methody, MethodsetY, MethodmanhattanLength };
+ public:
+ Point( KJS::ExecState *exec, int id );
+ virtual ~Point();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+ private:
+ int mid;
+ };
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_POINT_IMP_H
diff --git a/kjsembed/bindings/rect_imp.cpp b/kjsembed/bindings/rect_imp.cpp
new file mode 100644
index 00000000..82b5268b
--- /dev/null
+++ b/kjsembed/bindings/rect_imp.cpp
@@ -0,0 +1,111 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include "rect_imp.h"
+#include <qrect.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ Rect::Rect( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+ {
+ }
+
+ Rect::~Rect()
+ {
+ }
+ void Rect::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QRect") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodx, "x" },
+ { MethodsetX, "setX" },
+ { Methody, "y" },
+ { MethodsetY, "setY" },
+ { Methodheight, "height" },
+ { MethodsetHeight, "setHeight" },
+ { Methodwidth, "width" },
+ { MethodsetWidth,"setWidth" },
+ { Methodcontains,"contains" },
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<Rect>(exec, methods, object );
+
+ }
+
+ KJS::Value Rect::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QRect") ) return KJS::Value();
+
+ KJS::Value retValue = KJS::Value();
+ JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
+
+ QRect val = vp->toVariant().toRect();
+
+ switch ( mid ) {
+ case Methodx:
+ retValue = KJS::Number(val.x());
+ break;
+ case MethodsetX:
+ val.setX(extractInt(exec, args, 0));
+ break;
+ case Methody:
+ retValue = KJS::Number(val.y());
+ break;
+ case MethodsetY:
+ val.setY(extractInt(exec, args, 0));
+ break;
+ case Methodheight:
+ retValue = KJS::Number(val.height());
+ break;
+ case MethodsetHeight:
+ val.setHeight(extractInt(exec, args, 0));
+ break;
+ case Methodwidth:
+ retValue = KJS::Number(val.width());
+ break;
+ case MethodsetWidth:
+ val.setWidth(extractInt(exec, args, 0));
+ break;
+ case Methodcontains:
+ retValue = convertToValue( exec, val.contains( extractQRect(exec, args, 0), extractBool(exec, args, 1)) );
+ break;
+ default:
+ QString msg = i18n( "Rect has no method %1" ).arg(mid);
+ return throwError(exec, msg);
+ break;
+ }
+
+ vp->setValue(val);
+ return retValue;
+ }
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/bindings/rect_imp.h b/kjsembed/bindings/rect_imp.h
new file mode 100644
index 00000000..16910e4e
--- /dev/null
+++ b/kjsembed/bindings/rect_imp.h
@@ -0,0 +1,56 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_RECT_IMP_H
+#define KJSEMBED_RECT_IMP_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ class Rect : public JSProxyImp
+ {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { Methodx, MethodsetX, Methody, MethodsetY, Methodheight, MethodsetHeight, Methodwidth, MethodsetWidth, Methodcontains };
+ public:
+ Rect( KJS::ExecState *exec, int id );
+ virtual ~Rect();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+ private:
+ int mid;
+ };
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_RECT_IMP_H
diff --git a/kjsembed/bindings/size_imp.cpp b/kjsembed/bindings/size_imp.cpp
new file mode 100644
index 00000000..09c01427
--- /dev/null
+++ b/kjsembed/bindings/size_imp.cpp
@@ -0,0 +1,133 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include "size_imp.h"
+#include <qsize.h>
+#include <kjsembed/jsvalueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+Size::Size( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+Size::~Size()
+{
+}
+void Size::addBindings( KJS::ExecState *exec, KJS::Object &object ) {
+
+ if( !JSProxy::checkType(object, JSProxy::ValueProxy, "QSize") ) return;
+
+ JSProxy::MethodTable methods[] = {
+ { Methodwidth, "width"},
+ { MethodsetWidth, "setWidth"},
+ { MethodHeight, "height"},
+ { MethodsetHeight, "setHeight"},
+ { Methodscale, "scale"},
+ { Methodtranspose, "transpose"},
+ { MethodexpandedTo, "expandedTo"},
+ { MethodboundedTo, "boundedTo"},
+ { 0, 0 }
+ };
+
+ JSProxy::addMethods<Size>(exec, methods, object );
+ //
+ // Define the enum constants
+ //
+
+ JSProxy::EnumTable enums[] = {
+ { "ScaleFree", (int)QSize::ScaleFree },
+ { "ScaleMin", (int)QSize::ScaleMin },
+ { "ScaleMax", (int)QSize::ScaleMax },
+ { 0, 0 }
+ };
+
+ JSProxy::addEnums(exec, enums, object);
+}
+
+KJS::Value Size::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {
+ if( !JSProxy::checkType(self, JSProxy::ValueProxy, "QSize") ) return KJS::Value();
+ KJS::Value retValue = KJS::Value();
+ JSValueProxy *vp = JSProxy::toValueProxy( self.imp() );
+ QSize val = vp->toVariant().toSize();
+
+ switch ( mid ) {
+ case Methodwidth:
+ retValue = KJS::Number(val.width());
+ break;
+ case MethodsetWidth:
+ val.setWidth(extractInt(exec,args,0));
+ break;
+ case MethodHeight:
+ retValue = KJS::Number(val.height());
+ break;
+ case MethodsetHeight:
+ val.setHeight(extractInt(exec,args,0));
+ break;
+ case Methodscale:
+ {
+ if( args.size() == 2 ) {
+ QSize sz = extractQSize(exec, args, 0);
+ int mode = extractInt(exec, args, 1);
+ val.scale(sz, (QSize::ScaleMode)mode);
+ } else {
+ int x = extractInt(exec, args, 0);
+ int y = extractInt(exec, args, 1);
+ int mode = extractInt(exec, args, 2);
+ val.scale(x,y, (QSize::ScaleMode)mode);
+ }
+ break;
+ }
+ case Methodtranspose:
+ val.transpose();
+ break;
+ case MethodexpandedTo:
+ {
+ QSize sz = extractQSize(exec, args, 0);
+ retValue = convertToValue( exec, val.expandedTo(sz) );
+ break;
+ }
+ case MethodboundedTo:
+ {
+ QSize sz = extractQSize(exec, args, 0);
+ retValue = convertToValue( exec, val.boundedTo(sz) );
+ break;
+ }
+ default:
+ QString msg = i18n( "Size has no method %1" ).arg(mid);
+ return throwError(exec, msg);
+ break;
+ }
+
+ vp->setValue(val);
+ return retValue;
+}
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/bindings/size_imp.h b/kjsembed/bindings/size_imp.h
new file mode 100644
index 00000000..9a1fb4eb
--- /dev/null
+++ b/kjsembed/bindings/size_imp.h
@@ -0,0 +1,56 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2004 Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_SIZE_IMP_H
+#define KJSEMBED_SIZE_IMP_H
+
+#include <kjsembed/jsproxy_imp.h>
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+ class Size : public JSProxyImp
+ {
+
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId { Methodwidth, MethodsetWidth, MethodHeight, MethodsetHeight, Methodscale, Methodtranspose, MethodexpandedTo, MethodboundedTo };
+ public:
+ Size( KJS::ExecState *exec, int id );
+ virtual ~Size();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return true; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+
+ private:
+ int mid;
+ };
+
+} // namespace Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_SIZE_IMP_H
diff --git a/kjsembed/bindings/sql_imp.cpp b/kjsembed/bindings/sql_imp.cpp
new file mode 100644
index 00000000..31c7f53c
--- /dev/null
+++ b/kjsembed/bindings/sql_imp.cpp
@@ -0,0 +1,310 @@
+// -*- c++ -*-
+
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <kjsembed/global.h>
+#include <qsqldatabase.h>
+#include <qsqlquery.h>
+#include <qsqlerror.h>
+#include "sql_imp.h"
+
+
+
+namespace KJSEmbed {
+namespace Bindings {
+
+SqlDatabase::SqlDatabase( QObject *parent, const char *name): BindingObject(parent, name)
+{
+ connectionName = "defaultConnection";
+ setJSClassName( "SqlDatabase" );
+}
+SqlDatabase::~SqlDatabase()
+{
+ QSqlDatabase::removeDatabase(connectionName);
+}
+bool SqlDatabase::addDatabase ( const QString &type, const QString &conn )
+{
+ connectionName = conn;
+ QSqlDatabase *db = QSqlDatabase::addDatabase(type, connectionName);
+ if ( !db )
+ return false;
+ return true;
+}
+QStringList SqlDatabase::drivers ()
+{
+ return QSqlDatabase::drivers();
+}
+bool SqlDatabase::open ( )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->open();
+ return false;
+}
+bool SqlDatabase::open ( const QString &user, const QString &password )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->open(user, password);
+ return false;
+}
+void SqlDatabase::close ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ {
+ db->close();
+ }
+}
+bool SqlDatabase::isOpen ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->isOpen();
+ return false;
+}
+bool SqlDatabase::isOpenError ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->isOpenError();
+ return true;
+}
+QStringList SqlDatabase::tables ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->tables();
+ return QStringList();
+}
+SqlQuery *SqlDatabase::exec (const QString &query )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ {
+ kdDebug() <<" exec query " << query << endl;
+ SqlQuery *qw = new SqlQuery(this, "query",db->exec( query ));
+ //JSFactory::instance()->addType( "SqlQuery" );
+ kdDebug() <<" size " << qw->size() << endl;
+ kdDebug() <<" valid " << qw->isValid() << endl;
+ return qw;
+ }
+ return 0L;
+}
+QString SqlDatabase::lastError () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ {
+ return db->lastError().text();
+ }
+ return "No Database Driver Loaded";
+}
+bool SqlDatabase::transaction ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->transaction();
+ return false;
+}
+bool SqlDatabase::commit ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->commit();
+ return false;
+}
+bool SqlDatabase::rollback ()
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->rollback();
+ return false;
+}
+void SqlDatabase::setDatabaseName (const QString &name )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ db->setDatabaseName(name);
+}
+void SqlDatabase::setUserName (const QString &name )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ db->setUserName(name);
+}
+void SqlDatabase::setPassword (const QString &password )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ db->setPassword(password);
+}
+void SqlDatabase::setHostName (const QString &host )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ db->setHostName(host);
+}
+void SqlDatabase::setPort ( int p )
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ db->setPort(p);
+}
+QString SqlDatabase::databaseName () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->databaseName();
+ return "";
+}
+QString SqlDatabase::userName () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->userName();
+ return "";
+}
+QString SqlDatabase::password () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->password();
+ return "";
+}
+QString SqlDatabase::hostName () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->hostName();
+ return "";
+}
+QString SqlDatabase::driverName () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->driverName();
+ return "";
+}
+int SqlDatabase::port () const
+{
+ QSqlDatabase *db = QSqlDatabase::database(connectionName,false);
+ if ( db )
+ return db->port();
+ return 0;
+}
+
+SqlQuery::SqlQuery( QObject *parent, const char *name ): BindingObject(parent, name)
+{
+ kdDebug() << "New null SQL Query" << endl;
+ m_query = QSqlQuery();
+ setJSClassName( "SqlQuery" );
+}
+SqlQuery::SqlQuery( QObject *parent, const char *name, const QSqlQuery &q ): BindingObject(parent, name)
+{
+ kdDebug() << "New SQL Query with argument" << endl;
+ m_query = q;
+}
+SqlQuery::~SqlQuery()
+{
+ kdDebug() << "SQL Query going away..." << endl;
+}
+
+/*SqlQuery::SqlQuery(const SqlQuery &copy) : BindingObject(copy.parent(), copy.name())
+{
+ m_query = copy.m_query;
+}
+*/
+bool SqlQuery::isValid () const
+{
+ if ( m_query.isValid())
+ kdDebug() << "Query is valid" << endl;
+ else
+ kdDebug() << "Query is not valid" << endl;
+ return m_query.isValid();
+}
+bool SqlQuery::isActive () const
+{
+ return m_query.isActive();
+}
+bool SqlQuery::isNull ( int field )
+{
+ return m_query.isNull(field);
+}
+int SqlQuery::at () const
+{
+ return m_query.at();
+}
+QString SqlQuery::lastQuery () const
+{
+ kdDebug() << "Last query error: " << m_query.lastQuery() << endl;
+ return m_query.lastQuery();
+}
+int SqlQuery::numRowsAffected () const
+{
+ return m_query.numRowsAffected();
+}
+QString SqlQuery::lastError () const
+{
+ return m_query.lastError().text();
+}
+bool SqlQuery::isSelect () const
+{
+ return m_query.isSelect();
+}
+int SqlQuery::size () const
+{
+ return m_query.size();
+}
+bool SqlQuery::exec ( const QString & query )
+{
+ return m_query.exec( query );
+}
+QVariant SqlQuery::value ( int i )
+{
+ return m_query.value(i);
+}
+bool SqlQuery::seek ( int i, bool relative )
+{
+ return m_query.seek(i,relative);
+}
+bool SqlQuery::next ()
+{
+ return m_query.next();
+}
+bool SqlQuery::prev ()
+{
+ return m_query.prev();
+}
+bool SqlQuery::first ()
+{
+ return m_query.first();
+}
+bool SqlQuery::last ()
+{
+ return m_query.last();
+}
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
+#ifndef QT_ONLY
+#include "sql_imp.moc"
+#endif
diff --git a/kjsembed/bindings/sql_imp.h b/kjsembed/bindings/sql_imp.h
new file mode 100644
index 00000000..78e54756
--- /dev/null
+++ b/kjsembed/bindings/sql_imp.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2003, Ian Reinhart Geiser <geiseri@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KJSEMBED_SQL_IMP_H
+#define KJSEMBED_SQL_IMP_H
+
+#include "bindingobject.h"
+#include <qsqlquery.h>
+#include <qsqldatabase.h>
+
+namespace KJSEmbed {
+namespace Bindings {
+
+/**
+ * QObject Binding for QSQLQuery.
+ *
+ * @author Ian Reinhart Geiser, geiseri@kde.org
+ * @version $Id$
+ */
+class SqlQuery : public BindingObject
+{
+ Q_OBJECT
+ Q_PROPERTY( int size READ size)
+ Q_PROPERTY( int at READ at)
+ Q_PROPERTY( int numRowsAffected READ numRowsAffected )
+ Q_PROPERTY( bool select READ isSelect)
+ Q_PROPERTY( bool valid READ isValid)
+ Q_PROPERTY( bool active READ isActive)
+ Q_PROPERTY( QString lastError READ lastError)
+ Q_PROPERTY( QString lastQuery READ lastQuery)
+
+public:
+ SqlQuery( QObject *parent=0, const char *name=0 );
+ SqlQuery( QObject *parent, const char *name, const QSqlQuery &q );
+ //SqlQuery( const SqlQuery &copy);
+ virtual ~SqlQuery();
+
+ QSqlQuery query(){ return m_query; }
+ void setQuery(const QSqlQuery &q) {m_query = QSqlQuery(q); }
+
+ int size () const;
+ bool isSelect () const;
+ bool isValid () const;
+ bool isActive () const;
+ int at () const;
+ int numRowsAffected () const;
+ QString lastError () const;
+ QString lastQuery () const;
+
+public slots:
+
+
+
+ bool isNull ( int field );
+ bool exec ( const QString & m_query );
+ QVariant value ( int i );
+ bool seek ( int i, bool relative = FALSE );
+ bool next ();
+ bool prev ();
+ bool first ();
+ bool last ();
+
+private:
+ QSqlQuery m_query;
+};
+
+/**
+ * QObject Binding for QSQLDatabase.
+ *
+ * @author Ian Reinhart Geiser, geiseri@kde.org
+ * @version $Id$
+ */
+class SqlDatabase : public BindingObject
+{
+ Q_OBJECT
+ Q_PROPERTY( QString databaseName READ databaseName WRITE setDatabaseName)
+ Q_PROPERTY( QString userName READ userName WRITE setUserName)
+ Q_PROPERTY( QString password READ password WRITE setPassword)
+ Q_PROPERTY( QString hostName READ hostName WRITE setHostName)
+ Q_PROPERTY( int port READ port WRITE setPort)
+ Q_PROPERTY( QString driverName READ driverName)
+ Q_PROPERTY( QString lastError READ lastError)
+
+public:
+ SqlDatabase( QObject *parent=0, const char *name=0 );
+ virtual ~SqlDatabase();
+
+
+public slots:
+ void setDatabaseName (const QString &name );
+ void setUserName (const QString &name );
+ void setPassword (const QString &password );
+ void setHostName (const QString &host );
+ void setPort ( int p );
+ QString databaseName () const;
+ QString userName () const;
+ QString password () const;
+ QString hostName () const;
+ int port () const;
+ QString driverName () const;
+
+ bool addDatabase ( const QString & type, const QString & connectionName = QSqlDatabase::defaultConnection );
+ QStringList drivers ();
+ bool open ();
+ bool open ( const QString &user, const QString &password );
+ void close ();
+ bool isOpen ();
+ bool isOpenError ();
+ QStringList tables ();
+ SqlQuery *exec( const QString &query );
+ QString lastError () const;
+ bool transaction ();
+ bool commit ();
+ bool rollback ();
+
+private:
+ QString connectionName;
+ //QSqlDatabase *db;
+};
+
+
+} // namespace KJSEmbed::Bindings
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_SQL_IMP_H