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.
233 lines
6.1 KiB
233 lines
6.1 KiB
15 years ago
|
/*
|
||
|
*
|
||
|
* $Id: sourceheader,v 1.3 2005/01/19 13:03:46 trueg Exp $
|
||
|
* Copyright (C) 2005-2007 Sebastian Trueg <trueg@k3b.org>
|
||
|
*
|
||
|
* This file is part of the K3b project.
|
||
|
* Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
|
||
|
*
|
||
|
* This program 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.
|
||
|
* See the file "COPYING" for the exact licensing terms.
|
||
|
*/
|
||
|
|
||
3 years ago
|
#ifndef _K3B_CONNECTION_H_
|
||
|
#define _K3B_CONNECTION_H_
|
||
15 years ago
|
|
||
|
#ifdef HAVE_CONFIG_H
|
||
|
#include <config.h>
|
||
|
#endif
|
||
|
|
||
|
#include "k3bdevice_export.h"
|
||
|
|
||
14 years ago
|
#include <tqobject.h>
|
||
|
#include <tqmap.h>
|
||
|
#include <tqstringlist.h>
|
||
4 years ago
|
#include <kdemacros.h>
|
||
15 years ago
|
|
||
4 years ago
|
#ifdef HAVE_TDEHWLIB
|
||
12 years ago
|
class TDEGenericDevice;
|
||
4 years ago
|
#else
|
||
|
#define TDEGenericDevice void
|
||
|
#endif
|
||
15 years ago
|
|
||
|
namespace K3bDevice {
|
||
|
|
||
|
class Device;
|
||
|
|
||
|
/**
|
||
3 years ago
|
* This is a simple wrapper which creates QT signals whenever a new optical
|
||
15 years ago
|
* drive is plugged into the system or one is unplugged.
|
||
|
*
|
||
3 years ago
|
* The Connection class also handles media changes. Whenever a new medium is inserted
|
||
15 years ago
|
* into a drive or a medium is removed (i.e. ejected) a signal is emitted. This way it
|
||
|
* is easy to keep track of the inserted media.
|
||
|
*
|
||
|
* This class does not deal with K3b devices but with system device names
|
||
|
* such as /dev/cdrom. These device names can be used in DeviceManager::findDevice().
|
||
|
*/
|
||
3 years ago
|
class LIBK3BDEVICE_EXPORT Connection : public TQObject
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
15 years ago
|
|
||
|
public:
|
||
3 years ago
|
~Connection();
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* Creates a new singleton Connection object or returns the already existing one.
|
||
|
* A newly created Connection will emit newDevice signals for all devices in the
|
||
|
* manager. However, since one cannot be sure if this is the first time the Connection
|
||
15 years ago
|
* is created it is recommended to connect to the signals and query the list of current
|
||
|
* devices.
|
||
|
*
|
||
3 years ago
|
* \return An instance of the singleton Connection object.
|
||
15 years ago
|
*/
|
||
3 years ago
|
static Connection* instance();
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* \return true if a connection to the deamon could be established and
|
||
15 years ago
|
* communication has been set up.
|
||
|
*/
|
||
|
bool isConnected() const;
|
||
|
|
||
|
/**
|
||
3 years ago
|
* \return a list of optical devices as reported.
|
||
15 years ago
|
*/
|
||
14 years ago
|
TQStringList devices() const;
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* Error codes named as the deamon raises them
|
||
15 years ago
|
*/
|
||
|
enum ErrorCodes {
|
||
3 years ago
|
Success = 0, //*< The operation was successful.
|
||
|
CommunicationError,
|
||
|
NoSuchDevice,
|
||
|
DeviceAlreadyLocked,
|
||
|
PermissionDenied,
|
||
|
Device_Volume_NoSuchDevice,
|
||
|
Device_Volume_PermissionDenied,
|
||
|
Device_Volume_AlreadyMounted,
|
||
|
Device_Volume_InvalidMountOption,
|
||
|
Device_Volume_UnknownFilesystemType,
|
||
|
Device_Volume_InvalidMountpoint,
|
||
|
Device_Volume_MountPointNotAvailable,
|
||
|
Device_Volume_PermissionDeniedByPolicy,
|
||
|
Device_Volume_InvalidUnmountOption,
|
||
|
Device_Volume_InvalidEjectOption
|
||
15 years ago
|
};
|
||
|
|
||
|
public slots:
|
||
|
/**
|
||
3 years ago
|
* Lock the device
|
||
15 years ago
|
*
|
||
3 years ago
|
* Be aware that once the method returns the deamon has not necessarily
|
||
15 years ago
|
* finished the procedure yet.
|
||
|
*
|
||
|
* \param dev The device to lock
|
||
|
* \return An error code
|
||
|
*
|
||
|
* \see ErrorCode
|
||
|
*/
|
||
|
int lock( Device* );
|
||
|
|
||
|
/**
|
||
3 years ago
|
* Unlock a previously locked device
|
||
15 years ago
|
*
|
||
3 years ago
|
* Be aware that once the method returns the deamon has not necessarily
|
||
15 years ago
|
* finished the procedure yet.
|
||
|
*
|
||
|
* \param dev The device to lock
|
||
|
* \return An error code
|
||
|
*
|
||
|
* \see ErrorCode
|
||
|
*/
|
||
|
int unlock( Device* );
|
||
|
|
||
|
/**
|
||
3 years ago
|
* Mounts a device
|
||
15 years ago
|
*
|
||
3 years ago
|
* Be aware that once the method returns the deamon has not necessarily
|
||
15 years ago
|
* finished the procedure yet.
|
||
|
*
|
||
|
* \param dev The device to lock
|
||
|
* \return An error code
|
||
|
*
|
||
|
* \see ErrorCode
|
||
|
*/
|
||
|
int mount( Device*,
|
||
14 years ago
|
const TQString& mountPoint = TQString(),
|
||
|
const TQString& fstype = TQString(),
|
||
|
const TQStringList& options = TQStringList() );
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* Unmounts a device
|
||
15 years ago
|
*
|
||
3 years ago
|
* Be aware that once the method returns the deamon has not necessarily
|
||
15 years ago
|
* finished the procedure yet.
|
||
|
*
|
||
|
* \param dev The device to lock
|
||
|
* \return An error code
|
||
|
*
|
||
|
* \see ErrorCode
|
||
|
*/
|
||
|
int unmount( Device*,
|
||
4 years ago
|
const TQStringList& options = TQStringList() );
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* Unmounts a device
|
||
15 years ago
|
*
|
||
3 years ago
|
* Be aware that once the method returns the deamon has not necessarily
|
||
15 years ago
|
* finished the procedure yet.
|
||
|
*
|
||
|
* \param dev The device to lock
|
||
|
* \return An error code
|
||
|
*
|
||
|
* \see ErrorCode
|
||
|
*/
|
||
|
int eject( Device*,
|
||
4 years ago
|
const TQStringList& options = TQStringList() );
|
||
15 years ago
|
|
||
4 years ago
|
private slots:
|
||
|
/**
|
||
|
* \internal
|
||
|
*/
|
||
|
void AddDeviceHandler(TDEGenericDevice*);
|
||
|
|
||
|
/**
|
||
|
* \internal
|
||
|
*/
|
||
|
void RemoveDeviceHandler(TDEGenericDevice*);
|
||
|
|
||
|
/**
|
||
|
* \internal
|
||
|
*/
|
||
|
void ModifyDeviceHandler(TDEGenericDevice*);
|
||
12 years ago
|
|
||
15 years ago
|
signals:
|
||
|
/**
|
||
3 years ago
|
* This signal gets emitted whenever it finds a new optical drive.
|
||
15 years ago
|
*
|
||
|
* \param dev The block device name of the new drive.
|
||
|
*/
|
||
14 years ago
|
void deviceAdded( const TQString& dev );
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* This signal gets emitted whenever it detects that an optical drive
|
||
15 years ago
|
* has been unplugged.
|
||
|
*
|
||
|
* \param dev The block device name of the drive.
|
||
|
*/
|
||
14 years ago
|
void deviceRemoved( const TQString& dev );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* This signal gets emitted whenever a new medium is inserted into a
|
||
|
* device or an inserted is removed (i.e. ejected)
|
||
|
*
|
||
|
* \param dev The block device name of the drive the medium is or was inserted into.
|
||
|
*/
|
||
14 years ago
|
void mediumChanged( const TQString& dev );
|
||
15 years ago
|
|
||
|
private:
|
||
|
/**
|
||
3 years ago
|
* Connection is a signelton class. Use the instance() method to create it.
|
||
15 years ago
|
*/
|
||
3 years ago
|
Connection( TQObject* parent = 0, const char* name = 0 );
|
||
15 years ago
|
|
||
|
/**
|
||
3 years ago
|
* Tries to open a connection
|
||
15 years ago
|
*/
|
||
|
bool open();
|
||
|
void close();
|
||
|
|
||
3 years ago
|
static Connection* s_instance;
|
||
15 years ago
|
|
||
|
class Private;
|
||
|
Private* d;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif
|