//
//     Copyright 2006 Jim Bublitz <jbublitz@nwinternet.com>
//     Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson
//     may also apply


//                 Generated by preSip
//            module kparts  version KDE 3.5.3


// This software is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; see the file COPYING.
// If not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

namespace KParts
{

class URLArgs
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:
                         URLArgs ();
                         URLArgs (const KParts::URLArgs&);
                         URLArgs (bool, int, int, const QString& = QString ::null );
    QStringList          docState;
    bool                 reload;
    int                  xOffset;
    int                  yOffset;
    QString              serviceType;
    QByteArray           postData;
    void                 setContentType (const QString&);
    QString              contentType () const;
    void                 setDoPost (bool);
    bool                 doPost () const;
    void                 setLockHistory (bool);
    bool                 lockHistory () const;

%If ( KDE_3_1_0 -  )
    void                 setNewTab (bool);
    bool                 newTab () const;
%End

    QMap<QString,QString>& metaData ();
    QString              frameName;
    bool                 trustedSource;

%If ( KDE_3_1_3 -  )
    bool                 redirectedRequest () const;
    void                 setRedirectedRequest (bool);

%If ( KDE_3_4_0 -  )
    void                 setForcesNewWindow (bool);
    bool                 forcesNewWindow () const;
%End

%End

//ig     URLArgsPrivate*      d;

};  // class URLArgs


class WindowArgs
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:
                         WindowArgs ();
                         WindowArgs (const KParts::WindowArgs&);
                         WindowArgs (const QRect&, bool, bool, bool, bool, bool);
                         WindowArgs (int, int, int, int, bool, bool, bool, bool, bool);
    int                  x;
    int                  y;
    int                  width;
    int                  height;
    bool                 fullscreen;
    bool                 menuBarVisible;
    bool                 toolBarsVisible;
    bool                 statusBarVisible;
    bool                 resizable;
    bool                 lowerWindow;

%If ( KDE_3_5_0 -  )
    bool                 scrollBarsVisible;
%End

//ig     WindowArgsPrivate*   d;

};  // class WindowArgs


class OpenURLEvent : KParts::Event
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:
                         OpenURLEvent (KParts::ReadOnlyPart*, const KURL&, const KParts::URLArgs& = KParts ::URLArgs ());
    KParts::ReadOnlyPart* part () const;
    KURL                 url () const;
    KParts::URLArgs      args () const;
    static bool          test (const QEvent*);

};  // class OpenURLEvent


class BrowserExtension : QObject
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:
                         BrowserExtension (KParts::ReadOnlyPart* /TransferThis/, const char* = 0);

%If ( KDE_3_2_0 -  )
    typedef uint PopupFlags;

%If ( KDE_3_4_0 -  )

    enum 
    {
        DefaultPopupItems, 
        ShowNavigationItems, 
        ShowUp, 
        ShowReload, 
        ShowBookmark, 
        ShowCreateDirectory, 
        ShowTextSelectionItems, 
        NoDeletion
    };

%End

%End

    virtual void         setURLArgs (const KParts::URLArgs&);
    KParts::URLArgs      urlArgs () const;
    virtual int          xOffset ();
    virtual int          yOffset ();
    virtual void         saveState (QDataStream&);
    virtual void         restoreState (QDataStream&);
    bool                 isURLDropHandlingEnabled () const;
    void                 setURLDropHandlingEnabled (bool);
    void                 setBrowserInterface (KParts::BrowserInterface*);
    KParts::BrowserInterface* browserInterface () const;
    bool                 isActionEnabled (const char*) const;

%If ( KDE_3_5_0 -  )
    QString              actionText (const char*) const;
%End

    typedef QMap<QCString,QCString> ActionSlotMap;
    static KParts::BrowserExtension::ActionSlotMap actionSlotMap ();
    static KParts::BrowserExtension::ActionSlotMap* actionSlotMapPtr ();
    static KParts::BrowserExtension* childObject (QObject*);

%If ( KDE_3_2_0 -  )
    void                 pasteRequest ();
%End


signals:
    void                 enableAction (const char*, bool);

%If ( KDE_3_5_0 -  )
    void                 setActionText (const char*, const QString&);
%End

    void                 openURLRequest (const KURL&, const KParts::URLArgs& = KParts ::URLArgs ());
    void                 openURLRequestDelayed (const KURL&, const KParts::URLArgs& = KParts ::URLArgs ());
    void                 openURLNotify ();
    void                 setLocationBarURL (const QString&);
    void                 setIconURL (const KURL&);
    void                 createNewWindow (const KURL&, const KParts::URLArgs& = KParts ::URLArgs ());
//ig     void                 createNewWindow (const KURL&, const KParts::URLArgs&, const KParts::WindowArgs&, KParts::ReadOnlyPart*&);
    void                 loadingProgress (int);
    void                 speedProgress (int);
    void                 infoMessage (const QString&);
    void                 popupMenu (const QPoint&, const KFileItemList&);
    void                 popupMenu (KXMLGUIClient*, const QPoint&, const KFileItemList&);

