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


//                 Generated by preSip
//            module kio  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.


class KMimeType : KServiceType
{
%TypeHeaderCode
#include <kmimetype.h>
%End


public:

    typedef KSharedPtr<KMimeType> Ptr;
    typedef TQValueList<KMimeType::Ptr> List;

public:
                         KMimeType (const TQString&, const TQString&, const TQString&, const TQString&, const TQStringList&);
                         KMimeType (const TQString&);
                         KMimeType (KDesktopFile*);
                         KMimeType (TQDataStream&, int);
    virtual TQString      icon (const TQString&, bool) const;
    virtual TQString      icon (const KURL&, bool) const;
    virtual TQPixmap      pixmap (KIcon::Group, int = 0, int = 0, TQString* = 0) const;
    virtual TQPixmap      pixmap (const KURL&, KIcon::Group, int = 0, int = 0, TQString* = 0) const;
    static TQPixmap       pixmapForURL (const KURL&, mode_t = 0, KIcon::Group = KIcon ::Desktop , int = 0, int = 0, TQString* = 0);
    static TQString       iconForURL (const KURL&, mode_t = 0);
    static TQString       favIconForURL (const KURL&);
    TQString              comment () const;
    virtual TQString      comment (const TQString&, bool) const;
    virtual TQString      comment (const KURL&, bool) const;
    const TQStringList&   patterns () const;
    virtual void         load (TQDataStream&);
    virtual void         save (TQDataStream&);
    virtual TQVariant     property (const TQString&) const;
    virtual TQStringList  propertyNames () const;
    static KMimeType::Ptr mimeType (const TQString&);
    static KMimeType::Ptr findByURL (const KURL&, mode_t = 0, bool = 0, bool = 0);

%If ( KDE_3_2_0 -  )
    static KMimeType::Ptr findByURL (const KURL&, mode_t, bool, bool, bool*);
%End

    static KMimeType::Ptr findByPath (const TQString&, mode_t = 0, bool = 0);
    static KMimeType::Ptr findByContent (const TQByteArray&, int* = 0);
    static KMimeType::Ptr findByFileContent (const TQString&, int* = 0);

%If ( KDE_3_2_1 -  )

    class Format
    {

    public:
        bool                 text;

        enum
        {
            NoCompression,
            GZipCompression
        };

//ig         int                  compression;
        int                  dummy;

    };  // class Format


public:
%End


%If ( KDE_3_2_0 -  )
//ig     static KMimeType::Format findFormatByFileContent (const TQString&);
%End

    static KMimeType::List allMimeTypes ();
    static const TQString& defaultMimeType ();

%If ( KDE_3_2_0 -  )
    static KMimeType::Ptr defaultMimeTypePtr ();
    TQString              parentMimeType () const;
    bool                 is (const TQString&) const /PyName=is_/; //'is' is a reserved keyword in python;
    static KMimeType::Ptr diagnoseFileName (const TQString&, TQString&);
%End


protected:
    void                 loadInternal (TQDataStream&);
    void                 init (KDesktopFile*);
    static void          errorMissingMimeType (const TQString&);
    static void          buildDefaultType ();
    static void          checkEssentialMimeTypes ();

protected:

%If ( KDE_3_2_0 -  )
    int                  patternsAccuracy () const;
%End


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

};  // class KMimeType


class KFolderType : KMimeType
{
%TypeHeaderCode
#include <kmimetype.h>
%End


public:
                         KFolderType (KDesktopFile*);
                         KFolderType (TQDataStream&, int);
    virtual TQString      icon (const TQString&, bool) const;
    virtual TQString      icon (const KURL&, bool) const;
    virtual TQString      comment (const TQString&, bool) const;
    virtual TQString      comment (const KURL&, bool) const;

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

};  // class KFolderType


class KDEDesktopMimeType : KMimeType
{
%TypeHeaderCode
#include <kmimetype.h>
%End


public:

    enum ServiceType
    {
        ST_MOUNT, 
        ST_UNMOUNT, 
        ST_USER_DEFINED
    };


    class Service
    {

    public:
                             Service ();

%If ( KDE_3_2_0 -  )
        bool                 isEmpty () const;
%End

        TQString              m_strName;
        TQString              m_strIcon;
        TQString              m_strExec;
        KDEDesktopMimeType::ServiceType m_type;
        bool                 m_display;

    };  // class Service


public:
                         KDEDesktopMimeType (KDesktopFile*);
                         KDEDesktopMimeType (TQDataStream&, int);
    virtual TQString      icon (const TQString&, bool) const;
    virtual TQString      icon (const KURL&, bool) const;
    virtual TQPixmap      pixmap (const KURL&, KIcon::Group, int = 0, int = 0, TQString* = 0) const;
    virtual TQString      comment (const TQString&, bool) const;
    virtual TQString      comment (const KURL&, bool) const;
    static TQValueList<KDEDesktopMimeType::Service> builtinServices (const KURL&);
    static TQValueList<KDEDesktopMimeType::Service> userDefinedServices (const TQString&, bool);

%If ( KDE_3_4_0 -  )
    static TQValueList<KDEDesktopMimeType::Service> userDefinedServices (const TQString&, KConfig&, bool);

%If ( KDE_3_5_0 -  )
    static TQValueList<KDEDesktopMimeType::Service> userDefinedServices (const TQString&, KConfig&, bool, const KURL::List&);
%End

%End

