TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

browserextension.cpp 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "browserextension.h"
  18. #include <tqapplication.h>
  19. #include <tqclipboard.h>
  20. #include <tqtimer.h>
  21. #include <tqobjectlist.h>
  22. #include <tqmetaobject.h>
  23. #include <tqregexp.h>
  24. #include <tqstrlist.h>
  25. #include <tqstylesheet.h>
  26. #include <kdebug.h>
  27. #include <tdelocale.h>
  28. #include <tdemessagebox.h>
  29. #include <kstaticdeleter.h>
  30. #include <kurifilter.h>
  31. #include <assert.h>
  32. using namespace KParts;
  33. const char *OpenURLEvent::s_strOpenURLEvent = "KParts/BrowserExtension/OpenURLevent";
  34. class OpenURLEvent::OpenURLEventPrivate
  35. {
  36. public:
  37. OpenURLEventPrivate()
  38. {
  39. }
  40. ~OpenURLEventPrivate()
  41. {
  42. }
  43. };
  44. OpenURLEvent::OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args )
  45. : Event( s_strOpenURLEvent ), m_part( part ), m_url( url ), m_args( args )
  46. {
  47. // d = new OpenURLEventPrivate();
  48. }
  49. OpenURLEvent::~OpenURLEvent()
  50. {
  51. // delete d;
  52. }
  53. namespace KParts
  54. {
  55. struct URLArgsPrivate
  56. {
  57. URLArgsPrivate() {
  58. doPost = false;
  59. redirectedRequest = false;
  60. lockHistory = false;
  61. newTab = false;
  62. forcesNewWindow = false;
  63. }
  64. TQString contentType; // for POST
  65. TQMap<TQString, TQString> metaData;
  66. bool doPost;
  67. bool redirectedRequest;
  68. bool lockHistory;
  69. bool newTab;
  70. bool forcesNewWindow;
  71. };
  72. }
  73. URLArgs::URLArgs()
  74. {
  75. reload = false;
  76. xOffset = 0;
  77. yOffset = 0;
  78. trustedSource = false;
  79. d = 0L; // Let's build it on demand for now
  80. }
  81. URLArgs::URLArgs( bool _reload, int _xOffset, int _yOffset, const TQString &_serviceType )
  82. {
  83. reload = _reload;
  84. xOffset = _xOffset;
  85. yOffset = _yOffset;
  86. serviceType = _serviceType;
  87. d = 0L; // Let's build it on demand for now
  88. }
  89. URLArgs::URLArgs( const URLArgs &args )
  90. {
  91. d = 0L;
  92. (*this) = args;
  93. }
  94. URLArgs &URLArgs::operator=(const URLArgs &args)
  95. {
  96. if (this == &args) return *this;
  97. delete d; d= 0;
  98. reload = args.reload;
  99. xOffset = args.xOffset;
  100. yOffset = args.yOffset;
  101. serviceType = args.serviceType;
  102. postData = args.postData;
  103. frameName = args.frameName;
  104. docState = args.docState;
  105. trustedSource = args.trustedSource;
  106. if ( args.d )
  107. d = new URLArgsPrivate( * args.d );
  108. return *this;
  109. }
  110. URLArgs::~URLArgs()
  111. {
  112. delete d;
  113. d = 0;
  114. }
  115. void URLArgs::setContentType( const TQString & contentType )
  116. {
  117. if (!d)
  118. d = new URLArgsPrivate;
  119. d->contentType = contentType;
  120. }
  121. void URLArgs::setRedirectedRequest( bool redirected )
  122. {
  123. if (!d)
  124. d = new URLArgsPrivate;
  125. d->redirectedRequest = redirected;
  126. }
  127. bool URLArgs::redirectedRequest () const
  128. {
  129. return d ? d->redirectedRequest : false;
  130. }
  131. TQString URLArgs::contentType() const
  132. {
  133. return d ? d->contentType : TQString::null;
  134. }
  135. TQMap<TQString, TQString> &URLArgs::metaData()
  136. {
  137. if (!d)
  138. d = new URLArgsPrivate;
  139. return d->metaData;
  140. }
  141. void URLArgs::setDoPost( bool enable )
  142. {
  143. if ( !d )
  144. d = new URLArgsPrivate;
  145. d->doPost = enable;
  146. }
  147. bool URLArgs::doPost() const
  148. {
  149. return d ? d->doPost : false;
  150. }
  151. void URLArgs::setLockHistory( bool lock )
  152. {
  153. if (!d)
  154. d = new URLArgsPrivate;
  155. d->lockHistory = lock;
  156. }
  157. bool URLArgs::lockHistory() const
  158. {
  159. return d ? d->lockHistory : false;
  160. }
  161. void URLArgs::setNewTab( bool newTab )
  162. {
  163. if (!d)
  164. d = new URLArgsPrivate;
  165. d->newTab = newTab;
  166. }
  167. bool URLArgs::newTab() const
  168. {
  169. return d ? d->newTab : false;
  170. }
  171. void URLArgs::setForcesNewWindow( bool forcesNewWindow )
  172. {
  173. if (!d)
  174. d = new URLArgsPrivate;
  175. d->forcesNewWindow = forcesNewWindow;
  176. }
  177. bool URLArgs::forcesNewWindow() const
  178. {
  179. return d ? d->forcesNewWindow : false;
  180. }
  181. namespace KParts
  182. {
  183. struct WindowArgsPrivate
  184. {
  185. };
  186. }
  187. WindowArgs::WindowArgs()
  188. {
  189. x = y = width = height = -1;
  190. fullscreen = false;
  191. menuBarVisible = true;
  192. toolBarsVisible = true;
  193. statusBarVisible = true;
  194. scrollBarsVisible = true;
  195. resizable = true;
  196. lowerWindow = false;
  197. d = 0;
  198. }
  199. WindowArgs::WindowArgs( const WindowArgs &args )
  200. {
  201. d = 0;
  202. (*this) = args;
  203. }
  204. WindowArgs::~WindowArgs()
  205. {
  206. delete d;
  207. }
  208. WindowArgs &WindowArgs::operator=( const WindowArgs &args )
  209. {
  210. if ( this == &args ) return *this;
  211. delete d; d = 0;
  212. x = args.x;
  213. y = args.y;
  214. width = args.width;
  215. height = args.height;
  216. fullscreen = args.fullscreen;
  217. menuBarVisible = args.menuBarVisible;
  218. toolBarsVisible = args.toolBarsVisible;
  219. statusBarVisible = args.statusBarVisible;
  220. scrollBarsVisible = args.scrollBarsVisible;
  221. resizable = args.resizable;
  222. lowerWindow = args.lowerWindow;
  223. /*
  224. if ( args.d )
  225. {
  226. [ ... ]
  227. }
  228. */
  229. return *this;
  230. }
  231. WindowArgs::WindowArgs( const TQRect &_geometry, bool _fullscreen, bool _menuBarVisible,
  232. bool _toolBarsVisible, bool _statusBarVisible, bool _resizable )
  233. {
  234. d = 0;
  235. x = _geometry.x();
  236. y = _geometry.y();
  237. width = _geometry.width();
  238. height = _geometry.height();
  239. fullscreen = _fullscreen;
  240. menuBarVisible = _menuBarVisible;
  241. toolBarsVisible = _toolBarsVisible;
  242. statusBarVisible = _statusBarVisible;
  243. resizable = _resizable;
  244. lowerWindow = false;
  245. }
  246. WindowArgs::WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
  247. bool _menuBarVisible, bool _toolBarsVisible,
  248. bool _statusBarVisible, bool _resizable )
  249. {
  250. d = 0;
  251. x = _x;
  252. y = _y;
  253. width = _width;
  254. height = _height;
  255. fullscreen = _fullscreen;
  256. menuBarVisible = _menuBarVisible;
  257. toolBarsVisible = _toolBarsVisible;
  258. statusBarVisible = _statusBarVisible;
  259. resizable = _resizable;
  260. lowerWindow = false;
  261. }
  262. namespace KParts
  263. {
  264. // Internal class, use to store the status of the actions
  265. class KBitArray
  266. {
  267. public:
  268. int val;
  269. KBitArray() { val = 0; }
  270. bool operator [](int index) { return (val & (1 << index)) ? true : false; }
  271. void setBit(int index, bool value) {
  272. if (value) val = val | (1 << index);
  273. else val = val & ~(1 << index);
  274. }
  275. };
  276. class BrowserExtensionPrivate
  277. {
  278. public:
  279. BrowserExtensionPrivate()
  280. {
  281. m_browserInterface = 0;
  282. }
  283. ~BrowserExtensionPrivate()
  284. {
  285. }
  286. struct DelayedRequest {
  287. KURL m_delayedURL;
  288. KParts::URLArgs m_delayedArgs;
  289. };
  290. TQValueList<DelayedRequest> m_requests;
  291. bool m_urlDropHandlingEnabled;
  292. KBitArray m_actionStatus;
  293. TQMap<int, TQString> m_actionText;
  294. BrowserInterface *m_browserInterface;
  295. };
  296. }
  297. BrowserExtension::ActionSlotMap * BrowserExtension::s_actionSlotMap = 0L;
  298. static KStaticDeleter<BrowserExtension::ActionSlotMap> actionSlotMapsd;
  299. BrowserExtension::ActionNumberMap * BrowserExtension::s_actionNumberMap = 0L;
  300. static KStaticDeleter<BrowserExtension::ActionNumberMap> actionNumberMapsd;
  301. BrowserExtension::BrowserExtension( KParts::ReadOnlyPart *parent,
  302. const char *name )
  303. : TQObject( parent, name), m_part( parent )
  304. {
  305. //kdDebug() << "BrowserExtension::BrowserExtension() " << this << endl;
  306. d = new BrowserExtensionPrivate;
  307. d->m_urlDropHandlingEnabled = false;
  308. if ( !s_actionSlotMap )
  309. // Create the action-slot map
  310. createActionSlotMap();
  311. // Set the initial status of the actions depending on whether
  312. // they're supported or not
  313. ActionSlotMap::ConstIterator it = s_actionSlotMap->begin();
  314. ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->end();
  315. TQStrList slotNames = metaObject()->slotNames();
  316. for ( int i=0 ; it != itEnd ; ++it, ++i )
  317. {
  318. // Does the extension have a slot with the name of this action ?
  319. d->m_actionStatus.setBit( i, slotNames.contains( it.key()+"()" ) );
  320. }
  321. connect( m_part, TQT_SIGNAL( completed() ),
  322. this, TQT_SLOT( slotCompleted() ) );
  323. connect( this, TQT_SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ),
  324. this, TQT_SLOT( slotOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) );
  325. connect( this, TQT_SIGNAL( enableAction( const char *, bool ) ),
  326. this, TQT_SLOT( slotEnableAction( const char *, bool ) ) );
  327. connect( this, TQT_SIGNAL( setActionText( const char *, const TQString& ) ),
  328. this, TQT_SLOT( slotSetActionText( const char *, const TQString& ) ) );
  329. }
  330. BrowserExtension::~BrowserExtension()
  331. {
  332. //kdDebug() << "BrowserExtension::~BrowserExtension() " << this << endl;
  333. delete d;
  334. }
  335. void BrowserExtension::setURLArgs( const URLArgs &args )
  336. {
  337. m_args = args;
  338. }
  339. URLArgs BrowserExtension::urlArgs() const
  340. {
  341. return m_args;
  342. }
  343. int BrowserExtension::xOffset()
  344. {
  345. return 0;
  346. }
  347. int BrowserExtension::yOffset()
  348. {
  349. return 0;
  350. }
  351. void BrowserExtension::saveState( TQDataStream &stream )
  352. {
  353. stream << m_part->url() << (TQ_INT32)xOffset() << (TQ_INT32)yOffset();
  354. }
  355. void BrowserExtension::restoreState( TQDataStream &stream )
  356. {
  357. KURL u;
  358. TQ_INT32 xOfs, yOfs;
  359. stream >> u >> xOfs >> yOfs;
  360. URLArgs args( urlArgs() );
  361. args.xOffset = xOfs;
  362. args.yOffset = yOfs;
  363. setURLArgs( args );
  364. m_part->openURL( u );
  365. }
  366. bool BrowserExtension::isURLDropHandlingEnabled() const
  367. {
  368. return d->m_urlDropHandlingEnabled;
  369. }
  370. void BrowserExtension::setURLDropHandlingEnabled( bool enable )
  371. {
  372. d->m_urlDropHandlingEnabled = enable;
  373. }
  374. void BrowserExtension::slotCompleted()
  375. {
  376. //empty the argument stuff, to avoid bogus/invalid values when opening a new url
  377. setURLArgs( URLArgs() );
  378. }
  379. void BrowserExtension::pasteRequest()
  380. {
  381. TQCString plain( "plain" );
  382. TQString url = TQApplication::clipboard()->text(plain, TQClipboard::Selection).stripWhiteSpace();
  383. // Remove linefeeds and any whitespace surrounding it.
  384. url.remove(TQRegExp("[\\ ]*\\n+[\\ ]*"));
  385. // Check if it's a URL
  386. TQStringList filters = KURIFilter::self()->pluginNames();
  387. filters.remove( "kuriikwsfilter" );
  388. filters.remove( "localdomainurifilter" );
  389. KURIFilterData filterData;
  390. filterData.setData( url );
  391. filterData.setCheckForExecutables( false );
  392. if ( KURIFilter::self()->filterURI( filterData, filters ) )
  393. {
  394. switch ( filterData.uriType() )
  395. {
  396. case KURIFilterData::LOCAL_FILE:
  397. case KURIFilterData::LOCAL_DIR:
  398. case KURIFilterData::NET_PROTOCOL:
  399. slotOpenURLRequest( filterData.uri(), KParts::URLArgs() );
  400. break;
  401. case KURIFilterData::ERROR:
  402. KMessageBox::sorry( m_part->widget(), filterData.errorMsg() );
  403. break;
  404. default:
  405. break;
  406. }
  407. }
  408. else if ( KURIFilter::self()->filterURI( filterData, "kuriikwsfilter" ) && url.length() < 250 )
  409. {
  410. if ( KMessageBox::questionYesNo( m_part->widget(),
  411. i18n( "<qt>Do you want to search the Internet for <b>%1</b>?" ).arg( TQStyleSheet::escape(url) ),
  412. i18n( "Internet Search" ), KGuiItem( i18n( "&Search" ), "edit-find"),
  413. KStdGuiItem::cancel(), "MiddleClickSearch" ) == KMessageBox::Yes)
  414. slotOpenURLRequest( filterData.uri(), KParts::URLArgs() );
  415. }
  416. }
  417. void BrowserExtension::slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args )
  418. {
  419. //kdDebug() << this << " BrowserExtension::slotOpenURLRequest(): url=" << url.url() << endl;
  420. BrowserExtensionPrivate::DelayedRequest req;
  421. req.m_delayedURL = url;
  422. req.m_delayedArgs = args;
  423. d->m_requests.append( req );
  424. TQTimer::singleShot( 0, this, TQT_SLOT( slotEmitOpenURLRequestDelayed() ) );
  425. }
  426. void BrowserExtension::slotEmitOpenURLRequestDelayed()
  427. {
  428. if (d->m_requests.isEmpty()) return;
  429. BrowserExtensionPrivate::DelayedRequest req = d->m_requests.front();
  430. d->m_requests.pop_front();
  431. emit openURLRequestDelayed( req.m_delayedURL, req.m_delayedArgs );
  432. // tricky: do not do anything here! (no access to member variables, etc.)
  433. }
  434. void BrowserExtension::setBrowserInterface( BrowserInterface *impl )
  435. {
  436. d->m_browserInterface = impl;
  437. }
  438. BrowserInterface *BrowserExtension::browserInterface() const
  439. {
  440. return d->m_browserInterface;
  441. }
  442. void BrowserExtension::slotEnableAction( const char * name, bool enabled )
  443. {
  444. //kdDebug() << "BrowserExtension::slotEnableAction " << name << " " << enabled << endl;
  445. ActionNumberMap::ConstIterator it = s_actionNumberMap->find( name );
  446. if ( it != s_actionNumberMap->end() )
  447. {
  448. d->m_actionStatus.setBit( it.data(), enabled );
  449. //kdDebug() << "BrowserExtension::slotEnableAction setting bit " << it.data() << " to " << enabled << endl;
  450. }
  451. else
  452. kdWarning() << "BrowserExtension::slotEnableAction unknown action " << name << endl;
  453. }
  454. bool BrowserExtension::isActionEnabled( const char * name ) const
  455. {
  456. int actionNumber = (*s_actionNumberMap)[ name ];
  457. return d->m_actionStatus[ actionNumber ];
  458. }
  459. void BrowserExtension::slotSetActionText( const char * name, const TQString& text )
  460. {
  461. kdDebug() << "BrowserExtension::slotSetActionText " << name << " " << text << endl;
  462. ActionNumberMap::ConstIterator it = s_actionNumberMap->find( name );
  463. if ( it != s_actionNumberMap->end() )
  464. {
  465. d->m_actionText[ it.data() ] = text;
  466. }
  467. else
  468. kdWarning() << "BrowserExtension::slotSetActionText unknown action " << name << endl;
  469. }
  470. TQString BrowserExtension::actionText( const char * name ) const
  471. {
  472. int actionNumber = (*s_actionNumberMap)[ name ];
  473. TQMap<int, TQString>::ConstIterator it = d->m_actionText.find( actionNumber );
  474. if ( it != d->m_actionText.end() )
  475. return *it;
  476. return TQString::null;
  477. }
  478. // for compatibility
  479. BrowserExtension::ActionSlotMap BrowserExtension::actionSlotMap()
  480. {
  481. return *actionSlotMapPtr();
  482. }
  483. BrowserExtension::ActionSlotMap * BrowserExtension::actionSlotMapPtr()
  484. {
  485. if (!s_actionSlotMap)
  486. createActionSlotMap();
  487. return s_actionSlotMap;
  488. }
  489. void BrowserExtension::createActionSlotMap()
  490. {
  491. assert(!s_actionSlotMap);
  492. s_actionSlotMap = actionSlotMapsd.setObject( s_actionSlotMap, new ActionSlotMap );
  493. s_actionSlotMap->insert( "cut", TQT_SLOT( cut() ) );
  494. s_actionSlotMap->insert( "copy", TQT_SLOT( copy() ) );
  495. s_actionSlotMap->insert( "paste", TQT_SLOT( paste() ) );
  496. s_actionSlotMap->insert( "rename", TQT_SLOT( rename() ) );
  497. s_actionSlotMap->insert( "trash", TQT_SLOT( trash() ) );
  498. s_actionSlotMap->insert( "del", TQT_SLOT( del() ) );
  499. s_actionSlotMap->insert( "properties", TQT_SLOT( properties() ) );
  500. s_actionSlotMap->insert( "editMimeType", TQT_SLOT( editMimeType() ) );
  501. s_actionSlotMap->insert( "print", TQT_SLOT( print() ) );
  502. // Tricky. Those aren't actions in fact, but simply methods that a browserextension
  503. // can have or not. No need to return them here.
  504. //s_actionSlotMap->insert( "reparseConfiguration", TQT_SLOT( reparseConfiguration() ) );
  505. //s_actionSlotMap->insert( "refreshMimeTypes", TQT_SLOT( refreshMimeTypes() ) );
  506. // nothing for setSaveViewPropertiesLocally either
  507. // Create the action-number map
  508. assert(!s_actionNumberMap);
  509. s_actionNumberMap = actionNumberMapsd.setObject( s_actionNumberMap, new ActionNumberMap );
  510. ActionSlotMap::ConstIterator it = s_actionSlotMap->begin();
  511. ActionSlotMap::ConstIterator itEnd = s_actionSlotMap->end();
  512. for ( int i=0 ; it != itEnd ; ++it, ++i )
  513. {
  514. //kdDebug(1202) << " action " << it.key() << " number " << i << endl;
  515. s_actionNumberMap->insert( it.key(), i );
  516. }
  517. }
  518. BrowserExtension *BrowserExtension::childObject( TQObject *obj )
  519. {
  520. if ( !obj || obj->childrenListObject().isEmpty() )
  521. return 0L;
  522. // we try to do it on our own, in hope that we are faster than
  523. // queryList, which looks kind of big :-)
  524. const TQObjectList children = obj->childrenListObject();
  525. TQObjectListIt it( children );
  526. for (; it.current(); ++it )
  527. if ( it.current()->inherits( "KParts::BrowserExtension" ) )
  528. return static_cast<KParts::BrowserExtension *>( it.current() );
  529. return 0L;
  530. }
  531. namespace KParts
  532. {
  533. class BrowserHostExtension::BrowserHostExtensionPrivate
  534. {
  535. public:
  536. BrowserHostExtensionPrivate()
  537. {
  538. }
  539. ~BrowserHostExtensionPrivate()
  540. {
  541. }
  542. KParts::ReadOnlyPart *m_part;
  543. };
  544. }
  545. BrowserHostExtension::BrowserHostExtension( KParts::ReadOnlyPart *parent, const char *name )
  546. : TQObject( parent, name )
  547. {
  548. d = new BrowserHostExtensionPrivate;
  549. d->m_part = parent;
  550. }
  551. BrowserHostExtension::~BrowserHostExtension()
  552. {
  553. delete d;
  554. }
  555. TQStringList BrowserHostExtension::frameNames() const
  556. {
  557. return TQStringList();
  558. }
  559. const TQPtrList<KParts::ReadOnlyPart> BrowserHostExtension::frames() const
  560. {
  561. return TQPtrList<KParts::ReadOnlyPart>();
  562. }
  563. bool BrowserHostExtension::openURLInFrame( const KURL &, const KParts::URLArgs & )
  564. {
  565. return false;
  566. }
  567. BrowserHostExtension *BrowserHostExtension::childObject( TQObject *obj )
  568. {
  569. if ( !obj || obj->childrenListObject().isEmpty() )
  570. return 0L;
  571. // we try to do it on our own, in hope that we are faster than
  572. // queryList, which looks kind of big :-)
  573. const TQObjectList children = obj->childrenListObject();
  574. TQObjectListIt it( children );
  575. for (; it.current(); ++it )
  576. if ( it.current()->inherits( "KParts::BrowserHostExtension" ) )
  577. return static_cast<KParts::BrowserHostExtension *>( it.current() );
  578. return 0L;
  579. }
  580. void BrowserExtension::virtual_hook( int, void* )
  581. { /*BASE::virtual_hook( id, data );*/ }
  582. BrowserHostExtension *
  583. BrowserHostExtension::findFrameParent(KParts::ReadOnlyPart *callingPart, const TQString &frame)
  584. {
  585. FindFrameParentParams param;
  586. param.parent = 0;
  587. param.callingPart = callingPart;
  588. param.frame = frame;
  589. virtual_hook(VIRTUAL_FIND_FRAME_PARENT, &param);
  590. return param.parent;
  591. }
  592. void BrowserHostExtension::virtual_hook( int, void* )
  593. { /*BASE::virtual_hook( id, data );*/ }
  594. LiveConnectExtension::LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name ) : TQObject( parent, name) {}
  595. bool LiveConnectExtension::get( const unsigned long, const TQString &, Type &, unsigned long &, TQString & ) {
  596. return false;
  597. }
  598. bool LiveConnectExtension::put( const unsigned long, const TQString &, const TQString & ) {
  599. return false;
  600. }
  601. bool LiveConnectExtension::call( const unsigned long, const TQString &, const TQStringList &, Type &, unsigned long &, TQString & ) {
  602. return false;
  603. }
  604. void LiveConnectExtension::unregister( const unsigned long ) {}
  605. LiveConnectExtension *LiveConnectExtension::childObject( TQObject *obj )
  606. {
  607. if ( !obj || obj->childrenListObject().isEmpty() )
  608. return 0L;
  609. // we try to do it on our own, in hope that we are faster than
  610. // queryList, which looks kind of big :-)
  611. const TQObjectList children = obj->childrenListObject();
  612. TQObjectListIt it( children );
  613. for (; it.current(); ++it )
  614. if ( it.current()->inherits( "KParts::LiveConnectExtension" ) )
  615. return static_cast<KParts::LiveConnectExtension *>( it.current() );
  616. return 0L;
  617. }
  618. #include "browserextension.moc"