%If ( KDE_3_2_0 -  )
    void                 popupMenu (KXMLGUIClient*, const QPoint&, const KFileItemList&, const KParts::URLArgs&, KParts::BrowserExtension::PopupFlags);
%End

    void                 popupMenu (const QPoint&, const KURL&, const QString&, mode_t = -1);
    void                 popupMenu (KXMLGUIClient*, const QPoint&, const KURL&, const QString&, mode_t = -1);

%If ( KDE_3_2_0 -  )
    void                 popupMenu (KXMLGUIClient*, const QPoint&, const KURL&, const KParts::URLArgs&, KParts::BrowserExtension::PopupFlags, mode_t = -1);
%End

    void                 selectionInfo (const KFileItemList&);
    void                 selectionInfo (const QString&);
    void                 selectionInfo (const KURL::List&);

%If ( KDE_3_1_0 -  )
    void                 mouseOverInfo (const KFileItem*);

%If ( KDE_3_2_0 -  )
    void                 addWebSideBar (const KURL&, const QString&);
    void                 moveTopLevelWidget (int, int);
    void                 resizeTopLevelWidget (int, int);

%If ( KDE_3_3_1 -  )
    void                 requestFocus (KParts::ReadOnlyPart*);

%If ( KDE_3_4_0 -  )
    void                 setPageSecurity (int);
%End

%End

%End

%End


public:
    typedef QMap<QCString,int> ActionNumberMap;

protected:
//igx     virtual void         virtual_hook (int, void*);

public:

%If ( KDE_3_3_0 - KDE_3_4_0 )

    enum 
    {
        DefaultPopupItems, 
        ShowNavigationItems, 
        ShowUp, 
        ShowReload, 
        ShowBookmark, 
        ShowCreateDirectory, 
        ShowTextSelectionItems
    };

%End


public:

%If ( KDE_3_2_0 - KDE_3_3_0 )

    enum 
    {
        DefaultPopupItems, 
        ShowNavigationItems, 
        ShowUp, 
        ShowReload, 
        ShowBookmark, 
        ShowCreateDirectory
    };

%End


};  // class BrowserExtension


class BrowserHostExtension : QObject
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:
                         BrowserHostExtension (KParts::ReadOnlyPart* /TransferThis/, const char* = 0);
    virtual QStringList  frameNames () const;
    virtual const QPtrList<KParts::ReadOnlyPart> frames () const;

%If ( KDE_3_3_0 -  )
    KParts::BrowserHostExtension* findFrameParent (KParts::ReadOnlyPart*, const QString&);
%End

    virtual bool         openURLInFrame (const KURL&, const KParts::URLArgs&);
    static KParts::BrowserHostExtension* childObject (QObject*);

protected:
//igx     virtual void         virtual_hook (int, void*);

};  // class BrowserHostExtension


%If ( KDE_3_1_0 -  )

class LiveConnectExtension : QObject
{
%TypeHeaderCode
#include <browserextension.h>
%End


public:

    enum Type
    {
        TypeVoid, 
        TypeBool, 
        TypeFunction, 
        TypeNumber, 
        TypeObject, 
        TypeString
    };

//ig     typedef QValueList<QPair<Type,QString>> ArgList;
                         LiveConnectExtension (KParts::ReadOnlyPart* /TransferThis/, const char* = 0);
    virtual bool         get (const ulong, const QString&, KParts::LiveConnectExtension::Type&, ulong&, QString&);
    virtual bool         put (const ulong, const QString&, const QString&);
    virtual bool         call (const ulong, const QString&, const QStringList&, KParts::LiveConnectExtension::Type&, ulong&, QString&);
    virtual void         unregister (const ulong);
    static KParts::LiveConnectExtension* childObject (QObject*);

signals:
//ig     virtual void         partEvent (const ulong, const QString&, const KParts::LiveConnectExtension::ArgList&);

};  // class LiveConnectExtension

%End

};  // namespace KParts


%If (  - KDE_3_5_3 )
//ig typedef QPtrList<KFileItem> KFileItemList;
%End

//force
QMap<QCString,int>   testQMapQCStringInt (QMap<QCString,int>);
%MethodCode
//takes dict | (QMap<QCString,int>)
//returns (QMap<QCString,int>)

    sipRes = a0;
%End

//end


