You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
429 lines
11 KiB
429 lines
11 KiB
//
|
|
// 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 QValueList<KMimeType::Ptr> List;
|
|
|
|
public:
|
|
KMimeType (const QString&, const QString&, const QString&, const QString&, const QStringList&);
|
|
KMimeType (const QString&);
|
|
KMimeType (KDesktopFile*);
|
|
KMimeType (QDataStream&, int);
|
|
virtual QString icon (const QString&, bool) const;
|
|
virtual QString icon (const KURL&, bool) const;
|
|
virtual QPixmap pixmap (KIcon::Group, int = 0, int = 0, QString* = 0) const;
|
|
virtual QPixmap pixmap (const KURL&, KIcon::Group, int = 0, int = 0, QString* = 0) const;
|
|
static QPixmap pixmapForURL (const KURL&, mode_t = 0, KIcon::Group = KIcon ::Desktop , int = 0, int = 0, QString* = 0);
|
|
static QString iconForURL (const KURL&, mode_t = 0);
|
|
static QString favIconForURL (const KURL&);
|
|
QString comment () const;
|
|
virtual QString comment (const QString&, bool) const;
|
|
virtual QString comment (const KURL&, bool) const;
|
|
const QStringList& patterns () const;
|
|
virtual void load (QDataStream&);
|
|
virtual void save (QDataStream&);
|
|
virtual QVariant property (const QString&) const;
|
|
virtual QStringList propertyNames () const;
|
|
static KMimeType::Ptr mimeType (const QString&);
|
|
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 QString&, mode_t = 0, bool = 0);
|
|
static KMimeType::Ptr findByContent (const QByteArray&, int* = 0);
|
|
static KMimeType::Ptr findByFileContent (const QString&, 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 QString&);
|
|
%End
|
|
|
|
static KMimeType::List allMimeTypes ();
|
|
static const QString& defaultMimeType ();
|
|
|
|
%If ( KDE_3_2_0 - )
|
|
static KMimeType::Ptr defaultMimeTypePtr ();
|
|
QString parentMimeType () const;
|
|
bool is (const QString&) const /PyName=is_/; //'is' is a reserved keyword in python;
|
|
static KMimeType::Ptr diagnoseFileName (const QString&, QString&);
|
|
%End
|
|
|
|
|
|
protected:
|
|
void loadInternal (QDataStream&);
|
|
void init (KDesktopFile*);
|
|
static void errorMissingMimeType (const QString&);
|
|
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 (QDataStream&, int);
|
|
virtual QString icon (const QString&, bool) const;
|
|
virtual QString icon (const KURL&, bool) const;
|
|
virtual QString comment (const QString&, bool) const;
|
|
virtual QString 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
|
|
|
|
QString m_strName;
|
|
QString m_strIcon;
|
|
QString m_strExec;
|
|
KDEDesktopMimeType::ServiceType m_type;
|
|
bool m_display;
|
|
|
|
}; // class Service
|
|
|
|
|
|
public:
|
|
KDEDesktopMimeType (KDesktopFile*);
|
|
KDEDesktopMimeType (QDataStream&, int);
|
|
virtual QString icon (const QString&, bool) const;
|
|
virtual QString icon (const KURL&, bool) const;
|
|
virtual QPixmap pixmap (const KURL&, KIcon::Group, int = 0, int = 0, QString* = 0) const;
|
|
virtual QString comment (const QString&, bool) const;
|
|
virtual QString comment (const KURL&, bool) const;
|
|
static QValueList<KDEDesktopMimeType::Service> builtinServices (const KURL&);
|
|
static QValueList<KDEDesktopMimeType::Service> userDefinedServices (const QString&, bool);
|
|
|
|
%If ( KDE_3_4_0 - )
|
|
static QValueList<KDEDesktopMimeType::Service> userDefinedServices (const QString&, KConfig&, bool);
|
|
|
|
%If ( KDE_3_5_0 - )
|
|
static QValueList<KDEDesktopMimeType::Service> userDefinedServices (const QString&, KConfig&, bool, const KURL::List&);
|
|
%End
|
|
|
|
%End
|
|
|
|
static void executeService (const QString&, KDEDesktopMimeType::Service&);
|
|
static void executeService (const KURL::List&, KDEDesktopMimeType::Service&);
|
|
static pid_t run (const KURL&, bool);
|
|
|
|
protected:
|
|
virtual QPixmap pixmap (KIcon::Group, int, int, QString*) const;
|
|
static pid_t runFSDevice (const KURL&, const KSimpleConfig&);
|
|
static pid_t runApplication (const KURL&, const QString&);
|
|
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 (QDataStream&, 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 QValueList<KDEDesktopMimeType::Service>
|
|
//converts a Python list of KDEDesktopMimeType.Service
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qvaluelist.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;
|
|
|
|
QValueList<KDEDesktopMimeType::Service> *cpplist = (QValueList<KDEDesktopMimeType::Service> *)sipCpp;
|
|
PyObject *inst;
|
|
|
|
// Get it.
|
|
QValueList<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);
|
|
|
|
QValueList<KDEDesktopMimeType::Service> *cpplist = new QValueList<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 QValueList<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.
|
|
|
|
QValueList<KMimeType::Ptr> *cList = (QValueList<KMimeType::Ptr> *)sipCpp;
|
|
PyObject *inst;
|
|
KMimeType *svc;
|
|
|
|
QValueList<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);
|
|
|
|
QValueList<KMimeType::Ptr> *cList = new QValueList<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
|
|
};
|
|
|
|
|