KHTML
khtml_run.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00004 * 1999 Lars Knoll <knoll@kde.org> 00005 * 1999 Antti Koivisto <koivisto@kde.org> 00006 * 2000 Simon Hausmann <hausmann@kde.org> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Library General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Library General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Library General Public License 00019 * along with this library; see the file COPYING.LIB. If not, write to 00020 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 */ 00023 #include "khtml_run.h" 00024 #include "khtmlpart_p.h" 00025 #include <kio/job.h> 00026 #include <kdebug.h> 00027 #include <klocale.h> 00028 #include "khtml_ext.h" 00029 #include <QtGui/QImage> 00030 00031 KHTMLRun::KHTMLRun( KHTMLPart *part, khtml::ChildFrame *child, const KUrl &url, 00032 const KParts::OpenUrlArguments& args, 00033 const KParts::BrowserArguments &browserArgs, 00034 bool hideErrorDialog ) 00035 : KParts::BrowserRun( url, args, browserArgs, part, part->widget() ? part->widget()->topLevelWidget() : 0, 00036 false, false, hideErrorDialog ), 00037 m_child( child ) 00038 { 00039 // Don't use an external browser for parts of a webpage we are rendering. (iframes at least are one example) 00040 setEnableExternalBrowser(false); 00041 00042 // get the wheel to start spinning 00043 part->started(0L); 00044 } 00045 00046 //KHTMLPart *KHTMLRun::htmlPart() const 00047 //{ return static_cast<KHTMLPart *>(part()); } 00048 00049 void KHTMLRun::foundMimeType( const QString &_type ) 00050 { 00051 //kDebug(6050) << this << _type; 00052 Q_ASSERT(!hasFinished()); 00053 QString mimeType = _type; // this ref comes from the job, we lose it when using KIO again 00054 00055 bool requestProcessed = static_cast<KHTMLPart *>(part())->processObjectRequest( m_child, KRun::url(), mimeType ); 00056 00057 if ( requestProcessed ) 00058 setFinished( true ); 00059 else { 00060 if ( hasFinished() ) // abort was called (this happens with the activex fallback for instance) 00061 return; 00062 // Couldn't embed -> call BrowserRun::handleNonEmbeddable() 00063 KService::Ptr selectedService; 00064 KParts::BrowserRun::NonEmbeddableResult res = handleNonEmbeddable( mimeType, &selectedService ); 00065 if ( res == KParts::BrowserRun::Delayed ) 00066 return; 00067 setFinished( res == KParts::BrowserRun::Handled ); 00068 if ( hasFinished() ) { // saved or canceled -> flag completed 00069 m_child->m_bCompleted = true; 00070 static_cast<KHTMLPart *>(part())->checkCompleted(); 00071 } else { 00072 // "Open" selected, possible with a specific application 00073 if (selectedService) { 00074 KRun::setPreferredService(selectedService->desktopEntryName()); 00075 } else { 00076 KRun::displayOpenWithDialog(url(), part()->widget(), false /*tempfile*/, suggestedFileName()); 00077 setFinished(true); 00078 } 00079 } 00080 } 00081 00082 if ( hasFinished() ) { 00083 kDebug() << "finished"; 00084 return; 00085 } 00086 00087 //kDebug(6050) << _type << " couldn't open"; 00088 KRun::foundMimeType( mimeType ); 00089 00090 // "open" is finished -> flag completed 00091 m_child->m_bCompleted = true; 00092 static_cast<KHTMLPart *>(part())->checkCompleted(); 00093 } 00094 00095 void KHTMLRun::handleError(KJob*) 00096 { 00097 // Tell KHTML that loading failed. 00098 static_cast<KHTMLPart *>(part())->processObjectRequest( m_child, KUrl(), QString() ); 00099 setJob(0); 00100 } 00101 00102 void KHTMLRun::save( const KUrl & url, const QString & suggestedFilename ) 00103 { 00104 KHTMLPopupGUIClient::saveURL( part()->widget(), i18n( "Save As" ), url, arguments().metaData(), QString(), 0, suggestedFilename ); 00105 } 00106 00107 #include "khtml_run.moc"
KDE 4.6 API Reference