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.h 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. /* This file is part of the KDE project
  2. Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3. 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. #ifndef __tdeparts_browserextension_h__
  18. #define __tdeparts_browserextension_h__
  19. #include <sys/types.h>
  20. #include <tqpoint.h>
  21. #include <tqptrlist.h>
  22. #include <tqdatastream.h>
  23. #include <tqstringlist.h>
  24. #include <tqpair.h>
  25. #include <tdeparts/part.h>
  26. #include <tdeparts/event.h>
  27. class KFileItem;
  28. typedef TQPtrList<KFileItem> KFileItemList;
  29. class TQString;
  30. namespace KParts {
  31. class BrowserInterface;
  32. struct URLArgsPrivate;
  33. /**
  34. * URLArgs is a set of arguments bundled into a structure,
  35. * to allow specifying how a URL should be opened by openURL().
  36. * In other words, this is like arguments to openURL(), but without
  37. * have to change the signature of openURL() (since openURL is a
  38. * generic KParts method).
  39. * The parts (with a browser extension) who care about urlargs will
  40. * use those arguments, others will ignore them.
  41. *
  42. * This can also be used the other way round, when a part asks
  43. * for a URL to be opened (with openURLRequest or createNewWindow).
  44. */
  45. struct TDEPARTS_EXPORT URLArgs
  46. {
  47. URLArgs();
  48. URLArgs( const URLArgs &args );
  49. URLArgs &operator=( const URLArgs &args);
  50. URLArgs( bool reload, int xOffset, int yOffset, const TQString &serviceType = TQString::null );
  51. virtual ~URLArgs();
  52. /**
  53. * This buffer can be used by the part to save and restore its contents.
  54. * See TDEHTMLPart for instance.
  55. */
  56. TQStringList docState;
  57. /**
  58. * @p reload is set when the cache shouldn't be used (forced reload).
  59. */
  60. bool reload;
  61. /**
  62. * @p xOffset is the horizontal scrolling of the part's widget
  63. * (in case it's a scrollview). This is saved into the history
  64. * and restored when going back in the history.
  65. */
  66. int xOffset;
  67. /**
  68. * @p yOffset vertical scrolling position, xOffset.
  69. */
  70. int yOffset;
  71. /**
  72. * The servicetype (usually mimetype) to use when opening the next URL.
  73. */
  74. TQString serviceType;
  75. /**
  76. * TDEHTML-specific field, contents of the HTTP POST data.
  77. */
  78. TQByteArray postData;
  79. /**
  80. * TDEHTML-specific field, header defining the type of the POST data.
  81. */
  82. void setContentType( const TQString & contentType );
  83. /**
  84. * TDEHTML-specific field, header defining the type of the POST data.
  85. */
  86. TQString contentType() const;
  87. /**
  88. * TDEHTML-specific field, whether to do a POST instead of a GET,
  89. * for the next openURL.
  90. */
  91. void setDoPost( bool enable );
  92. /**
  93. * TDEHTML-specific field, whether to do a POST instead of a GET,
  94. * for the next openURL.
  95. */
  96. bool doPost() const;
  97. /**
  98. * Whether to lock the history when opening the next URL.
  99. * This is used during e.g. a redirection, to avoid a new entry
  100. * in the history.
  101. */
  102. void setLockHistory( bool lock );
  103. bool lockHistory() const;
  104. /**
  105. * Whether the URL should be opened in a new tab instead in a new window.
  106. */
  107. void setNewTab( bool newTab );
  108. bool newTab() const;
  109. /**
  110. * Meta-data to associate with the next TDEIO operation
  111. * @see TDEIO::TransferJob etc.
  112. */
  113. TQMap<TQString, TQString> &metaData();
  114. /**
  115. * The frame in which to open the URL. TDEHTML/Konqueror-specific.
  116. */
  117. TQString frameName;
  118. /**
  119. * If true, the part who asks for a URL to be opened can be 'trusted'
  120. * to execute applications. For instance, the directory views can be
  121. * 'trusted' whereas HTML pages are not trusted in that respect.
  122. */
  123. bool trustedSource;
  124. /**
  125. * @return true if the request was a result of a META refresh/redirect request or
  126. * HTTP redirect.
  127. */
  128. bool redirectedRequest () const;
  129. /**
  130. * Set the redirect flag to indicate URL is a result of either a META redirect
  131. * or HTTP redirect.
  132. *
  133. * @param redirected
  134. */
  135. void setRedirectedRequest(bool redirected);
  136. /**
  137. * Set whether the URL specifies to be opened in a new window
  138. * @since 3.4
  139. */
  140. void setForcesNewWindow( bool forcesNewWindow );
  141. /**
  142. * Whether the URL specifies to be opened in a new window
  143. * @since 3.4
  144. */
  145. bool forcesNewWindow() const;
  146. URLArgsPrivate *d;
  147. };
  148. struct WindowArgsPrivate;
  149. /**
  150. * The WindowArgs are used to specify arguments to the "create new window"
  151. * call (see the createNewWindow variant that uses WindowArgs).
  152. * The primary reason for this is the javascript window.open function.
  153. */
  154. struct TDEPARTS_EXPORT WindowArgs
  155. {
  156. WindowArgs();
  157. ~WindowArgs();
  158. WindowArgs( const WindowArgs &args );
  159. WindowArgs &operator=( const WindowArgs &args );
  160. WindowArgs( const TQRect &_geometry, bool _fullscreen, bool _menuBarVisible,
  161. bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
  162. WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
  163. bool _menuBarVisible, bool _toolBarsVisible,
  164. bool _statusBarVisible, bool _resizable );
  165. // Position
  166. int x;
  167. int y;
  168. // Size
  169. int width;
  170. int height;
  171. bool fullscreen; //defaults to false
  172. bool menuBarVisible; //defaults to true
  173. bool toolBarsVisible; //defaults to true
  174. bool statusBarVisible; //defaults to true
  175. bool resizable; //defaults to true
  176. bool lowerWindow; //defaults to false
  177. bool scrollBarsVisible; //defaults to true
  178. WindowArgsPrivate *d; // don't use before KDE4, many KDE-3.x didn't have an explicit destructor
  179. };
  180. /**
  181. * The KParts::OpenURLEvent event informs that a given part has opened a given URL.
  182. * Applications can use this event to send this information to interested plugins.
  183. *
  184. * The event should be sent before opening the URL in the part, so that the plugins
  185. * can use part()->url() to get the old URL.
  186. */
  187. class TDEPARTS_EXPORT OpenURLEvent : public Event
  188. {
  189. public:
  190. OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
  191. virtual ~OpenURLEvent();
  192. ReadOnlyPart *part() const { return m_part; }
  193. KURL url() const { return m_url; }
  194. URLArgs args() const { return m_args; }
  195. static bool test( const TQEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
  196. private:
  197. static const char *s_strOpenURLEvent;
  198. ReadOnlyPart *m_part;
  199. KURL m_url;
  200. URLArgs m_args;
  201. class OpenURLEventPrivate;
  202. OpenURLEventPrivate *d;
  203. };
  204. class BrowserExtensionPrivate;
  205. /**
  206. * The Browser Extension is an extension (yes, no kidding) to
  207. * KParts::ReadOnlyPart, which allows a better integration of parts
  208. * with browsers (in particular Konqueror).
  209. * Remember that ReadOnlyPart only has openURL(KURL), with no other settings.
  210. * For full-fledged browsing, we need much more than that, including
  211. * many arguments about how to open this URL (see URLArgs), allowing
  212. * parts to save and restore their data into the back/forward history,
  213. * allowing parts to control the location bar URL, to requests URLs
  214. * to be opened by the hosting browser, etc.
  215. *
  216. * The part developer needs to define its own class derived from BrowserExtension,
  217. * to implement the virtual methods [and the standard-actions slots, see below].
  218. *
  219. * The way to associate the BrowserExtension with the part is to simply
  220. * create the BrowserExtension as a child of the part (in QObject's terms).
  221. * The hosting application will look for it automatically.
  222. *
  223. * Another aspect of the browser integration is that a set of standard
  224. * actions are provided by the browser, but implemented by the part
  225. * (for the actions it supports).
  226. *
  227. * The following standard actions are defined by the host of the view :
  228. *
  229. * [selection-dependent actions]
  230. * @li @p cut : Copy selected items to clipboard and store 'not cut' in clipboard.
  231. * @li @p copy : Copy selected items to clipboard and store 'cut' in clipboard.
  232. * @li @p paste : Paste clipboard into view URL.
  233. * @li @p pasteTo(const KURL &) : Paste clipboard into given URL.
  234. * @li @p rename : Rename item in place.
  235. * @li @p trash : Move selected items to trash.
  236. * @li @p del : Delete selected items (couldn't call it delete!).
  237. * @li @p shred : Shred selected items (secure deletion) - DEPRECATED.
  238. * @li @p properties : Show file/document properties.
  239. * @li @p editMimeType : show file/document's mimetype properties.
  240. * @li @p searchProvider : Lookup selected text at default search provider
  241. *
  242. * [normal actions]
  243. * @li @p print : Print :-)
  244. * @li @p reparseConfiguration : Re-read configuration and apply it.
  245. * @li @p refreshMimeTypes : If the view uses mimetypes it should re-determine them.
  246. *
  247. *
  248. * The view defines a slot with the name of the action in order to implement the action.
  249. * The browser will detect the slot automatically and connect its action to it when
  250. * appropriate (i.e. when the view is active).
  251. *
  252. *
  253. * The selection-dependent actions are disabled by default and the view should
  254. * enable them when the selection changes, emitting enableAction().
  255. *
  256. * The normal actions do not depend on the selection.
  257. * You need to enable 'print' when printing is possible - you can even do that
  258. * in the constructor.
  259. *
  260. * A special case is the configuration slots, not connected to any action directly,
  261. * and having parameters.
  262. *
  263. * [configuration slot]
  264. * @li @p setSaveViewPropertiesLocally( bool ): If @p true, view properties are saved into .directory
  265. * otherwise, they are saved globally.
  266. * @li @p disableScrolling: no scrollbars
  267. */
  268. class TDEPARTS_EXPORT BrowserExtension : public TQObject
  269. {
  270. Q_OBJECT
  271. TQ_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
  272. public:
  273. /**
  274. * Constructor
  275. *
  276. * @param parent The KParts::ReadOnlyPart that this extension ... "extends" :)
  277. * @param name An optional name for the extension.
  278. */
  279. BrowserExtension( KParts::ReadOnlyPart *parent,
  280. const char *name = 0L );
  281. virtual ~BrowserExtension();
  282. typedef uint PopupFlags;
  283. /**
  284. * Set of flags passed via the popupMenu signal, to ask for some items in the popup menu.
  285. * DefaultPopupItems: default value, no additional menu item
  286. * ShowNavigationItems: show "back" and "forward" (usually done when clicking the background of the view, but not an item)
  287. * ShowUp: show "up" (same thing, but not over e.g. HTTP). Requires ShowNavigationItems.
  288. * ShowReload: show "reload" (usually done when clicking the background of the view, but not an item)
  289. * ShowBookmark: show "add to bookmarks" (usually not done on the local filesystem)
  290. * ShowCreateDirectory: show "create directory" (usually only done on the background of the view, or
  291. * in hierarchical views like directory trees, where the new dir would be visible)
  292. * ShowTextSelectionItems: set when selecting text, for a popup that only contains text-related items.
  293. * NoDeletion: deletion, trashing and renaming not allowed (e.g. parent dir not writeable).
  294. * (this is only needed if the protocol itself supports deletion, unlike e.g. HTTP)
  295. *
  296. * KDE4 TODO: add IsLink flag, for "Bookmark This Link" and linkactions merging group.
  297. * [currently it depends on which signal is emitted]
  298. * add ShowURLOperation flags for copy,cut,paste,rename,trash,del [same thing]
  299. */
  300. enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001,
  301. ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008,
  302. ShowCreateDirectory=0x0010, ShowTextSelectionItems=0x0020,
  303. NoDeletion=0x0040 ///< @since 3.4
  304. };
  305. /**
  306. * Set the parameters to use for opening the next URL.
  307. * This is called by the "hosting" application, to pass parameters to the part.
  308. * @see URLArgs
  309. */
  310. virtual void setURLArgs( const URLArgs &args );
  311. /**
  312. * Retrieve the set of parameters to use for opening the URL
  313. * (this must be called from openURL() in the part).
  314. * @see URLArgs
  315. */
  316. URLArgs urlArgs() const;
  317. /**
  318. * Returns the current x offset.
  319. *
  320. * For a scrollview, implement this using contentsX().
  321. */
  322. virtual int xOffset();
  323. /**
  324. * Returns the current y offset.
  325. *
  326. * For a scrollview, implement this using contentsY().
  327. */
  328. virtual int yOffset();
  329. /**
  330. * Used by the browser to save the current state of the view
  331. * (in order to restore it if going back in navigation).
  332. *
  333. * If you want to save additional properties, reimplement it
  334. * but don't forget to call the parent method (probably first).
  335. */
  336. virtual void saveState( TQDataStream &stream );
  337. /**
  338. * Used by the browser to restore the view in the state
  339. * it was when we left it.
  340. *
  341. * If you saved additional properties, reimplement it
  342. * but don't forget to call the parent method (probably first).
  343. */
  344. virtual void restoreState( TQDataStream &stream );
  345. /**
  346. * Returns whether url drop handling is enabled.
  347. * See setURLDropHandlingEnabled for more information about this
  348. * property.
  349. */
  350. bool isURLDropHandlingEnabled() const;
  351. /**
  352. * Enables or disables url drop handling. URL drop handling is a property
  353. * describing whether the hosting shell component is allowed to install an
  354. * event filter on the part's widget, to listen for URI drop events.
  355. * Set it to true if you are exporting a BrowserExtension implementation and
  356. * do not provide any special URI drop handling. If set to false you can be
  357. * sure to receive all those URI drop events unfiltered. Also note that the
  358. * implementation as of Konqueror installs the event filter only on the part's
  359. * widget itself, not on child widgets.
  360. */
  361. void setURLDropHandlingEnabled( bool enable );
  362. void setBrowserInterface( BrowserInterface *impl );
  363. BrowserInterface *browserInterface() const;
  364. /**
  365. * @return the status (enabled/disabled) of an action.
  366. * When the enableAction signal is emitted, the browserextension
  367. * stores the status of the action internally, so that it's possible
  368. * to query later for the status of the action, using this method.
  369. */
  370. bool isActionEnabled( const char * name ) const;
  371. /**
  372. * @return the text of an action, if it was set explicitely by the part.
  373. * When the setActionText signal is emitted, the browserextension
  374. * stores the text of the action internally, so that it's possible
  375. * to query later for the text of the action, using this method.
  376. * @since 3.5
  377. */
  378. TQString actionText( const char * name ) const;
  379. typedef TQMap<TQCString,TQCString> ActionSlotMap;
  380. /**
  381. * Returns a map containing the action names as keys and corresponding
  382. * TQT_SLOT()'ified method names as data entries.
  383. *
  384. * This is very useful for
  385. * the host component, when connecting the own signals with the
  386. * extension's slots.
  387. * Basically you iterate over the map, check if the extension implements
  388. * the slot and connect to the slot using the data value of your map
  389. * iterator.
  390. * Checking if the extension implements a certain slot can be done like this:
  391. *
  392. * \code
  393. * extension->metaObject()->slotNames().contains( actionName + "()" )
  394. * \endcode
  395. *
  396. * (note that @p actionName is the iterator's key value if already
  397. * iterating over the action slot map, returned by this method)
  398. *
  399. * Connecting to the slot can be done like this:
  400. *
  401. * \code
  402. * connect( yourObject, TQT_SIGNAL( yourSignal() ),
  403. * extension, mapIterator.data() )
  404. * \endcode
  405. *
  406. * (where "mapIterator" is your TQMap<TQCString,TQCString> iterator)
  407. */
  408. static ActionSlotMap actionSlotMap();
  409. /**
  410. * @return a pointer to the static action-slot map. Preferred method to get it.
  411. * The map is created if it doesn't exist yet
  412. */
  413. static ActionSlotMap * actionSlotMapPtr();
  414. /**
  415. * Queries @p obj for a child object which inherits from this
  416. * BrowserExtension class. Convenience method.
  417. */
  418. static BrowserExtension *childObject( TQObject *obj );
  419. /**
  420. * Asks the hosting browser to perform a paste (using openURLRequestDelayed)
  421. * @since 3.2
  422. */
  423. void pasteRequest();
  424. // KDE invents support for public signals...
  425. #undef signals
  426. #define signals public
  427. signals:
  428. #undef signals
  429. #define signals protected
  430. /**
  431. * Enables or disable a standard action held by the browser.
  432. *
  433. * See class documentation for the list of standard actions.
  434. */
  435. void enableAction( const char * name, bool enabled );
  436. /**
  437. * Change the text of a standard action held by the browser.
  438. * This can be used to change "Paste" into "Paste Image" for instance.
  439. *
  440. * See class documentation for the list of standard actions.
  441. * @since 3.5
  442. */
  443. void setActionText( const char * name, const TQString& text );
  444. /**
  445. * Asks the host (browser) to open @p url.
  446. * To set a reload, the x and y offsets, the service type etc., fill in the
  447. * appropriate fields in the @p args structure.
  448. * Hosts should not connect to this signal but to openURLRequestDelayed.
  449. */
  450. void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  451. /**
  452. * This signal is emitted when openURLRequest is called, after a 0-seconds timer.
  453. * This allows the caller to terminate what it's doing first, before (usually)
  454. * being destroyed. Parts should never use this signal, hosts should only connect
  455. * to this signal.
  456. */
  457. void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  458. /**
  459. * Tells the hosting browser that the part opened a new URL (which can be
  460. * queried via KParts::Part::url().
  461. *
  462. * This helps the browser to update/create an entry in the history.
  463. * The part may @em not emit this signal together with openURLRequest().
  464. * Emit openURLRequest() if you want the browser to handle a URL the user
  465. * asked to open (from within your part/document). This signal however is
  466. * useful if you want to handle URLs all yourself internally, while still
  467. * telling the hosting browser about new opened URLs, in order to provide
  468. * a proper history functionality to the user.
  469. * An example of usage is a html rendering component which wants to emit
  470. * this signal when a child frame document changed its URL.
  471. * Conclusion: you probably want to use openURLRequest() instead.
  472. */
  473. void openURLNotify();
  474. /**
  475. * Updates the URL shown in the browser's location bar to @p url.
  476. */
  477. void setLocationBarURL( const TQString &url );
  478. /**
  479. * Sets the URL of an icon for the currently displayed page.
  480. */
  481. void setIconURL( const KURL &url );
  482. /**
  483. * Asks the hosting browser to open a new window for the given @p url.
  484. *
  485. * The @p args argument is optional additional information for the
  486. * browser,
  487. * @see KParts::URLArgs
  488. */
  489. void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
  490. /**
  491. * Asks the hosting browser to open a new window for the given @p url
  492. * and return a reference to the content part.
  493. * The request for a reference to the part is only fullfilled/processed
  494. * if the serviceType is set in the @p args . (otherwise the request cannot be
  495. * processed synchroniously.
  496. */
  497. void createNewWindow( const KURL &url, const KParts::URLArgs &args,
  498. const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
  499. /**
  500. * Since the part emits the jobid in the started() signal,
  501. * progress information is automatically displayed.
  502. *
  503. * However, if you don't use a TDEIO::Job in the part,
  504. * you can use loadingProgress() and speedProgress()
  505. * to display progress information.
  506. */
  507. void loadingProgress( int percent );
  508. /**
  509. * @see loadingProgress
  510. */
  511. void speedProgress( int bytesPerSecond );
  512. void infoMessage( const TQString & );
  513. /**
  514. * Emit this to make the browser show a standard popup menu
  515. * at the point @p global for the files @p items.
  516. */
  517. void popupMenu( const TQPoint &global, const KFileItemList &items );
  518. /**
  519. * Emit this to make the browser show a standard popup menu
  520. * at the point @p global for the files @p items.
  521. *
  522. * The GUI described by @p client is being merged with the popupmenu of the host
  523. */
  524. void popupMenu( KXMLGUIClient *client, const TQPoint &global, const KFileItemList &items );
  525. void popupMenu( KXMLGUIClient *client, const TQPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i );
  526. /**
  527. * Emit this to make the browser show a standard popup menu
  528. * at the point @p global for the given @p url.
  529. *
  530. * Give as much information
  531. * about this URL as possible, like the @p mimeType and the file type
  532. * (@p mode: S_IFREG, S_IFDIR...)
  533. */
  534. void popupMenu( const TQPoint &global, const KURL &url,
  535. const TQString &mimeType, mode_t mode = (mode_t)-1 );
  536. /**
  537. * Emit this to make the browser show a standard popup menu
  538. * at the point @p global for the given @p url.
  539. *
  540. * Give as much information
  541. * about this URL as possible, like the @p mimeType and the file type
  542. * (@p mode: S_IFREG, S_IFDIR...)
  543. * The GUI described by @p client is being merged with the popupmenu of the host
  544. */
  545. void popupMenu( KXMLGUIClient *client,
  546. const TQPoint &global, const KURL &url,
  547. const TQString &mimeType, mode_t mode = (mode_t)-1 );
  548. /**
  549. * Emit this to make the browser show a standard popup menu
  550. * at the point @p global for the given @p url.
  551. *
  552. * Give as much information
  553. * about this URL as possible, like @p args.mimeType and the file type
  554. * (@p mode: S_IFREG, S_IFDIR...)
  555. * The GUI described by @p client is being merged with the popupmenu of the host
  556. */
  557. void popupMenu( KXMLGUIClient *client,
  558. const TQPoint &global, const KURL &url,
  559. const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 );
  560. /**
  561. * Inform the hosting application about the current selection.
  562. * Used when a set of files/URLs is selected (with full information
  563. * about those URLs, including size, permissions etc.)
  564. */
  565. void selectionInfo( const KFileItemList &items );
  566. /**
  567. * Inform the hosting application about the current selection.
  568. * Used when some text is selected.
  569. */
  570. void selectionInfo( const TQString &text );
  571. /**
  572. * Inform the hosting application about the current selection.
  573. * Used when a set of URLs is selected.
  574. */
  575. void selectionInfo( const KURL::List &urls );
  576. /**
  577. * Inform the hosting application that the user moved the mouse over an item.
  578. * Used when the mouse is on an URL.
  579. */
  580. void mouseOverInfo( const KFileItem* item );
  581. /**
  582. * Ask the hosting application to add a new HTML (aka Mozilla/Netscape)
  583. * SideBar entry.
  584. */
  585. void addWebSideBar(const KURL &url, const TQString& name);
  586. /**
  587. * Ask the hosting application to move the top level widget.
  588. */
  589. void moveTopLevelWidget( int x, int y );
  590. /**
  591. * Ask the hosting application to resize the top level widget.
  592. */
  593. void resizeTopLevelWidget( int w, int h );
  594. /**
  595. * Ask the hosting application to focus @p part.
  596. * @since 3.4
  597. */
  598. void requestFocus(KParts::ReadOnlyPart *part);
  599. /**
  600. * Tell the host (browser) about security state of current page
  601. * enum PageSecurity { NotCrypted, Encrypted, Mixed };
  602. * @since 3.4
  603. */
  604. void setPageSecurity( int );
  605. #define TDEPARTS_BROWSEREXTENSION_HAS_ITEMS_REMOVED
  606. /**
  607. * Inform the host about items that have been removed.
  608. * @since 3.5.5
  609. */
  610. void itemsRemoved( const KFileItemList &items );
  611. private slots:
  612. void slotCompleted();
  613. void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
  614. void slotEmitOpenURLRequestDelayed();
  615. void slotEnableAction( const char *, bool );
  616. void slotSetActionText( const char*, const TQString& );
  617. private:
  618. KParts::ReadOnlyPart *m_part;
  619. URLArgs m_args;
  620. public:
  621. typedef TQMap<TQCString,int> ActionNumberMap;
  622. private:
  623. static ActionNumberMap * s_actionNumberMap;
  624. static ActionSlotMap * s_actionSlotMap;
  625. static void createActionSlotMap();
  626. protected:
  627. virtual void virtual_hook( int id, void* data );
  628. private:
  629. BrowserExtensionPrivate *d;
  630. };
  631. /**
  632. * An extension class for container parts, i.e. parts that contain
  633. * other parts.
  634. * For instance a TDEHTMLPart hosts one part per frame.
  635. */
  636. class TDEPARTS_EXPORT BrowserHostExtension : public TQObject
  637. {
  638. Q_OBJECT
  639. public:
  640. BrowserHostExtension( KParts::ReadOnlyPart *parent,
  641. const char *name = 0L );
  642. virtual ~BrowserHostExtension();
  643. /**
  644. * Returns a list of the names of all hosted child objects.
  645. *
  646. * Note that this method does not query the child objects recursively.
  647. */
  648. virtual TQStringList frameNames() const;
  649. /**
  650. * Returns a list of pointers to all hosted child objects.
  651. *
  652. * Note that this method does not query the child objects recursively.
  653. */
  654. virtual const TQPtrList<KParts::ReadOnlyPart> frames() const;
  655. /**
  656. * Returns the part that contains @p frame and that may be accessed
  657. * by @p callingPart
  658. * @since 3.3
  659. */
  660. BrowserHostExtension *findFrameParent(KParts::ReadOnlyPart *callingPart, const TQString &frame);
  661. /**
  662. * Opens the given url in a hosted child frame. The frame name is specified in the
  663. * frameName variable in the urlArgs argument structure (see KParts::URLArgs ) .
  664. */
  665. virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
  666. /**
  667. * Queries @p obj for a child object which inherits from this
  668. * BrowserHostExtension class. Convenience method.
  669. */
  670. static BrowserHostExtension *childObject( TQObject *obj );
  671. protected:
  672. /** This 'enum' along with the structure below is NOT part of the public API.
  673. * It's going to disappear in KDE 4.0 and is likely to change inbetween.
  674. *
  675. * @internal
  676. */
  677. enum { VIRTUAL_FIND_FRAME_PARENT = 0x10 };
  678. struct FindFrameParentParams
  679. {
  680. BrowserHostExtension *parent;
  681. KParts::ReadOnlyPart *callingPart;
  682. TQString frame;
  683. };
  684. virtual void virtual_hook( int id, void* data );
  685. private:
  686. class BrowserHostExtensionPrivate;
  687. BrowserHostExtensionPrivate *d;
  688. };
  689. /**
  690. * An extension class for LiveConnect, i.e\. a call from JavaScript
  691. * from a HTML page which embeds this part.
  692. * A part can have an object hierarchie by using objid as a reference
  693. * to an object.
  694. */
  695. class TDEPARTS_EXPORT LiveConnectExtension : public TQObject
  696. {
  697. Q_OBJECT
  698. public:
  699. enum Type {
  700. TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
  701. };
  702. typedef TQValueList<QPair<Type, TQString> > ArgList;
  703. LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
  704. virtual ~LiveConnectExtension() {}
  705. /**
  706. * get a field value from objid, return true on success
  707. */
  708. virtual bool get( const unsigned long objid, const TQString & field, Type & type, unsigned long & retobjid, TQString & value );
  709. /**
  710. * put a field value in objid, return true on success
  711. */
  712. virtual bool put( const unsigned long objid, const TQString & field, const TQString & value );
  713. /**
  714. * calls a function of objid, return true on success
  715. */
  716. virtual bool call( const unsigned long objid, const TQString & func, const TQStringList & args, Type & type, unsigned long & retobjid, TQString & value );
  717. /**
  718. * notifies the part that there is no reference anymore to objid
  719. */
  720. virtual void unregister( const unsigned long objid );
  721. static LiveConnectExtension *childObject( TQObject *obj );
  722. signals:
  723. /**
  724. * notify an event from the part of object objid
  725. */
  726. virtual void partEvent( const unsigned long objid, const TQString & event, const ArgList & args );
  727. };
  728. }
  729. #endif