summaryrefslogtreecommitdiff
path: root/noncore/net/ubrowser/httpfactory.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/ubrowser/httpfactory.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/ubrowser/httpfactory.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/noncore/net/ubrowser/httpfactory.cpp b/noncore/net/ubrowser/httpfactory.cpp
index 92718fb..50a3c9a 100644
--- a/noncore/net/ubrowser/httpfactory.cpp
+++ b/noncore/net/ubrowser/httpfactory.cpp
@@ -13,49 +13,51 @@ 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);
+ image = new QImageDrag;
}
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;
+ bool done=false, isImage=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;
+ name.prepend(browser->context());
+ name = name.remove(0, 7);
}
addrEnd = name.find('/');
if(addrEnd == -1)
{
name += '/';
addrEnd = name.length()-1;
}
host = name;
file = name;
@@ -69,32 +71,43 @@ const QMimeSource * HttpFactory::data(const QString &abs_name) const
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);
+ if(file.find(".png", file.length()-4) != -1 || file.find(".gif", file.length()-4) != -1 || file.find(".jpg", file.length()-4) != -1)
+ {
+ isImage=true;
+ }
+
+ comm->setStuff(host, portS, file, text, image, isImage);
socket->connectToHost(host, port);
+ if(!image)
+ {
text->setText("");
-
return text;
}
+ else
+ {
+ return image;
+ }
+}
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);