• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KParts

  • sources
  • kde-4.12
  • kdelibs
  • kparts
browserextension.cpp
Go to the documentation of this file.
1  /* This file is part of the KDE project
2  Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3  (C) 1999 David Faure <faure@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #include "browserextension.h"
21 
22 #include <QtGui/QApplication>
23 #include <QtGui/QClipboard>
24 #include <QtCore/QTimer>
25 #include <QtCore/QObject>
26 #include <QtCore/QMap>
27 #include <QtCore/QMetaEnum>
28 #include <QtCore/QRegExp>
29 #include <QtGui/QTextDocument>
30 
31 #include <kdebug.h>
32 #include <klocale.h>
33 #include <kmessagebox.h>
34 #include <kurifilter.h>
35 #include <kglobal.h>
36 
37 using namespace KParts;
38 
39 
40 class OpenUrlEvent::OpenUrlEventPrivate
41 {
42 public:
43  OpenUrlEventPrivate( ReadOnlyPart *part,
44  const KUrl &url,
45  const OpenUrlArguments &args,
46  const BrowserArguments &browserArgs )
47  : m_part( part )
48  , m_url( url )
49  , m_args(args)
50  , m_browserArgs(browserArgs)
51  {
52  }
53  ~OpenUrlEventPrivate()
54  {
55  }
56  static const char *s_strOpenUrlEvent;
57  ReadOnlyPart *m_part;
58  KUrl m_url;
59  OpenUrlArguments m_args;
60  BrowserArguments m_browserArgs;
61 };
62 
63 const char *OpenUrlEvent::OpenUrlEventPrivate::s_strOpenUrlEvent =
64  "KParts/BrowserExtension/OpenURLevent";
65 
66 OpenUrlEvent::OpenUrlEvent( ReadOnlyPart *part, const KUrl &url,
67  const OpenUrlArguments &args,
68  const BrowserArguments &browserArgs )
69  : Event( OpenUrlEventPrivate::s_strOpenUrlEvent )
70  , d( new OpenUrlEventPrivate(part, url, args, browserArgs) )
71 {
72 }
73 
74 OpenUrlEvent::~OpenUrlEvent()
75 {
76  delete d;
77 }
78 
79 ReadOnlyPart *OpenUrlEvent::part() const
80 {
81  return d->m_part;
82 }
83 
84 KUrl OpenUrlEvent::url() const
85 {
86  return d->m_url;
87 }
88 
89 OpenUrlArguments OpenUrlEvent::arguments() const
90 {
91  return d->m_args;
92 }
93 
94 BrowserArguments OpenUrlEvent::browserArguments() const
95 {
96  return d->m_browserArgs;
97 }
98 
99 bool OpenUrlEvent::test( const QEvent *event )
100 {
101  return Event::test( event, OpenUrlEventPrivate::s_strOpenUrlEvent );
102 }
103 
104 namespace KParts
105 {
106 
107 struct BrowserArgumentsPrivate
108 {
109  BrowserArgumentsPrivate() {
110  doPost = false;
111  redirectedRequest = false;
112  lockHistory = false;
113  newTab = false;
114  forcesNewWindow = false;
115  }
116  QString contentType; // for POST
117  bool doPost;
118  bool redirectedRequest;
119  bool lockHistory;
120  bool newTab;
121  bool forcesNewWindow;
122 };
123 
124 }
125 
126 BrowserArguments::BrowserArguments()
127 {
128  softReload = false;
129  trustedSource = false;
130  d = 0; // Let's build it on demand for now
131 }
132 
133 BrowserArguments::BrowserArguments( const BrowserArguments &args )
134 {
135  d = 0;
136  (*this) = args;
137 }
138 
139 BrowserArguments &BrowserArguments::operator=(const BrowserArguments &args)
140 {
141  if (this == &args) return *this;
142 
143  delete d; d= 0;
144 
145  softReload = args.softReload;
146  postData = args.postData;
147  frameName = args.frameName;
148  docState = args.docState;
149  trustedSource = args.trustedSource;
150 
151  if ( args.d )
152  d = new BrowserArgumentsPrivate( * args.d );
153 
154  return *this;
155 }
156 
157 BrowserArguments::~BrowserArguments()
158 {
159  delete d;
160  d = 0;
161 }
162 
163 void BrowserArguments::setContentType( const QString & contentType )
164 {
165  if (!d)
166  d = new BrowserArgumentsPrivate;
167  d->contentType = contentType;
168 }
169 
170 void BrowserArguments::setRedirectedRequest( bool redirected )
171 {
172  if (!d)
173  d = new BrowserArgumentsPrivate;
174  d->redirectedRequest = redirected;
175 }
176 
177 bool BrowserArguments::redirectedRequest () const
178 {
179  return d ? d->redirectedRequest : false;
180 }
181 
182 QString BrowserArguments::contentType() const
183 {
184  return d ? d->contentType : QString();
185 }
186 
187 void BrowserArguments::setDoPost( bool enable )
188 {
189  if ( !d )
190  d = new BrowserArgumentsPrivate;
191  d->doPost = enable;
192 }
193 
194 bool BrowserArguments::doPost() const
195 {
196  return d ? d->doPost : false;
197 }
198 
199 void BrowserArguments::setLockHistory( bool lock )
200 {
201  if (!d)
202  d = new BrowserArgumentsPrivate;
203  d->lockHistory = lock;
204 }
205 
206 bool BrowserArguments::lockHistory() const
207 {
208  return d ? d->lockHistory : false;
209 }
210 
211 void BrowserArguments::setNewTab( bool newTab )
212 {
213  if (!d)
214  d = new BrowserArgumentsPrivate;
215  d->newTab = newTab;
216 }
217 
218 bool BrowserArguments::newTab() const
219 {
220  return d ? d->newTab : false;
221 }
222 
223 void BrowserArguments::setForcesNewWindow( bool forcesNewWindow )
224 {
225  if (!d)
226  d = new BrowserArgumentsPrivate;
227  d->forcesNewWindow = forcesNewWindow;
228 }
229 
230 bool BrowserArguments::forcesNewWindow() const
231 {
232  return d ? d->forcesNewWindow : false;
233 }
234 
235 namespace KParts
236 {
237 
238 class WindowArgsPrivate : public QSharedData
239 {
240 public:
241  WindowArgsPrivate()
242  : x(-1), y(-1), width(-1), height(-1),
243  fullscreen(false),
244  menuBarVisible(true),
245  toolBarsVisible(true),
246  statusBarVisible(true),
247  resizable(true),
248  lowerWindow(false),
249  scrollBarsVisible(true)
250  {
251  }
252 
253  // Position
254  int x;
255  int y;
256  // Size
257  int width;
258  int height;
259  bool fullscreen; //defaults to false
260  bool menuBarVisible; //defaults to true
261  bool toolBarsVisible; //defaults to true
262  bool statusBarVisible; //defaults to true
263  bool resizable; //defaults to true
264 
265  bool lowerWindow; //defaults to false
266  bool scrollBarsVisible; //defaults to true
267 };
268 
269 }
270 
271 WindowArgs::WindowArgs()
272  : d(new WindowArgsPrivate)
273 {
274 }
275 
276 WindowArgs::WindowArgs( const WindowArgs &args )
277  : d(args.d)
278 {
279 }
280 
281 WindowArgs::~WindowArgs()
282 {
283 }
284 
285 WindowArgs &WindowArgs::operator=( const WindowArgs &args )
286 {
287  if ( this == &args ) return *this;
288 
289  d = args.d;
290  return *this;
291 }
292 
293 WindowArgs::WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
294  bool _toolBarsVisible, bool _statusBarVisible, bool _resizable )
295  : d(new WindowArgsPrivate)
296 {
297  d->x = _geometry.x();
298  d->y = _geometry.y();
299  d->width = _geometry.width();
300  d->height = _geometry.height();
301  d->fullscreen = _fullscreen;
302  d->menuBarVisible = _menuBarVisible;
303  d->toolBarsVisible = _toolBarsVisible;
304  d->statusBarVisible = _statusBarVisible;
305  d->resizable = _resizable;
306  d->lowerWindow = false;
307 }
308 
309 WindowArgs::WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
310  bool _menuBarVisible, bool _toolBarsVisible,
311  bool _statusBarVisible, bool _resizable )
312  : d(new WindowArgsPrivate)
313 {
314  d->x = _x;
315  d->y = _y;
316  d->width = _width;
317  d->height = _height;
318  d->fullscreen = _fullscreen;
319  d->menuBarVisible = _menuBarVisible;
320  d->toolBarsVisible = _toolBarsVisible;
321  d->statusBarVisible = _statusBarVisible;
322  d->resizable = _resizable;
323  d->lowerWindow = false;
324 }
325 
326 void WindowArgs::setX(int x)
327 {
328  d->x = x;
329 }
330 
331 int WindowArgs::x() const
332 {
333  return d->x;
334 }
335 
336 void WindowArgs::setY(int y)
337 {
338  d->y = y;
339 }
340 
341 int WindowArgs::y() const
342 {
343  return d->y;
344 }
345 
346 void WindowArgs::setWidth(int w)
347 {
348  d->width = w;
349 }
350 
351 int WindowArgs::width() const
352 {
353  return d->width;
354 }
355 
356 void WindowArgs::setHeight(int h)
357 {
358  d->height = h;
359 }
360 
361 int WindowArgs::height() const
362 {
363  return d->height;
364 }
365 
366 void WindowArgs::setFullScreen(bool fs)
367 {
368  d->fullscreen = fs;
369 }
370 
371 bool WindowArgs::isFullScreen() const
372 {
373  return d->fullscreen;
374 }
375 
376 void WindowArgs::setMenuBarVisible(bool visible)
377 {
378  d->menuBarVisible = visible;
379 }
380 
381 bool WindowArgs::isMenuBarVisible() const
382 {
383  return d->menuBarVisible;
384 }
385 
386 void WindowArgs::setToolBarsVisible(bool visible)
387 {
388  d->toolBarsVisible = visible;
389 }
390 
391 bool WindowArgs::toolBarsVisible() const
392 {
393  return d->toolBarsVisible;
394 }
395 
396 void WindowArgs::setStatusBarVisible(bool visible)
397 {
398  d->statusBarVisible = visible;
399 }
400 
401 bool WindowArgs::isStatusBarVisible() const
402 {
403  return d->statusBarVisible;
404 }
405 
406 void WindowArgs::setResizable(bool resizable)
407 {
408  d->resizable = resizable;
409 }
410 
411 bool WindowArgs::isResizable() const
412 {
413  return d->resizable;
414 }
415 
416 void WindowArgs::setLowerWindow(bool lower)
417 {
418  d->lowerWindow = lower;
419 }
420 
421 bool WindowArgs::lowerWindow() const
422 {
423  return d->lowerWindow;
424 }
425 
426 void WindowArgs::setScrollBarsVisible(bool visible)
427 {
428  d->scrollBarsVisible = visible;
429 }
430 
431 bool WindowArgs::scrollBarsVisible() const
432 {
433  return d->scrollBarsVisible;
434 }
435 
436 namespace KParts
437 {
438 
439 // Internal class, use to store the status of the actions
440 class KBitArray
441 {
442 public:
443  int val;
444  KBitArray() { val = 0; }
445  bool operator [](int index) { return (val & (1 << index)) ? true : false; }
446  void setBit(int index, bool value) {
447  if (value) val = val | (1 << index);
448  else val = val & ~(1 << index);
449  }
450 };
451 
452 class BrowserExtension::BrowserExtensionPrivate
453 {
454 public:
455  BrowserExtensionPrivate( KParts::ReadOnlyPart *parent )
456  : m_urlDropHandlingEnabled(false),
457  m_browserInterface(0),
458  m_part( parent )
459  {}
460 
461  struct DelayedRequest {
462  KUrl m_delayedURL;
463  KParts::OpenUrlArguments m_delayedArgs;
464  KParts::BrowserArguments m_delayedBrowserArgs;
465  };
466 
467  QList<DelayedRequest> m_requests;
468  bool m_urlDropHandlingEnabled;
469  KBitArray m_actionStatus;
470  QMap<int, QString> m_actionText;
471  BrowserInterface *m_browserInterface;
472 
473  static void createActionSlotMap();
474 
475  KParts::ReadOnlyPart *m_part;
476  OpenUrlArguments m_args;
477  BrowserArguments m_browserArgs;
478 };
479 
480 K_GLOBAL_STATIC(BrowserExtension::ActionSlotMap, s_actionSlotMap)
481 K_GLOBAL_STATIC(BrowserExtension::ActionNumberMap, s_actionNumberMap)
482 
483 void BrowserExtension::BrowserExtensionPrivate::createActionSlotMap()
484 {
485  s_actionSlotMap->insert( "cut", SLOT(cut()) );
486  s_actionSlotMap->insert( "copy", SLOT(copy()) );
487  s_actionSlotMap->insert( "paste", SLOT(paste()) );
488  s_actionSlotMap->insert( "print", SLOT(print()) );
489  // Tricky. Those aren't actions in fact, but simply methods that a browserextension
490  // can have or not. No need to return them here.
491  //s_actionSlotMap->insert( "reparseConfiguration", SLOT(reparseConfiguration()) );
492  //s_actionSlotMap->insert( "refreshMimeTypes", SLOT(refreshMimeTypes()) );
493 
494  // Create the action-number map
495  ActionSlotMap::ConstIterator it = s_actionSlotMap->constBegin();
496  ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->constEnd();
497  for ( int i=0 ; it != itEnd ; ++it, ++i )
498  {
499  //kDebug(1202) << " action " << it.key() << " number " << i;
500  s_actionNumberMap->insert( it.key(), i );
501  }
502 }
503 
504 }
505 
506 BrowserExtension::BrowserExtension( KParts::ReadOnlyPart *parent )
507 : QObject( parent ), d( new BrowserExtensionPrivate(parent) )
508 {
509  //kDebug() << "BrowserExtension::BrowserExtension() " << this;
510 
511  if (s_actionSlotMap->isEmpty())
512  // Create the action-slot map
513  BrowserExtensionPrivate::createActionSlotMap();
514 
515  // Build list with this extension's slot names.
516  QList<QByteArray> slotNames;
517  int methodCount = metaObject()->methodCount();
518  int methodOffset = metaObject()->methodOffset();
519  for ( int i=0 ; i < methodCount; ++i )
520  {
521  QMetaMethod method = metaObject()->method( methodOffset + i );
522  if ( method.methodType() == QMetaMethod::Slot )
523  slotNames.append( method.signature() );
524  }
525 
526  // Set the initial status of the actions depending on whether
527  // they're supported or not
528  ActionSlotMap::ConstIterator it = s_actionSlotMap->constBegin();
529  ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->constEnd();
530  for ( int i=0 ; it != itEnd ; ++it, ++i )
531  {
532  // Does the extension have a slot with the name of this action ?
533  // ######### KDE4 TODO: use QMetaObject::indexOfMethod() #######
534  d->m_actionStatus.setBit( i, slotNames.contains( it.key()+"()" ) );
535  }
536 
537  connect( d->m_part, SIGNAL(completed()),
538  this, SLOT(slotCompleted()) );
539  connect( this, SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
540  this, SLOT(slotOpenUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
541  connect( this, SIGNAL(enableAction(const char*,bool)),
542  this, SLOT(slotEnableAction(const char*,bool)) );
543  connect( this, SIGNAL(setActionText(const char*,QString)),
544  this, SLOT(slotSetActionText(const char*,QString)) );
545 }
546 
547 BrowserExtension::~BrowserExtension()
548 {
549  //kDebug() << "BrowserExtension::~BrowserExtension() " << this;
550  delete d;
551 }
552 
553 void BrowserExtension::setBrowserArguments( const BrowserArguments &args )
554 {
555  d->m_browserArgs = args;
556 }
557 
558 BrowserArguments BrowserExtension::browserArguments() const
559 {
560  return d->m_browserArgs;
561 }
562 
563 int BrowserExtension::xOffset()
564 {
565  return 0;
566 }
567 
568 int BrowserExtension::yOffset()
569 {
570  return 0;
571 }
572 
573 void BrowserExtension::saveState( QDataStream &stream )
574 {
575  // TODO add d->m_part->mimeType()
576  stream << d->m_part->url() << (qint32)xOffset() << (qint32)yOffset();
577 }
578 
579 void BrowserExtension::restoreState( QDataStream &stream )
580 {
581  KUrl u;
582  qint32 xOfs, yOfs;
583  stream >> u >> xOfs >> yOfs;
584 
585  OpenUrlArguments args;
586  args.setXOffset(xOfs);
587  args.setYOffset(yOfs);
588  // TODO add args.setMimeType
589  d->m_part->setArguments(args);
590  d->m_part->openUrl(u);
591 }
592 
593 bool BrowserExtension::isURLDropHandlingEnabled() const
594 {
595  return d->m_urlDropHandlingEnabled;
596 }
597 
598 void BrowserExtension::setURLDropHandlingEnabled( bool enable )
599 {
600  d->m_urlDropHandlingEnabled = enable;
601 }
602 
603 void BrowserExtension::slotCompleted()
604 {
605  //empty the argument stuff, to avoid bogus/invalid values when opening a new url
606  setBrowserArguments( BrowserArguments() );
607 }
608 
609 void BrowserExtension::pasteRequest()
610 {
611  QString plain( "plain" );
612  QString url = QApplication::clipboard()->text(plain, QClipboard::Selection).trimmed();
613  // Remove linefeeds and any whitespace surrounding it.
614  url.remove(QRegExp("[\\ ]*\\n+[\\ ]*"));
615 
616  // Check if it's a URL
617  QStringList filters = KUriFilter::self()->pluginNames();
618  filters.removeAll( "kuriikwsfilter" );
619  filters.removeAll( "localdomainurifilter" );
620  KUriFilterData filterData;
621  filterData.setData( url );
622  filterData.setCheckForExecutables( false );
623  if ( KUriFilter::self()->filterUri( filterData, filters ) )
624  {
625  switch ( filterData.uriType() )
626  {
627  case KUriFilterData::LocalFile:
628  case KUriFilterData::LocalDir:
629  case KUriFilterData::NetProtocol:
630  slotOpenUrlRequest( filterData.uri() );
631  break;
632  case KUriFilterData::Error:
633  KMessageBox::sorry( d->m_part->widget(), filterData.errorMsg() );
634  break;
635  default:
636  break;
637  }
638  }
639  else if ( KUriFilter::self()->filterUri( filterData,
640  QStringList( QLatin1String( "kuriikwsfilter" ) ) ) &&
641  url.length() < 250 )
642  {
643  if ( KMessageBox::questionYesNo( d->m_part->widget(),
644  i18n( "<qt>Do you want to search the Internet for <b>%1</b>?</qt>" , Qt::escape(url) ),
645  i18n( "Internet Search" ), KGuiItem( i18n( "&Search" ), "edit-find"),
646  KStandardGuiItem::cancel(), "MiddleClickSearch" ) == KMessageBox::Yes)
647  slotOpenUrlRequest( filterData.uri() );
648  }
649 }
650 
651 void BrowserExtension::slotOpenUrlRequest( const KUrl &url, const KParts::OpenUrlArguments& args, const KParts::BrowserArguments &browserArgs )
652 {
653  //kDebug() << this << " BrowserExtension::slotOpenURLRequest(): url=" << url.url();
654  BrowserExtensionPrivate::DelayedRequest req;
655  req.m_delayedURL = url;
656  req.m_delayedArgs = args;
657  req.m_delayedBrowserArgs = browserArgs;
658  d->m_requests.append( req );
659  QTimer::singleShot( 0, this, SLOT(slotEmitOpenUrlRequestDelayed()) );
660 }
661 
662 void BrowserExtension::slotEmitOpenUrlRequestDelayed()
663 {
664  if (d->m_requests.isEmpty()) return;
665  BrowserExtensionPrivate::DelayedRequest req = d->m_requests.front();
666  d->m_requests.pop_front();
667  emit openUrlRequestDelayed( req.m_delayedURL, req.m_delayedArgs, req.m_delayedBrowserArgs );
668  // tricky: do not do anything here! (no access to member variables, etc.)
669 }
670 
671 void BrowserExtension::setBrowserInterface( BrowserInterface *impl )
672 {
673  d->m_browserInterface = impl;
674 }
675 
676 BrowserInterface *BrowserExtension::browserInterface() const
677 {
678  return d->m_browserInterface;
679 }
680 
681 void BrowserExtension::slotEnableAction( const char * name, bool enabled )
682 {
683  //kDebug() << "BrowserExtension::slotEnableAction " << name << " " << enabled;
684  ActionNumberMap::ConstIterator it = s_actionNumberMap->constFind( name );
685  if ( it != s_actionNumberMap->constEnd() )
686  {
687  d->m_actionStatus.setBit( it.value(), enabled );
688  //kDebug() << "BrowserExtension::slotEnableAction setting bit " << it.data() << " to " << enabled;
689  }
690  else
691  kWarning() << "BrowserExtension::slotEnableAction unknown action " << name;
692 }
693 
694 bool BrowserExtension::isActionEnabled( const char * name ) const
695 {
696  int actionNumber = (*s_actionNumberMap)[ name ];
697  return d->m_actionStatus[ actionNumber ];
698 }
699 
700 void BrowserExtension::slotSetActionText( const char * name, const QString& text )
701 {
702  //kDebug() << "BrowserExtension::slotSetActionText " << name << " " << text;
703  ActionNumberMap::ConstIterator it = s_actionNumberMap->constFind( name );
704  if ( it != s_actionNumberMap->constEnd() )
705  {
706  d->m_actionText[ it.value() ] = text;
707  }
708  else
709  kWarning() << "BrowserExtension::slotSetActionText unknown action " << name;
710 }
711 
712 QString BrowserExtension::actionText( const char * name ) const
713 {
714  int actionNumber = (*s_actionNumberMap)[ name ];
715  QMap<int, QString>::ConstIterator it = d->m_actionText.constFind( actionNumber );
716  if ( it != d->m_actionText.constEnd() )
717  return *it;
718  return QString();
719 }
720 
721 // for compatibility
722 BrowserExtension::ActionSlotMap BrowserExtension::actionSlotMap()
723 {
724  return *actionSlotMapPtr();
725 }
726 
727 BrowserExtension::ActionSlotMap * BrowserExtension::actionSlotMapPtr()
728 {
729  if (s_actionSlotMap->isEmpty())
730  BrowserExtensionPrivate::createActionSlotMap();
731  return s_actionSlotMap;
732 }
733 
734 BrowserExtension *BrowserExtension::childObject( QObject *obj )
735 {
736  return KGlobal::findDirectChild<KParts::BrowserExtension *>(obj);
737 }
738 
739 namespace KParts
740 {
741 
742 class BrowserHostExtension::BrowserHostExtensionPrivate
743 {
744 public:
745  BrowserHostExtensionPrivate()
746  {
747  }
748  ~BrowserHostExtensionPrivate()
749  {
750  }
751 
752  KParts::ReadOnlyPart *m_part;
753 };
754 
755 }
756 
757 BrowserHostExtension::BrowserHostExtension( KParts::ReadOnlyPart *parent )
758  : QObject( parent ), d( new BrowserHostExtensionPrivate )
759 {
760  d->m_part = parent;
761 }
762 
763 BrowserHostExtension::~BrowserHostExtension()
764 {
765  delete d;
766 }
767 
768 QStringList BrowserHostExtension::frameNames() const
769 {
770  return QStringList();
771 }
772 
773 const QList<KParts::ReadOnlyPart*> BrowserHostExtension::frames() const
774 {
775  return QList<KParts::ReadOnlyPart*>();
776 }
777 
778 bool BrowserHostExtension::openUrlInFrame( const KUrl &,
779  const KParts::OpenUrlArguments&,
780  const KParts::BrowserArguments & )
781 {
782  return false;
783 }
784 
785 BrowserHostExtension *BrowserHostExtension::childObject( QObject *obj )
786 {
787  return KGlobal::findDirectChild<KParts::BrowserHostExtension *>(obj);
788 }
789 
790 BrowserHostExtension *
791 BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
792 {
793  Q_UNUSED(callingPart);
794  Q_UNUSED(frame);
795  return 0;
796 }
797 
798 LiveConnectExtension::LiveConnectExtension( KParts::ReadOnlyPart *parent )
799  : QObject( parent ), d( 0 ) {}
800 
801 LiveConnectExtension::~LiveConnectExtension() {}
802 
803 bool LiveConnectExtension::get( const unsigned long, const QString &, Type &, unsigned long &, QString & ) {
804  return false;
805 }
806 
807 bool LiveConnectExtension::put( const unsigned long, const QString &, const QString & ) {
808  return false;
809 }
810 
811 bool LiveConnectExtension::call( const unsigned long, const QString &, const QStringList &, Type &, unsigned long &, QString & ) {
812  return false;
813 }
814 
815 void LiveConnectExtension::unregister( const unsigned long ) {}
816 
817 LiveConnectExtension *LiveConnectExtension::childObject( QObject *obj )
818 {
819  return KGlobal::findDirectChild<KParts::LiveConnectExtension *>(obj);
820 }
821 
822 #include "browserextension.moc"
KParts::BrowserExtension
The Browser Extension is an extension (yes, no kidding) to KParts::ReadOnlyPart, which allows a bette...
Definition: browserextension.h:320
KStandardGuiItem::cancel
KGuiItem cancel()
KParts::BrowserExtension::~BrowserExtension
virtual ~BrowserExtension()
Definition: browserextension.cpp:547
i18n
QString i18n(const char *text)
KParts::BrowserArguments::setLockHistory
void setLockHistory(bool lock)
Whether to lock the history when opening the next URL.
Definition: browserextension.cpp:199
KParts::OpenUrlEvent::part
ReadOnlyPart * part() const
Definition: browserextension.cpp:79
KUriFilterData::errorMsg
QString errorMsg() const
KParts::BrowserArguments::operator=
BrowserArguments & operator=(const BrowserArguments &args)
Definition: browserextension.cpp:139
print
KAction * print(const QObject *recvr, const char *slot, QObject *parent)
cut
KAction * cut(const QObject *recvr, const char *slot, QObject *parent)
KParts::WindowArgs::setY
void setY(int y)
Definition: browserextension.cpp:336
KParts::BrowserArguments::contentType
QString contentType() const
KHTML-specific field, header defining the type of the POST data.
Definition: browserextension.cpp:182
kdebug.h
KUriFilterData::Error
KParts::OpenUrlEvent::~OpenUrlEvent
virtual ~OpenUrlEvent()
Definition: browserextension.cpp:74
KParts::BrowserArguments::forcesNewWindow
bool forcesNewWindow() const
Whether the URL specifies to be opened in a new window.
Definition: browserextension.cpp:230
KParts::LiveConnectExtension::Type
Type
Definition: browserextension.h:769
KParts::WindowArgs::scrollBarsVisible
bool scrollBarsVisible() const
Definition: browserextension.cpp:431
KParts::BrowserExtension::BrowserExtension
BrowserExtension(KParts::ReadOnlyPart *parent)
Constructor.
Definition: browserextension.cpp:506
KParts::BrowserInterface
The purpose of this interface is to allow a direct communication between a KPart and the hosting brow...
Definition: browserinterface.h:53
KParts::BrowserExtension::setBrowserInterface
void setBrowserInterface(BrowserInterface *impl)
Definition: browserextension.cpp:671
copy
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
KParts::OpenUrlEvent::browserArguments
BrowserArguments browserArguments() const
Definition: browserextension.cpp:94
KParts::BrowserExtension::setURLDropHandlingEnabled
void setURLDropHandlingEnabled(bool enable)
Enables or disables url drop handling.
Definition: browserextension.cpp:598
KParts::WindowArgs::setToolBarsVisible
void setToolBarsVisible(bool visible)
Definition: browserextension.cpp:386
K_GLOBAL_STATIC
#define K_GLOBAL_STATIC(TYPE, NAME)
KParts::BrowserArguments
BrowserArguments is a set of web-browsing-specific arguments, which allow specifying how a URL should...
Definition: browserextension.h:64
KParts::BrowserHostExtension::BrowserHostExtension
BrowserHostExtension(KParts::ReadOnlyPart *parent)
Definition: browserextension.cpp:757
KParts::BrowserExtension::saveState
virtual void saveState(QDataStream &stream)
Used by the browser to save the current state of the view (in order to restore it if going back in na...
Definition: browserextension.cpp:573
KParts::LiveConnectExtension::call
virtual bool call(const unsigned long objid, const QString &func, const QStringList &args, Type &type, unsigned long &retobjid, QString &value)
calls a function of objid, return true on success
Definition: browserextension.cpp:811
KParts::BrowserExtension::actionSlotMap
static ActionSlotMap actionSlotMap()
Returns a map containing the action names as keys and corresponding SLOT()'ified method names as data...
Definition: browserextension.cpp:722
KParts::BrowserHostExtension::frames
virtual const QList< KParts::ReadOnlyPart * > frames() const
Returns a list of pointers to all hosted child objects.
Definition: browserextension.cpp:773
KParts::WindowArgs::lowerWindow
bool lowerWindow() const
Definition: browserextension.cpp:421
QString
KParts::WindowArgs::setX
void setX(int x)
Definition: browserextension.cpp:326
QObject
KParts::BrowserArguments::setDoPost
void setDoPost(bool enable)
KHTML-specific field, whether to do a POST instead of a GET, for the next openURL.
Definition: browserextension.cpp:187
klocale.h
KParts::BrowserHostExtension::frameNames
virtual QStringList frameNames() const
Returns a list of the names of all hosted child objects.
Definition: browserextension.cpp:768
KParts::OpenUrlEvent::url
KUrl url() const
Definition: browserextension.cpp:84
paste
KAction * paste(const QObject *recvr, const char *slot, QObject *parent)
kurifilter.h
KParts::LiveConnectExtension::~LiveConnectExtension
virtual ~LiveConnectExtension()
Definition: browserextension.cpp:801
KParts::BrowserExtension::browserArguments
BrowserArguments browserArguments() const
Retrieve the set of parameters to use for opening the URL (this must be called from openUrl() in the ...
Definition: browserextension.cpp:558
KUrl
KParts::WindowArgs::setWidth
void setWidth(int w)
Definition: browserextension.cpp:346
KParts::BrowserArguments::trustedSource
bool trustedSource
If true, the part who asks for a URL to be opened can be 'trusted' to execute applications.
Definition: browserextension.h:140
KParts::BrowserArguments::redirectedRequest
bool redirectedRequest() const
Definition: browserextension.cpp:177
KUriFilterData::setData
void setData(const KUrl &url)
KParts::BrowserArguments::setRedirectedRequest
void setRedirectedRequest(bool redirected)
Set the redirect flag to indicate URL is a result of either a META redirect or HTTP redirect...
Definition: browserextension.cpp:170
KParts::BrowserExtension::restoreState
virtual void restoreState(QDataStream &stream)
Used by the browser to restore the view in the state it was when we left it.
Definition: browserextension.cpp:579
KParts::WindowArgs::isMenuBarVisible
bool isMenuBarVisible() const
Definition: browserextension.cpp:381
KParts::BrowserArguments::docState
QStringList docState
This buffer can be used by the part to save and restore its contents.
Definition: browserextension.h:81
KParts::OpenUrlArguments::setXOffset
void setXOffset(int x)
Definition: part.cpp:1106
kglobal.h
KParts::BrowserExtension::enableAction
void enableAction(const char *name, bool enabled)
Enables or disable a standard action held by the browser.
KParts::WindowArgs::toolBarsVisible
bool toolBarsVisible() const
Definition: browserextension.cpp:391
KParts::WindowArgs::y
int y() const
Definition: browserextension.cpp:341
KParts::LiveConnectExtension
An extension class for LiveConnect, i.e.
Definition: browserextension.h:765
KUriFilter::filterUri
bool filterUri(KUriFilterData &data, const QStringList &filters=QStringList())
KParts::BrowserExtension::isURLDropHandlingEnabled
bool isURLDropHandlingEnabled() const
Returns whether url drop handling is enabled.
Definition: browserextension.cpp:593
KParts::WindowArgs::setResizable
void setResizable(bool resizable)
Definition: browserextension.cpp:406
KGuiItem
KParts::BrowserExtension::childObject
static BrowserExtension * childObject(QObject *obj)
Queries obj for a child object which inherits from this BrowserExtension class.
Definition: browserextension.cpp:734
QStringList
KMessageBox::sorry
static void sorry(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
KParts::BrowserHostExtension::childObject
static BrowserHostExtension * childObject(QObject *obj)
Queries obj for a child object which inherits from this BrowserHostExtension class.
Definition: browserextension.cpp:785
KParts::WindowArgs::setMenuBarVisible
void setMenuBarVisible(bool visible)
Definition: browserextension.cpp:376
KParts::WindowArgs::operator=
WindowArgs & operator=(const WindowArgs &args)
Definition: browserextension.cpp:285
KParts::BrowserExtension::openUrlRequest
void openUrlRequest(const KUrl &url, const KParts::OpenUrlArguments &arguments=KParts::OpenUrlArguments(), const KParts::BrowserArguments &browserArguments=KParts::BrowserArguments())
Asks the host (browser) to open url.
KParts::WindowArgs::isStatusBarVisible
bool isStatusBarVisible() const
Definition: browserextension.cpp:401
KParts::BrowserExtension::browserInterface
BrowserInterface * browserInterface() const
Definition: browserextension.cpp:676
KUriFilterData
KParts::WindowArgs::WindowArgs
WindowArgs()
Definition: browserextension.cpp:271
KParts::WindowArgs::setStatusBarVisible
void setStatusBarVisible(bool visible)
Definition: browserextension.cpp:396
KMessageBox::questionYesNo
static int questionYesNo(QWidget *parent, const QString &text, const QString &caption=QString(), const KGuiItem &buttonYes=KStandardGuiItem::yes(), const KGuiItem &buttonNo=KStandardGuiItem::no(), const QString &dontAskAgainName=QString(), Options options=Notify)
KParts::BrowserExtension::yOffset
virtual int yOffset()
Returns the current y offset.
Definition: browserextension.cpp:568
KParts::BrowserExtension::actionSlotMapPtr
static ActionSlotMap * actionSlotMapPtr()
Definition: browserextension.cpp:727
KUriFilter::self
static KUriFilter * self()
KParts::BrowserHostExtension
An extension class for container parts, i.e.
Definition: browserextension.h:712
KParts::LiveConnectExtension::unregister
virtual void unregister(const unsigned long objid)
notifies the part that there is no reference anymore to objid
Definition: browserextension.cpp:815
KParts::BrowserArguments::setForcesNewWindow
void setForcesNewWindow(bool forcesNewWindow)
Set whether the URL specifies to be opened in a new window.
Definition: browserextension.cpp:223
KParts::WindowArgs::~WindowArgs
~WindowArgs()
Definition: browserextension.cpp:281
KUriFilter::pluginNames
QStringList pluginNames() const
KParts::BrowserArguments::softReload
bool softReload
softReload is set when user just hits reload button.
Definition: browserextension.h:89
KParts::OpenUrlEvent::arguments
OpenUrlArguments arguments() const
Definition: browserextension.cpp:89
KParts::WindowArgs::width
int width() const
Definition: browserextension.cpp:351
KParts::BrowserArguments::frameName
QString frameName
The frame in which to open the URL.
Definition: browserextension.h:133
KParts::BrowserArguments::doPost
bool doPost() const
KHTML-specific field, whether to do a POST instead of a GET, for the next openURL.
Definition: browserextension.cpp:194
QSharedData
KParts::BrowserArguments::newTab
bool newTab() const
Definition: browserextension.cpp:218
KParts::BrowserExtension::openUrlRequestDelayed
void openUrlRequestDelayed(const KUrl &url, const KParts::OpenUrlArguments &arguments, const KParts::BrowserArguments &browserArguments)
This signal is emitted when openUrlRequest() is called, after a 0-seconds timer.
KParts::WindowArgs::isResizable
bool isResizable() const
Definition: browserextension.cpp:411
KParts::WindowArgs::isFullScreen
bool isFullScreen() const
Definition: browserextension.cpp:371
KParts::LiveConnectExtension::put
virtual bool put(const unsigned long objid, const QString &field, const QString &value)
put a field value in objid, return true on success
Definition: browserextension.cpp:807
KParts::WindowArgs::setScrollBarsVisible
void setScrollBarsVisible(bool visible)
Definition: browserextension.cpp:426
KParts::Event
Base class for all KParts events.
Definition: event.h:37
KParts::BrowserArguments::lockHistory
bool lockHistory() const
Definition: browserextension.cpp:206
KParts::WindowArgs::x
int x() const
Definition: browserextension.cpp:331
KParts::WindowArgs::setFullScreen
void setFullScreen(bool fs)
Definition: browserextension.cpp:366
KParts::BrowserArguments::~BrowserArguments
virtual ~BrowserArguments()
Definition: browserextension.cpp:157
QRect
KParts::OpenUrlArguments::setYOffset
void setYOffset(int y)
Definition: part.cpp:1116
KUriFilterData::LocalFile
KParts::Event::test
static bool test(const QEvent *event)
Definition: event.cpp:53
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KUriFilterData::NetProtocol
qint32
KParts::BrowserHostExtension::~BrowserHostExtension
virtual ~BrowserHostExtension()
Definition: browserextension.cpp:763
KParts::WindowArgs::setHeight
void setHeight(int h)
Definition: browserextension.cpp:356
KParts::BrowserArguments::setContentType
void setContentType(const QString &contentType)
KHTML-specific field, header defining the type of the POST data.
Definition: browserextension.cpp:163
browserextension.h
KMessageBox::Yes
KParts::BrowserExtension::isActionEnabled
bool isActionEnabled(const char *name) const
Definition: browserextension.cpp:694
KParts::BrowserExtension::pasteRequest
void pasteRequest()
Asks the hosting browser to perform a paste (using openUrlRequestDelayed())
Definition: browserextension.cpp:609
KParts::WindowArgs::setLowerWindow
void setLowerWindow(bool lower)
Definition: browserextension.cpp:416
KParts::OpenUrlEvent::OpenUrlEvent
OpenUrlEvent(ReadOnlyPart *part, const KUrl &url, const OpenUrlArguments &args=OpenUrlArguments(), const BrowserArguments &browserArgs=BrowserArguments())
Definition: browserextension.cpp:66
KParts::BrowserHostExtension::findFrameParent
virtual BrowserHostExtension * findFrameParent(KParts::ReadOnlyPart *callingPart, const QString &frame)
Returns the part that contains frame and that may be accessed by callingPart.
Definition: browserextension.cpp:791
KParts::WindowArgs::height
int height() const
Definition: browserextension.cpp:361
KParts::BrowserArguments::setNewTab
void setNewTab(bool newTab)
Whether the URL should be opened in a new tab instead in a new window.
Definition: browserextension.cpp:211
KParts::OpenUrlEvent::test
static bool test(const QEvent *event)
Definition: browserextension.cpp:99
kmessagebox.h
KParts::BrowserHostExtension::openUrlInFrame
virtual bool openUrlInFrame(const KUrl &url, const KParts::OpenUrlArguments &arguments, const KParts::BrowserArguments &browserArguments)
Opens the given url in a hosted child frame.
Definition: browserextension.cpp:778
KUriFilterData::uriType
UriTypes uriType() const
QEvent
KParts::LiveConnectExtension::childObject
static LiveConnectExtension * childObject(QObject *obj)
Definition: browserextension.cpp:817
KParts::BrowserExtension::setBrowserArguments
virtual void setBrowserArguments(const BrowserArguments &args)
Set the parameters to use for opening the next URL.
Definition: browserextension.cpp:553
KUriFilterData::uri
KUrl uri() const
KParts::BrowserArguments::BrowserArguments
BrowserArguments()
Definition: browserextension.cpp:126
KUriFilterData::LocalDir
KUriFilterData::setCheckForExecutables
void setCheckForExecutables(bool check)
KParts::BrowserExtension::xOffset
virtual int xOffset()
Returns the current x offset.
Definition: browserextension.cpp:563
KParts::BrowserArguments::postData
QByteArray postData
KHTML-specific field, contents of the HTTP POST data.
Definition: browserextension.h:94
KParts::WindowArgs
The WindowArgs are used to specify arguments to the "create new window" call (see the createNewWindow...
Definition: browserextension.h:192
QMap< int, QString >
KParts::BrowserExtension::setActionText
void setActionText(const char *name, const QString &text)
Change the text of a standard action held by the browser.
KParts::BrowserExtension::actionText
QString actionText(const char *name) const
Definition: browserextension.cpp:712
KParts::OpenUrlArguments
OpenUrlArguments is the set of arguments that specify how a URL should be opened by KParts::ReadOnlyP...
Definition: part.h:404
QList< DelayedRequest >
KParts::LiveConnectExtension::LiveConnectExtension
LiveConnectExtension(KParts::ReadOnlyPart *parent)
Definition: browserextension.cpp:798
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:488
KParts::LiveConnectExtension::get
virtual bool get(const unsigned long objid, const QString &field, Type &type, unsigned long &retobjid, QString &value)
get a field value from objid, return true on success
Definition: browserextension.cpp:803
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

Skip menu "KParts"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal