21 files changed, 1303 insertions, 0 deletions
diff --git a/noncore/net/ubrowser/Makefile b/noncore/net/ubrowser/Makefile new file mode 100644 index 0000000..4d92441 --- a/dev/null +++ b/noncore/net/ubrowser/Makefile @@ -0,0 +1,253 @@ +############################################################################# +# Automatically generated from noncore/ubrowser/Makefile.in +# Build options from +############################################################################# + +# Compiling +INTERFACE_DECL_PATH = . +SYSCONF_CXX = arm-linux-g++ +SYSCONF_CC = arm-linux-gcc +DASHCROSS = -arm + +# Compiling with support libraries +SYSCONF_CXXFLAGS_X11 = +SYSCONF_CXXFLAGS_QT = -I$(QTDIR)/include +SYSCONF_CXXFLAGS_OPENGL = -I/usr/X11R6/include + +# Compiling YACC output +SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses + +# Linking with support libraries +SYSCONF_RPATH_X11 = +SYSCONF_RPATH_QT = -Wl,-rpath,$(QTDIR)/lib +SYSCONF_RPATH_OPENGL = -Wl,-rpath,/usr/X11R6/lib + +# Linking with support libraries +# X11 +SYSCONF_LFLAGS_X11 = +SYSCONF_LIBS_X11 = +# Qt, Qt+OpenGL +SYSCONF_LFLAGS_QT = -L$(QTDIR)/lib +SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) +SYSCONF_LIBS_QT_OPENGL = +# OpenGL +SYSCONF_LFLAGS_OPENGL = -L/usr/X11R6/lib +SYSCONF_LIBS_OPENGL = +# Yacc +SYSCONF_LIBS_YACC = + +# Linking applications +SYSCONF_LINK = arm-linux-gcc +SYSCONF_LFLAGS = +SYSCONF_LIBS = + +# Link flags for shared objects +SYSCONF_LFLAGS_SHOBJ = -shared + +# Flags for threading +SYSCONF_CFLAGS_THREAD = -D_REENTRANT +SYSCONF_CXXFLAGS_THREAD = -D_REENTRANT +SYSCONF_LFLAGS_THREAD = +SYSCONF_LIBS_THREAD = -lpthread + +# Meta-object compiler +SYSCONF_MOC = $(QTDIR)/bin/moc + +# UI compiler +SYSCONF_UIC = $(QTDIR)/bin/uic + +# Linking shared libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 +# - Place target in $(DESTDIR) - which has a trailing / +# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) +# +SYSCONF_LINK_SHLIB = arm-linux-gcc +SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) +SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ + $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ + $(OBJECTS) $(OBJMOC) $(LIBS) && \ + mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ + cd $(DESTDIR) && \ + rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) + +# Linking static libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).a +# - Place target in $(DESTDIR) - which has a trailing / +# +SYSCONF_AR = arm-linux-ar cqs +SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a +SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ + $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) +# Compiling application source +SYSCONF_CXXFLAGS = -pipe -DQT_QWS_IPAQ -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W +SYSCONF_CFLAGS = -pipe -O2 -Wall -W +# Default link type (static linking is still be used where required) +SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) +SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) +# Compiling library source +SYSCONF_CXXFLAGS_LIB = -fPIC +SYSCONF_CFLAGS_LIB = -fPIC +# Compiling shared-object source +SYSCONF_CXXFLAGS_SHOBJ = -fPIC +SYSCONF_CFLAGS_SHOBJ = -fPIC +# Linking Qt +SYSCONF_LIBS_QTLIB = $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) +# Linking Qt applications +SYSCONF_LIBS_QTAPP = +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(OPIEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = $(OPIEDIR)/bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = ubrowser +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = mainview.h \ + httpfactory.h \ + httpcomm.h +SOURCES = main.cpp \ + mainview.cpp \ + httpfactory.cpp \ + httpcomm.cpp +OBJECTS = main.o \ + mainview.o \ + httpfactory.o \ + httpcomm.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_mainview.cpp \ + moc_httpcomm.cpp +OBJMOC = moc_mainview.o \ + moc_httpcomm.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake ubrowser.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +main.o: main.cpp \ + $(OPIEDIR)/include/qpe/qpeapplication.h \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +mainview.o: mainview.cpp \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +httpfactory.o: httpfactory.cpp \ + httpfactory.h \ + httpcomm.h + +httpcomm.o: httpcomm.cpp \ + httpcomm.h + +moc_mainview.o: moc_mainview.cpp \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +moc_httpcomm.o: moc_httpcomm.cpp \ + httpcomm.h + +moc_mainview.cpp: mainview.h + $(MOC) mainview.h -o moc_mainview.cpp + +moc_httpcomm.cpp: httpcomm.h + $(MOC) httpcomm.h -o moc_httpcomm.cpp + + + +lupdate: + lupdate ubrowser.pro + +lrelease: + lrelease ubrowser.pro + diff --git a/noncore/net/ubrowser/Makefile.in b/noncore/net/ubrowser/Makefile.in new file mode 100644 index 0000000..010f16f --- a/dev/null +++ b/noncore/net/ubrowser/Makefile.in @@ -0,0 +1,147 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(OPIEDIR)/include +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = $(OPIEDIR)/bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = ubrowser +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = mainview.h \ + httpfactory.h \ + httpcomm.h +SOURCES = main.cpp \ + mainview.cpp \ + httpfactory.cpp \ + httpcomm.cpp +OBJECTS = main.o \ + mainview.o \ + httpfactory.o \ + httpcomm.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = moc_mainview.cpp \ + moc_httpcomm.cpp +OBJMOC = moc_mainview.o \ + moc_httpcomm.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake ubrowser.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +main.o: main.cpp \ + $(OPIEDIR)/include/qpe/qpeapplication.h \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +mainview.o: mainview.cpp \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +httpfactory.o: httpfactory.cpp \ + httpfactory.h \ + httpcomm.h + +httpcomm.o: httpcomm.cpp \ + httpcomm.h + +moc_mainview.o: moc_mainview.cpp \ + mainview.h \ + $(OPIEDIR)/include/qpe/resource.h \ + $(OPIEDIR)/include/qpe/qpetoolbar.h \ + httpfactory.h \ + httpcomm.h + +moc_httpcomm.o: moc_httpcomm.cpp \ + httpcomm.h + +moc_mainview.cpp: mainview.h + $(MOC) mainview.h -o moc_mainview.cpp + +moc_httpcomm.cpp: httpcomm.h + $(MOC) httpcomm.h -o moc_httpcomm.cpp + + diff --git a/noncore/net/ubrowser/gnu-license-header b/noncore/net/ubrowser/gnu-license-header new file mode 100644 index 0000000..9973e8c --- a/dev/null +++ b/noncore/net/ubrowser/gnu-license-header @@ -0,0 +1,15 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/
\ No newline at end of file diff --git a/noncore/net/ubrowser/httpcomm.cpp b/noncore/net/ubrowser/httpcomm.cpp new file mode 100644 index 0000000..51068db --- a/dev/null +++ b/noncore/net/ubrowser/httpcomm.cpp @@ -0,0 +1,256 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "httpcomm.h" + +HttpComm::HttpComm(QSocket *newSocket, QTextBrowser *newBrowser):QObject() +{ + socket = newSocket; + + connect(socket, SIGNAL(hostFound()), this, SLOT(hostFound()) ); + connect(socket, SIGNAL(connected()), this, SLOT(connected()) ); + connect(socket, SIGNAL(readyRead()), this, SLOT(incoming()) ); + connect(socket, SIGNAL(connectionClosed()), this, SLOT(connectionClosed()) ); + + headerRead=false; + length = 0; + bRead = 0; + chunked=false; + lengthset=false; + + browser=newBrowser; +} + +void HttpComm::setUp(QString *newName) +{ + name = newName; +} + +void HttpComm::setStuff(QString newHost, QString newPortS, QString newFile, QTextDrag *newText) +{ + host = newHost; + portS = newPortS; + file = newFile; + text = newText; +} + +void HttpComm::hostFound() +{ + printf("HttpComm::hostFound: host found\n"); +} + +void HttpComm::connected() +{ + QString request("GET " + file + " HTTP/1.1\r\nHost: " + host + ':' + portS + "\r\nConnection: close\r\n\r\n"); +// QString request("GET " + file + " HTTP/1.0\r\n\r\n"); + printf("HttpComm::data: bytes written: %d\n", socket->writeBlock(request.latin1(), request.length()) ); + printf("HttpComm::data: request sent:\n%s", request.latin1()); + + headerRead=false; + bRead=0; + length = 0; + header=""; + body=""; + chunked=false; + lengthset=false; +} + +void HttpComm::incoming() +{ + int ba=socket->bytesAvailable(), i=0, j=0, semi=0; + char *tempString = new char [ba]; + bool nextChunk=false; + bool done=false; + socket->readBlock(tempString, ba); + printf("HttpComm::incoming: ba: %d\n", ba); + QString sclength; + + if(headerRead == false) + { + for(i=0; i<ba; i++) + { + if(tempString[i] != '\r') + { + if(tempString[i] == '\n' && header[header.length()-1] == '\n') + { + j=i; + headerRead = true; + parseHeader(); + goto body; + } + else + { + header+=tempString[i]; + } + } +// printf("%d %d\n", ba, i); + } + } + else + { + body: + printf("HttpComm::incoming: reading body\n"); + printf("HttpComm::incoming: j is: %d\n", j); + if(!chunked) + { +//make sure we didnt just leave that break above... + if(j != 0) + { + for( ; j<ba ; j++) + { + body+=tempString[j]; + bRead++; +// printf("bRead1: %d\n", bRead); + } + } + else + { + body += tempString; + bRead+=ba; +// printf("bRead2: %d\n", bRead); + } + + if(bRead >= length) + { + printf("HttpComm::incoming: finished reading body\n"); + processBody(); + socket->close(); + } + } + else + { + QString tempQString = tempString; + //remove the http header, if one exists + if(j != 0) + { + tempQString.remove(0, j); + } + while(!done) + { + switch(status) + { + //case 0=need to read chunk length + case 0: + j = tempQString.find('\n'); + sclength = tempQString; + sclength.truncate(j); + clength = sclength.toUInt(0, 16); + printf("HttpComm::Incoming: chunk length: %d\n", clength); + if(clength==0) + { + processBody(); + done=true; + } + if(ba <= j) + { + status=1; + done=true; +// break; + } + else + { + done=false; + } + bRead=0; + break; + //if there is more fall through to: + //chunk length just read, still more in tempQstring + case 1: + //the current data extends beyond the end of the chunk + if(bRead + tempQString.length() > clength) + { + QString newTQstring = tempQString; + newTQstring.truncate(clength-bRead); + body+=newTQstring; + printf("HttpComm::incoming: start new body piece 1: \n"); + printf("%s", newTQstring.latin1() ); + printf("HttpComm::incoming: end new body piece 1.\n"); + status=0; + j=clength-bRead; + done=false; + break; + } + //the chunk extends beyond the current data; + else + { + body+=tempQString; + bRead+=ba; + printf("HttpComm::incoming: start new body piece 2: \n"); + printf("%s", tempQString.latin1() ); + printf("HttpComm::incoming: end new body piece 2.\n"); + done=true; + break; + } + break; + } + } + } + } + delete tempString; +} + +void HttpComm::connectionClosed() +{ + printf("HttpComm::connectionClosed: connection closed\n"); + processBody(); +} + +void HttpComm::parseHeader() +{ + QStringList headerLines, tempList; + int i; + + printf("HttpComm::parseHeader: start header\n\n"); + printf("%s", header.latin1()); + printf("HttpComm::parseHeader: end header\n"); + + headerLines = QStringList::split('\n', header); + + for(i=0; i<headerLines.count(); i++) + { + if(headerLines[i].startsWith("Content-Length:") ) + { + tempList = QStringList::split(':', headerLines[i]); + tempList[1].stripWhiteSpace(); + length = tempList[1].toUInt(); + } + else if(headerLines[i].startsWith("Transfer-Encoding: chunked") ) + { + printf("HttpComm::parseHeader: using chunked encoding\n"); + chunked = true; + status=0; + } + } + + printf("HttpConn::parseHeader: content-length: %d\n", length); +} + +void HttpComm::processBody() +{ +// printf("HttpComm::processBody: start body\n\n"); +// printf("%s", body.latin1()); +// printf("HttpComm::processBody: end body\n"); + + int lastSlash = file.findRev('/'); + + QString end = file; + end.truncate(lastSlash-1); + QString context("http://"+host+':'+portS+end); + + browser->setTextFormat(RichText); + browser->setText(body, context); + printf("%s\n", context.latin1() ); +} diff --git a/noncore/net/ubrowser/httpcomm.h b/noncore/net/ubrowser/httpcomm.h new file mode 100644 index 0000000..c20fe72 --- a/dev/null +++ b/noncore/net/ubrowser/httpcomm.h @@ -0,0 +1,57 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <qobject.h> +#include <qstring.h> +#include <qsocket.h> +#include <qstringlist.h> +#include <qdragobject.h> +#include <qtextbrowser.h> + +#include <stdio.h> + +class HttpComm : public QObject +{ +Q_OBJECT +public: + HttpComm(QSocket *newSocket, QTextBrowser *newBrowser); + void setUp(QString *newName); + void setStuff(QString newHost, QString newPortS, QString newFile, QTextDrag *newText); + void parseHeader(); + void processBody(); +public slots: + void hostFound(); + void connected(); + void connectionClosed(); + void incoming(); +private: + QString *name; + QSocket *socket; + QString host; + QString portS; + QString file; + bool headerRead; + QString header; + QString body; + unsigned int length; + unsigned int bRead; + QTextDrag *text; + QTextBrowser *browser; + bool chunked; + bool lengthset; + unsigned int clength; + int status; +}; diff --git a/noncore/net/ubrowser/httpcomm.o b/noncore/net/ubrowser/httpcomm.o Binary files differnew file mode 100644 index 0000000..144d123 --- a/dev/null +++ b/noncore/net/ubrowser/httpcomm.o diff --git a/noncore/net/ubrowser/httpfactory.cpp b/noncore/net/ubrowser/httpfactory.cpp new file mode 100644 index 0000000..92718fb --- a/dev/null +++ b/noncore/net/ubrowser/httpfactory.cpp @@ -0,0 +1,104 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "httpfactory.h" + +HttpFactory::HttpFactory(QTextBrowser *newBrowser):QMimeSourceFactory() +{ + socket = new QSocket; + text = new QTextDrag; + browser=newBrowser; + comm = new HttpComm(socket, browser); +} + +const QMimeSource * HttpFactory::data(const QString &abs_name) const +{ + printf("HttpFactory::data: using absolute data func\n"); + + int port=80, addrEnd, portSep; + QString host, file, portS, name, tempString; + bool done=false; + + comm->setUp((QString *)&abs_name); + + name = abs_name; +// name = name.lower(); + name = name.stripWhiteSpace(); + + printf("%s\n", name.latin1()); + + if(name.startsWith("http://")) + { + name = name.remove(0, 7); + } + else + { + return 0; + } + + addrEnd = name.find('/'); + if(addrEnd == -1) + { + name += '/'; + addrEnd = name.length()-1; + } + + host = name; + file = name; + + host.truncate(addrEnd); + file.remove(0, addrEnd); + + portSep = host.find(':'); + if(portSep != -1) + { + portS=host; + host.truncate(portSep); + portS.remove(0, portSep+1); + port = portS.toInt(); + } + + printf("%s %s %d\n", host.latin1(), file.latin1(), port); + + if(port == 80) + { + portS="80"; + } + + comm->setStuff(host, portS, file, text); + + socket->connectToHost(host, port); + + text->setText(""); + + return text; +} + +const QMimeSource * HttpFactory::data(const QString &abs_or_rel_name, const QString & context) const +{ + printf("HttpFactory::data: using relative data func\n"); + + if(abs_or_rel_name.startsWith(context)) + { + return data(abs_or_rel_name); + } + else + { + return data(context + abs_or_rel_name); + } + + return 0; +} diff --git a/noncore/net/ubrowser/httpfactory.h b/noncore/net/ubrowser/httpfactory.h new file mode 100644 index 0000000..bb7615b --- a/dev/null +++ b/noncore/net/ubrowser/httpfactory.h @@ -0,0 +1,38 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <qmime.h> +#include <qsocket.h> +#include <qstring.h> +#include <qdragobject.h> +#include <qtextbrowser.h> + +#include <stdio.h> + +#include "httpcomm.h" + +class HttpFactory : public QMimeSourceFactory +{ +public: + HttpFactory(QTextBrowser *newBrowser); + const QMimeSource * data(const QString &abs_name) const; + const QMimeSource * data(const QString &abs_or_rel_name, const QString & context) const; +private: + QSocket *socket; + HttpComm *comm; + QTextDrag *text; + QTextBrowser *browser; +}; diff --git a/noncore/net/ubrowser/httpfactory.o b/noncore/net/ubrowser/httpfactory.o Binary files differnew file mode 100644 index 0000000..949d943 --- a/dev/null +++ b/noncore/net/ubrowser/httpfactory.o diff --git a/noncore/net/ubrowser/main.cpp b/noncore/net/ubrowser/main.cpp new file mode 100644 index 0000000..fe0f243 --- a/dev/null +++ b/noncore/net/ubrowser/main.cpp @@ -0,0 +1,29 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <qpe/qpeapplication.h> + +#include "mainview.h" + +int main( int argc, char **argv ) +{ + QPEApplication a( argc, argv ); + MainView w; + + a.setMainWidget( &w ); + w.showMaximized(); + return a.exec(); +} diff --git a/noncore/net/ubrowser/main.o b/noncore/net/ubrowser/main.o Binary files differnew file mode 100644 index 0000000..417abd2 --- a/dev/null +++ b/noncore/net/ubrowser/main.o diff --git a/noncore/net/ubrowser/mainview.cpp b/noncore/net/ubrowser/mainview.cpp new file mode 100644 index 0000000..87a7d6a --- a/dev/null +++ b/noncore/net/ubrowser/mainview.cpp @@ -0,0 +1,88 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#include "mainview.h" + +MainView::MainView(QWidget *parent=0, const char *name=0) : QMainWindow(parent, name) +{ + setCaption("uBrowser"); + + QPEToolBar *toolbar = new QPEToolBar(this, "toolbar"); + back = new QToolButton(Resource::loadPixmap("ubrowser/back"), 0, 0, 0, 0, toolbar, "back"); + forward = new QToolButton(Resource::loadPixmap("ubrowser/forward"), 0, 0, 0, 0, toolbar, "forward"); + home = new QToolButton(Resource::loadPixmap("ubrowser/home"), 0, 0, 0, 0, toolbar, "home"); + location = new QComboBox(true, toolbar, "location"); + go = new QToolButton(Resource::loadPixmap("ubrowser/go"), 0, 0, 0, 0, toolbar, "go"); + + toolbar->setStretchableWidget(location); + toolbar->setHorizontalStretchable(true); + + addToolBar(toolbar); + + browser = new QTextBrowser(this, "browser"); + setCentralWidget(browser); + +//make the button take you to the location + connect(go, SIGNAL(clicked()), this, SLOT(goClicked()) ); + connect(location->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goClicked()) ); + +//make back, forward and home do their thing (isnt QTextBrowser great?) + connect(back, SIGNAL(clicked()), browser, SLOT(backward()) ); + connect(forward, SIGNAL(clicked()), browser, SLOT(forward()) ); + connect(home, SIGNAL(clicked()), browser, SLOT(home()) ); + +//make back and forward buttons be enabled, only when you can go back or forward (again, i love QTextBrowser) +//this doesnt seem to work, but doesnt break anything either... + connect(browser, SIGNAL(backwardAvailable(bool)), back, SLOT(setOn(bool)) ); + connect(browser, SIGNAL(forwardAvailable(bool)), forward, SLOT(setOn(bool)) ); + +//notify me when the text of the browser has changed (like when the user clicks a link) + connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()) ); + + http = new HttpFactory(browser); +} + +void MainView::goClicked() +{ + if(location->currentText().startsWith("http://") ) + { + location->setEditText(location->currentText().lower()); + browser->setMimeSourceFactory(http); + printf("MainView::goClicked: using http source factory\n"); + } + else + { + browser->setMimeSourceFactory(QMimeSourceFactory::defaultFactory()); + printf("MainView::goClicked: using default source factory\n"); + } + + browser->setSource(location->currentText()); +} + +void MainView::textChanged() +{ + if(browser->documentTitle().isNull()) + { + setCaption(browser->source() + " - uBrowser"); + } + else + { + setCaption(browser->documentTitle() + " - uBrowser"); + } + + location->setEditText(browser->source()); +} diff --git a/noncore/net/ubrowser/mainview.h b/noncore/net/ubrowser/mainview.h new file mode 100644 index 0000000..bd9d19c --- a/dev/null +++ b/noncore/net/ubrowser/mainview.h @@ -0,0 +1,48 @@ +/* +Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing +Copyright (C) 2002 Thomas Stephens + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public +License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later +version. + +This program 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 General +Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include <qpe/resource.h> +#include <qpe/qpetoolbar.h> + +#include <qmainwindow.h> +#include <qwidget.h> +#include <qtextbrowser.h> +#include <qtoolbutton.h> +#include <qcombobox.h> +#include <qlayout.h> +#include <qlineedit.h> + +#include <stdio.h> + +#include "httpfactory.h" + +class MainView : public QMainWindow +{ + Q_OBJECT +public: + MainView(QWidget *parent=0, const char *name=0); +public slots: + void goClicked(); + void textChanged(); +private: + QToolButton *back; + QToolButton *forward; + QToolButton *home; + QToolButton *go; + QComboBox *location; + QTextBrowser *browser; + HttpFactory *http; +}; diff --git a/noncore/net/ubrowser/mainview.o b/noncore/net/ubrowser/mainview.o Binary files differnew file mode 100644 index 0000000..d86c4fc --- a/dev/null +++ b/noncore/net/ubrowser/mainview.o diff --git a/noncore/net/ubrowser/moc_httpcomm.cpp b/noncore/net/ubrowser/moc_httpcomm.cpp new file mode 100644 index 0000000..0078968 --- a/dev/null +++ b/noncore/net/ubrowser/moc_httpcomm.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** HttpComm meta object code from reading C++ file 'httpcomm.h' +** +** Created: Thu Jun 27 17:57:53 2002 +** by: The Qt MOC ($Id$) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#if !defined(Q_MOC_OUTPUT_REVISION) +#define Q_MOC_OUTPUT_REVISION 9 +#elif Q_MOC_OUTPUT_REVISION != 9 +#error "Moc format conflict - please regenerate all moc files" +#endif + +#include "httpcomm.h" +#include <qmetaobject.h> +#include <qapplication.h> + + + +const char *HttpComm::className() const +{ + return "HttpComm"; +} + +QMetaObject *HttpComm::metaObj = 0; + +void HttpComm::initMetaObject() +{ + if ( metaObj ) + return; + if ( qstrcmp(QObject::className(), "QObject") != 0 ) + badSuperclassWarning("HttpComm","QObject"); + (void) staticMetaObject(); +} + +#ifndef QT_NO_TRANSLATION + +QString HttpComm::tr(const char* s) +{ + return qApp->translate( "HttpComm", s, 0 ); +} + +QString HttpComm::tr(const char* s, const char * c) +{ + return qApp->translate( "HttpComm", s, c ); +} + +#endif // QT_NO_TRANSLATION + +QMetaObject* HttpComm::staticMetaObject() +{ + if ( metaObj ) + return metaObj; + (void) QObject::staticMetaObject(); +#ifndef QT_NO_PROPERTIES +#endif // QT_NO_PROPERTIES + typedef void (HttpComm::*m1_t0)(); + typedef void (QObject::*om1_t0)(); + typedef void (HttpComm::*m1_t1)(); + typedef void (QObject::*om1_t1)(); + typedef void (HttpComm::*m1_t2)(); + typedef void (QObject::*om1_t2)(); + typedef void (HttpComm::*m1_t3)(); + typedef void (QObject::*om1_t3)(); + m1_t0 v1_0 = &HttpComm::hostFound; + om1_t0 ov1_0 = (om1_t0)v1_0; + m1_t1 v1_1 = &HttpComm::connected; + om1_t1 ov1_1 = (om1_t1)v1_1; + m1_t2 v1_2 = &HttpComm::connectionClosed; + om1_t2 ov1_2 = (om1_t2)v1_2; + m1_t3 v1_3 = &HttpComm::incoming; + om1_t3 ov1_3 = (om1_t3)v1_3; + QMetaData *slot_tbl = QMetaObject::new_metadata(4); + QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(4); + slot_tbl[0].name = "hostFound()"; + slot_tbl[0].ptr = (QMember)ov1_0; + slot_tbl_access[0] = QMetaData::Public; + slot_tbl[1].name = "connected()"; + slot_tbl[1].ptr = (QMember)ov1_1; + slot_tbl_access[1] = QMetaData::Public; + slot_tbl[2].name = "connectionClosed()"; + slot_tbl[2].ptr = (QMember)ov1_2; + slot_tbl_access[2] = QMetaData::Public; + slot_tbl[3].name = "incoming()"; + slot_tbl[3].ptr = (QMember)ov1_3; + slot_tbl_access[3] = QMetaData::Public; + metaObj = QMetaObject::new_metaobject( + "HttpComm", "QObject", + slot_tbl, 4, + 0, 0, +#ifndef QT_NO_PROPERTIES + 0, 0, + 0, 0, +#endif // QT_NO_PROPERTIES + 0, 0 ); + metaObj->set_slot_access( slot_tbl_access ); +#ifndef QT_NO_PROPERTIES +#endif // QT_NO_PROPERTIES + return metaObj; +} diff --git a/noncore/net/ubrowser/moc_httpcomm.o b/noncore/net/ubrowser/moc_httpcomm.o Binary files differnew file mode 100644 index 0000000..dd52a15 --- a/dev/null +++ b/noncore/net/ubrowser/moc_httpcomm.o diff --git a/noncore/net/ubrowser/moc_mainview.cpp b/noncore/net/ubrowser/moc_mainview.cpp new file mode 100644 index 0000000..009ee1b --- a/dev/null +++ b/noncore/net/ubrowser/moc_mainview.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** MainView meta object code from reading C++ file 'mainview.h' +** +** Created: Mon Jun 10 19:05:57 2002 +** by: The Qt MOC ($Id$) +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#if !defined(Q_MOC_OUTPUT_REVISION) +#define Q_MOC_OUTPUT_REVISION 9 +#elif Q_MOC_OUTPUT_REVISION != 9 +#error "Moc format conflict - please regenerate all moc files" +#endif + +#include "mainview.h" +#include <qmetaobject.h> +#include <qapplication.h> + + + +const char *MainView::className() const +{ + return "MainView"; +} + +QMetaObject *MainView::metaObj = 0; + +void MainView::initMetaObject() +{ + if ( metaObj ) + return; + if ( qstrcmp(QMainWindow::className(), "QMainWindow") != 0 ) + badSuperclassWarning("MainView","QMainWindow"); + (void) staticMetaObject(); +} + +#ifndef QT_NO_TRANSLATION + +QString MainView::tr(const char* s) +{ + return qApp->translate( "MainView", s, 0 ); +} + +QString MainView::tr(const char* s, const char * c) +{ + return qApp->translate( "MainView", s, c ); +} + +#endif // QT_NO_TRANSLATION + +QMetaObject* MainView::staticMetaObject() +{ + if ( metaObj ) + return metaObj; + (void) QMainWindow::staticMetaObject(); +#ifndef QT_NO_PROPERTIES +#endif // QT_NO_PROPERTIES + typedef void (MainView::*m1_t0)(); + typedef void (QObject::*om1_t0)(); + typedef void (MainView::*m1_t1)(); + typedef void (QObject::*om1_t1)(); + m1_t0 v1_0 = &MainView::goClicked; + om1_t0 ov1_0 = (om1_t0)v1_0; + m1_t1 v1_1 = &MainView::textChanged; + om1_t1 ov1_1 = (om1_t1)v1_1; + QMetaData *slot_tbl = QMetaObject::new_metadata(2); + QMetaData::Access *slot_tbl_access = QMetaObject::new_metaaccess(2); + slot_tbl[0].name = "goClicked()"; + slot_tbl[0].ptr = (QMember)ov1_0; + slot_tbl_access[0] = QMetaData::Public; + slot_tbl[1].name = "textChanged()"; + slot_tbl[1].ptr = (QMember)ov1_1; + slot_tbl_access[1] = QMetaData::Public; + metaObj = QMetaObject::new_metaobject( + "MainView", "QMainWindow", + slot_tbl, 2, + 0, 0, +#ifndef QT_NO_PROPERTIES + 0, 0, + 0, 0, +#endif // QT_NO_PROPERTIES + 0, 0 ); + metaObj->set_slot_access( slot_tbl_access ); +#ifndef QT_NO_PROPERTIES +#endif // QT_NO_PROPERTIES + return metaObj; +} diff --git a/noncore/net/ubrowser/moc_mainview.o b/noncore/net/ubrowser/moc_mainview.o Binary files differnew file mode 100644 index 0000000..cd48c62 --- a/dev/null +++ b/noncore/net/ubrowser/moc_mainview.o diff --git a/noncore/net/ubrowser/new_chunked_algo_thoughts b/noncore/net/ubrowser/new_chunked_algo_thoughts new file mode 100644 index 0000000..8ca9318 --- a/dev/null +++ b/noncore/net/ubrowser/new_chunked_algo_thoughts @@ -0,0 +1,12 @@ +use a switch case, with each case being one potential way that the data is when the function is entered, or +another one exits. + +while(!done) +{ + switch(status) + { + case chunk header: + case after chunk header: + case no chunk header: + } +}
\ No newline at end of file diff --git a/noncore/net/ubrowser/old_chunked_algo b/noncore/net/ubrowser/old_chunked_algo new file mode 100644 index 0000000..9b4ccda --- a/dev/null +++ b/noncore/net/ubrowser/old_chunked_algo @@ -0,0 +1,57 @@ +readchunk: + if(semi != 0) + { + printf("HttpComm::incoming: semi !=0\n"); + QString newBody = tempString; + if(i != 0) + { + printf("HttpComm::incoming: striping header2\n"); + newBody.remove(0,i); + } + newBody=newBody.remove(0, semi); + if(newBody.length() > clength) + { + newBody.truncate(clength); + nextChunk = true; + } + body += newBody; + bRead += newBody.length(); + printf("HttpComm::incoming: start body chunk1\n"); + printf("%s", newBody.latin1()); + printf("\nHttpComm::incoming: end body chunk\n"); + printf("HttpComm::incoming: bRead: %d\n", bRead); + if(nextChunk) + { + QString tmpQString = tempString; + tmpQString=tmpQString.remove(0, clength); + tempString = (char *)tmpQString.latin1(); + lengthset=false; + goto topchunk; + } + } + else + { + if( (bRead + ba) > clength) + { +// int bRead2=bRead; + for(; bRead < clength; bRead++) + { + body+=tempString[j]; +// bRead++; + } + } + else + { + body += tempString; + bRead += ba; + } + printf("HttpComm::incoming: start body chunk2\n"); + printf("%s", tempString); + printf("\nHttpComm::incoming: end body chunk\n"); + printf("HttpComm::incoming: bRead: %d\n", bRead); + } + if(bRead >= clength) + { + printf("HttpComm::incoming: end chunk\n"); + lengthset=false; + }
\ No newline at end of file diff --git a/noncore/net/ubrowser/ubrowser.pro b/noncore/net/ubrowser/ubrowser.pro new file mode 100644 index 0000000..3704a48 --- a/dev/null +++ b/noncore/net/ubrowser/ubrowser.pro @@ -0,0 +1,9 @@ +TEMPLATE =app +CONFIG +=qt warn_on release +DESTDIR =../../../bin +HEADERS = mainview.h httpfactory.h httpcomm.h +SOURCES = main.cpp mainview.cpp httpfactory.cpp httpcomm.cpp +INCLUDEPATH +=../../../include +DEPENDPATH +=../../../include +LIBS += -lqpe +TARGET = ubrowser |