khtml Library API Documentation

xmlhttprequest.h

00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 2003 Apple Computer, Inc. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #ifndef _XMLHTTPREQUEST_H_ 00022 #define _XMLHTTPREQUEST_H_ 00023 00024 #include "ecma/kjs_binding.h" 00025 #include "ecma/kjs_dom.h" 00026 #include "misc/decoder.h" 00027 #include "kio/jobclasses.h" 00028 00029 namespace KJS { 00030 00031 class JSEventListener; 00032 class XMLHttpRequestQObject; 00033 00034 // these exact numeric values are important because JS expects them 00035 enum XMLHttpRequestState { 00036 Uninitialized = 0, 00037 Loading = 1, 00038 Loaded = 2, 00039 Interactive = 3, 00040 Completed = 4 00041 }; 00042 00043 class XMLHttpRequestConstructorImp : public ObjectImp { 00044 public: 00045 XMLHttpRequestConstructorImp(ExecState *exec, const DOM::Document &d); 00046 virtual bool implementsConstruct() const; 00047 virtual Object construct(ExecState *exec, const List &args); 00048 private: 00049 DOM::Document doc; 00050 }; 00051 00052 class XMLHttpRequest : public DOMObject { 00053 public: 00054 XMLHttpRequest(ExecState *, const DOM::Document &d); 00055 ~XMLHttpRequest(); 00056 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00057 Value getValueProperty(ExecState *exec, int token) const; 00058 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None); 00059 void putValueProperty(ExecState *exec, int token, const Value& value, int /*attr*/); 00060 virtual bool toBoolean(ExecState *) const { return true; } 00061 virtual const ClassInfo* classInfo() const { return &info; } 00062 static const ClassInfo info; 00063 enum { Onload, Onreadystatechange, ReadyState, ResponseText, ResponseXML, Status, StatusText, Abort, GetAllResponseHeaders, GetResponseHeader, Open, Send, SetRequestHeader }; 00064 00065 private: 00066 friend class XMLHttpRequestProtoFunc; 00067 friend class XMLHttpRequestQObject; 00068 00069 Value getStatusText() const; 00070 Value getStatus() const; 00071 bool urlMatchesDocumentDomain(const KURL&) const; 00072 00073 XMLHttpRequestQObject *qObject; 00074 00075 #ifdef APPLE_CHANGES 00076 void slotData( KIO::Job* job, const char *data, int size ); 00077 #else 00078 void slotData( KIO::Job* job, const QByteArray &data ); 00079 #endif 00080 void slotFinished( KIO::Job* ); 00081 void slotRedirection( KIO::Job*, const KURL& ); 00082 00083 void processSyncLoadResults(const QByteArray &data, const KURL &finalURL, const QString &headers); 00084 00085 void open(const QString& _method, const KURL& _url, bool _async); 00086 void send(const QString& _body); 00087 void abort(); 00088 void setRequestHeader(const QString& name, const QString &value); 00089 Value getAllResponseHeaders() const; 00090 Value getResponseHeader(const QString& name) const; 00091 00092 void changeState(XMLHttpRequestState newState); 00093 00094 QGuardedPtr<DOM::DocumentImpl> doc; 00095 00096 KURL url; 00097 QString method; 00098 bool async; 00099 QString requestHeaders; 00100 00101 KIO::TransferJob * job; 00102 00103 XMLHttpRequestState state; 00104 JSEventListener *onReadyStateChangeListener; 00105 JSEventListener *onLoadListener; 00106 00107 khtml::Decoder *decoder; 00108 QString encoding; 00109 QString responseHeaders; 00110 00111 QString response; 00112 mutable bool createdDocument; 00113 mutable bool typeIsXML; 00114 mutable DOM::Document responseXML; 00115 00116 bool aborted; 00117 }; 00118 00119 00120 class XMLHttpRequestQObject : public QObject { 00121 Q_OBJECT 00122 00123 public: 00124 XMLHttpRequestQObject(XMLHttpRequest *_jsObject); 00125 00126 public slots: 00127 void slotData( KIO::Job* job, const QByteArray &data ); 00128 void slotFinished( KIO::Job* job ); 00129 void slotRedirection( KIO::Job* job, const KURL& url); 00130 00131 private: 00132 XMLHttpRequest *jsObject; 00133 }; 00134 00135 } // namespace 00136 00137 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:34:06 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003