# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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,
    00064            GetAllResponseHeaders, GetResponseHeader, Open, Send, SetRequestHeader };
    00065
    00066   private:
    00067     friend class XMLHttpRequestProtoFunc;
    00068     friend class XMLHttpRequestQObject;
    00069
    00070     Value getStatusText() const;
    00071     Value getStatus() const;
    00072     bool urlMatchesDocumentDomain(const KURL&) const;
    00073
    00074     XMLHttpRequestQObject *qObject;
    00075
    00076 #ifdef APPLE_CHANGES
    00077     void slotData( KIO::Job* job, const char *data, int size );
    00078 #else
    00079     void slotData( KIO::Job* job, const QByteArray &data );
    00080 #endif
    00081     void slotFinished( KIO::Job* );
    00082     void slotRedirection( KIO::Job*, const KURL& );
    00083
    00084     void processSyncLoadResults(const QByteArray &data, const KURL &finalURL, const QString &headers);
    00085
    00086     void open(const QString& _method, const KURL& _url, bool _async);
    00087     void send(const QString& _body);
    00088     void abort();
    00089     void setRequestHeader(const QString& name, const QString &value);
    00090     Value getAllResponseHeaders() const;
    00091     Value getResponseHeader(const QString& name) const;
    00092
    00093     void changeState(XMLHttpRequestState newState);
    00094
    00095     QGuardedPtr<DOM::DocumentImpl> doc;
    00096
    00097     KURL url;
    00098     QString method;
    00099     bool async;
    00100     QString requestHeaders;
    00101     QString contentType;
    00102
    00103     KIO::TransferJob * job;
    00104
    00105     XMLHttpRequestState state;
    00106     JSEventListener *onReadyStateChangeListener;
    00107     JSEventListener *onLoadListener;
    00108
    00109     khtml::Decoder *decoder;
    00110     QString encoding;
    00111     QString responseHeaders;
    00112
    00113     QString response;
    00114     mutable bool createdDocument;
    00115     mutable bool typeIsXML;
    00116     mutable DOM::Document responseXML;
    00117
    00118     bool aborted;
    00119   };
    00120
    00121
    00122   class XMLHttpRequestQObject : public QObject {
    00123     Q_OBJECT
    00124
    00125   public:
    00126     XMLHttpRequestQObject(XMLHttpRequest *_jsObject);
    00127
    00128   public slots:
    00129     void slotData( KIO::Job* job, const QByteArray &data );
    00130     void slotFinished( KIO::Job* job );
    00131     void slotRedirection( KIO::Job* job, const KURL& url);
    00132
    00133   private:
    00134     XMLHttpRequest *jsObject;
    00135   };
    00136
    00137 } // namespace
    00138
    00139 #endif

This file is part of the documentation for khtml Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:33:19 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003