DBus-1-TQt 1.0
Loading...
Searching...
No Matches
tqdbusunixfd.cpp
Go to the documentation of this file.
1/* tqdbusunixfd.cpp DBUS unix file handle data type
2 *
3 * Copyright (C) 2013 Slávek Banko <slavek.banko@axis.cz>
4 *
5 * Licensed under the Academic Free License version 2.1
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 * USA.
21 *
22 */
23
24#include <unistd.h>
25#include "tqdbusunixfd.h"
26
28{
29 d->ref();
30 d->fd = -1;
31};
32
34{
35 d->ref();
36}
37
39{
40 setFileDescriptor(other);
41}
42
44{
45 if (d && d->deref() ) {
46 if ( isValid() ) {
47 close(d->fd);
48 }
49 delete d;
50 }
51}
52
54{
55 return d ? d->fd != -1 : false;
56}
57
59{
60 return d ? d->fd : -1;
61}
62
63void TQT_DBusUnixFd::setFileDescriptor(int fileDescriptor)
64{
66}
67
68void TQT_DBusUnixFd::giveFileDescriptor(int fileDescriptor)
69{
70 if ( d && d->deref() ) {
71 if ( isValid() ) {
72 close(d->fd);
73 }
74 }
75 else {
77 }
78 d->ref();
80}
81
83{
84 if (other.d) {
85 other.d->ref();
86 }
87 if ( d && d->deref() ) {
88 if ( isValid() ) {
89 close(d->fd);
90 }
91 delete d;
92 }
93 d = other.d;
94 return *this;
95}
Class for representing D-Bus unix file handles.
virtual ~TQT_DBusUnixFd()
Destroys the unix file handle.
TQT_DBusUnixFd()
Creates an empty and invalid unix file handle.
TQT_DBusUnixFd & operator=(const TQT_DBusUnixFd &other)
Copy unix file handle from TQT_DBusUnixFd.
TQT_DBusUnixFd::TQT_DBusUnixFdPrivate * d
void setFileDescriptor(int fileDescriptor)
Set new unix file handle.
void giveFileDescriptor(int fileDescriptor)
Give unix file handle.
int fileDescriptor() const
Get unix file handle.
bool isValid() const
Returns whether the current content is considered a valid unix file handle.