%MappedType QMap<QCString,QCString>
//converts a Python dict of QCString:QCString
{
%TypeHeaderCode
#include <qmap.h>
%End

%ConvertFromTypeCode
    // Convert to a Python dict

    if (!sipCpp)
        return PyDict_New();

    PyObject *dict;

    // Create the dictionary.

    if ((dict = PyDict_New()) == NULL)
        return NULL;

    // Get it.

    const QMap<QCString,QCString> cppmap = *sipCpp;
    QMap<QCString,QCString>::ConstIterator it;

    for (it = cppmap.begin (); it != cppmap.end (); ++it)
    {
        QCString acpp = it.key ();
        QCString bcpp = it.data ();
        PyObject *ainst;
        PyObject *binst = NULL;
        if (((ainst = sipConvertFromNewType(new QCString (acpp), sipType_QCString, NULL)) == NULL)
            || ((binst = sipConvertFromNewType(new QCString (bcpp), sipType_QCString, NULL)) == NULL)
            || (PyDict_SetItem (dict, ainst, binst) < 0))
        {
            Py_XDECREF (ainst);
            Py_XDECREF (binst);
            Py_DECREF (dict);
            return NULL;
        }
    }

    return dict;
%End


%ConvertToTypeCode
    // Convert a Python dictionary to a QMap on the heap.

    if (sipIsErr == NULL)
        return PyDict_Check(sipPy);

    QMap<QCString,QCString> *cppmap = new QMap<QCString,QCString>;

    PyObject *aelem, *belem;
    SIP_SSIZE_T pos = 0;
    QCString *acpp;
    QCString *bcpp;

    while (PyDict_Next(sipPy, &pos, &aelem, &belem))
    {
        int iserr = 0;

        acpp = (QCString *)sipForceConvertToType(aelem, sipType_QCString, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);
        bcpp = (QCString *)sipForceConvertToType(belem, sipType_QCString, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);

        if (iserr)
        {
            *sipIsErr = 1;
            delete cppmap;
            return 0;
        }

        cppmap->insert (*acpp, *bcpp);
    }

    *sipCppPtr = cppmap;

    return 1;
%End
};


%MappedType QMap<QCString,int>
//converts a Python dict of QCString:int
{
%TypeHeaderCode
#include <qmap.h>
%End

%ConvertFromTypeCode
    // Convert to a Python dict

    if (!sipCpp)
        return PyDict_New();

    PyObject *dict;

    // Create the dictionary.

    if ((dict = PyDict_New()) == NULL)
        return NULL;

    // Get it.

    const QMap<QCString,int> cppmap = *sipCpp;
    QMap<QCString,int>::ConstIterator it;

    for (it = cppmap.begin (); it != cppmap.end (); ++it)
    {
        QCString acpp = it.key ();
        int bcpp = it.data ();
        PyObject *ainst;
        PyObject *binst = NULL;
        if (((ainst = sipConvertFromNewType(new QCString (acpp), sipType_QCString, NULL)) == NULL)
            || ((binst = PyInt_FromLong (bcpp)) < 0)
            || (PyDict_SetItem (dict, ainst, binst) < 0))
        {
            Py_XDECREF (ainst);
            Py_XDECREF (binst);
            Py_DECREF (dict);
            return NULL;
        }
    }

    return dict;
%End


%ConvertToTypeCode
    // Convert a Python dictionary to a QMap on the heap.

    if (sipIsErr == NULL)
        return PyDict_Check(sipPy);

    QMap<QCString,int> *cppmap = new QMap<QCString,int>;

    PyObject *aelem, *belem;
    SIP_SSIZE_T pos = 0;
    QCString *acpp;
    int bcpp;

    while (PyDict_Next(sipPy, &pos, &aelem, &belem))
    {
        int iserr = 0;

        acpp = (QCString *)sipForceConvertToType(aelem, sipType_QCString, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);

        if (iserr || !PyInt_Check (belem))
        {
            *sipIsErr = 1;
            delete cppmap;
            return 0;
        }

        bcpp = PyInt_AS_LONG (belem);

        cppmap->insert (*acpp, bcpp);
    }

    *sipCppPtr = cppmap;

    return 1;
%End
};


%MappedType QPtrList<KParts::ReadOnlyPart>
//converts a Python list of KParts.ReadOnlyPart
{
%TypeHeaderCode
#include <qptrlist.h>
%End

%ConvertFromTypeCode
    if (!sipCpp)
        return PyList_New (0);

    PyObject *pylist;

    // Create the list

    if ((pylist = PyList_New(0)) == NULL)
        return NULL;

    // Get it.

    QPtrList<KParts::ReadOnlyPart> *cpplist = (QPtrList<KParts::ReadOnlyPart> *)sipCpp;
    KParts::ReadOnlyPart *cpp;
    PyObject *inst;

    // the loop depends on the type of iterator the  tmeplate makes available
    for(cpp = cpplist->first (); cpp != 0; cpp = cpplist->next () )
    {
        if (((inst = sipConvertFromInstance (cpp, sipClass_KParts_ReadOnlyPart, sipTransferObj)) == NULL)
            || PyList_Append (pylist, inst) < 0)
        {
            Py_DECREF (pylist);
            return NULL;
        }
    }

    return pylist;
%End

%ConvertToTypeCode
    if (sipIsErr == NULL)
        return PyList_Check(sipPy);

    QPtrList<KParts::ReadOnlyPart> *cpplist = new QPtrList<KParts::ReadOnlyPart>;

    PyObject *elem;
    KParts::ReadOnlyPart *cpp;
    int iserr = 0;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        cpp = (KParts::ReadOnlyPart *)sipForceConvertToType(elem, sipType_KParts_ReadOnlyPart, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);

        if (iserr)
        {
            *sipIsErr = 1;
            delete cpplist;
            return 0;
        }

        cpplist->append (cpp);
    }

    *sipCppPtr = cpplist;

    return 1;
%End
};


