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.
172 lines
4.6 KiB
172 lines
4.6 KiB
13 years ago
|
/* This file is part of the TDE Project
|
||
|
Copyright (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License version 2 as published by the Free Software Foundation.
|
||
|
|
||
|
This library 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
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* This is a media:/ backend for the builtin TDE hardware library
|
||
|
*
|
||
|
* @author Timothy Pearson <kb9vqf@pearsoncomputing.net>
|
||
|
* @short media:/ backend for the TDE hardware library
|
||
|
*/
|
||
|
|
||
|
#ifndef _TDEBACKEND_H_
|
||
|
#define _TDEBACKEND_H_
|
||
|
|
||
|
#include "backendbase.h"
|
||
|
|
||
|
#include <tqobject.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqstring.h>
|
||
|
|
||
|
#include <config.h>
|
||
|
|
||
|
#include <tdehardwaredevices.h>
|
||
|
|
||
12 years ago
|
namespace TDEIO {
|
||
13 years ago
|
class Job;
|
||
|
}
|
||
|
|
||
|
class Dialog;
|
||
|
|
||
|
class TDEBackend : public TQObject, public BackendBase
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
/**
|
||
|
* Constructor
|
||
|
*/
|
||
|
TDEBackend(MediaList &list, TQObject* parent);
|
||
|
|
||
|
/**
|
||
|
* Destructor
|
||
|
*/
|
||
|
~TDEBackend();
|
||
|
|
||
|
/**
|
||
|
* List all devices and append them to the media device list (called only once, at startup).
|
||
|
*
|
||
|
* @return true if succeded, false otherwise
|
||
|
*/
|
||
|
bool ListDevices();
|
||
|
|
||
|
TQStringList mountoptions(const TQString &id);
|
||
|
|
||
|
bool setMountoptions(const TQString &id, const TQStringList &options);
|
||
|
|
||
|
TQString mount(const TQString &id);
|
||
|
TQString mount(const Medium *medium);
|
||
|
TQString unmount(const TQString &id);
|
||
|
// TQString decrypt(const TQString &id, const TQString &password);
|
||
|
// TQString undecrypt(const TQString &id);
|
||
|
|
||
|
private:
|
||
|
/**
|
||
|
* Append a device in the media list. This function will check if the device
|
||
|
* is worth listing.
|
||
|
*
|
||
|
* @param sdevice A pointer to a TDEStorageDevice object
|
||
|
* @param allowNotification Indicates if this event will be notified to the user
|
||
|
*/
|
||
|
void AddDevice(TDEStorageDevice * sdevice, bool allowNotification=true);
|
||
|
|
||
|
/**
|
||
|
* Remove a device from the device list
|
||
|
*
|
||
|
* @param sdevice A pointer to a TDEStorageDevice object
|
||
|
*/
|
||
|
void RemoveDevice(TDEStorageDevice * sdevice);
|
||
|
|
||
|
/**
|
||
|
* A device has changed, update it
|
||
|
*
|
||
|
* @param sdevice A pointer to a TDEStorageDevice object
|
||
|
*/
|
||
|
void ModifyDevice(TDEStorageDevice * sdevice);
|
||
|
|
||
|
private slots:
|
||
|
void AddDeviceHandler(TDEGenericDevice* device);
|
||
|
void RemoveDeviceHandler(TDEGenericDevice* device);
|
||
|
void ModifyDeviceHandler(TDEGenericDevice* device);
|
||
|
|
||
|
void slotPasswordReady();
|
||
|
void slotPasswordCancel();
|
||
|
|
||
|
signals:
|
||
|
void signalDecryptionPasswordError(TQString);
|
||
|
|
||
|
/* Set media properties */
|
||
|
private:
|
||
|
/**
|
||
|
* Reset properties for the given medium
|
||
|
*
|
||
|
* @param sdevice A pointer to a TDEStorageDevice objec
|
||
13 years ago
|
* @param allowNotification Indicates if this event will be notified to the user
|
||
|
* @param overrideIgnoreList If true, override event ignore requests for the current device node
|
||
13 years ago
|
*/
|
||
13 years ago
|
void ResetProperties(TDEStorageDevice * sdevice, bool allowNotification=false, bool overrideIgnoreList=false);
|
||
13 years ago
|
|
||
|
/**
|
||
|
* Find the medium that is concerned with device udi
|
||
|
*/
|
||
|
// const char* findMediumUdiFromUdi(const char* udi);
|
||
|
|
||
|
void setVolumeProperties(Medium* medium);
|
||
|
bool setFloppyProperties(Medium* medium);
|
||
13 years ago
|
void setFloppyMountState( Medium* medium );
|
||
13 years ago
|
// bool setFstabProperties(Medium* medium);
|
||
|
void setCameraProperties(Medium* medium);
|
||
|
TQString generateName(const TQString &devNode);
|
||
|
static TQString isInFstab(const Medium *medium);
|
||
|
static TQString listUsingProcesses(const Medium *medium);
|
||
|
static TQString killUsingProcesses(const Medium *medium);
|
||
|
|
||
12 years ago
|
TQString driveUDIFromDeviceUID(TQString uuid);
|
||
|
|
||
13 years ago
|
// Decryption
|
||
|
Dialog* m_decryptDialog;
|
||
|
TQString m_decryptionPassword;
|
||
|
bool m_decryptPasswordValid;
|
||
|
|
||
|
/* TDE structures */
|
||
|
private:
|
||
|
/**
|
||
|
* Object for the kded module
|
||
|
*/
|
||
|
TQObject* m_parent;
|
||
|
|
||
|
/**
|
||
|
* Data structure for fstab mount/unmount jobs
|
||
|
*/
|
||
|
struct mount_job_data {
|
||
|
// [in] Medium, which is being mounted/unmounted by the job
|
||
|
const Medium* medium;
|
||
|
// [in,out] Should be set to true when the job completes
|
||
|
bool completed;
|
||
12 years ago
|
// [out] TDEIO::Error if an error occured during operation. Otherwise, 0
|
||
13 years ago
|
int error;
|
||
|
// [out] Error message to be displayed to the user
|
||
|
TQString errorMessage;
|
||
|
};
|
||
|
|
||
12 years ago
|
TQMap<TDEIO::Job *, struct mount_job_data*> mount_jobs;
|
||
13 years ago
|
|
||
|
TQStringList m_ignoreDeviceChangeEvents;
|
||
13 years ago
|
};
|
||
|
|
||
|
#endif /* _TDEBACKEND_H_ */
|