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


//                 Generated by preSip
//            module tdeio  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 KProtocolInfo : KSycocaEntry
{
%TypeHeaderCode
#include <kprotocolinfo.h>
%End


public:
    typedef TDESharedPtr<KProtocolInfo> Ptr;

public:
                         KProtocolInfo (const TQString&);
    virtual bool         isValid () const;
    virtual TQString      name () const;
    static TQStringList   protocols ();
    static bool          isKnownProtocol (const KURL&);
    static bool          isKnownProtocol (const TQString&);
    static TQString       exec (const TQString&)  /PyName=exec_/;

    enum Type
    {
        T_STREAM, 
        T_FILESYSTEM, 
        T_NONE, 
        T_ERROR
    };

    static KProtocolInfo::Type inputType (const KURL&);
    static KProtocolInfo::Type outputType (const KURL&);
    static TQStringList   listing (const KURL&);

%If ( KDE_3_2_0 -  )

    class ExtraField
    {

    public:
                             ExtraField ();
                             ExtraField (const TQString&, const TQString&);
        TQString              name;
        TQString              type;

    };  // class ExtraField


public:
%End


%If ( KDE_3_2_0 -  )
    typedef TQValueList<KProtocolInfo::ExtraField> ExtraFieldList;
    static KProtocolInfo::ExtraFieldList extraFields (const KURL&);
%End

    static bool          isSourceProtocol (const KURL&);
    static bool          isHelperProtocol (const KURL&);
    static bool          isHelperProtocol (const TQString&);
    static bool          isFilterProtocol (const KURL&);
    static bool          isFilterProtocol (const TQString&);
    static bool          supportsListing (const KURL&);
    static bool          supportsReading (const KURL&);
    static bool          supportsWriting (const KURL&);
    static bool          supportsMakeDir (const KURL&);
    static bool          supportsDeleting (const KURL&);
    static bool          supportsLinking (const KURL&);
    static bool          supportsMoving (const KURL&);
    static bool          canCopyFromFile (const KURL&);
    static bool          canCopyToFile (const KURL&);

%If ( KDE_3_4_0 -  )
    static bool          canRenameFromFile (const KURL&);
    static bool          canRenameToFile (const KURL&);
    static bool          canDeleteRecursive (const KURL&);

    enum FileNameUsedForCopying
    {
        Name, 
        FromURL
    };

    static KProtocolInfo::FileNameUsedForCopying fileNameUsedForCopying (const KURL&);
%End

    static TQString       defaultMimetype (const KURL&);
    static TQString       icon (const TQString&);
    static TQString       config (const TQString&);
    static int           maxSlaves (const TQString&);
    static bool          determineMimetypeFromExtension (const TQString&);

%If ( KDE_3_2_0 -  )
    static TQString       docPath (const TQString&);
    static TQString       protocolClass (const TQString&);
    static bool          showFilePreview (const TQString&);
    static KURL::URIMode uriParseMode (const TQString&);

%If ( KDE_3_3_0 -  )
    static TQStringList   capabilities (const TQString&);
    static TQString       proxiedBy (const TQString&);
%End

%End


public:
                         KProtocolInfo (TQDataStream&, int);
    virtual void         load (TQDataStream&);
    virtual void         save (TQDataStream&);
    static Type          inputType (const TQString&);
    static Type          outputType (const TQString&);
    static TQStringList   listing (const TQString&);
    static bool          isSourceProtocol (const TQString&);
    static bool          supportsListing (const TQString&);
    static bool          supportsReading (const TQString&);
    static bool          supportsWriting (const TQString&);
    static bool          supportsMakeDir (const TQString&);
    static bool          supportsDeleting (const TQString&);
    static bool          supportsLinking (const TQString&);
    static bool          supportsMoving (const TQString&);
    static bool          canCopyFromFile (const TQString&);
    static bool          canCopyToFile (const TQString&);
    static TQString       defaultMimetype (const TQString&);

protected:

%If ( KDE_3_5_1 -  )
    bool                 canRenameFromFile () const;
    bool                 canRenameToFile () const;
    bool                 canDeleteRecursive () const;
    KProtocolInfo::FileNameUsedForCopying fileNameUsedForCopying () const;
%End


%If ( KDE_3_4_0 -  )
    static KProtocolInfo* findProtocol (const KURL&);
%End


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

};  // class KProtocolInfo


%If ( KDE_3_2_0 -  )
//igx TQDataStream&         operator >> (TQDataStream&, KProtocolInfo::ExtraField&);
//igx TQDataStream&         operator << (TQDataStream&, const KProtocolInfo::ExtraField&);
%End


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

%ConvertFromTypeCode
    // Convert to a Python instance

    if (!sipCpp)
        return NULL;

    TDESharedPtr<KProtocolInfo> *cPtr = new TDESharedPtr<KProtocolInfo>(*(TDESharedPtr<KProtocolInfo> *)sipCpp);
    KProtocolInfo *cpp = cPtr->data ();
    PyObject *obj = sipConvertFromInstance (cpp, sipClass_KProtocolInfo, sipTransferObj);

    return obj;
%End

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

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

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

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

    *sipCppPtr = new TDESharedPtr<KProtocolInfo> (cpp);

    return 1;
%End
};


%If (KDE_3_2_0 - )
%MappedType TQValueList<KProtocolInfo::ExtraField>
//converts a Python list of KProtocolInfo::ExtraField
{
%TypeHeaderCode
#include <tqvaluelist.h>
%End

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

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

    TQValueList<KProtocolInfo::ExtraField> *cpplist = (TQValueList<KProtocolInfo::ExtraField> *)sipCpp;
    PyObject *inst;

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

    return pylist;
%End


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

    TQValueList<KProtocolInfo::ExtraField> *cpplist = new TQValueList<KProtocolInfo::ExtraField>;

    PyObject *elem;
    KProtocolInfo::ExtraField *cpp;
    int iserr = 0;

    for (int i = 0; i < PyList_Size (sipPy); i++)
    {
        elem = PyList_GET_ITEM (sipPy, i);
        cpp = (KProtocolInfo::ExtraField *)sipForceConvertToType(elem, sipType_KProtocolInfo_ExtraField, 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
};
%End


