// // Copyright 2006 Jim Bublitz // 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 KMimeType : KServiceType { %TypeHeaderCode #include %End public: typedef TDESharedPtr Ptr; typedef TQValueList 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 (TDEIcon::Group, int = 0, int = 0, TQString* = 0) const; virtual TQPixmap pixmap (const KURL&, TDEIcon::Group, int = 0, int = 0, TQString* = 0) const; static TQPixmap pixmapForURL (const KURL&, mode_t = 0, TDEIcon::Group = TDEIcon ::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 %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 %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&, TDEIcon::Group, int = 0, int = 0, TQString* = 0) const; virtual TQString comment (const TQString&, bool) const; virtual TQString comment (const KURL&, bool) const; static TQValueList builtinServices (const KURL&); static TQValueList userDefinedServices (const TQString&, bool); %If ( KDE_3_4_0 - ) static TQValueList userDefinedServices (const TQString&, TDEConfig&, bool); %If ( KDE_3_5_0 - ) static TQValueList userDefinedServices (const TQString&, TDEConfig&, 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 (TDEIcon::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 %End public: KExecMimeType (KDesktopFile*); KExecMimeType (TQDataStream&, int); protected: //igx virtual void virtual_hook (int, void*); }; // class KExecMimeType %MappedType KMimeType::Ptr //converts KMimeType { %TypeHeaderCode #include #include %End %ConvertFromTypeCode // Convert to a Python instance if (!sipCpp) return NULL; TDESharedPtr *cPtr = (TDESharedPtr *)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 TDESharedPtr (cpp); return 1; %End }; %MappedType TQValueList //converts a Python list of KDEDesktopMimeType.Service { %TypeHeaderCode #include #include %End %ConvertFromTypeCode if (!sipCpp) return PyList_New(0); // Create the list PyObject *pylist; if ((pylist = PyList_New(0)) == NULL) return NULL; TQValueList *cpplist = (TQValueList *)sipCpp; PyObject *inst; // Get it. TQValueList::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 *cpplist = new TQValueList; 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 //converts a Python list of KMimeType { %TypeHeaderCode #include %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 *cList = (TQValueList *)sipCpp; PyObject *inst; KMimeType *svc; TQValueList::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 *cList = new TQValueList; 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 };