File indexing completed on 2024-04-28 09:43:03

0001 /*************************************************************************************
0002  *  Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org>              *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #ifndef MOUNT_INFO_H
0020 #define MOUNT_INFO_H
0021 
0022 #include "ui_mount.h"
0023 
0024 #include <QWidget>
0025 #include <KIO/AuthInfo>
0026 #include <KConfigGroup>
0027 
0028 class QProcess;
0029 class KPixmapSequenceOverlayPainter;
0030 class OrgKdeKPasswdServerInterface;
0031 class MountInfo : public QWidget, Ui::MountInfo
0032 {
0033     Q_OBJECT
0034     public:
0035          enum Status {
0036             Empty   = 1,
0037             Ok      = 2,
0038             Fail    = 4
0039         };
0040         explicit MountInfo(OrgKdeKPasswdServerInterface* interface, KConfigGroup config, QWidget* parent = 0);
0041         virtual ~MountInfo();
0042 
0043         QString id() const;
0044         void setConfigGroup(const QString &name);
0045 
0046     public Q_SLOTS:
0047         void checkValidSamba(const QUrl &url);
0048         void checkValidSamba(const QString &url);
0049         void nameResolveFinished(int status);
0050 
0051         bool checkMountPoint(const QUrl &url);
0052         bool checkMountPoint(const QString& name);
0053 
0054         void setResult(QLabel *lbl, Status status);
0055 
0056         void buttonClicked();
0057         void mountIsValid();
0058         void saveConfig();
0059         void saveConfig(KConfigGroup group);
0060 
0061     Q_SIGNALS:
0062         void changed();
0063         void checkDone();
0064         void mountCreated(KConfigGroup);
0065         void mountEditted(KConfigGroup);
0066 
0067     private:
0068         void setEditMode();
0069         void autoFillMountName();
0070         bool isIp(const QString &host);
0071         void checkValidIp(const QString &url);
0072         void checkValidHost(const QString &url);
0073 
0074     private:
0075         void authInfoReceived(qlonglong requestId, qlonglong seqNr, const KIO::AuthInfo & info);
0076         bool m_share, m_mount, m_editMode;
0077         QProcess *m_process;
0078         KConfigGroup m_config;
0079         KPixmapSequenceOverlayPainter *m_painter1;
0080         KPixmapSequenceOverlayPainter *m_painter2;
0081         OrgKdeKPasswdServerInterface* m_interface;
0082 
0083         QString m_id;
0084         QString m_host;
0085         QString m_ip;
0086         QString m_sambaDir;
0087         QString m_fullSambaUrl;
0088         QString m_mountPoint;
0089         QString m_mountName;
0090 };
0091 
0092 #endif //MOUNT_INFO_H