Gnash  0.8.10
klash_part.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 // Written by Koos Vriezen <koos ! vriezen ? xs4all ! nl>
00020 
00021 #ifndef KLASH_PART_H
00022 #define KLASH_PART_H
00023 
00024 #include <qxembed.h>
00025 #include <kprocess.h>
00026 #include <kparts/browserextension.h>
00027 
00028 #if __GNUC__ - 0 > 3
00029 #define KLASH_NO_EXPORT __attribute__ ((visibility("hidden")))
00030 #else
00031 #define KLASH_NO_EXPORT
00032 #endif
00033 #define KDE_NO_CDTOR_EXPORT KLASH_NO_EXPORT
00034 #ifndef KDE_NO_EXPORT
00035 #define KDE_NO_EXPORT KLASH_NO_EXPORT
00036 #endif
00037 
00038 class KAboutData;
00039 class KlashPart;
00040 class KInstance;
00041 class KProcess;
00042 class JSCommandEntry;
00043 class KlashView;
00044 
00045 /*
00046  * Part notifications to hosting application
00047  */
00048 class KLASH_NO_EXPORT KlashBrowserExtension : public KParts::BrowserExtension {
00049     Q_OBJECT
00050 public:
00051     KlashBrowserExtension(KlashPart *parent);
00052     KDE_NO_CDTOR_EXPORT ~KlashBrowserExtension () {}
00053     void urlChanged (const QString & url);
00054     void setLoadingProgress (int percentage);
00055 
00056     void saveState (QDataStream & stream);
00057     void restoreState (QDataStream & stream);
00058     void requestOpenURL (const KURL & url, const QString & target, const QString & service);
00059 };
00060 
00061 /*
00062  * Part javascript support
00063  */
00064 class KLASH_NO_EXPORT KlashLiveConnectExtension : public KParts::LiveConnectExtension {
00065     Q_OBJECT
00066 public:
00067     KlashLiveConnectExtension (KlashPart * parent);
00068     ~KlashLiveConnectExtension ();
00069 
00070     // LiveConnect interface
00071     bool get (const unsigned long, const QString &,
00072             KParts::LiveConnectExtension::Type &, unsigned long &, QString &);
00073     bool put (const unsigned long, const QString &, const QString &);
00074     bool call (const unsigned long, const QString &,
00075             const QStringList &, KParts::LiveConnectExtension::Type &, 
00076             unsigned long &, QString &);
00077     void unregister (const unsigned long);
00078     void sendEvent(const unsigned long objid, const QString & event, const KParts::LiveConnectExtension::ArgList & args ) {
00079         emit partEvent(objid, event, args);
00080     }
00081 
00082     void enableFinishEvent (bool b = true) { m_enablefinish = b; }
00083 signals:
00084     void partEvent (const unsigned long, const QString &,
00085                     const KParts::LiveConnectExtension::ArgList &);
00086 public slots:
00087     void setSize (int w, int h);
00088     void started ();
00089     void finished ();
00090 private:
00091     KlashPart * player;
00092     const JSCommandEntry * lastJSCommandEntry;
00093     bool m_started : 1;
00094     bool m_enablefinish : 1;
00095 };
00096 
00097 class KLASH_NO_EXPORT KlashEmbed : public QXEmbed {
00098     KlashView * m_view;
00099 public:
00100     KlashEmbed (KlashView * parent);
00101     ~KlashEmbed ();
00102 };
00103 
00104 class KLASH_NO_EXPORT KlashView : public QWidget {
00105     KlashEmbed * m_embed;
00106 public:
00107     KlashView (QWidget * parent);
00108     ~KlashView ();
00109     WId embedId ();
00110 protected:
00111     void resizeEvent (QResizeEvent *);
00112 };
00113 
00114 /*
00115  * Part that gets created when used a KPart
00116  */
00117 class KLASH_NO_EXPORT KlashPart : public KParts::ReadOnlyPart {
00118     Q_OBJECT
00119     friend struct GroupPredicate;
00120 public:
00121     KlashPart (QWidget * wparent, const char * wname,
00122               QObject * parent, const char * name, const QStringList &args);
00123     ~KlashPart ();
00124 
00125     KDE_NO_EXPORT KlashBrowserExtension * browserextension() const
00126         { return m_browserextension; }
00127     KlashLiveConnectExtension * liveconnectextension () const
00128         { return m_liveconnectextension; }
00129     bool allowRedir (const KURL & url) const;
00130     void fullScreen ();
00131     void setLoaded (int percentage);
00132     const QString & source () const { return m_src_url; }
00133 public slots:
00134     virtual bool openURL (const KURL & url);
00135     virtual bool closeURL ();
00136     void play ();
00137     void stop ();
00138     void pause ();
00139     int width () const {return m_width; }
00140     int height () const {return m_height; }
00141 protected slots:
00142     void playingStarted ();
00143     void playingStopped ();
00144     void processStopped (KProcess *);
00145 protected:
00146     virtual bool openFile();
00147 private:
00148     QStringList m_args;
00149     KlashBrowserExtension * m_browserextension;
00150     KlashLiveConnectExtension * m_liveconnectextension;
00151     KProcess * m_process;
00152     KURL m_docbase;
00153     QString m_src_url;
00154     QString m_file_name;
00155     int m_width;
00156     int m_height;
00157     //bool m_noresize : 1;
00158     bool m_autostart : 1;
00159     bool m_fullscreen : 1;
00160     bool m_started_emited : 1;
00161 };
00162 
00163 
00164 #endif