    static void          executeService (const TQString&, KDEDesktopMimeType::Service&);
    static void          executeService (const KURL::List&, KDEDesktopMimeType::Service&);
    static pid_t         run (const KURL&, bool);

protected:
    virtual TQPixmap      pixmap (KIcon::Group, int, int, TQString*) const;
    static pid_t         runFSDevice (const KURL&, const KSimpleConfig&);
    static pid_t         runApplication (const KURL&, const TQString&);
    static pid_t         runLink (const KURL&, const KSimpleConfig&);
    static pid_t         runMimeType (const KURL&, const KSimpleConfig&);

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

};  // class KDEDesktopMimeType


class KExecMimeType : KMimeType
{
%TypeHeaderCode
#include <kmimetype.h>
%End


public:
                         KExecMimeType (KDesktopFile*);
                         KExecMimeType (TQDataStream&, int);

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

};  // class KExecMimeType



%MappedType KMimeType::Ptr
//converts KMimeType
{
%TypeHeaderCode
#include <ksharedptr.h>
#include <kmimetype.h>
%End

%ConvertFromTypeCode
    // Convert to a Python instance

    if (!sipCpp)
        return NULL;

    KSharedPtr<KMimeType> *cPtr = (KSharedPtr<KMimeType> *)sipCpp;
    KMimeType *cpp = new KMimeType (*cPtr->data ());
    PyObject *obj = sipConvertFromInstance (cpp, sipClass_KMimeType, sipTransferObj);

    return obj;
%End

%ConvertToTypeCode
    // Convert a Python instance to a Ptr on the heap.

    if (sipIsErr == NULL)
        return sipCanConvertToType(sipPy, sipType_KMimeType, SIP_NO_CONVERTORS);

    int iserr = 0;
    KMimeType *cpp = (KMimeType *)sipConvertToType(sipPy, sipType_KMimeType, sipTransferObj, SIP_NO_CONVERTORS, NULL, &iserr);

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

    *sipCppPtr = new KSharedPtr<KMimeType> (cpp);

    return 1;
%End
};


%MappedType TQValueList<KDEDesktopMimeType::Service>
//converts a Python list of KDEDesktopMimeType.Service
{
%TypeHeaderCode
#include <tqvaluelist.h>
#include <kmimetype.h>
%End

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

    // Create the list
    PyObject *pylist;
    if ((pylist = PyList_New(0)) == NULL)
        return NULL;

    TQValueList<KDEDesktopMimeType::Service> *cpplist = (TQValueList<KDEDesktopMimeType::Service> *)sipCpp;
    PyObject *inst;

    // Get it.
    TQValueList<KDEDesktopMimeType::Service>::Iterator it;
    for( it = cpplist->begin(); it != cpplist->end(); ++it )
    {
        if (((inst = sipConvertFromNewType(new KDEDesktopMimeType::Service(*it), sipType_KDEDesktopMimeType_Service, NULL)) == NULL)
            || PyList_Append (pylist, inst) < 0)
        {
            Py_DECREF (pylist);
            return NULL;
        }
    }

    return pylist;
%End


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

    TQValueList<KDEDesktopMimeType::Service> *cpplist = new TQValueList<KDEDesktopMimeType::Service>;

    PyObject *elem;
    KDEDesktopMimeType::Service *cpp;
    int iserr = 0;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        cpp = (KDEDesktopMimeType::Service *)sipForceConvertToType(elem, sipType_KDEDesktopMimeType_Service, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);

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

        cpplist->append (*cpp);
    }

    *sipCppPtr = cpplist;

    return 1;
%End
};


%MappedType TQValueList<KMimeType::Ptr>
//converts a Python list of KMimeType
{
%TypeHeaderCode
#include <kmimetype.h>
%End

%ConvertFromTypeCode
    // Convert to a Python list of Ptr (KMimeType).

    if (!sipCpp)
        return PyList_New (0);

    PyObject *plist;

    // Create the list

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

    // Get it.

    TQValueList<KMimeType::Ptr> *cList = (TQValueList<KMimeType::Ptr> *)sipCpp;
    PyObject *inst;
    KMimeType *svc;

    TQValueList<KMimeType::Ptr>::Iterator it;
    for( it = cList->begin(); it != cList->end(); ++it )
    {
        svc  = new KMimeType (*(KMimeType *)((KMimeType::Ptr)(*it)).data ());
        inst = sipConvertFromNewType(svc, sipType_KMimeType, NULL);
        if ((inst == NULL) || (PyList_Append (plist, inst) < 0))
        {
            Py_XDECREF (inst);
            Py_DECREF (plist);
            return NULL;
        }
    }

    return plist;
%End

%ConvertToTypeCode
    // Convert a Python list to List on the heap.

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

    TQValueList<KMimeType::Ptr> *cList = new TQValueList<KMimeType::Ptr>;
    PyObject *elem;
    KMimeType *service;
    int iserr = 0;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        service = (KMimeType *)sipForceConvertToType(elem, sipType_KMimeType, sipTransferObj, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &iserr);

        KMimeType::Ptr *ptr = new KMimeType::Ptr (service);

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

        cList->append (*ptr);
    }

    *sipCppPtr = cList;

    return 1;
%End
};


