26 #include <linux/rfkill.h>
33 #include <tqdbusproxy.h>
34 #include <tqmessagebox.h>
35 #include <tdelocale.h>
59 device = device.replace(TQRegExp(
"^/.*/"),
"");
61 TQDir d(
"/sys/class/rfkill");
62 d.setFilter(TQDir::Dirs);
63 for (
int i = 0; i < d.count(); i++)
66 TQFile f(
"/sys/class/rfkill/" + d[i] +
"/name");
68 if (f.exists() && f.open(IO_ReadOnly))
70 TQTextStream stream(&f);
71 content = stream.readLine();
78 if (content.startsWith(device))
80 TQFile f(
"/sys/class/rfkill/" + d[i] +
"/index");
81 if (f.exists() && f.open(IO_ReadOnly))
83 TQTextStream stream(&f);
84 hcidx = stream.readLine().toUInt();
94 tqDebug(i18n(
"Index for the device %1 not found").arg(device));
98 struct rfkill_event event = { 0 };
100 TQFile file(
"/dev/rfkill");
101 if (!file.open(IO_ReadWrite))
103 tqDebug(i18n(
"Failed to open %1").arg(file.name()));
108 event.op = RFKILL_OP_CHANGE;
114 tqDebug(i18n(
"Bluetooth device %1 switches: idx(%2), soft(%3).").arg(device).arg(event.idx).arg(event.soft));
116 if (write(file.handle(), &event,
sizeof(event)) < 0)
117 tqDebug(i18n(
"Failed to write to %1").arg(file.name()));
128 TQT_DBusError dbuserror;
130 if (dbuserror.isValid())
131 tqDebug(i18n(
"AdapterImpl::slotSetAlias(%1) failed: %2").arg(alias).arg(dbuserror.message()));
136 TQT_DBusError dbuserror;
138 if (dbuserror.isValid())
139 tqDebug(i18n(
"AdapterImpl::slotSetTimeout(%1) failed: %2").arg(timeout).arg(dbuserror.message()));
144 #include "adapterImpl.moc"
void slotSetTimeout(int timeout)
void slotSetAlias(const TQString &alias)
AdapterImpl(const TQString &service, const TQString &path, TQObject *parent=0, const char *name=0)
TQT_DBusProxy * m_baseProxy
virtual void setAlias(const TQString &value, TQT_DBusError &error)
virtual void setDiscoverableTimeout(TQ_UINT32 value, TQT_DBusError &error)