Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QDBusUnixFileDescriptor Class

TheQDBusUnixFileDescriptor class holds one Unix file descriptor.More...

Header:#include <QDBusUnixFileDescriptor>
Since: Qt 4.8

Public Functions

QDBusUnixFileDescriptor()
QDBusUnixFileDescriptor(int fileDescriptor)
QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor & other)
QDBusUnixFileDescriptor(QDBusUnixFileDescriptor && other)
~QDBusUnixFileDescriptor()
intfileDescriptor() const
boolisValid() const
voidsetFileDescriptor(int fileDescriptor)
QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor & other)
QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor && other)

Static Public Members

Detailed Description

TheQDBusUnixFileDescriptor class holds one Unix file descriptor.

TheQDBusUnixFileDescriptor class is used to hold one Unix file descriptor for use with theQtDBus module. This allows applications to send and receive Unix file descriptors over the D-Bus connection, mapping automatically to the D-Bus type 'h'.

Objects of type QDBusUnixFileDescriptors can be used also as parameters in signals and slots that get exported to D-Bus by registering withQDBusConnection::registerObject.

QDBusUnixFileDescriptor does not take ownership of the file descriptor. Instead, it will use the Unix system calldup(2) to make a copy of the file descriptor. This file descriptor belongs to theQDBusUnixFileDescriptor object and should not be stored or closed by the user. Instead, you should make your own copy if you need that.

Availability

Unix file descriptor passing is not available in all D-Bus connections. This feature is present with D-Bus library and bus daemon version 1.4 and upwards on Unix systems.QtDBus automatically enables the feature if such a version was found at compile-time and run-time.

To verify that your connection does support passing file descriptors, check if theQDBusConnection::UnixFileDescriptorPassing capability is set withQDBusConnection::connectionCapabilities(). If the flag is not active, then you will not be able to make calls to methods that haveQDBusUnixFileDescriptor as arguments or even embed such a type in a variant. You will also not receive calls containing that type.

Note also that remote applications may not have support for Unix file descriptor passing. If you make a D-Bus to a remote application that cannot receive such a type, you will receive an error reply. If you try to send a signal containing a D-Bus file descriptor or return one from a method call, the message will be silently dropped.

Even if the feature is not available,QDBusUnixFileDescriptor will continue to operate, so code need not have compile-time checks for the availability of this feature.

On non-Unix systems,QDBusUnixFileDescriptor will always report an invalid state andQDBusUnixFileDescriptor::isSupported() will return false.

See alsoQDBusConnection::ConnectionCapabilities andQDBusConnection::connectionCapabilities().

Member Function Documentation

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor()

Constructs aQDBusUnixFileDescriptor without a wrapped file descriptor. This is equivalent to constructing the object with an invalid file descriptor (like -1).

See alsofileDescriptor() andisValid().

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(int fileDescriptor)

Constructs aQDBusUnixFileDescriptor object by copying thefileDescriptor parameter. The original file descriptor is not touched and must be closed by the user.

Note that the value returned byfileDescriptor() will be different from thefileDescriptor parameter passed.

If thefileDescriptor parameter is not valid,isValid() will return false andfileDescriptor() will return -1.

See alsosetFileDescriptor() andfileDescriptor().

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(constQDBusUnixFileDescriptor & other)

Constructs aQDBusUnixFileDescriptor object by copyingother.

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor(QDBusUnixFileDescriptor && other)

QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor()

Destroys thisQDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained.

int QDBusUnixFileDescriptor::fileDescriptor() const

Returns the Unix file descriptor contained by thisQDBusUnixFileDescriptor object. An invalid file descriptor is represented by the value -1.

Note that the file descriptor returned by this function is owned by theQDBusUnixFileDescriptor object and must not be stored past the lifetime of this object. It is ok to use it while this object is valid, but if one wants to store it for longer use, the file descriptor should be cloned using the Unixdup(2),dup2(2) ordup3(2) functions.

See alsosetFileDescriptor() andisValid().

[static]bool QDBusUnixFileDescriptor::isSupported()

Returns true if Unix file descriptors are supported on this platform. In other words, this function returns true if this is a Unix platform.

Note thatQDBusUnixFileDescriptor continues to operate even if this function returns false. The only difference is that theQDBusUnixFileDescriptor objects will always be in theisValid() == false state andfileDescriptor() will always return -1. The class will not consume any operating system resources.

bool QDBusUnixFileDescriptor::isValid() const

Returns true if this Unix file descriptor is valid. A valid Unix file descriptor is not -1.

See alsofileDescriptor().

void QDBusUnixFileDescriptor::setFileDescriptor(int fileDescriptor)

Sets the file descriptor that thisQDBusUnixFileDescriptor object holds to a copy offileDescriptor. The original file descriptor is not touched and must be closed by the user.

Note that the value returned byfileDescriptor() will be different from thefileDescriptor parameter passed.

If thefileDescriptor parameter is not valid,isValid() will return false andfileDescriptor() will return -1.

See alsoisValid() andfileDescriptor().

QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator=(constQDBusUnixFileDescriptor & other)

Copies the Unix file descriptor from theotherQDBusUnixFileDescriptor object. If the current object contained a file descriptor, it will be properly disposed of before.

QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator=(QDBusUnixFileDescriptor && other)

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp