// Copyright 2008 Simon Edwards <simon@simonzone.com>

//                 Generated by twine

// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as
// published by the Free Software Foundation; either version 2, or
// (at your option) any later version.

// This program 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 Library General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


namespace Plasma
{

class PackageStructure : QObject
{
%TypeHeaderCode
#include <plasma/packagestructure.h>
%End

public:
    typedef KSharedPtr<Plasma::PackageStructure> Ptr;

    explicit                PackageStructure (QObject* parent /TransferThis/ = 0, const QString& type = i18nc("A non-functional package","Invalid"));
    static Plasma::PackageStructure::Ptr  load (const QString& packageFormat);
    QString                 type () const;

    QList<const char*>      directories () const;
    QList<const char*>      requiredDirectories () const;
    QList<const char*>      files () const;
    QList<const char*>      requiredFiles () const;
    void                    addDirectoryDefinition (const char* key, const QString& path, const QString& name);
    void                    addFileDefinition (const char* key, const QString& path, const QString& name);
    QString                 path (const char* key) const;
    QStringList             entryList (const char* key);
    QString                 name (const char* key) const;
    void                    setRequired (const char* key, bool required);
    bool                    isRequired (const char* key) const;
    void                    setDefaultMimetypes (QStringList mimetypes);
    void                    setMimetypes (const char* key, QStringList mimetypes);
    QStringList             mimetypes (const char* key) const;
    void                    setPath (const QString& path);
    QString                 path () const;
    void                    read (const KConfigBase* config);
    void                    write (KConfigBase* config) const;
    virtual bool            installPackage (const QString& archivePath, const QString& packageRoot);
    virtual bool            uninstallPackage (const QString& packageName, const QString& packageRoot);
    virtual void            createNewWidgetBrowser (QWidget* parent /Transfer/ = 0);
    QString                 contentsPrefix () const;
    QString                 defaultPackageRoot () const;
    QString                 servicePrefix () const;
    void                    setServicePrefix (const QString& servicePrefix);

//FIXME PackageMetadata needs a custom = operator for this to work.
//    virtual Plasma::PackageMetadata  metadata ();

    bool                    allowExternalPaths () const;

signals:
    void                    newWidgetBrowserFinished ();

protected:
    void                    setAllowExternalPaths (bool allow);
    void                    setContentsPrefix (const QString& prefix);
    void                    setDefaultPackageRoot (const QString& packageRoot);
    virtual void            pathChanged ();

};   // PackageStructure

};   // Plasma

%MappedType QList<const char *>
{
%TypeHeaderCode
#include <qlist.h>
%End
%ConvertToTypeCode
    return NULL;
%End

%ConvertFromTypeCode
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        PyObject *pobj;
        int iserr;

        if ((pobj = sipBuildResult(&iserr,"s",sipCpp->value(i))) == NULL)
        {
            Py_DECREF(l);

            return NULL;
        }

        PyList_SET_ITEM(l, i, pobj);
    }

    return l;
%End
};
