00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __kparts_browserextension_h__
00022 #define __kparts_browserextension_h__
00023
00024 #include <sys/types.h>
00025
00026 #include <qpoint.h>
00027 #include <qptrlist.h>
00028 #include <qdatastream.h>
00029 #include <qstringlist.h>
00030 #include <qpair.h>
00031
00032 #include <kparts/part.h>
00033 #include <kparts/event.h>
00034
00035 class KFileItem;
00036 typedef QPtrList<KFileItem> KFileItemList;
00037 class QString;
00038
00039 namespace KParts {
00040
00041 class BrowserInterface;
00042
00043 struct URLArgsPrivate;
00044
00057 struct URLArgs
00058 {
00059 URLArgs();
00060 URLArgs( const URLArgs &args );
00061 URLArgs &operator=( const URLArgs &args);
00062
00063 URLArgs( bool reload, int xOffset, int yOffset, const QString &serviceType = QString::null );
00064 virtual ~URLArgs();
00065
00070 QStringList docState;
00071
00075 bool reload;
00081 int xOffset;
00085 int yOffset;
00089 QString serviceType;
00090
00094 QByteArray postData;
00095
00099 void setContentType( const QString & contentType );
00103 QString contentType() const;
00108 void setDoPost( bool enable );
00109
00114 bool doPost() const;
00115
00121 void setLockHistory( bool lock );
00122 bool lockHistory() const;
00123
00127 void setNewTab( bool newTab );
00128 bool newTab() const;
00129
00134 QMap<QString, QString> &metaData();
00135
00139 QString frameName;
00140
00146 bool trustedSource;
00147
00152 bool redirectedRequest () const;
00153
00160 void setRedirectedRequest(bool redirected);
00161
00162 URLArgsPrivate *d;
00163 };
00164
00165 struct WindowArgsPrivate;
00166
00172 struct WindowArgs
00173 {
00174 WindowArgs();
00175 WindowArgs( const WindowArgs &args );
00176 WindowArgs &operator=( const WindowArgs &args );
00177 WindowArgs( const QRect &_geometry, bool _fullscreen, bool _menuBarVisible,
00178 bool _toolBarsVisible, bool _statusBarVisible, bool _resizable );
00179 WindowArgs( int _x, int _y, int _width, int _height, bool _fullscreen,
00180 bool _menuBarVisible, bool _toolBarsVisible,
00181 bool _statusBarVisible, bool _resizable );
00182
00183
00184 int x;
00185 int y;
00186
00187 int width;
00188 int height;
00189 bool fullscreen;
00190 bool menuBarVisible;
00191 bool toolBarsVisible;
00192 bool statusBarVisible;
00193 bool resizable;
00194
00195 bool lowerWindow;
00196
00197 WindowArgsPrivate *d;
00198 };
00199
00200 class OpenURLEvent : public Event
00201 {
00202 public:
00203 OpenURLEvent( ReadOnlyPart *part, const KURL &url, const URLArgs &args = URLArgs() );
00204 virtual ~OpenURLEvent();
00205
00206 ReadOnlyPart *part() const { return m_part; }
00207 KURL url() const { return m_url; }
00208 URLArgs args() const { return m_args; }
00209
00210 static bool test( const QEvent *event ) { return Event::test( event, s_strOpenURLEvent ); }
00211
00212 private:
00213 static const char *s_strOpenURLEvent;
00214 ReadOnlyPart *m_part;
00215 KURL m_url;
00216 URLArgs m_args;
00217
00218 class OpenURLEventPrivate;
00219 OpenURLEventPrivate *d;
00220 };
00221
00222 class BrowserExtensionPrivate;
00223
00285 class BrowserExtension : public QObject
00286 {
00287 Q_OBJECT
00288 Q_PROPERTY( bool urlDropHandling READ isURLDropHandlingEnabled WRITE setURLDropHandlingEnabled )
00289 public:
00296 BrowserExtension( KParts::ReadOnlyPart *parent,
00297 const char *name = 0L );
00298
00299
00300 virtual ~BrowserExtension();
00301
00302 typedef uint PopupFlags;
00303
00314 enum { DefaultPopupItems=0x0000, ShowNavigationItems=0x0001,
00315 ShowUp=0x0002, ShowReload=0x0004, ShowBookmark=0x0008,
00316 ShowCreateDirectory=0x0010 };
00317
00318
00324 virtual void setURLArgs( const URLArgs &args );
00325
00331 URLArgs urlArgs() const;
00332
00338 virtual int xOffset();
00344 virtual int yOffset();
00345
00353 virtual void saveState( QDataStream &stream );
00354
00362 virtual void restoreState( QDataStream &stream );
00363
00369 bool isURLDropHandlingEnabled() const;
00370
00381 void setURLDropHandlingEnabled( bool enable );
00382
00383 void setBrowserInterface( BrowserInterface *impl );
00384 BrowserInterface *browserInterface() const;
00385
00392 bool isActionEnabled( const char * name ) const;
00393
00394 typedef QMap<QCString,QCString> ActionSlotMap;
00423 static ActionSlotMap actionSlotMap();
00424
00429 static ActionSlotMap * actionSlotMapPtr();
00430
00435 static BrowserExtension *childObject( QObject *obj );
00436
00441 void pasteRequest();
00442
00443 #undef signals
00444 #define signals public
00445 signals:
00446 #undef signals
00447 #define signals protected
00448
00453 void enableAction( const char * name, bool enabled );
00454
00461 void openURLRequest( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00462
00469 void openURLRequestDelayed( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00470
00486 void openURLNotify();
00487
00491 void setLocationBarURL( const QString &url );
00492
00496 void setIconURL( const KURL &url );
00497
00505 void createNewWindow( const KURL &url, const KParts::URLArgs &args = KParts::URLArgs() );
00506
00514 void createNewWindow( const KURL &url, const KParts::URLArgs &args,
00515 const KParts::WindowArgs &windowArgs, KParts::ReadOnlyPart *&part );
00516
00525 void loadingProgress( int percent );
00529 void speedProgress( int bytesPerSecond );
00530
00531 void infoMessage( const QString & );
00532
00537 void popupMenu( const QPoint &global, const KFileItemList &items );
00538
00545 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items );
00546
00547 void popupMenu( KXMLGUIClient *client, const QPoint &global, const KFileItemList &items, const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i );
00548
00557 void popupMenu( const QPoint &global, const KURL &url,
00558 const QString &mimeType, mode_t mode = (mode_t)-1 );
00559
00569 void popupMenu( KXMLGUIClient *client,
00570 const QPoint &global, const KURL &url,
00571 const QString &mimeType, mode_t mode = (mode_t)-1 );
00572
00582 void popupMenu( KXMLGUIClient *client,
00583 const QPoint &global, const KURL &url,
00584 const KParts::URLArgs &args, KParts::BrowserExtension::PopupFlags i, mode_t mode = (mode_t)-1 );
00585
00591 void selectionInfo( const KFileItemList &items );
00596 void selectionInfo( const QString &text );
00601 void selectionInfo( const KURL::List &urls );
00602
00607 void mouseOverInfo( const KFileItem* item );
00608
00613 void addWebSideBar(const KURL &url, const QString& name);
00614
00618 void moveTopLevelWidget( int x, int y );
00619
00623 void resizeTopLevelWidget( int w, int h );
00624
00625
00626 private slots:
00627 void slotCompleted();
00628 void slotOpenURLRequest( const KURL &url, const KParts::URLArgs &args );
00629 void slotEmitOpenURLRequestDelayed();
00630 void slotEnableAction( const char *, bool );
00631
00632 private:
00633 KParts::ReadOnlyPart *m_part;
00634 URLArgs m_args;
00635 public:
00636 typedef QMap<QCString,int> ActionNumberMap;
00637
00638 private:
00639 static ActionNumberMap * s_actionNumberMap;
00640 static ActionSlotMap * s_actionSlotMap;
00641 static void createActionSlotMap();
00642 protected:
00643 virtual void virtual_hook( int id, void* data );
00644 private:
00645 BrowserExtensionPrivate *d;
00646 };
00647
00653 class BrowserHostExtension : public QObject
00654 {
00655 Q_OBJECT
00656 public:
00657 BrowserHostExtension( KParts::ReadOnlyPart *parent,
00658 const char *name = 0L );
00659
00660 virtual ~BrowserHostExtension();
00661
00667 virtual QStringList frameNames() const;
00668
00675 virtual const QPtrList<KParts::ReadOnlyPart> frames() const;
00676
00681 virtual bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs );
00682
00687 static BrowserHostExtension *childObject( QObject *obj );
00688
00689 protected:
00690 virtual void virtual_hook( int id, void* data );
00691 private:
00692 class BrowserHostExtensionPrivate;
00693 BrowserHostExtensionPrivate *d;
00694 };
00695
00702 class LiveConnectExtension : public QObject
00703 {
00704 Q_OBJECT
00705 public:
00706 enum Type {
00707 TypeVoid=0, TypeBool, TypeFunction, TypeNumber, TypeObject, TypeString
00708 };
00709 typedef QValueList<QPair<Type, QString> > ArgList;
00710
00711 LiveConnectExtension( KParts::ReadOnlyPart *parent, const char *name = 0L );
00712
00713 virtual ~LiveConnectExtension() {}
00717 virtual bool get( const unsigned long objid, const QString & field, Type & type, unsigned long & retobjid, QString & value );
00721 virtual bool put( const unsigned long objid, const QString & field, const QString & value );
00725 virtual bool call( const unsigned long objid, const QString & func, const QStringList & args, Type & type, unsigned long & retobjid, QString & value );
00729 virtual void unregister( const unsigned long objid );
00730
00731 static LiveConnectExtension *childObject( QObject *obj );
00732 signals:
00736 virtual void partEvent( const unsigned long objid, const QString & event, const ArgList & args );
00737 };
00738
00739 }
00740
00741 #endif
00742