summaryrefslogtreecommitdiffstats
path: root/kjsembed/builtins
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit90825e2392b2d70e43c7a25b8a3752299a933894 (patch)
treee33aa27f02b74604afbfd0ea4f1cfca8833d882a /kjsembed/builtins
downloadtdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz
tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kjsembed/builtins')
-rw-r--r--kjsembed/builtins/Makefile.am18
-rw-r--r--kjsembed/builtins/builtins.pro18
-rw-r--r--kjsembed/builtins/qdir_imp.cpp1009
-rw-r--r--kjsembed/builtins/qdir_imp.h172
-rw-r--r--kjsembed/builtins/qfile_imp.cpp622
-rw-r--r--kjsembed/builtins/qfile_imp.h148
-rw-r--r--kjsembed/builtins/resources.cpp231
-rw-r--r--kjsembed/builtins/resources.h99
-rw-r--r--kjsembed/builtins/saxhandler.cpp186
-rw-r--r--kjsembed/builtins/saxhandler.h80
-rw-r--r--kjsembed/builtins/stdaction_imp.cpp99
-rw-r--r--kjsembed/builtins/stdaction_imp.h68
-rw-r--r--kjsembed/builtins/stddialog_imp.cpp147
-rw-r--r--kjsembed/builtins/stddialog_imp.h81
-rw-r--r--kjsembed/builtins/textstream_imp.cpp134
-rw-r--r--kjsembed/builtins/textstream_imp.h79
16 files changed, 3191 insertions, 0 deletions
diff --git a/kjsembed/builtins/Makefile.am b/kjsembed/builtins/Makefile.am
new file mode 100644
index 00000000..d1b1ade9
--- /dev/null
+++ b/kjsembed/builtins/Makefile.am
@@ -0,0 +1,18 @@
+INCLUDES= -I$(srcdir)/../.. -I.. -I$(top_srcdir)/kjsembed $(all_includes)
+KDE_CXXFLAGS = -DQT_NO_ASCII_CAST -DQT_CLEAN_NAMESPACE -Wno-unused
+
+noinst_LTLIBRARIES = libkjsembedbuiltins.la
+
+libkjsembedbuiltins_la_SOURCES = stdaction_imp.cpp \
+ resources.cpp \
+ stddialog_imp.cpp \
+ saxhandler.cpp \
+ textstream_imp.cpp \
+ qdir_imp.cpp \
+ qfile_imp.cpp
+
+libkjsembedbuiltins_la_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+libkjsembedbuiltins_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KPARTS) \
+ $(LIB_KFILE) -lkjs $(LIBSOCKET)
+
+libkjsembedbuiltins_la_METASOURCES = AUTO
diff --git a/kjsembed/builtins/builtins.pro b/kjsembed/builtins/builtins.pro
new file mode 100644
index 00000000..cb408cf2
--- /dev/null
+++ b/kjsembed/builtins/builtins.pro
@@ -0,0 +1,18 @@
+# File generated by kdevelop's qmake manager.
+# -------------------------------------------
+# Subdir relative project main directory: ./builtins
+# Target is a library:
+include(../qjsembed.pri)
+INCLUDEPATH += .. . ../..
+CONFIG += staticlib
+TEMPLATE = lib
+HEADERS += textstream_imp.h \
+ qdir_imp.h \
+ saxhandler.h \
+ stddialog_imp.h
+
+SOURCES += saxhandler.cpp \
+ qdir_imp.cpp \
+ stddialog_imp.cpp \
+ textstream_imp.cpp \
+ qfile_imp.cpp
diff --git a/kjsembed/builtins/qdir_imp.cpp b/kjsembed/builtins/qdir_imp.cpp
new file mode 100644
index 00000000..32d79d14
--- /dev/null
+++ b/kjsembed/builtins/qdir_imp.cpp
@@ -0,0 +1,1009 @@
+
+
+
+#include <kjsembed/global.h>
+
+#include <kjs/object.h>
+
+#ifndef QT_ONLY
+#include <klocale.h>
+#include <kdebug.h>
+#endif
+
+
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsbinding.h>
+
+#include <qdir.h>
+#include "qdir_imp.h"
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+namespace Bindings {
+ KJS::Object QDirLoader::createBinding(KJSEmbedPart *jspart, KJS::ExecState *exec, const KJS::List &args) const
+ {
+ JSOpaqueProxy * prx;
+ if ( args.size() == 0 ) {
+ prx = new JSOpaqueProxy( new QDir( QDir::current() ), "QDir" );
+ } else {
+ QString arg0 = ( args.size() >= 1 ) ? args[ 0 ].toString( exec ).qstring() : QString::null;
+ prx = new JSOpaqueProxy( new QDir( arg0 ), "QDir" );
+ }
+ prx->setOwner( JSProxy::JavaScript );
+ KJS::Object proxyObj( prx );
+ addBindings( jspart, exec, proxyObj );
+ return proxyObj;
+ }
+
+ void QDirLoader::addBindings( KJSEmbedPart *jspart, KJS::ExecState *exec, KJS::Object &proxy ) const
+ {
+ QDirImp::addBindings( exec, proxy );
+ }
+
+}
+
+QDirImp::QDirImp( KJS::ExecState *exec, int id )
+ : JSProxyImp(exec), mid(id)
+{
+}
+
+QDirImp::~QDirImp()
+{
+}
+
+void QDirImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ JSProxy::MethodTable methods[] = {
+
+ { Method_setPath_7, "setPath" },
+
+ { Method_path_8, "path" },
+
+ { Method_absPath_9, "absPath" },
+
+ { Method_canonicalPath_10, "canonicalPath" },
+
+ { Method_dirName_11, "dirName" },
+
+ { Method_filePath_12, "filePath" },
+
+ { Method_absFilePath_13, "absFilePath" },
+
+ { Method_cd_14, "cd" },
+
+ { Method_cdUp_15, "cdUp" },
+
+ { Method_nameFilter_16, "nameFilter" },
+
+ { Method_setNameFilter_17, "setNameFilter" },
+
+ { Method_filter_18, "filter" },
+
+ { Method_setFilter_19, "setFilter" },
+
+ { Method_sorting_20, "sorting" },
+
+ { Method_setSorting_21, "setSorting" },
+
+ { Method_matchAllDirs_22, "matchAllDirs" },
+
+ { Method_setMatchAllDirs_23, "setMatchAllDirs" },
+
+ { Method_count_24, "count" },
+
+ { Method_encodedEntryList_26, "encodedEntryList" },
+
+ { Method_encodedEntryList_27, "encodedEntryList" },
+
+ { Method_entryList_28, "entryList" },
+
+ { Method_entryList_29, "entryList" },
+
+ { Method_entryInfoList_30, "entryInfoList" },
+
+ { Method_entryInfoList_31, "entryInfoList" },
+
+ { Method_mkdir_32, "mkdir" },
+
+ { Method_rmdir_33, "rmdir" },
+
+ { Method_isReadable_34, "isReadable" },
+
+ { Method_exists_35, "exists" },
+
+ { Method_isRoot_36, "isRoot" },
+
+ { Method_isRelative_37, "isRelative" },
+
+ { Method_convertToAbs_38, "convertToAbs" },
+
+ { Method_remove_41, "remove" },
+
+ { Method_rename_42, "rename" },
+
+ { Method_exists_43, "exists" },
+
+ { Method_refresh_44, "refresh" },
+
+ { Method_convertSeparators_45, "convertSeparators" },
+
+ { Method_drives_46, "drives" },
+
+ { Method_separator_47, "separator" },
+
+ { Method_setCurrent_48, "setCurrent" },
+
+ { Method_current_49, "current" },
+
+ { Method_home_50, "home" },
+
+ { Method_root_51, "root" },
+
+ { Method_currentDirPath_52, "currentDirPath" },
+
+ { Method_homeDirPath_53, "homeDirPath" },
+
+ { Method_rootDirPath_54, "rootDirPath" },
+
+ { Method_match_55, "match" },
+
+ { Method_match_56, "match" },
+
+ { Method_cleanDirPath_57, "cleanDirPath" },
+
+ { Method_isRelativePath_58, "isRelativePath" },
+
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ QDirImp *meth = new QDirImp( 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[] = {
+
+ // enum FilterSpec
+ { "Dirs", QDir::Dirs },
+ { "Files", QDir::Files },
+ { "Drives", QDir::Drives },
+ { "NoSymLinks", QDir::NoSymLinks },
+ { "All", QDir::All },
+ { "TypeMask", QDir::TypeMask },
+ { "Readable", QDir::Readable },
+ { "Writable", QDir::Writable },
+ { "Executable", QDir::Executable },
+ { "RWEMask", QDir::RWEMask },
+ { "Modified", QDir::Modified },
+ { "Hidden", QDir::Hidden },
+ { "System", QDir::System },
+ { "AccessMask", QDir::AccessMask },
+ { "DefaultFilter", QDir::DefaultFilter },
+ // enum SortSpec
+ { "Name", QDir::Name },
+ { "Time", QDir::Time },
+ { "Size", QDir::Size },
+ { "Unsorted", QDir::Unsorted },
+ { "SortByMask", QDir::SortByMask },
+ { "DirsFirst", QDir::DirsFirst },
+ { "Reversed", QDir::Reversed },
+ { "IgnoreCase", QDir::IgnoreCase },
+ { "DefaultSort", QDir::DefaultSort },
+ { 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 QDirImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
+{
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+ if ( !op ) {
+ kdWarning() << "QDirImp::call() failed, not a JSOpaqueProxy" << endl;
+ return KJS::Value();
+ }
+
+ if ( op->typeName() != "QDir" ) {
+ kdWarning() << "QDirImp::call() failed, type is " << op->typeName() << endl;
+ return KJS::Value();
+ }
+
+ instance = op->toNative<QDir>();
+
+ switch( mid ) {
+
+ case Method_setPath_7:
+ return setPath_7( exec, self, args );
+ break;
+
+ case Method_path_8:
+ return path_8( exec, self, args );
+ break;
+
+ case Method_absPath_9:
+ return absPath_9( exec, self, args );
+ break;
+
+ case Method_canonicalPath_10:
+ return canonicalPath_10( exec, self, args );
+ break;
+
+ case Method_dirName_11:
+ return dirName_11( exec, self, args );
+ break;
+
+ case Method_filePath_12:
+ return filePath_12( exec, self, args );
+ break;
+
+ case Method_absFilePath_13:
+ return absFilePath_13( exec, self, args );
+ break;
+
+ case Method_cd_14:
+ return cd_14( exec, self, args );
+ break;
+
+ case Method_cdUp_15:
+ return cdUp_15( exec, self, args );
+ break;
+
+ case Method_nameFilter_16:
+ return nameFilter_16( exec, self, args );
+ break;
+
+ case Method_setNameFilter_17:
+ return setNameFilter_17( exec, self, args );
+ break;
+
+ case Method_filter_18:
+ return filter_18( exec, self, args );
+ break;
+
+ case Method_setFilter_19:
+ return setFilter_19( exec, self, args );
+ break;
+
+ case Method_sorting_20:
+ return sorting_20( exec, self, args );
+ break;
+
+ case Method_setSorting_21:
+ return setSorting_21( exec, self, args );
+ break;
+
+ case Method_matchAllDirs_22:
+ return matchAllDirs_22( exec, self, args );
+ break;
+
+ case Method_setMatchAllDirs_23:
+ return setMatchAllDirs_23( exec, self, args );
+ break;
+
+ case Method_count_24:
+ return count_24( exec, self, args );
+ break;
+
+ case Method_encodedEntryList_26:
+ return encodedEntryList_26( exec, self, args );
+ break;
+
+ case Method_encodedEntryList_27:
+ return encodedEntryList_27( exec, self, args );
+ break;
+
+ case Method_entryList_28:
+ return entryList_28( exec, self, args );
+ break;
+
+ case Method_entryList_29:
+ return entryList_29( exec, self, args );
+ break;
+
+ case Method_entryInfoList_30:
+ return entryInfoList_30( exec, self, args );
+ break;
+
+ case Method_entryInfoList_31:
+ return entryInfoList_31( exec, self, args );
+ break;
+
+ case Method_mkdir_32:
+ return mkdir_32( exec, self, args );
+ break;
+
+ case Method_rmdir_33:
+ return rmdir_33( exec, self, args );
+ break;
+
+ case Method_isReadable_34:
+ return isReadable_34( exec, self, args );
+ break;
+
+ case Method_exists_35:
+ return exists_35( exec, self, args );
+ break;
+
+ case Method_isRoot_36:
+ return isRoot_36( exec, self, args );
+ break;
+
+ case Method_isRelative_37:
+ return isRelative_37( exec, self, args );
+ break;
+
+ case Method_convertToAbs_38:
+ return convertToAbs_38( exec, self, args );
+ break;
+
+ case Method_remove_41:
+ return remove_41( exec, self, args );
+ break;
+
+ case Method_rename_42:
+ return rename_42( exec, self, args );
+ break;
+
+ case Method_exists_43:
+ return exists_43( exec, self, args );
+ break;
+
+ case Method_refresh_44:
+ return refresh_44( exec, self, args );
+ break;
+
+ case Method_convertSeparators_45:
+ return convertSeparators_45( exec, self, args );
+ break;
+
+ case Method_drives_46:
+ return drives_46( exec, self, args );
+ break;
+
+ case Method_separator_47:
+ return separator_47( exec, self, args );
+ break;
+
+ case Method_setCurrent_48:
+ return setCurrent_48( exec, self, args );
+ break;
+
+ case Method_current_49:
+ return current_49( exec, self, args );
+ break;
+
+ case Method_home_50:
+ return home_50( exec, self, args );
+ break;
+
+ case Method_root_51:
+ return root_51( exec, self, args );
+ break;
+
+ case Method_currentDirPath_52:
+ return currentDirPath_52( exec, self, args );
+ break;
+
+ case Method_homeDirPath_53:
+ return homeDirPath_53( exec, self, args );
+ break;
+
+ case Method_rootDirPath_54:
+ return rootDirPath_54( exec, self, args );
+ break;
+
+ case Method_match_55:
+ return match_55( exec, self, args );
+ break;
+
+ case Method_match_56:
+ return match_56( exec, self, args );
+ break;
+
+ case Method_cleanDirPath_57:
+ return cleanDirPath_57( exec, self, args );
+ break;
+
+ case Method_isRelativePath_58:
+ return isRelativePath_58( exec, self, args );
+ break;
+
+ default:
+ break;
+ }
+
+ QString msg = i18n( "QDirImp has no method with id '%1'." ).arg( mid );
+ return throwError(exec, msg,KJS::ReferenceError);
+}
+
+
+KJS::Value QDirImp::setPath_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ instance->setPath(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::path_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->path( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::absPath_9( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->absPath( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::canonicalPath_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->canonicalPath( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::dirName_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->dirName( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::filePath_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ QString ret;
+ ret = instance->filePath(
+ arg0,
+ arg1 );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::absFilePath_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ QString ret;
+ ret = instance->absFilePath(
+ arg0,
+ arg1 );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::cd_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->cd(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::cdUp_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->cdUp( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::nameFilter_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->nameFilter( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::setNameFilter_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ instance->setNameFilter(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::filter_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->filter( );
+ return KJS::Value(); // Returns 'FilterSpec'
+
+}
+
+KJS::Value QDirImp::setFilter_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ instance->setFilter(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::sorting_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->sorting( );
+ return KJS::Value(); // Returns 'SortSpec'
+
+}
+
+KJS::Value QDirImp::setSorting_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ instance->setSorting(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::matchAllDirs_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->matchAllDirs( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::setMatchAllDirs_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool arg0 = (args.size() >= 1) ? args[0].toBoolean(exec) : false;
+
+ instance->setMatchAllDirs(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::count_24( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ uint ret;
+ ret = instance->count( );
+ return KJS::Number( ret );
+
+}
+
+KJS::Value QDirImp::encodedEntryList_26( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ instance->encodedEntryList(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'QStrList'
+
+}
+
+KJS::Value QDirImp::encodedEntryList_27( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1;
+
+ instance->encodedEntryList(
+ arg0,
+ arg1,
+ arg2 );
+ return KJS::Value(); // Returns 'QStrList'
+
+}
+
+KJS::Value QDirImp::entryList_28( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ QStringList ret;
+ ret = instance->entryList(
+ arg0,
+ arg1 );
+
+ return convertToValue( exec, ret );
+
+}
+
+KJS::Value QDirImp::entryList_29( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1;
+
+ QStringList ret;
+ ret = instance->entryList(
+ arg0,
+ arg1,
+ arg2 );
+
+ return convertToValue( exec, ret );
+
+}
+
+KJS::Value QDirImp::entryInfoList_30( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ instance->entryInfoList(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'const QFileInfoList *'
+
+}
+
+KJS::Value QDirImp::entryInfoList_31( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ int arg2 = (args.size() >= 3) ? args[2].toInteger(exec) : -1;
+
+ instance->entryInfoList(
+ arg0,
+ arg1,
+ arg2 );
+ return KJS::Value(); // Returns 'const QFileInfoList *'
+
+}
+
+KJS::Value QDirImp::mkdir_32( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->mkdir(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::rmdir_33( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->rmdir(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::isReadable_34( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->isReadable( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::exists_35( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->exists( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::isRoot_36( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->isRoot( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::isRelative_37( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->isRelative( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::convertToAbs_38( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->convertToAbs( );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::remove_41( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->remove(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::rename_42( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;
+
+ bool arg2 = (args.size() >= 3) ? args[2].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->rename(
+ arg0,
+ arg1,
+ arg2 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::exists_43( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool arg1 = (args.size() >= 2) ? args[1].toBoolean(exec) : false;
+
+ bool ret;
+ ret = instance->exists(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::refresh_44( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->refresh( );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QDirImp::convertSeparators_45( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ QString ret;
+ ret = instance->convertSeparators(
+ arg0 );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::drives_46( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->drives( );
+ return KJS::Value(); // Returns 'const QFileInfoList *'
+
+}
+
+KJS::Value QDirImp::separator_47( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->separator( );
+ return KJS::Value(); // Returns 'char'
+
+}
+
+KJS::Value QDirImp::setCurrent_48( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->setCurrent(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::current_49( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->current( );
+ return KJS::Value(); // Returns 'QDir'
+
+}
+
+KJS::Value QDirImp::home_50( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->home( );
+ return KJS::Value(); // Returns 'QDir'
+
+}
+
+KJS::Value QDirImp::root_51( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->root( );
+ return KJS::Value(); // Returns 'QDir'
+
+}
+
+KJS::Value QDirImp::currentDirPath_52( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->currentDirPath( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::homeDirPath_53( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->homeDirPath( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::rootDirPath_54( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->rootDirPath( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::match_55( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QStringList arg0;
+ if ( args.size() >= 1 ) {
+ // TODO: populate the list
+ }
+
+ QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->match(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::match_56( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ QString arg1 = (args.size() >= 2) ? args[1].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->match(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QDirImp::cleanDirPath_57( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ QString ret;
+ ret = instance->cleanDirPath(
+ arg0 );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QDirImp::isRelativePath_58( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->isRelativePath(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/builtins/qdir_imp.h b/kjsembed/builtins/qdir_imp.h
new file mode 100644
index 00000000..f78850e7
--- /dev/null
+++ b/kjsembed/builtins/qdir_imp.h
@@ -0,0 +1,172 @@
+
+
+
+#ifndef KJSEMBED_QDir_H
+#define KJSEMBED_QDir_H
+
+#include <kjs/interpreter.h>
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+#include <kjsembed/jsbindingbase.h>
+
+class QDir;
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+namespace Bindings {
+ class QDirLoader : 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;
+ };
+}
+/**
+ * Wrapper class for QDir methods.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+class QDirImp : public JSProxyImp
+{
+public:
+ /** Enumerates the methods supported by this class. */
+ enum Methods {
+
+ Method_setPath_7,
+ Method_path_8,
+ Method_absPath_9,
+ Method_canonicalPath_10,
+ Method_dirName_11,
+ Method_filePath_12,
+ Method_absFilePath_13,
+ Method_cd_14,
+ Method_cdUp_15,
+ Method_nameFilter_16,
+ Method_setNameFilter_17,
+ Method_filter_18,
+ Method_setFilter_19,
+ Method_sorting_20,
+ Method_setSorting_21,
+ Method_matchAllDirs_22,
+ Method_setMatchAllDirs_23,
+ Method_count_24,
+ Method_encodedEntryList_26,
+ Method_encodedEntryList_27,
+ Method_entryList_28,
+ Method_entryList_29,
+ Method_entryInfoList_30,
+ Method_entryInfoList_31,
+ Method_mkdir_32,
+ Method_rmdir_33,
+ Method_isReadable_34,
+ Method_exists_35,
+ Method_isRoot_36,
+ Method_isRelative_37,
+ Method_convertToAbs_38,
+ Method_remove_41,
+ Method_rename_42,
+ Method_exists_43,
+ Method_refresh_44,
+ Method_convertSeparators_45,
+ Method_drives_46,
+ Method_separator_47,
+ Method_setCurrent_48,
+ Method_current_49,
+ Method_home_50,
+ Method_root_51,
+ Method_currentDirPath_52,
+ Method_homeDirPath_53,
+ Method_rootDirPath_54,
+ Method_match_55,
+ Method_match_56,
+ Method_cleanDirPath_57,
+ Method_isRelativePath_58,
+ Method_Last = -1
+ };
+
+ QDirImp( KJS::ExecState *exec, int id );
+ ~QDirImp();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ //
+ // Methods implemented by this class.
+ //
+
+ KJS::Value setPath_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value path_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value absPath_9( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value canonicalPath_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value dirName_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value filePath_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value absFilePath_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value cd_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value cdUp_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value nameFilter_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setNameFilter_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value filter_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setFilter_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value sorting_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setSorting_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value matchAllDirs_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setMatchAllDirs_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value count_24( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value encodedEntryList_26( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value encodedEntryList_27( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value entryList_28( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value entryList_29( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value entryInfoList_30( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value entryInfoList_31( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value mkdir_32( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value rmdir_33( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value isReadable_34( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value exists_35( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value isRoot_36( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value isRelative_37( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value convertToAbs_38( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value remove_41( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value rename_42( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value exists_43( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value refresh_44( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value convertSeparators_45( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value drives_46( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value separator_47( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setCurrent_48( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value current_49( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value home_50( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value root_51( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value currentDirPath_52( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value homeDirPath_53( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value rootDirPath_54( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value match_55( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value match_56( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value cleanDirPath_57( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value isRelativePath_58( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+
+ //
+ // JS binding code.
+ //
+
+ /** 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:
+ QDir *instance; // Temp
+ int mid;
+};
+
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_QDir_H
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/builtins/qfile_imp.cpp b/kjsembed/builtins/qfile_imp.cpp
new file mode 100644
index 00000000..d404e239
--- /dev/null
+++ b/kjsembed/builtins/qfile_imp.cpp
@@ -0,0 +1,622 @@
+
+
+#include <qcstring.h>
+#include <qpalette.h>
+#include <qpixmap.h>
+#include <qfont.h>
+
+#ifndef QT_ONLY
+#include <klocale.h>
+#include <kdebug.h>
+#endif
+
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy.h>
+#include <kjsembed/jsopaqueproxy.h>
+#include <kjsembed/jsbinding.h>
+#include <kjsembed/global.h>
+
+#include <qfile.h>
+#include "qfile_imp.h"
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+
+QFileImp::QFileImp( KJS::ExecState *exec, int mid, bool constructor )
+ : JSProxyImp(exec), id(mid), cons(constructor)
+{
+}
+
+QFileImp::~QFileImp()
+{
+}
+
+void QFileImp::addBindings( KJS::ExecState *exec, KJS::Object &object )
+{
+ JSProxy::MethodTable methods[] = {
+
+ { Method_name_4, "name" },
+ { Method_setName_5, "setName" },
+ { Method_exists_6, "exists" },
+ { Method_remove_7, "remove" },
+ { Method_open_8, "open" },
+ { Method_open_9, "open" },
+ { Method_open_10, "open" },
+ { Method_close_11, "close" },
+ { Method_flush_12, "flush" },
+ { Method_size_13, "size" },
+ { Method_at_14, "at" },
+ { Method_at_15, "at" },
+ { Method_atEnd_16, "atEnd" },
+ { Method_readBlock_17, "readBlock" },
+ { Method_writeBlock_18, "writeBlock" },
+ { Method_writeBlock_19, "writeBlock" },
+ { Method_readLine_20, "readLine" },
+ { Method_readLine_21, "readLine" },
+ { Method_getch_22, "getch" },
+ { Method_putch_23, "putch" },
+ { Method_ungetch_24, "ungetch" },
+ { Method_handle_25, "handle" },
+ { Method_errorString_26, "errorString" },
+ { Method_encodeName_27, "encodeName" },
+ { Method_decodeName_28, "decodeName" },
+ { Method_setEncodingFunction_29, "setEncodingFunction" },
+ { Method_setDecodingFunction_30, "setDecodingFunction" },
+ { Method_exists_31, "exists" },
+ { Method_remove_32, "remove" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ QCString lastName;
+
+ do {
+ if ( lastName != methods[idx].name ) {
+ QFileImp *meth = new QFileImp( exec, methods[idx].id );
+ object.put( exec , methods[idx].name, KJS::Object(meth) );
+ lastName = methods[idx].name;
+ }
+ ++idx;
+ } while( methods[idx].id );
+
+
+}
+
+QFile *QFileImp::toQFile( KJS::Object &self )
+{
+ JSObjectProxy *ob = JSProxy::toObjectProxy( self.imp() );
+ if ( ob ) {
+ QObject *obj = ob->object();
+ if ( obj )
+ return dynamic_cast<QFile *>( obj );
+ }
+
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( self.imp() );
+ if ( !op )
+ return 0;
+
+ if ( op->typeName() != "QFile" )
+ return 0;
+
+ return op->toNative<QFile>();
+}
+
+
+KJS::Object QFileImp::construct( KJS::ExecState *exec, const KJS::List &args )
+{
+ switch( id ) {
+
+ case Constructor_QFile_1:
+ return QFile_1( exec, args );
+ break;
+
+ case Constructor_QFile_2:
+ return QFile_2( exec, args );
+ break;
+
+ default:
+ break;
+ }
+
+ QString msg = i18n("QFileCons has no constructor with id '%1'.").arg(id);
+ return throwError(exec, msg,KJS::ReferenceError);
+}
+
+
+KJS::Object QFileImp::QFile_1( KJS::ExecState *exec, const KJS::List &args )
+{
+ return KJS::Object();
+}
+
+KJS::Object QFileImp::QFile_2( KJS::ExecState *exec, const KJS::List &args )
+{
+
+ // TODO
+ QWidget *arg0 = 0L;
+ return KJS::Object();
+
+}
+
+KJS::Value QFileImp::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args )
+{
+ instance = QFileImp::toQFile( self );
+
+ switch( id ) {
+
+ case Method_name_4:
+ return name_4( exec, self, args );
+ break;
+
+ case Method_setName_5:
+ return setName_5( exec, self, args );
+ break;
+
+ case Method_exists_6:
+ return exists_6( exec, self, args );
+ break;
+
+ case Method_remove_7:
+ return remove_7( exec, self, args );
+ break;
+
+ case Method_open_8:
+ return open_8( exec, self, args );
+ break;
+
+ case Method_open_9:
+ return open_9( exec, self, args );
+ break;
+
+ case Method_open_10:
+ return open_10( exec, self, args );
+ break;
+
+ case Method_close_11:
+ return close_11( exec, self, args );
+ break;
+
+ case Method_flush_12:
+ return flush_12( exec, self, args );
+ break;
+
+ case Method_size_13:
+ return size_13( exec, self, args );
+ break;
+
+ case Method_at_14:
+ return at_14( exec, self, args );
+ break;
+
+ case Method_at_15:
+ return at_15( exec, self, args );
+ break;
+
+ case Method_atEnd_16:
+ return atEnd_16( exec, self, args );
+ break;
+
+ case Method_readBlock_17:
+ return readBlock_17( exec, self, args );
+ break;
+
+ case Method_writeBlock_18:
+ return writeBlock_18( exec, self, args );
+ break;
+
+ case Method_writeBlock_19:
+ return writeBlock_19( exec, self, args );
+ break;
+
+ case Method_readLine_20:
+ return readLine_20( exec, self, args );
+ break;
+
+ case Method_readLine_21:
+ return readLine_21( exec, self, args );
+ break;
+
+ case Method_getch_22:
+ return getch_22( exec, self, args );
+ break;
+
+ case Method_putch_23:
+ return putch_23( exec, self, args );
+ break;
+
+ case Method_ungetch_24:
+ return ungetch_24( exec, self, args );
+ break;
+
+ case Method_handle_25:
+ return handle_25( exec, self, args );
+ break;
+
+ case Method_errorString_26:
+ return errorString_26( exec, self, args );
+ break;
+
+ case Method_encodeName_27:
+ return encodeName_27( exec, self, args );
+ break;
+
+ case Method_decodeName_28:
+ return decodeName_28( exec, self, args );
+ break;
+
+ case Method_setEncodingFunction_29:
+ return setEncodingFunction_29( exec, self, args );
+ break;
+
+ case Method_setDecodingFunction_30:
+ return setDecodingFunction_30( exec, self, args );
+ break;
+
+ case Method_exists_31:
+ return exists_31( exec, self, args );
+ break;
+
+ case Method_remove_32:
+ return remove_32( exec, self, args );
+ break;
+
+ default:
+ break;
+ }
+
+ QString msg = i18n( "QFileImp has no method with id '%1'." ).arg( id );
+ return throwError(exec, msg, KJS::ReferenceError );
+}
+
+
+KJS::Value QFileImp::name_4( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->name( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QFileImp::setName_5( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ instance->setName(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QFileImp::exists_6( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->exists( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::remove_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->remove( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::open_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ bool ret;
+ ret = instance->open(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::open_9( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ // Unsupported parameter FILE *
+ return KJS::Value();
+
+ FILE * arg1; // Dummy
+
+ bool ret;
+ ret = instance->open(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::open_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int arg1 = (args.size() >= 2) ? args[1].toInteger(exec) : -1;
+
+ bool ret;
+ ret = instance->open(
+ arg0,
+ arg1 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::close_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->close( );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QFileImp::flush_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->flush( );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QFileImp::size_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->size( );
+ return KJS::Value(); // Returns 'Offset'
+
+}
+
+KJS::Value QFileImp::at_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ instance->at( );
+ return KJS::Value(); // Returns 'Offset'
+
+}
+
+KJS::Value QFileImp::at_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QFile::Offset arg0 = 0; // TODO (hack for qfile)
+
+ bool ret;
+ ret = instance->at(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::atEnd_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ bool ret;
+ ret = instance->atEnd( );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::readBlock_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ // Unsupported parameter char *
+ return KJS::Value();
+
+ char * arg0; // Dummy
+
+ // Unsupported parameter Q_ULONG
+ return KJS::Value();
+
+ Q_ULONG arg1; // Dummy
+
+ instance->readBlock(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'Q_LONG'
+
+}
+
+KJS::Value QFileImp::writeBlock_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ const char *arg0 = (args.size() >= 1) ? args[0].toString(exec).ascii() : 0;
+
+ // Unsupported parameter Q_ULONG
+ return KJS::Value();
+
+ Q_ULONG arg1; // Dummy
+
+ instance->writeBlock(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'Q_LONG'
+
+}
+
+KJS::Value QFileImp::writeBlock_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QByteArray arg0; // TODO (hack for qfile)
+
+ instance->writeBlock(
+ arg0 );
+ return KJS::Value(); // Returns 'Q_LONG'
+
+}
+
+KJS::Value QFileImp::readLine_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ // Unsupported parameter char *
+ return KJS::Value();
+
+ char * arg0; // Dummy
+
+ // Unsupported parameter Q_ULONG
+ return KJS::Value();
+
+ Q_ULONG arg1; // Dummy
+
+ instance->readLine(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'Q_LONG'
+
+}
+
+KJS::Value QFileImp::readLine_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ // Unsupported parameter Q_ULONG
+ return KJS::Value();
+
+ Q_ULONG arg1; // Dummy
+
+ instance->readLine(
+ arg0,
+ arg1 );
+ return KJS::Value(); // Returns 'Q_LONG'
+
+}
+
+KJS::Value QFileImp::getch_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int ret;
+ ret = instance->getch( );
+ return KJS::Number( ret );
+
+}
+
+KJS::Value QFileImp::putch_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int ret;
+ ret = instance->putch(
+ arg0 );
+ return KJS::Number( ret );
+
+}
+
+KJS::Value QFileImp::ungetch_24( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int arg0 = (args.size() >= 1) ? args[0].toInteger(exec) : -1;
+
+ int ret;
+ ret = instance->ungetch(
+ arg0 );
+ return KJS::Number( ret );
+
+}
+
+KJS::Value QFileImp::handle_25( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ int ret;
+ ret = instance->handle( );
+ return KJS::Number( ret );
+
+}
+
+KJS::Value QFileImp::errorString_26( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString ret;
+ ret = instance->errorString( );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QFileImp::encodeName_27( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ instance->encodeName(
+ arg0 );
+ return KJS::Value(); // Returns 'QCString'
+
+}
+
+KJS::Value QFileImp::decodeName_28( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ const QCString arg0 = (args.size() >= 1) ? args[0].toString(exec).ascii() : 0;
+
+ QString ret;
+ ret = instance->decodeName(
+ arg0 );
+ return KJS::String( ret );
+
+}
+
+KJS::Value QFileImp::setEncodingFunction_29( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QFile::EncoderFn arg0 = 0; // TODO (hack for qfile)
+
+ instance->setEncodingFunction(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QFileImp::setDecodingFunction_30( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QFile::DecoderFn arg0 = 0; // TODO (hack for qfile)
+
+ instance->setDecodingFunction(
+ arg0 );
+ return KJS::Value(); // Returns void
+
+}
+
+KJS::Value QFileImp::exists_31( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->exists(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+KJS::Value QFileImp::remove_32( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args )
+{
+
+ QString arg0 = (args.size() >= 1) ? args[0].toString(exec).qstring() : QString::null;
+
+ bool ret;
+ ret = instance->remove(
+ arg0 );
+ return KJS::Boolean( ret );
+
+}
+
+
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/builtins/qfile_imp.h b/kjsembed/builtins/qfile_imp.h
new file mode 100644
index 00000000..ae88dd52
--- /dev/null
+++ b/kjsembed/builtins/qfile_imp.h
@@ -0,0 +1,148 @@
+
+
+
+#ifndef KJSEMBED_QFile_H
+#define KJSEMBED_QFile_H
+
+#include <kjs/interpreter.h>
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+class QFile;
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+
+/**
+ * Wrapper class for QFile methods.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+class QFileImp : public JSProxyImp
+{
+public:
+ /** Enumerates the constructors supported by this class. */
+ enum Constructors {
+ Constructor_QFile_1,
+ Constructor_QFile_2,
+
+ LastConstuctor = -1
+ };
+
+ /** Enumerates the methods supported by this class. */
+ enum Methods {
+
+ Method_name_4,
+ Method_setName_5,
+ Method_exists_6,
+ Method_remove_7,
+ Method_open_8,
+ Method_open_9,
+ Method_open_10,
+ Method_close_11,
+ Method_flush_12,
+ Method_size_13,
+ Method_at_14,
+ Method_at_15,
+ Method_atEnd_16,
+ Method_readBlock_17,
+ Method_writeBlock_18,
+ Method_writeBlock_19,
+ Method_readLine_20,
+ Method_readLine_21,
+ Method_getch_22,
+ Method_putch_23,
+ Method_ungetch_24,
+ Method_handle_25,
+ Method_errorString_26,
+ Method_encodeName_27,
+ Method_decodeName_28,
+ Method_setEncodingFunction_29,
+ Method_setDecodingFunction_30,
+ Method_exists_31,
+ Method_remove_32,
+ Method_Last = -1
+ };
+
+ QFileImp( KJS::ExecState *exec, int id, bool constructor=false );
+ ~QFileImp();
+
+ static void addBindings( KJS::ExecState *exec, KJS::Object &object );
+
+ static QFile *toQFile( KJS::Object &object );
+
+ //
+ // Constructors implemented by this class.
+ //
+
+ KJS::Object QFile_1( KJS::ExecState *exec, const KJS::List &args );
+ KJS::Object QFile_2( KJS::ExecState *exec, const KJS::List &args );
+
+ //
+ // Methods implemented by this class.
+ //
+
+ KJS::Value name_4( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setName_5( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value exists_6( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value remove_7( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value open_8( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value open_9( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value open_10( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value close_11( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value flush_12( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value size_13( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value at_14( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value at_15( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value atEnd_16( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value readBlock_17( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value writeBlock_18( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value writeBlock_19( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value readLine_20( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value readLine_21( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value getch_22( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value putch_23( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value ungetch_24( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value handle_25( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value errorString_26( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value encodeName_27( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value decodeName_28( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setEncodingFunction_29( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value setDecodingFunction_30( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value exists_31( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+ KJS::Value remove_32( KJS::ExecState *exec, KJS::Object &obj, const KJS::List &args );
+
+ //
+ // JS binding code.
+ //
+
+ /** Returns true iff this object implements the construct function. */
+ virtual bool implementsConstruct() const { return cons; }
+
+ /** Invokes the construct function. */
+ virtual KJS::Object construct( KJS::ExecState *exec, const KJS::List &args );
+
+ /** Returns true iff this object implements the call function. */
+ virtual bool implementsCall() const { return !cons; }
+
+ /** Invokes the call function. */
+ virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
+
+private:
+ QFile *instance; // Temp
+ int id;
+ bool cons;
+};
+
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_QFile_H
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
+
+
diff --git a/kjsembed/builtins/resources.cpp b/kjsembed/builtins/resources.cpp
new file mode 100644
index 00000000..14912303
--- /dev/null
+++ b/kjsembed/builtins/resources.cpp
@@ -0,0 +1,231 @@
+/*
+ * 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 <kstandarddirs.h>
+#include <kiconloader.h>
+#include <kglobal.h>
+#include <kdebug.h>
+#include <jsproxy.h>
+#include <jsbinding.h>
+#include <jsfactory.h>
+#include <qdir.h>
+#include <qapplication.h>
+#include "resources.h"
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+
+StdDirsImp::StdDirsImp( KJS::ExecState *exec, uint mid )
+ : JSProxyImp(exec), id(mid)
+{
+
+}
+
+StdDirsImp::~StdDirsImp() {}
+
+void StdDirsImp::addBindings( KJS::ExecState *exec, KJS::Object &parent )
+{
+
+ JSProxy::MethodTable methods[] = {
+ { StdDirsImp::findResource, "findResource" },
+ { StdDirsImp::addResourceType, "addResourceType" },
+ { StdDirsImp::kde_default, "kde_default" },
+ { StdDirsImp::addResourceDir, "addResourceDir" },
+ { StdDirsImp::findResourceDir, "findResourceDir" },
+ { StdDirsImp::saveLocation, "saveLocation" },
+ { StdDirsImp::makeDir, "makeDir" },
+ { StdDirsImp::exists, "exists" },
+ { StdDirsImp::realPath, "realPath" },
+ { StdDirsImp::currentDirPath, "currentDirPath" },
+ { StdDirsImp::homeDirPath, "homeDirPath" },
+ { StdDirsImp::applicationDirPath, "applicationDirPath" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ StdDirsImp *sdi = new StdDirsImp( exec, idx );
+ parent.put( exec , methods[idx].name, KJS::Object(sdi) );
+ ++idx;
+ } while( methods[idx].id );
+
+}
+
+KJS::Value StdDirsImp::call( KJS::ExecState *exec, KJS::Object &/*self*/, const KJS::List &args )
+{
+// QString arg0 = extractQString(exec, args, 0);
+// QString arg1 = extractQString(exec, args, 1);
+
+ switch( id ) {
+ case StdDirsImp::findResource:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ QString path = KGlobal::dirs ()->findResource(arg0.latin1(), arg1);
+ return KJS::String( path );
+ }
+ case StdDirsImp::addResourceType:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ bool isOk = KGlobal::dirs ()->addResourceType(arg0.latin1(), arg1);
+ return KJS::Boolean( isOk );
+ }
+ case StdDirsImp::kde_default:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString path = KGlobal::dirs ()->kde_default(arg0.latin1());
+ return KJS::String( path );
+ }
+ case StdDirsImp::addResourceDir:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ bool isOk = KGlobal::dirs ()->addResourceDir(arg0.latin1(), arg1);
+ return KJS::Boolean( isOk );
+ }
+ case StdDirsImp::findResourceDir:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ QString path = KGlobal::dirs ()->findResourceDir(arg0.latin1(), arg1);
+ return KJS::String( path );
+ }
+ case StdDirsImp::saveLocation:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString arg1 = extractQString(exec, args, 1);
+ bool arg2 = (args.size() > 2) ? args[2].toBoolean(exec) : true;
+ QString path = KGlobal::dirs ()->saveLocation(arg0.latin1(), arg1, arg2);
+ return KJS::String( path );
+ }
+ case StdDirsImp::makeDir:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ int arg1 = (args.size() > 1) ? args[1].toInteger(exec) : 0755;
+ bool isOk = KStandardDirs::makeDir(arg0, arg1);
+ return KJS::Boolean( isOk );
+ }
+ case StdDirsImp::exists:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ bool isOk = KStandardDirs::exists(arg0);
+ return KJS::Boolean( isOk );
+ }
+ case StdDirsImp::realPath:
+ {
+ QString arg0 = extractQString(exec, args, 0);
+ QString path = KStandardDirs::realPath(arg0);
+ return KJS::String( path );
+ }
+ case StdDirsImp::currentDirPath:
+ return KJS::String(QDir::currentDirPath());
+ case StdDirsImp::homeDirPath:
+ return KJS::String(QDir::homeDirPath());
+ case StdDirsImp::applicationDirPath:
+ return KJS::String(qApp->applicationDirPath());
+ default:
+ kdWarning() << "StdDirsImp has no method " << id << endl;
+ }
+
+ kdWarning() << "StdDirsImp returning null" << endl;
+
+ return KJS::Null();
+}
+
+StdIconsImp::StdIconsImp( JSFactory *fact, KJS::ExecState *exec, uint mid )
+ : JSProxyImp(exec), id(mid), jsfact(fact)
+{
+}
+
+StdIconsImp::~StdIconsImp() {}
+
+void StdIconsImp::addBindings( JSFactory *fact, KJS::ExecState *exec, KJS::Object &parent )
+{
+ JSProxy::MethodTable methods[] = {
+ { StdIconsImp::BarIcon, "BarIcon" },
+ { StdIconsImp::DesktopIcon, "DesktopIcon" },
+ { StdIconsImp::SmallIcon, "SmallIcon" },
+ { StdIconsImp::MainBarIcon, "MainBarIcon" },
+ { StdIconsImp::UserIcon, "UserIcon" },
+ { StdIconsImp::MimeSourceIcon, "MimeSourceIcon" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ StdIconsImp *sdi = new StdIconsImp( fact, exec, idx );
+ parent.put( exec , methods[idx].name, KJS::Object(sdi) );
+ ++idx;
+ } while( methods[idx].id );
+
+}
+
+KJS::Value StdIconsImp::wrapPixmap(KJS::ExecState *exec, const QPixmap &icon)
+{
+ return convertToValue(exec, icon);
+}
+
+KJS::Value StdIconsImp::call( KJS::ExecState *exec, KJS::Object &/*obj*/, const KJS::List &args )
+{
+ QString arg0 = extractQString(exec, args, 0); // Name
+ int arg1 = extractInt(exec, args, 1); // Size 0, 16, 24, 32, 48, 64, 128
+ int arg2 = extractInt(exec, args, 2);
+ // State 0 DefaultState, 1 ActiveState, 2 DisabledState, 3 LastState
+ switch( id ) {
+ case StdIconsImp::BarIcon:
+ {
+ return wrapPixmap(exec, ::BarIcon(arg0, arg1, arg2));
+ }
+ case StdIconsImp::DesktopIcon:
+ {
+ return wrapPixmap(exec, ::DesktopIcon(arg0, arg1, arg2));
+ }
+ case StdIconsImp::SmallIcon:
+ {
+ return wrapPixmap(exec, ::SmallIcon(arg0, arg1, arg2));
+ }
+ case StdIconsImp::MainBarIcon:
+ {
+ return wrapPixmap(exec, ::MainBarIcon(arg0, arg1, arg2));
+ }
+ case StdIconsImp::UserIcon:
+ {
+ return wrapPixmap(exec, ::UserIcon(arg0, arg2));
+ }
+ case StdIconsImp::MimeSourceIcon:
+ {
+ return wrapPixmap( exec, QPixmap::fromMimeSource(arg0));
+ }
+ default:
+ kdWarning() << "StdDirsImp has no method " << id << endl;
+ }
+
+ kdWarning() << "StdDirsImp returning null" << endl;
+
+ return KJS::Null();
+}
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/resources.h b/kjsembed/builtins/resources.h
new file mode 100644
index 00000000..d83cd0b3
--- /dev/null
+++ b/kjsembed/builtins/resources.h
@@ -0,0 +1,99 @@
+// -*- 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_RESOURCES_H
+#define KJSEMBED_RESOURCES_H
+
+#include <qpixmap.h>
+
+#include <kjs/interpreter.h>
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+/**
+ * KJS binding for KStandardDirs.
+ *
+ * @author Ian Reinhart Geiser geiseri@kde.org
+ */
+class StdDirsImp : public JSProxyImp
+{
+
+public:
+ /** Identifiers for the various methods. */
+ enum DirMethods {
+ findResource, addResourceType, kde_default,
+ addResourceDir, findResourceDir, saveLocation,
+ makeDir, exists, realPath, currentDirPath,
+ homeDirPath, applicationDirPath };
+ StdDirsImp( KJS::ExecState *exec, uint id );
+ virtual ~StdDirsImp();
+
+ /** Adds the StdActions object to the specified parent. */
+ static void addBindings( KJS::ExecState *exec, KJS::Object &parent );
+
+ /** 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:
+ uint id;
+ JSFactory *jsfact;
+};
+
+
+/**
+ * KJS binding for KIconLoader.
+ *
+ * @author Ian Reinhart Geiser geiseri@kde.org
+ */
+class StdIconsImp : public JSProxyImp
+{
+public:
+ enum IconMethods { BarIcon, DesktopIcon, SmallIcon, MainBarIcon, UserIcon, MimeSourceIcon };
+ StdIconsImp(JSFactory *fac, KJS::ExecState *exec, uint id );
+ virtual ~StdIconsImp();
+
+ /** Adds the StdActions object to the specified parent. */
+ static void addBindings( JSFactory *fac, KJS::ExecState *exec, KJS::Object &parent );
+
+ /** 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:
+ /** wrap a QPixmap **/
+ KJS::Value wrapPixmap(KJS::ExecState *exec,const QPixmap &icon);
+ uint id;
+ JSFactory *jsfact;
+};
+
+} // namespace BuiltIns
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_RESOURCES_H
diff --git a/kjsembed/builtins/saxhandler.cpp b/kjsembed/builtins/saxhandler.cpp
new file mode 100644
index 00000000..d4a6f5f3
--- /dev/null
+++ b/kjsembed/builtins/saxhandler.cpp
@@ -0,0 +1,186 @@
+/*
+ * 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 "kjsembed/jsbinding.h"
+#include "saxhandler.h"
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+SaxHandler::SaxHandler( KJS::ExecState *execstate )
+ : QXmlDefaultHandler(), exec(execstate), error( ErrorNone )
+{
+}
+
+SaxHandler::~SaxHandler()
+{
+}
+
+void SaxHandler::setHandler( const KJS::Object &handler )
+{
+ jshandler = handler;
+}
+
+bool SaxHandler::startDocument()
+{
+ if ( !jshandler.isValid() ) {
+ error = ErrorNoHandler;
+ return false;
+ }
+
+ KJS::Identifier funName("startDocument");
+ if ( !jshandler.hasProperty(exec, funName) )
+ return QXmlDefaultHandler::startDocument();
+
+ KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
+ if ( !fun.implementsCall() ) {
+ error = ErrorNotCallable;
+ return false;
+ }
+
+ KJS::Value ret = fun.call( exec, jshandler, KJS::List() );
+ return ret.toBoolean( exec );
+}
+
+bool SaxHandler::endDocument()
+{
+ if ( !jshandler.isValid() ) {
+ error = ErrorNoHandler;
+ return false;
+ }
+
+ KJS::Identifier funName("endDocument");
+ if ( !jshandler.hasProperty(exec, funName) )
+ return QXmlDefaultHandler::endDocument();
+
+ KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
+ if ( !fun.implementsCall() ) {
+ error = ErrorNotCallable;
+ return false;
+ }
+
+ KJS::Value ret = fun.call( exec, jshandler, KJS::List() );
+ return ret.toBoolean( exec );
+}
+
+bool SaxHandler::startElement( const QString &ns, const QString &ln, const QString &qn,
+ const QXmlAttributes &attrs )
+{
+ if ( !jshandler.isValid() ) {
+ error = ErrorNoHandler;
+ return false;
+ }
+
+ KJS::Identifier funName("startElement");
+ if ( !jshandler.hasProperty(exec, funName) )
+ return QXmlDefaultHandler::startElement( ns, ln, qn, attrs );
+
+ KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
+ if ( !fun.implementsCall() ) {
+ error = ErrorNotCallable;
+ return false;
+ }
+
+ KJS::List args;
+ args.append( KJS::String(ns) );
+ args.append( KJS::String(ln) );
+ args.append( KJS::String(qn) );
+ // TODO: XmlAttributes not yet supported
+
+ KJS::Value ret = fun.call( exec, jshandler, args );
+ return ret.toBoolean( exec );
+}
+
+bool SaxHandler::endElement( const QString &ns, const QString &ln, const QString &qn )
+{
+ if ( !jshandler.isValid() ) {
+ error = ErrorNoHandler;
+ return false;
+ }
+
+ KJS::Identifier funName("endElement");
+ if ( !jshandler.hasProperty(exec, funName) )
+ return QXmlDefaultHandler::endElement( ns, ln, qn );
+
+ KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
+ if ( !fun.implementsCall() ) {
+ error = ErrorNotCallable;
+ return false;
+ }
+
+ KJS::List args;
+ args.append( KJS::String(ns) );
+ args.append( KJS::String(ln) );
+ args.append( KJS::String(qn) );
+
+ KJS::Value ret = fun.call( exec, jshandler, args );
+ return ret.toBoolean( exec );
+}
+
+bool SaxHandler::characters( const QString &chars )
+{
+ if ( !jshandler.isValid() ) {
+ error = ErrorNoHandler;
+ return false;
+ }
+
+ KJS::Identifier funName("characters");
+ if ( !jshandler.hasProperty(exec, funName) )
+ return QXmlDefaultHandler::characters( chars );
+
+ KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
+ if ( !fun.implementsCall() ) {
+ error = ErrorNotCallable;
+ return false;
+ }
+
+ KJS::List args;
+ args.append( KJS::String(chars) );
+
+ KJS::Value ret = fun.call( exec, jshandler, args );
+ return ret.toBoolean( exec );
+}
+
+QString SaxHandler::errorString()
+{
+ switch( error ) {
+
+ case ErrorNoHandler:
+ return QString("No handler specified");
+ break;
+ case ErrorNotCallable:
+ return QString("One of the callbacks of the handler is not callable");
+ break;
+ case ErrorNone:
+ // This only means that no error occured in the JS dispatch, there
+ // could still have been an error from the parser so we fall
+ // though to call the baseclass.
+ break;
+ default:
+ break;
+ }
+
+ return QXmlDefaultHandler::errorString();
+}
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/saxhandler.h b/kjsembed/builtins/saxhandler.h
new file mode 100644
index 00000000..f396dbfe
--- /dev/null
+++ b/kjsembed/builtins/saxhandler.h
@@ -0,0 +1,80 @@
+// -*- 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_SAXHANDLER_H
+#define KJSEMBED_SAXHANDLER_H
+
+#include <qxml.h>
+#include <kjs/object.h>
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+/**
+ * SAX handler that calls JS methods according to the SAX API.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+class SaxHandler : public QXmlDefaultHandler
+{
+public:
+ /** Defines the errors that are specific to the KJS SAX support. */
+ enum SaxHandlerError {
+ ErrorNone,
+ ErrorNoHandler,
+ ErrorNotCallable
+ };
+
+ /** Creates a SaxHandler. */
+ SaxHandler( KJS::ExecState *exec );
+ /** Cleans up. */
+ virtual ~SaxHandler();
+
+ /**
+ * Sets the handler object that defines the callbacks to be invoked
+ * according to the SAX api.
+ */
+ void setHandler( const KJS::Object &handler );
+
+ virtual bool startDocument();
+ virtual bool endDocument();
+
+ virtual bool startElement( const QString &ns, const QString &ln, const QString &qn,
+ const QXmlAttributes &attrs );
+ virtual bool endElement( const QString &ns, const QString &ln, const QString &qn );
+ virtual bool characters( const QString &chars );
+
+ virtual QString errorString();
+
+private:
+ KJS::ExecState *exec;
+ KJS::Object jshandler;
+ int error;
+
+ class SaxHandlerPrivate *d;
+};
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_SAXHANDLER_H
+
+
diff --git a/kjsembed/builtins/stdaction_imp.cpp b/kjsembed/builtins/stdaction_imp.cpp
new file mode 100644
index 00000000..1361acf8
--- /dev/null
+++ b/kjsembed/builtins/stdaction_imp.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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 <kaction.h>
+#include <kdebug.h>
+#include <kstdaction.h>
+
+#include <jsfactory.h>
+#include <jsobjectproxy.h>
+
+#include "stdaction_imp.h"
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+StdActionImp::StdActionImp( KJS::ExecState *exec, JSFactory *fact, uint actid )
+ : JSProxyImp(exec), id(actid), jsfact( fact )
+{
+}
+
+StdActionImp::~StdActionImp()
+{
+}
+
+static uint KSTDACTION_START = KStdAction::New;
+static uint KSTDACTION_END = KStdAction::ConfigureNotifications+1;
+
+const char *factoryMethodNames[] = {
+ "START_MARKER",
+ "fileNew", "open", "openRecent", "save", "saveAs", "revert", "close",
+ "print", "printPreview", "mail", "quit",
+ "undo", "redo", "cut", "copy", "paste", "selectAll", "deselect", "find", "findNext", "findPrev",
+ "replace",
+ "actualSize", "fitToPage", "fitToWidth", "fitToHeight", "zoomIn", "zoomOut",
+ "zoom", "redisplay",
+ "up", "back", "forward", "home", "prior", "next", "goGoto", "gotoPage", "gotoLine",
+ "firstPage", "lastPage",
+ "addBookmark", "editBookmarks",
+ "spelling",
+ "showMenubar", "showToolbar", "showStatusbar", "saveOptions", "keyBindings",
+ "preferences", "configureToolbars",
+ "help", "helpContents", "whatsThis", "reportBug", "aboutApp", "aboutKDE",
+ "tipofDay",
+ "configureNotifications",
+ "END_MARKER"
+};
+
+void StdActionImp::addBindings( JSFactory *fact, KJS::ExecState *exec, KJS::Object &parent )
+{
+ for ( uint i = KSTDACTION_START; i < KSTDACTION_END; i++ ) {
+ StdActionImp *sai = new StdActionImp( exec, fact, i );
+ parent.put( exec, factoryMethodNames[i], KJS::Object( sai ) );
+ }
+}
+
+KJS::Value StdActionImp::call( KJS::ExecState *exec, KJS::Object &/*self*/, const KJS::List &args )
+{
+ if ( ( args.size() < 3 ) || ( args.size() > 4 ) )
+ return KJS::Null();
+
+ // recv, slot, parent, name?
+ QObject *recv = extractQObject( exec, args, 0);
+
+ QString sl = extractQString( exec, args, 1 );
+ const char *slc = sl.isNull() ? "" : sl.ascii();
+
+ QObject *parentobj = extractQObject( exec, args, 2 );
+ KActionCollection *parent = parentobj ? dynamic_cast<KActionCollection *>( parentobj ) : 0;
+
+ KStdAction::StdAction actid = static_cast<KStdAction::StdAction>(id);
+ const char *arg3 = (args.size() == 4) ? args[3].toString(exec).ascii() : KStdAction::name( actid );
+
+ // Create the object
+ KAction *act = KStdAction::create( actid, arg3, recv, slc, parent );
+ return jsfact->createProxy( exec, act );
+}
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/stdaction_imp.h b/kjsembed/builtins/stdaction_imp.h
new file mode 100644
index 00000000..9a64174b
--- /dev/null
+++ b/kjsembed/builtins/stdaction_imp.h
@@ -0,0 +1,68 @@
+// -*- 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_STDACTION_IMP_H
+#define KJSEMBED_STDACTION_IMP_H
+
+#include <kjs/interpreter.h>
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+namespace BuiltIns {
+
+/**
+ * KJS bindings to KStdAction.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+class StdActionImp : public JSProxyImp
+{
+public:
+ StdActionImp( KJS::ExecState *exec, JSFactory *fact, uint id );
+ virtual ~StdActionImp();
+
+ /** Adds the StdActions object to the specified parent. */
+ static void addBindings( JSFactory *fact, KJS::ExecState *exec, KJS::Object &parent );
+
+ /** 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:
+ uint id;
+ JSFactory *jsfact;
+};
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_STDACTION_IMP_H
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/stddialog_imp.cpp b/kjsembed/builtins/stddialog_imp.cpp
new file mode 100644
index 00000000..1b45c5e0
--- /dev/null
+++ b/kjsembed/builtins/stddialog_imp.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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 QT_ONLY
+
+#include <kcolordialog.h>
+#include <kfiledialog.h>
+#include <kpropertiesdialog.h>
+
+#else
+
+#include <qfiledialog.h>
+#define KFileDialog QFileDialog
+
+#endif // QT_ONLY
+
+#include <kjsembed/jsbinding.h>
+#include <kjsembed/global.h>
+
+#include "stddialog_imp.h"
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+StdDialogImp::StdDialogImp( KJS::ExecState *exec, int mid )
+ : JSProxyImp(exec), id(mid)
+{
+}
+
+StdDialogImp::~StdDialogImp() {}
+
+void StdDialogImp::addBindings( KJS::ExecState *exec, KJS::Object &parent )
+{
+ StdDialogImp *sdi;
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetOpenFileName );
+ parent.put( exec, "getOpenFileName", KJS::Object( sdi ) );
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetSaveFileName );
+ parent.put( exec, "getSaveFileName", KJS::Object( sdi ) );
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetOpenURL );
+ parent.put( exec, "getOpenURL", KJS::Object( sdi ) );
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetSaveURL );
+ parent.put( exec, "getSaveURL", KJS::Object( sdi ) );
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetExistingDirectory );
+ parent.put( exec, "getExistingDirectory", KJS::Object( sdi ) );
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetExistingURL );
+ parent.put( exec, "getExistingURL", KJS::Object( sdi ) );
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetImageOpenURL );
+ parent.put( exec, "getImageOpenURL", KJS::Object( sdi ) );
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodGetColor );
+ parent.put( exec, "getColor", KJS::Object( sdi ) );
+
+ sdi = new StdDialogImp( exec, StdDialogImp::MethodShowProperties );
+ parent.put( exec, "showProperties", KJS::Object( sdi ) );
+}
+
+KJS::Value StdDialogImp::call( KJS::ExecState *exec, KJS::Object &/*self*/, const KJS::List &args )
+{
+ QString arg0 = (args.size() > 0) ? args[0].toString(exec).qstring() : QString::null;
+ QString arg1 = (args.size() > 1) ? args[1].toString(exec).qstring() : QString::null;
+
+ switch( id ) {
+ case MethodGetOpenFileName:
+ {
+ QString s = KFileDialog::getOpenFileName( arg0, arg1 );
+ return KJS::String( s );
+ }
+ case MethodGetSaveFileName:
+ {
+ QString s = KFileDialog::getSaveFileName( arg0, arg1 );
+ return KJS::String( s );
+ }
+ case MethodGetExistingDirectory:
+ {
+ QString s = KFileDialog::getExistingDirectory( arg0 );
+ return KJS::String( s );
+ }
+#ifndef QT_ONLY
+ case MethodGetColor:
+ {
+ QColor col;
+ int res = KColorDialog::getColor( col );
+ if ( res == QDialog::Accepted )
+ return convertToValue( exec, QVariant(col) );
+ }
+ case MethodGetOpenURL:
+ {
+ KURL u = KFileDialog::getOpenURL( arg0, arg1 );
+ return KJS::String( u.url() );
+ }
+ case MethodGetSaveURL:
+ {
+ KURL u = KFileDialog::getSaveURL( arg0, arg1 );
+ return KJS::String( u.url() );
+ }
+ case MethodGetExistingURL:
+ {
+ KURL u = KFileDialog::getExistingURL( arg0 );
+ return KJS::String( u.url() );
+ }
+ case MethodGetImageOpenURL:
+ {
+ KURL u = KFileDialog::getImageOpenURL( arg0 );
+ return KJS::String( u.url() );
+ }
+ case MethodShowProperties:
+ {
+ // The default args mean this dialog auto-shows
+ /*KPropertiesDialog *dlg =*/ new KPropertiesDialog( KURL(arg0) );
+ return KJS::Null();
+ }
+#endif // QT_ONLY
+ default:
+ kdWarning() << "StdDialogImp has no method " << id << endl;
+ }
+
+ kdWarning() << "StdDialogImp returning null" << endl;
+
+ return KJS::Null();
+}
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/stddialog_imp.h b/kjsembed/builtins/stddialog_imp.h
new file mode 100644
index 00000000..ea70db73
--- /dev/null
+++ b/kjsembed/builtins/stddialog_imp.h
@@ -0,0 +1,81 @@
+// -*- 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_STDDIALOG_IMP_H
+#define KJSEMBED_STDDIALOG_IMP_H
+
+#include <kjs/interpreter.h>
+#include <kjs/object.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+/**
+ * Namespace containing the KJSEmbed library.
+ */
+namespace KJSEmbed {
+namespace BuiltIns {
+
+/**
+ * KJS bindings to the standard KDE dialogs.
+ *
+ * @author Richard Moore, rich@kde.org
+ */
+class StdDialogImp : public JSProxyImp
+{
+public:
+ /** Identifiers for the various methods. */
+ enum MethodId {
+ // KFileDialog
+ MethodGetOpenFileName, MethodGetSaveFileName,
+ MethodGetOpenURL, MethodGetSaveURL,
+ MethodGetExistingDirectory, MethodGetExistingURL,
+ MethodGetImageOpenURL,
+
+ // KColorDialog
+ MethodGetColor,
+ // KPropertiesDialog
+ MethodShowProperties
+ };
+
+ StdDialogImp( KJS::ExecState *exec, int id );
+ ~StdDialogImp();
+
+ /** Adds the StdDialogs object to the specified parent. */
+ static void addBindings( KJS::ExecState *exec, KJS::Object &parent );
+
+ /** 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:
+ uint id;
+};
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+#endif // KJSEMBED_STDDIALOG_IMP_H
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/textstream_imp.cpp b/kjsembed/builtins/textstream_imp.cpp
new file mode 100644
index 00000000..6be24dd9
--- /dev/null
+++ b/kjsembed/builtins/textstream_imp.cpp
@@ -0,0 +1,134 @@
+/*
+ * 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 <qtextstream.h>
+#include <qiodevice.h>
+
+#include <kjsembed/global.h>
+#include <kjsembed/jsbinding.h>
+#include "jsopaqueproxy.h"
+#include "textstream_imp.h"
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+TextStreamImp::TextStreamImp( KJS::ExecState *exec, int mid, QTextStream *textstream )
+ : JSProxyImp(exec), id(mid), ts(textstream)
+{
+}
+
+TextStreamImp::~TextStreamImp()
+{
+}
+
+void TextStreamImp::addBindings( KJS::ExecState *exec, KJS::Object &parent )
+{
+ kdDebug() << "TextStreamImp::addBindings()" << endl;
+
+ JSOpaqueProxy *op = JSProxy::toOpaqueProxy( parent.imp() );
+ if ( !op ) {
+ kdWarning() << "TextStreamImp::addBindings() failed, not a JSOpaqueProxy" << endl;
+ return;
+ }
+
+ QTextStream *ts = op->toTextStream();
+ if ( !ts ) {
+ kdWarning() << "TextStreamImp::addBindings() failed, type is " << op->typeName() << endl;
+ return;
+ }
+
+ JSProxy::MethodTable methods[] = {
+ { MethodIsReadable, "isReadable" },
+ { MethodIsWritable, "isWritable" },
+ { MethodPrint, "print" },
+ { MethodPrintLn, "println" },
+ { MethodReadLine, "readLine" },
+ { MethodFlush, "flush" },
+ { 0, 0 }
+ };
+
+ int idx = 0;
+ do {
+ TextStreamImp *tsi = new TextStreamImp( exec, idx, ts );
+ parent.put( exec , methods[idx].name, KJS::Object(tsi) );
+ ++idx;
+ } while( methods[idx].id );
+}
+
+KJS::Value TextStreamImp::call( KJS::ExecState *exec, KJS::Object &/*self*/, const KJS::List &args )
+{
+ QString not_readable = i18n( "Attempt to read from a write-only text stream." );
+ QString not_writable = i18n( "Attempt to write to a read-only text stream." );
+
+ QString arg0 = extractQString(exec, args, 0);
+
+ QIODevice *dev = ts->device();
+ KJS::Object err;
+
+ switch ( id ) {
+ case MethodIsReadable:
+ return KJS::Boolean( dev->isReadable() );
+ break;
+ case MethodIsWritable:
+ return KJS::Boolean( dev->isWritable() );
+ break;
+ case MethodPrint:
+ if ( !dev->isWritable() ) {
+ return throwError(exec, not_writable.utf8());
+ }
+ (*ts) << arg0;
+ break;
+ case MethodPrintLn:
+ if ( !dev->isWritable() ) {
+ return throwError(exec, not_writable.utf8());
+ }
+ (*ts) << arg0 << endl;
+ break;
+ case MethodReadLine:
+ if ( dev->isReadable() ) {
+ QString line = ts->readLine();
+ if ( line.isNull() )
+ return KJS::Null();
+ else
+ return KJS::String( line );
+ }
+ else {
+ return throwError(exec, not_readable.utf8());
+ }
+ break;
+ case MethodFlush:
+ if ( !dev->isWritable() ) {
+ return throwError(exec, not_writable.utf8());
+ }
+ (*ts) << flush;
+ break;
+ default:
+ kdWarning() << "TextStreamImp has no method " << id << endl;
+ break;
+ }
+
+ return KJS::Value();
+}
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+// Local Variables:
+// c-basic-offset: 4
+// End:
diff --git a/kjsembed/builtins/textstream_imp.h b/kjsembed/builtins/textstream_imp.h
new file mode 100644
index 00000000..ca46fc37
--- /dev/null
+++ b/kjsembed/builtins/textstream_imp.h
@@ -0,0 +1,79 @@
+// -*- 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 KJSEMBEDTEXTSTREAMIMP_H
+#define KJSEMBEDTEXTSTREAMIMP_H
+
+#include <kjs/object.h>
+#include <kjsembed/jsbinding.h>
+
+#include <kjsembed/jsobjectproxy_imp.h>
+
+class QTextStream;
+
+namespace KJSEmbed {
+namespace BuiltIns {
+
+/**
+ * Implements the JS methods of text stream object bindings.
+ *
+ * @author Richard Moore, rich@kde.org
+ * @version $Id$
+ */
+class TextStreamImp : public JSProxyImp
+{
+public:
+ /** Identifiers for the methods provided by this class. */
+ enum MethodId {
+ MethodIsReadable,
+ MethodIsWritable,
+ MethodPrint,
+ MethodPrintLn,
+ MethodReadLine,
+ MethodFlush
+ };
+
+ TextStreamImp( KJS::ExecState *exec, int id, QTextStream *ts );
+ ~TextStreamImp();
+
+ 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 id;
+ QTextStream *ts;
+
+ class TextStreamImpPrivate *d;
+};
+
+} // namespace KJSEmbed::BuiltIns
+} // namespace KJSEmbed
+
+#endif // KJSEMBEDTEXTSTREAMIMP_H
+
+// Local Variables:
+// c-basic-offset: 4
+// End: