[Kst] branches/work/kst/1.6/kst/src/extensions/js
Andrew Walker
arwalker at sumusltd.com
Fri Nov 23 01:16:03 CET 2007
SVN commit 740327 by arwalker:
near complete draft of ELOG functionality in javaScript - more testing needed
M +1 -0 Makefile.am
M +196 -10 bind_elog.cpp
M +60 -0 bind_elog.h
A elogthreadsubmit.cpp [License: GPL (v2+)]
A elogthreadsubmit.h [License: GPL (v2+)]
--- branches/work/kst/1.6/kst/src/extensions/js/Makefile.am #740326:740327
@@ -30,6 +30,7 @@
js.cpp \
jsiface.skel \
jsiface_impl.cpp \
+ elogthreadsubmit.cpp \
kstbinding.cpp \
bind_object.cpp \
bind_objectcollection.cpp \
--- branches/work/kst/1.6/kst/src/extensions/js/bind_elog.cpp #740326:740327
@@ -16,6 +16,7 @@
***************************************************************************/
#include "bind_elog.h"
+#include "elogthreadsubmit.h"
#include <kdebug.h>
@@ -79,7 +80,14 @@
{ "logbook", &KstBindELOG::setLogbook , &KstBindELOG::logbook },
{ "username", &KstBindELOG::setUsername , &KstBindELOG::username },
{ "password", &KstBindELOG::setPassword , &KstBindELOG::password },
+ { "writePassword", &KstBindELOG::setWritePassword , &KstBindELOG::writePassword },
+ { "encodedHTML", &KstBindELOG::setEncodedHTML , &KstBindELOG::encodedHTML },
{ "text", &KstBindELOG::setText , &KstBindELOG::text },
+ { "includeCapture", &KstBindELOG::setIncludeCapture , &KstBindELOG::includeCapture },
+ { "captureWidth", &KstBindELOG::setCaptureWidth , &KstBindELOG::captureWidth },
+ { "captureHeight", &KstBindELOG::setCaptureHeight , &KstBindELOG::captureHeight },
+ { "includeConfiguration", &KstBindELOG::setIncludeConfiguration , &KstBindELOG::includeConfiguration },
+ { "includeDebugInfo", &KstBindELOG::setIncludeDebugInfo , &KstBindELOG::includeDebugInfo },
{ 0L, 0L, 0L }
};
@@ -108,11 +116,6 @@
void KstBindELOG::put(KJS::ExecState *exec, const KJS::Identifier& propertyName, const KJS::Value& value, int attr) {
-/* if (!_f) {
- KstBinding::put(exec, propertyName, value, attr);
- return;
- }
-*/
QString prop = propertyName.qstring();
for (int i = 0; elogProperties[i].name; ++i) {
if (prop == elogProperties[i].name) {
@@ -129,11 +132,6 @@
KJS::Value KstBindELOG::get(KJS::ExecState *exec, const KJS::Identifier& propertyName) const {
-/*
- if (!_f) {
- return KstBinding::get(exec, propertyName);
- }
-*/
QString prop = propertyName.qstring();
for (int i = 0; elogProperties[i].name; ++i) {
if (prop == elogProperties[i].name) {
@@ -176,6 +174,9 @@
KJS::Value KstBindELOG::submit(KJS::ExecState *exec, const KJS::List& args) {
+ ElogThreadSubmit* pThread;
+ QByteArray byteArrayCapture;
+
if (args.size() != 0) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires no arguments.");
exec->setException(eobj);
@@ -188,6 +189,23 @@
return KJS::Undefined();
}
+ pThread = new ElogThreadSubmit(_hostname,
+ _port,
+ false,
+ false,
+ false,
+ &byteArrayCapture,
+ _text,
+ _username,
+ _password,
+ _writePassword,
+ _logbook,
+ _attributes,
+ _attachments,
+ _encodedHTML,
+ _suppressEmailNotification);
+ pThread->doTransmit();
+
return KJS::Boolean(true);
}
@@ -205,6 +223,12 @@
return KJS::Boolean(false);
}
+ if (_attachments.count()+1 >= MAX_ATTACHMENTS) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError, "Maximum number of attachments has been reached.");
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
_attachments.append(args[0].toString(exec).qstring());
return KJS::Boolean(true);
}
@@ -241,6 +265,12 @@
return KJS::Boolean(false);
}
+ if (_attributes.count()+1 >= MAX_N_ATTR) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError, "Maximum number of attributes has been reached.");
+ exec->setException(eobj);
+ return KJS::Undefined();
+ }
+
_attributes.insert(args[0].toString(exec).qstring(), args[1].toString(exec).qstring());
return KJS::Boolean(true);
}
@@ -360,6 +390,23 @@
}
+KJS::Value KstBindELOG::writePassword(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::String(_writePassword);
+}
+
+
+void KstBindELOG::setWritePassword(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::StringType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _writePassword = value.toString(exec).qstring();
+}
+
+
KJS::Value KstBindELOG::text(KJS::ExecState *exec) const {
Q_UNUSED(exec)
@@ -375,3 +422,142 @@
}
_text = value.toString(exec).qstring();
}
+
+
+KJS::Value KstBindELOG::suppressEmailNotification(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Boolean(_suppressEmailNotification);
+}
+
+
+void KstBindELOG::setSuppressEmailNotification(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _suppressEmailNotification = value.toBoolean(exec);
+}
+
+
+KJS::Value KstBindELOG::encodedHTML(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Boolean(_encodedHTML);
+}
+
+
+void KstBindELOG::setEncodedHTML(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _encodedHTML = value.toBoolean(exec);
+}
+
+
+KJS::Value KstBindELOG::includeCapture(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Boolean(_includeCapture);
+}
+
+
+void KstBindELOG::setIncludeCapture(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _includeCapture = value.toBoolean(exec);
+}
+
+
+KJS::Value KstBindELOG::captureWidth(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Number(_captureWidth);
+}
+
+
+void KstBindELOG::setCaptureWidth(KJS::ExecState *exec, const KJS::Value& value) {
+ int val;
+
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ val = value.toInt32(exec);
+ if (val <= 0 || val > 10000) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::RangeError, "Value is out of range" );
+ exec->setException(eobj);
+ return;
+ }
+
+ _captureWidth = val;
+}
+
+
+KJS::Value KstBindELOG::captureHeight(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Number(_captureHeight);
+}
+
+
+void KstBindELOG::setCaptureHeight(KJS::ExecState *exec, const KJS::Value& value) {
+ int val;
+
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+
+ val = value.toInt32(exec);
+ if (val <= 0 || val > 10000) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::RangeError, "Value is out of range" );
+ exec->setException(eobj);
+ return;
+ }
+
+ _captureHeight = val;
+}
+
+
+KJS::Value KstBindELOG::includeConfiguration(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Boolean(_includeConfiguration);
+}
+
+
+void KstBindELOG::setIncludeConfiguration(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _includeConfiguration = value.toBoolean(exec);
+}
+
+
+KJS::Value KstBindELOG::includeDebugInfo(KJS::ExecState *exec) const {
+ Q_UNUSED(exec)
+
+ return KJS::Boolean(_includeDebugInfo);
+}
+
+
+void KstBindELOG::setIncludeDebugInfo(KJS::ExecState *exec, const KJS::Value& value) {
+ if (value.type() != KJS::BooleanType) {
+ KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
+ exec->setException(eobj);
+ return;
+ }
+ _includeDebugInfo = value.toBoolean(exec);
+}
--- branches/work/kst/1.6/kst/src/extensions/js/bind_elog.h #740326:740327
@@ -23,6 +23,9 @@
#include <kjs/interpreter.h>
#include <kjs/object.h>
+#define MAX_ATTACHMENTS 50
+#define MAX_N_ATTR 50
+
/* @class ELOG
@description An object that represents the interface to an ELOG server.
*/
@@ -105,12 +108,60 @@
KJS::Value password(KJS::ExecState *exec) const;
void setPassword(KJS::ExecState *exec, const KJS::Value& value);
+ /* @property string writePassword
+ @description The write password.
+ */
+ KJS::Value writePassword(KJS::ExecState *exec) const;
+ void setWritePassword(KJS::ExecState *exec, const KJS::Value& value);
+
/* @property string text
@description Text.
*/
KJS::Value text(KJS::ExecState *exec) const;
void setText(KJS::ExecState *exec, const KJS::Value& value);
+ /* @property boolean encodedHTML
+ @description The message is HTML encoded.
+ */
+ KJS::Value encodedHTML(KJS::ExecState *exec) const;
+ void setEncodedHTML(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property boolean suppressEmailNotification
+ @description If true email notification is suppressed.
+ */
+ KJS::Value suppressEmailNotification(KJS::ExecState *exec) const;
+ void setSuppressEmailNotification(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property boolean includeCapture
+ @description If true an image capture of the Kst session is included in the ELOG entry.
+ */
+ KJS::Value includeCapture(KJS::ExecState *exec) const;
+ void setIncludeCapture(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property number captureWidth
+ @description The width of the image capture to be included in the ELOG entry.
+ */
+ KJS::Value captureWidth(KJS::ExecState *exec) const;
+ void setCaptureWidth(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property number captureHeight
+ @description The height of the image capture to be included in the ELOG entry.
+ */
+ KJS::Value captureHeight(KJS::ExecState *exec) const;
+ void setCaptureHeight(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property boolean includeConfiguration
+ @description If true a capture of the Kst session is included in the ELOG entry.
+ */
+ KJS::Value includeConfiguration(KJS::ExecState *exec) const;
+ void setIncludeConfiguration(KJS::ExecState *exec, const KJS::Value& value);
+
+ /* @property boolean includeDebugInfo
+ @description If true a capture of the Kst debug information is included in the ELOG entry.
+ */
+ KJS::Value includeDebugInfo(KJS::ExecState *exec) const;
+ void setIncludeDebugInfo(KJS::ExecState *exec, const KJS::Value& value);
+
protected:
KstBindELOG(int id);
void addBindings(KJS::ExecState *exec, KJS::Object& obj);
@@ -121,11 +172,20 @@
QString _hostname;
int _port;
QString _logbook;
+ QString _writePassword;
QString _password;
QString _username;
QString _text;
QStringList _attachments;
QMap<QString, QString> _attributes;
+
+ bool _suppressEmailNotification;
+ bool _encodedHTML;
+ bool _includeCapture;
+ bool _includeConfiguration;
+ bool _includeDebugInfo;
+ int _captureWidth;
+ int _captureHeight;
};
#endif
More information about the Kst
mailing list