ukui-bluetooth/0000775000175000017500000000000015167665770012504 5ustar fengfengukui-bluetooth/ukui-bluetooth/0000775000175000017500000000000015167665770015464 5ustar fengfengukui-bluetooth/ukui-bluetooth/dbus/0000775000175000017500000000000015167665770016421 5ustar fengfengukui-bluetooth/ukui-bluetooth/dbus/sessiondbusinterface.cpp0000664000175000017500000004525615167665770023363 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "sessiondbusinterface.h" #include "popwidget/beforeturnoffhintwidget.h" #include #include static BeforeTurnOffHintWidget * static_closeInfoDialog = nullptr; static QMessageBox * static_messagebox = nullptr; SessionDbusInterface::SessionDbusInterface(QMap *_adapterAttr, QMap> *_adapterList, QMap> *_deviceList, QObject *parent) : QObject(parent) { adapterAttr = _adapterAttr; deviceList = _deviceList; adapterList = _adapterList; KyInfo() ; if (InterfaceAlreadyExists()) { QDBusConnection sessionDbus = QDBusConnection::sessionBus(); if (!sessionDbus.registerService("com.ukui.bluetooth")) { qCritical() << "QDbus register service failed reason:" << sessionDbus.lastError(); } if (!sessionDbus.registerObject("/com/ukui/bluetooth", "com.ukui.bluetooth", this, QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals)){ qCritical() << "QDbus register object failed reason:" << sessionDbus.lastError(); } KyInfo() ; } initMprisMediaDbusConnect(); } void SessionDbusInterface::ConnectSystemDbusSignal() { } bool SessionDbusInterface::InterfaceAlreadyExists() { QDBusConnection conn = QDBusConnection::sessionBus(); if (!conn.isConnected()) return false; QDBusReply reply = conn.interface()->call("GetNameOwner", "com.ukui.bluetooth"); KyInfo() << reply.value(); return reply.value() == ""; } bool SessionDbusInterface::registerClient(QString dbusid, QString username, int type, quint64 pid) { QMap rcParam; rcParam.insert("dbusid", dbusid); rcParam.insert("username", username); rcParam.insert("type", type); rcParam.insert("pid", pid); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("registerClient"); dbusMsg << rcParam; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } bool SessionDbusInterface::unregisterClient(QString dbusid) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("unregisterClient"); dbusMsg << dbusid; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } bool SessionDbusInterface::getBluetoothBlock() { return adapterAttr->value("Block").toBool(); } QString SessionDbusInterface::getDefaultAdapterAddress(){ return adapterAttr->value("Addr").toString(); } bool SessionDbusInterface::getDefaultAdapterPower() { return adapterAttr->value("Powered").toBool(); } bool SessionDbusInterface::getDefaultAdapterScanStatus() { return adapterAttr->value("Discovering").toBool(); } bool SessionDbusInterface::getDefaultAdapterDiscoverable() { return adapterAttr->value("Discoverable").toBool(); } QString SessionDbusInterface::getAdapterNameByAddr(QString address) { if (!adapterList->keys().contains(address)) return ""; return adapterList->value(address).value("Name").toString(); } QStringList SessionDbusInterface::getDefaultAdapterPairedDevAddress() { QStringList pairedList; for (auto i : deviceList->keys()) { if (deviceList->value(i).value("Paired").toBool()) pairedList.append(i); } return pairedList; } QStringList SessionDbusInterface::getPairedPhoneAddr() { QStringList pairedList; if (adapterList->keys().isEmpty()) { return pairedList; } for (auto i : deviceList->keys()) { if (deviceList->value(i).value("Type").toInt() != Type::Phone) { continue; } KyDebug() << "phone" << i; if (!deviceList->value(i).value("Paired").toBool()) { continue; } if (!deviceList->value(i).value("Connected").toBool()) { continue; } pairedList.append(i); } KyDebug() << pairedList; return pairedList; } bool SessionDbusInterface::getLeaveLockPower() { return Config::getLeaveLockPower(); } void SessionDbusInterface::setLeaveLockPower(bool v) { Config::setLeaveLockPower(v); } QStringList SessionDbusInterface::getDefaultAdapterTrustedDevAddress() { QStringList trustedList; for (auto i : deviceList->keys()) { if (deviceList->value(i).value("Trusted").toBool()) trustedList.append(i); } return trustedList; } QStringList SessionDbusInterface::getDefaultAdapterCacheDevAddress() { QStringList cacheList; for (auto i : deviceList->keys()) { cacheList.append(i); } return cacheList; } QStringList SessionDbusInterface::getAdapterDevAddressList() { QStringList _adapterList; for (auto i : adapterList->keys()) { _adapterList.append(i); } return _adapterList; } void SessionDbusInterface::setDefaultAdapterPower(bool powered) { QMap Attr; if (powered == adapterAttr->value("Powered").toBool()) return; Attr.insert("Powered", QVariant(powered)); Config::setDefaultAdapterAttr(Attr); } void SessionDbusInterface::setDefaultAdapterScanOn(bool dicovering) { QMap Attr; if (dicovering == adapterAttr->value("Discovering").toBool()) return; Attr.insert("Discovering", QVariant(dicovering)); Config::setDefaultAdapterAttr(Attr); } void SessionDbusInterface::setDefaultAdapter(QString address) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("setDefaultAdapter"); dbusMsg << address; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { switch(response.arguments().takeFirst().toInt()) { case 0 : DEBUG_PRINT("set default adapter Succeed"); break; case -1 : DEBUG_PRINT("set default adapter Error"); break; case -2 : DEBUG_PRINT("default adapter doesn't Exist"); break; } } else DEBUG_PRINT("call 'setDefaultAdapter' Failed"); } void SessionDbusInterface::setDefaultAdapterDiscoverable(bool discoverable) { QMap Attr; if (discoverable == adapterAttr->value("Discoverable").toBool()) return; Attr.insert("Discoverable", QVariant(discoverable)); Config::setDefaultAdapterAttr(Attr); } void SessionDbusInterface::setBluetoothBlock(bool) { return; } void SessionDbusInterface::setDefaultAdapterName(QString name) { QMap Attr; if (name == adapterAttr->value("Name").toString()) return; Attr.insert("Name", QVariant(name)); Config::setDefaultAdapterAttr(Attr); } void SessionDbusInterface::clearNonViableDevice(QStringList) { return; } void SessionDbusInterface::devPair(const QString address) { Config::devConnect(address); } void SessionDbusInterface::devConnect(const QString address) { Config::devConnect(address); } void SessionDbusInterface::devDisconnect(const QString address) { Config::devDisconnect(address); } void SessionDbusInterface::devRemove(const QString address) { Config::devRemove(address, adapterAttr->value("Addr").toString()); } void SessionDbusInterface::devTrust(const QString address,const bool trusted) { if (!deviceList->keys().contains(address)) { return; } for (auto i = deviceList->begin(); i != deviceList->end(); i++) { if (i.key() == address) { i->remove("Trusted"); i->insert("Trusted", QVariant(trusted)); } } QMap devAttr; devAttr.insert("Name", QVariant(deviceList->value(address).value("Name").toString())); devAttr.insert("Trusted", QVariant(trusted)); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("setDevAttr"); dbusMsg << devAttr; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Remove Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } } else DEBUG_PRINT("Method Call Error"); } bool SessionDbusInterface::getDevPairStatus(const QString address) { if (!deviceList->keys().contains(address)) { return false; } return deviceList->value(address).value("Paired").toBool(); } bool SessionDbusInterface::getDevConnectStatus(const QString address) { if (!deviceList->keys().contains(address)) { return false; } return deviceList->value(address).value("Connected").toBool(); } QString SessionDbusInterface::getDevName(const QString address) { if (adapterList->isEmpty()) return ""; if (!deviceList->keys().contains(address)) { return ""; } if (deviceList->value(address).keys().contains("ShowName")) { if (deviceList->value(address).value("ShowName") != "") { return deviceList->value(address).value("ShowName").toString();} } return deviceList->value(address).value("Name").toString(); } QString SessionDbusInterface::getDevType(const QString address) { if (!deviceList->keys().contains(address)) { return ""; } switch(deviceList->value(address).value("Type").toInt()) { case Type::Phone: return QString("phone"); case Type::Modem: return QString("modem"); case Type::Computer: return QString("computer"); case Type::Network: return QString("network"); case Type::Headset: return QString("headset"); case Type::Headphones: return QString("headphones"); case Type::AudioVideo: return QString("audiovideo"); case Type::Keyboard: return QString("keyboard"); case Type::Mouse: return QString("mouse"); case Type::Joypad: return QString("joypad"); case Type::Tablet: return QString("tablet"); case Type::Peripheral: return QString("peripheral"); case Type::Camera: return QString("camera"); case Type::Printer: return QString("printer"); case Type::Imaging: return QString("imaging"); case Type::Wearable: return QString("wearable"); case Type::Toy: return QString("toy"); case Type::Health: return QString("health"); case Type::Uncategorized: default: return QString("uncategorized"); } } void SessionDbusInterface::clearAllUnPairedDevicelist() { return; } void SessionDbusInterface::setSendTransferDeviceMesg(QString address) { emit sendTransferDeviceMesg(address); } void SessionDbusInterface::setSendTransferFileMesg(QStringList files) { emit sendTransferFilesMesg(files); } void SessionDbusInterface::setclearOldSession() { emit clearOldSession(); } void SessionDbusInterface::continueSendFiles(QString filename) { emit continueSendFilesSignal(filename); } void SessionDbusInterface::cancelFileReceiving() { emit cancelFileReceivingSignal(); } int SessionDbusInterface::getDevBattery(const QString address) { return deviceList->value(address).value("Battery").toInt(); } bool SessionDbusInterface::getDevSupportFileSend(const QString address) { if (!deviceList->keys().contains(address)) return false; return deviceList->value(address).value("FileTransportSupport").toBool(); } int SessionDbusInterface::getDevRssi(const QString address) { return deviceList->value(address).value("Rssi").toInt(); } void SessionDbusInterface::sendFiles(QString addr,QString filename) { if (filename.isEmpty() || filename.isNull()) return; emit sendFile(addr,filename); } void SessionDbusInterface::exit() { return; } void SessionDbusInterface::sendNotifyMessage(QString message) { Config::SendNotifyMessage(QString(tr("Bluetooth Message")), message, QString("mute")); } void SessionDbusInterface::openBluetoothSettings() { Config::OpenBluetoothSettings(); } void SessionDbusInterface::connectSignal() { return; } void SessionDbusInterface::showTrayWidgetUI() { emit showTrayWidgetUISignal(); } bool SessionDbusInterface::getTransferDevAndStatus(QString dev) { return true; } void SessionDbusInterface::sendContinueRecieveFilesSignal() { emit continueRecieveFilesSignal(); } void SessionDbusInterface::sendReplyRequestConfirmation(bool v) { emit replyRequestConfirmation(v); } void SessionDbusInterface::sendReplyFileReceivingSignal(bool v) { emit replyFileReceivingSignal(v); } void SessionDbusInterface::sendCloseSession() { emit closeSessionSignal(); } void SessionDbusInterface::activeConnectionReply(QString dev, bool v) { Config::activeConnectionReply(dev, v); } void SessionDbusInterface::showCloseBluetoothInfoDialog() { if( nullptr == static_closeInfoDialog) { static_closeInfoDialog = new BeforeTurnOffHintWidget(); static_closeInfoDialog->hide(); } if(nullptr == static_messagebox){ static_messagebox = new QMessageBox(); static_messagebox->setIcon(QMessageBox::Warning); static_messagebox->setText(static_closeInfoDialog->textDataStr()); QPushButton * cancelBtn= new QPushButton(static_closeInfoDialog->cancelStr()); QPushButton * closeBluetoothBtn= new QPushButton(static_closeInfoDialog->closeStr()); static_messagebox->addButton(cancelBtn,QMessageBox::RejectRole); static_messagebox->addButton(closeBluetoothBtn,QMessageBox::AcceptRole); connect(static_messagebox, &QMessageBox::accepted, this, [=]() { KyInfo(); QMap attr; attr["Powered"] = false; Config::setDefaultAdapterAttr(attr); static_messagebox->hide(); }); } QDBusInterface iface("org.ukui.Sidebar", "/org/ukui/Sidebar", "org.ukui.Sidebar", QDBusConnection::sessionBus()); iface.asyncCall("shortcutWidgetActive", "org.ukui.shortcut.bluetooth", true); static_messagebox->show(); } void SessionDbusInterface::showActiveConnectDialog() { emit ActiveConnection("12:34:56:78:90:12", "test", "headset", 40, 30); } //多媒体键值处理 void SessionDbusInterface::initMprisMediaDbusConnect() { CONNECT_SYSTEM_DBUS_SIGNAL("VolumeDown",VolumeDownSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("VolumeUp",VolumeUpSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("Next",NextSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("PlayPause",PlayPauseSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("Previous",PreviousSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("Stop",StopSlot()); CONNECT_SYSTEM_DBUS_SIGNAL("Play",PlaySlot()); CONNECT_SYSTEM_DBUS_SIGNAL("Pause",PauseSlot()); } void SessionDbusInterface::VolumeDownSlot(){ KyInfo(); controlMprisPlayerDbus("VolumeDown"); } void SessionDbusInterface::VolumeUpSlot(){ KyInfo(); controlMprisPlayerDbus("VolumeUp"); } void SessionDbusInterface::NextSlot(){ KyInfo(); controlMprisPlayerDbus("Next"); } void SessionDbusInterface::PlayPauseSlot(){ KyInfo(); controlMprisPlayerDbus("PlayPause"); } void SessionDbusInterface::PreviousSlot(){ KyInfo(); controlMprisPlayerDbus("Previous"); } void SessionDbusInterface::StopSlot(){ KyInfo(); controlMprisPlayerDbus("Stop"); } void SessionDbusInterface::PlaySlot(){ KyInfo(); controlMprisPlayerDbus("Play"); } void SessionDbusInterface::PauseSlot(){ KyInfo(); controlMprisPlayerDbus("Pause"); } //获取session bus总线上注册的dbus名称 QStringList SessionDbusInterface::sessionDbusListNames() { KyDebug (); QDBusInterface iface(SESSION_DBUS_FREEDESKTOP_SERVICE, SESSION_DBUS_FREEDESKTOP_PATH, SESSION_DBUS_FREEDESKTOP_INTERFACE, QDBusConnection::sessionBus()); //设置超时时间, ms iface.setTimeout(300); QDBusReply reply=iface.call("ListNames"); return reply; } // void SessionDbusInterface::controlMprisPlayerDbus(const QString funcName) { KyDebug() << funcName ; QStringList sessionDbusNamesList = sessionDbusListNames(); QStringList mprisDbusNameList = sessionDbusNamesList.filter(SESSION_DBUS_NAME_STR_FIELD,Qt::CaseInsensitive); if (mprisDbusNameList.isEmpty()) { KyInfo() << "not mpris dbus" ; return; } KyInfo() << "funcName:" <. * **/ #include "sysdbusinterface.h" #include #include //#include #include #include "ukui-log4qt.h" sysdbusinterface::sysdbusinterface() { QDBusConnection systemBus = QDBusConnection::systemBus(); if (!systemBus.registerObject("/", this, QDBusConnection::ExportAllSlots)) { KyWarning() << "QDbus register object failed reason:" << systemBus.lastError(); } } sysdbusinterface::~sysdbusinterface() { } QString sysdbusinterface::getProperFilePath(QString user, QString filename) { KyInfo() << user << filename; QString dest; /* dest = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/" + filename; KyDebug() << dest; while (QFile::exists(dest)) { QStringList newUrl = dest.split("/"); newUrl.pop_back(); newUrl.append(Peony::FileUtils::handleDuplicateName(Peony::FileUtils::urlDecode(dest))); dest = newUrl.join("/"); KyDebug() << dest << newUrl; }*/ return dest; } void sysdbusinterface::setMultiAudioCombine(bool v) { KyInfo() << v; QDBusInterface iface("org.ukui.volume.control", "/org/ukui/volume/control", "org.ukui.volume.control", QDBusConnection::sessionBus()); iface.asyncCall("setMultiAudioCombine", 1, v, QStringList()); } ukui-bluetooth/ukui-bluetooth/dbus/sysdbusinterface.h0000664000175000017500000000234015167665770022146 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef SYSDBUSINTERFACE_H #define SYSDBUSINTERFACE_H #include #include #include #include #include #include class sysdbusinterface : public QObject, protected QDBusContext { Q_CLASSINFO("D-Bus Interface", "com.ukui.bluetooth") Q_OBJECT public: sysdbusinterface(); ~sysdbusinterface(); public slots: QString getProperFilePath(QString user, QString filename); void setMultiAudioCombine(bool v); }; #endif // SYSDBUSINTERFACE_H ukui-bluetooth/ukui-bluetooth/dbus/bluetoothdbus.cpp0000664000175000017500000006777515167665770022036 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothdbus.h" #include BluetoothDbus::BluetoothDbus(QObject *parent) { Q_UNUSED(parent); KyDebug(); userName = QString(qgetenv("USER").toStdString().data()); adapterList = new QMap>(); devicesList = new QMap>(); pairedList = new QMap>(); connectDBusSignals(); InitAdaptersAttr(); InitDefaultAdapterDevicesAttr(); registerClient(); sessDbusInterface = new SessionDbusInterface(&defaultAdapterAttr,adapterList,pairedList,this); connect(sessDbusInterface, &SessionDbusInterface::ActiveConnection, this, &BluetoothDbus::activeConnectionSignal); connect(sessDbusInterface, &SessionDbusInterface::setLeaveLockSignal, this, &BluetoothDbus::setLeaveLock); if(QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).keys().contains("leave-lock")) { leaveLockon = QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).get("leave-lock").toBool(); lockDev = QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).get("leavelock-dev").toString(); } sessDbusInterface->setLeaveLockOn(leaveLockon); sessDbusInterface->setLeaveLockDev(lockDev); QDBusMessage message = QDBusMessage::createMethodCall("org.ukui.ScreenSaver", "/", "org.ukui.ScreenSaver", "GetLockState"); QDBusMessage response = QDBusConnection::sessionBus().call(message); if (response.type() == QDBusMessage::ReplyMessage) { bool ret = response.arguments().takeFirst().toBool(); if (leaveLockon && !ret) if (lockDev != "") leaveLock(lockDev, leaveLockon); } KyDebug(); } BluetoothDbus::~BluetoothDbus() { unregisterClient(); } void BluetoothDbus::connectDBusSignals() { KyDebug(); TRANSFER_DBUS_SIGNAL("showTrayWidgetUISignal", showTrayWidgetUISignal()); TRANSFER_DBUS_SIGNAL("sendTransferFilesMesg", sendTransferFilesMesgSignal(QStringList)); TRANSFER_DBUS_SIGNAL("sendTransferDeviceMesg", sendTransferDeviceMesgSignal(QString)); CONNECT_SYSTEM_DBUS_SIGNAL("adapterAddSignal", adapterAddSignalSLot(QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("adapterAttrChanged", adapterAttrChangedSLot(QString, QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("adapterRemoveSignal", adapterRemoveSignalSLot(QString)); CONNECT_SYSTEM_DBUS_SIGNAL("deviceAddSignal", deviceAddSLot(QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("deviceAttrChanged", deviceAttrChangedSLot(QString, QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("deviceRemoveSignal", devRemoveSignalSLot(QString, QMap)); TRANSFER_SYSTEM_DBUS_SIGNAL("ActiveConnection", activeConnectionSignal(QString,QString,QString,int,int)); CONNECT_SYSTEM_DBUS_SIGNAL("updateClient", updateClientSLot()); TRANSFER_SYSTEM_DBUS_SIGNAL("fileStatusChanged", statusChangedSignal(QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("fileReceiveSignal", receiveFilesSlot(QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("startPair", devPairSignalSLot(QMap)); CONNECT_SYSTEM_DBUS_SIGNAL("pingTimeSignal", pingTimeSignalSLot(QByteArray)); QDBusConnection::systemBus().connect(SYSTEM_ACTIVE_USER_DBUS, SYSTEM_ACTIVE_USER_PATH, SYSTEM_ACTIVE_USER_INTERFACE, "ActiveUserChange", this,SIGNAL(activeUserChangedSignal(QString))); QDBusConnection::sessionBus().connect(MEDIA_BATTERY_SERVICE, MEDIA_BATTERY_PATH, MEDIA_BATTERY_INTERFACE, "batteryChanged", this, SLOT(devBatteryChangedSignalSlot(QString, int))); QDBusConnection::sessionBus().connect("org.ukui.ScreenSaver", "/", "org.ukui.ScreenSaver", "lock", this, SLOT(lockSlot())); QDBusConnection::sessionBus().connect("org.ukui.ScreenSaver", "/", "org.ukui.ScreenSaver", "unlock", this, SLOT(unlockSlot())); KyDebug(); } bool BluetoothDbus::registerClient() { QMap rcParam; rcParam.insert("dbusid", QVariant(QDBusConnection::systemBus().baseService())); rcParam.insert("username", QVariant(userName)); rcParam.insert("type", QVariant(1)); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("registerClient"); dbusMsg << rcParam; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { rcParam = response.arguments().takeFirst().toMap(); envPC = rcParam.value("envPC").toInt(); return rcParam.value("result").toBool(); } else return false; } bool BluetoothDbus::unregisterClient() { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("unregisterClient"); dbusMsg << QDBusConnection::systemBus().baseService(); QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } void BluetoothDbus::updateClientSLot() { InitAdaptersAttr(); InitDefaultAdapterDevicesAttr(); registerClient(); } void BluetoothDbus::adapterAttrChanged(QString address, QMap mapAttr) { QMap insertAttr; KyDebug() << mapAttr; if (adapterList->contains(address)) insertAttr = adapterList->value(address); if (mapAttr.contains("DefaultAdapter") && insertAttr.contains("DefaultAdapter")){ if (mapAttr.value("DefaultAdapter").toBool() != insertAttr.value("DefaultAdapter")) { leaveLock(lockDev, false); InitDefaultAdapterDevicesAttr(); emit defaultAdapterChanged(); } } for (auto key : mapAttr.keys()) { insertAttr.remove(key); insertAttr.insert(key, QVariant(mapAttr.value(key))); } if (adapterList->contains(address)) { adapterCnt--; adapterList->remove(address); } adapterList->insert(address, insertAttr); adapterCnt++; if(insertAttr.contains("DefaultAdapter")) if (insertAttr.value("DefaultAdapter").toBool()) defaultAdapterAttr = insertAttr; if(mapAttr.contains("ActiveConnection")) { emit adapterAutoConnChanged(mapAttr.value("ActiveConnection").toBool()); } if (mapAttr.contains("Powered")) { if (insertAttr.value("DefaultAdapter").toBool()) { bool powered = mapAttr.value("Powered").toBool(); emit powerChangedSignal(powered); if (leaveLockon) leaveLock(lockDev, powered); if (sessDbusInterface != nullptr) sessDbusInterface->emitPoweredSignal(powered); } } if (mapAttr.contains("trayShow") && insertAttr.contains("DefaultAdapter") && insertAttr.value("DefaultAdapter").toBool()) { KyDebug(); emit showTrayIcon(mapAttr.value("trayShow").toBool()); } if(mapAttr.contains("ClearPinCode")) if (mapAttr.value("ClearPinCode").toBool()) emit pairAgentCanceledSignal(QString("")); } void BluetoothDbus::setAdapterAttrInside(QString address, QMap mapAttr) { if (adapterList->contains(address)) { adapterCnt--; adapterList->remove(address); } adapterList->insert(address, mapAttr); adapterCnt++; } void BluetoothDbus::deviceAttrChanged(QString address, QMap mapAttr) { QMap insertAttr; insertAttr = devicesList->value(address); for (auto key : mapAttr.keys()) { insertAttr.remove(key); insertAttr.insert(key, QVariant(mapAttr.value(key))); } if (!mapAttr.contains("Battery") && (mapAttr.value("Type").toInt() == Type::Headset || mapAttr.value("Type").toInt() == Type::Headphones || mapAttr.value("Type").toInt() == Type::AudioVideo)) { mapAttr.insert("Battery", QVariant(getDevBatteryLevel(address))); } if (!mapAttr.contains("Battery")) mapAttr.insert("Battery", QVariant(-1)); devicesList->remove(address); devicesList->insert(address, insertAttr); if (mapAttr.contains("Paired")) emit pairAgentCanceledSignal(address); if (mapAttr.contains("Connecting") && !mapAttr.value("Connecting").toBool()) emit pairAgentCanceledSignal(address); if (insertAttr.value("Paired").toBool()) { pairedList->insert(address, insertAttr); if (sessDbusInterface != nullptr) sessDbusInterface->emitPairedSignal(address, true); } if (mapAttr.contains("Connected") && insertAttr.value("Type").toInt() == Type::Phone) { KyInfo() << address << mapAttr.value("Connected").toBool(); emit sessDbusInterface->devConnectStatusSignal(address, mapAttr.value("Connected").toBool()); } if (pairedList->contains(address)) { if (mapAttr.value("Connected").toBool()) { if (m_Order.contains(address)) m_Order.removeOne(address); m_Order.push_front(address); } else if (m_Order.contains(address)) { m_Order.removeOne(address); m_Order.push_back(address); } } } void BluetoothDbus::setDeviceAttrInside(QString address, QMap mapAttr) { if (devicesList->keys().contains(address)) devicesList->remove(address); if (!mapAttr.contains("Battery") && (mapAttr.value("Type").toInt() == Type::Headset || mapAttr.value("Type").toInt() == Type::Headphones || mapAttr.value("Type").toInt() == Type::AudioVideo)) { mapAttr.insert("Battery", QVariant(getDevBatteryLevel(address))); } if (!mapAttr.contains("Battery")) mapAttr.insert("Battery", QVariant(-1)); devicesList->insert(address, mapAttr); if (mapAttr.contains("Paired") && mapAttr.value("Paired").toBool()) { pairedList->insert(address, mapAttr); if (sessDbusInterface == nullptr) return; sessDbusInterface->emitPairedSignal(address, true); } if (pairedList->contains(address)) { if (mapAttr.value("Connected").toBool()) { if (m_Order.contains(address)) m_Order.removeOne(address); m_Order.push_front(address); } else if (m_Order.contains(address)) { m_Order.removeOne(address); m_Order.push_back(address); } } } int BluetoothDbus::getDevBatteryLevel(QString address) { QDBusInterface iface(MEDIA_BATTERY_SERVICE, MEDIA_BATTERY_PATH, MEDIA_BATTERY_INTERFACE, QDBusConnection::sessionBus()); if (!iface.isValid()) return -1; else { QDBusMessage battery_response = iface.call("getBatteryLevel", address); int battery_int = battery_response.arguments().takeFirst().toInt(); if(battery_int) return battery_int; else return -1; } } void BluetoothDbus::getAdapterAttr(QString address) { QMap mapAttr; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("getAdapterAttr"); dbusMsg << address << QString(""); QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { mapAttr = QDBusReply>(response); } if (mapAttr.isEmpty()) { INFO_PRINT("Adapter" << address << "Init Error"); return; } setAdapterAttrInside(address, mapAttr); } void BluetoothDbus::InitAdaptersAttr() { QStringList adpsAddrList; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("getAllAdapterAddress"); QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { adpsAddrList = response.arguments().takeFirst().toStringList(); } if (adpsAddrList.isEmpty()) { INFO_PRINT("Adapter Address Init Error"); return; } for (int i = 0; i < adpsAddrList.size(); i++) { getAdapterAttr(adpsAddrList.at(i)); } adapterCnt = adapterList->size(); if(adapterList->size() == 1) defaultAdapterAttr = adapterList->values().at(0); else { for (auto addr : adapterList->keys()) { if (adapterList->value(addr).value("DefaultAdapter").toBool()) { defaultAdapterAttr = adapterList->value(addr); return; } } } } void BluetoothDbus::getDevAttr(QString address) { QMap mapAttr; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("getDevAttr"); dbusMsg << address; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { mapAttr = QDBusReply>(response); } if (mapAttr.isEmpty()) { INFO_PRINT("Device" << address << "Init Error"); return; } setDeviceAttrInside(address, mapAttr); } void BluetoothDbus::InitDefaultAdapterDevicesAttr() { pairedList->clear(); QStringList devsAddrList; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("getDefaultAdapterPairedDev"); QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { devsAddrList = response.arguments().takeFirst().toStringList(); } if (devsAddrList.isEmpty()) { INFO_PRINT("Adapter Address Init Error"); return; } for (int i = 0; i < devsAddrList.size(); i++) { getDevAttr(devsAddrList.at(i)); } } void BluetoothDbus::devBatteryChangedSignalSlot(QString address, int battery) { if (envPC == Environment::HUAWEI) return; if (!pairedList->keys().contains(address)) return; KyDebug() << "devBatteryChangedSignalSLot" << address << battery; QMap mapAttr = pairedList->value(address); if (mapAttr.value("Battery").toInt() != -1) return; mapAttr.remove("Battery"); mapAttr.insert("Battery", QVariant(battery)); pairedList->remove(address); pairedList->insert(address, mapAttr); emit devAttrChanged(address, pairedList->value(address)); } void BluetoothDbus::adapterAttrChangedSLot(QString address, QMap adapterAttr) { if (!adapterList->contains(address)) return; adapterAttrChanged(address, adapterAttr); } void BluetoothDbus::adapterRemoveSignalSLot(QString address) { KyDebug() << address; adapterList->remove(address); --adapterCnt; if (adapterList->isEmpty() || adapterList->size() == 0 || adapterCnt == 0) { leaveLock(lockDev, false); emit existAdapter(false, false); sessDbusInterface->adapterRemoveSignal(address); } } void BluetoothDbus::adapterAddSignalSLot(QMap adapterAttr) { KyDebug() << adapterAttr; bool trayshow = adapterAttr.value("trayShow", false).toBool(); QString address = adapterAttr.value("Addr").toString(); setAdapterAttrInside(address, adapterAttr); emit existAdapter(true, trayshow); emit adapterAddSignal(address); sessDbusInterface->emitAdapterAddSignal(address); } void BluetoothDbus::adapterChangedSLot(QString address, QMap adapterAttr) { KyDebug() << address; if (adapterAttr.value("DefaultAdapter").toBool() && defaultAdapterAttr.value("Addr").toString() != address) { InitDefaultAdapterDevicesAttr(); emit adapterChangedSignal(); sessDbusInterface->emitDefaultAdapterChangedSignal(address); } else setAdapterAttrInside(address, adapterAttr); } void BluetoothDbus::deviceAddSLot(QMap deviceAttr) { KyDebug() ; setDeviceAttrInside(deviceAttr.value("Addr").toString(), deviceAttr); } void BluetoothDbus::deviceAttrChangedSLot(QString address, QMap deviceAttr) { if (!devicesList->contains(address)) return; KyDebug() << Q_FUNC_INFO << deviceAttr << __LINE__ ; deviceAttrChanged(address, deviceAttr); if (deviceAttr.contains("Paired")) emit deviceAddSignal(pairedList->value(address)); if (deviceAttr.contains("ConnectFailedId")) { if (pairedList->value(address).value("ShowName") != "") emit connectionErrorMsg(pairedList->value(address).value("ShowName").toString(), deviceAttr.value("ConnectFailedId").toInt()); else emit connectionErrorMsg(pairedList->value(address).value("Name").toString(), deviceAttr.value("ConnectFailedId").toInt()); } emit devAttrChanged(address, pairedList->value(address)); } void BluetoothDbus::devRemoveSignalSLot(QString address, QMap attr) { if (attr.value("Adapter").toString() != defaultAdapterAttr.value("Addr").toString()) return; if (devicesList->contains(address)) devicesList->remove(address); if (!pairedList->contains(address)) return; KyDebug() ; pairedList->remove(address); if (lockDev == address) { leaveLock(address, false); lockDev = ""; setLeaveLock(lockDev, false); } if (m_Order.contains(address)) m_Order.removeOne(address); emit devRemoveSignal(address); if (sessDbusInterface == nullptr) return; sessDbusInterface->emitPairedSignal(address, false); } void BluetoothDbus::devErrorSignalSLot(QString a) { KyDebug() << "-----------------------" << a; } void BluetoothDbus::devPairSignalSLot(QMap pairAttr) { KyDebug() ; if (pairAttr.value("type").toInt()) emit displayPasskeySignal(pairAttr.value("dev").toString(), pairAttr.value("name").toString(), pairAttr.value("pincode").toString()); else emit requestConfirmationSignal(pairAttr.value("dev").toString(), pairAttr.value("name").toString(), pairAttr.value("pincode").toString()); } void BluetoothDbus::receiveFilesSlot(QMap info) { KyDebug() << Q_FUNC_INFO << info << __LINE__ ; if (!pairedList->contains(info.value("dev").toString())) return; QString name = info.value("name").toString(); QMap device = pairedList->value(info.value("dev").toString()); if (device.contains("ShowName") && device.value("ShowName").toString() != QString("")) name = device.value("ShowName").toString(); emit receiveFilesSignal(info.value("dev").toString(), name, info.value("filename").toString(), info.value("filetype").toString(), info.value("filesize").toULongLong()); } bool BluetoothDbus::sendFiles(QString address, QStringList filelist) { KyDebug() ; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("sendFiles"); dbusMsg << userName << address << filelist; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Send Succeed"); return 0; default: DEBUG_PRINT("Send Failed"); return -1; } } else { DEBUG_PRINT("Method Call Error"); return -1; } } void BluetoothDbus::cancelFileTransfer(QString address, int opt) { KyDebug() ; QMap sendMsg; sendMsg.insert("dev", QVariant(address)); sendMsg.insert("transportType", QVariant(opt)); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("stopFiles"); dbusMsg << sendMsg; QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Send Succeed"); break; default: DEBUG_PRINT("Send Failed"); } } else { DEBUG_PRINT("Method Call Error"); } } void BluetoothDbus::openBluetoothSettings() { KyDebug() ; Config::OpenBluetoothSettings(); } void BluetoothDbus::activeConnectionReply(QString dev, bool v) { KyDebug() ; Config::activeConnectionReply(dev, v); } void BluetoothDbus::pairFuncReply(QString address, bool accept) { KyDebug() << "pair with :" << address << " reply :" << accept; Config::pairFuncReply(address, accept); } void BluetoothDbus::replyFileReceiving(QString address, bool accept) { KyDebug() << QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) << QDir::homePath(); Config::replyFileReceiving(address, accept, QStandardPaths::writableLocation(QStandardPaths::DownloadLocation), QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); } void BluetoothDbus::devConnect(const QString address) { KyDebug() ; Config::devConnect(address); } void BluetoothDbus::devDisconnect(const QString address) { KyDebug() ; Config::devDisconnect(address); } void BluetoothDbus::setDefaultAdapterPower(bool power) { KyDebug() << Q_FUNC_INFO < Attr; if (power == defaultAdapterAttr.value("Powered").toBool()) return; KyDebug() << Q_FUNC_INFO <> BluetoothDbus::getSendableDevices() { KyDebug() ; QMap> ret; for (auto addr : pairedList->keys()) { if (pairedList->value(addr).value("FileTransportSupport").toBool()) { QMap inode = pairedList->value(addr); ret.insert(addr, inode); } } return ret; } bool BluetoothDbus::getDevSupportFileSend(QString address) { KyDebug() ; if (!pairedList->contains(address)) return false; return pairedList->value(address).value("FileTransportSupport").toBool();; } bool BluetoothDbus::getTrayIconShow() { KyDebug(); if (adapterList->isEmpty()) return false; return defaultAdapterAttr.value("trayShow").toBool(); } bool BluetoothDbus::getExistAdapter() { KyDebug(); return !adapterList->isEmpty(); } bool BluetoothDbus::isPowered() { KyDebug() << Q_FUNC_INFO << defaultAdapterAttr.value("Powered").toBool() << __LINE__ ; return defaultAdapterAttr.value("Powered").toBool(); } QMap> BluetoothDbus::getPairedDevices() { KyDebug() ; return *pairedList; } QStringList BluetoothDbus::getOrderList() { KyDebug() ; return m_Order; } void BluetoothDbus::pingTimeSignalSLot(QByteArray time) { if (!leaveLockon) { KyDebug() << "leave lock off"; return; } QString s_info = QString(time); KyDebug() << time; if (s_info.contains("Connection reset by peer")) { reping = true; leaveLock(lockDev, leaveLockon); return; } if (s_info.contains("loss connect") || (s_info.contains("Host is down") && reping)) { reping = false; QTimer::singleShot(60000,this, [=](){ KyDebug() << "++++++Command to lock Screen"; system("ukui-screensaver-command -l"); emit sessDbusInterface->leaveLockSuc(); }); return; } if (s_info.contains("Host is down") && !reping) { return; } QString s_time = s_info.right(9).left(6); int i_time = s_time.toDouble(); KyDebug() << s_time << i_time; if (i_time == 0) { bool removedOne = false; if (s_time.at(0) == ' ') { s_time.remove(0,1); removedOne = true; } if (s_time.at(1) == ' ') { s_time.remove(0,2); removedOne = true; } if (removedOne) { i_time = s_time.toDouble(); getPingTimeList(i_time); } } else { getPingTimeList(i_time); } } void BluetoothDbus::getPingTimeList(int i_time) { if (!leaveLockon) return; if (leaveLockCount[ leaveLockCount[PINT_TIME_COUNT] ] >= LOCK_PING_TIME) leaveLockCount[TIME_OUT_COUNT] -= 1; leaveLockCount[ leaveLockCount[PINT_TIME_COUNT] ] = i_time; leaveLockCount[PINT_TIME_COUNT] += 1; if (leaveLockCount[PINT_TIME_COUNT] == LENGTH_OF_TIME_VECTOR) leaveLockCount[PINT_TIME_COUNT] = 0; if (i_time >= LOCK_PING_TIME) leaveLockCount[TIME_OUT_COUNT] += 1; if (leaveLockCount[TIME_OUT_COUNT] >= MAX_TIME_OUT && leaveLockon) { KyDebug() << "LockScren" ; if (!timerActive) { timerActive = true; QTimer::singleShot(55000,this, [=](){ timerActive = false; if (reping) { leaveLock(lockDev, leaveLockon); } if (leaveLockCount[TIME_OUT_COUNT] >= MAX_TIME_OUT && leaveLockon) { KyDebug() << "++++++Command to lock Screen"; system("ukui-screensaver-command -l"); emit sessDbusInterface->leaveLockSuc(); } }); } } /* //DEBUG for (int i = 0; i < LENGTH_OF_ALL_VECTOR; i++) { printf("%d ", leaveLockCount[i]); } printf("\n"); */ } void BluetoothDbus::setLeaveLock(QString address, bool on) { if(leaveLockon == on) { return; } if (address == "") { leaveLockon = false; } QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).set("leave-lock", QVariant(on)); QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).set("leavelock-dev", QVariant(address)); leaveLock(address, on); } void BluetoothDbus::leaveLock(QString address, bool on) { if(address.isEmpty() && leaveLockon == on) { return; } lockDev = address; if (address == "") { leaveLockon = false; } KyDebug() << address << on ; for (int i = 0; i < LENGTH_OF_ALL_VECTOR; i++) { leaveLockCount[i] = 0; } QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("setLeaveLock"); dbusMsg << QDBusConnection::systemBus().baseService() << address<< on; QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); leaveLockon = on; sessDbusInterface->setLeaveLockOn(leaveLockon); sessDbusInterface->setLeaveLockDev(lockDev); } void BluetoothDbus::unlockSlot() { if (!leaveLockon) return; QTimer::singleShot(3000, this, [=](){ leaveLock(lockDev, true); }); } void BluetoothDbus::lockSlot() { QTimer::singleShot(3000, this, [=](){ leaveLock(lockDev, false); }); } ukui-bluetooth/ukui-bluetooth/dbus/bluetoothdbus.h0000664000175000017500000001326115167665755021463 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHDBUS_H #define BLUETOOTHDBUS_H #include #include #include #include #include #include #include #include #include #include #include #include #include "config/config.h" #include "sessiondbusinterface.h" #define LOCK_PING_TIME 70 #define LENGTH_OF_TIME_VECTOR 20 #define PINT_TIME_COUNT 20 #define TIME_OUT_COUNT 21 #define LENGTH_OF_ALL_VECTOR 22 #define MAX_TIME_OUT 10 class BluetoothDbus : public QObject { Q_OBJECT public: explicit BluetoothDbus(QObject *parent = nullptr); ~BluetoothDbus(); void setDeviceList(QStringList devicelist); void setDeviceType(QStringList typelist); public: //DBus调用函数 void InitDefaultAdapterDevicesAttr(); bool getTrayIconShow(); void setDefaultAdapterPower(bool power); void cancelFileTransfer(QString address, int opt); bool sendFiles(QString address, QStringList filelist); void openBluetoothSettings(); void devConnect(const QString address); void devDisconnect(const QString address); void activeConnectionReply(QString dev, bool v); void replyFileReceiving(QString address, bool accept); void pairFuncReply(QString address, bool accept); bool isPowered(); bool getExistAdapter(); bool getDevPairStatus(QString address); QStringList getOrderList(); QMap> getPairedDevices(); QMap> getSendableDevices(); signals: void devRemoveSignal(QString); void devAttrChanged(QString, QMap); void showTrayIcon(bool); void existAdapter(bool, bool); void adapterAddSignal(QString); void adapterRemoveSignal(QString); void adapterChangedSignal(); void adapterCanOperat(bool); void powerChangedSignal(bool); void displayPasskeySignal(QString, QString,QString); void requestConfirmationSignal(QString, QString, QString); void receiveFilesSignal(QString, QString,QString,QString,quint64); void sendTransferFilesMesgSignal(QStringList); void sendTransferDeviceMesgSignal(QString); void showTrayWidgetUISignal(); void activeConnectionSignal(QString,QString,QString,int,int); void defaultAdapterChanged(); void deviceAddSignal(QMap); void transferredChangedSignal(quint64,QString); void statusChangedSignal(QMap); void pairAgentCanceledSignal(QString); void devBatteryChangedSignal(); void activeUserChangedSignal(QString); void connectionErrorMsg(QString,int); void adapterAutoConnChanged(bool); private: int getDevBatteryLevel(QString address); void connectDBusSignals(); void addNewPairedDevice(QString address); bool registerClient(); bool unregisterClient(); /** Init adapters attr */ void InitAdaptersAttr(); void getAdapterAttr(QString address); void setAdapterAttrInside(QString address, QMap mapAttr); void adapterAttrChanged(QString address, QMap mapAttr); /** Init devices attr of default adapter */ void getDevAttr(QString address); void setDeviceAttrInside(QString address, QMap mapAttr); void deviceAttrChanged(QString address, QMap mapAttr); void leaveLock(QString address, bool on); void setLeaveLock(QString address, bool on); void getPingTimeList(int i_time); SessionDbusInterface *sessDbusInterface = nullptr; int leaveLockCount[LENGTH_OF_ALL_VECTOR] = {0}; int adapterCnt = 0; bool leaveLockon = false; bool passWrongSignal = false; bool timerActive = false; bool reping = false; QString userName; QStringList m_Order; QString lockDev; QGSettings *gsetting; QMap defaultAdapterAttr; QMap> *devicesList; QMap> *pairedList; QMap> *adapterList; private slots: void adapterAddSignalSLot(QMap adapterAttr); void adapterChangedSLot(QString address, QMap adapterAttr); void adapterAttrChangedSLot(QString address, QMap adapterAttr); void updateClientSLot(); void deviceAddSLot(QMap deviceAttr); void deviceAttrChangedSLot(QString address, QMap deviceAttr); void devRemoveSignalSLot(QString address, QMap attr); void devBatteryChangedSignalSlot(QString address, int battery); void adapterRemoveSignalSLot(QString address); void receiveFilesSlot(QMap info); void devPairSignalSLot(QMap pairAttr); bool getDevSupportFileSend(QString address); void devErrorSignalSLot(QString); void pingTimeSignalSLot(QByteArray); void unlockSlot(); void lockSlot(); }; #endif // BLUETOOTHDBUS_H ukui-bluetooth/ukui-bluetooth/dbus/sessiondbusinterface.h0000664000175000017500000001516715167665770023026 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef SESSIONDBUSINTERFACE_H #define SESSIONDBUSINTERFACE_H #include #include #include #include #include #include #include #include #include #include "config/config.h" class SessionDbusInterface : public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.ukui.bluetooth") public: SessionDbusInterface(QMap *_adapterAttr, QMap > *_adapterList, QMap > *_deviceList, QObject *parent = nullptr); void emitPairedSignal(QString address, bool paired); void emitPoweredSignal(bool powered); void setLeaveLockOn(bool leaveLock); void setLeaveLockDev(QString lockdev); void emitAdapterRemoveSignal(QString address); void emitAdapterAddSignal(QString address); void emitDefaultAdapterChangedSignal(QString address); private: void ConnectSystemDbusSignal(); bool InterfaceAlreadyExists(); QStringList sessionDbusListNames(); void controlMprisPlayerDbus(const QString funcName); void initMprisMediaDbusConnect(); bool isLeaveLock = false; QString leaveLockDev; QMap *adapterAttr = nullptr; QMap> *adapterList = nullptr; QMap> *deviceList = nullptr; public slots: bool registerClient(QString, QString, int, quint64); bool unregisterClient(QString); bool getBluetoothBlock(); QString getDefaultAdapterAddress(); bool getDefaultAdapterPower(); bool getDefaultAdapterScanStatus(); bool getDefaultAdapterDiscoverable(); QString getAdapterNameByAddr(QString); QStringList getDefaultAdapterPairedDevAddress(); QStringList getDefaultAdapterTrustedDevAddress(); QStringList getDefaultAdapterCacheDevAddress(); QStringList getAdapterDevAddressList(); void setDefaultAdapterPower(bool); void setDefaultAdapterScanOn(bool); void setDefaultAdapter(QString); void setDefaultAdapterDiscoverable(bool); /** Disabled in newer version */ void setBluetoothBlock(bool); void setDefaultAdapterName(QString); void clearNonViableDevice(QStringList); void devPair(const QString); void devConnect(const QString); void devDisconnect(const QString); void devRemove(const QString); void devTrust(const QString,const bool); bool getDevPairStatus(const QString); bool getDevConnectStatus(const QString); QString getDevName(const QString); QString getDevType(const QString); void clearAllUnPairedDevicelist(); void setSendTransferDeviceMesg(QString); void setSendTransferFileMesg(QStringList files); void setclearOldSession(); void continueSendFiles(QString filename); void cancelFileReceiving(); int getDevBattery(const QString); bool getDevSupportFileSend(const QString address); int getDevRssi(const QString); void sendFiles(QString,QString); void exit(); void sendNotifyMessage(QString); void openBluetoothSettings(); void connectSignal(); void showTrayWidgetUI(); bool getTransferDevAndStatus(QString dev); void sendContinueRecieveFilesSignal(); void sendReplyRequestConfirmation(bool); void sendReplyFileReceivingSignal(bool v); void sendCloseSession(); void activeConnectionReply(QString dev, bool v); void showCloseBluetoothInfoDialog(void); void showActiveConnectDialog(void); //leavelock method bool getLeaveLock(); QString getLeaveLockDev(); void setLeaveLock(QString, bool); QStringList getPairedPhoneAddr(); bool getLeaveLockPower(void); void setLeaveLockPower(bool); private slots: // 操作多媒体影音 void VolumeDownSlot(); void VolumeUpSlot(); void NextSlot(); void PlayPauseSlot(); void PreviousSlot(); void StopSlot(); void PlaySlot(); void PauseSlot(); signals: void defaultAdapterPowerChanged(bool); void defaultAdapterChanged(QString); void defaultScanStatusChanged(bool); void defaultDiscoverableChanged(bool); void adapterAddSignal(QString); void adapterRemoveSignal(QString); void defaultAdapterNameChanged(QString); void deviceScanResult(QString,QString,QString,bool,qint16); void devPairSignal(QString,bool); void devTypeChangedSignal(QString,QString); void devBatteryChangedSignal(QString, QString); void devNameChangedSignal(QString,QString); void devConnectStatusSignal(QString,bool); void devRemoveSignal(QString); void devLaunchConnecting(QString); void devOperateErrorSignal(QString,int,QString); void devMacAddressChangedSignal(QString,QString); void devRssiChangedSignal(QString,qint16); void sendFile(QString,QString); void continueSendFilesSignal(QString); void displayPasskey(QString,QString); void requestConfirmation(QString,QString); void replyRequestConfirmation(bool); void transferredChanged(quint64,QString); void statusChanged(QString,QString,QString); void fileReceivingSignal(QString,QString,QString,QString,quint64); void replyFileReceivingSignal(bool); void continueRecieveFilesSignal(); void closeSessionSignal(); void pairAgentCanceled(); void obexAgentCanceled(); void propertyChanged(quint64); void sendTransferDeviceMesg(QString); void sendTransferFilesMesg(QStringList); void clearOldSession(); void cancelFileReceivingSignal(); void showTrayWidgetUISignal(); void initTransferPath(QString, bool); void powerProgress(bool); void clearBluetoothDev(QStringList); void ActiveConnection(QString, QString, QString, int, int); void setLeaveLockSignal(QString, bool); void leaveLockSuc(void); }; #endif // SESSIONDBUSINTERFACE_H ukui-bluetooth/ukui-bluetooth/translations/0000775000175000017500000000000015167665770020205 5ustar fengfengukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_kk.ts0000664000175000017500000005704415167665770024234 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection كۅك چىشقا ۇلوو Bluetooth Connections كۅك چىشقا ۇلوو Found audio device " ياڭراتقۇئۈسكۈنىسىنى بايقوو ", connect it or not? جالعايسٸزبا؟ No prompt كۇشىنەن قالدىرۋ Connect جالعانۋ Cancel كۇشىنەن قالدىرۋ BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " حۇجاتتى جٸبەرۋ and مەنەن Bluetooth File كوك تىس حۇجاتى Bytes بايت files more بٸر حۇجات Select Device اسبابٸن تالداۋ OK ماقۇل Cancel كۇشىنەن قالدىرۋ The selected file is larger than 4GB, which is not supported transfer! حۇجاتتىڭ قىسىمى 4 G دان ىس كەتتى، جولداعالى بولمايدى Transferred ' حۇجات ' and جالپٸسٸ ساقتاۋ files in all to ' بٸر حۇجات جولدانىپ قالدى File Transfer Success! حۇجاتتى جولداۋ جەڭىسكە جەتۋ قالدى File Transmission Failed ! 文件发送失败! Warning ەسكەرتۋ The selected file is empty, please select the file again ! نۇ حۇجات قۇرعاق، قايتادان تالدا File Transmition Succeed! 文件发送成功! Close تاقاۋ File Transmission Succeed! حۇجاتتى جولاۋ جەڭىسكە جەتۋ قالدى File Transfer Fail! حۇجاتتى جولداۋ جەڭىلىپ قالدى ' to ' عا Transferring file ' حۇجات جولداۋ ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth كۆكچىش Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message كۆكچىش ۇچۇرۇ Please confirm if the device ' اسبابٸن كەسٸم جاساۋ The number of connected Bluetooth audio devices has reached the upper limit. جالعانعان كۆكچىش دووش ئۈسكۈنىلىرىنىڭ سانى ەڭ جوعورۇ چەككە جەتى . Only two Bluetooth audio devices can be connected simultaneously. بىر ەلە ۇباقىتتا جالاڭ عانا ەكى كۆكچىش دووش جابدۇۇسۇن ۇلاعالى بولوت . Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. سەگنال بۇركەلگەن كولەم شتىمە ەمەسپە؟ ياكي كوك تىس رولدارٸ ئوچۇقمۇ ەمەسپە؟ Connection Time Out! جالعانۋ ۋاقىتى ىس كەتتى FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File كوك تىس حۇجاتى File from " حۇجات كەل " ", waiting for receive... ", قابىلداۋ ورىنداۋدى ساقتاپ جاتىر ", waiting for receive. ", قابىلداۋ ورىنداۋدى ساقتاپ جاتىر Greater than 4GB 该文件大于4GB Cancel كۇشىنەن قالدىرۋ Accept قابىلداۋ ەتۋ View كورىنۋ ", is receiving... (has recieved ",正在接收… (已接收 files) حۇجات) ", is receiving... ", بولسو قوبۇللىنىۋاتىدۇ File Receive Failed! حۇجات قابىلداۋ ەتۋ جەڭىلىس قالدى ' from ' ' تىن ' Receiving file ' 接收文件 " ", is receiving... (has received ", قابىلداۋ ورىندالىپ جاتىر … (قابىلداۋ قىلىندى ' Receive file ' قابىلداۋ ەتۋ ' OK ماقۇل ", received failed ! ", قابىلداۋ ەتۋ جەڭىلىس قالدى File Transmission Failed ! حۇجات جولداۋ جەڭىلىپ قالدى! Bytes بايت KyFileDialog Bluetooth File كوك تىس حۇجاتى MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing كوك تىس مەنەن جۇپتەش The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' نۇ PIN مەنەن ۇقساس. جالعاپ بەرۋدٸ باس If ' قيسٸق ' Refuse رەت ەتۋ Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed كوك تىس ورنالاسٸۋٸ جەڭىلىپ قالدى Close تاقاۋ Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ٷستٸندەگٸ PIN مەنەن نۇ PIN ۇقساس. جالعاۋدى باس. Bluetooth Connection كۅك چىشقا ۇلوو If the PIN on ' قيسٸق PIN اشلسا Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: كوك تىس اسپابىنىڭ %1 گە تومەندەگٸ PIN بەلگىنى كىرگىزىڭىز، سونان Enter كىنوپكاسىن باسٸپ جۇپتەش: Confirm كەسٸم جاساۋ Connect جالعانۋ Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message كۆكچىش ۇچۇرۇ SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item كوك تىس تاللانمىىسنى بەلگٸلەۋ Bluetooth كۆكچىش TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth كۆكچىش Turn Off ئۈچۈرۋەت Cancel كۇشىنەن قالدىرۋ Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? كۆكچىش ماۇس كۅرۉنۉشتۅرۉ كۇنۇپكا تاقتاسىن ىشتەتىپ، كۆكچىشنى ئېتىۋەتمەكچىمۇ؟ ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_ar.ts0000664000175000017500000005405615167665770024231 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Bluetooth Connections Found audio device " ", connect it or not? No prompt Connect Cancel BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " and Bluetooth File Bytes files more Select Device OK Cancel The selected file is larger than 4GB, which is not supported transfer! Transferred ' ' and files in all to ' File Transfer Success! File Transmission Failed ! 文件发送失败! Warning The selected file is empty, please select the file again ! File Transmition Succeed! 文件发送成功! Close File Transmission Succeed! File Transfer Fail! ' to ' Transferring file ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message Please confirm if the device ' The number of connected Bluetooth audio devices has reached the upper limit. Only two Bluetooth audio devices can be connected simultaneously. Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. Connection Time Out! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File File from " ", waiting for receive... ", waiting for receive. Greater than 4GB 该文件大于4GB Cancel Accept View ", is receiving... (has recieved ",正在接收… (已接收 files) ", is receiving... File Receive Failed! ' from ' Receiving file ' 接收文件 " ", is receiving... (has received ' Receive file ' OK ", received failed ! File Transmission Failed ! Bytes KyFileDialog Bluetooth File MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' If ' Refuse Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed Close Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. Bluetooth Connection If the PIN on ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Confirm Connect Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Bluetooth TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth Turn Off Cancel Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_zh_HK.ts0000664000175000017500000005406515167665770024632 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection 藍牙連接 Bluetooth Connections 藍牙連接 Found audio device " 找到音訊設備 ” ", connect it or not? “,連接還是不連接? No prompt 無提示 Connect 連接 Cancel 取消 BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " 轉接至” and Bluetooth File 藍牙檔 Bytes 位元組 files more 檔 更多 Select Device 選擇設備 OK 還行 Cancel 取消 The selected file is larger than 4GB, which is not supported transfer! 所選檔大於 4GB,不支援傳輸! Transferred ' 已轉移 ' ' and ' 和 files in all to ' 檔案全部設定為 ' File Transfer Success! 檔傳輸成功! File Transmission Failed ! 文件发送失败! Warning 警告 The selected file is empty, please select the file again ! 選取檔案為空,請再次選擇該檔案! File Transmition Succeed! 文件发送成功! Close 關閉 File Transmission Succeed! 檔傳輸成功! File Transfer Fail! 檔案傳輸失敗! ' to ' ' 到 ' Transferring file ' 傳輸檔案 ' ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth 藍牙 Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message 藍牙消息 Please confirm if the device ' 請確認裝置是否 ' The number of connected Bluetooth audio devices has reached the upper limit. 已連接的藍牙音訊設備數量已達到上限。 Only two Bluetooth audio devices can be connected simultaneously. 只能同時連接兩個藍牙音訊設備。 Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. ' 在信號範圍內或藍牙已啟用。 Connection Time Out! 連接超時! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File 藍牙檔 File from " 檔案來自 ” ", waiting for receive... “,等待接收...... ", waiting for receive. “,等待接收。 Greater than 4GB 该文件大于4GB Cancel 取消 Accept 接受 View 視圖 ", is receiving... (has recieved ",正在接收… (已接收 files) 檔案) ", is receiving... “,正在接收...... File Receive Failed! 檔案接收失敗! ' from ' ' 來自 ' Receiving file ' 接收文件 " ", is receiving... (has received “,正在接收......(已收到 ' ' Receive file ' 接收檔案 ' OK 還行 ", received failed ! “,接收失敗! File Transmission Failed ! 檔案傳輸失敗 。 Bytes 位元組 KyFileDialog Bluetooth File 藍牙檔 MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing 藍牙配對 The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' ' 與此 PIN 相同。請按“連接” If ' 如果 ' Refuse 拒絕 Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed 藍牙連接失敗 Close 關閉 Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ' 上的 PIN 與此 PIN 相同。請按「連接」。 Bluetooth Connection 藍牙連接 If the PIN on ' 如果 PIN 在 ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: 請在藍牙設備「%1」 上輸入以下 PIN 碼,然後按 Enter 鍵進行配對: Confirm 確認 Connect 連接 Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message 藍牙消息 SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item 設置藍牙項 Bluetooth 藍牙 TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth 藍牙 Turn Off 關閉 Cancel 取消 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 使用藍牙滑鼠或鍵盤,是否要關閉藍牙? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_zh_Hant.ts0000664000175000017500000005406515167665770025222 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection 藍牙連接 Bluetooth Connections 藍牙連接 Found audio device " 找到音訊設備 ” ", connect it or not? “,連接還是不連接? No prompt 無提示 Connect 連接 Cancel 取消 BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " 轉接至” and Bluetooth File 藍牙檔 Bytes 位元組 files more 檔 更多 Select Device 選擇設備 OK 還行 Cancel 取消 The selected file is larger than 4GB, which is not supported transfer! 所選檔大於 4GB,不支援傳輸! Transferred ' 已轉移 ' ' and ' 和 files in all to ' 檔案全部設定為 ' File Transfer Success! 檔傳輸成功! File Transmission Failed ! 文件发送失败! Warning 警告 The selected file is empty, please select the file again ! 選取檔案為空,請再次選擇該檔案! File Transmition Succeed! 文件发送成功! Close 關閉 File Transmission Succeed! 檔傳輸成功! File Transfer Fail! 檔案傳輸失敗! ' to ' ' 到 ' Transferring file ' 傳輸檔案 ' ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth 藍牙 Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message 藍牙消息 Please confirm if the device ' 請確認裝置是否 ' The number of connected Bluetooth audio devices has reached the upper limit. 已連接的藍牙音訊設備數量已達到上限。 Only two Bluetooth audio devices can be connected simultaneously. 只能同時連接兩個藍牙音訊設備。 Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. ' 在信號範圍內或藍牙已啟用。 Connection Time Out! 連接超時! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File 藍牙檔 File from " 檔案來自 ” ", waiting for receive... “,等待接收...... ", waiting for receive. “,等待接收。 Greater than 4GB 该文件大于4GB Cancel 取消 Accept 接受 View 視圖 ", is receiving... (has recieved ",正在接收… (已接收 files) 檔案) ", is receiving... “,正在接收...... File Receive Failed! 檔案接收失敗! ' from ' ' 來自 ' Receiving file ' 接收文件 " ", is receiving... (has received “,正在接收......(已收到 ' ' Receive file ' 接收檔案 ' OK 還行 ", received failed ! “,接收失敗! File Transmission Failed ! 檔案傳輸失敗 。 Bytes 位元組 KyFileDialog Bluetooth File 藍牙檔 MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing 藍牙配對 The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' ' 與此 PIN 相同。請按“連接” If ' 如果 ' Refuse 拒絕 Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed 藍牙連接失敗 Close 關閉 Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ' 上的 PIN 與此 PIN 相同。請按「連接」。 Bluetooth Connection 藍牙連接 If the PIN on ' 如果 PIN 在 ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: 請在藍牙設備「%1」 上輸入以下 PIN 碼,然後按 Enter 鍵進行配對: Confirm 確認 Connect 連接 Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message 藍牙消息 SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item 設置藍牙項 Bluetooth 藍牙 TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth 藍牙 Turn Off 關閉 Cancel 取消 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 使用藍牙滑鼠或鍵盤,是否要關閉藍牙? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_es.ts0000664000175000017500000005360715167665770024237 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Conexión Bluetooth Bluetooth Connections Conexiones Bluetooth Found audio device " Dispositivo de audio encontrado " ", connect it or not? ", ¿conectarlo o no? No prompt Connect Conectar Cancel Cancelar BluetoothFileTransferWidget Bluetooth file transfer Transferencia de archivos por Bluetooth Transferring to " Transferencia a " and y Bluetooth File Archivo Bluetooth files more archivos más Select Device Seleccionar dispositivo OK De acuerdo Cancel Cancelar File Transfer Fail! The selected file is larger than 4GB, which is not supported transfer! Bytes File Transmission Succeed! Transferred ' ' and files in all to ' ' File Transfer Success! Transferring file ' ' to ' File Transmission Failed ! ¡Error en la transmisión de archivos! Warning Advertencia The selected file is empty, please select the file again ! El archivo seleccionado está vacío, ¡selecciónelo de nuevo! File Transmition Succeed! ¡La transmisión de archivos se realiza correctamente! Close Cerrar BluetoothSettingLabel Bluetooth Settings Configuración de Bluetooth Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Bluetooth Message Mensaje Bluetooth Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device No hay ningún dispositivo disponible actualmente Por favor, vaya a emparejar el dispositivo ErrorMessageWidget Bluetooth Message Mensaje Bluetooth Please confirm if the device ' ' is in the signal range or the Bluetooth is enabled. Connection Time Out! The number of connected Bluetooth audio devices has reached the upper limit. Only two Bluetooth audio devices can be connected simultaneously. FileReceivingPopupWidget Bluetooth file transfer Transferencia de archivos por Bluetooth Bluetooth File Archivo Bluetooth File from " Archivo de " ", waiting for receive... ", a la espera de recibir... ", waiting for receive. ", a la espera de recibir. Cancel Cancelar Accept Aceptar View Vista ", is receiving... (has recieved ", está recibiendo... (ha recibido ", is receiving... (has received files) archivos) ", is receiving... ", está recibiendo... File Receive Failed! Receive file ' ' from ' ' OK De acuerdo ", received failed ! ", recibido falló ! File Transmission Failed ! ¡Error en la transmisión de archivos! Bytes KyFileDialog Bluetooth File Archivo Bluetooth MainProgram Warning Advertencia The selected file is empty, please select the file again ! El archivo seleccionado está vacío, ¡selecciónelo de nuevo! PinCodeWidget Bluetooth pairing Emparejamiento Bluetooth ' is the same as this PIN. Please press 'Connect' ' es el mismo que este PIN. Por favor, pulse 'Conectar' If ' Si ' Refuse Rehusar Bluetooth Connections Conexiones Bluetooth Bluetooth Connect Failed Error de conexión Bluetooth Close Cerrar Connect Failed! ¡Falló la conexión! ' the PIN on is the same as this PIN. Please press 'Connect'. ' el PIN activado es el mismo que este PIN. Por favor, pulse 'Conectar'. Bluetooth Connection Conexión Bluetooth If the PIN on ' Si el PIN en ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Ingrese el siguiente código PIN en el dispositivo bluetooth '%1' y presione enter para emparejar: Confirm Confirmar Connect Conectar Pair Par QDevItem The connection with the Bluetooth device “%1” is successful! ¡La conexión con el dispositivo Bluetooth "%1" se ha realizado correctamente! Bluetooth device “%1” disconnected! ¡Dispositivo Bluetooth "%1" desconectado! SessionDbusInterface Bluetooth Message Mensaje Bluetooth SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Establecer elemento Bluetooth Bluetooth Bluetooth TrayWidget bluetooth bluetooth Bluetooth Bluetooth My Device Mi dispositivo The connection with the Bluetooth device “%1” is successful! ¡La conexión con el dispositivo Bluetooth "%1" se ha realizado correctamente! Bluetooth device “%1” disconnected! ¡Dispositivo Bluetooth "%1" desconectado! beforeTurnOffHintWidget Bluetooth Turn Off Cancel Cancelar Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_zh_CN.ts0000664000175000017500000005410515167665770024623 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection 蓝牙连接 Bluetooth Connections 蓝牙连接 Found audio device " 发现音频设备 " ", connect it or not? " ,是否连接? No prompt 不再提示 Connect 连接 Cancel 取消 BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " 发送文件至 " and Bluetooth File 蓝牙文件 Bytes 字节 files more 个文件 Select Device 选择设备 OK 确定 Cancel 取消 The selected file is larger than 4GB, which is not supported transfer! 文件超过 4GB,不支持传输! Transferred ' 发送" ' and "等 files in all to ' 个文件到 " File Transfer Success! 文件发送成功! File Transmission Failed ! 文件发送失败! Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! File Transmition Succeed! 文件发送成功! Close 关闭 File Transmission Succeed! 文件发送成功! File Transfer Fail! 文件发送失败! ' to ' " 至 " Transferring file ' 发送文件 " ' " File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth 蓝牙 Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message 蓝牙消息 Please confirm if the device ' 请确认设备 " The number of connected Bluetooth audio devices has reached the upper limit. 蓝牙音频设备连接数量已达上限。 Only two Bluetooth audio devices can be connected simultaneously. 仅支持同时连接 2 台蓝牙音频设备。 Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. " 是否在信号范围内或蓝牙功能是否已开启。 Connection Time Out! 连接超时! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File 蓝牙文件 File from " 文件来自 " ", waiting for receive... ",等待接收… ", waiting for receive. ",等待接收。 Greater than 4GB 该文件大于4GB Cancel 取消 Accept 接收 View 查看 ", is receiving... (has recieved ",正在接收… (已接收 files) 个文件) ", is receiving... ",正在接收… File Receive Failed! 文件接收失败! ' from ' " 自 " Receiving file ' 接收文件 " ", is receiving... (has received ",正在接收… (已接收 ' " Receive file ' 接收文件 " OK 确定 ", received failed ! ",接收失败! File Transmission Failed ! 文件传输失败! Bytes 字节 KyFileDialog Bluetooth File 蓝牙文件 MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing 蓝牙设备配对 The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' ”上的数字与下面相同,请点击“连接” If ' 如果 " Refuse 取消 Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed 蓝牙连接失败 Close 关闭 Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. " 上的PIN码与此PIN码相同,请按 "连接"。 Bluetooth Connection 蓝牙连接 If the PIN on ' 如“ Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: 请在蓝牙设备 "%1" 上输入相同PIN,并按"Enter"确认: Confirm 确定 Connect 连接 Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message 蓝牙消息 SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item 设置蓝牙项 Bluetooth 蓝牙 TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth 蓝牙 Turn Off 关闭蓝牙 Cancel 取消 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 正在使用蓝牙鼠标或键盘,是否关闭蓝牙? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_fr.ts0000664000175000017500000005347015167665770024235 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Connexion Bluetooth Bluetooth Connections Connexions Bluetooth Found audio device " Périphérique audio trouvé » ", connect it or not? », le connecter ou pas ? No prompt Connect Relier Cancel Annuler BluetoothFileTransferWidget Bluetooth file transfer Transfert de fichiers Bluetooth Transferring to " Transfert vers » and et Bluetooth File Fichier Bluetooth files more Fichiers plus Select Device Sélectionnez l’appareil OK D’ACCORD Cancel Annuler File Transfer Fail! The selected file is larger than 4GB, which is not supported transfer! Bytes File Transmission Succeed! Transferred ' ' and files in all to ' ' File Transfer Success! Transferring file ' ' to ' File Transmission Failed ! Echec de la transmission du fichier ! Warning Avertissement The selected file is empty, please select the file again ! Le fichier sélectionné est vide, veuillez sélectionner à nouveau le fichier ! File Transmition Succeed! Transmission de fichiers réussie ! Close Fermer BluetoothSettingLabel Bluetooth Settings Paramètres Bluetooth Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Bluetooth Message Bluetooth Message Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device Aucun appareil n’est actuellement disponible Veuillez aller pour appairer l’appareil ErrorMessageWidget Bluetooth Message Bluetooth Message Please confirm if the device ' ' is in the signal range or the Bluetooth is enabled. Connection Time Out! The number of connected Bluetooth audio devices has reached the upper limit. Only two Bluetooth audio devices can be connected simultaneously. FileReceivingPopupWidget Bluetooth file transfer Transfert de fichiers Bluetooth Bluetooth File Fichier Bluetooth File from " Fichier de » ", waiting for receive... « , en attente de recevoir... ", waiting for receive. « , en attente de réception. Cancel Annuler Accept Accepter View Vue ", is receiving... (has recieved « , reçoit... (a reçu ", is receiving... (has received files) fichiers) ", is receiving... « , reçoit... File Receive Failed! Receive file ' ' from ' ' OK D’ACCORD ", received failed ! « , reçu a échoué ! File Transmission Failed ! Echec de la transmission du fichier ! Bytes KyFileDialog Bluetooth File Fichier Bluetooth MainProgram Warning Avertissement The selected file is empty, please select the file again ! Le fichier sélectionné est vide, veuillez sélectionner à nouveau le fichier ! PinCodeWidget Bluetooth pairing Appairage Bluetooth ' is the same as this PIN. Please press 'Connect' ' est identique à ce code PIN. Veuillez appuyer sur 'Connecter' If ' Si ' Refuse Refuser Bluetooth Connections Connexions Bluetooth Bluetooth Connect Failed Échec de la connexion Bluetooth Close Fermer Connect Failed! Echec de la connexion ! ' the PIN on is the same as this PIN. Please press 'Connect'. ' le code PIN activé est le même que ce code PIN. Veuillez appuyer sur « Connecter ». Bluetooth Connection Connexion Bluetooth If the PIN on ' Si le code PIN sur ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Veuillez saisir le code PIN suivant sur l’appareil Bluetooth '%1' et appuyez sur Entrée pour coupler : Confirm Confirmer Connect Relier Pair Paire QDevItem The connection with the Bluetooth device “%1” is successful! La connexion avec l’appareil Bluetooth « %1 » est réussie ! Bluetooth device “%1” disconnected! Appareil Bluetooth « %1 » déconnecté ! SessionDbusInterface Bluetooth Message Bluetooth Message SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Définir l’élément Bluetooth Bluetooth Bluetooth TrayWidget bluetooth Bluetooth Bluetooth Bluetooth My Device Mon appareil The connection with the Bluetooth device “%1” is successful! La connexion avec l’appareil Bluetooth « %1 » est réussie ! Bluetooth device “%1” disconnected! Appareil Bluetooth « %1 » déconnecté ! beforeTurnOffHintWidget Bluetooth Turn Off Cancel Annuler Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_mn.ts0000664000175000017500000006241515167665770024237 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection ᠯᠠᠨᠶᠠ ᠵᠢ ᠵᠠᠯᠭᠠᠪᠠ Bluetooth Connections ᠯᠠᠨᠶᠠ ᠵᠢ ᠵᠠᠯᠭᠠᠪᠠ Found audio device " ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠢ ᠢᠯᠡᠷᠡᠬᠦᠯᠪᠡ" ", connect it or not? ", ᠴᠦᠷᠬᠡᠯᠡᠬᠦ ᠤᠤ? No prompt ᠳᠠᠬᠢᠵᠤ ᠰᠠᠨᠠᠭᠤᠯᠬᠤ ᠦᠭᠡᠢ Connect ᠴᠦᠷᠬᠡᠯᠡᠬᠦ Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " ᠹᠠᠢᠯ ᠢ᠋ " ᠳ᠋ᠤ᠌/ ᠲᠤ᠌ ᠬᠦᠷᠭᠡᠬᠦ and ᠵᠡᠷᠭᠡ Bluetooth File ᠯᠠᠨᠶᠠ ᠹᠠᠢᠯ Bytes ᠪᠠᠰ files more ᠹᠠᠢᠯ Select Device ᠰᠤᠨᠭᠭᠤᠭᠰᠠᠨ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ OK ᠪᠠᠳᠤᠯᠠᠬᠤ Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ The selected file is larger than 4GB, which is not supported transfer! ᠹᠠᠢᠯ 4GB ᠡᠴᠡ ᠬᠡᠳᠦᠷᠡᠪᠡ᠂ ᠳᠠᠮᠵᠢᠭᠤᠯᠬᠤ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠥᠬᠡᠢ! Transferred ' ' ᠢ᠋\ ᠵᠢ ᠢᠯᠡᠬᠡᠬᠦ ' and ' ᠬᠦᠯᠢᠶᠡᠬᠦ files in all to ' ᠹᠠᠢᠯ ᠢ᠋ ' ᠲᠤ᠌\ ᠳ᠋ᠤ᠌ ᠬᠦᠷᠬᠡᠬᠦ File Transfer Success! ᠹᠠᠢᠯ ᠢ᠋ ᠢᠯᠡᠬᠡᠪᠡ! File Transmission Failed ! 文件发送失败! Warning ᠰᠠᠨᠠᠭᠤᠯᠬᠤ The selected file is empty, please select the file again ! ᠰᠤᠨᠭᠭᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠬᠤᠭᠤᠰᠤᠨ᠂ ᠳᠠᠬᠢᠵᠤ ᠰᠤᠨᠭᠭᠤᠭᠠᠷᠠᠢ ! File Transmition Succeed! 文件发送成功! Close ᠬᠠᠭᠠᠬᠤ File Transmission Succeed! ᠹᠠᠢᠯ ᠢ᠋ ᠢᠯᠡᠬᠡᠪᠡ! File Transfer Fail! ᠹᠠᠢᠯ ᠢ᠋ ᠢᠯᠡᠬᠡᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ! ' to ' ' ᠡᠴᠡ ' ᠲᠤ᠌\ ᠳ᠋ᠤ᠌ Transferring file ' ᠳᠠᠮᠵᠢᠭᠤᠯᠬᠤ ᠹᠠᠢᠯ ' ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth ᠯᠠᠨᠶᠠ Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠰᠤᠷᠠᠭ ᠵᠠᠩᠬᠢ Please confirm if the device ' ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠢ᠋ ᠪᠠᠳᠤᠯᠠᠭᠠᠷᠠᠢ ' The number of connected Bluetooth audio devices has reached the upper limit. ᠯᠠᠨᠶᠠ ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠳ᠋ᠤ᠌ ᠵᠠᠯᠭᠠᠬᠤ ᠲᠣᠭ᠎ᠠ ᠨᠢᠭᠡᠨᠳᠡ ᠬᠢᠵᠠᠭᠠᠷ ᠲᠤ᠌ ᠳᠤᠯᠪᠠ᠃ Only two Bluetooth audio devices can be connected simultaneously. ᠵᠥᠪᠬᠡᠨ2 ᠯᠠᠨᠶᠠ ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠳ᠋ᠤ᠌ ᠵᠡᠷᠭᠡ ᠪᠡᠷ ᠵᠠᠯᠭᠠᠬᠤ ᠵᠢ ᠳᠡᠮᠵᠢᠨ᠎ᠡ᠃ Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. ' ᠨᠢ ᠳᠣᠬᠢᠶᠠᠨ ᠤ᠋ ᠬᠡᠪᠴᠢᠶᠡᠨ ᠳᠤᠳᠤᠷ᠎ᠠ ᠪᠠᠢᠬᠤ ᠡᠰᠡᠬᠦ᠂ ᠡᠰᠡᠪᠡᠯ ᠯᠠᠨᠶᠠ ᠴᠢᠳᠠᠪᠬᠢ ᠵᠢ ᠨᠢᠬᠡᠨᠳᠡ ᠨᠡᠬᠡᠬᠡᠭᠰᠡᠨ ᠡᠰᠡᠬᠦ᠃ Connection Time Out! ᠴᠦᠷᠬᠡᠯᠡᠬᠡ ᠴᠠᠭ ᠡᠴᠡ ᠬᠡᠳᠦᠷᠡᠪᠡ! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File ᠯᠠᠨᠶᠠ ᠹᠠᠢᠯ File from " ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠢᠷᠡᠯᠳᠡ " ", waiting for receive... ", ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠬᠤ ᠵᠢ ᠬᠦᠯᠢᠶᠡᠵᠤ ᠪᠠᠢᠨ᠎ᠠ··· ", waiting for receive. ", ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠬᠤ ᠵᠢ ᠬᠦᠯᠢᠶᠡᠵᠤ ᠪᠠᠢᠨ᠎ᠠ᠃ Greater than 4GB 该文件大于4GB Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ Accept ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠬᠤ View ᠪᠠᠢᠴᠠᠭᠠᠵᠤ ᠦᠵᠡᠬᠦ ", is receiving... (has recieved ",正在接收… (已接收 files) ᠹᠠᠢᠯ) ", is receiving... ", ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠴᠤ ᠪᠠᠢᠨ᠎ᠠ··· File Receive Failed! ᠹᠠᠢᠯ ᠢ᠋ ᠬᠦᠯᠢᠶᠡᠵᠤ ᠠᠪᠤᠭᠰᠠᠨ ᠥᠬᠡᠢ! ' from ' ' ᠡᠴᠡ ' Receiving file ' 接收文件 " ", is receiving... (has received ", ᠶᠠᠭ ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠴᠤ ᠪᠠᠢᠨ᠎ᠠ···( ᠨᠢᠭᠡᠨᠳᠡ ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠤᠭᠰᠠᠨ ᠨᠢ ' ' Receive file ' ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ' OK ᠪᠠᠳᠤᠯᠠᠬᠤ ", received failed ! ", ᠬᠦᠯᠢᠶᠡᠨ ᠠᠪᠴᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ! File Transmission Failed ! ᠹᠠᠢᠯ ᠢ᠋ ᠳᠠᠮᠵᠢᠭᠤᠯᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ! Bytes ᠪᠠᠰ KyFileDialog Bluetooth File ᠯᠠᠨᠶᠠ ᠹᠠᠢᠯ MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing ᠯᠠᠨᠶᠠ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠠᠪᠴᠠᠯᠳᠤᠪᠠ The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' ' ᠳᠡᠭᠡᠷᠡᠬᠢ ᠳᠤᠭ᠎ᠠ ᠳᠤᠤᠷᠠᠬᠢ ᠲᠠᠢ ᠢᠵᠢᠯ᠂' ᠴᠦᠷᠬᠡᠯᠡᠬᠦ' ᠭᠡᠰᠡᠨ ᠢ᠋ ᠳᠠᠷᠤᠭᠠᠷᠠᠢ If ' ᠬᠡᠷᠪᠡ' Refuse ᠦᠬᠡᠢᠰᠬᠡᠬᠦ Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed ᠯᠠᠨᠶᠠ ᠵᠢ ᠵᠠᠯᠠᠭᠠᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ Close ᠬᠠᠭᠠᠬᠤ Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ' ᠳᠡᠭᠡᠷᠡᠬᠢ PIN ᠺᠤᠳ᠋ ᠡᠨᠡᠬᠦ PIN ᠺᠤᠳ᠋ ᠲᠠᠢ ᠢᠵᠢᠯ᠂' ᠴᠦᠷᠬᠡᠯᠡᠬᠦ' ᠬᠡᠰᠡᠨ ᠢ᠋ ᠳᠠᠷᠤᠭᠠᠷᠠᠢ᠃ Bluetooth Connection ᠯᠠᠨᠶᠠ ᠵᠢ ᠵᠠᠯᠭᠠᠪᠠ If the PIN on ' ᠬᠡᠷᠪᠡ ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: ᠯᠠᠨᠶᠠ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ '%1' ᠳ᠋ᠤ᠌/ ᠲᠤ᠌ ᠢᠵᠢᠯ PIN ᠤᠷᠤᠭᠤᠯᠵᠤ᠂enter ᠢ᠋/ ᠵᠢ ᠳᠠᠷᠤᠵᠤ ᠪᠠᠳᠤᠯᠠᠭᠠᠷᠠᠢ: Confirm ᠪᠠᠳᠤᠯᠠᠬᠤ Connect ᠴᠦᠷᠬᠡᠯᠡᠬᠦ Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠰᠤᠷᠠᠭ ᠵᠠᠩᠬᠢ SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠳᠦᠷᠦᠯ ᠢ᠋ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠬᠤ Bluetooth ᠯᠠᠨᠶᠠ TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth ᠯᠠᠨᠶᠠ Turn Off ᠯᠠᠨᠶᠠ ᠵᠢ ᠬᠠᠭᠠᠬᠤ Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ᠤᠳᠤ ᠶᠠᠭ ᠯᠠᠨᠶᠠ ᠬᠤᠯᠤᠭᠠᠨᠴᠢᠷ ᠪᠤᠶᠤ ᠳᠠᠷᠤᠭᠤᠯ ᠤ᠋ᠨ ᠳᠠᠪᠠᠭ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠵᠤ ᠪᠠᠢᠨ᠎ᠠ᠂ ᠯᠠᠨᠶᠠ ᠵᠢ ᠬᠠᠭᠠᠬᠤ ᠤᠤ? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_bo_CN.ts0000664000175000017500000006356215167665770024611 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection ཁ་དོག་སྔོན་པོའི་འབྲེལ་མཐུད། Bluetooth Connections ཁ་དོག་སྔོན་པོའི་འབྲེལ་མཐུད། Found audio device " སྒྲ་ཕབ་སྒྲིག་ཆས་རྙེད་པ"ཞེས་བཤད། ", connect it or not? "དེ་དང་འབྲེལ་བ་ཡོད་དམ་མེད། No prompt དྲན་སྐུལ་མི་བྱེད། Connect སྦྲེལ་མཐུད་བྱེད་པ Cancel མེད་པར་བཟོ་དགོས BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " བརྒྱུད་གཏོང་བྱེད་བཞིན་པ། and དེ་བཞིན་དེ་བཞིན་ Bluetooth File ཁ་དོག་སྔོན་པོའི་ཡིག་ཆ། Bytes Bytes files more ཡིག་ཆ་དེ་བས་མང་ Select Device སྒྲིག་ཆས་བདམས་པ། OK འགྲིགས། Cancel མེད་པར་བཟོ་དགོས The selected file is larger than 4GB, which is not supported transfer! ཡིག་ཆ་4GBལས་བརྒལ།བརྒྱུད་གཏོང་ལ་རྒྱབ་སྐྱོར་མི་བྱེད། Transferred ' སྤོ་སྒྱུར་' ' and ' ཞི་བདེ། files in all to ' ཡིག་ཆ་ཡོངས་རྫོགས།' File Transfer Success! ཡིག་ཆ་བརྒྱུད་སྤྲོད་ལེགས་འགྲུབ་བྱུང་བ་རེད། File Transmission Failed ! 文件发送失败! Warning ཐ་ཚིག་སྒྲོག་པ། The selected file is empty, please select the file again ! བདམས་ཟིན་པའི་ཡིག་ཆ་ཚང་མ་སྟོང་བ་རེད། ཡང་བསྐྱར་ཡིག་ཆ་འདེམས་རོགས། File Transmition Succeed! 文件发送成功! Close སྒོ་རྒྱག་པ་ File Transmission Succeed! ཡིག་ཆ་བརྒྱུད་སྤྲོད་ལེགས་འགྲུབ་བྱུང་བ་རེད། File Transfer Fail! ཡིག་ཆ་བརྒྱུད་སྐྱེལ་བྱེད་པར་ཕམ་ཉེས་བྱུང་ ' to ' " ནས་ " Transferring file ' བརྒྱུད་གཏོང་ཡིག་ཆ་" ' " ། File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth སོ་སྔོན། Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message སོ་སྔོན་བརྡ་འཕྲིན། Please confirm if the device ' ཁྱེད་ཀྱི་ངོས་འཛིན་སྒྲིག་ཆས་ " The number of connected Bluetooth audio devices has reached the upper limit. སོ་སྔོན་སྒྲ་ཟློས་སྒྲིག་ཆས་མཐུད་གྲངས་ཚད་ལ་ཐོན་ཟིན Only two Bluetooth audio devices can be connected simultaneously. སོ་སྔོན་སྒྲ་ཟློས་སྒྲིག་ཆས་ 2་མཉམ་ཏུ་མཐུད་ཆོག Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. " ཡིན་མིན་བརྡ་རྟགས་ཀྱི་ཁྱབ་ཁོངས་སུ་འམ་ཡང་ན་སྔོན་པོ་སོ་ནུས་པ་ཡོད་མེད་ཕྱེ་བ། Connection Time Out! སྦྲེལ་དུས་བརྒལ། FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File ཁ་དོག་སྔོན་པོའི་ཡིག་ཆ། File from " ཡིག་ཆ་ནས་ཡོང་བ་"ཞེས་པ ", waiting for receive... ""སྣེ་ལེན་བྱེད་པར་སྒུག་ཡོད། ", waiting for receive. ""སྣེ་ལེན་བྱེད་པར་སྒུག་ཡོད། Greater than 4GB 该文件大于4GB Cancel མེད་པར་བཟོ་དགོས Accept སྡུད་ལེན། View ལྟ་ཞིབ་ ", is receiving... (has recieved ",正在接收… (已接收 files) ཡིག་ཆ)། ", is receiving... "དང་ལེན་བྱེད་བཞིན་པའི་... File Receive Failed! ཡིག་ཆ་བསྡུ་ལེན་ཕམ་ཁ། ' from ' " ནས " Receiving file ' 接收文件 " ", is receiving... (has received "དང་ལེན་བྱེད་བཞིན་པའི་... (འབྱོར་ཟིན་པ། ' " ། Receive file ' ཡིག་ཆ་ལེན་མཁན " OK འགྲིགས། ", received failed ! "ལག་ཏུ་འབྱོར་བ་ནི་ཕམ་ཁ་རེད། File Transmission Failed ! ཡིག་ཆ་བརྒྱུད་སྐྱེལ་བྱེད་པར་ཕམ་ཉེས་བྱུང་ Bytes ཡིག་ཚིགས། KyFileDialog Bluetooth File ཁ་དོག་སྔོན་པོའི་ཡིག་ཆ། MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing སོ་སྔོན་སྒྲིག་ཆས་ཆ་སྒྲིག The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' 'PIN'འདི་དང་གཅིག་པ་རེད། ཁྱེད་ཀྱིས་"སྦྲེལ་མཐུད་"བྱེད་རོགས། If ' གལ་ཏེ་'ཡིན་ན། ' Refuse དང་ལེན་མི་བྱེད་ Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed Bluetooth Connect ལ་ཕམ་ཉེས་བྱུང་བ། Close སྒོ་རྒྱག་པ་ Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ་་་་་་ ཁྱེད་ཀྱིས་"སྦྲེལ་མཐུད་"བྱེད་རོགས། Bluetooth Connection ཁ་དོག་སྔོན་པོའི་འབྲེལ་མཐུད། If the PIN on ' གལ་ཏེ་PIN'སྟེང་དུ་བཞག་ན། Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: ཁྱོད་ཀྱིས་ཁ་དོག་སྔོན་པོའི་སྒྲིག་ཆས་སྟེང་གི་གཤམ་གྱི་PIN代码'%1'ནང་འཇུག་བྱས་ནས་ཆ་སྒྲིག་གཉེན་འཚོལ་བྱེད་རོགས། Confirm གཏན་འཁེལ། Connect སྦྲེལ་མཐུད་བྱེད་པ Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message སོ་སྔོན་བརྡ་འཕྲིན། SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item ཁ་དོག་སྔོན་པོའི་རྣམ་གྲངས་གཏན་འཁེལ་བྱ་དགོས། Bluetooth སོ་སྔོན། TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth སོ་སྔོན། Turn Off སོ་སྔོན་ཁ་རྒྱག་པ། Cancel མེད་པར་བཟོ་དགོས Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? སོ་སྔོན། ཀྱི་ཙི་ཙ/ཀียབཌའ ལག་ལེན་བྱེད་སྐབས། ཁྱེད་ སོ་སྔོན། བཀག་བྱེད་འདོད་དམ།? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_ug.ts0000664000175000017500000005717715167665770024251 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection كۆك چىشقا ئۇلاش Bluetooth Connections كۆك چىشقا ئۇلاش Found audio device " ياڭراتقۇئۈسكۈنىسىنى بايقاش ", connect it or not? ئۇلامسىز؟ No prompt ئەمەلدىن قالدۇرۇش Connect ئۇلىنىش Cancel ئەمەلدىن قالدۇرۇش BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " ھۆججەتنى ئەۋەتىش and بىلەن Bluetooth File كۆك چىش ھۆججىتى Bytes بايت files more بىر ھۆججەت Select Device ئۈسكۈنىنى تاللاش OK جەزملەشتۈرۈش Cancel ئەمەلدىن قالدۇرۇش The selected file is larger than 4GB, which is not supported transfer! ھۆججەتنىڭ سىغىمى 4 G دىن ئىشىپ كەتتى، يوللىغىلى بولمايدۇ Transferred ' ھۆججەت ' and ئومۇمىسىنى ساقلاش files in all to ' بىر ھۆججەت يوللىنىپ بولدى File Transfer Success! ھۆججەتنى يوللاش مۇۋەپپىقىيەتلىك بولدى File Transmission Failed ! 文件发送失败! Warning ئاگاھلانددۇرۇش The selected file is empty, please select the file again ! بۇ ھۆججەت قۇرۇق، قايتىدىن تاللاڭ File Transmition Succeed! 文件发送成功! Close تاقاش File Transmission Succeed! ھۆججەتنى يولاش مۇۋەپپىقىيەتلىك بولدى File Transfer Fail! ھۆججەتنى يوللاش مەغلۇپ بولدى ' to ' غا Transferring file ' ھۆججەت يوللاش ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth كۆكچىش Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message كۆكچىش ئۇچۇرى Please confirm if the device ' ئۈسكۈنىنى جەزىملەشتۈرۈڭ The number of connected Bluetooth audio devices has reached the upper limit. ئۇلانغان كۆكچىش ئاۋاز ئۈسكۈنىلىرىنىڭ سانى ئەڭ يۇقىرى چەككە يەتتى. Only two Bluetooth audio devices can be connected simultaneously. بىرلا ۋاقىتتا پەقەت ئىككى كۆكچىش ئاۋاز ئۈسكۈنىسىنى ئۇلىغىلى بولىدۇ. Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. سىگنال قاپلىغان دائىرە ئىچىدىمۇ ئەمەسمۇ؟ ياكى كۆك چىش ئىقتىدارى ئوچۇقمۇ ئەمەسمۇ؟ Connection Time Out! ئۇلىنىش ۋاقتى ئىشىپ كەتتى FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File كۆك چىش ھۆججىتى File from " ھۆججەت كەلگەن " ", waiting for receive... ", قوبۇل قىلىشنى ساقلاۋاتىدۇ ", waiting for receive. ", قوبۇل قىلىشنى ساقلاۋاتىدۇ Greater than 4GB 该文件大于4GB Cancel ئەمەلدىن قالدۇرۇش Accept قوبۇل قىلىش View كۆرۈش ", is receiving... (has recieved ",正在接收… (已接收 files) ھۆججەت) ", is receiving... ", بولسا قوبۇللىنىۋاتىدۇ File Receive Failed! ھۆججەت قوبۇل قىلىش مەغلۇب بولدى ' from ' ' تىن ' Receiving file ' 接收文件 " ", is receiving... (has received ", قوبۇل قىلىنىۋاتىدۇ … (قوبۇل قىلىندى ' ' Receive file ' قوبۇل قىلىش ' OK جەزملەشتۈرۈش ", received failed ! ", قوبۇل قىلىش مەغلۇب بولدى File Transmission Failed ! ھۆججەت يوللاش مەغلۇپ بولدى! Bytes بايت KyFileDialog Bluetooth File كۆك چىش ھۆججىتى MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing كۆك چىش بىلەن جۈپلەش The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' بۇ PIN بىلەن ئوخشاش. ئۇلاپ بېرىشنى بېسىڭ If ' ئەگەر ' Refuse رەت قىلىش Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed كۆك چىش ئۇلىنىشى مەغلۇپ بولدى Close تاقاش Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ئۈستىدىكى PIN بىلەن بۇ PIN ئوخشاش. ئۇلاشنى بېسىڭ. Bluetooth Connection كۆك چىشقا ئۇلاش If the PIN on ' ئەگەر PIN ئېچىلسا Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: كۆك چىش ئۈسكۈنىسىنىڭ %1 گە تۆۋەندىكى PIN كودىنى كىرگۈزۈڭ، ئاندىن Enter كۇنۇپكىسىنى بېسىپ جۈپلەش: Confirm جەزملەشتۈرۈش Connect ئۇلىنىش Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message كۆكچىش ئۇچۇرى SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item كۆك چىش تاللانمىىسنى بەلگىلەش Bluetooth كۆكچىش TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth كۆكچىش Turn Off ئۈچۈرۋەت Cancel ئەمەلدىن قالدۇرۇش Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? كۆكچىش مائۇس ياكى كۇنۇپكا تاختىسىنى ئىشلىتىپ، كۆكچىشنى ئېتىۋەتمەكچىمۇ؟ ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_de.ts0000664000175000017500000005345615167665770024222 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Bluetooth-Verbindung Bluetooth Connections Bluetooth-Verbindungen Found audio device " Gefundenes Audiogerät " ", connect it or not? ", anschließen oder nicht? No prompt Connect Verbinden Cancel Abbrechen BluetoothFileTransferWidget Bluetooth file transfer Bluetooth-Dateiübertragung Transferring to " Übertragen auf " and und Bluetooth File Bluetooth-Datei files more Dateien mehr Select Device Gerät auswählen OK OKAY Cancel Abbrechen File Transfer Fail! The selected file is larger than 4GB, which is not supported transfer! Bytes File Transmission Succeed! Transferred ' ' and files in all to ' ' File Transfer Success! Transferring file ' ' to ' File Transmission Failed ! Dateiübertragung fehlgeschlagen ! Warning Warnung The selected file is empty, please select the file again ! Die ausgewählte Datei ist leer, bitte wählen Sie die Datei erneut aus ! File Transmition Succeed! Dateiübertragung erfolgreich! Close Schließen BluetoothSettingLabel Bluetooth Settings Bluetooth-Einstellungen Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Bluetooth Message Bluetooth-Nachricht Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device Derzeit kein Gerät verfügbar Bitte gehen Sie, um das Gerät zu koppeln ErrorMessageWidget Bluetooth Message Bluetooth-Nachricht Please confirm if the device ' ' is in the signal range or the Bluetooth is enabled. Connection Time Out! The number of connected Bluetooth audio devices has reached the upper limit. Only two Bluetooth audio devices can be connected simultaneously. FileReceivingPopupWidget Bluetooth file transfer Bluetooth-Dateiübertragung Bluetooth File Bluetooth-Datei File from " Datei von " ", waiting for receive... ", warten auf den Empfang... ", waiting for receive. ", warten auf den Empfang. Cancel Abbrechen Accept Annehmen View Ansehen ", is receiving... (has recieved ", erhält... (hat ", is receiving... (has received files) Dateien) ", is receiving... ", erhält... File Receive Failed! Receive file ' ' from ' ' OK OKAY ", received failed ! ", erhalten fehlgeschlagen ! File Transmission Failed ! Dateiübertragung fehlgeschlagen ! Bytes KyFileDialog Bluetooth File Bluetooth-Datei MainProgram Warning Warnung The selected file is empty, please select the file again ! Die ausgewählte Datei ist leer, bitte wählen Sie die Datei erneut aus ! PinCodeWidget Bluetooth pairing Bluetooth-Kopplung ' is the same as this PIN. Please press 'Connect' ' ist identisch mit dieser PIN. Bitte klicken Sie auf "Verbinden" If ' Wenn ' Refuse Verweigern Bluetooth Connections Bluetooth-Verbindungen Bluetooth Connect Failed Bluetooth-Verbindung fehlgeschlagen Close Schließen Connect Failed! Verbindung fehlgeschlagen! ' the PIN on is the same as this PIN. Please press 'Connect'. ' Die PIN auf ist die gleiche wie diese PIN. Bitte klicken Sie auf "Verbinden". Bluetooth Connection Bluetooth-Verbindung If the PIN on ' Wenn die PIN auf ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Bitte geben Sie den folgenden PIN-Code auf dem Bluetooth-Gerät '%1' ein und drücken Sie die Eingabetaste, um ihn zu koppeln: Confirm Bestätigen Connect Verbinden Pair Paar QDevItem The connection with the Bluetooth device “%1” is successful! Die Verbindung mit dem Bluetooth-Gerät "%1" ist erfolgreich! Bluetooth device “%1” disconnected! Bluetooth-Gerät "%1" getrennt! SessionDbusInterface Bluetooth Message Bluetooth-Nachricht SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Bluetooth-Element festlegen Bluetooth Bluetooth TrayWidget bluetooth Bluetooth Bluetooth Bluetooth My Device Mein Gerät The connection with the Bluetooth device “%1” is successful! Die Verbindung mit dem Bluetooth-Gerät "%1" ist erfolgreich! Bluetooth device “%1” disconnected! Bluetooth-Gerät "%1" getrennt! beforeTurnOffHintWidget Bluetooth Turn Off Cancel Abbrechen Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_vi.ts0000664000175000017500000005511615167665770024243 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Kết nối Bluetooth Bluetooth Connections Kết nối Bluetooth Found audio device " Tìm thấy thiết bị âm thanh " ", connect it or not? ", kết nối nó hay không? No prompt Không nhắc nhở Connect Kết nối Cancel Hủy BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " Chuyển sang " and Bluetooth File Tệp Bluetooth Bytes Byte files more X tệp Select Device Chọn thiết bị OK Chắc chắc Cancel Hủy The selected file is larger than 4GB, which is not supported transfer! Tệp tin vượt quá 4GB, không hỗ trợ truyền tải! Transferred ' Chuyển nhượng ' ' and ' và files in all to ' tệp trong tất cả thành ' File Transfer Success! Truyền tệp thành công! File Transmission Failed ! 文件发送失败! Warning Sao lưu và phục hồi The selected file is empty, please select the file again ! 所选文件为空,请重新选择! File Transmition Succeed! 文件发送成功! Close Thoát File Transmission Succeed! Truyền tệp thành công! File Transfer Fail! Truyền tệp không thành công! ' to ' ' đến ' Transferring file ' Chuyển tệp ' ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message 蓝牙消息 Please confirm if the device ' Vui lòng xác nhận nếu thiết bị ' The number of connected Bluetooth audio devices has reached the upper limit. Số lượng thiết bị âm thanh Bluetooth được kết nối đã đạt đến giới hạn trên. Only two Bluetooth audio devices can be connected simultaneously. Chỉ có thể kết nối đồng thời hai thiết bị âm thanh Bluetooth. Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. ' nằm trong phạm vi tín hiệu hoặc Bluetooth được bật. Connection Time Out! Hết thời gian kết nối! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File Tệp Bluetooth File from " Tập tin từ " ", waiting for receive... ", chờ nhận... ", waiting for receive. ", chờ nhận. Greater than 4GB 该文件大于4GB Cancel Hủy Accept Chấp nhận View Xem ", is receiving... (has recieved ",正在接收… (已接收 files) tệp) ", is receiving... ", đang nhận... File Receive Failed! Nhận tệp không thành công! ' from ' ' từ ' Receiving file ' 接收文件 " ", is receiving... (has received ", đang nhận... (đã nhận được ' ' Receive file ' Nhận tập tin ' OK OK ", received failed ! ", nhận không thành công! File Transmission Failed ! 文件发送失败! Bytes Byte KyFileDialog Bluetooth File Tệp Bluetooth MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing Ghép nối Bluetooth The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' ' giống như mã PIN này. Vui lòng nhấn 'Kết nối' If ' Nếu ' Refuse Từ chối Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed Kết nối Bluetooth không thành công Close Thoát Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ' mã PIN trên giống với mã PIN này. Vui lòng nhấn 'Kết nối'. Bluetooth Connection Kết nối Bluetooth If the PIN on ' Nếu mã PIN trên ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Vui lòng nhập mã PIN sau trên thiết bị bluetooth '%1' và nhấn enter để ghép nối: Confirm Xác nhận Connect Kết nối Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message 蓝牙消息 SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Đặt mục Bluetooth Bluetooth Bluetooth TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth Bluetooth Turn Off Tắt Cancel Hủy Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Sử dụng chuột hoặc bàn phím Bluetooth, Bạn có muốn tắt bluetooth không? ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_ky.ts0000664000175000017500000005732515167665770024254 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection كۅك چىشقا ۇلوو Bluetooth Connections كۅك چىشقا ۇلوو Found audio device " ياڭراتقۇئۈسكۈنىسىنى بايقوو ", connect it or not? ۇلايسىزبى؟ No prompt ارعادان قالتىرىش Connect ۇلانۇۇ Cancel ارعادان قالتىرىش BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " ۅجۅتۉن جىبەرىش and مەنەن Bluetooth File كۅك تىش ۅجۅتۉۉ Bytes بايت files more بىر ۅجۅت Select Device اسپاپتى تانداش OK بەكىتۉۉ Cancel ارعادان قالتىرىش The selected file is larger than 4GB, which is not supported transfer! ۅجۅتتۉن كۅلۅمۉ 4 G نان اشىپ كەتتى، جىبەرگەلى بولبويت Transferred ' ۅجۅت ' and ئومۇمىسىنى ساقتوو files in all to ' بىر ۅجۅت جولدونۇپ بولدۇ File Transfer Success! ۅجۅتۉن جولدوو جەڭىشتۉۉ بولدۇ File Transmission Failed ! 文件发送失败! Warning ەسكەرتۉۉ The selected file is empty, please select the file again ! بۇل ۅجۅت كۅڭدۅي، قايتادان تانداڭ File Transmition Succeed! 文件发送成功! Close بەكىتىش File Transmission Succeed! ۅجۅتۉن جولدوو جەڭىشتۉۉ بولدۇ File Transfer Fail! ۅجۅتۉن جولدوو جەڭىلۉۉ بولدۇ ' to ' عا Transferring file ' ۅجۅت جولدوو ' " File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth كۆكچىش Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message كۆكچىش ۇچۇرۇ Please confirm if the device ' اسپاپتى بەكىتىڭ The number of connected Bluetooth audio devices has reached the upper limit. جالعانعان كۆكچىش دووش ئۈسكۈنىلىرىنىڭ سانى ەڭ جوعورۇ چەككە جەتى . Only two Bluetooth audio devices can be connected simultaneously. بىر ەلە ۇباقىتتا جالاڭ عانا ەكى كۆكچىش دووش جابدۇۇسۇن ۇلاعالى بولوت . Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. سەگنال قاپلىغان گۅۅلۅم ئىچىدىمۇ ەمەسبى؟ كۅرۉنۉشتۅرۉ كۅك تىش قۇرباتى ئوچۇقمۇ ەمەسبى؟ Connection Time Out! ۇلانۇۇ ۇباقتى اشىپ كەتتى FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File كۅك تىش ۅجۅتۉۉ File from " ۅجۅت گەلگەن " ", waiting for receive... ", قابىلدوو جاسوونۇ ساقتاپ جاتات ", waiting for receive. ", قابىلدوو جاسوونۇ ساقتاپ جاتات Greater than 4GB 该文件大于4GB Cancel ارعادان قالتىرىش Accept قابىلدوو جاسوو ،اتقارۇۇ View كۅرۉنۉش ", is receiving... (has recieved ",正在接收… (已接收 files) ۅجۅت) ", is receiving... ", بولسو قوبۇللىنىۋاتىدۇ File Receive Failed! ۅجۅت قابىلدوو جاسوو ،اتقارۇۇ جەڭىلۉۉ بولدۇ ' from ' ' تىن ' Receiving file ' 接收文件 " ", is receiving... (has received ", قابىلدوو قىلىنىپ جاتات … ( قابىلدوو اتقارىلدى ' " Receive file ' قابىلدوو جاسوو ،اتقارۇۇ ' OK بەكىتۉۉ ", received failed ! ", قابىلدوو جاسوو ،اتقارۇۇ جەڭىلۉۉ بولدۇ File Transmission Failed ! ۅجۅت جولدوو جەڭىلۉۉ بولدۇ ! Bytes بايت KyFileDialog Bluetooth File كۅك تىش ۅجۅتۉۉ MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing كۅك تىش مەنەن جۈپلەش The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' بۇل PIN مەنەن وقشوش . جالعاپ بارىشتى باسىڭ If ' ەگەر ' Refuse قاتار جاسوو ،اتقارۇۇ Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed كۅك تىش ۇلانۇۇسۇ جەڭىلۉۉ بولدۇ Close بەكىتىش Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. ۉستۉندۆكۉ PIN مەنەن بۇل PIN وقشوش . جالعاشتى باسىڭ. Bluetooth Connection كۅك چىشقا ۇلوو If the PIN on ' ەگەر PIN ئېچىلسا Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: كۅك تىش شايمانىنىن %1 گە تۅمۅندۅكۉ PIN قۇپۇيا نومۇرۇن كىرگىزىڭ، اندان Enter كۇنۇپكاسىن باسىپ جۈپلەش: Confirm جەزىملەشتۈرمەك Connect ۇلانۇۇ Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message كۆكچىش ۇچۇرۇ SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item كۅك تىش تاللانمىىسنى بەلگىلۅۅ Bluetooth كۆكچىش TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth كۆكچىش Turn Off ئۈچۈرۋەت Cancel ارعادان قالتىرىش Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? كۆكچىش ماۇس كۅرۉنۉشتۅرۉ كۇنۇپكا تاقتاسىن ىشتەتىپ، كۆكچىشنى ئېتىۋەتمەكچىمۇ؟ ukui-bluetooth/ukui-bluetooth/translations/ukui-bluetooth_ms.ts0000664000175000017500000005405615167665770024246 0ustar fengfeng ActiveConnectionWidget Bluetooth Connection Bluetooth Connections Found audio device " ", connect it or not? No prompt Connect Cancel BluetoothFileTransferWidget Bluetooth file transfer 蓝牙文件 Transferring to " and Bluetooth File Bytes files more Select Device OK Cancel The selected file is larger than 4GB, which is not supported transfer! Transferred ' ' and files in all to ' File Transfer Success! File Transmission Failed ! 文件发送失败! Warning The selected file is empty, please select the file again ! File Transmition Succeed! 文件发送成功! Close File Transmission Succeed! File Transfer Fail! ' to ' Transferring file ' ' File Transmission Failed! 文件发送失败! BluetoothSettingLabel Bluetooth Settings 蓝牙设置 Config ukui-bluetooth 蓝牙 Bluetooth Bluetooth Message 蓝牙消息 Bluetooth message 蓝牙消息 DeviceSeleterWidget No device currently available Please go to pair the device 当前没有可用的设备 请去配对设备 ErrorMessageWidget Bluetooth Message Please confirm if the device ' The number of connected Bluetooth audio devices has reached the upper limit. Only two Bluetooth audio devices can be connected simultaneously. Bluetooth File 蓝牙文件 ' is in the signal range or the Bluetooth is enabled. Connection Time Out! FileReceivingPopupWidget Bluetooth file transfer 蓝牙文件传输 Bluetooth File File from " ", waiting for receive... ", waiting for receive. Greater than 4GB 该文件大于4GB Cancel Accept View ", is receiving... (has recieved ",正在接收… (已接收 files) ", is receiving... File Receive Failed! ' from ' Receiving file ' 接收文件 " ", is receiving... (has received ' Receive file ' OK ", received failed ! File Transmission Failed ! Bytes KyFileDialog Bluetooth File MainProgram Warning 提示 The selected file is empty, please select the file again ! 所选文件为空,请重新选择! PinCodeWidget Bluetooth pairing The pairing with the Bluetooth device “%1” is failed! 与蓝牙设备“%1”配对失败! ' is the same as this PIN. Please press 'Connect' If ' Refuse Bluetooth Connections 蓝牙连接 Bluetooth Connect Failed Close Connect Failed! 连接失败! ' the PIN on is the same as this PIN. Please press 'Connect'. Bluetooth Connection If the PIN on ' Please enter the following PIN code on the bluetooth device '%1' and press enter to pair: Confirm Connect Pair 配对 QDevItem The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! SessionDbusInterface Bluetooth Message SwitchAction Bluetooth 蓝牙 TrayIcon Set Bluetooth Item Bluetooth TrayWidget bluetooth 蓝牙 Bluetooth 蓝牙 My Device 我的设备 The connection with the Bluetooth device “%1” is successful! 与蓝牙设备“%1”连接成功! Bluetooth device “%1” disconnected! 蓝牙设备“%1”失去连接! beforeTurnOffHintWidget Bluetooth Turn Off Cancel Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ukui-bluetooth/ukui-bluetooth/config/0000775000175000017500000000000015167665770016731 5ustar fengfengukui-bluetooth/ukui-bluetooth/config/config.h0000664000175000017500000002744215167665770020360 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef CONFIG_H #define CONFIG_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "windowmanager/windowmanager.h" #define INFO_PRINT(info) qInfo() << Q_FUNC_INFO << info << "in line :" << __LINE__ #define DEBUG_PRINT(info) qInfo() << Q_FUNC_INFO << info << "in line :" << __LINE__ #define PANEL_SETTINGS "org.ukui.panel.settings" #define PANEL_SIZE_KEY "panelsize" #define PANEL_POSITION_KEY "panelposition" #define PANEL_TYPE_KEY "paneltype" #define PANEL_LENGTH_KEY "panellength" #define PANEL_DATAISLANDPOSITION_KEY "dataislandposition" #define PANEL_SETTINGSISLANDPOSITION_KEY "settingsislandposition" #define MEDIA_SOUND_SERVICE "org.ukui.sound.theme.player" #define MEDIA_SOUND_PATH "/org/ukui/sound/theme/player" #define MEDIA_SOUND_INTERFACE MEDIA_SOUND_SERVICE #define MEDIA_BATTERY_SERVICE "org.ukui.media" #define MEDIA_BATTERY_PATH "/org/ukui/media/bluetooth" #define MEDIA_BATTERY_INTERFACE MEDIA_BATTERY_SERVICE #define SYSTEMD_SERVICE "com.ukui.bluetooth" #define SYSTEMD_PATH "/com/ukui/bluetooth" #define SYSTEMD_INTERFACE SYSTEMD_SERVICE #define SESSION_SERVICE "com.ukui.bluetooth" #define SESSION_PATH "/com/ukui/bluetooth" #define SESSION_INTERFACE SESSION_SERVICE #define SYSTEM_ACTIVE_USER_DBUS SYSTEMD_SERVICE #define SYSTEM_ACTIVE_USER_PATH SYSTEMD_PATH #define SYSTEM_ACTIVE_USER_INTERFACE SYSTEMD_INTERFACE //org.freedesktop.DBus #define SESSION_DBUS_FREEDESKTOP_SERVICE "org.freedesktop.DBus" #define SESSION_DBUS_FREEDESKTOP_PATH "/org/freedesktop/DBus" #define SESSION_DBUS_FREEDESKTOP_INTERFACE "org.freedesktop.DBus" //音视频session dbus #define SESSION_DBUS_NAME_STR_FIELD "org.mpris.MediaPlayer2" #define SESSION_DBUS_PLAYER_PATH "/org/mpris/MediaPlayer2" #define SESSION_DBUS_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player" #define GSETTING_SCHEMA_UKUIBLUETOOH "org.ukui.bluetooth" #define GSETTING_SCHEMA_UKCC "org.ukui.control-center.plugins" #define GSETTING_PACH_UKCC "/org/ukui/control-center/plugins/Bluetooth/" #define SESSION_DBUS_CONNECT QDBusConnection::sessionBus().connect #define SYSTEM_DBUS_CONNECT QDBusConnection::systemBus().connect #define CONNECT_DBUS_SIGNAL(signame, func) \ SESSION_DBUS_CONNECT(SESSION_SERVICE, \ SESSION_PATH, \ SESSION_INTERFACE, \ signame, \ this,\ SLOT(func)) #define TRANSFER_DBUS_SIGNAL(signame, func) \ SESSION_DBUS_CONNECT(SESSION_SERVICE, \ SESSION_PATH, \ SESSION_INTERFACE, \ signame, \ this,\ SIGNAL(func)) #define CREATE_METHOD_CALL(funcName) \ QDBusMessage::createMethodCall(SESSION_SERVICE, \ SESSION_PATH, \ SESSION_INTERFACE, \ funcName) #define CONNECT_SYSTEM_DBUS_SIGNAL(signame, func) \ SYSTEM_DBUS_CONNECT(SYSTEMD_SERVICE, \ SYSTEMD_PATH, \ SYSTEMD_INTERFACE, \ signame, \ this,\ SLOT(func)) #define TRANSFER_SYSTEM_DBUS_SIGNAL(signame, func) \ SYSTEM_DBUS_CONNECT(SYSTEMD_SERVICE, \ SYSTEMD_PATH, \ SYSTEMD_INTERFACE, \ signame, \ this,\ SIGNAL(func)) #define CREATE_SYSTEM_METHOD_CALL(funcName) \ QDBusMessage::createMethodCall(SYSTEMD_SERVICE, \ SYSTEMD_PATH, \ SYSTEMD_INTERFACE, \ funcName) #define CALL_METHOD(dbusmsg) QDBusConnection::sessionBus().call(dbusmsg); #define SYSTEM_CALL_METHOD(dbusmsg) QDBusConnection::systemBus().call(dbusmsg); enum Environment { NOMAL = 0, HUAWEI, LAIKA, MAVIS }; extern int envPC; typedef enum Status { /** Indicates that the transfer is queued. */ Queued, /** Indicates that the transfer is active. */ Active, /** Indicates that the transfer is suspended. */ Suspended, /** Indicates that the transfer have completed successfully. */ Complete, /** Indicates that the transfer have failed with error. */ Error, /** Indicates that the transfer status is unknown. */ Unknown, /** Indicates that the transfer status is static. */ Static = 0xff } SendStatus; enum Type { /** The device is a phone. */ Phone = 0, /** The device is a modem. */ Modem, /** The device is a computer. */ Computer, /** The device is a network. */ Network, /** The device is a headset. */ Headset, /** The device is a headphones. */ Headphones, /** The device is an uncategorized audio video device. */ AudioVideo, /** The device is a keyboard. */ Keyboard, /** The device is a mouse. */ Mouse, /** The device is a joypad. */ Joypad, /** The device is a graphics tablet (input device). */ Tablet, /** The deivce is an uncategorized peripheral device. */ Peripheral, /** The device is a camera. */ Camera, /** The device is a printer. */ Printer, /** The device is an uncategorized imaging device. */ Imaging, /** The device is a wearable device. */ Wearable, /** The device is a toy. */ Toy, /** The device is a health device. */ Health, /** The device is not of any of the known types. */ Uncategorized }; enum ConnectionErrMsg { ERR_BREDR_CONN_SUC, ERR_BREDR_CONN_ALREADY_CONNECTED = 1, ERR_BREDR_CONN_PAGE_TIMEOUT, ERR_BREDR_CONN_PROFILE_UNAVAILABLE, ERR_BREDR_CONN_SDP_SEARCH, ERR_BREDR_CONN_CREATE_SOCKET, ERR_BREDR_CONN_INVALID_ARGUMENTS, ERR_BREDR_CONN_ADAPTER_NOT_POWERED, ERR_BREDR_CONN_NOT_SUPPORTED, ERR_BREDR_CONN_BAD_SOCKET, ERR_BREDR_CONN_MEMORY_ALLOC, ERR_BREDR_CONN_BUSY, ERR_BREDR_CONN_CNCR_CONNECT_LIMIT, ERR_BREDR_CONN_TIMEOUT, ERR_BREDR_CONN_REFUSED, ERR_BREDR_CONN_ABORT_BY_REMOTE, ERR_BREDR_CONN_ABORT_BY_LOCAL, ERR_BREDR_CONN_LMP_PROTO_ERROR, ERR_BREDR_CONN_CANCELED, ERR_BREDR_CONN_UNKNOWN, //////////////////////////////////////////// ERR_LE_CONN_INVALID_ARGUMENTS = 20, ERR_LE_CONN_ADAPTER_NOT_POWERED, ERR_LE_CONN_NOT_SUPPORTED, ERR_LE_CONN_ALREADY_CONNECTED, ERR_LE_CONN_BAD_SOCKET, ERR_LE_CONN_MEMORY_ALLOC, ERR_LE_CONN_BUSY, ERR_LE_CONN_REFUSED, ERR_LE_CONN_CREATE_SOCKET, ERR_LE_CONN_TIMEOUT, ERR_LE_CONN_SYNC_CONNECT_LIMIT, ERR_LE_CONN_ABORT_BY_REMOTE, ERR_LE_CONN_ABORT_BY_LOCAL, ERR_LE_CONN_LL_PROTO_ERROR, ERR_LE_CONN_GATT_BROWSE, ERR_LE_CONN_UNKNOWN, //////////////////////////////////////////////////// ERR_BREDR_Invalid_Arguments = 36, ERR_BREDR_Operation_Progress, ERR_BREDR_Already_Exists, ERR_BREDR_Operation_Not_Supported, ERR_BREDR_Already_Connected, ERR_BREDR_Operation_Not_Available, ERR_BREDR_Does_Not_Exist, ERR_BREDR_Does_Not_Connected, ERR_BREDR_Does_In_Progress, ERR_BREDR_Operation_Not_Authorized, ERR_BREDR_No_Such_Adapter, ERR_BREDR_Agent_Not_Available, ERR_BREDR_Resource_Not_Ready, /************上面错误码为bluez返回错误码****************/ ERR_BREDR_Bluezqt_DidNot_ReceiveReply, ///////////////////////////////////////////////// ERR_BREDR_INTERNAL_NO_Default_Adapter, ERR_BREDR_INTERNAL_Operation_Progress, ERR_BREDR_INTERNAL_Already_Connected, ERR_BREDR_INTERNAL_Dev_Not_Exist, ERR_BREDR_INTERNAL_AUDIO_MAXNUM, ERR_BREDR_UNKNOWN_Other, }; enum PanelPosition{ Bottom = 0, //!< The bottom side of the screen. Top, //!< The top side of the screen. Left, //!< The left side of the screen. Right //!< The right side of the screen. }; struct struct_pos { struct_pos() {} struct_pos(int _x, int _y, int _width, int _high){ x = _x; y = _y; width = _width; high = _high; } int x = 0; int y = 0; int width = 0; int high = 0; }; class Config : public QObject { Q_OBJECT public: enum PixmapColor { WHITE = 0, BLACK, GRAY, BLUE, }; Q_ENUM(PixmapColor) Config(QObject *parent = nullptr,QString name = GSETTING_SCHEMA_UKUIBLUETOOH); ~Config(); static int pairFuncReply(QString, bool); static int replyFileReceiving(QString, bool, QString, QString); static int activeConnectionReply(QString, bool); static int devConnect(QString); static int devDisconnect(QString); static int devRemove(QString, QString); static bool setDefaultAdapterAttr(QMap adpAttr); static bool getLeaveLockPower(void); static void setLeaveLockPower(bool); static void soundWarning(); static void soundComplete(); static void SendNotifyMessage(QString title, QString, QString soundeffects); static void OpenBluetoothSettings(); static void CommandToOpenBluetoothSettings(); static void AppManagerToOpenBluetoothSettings(); static const QPixmap loadSvg(const QPixmap &source, const PixmapColor &color); static void setKdkGeometry(QWindow *windowHandle, int width, int height, bool center); static void setKdkGeometry(QWindow *windowHandle, int width, int height, int panelPosition, int panelSize, bool center); static struct_pos getKdkGeometry(int width, int height, bool center); static struct_pos getWidgetPos(int ax, int ay, int aw, int ah, int width); static int setSlideWindow(QWidget * window); static void setSkipTaskBar(QWidget * window); static void setWindowState(QWidget * window); private: QString setting_name; QGSettings *gsetting = nullptr; friend class MainProgram; friend class TrayWidget; }; #endif // CONFIG_H ukui-bluetooth/ukui-bluetooth/config/xatom-helper.cpp0000664000175000017500000001410515167665770022043 0ustar fengfeng/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * 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 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #include "xatom-helper.h" #include //#include #include #include #include #include static XAtomHelper *global_instance = nullptr; XAtomHelper *XAtomHelper::getInstance() { if (!global_instance) global_instance = new XAtomHelper; return global_instance; } bool XAtomHelper::isFrameLessWindow(int winId) { auto hints = getInstance()->getWindowMotifHint(winId); if (hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) { return true; } return false; } bool XAtomHelper::isWindowDecorateBorderOnly(int winId) { return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId)); } bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint) { bool isDeco = false; if (hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) { if (hint.decorations == MWM_DECOR_BORDER) isDeco = true; } return isDeco; } bool XAtomHelper::isUKUICsdSupported() { // fixme: return false; } bool XAtomHelper::isUKUIDecorationWindow(int winId) { if (m_ukuiDecorationAtion == None) return false; Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; bool isUKUIDecoration = false; /* XGetWindowProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, 0, LONG_MAX, false, m_ukuiDecorationAtion, &type, &format, &nitems, &bytes_after, &data); if (type == m_ukuiDecorationAtion) { if (nitems == 1) { isUKUIDecoration = data[0]; } } */ return isUKUIDecoration; } UnityCorners XAtomHelper::getWindowBorderRadius(int winId) { UnityCorners corners; /* Atom type; int format; ulong nitems; ulong bytes_after; uchar *data; if (m_unityBorderRadiusAtom != None) { XGetWindowProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, 0, LONG_MAX, false, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &data); if (type == XA_CARDINAL) { if (nitems == 4) { corners.topLeft = static_cast(data[0]); corners.topRight = static_cast(data[1*sizeof (ulong)]); corners.bottomLeft = static_cast(data[2*sizeof (ulong)]); corners.bottomRight = static_cast(data[3*sizeof (ulong)]); } XFree(data); } }*/ return corners; } void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight}; //XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, // 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight) { if (m_unityBorderRadiusAtom == None) return; ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight}; //XChangeProperty(QX11Info::display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL, // 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0])); } void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set) { if (m_ukuiDecorationAtion == None) return; //XChangeProperty(QX11Info::display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1); } void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints) { if (m_unityBorderRadiusAtom == None) return; //XChangeProperty(QX11Info::display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom, // 32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof (MotifWmHints)/ sizeof (ulong)); } MotifWmHints XAtomHelper::getWindowMotifHint(int winId) { MotifWmHints hints; /* if (m_unityBorderRadiusAtom == None) return hints; uchar *data; Atom type; int format; ulong nitems; ulong bytes_after; XGetWindowProperty(QX11Info::display(), winId, m_motifWMHintsAtom, 0, sizeof (MotifWmHints)/sizeof (long), false, AnyPropertyType, &type, &format, &nitems, &bytes_after, &data); if (type == None) { return hints; } else { hints = *(MotifWmHints *)data; XFree(data); }*/ return hints; } XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent) { /* if (!QX11Info::isPlatformX11()) return; m_motifWMHintsAtom = XInternAtom(QX11Info::display(), "_MOTIF_WM_HINTS", true); m_unityBorderRadiusAtom = XInternAtom(QX11Info::display(), "_UNITY_GTK_BORDER_RADIUS", false); m_ukuiDecorationAtion = XInternAtom(QX11Info::display(), "_KWIN_UKUI_DECORAION", false);*/ } Atom XAtomHelper::registerUKUICsdNetWmSupportAtom() { // fixme: return None; } void XAtomHelper::unregisterUKUICsdNetWmSupportAtom() { // fixme: } ukui-bluetooth/ukui-bluetooth/config/xatom-helper.h0000664000175000017500000000626715167665755021525 0ustar fengfeng/* * KWin Style UKUI * * Copyright (C) 2020, KylinSoft Co., Ltd. * * 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 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: Yue Lan * */ #ifndef XATOMHELPER_H #define XATOMHELPER_H #include //#include //#include struct UnityCorners { ulong topLeft = 0; ulong topRight = 0; ulong bottomLeft = 0; ulong bottomRight = 0; }; typedef struct { ulong flags = 0; ulong functions = 0; ulong decorations = 0; long input_mode = 0; ulong status = 0; } MotifWmHints, MwmHints; #define MWM_HINTS_FUNCTIONS (1L << 0) #define MWM_HINTS_DECORATIONS (1L << 1) #define MWM_HINTS_INPUT_MODE (1L << 2) #define MWM_HINTS_STATUS (1L << 3) #define MWM_FUNC_ALL (1L << 0) #define MWM_FUNC_RESIZE (1L << 1) #define MWM_FUNC_MOVE (1L << 2) #define MWM_FUNC_MINIMIZE (1L << 3) #define MWM_FUNC_MAXIMIZE (1L << 4) #define MWM_FUNC_CLOSE (1L << 5) #define MWM_DECOR_ALL (1L << 0) #define MWM_DECOR_BORDER (1L << 1) #define MWM_DECOR_RESIZEH (1L << 2) #define MWM_DECOR_TITLE (1L << 3) #define MWM_DECOR_MENU (1L << 4) #define MWM_DECOR_MINIMIZE (1L << 5) #define MWM_DECOR_MAXIMIZE (1L << 6) #define MWM_INPUT_MODELESS 0 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 #define MWM_INPUT_SYSTEM_MODAL 2 #define MWM_INPUT_FULL_APPLICATION_MODAL 3 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL #define MWM_TEAROFF_WINDOW (1L<<0) namespace UKUI { class Decoration; } class XAtomHelper : public QObject { friend class UKUI::Decoration; Q_OBJECT public: static XAtomHelper *getInstance(); static bool isFrameLessWindow(int winId); bool isWindowDecorateBorderOnly(int winId); bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint); bool isUKUICsdSupported(); bool isUKUIDecorationWindow(int winId); UnityCorners getWindowBorderRadius(int winId); void setWindowBorderRadius(int winId, const UnityCorners &data); void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight); void setUKUIDecoraiontHint(int winId, bool set = true); void setWindowMotifHint(int winId, const MotifWmHints &hints); MotifWmHints getWindowMotifHint(int winId); private: explicit XAtomHelper(QObject *parent = nullptr); ulong registerUKUICsdNetWmSupportAtom(); void unregisterUKUICsdNetWmSupportAtom(); ulong m_motifWMHintsAtom = 0l; ulong m_unityBorderRadiusAtom = 0l; ulong m_ukuiDecorationAtion = 0l; }; #endif // XATOMHELPER_H ukui-bluetooth/ukui-bluetooth/config/config.cpp0000664000175000017500000005146015167665770020710 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "config.h" #include #include #include #if defined(__has_include) && __has_include("ukuiwindowhelper.h") #include #define UKUIWINDOWHELPER #else class UkuiWindowHelper; #endif static QGSettings *static_panelGSettings = nullptr; int envPC = 0; bool global_rightToleft = false; //全局变量,判定机型架构 Config::Config(QObject *parent, QString name) :QObject(parent) ,setting_name(name) { if (QGSettings::isSchemaInstalled(setting_name.toUtf8())) { gsetting = new QGSettings(setting_name.toUtf8()); } } Config::~Config() { delete gsetting; } void Config::SendNotifyMessage(QString title, QString message, QString soundeffects) { QDBusInterface iface("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QList args; QMap vmap; vmap.insert("sound-name", QVariant(soundeffects)); args< 0) { switch (cgColor) { case PixmapColor::WHITE: color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); break; case PixmapColor::BLACK: color.setRed(0); color.setGreen(0); color.setBlue(0); img.setPixelColor(x, y, color); break; case PixmapColor::GRAY: color.setRed(152); color.setGreen(163); color.setBlue(164); img.setPixelColor(x, y, color); break; case PixmapColor::BLUE: color.setRed(61); color.setGreen(107); color.setBlue(229); img.setPixelColor(x, y, color); break; default: return source; break; } } } } return QPixmap::fromImage(img); } void Config::setKdkGeometry(QWindow *windowHandle, int width, int height, bool center) { if (nullptr == windowHandle) { KyWarning() << "null windowHandle"; return; } int panelPosition = 0; int panelSize = 46; if ( nullptr == static_panelGSettings) { const QByteArray id(PANEL_SETTINGS); if (QGSettings::isSchemaInstalled(id)) { if (nullptr == static_panelGSettings) { static_panelGSettings = new QGSettings(id); } } } if (static_panelGSettings->keys().contains(PANEL_POSITION_KEY)) { panelPosition = static_panelGSettings->get(PANEL_POSITION_KEY).toInt(); KyDebug() << "panelPosition: " << panelPosition; } if (static_panelGSettings->keys().contains(PANEL_SIZE_KEY)) { panelSize = static_panelGSettings->get(PANEL_SIZE_KEY).toInt(); KyDebug() << "panelSize: " << panelSize; } setKdkGeometry(windowHandle, width, height, panelPosition, panelSize, center); } void Config::setKdkGeometry(QWindow *windowHandle, int width, int height, int panelPosition, int panelSize, bool center) { if (nullptr == windowHandle) { KyWarning() << "null windowHandle"; return; } QScreen * qscreen = QGuiApplication::screenAt(QCursor::pos()); if (nullptr == qscreen) { KyWarning() << "null qscreen"; return; } QRect availableGeo = qscreen->geometry(); int x, y; int margin = 8; if (center) { x = (availableGeo.width() - width) / 2; y = (availableGeo.height() - height) / 2; if (windowHandle) { windowHandle->setGeometry(QRect(x, y, width, height)); } return; } switch (panelPosition) { case PanelPosition::Top: x = availableGeo.x() + availableGeo.width() - width - margin; y = availableGeo.y() + panelSize + margin; if (global_rightToleft) x = availableGeo.x() + availableGeo.width() - x - width; break; case PanelPosition::Bottom: x = availableGeo.x() + availableGeo.width() - width - margin; y = availableGeo.y() + availableGeo.height() - panelSize - height - margin; if (global_rightToleft) x = availableGeo.x() + availableGeo.width() - x - width; break; case PanelPosition::Left: x = availableGeo.x() + panelSize + margin; y = availableGeo.y() + availableGeo.height() - height - margin; break; case PanelPosition::Right: x = availableGeo.x() + availableGeo.width() - panelSize - width - margin; y = availableGeo.y() + availableGeo.height() - height - margin; break; } KyDebug() << "availableGeo.x: " << availableGeo.x() << ", availableGeo.width: " << availableGeo.width() << ", availableGeo.y:" << availableGeo.y() << ", availableGeo.height: " << availableGeo.height() << ", width: "<< width << ", height: " << height << ", x: "<< x << ", y: " << y << ", panelSize: " << panelSize << ", panelPosition: " << panelPosition; if (windowHandle) { windowHandle->setGeometry(QRect(x, y, width, height)); } } struct_pos Config::getKdkGeometry(int width, int height, bool center) { struct_pos pos; int panelPosition = 0; int panelSize = 46; if ( nullptr == static_panelGSettings) { const QByteArray id(PANEL_SETTINGS); if (QGSettings::isSchemaInstalled(id)) { if (nullptr == static_panelGSettings) { static_panelGSettings = new QGSettings(id); } } } if (static_panelGSettings->keys().contains(PANEL_POSITION_KEY)) { panelPosition = static_panelGSettings->get(PANEL_POSITION_KEY).toInt(); KyDebug() << "panelPosition: " << panelPosition; } if (static_panelGSettings->keys().contains(PANEL_SIZE_KEY)) { panelSize = static_panelGSettings->get(PANEL_SIZE_KEY).toInt(); KyDebug() << "panelSize: " << panelSize; } QScreen * qscreen = QGuiApplication::screenAt(QCursor::pos()); if (nullptr == qscreen) { KyWarning() << "null qscreen"; return pos; } QRect availableGeo = qscreen->geometry(); int x, y; int margin = 8; if (center) { x = (availableGeo.width() - width) / 2; y = (availableGeo.height() - height) / 2; pos.x = x; pos.y = y; return pos; } switch (panelPosition) { case PanelPosition::Top: x = availableGeo.x() + availableGeo.width() - width - margin; y = availableGeo.y() + panelSize + margin; if (global_rightToleft) x = availableGeo.x() + availableGeo.width() - x - width; break; case PanelPosition::Bottom: x = availableGeo.x() + availableGeo.width() - width - margin; y = availableGeo.y() + availableGeo.height() - panelSize - height - margin; if (global_rightToleft) x = availableGeo.x() + availableGeo.width() - x - width; break; case PanelPosition::Left: x = availableGeo.x() + panelSize + margin; y = availableGeo.y() + availableGeo.height() - height - margin; break; case PanelPosition::Right: x = availableGeo.x() + availableGeo.width() - panelSize - width - margin; y = availableGeo.y() + availableGeo.height() - height - margin; break; } pos.x = x; pos.y = y; KyDebug() << "availableGeo.x: " << availableGeo.x() << ", availableGeo.width: " << availableGeo.width() << ", availableGeo.y:" << availableGeo.y() << ", availableGeo.height: " << availableGeo.height() << ", width: "<< width << ", height: " << height << ", x: "<< x << ", y: " << y << ", panelSize: " << panelSize << ", panelPosition: " << panelPosition; return pos; } struct_pos Config::getWidgetPos(int ax, int ay, int aw, int ah, int width) { struct_pos t(ax, ay, aw, ah); //从右到左布局,需要重新定位x坐标 if (global_rightToleft) { t.x = width - ax - aw; } return t; } int Config::setSlideWindow(QWidget *window) { int panelPosition = 0; if ( nullptr == static_panelGSettings) { const QByteArray id(PANEL_SETTINGS); if (QGSettings::isSchemaInstalled(id)) { if (nullptr == static_panelGSettings) { static_panelGSettings = new QGSettings(id); } } } if (static_panelGSettings->keys().contains(PANEL_POSITION_KEY)) { panelPosition = static_panelGSettings->get(PANEL_POSITION_KEY).toInt(); } /* if(0 == panelPosition) { KWindowEffects::slideWindow(window, KWindowEffects::BottomEdge); } else if (1 == panelPosition) { KWindowEffects::slideWindow(window, KWindowEffects::TopEdge); } else if(2 == panelPosition) { KWindowEffects::slideWindow(window, KWindowEffects::LeftEdge); } else { KWindowEffects::slideWindow(window, KWindowEffects::RightEdge); }*/ return 0; } static UkuiWindowHelper* getUkuiWindowHelper(QWidget * window) { #ifdef UKUIWINDOWHELPER UkuiWindowHelper* windowHelper = nullptr; if(nullptr != window) { windowHelper = window->findChild("WindowHelper"); if (nullptr == windowHelper) { KyInfo() << "not find WindowHelper child, create UkuiWindowHelper"; windowHelper = new UkuiWindowHelper(window); windowHelper->setObjectName("WindowHelper"); windowHelper->setParent(window); } else { KyInfo() << "find WindowHelper child"; } } return windowHelper; #else return NULL; #endif } void Config::setSkipTaskBar(QWidget * window) { #ifdef UKUIWINDOWHELPER if(nullptr != window) { UkuiWindowHelper * windowHelper = getUkuiWindowHelper(window); if(windowHelper) { windowHelper->setSkipTaskBar(true); } } else { KyWarning() << "null window"; } #endif } void Config::setWindowState(QWidget *window) { #ifdef UKUIWINDOWHELPER if(nullptr != window) { UkuiWindowHelper * windowHelper = getUkuiWindowHelper(window); if(windowHelper) { UkuiWindowHelper::States defaultstate = UkuiWindowHelper::States(0xff); defaultstate = defaultstate & ~qToUnderlying(UkuiWindowHelper::State::Minimizable); defaultstate = defaultstate & ~qToUnderlying(UkuiWindowHelper::State::Maximizable); defaultstate = defaultstate & ~qToUnderlying(UkuiWindowHelper::State::Fullscreenable); defaultstate = defaultstate & ~qToUnderlying(UkuiWindowHelper::State::Movable); defaultstate = defaultstate & ~qToUnderlying(UkuiWindowHelper::State::Resizable); windowHelper->setWindowState(defaultstate); } } else { KyWarning() << "null window"; } #endif } void Config::AppManagerToOpenBluetoothSettings() { KyInfo (); QDBusMessage m = QDBusMessage::createMethodCall("com.kylin.AppManager", "/com/kylin/AppManager", "com.kylin.AppManager", "LaunchAppWithArguments"); m<< QString("ukui-control-center.desktop") << QStringList{"-m","Bluetooth"}; QDBusConnection::sessionBus().call(m, QDBus::NoBlock); } void Config::CommandToOpenBluetoothSettings() { KyInfo (); static QProcess *process = nullptr; if(process) { process->close(); process->deleteLater(); } process = new QProcess(); QString cmd = "ukui-control-center"; QStringList arg; arg.clear(); arg << "-m"; arg << "Bluetooth"; KyDebug() << arg; process->startDetached(cmd,arg); } void Config::OpenBluetoothSettings() { if (Environment::MAVIS == envPC){ QDBusInterface *m_statusSessionDbus = new QDBusInterface("com.kylin.statusmanager.interface", "/", "com.kylin.statusmanager.interface", QDBusConnection::sessionBus()); if (m_statusSessionDbus->isValid()) { qInfo() << Q_FUNC_INFO << "is_tabletmode" << __LINE__; QDBusReply is_tabletmode = m_statusSessionDbus->call("get_current_tabletmode"); if (is_tabletmode) AppManagerToOpenBluetoothSettings(); else CommandToOpenBluetoothSettings(); } else CommandToOpenBluetoothSettings(); } else CommandToOpenBluetoothSettings(); } int Config::devConnect(QString address) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("devConnect"); dbusMsg << address; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Connect Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; case -3: DEBUG_PRINT("Adapter doesn't Exist"); break; case -4: DEBUG_PRINT("Pair Failed"); break; case -5: DEBUG_PRINT("Paring"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -6; } } int Config::devDisconnect(QString address) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("devDisconnect"); dbusMsg << address; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Disconnect Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -3; } } int Config::devRemove(QString address, QString adapter) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("devRemove"); dbusMsg << address << adapter; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Remove Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -3; } } int Config::activeConnectionReply(QString address, bool accept) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("activeConnectionReply"); dbusMsg << address << accept; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Remove Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -3; } } int Config::pairFuncReply(QString address, bool accept) { QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("pairFuncReply"); dbusMsg << address << accept; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Remove Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -3; } } int Config::replyFileReceiving(QString address, bool accept, QString savePathdir, QString user) { QMap sendMsg; sendMsg.insert("dev", QVariant(address)); sendMsg.insert("receive", QVariant(accept)); sendMsg.insert("savePathdir", QVariant(savePathdir)); sendMsg.insert("user", user); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("replyFileReceiving"); dbusMsg << sendMsg; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { int res = response.arguments().takeFirst().toInt(); switch (res) { case 0: DEBUG_PRINT("Remove Succeed"); break; case -1: DEBUG_PRINT("Address Error"); break; case -2: DEBUG_PRINT("Devices doesn't Exist"); break; } return res; } else { DEBUG_PRINT("Method Call Error"); return -3; } } bool Config::setDefaultAdapterAttr(QMap adpAttr) { KyDebug() << adpAttr; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("setDefaultAdapterAttr"); dbusMsg << adpAttr; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } bool Config::getLeaveLockPower() { KyDebug(); QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("getLeaveLockPower"); QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } return false; } void Config::setLeaveLockPower(bool v) { KyDebug() << v; QDBusMessage dbusMsg = CREATE_SYSTEM_METHOD_CALL("setLeaveLockPower"); dbusMsg << v; QDBusConnection::systemBus().asyncCall(dbusMsg); } void Config::soundComplete() { QDBusMessage m = QDBusMessage::createMethodCall("org.ukui.sound.theme.player", "/org/ukui/sound/theme/player", "org.ukui.sound.theme.player", "playAlertSound"); m<< QString("complete"); QDBusConnection::sessionBus().call(m, QDBus::NoBlock); } void Config::soundWarning() { QDBusMessage m = QDBusMessage::createMethodCall("org.ukui.sound.theme.player", "/org/ukui/sound/theme/player", "org.ukui.sound.theme.player", "playAlertSound"); m<< QString("dialog-error"); QDBusConnection::sessionBus().call(m, QDBus::NoBlock); } ukui-bluetooth/ukui-bluetooth/config/x11devices.h0000664000175000017500000000220315167665770021053 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef X11DEVICES_H #define X11DEVICES_H #include #define STR_MOUSE "MOUSE" #define STR_TOUCHPAD "TOUCHPAD" #define STR_KEYBOARD "KEYBOARD" #define STR_TRACKPOINT "TRACKPOINT" class x11Devices : public QObject { Q_OBJECT public: explicit x11Devices(QObject *parent = nullptr); static unsigned int getSystemCurrentMouseAndTouchPadDevCount(); static unsigned int getSystemCurrentKeyBoardDevCount(); }; #endif // X11DEVICES_H ukui-bluetooth/ukui-bluetooth/config/panel-gsettings.cpp0000664000175000017500000000462215167665770022545 0ustar fengfeng#include #include #include #include #include "panel-gsettings.h" static std::once_flag onceFlag; static PanelGSettings* g_instance = nullptr; static GSettings * m_settings = nullptr; static GSettingsSchema * m_schema = nullptr; static const char *m_panelLengthKey = "panellength"; PanelGSettings *PanelGSettings::instance() { std::call_once(onceFlag, [ & ] { g_instance = new PanelGSettings(); }); return g_instance; } int PanelGSettings::getPanelLength(QString screenName) { if (!m_settings || !m_schema) return -1; if (!isKeysContain(m_panelLengthKey)) return -1; QMap map = getPanelLengthMap(); if (!map.contains(screenName)) { return -1; } return map.value(screenName).toInt(); } PanelGSettings::~PanelGSettings() { if (m_settings) { g_object_unref(m_settings); } if (m_schema) { g_settings_schema_unref(m_schema); } g_instance = nullptr; } PanelGSettings::PanelGSettings(QObject *parent) : QObject(parent) { GSettingsSchemaSource *source; source = g_settings_schema_source_get_default(); m_schema = g_settings_schema_source_lookup(source, "org.ukui.panel.settings", true); g_settings_schema_source_unref(source); if (!m_schema) { m_settings = nullptr; return; } m_settings = g_settings_new_with_path("org.ukui.panel.settings", "/org/ukui/panel/settings/"); } bool PanelGSettings::isKeysContain(const char *key) { if (!m_settings || !m_schema) return false; gchar **keys = g_settings_schema_list_keys(m_schema); if (g_strv_contains(keys, key)) { g_strfreev(keys); return true; } else { g_strfreev(keys); return false; } } QMap PanelGSettings::getPanelLengthMap() { GVariant *gvalue = g_settings_get_value(m_settings, m_panelLengthKey); GVariantIter iter; QMap map; const gchar *key; size_t str_len; GVariant *val = NULL; g_variant_iter_init (&iter, gvalue); QVariant qvar; while (g_variant_iter_next (&iter, "{&sv}", &key, &val)) { if (g_variant_is_of_type(val, G_VARIANT_TYPE_UINT32)) { qvar = QVariant::fromValue(static_cast(g_variant_get_uint32(val))); map.insert(key, qvar); } } g_variant_unref(gvalue); return map; } ukui-bluetooth/ukui-bluetooth/config/panel-gsettings.h0000664000175000017500000000067015167665770022211 0ustar fengfeng#ifndef PANELGSETTINGS_H #define PANELGSETTINGS_H #include #include class PanelGSettings : public QObject { Q_OBJECT public: static PanelGSettings *instance(); int getPanelLength(QString screenName); ~PanelGSettings(); private: PanelGSettings(QObject *parent = nullptr); bool isKeysContain(const char* key); QMap getPanelLengthMap(); }; #endif // PANELGSETTINGS_H ukui-bluetooth/ukui-bluetooth/config/kqpushbutton.h0000664000175000017500000000210015167665770021642 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef KQPUSHBUTTON_H #define KQPUSHBUTTON_H #include #include #include class KQPushButton : public QPushButton { Q_OBJECT public: explicit KQPushButton(const QString &text, QWidget *parent = nullptr); explicit KQPushButton(QWidget *parent = nullptr); protected: bool event(QEvent *e); signals: void hovered(bool); }; #endif // KQPUSHBUTTON_H ukui-bluetooth/ukui-bluetooth/config/x11devices.cpp0000664000175000017500000000674615167665770021426 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "x11devices.h" #include extern "C"{ #include #include } x11Devices::x11Devices(QObject *parent) : QObject(parent) { } unsigned int x11Devices::getSystemCurrentMouseAndTouchPadDevCount() { unsigned int count = 0 ; Display *display = XOpenDisplay(NULL); if (display == NULL) { // 错误处理 //KyWarning() << "display error!"; XCloseDisplay(display); exit(1); } XDeviceInfo *devices; int num_devices; devices = XListInputDevices(display, &num_devices); if (devices == NULL) { //KyWarning() << "devices error!"; XCloseDisplay(display); exit(1); } Atom mouse_prop = XInternAtom(display,STR_MOUSE,false); Atom touchPad_prop = XInternAtom(display,STR_TOUCHPAD,false); for (int i = 0; i < num_devices; i++) { if (devices[i].type == mouse_prop || devices[i].type == touchPad_prop) { QString dev_name = QString(devices[i].name); KyDebug() << "dev_name:" <. * **/ #include "kqpushbutton.h" KQPushButton::KQPushButton(const QString &text, QWidget *parent) : QPushButton(text, parent) { } KQPushButton::KQPushButton(QWidget *parent) : QPushButton(parent) { } bool KQPushButton::event(QEvent *e) { if (e->type() == QEvent::HoverEnter) { emit hovered(true); } if (e->type() == QEvent::HoverLeave) { emit hovered(false); } return QPushButton::event(e); } ukui-bluetooth/ukui-bluetooth/translate_generation.sh0000775000175000017500000000056615167665770022242 0ustar fengfeng#!/bin/bash export PATH="/usr/lib/qt6/bin:$PATH" ts_list=(`ls translations/*.ts`) source /etc/os-release version=(`echo $ID`) for ts in "${ts_list[@]}" do printf "\nprocess ${ts}\n" if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then lrelease-qt6 "${ts}" else lrelease "${ts}" fi done ukui-bluetooth/ukui-bluetooth/main/0000775000175000017500000000000015167665770016410 5ustar fengfengukui-bluetooth/ukui-bluetooth/main/main.cpp0000664000175000017500000000533215167665770020043 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "mainprogram.h" #include #include #include #include #include #include #include #include #include "kysdk/kysdk-system/libkysysinfo.h" #include "dbus/sysdbusinterface.h" extern bool global_rightToleft; int main(int argc, char *argv[]) { initUkuiLog4qt("ukui-bluetooth"); // QApplication::setStyle(QStyleFactory::create("ukui-default")); QApplication::setQuitOnLastWindowClosed(false); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); QString systemLang = QLocale::system().name(); if(systemLang == "ug_CN" || systemLang == "ky_KG" || systemLang == "kk_KZ"){ QGuiApplication::setLayoutDirection(Qt::RightToLeft); global_rightToleft = true; KyInfo() << "global_rightToleft set true"; } else { QGuiApplication::setLayoutDirection(Qt::LeftToRight); } #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); #endif QApplication app(argc, argv); QTranslator *t = new QTranslator(); t->load("/usr/share/libpeony-qt/libpeony-qt_"+QLocale::system().name() + ".qm"); QApplication::installTranslator(t); //安装ukui-bluetooth的中文翻译 QTranslator * translator = new QTranslator();; translator->load("/usr/share/ukui-bluetooth/translations/ukui-bluetooth_" + QLocale::system().name() + ".qm"); app.installTranslator(translator); //安装Qt中文翻译 QTranslator * qt_translator = new QTranslator(); QString qtTransPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (qt_translator->load(QLocale(), "qt", "_", qtTransPath)) app.installTranslator(qt_translator); auto ptr = new sysdbusinterface(); MainProgram w(envPC); if(w.exit_flag){ return 0; } return app.exec(); } ukui-bluetooth/ukui-bluetooth/main/mainprogram.h0000664000175000017500000000634715167665770021107 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef MAINPROGRAM_H #define MAINPROGRAM_H #include "dbus/bluetoothdbus.h" #include "config/config.h" #include "component/kyfiledialog.h" #include "popwidget/pincodewidget.h" #include "popwidget/errormessagewidget.h" #include "popwidget/activeconnectionwidget.h" #include "popwidget/filereceivingpopupwidget.h" #include "popwidget/bluetoothfiletransferwidget.h" #include "ukuistylehelper/ukuistylehelper.h" #include "popwidget/trayicon.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #define LIST_PATH "/etc/pairDevice.list" class KDbusInterface; class MainProgram : public QObject { Q_OBJECT public: explicit MainProgram(bool env, QObject *parent = nullptr); ~MainProgram(); bool exit_flag = false; private slots: void sendFiles(QString, QStringList); void gsettingsChangedSlot(const QString &); void sendTransferFilesMesgSlot(QStringList); void sendTransferDeviceMesgSlot(QString address); void activeConnectionSlot(QString address, QString name, QString type, int rssi, int timeout); void receiveFileSlot(QString address, QString name, QString filename, QString type, quint64 size); void displayPasskeySlot(QString dev, QString name, QString passkey); void requestConfirmationSlot(QString dev, QString name, QString passkey); void connectionErrorSlot(QString, int); void openBluetoothSettings(); private: bool _mIntel; QTimer *replyTimer; QStringList selectedFiles; QMap _mGsetting; QList *deviceAddressList = nullptr; QList *deviceTypeList = nullptr; TrayIcon * m_trayicon; Config *_mConfig = nullptr; BluetoothDbus *_sessionDbus = nullptr; PinCodeWidget *pincodewidget = nullptr; PinCodeWidget *Keypincodewidget = nullptr; FileReceivingPopupWidget *receiving_widget = nullptr; BluetoothFileTransferWidget *fileSendWidget = nullptr; ActiveConnectionWidget *activeConnectionWidget = nullptr; ErrorMessageWidget *errMsgWidget = nullptr; QString m_Passkey; QString current_User; QString active_User; void initGSettingInfo(); }; #endif // MAINPROGRAM_H ukui-bluetooth/ukui-bluetooth/main/mainprogram.cpp0000664000175000017500000004777315167665770021452 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "mainprogram.h" MainProgram::MainProgram(bool env, QObject *parent) : QObject(parent) { envPC = env; _sessionDbus = new BluetoothDbus(this); if (envPC == Environment::LAIKA || envPC == Environment::MAVIS) _mIntel = true; else _mIntel = false; _mConfig = new Config(this); initGSettingInfo(); errMsgWidget = new ErrorMessageWidget(); Config::setKdkGeometry(errMsgWidget->windowHandle(), errMsgWidget->width(), errMsgWidget->height(), true); errMsgWidget->show(); Config::setKdkGeometry(errMsgWidget->windowHandle(), errMsgWidget->width(), errMsgWidget->height(), true); errMsgWidget->hide(); replyTimer = new QTimer(this); QDBusMessage dbusMsg = QDBusMessage::createMethodCall(SYSTEM_ACTIVE_USER_DBUS, SYSTEM_ACTIVE_USER_PATH, SYSTEM_ACTIVE_USER_INTERFACE, "GetActiveUser"); QDBusMessage response = SYSTEM_CALL_METHOD(dbusMsg); if (response.type() == QDBusMessage::ReplyMessage) active_User = response.arguments().takeFirst().toString(); else active_User = QString(); current_User = QString(qgetenv("USER").toStdString().data()); KyDebug() << active_User << current_User ; //非华为机器才存在文件功能 if(envPC != Environment::HUAWEI) { connect(_sessionDbus, &BluetoothDbus::receiveFilesSignal, this, &MainProgram::receiveFileSlot); connect(_sessionDbus, &BluetoothDbus::sendTransferDeviceMesgSignal, this, &MainProgram::sendTransferDeviceMesgSlot); connect(_sessionDbus, &BluetoothDbus::sendTransferFilesMesgSignal, this, &MainProgram::sendTransferFilesMesgSlot); } connect(_sessionDbus, &BluetoothDbus::connectionErrorMsg, this, &MainProgram::connectionErrorSlot); connect(_sessionDbus, &BluetoothDbus::activeConnectionSignal, this, &MainProgram::activeConnectionSlot); connect(_sessionDbus, &BluetoothDbus::displayPasskeySignal, this, &MainProgram::displayPasskeySlot); connect(_sessionDbus, &BluetoothDbus::requestConfirmationSignal, this, &MainProgram::requestConfirmationSlot); connect(_sessionDbus, &BluetoothDbus::showTrayWidgetUISignal, this, [=]() { }); connect(_sessionDbus, &BluetoothDbus::activeUserChangedSignal, this, [=](QString activeUserName) { active_User = activeUserName; }); m_trayicon = new TrayIcon(_sessionDbus->getTrayIconShow(), _sessionDbus->getExistAdapter(), nullptr); connect(_sessionDbus, &BluetoothDbus::powerChangedSignal, m_trayicon, &TrayIcon::SetTrayIcon); connect(_sessionDbus, &BluetoothDbus::showTrayIcon, m_trayicon, &TrayIcon::SetAdapterFlag); connect(_sessionDbus, &BluetoothDbus::existAdapter, m_trayicon, &TrayIcon::setAdapterExist); connect(m_trayicon, &TrayIcon::openBluetoothSettings, this, &MainProgram::openBluetoothSettings); m_trayicon->SetTrayIcon(_sessionDbus->isPowered()); } MainProgram::~MainProgram() { // _sessionDbus->unregisterClient(); } void MainProgram::initGSettingInfo() { _mGsetting.clear(); _mGsetting["switch"] = _mConfig->gsetting->get("switch"); _mGsetting["finally-connect-the-device"] = _mConfig->gsetting->get("finally-connect-the-device"); _mGsetting["adapter-address"] = _mConfig->gsetting->get("adapter-address"); _mGsetting["file-save-path"] = _mConfig->gsetting->get("file-save-path"); _mGsetting["adapter-address-list"] = _mConfig->gsetting->get("adapter-address-list"); if(_mConfig->gsetting->get("file-save-path").toString().isEmpty()){ _mConfig->gsetting->set("file-save-path",QVariant::fromValue(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation))); } connect(_mConfig->gsetting,SIGNAL(changed(QString)),this,SLOT(gsettingsChangedSlot(QString))); } void MainProgram::gsettingsChangedSlot(const QString &key) { if (_mGsetting.contains("key")) { _mGsetting[key] = _mConfig->gsetting->get(key); } } void MainProgram::sendFiles(QString address, QStringList files) { _sessionDbus->sendFiles(address, files); } void MainProgram::receiveFileSlot(QString address, QString devname, QString filename, QString type, quint64 size) { if (active_User != current_User) return; KyDebug(); receiving_widget = new FileReceivingPopupWidget(address, devname, filename, type, size); KyDebug(); connect(_sessionDbus,&BluetoothDbus::statusChangedSignal,receiving_widget,&FileReceivingPopupWidget::statusChangedSlot); connect(receiving_widget,&FileReceivingPopupWidget::accepted,this,[=]{ KyDebug() << Q_FUNC_INFO << __LINE__; _sessionDbus->replyFileReceiving(address, true); connect(receiving_widget,&FileReceivingPopupWidget::cancel,this,[=]{ _sessionDbus->cancelFileTransfer(address, 1); receiving_widget->deleteLater(); receiving_widget = nullptr; KyDebug() << Q_FUNC_INFO << "cancel" << __LINE__; }); }); connect(receiving_widget,&FileReceivingPopupWidget::rejected,this,[=]{ _sessionDbus->replyFileReceiving(address, false); receiving_widget->deleteLater(); receiving_widget = nullptr; }); // if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { // kdk::UkuiStyleHelper::self()->removeHeader(receiving_widget); // } receiving_widget->show(); receiving_widget->activateWindow(); Config::setKdkGeometry(receiving_widget->windowHandle(), receiving_widget->width(), receiving_widget->height(), true); } void MainProgram::sendTransferDeviceMesgSlot(QString address) { if (active_User != current_User) return; selectedFiles.clear(); KyFileDialog fd; QList list = fd.sidebarUrls(); int sidebarNum = 8;//最大添加U盘数,可以自己定义 QString home = QDir::homePath().section("/", -1, -1); QString mnt = "/media/" + home + "/"; QDir mntDir(mnt); mntDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList filist = mntDir.entryInfoList(); QList mntUrlList; for (int i = 0; i < sidebarNum && i < filist.size(); ++i) { QFileInfo fi = filist.at(i); //华为990、9a0需要屏蔽最小系统挂载的目录 if (fi.fileName() == "2691-6AB8") continue; mntUrlList << QUrl("file://" + fi.filePath()); } QFileSystemWatcher fsw(&fd); fsw.addPath("/media/" + home + "/"); connect(&fsw, &QFileSystemWatcher::directoryChanged, &fd, [=, &sidebarNum, &mntUrlList, &list, &fd](const QString path) { QDir wmntDir(path); wmntDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList wfilist = wmntDir.entryInfoList(); mntUrlList.clear(); for (int i = 0; i < sidebarNum && i < wfilist.size(); ++i) { QFileInfo fi = wfilist.at(i); //华为990、9a0需要屏蔽最小系统挂载的目录 if (fi.fileName() == "2691-6AB8") continue; mntUrlList << QUrl("file://" + fi.filePath()); } fd.setSidebarUrls(list + mntUrlList); fd.update(); }); connect(&fd, &QFileDialog::finished, &fd, [=, &list, &fd]() { fd.setSidebarUrls(list); }); //自己QFileDialog的用法,这里只是列子 //fd.setNameFilter(QLatin1String("All Files (*)")); fd.setDirectory(QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).at(0)); //这行要添加,设置左侧导航 fd.setSidebarUrls(list + mntUrlList); fd.show(); Config::setKdkGeometry(fd.windowHandle(), fd.width(), fd.height(), true); if (fd.exec() == QDialog::Accepted) { KyDebug()<getSendableDevices(),address); connect(fileSendWidget,&BluetoothFileTransferWidget::sender_dev_name,this,&MainProgram::sendFiles); connect(fileSendWidget,&BluetoothFileTransferWidget::stopSendFile,this,[=](QString address){ _sessionDbus->cancelFileTransfer(address, 0); }); connect(_sessionDbus,&BluetoothDbus::statusChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::statusChangedSlot); connect(_sessionDbus,&BluetoothDbus::powerChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::powerChanged); connect(_sessionDbus,&BluetoothDbus::devAttrChanged, fileSendWidget, &BluetoothFileTransferWidget::devattrChanged); // if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { // kdk::UkuiStyleHelper::self()->removeHeader(fileSendWidget); // } fileSendWidget->show(); fileSendWidget->activateWindow(); Config::setKdkGeometry(fileSendWidget->windowHandle(), fileSendWidget->width(), fileSendWidget->height(), true); } else { KyDebug() << Q_FUNC_INFO << fileSendWidget->get_send_data_state() << __LINE__; if (BluetoothFileTransferWidget::_SEND_FAILURE == fileSendWidget->get_send_data_state() || BluetoothFileTransferWidget::_SEND_COMPLETE == fileSendWidget->get_send_data_state() ) { fileSendWidget->close(); delete fileSendWidget; fileSendWidget = new BluetoothFileTransferWidget(selectedFiles,_sessionDbus->getSendableDevices(),address); connect(fileSendWidget,&BluetoothFileTransferWidget::sender_dev_name,this,&MainProgram::sendFiles); connect(fileSendWidget,&BluetoothFileTransferWidget::stopSendFile,this,[=](QString address){ _sessionDbus->cancelFileTransfer(address, 0); }); connect(_sessionDbus,&BluetoothDbus::statusChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::statusChangedSlot); connect(_sessionDbus,&BluetoothDbus::devAttrChanged, fileSendWidget, &BluetoothFileTransferWidget::devattrChanged); connect(_sessionDbus,&BluetoothDbus::powerChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::powerChanged); // if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { // kdk::UkuiStyleHelper::self()->removeHeader(fileSendWidget); // } fileSendWidget->show(); fileSendWidget->activateWindow(); Config::setKdkGeometry(fileSendWidget->windowHandle(), fileSendWidget->width(), fileSendWidget->height(), true); } else { fileSendWidget->insertNewFileList(selectedFiles); } } } } void MainProgram::sendTransferFilesMesgSlot(QStringList targetList) { if (active_User != current_User) return; KyDebug() << "Select file:" << targetList; //selectedFiles = targetList; selectedFiles.clear(); for (int i = 0 ; i < targetList.size() ; i++) { QString str = targetList.at(i); str = str.replace(QString("file://"), QString("")); selectedFiles.append(str); } KyDebug() << "Select file:" << selectedFiles; if(selectedFiles.size() != 0){ if (BluetoothFileTransferWidget::isShow == false) { fileSendWidget = new BluetoothFileTransferWidget(selectedFiles,_sessionDbus->getSendableDevices(),""); connect(fileSendWidget,&BluetoothFileTransferWidget::sender_dev_name,this,&MainProgram::sendFiles); connect(fileSendWidget,&BluetoothFileTransferWidget::stopSendFile,this,[=](QString address){ _sessionDbus->cancelFileTransfer(address, 0); }); connect(_sessionDbus,&BluetoothDbus::statusChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::statusChangedSlot); connect(_sessionDbus,&BluetoothDbus::devAttrChanged, fileSendWidget, &BluetoothFileTransferWidget::devattrChanged); connect(_sessionDbus,&BluetoothDbus::powerChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::powerChanged); // if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { // kdk::UkuiStyleHelper::self()->removeHeader(fileSendWidget); // } fileSendWidget->show(); fileSendWidget->activateWindow(); Config::setKdkGeometry(fileSendWidget->windowHandle(), fileSendWidget->width(), fileSendWidget->height(), true); } else { if (BluetoothFileTransferWidget::_SEND_FAILURE == fileSendWidget->get_send_data_state() || BluetoothFileTransferWidget::_SEND_COMPLETE == fileSendWidget->get_send_data_state() ) { fileSendWidget->close(); delete fileSendWidget; fileSendWidget = new BluetoothFileTransferWidget(selectedFiles,_sessionDbus->getSendableDevices(),""); connect(fileSendWidget,&BluetoothFileTransferWidget::sender_dev_name,this,&MainProgram::sendFiles); connect(fileSendWidget,&BluetoothFileTransferWidget::stopSendFile,this,[=](QString address){ _sessionDbus->cancelFileTransfer(address, 0); }); connect(_sessionDbus,&BluetoothDbus::statusChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::statusChangedSlot); connect(_sessionDbus,&BluetoothDbus::devAttrChanged, fileSendWidget, &BluetoothFileTransferWidget::devattrChanged); connect(_sessionDbus,&BluetoothDbus::powerChangedSignal,fileSendWidget,&BluetoothFileTransferWidget::powerChanged); // if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"),Qt::CaseInsensitive)) { // kdk::UkuiStyleHelper::self()->removeHeader(fileSendWidget); // } fileSendWidget->show(); fileSendWidget->activateWindow(); Config::setKdkGeometry(fileSendWidget->windowHandle(), fileSendWidget->width(), fileSendWidget->height(), true); } else { fileSendWidget->insertNewFileList(selectedFiles); } } } } void MainProgram::displayPasskeySlot(QString dev, QString name, QString passkey) { if (active_User != current_User) return; KyDebug() << Q_FUNC_INFO << dev << name << passkey; if(m_Passkey == passkey) return; if(Keypincodewidget != nullptr){ if (Keypincodewidget) { Keypincodewidget->updateUIInfo(name,passkey); return; } } Keypincodewidget = new PinCodeWidget(name,passkey,false, nullptr); QWindow *wi = Keypincodewidget->windowHandle(); wi->setTransientParent(nullptr); connect(Keypincodewidget, &PinCodeWidget::msgShowedOver, this, [=] { Keypincodewidget->deleteLater(); Keypincodewidget = nullptr; }); disconnect(_sessionDbus, &BluetoothDbus::pairAgentCanceledSignal, nullptr, nullptr); Keypincodewidget->show(); Keypincodewidget->activateWindow(); Config::setKdkGeometry(Keypincodewidget->windowHandle(), Keypincodewidget->width(), Keypincodewidget->height(), true); } void MainProgram::requestConfirmationSlot(QString dev, QString name, QString passkey) { if (active_User != current_User) return; KyDebug() << Q_FUNC_INFO << dev << name << passkey; if(pincodewidget != nullptr){ KyDebug(); return; } m_Passkey = passkey; pincodewidget = new PinCodeWidget(name,passkey, true, nullptr); QWindow *wi = pincodewidget->windowHandle(); wi->setTransientParent(nullptr); connect(pincodewidget, &PinCodeWidget::msgShowedOver, this, [=] { if (pincodewidget != nullptr) { KyDebug(); pincodewidget->deleteLater(); pincodewidget = nullptr; } }); /* connect(_sessionDbus, &BluetoothDbus::pairAgentCanceledSignal, this, [=](QString addr) { KyDebug(); if(addr != QString("") && addr != dev) return; if (pincodewidget != nullptr) { if (pincodewidget->canceled) return; pincodewidget->canceled = true; pincodewidget->pairFailureShow(); pincodewidget = nullptr; } });*/ connect(pincodewidget,&PinCodeWidget::accepted,this,[=]{ _sessionDbus->pairFuncReply(dev, true); }); connect(pincodewidget,&PinCodeWidget::rejected,this,[=]{ _sessionDbus->pairFuncReply(dev, false); }); connect(pincodewidget, &PinCodeWidget::destroyed, this, [=] { pincodewidget = nullptr; }); pincodewidget->show(); pincodewidget->activateWindow(); Config::setKdkGeometry(pincodewidget->windowHandle(), pincodewidget->width(), pincodewidget->height(), true); } void MainProgram::activeConnectionSlot(QString address, QString name, QString type, int rssi, int timeout) { KyInfo(); if (active_User != current_User) return; if (activeConnectionWidget != nullptr) activeConnectionWidget->deleteLater(); activeConnectionWidget = new ActiveConnectionWidget(address, name, type, rssi); disconnect(_sessionDbus, &BluetoothDbus::adapterAutoConnChanged, nullptr, nullptr); connect(_sessionDbus, &BluetoothDbus::adapterAutoConnChanged, activeConnectionWidget, &ActiveConnectionWidget::autoConnChanged); connect(activeConnectionWidget, &ActiveConnectionWidget::replyActiveConnection, this, [=](QString dev, bool v) { if (replyTimer->isActive()) replyTimer->stop(); _sessionDbus->activeConnectionReply(dev, v); disconnect(activeConnectionWidget, &ActiveConnectionWidget::replyActiveConnection, NULL, NULL); activeConnectionWidget = nullptr; }); replyTimer->disconnect(); connect(replyTimer, &QTimer::timeout, this, [=](){ if (nullptr == activeConnectionWidget) return; disconnect(activeConnectionWidget, &ActiveConnectionWidget::replyActiveConnection, NULL, NULL); activeConnectionWidget->hide(); activeConnectionWidget->deleteLater(); activeConnectionWidget = nullptr; }); activeConnectionWidget->show(); activeConnectionWidget->activateWindow(); struct_pos pos = Config::getKdkGeometry(activeConnectionWidget->width(), activeConnectionWidget->height(), false); if (pos.x != 0 || pos.y != 0) { activeConnectionWidget->setGeometry(pos.x, pos.y, activeConnectionWidget->width(), activeConnectionWidget->height()); } replyTimer->start(timeout * 1000); } void MainProgram::connectionErrorSlot(QString dev, int errCode) { if (active_User != current_User) return; KyDebug(); errMsgWidget->ErrCodeAnalysis(dev, errCode); } void MainProgram::openBluetoothSettings() { KyInfo(); if(_sessionDbus) { _sessionDbus->openBluetoothSettings(); } } ukui-bluetooth/ukui-bluetooth/ukui-bluetooth.pro0000664000175000017500000001060415167665770021167 0ustar fengfengTARGET = ukui-bluetooth DESTDIR = . TEMPLATE = app include(../environment.pri) INCLUDEPATH += /usr/include/KF6/KWindowSystem \ /usr/include/KF6/BluezQt QT += core gui dbus greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 link_pkgconfig USE_OBEX PKGCONFIG += gsettings-qt6 \ kysdk-waylandhelper \ gio-2.0 \ # peony \ kysdk-sysinfo \ kysdk-qtwidgets system(pkg-config --exists kysdk-ukuiwindowhelper) { PKGCONFIG += kysdk-ukuiwindowhelper } # 适配窗口管理器圆角阴影 LIBS += -lpthread LIBS += -lX11 -lXrandr -lXinerama -lXi -lXcursor LIBS += -L /usr/lib/x86_64-linux-gnu -l KF6BluezQt -lgio-2.0 -lglib-2.0 -lukui-log4qt #QMAKE_LFLAGS += -D_FORTIFY_SOURCE=2 -O2 CONFIG(release, debug|release) { !system($$PWD/translate_generation.sh): error("Failed to generate translation") } inst1.files += ../data/org.bluez.Agent1.conf inst1.path = $$CONF_INSTALL_DIR inst2.files += ../data/org.ukui.bluetooth.gschema.xml inst2.path = $$SCHEMAS_INSTALL_DIR inst3.files += ../data/no-bluetooth.svg inst3.path = $$SHARE_INSTALL_DIR inst4.files += ../data/file-transfer-success.svg inst4.path = $$SHARE_INSTALL_DIR inst5.files += ../data/file-transfer-failed.svg inst5.path = $$SHARE_INSTALL_DIR inst6.files +=../data/connection-failed.svg inst6.path = $$SHARE_INSTALL_DIR qm_files.files += translations/*.qm qm_files.path += $${SHARE_TRANSLATIONS_INSTALL_DIR} target.source += $$TARGET target.path = $$BIN_INSTALL_DIR INSTALLS += inst1 \ inst2 \ inst3 \ inst4 \ inst5 \ inst6 \ qm_files \ target # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_INFO_OUTPUT DEFINES += QT_NO_DEBUG_OUTPUT #exists(/usr/include/kysec/libkysec.h){ # DEFINES += KYSEC # LIBS += -lkysec #} # You can also make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 unix { UI_DIR = .ui MOC_DIR = .moc OBJECTS_DIR = .obj } SOURCES += \ config/kqpushbutton.cpp \ config/panel-gsettings.cpp \ config/x11devices.cpp \ dbus/sysdbusinterface.cpp \ popwidget/activeconnectionwidget.cpp \ component/kyfiledialog.cpp \ component/kyhline.cpp \ config/config.cpp \ popwidget/beforeturnoffhintwidget.cpp \ popwidget/bluetoothfiletransferwidget.cpp \ popwidget/errormessagewidget.cpp \ popwidget/filereceivingpopupwidget.cpp \ main/main.cpp \ main/mainprogram.cpp \ popwidget/trayicon.cpp \ popwidget/pincodewidget.cpp \ config/xatom-helper.cpp \ dbus/bluetoothdbus.cpp \ dbus/sessiondbusinterface.cpp HEADERS += \ config/kqpushbutton.h \ config/panel-gsettings.h \ config/x11devices.h \ dbus/sysdbusinterface.h \ popwidget/activeconnectionwidget.h \ component/kyfiledialog.h \ component/kyhline.h \ config/config.h \ popwidget/beforeturnoffhintwidget.h \ popwidget/bluetoothfiletransferwidget.h \ popwidget/errormessagewidget.h \ popwidget/filereceivingpopupwidget.h \ main/mainprogram.h \ popwidget/trayicon.h \ popwidget/pincodewidget.h \ config/xatom-helper.h \ dbus/bluetoothdbus.h \ dbus/sessiondbusinterface.h TRANSLATIONS += \ translations/ukui-bluetooth_zh_CN.ts \ translations/ukui-bluetooth_bo_CN.ts \ translations/ukui-bluetooth_zh_HK.ts \ translations/ukui-bluetooth_mn.ts \ translations/ukui-bluetooth_de.ts \ translations/ukui-bluetooth_es.ts \ translations/ukui-bluetooth_fr.ts \ translations/ukui-bluetooth_kk.ts \ translations/ukui-bluetooth_ky.ts \ translations/ukui-bluetooth_ug.ts \ translations/ukui-bluetooth_ar.ts \ translations/ukui-bluetooth_zh_Hant.ts # Default rules for deployment. #qnx: target.path = /tmp/$${TARGET}/bin #else: unix:!android: target.path = /opt/$${TARGET}/bin #!isEmpty(target.path): INSTALLS += target FORMS += \ popwidget/beforeturnoffhintwidget.ui #CONFIG+=force_debug_info ukui-bluetooth/ukui-bluetooth/ukui-bluetooth.qrc0000664000175000017500000000022715167665755021157 0ustar fengfeng ./translations/ukui-bluetooth_zh_CN.qm ukui-bluetooth/ukui-bluetooth/popwidget/0000775000175000017500000000000015167665770017466 5ustar fengfengukui-bluetooth/ukui-bluetooth/popwidget/filereceivingpopupwidget.cpp0000664000175000017500000005271615167665770025310 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "filereceivingpopupwidget.h" #include "config/xatom-helper.h" #include "config/config.h" //#include //using namespace Peony; FileReceivingPopupWidget::FileReceivingPopupWidget(QString address, QString devname, QString filename, QString type, quint64 size): target_address(address), target_name(devname), target_source(filename), target_type(type), target_size(size), org_name(devname), org_source(filename) { if (envPC == Environment::LAIKA || envPC == Environment::MAVIS) isIntel = true; else isIntel = false; // 添加窗管协议 MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_CLOSE; hints.decorations = MWM_DECOR_ALL; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); if(QGSettings::isSchemaInstalled("org.ukui.style")){ StyleSettings = new QGSettings("org.ukui.style"); connect(StyleSettings,&QGSettings::changed,this,&FileReceivingPopupWidget::GSettingsChanges); } this->setWindowIcon(QIcon::fromTheme("bluetooth")); this->setWindowTitle(tr("Bluetooth File")); this->setAttribute(Qt::WA_DeleteOnClose); this->setBackgroundRole(QPalette::Base); this->setAutoFillBackground(true); if(QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKUIBLUETOOH)){ settings = new QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH); file_path = settings->get("file-save-path").toString(); connect(settings, &QGSettings::changed,this,&FileReceivingPopupWidget::GSettings_value_chanage); }else{ file_path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); } file_source = new QLabel(this); file_source->setAlignment(Qt::AlignTop); QIcon fileicon = getFileIconFromType(target_type); file_icon = new QLabel(this); file_icon->setPixmap(fileicon.pixmap(64,64)); file_icon->setAlignment(Qt::AlignCenter); QFontMetrics fontMetrics(file_source->font()); QString fileName = fontMetrics.elidedText(target_source, Qt::ElideMiddle, 280); file_name = new QLabel(fileName,this); file_name->setToolTip(target_source); file_name->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); QString fileSizeStr; int unitcount = 0; //将单位B转化为对应的KB、MB等单位 double calc_size = target_size; while(calc_size >= 1024) { calc_size /= 1024; unitcount++; } fileSizeStr = QString::asprintf("%.1f ", calc_size) + unitString[unitcount]; file_size = new QLabel(this); file_size->setText(fileSizeStr); file_size->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); file_size->setWordWrap(true); transfer_progress = new QProgressBar(this); transfer_progress->setFixedHeight(15); transfer_progress->setTextVisible(false); transfer_progress->setVisible(false); transfer_progress->setMinimum(0); transfer_progress->setMaximum(100); cancel_btn = new QPushButton(tr("Cancel"),this); cancel_btn->setFocusPolicy(Qt::NoFocus); connect(cancel_btn,&QPushButton::clicked,this,[=]{ Q_EMIT this->rejected(); this->close(); }); accept_btn = new QPushButton(tr("Accept"),this); accept_btn->setFocusPolicy(Qt::NoFocus); connect(accept_btn,&QPushButton::clicked,this,[=]{ OnClickedAcceptBtn(); }); warn_icon = new QLabel(this); warn_icon->setPixmap(QIcon::fromTheme("kylin-dialog-warning").pixmap(22,22)); warn_icon->setVisible(false); view_btn = new QPushButton(tr("View"),this); view_btn->setFocusPolicy(Qt::NoFocus); view_btn->setVisible(false); receivedFiles.clear(); receiveTimer = new QTimer(this); connect(receiveTimer,SIGNAL(timeout()), this, SLOT(transferCompelete())); if (isIntel) initIntelLayout(); else initLayout(); fileNums = 0; window_pop_up_animation(); this->activateWindow(); this->show(); this->setFocusPolicy(Qt::NoFocus); kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true); Config::setSkipTaskBar(this); } FileReceivingPopupWidget::~FileReceivingPopupWidget() { if (fileStatus == Active) { Q_EMIT this->cancel(); isCanceled = true; } else { Q_EMIT this->rejected(); } delete settings; } void FileReceivingPopupWidget::initLayout() { this->setFixedSize(520,236); struct_pos pos; pos = Config::getWidgetPos(390,175,120,36, this->width()); view_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,12,460,54, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,64,64,64, this->width()); file_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(112,71,293,28, this->width()); file_name->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(112,96,293,20, this->width()); file_size->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,144,454,10, this->width()); transfer_progress->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(278,175,96,36, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(390,175,96,36, this->width()); accept_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,14,22,22, this->width()); warn_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); double size = 12; if(QGSettings::isSchemaInstalled("org.ukui.style")) size = StyleSettings->get("system-font-size").toDouble() - 11; QFont ft; ft.setPixelSize(18 + size); file_source->setFont(ft); file_source->setToolTip(target_name); QString fileSource; QFontMetrics fontMetrics(file_source->font()); if (ft.pixelSize() > 17) target_name = fontMetrics.elidedText(target_name, Qt::ElideMiddle, 140); else target_name = fontMetrics.elidedText(target_name, Qt::ElideMiddle, 160); QString fileName = fontMetrics.elidedText(target_source, Qt::ElideMiddle, 280); fileSource = fontMetrics.elidedText(QString(tr("File from \"")+target_name+tr("\", waiting for receive.")), Qt::ElideMiddle, file_source->width()); file_source->setText(fileSource); file_name->setText(fileName); ft.setPixelSize(14 + size); file_name->setFont(ft); file_size->setFont(ft); } void FileReceivingPopupWidget::initIntelLayout() { this->setWindowFlags(Qt::Dialog); this->setFixedSize(478,280); QFont ft; ft.setPixelSize(16); file_size->setFont(ft); file_name->setFont(ft); QFontMetrics fontMetrics(file_source->font()); QString filesource = fontMetrics.elidedText(QString(tr("File from \"")+target_name+tr("\", waiting for receive...")), Qt::ElideMiddle, file_source->width()); file_source->setText(filesource); struct_pos pos; pos = Config::getWidgetPos(342,200,112,56, this->width()); accept_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(214,200,112,56, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,75,293,23, this->width()); file_name->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,107,293,23, this->width()); file_size->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(342,200,120,36, this->width()); view_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,24,430,54, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,71,64,64, this->width()); file_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,159,430,8, this->width()); transfer_progress->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,34,22,22, this->width()); warn_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); } void FileReceivingPopupWidget::updateUI(QString name, quint64 size, QString type) { if (fileStatus == Status::Error) return; fileNums += 1; KyDebug() << name << size << type; QFontMetrics fontMetrics(file_source->font()); QString fileName = fontMetrics.elidedText(name, Qt::ElideMiddle, 280); QString fileSource = QString(tr("File from \"") + target_name + tr("\", is receiving... (has received ") + QString::number(fileNums) + tr(" files)")); QString fileSizeStr; int unitcount = 0; //将单位B转化为对应的KB、MB等单位 double calc_size = size; while(calc_size >= 1024) { calc_size /= 1024; unitcount++; } fileSizeStr = QString::asprintf("%.1f", calc_size) + unitString[unitcount]; target_size = size; target_type = type; target_source = name; QIcon fileicon = getFileIconFromType(target_type); file_size->setText(fileSizeStr); file_icon->setPixmap(fileicon.pixmap(64,64)); file_name->setText(fileName); file_name->setToolTip(name); file_source->setWordWrap(true); file_source->setText(fileSource); file_source->setToolTip(target_name); if (file_source->font().pixelSize() > 17) { struct_pos pos; pos = Config::getWidgetPos(32,0,460,66, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); } this->update(); } void FileReceivingPopupWidget::window_pop_up_animation() { KyDebug() << desktop << desktop.right() << desktop.bottom() <geometry(); // QPropertyAnimation *window_action = new QPropertyAnimation(this,"geometry"); // window_action->setDuration(100); // QRect this_rect = this->rect(); // this_rect.setHeight(0); // this_rect.setWidth(0); // window_action->setStartValue(QRect(desktop.right()-1,desktop.bottom()-this->height(),desktop.right(),desktop.bottom())); // window_action->setEndValue(QRect(desktop.right()-this->width(),desktop.bottom()-this->height(),desktop.right(),desktop.bottom())); // window_action->setStartValue(QPoint(desktop.right()-1,desktop.bottom()-this->height())); // window_action->setEndValue(QPoint(desktop.right()-this->width(),desktop.bottom()-this->height())); // KyDebug() << this_rect << this->geometry() << QRect(desktop.right()-1,desktop.bottom()-this->height(),desktop.right(),desktop.bottom()) <width(),desktop.bottom()-this->height(),desktop.right(),desktop.bottom()); // window_action->start(); } void FileReceivingPopupWidget::OnClickedAcceptBtn() { transfer_progress->setVisible(true); accept_btn->setVisible(false); this->accepted(); } void FileReceivingPopupWidget::update_transfer_progress_bar(quint64 value) { if (target_size == 0 && fileStatus != Status::Active) return; transfer_progress->setValue(value); transfer_progress->repaint(); } void FileReceivingPopupWidget::showFiles() { if(receivedFiles.isEmpty()) return; QProcess *process = new QProcess(this); QString cmd = "peony"; QStringList arg; KyDebug(); arg << "--show-items"; for (int i = 0; i < receivedFiles.size(); i++) { QString mDest = "file://" + receivedFiles.at(i); //if (FileUtils::isFileExsit(mDest)) // arg << receivedFiles.at(i); } process->startDetached(cmd,arg); } void FileReceivingPopupWidget::transferCompelete() { cancel_btn->setVisible(false); Config::soundComplete(); showFiles(); this->close(); } void FileReceivingPopupWidget::statusChangedSlot(QMap status) { if (!status.value("transportType").toInt()) return; if (status.contains("dev")) { if (status.value("dev").toString() != target_address) return; } if(status.contains("status")) if (status.value("status").toInt() != fileStatus) { if (status.value("status").toInt() == 3 && !receivedFiles.contains(status.value("savepath").toString())) receivedFiles.append(status.value("savepath").toString()); KyDebug()<< receivedFiles << __LINE__; file_transfer_completed(status.value("status").toULongLong()); } if (status.contains("progress")) update_transfer_progress_bar(status.value("progress").toInt()); if(status.contains("fileseq")) if (status.value("fileseq").toInt() > fileNums) updateUI(status.value("filename").toString(), status.value("filesize").toULongLong(), status.value("filetype").toString()); } void FileReceivingPopupWidget::file_transfer_completed(int status) { if (isCanceled) { this->close(); this->deleteLater(); return; } struct_pos pos; KyDebug() << "status : " << status << " inside status:" << fileStatus << " value:" << transfer_progress->value(); if(status == Status::Active){ if (receiveTimer->isActive()) { receiveTimer->stop(); } else { QFontMetrics fontMetrics(file_source->font()); QString fileSource; fileSource = fontMetrics.elidedText(QString(tr("File from \"")+target_name+tr("\", is receiving...")), Qt::ElideMiddle, file_source->width()); file_source->setText(fileSource); } this->update(); cancel_btn->disconnect(); cancel_btn->connect(cancel_btn,&QPushButton::clicked,this,[=]{ Q_EMIT this->cancel(); isCanceled = true; }); if (!isIntel) { pos = Config::getWidgetPos(390,175,96,36, this->width()); } else pos = Config::getWidgetPos(342,200,112,56, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); }else if(status == Status::Complete){ receiveTimer->start(2000); KyDebug() << __LINE__ ; }else if(status == Status::Error || (status == Status::Static && transfer_progress->value() != 100)){ if (fileStatus == Status::Complete || fileStatus == Status::Error) { fileStatus = status; return; } if (!isIntel) { Config::SendNotifyMessage(QString(tr("File Receive Failed!")), QString(tr("Receive file '") + org_source + tr("' from '") + org_name + tr("'")), QString("dialog-error")); showFiles(); this->close(); fileStatus = status; return; } accept_btn->setVisible(true); accept_btn->setText(tr("OK")); accept_btn->disconnect(); accept_btn->connect(accept_btn,&QPushButton::clicked,this,[=]{ this->close(); }); cancel_btn->setVisible(false); view_btn->setVisible(false); transfer_progress->setVisible(false); file_icon->setVisible(false); file_name->setVisible(false); file_size->setVisible(false); file_source->setAlignment(Qt::AlignTop); pos = Config::getWidgetPos(62,12,430,60, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); QFontMetrics fontMetrics(file_source->font()); QString fileSource = fontMetrics.elidedText(QString(tr("File from \"")+target_name+tr("\", received failed !")), Qt::ElideMiddle, file_source->width()); file_source->setText(fileSource); warn_icon->setVisible(true); warn_icon->setFixedSize(64,64); warn_icon->setPixmap(QPixmap("/usr/share/ukui-bluetooth/file-transfer-failed.svg")); file_source->setText(tr("File Transmission Failed !")); file_source->setStyleSheet("QLabel{\ font-family: NotoSansCJKsc;\ font-size: 16px;\ line-height: 19px;\ text-align: center;\ color: #FB5050;}"); pos = Config::getWidgetPos(207,17,64,64, this->width()); warn_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(191,89,200,24, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); this->activateWindow(); this->show(); } fileStatus = status; } void FileReceivingPopupWidget::GSettings_value_chanage(const QString &key) { if(key == "file-save-path"){ file_path = settings->get("file-save-path").toString(); } } QIcon FileReceivingPopupWidget::getFileIconFromType(QString type) { QIcon fileicon; if (type.split("/").at(0) == "image"){ fileicon = QIcon::fromTheme("image"); if (fileicon.isNull()) { fileicon = QIcon::fromTheme("text"); } }else if (type.split("/").at(0) == "video") fileicon = QIcon::fromTheme("video-x-generic"); else if (type.split("/").at(0) == "audio" || type.split("/").at(0) == "application" || type.split("/").at(0) == "text" || type.split("/").at(0) == "inode"){ if (QIcon::hasThemeIcon(type.split("/").join("-"))) { fileicon = QIcon::fromTheme(type.split("/").join("-")); } else if (target_source.split(".").size() >= 2){ if (fileicon.isNull()) fileicon = QIcon::fromTheme(target_source.split(".").at(1)); if (fileicon.isNull()) fileicon = QIcon::fromTheme(QString("application-")+target_source.split(".").at(1)); if (fileicon.isNull()) fileicon = QIcon::fromTheme(QString("application-wps-office.")+target_source.split(".").at(1)); } } if (fileicon.isNull() && !target_type.isEmpty()){ QString icon = g_content_type_get_generic_icon_name(target_type.toUtf8().constData()); fileicon = QIcon::fromTheme(icon); } if (fileicon.isNull()) { fileicon = QIcon::fromTheme("text"); } return fileicon; } void FileReceivingPopupWidget::GSettingsChanges(const QString &key) { KyDebug() << key; if(key == "styleName"){ this->update(); } if (key == "systemFontSize") { double size = StyleSettings->get("system-font-size").toDouble() - 11; QFont ft; struct_pos pos; ft.setPixelSize(18 + size); if (ft.pixelSize() > 17) pos = Config::getWidgetPos(32,0,460,66, this->width()); else pos = Config::getWidgetPos(32,12,460,54, this->width()); file_source->setGeometry(pos.x, pos.y, pos.width, pos.high); file_source->setFont(ft); QFontMetrics fontMetrics(file_source->font()); if (ft.pixelSize() > 17) target_name = fontMetrics.elidedText(target_name, Qt::ElideMiddle, 140); else target_name = fontMetrics.elidedText(target_name, Qt::ElideMiddle, 160); QString fileName = fontMetrics.elidedText(target_source, Qt::ElideMiddle, 280); file_name->setText(fileName); ft.setPixelSize(14 + size); file_name->setFont(ft); file_size->setFont(ft); } } QPushButton* FileReceivingPopupWidget::getButton() { switch (pressCnt) { case 1: if (!accept_btn->isVisible() || !cancel_btn->isVisible()) ++pressCnt; if(accept_btn->isVisible()) return accept_btn; else if (cancel_btn->isVisible()){ return cancel_btn; } return nullptr; case 2: return cancel_btn; case 3: // return close_btn; default: return nullptr; } return nullptr; } void FileReceivingPopupWidget::paintEvent(QPaintEvent *event) { QPushButton *btn = getButton(); if(btn) btn->setFocus(); else this->setFocus(); QWidget::paintEvent(event); return; QPainter pt(this); QColor color = QColor("#818181"); pt.setPen(color); btn = getButton(); if (btn == nullptr) return; QRect rect = btn->geometry(); pt.setRenderHint(QPainter::Antialiasing); pt.drawRect(rect); QWidget::paintEvent(event); } void FileReceivingPopupWidget::keyPressEvent(QKeyEvent *event) { QPushButton *bbtn = getButton(); switch (event->key()) { case Qt::Key_Tab: KyDebug()<< "press Tab"; ++pressCnt; if (pressCnt == 4) pressCnt = 1; this->update(); break; case Qt::Key_Enter: case Qt::Key_Return: KyDebug()<< "press Enter"; if (bbtn == nullptr) return; bbtn->clicked(); break; case Qt::Key_Escape: KyDebug()<< "press Esc"; if (pressCnt == 0) this->close(); pressCnt = 0; this->update(); break; default: break; } } ukui-bluetooth/ukui-bluetooth/popwidget/errormessagewidget.h0000664000175000017500000000342215167665770023542 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef ERRORMESSAGEWIDGET_H #define ERRORMESSAGEWIDGET_H #include #include #include #include #include #include #include #include #include "beforeturnoffhintwidget.h" class ErrorMessageWidget : public QWidget { Q_OBJECT public: explicit ErrorMessageWidget(QWidget *parent = nullptr); ~ErrorMessageWidget(); void ErrCodeAnalysis(QString dev, int errCode); void showCloseInfoDialog(); public slots: void closeMessageWidget(void); private: QGSettings *gsettings; QLabel *warn_icon; QLabel *warn_title; QLabel *warn_txt; QPushButton *ok_btn; QMessageBox *mbox = nullptr; bool msgBoxShowed = false; BeforeTurnOffHintWidget *closeInfoDialog; void GSettingsChanges(QString key); void TimeOutLayoutInit(QString dev); void BtAudioNumMaxInit(void); void showMessageBox(QString title, QString text, QString information); signals: void messageBoxShowed(bool); void closeInfoDialogConfirmed(bool); }; #endif // ERRORMESSAGEWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/errormessagewidget.cpp0000664000175000017500000001105515167665770024076 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "errormessagewidget.h" #include #include using namespace kdk; ErrorMessageWidget::ErrorMessageWidget(QWidget *parent) : QWidget(parent) { MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_CLOSE; hints.decorations = MWM_DECOR_ALL; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); KyDebug(); this->setWindowIcon(QIcon::fromTheme("bluetooth")); this->setWindowTitle(tr("Bluetooth Message")); this->setAttribute(Qt::WA_DeleteOnClose); this->setBackgroundRole(QPalette::Base); this->setAutoFillBackground(true); closeInfoDialog = new BeforeTurnOffHintWidget(this); connect(closeInfoDialog, &BeforeTurnOffHintWidget::buttonPressed, this,[=](bool confirm) { emit closeInfoDialogConfirmed(confirm); closeInfoDialog->hide(); }); #if 0 if(QGSettings::isSchemaInstalled("org.ukui.style")){ gsettings = new QGSettings("org.ukui.style"); connect(gsettings,&QGSettings::changed,this,&ErrorMessageWidget::GSettingsChanges); } this->setFixedSize(520,160); warn_icon = new QLabel(this); warn_icon->setFixedSize(22, 22); warn_icon->setGeometry(23, 20, 22, 22); warn_icon->setPixmap(QIcon::fromTheme("kylin-dialog-warning").pixmap(22,22)); if (warn_icon->pixmap()->isNull()) warn_icon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(22,22)); warn_icon->setVisible(false); warn_title = new QLabel(this); warn_title->setVisible(false); warn_txt = new QLabel(this); warn_txt->setVisible(false); ok_btn = new QPushButton(this); ok_btn->setVisible(false); #endif kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true); } ErrorMessageWidget::~ErrorMessageWidget() { KyDebug(); } #if 0 void ErrorMessageWidget::GSettingsChanges(QString key) { if (key == "systemFontSize" || key == "styleName") this->update(); } #endif void ErrorMessageWidget::ErrCodeAnalysis(QString dev, int errCode) { switch (errCode) { case ConnectionErrMsg::ERR_BREDR_CONN_TIMEOUT: case ConnectionErrMsg::ERR_BREDR_CONN_PAGE_TIMEOUT: TimeOutLayoutInit(dev); break; case ConnectionErrMsg::ERR_BREDR_INTERNAL_AUDIO_MAXNUM: BtAudioNumMaxInit(); break; default: break; } } void ErrorMessageWidget::TimeOutLayoutInit(QString dev) { QString txt = QString(tr("Please confirm if the device '")) + dev + QString(tr("' is in the signal range or the Bluetooth is enabled.")); showMessageBox(QString(tr("Bluetooth Message")), QString(tr("Connection Time Out!")), txt); } void ErrorMessageWidget::BtAudioNumMaxInit() { QString info = QString(tr("The number of connected Bluetooth audio devices has reached the upper limit.")); QString txt = QString(tr("Only two Bluetooth audio devices can be connected simultaneously.")); showMessageBox(QString(tr("Bluetooth Message")), info, txt); } void ErrorMessageWidget::showMessageBox(QString title, QString text, QString information) { KyDebug() << ""; if (nullptr != mbox) { mbox->accept(); mbox->deleteLater(); } mbox = new QMessageBox(QMessageBox::Warning,title, text, QMessageBox::Ok); mbox->setAttribute(Qt::WA_NativeWindow); mbox->setInformativeText(information); Config::setKdkGeometry(mbox->windowHandle(), mbox->width(), mbox->height(), true); Config::setSkipTaskBar(mbox); mbox->show(); KyDebug() << "setSkipTaskBar true"; WindowManager::setSkipTaskBar(mbox->windowHandle(), true); int ret = mbox->exec(); KyDebug() << ret; mbox->deleteLater(); mbox = nullptr; } void ErrorMessageWidget::showCloseInfoDialog() { closeInfoDialog->show(); } void ErrorMessageWidget::closeMessageWidget() { KyInfo() << ""; if (nullptr != mbox) mbox->accept(); } ukui-bluetooth/ukui-bluetooth/popwidget/beforeturnoffhintwidget.ui0000664000175000017500000000413515167665755024770 0ustar fengfeng beforeTurnOffHintWidget 0 0 424 140 424 140 424 140 Bluetooth .. true 304 79 96 36 Turn Off 192 79 96 36 Cancel 26 19 22 22 57 16 341 58 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop true ukui-bluetooth/ukui-bluetooth/popwidget/filereceivingpopupwidget.h0000664000175000017500000000707715167665770024755 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef FILERECEIVINGPOPUPWIDGET_H #define FILERECEIVINGPOPUPWIDGET_H //extern "C" { #include #include #include #include #include //} #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" class FileReceivingPopupWidget : public QWidget { Q_OBJECT public: explicit FileReceivingPopupWidget(QString address, QString devname = "", QString filename = "", QString type = "", quint64 size = 0); ~FileReceivingPopupWidget(); void window_pop_up_animation(); public slots: void updateUI(QString name, quint64 size, QString type); void OnClickedAcceptBtn(); void update_transfer_progress_bar(quint64); void file_transfer_completed(int status); void statusChangedSlot(QMap status); void GSettings_value_chanage(const QString &key); void GSettingsChanges(const QString &key); void transferCompelete(); signals: void cancel(); void rejected(); void accepted(); private: bool isCanceled = false; bool isIntel = false; int fileStatus = 0xff; QGSettings *StyleSettings = nullptr; QGSettings *settings = nullptr; QGSettings *transparency_gsettings = nullptr; QPushButton *close_btn = nullptr; QPushButton *cancel_btn = nullptr; QPushButton *accept_btn = nullptr; QPushButton *view_btn = nullptr; QLabel *icon_label = nullptr; QLabel *file_source = nullptr; QLabel *window_Title = nullptr; QLabel *file_name = nullptr; QLabel *file_size = nullptr; QLabel *file_icon = nullptr; QLabel *warn_icon = nullptr; QProgressBar *transfer_progress = nullptr; QRect desktop; QString unitString[5] = {tr("Bytes"), "KB", "MB", "GB", "TB"}; QString target_address; QString target_name; QString org_name; QString target_source; QString org_source; QString target_type; QString root_address; QString file_path; quint64 target_size; QTimer *receiveTimer; int fileNums = 0; QList receivedFiles; int pressCnt = 0; QPushButton *getButton(); void showFiles(); void initLayout(); void initIntelLayout(); QIcon getFileIconFromType(QString type); protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); }; #endif // FILERECEIVINGPOPUPWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/bluetoothfiletransferwidget.h0000664000175000017500000001112015167665770025450 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHFILETRANSFERWIDGET_H #define BLUETOOTHFILETRANSFERWIDGET_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config/config.h" #define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" #define QPROGRESSBAR_MAX_IMUM 1000 class BluetoothFileTransferWidget : public QWidget { Q_OBJECT public: explicit BluetoothFileTransferWidget(QStringList files, QMap> devicelist, QString dev_address = ""); ~BluetoothFileTransferWidget(); typedef enum _SEND_DATA_STATE { _SEND_NONE = 0, _SEND_ACTIVE, _SEND_COMPLETE, _SENDING, _SEND_FAILURE }SEND_DATA_STATE; static bool isShow; void Get_fie_type(int i); bool initFileInfo(); void Get_file_size(float); void Initialize_and_start_animation(); void tranfer_error(); void insertNewFileList(QStringList fileList); int get_send_data_state(); signals: void sender_dev_name(QString, QStringList); void stopSendFile(QString); public slots: void onClicked_OK_Btn(); void GSettingsChanges(const QString &key); void statusChangedSlot(QMap); void powerChanged(bool powered); void devattrChanged(QString address, QMap devAttr); private: bool is_Intel = false; bool closed = false; bool hasemptyfile =false; double tran =1; int fileNums = 0; int active_flag = 3; int pressTabCnt = 0; int pressUDCnt = 0; QString target_dev; QGSettings *GSettings = nullptr; QGSettings *transparency_gsettings = nullptr; QLabel *tip_text = nullptr; QLabel *title_icon = nullptr; QLabel *title_text = nullptr; QLabel *target_icon = nullptr; QLabel *target_name = nullptr; QLabel *target_size = nullptr; QLabel *Tiptop = nullptr; QLabel *transNum = nullptr; QLabel *tranfer_status_icon = nullptr; QLabel *tranfer_status_text = nullptr; QTreeWidget *qtw = nullptr; QParallelAnimationGroup *main_animation_group = nullptr; QProgressBar *m_progressbar = nullptr; QPushButton *close_btn = nullptr; QPushButton *cancel_btn = nullptr; QPushButton *ok_btn = nullptr; QPushButton *selectedBtn = nullptr; QTreeWidgetItem *selectedItem = nullptr; QList file_icon; QList file_size; QList filetype; QMap oversizedFile; QStringList selectedFiles; QStringList sendFilesList; SEND_DATA_STATE send_state = _SEND_NONE; QTreeWidgetItem* selectedDev = nullptr; QList toolbutton_list; QMap itemMap; void initLayout(); void set_m_progressbar_value(int); void get_transfer_status(int); void initIntelLayout(); QRect getButton(); QString changeUnit(QString size); QString getFileName(QString filePath); void initQTreeWidget(QMap > devicelist, QString dev_address); protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); }; #endif // BLUETOOTHFILETRANSFERWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/activeconnectionwidget.cpp0000664000175000017500000000601515167665770024733 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "activeconnectionwidget.h" #include "config/xatom-helper.h" #include "config/config.h" #include ActiveConnectionWidget::ActiveConnectionWidget(QString address, QString name, QString type, int rssi) : m_devAddr(address), m_devName(name), m_devType(type), m_devRSSI(rssi) { this->setWindowIcon(QIcon::fromTheme("bluetooth")); this->setWindowTitle(tr("Bluetooth Connection")); QFontMetrics fontMetrics(this->font()); QString tip = QString(tr("Found audio device \"") + m_devName + tr("\", connect it or not?")); QString _tip = fontMetrics.elidedText(tip, Qt::ElideMiddle, this->width() - 80); if (tip != _tip) { tip = _tip; } this->setText(tip); m_cancel_btn = new QPushButton(tr("Cancel"), this); m_connect_btn = new QPushButton(tr("Connect"), this); this->addButton(m_cancel_btn,QMessageBox::RejectRole); this->addButton(m_connect_btn,QMessageBox::AcceptRole); m_actCnt_box = new QCheckBox(tr("No prompt"), this); this->setCheckBox(m_actCnt_box); connect(m_actCnt_box, &QCheckBox::toggled, this, &ActiveConnectionWidget::toggled); connect(this, &QMessageBox::accepted, this, &ActiveConnectionWidget::onClick_connect_btn); connect(this, &QMessageBox::rejected, this, &ActiveConnectionWidget::onClick_cancel_btn); } ActiveConnectionWidget::~ActiveConnectionWidget() { KyDebug(); } void ActiveConnectionWidget::autoConnChanged(bool activate) { m_actCnt_box->setChecked(!activate); if (m_mutex) { m_mutex = false; return; } m_mutex = true; } void ActiveConnectionWidget::onClick_connect_btn() { KyDebug() << "accpet"; emit replyActiveConnection(m_devAddr, true); this->hide(); this->deleteLater(); } void ActiveConnectionWidget::onClick_cancel_btn() { KyDebug() << "cancel"; emit replyActiveConnection(m_devAddr, false); this->hide(); this->deleteLater(); } void ActiveConnectionWidget::toggled(bool checked) { if (QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKUIBLUETOOH)) { QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH).set("active-connection", QVariant(!checked)); } if (m_mutex) { m_mutex = false; return; } m_mutex = true; QMap attr; attr.insert("ActiveConnection", QVariant(!checked)); Config::setDefaultAdapterAttr(attr); } ukui-bluetooth/ukui-bluetooth/popwidget/trayicon.h0000664000175000017500000000376015167665770021475 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef TRAYICON_H #define TRAYICON_H #include #include #include #include #include #include #include #include #include #include #include #ifdef KYSEC #include #include #endif #include "config/config.h" using namespace std; class TrayIcon : public QWidget { Q_OBJECT public: TrayIcon(bool _trayshow, bool _existAdapter, QWidget *parent = nullptr); ~TrayIcon(); void setClickEnable(bool enable); void updateTrayiconMenuStyle(); signals: void showTrayWidget(); void hideTrayWidget(); void openBluetoothSettings(); public slots: void SetTrayIcon(bool open); void SetAdapterFlag(bool set); void setAdapterExist(bool exist, bool show); private: QSystemTrayIcon *bluetooth_tray_icon = nullptr; QMenu *tray_Menu = nullptr; QGSettings *settings = nullptr; QGSettings *ukccGsetting = nullptr; bool existAdapter = false; bool secState = false; bool clickEnable = true; bool existSettings = false; bool canShow = false; } ; #endif // TRAYICON_H ukui-bluetooth/ukui-bluetooth/popwidget/activeconnectionwidget.h0000664000175000017500000000346215167665770024403 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef ACTIVECONNECTIONWIDGET_H #define ACTIVECONNECTIONWIDGET_H #include #include #include #include #include #include #include #include #include #include #include #include #define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" class ActiveConnectionWidget : public QMessageBox { Q_OBJECT public: explicit ActiveConnectionWidget(QString address, QString name, QString type, int rssi); ~ActiveConnectionWidget(); private slots: void onClick_connect_btn(); void onClick_cancel_btn(); void toggled(bool checked); public slots: void autoConnChanged(bool activate); signals: void replyActiveConnection(QString,bool); private: QPushButton * m_cancel_btn = nullptr; QPushButton * m_connect_btn = nullptr; QCheckBox * m_actCnt_box = nullptr; int m_devRSSI; bool m_mutex = false; QString m_devAddr; QString m_devName; QString m_devType; }; #endif // ACTIVECONNECTIONWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/trayicon.cpp0000664000175000017500000001333215167665770022024 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "trayicon.h" #include #include #include #include #include #include #include TrayIcon::TrayIcon(bool _trayshow, bool _existAdapter, QWidget *parent) : QWidget(parent) { KyInfo(); if(QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKUIBLUETOOH)){ settings = new QGSettings(GSETTING_SCHEMA_UKUIBLUETOOH); existSettings = true; } if(QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKCC)){ ukccGsetting = new QGSettings(GSETTING_SCHEMA_UKCC,GSETTING_PACH_UKCC); } existAdapter = _existAdapter; bluetooth_tray_icon = new QSystemTrayIcon(this); tray_Menu = new QMenu(this); QAction *settins_action = new QAction(tr("Set Bluetooth Item"),tray_Menu); settins_action->setIcon(QIcon::fromTheme("document-page-setup-symbolic", QIcon(":/res/x/setup.png")) ); tray_Menu->addAction(settins_action); canShow = true; connect(tray_Menu, &QMenu::aboutToShow, this, [=]{ //emit hideTrayWidget(); canShow = false; }); connect(tray_Menu, &QMenu::aboutToHide, this, [=]{ //emit hideTrayWidget(); canShow = true; }); connect(tray_Menu, &QMenu::triggered, this, [=]{ emit openBluetoothSettings(); }); //Create taskbar tray icon and connect to signal slot //创建任务栏托盘图标,并连接信号槽 //bluetooth_tray_icon = new QSystemTrayIcon(this); bluetooth_tray_icon->setContextMenu(tray_Menu); bluetooth_tray_icon->setToolTip(tr("Bluetooth")); bluetooth_tray_icon->setProperty("useIconHighlightEffect", 0x2); if (existAdapter && existSettings && _trayshow != settings->get("tray-show").toBool()) { if(QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKUIBLUETOOH)) { _trayshow = settings->get("tray-show").toBool(); QMap attr; attr.remove("trayShow"); attr.insert("trayShow", QVariant(settings->get("tray-show").toBool())); Config::setDefaultAdapterAttr(attr); } } bluetooth_tray_icon->setVisible(_trayshow && existAdapter); connect(bluetooth_tray_icon,&QSystemTrayIcon::activated, [=](QSystemTrayIcon::ActivationReason reason){ switch (reason) { case QSystemTrayIcon::MiddleClick: case QSystemTrayIcon::DoubleClick: /* 来自于双击激活。 */ case QSystemTrayIcon::Trigger: /* 来自于单击激活。 */ if (clickEnable && canShow) { QDBusInterface iface("org.ukui.Sidebar", "/org/ukui/Sidebar", "org.ukui.Sidebar", QDBusConnection::sessionBus()); iface.asyncCall("shortcutWidgetActive", "org.ukui.shortcut.bluetooth", false); KyInfo() << "send message"; } break; case QSystemTrayIcon::Unknown: case QSystemTrayIcon::Context: break; } }); updateTrayiconMenuStyle(); #ifdef KYSEC if (!kysec_is_disabled() && kysec_get_3adm_status() && (getuid() || geteuid())){ secState = true; bluetooth_tray_icon->setVisible(false); } #endif } TrayIcon::~TrayIcon() { KyInfo(); delete settings; } void TrayIcon::SetTrayIcon(bool open) { KyDebug() << open; if(!open){ if(QIcon::hasThemeIcon("bluetooth-error")) bluetooth_tray_icon->setIcon(QIcon::fromTheme("bluetooth-error")); else bluetooth_tray_icon->setIcon(QIcon::fromTheme("bluetooth-active-symbolic")); }else{ bluetooth_tray_icon->setIcon(QIcon::fromTheme("bluetooth-active-symbolic")); } } void TrayIcon::SetAdapterFlag(bool set) { KyDebug() << set; if (secState) return; if (!existAdapter) return; bluetooth_tray_icon->setVisible(set); if(QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKUIBLUETOOH)){ settings->set("tray-show", QVariant(set)); } if (set && QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKCC)) ukccGsetting->set("show",QVariant(true)); KyDebug() ; } void TrayIcon::setClickEnable(bool enable) { clickEnable = !enable; } void TrayIcon::setAdapterExist(bool exist, bool show) { KyInfo() << exist << show; if (exist) { if (QGSettings::isSchemaInstalled(GSETTING_SCHEMA_UKCC)) { ukccGsetting->set("show",QVariant(true)); } } existAdapter = exist; bluetooth_tray_icon->setVisible(exist && show); if (!bluetooth_tray_icon->isVisible()) { ; } } void TrayIcon::updateTrayiconMenuStyle() { QPalette pal = this->palette(); //托盘watcher异常时的规避方案 bug#214664 if (tray_Menu != nullptr) { pal.setColor(QPalette::Base, pal.color(QPalette::Base)); //处理Wayland环境setPalette(pal)不生效问题 pal.setColor(QPalette::Text, pal.color(QPalette::Text)); tray_Menu->setPalette(pal); } } ukui-bluetooth/ukui-bluetooth/popwidget/bluetoothfiletransferwidget.cpp0000664000175000017500000011722015167665770026013 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothfiletransferwidget.h" #include "config/xatom-helper.h" bool BluetoothFileTransferWidget::isShow = false; BluetoothFileTransferWidget::BluetoothFileTransferWidget(QStringList files, QMap> devicelist, QString dev_address): // QWidget(parent), selectedFiles(files) { isShow = true; send_state = _SEND_NONE; fileNums = selectedFiles.size(); if (envPC == Environment::LAIKA || envPC == Environment::MAVIS) is_Intel = true; else is_Intel = false; if(QGSettings::isSchemaInstalled("org.ukui.style")){ GSettings = new QGSettings("org.ukui.style"); connect(GSettings,&QGSettings::changed,this,&BluetoothFileTransferWidget::GSettingsChanges); } //窗管协议 // setAttribute(Qt::WA_TranslucentBackground); // setProperty("useSystemStyleBlur", true); MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_CLOSE; hints.decorations = MWM_DECOR_ALL; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); KyDebug() ; this->setWindowIcon(QIcon::fromTheme("bluetooth")); this->setWindowTitle(tr("Bluetooth File")); this->setAttribute(Qt::WA_DeleteOnClose); this->setBackgroundRole(QPalette::Base); this->setAutoFillBackground(true); const QByteArray transparency_id("org.ukui.control-center.personalise"); if(QGSettings::isSchemaInstalled(transparency_id)){ transparency_gsettings = new QGSettings(transparency_id); } if(QGSettings::isSchemaInstalled(transparency_id)){ tran=transparency_gsettings->get("transparency").toDouble()*255; connect(transparency_gsettings, &QGSettings::changed, this, [=] { tran=transparency_gsettings->get("transparency").toDouble()*255; this->update(); }); } tip_text = new QLabel(this); tip_text->setWordWrap(true); tip_text->setVisible(false); if (!initFileInfo()) return; target_icon = new QLabel(this); target_icon->setPixmap(file_icon.at(0).pixmap(64,64)); target_size = new QLabel(file_size.at(0),this); target_name = new QLabel(this); QFontMetrics fontMetrics(target_size->font()); QString fileName; QString Name = getFileName(selectedFiles.at(0)); if (fileNums > 1) { fileName = fontMetrics.elidedText("\"" + Name +"\"", Qt::ElideMiddle, 280); if(fileName != Name) target_name->setToolTip(Name); fileName.append(tr(" and ")+QString::number(fileNums)+tr(" files more")); }else { fileName = fontMetrics.elidedText(Name, Qt::ElideMiddle, 280); if(fileName != Name) target_name->setToolTip(Name); } target_name->setText(fileName); transNum = new QLabel("1/"+QString::number(fileNums), this); transNum->setVisible(false); m_progressbar = new QProgressBar(this); m_progressbar->setOrientation(Qt::Horizontal); m_progressbar->setTextVisible(false); m_progressbar->setVisible(false); m_progressbar->setFocusPolicy(Qt::NoFocus); m_progressbar->setMinimum(0); m_progressbar->setMaximum(100); m_progressbar->setValue(0); Tiptop = new QLabel(tr("Select Device"),this); ok_btn = new QPushButton(tr("OK"),this); ok_btn->setFocusPolicy(Qt::NoFocus); ok_btn->setFixedSize(100,36); if(selectedDev == nullptr) { ok_btn->setEnabled(false); } connect(ok_btn,&QPushButton::clicked,this,&BluetoothFileTransferWidget::onClicked_OK_Btn); cancel_btn = new QPushButton(tr("Cancel"),this); cancel_btn->setFocusPolicy(Qt::NoFocus); cancel_btn->setFixedSize(100,36); connect(cancel_btn,&QPushButton::clicked,this,[=]{ this->close(); if (target_dev.isEmpty()) return; if (this->send_state == _SEND_NONE) return; if (this->send_state != _SEND_COMPLETE || this->send_state != _SEND_FAILURE) emit stopSendFile(target_dev); }); qtw = new QTreeWidget(this); qtw->setFocusProxy(this); qtw->setFixedSize(456,356); qtw->setHeaderHidden(true); qtw->addTopLevelItems(toolbutton_list); qtw->setAlternatingRowColors(true); qtw->setProperty("highlightMode", true); this->setTabOrder(this,qtw); connect(qtw, &QTreeWidget::itemSelectionChanged, this, [=](){ if(qtw->selectedItems().size() == 0) return; int cnt = toolbutton_list.indexOf(qtw->selectedItems().at(0)); if(selectedDev != nullptr) { if (QGSettings::isSchemaInstalled("org.ukui.style") && GSettings->get("style-name").toString() != "ukui-dark") selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::BLACK))); else selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::WHITE))); } selectedDev = toolbutton_list.value(cnt); if (!ok_btn->isEnabled()) ok_btn->setEnabled(true); }); connect(qtw, &QTreeWidget::itemPressed, this, [=](QTreeWidgetItem *item, int column){ Q_UNUSED(column) if(selectedDev != nullptr) { if (GSettings->get("style-name").toString() != "ukui-dark") selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::BLACK))); else selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::WHITE))); } selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::WHITE))); selectedDev = item; if (!ok_btn->isEnabled()) ok_btn->setEnabled(true); }); initQTreeWidget(devicelist,dev_address); tranfer_status_icon = new QLabel(this); tranfer_status_icon->setPixmap(QIcon::fromTheme("kylin-dialog-warning").pixmap(22,22)); tranfer_status_icon->setFixedSize(22,22); tranfer_status_icon->setVisible(false); tranfer_status_text = new QLabel(this); tranfer_status_text->setText(tr("File Transfer Fail!")); tranfer_status_text->setVisible(false); if (is_Intel) initIntelLayout(); else initLayout(); this->setFocus(); kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true); Config::setSkipTaskBar(this); } BluetoothFileTransferWidget::~BluetoothFileTransferWidget() { if (this->send_state == _SENDING || this->send_state == _SEND_NONE) emit stopSendFile(target_dev); isShow = false; oversizedFile.clear(); hasemptyfile = false; closed = false; } void BluetoothFileTransferWidget::initQTreeWidget(QMap> devicelist, QString dev_address) { for(auto addr : devicelist.keys()){ BluezQt::Device::Type type = BluezQt::Device::stringToType(devicelist.value(addr).value("TypeName").toString()); if((type == BluezQt::Device::Phone)||(type == BluezQt::Device::Computer)){ QIcon icon; switch (type){ case BluezQt::Device::Type::Phone: icon = QIcon::fromTheme("phone-symbolic"); break; case BluezQt::Device::Type::Computer: icon = QIcon::fromTheme("video-display-symbolic"); break; case BluezQt::Device::Type::Uncategorized: default: icon = QIcon::fromTheme("bluetooth-symbolic"); break; } QTreeWidgetItem *item = new QTreeWidgetItem(qtw); item->setExpanded(true); item->setSizeHint(0,QSize(456, 50)); item->setText(0, devicelist.value(addr).value("Name").toString()); item->setToolTip(0, devicelist.value(addr).value("Name").toString()); if (devicelist.value(addr).contains("ShowName")) if (devicelist.value(addr).value("ShowName").toString() != QString("")) { item->setText(0, devicelist.value(addr).value("ShowName").toString()); item->setToolTip(0, devicelist.value(addr).value("ShowName").toString()); } if (GSettings->get("style-name").toString() != "ukui-dark") item->setIcon(0,QIcon(icon.pixmap(64,64))); else item->setIcon(0, QIcon(Config::loadSvg(icon.pixmap(64,64), Config::PixmapColor::WHITE))); itemMap.insert(item, addr); toolbutton_list.append(item); if (dev_address == addr) { item->setSelected(true); item->setIcon(0, QIcon(Config::loadSvg(icon.pixmap(64,64), Config::PixmapColor::WHITE))); selectedDev = item; if (!ok_btn->isEnabled()) ok_btn->setEnabled(true); } } } } void BluetoothFileTransferWidget::initLayout() { this->setFixedSize(520,580); //布局 qtw->resize(456,356); struct_pos pos; pos = Config::getWidgetPos(62,13,376,27, this->width()); tranfer_status_text->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,15,22,22, this->width()); tranfer_status_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(280,520,100,36, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(390,520,100,36, this->width()); ok_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,135,456,356, this->width()); qtw->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,104,Tiptop->width(), 0, this->width()); Tiptop->move(pos.x, pos.y); pos = Config::getWidgetPos(112,48,88,30, this->width()); target_size->setGeometry(pos.x, pos.y, pos.width, pos.high); tip_text->setFixedWidth(452); pos = Config::getWidgetPos(32, 12, tip_text->width(), 0, this->width()); tip_text->move(pos.x, pos.y); pos = Config::getWidgetPos(32,16,64,64, this->width()); target_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); target_name->setMinimumWidth(100); pos = Config::getWidgetPos(112, 23, target_name->width(), 0, this->width()); target_name->move(pos.x, pos.y); pos = Config::getWidgetPos(459,128,52,20, this->width()); transNum->setGeometry(pos.x, pos.y, pos.width, pos.high); if (fileNums > 1) { pos = Config::getWidgetPos(32,135,406,10, this->width()); m_progressbar->setGeometry(pos.x, pos.y, pos.width, pos.high); } else { pos = Config::getWidgetPos(32,145,456,10, this->width()); m_progressbar->setGeometry(pos.x, pos.y, pos.width, pos.high); } //字体 double size = GSettings->get("system-font-size").toDouble() - 11; QFont ft; ft.setPixelSize(14+size); target_size->setFont(ft); target_name->setFont(ft); transNum->setFont(ft); Tiptop->setFont(ft); ft.setPixelSize(18+size); tip_text->setFont(ft); tranfer_status_text->setFont(ft); } void BluetoothFileTransferWidget::initIntelLayout() { this->setWindowFlags(Qt::Dialog); this->setFixedSize(478,530); cancel_btn->setFixedSize(112,56); ok_btn->setFixedSize(112,56); target_name->setFixedHeight(30); target_size->setFixedWidth(88); qtw->resize(430,296); struct_pos pos; pos = Config::getWidgetPos(342,450,112,56, this->width()); ok_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(214,450,112,56, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(62,33,376,27, this->width()); tranfer_status_text->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,35,22,22, this->width()); tranfer_status_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,139,430,296, this->width()); qtw->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,111,100,20, this->width()); Tiptop->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,60,88,30, this->width()); target_size->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,24,430,56, this->width()); tip_text->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,24,64,64, this->width()); target_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,28,400,30, this->width()); target_name->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(410,148,52,20, this->width()); transNum->setGeometry(pos.x, pos.y, pos.width, pos.high); if (fileNums > 1) pos = Config::getWidgetPos(24,155,372,8, this->width()); else pos = Config::getWidgetPos(24,155,420,8, this->width()); m_progressbar->setGeometry(pos.x, pos.y, pos.width, pos.high); double size = GSettings->get("system-font-size").toDouble() - 11; QFont ft; ft.setPixelSize(14+size); target_size->setFont(ft); target_name->setFont(ft); transNum->setFont(ft); Tiptop->setFont(ft); ft.setPixelSize(18+size); tip_text->setFont(ft); tranfer_status_text->setFont(ft); this->show(); this->activateWindow(); } bool BluetoothFileTransferWidget::initFileInfo() { for (int i = 0; i < fileNums; i++) { Get_fie_type(i); } if (hasemptyfile) { QMessageBox *mbox = new QMessageBox(QMessageBox::Warning,tr("Warning"),tr("The selected file is empty, please select the file again !"),QMessageBox::Ok,this); mbox->show(); Config::setKdkGeometry(mbox->windowHandle(), mbox->width(), mbox->height(), true); mbox->exec(); this->deleteLater(); return false; } if (!oversizedFile.isEmpty()) { QString txt; for (auto item:oversizedFile.keys()) { QString size = oversizedFile.value(item); for (int i = 0; i < size.size(); i++) { if (i != 0 && size.at(i - 1) >= '0' && size.at(i - 1) <= '9' && size.at(i + 1) >= 'A' && size.at(i + 1) <= 'Z') { size.remove(i, 1); } } txt.append(getFileName(item) +" " + size + "\n"); } QMessageBox *mbox = new QMessageBox(QMessageBox::Warning,tr("Warning"),tr("The selected file is larger than 4GB, which is not supported transfer!"),QMessageBox::Ok,this); if (fileNums > 1) { mbox->setInformativeText(txt); } mbox->show(); Config::setKdkGeometry(mbox->windowHandle(), mbox->width(), mbox->height(), true); mbox->exec(); this->deleteLater(); return false; } for (int i = 0; i < fileNums; i++) { sendFilesList.append(selectedFiles.at(i) + QString(" ") + filetype.at(0)); } return true; } QString BluetoothFileTransferWidget::getFileName(QString filePath) { return filePath.split("/").at(filePath.split("/").length()-1); } QString BluetoothFileTransferWidget::changeUnit(QString size) { bool isBytes = false; int ii = QString(size).indexOf('i'); QString _tmp_size = size; _tmp_size.remove(ii, ii); if (ii != -1 && _tmp_size.at(_tmp_size.size() - 1) != 'B') _tmp_size.append("B"); QStringList strSlipList = _tmp_size.split(" "); if (strSlipList.at(strSlipList.size() - 1) == "字节") { _tmp_size.remove("字节"); isBytes = true; } if (strSlipList.at(strSlipList.size() - 1) == "bytes") { _tmp_size.remove("bytes"); isBytes = true; } if(isBytes) _tmp_size.append(tr("Bytes")); return _tmp_size; } void BluetoothFileTransferWidget::Get_fie_type(int i) { GError *error; KyDebug() << selectedFiles.at(i); GFile *file = g_file_new_for_path(selectedFiles.at(i).toStdString().c_str()); GFileInfo *file_info = g_file_query_info(file,"*",G_FILE_QUERY_INFO_NONE,NULL,&error); QString s_size = changeUnit(g_format_size_full(g_file_info_get_size(file_info),G_FORMAT_SIZE_IEC_UNITS)); quint64 ul_size = g_file_info_get_size(file_info); QString str = g_file_info_get_content_type(file_info); if (!hasemptyfile && ul_size == 0) hasemptyfile = true; if (ul_size >= 4250000000) { oversizedFile.insert(selectedFiles.at(i), s_size); return; } file_size.push_back(s_size); if (str.isEmpty() && g_file_info_has_attribute(file_info, "standard::fast-content-type")) str = g_file_info_get_attribute_string(file_info, "standard::fast-content-type"); filetype.push_back(str); QIcon fileicon; if (str.split("/").at(0) == "image"){ fileicon = QIcon(selectedFiles.at(i)); }else if (str.split("/").at(0) == "video") fileicon = QIcon::fromTheme("video-x-generic"); else if (str.split("/").at(0) == "audio" || str.split("/").at(0) == "application" || str.split("/").at(0) == "text" || str.split("/").at(0) == "inode"){ if (QIcon::hasThemeIcon(str.split("/").join("-"))) { fileicon = QIcon::fromTheme(str.split("/").join("-")); } } if (fileicon.isNull() && !str.isEmpty()){ QString icon = g_content_type_get_generic_icon_name(str.toUtf8().constData()); fileicon = QIcon::fromTheme(icon); } if (fileicon.isNull()) { fileicon = QIcon::fromTheme("text"); } file_icon.push_back(fileicon); } void BluetoothFileTransferWidget::Initialize_and_start_animation() { this->setFixedSize(520,236); QString nName; QString orgName; orgName = selectedDev->text(0); double size = GSettings->get("system-font-size").toDouble() - 11; QFont ft; ft.setPixelSize(18 + size); tip_text->setFont(ft); QFontMetrics fontMetrics(tip_text->font()); nName = fontMetrics.elidedText(orgName, Qt::ElideMiddle, 280); QString fileSource = QString(tr("Transferring to \"")+nName+"\""); tip_text->setText(fileSource); if (orgName != nName) tip_text->setToolTip(orgName); tip_text->update(); ok_btn->setVisible(false); cancel_btn->setVisible(true); m_progressbar->setVisible(true); transNum->setVisible(fileNums - 1); Tiptop->setVisible(false); qtw->setVisible(false); tip_text->setVisible(true); struct_pos pos; if (is_Intel) { pos = Config::getWidgetPos(342,450,112,56, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,67,64,64, this->width()); target_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,71,400,30, this->width()); target_name->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(104,103,88,30, this->width()); target_size->setGeometry(pos.x, pos.y, pos.width, pos.high); } else { pos = Config::getWidgetPos(390, 173, 100, 36, this->width()); cancel_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(32,65,64,64, this->width()); target_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(112,72,400,30, this->width()); target_name->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(112,97,88,30, this->width()); target_size->setGeometry(pos.x, pos.y, pos.width, pos.high); } if (is_Intel) this->setFixedSize(478,280); else this->setFixedSize(520,236); main_animation_group = new QParallelAnimationGroup(this); QPropertyAnimation *progress_action = new QPropertyAnimation(m_progressbar,"geometry"); QRect transfer_progress_rect = m_progressbar->geometry(); transfer_progress_rect.setWidth(0); progress_action->setStartValue(transfer_progress_rect); progress_action->setEndValue(m_progressbar->geometry()); progress_action->setDuration(200); main_animation_group->addAnimation(progress_action); main_animation_group->start(); } void BluetoothFileTransferWidget::insertNewFileList(QStringList fileList) { QMap newoversizeFile; QList fileIconList; QList fileSizeList; QList filetypeList; QList sendList; for (int i = 0; i < fileList.size(); i++) { GError *error; KyDebug() << fileList.at(i); GFile *file = g_file_new_for_path(fileList.at(i).toStdString().c_str()); GFileInfo *file_info = g_file_query_info(file,"*",G_FILE_QUERY_INFO_NONE,NULL,&error); KyDebug() << g_file_info_get_size(file_info) << g_file_info_get_content_type(file_info); KyDebug() ; QString s_size = changeUnit(g_format_size_full(g_file_info_get_size(file_info),G_FORMAT_SIZE_IEC_UNITS)); quint64 ul_size = g_file_info_get_size(file_info); QString str = g_file_info_get_content_type(file_info); if (!hasemptyfile && ul_size == 0) hasemptyfile = true; if (ul_size >= 4250000000) { newoversizeFile.insert(fileList.at(i), s_size); continue; } fileSizeList.push_back(s_size); filetypeList.push_back(str); KyDebug() ; QIcon fileicon; if (str.split("/").at(0) == "image"){ fileicon = QIcon(fileList.at(i)); if (fileicon.isNull()) { fileicon = QIcon::fromTheme("text"); } }else if (str.split("/").at(0) == "video") fileicon = QIcon::fromTheme("video-x-generic"); else if (str.split("/").at(0) == "audio" || str.split("/").at(0) == "application" || str.split("/").at(0) == "text" || str.split("/").at(0) == "inode"){ if (QIcon::hasThemeIcon(str.split("/").join("-"))) { fileicon = QIcon::fromTheme(str.split("/").join("-")); } else { fileicon = QIcon::fromTheme("text"); } }else fileicon = QIcon::fromTheme("text"); KyDebug() ; fileIconList.push_back(fileicon); sendList.append(fileList[i] + QString(" ") + str); } if (hasemptyfile) { QMessageBox *mbox = new QMessageBox(QMessageBox::Warning,tr("Warning"),tr("The selected file is empty, please select the file again !"),QMessageBox::Ok,this); mbox->show(); Config::setKdkGeometry(mbox->windowHandle(), mbox->width(), mbox->height(), true); mbox->exec(); return; } if (!newoversizeFile.isEmpty()) { QString txt; for (auto item:newoversizeFile.keys()) { txt.append(getFileName(item) +" " + newoversizeFile.value(item) + "\n"); } QMessageBox *mbox = new QMessageBox(QMessageBox::Warning,tr("Warning"),tr("The selected file is larger than 4GB, which is not supported transfer!"),QMessageBox::Ok,this); if (fileList.size() > 1) { mbox->setInformativeText(txt); } mbox->show(); Config::setKdkGeometry(mbox->windowHandle(), mbox->width(), mbox->height(), true); mbox->exec(); return; } filetype.append(filetypeList); file_icon.append(fileIconList); file_size.append(fileSizeList); selectedFiles.append(fileList); sendFilesList.append(sendList); fileNums += fileList.size(); int transfing = fileNums - selectedFiles.size() + 1; emit sender_dev_name(target_dev, sendList); QFontMetrics fontMetrics(target_size->font()); QString _filename = getFileName(selectedFiles.at(0)); QString _text; if (selectedFiles.size() == 1) { _text = fontMetrics.elidedText(_filename, Qt::ElideMiddle, 280); target_name->setText(_text); } else if(selectedFiles.size() > 1) { _filename = "\"" + _filename + "\""; _text = fontMetrics.elidedText(_filename, Qt::ElideMiddle, 280); target_name->setText(_text.append(tr(" and ")+QString::number(fileNums)+tr(" files more"))); } if (_text != _filename) target_name->setToolTip(_filename); transNum->setText(QString::number(transfing)+"/"+QString::number(fileNums)); struct_pos pos; if (is_Intel) if (fileNums > 1) pos = Config::getWidgetPos(24,155,372,8, this->width()); else pos = Config::getWidgetPos(24,155,420,8, this->width()); else if (fileNums > 1) pos = Config::getWidgetPos(32,135,406,15, this->width()); else pos = Config::getWidgetPos(32,145,454,15, this->width()); m_progressbar->setGeometry(pos.x, pos.y, pos.width, pos.high); transNum->setVisible((fileNums - 1) && (this->send_state == _SENDING)); this->update(); this->show(); this->activateWindow(); } void BluetoothFileTransferWidget::statusChangedSlot(QMap status) { if (status.value("transportType").toInt() == 1) { return; } if (status.value("dev").toString() != target_dev) { return; } if(status.contains("status")) { get_transfer_status(status.value("status").toInt()); } if (status.contains("progress")) { set_m_progressbar_value(status.value("progress").toInt()); } if (status.contains("fileFailedDisc")) { if(this->send_state == _SEND_NONE) { this->send_state = _SEND_ACTIVE; } tranfer_error(); this->send_state = _SEND_FAILURE; } } void BluetoothFileTransferWidget::powerChanged(bool powered) { if (powered) return; if (send_state == _SEND_FAILURE) return; closed =true; emit stopSendFile(target_dev); } void BluetoothFileTransferWidget::devattrChanged(QString address, QMap devAttr) { if (address != target_dev) return; if (send_state == _SEND_FAILURE) return; if (!devAttr.contains("Connected")) return; if (devAttr.value("Connected").toBool()) return; emit stopSendFile(target_dev); closed =true; KyDebug() << devAttr; tranfer_error(); } void BluetoothFileTransferWidget::get_transfer_status(int status) { KyDebug() << status ; if(status == Status::Complete){ if (selectedFiles.size() > 1) { selectedFiles.pop_front(); file_size.pop_front(); file_icon.pop_front(); QFontMetrics fontMetrics(target_size->font()); QString _filename = getFileName(selectedFiles.at(0)); QString _text; if (selectedFiles.size() == 1) { _text = fontMetrics.elidedText(_filename, Qt::ElideMiddle, 280); target_name->setText(_text); } else if(selectedFiles.size() > 1) { _filename = "\"" + _filename + "\""; _text = fontMetrics.elidedText(_filename, Qt::ElideMiddle, 280); target_name->setText(_text.append(tr(" and ")+QString::number(fileNums)+tr(" files more"))); } else { KyDebug(); tranfer_error(); this->show(); this->activateWindow(); this->send_state = _SEND_FAILURE ; } if (_text != _filename) target_name->setToolTip(_filename); target_size->setText(file_size.at(0)); target_icon->setPixmap(file_icon.at(0).pixmap(64,64)); int transfing = fileNums - selectedFiles.size() + 1; transNum->setText(QString::number(transfing)+"/"+QString::number(fileNums)); this->show(); this->activateWindow(); return; } if(is_Intel) { tip_text->setVisible(false); m_progressbar->setVisible(false); transNum->setVisible(false); cancel_btn->setText(tr("OK")); tranfer_status_icon->setFixedSize(64,64); tranfer_status_icon->setPixmap(QPixmap("/usr/share/ukui-bluetooth/file-transfer-success.svg")); tranfer_status_text->setText(tr("File Transmission Succeed!")); tranfer_status_text->setFixedWidth(500); QFont ft; ft.setPixelSize(16); tranfer_status_text->setFont(ft); struct_pos pos; pos = Config::getWidgetPos(207,57,64,64, this->width()); tranfer_status_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(191,129,200,24, this->width()); tranfer_status_text->setGeometry(pos.x, pos.y, pos.width, pos.high); tranfer_status_icon->setVisible(true); tranfer_status_text->setVisible(true); target_icon->setVisible(false); target_name->setVisible(false); target_size->setVisible(false); cancel_btn->setText(tr("Close")); return; } if (this->send_state != _SEND_COMPLETE || this->send_state != _SEND_FAILURE) emit stopSendFile(target_dev); m_progressbar->setValue(100); m_progressbar->repaint(); QString notify_msg = QString(tr("Transferred '") + getFileName(selectedFiles.at(0)) + tr("' and ") + QString::number(fileNums) + tr(" files in all to '") + selectedDev->text(0) + tr("'")); Config::SendNotifyMessage(QString(tr("File Transfer Success!")), notify_msg, QString("complete")); selectedFiles.clear(); file_size.clear(); file_icon.clear(); this->send_state = _SEND_COMPLETE ; this->close(); }else if(status == Status::Active){ this->send_state = _SENDING ; }else if(status == Status::Error){ if (this->send_state == _SEND_FAILURE || send_state == _SEND_COMPLETE) return ; KyDebug() ; tranfer_error(); this->send_state = _SEND_FAILURE ; this->show(); this->activateWindow(); } else if (status == Status::Static) { this->send_state = _SEND_NONE; } } void BluetoothFileTransferWidget::tranfer_error() { if (this->send_state == _SEND_FAILURE || send_state == _SEND_COMPLETE) return ; if (is_Intel){ tip_text->setVisible(false); m_progressbar->setVisible(false); transNum->setVisible(false); target_icon->setVisible(false); target_name->setVisible(false); target_size->setVisible(false); Tiptop->setVisible(false); qtw->setVisible(false); tranfer_status_icon->setFixedSize(64,64); tranfer_status_icon->setPixmap(QPixmap("/usr/share/ukui-bluetooth/file-transfer-failed.svg")); tranfer_status_text->setFixedWidth(500); QFont ft; ft.setPixelSize(16); tranfer_status_text->setFont(ft); struct_pos pos; pos = Config::getWidgetPos(207,57,64,64, this->width()); tranfer_status_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(191,129,200,24, this->width()); tranfer_status_text->setGeometry(pos.x, pos.y, pos.width, pos.high); cancel_btn->setText(tr("OK")); this->show(); this->activateWindow(); } KyDebug() << send_state; QString notify_msg = QString(tr("Transferring file '") + getFileName(selectedFiles.at(0)) + tr("' to '") + selectedDev->text(0) + tr("'")); Config::SendNotifyMessage(QString(tr("File Transfer Fail!")), notify_msg, QString("dialog-error")); if (this->send_state == _SEND_NONE && !closed) return; if (target_dev.isEmpty()) return; KyDebug() << send_state; emit stopSendFile(target_dev); this->close(); } int BluetoothFileTransferWidget::get_send_data_state() { return this->send_state; } void BluetoothFileTransferWidget::set_m_progressbar_value(int value) { if (--active_flag > 0) return; m_progressbar->setValue(value); m_progressbar->repaint(); } void BluetoothFileTransferWidget::GSettingsChanges(const QString &key) { KyDebug() << key; if(key == "styleName"){ if(GSettings->get("style-name").toString() == "ukui-default" || GSettings->get("style-name").toString() == "ukui-light"){ target_icon->setProperty("setIconHighlightEffectDefaultColor", QColor(0,0,0)); target_icon->setProperty("useIconHighlightEffect", 0x10); }else{ target_icon->setProperty("setIconHighlightEffectDefaultColor", QColor(255,255,255)); target_icon->setProperty("useIconHighlightEffect", 0x10); } this->update(); } if (key == "systemFontSize") { double size = GSettings->get("system-font-size").toDouble() - 11; QFont ft; ft.setPixelSize(14+size); target_size->setFont(ft); target_name->setFont(ft); transNum->setFont(ft); Tiptop->setFont(ft); Tiptop->adjustSize(); ft.setPixelSize(18+size); tip_text->setFont(ft); tranfer_status_text->setFont(ft); if (selectedDev == nullptr) return; QFontMetrics fontMetrics(tip_text->font()); QString nName; nName = fontMetrics.elidedText(selectedDev->text(0), Qt::ElideMiddle, 280); QString fileSource = QString(tr("Transferring to \"")+nName+"\""); QString txt = fontMetrics.elidedText(fileSource, Qt::ElideMiddle, tip_text->width()); tip_text->setText(txt); if (txt != fileSource) tip_text->setToolTip(selectedDev->text(0)); } } void BluetoothFileTransferWidget::onClicked_OK_Btn() { QString dev_addr = itemMap.value(selectedDev); KyDebug() << dev_addr; target_dev = dev_addr; emit this->sender_dev_name(dev_addr, sendFilesList); Initialize_and_start_animation(); send_state = _SEND_ACTIVE; } QRect BluetoothFileTransferWidget::getButton() { if (pressTabCnt <= 0) return QRect(); switch (pressTabCnt) { case 1: if (pressUDCnt == 0) pressUDCnt = 1; selectedBtn = nullptr; if (selectedDev != nullptr) selectedDev->setSelected(false); selectedItem = toolbutton_list.at(pressUDCnt - 1); selectedItem->setSelected(true); selectedDev = selectedItem; qtw->scrollToItem(selectedItem); if (!ok_btn->isEnabled()) ok_btn->setEnabled(true); return QRect(); case 2: selectedItem = nullptr; if (!ok_btn->isVisible() || !cancel_btn->isVisible()) ++pressTabCnt; if(ok_btn->isVisible()) { selectedBtn = ok_btn; ok_btn->setFocus(); return ok_btn->geometry(); } else if (cancel_btn->isVisible()){ selectedBtn = cancel_btn; cancel_btn->setFocus(); return cancel_btn->geometry(); } return QRect(); break; case 3: selectedItem = nullptr; selectedBtn = cancel_btn; cancel_btn->setFocus(); return cancel_btn->geometry(); break; case 4: selectedItem = nullptr; this->setFocus(); // selectedBtn = close_btn; // return close_btn->geometry(); return QRect(); break; default: break; } return QRect(); } void BluetoothFileTransferWidget::paintEvent(QPaintEvent *event) { getButton(); QWidget::paintEvent(event); return; QPainter pt(this); QColor color = QColor("#818181"); // color.setAlpha(tran); pt.setPen(color); QRect rect; rect = getButton(); pt.setRenderHint(QPainter::Antialiasing); pt.drawRect(rect); QWidget::paintEvent(event); } void BluetoothFileTransferWidget::keyPressEvent(QKeyEvent *event) { int size = toolbutton_list.size(); qDebug() << event->key(); switch (event->key()) { case Qt::Key_Tab: ++pressTabCnt; if (pressTabCnt == 5) pressTabCnt = 1; if(send_state != _SEND_NONE && pressTabCnt == 1) ++pressTabCnt; KyDebug() << "press Tab" << pressTabCnt << send_state; this->update(); break; case Qt::Key_Home: case Qt::Key_End: if (pressTabCnt != 1) return; pressUDCnt = (event->key() == Qt::Key_End) ? size : 1; KyDebug() << "press Home/End" << pressTabCnt << pressUDCnt; this->update(); break; case Qt::Key_PageDown: case Qt::Key_PageUp: if (pressTabCnt != 1) return; (event->key() == Qt::Key_PageDown) ? pressUDCnt += 6 : pressUDCnt -= 6; if (pressUDCnt > size) pressUDCnt = size; if (pressUDCnt < 1) pressUDCnt = 1; KyDebug() << "press page Down/Up" << pressTabCnt << pressUDCnt; this->update(); break; case Qt::Key_Down: case Qt::Key_Up: if (pressTabCnt != 1) return; (event->key() == Qt::Key_Down) ? ++pressUDCnt : --pressUDCnt; if (pressUDCnt > size) pressUDCnt = 1; if (pressUDCnt < 1) pressUDCnt = size; KyDebug() << "press Down/Up" << pressTabCnt << pressUDCnt; this->update(); break; case Qt::Key_Enter: case Qt::Key_Return: KyDebug() << "press Enter"; if (selectedBtn != nullptr && selectedBtn->isEnabled()) selectedBtn->clicked(); break; case Qt::Key_Escape: KyDebug() << "press Esc"; if (pressTabCnt == 0) { this->close(); if (!target_dev.isEmpty() && send_state == _SENDING) emit stopSendFile(target_dev); } qtw->clearSelection(); qtw->clearFocus(); ok_btn->setEnabled(false); pressTabCnt = 0; pressUDCnt = 0; selectedBtn = nullptr; if (selectedItem != nullptr) selectedItem->setSelected(false); selectedItem = nullptr; if (selectedDev != nullptr) { selectedDev->setSelected(false); if (GSettings->get("style-name").toString() != "ukui-dark") selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::BLACK))); else selectedDev->setIcon(0, QIcon(Config::loadSvg(selectedDev->icon(0).pixmap(64,64), Config::PixmapColor::WHITE))); } this->update(); break; default: break; } } ukui-bluetooth/ukui-bluetooth/popwidget/beforeturnoffhintwidget.cpp0000664000175000017500000000477215167665770025141 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "beforeturnoffhintwidget.h" #include "ui_beforeturnoffhintwidget.h" #include "config/config.h" BeforeTurnOffHintWidget::BeforeTurnOffHintWidget(QWidget *parent) : QDialog(parent), ui(new Ui::beforeTurnOffHintWidget) { ui->setupUi(this); QIcon warningIcon = QIcon::fromTheme("kylin-dialog-warning"); if (warningIcon.isNull()) warningIcon = QIcon::fromTheme("dialog-warning"); ui->iconLabel->setPixmap(warningIcon.pixmap(22,22)); ui->cancelButton->setChecked(true); if(QGSettings::isSchemaInstalled("org.ukui.style")){ styleGSettings = new QGSettings("org.ukui.style"); double size = styleGSettings->get("system-font-size").toDouble(); if (size == 10) ui->iconLabel->move(26,16); connect(styleGSettings,&QGSettings::changed,this,[=](QString key) { if (key == "systemFontSize") { double size = styleGSettings->get("system-font-size").toDouble(); if (size == 10) ui->iconLabel->move(26,16); else ui->iconLabel->move(26,19); this->repaint(); } }); } Config::setSkipTaskBar(this); Config::setWindowState(this); initConnect(); } BeforeTurnOffHintWidget::~BeforeTurnOffHintWidget() { delete ui; } QString BeforeTurnOffHintWidget::textDataStr() { return ui->textLabel->text(); } QString BeforeTurnOffHintWidget::cancelStr() { return ui->cancelButton->text(); } QString BeforeTurnOffHintWidget::closeStr() { return ui->closeButton->text(); } void BeforeTurnOffHintWidget::initConnect() { connect(ui->closeButton, &QPushButton::pressed, this, [=]() { emit buttonPressed(false); }); connect(ui->cancelButton, &QPushButton::pressed, this, [=]() { emit buttonPressed(true); }); } ukui-bluetooth/ukui-bluetooth/popwidget/beforeturnoffhintwidget.h0000664000175000017500000000246515167665770024603 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BEFORETURNOFFHINTWIDGET_H #define BEFORETURNOFFHINTWIDGET_H #include #include #include namespace Ui { class beforeTurnOffHintWidget; } class BeforeTurnOffHintWidget : public QDialog { Q_OBJECT public: explicit BeforeTurnOffHintWidget(QWidget *parent = nullptr); ~BeforeTurnOffHintWidget(); QString textDataStr(); QString cancelStr(); QString closeStr(); private: Ui::beforeTurnOffHintWidget *ui; QGSettings *styleGSettings; QLabel *textLabel; private: void initConnect(); signals: void buttonPressed(bool confirm); }; #endif // BEFORETURNOFFHINTWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/pincodewidget.h0000664000175000017500000000522215167665755022470 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef PINCODEWIDGET_H #define PINCODEWIDGET_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" class PinCodeWidget : public QWidget { Q_OBJECT public: explicit PinCodeWidget(QString name = "", QString pin = "", bool flag = true, QWidget* parent = nullptr); ~PinCodeWidget(); void pairFailureShow(); void updateUIInfo(const QString &name,const QString &pin); bool canceled = false; public slots: private slots: void onClick_close_btn(bool); void onClick_accept_btn(bool); void onClick_refuse_btn(bool); void GSettingsChanges(const QString &key); signals: void accepted(); void rejected(); void msgShowedOver(); private: QGSettings *settings = nullptr; QGSettings *transparency_gsettings = nullptr; QLabel *PIN_label = nullptr; QLabel *tip_label = nullptr; QLabel *top_label = nullptr; QLabel *warn_icon = nullptr; QLabel *title_icon = nullptr; QLabel *title_text = nullptr; double tran = 1; QVBoxLayout *main_layout = nullptr; QPushButton *close_btn = nullptr; QPushButton *accept_btn = nullptr; QPushButton *refuse_btn = nullptr; QString dev_name; QString PINCode; bool show_flag; bool is_Intel = false; double scale = 1.0; int pressCnt = 0; QPushButton *selectedBtn = nullptr; QPushButton *getButton(); protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); }; #endif // PINCODEWIDGET_H ukui-bluetooth/ukui-bluetooth/popwidget/pincodewidget.cpp0000664000175000017500000002447515167665770023033 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "pincodewidget.h" #include "config/xatom-helper.h" #include "config/config.h" PinCodeWidget::PinCodeWidget(QString name, QString pin, bool flag, QWidget *parent) : dev_name(name), PINCode(pin), show_flag(flag) { if (envPC == Environment::LAIKA || envPC == Environment::MAVIS) is_Intel = true; else is_Intel = false; if (envPC == Environment::HUAWEI && QGSettings::isSchemaInstalled("org.ukui.SettingsDaemon.plugins.xsettings")) scale = QGSettings("org.ukui.SettingsDaemon.plugins.xsettings").get("scaling-factor").toDouble(); if(QGSettings::isSchemaInstalled("org.ukui.style")){ settings = new QGSettings("org.ukui.style"); connect(settings,&QGSettings::changed,this,&PinCodeWidget::GSettingsChanges); } // setProperty("useSystemStyleBlur", true); this->setWindowModality(Qt::WindowModality::WindowModal); //窗管协议 MotifWmHints hints; hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS; hints.functions = MWM_FUNC_CLOSE; hints.decorations = MWM_DECOR_ALL; XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints); this->setWindowIcon(QIcon::fromTheme("bluetooth")); if (is_Intel) this->setWindowTitle(tr("Bluetooth Connection")); else this->setWindowTitle(tr("Bluetooth pairing")); this->setAttribute(Qt::WA_DeleteOnClose); this->setBackgroundRole(QPalette::Base); this->setAutoFillBackground(true); QFont ft_14, ft_16, ft_20, ft_24, ft_40; double ft_size = 12; if(QGSettings::isSchemaInstalled("org.ukui.style")) ft_size = settings->get("system-font-size").toDouble() - 11; ft_14.setPixelSize((14 + ft_size) * scale); ft_16.setPixelSize((16 + ft_size) * scale); ft_20.setPixelSize((20 + ft_size) * scale); ft_24.setPixelSize((24 + ft_size) * scale); ft_40.setPixelSize((40 + ft_size) * scale); tip_label = new QLabel(this); tip_label->setFont(ft_14); tip_label->setWordWrap(true); // tip_label->setToolTip(dev_name); PIN_label = new QLabel(this); PIN_label->setFont(ft_24); accept_btn = new QPushButton(tr("Connect"),this); accept_btn->setFocusPolicy(Qt::NoFocus); accept_btn->setProperty("isImportant", true); refuse_btn = new QPushButton(tr("Refuse"),this); refuse_btn->setFocusPolicy(Qt::NoFocus); if(show_flag){ connect(accept_btn,&QPushButton::clicked,this,&PinCodeWidget::onClick_accept_btn); connect(refuse_btn,&QPushButton::clicked,this,&PinCodeWidget::onClick_refuse_btn); }else{ connect(accept_btn,&QPushButton::clicked,this,&PinCodeWidget::onClick_close_btn); accept_btn->setText(tr("Confirm")); accept_btn->adjustSize(); //accept_btn->setddVisible(false); refuse_btn->setVisible(false); } struct_pos pos; if (is_Intel) { this->setWindowFlags(Qt::Dialog); this->setFixedSize(510, 239); tip_label->setFont(ft_16); PIN_label->setFont(ft_40); pos = Config::getWidgetPos(24,24,450,50, this->width()); tip_label->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(24,88,462,47, this->width()); PIN_label->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(374,159,112,56, this->width()); accept_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(246,159,112,56, this->width()); refuse_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); } else { this->setFixedSize(520 * scale ,172 * scale); pos = Config::getWidgetPos(25 * scale,58 * scale,207 * scale,36 * scale, this->width()); PIN_label->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(25 * scale,16 * scale,437 * scale,48 * scale, this->width()); tip_label->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(388 * scale,112 * scale,108 * scale,36 * scale, this->width()); accept_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); pos = Config::getWidgetPos(264 * scale,112 * scale,108 * scale,36 * scale, this->width()); refuse_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); } updateUIInfo(name, pin); QList list = QGuiApplication::screens(); this->move(list.at(0)->size().width()/2-this->width()/2,list.at(0)->size().height()/2-this->height()/2); kdk::WindowManager::setSkipTaskBar(this->windowHandle(), true); Config::setSkipTaskBar(this); Config::setWindowState(this); } PinCodeWidget::~PinCodeWidget() { if (refuse_btn->isVisible()) { emit this->rejected(); } emit msgShowedOver(); KyDebug() << dev_name << PINCode << show_flag; } void PinCodeWidget::pairFailureShow() { KyDebug(); if (is_Intel) { warn_icon = new QLabel(this); warn_icon->setFixedSize(64 * scale,64 * scale); KyDebug(); struct_pos pos; warn_icon->setPixmap(QPixmap("/usr/share/ukui-bluetooth/connection-failed.svg")); pos = Config::getWidgetPos(223 * scale,42 * scale,64 * scale,64 * scale, this->width()); warn_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); warn_icon->setVisible(true); tip_label->setText(QString(tr("Bluetooth Connect Failed"))); pos = Config::getWidgetPos(210 * scale,108 * scale,190 * scale,28 * scale, this->width()); tip_label->setGeometry(pos.x, pos.y, pos.width, pos.high); tip_label->setStyleSheet("QLabel{\ font-family: NotoSansCJKsc;\ font-size: 16px;\ line-height: 19px;\ text-align: center;\ color: #FB5050;}"); PIN_label->setVisible(false); accept_btn->setVisible(false); refuse_btn->setText(tr("Close")); pos = Config::getWidgetPos(374 * scale,159 * scale,112 * scale,56 * scale, this->width()); refuse_btn->setGeometry(pos.x, pos.y, pos.width, pos.high); return; } KyDebug()<< this ; this->setHidden(true); emit msgShowedOver(); } void PinCodeWidget::updateUIInfo(const QString &name, const QString &pin) { KyDebug() << this->isActiveWindow() ; PINCode = pin; PIN_label->setText(pin); PIN_label->update(); QFontMetrics fontMetrics(tip_label->font()); QString Name = fontMetrics.elidedText(name, Qt::ElideRight, 240); QString tip_text; if(show_flag) if (is_Intel) tip_text = tr("If the PIN on \'")+Name+tr("\' is the same as this PIN. Please press \'Connect\'"); else tip_text = tr("If \'")+Name+tr("\' the PIN on is the same as this PIN. Please press \'Connect\'."); else tip_text = QString(tr("Please enter the following PIN code on the bluetooth device '%1' and press enter to pair:")).arg(Name); // QString show_text = fontMetrics.elidedText(tip_text, Qt::ElideMiddle, tip_label->width()); if (Name.length() != name.length()) tip_label->setToolTip(name); tip_label->setText(tip_text); tip_label->update(); if (!this->isActiveWindow()) this->setHidden(false); } void PinCodeWidget::onClick_close_btn(bool) { KyDebug(); if (show_flag) { emit this->rejected(); } this->close(); } void PinCodeWidget::onClick_accept_btn(bool) { KyDebug() << "pincodewindget.cpp : accpet"; emit this->accepted(); this->close(); } void PinCodeWidget::onClick_refuse_btn(bool) { emit this->rejected(); this->close(); } void PinCodeWidget::GSettingsChanges(const QString &key) { KyDebug()<< key; if(key == "styleName"){ this->update(); } if (key == "systemFontSize") { double size = settings->get("system-font-size").toDouble() - 11; KyDebug()<< size; QFont ft, ft1; ft.setPixelSize((14 + size) * scale); tip_label->setFont(ft); ft1.setPixelSize((24 + size) * scale); PIN_label->setFont(ft1); } } QPushButton* PinCodeWidget::getButton() { switch (pressCnt) { case 1: if (!accept_btn->isVisible() || !refuse_btn->isVisible()) ++pressCnt; if(accept_btn->isVisible()) return accept_btn; else if (refuse_btn->isVisible()){ return refuse_btn; } return nullptr; case 2: return refuse_btn; case 3: // return close_btn; default: return nullptr; } } void PinCodeWidget::paintEvent(QPaintEvent *event) { selectedBtn = getButton(); if(selectedBtn) selectedBtn->setFocus(); else this->setFocus(); QWidget::paintEvent(event); return; QPainter pt(this); QColor color = QColor("#818181"); pt.setPen(color); selectedBtn = getButton(); if (selectedBtn == nullptr) return; QRect rect = selectedBtn->geometry(); pt.setRenderHint(QPainter::Antialiasing); pt.drawRect(rect); QWidget::paintEvent(event); } void PinCodeWidget::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case Qt::Key_Tab: KyDebug() << "press Tab"; ++pressCnt; if (pressCnt == 4) pressCnt = 1; this->update(); break; case Qt::Key_Enter: case Qt::Key_Return: KyDebug() << "press Enter"; if (selectedBtn == nullptr) return; selectedBtn->clicked(); break; case Qt::Key_Escape: KyDebug() << "press Esc"; if (pressCnt == 0) this->close(); pressCnt = 0; this->update(); break; default: break; } } ukui-bluetooth/ukui-bluetooth/component/0000775000175000017500000000000015167665770017466 5ustar fengfengukui-bluetooth/ukui-bluetooth/component/kyfiledialog.cpp0000664000175000017500000000555215167665755022647 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "kyfiledialog.h" //被注释部分主要用于文件夹的选择,用于目录传输功能,暂不深度开发 KyFileDialog::KyFileDialog(QWidget *parent) : QFileDialog(parent) { openButton = NULL; listView = NULL; treeView = NULL; _selectedFiles.clear(); this->setWindowIcon(QIcon::fromTheme("preferences-system-bluetooth")); this->setWindowTitle(QString(tr("Bluetooth File"))); this->setFileMode(QFileDialog::ExistingFiles); // QList btns = this->findChildren(); // for (int i = 0; i < btns.size(); ++i) { // QString text = btns[i]->text(); // if (text.toLower().contains("open") || text.toLower().contains("choose") // || btns[i]->text() == "打开(&O)" || btns[i]->text() == "选择(&C)") // { // openButton = btns[i]; // break; // } // } // if (!openButton) { // qDebug() << "-- NULL --"; // return; // } // openButton->installEventFilter(this); // openButton->disconnect(SIGNAL(clicked())); // connect(openButton, SIGNAL(clicked()), this, SLOT(chooseClicked())); //多选 listView = findChild("listView"); if (listView) listView->setSelectionMode(QAbstractItemView::ExtendedSelection); treeView = findChild(); if (treeView) treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); } QStringList KyFileDialog::getselectedFiles() { return _selectedFiles; } void KyFileDialog::chooseClicked() { QModelIndexList indexList = listView->selectionModel()->selectedIndexes(); foreach (QModelIndex index, indexList) { if (index.column()== 0) _selectedFiles.append(this->directory().absolutePath() + "/" + index.data().toString()); } QDialog::accept(); } //文件和文件夹均可选择 //bool KyFileDialog::eventFilter( QObject* watched, QEvent* event ) //{ // QPushButton *btn = qobject_cast(watched); // if (btn) // { // if(event->type()==QEvent::EnabledChange) { // if (!btn->isEnabled()) // btn->setEnabled(true); // } // } // return QWidget::eventFilter(watched, event); //} ukui-bluetooth/ukui-bluetooth/component/kyfiledialog.h0000664000175000017500000000276415167665755022316 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef KYFILEDIALOG_H #define KYFILEDIALOG_H #include #include #include #include #include #include #include #include #include #include #include //此类意在改写QFileDialog无法同时选定文件和文件夹的问题 class KyFileDialog : public QFileDialog { Q_OBJECT public: explicit KyFileDialog(QWidget *parent = Q_NULLPTR); QStringList getselectedFiles(); //取消禁止选择文件 // bool eventFilter( QObject* watched, QEvent* event ); public slots: void chooseClicked(); private: QListView *listView; QTreeView *treeView; QPushButton *openButton; QStringList _selectedFiles; }; #endif // KYFILEDIALOG_H ukui-bluetooth/ukui-bluetooth/component/switchbutton.h0000664000175000017500000000553115167665755022403 0ustar fengfeng/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * */ #ifndef SWITCHBUTTON_H #define SWITCHBUTTON_H #include #include #include #include #include #include #define OFF_BG_DARK_COLOR "#404040" #define OFF_HOVER_BG_DARK_COLOR "#666666" #define ON_BG_DARK_COLOR "#3790FA" #define ON_HOVER_BG_DARK_COLOR "#40A9FB" #define DISABLE_DARK_COLOR "#474747" #define DISABLE_RECT_DARK_COLOR "#6E6E6E" #define ENABLE_RECT_DARK_COLOR "#FFFFFF" #define OFF_BG_LIGHT_COLOR "#E0E0E0" #define OFF_HOVER_BG_LIGHT_COLOR "#B3B3B3" #define ON_BG_LIGHT_COLOR "#3790FA" #define ON_HOVER_BG_LIGHT_COLOR "#40A9FB" #define DISABLE_LIGHT_COLOR "#E9E9E9" #define DISABLE_RECT_LIGHT_COLOR "#B3B3B3" #define ENABLE_RECT_LIGHT_COLOR "#FFFFFF" class SwitchButton : public QWidget { Q_OBJECT public: SwitchButton(QWidget *parent = 0); ~SwitchButton(); void setChecked(bool checked); bool isChecked(); void setFocusStyle(bool val); void setDisabledFlag(bool); bool getDisabledFlag(); protected: void mousePressEvent(QMouseEvent *); void resizeEvent(QResizeEvent *); void paintEvent(QPaintEvent *); void enterEvent(QEvent *event); void leaveEvent(QEvent *event); void drawBg(QPainter * painter); void drawSlider(QPainter * painter); void changeColor(const QString &themes); private: bool checked; bool disabled; bool focused = false; QColor bgColorOff; QColor bgColorOn; QColor bgHoverOnColor; QColor bgHoverOffColor; QColor bgColorDisabled; QColor sliderColorEnabled; QColor sliderColorDisabled; QColor rectColorEnabled; QColor rectColorDisabled; QGSettings *m_qtThemeSetting; QGSettings *m_gtkThemeSetting; int space; //滑块离背景间隔 int rectRadius; //圆角角度 int step; //移动步长 int startX; int endX; bool hover; QTimer * timer; private slots: void updatevalue(); Q_SIGNALS: void checkedChanged(bool checked); void clickedButton(bool value); }; #endif // SWITCHBUTTON_H ukui-bluetooth/ukui-bluetooth/component/switchbutton.cpp0000664000175000017500000002115215167665755022733 0ustar fengfeng/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "switchbutton.h" #include #include #define THEME_QT_SCHEMA "org.ukui.style" #define THEME_GTK_SCHEMA "org.mate.interface" SwitchButton::SwitchButton(QWidget *parent) : QWidget(parent) { // this->resize(QSize(52, 24)); this->setFixedSize(QSize(50, 24)); checked = false; hover = false; disabled = false; space = 4; // rectRadius = 5; step = width() / 40; startX = 0; endX= 0; timer = new QTimer(this); timer->setInterval(5); connect(timer, SIGNAL(timeout()), this, SLOT(updatevalue())); if (QGSettings::isSchemaInstalled(THEME_GTK_SCHEMA) && QGSettings::isSchemaInstalled(THEME_QT_SCHEMA)) { QByteArray qtThemeID(THEME_QT_SCHEMA); QByteArray gtkThemeID(THEME_GTK_SCHEMA); m_gtkThemeSetting = new QGSettings(gtkThemeID,QByteArray(),this); m_qtThemeSetting = new QGSettings(qtThemeID,QByteArray(),this); QString style = m_qtThemeSetting->get("styleName").toString(); changeColor(style); connect(m_qtThemeSetting,&QGSettings::changed, [this] (const QString &key) { QString style = m_qtThemeSetting->get("styleName").toString(); if (key == "styleName") { changeColor(style); } }); } } SwitchButton::~SwitchButton() { } void SwitchButton::paintEvent(QPaintEvent *){ //启用反锯齿 QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); drawBg(&painter); drawSlider(&painter); //焦点预选框 if (!focused) return; QColor color = QColor("#818181"); painter.setPen(color); QRect rect = this->rect(); rect.setWidth(this->rect().width()); rect.setHeight(this->rect().height()); painter.drawRect(rect); } void SwitchButton::changeColor(const QString &themes) { if (hover) { return ; } if (themes == "ukui-dark" || themes == "ukui-black" || themes == "ukui-default") { bgColorOff = QColor(OFF_BG_DARK_COLOR); bgColorOn = QColor(ON_BG_DARK_COLOR); rectColorEnabled = QColor(ENABLE_RECT_DARK_COLOR); rectColorDisabled = QColor(DISABLE_RECT_DARK_COLOR); sliderColorDisabled = QColor(DISABLE_RECT_DARK_COLOR); sliderColorEnabled = QColor(ENABLE_RECT_DARK_COLOR); bgHoverOnColor = QColor(ON_HOVER_BG_DARK_COLOR); bgHoverOffColor = QColor(OFF_HOVER_BG_DARK_COLOR); bgColorDisabled = QColor(DISABLE_DARK_COLOR); } else { bgColorOff = QColor(OFF_BG_LIGHT_COLOR); bgColorOn = QColor(ON_BG_LIGHT_COLOR); rectColorEnabled = QColor(ENABLE_RECT_LIGHT_COLOR); rectColorDisabled = QColor(DISABLE_RECT_LIGHT_COLOR); sliderColorDisabled = QColor(DISABLE_RECT_LIGHT_COLOR); sliderColorEnabled = QColor(ENABLE_RECT_LIGHT_COLOR); bgHoverOnColor = QColor(ON_HOVER_BG_LIGHT_COLOR); bgHoverOffColor = QColor(OFF_HOVER_BG_LIGHT_COLOR); bgColorDisabled = QColor(DISABLE_LIGHT_COLOR); } } void SwitchButton::drawBg(QPainter *painter){ painter->save(); // painter->setPen(Qt::NoPen); if (disabled) { painter->setPen(Qt::NoPen); painter->setBrush(bgColorDisabled); } else { if (!checked){ painter->setPen(Qt::NoPen); painter->setBrush(bgColorOff); } else { painter->setPen(Qt::NoPen); painter->setBrush(bgColorOn); } } //circle out // QRect rect(space, space, width() - space * 2, height() - space * 2); // painter->drawRoundedRect(rect, rectRadius, rectRadius); //circle in QRect rect(0, 0, width(), height()); //半径为高度的一半 int radius = rect.height() / 2; //圆的宽度为高度 int circleWidth = rect.height(); QPainterPath path; path.moveTo(radius, rect.left()); path.arcTo(QRectF(rect.left(), rect.top(), circleWidth, circleWidth), 90, 180); path.lineTo(rect.width() - radius, rect.height()); path.arcTo(QRectF(rect.width() - rect.height(), rect.top(), circleWidth, circleWidth), 270, 180); path.lineTo(radius, rect.top()); painter->drawPath(path); painter->restore(); } void SwitchButton::drawSlider(QPainter *painter){ painter->save(); painter->setPen(Qt::NoPen); if (!disabled){ painter->setBrush(sliderColorEnabled); } else painter->setBrush(sliderColorDisabled); //circle out // QRect rect(0, 0, width() - space, height() - space); // int sliderwidth = rect.height(); // QRect sliderRect(startX, space / 2, sliderwidth, sliderwidth); // painter->drawEllipse(sliderRect); //circle in if (disabled) { if (checked) { QRect smallRect(8, height() / 2 - 2, 10 , 4); painter->drawRoundedRect(smallRect,3,3); } else { QRect smallRect(width() - 8 * 2, height() / 2 - 2, 10 , 4); painter->drawRoundedRect(smallRect,3,3); } } QRect rect(0, 0, width(), height()); int sliderWidth = rect.height() - space * 2; QRect sliderRect(startX + space, space, sliderWidth, sliderWidth); painter->drawEllipse(sliderRect); painter->restore(); } void SwitchButton::mousePressEvent(QMouseEvent *event){ if (timer->isActive()) { return ; } if (!disabled){ checked = !checked; emit clickedButton(checked); step = width() / 40; if (checked){ //circle out // endX = width() - height() + space; //circle in endX = width() - height(); } else { endX = 0; } timer->start(); } else { endX = 0; } return QWidget::mousePressEvent(event); } void SwitchButton::resizeEvent(QResizeEvent *){ // step = width() / 40; if (checked){ //circle out // startX = width() - height() + space; //circle in startX = width() - height(); } else startX = 0; update(); } void SwitchButton::enterEvent(QEvent *event) { if (focused) return; bgColorOn = bgHoverOnColor; bgColorOff = bgHoverOffColor; hover = true; update(); return QWidget::enterEvent(event); } void SwitchButton::leaveEvent(QEvent *event) { if (focused) return; hover = false; QString style = m_qtThemeSetting->get("styleName").toString(); changeColor(style); update(); return QWidget::leaveEvent(event); } void SwitchButton::setFocusStyle(bool val) { focused = val; if (val) { bgColorOn = bgHoverOnColor; bgColorOff = bgHoverOffColor; hover = true; update(); } else { hover = false; QString style = m_qtThemeSetting->get("styleName").toString(); changeColor(style); update(); } this->update(); } void SwitchButton::updatevalue(){ if (disabled) { return ; } if (checked) if (startX < endX){ startX = startX + step; } else { startX = endX; timer->stop(); } else { if (startX > endX){ startX = startX - step; } else { startX = endX; timer->stop(); } } update(); } void SwitchButton::setChecked(bool checked){ if (this->checked != checked){ this->checked = checked; emit checkedChanged(checked); update(); } step = width() / 40; if (checked){ //circle out // endX = width() - height() + space; //circle in endX = width() - height(); } else { endX = 0; } timer->start(); } bool SwitchButton::isChecked(){ return this->checked; } void SwitchButton::setDisabledFlag(bool value) { disabled = value; update(); } bool SwitchButton::getDisabledFlag() { return disabled; } ukui-bluetooth/ukui-bluetooth/component/kyhline.h0000664000175000017500000000200615167665755021303 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef KYHLINE_H #define KYHLINE_H #include #include #include #include class KyHLine : public QFrame { public: KyHLine(QWidget * parent = nullptr); ~KyHLine() = default; private: QGSettings *StyleSettings; protected: void paintEvent(QPaintEvent *event); }; #endif // KYHLINE_H ukui-bluetooth/ukui-bluetooth/component/kyhline.cpp0000664000175000017500000000302015167665755021633 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "kyhline.h" KyHLine::KyHLine(QWidget *parent) : QFrame(parent) { this->setFixedHeight(1); if(QGSettings::isSchemaInstalled("org.ukui.style")) { StyleSettings = new QGSettings("org.ukui.style"); connect(StyleSettings,&QGSettings::changed,this,[=](const QString &key) { if(key == "styleName") this->update(); }); } } void KyHLine::paintEvent(QPaintEvent * e) { QPainter p(this); QColor color; if(StyleSettings->get("style-name").toString() == "ukui-default"){ color = QColor(217, 217, 217); } else color = qApp->palette().color(QPalette::Active, QPalette::BrightText); color.setAlphaF(0.08); p.save(); p.setBrush(color); p.setPen(Qt::transparent); p.drawRoundedRect(this->rect(), 6, 6); p.restore(); return QFrame::paintEvent(e); } ukui-bluetooth/service/0000775000175000017500000000000015167665770014144 5ustar fengfengukui-bluetooth/service/config.h0000664000175000017500000000775615167665770015601 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef CONFIG_H #define CONFIG_H #include #include #include #include #include #include #include #include #include #include #include #include extern "C" { #include #include #include } #include "CSingleton.h" //全局变量,是否是华为机器, 默认false, 在config.cpp文件定义 enum Environment { NOMAL = 0, HUAWEI, LAIKA, MAVIS }; //gsetting name define #define GSETTING_SCHEMA_UKUIBLUETOOH "org.ukui.bluetooth" #define GSETTING_SCHEMA_UKCC "org.ukui.control-center.plugins" #define GSETTING_PACH_UKCC "/org/ukui/control-center/plugins/Bluetooth/" extern Environment envPC; class Config : public QObject { public: Config(QObject *parent = nullptr); ~Config(); int init(void); bool power_switch(void){ return m_power_switch; } void power_switch(bool); bool discoverable_switch(void){ return m_discoverable_switch; } void discoverable_switch(bool); QStringList finally_audiodevice(void){ return m_finally_audiodevices; } void finally_audiodevice(QString); void remove_finally_audiodevice(QString); QString adapter_addr(void){ return m_adapter_addr; } void adapter_addr(QString); QString file_save_path(void){ return m_file_save_path; } void file_save_path(QString); bool activeconnection(void){ return m_activeconnection; } void activeconnection(bool); bool trayShow(void){ return m_tray_show; } void trayShow(bool); QString loglevel(void); void loglevel(QString); void loglevel(int); bool leaveLock(void) { return m_leaveLock; } void leaveLock(bool); ///////////////////////////////////////////////////////// bool bluetooth_block(void){ return m_bluetooth_block; } void bluetooth_block(bool v){ m_bluetooth_block = v; } bool systemSleepFlag(void){ return m_systemSleepFlag; } void systemSleepFlag(bool v){ m_systemSleepFlag = v; } bool showBluetooth(void){ return m_showBluetooth; } void showBluetooth(bool v){ m_showBluetooth = v; } QString get_active_user(void) { return m_active_user; } QString active_user(void); void active_user(QString v){ m_active_user = v; } void set_rename(QString, QString); QString get_rename(QString); void delete_rename(QString); bool AudioCombine(void) {return m_audioCombine; } void AudioCombine(bool v); protected slots: private: void init_rename(void); void init_conf(void); protected: QString getActiveUser(void); QSettings * m_ukui_bluetooth = nullptr; private: bool m_power_switch = false; bool m_discoverable_switch = true; QStringList m_finally_audiodevices; QString m_adapter_addr; QString m_file_save_path; bool m_activeconnection = false; bool m_tray_show = true; bool m_audioCombine = false; //debug, info, warning QString m_loglevel = "info"; bool m_leaveLock = false; //内部属性 bool m_bluetooth_block = false; bool m_systemSleepFlag = false; bool m_showBluetooth = false; QString m_active_user; //别名 QMap m_rename; friend class SingleTon; }; typedef SingleTon CONFIG; #endif // CONFIG_H ukui-bluetooth/service/daemon.h0000664000175000017500000000556615167665770015574 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DAEMON_H #define DAEMON_H #include "bluetoothagent.h" #include "bluetoothobexagent.h" #include "config.h" #include "buriedpointdata.h" #ifdef BATTERY #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include "CSingleton.h" class Daemon : public QObject { Q_OBJECT public: explicit Daemon(QObject *parent = nullptr); ~Daemon(); int start(void); int stop(void); int unblock_bluetooth(void); protected: int init_bluez(void); int init_obex(void); int init_sys_monistor(void); static void static_activeuser_callback(char *old_user, char *new_user, void *userdata); private: int __init_bluez_adapter(void); protected slots: //bluez void operationalChanged(bool operational); void bluetoothOperationalChanged(bool operational); void bluetoothBlockedChanged(bool blocked); void adapterAdded(BluezQt::AdapterPtr adapter); void adapterRemoved(BluezQt::AdapterPtr adapter); void usableAdapterChanged(BluezQt::AdapterPtr adapter); void allAdaptersRemoved(); //sleep void monitorSleepSlot(bool); void activeUserChange(QString); private: void __unblock_sleep(int); void wait_for_finish(BluezQt::PendingCall *call); protected: BluezQt::Manager * m_bluez = nullptr; friend class SingleTon; }; typedef SingleTon DAEMON; #endif // DAEMON_H ukui-bluetooth/service/bluetoothobexagent.h0000664000175000017500000000364415167665770020226 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHOBEXAGENT_H #define BLUETOOTHOBEXAGENT_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "CSingleton.h" class BluetoothObexAgent : public BluezQt::ObexAgent { Q_OBJECT public: explicit BluetoothObexAgent(QObject *parent = nullptr); ~BluetoothObexAgent(); void authorizePush (BluezQt::ObexTransferPtr transfer,BluezQt::ObexSessionPtr session, const BluezQt::Request &request); QDBusObjectPath objectPath() const override; void cancel (); void release (); private: BluezQt::ObexSessionPtr m_session = nullptr; friend class SingleTon; }; typedef SingleTon BLUETOOTHOBEXAGENT; #endif // BLUETOOTHOBEXAGENT_H ukui-bluetooth/service/bluetoothagent.h0000664000175000017500000000440015167665770017337 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHAGENT_H #define BLUETOOTHAGENT_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include "CSingleton.h" class BluetoothAgent : public BluezQt::Agent { Q_OBJECT public: explicit BluetoothAgent(QObject *parent = nullptr); QDBusObjectPath objectPath() const override; void requestPinCode(BluezQt::DevicePtr device, const BluezQt::Request &request) override; void displayPinCode(BluezQt::DevicePtr device, const QString &pinCode) override; void requestPasskey(BluezQt::DevicePtr device, const BluezQt::Request &request) override; void displayPasskey(BluezQt::DevicePtr device, const QString &passkey, const QString &entered) override; void requestConfirmation(BluezQt::DevicePtr device, const QString &passkey, const BluezQt::Request<> &request) override; void requestAuthorization(BluezQt::DevicePtr device, const BluezQt::Request<> &request) override; void authorizeService(BluezQt::DevicePtr device, const QString &uuid, const BluezQt::Request<> &request) override; void cancel() override; void release() override; private: friend class SingleTon; }; typedef SingleTon BLUETOOTHAGENT; #endif // BLUETOOTHAGENT_H ukui-bluetooth/service/daemon.cpp0000664000175000017500000001472415167665770016123 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "daemon.h" #include #include #include #include "sessiondbusregister.h" #include "adapter.h" extern "C" { #include #include } Daemon::Daemon(QObject *parent) { } Daemon::~Daemon() { } int Daemon::start() { this->init_bluez(); this->init_sys_monistor(); return 0; } int Daemon::stop() { return 0; } int Daemon::unblock_bluetooth() { if(m_bluez->isBluetoothBlocked()) { m_bluez->setBluetoothBlocked(false); } return 0; } int Daemon::init_bluez() { m_bluez = new BluezQt::Manager(this); BluezQt::InitManagerJob *job = m_bluez->init(); job->exec(); connect(m_bluez,&BluezQt::Manager::operationalChanged,this, &Daemon::operationalChanged); connect(m_bluez,&BluezQt::Manager::bluetoothOperationalChanged,this, &Daemon::bluetoothOperationalChanged); connect(m_bluez,&BluezQt::Manager::bluetoothBlockedChanged,this, &Daemon::bluetoothBlockedChanged); connect(m_bluez,&BluezQt::Manager::adapterAdded,this, &Daemon::adapterAdded); connect(m_bluez,&BluezQt::Manager::adapterRemoved,this, &Daemon::adapterRemoved); connect(m_bluez,&BluezQt::Manager::usableAdapterChanged,this, &Daemon::usableAdapterChanged); connect(m_bluez,&BluezQt::Manager::allAdaptersRemoved,this, &Daemon::allAdaptersRemoved); KyInfo() << m_bluez->isOperational() << m_bluez->isBluetoothOperational(); emit m_bluez->operationalChanged(m_bluez->isOperational()); emit m_bluez->bluetoothBlockedChanged(m_bluez->isBluetoothBlocked()); if(m_bluez->adapters().size() > 0) { this->__init_bluez_adapter(); } return 0; } int Daemon::init_sys_monistor() { KyInfo(); //部分机器在系统s3/s4会对蓝牙适配器进行移除添加操作 if (QDBusConnection::systemBus().connect("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "PrepareForSleep", this, SLOT(monitorSleepSlot(bool)))) { KyDebug() << "PrepareForSleep signal connected successfully to slot"; } else { KyDebug() << "PrepareForSleep signal connection was not successful"; } kdk_system_register_switch_user_handle(&Daemon::static_activeuser_callback, NULL); return 0; } void Daemon::static_activeuser_callback(char *old_user, char *new_user, void *userdata) { KyInfo() << "new user: " << new_user; if (DAEMON::getInstance()) { QMetaObject::invokeMethod(DAEMON::getInstance(), "activeUserChange", Qt::QueuedConnection, Q_ARG(QString, new_user)); } else { KyCritical() << "null DAEMON::getInstance()"; } } int Daemon::__init_bluez_adapter() { KyInfo(); if(m_bluez->adapters().size() > 0) { for (auto item : m_bluez->adapters()) { ADAPTERMNG::getInstance()->add(item); } } return 0; } void Daemon::operationalChanged(bool operational) { KyInfo() << operational; if(operational) { if(!BLUETOOTHAGENT::getInstance()) { BLUETOOTHAGENT::instance(this); BluezQt::PendingCall * call = m_bluez->registerAgent(BLUETOOTHAGENT::getInstance()); this->wait_for_finish(call); call = m_bluez->requestDefaultAgent(BLUETOOTHAGENT::getInstance()); this->wait_for_finish(call); } } else { if(BLUETOOTHAGENT::getInstance()) { BluezQt::PendingCall * call = m_bluez->unregisterAgent(BLUETOOTHAGENT::getInstance()); this->wait_for_finish(call); BLUETOOTHAGENT::destroyInstance(); } } } void Daemon::bluetoothOperationalChanged(bool operational) { KyInfo() << operational; } void Daemon::bluetoothBlockedChanged(bool blocked) { KyInfo() << blocked; CONFIG::getInstance()->bluetooth_block(blocked); ADAPTERMNG::getInstance()->bluetooth_block(blocked); } void Daemon::adapterAdded(BluezQt::AdapterPtr adapter) { KyInfo() << adapter->address(); ADAPTERMNG::getInstance()->add(adapter); } void Daemon::adapterRemoved(BluezQt::AdapterPtr adapter) { KyInfo() << adapter->address(); ADAPTERMNG::getInstance()->remove(adapter); } void Daemon::usableAdapterChanged(BluezQt::AdapterPtr adapter) { if(adapter.isNull()) { KyInfo(); } else { KyInfo() << adapter->address(); } } void Daemon::allAdaptersRemoved() { KyInfo(); } void Daemon::monitorSleepSlot(bool sleep) { KyInfo () << "app is sleep: " << sleep; CONFIG::getInstance()->systemSleepFlag(sleep); if(sleep) { KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->devDisconnectAll(); } } else { //启动默认适配器 KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->start(); } } } void Daemon::activeUserChange(QString user) { KyDebug() << user; if(CONFIG::getInstance()->get_active_user() != user) { CONFIG::getInstance()->active_user(user); KyInfo() << "send activeUserChange signal, new user: "<< user; emit SYSDBUSMNG::getInstance()->ActiveUserChange(user); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->set_need_reconnect(true); ptr->reconnect_dev(); } } } void Daemon::__unblock_sleep(int ms) { QEventLoop eventloop; QTimer::singleShot(ms, &eventloop, SLOT(quit())); eventloop.exec(); } void Daemon::wait_for_finish(BluezQt::PendingCall *call) { QEventLoop eventloop; connect(call, &BluezQt::PendingCall::finished, this, [&](BluezQt::PendingCall *callReturn) { eventloop.exit(); }); eventloop.exec(); } ukui-bluetooth/service/device.h0000664000175000017500000001022415167665770015553 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DEVICE_H #define DEVICE_H #include #include #include #include #include #include #include #include #include #ifdef BATTERY #include #endif #include "common.h" class KylinAdapter; class KylinDevice: public QObject { public: explicit KylinDevice(BluezQt::DevicePtr device, QString adapter); ~KylinDevice(); int start(void); int devConnect(int type = 0); int devDisconnect(void); QMap getDevAttr(void); int setDevAttr(QMap); int pairFuncReply(bool); void requestPinCode(const BluezQt::Request &request); void requestPasskey(const BluezQt::Request &request); void requestConfirmation(const QString &passkey, const BluezQt::Request<> &request); void requestAuthorization(const BluezQt::Request<> &request); void authorizeService(const QString &uuid, const BluezQt::Request<> &request); void displayPinCode(const QString &pinCode); bool needClean(void); bool isAudioType(void); int reset(void); QString Name(void) { return m_device->name(); } bool ispaired(void) { return m_paired; } void setSendfileStatus(bool status = true); void sendAudioMaxSignal(void); protected slots: void nameChanged(const QString &name); void pairedChanged(bool paired); void trustedChanged(bool trusted); void blockedChanged(bool blocked); void rssiChanged(qint16 rssi); void connectedChanged(bool connected); #ifdef BATTERY void batteryChanged(BluezQt::BatteryPtr battery); void percentageChanged(int percentage); #endif void typeChanged(BluezQt::Device::Type type); void uuidsChanged(const QStringList &uuids); void mediaTransportChanged(BluezQt::MediaTransportPtr mediaTransport); ////////////////////////////////////////////// void pairfinished(BluezQt::PendingCall *call); void connectfinished(BluezQt::PendingCall *call); protected: int pair(); int connectToDevice(); int updateAudioDevice(void); void deal_active_connection(void); virtual void timerEvent( QTimerEvent *event); void wait_for_finish(BluezQt::PendingCall *call); private: void __send_attr(enum_send_type stype = enum_send_type_delay); void __send_add(void); void __send_remove(void); void __init_uuid(); void __init_devattr(QMap &); void __kill_reconnect_a2dp_timer(void); protected: QString m_adapter; int m_need_clean = 0; BluezQt::DevicePtr m_device = nullptr; bool m_connectProgress = false; bool m_pairProgress = false; bool m_connect = false; bool m_paired = false; QString m_showName; BluezQt::Request<> m_request; QStringList m_uuids; bool m_support_ad2p_sink = false; bool m_support_a2dp_source = false; bool m_support_hfphsp_ag = false; bool m_support_hfphsp_hf = false; bool m_support_filetransport = false; QMap m_attr_send; int m_attrsignal_TimerID= 0; /** * @brief m_connect_type * 0 : 主动连接 * 1 : 回连 */ int m_connect_type = 0; QString m_lastConnectError; bool m_a2dp_connect = false; int m_a2dp_reconnect_TimerID = 0; int m_a2dp_reconnect_count = 0; friend class KylinAdapter; }; #endif // DEVICE_H ukui-bluetooth/service/device.cpp0000664000175000017500000006266615167665770016127 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "device.h" #include #include #include #include "sessiondbusregister.h" #include "adapter.h" #include "config.h" #if defined(__has_include) && __has_include("KF6/BluezQt/bluezqt/mediatransport.h") #else class BluezQt::MediaTransport{}; #endif KylinDevice::KylinDevice(BluezQt::DevicePtr device, QString adapter) { m_device = device; m_adapter = adapter; connect(m_device.data(), &BluezQt::Device::nameChanged, this, &KylinDevice::nameChanged); connect(m_device.data(), &BluezQt::Device::pairedChanged, this, &KylinDevice::pairedChanged); connect(m_device.data(), &BluezQt::Device::trustedChanged, this, &KylinDevice::trustedChanged); connect(m_device.data(), &BluezQt::Device::blockedChanged, this, &KylinDevice::blockedChanged); connect(m_device.data(), &BluezQt::Device::rssiChanged, this, &KylinDevice::rssiChanged); connect(m_device.data(), &BluezQt::Device::connectedChanged, this, &KylinDevice::connectedChanged); #ifdef BATTERY connect(m_device.data(), &BluezQt::Device::batteryChanged, this, &KylinDevice::batteryChanged); #endif connect(m_device.data(), &BluezQt::Device::typeChanged, this, &KylinDevice::typeChanged); connect(m_device.data(), &BluezQt::Device::uuidsChanged, this, &KylinDevice::uuidsChanged); connect(m_device.data(), &BluezQt::Device::mediaTransportChanged, this, &KylinDevice::mediaTransportChanged); m_a2dp_connect =m_device->mediaTransport() ? true : false; KyDebug() << m_device->address() << " a2dp_connect : " << m_a2dp_connect; m_paired = m_device->isPaired(); if(m_paired) { m_connect = m_device->isConnected(); } m_uuids = m_device->uuids(); m_showName = CONFIG::getInstance()->get_rename(m_device->address()); this->__send_add(); this->__init_uuid(); } KylinDevice::~KylinDevice() { KyDebug() << m_device->address(); m_device->disconnect(this); if(0 != m_attrsignal_TimerID) { this->killTimer(m_attrsignal_TimerID); m_attrsignal_TimerID = 0; } this->__kill_reconnect_a2dp_timer(); } int KylinDevice::start() { this->deal_active_connection(); return 0; } int KylinDevice::devConnect(int type /*= 0*/) { KyInfo()<< m_device->address(); m_need_clean = 0; m_lastConnectError = ""; m_connect_type = type; if(m_connectProgress) { return ERR_BREDR_INTERNAL_Operation_Progress; } m_connectProgress = true; m_attr_send[DeviceAttr(enum_device_attr_Connecting)] = m_connectProgress; this->__send_attr(enum_send_type_immediately); this->__kill_reconnect_a2dp_timer(); int ret = ERR_BREDR_CONN_SUC; if(m_device->isPaired()) { if(Environment::HUAWEI == envPC) { if(m_device->type() != BluezQt::Device::Computer && m_device->type() != BluezQt::Device::Phone) { ret = this->connectToDevice(); } } else { ret = this->connectToDevice(); } } else { ret = this->pair(); if(ERR_BREDR_CONN_SUC == ret) { if(Environment::HUAWEI == envPC) { if(m_device->type() != BluezQt::Device::Computer && m_device->type() != BluezQt::Device::Phone) { ret = this->connectToDevice(); } } else { ret = this->connectToDevice(); } } } m_connectProgress = false; m_attr_send[DeviceAttr(enum_device_attr_Connecting)] = m_connectProgress; this->__send_attr(enum_send_type_immediately); return ret; } int KylinDevice::devDisconnect() { KyInfo()<< m_device->address(); m_need_clean = 0; this->__kill_reconnect_a2dp_timer(); if((m_device->isPaired() && m_device->isConnected()) || m_connect) { m_a2dp_connect = false; BluezQt::PendingCall *call = m_device->disconnectFromDevice(); //this->wait_for_finish(call); } return ERR_BREDR_CONN_SUC; } int KylinDevice::pairFuncReply(bool v) { KyInfo()<< m_device->address() << v; if(v) { m_request.accept(); } else { m_request.reject(); } return 0; } void KylinDevice::requestPinCode(const BluezQt::Request &request) { KyInfo()<< m_device->address(); request.accept(QString()); } void KylinDevice::requestPasskey(const BluezQt::Request &request) { KyInfo()<< m_device->address(); request.accept(0); } void KylinDevice::requestConfirmation(const QString &passkey, const BluezQt::Request<> &request) { KyInfo()<< m_device->address(); if(this->isAudioType()) { request.accept(); } else { m_request = request; QMap attrs; attrs[PairAttr(enum_start_pair_dev)] = m_device->address(); attrs[PairAttr(enum_start_pair_name)] = m_device->name(); attrs[PairAttr(enum_start_pair_pincode)] = passkey; attrs[PairAttr(enum_start_pair_type)] = enum_pair_pincode_type_request; emit SYSDBUSMNG::getInstance()->startPair(attrs); //request.accept(); } } void KylinDevice::requestAuthorization(const BluezQt::Request<> &request) { KyInfo()<< m_device->address(); request.accept(); } void KylinDevice::authorizeService(const QString &uuid, const BluezQt::Request<> &request) { KyInfo()<< m_device->address() << uuid; if(this->isAudioType()) { //主动连接, 信任状态 if(m_device->isTrusted()) { request.accept(); } //本机移除后再连接 else { request.reject(); } } else { request.accept(); m_connect = true; m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); } } void KylinDevice::displayPinCode(const QString &pinCode) { KyInfo()<< m_device->address(); //if(m_connectProgress) { QMap attrs; attrs[PairAttr(enum_start_pair_dev)] = m_device->address(); attrs[PairAttr(enum_start_pair_name)] = m_device->name(); attrs[PairAttr(enum_start_pair_pincode)] = pinCode; attrs[PairAttr(enum_start_pair_type)] = enum_pair_pincode_type_display; emit SYSDBUSMNG::getInstance()->startPair(attrs); } } bool KylinDevice::needClean() { if(m_connect || m_paired || m_connectProgress || m_pairProgress || m_device->isPaired() || m_device->isConnected()) { return false; } if(m_need_clean > 3) { KyDebug() << m_device->address() << "need delete"; return true; } m_need_clean++; return false; } bool KylinDevice::isAudioType() { if(m_device->type() == BluezQt::Device::AudioVideo || m_device->type() == BluezQt::Device::Headphones || m_device->type() == BluezQt::Device::Headset) { return true; } return false; } int KylinDevice::reset() { m_need_clean = 0; return 0; } void KylinDevice::setSendfileStatus(bool status /*= true*/) { KyInfo() << "connect: " << m_connect << " devconnect: " << m_device->isConnected() << " stasus: " << status; if (status) { if (!m_connect) { m_connect = true; m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); } } else { if (m_connect != m_device->isConnected()) { m_connect = m_device->isConnected(); m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); } } } void KylinDevice::sendAudioMaxSignal() { m_attr_send[DeviceAttr(enum_device_attr_Connecting)] = false; m_attr_send[DeviceAttr(enum_device_attr_ConnectFailedId)] = ERR_BREDR_INTERNAL_AUDIO_MAXNUM; this->__send_attr(); } void KylinDevice::nameChanged(const QString &name) { m_need_clean = 0; m_attr_send[DeviceAttr(enum_device_attr_Name)] = name; this->__send_attr(); } void KylinDevice::pairedChanged(bool paired) { m_need_clean = 0; KyInfo() << m_device->address() <<", paired: "<< paired; if(this->isAudioType()) { if(m_pairProgress || m_paired) { m_paired = paired; m_attr_send[DeviceAttr(enum_device_attr_Paired)] = paired; this->__send_attr(); } else { //移除设备 KylinAdapterPtr adapterPtr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(adapterPtr) { KyInfo() << m_device->address() << "active connect, delete dev"; adapterPtr->__devRemove(m_device->address()); } } } else { m_paired = paired; m_attr_send[DeviceAttr(enum_device_attr_Paired)] = paired; this->__send_attr(); } } void KylinDevice::trustedChanged(bool trusted) { m_need_clean = 0; m_attr_send[DeviceAttr(enum_device_attr_Trusted)] = trusted; this->__send_attr(); } void KylinDevice::blockedChanged(bool blocked) { m_need_clean = 0; } void KylinDevice::rssiChanged(qint16 rssi) { m_need_clean = 0; if(-rssi > 0 && -rssi < 100 ) { //this->deal_active_connection(); m_attr_send[DeviceAttr(enum_device_attr_Rssi)] = rssi; this->__send_attr(); } } void KylinDevice::connectedChanged(bool connected) { m_need_clean = 0; KyInfo() << m_device->address() << connected; if(Environment::HUAWEI == envPC) { if(BluezQt::Device::Computer == m_device->type() || BluezQt::Device::Phone == m_device->type() ) { if(connected && m_device->isPaired()) { KyInfo() << m_device->address() << " disconnect, HUAWEI"; m_device->disconnectFromDevice(); return; } } } // 底层状态断开 && 当前保存状态 不等于 底层状态 if(!connected && m_connect != connected) { m_connect = connected; m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); this->updateAudioDevice(); this->__kill_reconnect_a2dp_timer(); } //未主动连接 && 底层状态变为已连接 && 设备信任(以前主动连接的设备) else if(!m_connectProgress && connected && m_device->isTrusted()) { m_connect = connected; m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); this->updateAudioDevice(); } } #ifdef BATTERY void KylinDevice::batteryChanged(BluezQt::BatteryPtr battery) { m_need_clean = 0; if(battery) { connect(battery.data(), &BluezQt::Battery::percentageChanged, this, &KylinDevice::percentageChanged, Qt::UniqueConnection); m_attr_send[DeviceAttr(enum_device_attr_Battery)] = battery->percentage(); this->__send_attr(); } } void KylinDevice::percentageChanged(int percentage) { m_need_clean = 0; m_attr_send[DeviceAttr(enum_device_attr_Battery)] = percentage; this->__send_attr(); } #endif void KylinDevice::typeChanged(BluezQt::Device::Type Type) { m_need_clean = 0; if(Environment::HUAWEI == envPC) { if(Type == BluezQt::Device::Type::AudioVideo) { m_attr_send[DeviceAttr(enum_device_attr_Type)] = BluezQt::Device::Type::Headphones; } else { m_attr_send[DeviceAttr(enum_device_attr_Type)] = Type; } } else { m_attr_send[DeviceAttr(enum_device_attr_Type)] = Type; } m_attr_send[DeviceAttr(enum_device_attr_TypeName)] = BluezQt::Device::typeToString(Type); this->__send_attr(); } void KylinDevice::uuidsChanged(const QStringList &uuids) { m_uuids = uuids; this->__init_uuid();; } void KylinDevice::mediaTransportChanged(BluezQt::MediaTransportPtr mediaTransport) { KyInfo() << m_device->address(); if(mediaTransport) { KyInfo() << m_device->address() << " a2dp connect suc"; this->__kill_reconnect_a2dp_timer(); m_a2dp_connect = true; } else { KyInfo() << m_device->address() << " a2dp disconnect"; if(m_a2dp_connect) { this->__kill_reconnect_a2dp_timer(); m_a2dp_reconnect_TimerID = this->startTimer(5000); KyInfo() << m_device->address() << "start a2dp reconnect timer"; } m_a2dp_connect = false; } } void KylinDevice::pairfinished(BluezQt::PendingCall *call) { if(call->error() != 0) { KyWarning()<< m_device->address() <<" paired error, code: " <error() << ", msg: "<< call->errorText(); m_device.data()->cancelPairing(); m_lastConnectError = call->errorText(); m_attr_send[DeviceAttr(enum_device_attr_ConnectFailedDisc)] = m_lastConnectError; m_attr_send[DeviceAttr(enum_device_attr_ConnectFailedId)] = get_enum_errmsg(m_lastConnectError); this->__send_attr(); } //配对成功 else { m_paired = true; KyInfo() << m_device->address() << " pair suc"; BluezQt::PendingCall * p = m_device->setTrusted(true); this->wait_for_finish(p); } } void KylinDevice::connectfinished(BluezQt::PendingCall *call) { if(call->error() != 0) { m_connect = false; KyWarning()<< m_device->address() <<" connect error, code: " <error() << ", msg: "<< call->errorText(); //回连失败不发送错误信号 if(0 == m_connect_type) { m_lastConnectError = call->errorText(); m_attr_send[DeviceAttr(enum_device_attr_ConnectFailedDisc)] = m_lastConnectError; m_attr_send[DeviceAttr(enum_device_attr_ConnectFailedId)] = get_enum_errmsg(m_lastConnectError); this->__send_attr(); } } else { KyInfo() << m_device->address() << " connect suc"; m_connect = true; m_attr_send[DeviceAttr(enum_device_attr_Connected)] = m_connect; this->__send_attr(); this->updateAudioDevice(); } } int KylinDevice::pair() { m_pairProgress = true; KyInfo()<< m_device->address(); BluezQt::PendingCall *call = m_device->pair(); connect(call, &BluezQt::PendingCall::finished, this, &KylinDevice::pairfinished); this->wait_for_finish(call); m_pairProgress = false; if(m_lastConnectError.isEmpty()) { return 0; } return get_enum_errmsg(m_lastConnectError); } int KylinDevice::connectToDevice() { KyInfo() << m_device->address(); BluezQt::PendingCall *call = m_device->connectToDevice(); connect(call, &BluezQt::PendingCall::finished, this, &KylinDevice::connectfinished); this->wait_for_finish(call); if(m_lastConnectError.isEmpty()) { return 0; } return get_enum_errmsg(m_lastConnectError); } int KylinDevice::updateAudioDevice() { //音频设备 if(this->isAudioType()) { KyInfo(); QStringList connected_audio_devices; //移除设备 KylinAdapterPtr adapterPtr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(adapterPtr) { connected_audio_devices = adapterPtr->connected_audio_device(); KyInfo() << connected_audio_devices; if(m_connect) { if(!connected_audio_devices.contains(m_device->address())) { if(connected_audio_devices.size() >= 2) { KyInfo() << "connected_audio_devices >= 2, disconnect dev: " << m_device->address(); this->devDisconnect(); return 0; } else { adapterPtr->connected_audio_device(m_device->address()); } } //判断a2dp是否连接 m_a2dp_connect = m_device->mediaTransport() ? true : false; if(!m_a2dp_connect) { if(0 != m_a2dp_reconnect_TimerID) { this->__kill_reconnect_a2dp_timer(); } m_a2dp_reconnect_TimerID = this->startTimer(5000); KyInfo() << m_device->address() << "start a2dp reconnect timer"; } } else { adapterPtr->disconnected_audio_device(m_device->address()); } } } return 0; } void KylinDevice::deal_active_connection() { if(CONFIG::getInstance()->activeconnection()) { if(!this->isAudioType() || m_device->isPaired()) { return; } int timeout = 15; int v= m_device->rssi(); if(abs(v) <= 60) { //移除设备 KylinAdapterPtr adapterPtr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(adapterPtr && adapterPtr->deal_active_connection(m_device->address(), timeout)) { emit SYSDBUSMNG::getInstance()->ActiveConnection(m_device->address(), m_device->name(), BluezQt::Device::typeToString(m_device->type()), v, timeout); KyInfo() << "start active conection" << m_device->address() <<" rssi: "<< m_device->rssi() << " timeout:" << timeout <<" type: " << BluezQt::Device::typeToString(m_device->type()) <<" name: " << m_device->name(); } } } } void KylinDevice::timerEvent(QTimerEvent *event) { if(event->timerId() == m_attrsignal_TimerID) { KyDebug() << m_device->address() <<" send attrs" << m_attr_send; this->killTimer(m_attrsignal_TimerID); m_attrsignal_TimerID = 0; emit SYSDBUSMNG::getInstance()->deviceAttrChanged(m_device->address(), m_attr_send); m_attr_send.clear(); } else if(event->timerId() == m_a2dp_reconnect_TimerID) { KyInfo() << m_device->address() <<" a2dp_reconnect_TimerID"; if(m_device->isConnected()) { m_a2dp_reconnect_count += 1; if(m_a2dp_reconnect_count > 2) { KyInfo() << m_device->address() <<" a2dp sink connect failed, disconnect"; this->devDisconnect(); return; } KyInfo() << m_device->address() <<" reconnect a2dp sink"; m_device->connectProfile(A2DP_SINK_UUID); } else { // 蓝牙连接断开,移删除定时器 this->__kill_reconnect_a2dp_timer(); KyInfo() << m_device->address() <<" already disconnected"; } } else { KyDebug() << m_device->address() << "other timer, delete"; this->killTimer(event->timerId()); } } void KylinDevice::wait_for_finish(BluezQt::PendingCall *call) { QEventLoop eventloop; connect(call, &BluezQt::PendingCall::finished, this, [&](BluezQt::PendingCall *callReturn) { eventloop.exit(); }); eventloop.exec(); } void KylinDevice::__send_attr(enum_send_type stype /*= enum_send_type_delay*/) { if(enum_send_type_delay == stype) { if(0 == m_attrsignal_TimerID) { m_attrsignal_TimerID = this->startTimer(500); } } else { if(0 != m_attrsignal_TimerID) { this->killTimer(m_attrsignal_TimerID); m_attrsignal_TimerID = 0; } KyDebug() << m_device->address() << " attrs: "<< m_attr_send; emit SYSDBUSMNG::getInstance()->deviceAttrChanged(m_device->address(), m_attr_send); m_attr_send.clear(); } } void KylinDevice::__send_remove() { QMap attrs; attrs[DeviceAttr(enum_device_attr_Adapter)] = m_adapter; emit SYSDBUSMNG::getInstance()->deviceRemoveSignal(m_device->address(), attrs); } void KylinDevice::__init_uuid() { if(support_a2dp_sink(m_uuids)) { if(!m_support_ad2p_sink) { m_support_ad2p_sink = true; //KyDebug() << m_device->address() <<" support_a2dp_sink"; } } else { if(m_support_ad2p_sink) { m_support_ad2p_sink = false; //KyDebug() << m_device->address() << "not support_a2dp_sink"; } } if(support_a2dp_source(m_uuids)) { if(!m_support_a2dp_source) { m_support_a2dp_source = true; //KyDebug()<< m_device->address() << "support_a2dp_source"; } } else { if(m_support_a2dp_source) { m_support_a2dp_source = false; //KyDebug()<< m_device->address() << "not support_a2dp_source"; } } if(support_hfphsp_ag(m_uuids)) { if(!m_support_hfphsp_ag) { m_support_hfphsp_ag = true; //KyDebug()<< m_device->address() << "support_hfphsp_ag"; } } else { if(m_support_hfphsp_ag) { m_support_hfphsp_ag = false; //KyDebug()<< m_device->address() << "not support_hfphsp_ag"; } } if(support_hfphsp_hf(m_uuids)) { if(!m_support_hfphsp_hf) { m_support_hfphsp_hf = true; //KyDebug() << m_device->address() << "support_hfphsp_hf"; } } else { if(m_support_hfphsp_hf) { m_support_hfphsp_hf = false; //KyDebug()<< m_device->address() << "not support_hfphsp_hf"; } } if(support_filetransport(m_uuids)) { if(!m_support_filetransport) { m_support_filetransport = true; m_attr_send[DeviceAttr(enum_device_attr_FileTransportSupport)] = m_support_filetransport; this->__send_attr(); //KyDebug()<< m_device->address() << "support_filetransport"; } } else { if(m_support_filetransport) { m_support_filetransport = false; m_attr_send[DeviceAttr(enum_device_attr_FileTransportSupport)] = m_support_filetransport; this->__send_attr(); //KyDebug()<< m_device->address() << "not support_filetransport"; } } } void KylinDevice::__init_devattr(QMap & attrs) { attrs.clear(); attrs[DeviceAttr(enum_device_attr_Adapter)] = m_adapter; attrs[DeviceAttr(enum_device_attr_Paired)] = m_device->isPaired(); attrs[DeviceAttr(enum_device_attr_Trusted)] = m_device->isTrusted(); attrs[DeviceAttr(enum_device_attr_Connected)] = m_connect; attrs[DeviceAttr(enum_device_attr_Name)] = m_device->name(); if(Environment::HUAWEI == envPC) { if(m_device->type() == BluezQt::Device::Type::AudioVideo) { attrs[DeviceAttr(enum_device_attr_Type)] = BluezQt::Device::Type::Headphones; } else { attrs[DeviceAttr(enum_device_attr_Type)] = m_device->type(); } } else { attrs[DeviceAttr(enum_device_attr_Type)] = m_device->type(); } attrs[DeviceAttr(enum_device_attr_TypeName)] = BluezQt::Device::typeToString(m_device->type()); attrs[DeviceAttr(enum_device_attr_Connecting)] = m_connectProgress; if(m_device->type() == BluezQt::Device::Type::Phone || m_device->type() == BluezQt::Device::Type::Computer) { attrs[DeviceAttr(enum_device_attr_FileTransportSupport)] = m_support_filetransport; } #ifdef BATTERY if(m_device->battery()) { attrs[DeviceAttr(enum_device_attr_Battery)] = m_device->battery()->percentage(); } #endif attrs[DeviceAttr(enum_device_attr_Addr)] = m_device->address(); attrs[DeviceAttr(enum_device_attr_Rssi)] = m_device->rssi(); attrs[DeviceAttr(enum_device_attr_ShowName)] = m_showName; } void KylinDevice::__kill_reconnect_a2dp_timer() { if(0 != m_a2dp_reconnect_TimerID) { KyInfo() << m_device->address() << "stop a2dp reconnect timer"; this->killTimer(m_a2dp_reconnect_TimerID); m_a2dp_reconnect_TimerID = 0; m_a2dp_reconnect_count = 0; } } QMap KylinDevice::getDevAttr() { QMap attrs; this->__init_devattr(attrs); return attrs; } int KylinDevice::setDevAttr(QMap attrs) { QString key = DeviceAttr(enum_device_attr_Name); if(attrs.contains(key) && this->ispaired()) { m_showName = attrs[key].toString(); if(m_showName.length() == 0) { m_showName = m_device->name(); } CONFIG::getInstance()->set_rename(m_device->address(), m_showName); m_attr_send[DeviceAttr(enum_device_attr_ShowName)] = m_showName; this->m_device->setName(m_showName); this->__send_attr(); } return 0; } void KylinDevice::__send_add() { QMap attrs; this->__init_devattr(attrs); KyDebug() << m_device->address() << attrs; emit SYSDBUSMNG::getInstance()->deviceAddSignal(attrs); } ukui-bluetooth/service/sessiondbusregister.h0000664000175000017500000000522415167665770020426 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef SESSIONDBUSREGISTER_H #define SESSIONDBUSREGISTER_H #include #include #include #include #include #include #include #include #include "CSingleton.h" class SystemAdapter; class SysDbusMng : public QObject { Q_OBJECT protected: explicit SysDbusMng(QObject *parent = nullptr); ~SysDbusMng(); public: int start(void); int stop(void); SystemAdapter *get_sys_adapter(){ return m_sys_adapter; } public: bool registerClient(QMap, QString); bool unregisterClient(QString); QString bluetoothKeyValue(unsigned int,QString); signals: void adapterAddSignal(QMap); void adapterAttrChanged(QString, QMap); void adapterRemoveSignal(QString); void deviceAddSignal(QMap); void deviceAttrChanged(QString, QMap); void deviceRemoveSignal(QString, QMap); void ActiveConnection(QString, QString, QString, int, int); void updateClient(void); void startPair(QMap); void fileStatusChanged(QMap); void fileReceiveSignal(QMap); void clearBluetoothDev(QStringList); void pingTimeSignal(QByteArray); //音频控制信号 void VolumeDown(); void VolumeUp(); void Next(); void PlayPause(); void Previous(); void Stop(); void Play(); void Pause(); //活跃用户信号 void ActiveUserChange(QString); protected: void sendMultimediaControlButtonSignal(unsigned int); private: SystemAdapter * m_sys_adapter = nullptr; QMap m_pressTimeMap; //记录键值按下的时间 QMap m_releaseTimeMap; //记录键值释放的时间 friend class SingleTon; }; typedef SingleTon SYSDBUSMNG; #endif // SESSIONDBUSREGISTER_H ukui-bluetooth/service/config.cpp0000664000175000017500000002464215167665770016125 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "config.h" #include #include #include #include #include Environment envPC = Environment::NOMAL; #define CONF_FILE_FULLPATH "/etc/bluetooth/ukui-bluetooth.conf" //#define CONF_FILE_FULLPATH "./ukui-bluetooth.conf" #define CONF_STR_BLUETOOTH_POWER_SWTICH "switch" #define CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH "bluetoothDiscoverableSwitch" #define CONF_STR_FINALLY_CONNECT_THE_DEVICE "finallyConnectTheDevice" #define CONF_STR_ADAPTER_ADDRESS "adapterAddress" #define CONF_STR_FILE_SAVE_PATH "fileSavePath" #define CONF_STR_ADAPTER_ADDRESS_LIST "adapterAddressList" #define CONF_STR_ACTIVE_CONNECTION "activeConnection" #define CONF_STR_TRAY_SHOW "trayShow" #define CONF_STR_AUDIO_COMBINE "audioCombine" #define CONF_STR_LEAVE_LOCK "leaveLock" #define CONF_LOG_LEVEL "loglevel" Config::Config(QObject *parent) :QObject(parent) { m_ukui_bluetooth = new QSettings(CONF_FILE_FULLPATH, QSettings::IniFormat); QStringList groups = m_ukui_bluetooth->childGroups(); KyInfo() << groups; if(groups.indexOf("conf") == -1) { KyInfo() << "create and init conf"; m_ukui_bluetooth->beginGroup("conf"); this->init_conf(); } else { m_ukui_bluetooth->beginGroup("conf"); this->init_conf(); } } Config::~Config() { delete m_ukui_bluetooth; m_ukui_bluetooth = nullptr; } void Config::init_conf() { KyInfo(); if(!m_ukui_bluetooth->contains(CONF_STR_BLUETOOTH_POWER_SWTICH)) { KyInfo() << "add conf: " << CONF_STR_BLUETOOTH_POWER_SWTICH; m_ukui_bluetooth->setValue(CONF_STR_BLUETOOTH_POWER_SWTICH, false); } if(!m_ukui_bluetooth->contains(CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH)) { KyInfo() << "add conf: " << CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH; m_ukui_bluetooth->setValue(CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH, true); } if(!m_ukui_bluetooth->contains(CONF_STR_FINALLY_CONNECT_THE_DEVICE)) { KyInfo() << "add conf: " << CONF_STR_FINALLY_CONNECT_THE_DEVICE; m_ukui_bluetooth->setValue(CONF_STR_FINALLY_CONNECT_THE_DEVICE, ""); } if(!m_ukui_bluetooth->contains(CONF_STR_ADAPTER_ADDRESS)) { KyInfo() << "add conf: " << CONF_STR_ADAPTER_ADDRESS; m_ukui_bluetooth->setValue(CONF_STR_ADAPTER_ADDRESS, ""); } if(!m_ukui_bluetooth->contains(CONF_STR_FILE_SAVE_PATH)) { KyInfo() << "add conf: " << CONF_STR_FILE_SAVE_PATH; m_ukui_bluetooth->setValue(CONF_STR_FILE_SAVE_PATH, ""); } if(!m_ukui_bluetooth->contains(CONF_STR_ADAPTER_ADDRESS_LIST)) { KyInfo() << "add conf: " << CONF_STR_ADAPTER_ADDRESS_LIST; QStringList t; t.append("null"); m_ukui_bluetooth->setValue(CONF_STR_ADAPTER_ADDRESS_LIST, t); } if(!m_ukui_bluetooth->contains(CONF_STR_ACTIVE_CONNECTION)) { KyInfo() << "add conf: " << CONF_STR_ACTIVE_CONNECTION; m_ukui_bluetooth->setValue(CONF_STR_ACTIVE_CONNECTION, false); } if(!m_ukui_bluetooth->contains(CONF_STR_TRAY_SHOW)) { KyInfo() << "add conf: " << CONF_STR_TRAY_SHOW; m_ukui_bluetooth->setValue(CONF_STR_TRAY_SHOW, true); } if(!m_ukui_bluetooth->contains(CONF_STR_AUDIO_COMBINE)) { KyInfo() << "add conf: " << CONF_STR_AUDIO_COMBINE; m_ukui_bluetooth->setValue(CONF_STR_AUDIO_COMBINE, false); } if(!m_ukui_bluetooth->contains(CONF_STR_LEAVE_LOCK)) { KyInfo() << "add conf: " << CONF_STR_LEAVE_LOCK; m_ukui_bluetooth->setValue(CONF_STR_LEAVE_LOCK, false); } if(!m_ukui_bluetooth->contains(CONF_LOG_LEVEL)) { KyInfo() << "add conf: " << CONF_LOG_LEVEL; m_ukui_bluetooth->setValue(CONF_LOG_LEVEL, m_loglevel); } } int Config::init() { if(m_ukui_bluetooth->contains(CONF_LOG_LEVEL)) { m_loglevel = m_ukui_bluetooth->value(CONF_LOG_LEVEL).toString(); KyInfo() << CONF_LOG_LEVEL << m_loglevel; set_logLevel(m_loglevel); } if(m_ukui_bluetooth->contains(CONF_STR_BLUETOOTH_POWER_SWTICH)) { m_power_switch = m_ukui_bluetooth->value(CONF_STR_BLUETOOTH_POWER_SWTICH).toBool(); KyInfo() << CONF_STR_BLUETOOTH_POWER_SWTICH << m_power_switch; } if(m_ukui_bluetooth->contains(CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH)) { m_discoverable_switch = m_ukui_bluetooth->value(CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH).toBool(); KyInfo() << CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH << m_discoverable_switch; } if(m_ukui_bluetooth->contains(CONF_STR_FINALLY_CONNECT_THE_DEVICE)) { m_finally_audiodevices = m_ukui_bluetooth->value(CONF_STR_FINALLY_CONNECT_THE_DEVICE).toStringList(); KyInfo() << CONF_STR_FINALLY_CONNECT_THE_DEVICE << m_finally_audiodevices; } if(m_ukui_bluetooth->contains(CONF_STR_ADAPTER_ADDRESS)) { m_adapter_addr = m_ukui_bluetooth->value(CONF_STR_ADAPTER_ADDRESS).toString(); KyInfo() << CONF_STR_ADAPTER_ADDRESS << m_adapter_addr; } if(m_ukui_bluetooth->contains(CONF_STR_FILE_SAVE_PATH)) { m_file_save_path = m_ukui_bluetooth->value(CONF_STR_FILE_SAVE_PATH).toString(); KyInfo() << CONF_STR_FILE_SAVE_PATH << m_file_save_path; } if(m_ukui_bluetooth->contains(CONF_STR_ACTIVE_CONNECTION)) { m_activeconnection = m_ukui_bluetooth->value(CONF_STR_ACTIVE_CONNECTION).toBool(); KyInfo() << CONF_STR_ACTIVE_CONNECTION << m_activeconnection; } if(m_ukui_bluetooth->contains(CONF_STR_TRAY_SHOW)) { m_tray_show = m_ukui_bluetooth->value(CONF_STR_TRAY_SHOW).toBool(); KyInfo() << CONF_STR_TRAY_SHOW << m_tray_show; } if(m_ukui_bluetooth->contains(CONF_LOG_LEVEL)) { m_loglevel = m_ukui_bluetooth->value(CONF_LOG_LEVEL).toString(); KyInfo() << CONF_LOG_LEVEL << m_loglevel; } if(m_ukui_bluetooth->contains(CONF_STR_AUDIO_COMBINE)) { m_audioCombine = m_ukui_bluetooth->value(CONF_STR_AUDIO_COMBINE).toBool(); KyInfo() << CONF_STR_AUDIO_COMBINE << m_audioCombine; } if(m_ukui_bluetooth->contains(CONF_STR_LEAVE_LOCK)) { m_leaveLock = m_ukui_bluetooth->value(CONF_STR_LEAVE_LOCK).toBool(); KyInfo() << CONF_STR_LEAVE_LOCK << m_audioCombine; } m_active_user = this->getActiveUser(); KyInfo()<< "active user: "<< m_active_user; this->init_rename(); return 0; } void Config::power_switch(bool v) { m_power_switch = v; m_ukui_bluetooth->setValue(CONF_STR_BLUETOOTH_POWER_SWTICH, v); } void Config::discoverable_switch(bool v) { m_discoverable_switch = v; m_ukui_bluetooth->setValue(CONF_STR_BLUETOOTH_DISCOVERABLE_SWTICH, v); } void Config::finally_audiodevice(QString v) { if(!m_finally_audiodevices.contains(v)) { while (m_finally_audiodevices.size() >= 2) { m_finally_audiodevices.removeFirst(); } m_finally_audiodevices.append(v); m_ukui_bluetooth->setValue(CONF_STR_FINALLY_CONNECT_THE_DEVICE, m_finally_audiodevices); } } void Config::remove_finally_audiodevice(QString v) { if(m_finally_audiodevices.contains(v)) { m_finally_audiodevices.removeOne(v); m_ukui_bluetooth->setValue(CONF_STR_FINALLY_CONNECT_THE_DEVICE, m_finally_audiodevices); } } void Config::adapter_addr(QString v) { m_adapter_addr = v; m_ukui_bluetooth->setValue(CONF_STR_ADAPTER_ADDRESS, v); } void Config::file_save_path(QString v) { m_file_save_path = v; m_ukui_bluetooth->setValue(CONF_STR_FILE_SAVE_PATH, v); } void Config::activeconnection(bool v) { m_activeconnection = v; m_ukui_bluetooth->setValue(CONF_STR_ACTIVE_CONNECTION, v); } void Config::trayShow(bool v) { m_tray_show = v; m_ukui_bluetooth->setValue(CONF_STR_TRAY_SHOW, v); } void Config::loglevel(QString v) { set_logLevel(v); m_loglevel = v; m_ukui_bluetooth->setValue(CONF_LOG_LEVEL, m_loglevel); } void Config::loglevel(int v) { set_logLevel(v); if (0 == v) { m_loglevel = "debug"; } else if ( 1== v) { m_loglevel = "info"; } else if (2 == v) { m_loglevel = "warning"; } m_ukui_bluetooth->setValue(CONF_LOG_LEVEL, m_loglevel); } QString Config::active_user() { if (m_active_user.length() == 0) { m_active_user = this->getActiveUser(); } return m_active_user; } void Config::leaveLock(bool v) { m_leaveLock = v; m_ukui_bluetooth->setValue(CONF_STR_LEAVE_LOCK, v); } void Config::set_rename(QString addr, QString name) { m_rename[addr] = name; QSettings s(CONF_FILE_FULLPATH, QSettings::IniFormat); s.beginGroup("rename"); s.setValue(addr, name); s.endGroup(); } QString Config::get_rename(QString v) { if(m_rename.contains(v)) { return m_rename[v]; } return ""; } void Config::delete_rename(QString addr) { if(m_rename.contains(addr)) { QSettings s(CONF_FILE_FULLPATH, QSettings::IniFormat); s.beginGroup("rename"); s.remove(addr); s.endGroup(); m_rename.remove(addr); } } void Config::AudioCombine(bool v) { m_audioCombine = v; m_ukui_bluetooth->setValue(CONF_STR_AUDIO_COMBINE, m_audioCombine); } void Config::init_rename() { QSettings s(CONF_FILE_FULLPATH, QSettings::IniFormat); s.beginGroup("rename"); QStringList keys = s.allKeys(); for(auto iter : keys) { m_rename[iter] = s.value(iter).toString(); } KyDebug() << m_rename; s.endGroup(); } QString Config::getActiveUser() { QString user; char * euser = kdk_system_get_eUser(); if (NULL != euser) { user = euser; free(euser); euser = NULL; } KyInfo() << "active user: " << user; return user; } ukui-bluetooth/service/common.h0000664000175000017500000002103415167665770015605 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef COMMON_H #define COMMON_H #include #include #include #include #include #define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb" #define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb" #define HSP_HS_UUID "00001108-0000-1000-8000-00805f9b34fb" #define HSP_AG_UUID "00001112-0000-1000-8000-00805f9b34fb" #define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb" #define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb" //#define OBEX_SYNC_UUID "00001104-0000-1000-8000-00805f9b34fb" #define OBEX_OPP_UUID "00001105-0000-1000-8000-00805f9b34fb" #define OBEX_FTP_UUID "00001106-0000-1000-8000-00805f9b34fb" //#define OBEX_PCE_UUID "0000112e-0000-1000-8000-00805f9b34fb" //#define OBEX_PSE_UUID "0000112f-0000-1000-8000-00805f9b34fb" //#define OBEX_PBAP_UUID "00001130-0000-1000-8000-00805f9b34fb" //#define OBEX_MAS_UUID "00001132-0000-1000-8000-00805f9b34fb" //#define OBEX_MNS_UUID "00001133-0000-1000-8000-00805f9b34fb" //#define OBEX_MAP_UUID "00001134-0000-1000-8000-00805f9b34fb" #define LogPatten() get_logFormat(__FILE__, __FUNCTION__, __LINE__) #define KyDebug() qDebug() << "debug" << LogPatten() #define KyInfo() qInfo() << "info" << LogPatten() #define KyWarning() qWarning() << "warning" << LogPatten() #define KyCritical() qCritical() << "critical" << LogPatten() #define KyFatal() qFatal() << "fatal" << LogPatten() #define GREATERINDEX "greater index" enum enum_connect_errmsg { ERR_BREDR_CONN_SUC, ERR_BREDR_CONN_ALREADY_CONNECTED = 1, ERR_BREDR_CONN_PAGE_TIMEOUT, ERR_BREDR_CONN_PROFILE_UNAVAILABLE, ERR_BREDR_CONN_SDP_SEARCH, ERR_BREDR_CONN_CREATE_SOCKET, ERR_BREDR_CONN_INVALID_ARGUMENTS, ERR_BREDR_CONN_ADAPTER_NOT_POWERED, ERR_BREDR_CONN_NOT_SUPPORTED, ERR_BREDR_CONN_BAD_SOCKET, ERR_BREDR_CONN_MEMORY_ALLOC, ERR_BREDR_CONN_BUSY, ERR_BREDR_CONN_CNCR_CONNECT_LIMIT, ERR_BREDR_CONN_TIMEOUT, ERR_BREDR_CONN_REFUSED, ERR_BREDR_CONN_ABORT_BY_REMOTE, ERR_BREDR_CONN_ABORT_BY_LOCAL, ERR_BREDR_CONN_LMP_PROTO_ERROR, ERR_BREDR_CONN_CANCELED, ERR_BREDR_CONN_UNKNOWN, //////////////////////////////////////////// ERR_LE_CONN_INVALID_ARGUMENTS = 20, ERR_LE_CONN_ADAPTER_NOT_POWERED, ERR_LE_CONN_NOT_SUPPORTED, ERR_LE_CONN_ALREADY_CONNECTED, ERR_LE_CONN_BAD_SOCKET, ERR_LE_CONN_MEMORY_ALLOC, ERR_LE_CONN_BUSY, ERR_LE_CONN_REFUSED, ERR_LE_CONN_CREATE_SOCKET, ERR_LE_CONN_TIMEOUT, ERR_LE_CONN_SYNC_CONNECT_LIMIT, ERR_LE_CONN_ABORT_BY_REMOTE, ERR_LE_CONN_ABORT_BY_LOCAL, ERR_LE_CONN_LL_PROTO_ERROR, ERR_LE_CONN_GATT_BROWSE, ERR_LE_CONN_UNKNOWN, //////////////////////////////////////////////////// ERR_BREDR_Invalid_Arguments = 36, ERR_BREDR_Operation_Progress, ERR_BREDR_Already_Exists, ERR_BREDR_Operation_Not_Supported, ERR_BREDR_Already_Connected, ERR_BREDR_Operation_Not_Available, ERR_BREDR_Does_Not_Exist, ERR_BREDR_Does_Not_Connected, ERR_BREDR_Does_In_Progress, ERR_BREDR_Operation_Not_Authorized, ERR_BREDR_No_Such_Adapter, ERR_BREDR_Agent_Not_Available, ERR_BREDR_Resource_Not_Ready, /************上面错误码为bluez返回错误码****************/ ERR_BREDR_Bluezqt_DidNot_ReceiveReply, ///////////////////////////////////////////////// ERR_BREDR_INTERNAL_NO_Default_Adapter, ERR_BREDR_INTERNAL_Operation_Progress, ERR_BREDR_INTERNAL_Already_Connected, ERR_BREDR_INTERNAL_Dev_Not_Exist, ERR_BREDR_INTERNAL_AUDIO_MAXNUM, ERR_BREDR_UNKNOWN_Other, }; enum enum_Adapter_attr { enum_Adapter_attr_Pairing = 0, enum_Adapter_attr_Connecting, enum_Adapter_attr_Powered, enum_Adapter_attr_Discoverable, enum_Adapter_attr_Pairable, enum_Adapter_attr_Discovering, enum_Adapter_attr_Name, enum_Adapter_attr_Block, enum_Adapter_attr_Addr, enum_Adapter_attr_ActiveConnection, enum_Adapter_attr_DefaultAdapter, enum_Adapter_attr_TrayShow, enum_Adapter_attr_FileTransportSupport, enum_Adapter_attr_ClearPinCode, enum_Adapter_attr_AudioConnectedNum, enum_Adapter_attr_AudioCombine, }; enum enum_device_attr { enum_device_attr_Paired = 0, enum_device_attr_Trusted, enum_device_attr_Blocked, enum_device_attr_Connected, enum_device_attr_Name, enum_device_attr_Type, enum_device_attr_TypeName, enum_device_attr_Pairing, enum_device_attr_Connecting, enum_device_attr_Battery, enum_device_attr_ConnectFailedId, enum_device_attr_ConnectFailedDisc, enum_device_attr_Rssi, enum_device_attr_Addr, enum_device_attr_FileTransportSupport, enum_device_attr_ShowName, enum_device_attr_Adapter, }; enum enum_app_attr { enum_app_attr_dbusid = 0, enum_app_attr_username, enum_app_attr_type, enum_app_attr_pid, }; enum enum_app_type_bluetooth { enum_app_type_bluetooth_controlPanel = 0, //蓝牙控制面板 enum_app_type_bluetooth_tray, //蓝牙托盘 enum_app_type_bluetooth_quick, //蓝牙快捷面板 enum_app_type_bluetooth_other = 0xff, }; enum enum_start_pair { enum_start_pair_dev = 0, enum_start_pair_name, enum_start_pair_pincode, enum_start_pair_type, }; enum enum_pair_pincode_type { enum_pair_pincode_type_request = 0, enum_pair_pincode_type_display, }; /** * @brief * 蓝牙适配器属性发送类型 */ enum enum_send_type { enum_send_type_delay = 0, enum_send_type_immediately, }; enum enum_filestatus { enum_filestatus_status = 0, enum_filestatus_progress, enum_filestatus_filename, enum_filestatus_allfilenum, enum_filestatus_fileseq, enum_filestatus_dev, enum_filestatus_fileFailedDisc, enum_filestatus_filetype, enum_filestatus_transportType, enum_filestatus_savepath, enum_filestatus_filesize, }; enum enum_filetransport_Type { enum_filetransport_Type_send = 0, enum_filetransport_Type_receive, enum_filetransport_Type_other, }; enum enum_receivefile { enum_receivefile_dev = 0, enum_receivefile_name, enum_receivefile_filetype, enum_receivefile_filename, enum_receivefile_filesize, }; extern QStringList Adapter_attr; #define AdapterAttr(i) (((Adapter_attr.size()>i))?Adapter_attr[i]:GREATERINDEX) #define AdapterAttrIndex(str) (Adapter_attr.indexOf(str)) extern QStringList Device_attr; #define DeviceAttr(i) (((Device_attr.size()>i))?Device_attr[i]:GREATERINDEX) #define DeviceAttrIndex(str) (Device_attr.indexOf(str)) extern QStringList list_errmsg; #define get_enum_errmsg(str) (list_errmsg.indexOf(str)) #define get_enum_errmsg_str(i) (((list_errmsg.size()>i))?list_errmsg[i]:GREATERINDEX) extern QStringList app_attr; #define AppAttr(i) (((app_attr.size()>i))?app_attr[i]:GREATERINDEX) #define AppAttrIndex(str) (app_attr.indexOf(str)) extern QStringList startpair_attr; #define PairAttr(i) (((startpair_attr.size()>i))?startpair_attr[i]:GREATERINDEX) #define PairAttrIndex(str) (startpair_attr.indexOf(str)) extern QStringList filestatus_attr; #define FileStatusAttr(i) (((filestatus_attr.size()>i))?filestatus_attr[i]:GREATERINDEX) #define FileStatusAttrIndex(str) (filestatus_attr.indexOf(str)) extern QStringList receivefile_attr; #define ReceiveFileAttr(i) (((receivefile_attr.size()>i))?receivefile_attr[i]:GREATERINDEX) #define ReceiveFileAttrIndex(str) (receivefile_attr.indexOf(str)) /** * @brief * 蓝牙协议支持 * @param * @return true or false */ bool support_a2dp_sink(const QStringList &); bool support_a2dp_source(const QStringList &); bool support_hfphsp_ag(const QStringList &); bool support_hfphsp_hf(const QStringList &); bool support_filetransport(const QStringList &); //日志等级设置 void set_logLevel(const QString &level); void set_logLevel(int level); QString get_logFormat(QString file, QString function, int fileline); #endif // COMMON_H ukui-bluetooth/service/systemadapter.h0000664000175000017500000000674115167665770017212 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef SYSTEMADAPTER_H #define SYSTEMADAPTER_H #include #include #include #include #include #include #include #include #include #include "ukui-log4qt.h" class SystemAdapter : public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "com.ukui.bluetooth") public: explicit SystemAdapter(QObject *parent = nullptr); virtual ~SystemAdapter(); public slots: QMap registerClient(QMap); bool unregisterClient(QString); QStringList getRegisterClient(void); QStringList getAllAdapterAddress(void); QMap getAdapterAttr(QString, QString); QStringList getDefaultAdapterAllDev(void); QStringList getDefaultAdapterPairedDev(void); QMap getDevAttr(QString); bool setDevAttr(QString, QMap); bool setDefaultAdapterAttr(QMap); int setDefaultAdapter(QString); int devConnect(QString); int devDisconnect(QString); int devRemove(QStringList); int activeConnectionReply(QString, bool); int pairFuncReply(QString, bool); int sendFiles(QString, QString, QStringList); int stopFiles(QMap); int replyFileReceiving(QMap); void writeBuriedPointData(QString, QString, QString, QString); QString bluetoothKeyValue(unsigned int,QString); void setLogLevel(int level); //提供活跃用户接口 QString GetActiveUser(void); //托盘显示的蓝牙设备顺序 void updatePairedDeviceSort(QStringList); //leavelock bool setLeaveLock(QString uuid, QString dev, bool on); bool getLeaveLockPower(void); void setLeaveLockPower(bool); signals: void adapterAddSignal(QMap); void adapterAttrChanged(QString, QMap); void adapterRemoveSignal(QString); void deviceAddSignal(QMap); void deviceAttrChanged(QString, QMap); void deviceRemoveSignal(QString, QMap); void ActiveConnection(QString, QString, QString, int, int); void updateClient(void); void startPair(QMap); void fileStatusChanged(QMap); void fileReceiveSignal(QMap); void clearBluetoothDev(QStringList); void pingTimeSignal(QByteArray); //音频控制信号 void VolumeDown(); void VolumeUp(); void Next(); void PlayPause(); void Previous(); void Stop(); void Play(); void Pause(); //活跃用户信号 void ActiveUserChange(QString); private: QString getCallerDebus(void); QStringList m_sortPairedDeviceList; }; #endif // SYSTEMADAPTER_H ukui-bluetooth/service/main.cpp0000664000175000017500000001300115167665770015567 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "daemon.h" #include "sessiondbusregister.h" #include "systemadapter.h" #include "app.h" #include "adapter.h" #include "device.h" #include "common.h" #include "filesess.h" #include "leavelock.h" extern "C" { #include #include } #include "kysdk/kysdk-system/libkysysinfo.h" void signalHandlerFunc(int signal) { fprintf(stderr,"---------------------- %d",signal); } static QString executeLinuxCmd(QString strCmd) { QProcess p; p.start("bash", QStringList() <<"-c" << strCmd); p.waitForFinished(); QString strResult = p.readAllStandardOutput(); return strResult.toLower(); } static void setEnvPCValue() { unsigned int productFeatures = 0; char * projectName = ""; char * projectSubName = ""; productFeatures = kdk_system_get_productFeatures(); projectName = kdk_system_get_projectName(); QString qs_projectName = QString(projectName); projectSubName = kdk_system_get_projectSubName(); QString qs_projectSubName = QString(projectSubName); envPC = Environment::NOMAL; QString str = executeLinuxCmd("cat /proc/cpuinfo | grep -i hardware"); if(str.length() == 0) { goto FuncEnd; } if(str.indexOf("huawei") != -1 || str.indexOf("pangu") != -1 || str.indexOf("kirin") != -1) { QString str1 = executeLinuxCmd("dmidecode |grep \"String 4\""); //M900公版无需采用CBG方案,可跟随主线方案 if(str.indexOf("m900") != -1 && (str1.isEmpty() || str1.indexOf("pwc30") == -1)) { envPC = Environment::NOMAL; } else { envPC = Environment::HUAWEI; } } FuncEnd: if (QFile::exists("/etc/apt/ota_version")) envPC = Environment::LAIKA; else if(qs_projectName.contains("V10SP1-edu",Qt::CaseInsensitive) && qs_projectSubName.contains("mavis",Qt::CaseInsensitive)) { envPC = Environment::MAVIS; } KyInfo () << envPC; } static bool InterfaceAlreadyExists() { QDBusConnection conn = QDBusConnection::systemBus(); if (!conn.isConnected()) return 0; QDBusReply reply = conn.interface()->call("GetNameOwner", "com.ukui.bluetooth"); return reply.value() == ""; } static int init(void) { if (InterfaceAlreadyExists()) { CONFIG::instance(); CONFIG::getInstance()->init(); QDBusConnection conn = QDBusConnection::systemBus(); if (!conn.registerService("com.ukui.bluetooth")) { KyWarning() << "QDbus register service failed reason:" << conn.lastError(); return -1; } SYSDBUSMNG::instance(); SYSDBUSMNG::getInstance()->start(); if(!conn.registerObject("/com/ukui/bluetooth", "com.ukui.bluetooth", SYSDBUSMNG::getInstance()->get_sys_adapter(), QDBusConnection::ExportAllSlots|QDBusConnection::ExportAllSignals)) { KyWarning() << "QDbus register object failed reason:" << conn.lastError(); return -1; } BPDMNG::instance(); APPMNG::instance(); ADAPTERMNG::instance(); Q_EMIT SYSDBUSMNG::getInstance()->updateClient(); DAEMON::instance(); DAEMON::getInstance()->start(); LEAVELOCK::instance(); if(envPC != HUAWEI) { FILESESSMNG::instance(); FILESESSMNG::getInstance()->init(); } } else { KyInfo() << "already running"; return -1; } return 0; } static int fini(void) { return 0; } int main(int argc, char *argv[]) { set_logLevel("info"); fprintf(stdout,"Program running.....\n"); setEnvPCValue(); KyInfo() << "envPC: "<< envPC; QCoreApplication a(argc, argv); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); parser.addOptions({{{"o","obex"},QCoreApplication::translate("main","Load the Bluetooth file transfer agent")}}); parser.setApplicationDescription(QCoreApplication::translate("main","UKUI bluetooth daemon")); parser.process(a); QTranslator *t = new QTranslator(); t->load("/usr/share/libpeony-qt/libpeony-qt_"+QLocale::system().name() + ".qm"); QCoreApplication::installTranslator(t); int ret = init(); if(0 != ret) { return ret; } KyInfo() << "QCoreApplication exec"; int quitValue = a.exec(); fini(); KyInfo() << "Daemon program exit!!!!"; return quitValue; } ukui-bluetooth/service/bluetoothobexagent.cpp0000664000175000017500000000301715167665755020556 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothobexagent.h" #include "filesess.h" BluetoothObexAgent::BluetoothObexAgent(QObject *parent):ObexAgent(parent) { KyInfo(); } BluetoothObexAgent::~BluetoothObexAgent() { KyInfo(); } QDBusObjectPath BluetoothObexAgent::objectPath() const { return QDBusObjectPath(QStringLiteral("/org/bluez/obex/Agent1")); } void BluetoothObexAgent::authorizePush(BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, const BluezQt::Request &request) { KyInfo(); if(nullptr == transfer || nullptr == session) { request.reject(); } m_session = session; FILESESSMNG::getInstance()->receiveFiles(transfer, session, request); } void BluetoothObexAgent::cancel() { FILESESSMNG::getInstance()->sessionCanceled(m_session); KyInfo(); } void BluetoothObexAgent::release() { KyInfo(); } ukui-bluetooth/service/CSingleton.h0000664000175000017500000000262715167665770016371 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef CSINGLETON_H #define CSINGLETON_H #include "common.h" template class SingleTon { public: // 创建单例实例 template static T* instance(Args&&... args) { if (m_pInstance == nullptr) { m_pInstance = new T(std::forward(args)...); } return m_pInstance; } // 获取单例 static T* getInstance() { return m_pInstance; } // 删除单例 static void destroyInstance() { delete m_pInstance; m_pInstance = nullptr; } private: SingleTon(); virtual ~SingleTon(); private: static T* m_pInstance; }; template T* SingleTon::m_pInstance = nullptr; #endif ukui-bluetooth/service/app.h0000664000175000017500000000347315167665770015104 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef APP_H #define APP_H #include #include #include #include #include #include "CSingleton.h" class Application { public: explicit Application(QString, QString, int); ~Application(); QString dbusid(){ return m_dbusid; } QString username(){ return m_username; } int type(){ return m_type; } protected: QString m_dbusid; QString m_username; int m_type = 0; }; class ApplicationMng: public QObject { public: ApplicationMng(); ~ApplicationMng(); public: int add(QString, QString, int); int remove(QString); int getControlNum(void); int getAllNum(void) { return m_apps.size(); } bool existDbusid(QString); QStringList getRegisterClient(void); //int unknownDbusid(QString, ); QString getUserDbusid(QString, int); private: void update(void); protected slots: void serviceUnregistered(const QString &service); protected: QMap m_apps; QDBusServiceWatcher * m_watch = nullptr; friend class SingleTon; }; typedef SingleTon APPMNG; #endif // APP_H ukui-bluetooth/service/sessiondbusregister.cpp0000664000175000017500000001406015167665770020757 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "sessiondbusregister.h" #include #include #include #include #include #include "systemadapter.h" #include "app.h" #include "common.h" #define BLUETOOTH_KEY_VOLUMEDOWN 114 #define BLUETOOTH_KEY_VOLUMEUP 115 #define BLUETOOTH_KEY_NEXTSONG 163 #define BLUETOOTH_KEY_PLAYPAUSE 164 #define BLUETOOTH_KEY_PREVIOUSSONG 165 #define BLUETOOTH_KEY_STOPCD 166 #define BLUETOOTH_KEY_PLAYCD 200 #define BLUETOOTH_KEY_PAUSECD 201 SysDbusMng::SysDbusMng(QObject *parent) { KyInfo(); } SysDbusMng::~SysDbusMng() { KyInfo(); } int SysDbusMng::start() { KyInfo(); m_sys_adapter = new SystemAdapter(this); connect(this, &SysDbusMng::adapterAddSignal, m_sys_adapter, &SystemAdapter::adapterAddSignal); connect(this, &SysDbusMng::adapterAttrChanged, m_sys_adapter, &SystemAdapter::adapterAttrChanged); connect(this, &SysDbusMng::adapterRemoveSignal, m_sys_adapter, &SystemAdapter::adapterRemoveSignal); connect(this, &SysDbusMng::deviceAddSignal, m_sys_adapter, &SystemAdapter::deviceAddSignal); connect(this, &SysDbusMng::deviceAttrChanged, m_sys_adapter, &SystemAdapter::deviceAttrChanged); connect(this, &SysDbusMng::deviceRemoveSignal, m_sys_adapter, &SystemAdapter::deviceRemoveSignal); connect(this, &SysDbusMng::ActiveConnection, m_sys_adapter, &SystemAdapter::ActiveConnection); connect(this, &SysDbusMng::updateClient, m_sys_adapter, &SystemAdapter::updateClient); connect(this, &SysDbusMng::startPair, m_sys_adapter, &SystemAdapter::startPair); connect(this, &SysDbusMng::fileStatusChanged, m_sys_adapter, &SystemAdapter::fileStatusChanged); connect(this, &SysDbusMng::fileReceiveSignal, m_sys_adapter, &SystemAdapter::fileReceiveSignal); connect(this, &SysDbusMng::clearBluetoothDev, m_sys_adapter, &SystemAdapter::clearBluetoothDev); connect(this, &SysDbusMng::pingTimeSignal, m_sys_adapter, &SystemAdapter::pingTimeSignal); //音频控制信号 connect(this, &SysDbusMng::VolumeDown, m_sys_adapter, &SystemAdapter::VolumeDown); connect(this, &SysDbusMng::VolumeUp, m_sys_adapter, &SystemAdapter::VolumeUp); connect(this, &SysDbusMng::Next, m_sys_adapter, &SystemAdapter::Next); connect(this, &SysDbusMng::PlayPause, m_sys_adapter, &SystemAdapter::PlayPause); connect(this, &SysDbusMng::Previous, m_sys_adapter, &SystemAdapter::Previous); connect(this, &SysDbusMng::Stop, m_sys_adapter, &SystemAdapter::Stop); connect(this, &SysDbusMng::Play, m_sys_adapter, &SystemAdapter::Play); connect(this, &SysDbusMng::Pause, m_sys_adapter, &SystemAdapter::Pause); //活跃用户信号 connect(this, &SysDbusMng::ActiveUserChange, m_sys_adapter, &SystemAdapter::ActiveUserChange); return 0; } int SysDbusMng::stop() { return 0; } bool SysDbusMng::registerClient(QMap params, QString id) { QString dbusid; QString username; int type = -1; QString key; key = AppAttr(enum_app_attr_dbusid); if(params.contains(key) && params[key].type() == QVariant::String) { dbusid = params[key].toString(); } key = AppAttr(enum_app_attr_username); if(params.contains(key) && params[key].type() == QVariant::String) { username = params[key].toString(); } key = AppAttr(enum_app_attr_type); if(params.contains(key) && params[key].type() == QVariant::Int) { type = params[key].toInt(); } KyInfo() << dbusid << username << type; if(dbusid.isEmpty() || username.isEmpty() || -1 == type || id != dbusid) { KyWarning() << "registerClient error"; return false; } APPMNG::getInstance()->add(dbusid, username, type); return true; } bool SysDbusMng::unregisterClient(QString dbusid) { return APPMNG::getInstance()->remove(dbusid); } QString SysDbusMng::bluetoothKeyValue(unsigned int keyValue, QString str) { //获取当前时间 long long _currentTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); //对比按键-按下和释放的间隔时间,判断是否需要处理按键相应 if ("pressed" == str) { m_pressTimeMap[keyValue] = _currentTime; } else if ("released" == str) { m_releaseTimeMap[keyValue] = _currentTime; if (m_pressTimeMap.contains(keyValue)) { if((m_releaseTimeMap[keyValue] - m_pressTimeMap[keyValue]) <= 200) sendMultimediaControlButtonSignal(keyValue); //时间间隔太长,可能需要特殊处理 } else { sendMultimediaControlButtonSignal(keyValue); } } return QString("The Bluetooth key value is received."); } void SysDbusMng::sendMultimediaControlButtonSignal(unsigned int keyValue) { switch (keyValue) { case BLUETOOTH_KEY_VOLUMEDOWN: emit this->VolumeDown(); break; case BLUETOOTH_KEY_VOLUMEUP: emit this->VolumeUp(); break; case BLUETOOTH_KEY_NEXTSONG: emit this->Next(); break; case BLUETOOTH_KEY_PLAYPAUSE: emit this->PlayPause(); break; case BLUETOOTH_KEY_PREVIOUSSONG: emit this->Previous(); break; case BLUETOOTH_KEY_STOPCD: emit this->Stop(); break; case BLUETOOTH_KEY_PLAYCD: emit this->Play(); break; case BLUETOOTH_KEY_PAUSECD: emit this->Pause(); break; default: break; } } ukui-bluetooth/service/filesess.h0000664000175000017500000001136015167665770016133 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef FILESESS_H #define FILESESS_H #include #ifdef BATTERY #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "CSingleton.h" class KylinFileSess : public QObject { Q_OBJECT public: explicit KylinFileSess(QString, QStringList); explicit KylinFileSess(BluezQt::ObexTransferPtr transfer,BluezQt::ObexSessionPtr session, const BluezQt::Request &request); ~KylinFileSess(); void ObexSessionPtr(BluezQt::ObexSessionPtr p){ m_sess = p; } BluezQt::ObexSessionPtr ObexSessionPtr(void) { return m_sess; } enum_filetransport_Type type(void){ return m_type; } void receiveUpdate(BluezQt::ObexTransferPtr transfer,BluezQt::ObexSessionPtr session, const BluezQt::Request &request); QDBusObjectPath object_path(void){ return m_object_path; } void stop(void); int replyFileReceiving(bool, QString); void addNewFiles(QStringList files); void cancelReceive(); public slots: void CreateSessStart(BluezQt::PendingCall *call); protected slots: void TransferStart(BluezQt::PendingCall *call); void transferredChanged(quint64 transferred); void statusChanged(BluezQt::ObexTransfer::Status status); void fileNameChanged(const QString &fileName); protected: int sendfile(void); QString getProperFilePath(QString, QString); int movefile(QString, QString &); virtual void timerEvent( QTimerEvent *event); void setSendfileStatus(bool status = true); private: int send_statuschanged(void); int send_reveivesignal(void); int __init_Transfer(); int __send_statuschanged(void); bool __isdir_exist(QString); bool __isfile_exit(QString); protected: bool m_running = true; QString m_dest; QStringList m_files; int m_fileIndex = 0; QDBusObjectPath m_object_path; quint64 m_transfer_file_size = 0; QString m_transferPath; int m_percent = 0; BluezQt::ObexTransferPtr m_filePtr = nullptr; BluezQt::ObexSessionPtr m_sess = nullptr; BluezQt::ObexObjectPush * m_opp = nullptr; BluezQt::Request m_request; QMap m_attr; QString m_savePathdir; QString m_user; QString m_filetype; int m_remove_Timer = 0; enum_filetransport_Type m_type = enum_filetransport_Type_send; }; typedef QSharedPointer KylinFileSessPtr; //////////////////////////////////////// class FileSessMng : public QObject { Q_OBJECT public: explicit FileSessMng(); int init(void); int sendFiles(QString, QStringList); int receiveFiles(BluezQt::ObexTransferPtr transfer,BluezQt::ObexSessionPtr session, const BluezQt::Request &request); int removeSession(const QDBusObjectPath &session); int stopFiles(QString, int); int replyFileReceiving(QString, bool, QString); void sessionCanceled(BluezQt::ObexSessionPtr session); protected slots: //obex void operationalChanged(bool operational); void sessionAdded(BluezQt::ObexSessionPtr session); void sessionRemoved(BluezQt::ObexSessionPtr session); private: void wait_for_finish(BluezQt::PendingCall *call); void start_obexservice(); bool isFileExists(const QString& filePath); protected: QMap m_sess; QMap m_sess_recv; BluezQt::ObexManager * m_obex = nullptr; QProcess * m_process = nullptr; friend class SingleTon; }; typedef SingleTon FILESESSMNG; #endif // FILESESS_H ukui-bluetooth/service/buriedpointdata.h0000664000175000017500000000267215167665770017502 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BURIEDPOINTDATA_H #define BURIEDPOINTDATA_H #include #include #include #include #include #include #include "CSingleton.h" #ifdef EXISTS_KYSDK_DIAGNOSTICS //埋点 #include #endif class BuriedPointData : public QObject { Q_OBJECT public: BuriedPointData(QObject *parent = nullptr); Q_SIGNALS: void writeInData(QString, QString, QString, QString); public slots: void writeInDataSlot(QString , QString , QString , QString); protected: bool buriedSettings(QString, QString, QString, QString); QThread * m_Thread = nullptr; friend class SingleTon; }; typedef SingleTon BPDMNG; #endif // BURIEDPOINTDATA_H ukui-bluetooth/service/adapter.cpp0000664000175000017500000007314115167665770016276 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "adapter.h" #include "config.h" #include "device.h" #include "daemon.h" #include "app.h" #include "sessiondbusregister.h" #include KylinAdapter::KylinAdapter(BluezQt::AdapterPtr adapter) { m_adapter = adapter; m_set_activeConnection = CONFIG::getInstance()->activeconnection(); connect(m_adapter.data(),&BluezQt::Adapter::nameChanged,this, &KylinAdapter::nameChanged); connect(m_adapter.data(),&BluezQt::Adapter::poweredChanged,this, &KylinAdapter::poweredChanged); connect(m_adapter.data(),&BluezQt::Adapter::discoverableChanged,this, &KylinAdapter::discoverableChanged); connect(m_adapter.data(),&BluezQt::Adapter::discoveringChanged,this, &KylinAdapter::discoveringChanged); connect(m_adapter.data(),&BluezQt::Adapter::deviceRemoved,this, &KylinAdapter::deviceRemoved); connect(m_adapter.data(),&BluezQt::Adapter::deviceAdded,this, &KylinAdapter::deviceAdded); connect(m_adapter.data(),&BluezQt::Adapter::uuidsChanged, this, &KylinAdapter::uuidsChanged); KyInfo()<< m_adapter->address(); this->__sendAdd(); } KylinAdapter::~KylinAdapter() { KyInfo() << m_adapter->address(); this->__clear_timers(); m_adapter->disconnect(this); } int KylinAdapter::start() { KyInfo() << m_adapter->address(); m_is_start = true; m_need_reconnect = true; m_set_power = CONFIG::getInstance()->power_switch(); m_set_discoverable = CONFIG::getInstance()->discoverable_switch(); m_set_activeConnection = CONFIG::getInstance()->activeconnection(); m_active_dev = ""; m_uuids = m_adapter->uuids(); this->__init_uuid(); if(CONFIG::getInstance()->bluetooth_block()) { KyInfo() << "block, not start"; return -1; } for(auto item : m_adapter->devices()) { this->add(item); } if(m_set_power != m_adapter->isPowered()) { this->__setPower(); } else { this->__setPower(); emit m_adapter->poweredChanged(m_set_power); } this->__setDiscoverable(); m_attr_send[AdapterAttr(enum_Adapter_attr_DefaultAdapter)] = true; this->__sendAttr(enum_send_type_immediately); return 0; } int KylinAdapter::stop() { KyInfo() << m_adapter->address(); m_is_start = false; m_set_discoverable = false; m_set_Discovering = false; this->__setDiscoverable(); this->__setDiscovering(); this->__clear_timers(); return 0; } int KylinAdapter::bluetooth_block() { KyInfo() << m_adapter->address(); m_set_power = false; m_set_Discovering = false; this->set_need_reconnect(true); m_attr_send[AdapterAttr(enum_Adapter_attr_Powered)] = false; m_attr_send[AdapterAttr(enum_Adapter_attr_Block)] = true; this->__sendAttr(enum_send_type_immediately); this->__clear_timers(); return 0; } int KylinAdapter::reconnect_dev() { QStringList audiolist = CONFIG::getInstance()->finally_audiodevice(); KyInfo() << m_adapter->address() << " support_a2dp_source: " << m_support_a2dp_source << ", finally_audiodevice:" << audiolist << ", power: " << m_adapter->isPowered() << ", is_start: " << m_is_start; if(0 == m_reconnect_TimerId && m_support_a2dp_source && audiolist.size() > 0 && m_adapter->isPowered() && m_is_start) { m_reconnect_TimerId = this->startTimer(3 * 1000); } return 0; } void KylinAdapter::nameChanged(const QString &name) { m_attr_send[AdapterAttr(enum_Adapter_attr_Name)] = name; this->__sendAttr(); } void KylinAdapter::poweredChanged(bool powered) { KyInfo() << m_adapter->address() << powered; if(!m_is_start) { m_attr_send[AdapterAttr(enum_Adapter_attr_Powered)] = powered; this->__sendAttr(); return; } if(m_set_power != powered && 0 != m_set_TimerID) { KyWarning() << "set power error, set: "<< m_set_power << ", now: " << powered << ", reset"; return; } m_attr_send[AdapterAttr(enum_Adapter_attr_Powered)] = powered; this->__sendAttr(); if(powered) { this->updateDiscovering(); if(0 == m_autoclean_TimerID) { m_autoclean_TimerID = this->startTimer(20 * 1000); for(auto iter : m_devices.toStdMap()) { iter.second->reset(); } } if(!CONFIG::getInstance()->active_user().isEmpty()) { this->reconnect_dev(); } else { KyInfo() << "not join user"; } } else { m_need_reconnect = true; //关闭蓝牙后,停止回连 if(0 != m_reconnect_TimerId) { this->killTimer(m_reconnect_TimerId); m_reconnect_TimerId = 0; } } } void KylinAdapter::discoverableChanged(bool discoverable) { KyInfo() << m_adapter->address() << discoverable; m_attr_send[AdapterAttr(enum_Adapter_attr_Discoverable)] = discoverable; this->__sendAttr(); } void KylinAdapter::discoveringChanged(bool discovering) { KyInfo() << m_adapter->address() << discovering; m_attr_send[AdapterAttr(enum_Adapter_attr_Discovering)] = discovering; this->__sendAttr(); } void KylinAdapter::deviceAdded(BluezQt::DevicePtr device) { this->add(device); } void KylinAdapter::deviceRemoved(BluezQt::DevicePtr device) { this->remove(device); } void KylinAdapter::uuidsChanged(const QStringList &uuids) { if(!m_is_start) { KyInfo() << m_adapter->address() << " not default adpater"; return; } m_uuids = uuids; this->__init_uuid(); } QStringList KylinAdapter::getAllDev() { QStringList devlist; for(auto item : m_devices.toStdMap()) { devlist.append(item.first); } return devlist; } QStringList KylinAdapter::getPairedDev() { QStringList devlist; for(auto item : m_devices.toStdMap()) { if(item.second->ispaired()) { devlist.append(item.first); } } return devlist; } bool KylinAdapter::setDiscoverable(bool v) { KyInfo() << m_adapter->address() << v; m_set_discoverable = v; return this->__setDiscoverable(); } bool KylinAdapter::setPower(bool v) { KyInfo() << m_adapter->address() << v; m_set_power = v; if(v) { DAEMON::getInstance()->unblock_bluetooth(); } if(m_adapter->isPowered() == v) { KyInfo() << m_adapter->address() << " set same"; this->__setPower(); emit m_adapter->poweredChanged(m_set_power); } else { KyInfo() << m_adapter->address() << " set not same"; this->__setPower(); } return 0; } bool KylinAdapter::setActiveConnection(bool v) { KyInfo() << m_adapter->address() << v; m_set_activeConnection = v; return this->__setActiveConnection(); } bool KylinAdapter::setName(QString name) { BluezQt::PendingCall * pending = m_adapter->setName(name); //this->wait_for_finish(pending); return 0; } bool KylinAdapter::trayShow(bool v) { m_attr_send[AdapterAttr(enum_Adapter_attr_TrayShow)] = v; this->__sendAttr(); return true; } void KylinAdapter::audioCombine(bool v) { QString dbusid = APPMNG::getInstance()->getUserDbusid(CONFIG::getInstance()->active_user(), enum_app_type_bluetooth_tray); if(!dbusid.isEmpty()) { if(v) { if(m_connected_audio_device_list.size() >= 2) { QDBusInterface iface(dbusid, "/", "com.ukui.bluetooth", QDBusConnection::systemBus()); iface.asyncCall("setMultiAudioCombine", true); } } else { if(m_connected_audio_device_list.size() >= 2) { QDBusInterface iface(dbusid, "/", "com.ukui.bluetooth", QDBusConnection::systemBus()); iface.asyncCall("setMultiAudioCombine", false); } } } } QMap KylinAdapter::getAdapterAttr(QString key) { QMap attrs; this->__init_devattr(attrs); return attrs; } KylinDevicePtr KylinAdapter::getDevPtr(QString addr) { if(m_devices.contains(addr)) { return m_devices[addr]; } return nullptr; } bool KylinAdapter::devIsAudioType(QString addr) { if(m_devices.contains(addr)) { return m_devices[addr]->isAudioType(); } return false; } int KylinAdapter::devConnect(QString addr, int type /*= 0*/) { KyInfo() << m_adapter->address() << " addr: "<< addr; int ret = ERR_BREDR_CONN_SUC; if(addr.isEmpty() || !m_adapter->isPowered() || !m_devices.contains(addr)) { ret = ERR_BREDR_UNKNOWN_Other; return ret; } if(m_connectProgress) { ret = ERR_BREDR_INTERNAL_Operation_Progress; return ret; } m_connectProgress = true; this->updateDiscovering(); if(m_connected_audio_device_list.contains(addr)) { KyInfo() << addr << " is connected_audio_device"; ret = ERR_BREDR_INTERNAL_Already_Connected; goto END; } if(m_connected_audio_device_list.size() >= 2 && m_devices[addr]->isAudioType()) { KyInfo() << addr << " is connected_audio_device"; ret = ERR_BREDR_INTERNAL_AUDIO_MAXNUM; m_devices[addr]->sendAudioMaxSignal(); goto END; } if(m_devices.contains(addr)) { ret = m_devices[addr]->devConnect(type); } else { ret = ERR_BREDR_INTERNAL_Dev_Not_Exist; } END: m_connectProgress = false; this->updateDiscovering(); return ret; } int KylinAdapter::devDisconnect(QString addr) { KyInfo() << addr; int ret = ERR_BREDR_INTERNAL_Dev_Not_Exist; if(m_devices.contains(addr)) { ret = m_devices[addr]->devDisconnect(); } return ret; } int KylinAdapter::devRemove(QStringList devlist) { if(devlist.size() == 0 ) { return 0; } m_cleanProgress = true; this->updateDiscovering(); for(auto iter : devlist) { this->__devRemove(iter.toUpper()); CONFIG::getInstance()->remove_finally_audiodevice(iter.toUpper()); } m_cleanProgress = false; this->updateDiscovering(); return 0; } int KylinAdapter::__devRemove(QString addr) { BluezQt::DevicePtr devPtr = m_adapter->deviceForAddress(addr); if(devPtr) { m_adapter->removeDevice(devPtr); } return 0; } int KylinAdapter::updateDiscovering() { bool new_set_Discovering = false; bool ispower = m_adapter->isPowered(); int controlnum = APPMNG::getInstance()->getControlNum(); int allnum = APPMNG::getInstance()->getAllNum(); KyInfo() << m_adapter->address() << " adapterpower: "<< ispower << " controlnum: " << controlnum <<" allappnum: "<< allnum << " connectProgress:" << m_connectProgress << " activeConnection: " << m_set_activeConnection << " cleanProgress: " << m_cleanProgress; //默认适配器 && 适配器开启 && 无正在连接设备 && 无正在清理设备 if(m_is_start && ispower && !m_connectProgress && !m_cleanProgress) { if(controlnum > 0) { new_set_Discovering = true; } else if( allnum > 0 && m_set_activeConnection) { new_set_Discovering = true; } } if(new_set_Discovering != m_set_Discovering) { m_set_Discovering = new_set_Discovering; this->__setDiscovering(); } return 0; } int KylinAdapter::devDisconnectAll() { for(auto iter : m_devices.toStdMap()) { iter.second->devDisconnect(); } return 0; } void KylinAdapter::connected_audio_device(QString v) { KyInfo() << m_adapter->address() << v; if(!m_connected_audio_device_list.contains(v)) { m_connected_audio_device_list.append(v); m_attr_send[AdapterAttr(enum_Adapter_attr_AudioConnectedNum)] = m_connected_audio_device_list.size(); this->__sendAttr(); this->audioCombine(CONFIG::getInstance()->AudioCombine()); } } void KylinAdapter::disconnected_audio_device(QString v) { m_connected_audio_device_list.removeOne(v); KyInfo() << v << m_connected_audio_device_list; m_attr_send[AdapterAttr(enum_Adapter_attr_AudioConnectedNum)] = m_connected_audio_device_list.size(); this->__sendAttr(); this->audioCombine(CONFIG::getInstance()->AudioCombine()); } int KylinAdapter::activeConnectionReply(QString addr, bool v) { if(addr != m_active_dev || addr.isEmpty() || m_active_dev.isEmpty()) { return -1; } if(m_devices.contains(addr)) { if(0 != m_activeConnection_TimerID) { this->killTimer(m_activeConnection_TimerID); m_activeConnection_TimerID = 0; } if(v) { int ret = this->devConnect(addr); if(ERR_BREDR_CONN_SUC == ret ) { CONFIG::getInstance()->finally_audiodevice(addr); } } else { m_black_activeconn_dev.insert(addr); } m_active_dev = ""; } return 0; } void KylinAdapter::clearPinCode() { KyInfo() << m_adapter->address(); m_attr_send[AdapterAttr(enum_Adapter_attr_ClearPinCode)] = true; this->__sendAttr(); } int KylinAdapter::add(BluezQt::DevicePtr device) { if(m_devices.contains(device->address())) { m_devices[device->address()]->reset(); } else { KylinDevicePtr a(new KylinDevice(device, m_adapter->address())); m_devices[device->address()] = a; a->start(); } return 0; } int KylinAdapter::remove(BluezQt::DevicePtr device) { KyInfo() << m_adapter->address() << device->address(); if(m_devices.contains(device->address())) { //KylinDevicePtr对象删除可能延后,不可控,先发送删除信号 m_devices[device->address()]->__send_remove(); m_devices.remove(device->address()); } return 0; } bool KylinAdapter::deal_active_connection(QString addr, int timeout) { if(m_black_activeconn_dev.contains(addr) || 0 != m_activeConnection_TimerID) { KyInfo() << m_adapter->address() << " black list in" << addr; return false; } if(!m_active_dev.isEmpty() || !m_devices.contains(addr)) { return false; } m_active_dev = addr; m_activeConnection_TimerID = this->startTimer(timeout * 1000); return true; } bool KylinAdapter::__setDiscoverable() { BluezQt::PendingCall * pending = m_adapter->setDiscoverable(m_set_discoverable); //this->wait_for_finish(pending); if(0 == m_set_TimerID) { m_set_TimerID = this->startTimer(5000); } return true; } bool KylinAdapter::__setPower() { m_powerProgress = true; if(!m_set_power) { m_set_Discovering = false; this->__setDiscovering(); } KyInfo() << m_set_power; BluezQt::PendingCall * pending = m_adapter->setPowered(m_set_power); //this->wait_for_finish(pending); m_powerProgress = false; if(0 == m_set_TimerID) { m_set_TimerID = this->startTimer(5000); } return true; } bool KylinAdapter::__setActiveConnection() { this->updateDiscovering(); m_attr_send[AdapterAttr(enum_Adapter_attr_ActiveConnection)] = m_set_activeConnection; this->__sendAttr(); return true; } bool KylinAdapter::__setDiscovering() { BluezQt::PendingCall * pending = nullptr; if(m_set_Discovering) { pending = m_adapter->startDiscovery(); } else { pending = m_adapter->stopDiscovery(); } this->wait_for_finish(pending); if(0 == m_set_TimerID) { m_set_TimerID = this->startTimer(5000); } return true; } void KylinAdapter::__sendAttr(enum_send_type stype /*= enum_send_type_delay*/) { if(enum_send_type_delay == stype) { if(0 == m_attrsignal_TimerID) { m_attrsignal_TimerID = this->startTimer(500); } } else { if(0 != m_attrsignal_TimerID) { this->killTimer(m_attrsignal_TimerID); m_attrsignal_TimerID = 0; } KyInfo() << m_adapter->address() <<" attrs: "<< m_attr_send; emit SYSDBUSMNG::getInstance()->adapterAttrChanged(m_adapter->address(), m_attr_send); m_attr_send.clear(); } } void KylinAdapter::__sendAdd() { QMap attrs; this->__init_devattr(attrs); KyDebug() << m_adapter->address() << attrs; emit SYSDBUSMNG::getInstance()->adapterAddSignal(attrs); } void KylinAdapter::__reconnectFunc() { KyInfo() << m_need_reconnect; if(!m_need_reconnect || !m_adapter->isPowered()) { return; } if(CONFIG::getInstance()->active_user().isEmpty()) { KyInfo() << "not join user, not reconnect"; return; } m_need_reconnect = false; m_reconnectProgress = true; QStringList audiolist = CONFIG::getInstance()->finally_audiodevice(); KyInfo() << m_adapter->address() << " reconnect: "<< audiolist; for (auto & iter: audiolist) { this->devConnect(iter, 1); } m_reconnectProgress = false; } void KylinAdapter::__clear_timers() { if(0 != m_set_TimerID) { this->killTimer(m_set_TimerID); m_set_TimerID = 0; } if(0 != m_autoclean_TimerID) { this->killTimer(m_autoclean_TimerID); m_autoclean_TimerID = 0; } if(0 != m_attrsignal_TimerID) { this->killTimer(m_attrsignal_TimerID); m_attrsignal_TimerID = 0; KyDebug() << m_adapter->address() << " clear attrsignal_TimerID " << m_attr_send; emit SYSDBUSMNG::getInstance()->adapterAttrChanged(m_adapter->address(), m_attr_send); m_attr_send.clear(); } if(0 != m_activeConnection_TimerID) { this->killTimer(m_activeConnection_TimerID); m_activeConnection_TimerID = 0; m_active_dev = ""; } if(0 != m_reconnect_TimerId) { this->killTimer(m_reconnect_TimerId); m_reconnect_TimerId = 0; } } void KylinAdapter::timerEvent(QTimerEvent *event) { if(event->timerId() == m_set_TimerID) { KyInfo() << m_adapter->address() << " setAdapterConfTimer "; this->killTimer(event->timerId()); m_set_TimerID = 0; if(CONFIG::getInstance()->bluetooth_block()) { KyInfo() << "block, quit"; return ; } if(m_set_power != m_adapter->isPowered()) { this->__setPower(); } if(m_set_discoverable != m_adapter->isDiscoverable()) { this->__setDiscoverable(); } if(m_set_Discovering != m_adapter->isDiscovering()) { this->__setDiscovering(); } } else if(event->timerId() == m_attrsignal_TimerID) { KyDebug() << m_adapter->address() << " attrsignalTimer " << m_attr_send; this->killTimer(event->timerId()); m_attrsignal_TimerID = 0; emit SYSDBUSMNG::getInstance()->adapterAttrChanged(m_adapter->address(), m_attr_send); m_attr_send.clear(); } else if(event->timerId() == m_autoclean_TimerID) { //KyDebug() << "auto clean dev"; QStringList devlist; for(auto iter : m_devices.toStdMap()) { if(iter.second->needClean()) { devlist.append(iter.first); } } if(devlist.size() > 0) { int controlnum = APPMNG::getInstance()->getControlNum(); if(0 == controlnum) { this->devRemove(devlist); } else { emit SYSDBUSMNG::getInstance()->clearBluetoothDev(devlist); } } } else if(event->timerId() == m_activeConnection_TimerID) { KyInfo() << m_adapter->address() << " activeConnectionTimeout, addr: " << m_active_dev; this->killTimer(event->timerId()); m_activeConnection_TimerID = 0; m_active_dev = ""; } else if(event->timerId() == m_reconnect_TimerId) { KyInfo() << m_adapter->address() << " reconnectFunc"; this->killTimer(event->timerId()); m_reconnect_TimerId = 0; this->__reconnectFunc(); } else { KyInfo() << m_adapter->address() << " other timer, delete"; this->killTimer(event->timerId()); } } void KylinAdapter::wait_for_finish(BluezQt::PendingCall *call) { QEventLoop eventloop; connect(call, &BluezQt::PendingCall::finished, this, [&](BluezQt::PendingCall *callReturn) { eventloop.exit(); }); eventloop.exec(); } void KylinAdapter::__init_uuid() { if(support_a2dp_sink(m_uuids)) { if(!m_support_ad2p_sink) { m_support_ad2p_sink = true; KyInfo() << m_adapter->address() << "support_a2dp_sink"; } } else { if(m_support_ad2p_sink) { m_support_ad2p_sink = false; KyInfo() << m_adapter->address() << "not support_a2dp_sink"; } } if(support_a2dp_source(m_uuids)) { if(!m_support_a2dp_source) { m_support_a2dp_source = true; if(!CONFIG::getInstance()->active_user().isEmpty()) { QStringList audiolist = CONFIG::getInstance()->finally_audiodevice(); KyInfo() << m_adapter->address() << "support_a2dp_source" << ", devDisconnect finally_audiodevice " << audiolist; for(auto iter: audiolist) { this->devDisconnect(iter); } m_need_reconnect = true; this->reconnect_dev(); } else { KyInfo() << "not join user"; } } } else { if(m_support_a2dp_source) { m_support_a2dp_source = false; KyInfo() << m_adapter->address() << "not support_a2dp_source"; } } if(support_hfphsp_ag(m_uuids)) { if(!m_support_hfphsp_ag) { m_support_hfphsp_ag = true; KyInfo() << m_adapter->address() << "support_hfphsp_ag"; } } else { if(m_support_hfphsp_ag) { m_support_hfphsp_ag = false; KyInfo() << m_adapter->address() << "not support_hfphsp_ag"; } } if(support_hfphsp_hf(m_uuids)) { if(!m_support_hfphsp_hf) { m_support_hfphsp_hf = true; KyInfo() << m_adapter->address() << "support_hfphsp_hf"; } } else { if(m_support_hfphsp_hf) { m_support_hfphsp_hf = false; KyInfo() << m_adapter->address() << "not support_hfphsp_hf"; } } if(support_filetransport(m_uuids)) { if(!m_support_filetransport) { m_support_filetransport = true; KyInfo() << m_adapter->address() << "support_filetransport"; m_attr_send[AdapterAttr(enum_Adapter_attr_FileTransportSupport)] = m_support_filetransport; this->__sendAttr(); } } else { if(m_support_filetransport) { m_support_filetransport = false; KyInfo() << m_adapter->address() << "not support_filetransport"; m_attr_send[AdapterAttr(enum_Adapter_attr_FileTransportSupport)] = m_support_filetransport; this->__sendAttr(); } } } void KylinAdapter::__init_devattr(QMap & attrs) { attrs.clear(); attrs[AdapterAttr(enum_Adapter_attr_Powered)] = m_adapter->isPowered(); attrs[AdapterAttr(enum_Adapter_attr_Discoverable)] = m_adapter->isDiscoverable(); attrs[AdapterAttr(enum_Adapter_attr_Discovering)] = m_adapter->isDiscovering(); attrs[AdapterAttr(enum_Adapter_attr_Name)] = m_adapter->name(); attrs[AdapterAttr(enum_Adapter_attr_Addr)] = m_adapter->address(); attrs[AdapterAttr(enum_Adapter_attr_ActiveConnection)] = m_set_activeConnection; attrs[AdapterAttr(enum_Adapter_attr_Block)] = CONFIG::getInstance()->bluetooth_block(); attrs[AdapterAttr(enum_Adapter_attr_AudioCombine)] = CONFIG::getInstance()->AudioCombine(); attrs[AdapterAttr(enum_Adapter_attr_AudioConnectedNum)] = m_connected_audio_device_list.size(); attrs[AdapterAttr(enum_Adapter_attr_DefaultAdapter)] = m_is_start; attrs[AdapterAttr(enum_Adapter_attr_TrayShow)] = CONFIG::getInstance()->trayShow(); attrs[AdapterAttr(enum_Adapter_attr_FileTransportSupport)] = m_support_filetransport; } //////////////////////////////////////////////////////////// AdapterMng::AdapterMng() { } AdapterMng::~AdapterMng() { m_adapters.clear(); } int AdapterMng::add(BluezQt::AdapterPtr adapter) { if(m_adapters.contains(adapter->address())) { KyInfo() << adapter->address() << "exist"; m_adapters.remove(adapter->address()); this->update_adapter(); KylinAdapterPtr a(new KylinAdapter(adapter)); m_adapters[adapter->address()] = a; this->update_adapter(); //新增适配器非默认适配器 if(m_default_adapter && m_default_adapter->addr() != adapter->address()) { a->stop(); } } else { KylinAdapterPtr a(new KylinAdapter(adapter)); m_adapters[adapter->address()] = a; this->update_adapter(); //新增适配器非默认适配器 if(m_default_adapter && m_default_adapter->addr() != adapter->address()) { a->stop(); } return 0; } return 0; } int AdapterMng::remove(BluezQt::AdapterPtr adapter) { KyInfo() << adapter->address(); if(m_adapters.contains(adapter->address())) { m_adapters.remove(adapter->address()); KyDebug() << adapter->address(); //KylinAdapterPtr对象删除可能滞后,先发送移除信号 emit SYSDBUSMNG::getInstance()->adapterRemoveSignal(adapter->address()); } this->update_adapter(); return 0; } QStringList AdapterMng::getAllAdapterAddress() { QStringList AdapterList; for(auto item : m_adapters.toStdMap()) { AdapterList.append(item.first); } return AdapterList; } QStringList AdapterMng::getDefaultAdapterAllDev() { if(m_default_adapter) { return m_default_adapter->getAllDev(); } return QStringList(); } QStringList AdapterMng::getDefaultAdapterPairedDev() { if(m_default_adapter) { return m_default_adapter->getPairedDev(); } return QStringList(); } int AdapterMng::setDefaultAdapter(QString addr) { if(m_adapters.contains(addr)) { CONFIG::getInstance()->adapter_addr(addr); this->update_adapter(); if(m_default_adapter && m_default_adapter->addr() == addr) { return 0; } else { return -1; } } else { return -2; } return 0; } QMap AdapterMng::getAdapterAttr(QString addr, QString key) { if(m_adapters.contains(addr)) { return m_adapters[addr]->getAdapterAttr(key); } return QMap(); } void AdapterMng::bluetooth_block(bool v) { m_bluetooth_block = v; if(m_default_adapter) { if(v) { m_default_adapter->bluetooth_block(); } else { m_default_adapter->start(); } } } bool AdapterMng::isDefaultAdapter(QString addr) { if(m_default_adapter && m_default_adapter->addr() == addr) { return true; } return false; } int AdapterMng::update_adapter() { QString old_addr; if(m_default_adapter) { old_addr = m_default_adapter->addr(); if(!m_adapters.contains(m_default_adapter->addr())) { m_default_adapter = nullptr; } } if(m_adapters.size() == 0) { m_default_adapter = nullptr; CONFIG::getInstance()->adapter_addr("null"); } else if(m_adapters.size() == 1) { m_default_adapter = m_adapters.begin().value(); CONFIG::getInstance()->adapter_addr(m_default_adapter->addr()); m_default_adapter->start(); } else { QString conf_addr = CONFIG::getInstance()->adapter_addr(); if(m_default_adapter) { if(m_default_adapter->addr() != conf_addr) { if(m_adapters.contains(conf_addr)) { m_default_adapter->stop(); m_default_adapter = m_adapters[conf_addr]; m_default_adapter->start(); } else { CONFIG::getInstance()->adapter_addr(m_default_adapter->addr()); } } } else { if(m_adapters.contains(conf_addr)) { m_default_adapter = m_adapters[conf_addr]; } else { m_default_adapter = m_adapters.begin().value(); CONFIG::getInstance()->adapter_addr(m_default_adapter->addr()); } m_default_adapter->start(); } } if(m_default_adapter && m_default_adapter->addr() != old_addr) { KyInfo() << "default adapter changed, old: "<< old_addr <<", new: " << m_default_adapter->addr(); } return 0; } ukui-bluetooth/service/filesess.cpp0000664000175000017500000004731415167665770016476 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "filesess.h" #include #include #include #include "adapter.h" #include "bluetoothobexagent.h" #include "sessiondbusregister.h" #include "device.h" #include "config.h" #include "app.h" //#include KylinFileSess::KylinFileSess(QString addr, QStringList files) { KyInfo() << addr << files; m_dest = addr; m_files = files; m_type = enum_filetransport_Type_send; m_user = CONFIG::getInstance()->active_user(); } KylinFileSess::KylinFileSess(BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, const BluezQt::Request &request) { m_type = enum_filetransport_Type_receive; m_filePtr = transfer; m_sess = session; m_request = request; m_user = CONFIG::getInstance()->active_user(); m_dest = session->destination(); m_object_path = session->objectPath(); KyInfo() << m_object_path.path() << session->destination(); this->__init_Transfer(); this->send_reveivesignal(); //设置文件传输状态 this->setSendfileStatus(); } KylinFileSess::~KylinFileSess() { KyInfo() << m_dest; if(m_opp) { delete m_opp; m_opp = nullptr; } if(0 != m_remove_Timer) { this->killTimer(m_remove_Timer); m_remove_Timer = 0; } //接收异常 if(enum_filetransport_Type_receive == m_type) { } m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest; m_attr[FileStatusAttr(enum_filestatus_status)] = 0xff; m_attr[FileStatusAttr(enum_filestatus_transportType)] = m_type; this->__send_statuschanged(); //设置文件传输状态 this->setSendfileStatus(false); } void KylinFileSess::receiveUpdate(BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, const BluezQt::Request &request) { m_filetype = ""; m_filePtr = transfer; m_request = request; this->__init_Transfer(); if(session->objectPath() != m_sess->objectPath()) { KyInfo() << session->destination() << " sess changed, " << session->objectPath().path(); m_sess = session; m_object_path = m_sess->objectPath(); this->send_reveivesignal(); } else { m_fileIndex++; m_request.accept(m_filePtr->name()); } if(0 != m_remove_Timer) { this->killTimer(m_remove_Timer); m_remove_Timer = 0; } } void KylinFileSess::stop() { KyInfo(); if(nullptr != m_filePtr && BluezQt::ObexTransfer::Status::Active == m_filePtr->status()) { m_filePtr->cancel(); } m_running = false; } int KylinFileSess::replyFileReceiving(bool v, QString path) { KyInfo() << v; if(v) { if(!path.isEmpty() && this->__isdir_exist(path)) { m_savePathdir = path; if(!m_savePathdir.isEmpty() && m_savePathdir[m_savePathdir.length() - 1] != '/') { m_savePathdir += '/'; } } m_request.accept(m_filePtr->name()); } else { m_request.reject(); } return 0; } void KylinFileSess::CreateSessStart(BluezQt::PendingCall *call) { QVariant v = call->value(); m_object_path = v.value(); KyInfo() << m_object_path.path(); if(call->error() != 0) { KyWarning()<< m_dest <<" CreateSessStart error, code: " <error() << ", msg: "<< call->errorText(); m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest; m_attr[FileStatusAttr(enum_filestatus_fileFailedDisc)] = call->errorText(); FILESESSMNG::getInstance()->removeSession(m_object_path); return; } if(!m_running) { KyInfo() << "sendfile stop"; FILESESSMNG::getInstance()->removeSession(m_object_path); return; } //设置文件传输状态 this->setSendfileStatus(); m_opp = new BluezQt::ObexObjectPush(m_object_path); this->sendfile(); } void KylinFileSess::TransferStart(BluezQt::PendingCall *call) { KyInfo(); if(call->error() != 0) { KyWarning()<< m_dest <<" TransferStart error, code: " <error() << ", msg: "<< call->errorText(); m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest; m_attr[FileStatusAttr(enum_filestatus_fileFailedDisc)] = call->errorText(); this->__send_statuschanged(); FILESESSMNG::getInstance()->removeSession(m_object_path); return; } QVariant v = call->value(); m_filePtr = v.value(); this->__init_Transfer(); } void KylinFileSess::transferredChanged(quint64 transferred) { int percent = transferred * 100.0 / m_transfer_file_size; if(percent != m_percent) { m_attr[FileStatusAttr(enum_filestatus_progress)] = percent; this->send_statuschanged(); } m_percent = percent; } void KylinFileSess::statusChanged(BluezQt::ObexTransfer::Status status) { KyDebug() << status; if(BluezQt::ObexTransfer::Status::Active == status) { if(enum_filetransport_Type_receive == m_type) { if(m_filetype.isEmpty()) { /* QString src = "/root/.cache/obexd/" + m_filePtr->name(); GError *error; GFile *file = g_file_new_for_path(src.toStdString().c_str()); if(nullptr != file) { GFileInfo *file_info = g_file_query_info(file,"*",G_FILE_QUERY_INFO_NONE,NULL,&error); if(file_info) { m_filetype = g_file_info_get_content_type(file_info); KyInfo() << m_filePtr->name() << ", filetype: "< m_fileIndex) { this->sendfile(); } else { FILESESSMNG::getInstance()->removeSession(m_object_path); } } //接收文件,改变文件所属 else { QString dest; this->movefile(m_filePtr->name(), dest); m_attr[FileStatusAttr(enum_filestatus_savepath)] = dest; //10s内未收到文件传输信号,则断开文件连接连接 if(0 == m_remove_Timer) { m_remove_Timer = this->startTimer(10 * 1000); } } } else if(BluezQt::ObexTransfer::Status::Error == status) { this->send_statuschanged(); FILESESSMNG::getInstance()->removeSession(m_object_path); return; } else if(BluezQt::ObexTransfer::Status::Unknown == status) { this->send_statuschanged(); FILESESSMNG::getInstance()->removeSession(m_object_path); return; } this->send_statuschanged(); } void KylinFileSess::cancelReceive() { m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest; m_attr[FileStatusAttr(enum_filestatus_status)] = BluezQt::ObexTransfer::Error; m_attr[FileStatusAttr(enum_filestatus_transportType)] = m_type; this->__send_statuschanged(); } void KylinFileSess::fileNameChanged(const QString &fileName) { KyDebug() << fileName; } void KylinFileSess::addNewFiles(QStringList files) { m_files.append(files); } int KylinFileSess::sendfile() { int index = m_fileIndex; QString filename = m_files[index]; BluezQt::PendingCall *transfer = m_opp->sendFile(filename); connect(transfer, &BluezQt::PendingCall::finished, this, &KylinFileSess::TransferStart); return 0; } QString KylinFileSess::getProperFilePath(QString dir, QString filename) { QString dest; QString dbusid = APPMNG::getInstance()->getUserDbusid(m_user, enum_app_type_bluetooth_tray); if(!dbusid.isEmpty()) { QDBusInterface iface(dbusid, "/", "com.ukui.bluetooth", QDBusConnection::systemBus()); QDBusPendingCall pcall = iface.asyncCall("getProperFilePath", m_user, filename); pcall.waitForFinished(); QDBusMessage res = pcall.reply(); if(res.type() == QDBusMessage::ReplyMessage) { KyInfo() << res; if(res.arguments().size() > 0) { dest = res.arguments().takeFirst().toString(); } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } } return dest; } int KylinFileSess::movefile(QString filename, QString & dest) { QString src = "/root/.cache/obexd/" + filename; dest = this->getProperFilePath(m_savePathdir, filename); /* GError *error = NULL; GFile *source = g_file_new_for_path(src.toStdString().c_str()); GFile *destination = g_file_new_for_path(dest.toStdString().c_str()); bool flag = g_file_move(source,destination,G_FILE_COPY_BACKUP,NULL,NULL,NULL,&error); KyInfo() << "move file" << "target_path =" << dest << " source_path =" << src << "flag =" << flag; if(flag) { QString cmd; cmd = "chgrp " + m_user + " \'" + dest + "\'"; KyInfo() << cmd; system(cmd.toStdString().c_str()); cmd = "chown " + m_user + " \'" + dest + "\'";; KyInfo() << cmd; system(cmd.toStdString().c_str()); }*/ return 0; } void KylinFileSess::timerEvent(QTimerEvent *event) { if(event->timerId() == m_remove_Timer) { KyInfo() << "remove filesess"; this->killTimer(event->timerId()); m_remove_Timer = 0; FILESESSMNG::getInstance()->removeSession(m_object_path); } else { KyInfo() << "other timer, delete"; this->killTimer(event->timerId()); } } void KylinFileSess::setSendfileStatus(bool status /*= true*/) { KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(ptr) { d = ptr->getDevPtr(m_dest); } if(d) { d->setSendfileStatus(status); } } int KylinFileSess::send_statuschanged() { if(enum_filetransport_Type_send == m_type) { m_attr[FileStatusAttr(enum_filestatus_allfilenum)] = m_files.size(); } else { if(m_filetype.isEmpty()) { m_attr[FileStatusAttr(enum_filestatus_filetype)] = m_filePtr->type(); } else { m_attr[FileStatusAttr(enum_filestatus_filetype)] = m_filetype; } m_attr[FileStatusAttr(enum_filestatus_filesize)] = m_filePtr->size(); } m_attr[FileStatusAttr(enum_filestatus_filename)] = m_filePtr->name(); m_attr[FileStatusAttr(enum_filestatus_fileseq)] = m_fileIndex; m_attr[FileStatusAttr(enum_filestatus_dev)] = m_dest; m_attr[FileStatusAttr(enum_filestatus_status)] = m_filePtr->status(); m_attr[FileStatusAttr(enum_filestatus_transportType)] = m_type; this->__send_statuschanged(); return 0; } int KylinFileSess::__send_statuschanged() { Q_EMIT SYSDBUSMNG::getInstance()->fileStatusChanged(m_attr); m_attr.clear(); return 0; } bool KylinFileSess::__isdir_exist(QString dirpath) { QDir dir(dirpath); return dir.exists(); } bool KylinFileSess::__isfile_exit(QString filefullpath) { QFile file(filefullpath); return file.exists(); } int KylinFileSess::send_reveivesignal() { KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(!ptr) { KyWarning() << "getDefaultAdapter nullptr"; return -1; } d = ptr->getDevPtr(m_dest); if(!d) { KyWarning() << "getDevPtr nullptr"; return -1; } QMap attrs; attrs[ReceiveFileAttr(enum_receivefile_dev)] = m_dest; attrs[ReceiveFileAttr(enum_receivefile_name)] = d->Name(); attrs[ReceiveFileAttr(enum_receivefile_filetype)] = m_filePtr->type(); attrs[ReceiveFileAttr(enum_receivefile_filename)] = m_filePtr->name(); attrs[ReceiveFileAttr(enum_receivefile_filesize)] = m_filePtr->size(); Q_EMIT SYSDBUSMNG::getInstance()->fileReceiveSignal(attrs); //m_request.accept(m_filePtr->name()); return 0; } int KylinFileSess::__init_Transfer() { m_transfer_file_size = m_filePtr->size(); m_transferPath = m_filePtr->objectPath().path(); KyInfo() << m_transferPath << m_transfer_file_size << m_filePtr->name() << m_filePtr->fileName() << m_filePtr->type() << m_filePtr->status(); connect(m_filePtr.data(), &BluezQt::ObexTransfer::transferredChanged, this, &KylinFileSess::transferredChanged); connect(m_filePtr.data(), &BluezQt::ObexTransfer::statusChanged, this, &KylinFileSess::statusChanged); connect(m_filePtr.data(), &BluezQt::ObexTransfer::fileNameChanged, this, &KylinFileSess::fileNameChanged); m_percent = 0; m_attr[FileStatusAttr(enum_filestatus_progress)] = m_percent; this->send_statuschanged(); return 0; } //////////////////////////////////////////////////// FileSessMng::FileSessMng() { KyInfo(); } int FileSessMng::init() { m_obex = new BluezQt::ObexManager(this); BluezQt::InitObexManagerJob *obex_job = m_obex->init(); obex_job->exec(); connect(m_obex, &BluezQt::ObexManager::operationalChanged, this, &FileSessMng::operationalChanged); connect(m_obex, &BluezQt::ObexManager::sessionAdded, this, &FileSessMng::sessionAdded); connect(m_obex, &BluezQt::ObexManager::sessionRemoved, this, &FileSessMng::sessionRemoved); if(!m_obex->isOperational()) { this->start_obexservice(); } else { Q_EMIT m_obex->operationalChanged(m_obex->isOperational()); } return 0; } int FileSessMng::sendFiles(QString addr, QStringList files) { KyInfo() << addr << files; KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(!ptr || !m_obex->isOperational() || addr.isEmpty() || files.size() == 0) { return -1; } if (m_sess.contains(addr)) { m_sess[addr]->addNewFiles(files); return 0; } KylinFileSessPtr s(new KylinFileSess(addr, files)); m_sess[addr] = s; QMap map; map["Source"] = ptr->addr(); map["Target"] = "OPP"; BluezQt::PendingCall *target = m_obex->createSession(addr,map); connect(target, &BluezQt::PendingCall::finished, s.data(), &KylinFileSess::CreateSessStart); this->wait_for_finish(target); if(0 != target->error()) { m_sess.remove(addr); } return target->error(); } int FileSessMng::receiveFiles(BluezQt::ObexTransferPtr transfer, BluezQt::ObexSessionPtr session, const BluezQt::Request &request) { if(m_sess_recv.contains(session->destination())) { m_sess_recv[session->destination()]->receiveUpdate(transfer, session, request); return 0; } KylinFileSessPtr s(new KylinFileSess(transfer, session, request)); m_sess_recv[session->destination()] = s; return 0; } int FileSessMng::removeSession(const QDBusObjectPath &session) { KyInfo() << session.path(); m_obex->removeSession(session); return 0; } int FileSessMng::stopFiles(QString addr, int type) { KyInfo() << addr << type; if(enum_filetransport_Type_send == type) { if(m_sess.contains(addr)) { m_sess[addr]->stop(); if(!m_sess[addr]->object_path().path().isEmpty()) { this->removeSession(m_sess[addr]->object_path()); } } } else if(enum_filetransport_Type_receive == type) { if(m_sess_recv.contains(addr)) { m_sess_recv[addr]->stop(); this->removeSession(m_sess_recv[addr]->object_path()); } } return 0; } int FileSessMng::replyFileReceiving(QString addr, bool v, QString path) { KyInfo() << addr << v; if(m_sess_recv.contains(addr)) { return m_sess_recv[addr]->replyFileReceiving(v, path); } return 0; } void FileSessMng::operationalChanged(bool operational) { if(operational) { if(!BLUETOOTHOBEXAGENT::getInstance()) { BLUETOOTHOBEXAGENT::instance(this); BluezQt::PendingCall * call = m_obex->registerAgent(BLUETOOTHOBEXAGENT::getInstance()); this->wait_for_finish(call); } } else { if(BLUETOOTHOBEXAGENT::getInstance()) { BluezQt::PendingCall * call = m_obex->unregisterAgent(BLUETOOTHOBEXAGENT::getInstance()); this->wait_for_finish(call); BLUETOOTHOBEXAGENT::destroyInstance(); } QTimer::singleShot(5 * 1000,this,[=]{ KyInfo() << "restart obex"; this->start_obexservice(); }); } } void FileSessMng::sessionAdded(BluezQt::ObexSessionPtr session) { KyInfo(); if(session && m_sess.contains(session->destination())) { m_sess[session->destination()]->ObexSessionPtr(session); } } void FileSessMng::sessionRemoved(BluezQt::ObexSessionPtr session) { KyInfo() << ((nullptr == session) ? "null session" : session->destination()) << ((nullptr == session) ? "null session" : session->objectPath().path()); if(session && m_sess.contains(session->destination())) { BluezQt::ObexSessionPtr ptr = m_sess[session->destination()]->ObexSessionPtr(); if(ptr && ptr->objectPath() == session->objectPath()) { m_sess.remove(session->destination()); } } if(session && m_sess_recv.contains(session->destination())) { BluezQt::ObexSessionPtr ptr = m_sess_recv[session->destination()]->ObexSessionPtr(); if(ptr && ptr->objectPath() == session->objectPath()) { m_sess_recv.remove(session->destination()); } } } void FileSessMng::sessionCanceled(BluezQt::ObexSessionPtr session) { if (!m_sess_recv.contains(session->destination())) return; m_sess_recv[session->destination()]->cancelReceive(); } void FileSessMng::wait_for_finish(BluezQt::PendingCall *call) { QEventLoop eventloop; connect(call, &BluezQt::PendingCall::finished, this, [&](BluezQt::PendingCall *callReturn) { eventloop.exit(); }); eventloop.exec(); } void FileSessMng::start_obexservice() { KyInfo() << "start obex"; if(nullptr == m_process) { m_process = new QProcess; QString cmd = "/usr/lib/bluetooth/obexd"; if (!this->isFileExists(cmd)) { cmd = "/usr/libexec/bluetooth/obexd"; } KyInfo()<< cmd; m_process->setProgram(cmd); m_process->setArguments(QStringList{"-d"}); m_process->startDetached(); } else { QString cmd = "/usr/lib/bluetooth/obexd"; if (!this->isFileExists(cmd)) { cmd = "/usr/libexec/bluetooth/obexd"; } KyInfo()<< cmd; m_process->setProgram(cmd); m_process->setArguments(QStringList{"-d"}); m_process->startDetached(); } } bool FileSessMng::isFileExists(const QString &filePath) { QFile file(filePath); return file.exists(); } ukui-bluetooth/service/leavelock.h0000664000175000017500000000245715167665755016275 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef LEAVELOCK_H #define LEAVELOCK_H #include #include //#include #include #include "CSingleton.h" #include class LeaveLock : public QObject { Q_OBJECT public: explicit LeaveLock(QObject *parent = nullptr); ~LeaveLock(); bool setPing(QString uuid, QString dev, bool on); private: QString m_uid; QString m_lockdev; QProcess * m_process = nullptr; bool m_manualCancel = false; private slots: void readOutput(); void pingFinished(); friend class SingleTon; }; typedef SingleTon LEAVELOCK; #endif // LEAVELOCK_H ukui-bluetooth/service/bluetoothagent.cpp0000664000175000017500000000761415167665755017707 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothagent.h" #include "adapter.h" #include "device.h" BluetoothAgent::BluetoothAgent(QObject *parent) : Agent(parent) { KyInfo(); } QDBusObjectPath BluetoothAgent::objectPath() const { return QDBusObjectPath(QStringLiteral("/org/bluez/agent")); } void BluetoothAgent::requestPinCode(BluezQt::DevicePtr device, const BluezQt::Request &request) { KyInfo(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->requestPinCode(request); } else { request.reject(); } } void BluetoothAgent::displayPinCode(BluezQt::DevicePtr device, const QString &pinCode) { KyInfo(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->displayPinCode(pinCode); } } void BluetoothAgent::requestPasskey(BluezQt::DevicePtr device, const BluezQt::Request &request) { KyInfo(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->requestPasskey(request); } else { request.reject(); } } void BluetoothAgent::displayPasskey(BluezQt::DevicePtr device, const QString &passkey, const QString &entered) { KyInfo(); this->displayPinCode(device, passkey); } void BluetoothAgent::requestConfirmation(BluezQt::DevicePtr device, const QString &passkey, const BluezQt::Request<> &request) { KyInfo() << device->name() << passkey << device->isConnected() << device->isPaired(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->requestConfirmation(passkey, request); } else { request.reject(); } } void BluetoothAgent::requestAuthorization(BluezQt::DevicePtr device, const BluezQt::Request<> &request) { KyInfo() << device->name(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->requestAuthorization(request); } else { request.reject(); } } void BluetoothAgent::authorizeService(BluezQt::DevicePtr device, const QString &uuid, const BluezQt::Request<> &request) { KyInfo() << device->name(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(device && ptr) { d = ptr->getDevPtr(device->address()); } if(d) { d->authorizeService(uuid, request); } else { request.reject(); } } void BluetoothAgent::cancel() { KyInfo(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->clearPinCode(); } } void BluetoothAgent::release() { KyInfo(); } ukui-bluetooth/service/service.pro0000664000175000017500000000460415167665770016332 0ustar fengfeng###################################################################### # Automatically generated by qmake (3.1) Thu Mar 4 18:08:23 2021 ###################################################################### TEMPLATE = app TARGET = bluetoothService INCLUDEPATH += . \ /usr/include/KF6/BluezQt \ /usr/include/x86_64-linux-gnu/qt6 include(../environment.pri) QT += core dbus QT -= gui #greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 \ link_pkgconfig x11extras PKGCONFIG += gio-2.0 \ kysdk-sysinfo #exists(/usr/include/kysdk/kysdk-base/libkydiagnostics.h) #{ # PKGCONFIG += kysdk-diagnostics # DEFINES += EXISTS_KYSDK_DIAGNOSTICS #} LIBS += -lpthread \ -lglib-2.0 \ -lKF6BluezQt \ -lQt6DBus QMAKE_CFLAGS += -fPIC QMAKE_CXXFLAGS += -fPIC target.source += $$TARGET target.path = $$BIN_INSTALL_DIR inst1.files += ../data/org.ukui.log4qt.bluetoothserver.gschema.xml inst1.path = $$SCHEMAS_INSTALL_DIR INSTALLS += target # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. #DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_NO_INFO_OUTPUT #DEFINES += QT_NO_DEBUG_OUTPUT exists(/usr/include/KF6/BluezQt/bluezqt/battery.h){DEFINES += BATTERY} # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += main.cpp \ adapter.cpp \ app.cpp \ bluetoothagent.cpp \ bluetoothobexagent.cpp \ buriedpointdata.cpp \ common.cpp \ config.cpp \ daemon.cpp \ device.cpp \ filesess.cpp \ sessiondbusregister.cpp \ systemadapter.cpp \ leavelock.cpp HEADERS += \ CSingleton.h \ adapter.h \ app.h \ bluetoothagent.h \ bluetoothobexagent.h \ buriedpointdata.h \ common.h \ config.h \ daemon.h \ device.h \ filesess.h \ sessiondbusregister.h \ systemadapter.h \ leavelock.h OBJECTS_DIR = ./obj/ MOC_DIR = ./moc/ #CONFIG+=force_debug_info ukui-bluetooth/service/systemadapter.cpp0000664000175000017500000002671015167665770017543 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "systemadapter.h" #include "sessiondbusregister.h" #include "adapter.h" #include "device.h" #include "config.h" #include "app.h" #include "filesess.h" #include "common.h" #include "buriedpointdata.h" #include "leavelock.h" SystemAdapter::SystemAdapter(QObject *parent): QObject(parent) { KyDebug(); } SystemAdapter::~SystemAdapter() { KyDebug(); } QMap SystemAdapter::registerClient(QMap params) { QString dbusid = this->getCallerDebus(); KyInfo() << params << " dbusid: "<< dbusid; QMap res; res["result"] = SYSDBUSMNG::getInstance()->registerClient(params, dbusid); res["envPC"] = envPC; return res; } bool SystemAdapter::unregisterClient(QString id) { KyInfo() << id << " dbusid: "<getCallerDebus(); return SYSDBUSMNG::getInstance()->unregisterClient(id); } QStringList SystemAdapter::getRegisterClient() { KyInfo() << " dbusid: "<getCallerDebus(); return APPMNG::getInstance()->getRegisterClient(); } QStringList SystemAdapter::getAllAdapterAddress() { KyDebug() << " dbusid: "<getCallerDebus(); return ADAPTERMNG::getInstance()->getAllAdapterAddress(); } QMap SystemAdapter::getAdapterAttr(QString addr, QString key) { KyDebug() << " dbusid: "<getCallerDebus(); return ADAPTERMNG::getInstance()->getAdapterAttr(addr.toUpper(), key); } QStringList SystemAdapter::getDefaultAdapterAllDev() { KyDebug() << " dbusid: "<getCallerDebus(); return ADAPTERMNG::getInstance()->getDefaultAdapterAllDev(); } QStringList SystemAdapter::getDefaultAdapterPairedDev() { KyDebug() << " dbusid: "<getCallerDebus(); QStringList tmp1 = ADAPTERMNG::getInstance()->getDefaultAdapterPairedDev(); QStringList tmp2 = m_sortPairedDeviceList; QStringList tmp3 = tmp1; tmp3.sort(); tmp2.sort(); if(tmp3 == tmp2) { return m_sortPairedDeviceList; } return tmp1; } QMap SystemAdapter::getDevAttr(QString addr) { addr = addr.toUpper(); KyDebug() << addr << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(ptr) { d = ptr->getDevPtr(addr); } if(d) { return d->getDevAttr(); } return QMap(); } bool SystemAdapter::setDevAttr(QString dev, QMap attrs) { dev = dev.toUpper(); KyInfo() << dev << attrs << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(ptr) { d = ptr->getDevPtr(dev); } if(d) { d->setDevAttr(attrs); } return true; } bool SystemAdapter::setDefaultAdapterAttr(QMap attrs) { KyInfo() << attrs << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { QString key; key = AdapterAttr(enum_Adapter_attr_Powered); if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { bool v = attrs[key].toBool(); CONFIG::getInstance()->power_switch(v); ptr->setPower(v); } key = AdapterAttr(enum_Adapter_attr_Discoverable); if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { bool v = attrs[key].toBool(); CONFIG::getInstance()->discoverable_switch(v); ptr->setDiscoverable(v); } key = AdapterAttr(enum_Adapter_attr_Name); if(attrs.contains(key) && attrs[key].type() == QVariant::String) { QString v = attrs[key].toString(); ptr->setName(v); } key = AdapterAttr(enum_Adapter_attr_ActiveConnection); if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { bool v = attrs[key].toBool(); CONFIG::getInstance()->activeconnection(v); ptr->setActiveConnection(v); } key = AdapterAttr(enum_Adapter_attr_TrayShow); if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { bool v = attrs[key].toBool(); CONFIG::getInstance()->trayShow(v); ptr->trayShow(v); } key = AdapterAttr(enum_Adapter_attr_AudioCombine); if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { bool v = attrs[key].toBool(); CONFIG::getInstance()->AudioCombine(v); ptr->audioCombine(v); } return true; } return false; } int SystemAdapter::setDefaultAdapter(QString addr) { qInfo() << Q_FUNC_INFO << addr << " dbusid: "<getCallerDebus(); return ADAPTERMNG::getInstance()->setDefaultAdapter(addr); } int SystemAdapter::devConnect(QString addr) { addr = addr.toUpper(); KyInfo() << addr << " dbusid: "<getCallerDebus(); int ret = ERR_BREDR_INTERNAL_NO_Default_Adapter; KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ret = ptr->devConnect(addr); if(ERR_BREDR_CONN_SUC == ret && ptr->devIsAudioType(addr)) { CONFIG::getInstance()->finally_audiodevice(addr); } } return ret; } int SystemAdapter::devDisconnect(QString addr) { addr = addr.toUpper(); KyInfo() << addr << " dbusid: "<getCallerDebus(); int ret = ERR_BREDR_INTERNAL_NO_Default_Adapter; KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ret = ptr->devDisconnect(addr); CONFIG::getInstance()->remove_finally_audiodevice(addr); } return ret; } int SystemAdapter::devRemove(QStringList devlist) { KyDebug() << devlist << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->devRemove(devlist); for(auto iter : devlist) { CONFIG::getInstance()->delete_rename(iter.toUpper()); } } return 0; } int SystemAdapter::activeConnectionReply(QString addr, bool v) { addr = addr.toUpper(); KyInfo() << addr << v << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->activeConnectionReply(addr, v); } return 0; } int SystemAdapter::pairFuncReply(QString addr, bool v) { addr = addr.toUpper(); KyInfo() << addr << v << " dbusid: "<getCallerDebus(); KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); KylinDevicePtr d = nullptr; if(ptr) { d = ptr->getDevPtr(addr); } if(d) { return d->pairFuncReply(v); } return -1; } int SystemAdapter::sendFiles(QString user, QString addr, QStringList files) { addr = addr.toUpper(); KyInfo() << addr << files << " dbusid: "<getCallerDebus(); if(HUAWEI == envPC) { KyInfo() << "not support"; return -1; } return FILESESSMNG::getInstance()->sendFiles(addr, files); } int SystemAdapter::stopFiles(QMap params) { KyInfo() << params << " dbusid: "<getCallerDebus(); if(HUAWEI == envPC) { KyInfo() << "not support"; return -1; } QString addr; int transportType = enum_filetransport_Type_other; QString key; key = "dev"; if(params.contains(key) && params[key].type() == QVariant::String) { addr = params[key].toString(); addr = addr.toUpper(); } key = "transportType"; if(params.contains(key) && (params[key].type() == QVariant::Int || params[key].type() == QVariant::UInt)) { transportType = params[key].toInt(); } if(addr.isEmpty() || enum_filetransport_Type_other == transportType) { qWarning() << Q_FUNC_INFO << "error"; return -1; } return FILESESSMNG::getInstance()->stopFiles(addr, transportType); } int SystemAdapter::replyFileReceiving(QMap params) { KyInfo() << params << " dbusid: "<getCallerDebus(); if(HUAWEI == envPC) { KyInfo() << "not support"; return -1; } QString addr; bool v = false; QString savePathdir; QString user; QString key; key = "dev"; if(params.contains(key) && params[key].type() == QVariant::String) { addr = params[key].toString(); addr = addr.toUpper(); } key = "receive"; if(params.contains(key) && params[key].type() == QVariant::Bool) { v = params[key].toBool(); } key = "savePathdir"; if(params.contains(key) && params[key].type() == QVariant::String) { savePathdir = params[key].toString(); } key = "user"; if(params.contains(key) && params[key].type() == QVariant::String) { user = params[key].toString(); } if(addr.isEmpty()) { KyWarning() << "addr error"; return -1; } return FILESESSMNG::getInstance()->replyFileReceiving(addr, v, savePathdir); } void SystemAdapter::writeBuriedPointData(QString pluginName, QString settingsName, QString action, QString value) { KyDebug() << pluginName << settingsName << action << value << " dbusid: "<getCallerDebus(); emit BPDMNG::getInstance()->writeInData(pluginName, settingsName, action, value); } QString SystemAdapter::bluetoothKeyValue(unsigned int key, QString str) { KyDebug() << key << str << " dbusid: "<getCallerDebus(); return SYSDBUSMNG::getInstance()->bluetoothKeyValue(key, str); } void SystemAdapter::setLogLevel(int level) { KyInfo() << level; CONFIG::getInstance()->loglevel(level); } QString SystemAdapter::GetActiveUser() { KyDebug() << " dbusid: "<getCallerDebus(); return CONFIG::getInstance()->active_user(); } void SystemAdapter::updatePairedDeviceSort(QStringList listdev) { m_sortPairedDeviceList = listdev; } bool SystemAdapter::getLeaveLockPower() { KyInfo(); return CONFIG::getInstance()->leaveLock(); } void SystemAdapter::setLeaveLockPower(bool v) { KyInfo() << v; CONFIG::getInstance()->leaveLock(v); } QString SystemAdapter::getCallerDebus() { QDBusConnection conn = connection(); QDBusMessage msg = message(); QString dbusid = conn.interface()->serviceOwner(msg.service()).value(); if(APPMNG::getInstance()->existDbusid(dbusid)) { return dbusid; } int uid = conn.interface()->serviceUid(msg.service()).value(); int64_t pid = conn.interface()->servicePid(msg.service()).value(); KyDebug() << "unknown dbusid: "<< dbusid << " uid: "<< uid << " pid: " << pid; return dbusid; } bool SystemAdapter::setLeaveLock(QString uuid, QString dev, bool on) { return LEAVELOCK::getInstance()->setPing(uuid, dev, on); } ukui-bluetooth/service/app.cpp0000664000175000017500000000647215167665755015444 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "app.h" #include #include "adapter.h" #include "common.h" #include "config.h" Application::Application(QString dbusid, QString username, int type) { m_dbusid = dbusid; m_username = username; m_type = type; KyInfo() << "dbusid: " << m_dbusid <<", username: " << m_username << ", type: " << m_type; } Application::~Application() { KyInfo() << "dbusid: " << m_dbusid; } ApplicationMng::ApplicationMng() { m_watch = new QDBusServiceWatcher("",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForUnregistration, nullptr); connect(m_watch, &QDBusServiceWatcher::serviceUnregistered, this, &ApplicationMng::serviceUnregistered); } ApplicationMng::~ApplicationMng() { m_watch->disconnect(this); m_watch->deleteLater(); } int ApplicationMng::add(QString dbusid, QString username, int type) { KyInfo() << dbusid << username << type; if(m_apps.contains(dbusid)) { return 0; } else { Application * mem = new Application(dbusid, username, type); m_apps[dbusid] = mem; m_watch->addWatchedService(dbusid); } this->update(); return 1; } int ApplicationMng::remove(QString dbusid) { KyInfo() << dbusid; if(m_apps.contains(dbusid)) { delete m_apps[dbusid]; m_apps.remove(dbusid); this->update(); } return 1; } int ApplicationMng::getControlNum() { int num = 0; for(auto item : m_apps.toStdMap()) { //控制面板 if(item.second->type() == enum_app_type_bluetooth_controlPanel) { //仅计算活跃用户的控制面板数量 if(item.second->username() == CONFIG::getInstance()->active_user()) { num++; } } } return num; } bool ApplicationMng::existDbusid(QString id) { return m_apps.contains(id); } QStringList ApplicationMng::getRegisterClient() { QStringList apps; for(auto item : m_apps.toStdMap()) { apps.append(item.first); } return apps; } QString ApplicationMng::getUserDbusid(QString user, int type) { for(auto item : m_apps.toStdMap()) { //控制面板 if(item.second->type() == type && item.second->username() == user) { return item.second->dbusid(); } } return ""; } void ApplicationMng::update() { KylinAdapterPtr ptr = ADAPTERMNG::getInstance()->getDefaultAdapter(); if(ptr) { ptr->updateDiscovering(); } } void ApplicationMng::serviceUnregistered(const QString &service) { KyInfo() << service; this->remove(service); } ukui-bluetooth/service/buriedpointdata.cpp0000664000175000017500000000447715167665755020045 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "buriedpointdata.h" BuriedPointData::BuriedPointData(QObject *parent) :QObject(parent) { KyInfo(); m_Thread = new QThread(this); moveToThread(m_Thread); connect(this,&BuriedPointData::writeInData,this,&BuriedPointData::writeInDataSlot); m_Thread->start(); } bool BuriedPointData::buriedSettings(QString pluginName, QString settingsName, QString action, QString value) { KyInfo(); //QThread::sleep(5); #ifdef EXISTS_KYSDK_DIAGNOSTICS // 埋点数据 char appName[] = "ukui-bluetooth"; QString message; if (settingsName != nullptr) { message = pluginName + "/" + settingsName; } else { message = pluginName; } QByteArray ba = message.toLatin1(); char *messageType = ba.data(); KBuriedPoint pt[2]; pt[0].key = "action"; std::string str = action.toStdString(); pt[0].value = str.c_str(); pt[1].key = "value"; std::string valueStr = value.toStdString(); pt[1].value = valueStr.c_str(); //异常捕获,kdk_buried_point异常通过C++标准库中抛出,使用Qt的QException无法捕获 try { if (0 != kdk_buried_point(appName , messageType , pt , 2)) { return false; } } catch(std::exception &e) { KyWarning() << e.what(); return false; } #endif return true; } void BuriedPointData::writeInDataSlot(QString pluginName, QString settingsName, QString action, QString value) { KyDebug() << settingsName << action; if(buriedSettings(pluginName,settingsName,action,value)) KyDebug() << "write data successful"; else KyDebug() << "write data fail" ; } ukui-bluetooth/service/common.cpp0000664000175000017500000001511715167665770016145 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "common.h" QStringList list_errmsg = { "", "br-connection-already-connected", //1 "br-connection-page-timeout", "br-connection-profile-unavailable", "br-connection-sdp-search", "br-connection-create-socket", "br-connection-invalid-argument", "br-connection-adapter-not-powered", "br-connection-not-suuported", "br-connection-bad-socket", "br-connection-memory-allocation", "br-connection-busy", "br-connection-concurrent-connection-limit", "br-connection-timeout", "br-connection-refused", "br-connection-aborted-by-remote", "br-connection-aborted-by-local", "br-connection-lmp-protocol-error", "br-connection-canceled", "br-connection-unknown", ///////////////////////////////// "le-connection-invalid-arguments", //20 "le-connection-adapter-not-powered", "le-connection-not-supported", "le-connection-already-connected", "le-connection-bad-socket", "le-connection-memory-allocation", "le-connection-busy", "le-connection-refused", "le-connection-create-socket", "le-connection-timeout", "le-connection-concurrent-connection-limit", "le-connection-abort-by-remote", "le-connection-abort-by-local", "le-connection-link-layer-protocol-error", "le-connection-gatt-browsing", "le-connection-unknown", //////////////////////////////////////////// "Invalid arguments in method call", //36 "Operation already in progress", "Already Exists", "Operation is not supported", "Already Connected", "Operation currently not available", "Does Not Exist", "Not Connected", "In Progress", "Operation Not Authorized", "No such adapter", "Agent Not Available", "Resource Not Ready", //////////////////////////////////////////////// "Did not receive a reply. Possible causes include: "\ "the remote application did not send a reply, "\ "the message bus security policy blocked the reply, "\ "the reply timeout expired, or the network connection was broken.", /************上面错误码为bluez返回错误码****************/ "ERR_BREDR_INTERNAL_NO_Default_Adapter", "ERR_BREDR_INTERNAL_Operation_Progress", "ERR_BREDR_INTERNAL_Already_Connected", "ERR_BREDR_INTERNAL_Dev_Not_Exist", "ERR_BREDR_INTERNAL_Audio_Maxnum", "ERR_BREDR_UNKNOWN_Other", ///////////////////////////////////////////////// }; QStringList Adapter_attr { "Pairing", "Connecting", "Powered", "Discoverable", "Pairable", "Discovering", "Name", "Block", "Addr", "ActiveConnection", "DefaultAdapter", "trayShow", "FileTransportSupport", "ClearPinCode", "AudioConnectedNum", "AudioCombine", }; QStringList Device_attr { "Paired", "Trusted", "Blocked", "Connected", "Name", "Type", "TypeName", "Pairing", "Connecting", "Battery", "ConnectFailedId", "ConnectFailedDisc", "Rssi", "Addr", "FileTransportSupport", "ShowName", "Adapter", }; QStringList app_attr { "dbusid", "username", "type", "pid", }; QStringList startpair_attr { "dev", "name", "pincode", "type", }; QStringList filestatus_attr { "status", "progress", "filename", "allfilenum", "fileseq", "dev", "fileFailedDisc", "filetype", "transportType", "savepath", "filesize", }; QStringList receivefile_attr { "dev", "name", "filetype", "filename", "filesize", }; bool support_a2dp_sink(const QStringList & uuids) { if(-1 != uuids.indexOf(A2DP_SINK_UUID) || -1 != uuids.indexOf(QString(A2DP_SINK_UUID).toUpper())) { return true; } return false; } bool support_a2dp_source(const QStringList & uuids) { if(-1 != uuids.indexOf(A2DP_SOURCE_UUID) || -1 != uuids.indexOf(QString(A2DP_SOURCE_UUID).toUpper())) { return true; } return false; } bool support_hfphsp_ag(const QStringList & uuids) { if(-1 != uuids.indexOf(HFP_AG_UUID) || -1 != uuids.indexOf(QString(HFP_AG_UUID).toUpper()) || -1 != uuids.indexOf(HSP_AG_UUID) || -1 != uuids.indexOf(QString(HSP_AG_UUID).toUpper())) { return true; } return false; } bool support_hfphsp_hf(const QStringList & uuids) { if(-1 != uuids.indexOf(HFP_HS_UUID) || -1 != uuids.indexOf(QString(HFP_HS_UUID).toUpper()) || -1 != uuids.indexOf(HSP_HS_UUID) || -1 != uuids.indexOf(QString(HSP_HS_UUID).toUpper())) { return true; } return false; } static QStringList static_filetransport_uuids { //OBEX_SYNC_UUID, OBEX_OPP_UUID, OBEX_FTP_UUID, /* OBEX_PCE_UUID, OBEX_PSE_UUID, OBEX_PBAP_UUID, OBEX_MAS_UUID, OBEX_MNS_UUID, OBEX_MAP_UUID, */ }; bool support_filetransport(const QStringList & uuids) { for(auto key : static_filetransport_uuids) { if(-1 != uuids.indexOf(key) || -1 != uuids.indexOf(key.toUpper())) { return true; } } return false; } void set_logLevel(const QString &level) { QString rules; if (level == "debug") { rules = "*.debug=true\n*.info=true"; } else if (level == "info") { rules = "*.debug=false\n*.info=true"; } else if (level == "warning") { rules = "*.debug=false\n*.info=false\n*.warning=true"; } if (rules.length() > 0) { QLoggingCategory::setFilterRules(rules); } } void set_logLevel(int level) { QString rules; if (0 == level) { rules = "*.debug=true\n*.info=true"; } else if (1 == level) { rules = "*.debug=false\n*.info=true"; } else if (2 == level) { rules = "*.debug=false\n*.info=false\n*.warning=true"; } if (rules.length() > 0) { QLoggingCategory::setFilterRules(rules); } } QString get_logFormat(QString file, QString function, int fileline) { return QString("%1::%2:%3 ").arg(file.section('/', -1)).arg(function).arg(fileline); } ukui-bluetooth/service/adapter.h0000664000175000017500000001234215167665770015737 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef ADAPTER_H #define ADAPTER_H #include #include #include #include #include #include #include #include #include #include "CSingleton.h" #include "common.h" class KylinDevice; typedef QSharedPointer KylinDevicePtr; class KylinAdapter : public QObject { Q_OBJECT public: explicit KylinAdapter(BluezQt::AdapterPtr adapter); ~KylinAdapter(); int start(void); int stop(void); int bluetooth_block(void); void set_need_reconnect(bool v){ m_need_reconnect = v; } int reconnect_dev(void); public: QStringList getAllDev(void); QStringList getPairedDev(void); QString addr(void) { return m_adapter->address(); } bool setDiscoverable(bool); bool setPower(bool); bool setActiveConnection(bool); bool setName(QString); bool trayShow(bool); void audioCombine(bool); QMap getAdapterAttr(QString); KylinDevicePtr getDevPtr(QString); bool devIsAudioType(QString); /* **** type 连接模式 * 0 : 主动连接 * 1 :回连 */ int devConnect(QString addr, int type = 0); int devDisconnect(QString); int devRemove(QStringList); int updateDiscovering(void); int devDisconnectAll(void); QStringList connected_audio_device(void){ return m_connected_audio_device_list; } void connected_audio_device(QString v); void disconnected_audio_device(QString v); int activeConnectionReply(QString, bool); void clearPinCode(void); protected slots: void nameChanged(const QString &name); void poweredChanged(bool powered); void discoverableChanged(bool discoverable); void discoveringChanged(bool discovering); void deviceAdded(BluezQt::DevicePtr device); void deviceRemoved(BluezQt::DevicePtr device); void uuidsChanged(const QStringList &uuids); protected: int add(BluezQt::DevicePtr adapter); int remove(BluezQt::DevicePtr adapter); bool deal_active_connection(QString, int); bool __setDiscoverable(); bool __setPower(); bool __setActiveConnection(); bool __setDiscovering(); void __sendAttr(enum_send_type stype = enum_send_type_delay); void __sendAdd(); void __reconnectFunc(); void __clear_timers(); int __devRemove(QString); virtual void timerEvent( QTimerEvent *event); void wait_for_finish(BluezQt::PendingCall *call); void __init_uuid(); void __init_devattr(QMap &); protected: //正在使用的蓝牙适配器标志,仅有一个 bool m_is_start = false; BluezQt::AdapterPtr m_adapter = nullptr; QMap m_devices; bool m_connectProgress = false; bool m_need_reconnect = true; bool m_reconnectProgress = false; bool m_powerProgress = false; bool m_set_power = false; bool m_set_discoverable = false; bool m_set_Discovering = false; bool m_set_activeConnection = false; QStringList m_connected_audio_device_list; QMap m_attr_send; int m_set_TimerID = 0; int m_autoclean_TimerID = 0; int m_attrsignal_TimerID= 0; int m_activeConnection_TimerID = 0; int m_reconnect_TimerId = 0; QString m_active_dev; QSet m_black_activeconn_dev; QStringList m_uuids; bool m_support_ad2p_sink = false; bool m_support_a2dp_source = false; bool m_support_hfphsp_ag = false; bool m_support_hfphsp_hf = false; bool m_support_filetransport = false; bool m_cleanProgress = false; friend class KylinDevice; }; typedef QSharedPointer KylinAdapterPtr; class AdapterMng : public QObject { Q_OBJECT public: AdapterMng(); ~AdapterMng(); int add(BluezQt::AdapterPtr adapter); int remove(BluezQt::AdapterPtr adapter); QStringList getAllAdapterAddress(void); QStringList getDefaultAdapterAllDev(void); QStringList getDefaultAdapterPairedDev(void); int setDefaultAdapter(QString); QMap getAdapterAttr(QString, QString); KylinAdapterPtr getDefaultAdapter(void){ return m_default_adapter; } void bluetooth_block(bool); bool isDefaultAdapter(QString); protected: int update_adapter(void); protected: KylinAdapterPtr m_default_adapter = nullptr; QMap m_adapters; bool m_bluetooth_block = false; friend class SingleTon; }; typedef SingleTon ADAPTERMNG; #endif // ADAPTER_H ukui-bluetooth/service/leavelock.cpp0000664000175000017500000000465515167665755016632 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "leavelock.h" #include "sessiondbusregister.h" LeaveLock::LeaveLock(QObject *parent) : QObject(parent) { } LeaveLock::~LeaveLock() { if(m_process) { m_process->deleteLater(); m_process = nullptr; } } bool LeaveLock::setPing(QString uuid, QString dev, bool on) { if (dev == "" || !on) { if(m_process) { m_process->disconnect(this); m_process->deleteLater(); m_process = nullptr; } m_manualCancel = true; return true; } m_process = new QProcess(); connect(m_process, &QProcess::readyReadStandardOutput, this, &LeaveLock::readOutput); connect(m_process, &QProcess::readChannelFinished, this, &LeaveLock::pingFinished); m_manualCancel = false; m_uid = uuid; m_lockdev = dev; KyDebug() << m_lockdev; QString cmd = "l2ping " + m_lockdev; m_process->start(cmd); return true; } void LeaveLock::readOutput() { Q_EMIT SYSDBUSMNG::getInstance()->pingTimeSignal(m_process->readAllStandardOutput()); } void LeaveLock::pingFinished() { if(m_process) { QByteArray errorMsg = m_process->readAllStandardError(); QByteArray output = m_process->readAllStandardOutput(); KyDebug() << output << errorMsg; if (!output.isEmpty()) { Q_EMIT SYSDBUSMNG::getInstance()->pingTimeSignal(output); } if (!errorMsg.isEmpty()) { Q_EMIT SYSDBUSMNG::getInstance()->pingTimeSignal(errorMsg); return; } if (m_manualCancel) Q_EMIT SYSDBUSMNG::getInstance()->pingTimeSignal(QString("ping out").toLatin1()); else Q_EMIT SYSDBUSMNG::getInstance()->pingTimeSignal(QString("loss connect").toLatin1()); } m_manualCancel = false; } ukui-bluetooth/README.md0000664000175000017500000000206515167665755013771 0ustar fengfeng# UKUI-Bluetooth ## Simple bluetooth tool for ukui desktop environment ### 依赖 - KF5 - libkf5bluezqt6 - libkf5bluezqt-dev - libkf5windowsystem-dev - libqt5x11extras5-dev - libgsettings-qt-dev - libkf5bluezqt-data - libglib2.0-dev, - libxrandr-dev, - libxinerama-dev, - libxi-dev, - libxcursor-dev, - libukui-log4qt-dev - bluez - bluez-obexd ### 编译 ------ ```shell $ cd ukui-bluetooth $ mkdir build $ cd build $ qmake .. $ make ``` ### 安装 ------ ```shell $ sudo make install ``` ### 主体框架 - **InProgress** - [x] 界面绘制 - [x] 功能实现 - [x] 基础DBus接口提供 - **TROUBLE** - 无 - **TODO** - 无 ### 功能插件 ##### 蓝牙服务bluetoothService - **InProgress** - [x] 功能实现 - [x] 基础DBus接口提供 - **TODO** - 无 ##### 任务栏蓝牙ukui-bluetooth - **InProgress** - [x] 界面绘制 - [x] 功能实现 - **TODO** - 无 ##### 控制面板蓝牙ukcc-bluetooth - **InProgress** - [x] 界面绘制 - [x] 功能实现 - **TODO** - 无 ukui-bluetooth/man/0000775000175000017500000000000015167665770013257 5ustar fengfengukui-bluetooth/man/bluetoothService.10000664000175000017500000000122215167665770016664 0ustar fengfeng.\" Man Page for bluetoothService .TH BluetoothService 1 "August 05, 2020" .SH "NAME" bluetoothService \- command line binary for bluetoothService .SH "SYNOPSIS" .B bluetoothService .SH "DESCRIPTION" .B bluetoothService Manual for UKUI desktop environment A lightweight Bluetooth Service based on libkf5bluezqt6 .TP \fB --user\fR The user to be anthenticated. .TP \fB --device\fR The device for authentication. .SH "BUGS" .SS Should you encounter any bugs, they may be reported at: http://github.com/ukui/ukui-bluetooth/issues .SH "AUTHORS" .SS This Manual Page has been written for the UKUI Desktop Environment by tangguang (2020) ukui-bluetooth/man/ukui-bluetooth.10000664000175000017500000000120615167665770016320 0ustar fengfeng.\" Man Page for ukui-bluetooth .TH ukui-bluetooth 1 "August 05, 2020" .SH "NAME" bluetoothService \- command line binary for bluetoothService .SH "SYNOPSIS" .B ukui-bluetooth .SH "DESCRIPTION" .B ukui-bluetooth Manual for UKUI desktop environment A lightweight Bluetooth tool based on libkf5bluezqt6 .TP \fB --user\fR The user to be anthenticated. .TP \fB --device\fR The device for authentication. .SH "BUGS" .SS Should you encounter any bugs, they may be reported at: http://github.com/ukui/ukui-bluetooth/issues .SH "AUTHORS" .SS This Manual Page has been written for the UKUI Desktop Environment by tangguang (2020) ukui-bluetooth/COPYING0000664000175000017500000010451515167665770013545 0ustar fengfeng GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ukui-bluetooth/ukui-bluetooth.pro0000664000175000017500000000201715167665770016206 0ustar fengfeng###################################################################### # Automatically generated by qmake (3.1) Thu Mar 4 22:02:53 2021 ###################################################################### TEMPLATE = subdirs INCLUDEPATH += . SUBDIRS += ukui-bluetooth \ ukui-shortcut-bluetooth \ ukcc-bluetooth \ service # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #TRANSLATIONS += translations/ukui-bluetooth_zh_CN.ts ukui-bluetooth/ukcc-bluetooth/0000775000175000017500000000000015167665770015434 5ustar fengfengukui-bluetooth/ukcc-bluetooth/bluetoothdbusservice.cpp0000664000175000017500000016743215167665770022421 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothdbusservice.h" QDBusInterface BlueToothDBusService::interface(DBUSSERVICE,DBUSPATH,DBUSINTERFACE); bool BlueToothDBusService::m_taskbar_show_mark = true; QStringList BlueToothDBusService::m_bluetooth_adapter_name_list ; QStringList BlueToothDBusService::m_bluetooth_adapter_address_list ; bluetoothadapter * BlueToothDBusService::m_default_bluetooth_adapter = nullptr; QStringList BlueToothDBusService::m_bluetooth_Paired_Device_address_list; QStringList BlueToothDBusService::m_bluetooth_All_Device_address_list; QMap BlueToothDBusService::defaultAdapterDataAttr; QMap BlueToothDBusService::deviceDataAttr; BlueToothDBusService::BlueToothDBusService(QObject *parent):QObject(parent) { KyDebug(); defaultAdapterDataAttr.clear(); deviceDataAttr.clear(); m_loading_dev_timer = new QTimer(this); m_loading_dev_timer->setInterval(1000); connect(m_loading_dev_timer,SIGNAL(timeout()),this,SLOT(devLoadingTimeoutSlot())); bindServiceReportData(); } BlueToothDBusService::~BlueToothDBusService() { //向蓝牙注销 unregisterClient(); if(m_loading_dev_timer) m_loading_dev_timer->deleteLater(); } int BlueToothDBusService::checkAddrList(QStringList &addrList) { KyDebug() << addrList; if(addrList.size() <= 0) return 1;//没有适配器 for (QString var : addrList) { if (6 == var.split(":").size()) return 0; } return 2;//没有效的适配器地址 } int BlueToothDBusService::initBluetoothServer() { KyDebug(); //注册 QMap value; value["dbusid"] = QDBusConnection::systemBus().baseService(); //value["username"] = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); value["username"] = QString(qgetenv("USER").toStdString().data()); value["type"] = int(0); KyWarning() << QString(qgetenv("USER").toStdString().data()); QMap reg_flag = registerClient(value); KyWarning() << reg_flag; if (!reg_flag.contains("result") && !reg_flag["result"].toBool()) {//注册失败 KyWarning() << "registerClient failed!" ; return 1; } if (reg_flag.contains("envPC")) { envPC = Environment(reg_flag["envPC"].toInt()); } else ukccbluetoothconfig::setEnvPCValue(); KyDebug(); //获取适配器列表 m_bluetooth_adapter_list.clear(); m_bluetooth_adapter_name_list.clear(); m_bluetooth_adapter_address_list.clear(); m_bluetooth_adapter_address_list = getAllAdapterAddress(); KyInfo() << m_bluetooth_adapter_address_list ; //int res = checkAddrList(m_bluetooth_adapter_address_list); if (m_bluetooth_adapter_address_list.isEmpty()) { KyWarning() << "bluetooth adapter isEmpty" ; return 2; } //获取所有适配器数据 for (auto var : m_bluetooth_adapter_address_list) getAdapterAllData(var); KyDebug() << "m_bluetooth_adapter_name_list:" << m_bluetooth_adapter_name_list << "m_bluetooth_adapter_address_list:" << m_bluetooth_adapter_address_list << "m_bluetooth_adapter_list:" << m_bluetooth_adapter_list ; return 0;//初始化正常返回0 } QMap BlueToothDBusService::registerClient(void) { KyDebug(); //注册 QMap value; value["dbusid"] = QDBusConnection::systemBus().baseService(); //value["username"] = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); value["username"] = QString(qgetenv("USER").toStdString().data()); value["type"] = int(0); QMap reg_flag = registerClient(value); return reg_flag; } QMap BlueToothDBusService::registerClient(QMap value) { KyDebug() << value ; QDBusReply> reply_res; QDBusInterface iface(SERVICE, PATH, INTERFACE, QDBusConnection::systemBus()); QDBusPendingCall pcall = iface.asyncCall("registerClient", value); pcall.waitForFinished(); QDBusMessage res = pcall.reply(); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res; KyInfo() << reply_res.value(); } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res.value(); } bool BlueToothDBusService::unregisterClient() { KyInfo(); QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "unregisterClient"); message << QDBusConnection::systemBus().baseService(); QDBusReply reply_res = QDBusConnection::systemBus().call(message); return reply_res; } void BlueToothDBusService::reportUpdateClient() { KyInfo(); Q_EMIT btServiceRestart(); int res = initBluetoothServer(); if (0 == res) Q_EMIT btServiceRestartComplete(true); else Q_EMIT btServiceRestartComplete(false); } QStringList BlueToothDBusService::getAllAdapterAddress() { KyDebug(); QStringList reply_res; QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getAllAdapterAddress"); QDBusMessage res = QDBusConnection::systemBus().call(message, QDBus::Block, 500); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res.arguments().takeFirst().toStringList(); KyInfo() << reply_res; } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res; } void BlueToothDBusService::getDefaultAdapterDevices() { KyDebug(); if (nullptr == m_default_bluetooth_adapter) { KyDebug() << "m_default_bluetooth_adapter is nullptr!" ; return; } m_default_bluetooth_adapter->m_bt_dev_list.clear(); // m_default_bluetooth_adapter->m_bt_dev_paired_list.clear(); //读取默认适配器下配对和扫描出的设备 m_bluetooth_Paired_Device_address_list.clear(); m_bluetooth_Paired_Device_address_list = getDefaultAdapterPairedDev(); KyDebug () << m_bluetooth_Paired_Device_address_list; for (QString dev_addr : m_bluetooth_Paired_Device_address_list) { bluetoothdevice * dev = createOneBleutoothDeviceForAddress(dev_addr); if (dev != nullptr) { KyDebug () << "==========" << dev_addr << "ok"; m_default_bluetooth_adapter->m_bt_dev_list.insert(dev_addr,dev); // m_default_bluetooth_adapter->m_bt_dev_paired_list[dev_addr] = dev; KyDebug () << m_default_bluetooth_adapter->m_bt_dev_list; } } int dev_add_count = 0; m_remainder_loaded_bluetooth_device_address_list.clear(); m_bluetooth_All_Device_address_list.clear(); m_bluetooth_All_Device_address_list = getDefaultAdapterAllDev(); for (QString dev_addr : m_bluetooth_All_Device_address_list) { dev_add_count++; KyInfo() << "add an device (mac):" << dev_addr << "is count device: " << dev_add_count ; // if (dev_add_count > 100) // {//首次启动时,设备数量超过100个的情况下,多余的设备以定时加入的方式 // m_remainder_loaded_bluetooth_device_address_list.append(dev_addr); // } // else // { bluetoothdevice * dev = createOneBleutoothDeviceForAddress(dev_addr); if (dev != nullptr && !dev->isPaired()) { m_default_bluetooth_adapter->m_bt_dev_list.insert(dev->getDevAddress(),dev); } // } } KyInfo() << "####" << m_remainder_loaded_bluetooth_device_address_list; // if (m_remainder_loaded_bluetooth_device_address_list.size() > 0) // { // if (m_loading_dev_timer->isActive()) // m_loading_dev_timer->stop(); // m_loading_dev_timer->start(); // KyInfo() << "start m_loading_dev_timer!" << m_remainder_loaded_bluetooth_device_address_list; // } KyDebug() << "end"; } int BlueToothDBusService::getAdapterAllData(QString address) { KyDebug() << address; QString dev_name, dev_address; bool dev_block , dev_power, dev_pairing , dev_pairable , dev_connecting , dev_discovering , dev_discoverable, dev_activeConnection, dev_defaultAdapterMark, dev_trayShow; QMap adpater_data = getAdapterAttr(address,""); KyInfo()<< " ===================== " << adpater_data; bluetoothAdapterDataAnalysis(adpater_data, dev_name, dev_address, dev_block , dev_power, dev_pairing , dev_pairable , dev_connecting , dev_discovering , dev_discoverable, dev_activeConnection, dev_defaultAdapterMark, dev_trayShow); bluetoothadapter *bt_adapter = new bluetoothadapter(adpater_data); if(bt_adapter != nullptr) { m_bluetooth_adapter_list.append(bt_adapter); m_bluetooth_adapter_name_list.append(dev_name); KyInfo() << "dev_defaultAdapterMark:" << dev_defaultAdapterMark << "m_bluetooth_adapter_list:" << m_bluetooth_adapter_list << "m_bluetooth_adapter_name_list: " << m_bluetooth_adapter_name_list << "m_bluetooth_adapter_address_list: " << m_bluetooth_adapter_address_list ; if(dev_defaultAdapterMark)//是默认适配器,读取设备列表 { m_default_bluetooth_adapter = bt_adapter; bindDefaultAdapterReportData(); getDefaultAdapterDevices(); } return 0; } KyInfo() << address << ":data read fail! "; return 1; } QMap BlueToothDBusService::getAdapterAttr(QString adapterAddr , QString datakey) { QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getAdapterAttr"); message << adapterAddr << datakey; QDBusReply> reply_res = QDBusConnection::systemBus().call(message); return reply_res; } QStringList BlueToothDBusService::getDefaultAdapterPairedDev() { QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getDefaultAdapterPairedDev"); QDBusReply reply_res = QDBusConnection::systemBus().call(message); return reply_res; } QStringList BlueToothDBusService::getDefaultAdapterAllDev() { QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getDefaultAdapterAllDev"); QDBusReply reply_res = QDBusConnection::systemBus().call(message); return reply_res; } void BlueToothDBusService::bluetoothDeviceDataAnalysis(QMap value, QString &dev_address , QString &dev_name , QString &dev_showName , bluetoothdevice::BLUETOOTH_DEVICE_TYPE &dev_type , bool &dev_paired , bool &dev_trusted , bool &dev_blocked , bool &dev_connected , bool &dev_pairing , bool &dev_connecting , int &dev_battery , int &dev_connectFailedId , QString &dev_connectFailedDisc , qint16 &dev_rssi , bool &dev_sendFileMark , QString &adapter_addr ) { KyDebug() << value ; //解析bluetooth device数据 QString key = "Paired"; if(value.contains(key)) dev_paired = value[key].toBool(); key = "Trusted"; if(value.contains(key)) dev_trusted = value[key].toBool(); key = "Blocked"; if(value.contains(key)) dev_blocked = value[key].toBool(); key = "Connected"; if(value.contains(key)) dev_connected = value[key].toBool(); key = "Name"; if(value.contains(key)) dev_name = value[key].toString(); key = "ShowName"; if(value.contains(key)) dev_showName = value[key].toString(); key = "Addr"; if(value.contains(key)) dev_address = value[key].toString(); key = "Type"; if(value.contains(key)) dev_type = bluetoothdevice::BLUETOOTH_DEVICE_TYPE(value[key].toInt()); key = "Pairing"; if(value.contains(key)) dev_pairing = value[key].toBool(); key = "Connecting"; if(value.contains(key)) dev_connecting = value[key].toBool(); key = "Battery"; if(value.contains(key)) dev_battery = value[key].toInt(); key = "ConnectFailedId"; if(value.contains(key)) dev_connectFailedId = value[key].toInt(); key = "ConnectFailedDisc"; if(value.contains(key)) dev_connectFailedDisc = value[key].toString(); key = "Rssi"; if(value.contains(key)) dev_rssi = value[key].toInt(); key = "FileTransportSupport"; if(value.contains(key)) dev_sendFileMark = value[key].toBool(); key = "Adapter"; if(value.contains(key)) adapter_addr = value[key].toString(); } bluetoothdevice * BlueToothDBusService::createOneBleutoothDeviceForAddress(QString address) { KyDebug() ; bluetoothdevice * dev = nullptr; QString device_addr = address, adapter_addr, dev_name, dev_showName, dev_connectFailedDisc; bluetoothdevice::BLUETOOTH_DEVICE_TYPE dev_type; bool dev_paired , dev_trusted , dev_blocked , dev_connected , dev_pairing , dev_connecting , dev_sendFileMark ; int dev_battery , dev_connectFailedId ; qint16 dev_rssi ; QMap value = getDevAttr(device_addr); bluetoothDeviceDataAnalysis(value, device_addr , dev_name , dev_showName , dev_type , dev_paired , dev_trusted , dev_blocked , dev_connected , dev_pairing , dev_connecting , dev_battery , dev_connectFailedId , dev_connectFailedDisc , dev_rssi , dev_sendFileMark , adapter_addr); KyDebug() << "device_addr:" << device_addr ; KyDebug() << "dev_name:" << dev_name ; KyDebug() << "dev_showName:" << dev_showName ; KyDebug() << "dev_type:" << dev_type ; KyDebug() << "dev_paired:" << dev_paired ; KyDebug() << "dev_trusted:" << dev_trusted ; KyDebug() << "dev_blocked:" << dev_blocked ; KyDebug() << "dev_connected:" << dev_connected ; KyDebug() << "dev_pairing:" << dev_pairing ; KyDebug() << "dev_connecting:" << dev_connecting ; KyDebug() << "dev_battery:" << dev_battery ; KyDebug() << "dev_connectFailedId:" << dev_connectFailedId ; KyDebug() << "dev_connectFailedDisc:" << dev_connectFailedDisc ; KyDebug() << "dev_rssi:" << dev_rssi ; KyDebug() << "dev_sendFileMark:" << dev_sendFileMark ; KyDebug() << "adapter_addr:" << adapter_addr ; // dev = new bluetoothdevice(device_addr , // dev_name , // dev_showName , // dev_type , // dev_paired , // dev_trusted , // dev_blocked , // dev_connected , // dev_pairing , // dev_connecting , // dev_battery , // dev_connectFailedId , // dev_connectFailedDisc , // dev_rssi , // dev_sendFileMark , // adapter_addr // ); dev = new bluetoothdevice(value); if (dev == nullptr) return nullptr; return dev; } QMap BlueToothDBusService::getDevAttr(QString dev_address) { QDBusMessage message = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getDevAttr"); message << dev_address; QDBusReply> reply_res = QDBusConnection::systemBus().call(message); return reply_res; } bool BlueToothDBusService::devRename(QString address,QString rename_str) { KyInfo() << address << rename_str ; deviceDataAttr.remove("Name"); deviceDataAttr.insert("Name", QVariant(rename_str)); bool res = setDevAttr(address,deviceDataAttr); return res; } bool BlueToothDBusService::setDevTrusted(QString address,bool isTrusted) { KyDebug() << address << isTrusted ; deviceDataAttr.remove("Trusted"); deviceDataAttr.insert("Trusted", QVariant(isTrusted)); bool res = setDevAttr(address,deviceDataAttr); return res; } bool BlueToothDBusService::setDevAttr(QString addr,QMap devAttr) { KyWarning() << addr << devAttr; QDBusMessage dbusMsg = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "setDevAttr"); dbusMsg << addr << devAttr; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); deviceDataAttr.clear(); if ( response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } void BlueToothDBusService::bindServiceReportData() { KyDebug() ; QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "updateClient",this, SLOT(reportUpdateClient())); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "adapterAddSignal",this, SLOT(reportAdapterAddSignal(QMap))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "adapterAttrChanged",this, SLOT(reportAdapterAttrChanged( QString,QMap))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "adapterRemoveSignal",this, SLOT(reportAdapterRemoveSignal(QString))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "deviceAddSignal",this, SLOT(reportDeviceAddSignal(QMap))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "deviceAttrChanged",this, SLOT(reportDeviceAttrChanged(QString,QMap))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "deviceRemoveSignal",this, SLOT(reportDeviceRemoveSignal(QString,QMap))); QDBusConnection::systemBus().connect(SERVICE, PATH, INTERFACE, "clearBluetoothDev",this, SLOT(reportClearBluetoothDev(QStringList))); } void BlueToothDBusService::bindDefaultAdapterReportData() { KyDebug(); if (m_default_bluetooth_adapter) { m_default_bluetooth_adapter->disconnect(this); connect(m_default_bluetooth_adapter,SIGNAL(adapterNameChanged(QString)),this,SIGNAL(adapterNameChanged(QString))); connect(m_default_bluetooth_adapter,SIGNAL(adapterPoweredChanged(bool)),this,SIGNAL(adapterPoweredChanged(bool))); connect(m_default_bluetooth_adapter,SIGNAL(adapterTrayIconChanged(bool)),this,SIGNAL(adapterTrayIconChanged(bool))); connect(m_default_bluetooth_adapter,SIGNAL(adapterDiscoverableChanged(bool)),this,SIGNAL(adapterDiscoverableChanged(bool))); connect(m_default_bluetooth_adapter,SIGNAL(adapterDiscoveringChanged(bool)),this,SIGNAL(adapterDiscoveringChanged(bool))); connect(m_default_bluetooth_adapter,SIGNAL(adapterAutoConnStatuChanged(bool)),this,SIGNAL(adapterActiveConnectionChanged(bool))); } } void BlueToothDBusService::bluetoothAdapterDataAnalysis(QMap value, QString &dev_name, QString &dev_address, bool &dev_block , bool &dev_power, bool &dev_pairing , bool &dev_pairable , bool &dev_connecting , bool &dev_discovering , bool &dev_discoverable, bool &dev_activeConnection, bool &dev_defaultAdapterMark, bool &dev_trayShow) { KyDebug() ; //解析adpater数据 if(value.contains("Name")) dev_name = value["Name"].toString(); if(value.contains("Addr")) dev_address = value["Addr"].toString(); if(value.contains("Block")) dev_block = value["Block"].toBool(); if(value.contains("Powered")) dev_power = value["Powered"].toBool(); if(value.contains("Pairing")) dev_pairing = value["Pairing"].toBool(); if(value.contains("Pairable")) dev_pairable = value["Pairable"].toBool(); if(value.contains("Connecting")) dev_connecting = value["Connecting"].toBool(); if(value.contains("Discovering")) dev_discovering = value["Discovering"].toBool(); if(value.contains("Discoverable")) dev_discoverable = value["Discoverable"].toBool(); if(value.contains("ActiveConnection")) dev_activeConnection = value["ActiveConnection"].toBool(); if(value.contains("DefaultAdapter")) dev_defaultAdapterMark = value["DefaultAdapter"].toBool(); if(value.contains("trayShow")) dev_trayShow = value["trayShow"].toBool(); KyDebug() << "end" ; } void BlueToothDBusService::reportAdapterAddSignal(QMap value) { KyDebug() << value; QString dev_name, dev_address; bool dev_block , dev_power, dev_pairing , dev_pairable , dev_connecting , dev_discovering , dev_discoverable, dev_activeConnection, dev_defaultAdapterMark, dev_trayShow; bluetoothAdapterDataAnalysis(value, dev_name, dev_address, dev_block , dev_power, dev_pairing , dev_pairable , dev_connecting , dev_discovering , dev_discoverable, dev_activeConnection, dev_defaultAdapterMark, dev_trayShow); foreach (auto var, m_bluetooth_adapter_list) { if (dev_address == var->getDevAddress()) { KyWarning() << "Adapter already exists:" << dev_name << dev_address; return; } } // bluetoothadapter *bt_adapter = new bluetoothadapter(dev_name , // dev_address , // dev_block , // dev_power , // dev_pairing , // dev_pairable , // dev_connecting , // dev_discovering , // dev_discoverable, // dev_activeConnection, // dev_defaultAdapterMark , // dev_trayShow); bluetoothadapter *bt_adapter = new bluetoothadapter(value); if(bt_adapter != nullptr) { m_bluetooth_adapter_list.append(bt_adapter); m_bluetooth_adapter_address_list.append(dev_address); m_bluetooth_adapter_name_list.append(dev_name); KyInfo() << "add an adapter (mac):" << dev_address ; // KyWarning() << "add an adapter (mac):" << dev_address << // "dev_defaultAdapterMark:" << dev_defaultAdapterMark << // "m_bluetooth_adapter_list:" << m_bluetooth_adapter_list ; if(dev_defaultAdapterMark || 1 == m_bluetooth_adapter_list.size())//是默认适配器/只有一个适配器,读取设备列表 { m_default_bluetooth_adapter = bt_adapter; //读取默认适配器下配对和扫描出的设备 bindDefaultAdapterReportData(); getDefaultAdapterDevices(); if (m_bluetooth_adapter_list.size() > 1) { int indx = 0; if (m_bluetooth_adapter_list.size()-1 >= 0) indx = m_bluetooth_adapter_list.size()-1 ; emit defaultAdapterChangedSignal(indx); } } emit adapterAddSignal(dev_name); } } void BlueToothDBusService::reportAdapterRemoveSignal(QString address) { KyDebug() << address << m_bluetooth_adapter_address_list ; int indx = -1; foreach (auto val, m_bluetooth_adapter_list) { KyInfo() << " val->getDevAddress():" << val->getDevAddress(); indx++; if (address == val->getDevAddress()) break; } if (-1 == indx) { KyInfo() << "-1" << "m_bluetooth_adapter_list:" << m_bluetooth_adapter_list << m_bluetooth_adapter_list.size(); return; } KyDebug() << "indx:" <getDevAddress():" << m_default_bluetooth_adapter->getDevAddress(); if (address == m_default_bluetooth_adapter->getDevAddress()) { //emit btServiceRestart(); m_default_bluetooth_adapter = nullptr; } } if (indx < m_bluetooth_adapter_name_list.size()) m_bluetooth_adapter_name_list.removeAt(indx); if (indx < m_bluetooth_adapter_address_list.size()) m_bluetooth_adapter_address_list.removeAt(indx); if (indx < m_bluetooth_adapter_list.size()) { bluetoothadapter * adapter_dev = m_bluetooth_adapter_list.at(indx); m_bluetooth_adapter_list.removeAt(indx); adapter_dev->disconnect(); adapter_dev->deleteLater(); } Q_EMIT adapterRemoveSignal(indx); } void BlueToothDBusService::serviceChangedDefaultAdapter(int indx) { KyDebug() << "adapter address indx:" << indx ; if(m_default_bluetooth_adapter && m_default_bluetooth_adapter->getDevAddress() == m_bluetooth_adapter_list.at(indx)->getDevAddress()) { KyDebug() << "default Adapter not Changed:" << indx ; return; } m_default_bluetooth_adapter = m_bluetooth_adapter_list.at(indx); this->bindDefaultAdapterReportData(); getDefaultAdapterDevices(); Q_EMIT defaultAdapterChangedSignal(indx); } void BlueToothDBusService::reportAdapterAttrChanged(QString address,QMap value) { KyDebug() << "adapter address:" << address << value; // KyWarning() << "adapter address:" << address << value; bool flag = false ; int indx = 0; for (bluetoothadapter * btAdapter : m_bluetooth_adapter_list) { if (address == btAdapter->getDevAddress()) { flag = true; break; } indx++; } KyInfo() << "bt adapter list index:" << indx ; if (flag && indx < m_bluetooth_adapter_list.size()) { QString key; key = "Name"; if(value.contains(key) && (QVariant::String == value[key].type())) { QString new_name = value[key].toString(); m_bluetooth_adapter_list.at(indx)->resetDeviceName(value[key].toString()); if (m_bluetooth_adapter_name_list.count() > indx) { m_bluetooth_adapter_name_list.removeAt(indx); m_bluetooth_adapter_name_list.insert(indx,new_name); } Q_EMIT adapterNameChangedOfIndex(indx,new_name); } //key = "Addr"; key = "Block"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_block = value[key].toBool(); } key = "Powered"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_power = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterPower(value[key].toBool()); } key = "Pairing"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { //bool dev_pairing = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterPairing(value[key].toBool()); } key = "Pairable"; if(value.contains("Pairable") && (QVariant::Bool == value[key].type())) { // bool dev_pairable = value["Pairable"].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterPairable(value[key].toBool()); } key = "Connecting"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_connecting = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterConnecting(value[key].toBool()); } key = "Discovering"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_discovering = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterDiscovering(value[key].toBool()); } key = "Discoverable"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_discoverable = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterDiscoverable(value[key].toBool()); } key = "ActiveConnection"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_activeConnection = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterAutoConn(value[key].toBool()); } key = "DefaultAdapter"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_defaultAdapterMark = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterDefaultMark(value[key].toBool()); if (value[key].toBool()) { serviceChangedDefaultAdapter(indx); } } // support_a2dp_sink // support_a2dp_source // support_hfphsp_ag // support_hfphsp_hf // FileTransportSupport key = "trayShow"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_trayShow = value[key].toBool(); m_bluetooth_adapter_list.at(indx)->setAdapterTrayShow(value[key].toBool()); } } else { KyWarning() << "There is no corresponding adapter!" ; } } void BlueToothDBusService::reportDeviceAddSignal(QMap value) { KyDebug() << value; if(nullptr == m_default_bluetooth_adapter) { KyWarning() << "m_default_bluetooth_adapter is nullptr!" ; return; } bluetoothdevice * dev = nullptr; QString dev_address , adapter_addr , dev_name , dev_showName , dev_connectFailedDisc ; bluetoothdevice::BLUETOOTH_DEVICE_TYPE dev_type ; bool dev_paired , dev_trusted , dev_blocked , dev_connected , dev_pairing , dev_connecting , dev_sendFileMark ; int dev_battery , dev_connectFailedId ; qint16 dev_rssi ; bluetoothDeviceDataAnalysis(value, dev_address , dev_name , dev_showName , dev_type , dev_paired , dev_trusted , dev_blocked , dev_connected , dev_pairing , dev_connecting , dev_battery , dev_connectFailedId , dev_connectFailedDisc , dev_rssi , dev_sendFileMark , adapter_addr ); if(adapter_addr != m_default_bluetooth_adapter->getDevAddress()) { KyWarning() << "m_default_bluetooth_adapter != device default adapter addr" << adapter_addr << m_default_bluetooth_adapter->getDevAddress(); return ; } // KyDebug() << "dev_address:" << dev_address ; // KyDebug() << "dev_name:" << dev_name ; // KyDebug() << "dev_showName:" << dev_showName ; // KyDebug() << "dev_type:" << dev_type ; // KyDebug() << "dev_paired:" << dev_paired ; // KyDebug() << "dev_trusted:" << dev_trusted ; // KyDebug() << "dev_blocked:" << dev_blocked ; // KyDebug() << "dev_connected:" << dev_connected ; // KyDebug() << "dev_pairing:" << dev_pairing ; // KyDebug() << "dev_connecting:" << dev_connecting ; // KyDebug() << "dev_battery:" << dev_battery ; // KyDebug() << "dev_connectFailedId:" << dev_connectFailedId ; // KyDebug() << "dev_connectFailedDisc:" << dev_connectFailedDisc ; // KyDebug() << "dev_rssi:" << dev_rssi ; // KyDebug() << "dev_sendFileMark:" << dev_sendFileMark ; // KyDebug() << "adapter_addr:" << adapter_addr ; // dev = new bluetoothdevice(dev_address , // dev_name , // dev_showName , // dev_type , // dev_paired , // dev_trusted , // dev_blocked , // dev_connected , // dev_pairing , // dev_connecting , // dev_battery , // dev_connectFailedId , // dev_connectFailedDisc , // dev_rssi , // dev_sendFileMark , // adapter_addr // ); dev = new bluetoothdevice(value); if (nullptr != dev && !m_default_bluetooth_adapter->m_bt_dev_list.contains(dev->getDevAddress())) { m_default_bluetooth_adapter->m_bt_dev_list.insert(dev->getDevAddress(), dev); emit deviceAddSignal(dev->getDevAddress()); } else if (m_default_bluetooth_adapter->m_bt_dev_list.contains(dev->getDevAddress())) { //exist : update reportDeviceAttrChanged(dev->getDevAddress(),value); //界面add emit deviceAddSignal(dev->getDevAddress()); } else { dev->deleteLater(); } } void BlueToothDBusService::reportDeviceAttrChanged(QString address,QMap value) { KyDebug() << "device address:" << address << value; if (nullptr == m_default_bluetooth_adapter) { KyWarning() << "m_default_bluetooth_adapter is nullptr!"; return; } if (m_default_bluetooth_adapter->m_bt_dev_list.contains(address)) { QString key; key = "Paired"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->devPairedChanged(value[key].toBool()); if (value[key].toBool()) Q_EMIT devicePairedSuccess(address); } key = "Trusted"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevTrust(value[key].toBool()); } // key = "Blocked"; // if(value.contains(key) && (QVariant::Bool == value[key].type())) // { // bool dev_blocked = value[key].toBool(); // } key = "Connected"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->devConnectedChanged(value[key].toBool()); } key = "Name"; if(value.contains(key) && (QVariant::String == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->resetDeviceName(value[key].toString()); } key = "ShowName"; if(value.contains(key) && (QVariant::String == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevShowName(value[key].toString()); } key = "Type"; if(value.contains(key) && (QVariant::Int == value[key].type())) { bluetoothdevice::BLUETOOTH_DEVICE_TYPE dev_type = bluetoothdevice::BLUETOOTH_DEVICE_TYPE(value[key].toInt()); m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevType(dev_type); } key = "Pairing"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevPairing(value[key].toBool()); } key = "Connecting"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevConnecting(value[key].toBool()); } // key = "Battery"; // if(value.contains(key) && (QVariant::Int == value[key].type())) // { // int dev_battery = value[key].toInt(); // } key = "ConnectFailedId"; int dev_connectFailedId = 0; if(value.contains(key) && (QVariant::Int == value[key].type())) { dev_connectFailedId = value[key].toInt(); } key = "ConnectFailedDisc"; if(value.contains(key) && (QVariant::String == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevConnFailedInfo(dev_connectFailedId,value[key].toString()); } key = "Rssi"; if(value.contains(key) && (QVariant::Int == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevRssi(value[key].toInt()); } key = "FileTransportSupport"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { m_default_bluetooth_adapter->m_bt_dev_list[address]->setDevSendFileMark(value[key].toInt()); } } else { KyDebug() << address << "not add this dev"; bluetoothdevice * dev = createOneBleutoothDeviceForAddress(address); if (dev) { m_default_bluetooth_adapter->m_bt_dev_list.insert(address,dev); Q_EMIT deviceAddSignal(address); } } return ; #if 0 bool flag = false ; int indx = 0; for (bluetoothdevice * btDevice : m_default_bluetooth_adapter->m_bluetooth_device_list) { if (address == btDevice->getDevAddress()) { flag = true; break; } indx++; } KyDebug()<< "bt adapter list index:" << indx << "flag" << flag << "m_bluetooth_device_list size:" << m_default_bluetooth_adapter->m_bluetooth_device_list.size(); if (flag && indx < m_default_bluetooth_adapter->m_bluetooth_device_list.size()) { KyDebug() << "test dev" << m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->getDevAddress() << m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->getDevName(); QString key; key = "Paired"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_paired = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->devPairedChanged(value[key].toBool()); } key = "Trusted"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_trusted = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevTrust(value[key].toBool()); } // key = "Blocked"; // if(value.contains(key) && (QVariant::Bool == value[key].type())) // { // bool dev_blocked = value[key].toBool(); // } key = "Connected"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_connected = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->devConnectedChanged(value[key].toBool()); } key = "Name"; if(value.contains(key) && (QVariant::String == value[key].type())) { // QString dev_name = value[key].toString(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->resetDeviceName(value[key].toString()); } key = "ShowName"; if(value.contains(key) && (QVariant::String == value[key].type())) { // QString dev_name = value[key].toString(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevShowName(value[key].toString()); } key = "Type"; if(value.contains(key) && (QVariant::Int == value[key].type())) { bluetoothdevice::BLUETOOTH_DEVICE_TYPE dev_type = bluetoothdevice::BLUETOOTH_DEVICE_TYPE(value[key].toInt()); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevType(dev_type); } key = "Pairing"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_pairing = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevPairing(value[key].toBool()); } key = "Connecting"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_connecting = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevConnecting(value[key].toBool()); } // key = "Battery"; // if(value.contains(key) && (QVariant::Int == value[key].type())) // { // int dev_battery = value[key].toInt(); // } key = "ConnectFailedId"; int dev_connectFailedId = 0; if(value.contains(key) && (QVariant::Int == value[key].type())) { dev_connectFailedId = value[key].toInt(); } key = "ConnectFailedDisc"; if(value.contains(key) && (QVariant::String == value[key].type())) { // QString dev_connectFailedDisc = value[key].toString(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevConnFailedInfo(dev_connectFailedId,value[key].toString()); } key = "Rssi"; if(value.contains(key) && (QVariant::Int == value[key].type())) { // int dev_rssi = value[key].toInt(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevRssi(value[key].toInt()); } key = "FileTransportSupport"; if(value.contains(key) && (QVariant::Bool == value[key].type())) { // bool dev_sendFileMark = value[key].toBool(); m_default_bluetooth_adapter->m_bluetooth_device_list.at(indx)->setDevSendFileMark(value[key].toInt()); } } else { } #endif } //int BlueToothDBusService::getDevListIndex(QString address) //{ // if (nullptr == m_default_bluetooth_adapter) // { // KyWarning() << "m_default_bluetooth_adapter is nullptr!" ; // return -1; // } // int indx = -1; // for (bluetoothdevice * btDevice : m_default_bluetooth_adapter->m_bluetooth_device_list) // { // indx++; // if (address == btDevice->getDevAddress()) // { // break; // } // } // return indx; //} int BlueToothDBusService::reportDeviceRemoveSignal(QString devAddr,QMap value) { KyDebug() << devAddr << value; if (nullptr == m_default_bluetooth_adapter) { KyDebug() << "m_default_bluetooth_adapter is nullptr!"; return 1; } QString dev_adapter_addr ; QString key = "Adapter"; if(value.contains(key) && (QVariant::String == value[key].type())) dev_adapter_addr = value[key].toString(); if (dev_adapter_addr != m_default_bluetooth_adapter->getDevAddress()) { KyDebug() << "dev_adapter_addr:" << dev_adapter_addr << "m_default_bluetooth_adapter->getDevAddress:" << m_default_bluetooth_adapter->getDevAddress(); return 1; } if (!m_default_bluetooth_adapter->m_bt_dev_list.contains(devAddr)) { KyDebug() << devAddr << "remove dev not exist"; return 1; } if (m_default_bluetooth_adapter->m_bt_dev_list[devAddr]->getDevConnecting()) { KyDebug() << devAddr << "Device is connecting!"; return 1; } emit deviceRemoveSignal(devAddr); if (m_remainder_loaded_bluetooth_device_address_list.contains(devAddr)) { m_remainder_loaded_bluetooth_device_address_list.removeAll(devAddr); } bluetoothdevice * dev = m_default_bluetooth_adapter->m_bt_dev_list[devAddr]; // if (dev->isPaired()) // m_default_bluetooth_adapter->m_bt_dev_paired_list.remove(devAddr); m_default_bluetooth_adapter->m_bt_dev_list.remove(devAddr); dev->disconnect(); KyDebug() << "delete dev:" << dev->getDevName() << dev->getDevAddress(); dev->deleteLater(); return 0; } void BlueToothDBusService::reportClearBluetoothDev(QStringList addrList) { KyDebug()<< addrList ; if (nullptr == m_default_bluetooth_adapter) { KyWarning() << "m_default_bluetooth_adapter is nullptr!"; return; } for (QString addr : addrList) { //发送给界面移除信号 // emit deviceRemoveSignal(addr); //移除列表中的数据 QMap value; value["Adapter"] = m_default_bluetooth_adapter->getDevAddress(); if (0 == reportDeviceRemoveSignal(addr,value)) { //下发移除信号给服务 devRemove(addr); } } } int BlueToothDBusService::devConnect(QString address) { KyInfo() << address ; int reply_res = 0; QDBusMessage mesg = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "devConnect"); mesg << address; //KyDebug() << m.arguments().at(0).value() <<; // 发送Message QDBusMessage res = QDBusConnection::systemBus().call(mesg, QDBus::NoBlock); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res.arguments().takeFirst().toInt(); KyInfo() << reply_res; } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res; } int BlueToothDBusService::devDisconnect(QString address) { KyDebug(); int reply_res = 0; QDBusMessage m = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "devDisconnect"); m << address; KyDebug() << m.arguments().at(0).value(); // 发送Message QDBusMessage res = QDBusConnection::systemBus().call(m, QDBus::NoBlock); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res.arguments().takeFirst().toInt(); KyInfo() << reply_res; } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res; } int BlueToothDBusService::devRemove(QString address) { KyDebug() << address ; QStringList dev_addrList; dev_addrList.clear(); dev_addrList.append(address); int reply_res = devRemove(dev_addrList); return reply_res; } int BlueToothDBusService::devRemove(QStringList addressList) { KyDebug() << addressList ; int reply_res = 0; QDBusMessage m = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "devRemove"); m << addressList; KyDebug() << m.arguments().at(0).value(); // 发送Message QDBusMessage res = QDBusConnection::systemBus().call(m, QDBus::NoBlock); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res.arguments().takeFirst().toInt(); KyInfo() << reply_res; } } else { KyDebug()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res; } int BlueToothDBusService::sendFiles(QString address) { KyDebug() ; int reply_res = 0; QDBusMessage m = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "setSendTransferDeviceMesg"); m << address; KyDebug() << m.arguments().at(0).value(); //使用sessionBus 发送Message QDBusMessage res = QDBusConnection::sessionBus().call(m, QDBus::NoBlock); if(res.type() == QDBusMessage::ReplyMessage) { if(res.arguments().size() > 0) { reply_res = res.arguments().takeFirst().toInt(); KyInfo() << reply_res; } } else { KyWarning()<< res.errorName() << ": "<< res.errorMessage(); } return reply_res; } bool BlueToothDBusService::setDefaultAdapterAttr(QMap adpAttr) { KyDebug() << adpAttr; QDBusMessage dbusMsg = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "setDefaultAdapterAttr"); dbusMsg << adpAttr; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); defaultAdapterDataAttr.clear(); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toBool(); } else return false; } void BlueToothDBusService::setDefaultAdapterSwitchStatus(bool power) { KyDebug() << power; // KyWarning() << "===============" << power; defaultAdapterDataAttr.remove("Powered"); defaultAdapterDataAttr.insert("Powered", QVariant(power)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setDefaultAdapterDiscoverableStatus(bool status) { KyDebug() << status; // KyWarning() << "===============" << status; defaultAdapterDataAttr.remove("Discoverable"); defaultAdapterDataAttr.insert("Discoverable", QVariant(status)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setDefaultAdapterScanOn(bool scanStatus) { KyDebug() << "set adapter state:" << scanStatus ; // KyWarning() << "===============" << scanStatus; defaultAdapterDataAttr.remove("Discovering"); defaultAdapterDataAttr.insert("Discovering", QVariant(scanStatus)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setDefaultAdapterName(QString name) { KyDebug() << name ; defaultAdapterDataAttr.remove("Name"); defaultAdapterDataAttr.insert("Name", QVariant(name)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setAutoConnectAudioDevStatus(bool status) { KyDebug() << status ; defaultAdapterDataAttr.remove("ActiveConnection"); defaultAdapterDataAttr.insert("ActiveConnection", QVariant(status)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setAudioCombine(bool status) { KyDebug() << status ; defaultAdapterDataAttr.remove("AudioCombine"); defaultAdapterDataAttr.insert("AudioCombine", QVariant(status)); setDefaultAdapterAttr(defaultAdapterDataAttr); } void BlueToothDBusService::setTrayIconShowStatus(bool status) { KyDebug() << status ; defaultAdapterDataAttr.remove("trayShow"); defaultAdapterDataAttr.insert("trayShow", QVariant(status)); setDefaultAdapterAttr(defaultAdapterDataAttr); } int BlueToothDBusService::setDefaultAdapter(QString address) { KyInfo() << address ; QDBusMessage dbusMsg = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "setDefaultAdapter"); dbusMsg << address; QDBusMessage response = QDBusConnection::systemBus().call(dbusMsg, QDBus::NoBlock); if (response.type() == QDBusMessage::ReplyMessage) { return response.arguments().takeFirst().toInt(); } else return (-1); } bool BlueToothDBusService::getTransferInfo(QString dev) { QDBusMessage m = QDBusMessage::createMethodCall(SERVICE, PATH, INTERFACE, "getTransferDevAndStatus"); m << dev; QDBusMessage response = QDBusConnection::systemBus().call(m); if (response.type() == QDBusMessage::ReplyMessage) { //KyDebug() << "<<______>>"; return response.arguments().takeFirst().toBool(); } //默认暴露文件发送接口 return true; } void BlueToothDBusService::devLoadingTimeoutSlot() { KyDebug() << m_remainder_loaded_bluetooth_device_address_list; if (m_remainder_loaded_bluetooth_device_address_list.size() > 0) { m_loading_dev_timer->stop(); QString str_addr = m_remainder_loaded_bluetooth_device_address_list.at(0); bluetoothdevice * dev = createOneBleutoothDeviceForAddress(str_addr); if (nullptr != dev) { m_remainder_loaded_bluetooth_device_address_list.pop_front(); m_default_bluetooth_adapter->m_bt_dev_list[str_addr] = dev; emit deviceAddSignal(str_addr); } else { KyWarning() << str_addr << " get not data!"; } if (m_remainder_loaded_bluetooth_device_address_list.size() > 0) { m_loading_dev_timer->start(); } } else { m_loading_dev_timer->stop(); } } ukui-bluetooth/ukcc-bluetooth/config.h0000664000175000017500000000515415167665755017062 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef CONFIG_H #define CONFIG_H #include #define BluetoothServiceExePath "/usr/bin/bluetoothService -o" #define BluetoothTrayExePath "/usr/bin/ukui-bluetooth" #define BluetoothServiceName "bluetoothService" #define BluetoothTrayName "ukui-bluetooth" #define SYSTEMSTYLESCHEMA "org.ukui.style" #define SYSTEMSTYLENAME "styleName" #define SYSTEMFONTSIZE "systemFontSize" #define SYSTEMFONT "systemFont" #define MAX_DEVICE_CONECTIONS_TIMES 3 #define DELAYED_SCANNING_TIME_S (2*1000) #define DEVICE_CONNECTION_TIMEOUT_S (30*1000) #define LOADING_ICON_TIMEOUT_INTERVAL_MS (110) #define NO_DEV_ADD_SIGNAL_DETECTION_INTERVAL (5*1000) #define TRANSPARENCY_SETTINGS "org.ukui.control-center.personalise" #define TRANSPARENCY_KEY "transparency" #define GSETTING_UKUI_STYLE "org.ukui.style" #define GSETTING_SCHEMA_UKCC "org.ukui.control-center.plugins" #define GSETTING_PACH_UKCC "/org/ukui/control-center/plugins/Bluetooth/" #define DBUSSERVICE "com.ukui.bluetooth" #define DBUSPATH "/com/ukui/bluetooth" #define DBUSINTERFACE "com.ukui.bluetooth" #define TITLE_ICON_BLUETOOTH "bluetooth" const QString SERVICE = "com.ukui.bluetooth"; const QString PATH = "/com/ukui/bluetooth"; const QString INTERFACE = "com.ukui.bluetooth"; enum Environment { NOMAL = 0, HUAWEI, LAIKA, MAVIS }; extern Environment envPC; extern bool global_rightToleft; struct struct_pos { struct_pos() {} struct_pos(int _x, int _y, int _width, int _high){ x = _x; y = _y; width = _width; high = _high; } int x = 0; int y = 0; int width = 0; int high = 0; }; static struct_pos getWidgetPos(int ax, int ay, int aw, int ah, int width) { struct_pos t(ax, ay, aw, ah); //从右到左布局,需要重新定位x坐标 if (global_rightToleft) { t.x = width - ax - aw; } return t; } #endif // CONFIG_H ukui-bluetooth/ukcc-bluetooth/bluetoothnamelabel.cpp0000664000175000017500000001654215167665770022016 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothnamelabel.h" BluetoothNameLabel::BluetoothNameLabel(QWidget *parent, int x, int y): QWidget(parent) { this->setAutoFillBackground(true); this->setObjectName("BluetoothNameLabel"); this->setStyleSheet("QWidget{border: none;border-radius:2px;}"); // this->setMouseTracking(true); this->setMinimumSize(x,y); hLayout = new QHBoxLayout(this); hLayout->setContentsMargins(5,0,5,0); hLayout->setSpacing(0); m_label = new QLabel(this); m_label->setContentsMargins(1,0,1,0); m_label->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); hLayout->addWidget(m_label); hLayout->addStretch(0); const auto ratio = 1.0; icon_pencil = new QLabel(this); icon_pencil->setFixedSize(QSize(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio)); icon_pencil->setPixmap(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio)); icon_pencil->setToolTip(tr("Click to change the device name")); hLayout->addWidget(icon_pencil); hLayout->addStretch(20); if(QGSettings::isSchemaInstalled("org.ukui.style")){ settings = new QGSettings("org.ukui.style"); if(settings->get("style-name").toString() == "ukui-black" || settings->get("style-name").toString() == "ukui-dark") { style_flag = true; icon_pencil->setPixmap(ukccbluetoothconfig::loadSvg(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio),ukccbluetoothconfig::WHITE)); } else { style_flag = false; icon_pencil->setPixmap(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio)); } connect(settings,&QGSettings::changed,this,&BluetoothNameLabel::settings_changed); } } BluetoothNameLabel::~BluetoothNameLabel() { delete settings; settings = nullptr; if(nullptr != renameDialog) { renameDialog->deleteLater(); } } void BluetoothNameLabel::set_dev_name(const QString &dev_name) { device_name = dev_name; setMyNameLabelText(device_name); // QFontMetrics fontWidth(m_label->font());//得到QLabel字符的度量 // QString elidedNote = fontWidth.elidedText(dev_name, Qt::ElideMiddle, m_label->width());//获取处理后的文本 // m_label->setText(elidedNote); // m_label->setToolTip(tr("Can now be found as \"%1\"").arg(dev_name)); // m_label->update(); } void BluetoothNameLabel::showDevRenameDialog() { if(nullptr != renameDialog) { delete renameDialog; renameDialog = nullptr; } renameDialog = new DevRenameDialog(this); renameDialog->setDevName(device_name); renameDialog->setRenameInterface(DevRenameDialog::DEVRENAMEDIALOG_ADAPTER); connect(renameDialog,&DevRenameDialog::nameChanged,this,[=](QString name){ m_label->setText(name); device_name = name; emit sendAdapterName(name); }); renameDialog->exec(); } void BluetoothNameLabel::mousePressEvent(QMouseEvent *event) { Q_UNUSED(event); if(m_label->geometry().contains(this->mapFromGlobal(QCursor::pos())) || icon_pencil->geometry().contains(this->mapFromGlobal(QCursor::pos()))) showDevRenameDialog(); } void BluetoothNameLabel::mouseDoubleClickEvent(QMouseEvent *event) { Q_UNUSED(event); if(m_label->geometry().contains(this->mapFromGlobal(QCursor::pos())) || icon_pencil->geometry().contains(this->mapFromGlobal(QCursor::pos()))) showDevRenameDialog(); } //void BluetoothNameLabel::mouseMoveEvent(QMouseEvent *event) //{ // Q_UNUSED(event); // if(m_label->geometry().contains(this->mapFromGlobal(QCursor::pos()))) // { // KyWarning() << "===================" << "m_label"; // } // if(icon_pencil->geometry().contains(this->mapFromGlobal(QCursor::pos()))) // { // KyWarning() << "==================="<< "icon_pencil"; // } //} void BluetoothNameLabel::leaveEvent(QEvent *event) { Q_UNUSED(event); } void BluetoothNameLabel::enterEvent(QEvent *event){ Q_UNUSED(event); if(style_flag) this->setStyleSheet("QWidget#BluetoothNameLabel{background-color:black;border:none;border-radius:2px;}"); else this->setStyleSheet("QWidget#BluetoothNameLabel{background-color:white;border:none;border-radius:2px;}"); } void BluetoothNameLabel::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); if (nullptr != m_label) { setMyNameLabelText(device_name); // QFontMetrics fontWidth(m_label->font());//得到QLabel字符的度量 // QString elidedNote = fontWidth.elidedText(device_name, Qt::ElideMiddle, m_label->width());//获取处理后的文本 // m_label->setText(elidedNote); // m_label->update(); } } void BluetoothNameLabel::settings_changed(const QString &key) { qDebug() << Q_FUNC_INFO <devicePixelRatio(); if(key == "styleName"){ if(settings->get("style-name").toString() == "ukui-black" || settings->get("style-name").toString() == "ukui-dark") { style_flag = true; //icon_pencil->setPixmap(ImageUtil::drawSymbolicColoredPixmap(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W_H),"white")); icon_pencil->setPixmap(ukccbluetoothconfig::loadSvg(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio),ukccbluetoothconfig::WHITE)); } else { style_flag = false; icon_pencil->setPixmap(QIcon::fromTheme("document-edit-symbolic").pixmap(ICON_PENCIL_W*ratio,ICON_PENCIL_H*ratio)); } } else if(key == "systemFontSize"){ // qWarning() << Q_FUNC_INFO <font());//得到QLabel字符的度量 // qWarning() << Q_FUNC_INFO << m_label->width(); // QString elidedNote = fontWidth.elidedText(device_name, Qt::ElideMiddle, m_label->width());//获取处理后的文本 // qWarning() << Q_FUNC_INFO <setText(elidedNote); // m_label->update(); } } void BluetoothNameLabel::setMyNameLabelText(QString name_str) { QFontMetrics fontMe(m_label->font());//得到QLabel字符的度量 int fontWidth = fontMe.horizontalAdvance(name_str); qWarning() << Q_FUNC_INFO << m_label->width() << fontWidth ; QString elidedNote = name_str ; if (fontWidth > 200) elidedNote = fontMe.elidedText(name_str, Qt::ElideMiddle, 200);//获取处理后的文本 qWarning() << Q_FUNC_INFO <setText(elidedNote); m_label->setToolTip(tr("Can now be found as \"%1\"").arg(name_str)); // m_label->update(); } ukui-bluetooth/ukcc-bluetooth/bluetoothmainloadingwindow.h0000664000175000017500000000232215167665755023247 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHMAINLOADINGWINDOW_H #define BLUETOOTHMAINLOADINGWINDOW_H #include #include #include #include #include "loadinglabel.h" class BluetoothMainLoadingWindow : public QWidget { Q_OBJECT public: BluetoothMainLoadingWindow(); ~BluetoothMainLoadingWindow(); void DisplayLoadingWindow(); void HiddenLoadingWindow(); private: void InitAdapterLoadingWidget(); private: LoadingLabel *loadingWidgetIcon = nullptr; }; #endif // BLUETOOTHMAINLOADINGWINDOW_H ukui-bluetooth/ukcc-bluetooth/bluetoothmainnormalwindow.h0000664000175000017500000000352115167665755023124 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHMAINNORMALWINDOW_H #define BLUETOOTHMAINNORMALWINDOW_H #include #include #include #include "bluetoothdbusservice.h" #include "bluetoothtopwindow.h" #include "bluetoothmiddlewindow.h" #include "bluetoothbottomwindow.h" class BluetoothMiddleWindow; class BluetoothBottomWindow; class BluetoothMainNormalWindow : public QWidget { Q_OBJECT public: BluetoothMainNormalWindow(BlueToothDBusService * btServer,QWidget * parent = nullptr); ~BluetoothMainNormalWindow(); void SetHidden(bool); void reloadWindow(); void quitWindow(); private Q_SLOTS: void BluetoothSwitchChanged(bool); void defaultAdapterChangedSlot(int); void setHiddenForMyDevice(bool status); private: BluetoothTopWindow * m_topWidget = nullptr; BluetoothMiddleWindow * m_middleWidget = nullptr; BluetoothBottomWindow * m_bottomWidget = nullptr; QVBoxLayout *_NormalWidgetMainLayout = nullptr; BlueToothDBusService * m_btServer = nullptr; bool m_defaultPowerStatus = true; private: void Init(); void InitConnectData(); void InitDisplayStatus(); }; #endif // BLUETOOTHMAINNORMALWINDOW_H ukui-bluetooth/ukcc-bluetooth/bluetoothmainerrorwindow.h0000664000175000017500000000226015167665755022764 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHEMAINERRORWINDOW_H #define BLUETOOTHEMAINERRORWINDOW_H #include #include #include #include #include class BluetoothMainErrorWindow :public QWidget { Q_OBJECT public: BluetoothMainErrorWindow(QString str_error , QWidget * parent = nullptr); void setErrorText(QString error_str); private: QString m_str_error; QLabel * errorWidgetTip = nullptr; private: void InitErrorWindow(); }; #endif // BLUETOOTHEMAINERRORWINDOW_H ukui-bluetooth/ukcc-bluetooth/bluetoothdbusservice.h0000664000175000017500000001721715167665770022061 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHDBUSSERVICE_H #define BLUETOOTHDBUSSERVICE_H #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "devicebase.h" #include "ukccbluetoothconfig.h" /** * @brief * */ class BlueToothDBusService : public QObject { Q_OBJECT public: /** * @brief * * @param parent */ BlueToothDBusService(QObject *parent = nullptr); /** * @brief * */ ~BlueToothDBusService(); int initBluetoothServer(); static QDBusInterface interface; /**< TODO: systemd dbus */ static bool m_taskbar_show_mark ; /**< TODO: default bt adapter */ static QStringList m_bluetooth_adapter_address_list ; /**< TODO: default bt adapter */ static QStringList m_bluetooth_adapter_name_list ; /**< TODO: default bt adapter */ static QStringList m_bluetooth_Paired_Device_address_list ; /**< TODO: default bt adapter */ static QStringList m_bluetooth_All_Device_address_list ; /**< TODO: default bt adapter */ static bluetoothadapter * m_default_bluetooth_adapter ; /**< TODO: default bt adapter */ QList m_bluetooth_adapter_list ; /**< TODO: bt adapter list*/ static int checkAddrList(QStringList &); static QMap registerClient(); static QMap registerClient(QMap); static bool unregisterClient(); //Function operation static int devConnect(QString address); static bool devRename(QString address,QString reanme_str); static bool setDevTrusted(QString address,bool isTrusted); static int devDisconnect(QString address); static int devRemove(QString address); static int devRemove(QStringList addressList); static int sendFiles(QString address); //get adapter data static QMap defaultAdapterDataAttr; static QStringList getAllAdapterAddress(); QMap getAdapterAttr(QString,QString); static bool setDefaultAdapterAttr(QMap); int getAdapterAllData(QString); void bluetoothAdapterDataAnalysis(QMap value, QString &dev_name, QString &dev_address, bool &dev_block , bool &dev_power, bool &dev_pairing , bool &dev_pairable , bool &dev_connecting , bool &dev_discovering , bool &dev_discoverable, bool &dev_activeConnection, bool &dev_defaultAdapterMark, bool &dev_trayShow); //set default adapter static void setDefaultAdapterName(QString); static void setDefaultAdapterSwitchStatus(bool); static int setDefaultAdapter(QString); static void setTrayIconShowStatus(bool); static void setDefaultAdapterDiscoverableStatus(bool); static void setAutoConnectAudioDevStatus(bool); static void setAudioCombine(bool); //get device data static QMap deviceDataAttr; static QStringList getDefaultAdapterPairedDev(); static QStringList getDefaultAdapterAllDev(); static QMap getDevAttr(QString); static bool setDevAttr(QString,QMap); void bluetoothDeviceDataAnalysis(QMap value, QString &dev_address , QString &dev_name , QString &dev_showName , bluetoothdevice::BLUETOOTH_DEVICE_TYPE &dev_type , bool &dev_paired , bool &dev_trusted , bool &dev_blocked , bool &dev_connected , bool &dev_pairing , bool &dev_connecting , int &dev_battery , int &dev_connectFailedId , QString &dev_connectFailedDisc , qint16 &dev_rssi , bool &dev_sendFileMark , QString &adapter_addr ); bluetoothdevice * createOneBleutoothDeviceForAddress(QString address); //set device data /** * @brief * * @param dev * @return bool */ static bool getTransferInfo(QString dev); /** * @brief setDefaultAdapterScanOn * * @param bool */ static void setDefaultAdapterScanOn(bool); //report data signals: void adapterAddSignal(QString); void adapterRemoveSignal(int); void defaultAdapterChangedSignal(int); void adapterNameChanged(QString); void adapterNameChangedOfIndex(int ,QString); void adapterPoweredChanged(bool); void adapterTrayIconChanged(bool); void adapterDiscoverableChanged(bool); void adapterActiveConnectionChanged(bool); void adapterDiscoveringChanged(bool); void deviceAddSignal(QString); void deviceRemoveSignal(QString); void devicePairedSuccess(QString); void btServiceRestart(); void btServiceRestartComplete(bool); private Q_SLOTS: void reportAdapterAddSignal(QMap); void reportAdapterAttrChanged(QString,QMap); void reportAdapterRemoveSignal(QString address); void reportDeviceAddSignal(QMap); void reportDeviceAttrChanged(QString,QMap); int reportDeviceRemoveSignal(QString devAddr , QMap ); void reportClearBluetoothDev(QStringList); void reportUpdateClient(); void devLoadingTimeoutSlot(); private: /** * @brief * */ // int getDevListIndex(QString address); void bindServiceReportData(); void bindDefaultAdapterReportData(); void serviceChangedDefaultAdapter(int); void getDefaultAdapterDevices(); QStringList m_remainder_loaded_bluetooth_device_address_list ; QTimer * m_loading_dev_timer = nullptr; }; #endif // BLUETOOTHDBUSSERVICE_H ukui-bluetooth/ukcc-bluetooth/translations/0000775000175000017500000000000015167665770020155 5ustar fengfengukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_es.ts0000664000175000017500000003004415167665770024145 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! Bluetooth adapter is abnormal! No Bluetooth adapter detected! No Bluetooth adapter detected! Bluetooth Service init failed! Bluetooth Service init failed! Unknown Bluetooth Error! Unknown Bluetooth Error! Bluetooth Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices Bluetooth Devices /Bluetooth/Bluetooth Devices All All Audio Audio Peripherals Peripherals Computer Computer Phone Phone Other Other BluetoothMiddleWindow My Devices My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Click to change the device name Can now be found as "%1" Can now be found as "%1" BluetoothTopWindow Bluetooth Bluetooth /Bluetooth/Bluetooth Turn on : Turn on: /Bluetooth/Turn on : Adapter List Adapter List /Bluetooth/Adapter List Show icon on taskbar Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices Auto discover Bluetooth audio devices /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Cancel Close bluetooth Close bluetooth DevRemoveDialog Bluetooth Connections Bluetooth Connections After it is removed, the PIN code must be matched for the next connection. After it is removed, the PIN code must be matched for the next connection. close close Remove Remove Cancel Cancel Connection failed! Please remove it before connecting. Connection failed! Please remove it before connecting. Are you sure to remove %1 ? Are you sure to remove %1 ? DevRenameDialog Rename Rename Rename device Rename device close close Name Name The value contains 1 to 32 characters The value contains 1 to 32 characters OK OK Cancel Cancel bluetoothdevicefunc SendFile SendFile Remove Remove Connect Connect Disconnect Disconnect Rename Rename bluetoothdeviceitem unknown unknown Connecting Connecting Disconnecting Disconnecting Not Paired Not Paired Not Connected Not Connected Connected Connected Connect fail,Please try again Connect fail,Please try again Disconnection Fail Disconnection Fail ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_ms.ts0000664000175000017500000003007315167665770024157 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! No Bluetooth adapter detected! Bluetooth Service init failed! Unknown Bluetooth Error! Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices /Bluetooth/Bluetooth Devices All Audio Peripherals Computer Phone Other BluetoothMiddleWindow My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Can now be found as "%1" BluetoothTopWindow Bluetooth /Bluetooth/Bluetooth Turn on : /Bluetooth/Turn on : Adapter List /Bluetooth/Adapter List Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Close bluetooth DevRemoveDialog Bluetooth Connections After it is removed, the PIN code must be matched for the next connection. close Remove Cancel Connection failed! Please remove it before connecting. Are you sure to remove %1 ? DevRenameDialog Rename Rename device close Name The value contains 1 to 32 characters OK Cancel bluetoothdevicefunc SendFile Remove Connect Disconnect Rename bluetoothdeviceitem unknown Connecting Disconnecting Not Paired Not Connected Connected Connect fail,Please try again Disconnection Fail ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_zh_CN.ts0000664000175000017500000003004315167665770024536 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! 蓝牙适配器加载失败! Bluetooth adapter is abnormal! 蓝牙适配器异常! No Bluetooth adapter detected! 未检测到蓝牙适配器! Bluetooth Service init failed! 蓝牙初始化失败! Unknown Bluetooth Error! 未知蓝牙错误! Bluetooth Bluetooth 蓝牙 BluetoothBottomWindow Bluetooth Devices 蓝牙设备 /Bluetooth/Bluetooth Devices All 所有 Audio 音频设备 Peripherals 键鼠设备 Computer 电脑 Phone 手机 Other 其他 BluetoothMiddleWindow My Devices 我的设备 /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name 点击修改设备名称 Can now be found as "%1" 现在可被发现为"%1" BluetoothTopWindow Bluetooth 蓝牙 /Bluetooth/Bluetooth Turn on : 开启: /Bluetooth/Turn on : Adapter List 蓝牙适配器 /Bluetooth/Adapter List Show icon on taskbar 在任务栏显示蓝牙图标 /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices 可被附近的蓝牙设备发现 /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices 自动发现蓝牙音频设备 /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device 蓝牙音频组合设备 After being enabled,the two connected Bluetooth audio devices will play sound simultaneously 启用后,已连接的2台蓝牙音频设备将会同时播放声音 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 正在使用蓝牙鼠标或键盘,是否关闭蓝牙? Cancel 取消 Close bluetooth 关闭蓝牙 DevRemoveDialog Bluetooth Connections 蓝牙连接 After it is removed, the PIN code must be matched for the next connection. 移除后,下一次连接可能需匹配PIN码。 close 关闭 Remove 移除 Cancel 取消 Connection failed! Please remove it before connecting. 连接失败,请先移除后再次连接! Are you sure to remove %1 ? 确定移除"%1"? DevRenameDialog Rename 蓝牙重命名 Rename device 重命名设备 close 关闭 Name 蓝牙设备名称 The value contains 1 to 32 characters 长度必须为 1-32 个字符 OK 确定 Cancel 取消 bluetoothdevicefunc SendFile 发送文件 Remove 移除 Connect 连接 Disconnect 断开 Rename 蓝牙重命名 bluetoothdeviceitem unknown 未知 Connecting 正在连接 Disconnecting 正在断连 Not Paired 未配对 Not Connected 未连接 Connected 已连接 Connect fail,Please try again 连接失败,请重试 Disconnection Fail 断连失败 ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_bo_CN.ts0000664000175000017500000003602415167665770024522 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! བོད་ཡིག་འཕྲིན་བསྡུས་རྒྱབ་པར་ཐུབ་མི་ཐུབ།! Bluetooth adapter is abnormal! སོ་སྔོན་བཀོད་སྒྲིག་ཡོ་ཆས་རྒྱུན་ལྡན་མིན། No Bluetooth adapter detected! ཁ་དོག་སྔོན་པོའི་མཐུན་འཕྲོད་འཕྲུལ་ཆས་ལ་ཞིབ་དཔྱད་ཚད་ལེན་མ་བྱས། Bluetooth Service init failed! བོད་ཡིག་བོད་རིག་འབྲེལ་འགྱུར་བ་ཐུབ་མི་ཐུབ།! Unknown Bluetooth Error! ངའི་བོད་ཡིག་འཕྲིན་བསྡུས་འབྱུང་བར་མ་ཤོག! Bluetooth Bluetooth སོ་སྔོན། BluetoothBottomWindow Bluetooth Devices སྔོ་སོ་སྒྲིག་ཆས། /Bluetooth/Bluetooth Devices All ཚང་མ། Audio སྒྲ་ཕབ། Peripherals མཐའ་སྐོར་གྱི་གནས་ཚུལ། Computer རྩིས་འཁོར། Phone ཁ་པར། Other གཞན་དག BluetoothMiddleWindow My Devices སྒྲིག་ཆས། /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name སྒྲིག་ཆས་ཀྱི་མིང་བསྒྱུར་དགོས། Can now be found as "%1" ད་ལྟ་"%1"ཞེས་པར་བརྩིས་ཆོག BluetoothTopWindow Bluetooth སོ་སྔོན། /Bluetooth/Bluetooth Turn on : སྒོ་འབྱེད།: /Bluetooth/Turn on : Adapter List མཐུན་སྦྱོར་བྱེད་མཁན་གྱི་མིང་ཐོ། /Bluetooth/Adapter List Show icon on taskbar འགན་བྱང་དུ་སོ་སྔོན་རིས་རྟགས་འཆར་བ། /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices ཉེ་འཁོར་གྱི་སོ་སྔོན་སྒྲིག་ཆས་ཀྱི་བཤེར་རུང་བ། /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices རང་འགུལ་གྱིས་སོ་སྔོན།སྒྲིལ་ཆས་རྙེད་པ། /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device སོ་སྔོན་སྒྲ་ཟློས་་སྡེབ་སྒྲིག་སྒྲིག་ཆས། After being enabled,the two connected Bluetooth audio devices will play sound simultaneously སྤྱོད་རྗེས།མཐུད་ཟིན་པའི་སོ་སྔོན་སྒྲ་ཟློས་སྒྲིག་ཆས་2་གྱི་མཉམ་ཏུ་སྒྲ་གཏོང་། Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? སོ་སྔོན། ཀྱི་ཙི་ཙ/ཀียབཌའ ལག་ལེན་བྱེད་སྐབས། ཁྱེད་ སོ་སྔོན། བཀག་བྱེད་འདོད་དམ།? Cancel མེད་པར་བཟོ་དགོས Close bluetooth སྒོ་རྒྱག། སོ་སྔོན། DevRemoveDialog Bluetooth Connections ཁ་དོག་སྔོན་པོའི་འབྲེལ་མཐུད། After it is removed, the PIN code must be matched for the next connection. དེ་མེད་པར་བཟོས་རྗེས་ངེས་པར་དུ་PINཡི་ཚབ་རྟགས་དེ་ཐེངས་རྗེས་མའི་འབྲེལ་མཐུད་ལ་ཆ་འགྲིག་ཡོང་བར་བྱ་དགོས། close ཁ་རྒྱག Remove སྤོ་སྐྱོད་བྱས་པ། Cancel མེད་པར་བཟོ་དགོས Connection failed! Please remove it before connecting. འབྲེལ་མཐུད་བྱེད་མ་ཐུབ་པ་རེད། འབྲེལ་མཐུད་མ་བྱས་གོང་ལ་དེ་མེད་པར་བཟོ་རོགས། Are you sure to remove %1 ? ཁྱེད་རང་གི་གཏན་འཁེལ་གསུབ་ན་འགྲིག་གམ་། %1 ? DevRenameDialog Rename མིང་བསྒྱུར་བ། Rename device སྒྲིག་ཆས་ཀྱི་མིང་བསྒྱུར་བ། close ཁ་རྒྱག Name མིང་། The value contains 1 to 32 characters རིན་ཐང་དེའི་ནང་དུ་ཡི་གེ་1ནས་32བར་ཡོད། OK འགྲིགས། Cancel མེད་པར་བཟོ་དགོས bluetoothdevicefunc SendFile ཡིག་ཆ་ཁ་རྒྱག Remove སྤོ་སྐྱོད་བྱས་པ། Connect སྦྲེལ་མཐུད་བྱེད་པ Disconnect བར་མཚམས་ཆད་པ་རེད། Rename མིང་བསྒྱུར་བ། bluetoothdeviceitem unknown མ་ཤེས་པ། Connecting སྦྲེལ་མཐུད་བྱེད་པ། Disconnecting མཐུད་བཅད་བྱེད་བཞིན་པ། Not Paired ཆ་སྡེབ་མ་བྱེད་པ། Not Connected མ་མཐུད་པ། Connected འབྲེལ་མཐུད་བྱེད་པ། Connect fail,Please try again མཐུད་མ་ཐུབ།ཡང་བསྐྱར་ཚོད་ལྟ་བྱེད་རོགས། Disconnection Fail མཐུད་བཅད་མ་ཐུབ། ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_zh_HK.ts0000664000175000017500000003003315167665770024537 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! 藍牙配接器載入失敗! Bluetooth adapter is abnormal! 藍牙適配器異常! No Bluetooth adapter detected! 未檢測到藍牙適配器! Bluetooth Service init failed! 藍牙初始化失敗! Unknown Bluetooth Error! 未知藍牙錯誤! Bluetooth Bluetooth 藍牙 BluetoothBottomWindow Bluetooth Devices 藍牙設備 /Bluetooth/Bluetooth Devices All 所有 Audio 音訊設備 Peripherals 鍵鼠設備 Computer 電腦 Phone 手機 Other 其他 BluetoothMiddleWindow My Devices 我的設備 /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name 點擊修改設備名稱 Can now be found as "%1" 現在可被發現為“%1” BluetoothTopWindow Bluetooth 藍牙 /Bluetooth/Bluetooth Turn on : 開啟: /Bluetooth/Turn on : Adapter List 藍牙配接器 /Bluetooth/Adapter List Show icon on taskbar 在任務列顯示藍牙圖示 /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices 可被附近的藍牙設備發現 /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices 自動發現藍牙音訊設備 /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device 藍牙音訊組合設備 After being enabled,the two connected Bluetooth audio devices will play sound simultaneously 啟用後,已連接的2台藍牙音訊設備將會同時播放聲音 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 正在使用藍牙滑鼠或鍵盤,是否關閉藍牙? Cancel 取消 Close bluetooth 關閉藍牙 DevRemoveDialog Bluetooth Connections 藍牙連接 After it is removed, the PIN code must be matched for the next connection. 拿掉後,下一次連接可能需匹配PIN碼。 close 關閉 Remove 拿掉 Cancel 取消 Connection failed! Please remove it before connecting. 連接失敗,請先移除后再次連接! Are you sure to remove %1 ? 確定移除「%1」? DevRenameDialog Rename 藍牙重命名 Rename device 重新命名設備 close 關閉 Name 藍牙設備名稱 The value contains 1 to 32 characters 長度必須為 1-32 個字元 OK 確定 Cancel 取消 bluetoothdevicefunc SendFile 發送檔 Remove 拿掉 Connect 連接 Disconnect 斷開 Rename 藍牙重命名 bluetoothdeviceitem unknown 未知 Connecting 正在連接 Disconnecting 正在斷連 Not Paired 未配對 Not Connected 未連接 Connected 已連接 Connect fail,Please try again 連接失敗,請重試 Disconnection Fail 斷連失敗 ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_en_US.ts0000664000175000017500000003004715167665770024552 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! Bluetooth adapter is abnormal! No Bluetooth adapter detected! No Bluetooth adapter detected! Bluetooth Service init failed! Bluetooth Service init failed! Unknown Bluetooth Error! Unknown Bluetooth Error! Bluetooth Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices Bluetooth Devices /Bluetooth/Bluetooth Devices All All Audio Audio Peripherals Peripherals Computer Computer Phone Phone Other Other BluetoothMiddleWindow My Devices My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Click to change the device name Can now be found as "%1" Can now be found as "%1" BluetoothTopWindow Bluetooth Bluetooth /Bluetooth/Bluetooth Turn on : Turn on: /Bluetooth/Turn on : Adapter List Adapter List /Bluetooth/Adapter List Show icon on taskbar Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices Auto discover Bluetooth audio devices /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Cancel Close bluetooth Close bluetooth DevRemoveDialog Bluetooth Connections Bluetooth Connections After it is removed, the PIN code must be matched for the next connection. After it is removed, the PIN code must be matched for the next connection. close close Remove Remove Cancel Cancel Connection failed! Please remove it before connecting. Connection failed! Please remove it before connecting. Are you sure to remove %1 ? Are you sure to remove %1 ? DevRenameDialog Rename Rename Rename device Rename device close close Name Name The value contains 1 to 32 characters The value contains 1 to 32 characters OK OK Cancel Cancel bluetoothdevicefunc SendFile SendFile Remove Remove Connect Connect Disconnect Disconnect Rename Rename bluetoothdeviceitem unknown unknown Connecting Connecting Disconnecting Disconnecting Not Paired Not Paired Not Connected Not Connected Connected Connected Connect fail,Please try again Connect fail,Please try again Disconnection Fail Disconnection Fail ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_zh_Hant.ts0000664000175000017500000003003315167665770025127 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! 藍牙配接器載入失敗! Bluetooth adapter is abnormal! 藍牙適配器異常! No Bluetooth adapter detected! 未檢測到藍牙適配器! Bluetooth Service init failed! 藍牙初始化失敗! Unknown Bluetooth Error! 未知藍牙錯誤! Bluetooth Bluetooth 藍牙 BluetoothBottomWindow Bluetooth Devices 藍牙設備 /Bluetooth/Bluetooth Devices All 所有 Audio 音訊設備 Peripherals 鍵鼠設備 Computer 電腦 Phone 手機 Other 其他 BluetoothMiddleWindow My Devices 我的設備 /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name 點擊修改設備名稱 Can now be found as "%1" 現在可被發現為“%1” BluetoothTopWindow Bluetooth 藍牙 /Bluetooth/Bluetooth Turn on : 開啟: /Bluetooth/Turn on : Adapter List 藍牙配接器 /Bluetooth/Adapter List Show icon on taskbar 在任務列顯示藍牙圖示 /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices 可被附近的藍牙設備發現 /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices 自動發現藍牙音訊設備 /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device 藍牙音訊組合設備 After being enabled,the two connected Bluetooth audio devices will play sound simultaneously 啟用後,已連接的2台藍牙音訊設備將會同時播放聲音 Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? 正在使用藍牙滑鼠或鍵盤,是否關閉藍牙? Cancel 取消 Close bluetooth 關閉藍牙 DevRemoveDialog Bluetooth Connections 藍牙連接 After it is removed, the PIN code must be matched for the next connection. 拿掉後,下一次連接可能需匹配PIN碼。 close 關閉 Remove 拿掉 Cancel 取消 Connection failed! Please remove it before connecting. 連接失敗,請先移除后再次連接! Are you sure to remove %1 ? 確定移除「%1」? DevRenameDialog Rename 藍牙重命名 Rename device 重新命名設備 close 關閉 Name 藍牙設備名稱 The value contains 1 to 32 characters 長度必須為 1-32 個字元 OK 確定 Cancel 取消 bluetoothdevicefunc SendFile 發送檔 Remove 拿掉 Connect 連接 Disconnect 斷開 Rename 藍牙重命名 bluetoothdeviceitem unknown 未知 Connecting 正在連接 Disconnecting 正在斷連 Not Paired 未配對 Not Connected 未連接 Connected 已連接 Connect fail,Please try again 連接失敗,請重試 Disconnection Fail 斷連失敗 ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_de.ts0000664000175000017500000002071515167665770024132 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! No Bluetooth adapter detected! 未检测到蓝牙适配器! Bluetooth Service init failed! Unknown Bluetooth Error! Bluetooth Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices /Bluetooth/Bluetooth Devices All Audio Peripherals Computer Phone Other BluetoothMiddleWindow My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Klicken Sie hier, um den Gerätenamen zu ändern Can now be found as "%1" Kann jetzt als "%1" gefunden werden BluetoothTopWindow Bluetooth Bluetooth /Bluetooth/Bluetooth Turn on : 开启 /Bluetooth/Turn on : Adapter List 蓝牙适配器 /Bluetooth/Adapter List Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices Automatische Erkennung von Bluetooth-Audiogeräten /Bluetooth/Auto discover Bluetooth audio devices Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Abbrechen Close bluetooth Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously DevRemoveDialog Bluetooth Connections Bluetooth-Verbindungen After it is removed, the PIN code must be matched for the next connection. Nach dem Entfernen muss der PIN-Code für die nächste Verbindung abgeglichen werden. Remove Entfernen Cancel Abbrechen Connection failed! Please remove it before connecting. Verbindung fehlgeschlagen! Bitte entfernen Sie es, bevor Sie es verbinden. Are you sure to remove %1 ? Sind Sie sicher, %1 zu entfernen? close DevRenameDialog Rename Umbenennen Name Name The value contains 1 to 32 characters Der Wert enthält 1 bis 32 Zeichen OK OKAY Cancel Abbrechen Rename device close bluetoothdevicefunc SendFile Remove Entfernen Connect Disconnect Rename Umbenennen bluetoothdeviceitem Connecting Verbindend Disconnecting Trennend Not Connected Nicht verbunden Connected Verbunden unknown Not Paired Connect fail,Please try again Disconnection Fail ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_kk.ts0000664000175000017500000003275215167665770024153 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! كوك تىس ۇيلەستىرۋ تۇسىرۋ جەڭىلىپ قالدى! Bluetooth adapter is abnormal! كوك تىس ۇيلەستىرۋ بينورمال! No Bluetooth adapter detected! كوك تىس ۇيلەستىرۋ بايقالمادٸ! Bluetooth Service init failed! كوك تىس قىزىمەتتى باستاپ كەلتىرۋ جەڭىلىپ قالدى! Unknown Bluetooth Error! كۋالىك كوك تىس قاتەلىگى! Bluetooth Bluetooth بليۇتووت BluetoothBottomWindow Bluetooth Devices كوك تىس اسپابٸ /Bluetooth/Bluetooth Devices All بارلٸق Audio ۇن Peripherals كىنوپكا تاتيس تاقىرىپ اسپابٸ Computer كومپيۋتەر Phone تەلەفون Other باسقا BluetoothMiddleWindow My Devices مەنىڭ ئۈسكۈنەم /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name باسٸپ تۇرٸپ اسبابٸتٸڭ ەسىمىن وزگەرتۋ Can now be found as "%1" قازىر بايقىغىنى بولادٸ 1% BluetoothTopWindow Bluetooth بليۇتووت /Bluetooth/Bluetooth Turn on : ٸشٸۋ /Bluetooth/Turn on : Adapter List كوك ٴتىسىن سايكەستىرۋ اسپابٸ /Bluetooth/Adapter List Show icon on taskbar مىندەتتى ستونىندا كوك تىستەرى بەلگٸسٸن كورسەتۋ /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices جيىن توڭٸرەكتٸ كوك تىس اسپاپتارىنىڭ اشۋ جول قويۋ /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices كوك تىس دىبس ۇلعايتقىش اسبابٸن اۆتوماتتى باقىلاۋ /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device بليۇتووت ۇن بٸرٸكپە اسپابٸ After being enabled,the two connected Bluetooth audio devices will play sound simultaneously قوزعالتىلعاننان كەيىن، جالعانعان ەكٸ بليۇتووت اۋا اسپابٸ بٸرەۋ ۋاقىتتا اۋا قويادى Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? بليۇتووت تاقىرىپ ياكي كىنوپكا تاقتاسٸن ٸستەتٸپ، بليۇتووتنى ئېتىۋەتمەكچىمۇ؟ Cancel كۇشىنەن قالدىرۋ Close bluetooth بليۇتووت تاقاۋ DevRemoveDialog Bluetooth Connections كوك تىس اۋلاۋ After it is removed, the PIN code must be matched for the next connection. شعارىپ ەتكەننەن كەيىن، كەلەر رەت جالعاماقشٸ بولساڭٸز قايتادان ماشينكالاۋ نومەرى PIN نومەرىنى كىرگىزۋىڭىز مۇمكان close جابۋ Remove شىعارىپ وتۋ Cancel كۇشىنەن قالدىرۋ Connection failed! Please remove it before connecting. جالعانۋ جەڭىلىپ قالدى، الدٸمەن شعارىپ ەتكەننەن كەيىن، سونان قايتادان جالعاۋلٸ Are you sure to remove %1 ? 1%نى وشىرۋ كەسٸم جاسايسٸزبە؟ DevRenameDialog Rename قاتە ات فاميليا ەتۋ Rename device اسبابٸتٸڭ ەسىمىن قايتادان وزگەرتۋ close جابۋ Name مى The value contains 1 to 32 characters ۇزىندىعى ٴسوزسٸز 1دان 32 دەيىن بولعان ٴارىپ بولۋٸ كەرەك OK ماقۇل Cancel كۇشىنەن قالدىرۋ bluetoothdevicefunc SendFile حۇجات جولداۋ Remove شىعارىپ وتۋ Connect اۋلاۋ Disconnect جالعانۋٸن ۇزارتىۋ Rename قاتە ات فاميليا ەتۋ bluetoothdeviceitem unknown كۋالىك Connecting جالعانٸپ جاتٸر Disconnecting ٷزٸلٸپ قالدى Not Paired ماشلاشتۇرۇلمىدى Not Connected جالعاۋنبادٸ Connected جالعاندٸ Connect fail,Please try again جالعانۋ جەڭىلىپ قالدى، قايتادان سىناڭ Disconnection Fail ٷزۋ جەڭىلىپ قالدى ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_mn.ts0000664000175000017500000003603315167665770024154 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠠᠪᠴᠠᠯᠳᠤᠬᠤ ᠬᠡᠷᠡᠭᠰᠡᠯ ᠢ᠋ ᠠᠴᠢᠶᠠᠯᠠᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ! Bluetooth adapter is abnormal! ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠠᠪᠴᠠᠯᠳᠤᠬᠤ ᠬᠡᠷᠡᠭᠰᠡᠯ ᠬᠡᠪ ᠤ᠋ᠨ ᠪᠤᠰᠤ! No Bluetooth adapter detected! ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠠᠪᠴᠠᠯᠳᠤᠬᠤ ᠬᠡᠷᠡᠭᠰᠡᠯ ᠢ᠋ ᠬᠢᠨᠠᠨ ᠬᠡᠮᠵᠢᠵᠤ ᠤᠯᠤᠭᠰᠠᠨ ᠥᠬᠡᠢ! Bluetooth Service init failed! ᠯᠠᠨᠶᠠ ᠵᠢ ᠠᠩᠬᠠᠵᠢᠭᠤᠯᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ! Unknown Bluetooth Error! ᠦᠯᠦ ᠮᠡᠳᠡᠬᠦ ᠯᠠᠨᠶᠠ ᠪᠤᠷᠤᠭᠤ! Bluetooth Bluetooth ᠯᠠᠨᠶᠠ BluetoothBottomWindow Bluetooth Devices ᠯᠠᠨᠶᠠ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ /Bluetooth/Bluetooth Devices All ᠪᠦᠬᠦᠢᠯᠡ Audio ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ Peripherals ᠳᠠᠷᠤᠪᠴᠢ ᠬᠤᠯᠤᠭᠠᠨᠴᠢᠷ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ Computer ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ Phone ᠭᠠᠷ ᠤᠳᠠᠰᠤ Other ᠪᠤᠰᠤᠳ BluetoothMiddleWindow My Devices ᠮᠢᠨᠦ ᠲᠥᠬᠥᠭᠡᠷᠦᠮᠵᠢ /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name ᠳᠤᠪᠰᠢᠵᠤ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠢᠨ ᠨᠡᠷ᠎ᠡ ᠵᠢ ᠰᠤᠯᠢᠬᠤ Can now be found as "%1" ᠤᠳᠤ ᠪᠡᠷ ᠢᠯᠡᠷᠡᠬᠦᠯᠵᠤ ᠪᠤᠯᠬᠤ "%1" BluetoothTopWindow Bluetooth ᠯᠠᠨᠶᠠ /Bluetooth/Bluetooth Turn on : ᠨᠡᠭᠡᠭᠡᠬᠦ: /Bluetooth/Turn on : Adapter List ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠠᠪᠴᠠᠯᠳᠤᠬᠤ ᠬᠡᠷᠡᠭᠰᠡᠯ /Bluetooth/Adapter List Show icon on taskbar ᠡᠬᠦᠷᠬᠡ ᠵᠢᠨ ᠪᠠᠭᠠᠷ ᠲᠤ᠌ ᠯᠠᠨᠶᠠ ᠵᠢᠨ ᠢᠺᠦᠨ ᠵᠢᠷᠤᠭ ᠢ᠋ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices ᠤᠢᠷ᠎ᠠ ᠬᠠᠪᠢ ᠵᠢᠨ ᠯᠠᠨᠶᠠ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠳ᠋ᠤ᠌ ᠮᠡᠳᠡᠭᠳᠡᠬᠦ /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices ᠯᠠᠨᠶᠠ ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠢ ᠠᠦ᠋ᠲ᠋ᠣ᠋ ᠪᠡᠷ ᠢᠯᠡᠷᠡᠬᠦᠯᠬᠦ /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device ᠯᠠᠨᠶᠠ ᠠᠦ᠋ᠳᠢᠤ᠋ ᠬᠠᠮᠰᠠᠯ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ After being enabled,the two connected Bluetooth audio devices will play sound simultaneously ᠡᠬᠢᠯᠡᠬᠦᠯᠦᠭᠰᠡᠨ ᠤ᠋ ᠳᠠᠷᠠᠭ᠎ᠠ᠂ ᠨᠢᠭᠡᠨᠳᠡ ᠵᠠᠯᠭᠠᠭᠰᠠᠨ2 ᠯᠠᠨᠶᠠ ᠠᠦ᠋ᠳᠢᠤ᠋ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠡᠷᠭᠡ ᠪᠡᠷ ᠨᠡᠪᠳᠡᠷᠡᠬᠦᠯᠦᠨ᠎ᠡ Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? ᠤᠳᠤ ᠶᠠᠭ ᠯᠠᠨᠶᠠ ᠬᠤᠯᠤᠭᠠᠨᠴᠢᠷ ᠪᠤᠶᠤ ᠳᠠᠷᠤᠭᠤᠯ ᠤ᠋ᠨ ᠳᠠᠪᠠᠭ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠵᠤ ᠪᠠᠢᠨ᠎ᠠ᠂ ᠯᠠᠨᠶᠠ ᠵᠢ ᠬᠠᠭᠠᠬᠤ ᠤᠤ? Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ Close bluetooth ᠯᠠᠨᠶᠠ ᠵᠢ ᠬᠠᠭᠠᠬᠤ DevRemoveDialog Bluetooth Connections ᠯᠠᠨᠶᠠ ᠵᠢ ᠵᠠᠯᠭᠠᠪᠠ After it is removed, the PIN code must be matched for the next connection. ᠰᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠤᠰᠠᠳᠬᠠᠭᠰᠠᠨ ᠤ᠋ ᠳᠠᠷᠠᠭ᠎ᠠ᠂ ᠳᠠᠬᠢᠭᠠᠳ ᠴᠦᠷᠬᠡᠯᠡᠬᠦ ᠳ᠋ᠤ᠌ PIN ᠺᠤᠳ᠋ ᠲᠠᠢ ᠠᠪᠤᠴᠠᠯᠳᠤᠬᠤ ᠬᠡᠷᠡᠭᠳᠡᠢ᠃ close ᠬᠠᠭᠠᠬᠤ Remove ᠰᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠬᠠᠰᠤᠬᠤ Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ Connection failed! Please remove it before connecting. ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠦᠬᠡᠢ᠂ ᠤᠰᠠᠳᠬᠠᠭᠰᠠᠨ ᠤ᠋ ᠳᠠᠷᠠᠭ᠎ᠠ ᠳᠠᠬᠢᠭᠠᠳ ᠴᠦᠷᠬᠡᠯᠡᠬᠡᠷᠡᠢ᠃ Are you sure to remove %1 ? %1 ᠵᠢ/ ᠢ᠋ ᠯᠠᠪᠳᠠᠢ ᠤᠰᠠᠳᠬᠠᠬᠤ ᠤᠤ? DevRenameDialog Rename ᠯᠠᠨᠶᠠ ᠵᠢ ᠳᠠᠬᠢᠵᠤ ᠨᠡᠷᠡᠯᠡᠬᠦ Rename device ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠢ ᠳᠠᠬᠢᠵᠤ ᠨᠡᠷᠡᠢᠳᠬᠦ close ᠬᠠᠭᠠᠬᠤ Name ᠯᠠᠨᠶᠠ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ ᠵᠢᠨ ᠨᠡᠷᠡᠢᠳᠦᠯ The value contains 1 to 32 characters ᠤᠷᠳᠤ ᠨᠢ ᠡᠷᠬᠡᠪᠰᠢ 1-32 ᠦᠰᠦᠭ ᠪᠠᠢᠬᠤ ᠬᠡᠷᠡᠭᠳᠡᠢ OK ᠪᠠᠳᠤᠯᠠᠬᠤ Cancel ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌ bluetoothdevicefunc SendFile ᠹᠠᠢᠯ ᠢᠯᠡᠬᠡᠬᠦ Remove ᠰᠢᠯᠵᠢᠬᠦᠯᠦᠨ ᠬᠠᠰᠤᠬᠤ Connect ᠴᠦᠷᠬᠡᠯᠡᠬᠦ Disconnect ᠳᠠᠰᠤᠯᠬᠤ Rename ᠯᠠᠨᠶᠠ ᠵᠢ ᠳᠠᠬᠢᠵᠤ ᠨᠡᠷᠡᠯᠡᠬᠦ bluetoothdeviceitem unknown ᠦᠯᠦ ᠮᠡᠳᠡᠬᠦ Connecting ᠴᠦᠷᠬᠡᠯᠡᠵᠤ ᠪᠠᠢᠨ᠎ᠠ Disconnecting ᠴᠦᠷᠬᠡᠯᠡᠬᠡ ᠵᠢ ᠳᠠᠰᠤᠯᠵᠤ ᠪᠠᠢᠨ᠎ᠠ Not Paired ᠠᠪᠴᠠᠯᠳᠤᠭᠰᠠᠨ ᠦᠭᠡᠶ Not Connected ᠴᠦᠷᠬᠡᠯᠡᠬᠡ ᠥᠬᠡᠢ Connected ᠵᠠᠯᠭᠠᠪᠠ Connect fail,Please try again ᠵᠠᠯᠠᠭᠠᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ᠂ ᠳᠠᠬᠢᠵᠤ ᠳᠤᠷᠰᠢᠭᠠᠷᠠᠢ Disconnection Fail ᠵᠠᠯᠭᠠᠬᠤ ᠵᠢ ᠳᠠᠰᠤᠯᠵᠤ ᠴᠢᠳᠠᠭᠰᠠᠨ ᠥᠬᠡᠢ ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_fr.ts0000664000175000017500000003063415167665770024152 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! No Bluetooth adapter detected! 未检测到蓝牙适配器! Bluetooth Service init failed! Unknown Bluetooth Error! Bluetooth Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices /Bluetooth/Bluetooth Devices All Audio Peripherals Computer Phone Other BluetoothMiddleWindow My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Cliquez pour modifier le nom de l’appareil Can now be found as "%1" Peut maintenant être trouvé sous la forme « %1 » BluetoothTopWindow Bluetooth Bluetooth /Bluetooth/Bluetooth Turn on : 开启 /Bluetooth/Turn on : Adapter List 蓝牙适配器 /Bluetooth/Adapter List Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices Détection automatique des périphériques audio Bluetooth /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Annuler Close bluetooth DevRemoveDialog Bluetooth Connections Connexions Bluetooth After it is removed, the PIN code must be matched for the next connection. Une fois qu’il est supprimé, le code PIN doit être mis en correspondance pour la prochaine connexion. close Remove Enlever Cancel Annuler Connection failed! Please remove it before connecting. Echec de la connexion ! Veuillez le retirer avant de vous connecter. Are you sure to remove %1 ? Êtes-vous sûr de supprimer %1 ? DevRenameDialog Rename Renommer Rename device close Name Nom The value contains 1 to 32 characters La valeur contient de 1 à 32 caractères OK D’ACCORD Cancel Annuler bluetoothdevicefunc SendFile Remove Enlever Connect Disconnect Rename Renommer bluetoothdeviceitem unknown Connecting Connectant Disconnecting Déconnexion Not Paired Not Connected Non connecté Connected Relié Connect fail,Please try again Disconnection Fail ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_vi.ts0000664000175000017500000003123315167665770024155 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Tải bộ điều hợp Bluetooth không thành công! Bluetooth adapter is abnormal! Bộ điều hợp Bluetooth bị lỗi! No Bluetooth adapter detected! Không phát hiện bộ điều hợp Bluetooth! Bluetooth Service init failed! Dịch vụ Bluetooth khởi tạo không thành công! Unknown Bluetooth Error! Lỗi Bluetooth chưa xác định! Bluetooth Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices Thiết bị Bluetooth /Bluetooth/Bluetooth Devices All Tất cả Audio Âm thanh Peripherals Thiết bị bàn phím và chuột Computer Máy tính Phone Điện thoại Other Khác BluetoothMiddleWindow My Devices Thiết bị của tôi /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Nhấp để thay đổi tên thiết bị Can now be found as "%1" Hiện tại có thể tìm thấy được là "%1" BluetoothTopWindow Bluetooth Bluetooth /Bluetooth/Bluetooth Turn on : Bật: /Bluetooth/Turn on : Adapter List Danh sách bộ chuyển đổi /Bluetooth/Adapter List Show icon on taskbar Hiển thị biểu tượng Bluetooth trên thanh tác vụ /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices Có thể được các thiết bị Bluetooth gần đây tìm thấy /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices Tự động khám phá thiết bị âm thanh Bluetooth /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device Thiết bị kết hợp âm thanh Bluetooth After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Sau khi được bật, hai thiết bị âm thanh Bluetooth được kết nối sẽ phát âm thanh đồng thời Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Đang sử dụng chuột Bluetooth hoặc bàn phím , có tắt Bluetooth không? Cancel Hủy Close bluetooth Tắt bluetooth DevRemoveDialog Bluetooth Connections Kết nối Bluetooth After it is removed, the PIN code must be matched for the next connection. Sau khi nó được xóa, mã PIN phải được khớp cho kết nối tiếp theo. close đóng Remove Triệt Cancel Hủy Connection failed! Please remove it before connecting. Kết nối thất bại, vui lòng gỡ bỏ trước, sau đó kết nối lại. Are you sure to remove %1 ? Bạn có chắc chắn xóa %1 không? DevRenameDialog Rename Đổi tên Bluetooth Rename device Đổi tên thiết bị close Thoát Name Tên The value contains 1 to 32 characters Độ dài phải từ 1 đến 32 ký tự OK Chắc chắc Cancel Hủy bluetoothdevicefunc SendFile Gửi tệp Remove Xóa Connect Kết nối Disconnect Ngắt Rename Đổi tên Bluetooth bluetoothdeviceitem unknown không biết Connecting Đang kết nối Disconnecting Đang ngắt kết nối Not Paired Không được ghép nối Not Connected Chưa kết nối Connected Đã kết nối Connect fail,Please try again Kết nối thất bại ,vui lòng thử lại Disconnection Fail Ngắt kết nối thất bại ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_ug.ts0000664000175000017500000003313215167665770024152 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! كۆك چىش ماسلاشتۇرغۇچ قاچىلاش مەغلۇپ بولدى! Bluetooth adapter is abnormal! كۆك چىش ماسلاشتۇرغۇچ بىنورمال! No Bluetooth adapter detected! كۆك چىش ماسلاشتۇرغۇچ بايقالمىدى! Bluetooth Service init failed! كۆك چىش مۇلازىمىتىنى دەسلەپلەشتۈرۈش مەغلۇپ بولدى! Unknown Bluetooth Error! نامەلۇم كۆك چىش خاتالىقى! Bluetooth Bluetooth كۆكچىش BluetoothBottomWindow Bluetooth Devices كۆك چىش ئۈسكۈنىسى /Bluetooth/Bluetooth Devices All ھەممە Audio ئاۋاز Peripherals كۇنۇپكا تاىتىسى مائۇس ئۈسكۈنىسى Computer ھېسابلىغۇچ Phone تېلېفون Other باشقا BluetoothMiddleWindow My Devices مېنىڭ ئۈسكۈنەم /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name چىكىپ تۇرۇپ ئۈسكۈنىنىڭ ئىسمىنى ئۆزگەرتىش Can now be found as "%1" ھازىر بايقىغىنى بولىدۇ 1% BluetoothTopWindow Bluetooth كۆكچىش /Bluetooth/Bluetooth Turn on : ئېچىش /Bluetooth/Turn on : Adapter List كۆك چىشنى ماسلاشتۇرۇش ئۈسكۈنىسى /Bluetooth/Adapter List Show icon on taskbar ۋەزىپە ئىستونىدا كۆك چىشنىڭ بەلگىسىنى كۆرسىتىش /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices يىقىن ئەتراپتىكى كۆك چىش ئۈسكۈنىلىرىنىڭ بايقىشىغا يول قويۇش /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices كۆك چىش ياڭراتقۇ ئۈسكۈنىسىنى ئاپتوماتىك بايقاش /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device كۆكچىش ئۈن بىرىكمە ئۈسكۈنىسى After being enabled,the two connected Bluetooth audio devices will play sound simultaneously قوزغىتىلغاندىن كېيىن، ئۇلانغان ئىككى كۆكچىش ئاۋاز ئۈسكۈنىسى بىرلا ۋاقىتتا ئاۋاز قويىدۇ Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? كۆكچىش مائۇس ياكى كۇنۇپكا تاختىسىنى ئىشلىتىپ، كۆكچىشنى ئېتىۋەتمەكچىمۇ؟ Cancel ئەمەلدىن قالدۇرۇش Close bluetooth كۆكچىشنى تاقاش DevRemoveDialog Bluetooth Connections كۆك چىشقا ئۇلاش After it is removed, the PIN code must be matched for the next connection. چىقىرىۋەتكەندىن كېيىن، كېلەر قېتىم ئۇلىماقچى بولسىڭىز قايتىدىن ماشلاشتۇرۇش نومۇرى PIN نومۇرىنى كىرگۈزىشىڭىز مۇمكىن close ياپ Remove 删除 Cancel ئەمەلدىن قالدۇرۇش Connection failed! Please remove it before connecting. ئۇلىنىش مەغلۇپ بولدى، ئاۋۋال چىقىرىۋەتكەندىن كېيىن، ئاندىن قايتىدىن ئۇلاڭ Are you sure to remove %1 ? 1%نى چىقىرىۋىتىشنى جەزىملەشتۈرەمسىز؟ DevRenameDialog Rename قايتا ئىسىم فامىلە قىلىش Rename device ئۈسكۈنىنىڭ ئىسمىنى قايتىدىن ئۆزگەرتىش close ياپ Name نامى The value contains 1 to 32 characters ئۇزۇنلىقى چوقۇم 1دىن 32 گىچە بولغان خەت بولۇشى كېرەك OK جەزملەشتۈرۈش Cancel ئەمەلدىن قالدۇرۇش bluetoothdevicefunc SendFile ھۆججەت يوللاش Remove 删除 Connect ئۇلىنىش Disconnect ئۇلىنىش ئۈزۈلدى Rename قايتا ئىسىم فامىلە قىلىش bluetoothdeviceitem unknown نامەلۇم Connecting ئۇلىنىۋاتىدۇ Disconnecting ئۈزۈلۈپ قالدى Not Paired ماشلاشتۇرۇلمىدى Not Connected ئۇلانمىدى Connected ئۇلاندى Connect fail,Please try again ئۇلىنىش مەغلۇپ بولدى، قايتىدىن سىناڭ Disconnection Fail ئۈزۈش مەغلۇپ بولدى ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_ky.ts0000664000175000017500000003305015167665770024161 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! كۅك تىش شايكەشتىرگىچ قاچالوو جەڭىلۉۉ بولدۇ ! Bluetooth adapter is abnormal! كۅك تىش شايكەشتىرگىچ بۅتۅنچۅ! No Bluetooth adapter detected! كۅك تىش شايكەشتىرگىچ بايقالبادى! Bluetooth Service init failed! كۅك تىش مۇلازىمەتىردى العاچقىلاشتىرۇۇ جەڭىلۉۉ بولدۇ ! Unknown Bluetooth Error! بەلگىسىز كۅك تىش قاتالىعى! Bluetooth Bluetooth بليۇتۇز BluetoothBottomWindow Bluetooth Devices كۅك تىش جابدۇۇسۇ /Bluetooth/Bluetooth Devices All باردىق Audio دوبۇش Peripherals كۇنۇپكا تاتئس ماۇس جابدۇۇسۇ Computer ەسەپتەگۉچ Phone تەلەفون Other باشقا BluetoothMiddleWindow My Devices مەنىن ئۈسكۈنەم /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name چەگىپ تۇرۇپ جابدۇۇسۇنۇن اتىن ۅزگۅرتۉش Can now be found as "%1" ازىر بايقىغىنى بولوت 1% BluetoothTopWindow Bluetooth بليۇتۇز /Bluetooth/Bluetooth Turn on : اچۇۇ /Bluetooth/Turn on : Adapter List كۅك تئش شايكەشتىرىپ جابدۇۇسۇ /Bluetooth/Adapter List Show icon on taskbar مىلدەت قۇرۇندا كۅك تىشتەر. ەنىن كۅرسۅتۉۉ /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices جاقىن ايلاناداعى كۅك تىش جابدۇۇلار. اچىلىش. جول قويۇش /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices كۅك تىش جاڭىرتقى جابدۇۇسۇن اپتوماتتىك بايقوو /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device بليۇتۇز دوبۇش بىرىكمە جابدۇۇسۇ After being enabled,the two connected Bluetooth audio devices will play sound simultaneously قوزعوتۇلعاندان كىيىن، جالعانعان ەكى بليۇتۇز دووش جابدۇۇسۇ بىر ەلە ۇباقىتتا دووش قويوت Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? بليۇتۇز ماۇس كۅرۉنۉشتۅرۉ كۇنۇپكا تاقتاسىن ىشتەتىپ، بليۇتۇزنى ئېتىۋەتمەكچىمۇ؟ Cancel ارعادان قالتىرىش Close bluetooth بليۇتۇز بەكىتىش DevRemoveDialog Bluetooth Connections كۅك تئش ۇلوو After it is removed, the PIN code must be matched for the next connection. چىقىرىۋەتكەندىن كىيىن، گەلەەر ىرەت ۇلاماقچى بولسوڭۇز قايتادان ىشتەتۉۉ نومۇرۇ PIN نومۇرۇ نى كىرگىزۉۉڭۉز مۉمكۉن close بەكىتىش Remove چىعارۇۇ Cancel ارعادان قالتىرىش Connection failed! Please remove it before connecting. ۇلانۇۇ جەڭىلۉۉ بولدۇ ، الدىن چىقىرىۋەتكەندىن كىيىن، اندان قايتادان ۇلاڭ Are you sure to remove %1 ? 1%نى ۅچۉرۉۉ بەكىتەسىزبى؟ DevRenameDialog Rename اتىن ۅزگۅرتۉش Rename device جابدۇۇسۇنۇن اتىن قايتادان ۅزگۅرتۉش close بەكىتىش Name ات-تەك اتى The value contains 1 to 32 characters ۇزۇندۇعۇ سۅزسۉز 1نان 32 گىچە بولعون قات بولۇۇسۇ كەرەك OK بەكىتۉۉ Cancel ارعادان قالتىرىش bluetoothdevicefunc SendFile ۅجۅت جولدوو Remove چىعارۇۇ Connect ۇلانۇۇ Disconnect ۇلانۇۇسۇن ۉزۉپ اتۇۇ Rename اتىن ۅزگۅرتۉش bluetoothdeviceitem unknown بەلگىسىز Connecting ۇلانىپ جاتات Disconnecting ۉزۉلۉپ قالدى Not Paired ماشلاشتۇرۇلمىدى Not Connected ۇلانبادى Connected ۇلاندى Connect fail,Please try again ۇلانۇۇ جەڭىلۉۉ بولدۇ ، قايتادان سىناڭ Disconnection Fail ۉزۉۉ جەڭىلۉۉ بولدۇ ukui-bluetooth/ukcc-bluetooth/translations/ukcc-bluetooth_ar.ts0000664000175000017500000003007315167665770024142 0ustar fengfeng BlueToothMainWindow Bluetooth Adapter loading Failed! Bluetooth adapter is abnormal! No Bluetooth adapter detected! Bluetooth Service init failed! Unknown Bluetooth Error! Bluetooth Bluetooth BluetoothBottomWindow Bluetooth Devices /Bluetooth/Bluetooth Devices All Audio Peripherals Computer Phone Other BluetoothMiddleWindow My Devices /Bluetooth/My Devices BluetoothNameLabel Click to change the device name Double-click to change the device name Can now be found as "%1" BluetoothTopWindow Bluetooth /Bluetooth/Bluetooth Turn on : /Bluetooth/Turn on : Adapter List /Bluetooth/Adapter List Show icon on taskbar /Bluetooth/Show icon on taskbar Discoverable by nearby Bluetooth devices /Bluetooth/Discoverable by nearby Bluetooth devices Auto discover Bluetooth audio devices /Bluetooth/Auto discover Bluetooth audio devices Bluetooth Audio Combination Device After being enabled,the two connected Bluetooth audio devices will play sound simultaneously Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth? Cancel Close bluetooth DevRemoveDialog Bluetooth Connections After it is removed, the PIN code must be matched for the next connection. close Remove Cancel Connection failed! Please remove it before connecting. Are you sure to remove %1 ? DevRenameDialog Rename Rename device close Name The value contains 1 to 32 characters OK Cancel bluetoothdevicefunc SendFile Remove Connect Disconnect Rename bluetoothdeviceitem unknown Connecting Disconnecting Not Paired Not Connected Connected Connect fail,Please try again Disconnection Fail ukui-bluetooth/ukcc-bluetooth/loadinglabel.cpp0000664000175000017500000000610515167665755020562 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "loadinglabel.h" LoadingLabel::LoadingLabel(QObject *parent) { m_timer = new QTimer(this); m_timer->setInterval(100); connect(m_timer,&QTimer::timeout,this,&LoadingLabel::refreshIconNum); initGsettings(); } LoadingLabel::~LoadingLabel() { if (m_timer) m_timer->deleteLater(); } void LoadingLabel::setTimerStop() { m_timer->stop(); } void LoadingLabel::setTimerStart() { if (!m_timer->isActive()) { index = 0; m_timer->start(); } } void LoadingLabel::setTimeReresh(int m) { m_timer->setInterval(m); } void LoadingLabel::paintEvent(QPaintEvent *e) { QPainter painter(this); painter.setRenderHint(QPainter::SmoothPixmapTransform); painter.setPen(Qt::transparent); if (_themeIsBlack) painter.drawImage(0,0, ukccbluetoothconfig::loadSvgImage(QIcon::fromTheme("ukui-loading-"+QString("%1").arg(index)+"-symbolic").pixmap(this->width(),this->height()),ukccbluetoothconfig::WHITE), 0,0,-1,-1,Qt::ColorMode_Mask); else painter.drawPixmap(0,0,this->width(),this->height(),QIcon::fromTheme("ukui-loading-"+QString("%1").arg(index)+"-symbolic").pixmap(this->width(),this->height())); } void LoadingLabel::refreshIconNum() { index++; if(index > 7 || index < 0) index = 0; this->update(); } void LoadingLabel::initGsettings() { // qWarning()<< Q_FUNC_INFO << __LINE__; if (QGSettings::isSchemaInstalled(GSETTING_UKUI_STYLE)) { _mStyle_GSettings = new QGSettings(GSETTING_UKUI_STYLE); if(_mStyle_GSettings->get("styleName").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") _themeIsBlack = false; else _themeIsBlack = true; //_mIconThemeName = _mStyle_GSettings->get("iconThemeName").toString(); } connect(_mStyle_GSettings,&QGSettings::changed,this,&LoadingLabel::mStyle_GSettingsSlot); } void LoadingLabel::mStyle_GSettingsSlot(const QString &key) { // qWarning()<< Q_FUNC_INFO << key << __LINE__; if ("styleName" == key || "style-name" == key) { if(_mStyle_GSettings->get("style-name").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") { _themeIsBlack = false; } else { _themeIsBlack = true; } } } ukui-bluetooth/ukcc-bluetooth/ukcc-bluetooth.pro0000664000175000017500000000667115167665770021120 0ustar fengfengQT += gui dbus include(../environment.pri) greaterThan(QT_MAJOR_VERSION, 4): QT += widgets dbus TEMPLATE = lib CONFIG += plugin \ c++11 \ link_pkgconfig INCLUDEPATH += /usr/include/KF6/KWindowSystem PKGCONFIG += gsettings-qt6 \ kysdk-qtwidgets \ kysdk-waylandhelper \ kysdk-sysinfo \ x11 \ xi LIBS += -lukcc CONFIG(release, debug|release) { !system($$PWD/translate_generation.sh): error("Failed to generate translation") } # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += UKCC_BLUETOOTH_DATA_BURIAL_POINT DEFINES += QT_NO_INFO_OUTPUT DEFINES += QT_NO_DEBUG_OUTPUT #exists(/etc/apt/ota_version) #{ # DEFINES += DEVICE_IS_INTEL #} # You can also make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ bluetooth.cpp \ bluetoothbottomwindow.cpp \ bluetoothdbusservice.cpp \ bluetoothdevicefunc.cpp \ bluetoothdeviceitem.cpp \ bluetoothdevicewindowitem.cpp \ bluetoothmainerrorwindow.cpp \ bluetoothmainloadingwindow.cpp \ bluetoothmainnormalwindow.cpp \ bluetoothmainwindow.cpp \ bluetoothmiddlewindow.cpp \ bluetoothnamelabel.cpp \ bluetoothtopwindow.cpp \ common.cpp \ devicebase.cpp \ devremovedialog.cpp \ devrenamedialog.cpp \ loadinglabel.cpp \ ukccbluetoothconfig.cpp HEADERS += \ bluetooth.h \ bluetoothbottomwindow.h \ bluetoothdbusservice.h \ bluetoothdevicefunc.h \ bluetoothdeviceitem.h \ bluetoothdevicewindowitem.h \ bluetoothmainerrorwindow.h \ bluetoothmainloadingwindow.h \ bluetoothmainnormalwindow.h \ bluetoothmainwindow.h \ bluetoothmiddlewindow.h \ bluetoothnamelabel.h \ bluetoothtopwindow.h \ common.h \ config.h \ devicebase.h \ devremovedialog.h \ devrenamedialog.h \ loadinglabel.h \ ukccbluetoothconfig.h DISTFILES += ukcc-bluetooth.json TRANSLATIONS += \ translations/ukcc-bluetooth_zh_HK.ts \ translations/ukcc-bluetooth_zh_Hant.ts \ translations/ukcc-bluetooth_zh_CN.ts \ translations/ukcc-bluetooth_ug.ts \ translations/ukcc-bluetooth_mn.ts \ translations/ukcc-bluetooth_ky.ts \ translations/ukcc-bluetooth_kk.ts \ translations/ukcc-bluetooth_fr.ts \ translations/ukcc-bluetooth_es.ts \ translations/ukcc-bluetooth_en_US.ts \ translations/ukcc-bluetooth_de.ts \ translations/ukcc-bluetooth_ar.ts \ translations/ukcc-bluetooth_bo_CN.ts #system("lrelease translations/*.ts") # Default rules for deployment. unix { # target.path = $$[QT_INSTALL_PLUGINS]/generic target.path = $$FILES_INSTALL_DIR } qm_files.files += translations/*.qm qm_files.path += $${SHARE_TRANSLATIONS_INSTALL_DIR} ts_files.files += translations/*.ts ts_files.path += $${SHARE_TRANSLATIONS_INSTALL_DIR} INSTALLS += target qm_files ts_files OBJECTS_DIR = ./obj/ MOC_DIR = ./moc/ ukui-bluetooth/ukcc-bluetooth/bluetoothdevicefunc.cpp0000664000175000017500000002527515167665770022214 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothdevicefunc.h" #define RADIUS 6.0 bluetoothdevicefunc::bluetoothdevicefunc(QWidget *parent ,QString dev_address): QPushButton(parent), _MDev_addr(dev_address) { initGsettings(); initInterface(); } bluetoothdevicefunc::~bluetoothdevicefunc() { KyDebug() <<_MDev_addr ; _mStyle_GSettings->deleteLater(); } void bluetoothdevicefunc::initGsettings() { if (QGSettings::isSchemaInstalled(GSETTING_UKUI_STYLE)) { _mStyle_GSettings = new QGSettings(GSETTING_UKUI_STYLE); if(_mStyle_GSettings->get("styleName").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") _themeIsBlack = false; else _themeIsBlack = true; _mIconThemeName = _mStyle_GSettings->get("iconThemeName").toString(); connect(_mStyle_GSettings,&QGSettings::changed,this,&bluetoothdevicefunc::mStyle_GSettingsSlot); } } void bluetoothdevicefunc::initBackground() { this->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic")); this->setProperty("useButtonPalette", true); this->setFlat(true); } void bluetoothdevicefunc::initInterface() { KyDebug(); this->setFixedSize(36,36); // if (_themeIsBlack) initBackground(); devMenuFunc = new QMenu(this); devMenuFunc->setMinimumWidth(160); //devMenuFunc->setMaximumWidth(160); connect(devMenuFunc,&QMenu::triggered,this,&bluetoothdevicefunc::MenuSignalDeviceFunction); connect(devMenuFunc,&QMenu::aboutToHide,this,&bluetoothdevicefunc::MenuSignalAboutToHide); } void bluetoothdevicefunc::MenuSignalDeviceFunction(QAction *action) { KyDebug() << action->text(); if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) { KyWarning() << " bluetooth device is null"; return; } if(action->text() == tr("SendFile")) { BlueToothDBusService::sendFiles(_MDev_addr); } else if(action->text() == tr("Remove")) { DevRemoveDialog::REMOVE_INTERFACE_TYPE mode ; if (bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType() || bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType()) mode = DevRemoveDialog::REMOVE_HAS_PIN_DEV; else mode = DevRemoveDialog::REMOVE_NO_PIN_DEV; showDeviceRemoveWidget(mode); } else if (action->text() == tr("Connect")) { KyDebug() << "To :" << _MDev_addr << "connect" ; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) { BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->setDevConnecting(true); } BlueToothDBusService::devConnect(_MDev_addr); } else if(action->text() == tr("Disconnect")) { KyDebug() << "To :" <<_MDev_addr << "disconnect" ; BlueToothDBusService::devDisconnect(_MDev_addr); } else if(action->text() == tr("Rename")) { KyDebug() << "To :" << _MDev_addr << "disconnect" ; showDeviceRenameWidget(); } // emit devFuncOpertionSignal(); } void bluetoothdevicefunc::MenuSignalAboutToHide() { //KyWarning(); } void bluetoothdevicefunc::showDeviceRemoveWidget(DevRemoveDialog::REMOVE_INTERFACE_TYPE mode) { DevRemoveDialog *mesgBox = new DevRemoveDialog(mode,this); mesgBox->setModal(true); mesgBox->setDialogText(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevInterfaceShowName()); connect(mesgBox,&DevRemoveDialog::accepted,this,[=]{ KyDebug() << "To :" << _MDev_addr << "Remove" ; BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->setRemoving(true); BlueToothDBusService::devRemove(_MDev_addr); Q_EMIT devFuncOpertionRemoveSignal(_MDev_addr); }); /* QDBusInterface iface("org.ukui.panel", "/panel/position", "org.ukui.panel", QDBusConnection::sessionBus()); if (iface.isValid()) { QDBusReply reply=iface.call("GetPrimaryScreenGeometry"); kdk::WindowManager::setGeometry(mesgBox->windowHandle(), QRect((reply.value().at(2).toInt()-mesgBox->width())/2, (reply.value().at(3).toInt()-mesgBox->height())/2, mesgBox->width(), mesgBox->height())); }*/ mesgBox->exec(); } void bluetoothdevicefunc::showDeviceRenameWidget() { KyDebug(); DevRenameDialog *renameMesgBox = new DevRenameDialog(this); renameMesgBox->setDevName(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevInterfaceShowName()); renameMesgBox->setRenameInterface(DevRenameDialog::DEVRENAMEDIALOG_BT_DEVICE); connect(renameMesgBox,&DevRenameDialog::nameChanged,this,[=](QString name){ BlueToothDBusService::devRename(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress(),name); }); renameMesgBox->exec(); KyDebug() << "end" ; } void bluetoothdevicefunc::mStyle_GSettingsSlot(const QString &key) { KyDebug() << key; if ("iconThemeName" == key || "icon-theme-name" == key) { _mIconThemeName = _mStyle_GSettings->get("iconThemeName").toString(); } else if ("styleName" == key || "style-name" == key) { if(_mStyle_GSettings->get("style-name").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") { _themeIsBlack = false; } else { _themeIsBlack = true; } } // initBackground(); this->update(); } void bluetoothdevicefunc::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base().color()); QPalette pal = qApp->palette(); QColor color = pal.color(QPalette::Button); color.setAlphaF(0.6); pal.setColor(QPalette::Button, color); this->setPalette(pal); QPushButton::paintEvent(event); } void bluetoothdevicefunc::mousePressEvent(QMouseEvent *event) { // KyWarning(); //获取当前时间 _pressCurrentTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); QPushButton::mousePressEvent(event); } void bluetoothdevicefunc:: mouseReleaseEvent(QMouseEvent *event) { // KyWarning(); if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) return; long long _releaseCurrentTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); //KyDebug() << "_releaseCurrentTime" << _releaseCurrentTime << "_pressCurrentTime:" << _pressCurrentTime; //点击超时取消操作 if((_releaseCurrentTime - _pressCurrentTime) <= 300) { // 显示顺序 /* * 断开或连接 * 发送文件 * 重命名设备 * 移除 */ devMenuFunc->clear(); if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType() != bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType() != bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard) { QAction * connAction = new QAction(devMenuFunc); connAction->setText(tr("Connect")); devMenuFunc->addAction(connAction); } } else { QAction * disconnAction = new QAction(devMenuFunc); disconnAction->setText(tr("Disconnect")); devMenuFunc->addAction(disconnAction); } if ((bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType() || bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType()) && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevSendFileMark() && HUAWEI != envPC) { QAction * sendFileAction = new QAction(devMenuFunc); sendFileAction->setText(tr("SendFile")); devMenuFunc->addAction(sendFileAction); } QAction * renameAction = new QAction(devMenuFunc); renameAction->setText(tr("Rename")); devMenuFunc->addAction(renameAction); renameAction->setEnabled(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()); QAction * removeAction = new QAction(devMenuFunc); removeAction->setText(tr("Remove")); devMenuFunc->addAction(removeAction); //计算显示位置 QPoint currentWPoint = this->pos(); QPoint sreenPoint = QWidget::mapFromGlobal(currentWPoint); // qInfo() << this->x() << this->y() << "======x ======y"; // qInfo() << sreenPoint.x() << sreenPoint.y() << "======sreenPoint.x ======sreenPoint.y"; // qInfo() << devMenuFunc->width() << this->width() << this->height() << "======devMenuFunc->width ======this->width ======this->height"; // qInfo() << (-1)*sreenPoint.x()+devMenuFunc->width()+this->width()+4<<(-1)*sreenPoint.y()+this->height(); //devMenuFunc->move( this->x()+devMenuFunc->width()+this->width(),this->y()+devMenuFunc->height()+this->height()); devMenuFunc->move((-1)*sreenPoint.x()+this->x()-2,(-1)*sreenPoint.y()+this->height()+2); // devMenuFunc->setFocus(); devMenuFunc->exec(); } QPushButton::mouseReleaseEvent(event); emit devBtnReleaseSignal(); } ukui-bluetooth/ukcc-bluetooth/bluetoothmiddlewindow.h0000664000175000017500000000444315167665755022231 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHMIDDLEWINDOW_H #define BLUETOOTHMIDDLEWINDOW_H #include #include #include #include #include #include #include "bluetoothdbusservice.h" #include "bluetoothdevicewindowitem.h" class BluetoothMiddleWindow : public QWidget { Q_OBJECT public: BluetoothMiddleWindow(BlueToothDBusService * btServer,QWidget * parent = nullptr); ~BluetoothMiddleWindow(); void reloadWindow(); void quitWindow(); Q_SIGNALS: void myDeviceWindosHiddenSignal(bool status); private Q_SLOTS: void deviceRemoveSlot(QString dev_address); void devicePairedSuccessSlot(QString dev_address); void defaultAdapterChangedSlot(int indx); void devConnectedChangedSlot(QString dev_address,bool status); private: BlueToothDBusService * m_btServer = nullptr; QFrame *_MNormalFrameMiddle = nullptr; QVBoxLayout *_NormalWidgetPairedDevLayout = nullptr; QWidget *_MNotConnectedNormalFrameMiddle = nullptr; QVBoxLayout *_NormalWidgetNotConnecededDevLayout = nullptr; QWidget *_MConnectedNormalFrameMiddle = nullptr; QVBoxLayout *_NormalWidgetConnecededDevLayout = nullptr; //bool ; private: void InitNormalWidgetMiddle(); void InitConnectionData(); // void AddMyDeviceWidgetConnectedAndNotConnected(); void AddMyBluetoothDevices(); void addMyDeviceItemUI(QString device_address); void removeMyDeviceItemUI(QString device_address); void setLastDevItemWindowLine(bool status); void clearMyDevicesUI(); // int getConnectedCount(); // int getNotConnectedCount(); }; #endif // BLUETOOTHMIDDLEWINDOW_H ukui-bluetooth/ukcc-bluetooth/bluetoothtopwindow.h0000664000175000017500000000742315167665770021573 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHTOPWINDOW_H #define BLUETOOTHTOPWINDOW_H #include #include #include #include #include #include #include #include "kswitchbutton.h" #include "bluetoothnamelabel.h" #include "bluetoothdbusservice.h" #define MIN_WIDTH 582 #define MIN_HEIGTH 58 using namespace kdk; class BluetoothTopWindow : public QWidget { Q_OBJECT public: BluetoothTopWindow(BlueToothDBusService * btServer,QWidget * parent = nullptr); ~BluetoothTopWindow(); static bool m_defaultAdapterPowerStatus; void reloadWindow(); void quitWindow(); Q_SIGNALS: void btPowerSwitchChanged(bool status); private Q_SLOTS: void setDefaultAdapterNameSlot(QString); void _BtSwitchBtnSlot(bool status); void _BtSwitchBtnPressedSlot(); void _BtSwitchBtnReleasedSlot(); void _BtTrayIconShowSlot(bool status); void _BtDiscoverableSlot(bool status); void _BtAutoAudioConnBtnSlot(bool status); void _AdapterListSelectComboBoxSlot(int indx); void btAudioCombineStatusChangeSlot(bool); void adapterAddSlot(QString); void adapterRemoveSlot(int); void defaultAdapterChangedSlot(int); void adapterNameChangedSlot(QString); void adapterNameChangedOfIndexSlot(int indx , QString name); void adapterPowerStatusChangedSlot(bool); void adapterTrayIconSlot(bool); void adapterDiscoverableSlot(bool); void adapterActiveConnectionSlot(bool); private: BlueToothDBusService * m_btServer = nullptr; QFrame *_MNormalFrameTop = nullptr; QFrame *BtSwitchLineFrame = nullptr; QFrame *BtAdapterListFrame = nullptr; QFrame *BtAdapterListLineFrame = nullptr; QFrame *BtTrayIconShowFrame= nullptr; QFrame *BtTrayIconShowLineFrame = nullptr; QFrame *BtDiscoverableFrame= nullptr; QFrame *BtDiscoverableLineFrame= nullptr; QFrame *BtAutomaticAudioConnectionFrame= nullptr; QFrame * m_btAudioCombinationFrame = nullptr; KSwitchButton *_BtSwitchBtn = nullptr; KSwitchButton *_BtTrayIconShow = nullptr; KSwitchButton *_BtDiscoverable = nullptr; KSwitchButton *_BtAutoAudioConnBtn = nullptr; KSwitchButton * m_btAudioCombinationBtn = nullptr; QComboBox *_AdapterListSelectComboBox = nullptr; BluetoothNameLabel *_BtNameLabel = nullptr; bool _BTServiceReportPowerSwitchFlag = false; //服务上报的蓝牙开关状态 bool _BTServiceReportTrayIconSwitchFlag = false; //服务上报的蓝牙托盘显示开关状态 bool _BTServiceReportDiscoverableSwtichFlag = false; //服务上报的可被发现状态 bool _BTServiceReportAutoAudioConnSwtichFlag = false; //服务上报的自动音频状态 // bool _BTServiceReportDiscoveringSwtichFlag = false; //服务上报的扫描状态 bool m_SwitchBtnPressed = false; private: void InitNormalWidgetTop(); void InitDisplayState(); void InitConnectionData(); void sendBtPowerChangedSignal(bool status); void adapterChangedRefreshInterface(int indx); bool whetherNeedInfoUser(); }; #endif // BLUETOOTHTOPWINDOW_H ukui-bluetooth/ukcc-bluetooth/common.h0000664000175000017500000000220315167665770017072 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef COMMON_H #define COMMON_H #include #define STR_MOUSE "MOUSE" #define STR_TOUCHPAD "TOUCHPAD" #define STR_KEYBOARD "KEYBOARD" #define STR_TRACKPOINT "TRACKPOINT" class Common : public QObject { Q_OBJECT public: explicit Common(QObject *parent = nullptr); static bool isWayland(); static int getSystemCurrentMouseAndTouchPadDevCount(); static int getSystemCurrentKeyBoardDevCount(); signals: }; #endif // COMMON_H ukui-bluetooth/ukcc-bluetooth/ukcc-bluetooth.qrc0000664000175000017500000000005115167665755021072 0ustar fengfeng ukui-bluetooth/ukcc-bluetooth/bluetoothdevicewindowitem.cpp0000664000175000017500000000510615167665755023441 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothdevicewindowitem.h" class bluetoothdeviceitem; bluetoothdevicewindowitem::bluetoothdevicewindowitem(QString dev_address , bool show_line , QWidget *parent): m_dev_address(dev_address), m_show_line(show_line),//line显示标志 QFrame(parent) { KyDebug(); this->setFocusPolicy(Qt::NoFocus); this->setObjectName(m_dev_address); this->setMinimumSize(580, 56); Init(); } bluetoothdevicewindowitem::~bluetoothdevicewindowitem() { KyDebug(); if (m_devBtn) { m_devBtn->disconnect(); m_devBtn->deleteLater(); } if (line_frame) line_frame->deleteLater(); } void bluetoothdevicewindowitem::Init() { QVBoxLayout * m_VBoxLout = new QVBoxLayout(this); m_VBoxLout->setSpacing(0); m_VBoxLout->setContentsMargins(0,0,0,0); m_VBoxLout->setAlignment(Qt::AlignTop); m_devBtn = new bluetoothdeviceitem(m_dev_address,this); connect(m_devBtn,&bluetoothdeviceitem::devFuncOptSignals,this,&bluetoothdevicewindowitem::devFuncOptSignals); connect(m_devBtn,&bluetoothdeviceitem::devPairedSuccess,this,&bluetoothdevicewindowitem::devPairedSuccess); connect(m_devBtn,&bluetoothdeviceitem::devConnectedChanged,this,&bluetoothdevicewindowitem::devConnectedChanged); connect(m_devBtn,&bluetoothdeviceitem::devRssiChanged,this,&bluetoothdevicewindowitem::devRssiChanged); connect(m_devBtn,&bluetoothdeviceitem::bluetoothDeviceItemRemove,this,&bluetoothdevicewindowitem::bluetoothDeviceItemRemove); m_VBoxLout->addWidget(m_devBtn,1,Qt::AlignTop); line_frame = new QFrame(this); line_frame->setFixedHeight(1); line_frame->setMinimumWidth(582); line_frame->setFrameStyle(QFrame::HLine); m_VBoxLout->addWidget(line_frame,1,Qt::AlignTop); setLineFrameHidden(!m_show_line); } void bluetoothdevicewindowitem::setLineFrameHidden(bool hidden) { KyDebug() << hidden ; line_frame->setHidden(hidden); } ukui-bluetooth/ukcc-bluetooth/bluetoothmainerrorwindow.cpp0000664000175000017500000000361015167665770023314 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothmainerrorwindow.h" BluetoothMainErrorWindow::BluetoothMainErrorWindow(QString str_error , QWidget * parent) : m_str_error(str_error), QWidget(parent) { InitErrorWindow(); } void BluetoothMainErrorWindow::InitErrorWindow() { QVBoxLayout *errorWidgetLayout = new QVBoxLayout(this); QLabel *errorWidgetIcon = new QLabel(this); errorWidgetTip = new QLabel(this); this->setObjectName("ErrorWidget"); errorWidgetLayout->setSpacing(10); errorWidgetLayout->setContentsMargins(0,0,0,0); errorWidgetIcon->setFixedSize(56,56); errorWidgetTip->resize(200,30); errorWidgetTip->setFont(QFont("Noto Sans CJK SC",18,QFont::Bold)); errorWidgetLayout->addStretch(10); if (QIcon::hasThemeIcon("dialog-warning")) { errorWidgetIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(56,56)); errorWidgetLayout->addWidget(errorWidgetIcon,1,Qt::AlignCenter); } errorWidgetTip->setText(m_str_error); errorWidgetLayout->addWidget(errorWidgetTip,1,Qt::AlignCenter); errorWidgetLayout->addStretch(10); } void BluetoothMainErrorWindow::setErrorText(QString error_str) { m_str_error = error_str; errorWidgetTip->setText(error_str); } ukui-bluetooth/ukcc-bluetooth/ukccbluetoothconfig.h0000664000175000017500000000352615167665755021657 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef UKCCBLUETOOTHCONFIG_H #define UKCCBLUETOOTHCONFIG_H #include #include #include #include #include #include #ifdef UKCC_BLUETOOTH_DATA_BURIAL_POINT #include #endif #include "kysdk/kysdk-system/libkysysinfo.h" #include "config.h" class ukccbluetoothconfig { public: ukccbluetoothconfig(); ~ukccbluetoothconfig(); enum PixmapColor { WHITE = 0, BLACK, GRAY, BLUE, DEFAULT }; static QGSettings *ukccGsetting; static bool ukccBtBuriedSettings(QString pluginName, QString settingsName, QString action, QString value = nullptr); static void launchBluetoothServiceStart(const QString &processName); static void killAppProcess(const quint64 &processId); static bool checkProcessRunning(const QString &processName, QList &listProcessId); static void setEnvPCValue(); static const QPixmap loadSvg(const QPixmap &source, const PixmapColor &cgColor); static const QImage loadSvgImage(const QPixmap &source, const PixmapColor &cgColor); }; #endif // UKCCBLUETOOTHCONFIG_H ukui-bluetooth/ukcc-bluetooth/bluetoothdeviceitem.h0000664000175000017500000001056115167665770021654 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHDEVICEITEM_H #define BLUETOOTHDEVICEITEM_H #include "devicebase.h" #include "loadinglabel.h" #include "devremovedialog.h" #include "bluetoothdevicefunc.h" #include "bluetoothmainwindow.h" #include "bluetoothdbusservice.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "windowmanager/windowmanager.h" #define CONNECT_ERROR_COUNT (3) #define CONNECT_DEVICE_TIMING (35*1000) #define CONNECT_ERROR_TIMER_CLEAR (3*60*1000) //3分钟内用户来连接失败超过3次,提示用户是否移除后重新配对连接 #define DEV_ICON_WH 16,16 class bluetoothdeviceitem : public QPushButton { Q_OBJECT public: enum _DEV_STATUS { Dev_Connecting, Dev_Disconnecting, Dev_NotPaired, Dev_NotConnected, Dev_ConnectionFail, Dev_DisconnectionFail };//(_DEV_STATUS); bluetoothdeviceitem(QString dev_address ,QWidget *parent = nullptr); ~bluetoothdeviceitem(); QString m_str_unknown = tr("unknown"); QString m_str_connecting = tr("Connecting"); QString m_str_disconnecting = tr("Disconnecting"); QString m_str_notpaired = tr("Not Paired"); QString m_str_notconnected = tr("Not Connected"); QString m_str_connected = tr("Connected"); QString m_str_connectionfail = tr("Connect fail,Please try again"); QString m_str_disconnectionfail = tr("Disconnection Fail"); private: QHBoxLayout * devItemHLayout = nullptr; QHBoxLayout * devFuncHLayout = nullptr; QLabel * devIconLabel = nullptr; QLabel * devNameLabel = nullptr; QLabel * devStatusLabel = nullptr; // QFrame * devFuncFrame = nullptr; bluetoothdevicefunc * devFuncBtn = nullptr; LoadingLabel * devloadingLabel = nullptr; QTimer * devConnectiontimer = nullptr; QTimer * devConnectionFail_timer = nullptr; QString getDevName(); QString getDevStatus(); QPixmap getDevTypeIcon(); void initGsettings(); void initBackground(); void initInterface(); void refreshInterface(); void devStatusLoading(); void bindInInterfaceUISignals(); void bindDeviceChangedSignals(); void refreshDevCurrentStatus(); void devConnectionFail(); void showDeviceRemoveWidget(DevRemoveDialog::REMOVE_INTERFACE_TYPE); uint _mConnFailCount = 0; bool _themeIsBlack = false; QString _mIconThemeName; long long _pressCurrentTime; QString _MDev_addr ; QGSettings * _mStyle_GSettings = nullptr; protected: void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *e); signals: void devFuncOptSignals(); void devPairedSuccess(QString); void devConnectedChanged(bool); void devRssiChanged(qint64); void bluetoothDeviceItemRemove(QString); private Q_SLOTS: void devFuncOperationSlot(); void devConnOperationTimeoutSlot(); void devItemNameChanged(const QString &); void devItemTypeChanged(const bluetoothdevice::BLUETOOTH_DEVICE_TYPE &); void devItemStatusChanged(const QString &); void mStyle_GSettingsSlot(const QString &key); void devBtnPressedSlot(); void devFuncOpertionRemoveSlot(QString); }; #endif // BLUETOOTHDEVICEITEM_H ukui-bluetooth/ukcc-bluetooth/translate_generation.sh0000775000175000017500000000056615167665770022212 0ustar fengfeng#!/bin/bash export PATH="/usr/lib/qt6/bin:$PATH" ts_list=(`ls translations/*.ts`) source /etc/os-release version=(`echo $ID`) for ts in "${ts_list[@]}" do printf "\nprocess ${ts}\n" if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then lrelease-qt6 "${ts}" else lrelease "${ts}" fi done ukui-bluetooth/ukcc-bluetooth/bluetoothtopwindow.cpp0000664000175000017500000007322715167665770022133 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothtopwindow.h" #include #include "common.h" bool BluetoothTopWindow::m_defaultAdapterPowerStatus = false; BluetoothTopWindow::BluetoothTopWindow(BlueToothDBusService * btServer,QWidget * parent) : m_btServer(btServer), QWidget(parent) { // this->setFocusPolicy(Qt::NoFocus); this->setFocus(Qt::NoFocusReason); InitNormalWidgetTop(); if (btServer->m_default_bluetooth_adapter) InitDisplayState(); InitConnectionData(); } BluetoothTopWindow::~BluetoothTopWindow() { } void BluetoothTopWindow::InitNormalWidgetTop() { // KyDebug(); QVBoxLayout *NormalWidgetTopLayout = new QVBoxLayout(this); NormalWidgetTopLayout->setSpacing(8); NormalWidgetTopLayout->setContentsMargins(0,0,0,0); //~ contents_path /Bluetooth/Bluetooth QLabel *textBluetoothLabel = new QLabel(tr("Bluetooth"),this); textBluetoothLabel->resize(100,25); textBluetoothLabel->setContentsMargins(16,0,0,0); NormalWidgetTopLayout->addWidget(textBluetoothLabel,1,Qt::AlignTop); _MNormalFrameTop = new QFrame(this); _MNormalFrameTop->setMinimumWidth(MIN_WIDTH); _MNormalFrameTop->setFrameShape(QFrame::Shape::Box); NormalWidgetTopLayout->addWidget(_MNormalFrameTop); QVBoxLayout *NormalFrameLayout = new QVBoxLayout(this); NormalFrameLayout->setSpacing(0); NormalFrameLayout->setContentsMargins(0,0,0,0); _MNormalFrameTop->setLayout(NormalFrameLayout); //================================ init BtSwitchFrame ======================================= QFrame *BtSwitchFrame = new QFrame(_MNormalFrameTop); BtSwitchFrame->setMinimumWidth(MIN_WIDTH); BtSwitchFrame->setFrameShape(QFrame::Shape::Box); BtSwitchFrame->setFixedHeight(MIN_HEIGTH); // BtSwitchFrame->setAutoFillBackground(true); NormalFrameLayout->addWidget(BtSwitchFrame,1,Qt::AlignTop); QHBoxLayout *BtSwitchFrameLayout = new QHBoxLayout(BtSwitchFrame); BtSwitchFrameLayout->setSpacing(0); BtSwitchFrameLayout->setContentsMargins(16,0,16,0); //~ contents_path /Bluetooth/Turn on : QLabel *BtSwitchLabel = new QLabel(tr("Turn on :"),BtSwitchFrame); BtSwitchFrameLayout->addWidget(BtSwitchLabel,1,Qt::AlignLeft); _BtNameLabel = new BluetoothNameLabel(BtSwitchFrame,300,38); BtSwitchFrameLayout->addWidget(_BtNameLabel,1,Qt::AlignLeft); BtSwitchFrameLayout->addStretch(25); _BtSwitchBtn = new KSwitchButton(BtSwitchFrame); // _BtSwitchBtn->setChecked(true); BtSwitchFrameLayout->addWidget(_BtSwitchBtn); //添加分割线 BtSwitchLineFrame = new QFrame(_MNormalFrameTop); BtSwitchLineFrame->setFixedHeight(1); BtSwitchLineFrame->setMinimumWidth(MIN_WIDTH); BtSwitchLineFrame->setFrameStyle(QFrame::HLine); NormalFrameLayout->addWidget(BtSwitchLineFrame); //================================ end init BtSwitchFrame ======================================= //================================ init BtAdapterListFrame =========================================== BtAdapterListFrame = new QFrame(_MNormalFrameTop); BtAdapterListFrame->setMinimumWidth(MIN_WIDTH); BtAdapterListFrame->setFrameShape(QFrame::Shape::Box); BtAdapterListFrame->setFixedHeight(MIN_HEIGTH); // BtAdapterListFrame->setAutoFillBackground(true); NormalFrameLayout->addWidget(BtAdapterListFrame,1,Qt::AlignTop); QHBoxLayout *BtAdapterListFrameLayout = new QHBoxLayout(BtAdapterListFrame); BtAdapterListFrameLayout->setSpacing(0); BtAdapterListFrameLayout->setContentsMargins(16,0,16,0); //~ contents_path /Bluetooth/Adapter List QLabel *textAdapterListLabel = new QLabel(tr("Adapter List"),BtAdapterListFrame); BtAdapterListFrameLayout->addWidget(textAdapterListLabel); BtAdapterListFrameLayout->addStretch(10); _AdapterListSelectComboBox = new QComboBox(BtAdapterListFrame); _AdapterListSelectComboBox->clear(); _AdapterListSelectComboBox->setMinimumWidth(300); BtAdapterListFrameLayout->addWidget(_AdapterListSelectComboBox); //添加分割线 BtAdapterListLineFrame = new QFrame(_MNormalFrameTop); BtAdapterListLineFrame->setFixedHeight(1); BtAdapterListLineFrame->setMinimumWidth(MIN_WIDTH); BtAdapterListLineFrame->setFrameStyle(QFrame::HLine); NormalFrameLayout->addWidget(BtAdapterListLineFrame); //================================ end init BtAdapterListFrame ======================================= //================================ init BtTrayIconShowFrame =========================================== BtTrayIconShowFrame = new QFrame(_MNormalFrameTop); BtTrayIconShowFrame->setMinimumWidth(MIN_WIDTH); BtTrayIconShowFrame->setFrameShape(QFrame::Shape::Box); BtTrayIconShowFrame->setFixedHeight(MIN_HEIGTH); // BtTrayIconShowFrame->setAutoFillBackground(true); NormalFrameLayout->addWidget(BtTrayIconShowFrame,1,Qt::AlignTop); QHBoxLayout *BtTrayIconShowFrameLayout = new QHBoxLayout(BtTrayIconShowFrame); BtTrayIconShowFrameLayout->setSpacing(0); BtTrayIconShowFrameLayout->setContentsMargins(16,0,16,0); //~ contents_path /Bluetooth/Show icon on taskbar QLabel *BtTrayIconShowLabel = new QLabel(tr("Show icon on taskbar"),BtTrayIconShowFrame); BtTrayIconShowFrameLayout->addWidget(BtTrayIconShowLabel); _BtTrayIconShow = new KSwitchButton(BtTrayIconShowFrame); BtTrayIconShowFrameLayout->addStretch(10); BtTrayIconShowFrameLayout->addWidget(_BtTrayIconShow); BtTrayIconShowLineFrame = new QFrame(_MNormalFrameTop); BtTrayIconShowLineFrame->setFixedHeight(1); BtTrayIconShowLineFrame->setMinimumWidth(MIN_WIDTH); BtTrayIconShowLineFrame->setFrameStyle(QFrame::HLine); NormalFrameLayout->addWidget(BtTrayIconShowLineFrame); //================================ end init BtTrayIconShowFrame ======================================= //================================ init BtDiscoverableFrame =========================================== BtDiscoverableFrame = new QFrame(_MNormalFrameTop); BtDiscoverableFrame->setMinimumWidth(MIN_WIDTH); BtDiscoverableFrame->setFrameShape(QFrame::Shape::Box); BtDiscoverableFrame->setFixedHeight(MIN_HEIGTH); // BtDiscoverableFrame->setAutoFillBackground(true); NormalFrameLayout->addWidget(BtDiscoverableFrame,1,Qt::AlignTop); QHBoxLayout *BtDiscoverableFrameLayout = new QHBoxLayout(BtDiscoverableFrame); BtDiscoverableFrameLayout->setSpacing(0); BtDiscoverableFrameLayout->setContentsMargins(16,0,16,0); //~ contents_path /Bluetooth/Discoverable by nearby Bluetooth devices QLabel *BtDiscoverableLabel = new QLabel(tr("Discoverable by nearby Bluetooth devices"),BtDiscoverableFrame); BtDiscoverableFrameLayout->addWidget(BtDiscoverableLabel); _BtDiscoverable = new KSwitchButton(BtDiscoverableFrame); BtDiscoverableFrameLayout->addStretch(10); BtDiscoverableFrameLayout->addWidget(_BtDiscoverable); //添加分割线 BtDiscoverableLineFrame = new QFrame(_MNormalFrameTop); BtDiscoverableLineFrame->setFixedHeight(1); BtDiscoverableLineFrame->setMinimumWidth(MIN_WIDTH); BtDiscoverableLineFrame->setFrameStyle(QFrame::HLine); NormalFrameLayout->addWidget(BtDiscoverableLineFrame); //================================ end init BtDiscoverableFrame ======================================= //================================ init BtAutomaticAudioConnectionFrame =========================================== BtAutomaticAudioConnectionFrame = new QFrame(_MNormalFrameTop); BtAutomaticAudioConnectionFrame->setMinimumWidth(MIN_WIDTH); BtAutomaticAudioConnectionFrame->setFrameShape(QFrame::Shape::Box); BtAutomaticAudioConnectionFrame->setFixedHeight(MIN_HEIGTH); // BtAutomaticAudioConnectionFrame->setAutoFillBackground(true); NormalFrameLayout->addWidget(BtAutomaticAudioConnectionFrame,1,Qt::AlignTop); QHBoxLayout *BtAutomaticAudioConnectionFrameLayout = new QHBoxLayout(BtAutomaticAudioConnectionFrame); BtAutomaticAudioConnectionFrameLayout->setSpacing(0); BtAutomaticAudioConnectionFrameLayout->setContentsMargins(16,0,16,0); //~ contents_path /Bluetooth/Auto discover Bluetooth audio devices QLabel *BtAutomaticAudioConnectionLabel = new QLabel(tr("Auto discover Bluetooth audio devices"),BtAutomaticAudioConnectionFrame); BtAutomaticAudioConnectionFrameLayout->addWidget(BtAutomaticAudioConnectionLabel); _BtAutoAudioConnBtn = new KSwitchButton(BtDiscoverableFrame); BtAutomaticAudioConnectionFrameLayout->addStretch(10); BtAutomaticAudioConnectionFrameLayout->addWidget(_BtAutoAudioConnBtn); //================================ end init BtAutomaticAudioConnectionFrame ======================================= //添加分割线 BtDiscoverableLineFrame = new QFrame(_MNormalFrameTop); BtDiscoverableLineFrame->setFixedHeight(1); BtDiscoverableLineFrame->setMinimumWidth(MIN_WIDTH); BtDiscoverableLineFrame->setFrameStyle(QFrame::HLine); NormalFrameLayout->addWidget(BtDiscoverableLineFrame); m_btAudioCombinationFrame = new QFrame(_MNormalFrameTop); m_btAudioCombinationFrame->setMinimumWidth(MIN_WIDTH); m_btAudioCombinationFrame->setFrameShape(QFrame::Shape::Box); m_btAudioCombinationFrame->setFixedHeight(MIN_HEIGTH + 10); NormalFrameLayout->addWidget(m_btAudioCombinationFrame,1,Qt::AlignTop); QHBoxLayout * btAudioCombinationFrameLayout = new QHBoxLayout(m_btAudioCombinationFrame); btAudioCombinationFrameLayout->setSpacing(0); btAudioCombinationFrameLayout->setContentsMargins(16,0,16,0); QWidget * btAudioCombinationWidget = new QWidget(m_btAudioCombinationFrame); btAudioCombinationFrameLayout->addWidget(btAudioCombinationWidget); QVBoxLayout * btAudioCombinationWidgetLayout = new QVBoxLayout(btAudioCombinationWidget); btAudioCombinationWidgetLayout->setSpacing(0); btAudioCombinationWidgetLayout->setContentsMargins(0,10,0,10); QLabel *testlabel1 = new QLabel(tr("Bluetooth Audio Combination Device"),btAudioCombinationWidget); btAudioCombinationWidgetLayout->addWidget(testlabel1, 0, Qt::AlignVCenter); KLabel *testlabel2 = new KLabel(btAudioCombinationWidget); testlabel2->setText(tr("After being enabled," "the two connected Bluetooth audio devices will play sound simultaneously")); testlabel2->setFontColorRole(QPalette::PlaceholderText); btAudioCombinationWidgetLayout->addWidget(testlabel2, 0, Qt::AlignVCenter); m_btAudioCombinationBtn = new KSwitchButton(m_btAudioCombinationFrame); btAudioCombinationFrameLayout->addStretch(10); btAudioCombinationFrameLayout->addWidget(m_btAudioCombinationBtn); //================================ end init btAudioCombination ======================================= NormalWidgetTopLayout->addStretch(2); } void BluetoothTopWindow::InitDisplayState() { if (!BlueToothDBusService::m_default_bluetooth_adapter) return; //bluetooth _BtNameLabel->set_dev_name(BlueToothDBusService::m_default_bluetooth_adapter->getDevName()); KyWarning()<< "power status:" << BlueToothDBusService::m_default_bluetooth_adapter->getAdapterPower(); _BtSwitchBtn->setChecked(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterPower()); m_defaultAdapterPowerStatus = BlueToothDBusService::m_default_bluetooth_adapter->getAdapterPower(); //开关界面显示加载 BtSwitchLineFrame->setVisible(_BtSwitchBtn->isChecked()); if (BlueToothDBusService::m_bluetooth_adapter_name_list.size() > 1) { BtAdapterListFrame->setVisible(_BtSwitchBtn->isChecked()); BtAdapterListLineFrame->setVisible(_BtSwitchBtn->isChecked()); } BtTrayIconShowFrame->setVisible(_BtSwitchBtn->isChecked()); BtTrayIconShowLineFrame->setVisible(_BtSwitchBtn->isChecked()); BtDiscoverableFrame->setVisible(_BtSwitchBtn->isChecked()); BtDiscoverableLineFrame->setVisible(_BtSwitchBtn->isChecked()); BtAutomaticAudioConnectionFrame->setVisible(_BtSwitchBtn->isChecked()); m_btAudioCombinationFrame->setVisible(_BtSwitchBtn->isChecked()); //bluetooth adapter list KyWarning() << "m_bluetooth_adapter_name_list::" << BlueToothDBusService::m_bluetooth_adapter_name_list; if (BlueToothDBusService::m_bluetooth_adapter_name_list.size() <= 1) { _AdapterListSelectComboBox->clear(); _AdapterListSelectComboBox->addItems(BlueToothDBusService::m_bluetooth_adapter_name_list); BtAdapterListFrame->hide(); BtAdapterListLineFrame->hide(); } else { _AdapterListSelectComboBox->clear(); _AdapterListSelectComboBox->addItems(BlueToothDBusService::m_bluetooth_adapter_name_list); _AdapterListSelectComboBox->setCurrentText(BlueToothDBusService::m_default_bluetooth_adapter->getDevName()); BtAdapterListFrame->setVisible(_BtSwitchBtn->isChecked()); BtAdapterListLineFrame->setVisible(_BtSwitchBtn->isChecked()); } //show taskbar _BtTrayIconShow->setChecked(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterTrayShow()); //discoverable KyWarning()<< "_BtDiscoverable::" << _BtDiscoverable->isChecked() << BlueToothDBusService::m_default_bluetooth_adapter->getAdapterDiscoverable(); _BtDiscoverable->setChecked(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterDiscoverable()); //auto audio conncet _BtAutoAudioConnBtn->setChecked(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterAutoConn()); m_btAudioCombinationBtn->setChecked(BlueToothDBusService::m_default_bluetooth_adapter->audioCombine()); } void BluetoothTopWindow::InitConnectionData() { //name label connect(_BtNameLabel,&BluetoothNameLabel::sendAdapterName,this,&BluetoothTopWindow::setDefaultAdapterNameSlot); //btn connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool))); connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot); connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot); connect(_BtTrayIconShow,SIGNAL(stateChanged(bool)),this,SLOT(_BtTrayIconShowSlot(bool))); connect(_BtDiscoverable,SIGNAL(stateChanged(bool)),this,SLOT(_BtDiscoverableSlot(bool))); connect(_BtAutoAudioConnBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtAutoAudioConnBtnSlot(bool))); connect(m_btAudioCombinationBtn,SIGNAL(stateChanged(bool)),this,SLOT(btAudioCombineStatusChangeSlot(bool))); //ComboBox connect(_AdapterListSelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(_AdapterListSelectComboBoxSlot(int))); if(m_btServer) { connect(m_btServer,SIGNAL(adapterAddSignal(QString)),this,SLOT(adapterAddSlot(QString))); connect(m_btServer,SIGNAL(adapterRemoveSignal(int)),this,SLOT(adapterRemoveSlot(int))); connect(m_btServer,SIGNAL(defaultAdapterChangedSignal(int)),this,SLOT(defaultAdapterChangedSlot(int))); //adapter status change connect(m_btServer,SIGNAL(adapterNameChanged(QString)),this,SLOT(adapterNameChangedSlot(QString))); connect(m_btServer,SIGNAL(adapterNameChangedOfIndex(int,QString)),this,SLOT(adapterNameChangedOfIndexSlot(int,QString))); connect(m_btServer,SIGNAL(adapterPoweredChanged(bool)),this,SLOT(adapterPowerStatusChangedSlot(bool))); connect(m_btServer,SIGNAL(adapterTrayIconChanged(bool)),this,SLOT(adapterTrayIconSlot(bool))); connect(m_btServer,SIGNAL(adapterDiscoverableChanged(bool)),this,SLOT(adapterDiscoverableSlot(bool))); connect(m_btServer,SIGNAL(adapterActiveConnectionChanged(bool)),this,SLOT(adapterActiveConnectionSlot(bool))); } } void BluetoothTopWindow::adapterAddSlot(QString adapter_name) { KyDebug() << "adapter_name:" << adapter_name << "adapter_address_list:" << BlueToothDBusService::m_bluetooth_adapter_address_list << "size :" << BlueToothDBusService::m_bluetooth_adapter_address_list.size(); if(BlueToothDBusService::m_bluetooth_adapter_address_list.size()) { _AdapterListSelectComboBox->addItem(adapter_name); if(BlueToothDBusService::m_bluetooth_adapter_address_list.size() >1) { if (BtAdapterListFrame->isHidden()) BtAdapterListFrame->setVisible(_BtSwitchBtn->isChecked()); if (BtAdapterListLineFrame->isHidden()) BtAdapterListLineFrame->setVisible(_BtSwitchBtn->isChecked()); } } } void BluetoothTopWindow::adapterRemoveSlot(int indx) { KyDebug() << "adapter indx:" << indx << "\n" << "adapter_name_list size:" << BlueToothDBusService::m_bluetooth_adapter_name_list.size() << "\n" << "adapter_name_list:" << BlueToothDBusService::m_bluetooth_adapter_name_list; if (1 == BlueToothDBusService::m_bluetooth_adapter_name_list.size()) { KyWarning() << "adapter indx:" << indx << "\n" << "_AdapterListSelectComboBox currentIndex:" << _AdapterListSelectComboBox->currentIndex(); if (indx == _AdapterListSelectComboBox->currentIndex()) { //移除适配器是默认适配器 adapterChangedRefreshInterface(0); } else { BtAdapterListFrame->hide(); BtAdapterListLineFrame->hide(); _AdapterListSelectComboBox->removeItem(indx); } // bool flag = false ; // if (indx == _AdapterListSelectComboBox->currentIndex()) // { // flag = true; // _AdapterListSelectComboBox->disconnect(); // } // _AdapterListSelectComboBox->removeItem(indx); // if(flag) // connect(_AdapterListSelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(_AdapterListSelectComboBoxSlot(int))); } else { if (indx == _AdapterListSelectComboBox->currentIndex()) { //移除适配器是默认适配器 adapterChangedRefreshInterface(0); } else { _AdapterListSelectComboBox->removeItem(indx); } // BtAdapterListFrame->show(); // BtAdapterListLineFrame->show(); // bool flag = false ; // if (indx == _AdapterListSelectComboBox->currentIndex()) // { // flag = true; // _AdapterListSelectComboBox->disconnect(); // } // _AdapterListSelectComboBox->removeItem(indx); // if (flag) // connect(_AdapterListSelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(_AdapterListSelectComboBoxSlot(int))); } } void BluetoothTopWindow::defaultAdapterChangedSlot(int indx) { adapterChangedRefreshInterface(indx); } void BluetoothTopWindow::setDefaultAdapterNameSlot(QString name) { KyDebug(); BlueToothDBusService::setDefaultAdapterName(name); } void BluetoothTopWindow::sendBtPowerChangedSignal(bool status) { m_defaultAdapterPowerStatus = status; Q_EMIT btPowerSwitchChanged(status); } void BluetoothTopWindow::_BtSwitchBtnSlot(bool status) { KyDebug() << "status" << status << "_BtSwitchBtn status: "<< _BtSwitchBtn->isChecked(); if (!_BTServiceReportPowerSwitchFlag && !status && whetherNeedInfoUser()) { KyInfo() << "Close bluetooth risk info!" ; QMessageBox box; box.setIcon(QMessageBox::Warning); box.setText(tr("Using Bluetooth mouse or keyboard, Do you want to turn off bluetooth?")); QPushButton * cancelBtn= new QPushButton(tr("Cancel")); QPushButton * closeBluetoothBtn= new QPushButton(tr("Close bluetooth")); cancelBtn->setProperty("isImportant", true); box.addButton(cancelBtn,QMessageBox::RejectRole); box.addButton(closeBluetoothBtn,QMessageBox::AcceptRole); int res = box.exec(); if (!res) { m_SwitchBtnPressed = false; _BtSwitchBtn->disconnect(_BtSwitchBtn,NULL,this,NULL); _BtSwitchBtn->setChecked(true); connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool))); connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot); connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot); return; } } BtSwitchLineFrame->setVisible(status); if (BlueToothDBusService::m_bluetooth_adapter_name_list.size() > 1) { BtAdapterListFrame->setVisible(status); BtAdapterListLineFrame->setVisible(status); } BtTrayIconShowFrame->setVisible(status); BtTrayIconShowLineFrame->setVisible(status); BtDiscoverableFrame->setVisible(status); BtDiscoverableLineFrame->setVisible(status); BtAutomaticAudioConnectionFrame->setVisible(status); m_btAudioCombinationFrame->setVisible(status); //发送信号 sendBtPowerChangedSignal(status); KyInfo() << "_BTServiceReportPowerSwitchFlag:" << _BTServiceReportPowerSwitchFlag ; if(!_BTServiceReportPowerSwitchFlag)//服务上报的状态不再次下发 { m_SwitchBtnPressed = false; ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("BtSwitchBtn"),QString("clicked"),status?QString("true"):QString("false")); BlueToothDBusService::setDefaultAdapterSwitchStatus(status); } else _BTServiceReportPowerSwitchFlag = false; } void BluetoothTopWindow::_BtSwitchBtnPressedSlot() { m_SwitchBtnPressed = true; } void BluetoothTopWindow::_BtSwitchBtnReleasedSlot() { if (m_SwitchBtnPressed) { KyWarning() << "active click"; _BtSwitchBtn->disconnect(_BtSwitchBtn,NULL,this,NULL); connect(_BtSwitchBtn,SIGNAL(stateChanged(bool)),this,SLOT(_BtSwitchBtnSlot(bool))); _BtSwitchBtn->click(); connect(_BtSwitchBtn, &KSwitchButton::pressed, this, &BluetoothTopWindow::_BtSwitchBtnPressedSlot); connect(_BtSwitchBtn, &KSwitchButton::released, this, &BluetoothTopWindow::_BtSwitchBtnReleasedSlot); } m_SwitchBtnPressed = false; } void BluetoothTopWindow::_BtTrayIconShowSlot(bool status) { KyDebug(); if(!_BTServiceReportTrayIconSwitchFlag)//服务上报的状态不再次下发 { ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("BtTrayIconShow"),QString("clicked"),status?QString("true"):QString("false")); BlueToothDBusService::setTrayIconShowStatus(status); } else _BTServiceReportTrayIconSwitchFlag = false; } void BluetoothTopWindow::_BtDiscoverableSlot(bool status) { KyDebug(); if(!_BTServiceReportDiscoverableSwtichFlag) { ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("BtDiscoverable"),QString("clicked"),status?QString("true"):QString("false")); BlueToothDBusService::setDefaultAdapterDiscoverableStatus(status); } else _BTServiceReportDiscoverableSwtichFlag = false; } void BluetoothTopWindow::_BtAutoAudioConnBtnSlot(bool status) { KyDebug(); if(!_BTServiceReportAutoAudioConnSwtichFlag) { ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("BtAutoAudioConnBtn"),QString("clicked"),status?QString("true"):QString("false")); BlueToothDBusService::setAutoConnectAudioDevStatus(status); } else _BTServiceReportAutoAudioConnSwtichFlag = false; } void BluetoothTopWindow::_AdapterListSelectComboBoxSlot(int indx) { KyDebug() << indx << BlueToothDBusService::m_bluetooth_adapter_address_list.size() << BlueToothDBusService::m_bluetooth_adapter_address_list; //KyWarning() << indx << BlueToothDBusService::m_bluetooth_adapter_address_list.size() << BlueToothDBusService::m_bluetooth_adapter_address_list; ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("AdapterListSelectComboBox"),QString("settings"),QString::number(indx)); if (BlueToothDBusService::m_bluetooth_adapter_address_list.size() > indx) { KyInfo() << BlueToothDBusService::m_bluetooth_adapter_address_list.at(indx); BlueToothDBusService::setDefaultAdapter(BlueToothDBusService::m_bluetooth_adapter_address_list.at(indx)); } } void BluetoothTopWindow::adapterNameChangedSlot(QString name) { KyDebug() << name ; _BtNameLabel->set_dev_name(name); _AdapterListSelectComboBox->setCurrentText(name); } void BluetoothTopWindow::adapterPowerStatusChangedSlot(bool status) { KyDebug() << status ; KyWarning() << "_BTServiceReportPowerSwitchFlag:"<< _BTServiceReportPowerSwitchFlag ; _BTServiceReportPowerSwitchFlag = true; KyWarning() << "_BtSwitchBtn->isChecked:"<< _BtSwitchBtn->isChecked() ; if(status != _BtSwitchBtn->isChecked()) _BtSwitchBtn->setChecked(status); else Q_EMIT _BtSwitchBtn->stateChanged(status); } void BluetoothTopWindow::adapterNameChangedOfIndexSlot(int indx , QString name) { KyWarning() << "changed indx:" << indx << "changed name:" << name; if (_AdapterListSelectComboBox->count() > indx) _AdapterListSelectComboBox->setItemText(indx,name); } void BluetoothTopWindow::adapterTrayIconSlot(bool status) { KyDebug(); _BTServiceReportTrayIconSwitchFlag = true; if(status != _BtTrayIconShow->isChecked()) _BtTrayIconShow->setChecked(status); else Q_EMIT _BtTrayIconShow->stateChanged(status); } void BluetoothTopWindow::adapterDiscoverableSlot(bool status) { KyDebug(); _BTServiceReportDiscoverableSwtichFlag = true; if(status != _BtDiscoverable->isChecked()) _BtDiscoverable->setChecked(status); else Q_EMIT _BtDiscoverable->stateChanged(status); } void BluetoothTopWindow::adapterActiveConnectionSlot(bool status) { KyDebug(); _BTServiceReportAutoAudioConnSwtichFlag = true; if(status != _BtAutoAudioConnBtn->isChecked()) _BtAutoAudioConnBtn->setChecked(status); else Q_EMIT _BtAutoAudioConnBtn->stateChanged(status); } void BluetoothTopWindow::btAudioCombineStatusChangeSlot(bool status) { BlueToothDBusService::m_default_bluetooth_adapter->audioCombine(status); BlueToothDBusService::setAudioCombine(status); } void BluetoothTopWindow::adapterChangedRefreshInterface(int indx) { KyDebug() << indx; if (!BlueToothDBusService::m_default_bluetooth_adapter) { KyWarning() << "m_default_bluetooth_adapter is nullptr!"; return; } if(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterPower() != _BtSwitchBtn->isChecked()) _BTServiceReportPowerSwitchFlag = true; if(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterTrayShow() != _BtTrayIconShow->isChecked()) _BTServiceReportTrayIconSwitchFlag = true; if(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterDiscoverable() != _BtDiscoverable->isChecked()) _BTServiceReportDiscoverableSwtichFlag = true; if(BlueToothDBusService::m_default_bluetooth_adapter->getAdapterAutoConn() != _BtAutoAudioConnBtn->isChecked()) _BTServiceReportAutoAudioConnSwtichFlag = true; _AdapterListSelectComboBox->disconnect(); InitDisplayState(); _AdapterListSelectComboBox->setCurrentIndex(indx); connect(_AdapterListSelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(_AdapterListSelectComboBoxSlot(int))); } void BluetoothTopWindow::reloadWindow() { if (m_btServer && m_btServer->m_default_bluetooth_adapter) { int indx = m_btServer->m_bluetooth_adapter_address_list.indexOf(m_btServer->m_default_bluetooth_adapter->getDevAddress()) ; adapterChangedRefreshInterface(indx); } } void BluetoothTopWindow::quitWindow() { } bool BluetoothTopWindow::whetherNeedInfoUser() { KyDebug(); int bluetoothMouseAmount = 0; int bluetoothKeyBoardAmount = 0 ; if (BlueToothDBusService::m_default_bluetooth_adapter) { for (auto var : BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list) { if (!var->getRemoving() && var->isPaired() && var->isConnected()) { if (bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse == var->getDevType()) { bluetoothMouseAmount += 1; } else if (bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard == var->getDevType()) { bluetoothKeyBoardAmount += 1; } else continue; } } } KyInfo() << "Connected mouse amount:" << bluetoothMouseAmount << "Connected KeyBoard amount:" << bluetoothKeyBoardAmount; if (bluetoothMouseAmount == 0 && bluetoothKeyBoardAmount == 0) { KyDebug() << "Not connected KeyBoard and Mouse"; return false; } int systemMouseAndTouchPadAmount = Common::getSystemCurrentMouseAndTouchPadDevCount(); int systemKeyBoardAmount = Common::getSystemCurrentKeyBoardDevCount(); KyInfo() << "Connected bluetooth Mouse amount:" << bluetoothMouseAmount << "Connected bluetooth KeyBoard amount:" << bluetoothKeyBoardAmount << "System Mouse and TouchPad amount:" << systemMouseAndTouchPadAmount << "System KeyBoard amount:" << systemKeyBoardAmount; if ((bluetoothMouseAmount != 0) && (systemMouseAndTouchPadAmount == bluetoothMouseAmount)) { return true; } if ((bluetoothKeyBoardAmount != 0) && (systemKeyBoardAmount == bluetoothKeyBoardAmount)) { return true; } return false; } ukui-bluetooth/ukcc-bluetooth/loadinglabel.h0000664000175000017500000000273515167665755020234 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef LOADINGLABEL_H #define LOADINGLABEL_H #include #include #include #include #include #include #include #include "config.h" #include "ukccbluetoothconfig.h" class LoadingLabel : public QWidget { Q_OBJECT public: explicit LoadingLabel(QObject *parent = nullptr); ~LoadingLabel(); void setTimerStop(); void setTimerStart(); void setTimeReresh(int); private Q_SLOTS: void refreshIconNum(); void mStyle_GSettingsSlot(const QString &key); protected: void paintEvent(QPaintEvent *e); private: int index = 0; QTimer * m_timer; bool _themeIsBlack = false; QGSettings * _mStyle_GSettings = nullptr; private: void initGsettings(); }; #endif // LOADINGLABEL_H ukui-bluetooth/ukcc-bluetooth/bluetooth.h0000664000175000017500000000405315167665755017617 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTH_H #define BLUETOOTH_H #include #include #include #include #include #include #include #include #include "bluetoothmainwindow.h" #include "ukccbluetoothconfig.h" class Bluetooth : public QObject, CommonInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.ukcc.CommonInterface") Q_INTERFACES(CommonInterface) public: Bluetooth(); ~Bluetooth(); QString plugini18nName() Q_DECL_OVERRIDE; int pluginTypes() Q_DECL_OVERRIDE; QWidget * pluginUi() Q_DECL_OVERRIDE; const QString name() const Q_DECL_OVERRIDE; bool isShowOnHomePage() const Q_DECL_OVERRIDE; QIcon icon() const Q_DECL_OVERRIDE; bool isEnable() const Q_DECL_OVERRIDE; void plugin_leave() Q_DECL_OVERRIDE; //static bool isIntel_bt = CommonInterface::isIntel(); //注意:ukcc-bluetooth_%1.ts QString translationPath() const { // 获取多语言文件路径,用于搜索 qDebug() << Q_FUNC_INFO << QStringLiteral("/usr/share/ukui-bluetooth/translations/%1.ts"); return QStringLiteral("/usr/share/ukui-bluetooth/translations/ukcc-bluetooth_%1.ts"); } private: QString pluginName; int pluginType; BlueToothMainWindow *pluginWidget; bool mFirstLoad; }; #endif // BLUETOOTH_H ukui-bluetooth/ukcc-bluetooth/devicebase.h0000664000175000017500000002041415167665770017700 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DEVICEBASE_H #define DEVICEBASE_H #include #include #include #include #include #include #include #include "config.h" class devicebase; class bluetoothadapter; class bluetoothdevice; //devicebase class devicebase : public QObject { Q_OBJECT public: devicebase(); virtual ~devicebase(){} virtual void resetDeviceName(QString) = 0 ; virtual QString getDevName() = 0; virtual QString getDevAddress() = 0; private: QString m_dev_name; QString m_dev_address; }; //devicebase end //bluetoothadapter class bluetoothadapter : public devicebase { Q_OBJECT public: bluetoothadapter(QString dev_name , const QString dev_address , bool dev_block , bool dev_power , bool dev_pairing , bool dev_pairable , bool dev_connecting , bool dev_discovering , bool dev_discoverable, bool dev_activeConnection, bool dev_defaultAdapterMark, bool dev_trayShow); bluetoothadapter(QMap value); ~bluetoothadapter(){ //KyDebug() << "======" << m_dev_name << m_dev_address; } void resetDeviceName(QString) Q_DECL_OVERRIDE ; QString getDevName() Q_DECL_OVERRIDE ; QString getDevAddress() Q_DECL_OVERRIDE ; void setAdapterPower(bool); bool getAdapterPower(); void setAdapterPairing(bool); bool getAdapterPairing(); void setAdapterConnecting(bool); bool getAdapterConnecting(); void setAdapterPairable(bool); bool getAdapterPairable(); void setAdapterDiscovering(bool); bool getAdapterDiscovering(); void setAdapterDiscoverable(bool); bool getAdapterDiscoverable(); void setAdapterAutoConn(bool); bool getAdapterAutoConn(); void setAdapterDefaultMark(bool); bool getAdapterDefaultMark(); void setAdapterTrayShow(bool); bool getAdapterTrayShow(); bool audioCombine(void); void audioCombine(bool v); QMap m_bt_dev_list; // QList m_bluetooth_device_list; QMap m_bt_dev_paired_list; // QList m_bluetooth_device_paired_list; signals: void adapterNameChanged(const QString &name); void adapterPoweredChanged(bool powered); void adapterPairingChanged(bool pairing); void adapterPairableChanged(bool pairable); void adapterConnectingChanged(bool connecting); void adapterTrayIconChanged(bool status); void adapterDiscoverableChanged(bool discoverable); void adapterDiscoveringChanged(bool discovering); void adapterAutoConnStatuChanged(bool status); void adapterDeviceAdded(bluetoothdevice * &device); void adapterDeviceRemoved(bluetoothdevice * &device); void defaultAdapterChanged(const QString &address); private: QString m_dev_name ; QString m_dev_address ; bool m_dev_block ; bool m_dev_power ; bool m_dev_pairing ; bool m_dev_pairable ; bool m_dev_connecting ; bool m_dev_discovering ; bool m_dev_discoverable ; bool m_dev_activeConnection ; bool m_dev_defaultAdapterMark ; bool m_dev_trayShow ; bool m_audio_combine = false ; void bluetoothAdapterDataAnalysis(QMap value); }; //bluetoothadapter end //bluetoothdevice class bluetoothdevice : public devicebase { Q_OBJECT public: enum BLUETOOTH_DEVICE_TYPE{ BtPhone = 0, BtModem, BtComputer, BtNetwork, BtHeadset, BtHeadphones, BtAudiovideo, BtKeyboard, BtMouse, BtJoypad, BtTablet, BtPeripheral, BtCamera, BtPrinter, BtImaging, BtWearable, BtToy, BtHealth, uncategorized }; Q_ENUM(BLUETOOTH_DEVICE_TYPE) bluetoothdevice(QString dev_address , QString dev_name , QString dev_showName , BLUETOOTH_DEVICE_TYPE dev_type , bool dev_paired , bool dev_trusted , bool dev_blocked , bool dev_connected , bool dev_pairing , bool dev_connecting , int dev_battery , int dev_connectFailedId , QString dev_connectFailedDisc , qint16 dev_rssi , bool dev_sendFileMark , QString adapter_address); bluetoothdevice(QMap value); ~bluetoothdevice(){ //KyDebug() << m_dev_name << m_dev_address; } void resetDeviceName(QString) Q_DECL_OVERRIDE ; QString getDevName() Q_DECL_OVERRIDE ; QString getDevAddress() Q_DECL_OVERRIDE ; void setDevShowName(QString); QString getDevShowName(); QString getDevInterfaceShowName(); void setDevType(BLUETOOTH_DEVICE_TYPE); BLUETOOTH_DEVICE_TYPE getDevType(); bool isPaired(); void devPairedChanged(bool); bool isConnected(); void devConnectedChanged(bool); void setDevPairing(bool); bool getDevPairing();//暂时不使用 void setDevConnecting(bool); bool getDevConnecting(); void devMacAddressChanged(QString); void setDevTrust(bool); bool getDevTrust(); void setDevConnFailedInfo(int,QString); void setDevSendFileMark(bool); bool getDevSendFileMark(); qint16 getDevRssi(); void setDevRssi(qint16); int getErrorId(); void setRemoving(bool); bool getRemoving(); signals: void nameChanged(QString); void showNameChanged(QString); void rssiChanged(qint16); void typeChanged(BLUETOOTH_DEVICE_TYPE); void pairedChanged(bool); void connectedChanged(bool); void pairingChanged(bool); void connectingChanged(bool); void trustChanged(bool); void errorInfoRefresh(int,QString); void devConnectingSignal(); private: QString m_dev_address ; QString m_dev_name ; QString m_dev_showName ; BLUETOOTH_DEVICE_TYPE m_dev_type ; bool m_dev_paired = false ; bool m_dev_trusted = false ; bool m_dev_blocked = false ; bool m_dev_connected = false ; bool m_dev_pairing = false ;//暂时不使用 bool m_dev_connecting = false ; int m_dev_battery ; int m_dev_connectFailedId ; QString m_dev_connectFailedDisc ; qint16 m_dev_rssi = -256 ; bool m_dev_sendFileMark ; QString m_adapter_address ;//暂时不使用 bool m_dev_removing = false ;//正在移除该设备 void bluetoothDeviceDataAnalysis(QMap value); }; //bluetoothdevice end #endif // DEVICEBASE_H ukui-bluetooth/ukcc-bluetooth/devicebase.cpp0000664000175000017500000003633115167665770020240 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "devicebase.h" //devicebase devicebase::devicebase() { } //devicebase end //bluetoothadapter bluetoothadapter::bluetoothadapter(QString dev_name , const QString dev_address , bool dev_block , bool dev_power , bool dev_pairing , bool dev_pairable , bool dev_connecting , bool dev_discovering , bool dev_discoverable, bool dev_activeConnection, bool dev_defaultAdapterMark, bool dev_trayShow) :m_dev_name(dev_name), m_dev_address(dev_address) , m_dev_block(dev_block) , m_dev_power(dev_power) , m_dev_pairing(dev_pairing) , m_dev_pairable(dev_pairable) , m_dev_connecting(dev_connecting) , m_dev_discovering(dev_discovering) , m_dev_discoverable(dev_discoverable), m_dev_activeConnection(dev_activeConnection), m_dev_defaultAdapterMark(dev_defaultAdapterMark), m_dev_trayShow(dev_trayShow) { KyDebug(); this->setObjectName(dev_address); } bluetoothadapter::bluetoothadapter(QMap value) { bluetoothAdapterDataAnalysis(value); } void bluetoothadapter::bluetoothAdapterDataAnalysis(QMap value) { //解析adpater数据 QString key = "Name"; if(value.contains(key)) this->m_dev_name = value[key].toString(); key = "Addr"; if(value.contains(key)) this->m_dev_address = value[key].toString(); key = "Block"; if(value.contains(key)) this->m_dev_block = value[key].toBool(); key = "Powered"; if(value.contains(key)) this->m_dev_power = value[key].toBool(); key = "Pairing"; if(value.contains(key)) this->m_dev_pairing = value[key].toBool(); key = "Pairable"; if(value.contains(key)) this->m_dev_pairable = value[key].toBool(); key = "Connecting"; if(value.contains(key)) this->m_dev_connecting = value[key].toBool(); key = "Discovering"; if(value.contains(key)) this->m_dev_discovering = value[key].toBool(); key = "Discoverable"; if(value.contains(key)) this->m_dev_discoverable = value[key].toBool(); key = "ActiveConnection"; if(value.contains(key)) this->m_dev_activeConnection = value[key].toBool(); key = "DefaultAdapter"; if(value.contains(key)) this->m_dev_defaultAdapterMark = value[key].toBool(); key = "trayShow"; if(value.contains(key)) this->m_dev_trayShow = value[key].toBool(); key = "AudioCombine"; if(value.contains(key)) { m_audio_combine = value[key].toBool(); } } void bluetoothadapter::resetDeviceName(QString new_dev_name) { KyDebug(); if (new_dev_name != this->m_dev_name) { this->m_dev_name = new_dev_name; Q_EMIT adapterNameChanged(this->m_dev_name); } } QString bluetoothadapter::getDevName() { KyDebug(); return this->m_dev_name; } QString bluetoothadapter::getDevAddress() { KyDebug(); return this->m_dev_address; } void bluetoothadapter::setAdapterPower(bool value) { KyDebug() << "this->m_dev_power:" << this->m_dev_power << " value:" << value; if (value != this->m_dev_power) { this->m_dev_power = value; Q_EMIT adapterPoweredChanged(this->m_dev_power); } } bool bluetoothadapter::getAdapterPower() { KyDebug(); return this->m_dev_power; } void bluetoothadapter::setAdapterPairing(bool value) { KyDebug() << value ; if (value != this->m_dev_pairing) { this->m_dev_pairing = value; Q_EMIT adapterPairingChanged(this->m_dev_pairing); } } bool bluetoothadapter::getAdapterPairing() { return this->m_dev_pairing; } void bluetoothadapter::setAdapterConnecting(bool value) { KyDebug() << value ; if (value != this->m_dev_connecting) { this->m_dev_connecting = value; Q_EMIT adapterConnectingChanged(this->m_dev_connecting); } } bool bluetoothadapter::getAdapterConnecting() { return this->m_dev_connecting; } void bluetoothadapter::setAdapterPairable(bool value) { if (value != this->m_dev_pairable) { this->m_dev_pairable = value; Q_EMIT adapterPairableChanged(this->m_dev_pairable); } } bool bluetoothadapter::getAdapterPairable() { return this->m_dev_pairable; } void bluetoothadapter::setAdapterDiscovering(bool value) { KyDebug() << value ; if (value != this->m_dev_discovering) { this->m_dev_discovering = value; Q_EMIT adapterDiscoveringChanged(this->m_dev_discovering); } } bool bluetoothadapter::getAdapterDiscovering() { KyDebug() ; return this->m_dev_discovering; } void bluetoothadapter::setAdapterDiscoverable(bool value) { KyDebug() ; if (value != this->m_dev_discoverable) { this->m_dev_discoverable = value; Q_EMIT adapterDiscoverableChanged(this->m_dev_discoverable); } } bool bluetoothadapter::getAdapterDiscoverable() { KyDebug(); return this->m_dev_discoverable; } void bluetoothadapter::setAdapterAutoConn(bool value) { KyDebug(); if (value != this->m_dev_activeConnection) { this->m_dev_activeConnection = value; Q_EMIT adapterAutoConnStatuChanged(this->m_dev_activeConnection); } } bool bluetoothadapter::getAdapterAutoConn() { return this->m_dev_activeConnection; } void bluetoothadapter::setAdapterDefaultMark(bool mark) { KyDebug(); if (mark != this->m_dev_defaultAdapterMark) { this->m_dev_defaultAdapterMark = mark; if (mark) Q_EMIT defaultAdapterChanged(this->m_dev_address); } } bool bluetoothadapter::getAdapterDefaultMark() { KyDebug(); return this->m_dev_defaultAdapterMark; } void bluetoothadapter::setAdapterTrayShow(bool trayShow) { KyDebug(); if (trayShow != this->m_dev_trayShow) { this->m_dev_trayShow = trayShow; Q_EMIT adapterTrayIconChanged(this->m_dev_trayShow); } } bool bluetoothadapter::getAdapterTrayShow() { KyDebug(); return this->m_dev_trayShow; } bool bluetoothadapter::audioCombine() { return m_audio_combine; } void bluetoothadapter::audioCombine(bool v) { m_audio_combine = v; } //bluetoothadapter end //bluetoothdevice bluetoothdevice::bluetoothdevice(QString dev_address , QString dev_name , QString dev_showName , BLUETOOTH_DEVICE_TYPE dev_type , bool dev_paired , bool dev_trusted , bool dev_blocked , bool dev_connected , bool dev_pairing , bool dev_connecting , int dev_battery , int dev_connectFailedId , QString dev_connectFailedDisc , qint16 dev_rssi , bool dev_sendFileMark , QString adapter_address ) :m_dev_address ( dev_address ) ,m_dev_name ( dev_name ) ,m_dev_showName ( dev_showName ) ,m_dev_type ( dev_type ) ,m_dev_paired ( dev_paired ) ,m_dev_trusted ( dev_trusted ) ,m_dev_blocked ( dev_blocked ) ,m_dev_connected ( dev_connected ) ,m_dev_pairing ( dev_pairing ) ,m_dev_connecting ( dev_connecting ) ,m_dev_battery ( dev_battery ) ,m_dev_connectFailedId ( dev_connectFailedId ) ,m_dev_connectFailedDisc ( dev_connectFailedDisc ) ,m_dev_rssi ( dev_rssi ) ,m_dev_sendFileMark ( dev_sendFileMark ) ,m_adapter_address ( adapter_address ) { this->setObjectName(dev_address); } bluetoothdevice::bluetoothdevice(QMap value) { bluetoothDeviceDataAnalysis(value); } void bluetoothdevice::bluetoothDeviceDataAnalysis(QMap value) { //解析bluetooth device数据 QString key = "Paired"; if(value.contains(key)) this->m_dev_paired = value[key].toBool(); key = "Trusted"; if(value.contains(key)) this->m_dev_trusted = value[key].toBool(); key = "Blocked"; if(value.contains(key)) this->m_dev_blocked = value[key].toBool(); key = "Connected"; if(value.contains(key)) this->m_dev_connected = value[key].toBool(); key = "Name"; if(value.contains(key)) this->m_dev_name = value[key].toString(); key = "ShowName"; if(value.contains(key)) this->m_dev_showName = value[key].toString(); key = "Addr"; if(value.contains(key)) this->m_dev_address = value[key].toString(); key = "Type"; if(value.contains(key)) this->m_dev_type = bluetoothdevice::BLUETOOTH_DEVICE_TYPE(value[key].toInt()); key = "Pairing"; if(value.contains(key)) this->m_dev_pairing = value[key].toBool(); key = "Connecting"; if(value.contains(key)) this->m_dev_connecting = value[key].toBool(); key = "Battery"; if(value.contains(key)) this->m_dev_battery = value[key].toInt(); key = "ConnectFailedId"; if(value.contains(key)) this->m_dev_connectFailedId = value[key].toInt(); key = "ConnectFailedDisc"; if(value.contains(key)) this->m_dev_connectFailedDisc = value[key].toString(); key = "Rssi"; if(value.contains(key)) this->m_dev_rssi = value[key].toInt(); key = "FileTransportSupport"; if(value.contains(key)) this->m_dev_sendFileMark = value[key].toBool(); key = "Adapter"; if(value.contains(key)) this->m_adapter_address = value[key].toString(); if (this->m_dev_name.isEmpty()) this->m_dev_name = this->m_dev_address; } void bluetoothdevice::resetDeviceName(QString new_dev_name) { //KyDebug(); if(new_dev_name != this->m_dev_name) { this->m_dev_name = new_dev_name; Q_EMIT nameChanged(new_dev_name); } } void bluetoothdevice::setDevShowName(QString new_dev_showName) { //KyDebug() << this->m_dev_showName << new_dev_showName ; if(new_dev_showName != this->m_dev_showName) { this->m_dev_showName = new_dev_showName; Q_EMIT showNameChanged(new_dev_showName); } } QString bluetoothdevice::getDevShowName() { return this->m_dev_showName; } QString bluetoothdevice::getDevInterfaceShowName() { if(this->m_dev_showName.isEmpty()) return this->m_dev_name; else return this->m_dev_showName; } void bluetoothdevice::devMacAddressChanged(QString macAddress) { if(this->m_dev_address != macAddress) { this->m_dev_address = macAddress; //emit macAddressChanged(value); } } QString bluetoothdevice::getDevName() { //KyDebug(); return this->m_dev_name; } QString bluetoothdevice::getDevAddress() { //KyDebug(); return this->m_dev_address; } void bluetoothdevice::setDevType(BLUETOOTH_DEVICE_TYPE type) { //KyDebug(); if (this->m_dev_type != type) { this->m_dev_type = type; Q_EMIT typeChanged(type); } } bluetoothdevice::BLUETOOTH_DEVICE_TYPE bluetoothdevice::getDevType() { //KyDebug(); return this->m_dev_type; } void bluetoothdevice::setDevPairing(bool value) { if (value != this->m_dev_pairing) { this->m_dev_pairing = value; Q_EMIT pairingChanged(value); } } bool bluetoothdevice::getDevPairing() { return this->m_dev_pairing; } void bluetoothdevice::setDevConnecting(bool value) { KyWarning() << value << this->m_dev_connecting ; if (value != this->m_dev_connecting) { this->m_dev_connecting = value; Q_EMIT connectingChanged(value); } } bool bluetoothdevice::getDevConnecting() { return this->m_dev_connecting; } void bluetoothdevice::setDevTrust(bool value) { //KyDebug(); if (value != this->m_dev_trusted) { this->m_dev_trusted = value; Q_EMIT trustChanged(value); } } bool bluetoothdevice::getDevTrust() { //KyDebug(); return this->m_dev_trusted; } bool bluetoothdevice::isPaired() { //KyDebug(); return m_dev_paired; } void bluetoothdevice::devPairedChanged(bool value) { qDebug() << Q_FUNC_INFO << value << this->m_dev_paired << __LINE__; if(value != this->m_dev_paired ) { this->m_dev_paired = value; Q_EMIT pairedChanged(value); } } bool bluetoothdevice::isConnected() { //KyDebug(); return m_dev_connected; } void bluetoothdevice::devConnectedChanged(bool value) { if(value != this->m_dev_connected) { this->m_dev_connected = value; Q_EMIT connectedChanged(value); } } void bluetoothdevice::setDevSendFileMark(bool mark) { if (mark != this->m_dev_sendFileMark) this->m_dev_sendFileMark = mark; } bool bluetoothdevice::getDevSendFileMark() { return this->m_dev_sendFileMark; } void bluetoothdevice::setDevRssi(qint16 rssi) { if (m_dev_rssi != rssi) { this->m_dev_rssi = rssi; Q_EMIT this->rssiChanged(rssi); } } qint16 bluetoothdevice::getDevRssi() { return this->m_dev_rssi; } void bluetoothdevice::setDevConnFailedInfo(int errId,QString errInfo) { //if(errId != this->m_dev_connectFailedId) { this->m_dev_connectFailedId = errId; } //if(errInfo != this->m_dev_connectFailedDisc) { this->m_dev_connectFailedDisc = errInfo; } //收到一次转发一下 Q_EMIT errorInfoRefresh(errId,errInfo); } int bluetoothdevice::getErrorId() { return this->m_dev_connectFailedId; } void bluetoothdevice::setRemoving(bool state) { this->m_dev_removing = state; } bool bluetoothdevice::getRemoving() { return this->m_dev_removing; } //bluetoothdevice end // ukui-bluetooth/ukcc-bluetooth/devrenamedialog.h0000664000175000017500000000432515167665755020742 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DEVRENAMEDIALOG_H #define DEVRENAMEDIALOG_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #define INPUT_STRNAME_MIN 1 #define INPUT_STRNAME_MAX 32 class DevRenameDialog : public QDialog { Q_OBJECT public: enum DEV_RENAME_DIALOG_TYPE { DEVRENAMEDIALOG_ADAPTER = 0, DEVRENAMEDIALOG_BT_DEVICE = 1 }; Q_ENUM(DEV_RENAME_DIALOG_TYPE) explicit DevRenameDialog(QWidget *parent = nullptr); ~DevRenameDialog(); void setDevName(const QString &); void setRenameInterface(DEV_RENAME_DIALOG_TYPE mode); void initGsettings(); QLabel * titleLabel = nullptr; QLabel * textLabel = nullptr; DEV_RENAME_DIALOG_TYPE _mMode = DEVRENAMEDIALOG_ADAPTER; private slots: void gsettingsSlot(const QString &); protected: void paintEvent(QPaintEvent *); void keyPressEvent(QKeyEvent *); public slots: void lineEditSlot(const QString &); signals: void nameChanged(QString); private: void initUI(); int _fontSize; bool isblack = false; QString adapterOldName; QLabel *tipLabel = nullptr; QGSettings *gsettings = nullptr; QPushButton *closeBtn = nullptr; QPushButton *acceptBtn = nullptr; QPushButton *rejectBtn = nullptr; QLineEdit *lineEdit = nullptr; }; #endif // DEVRENAMEDIALOG_H ukui-bluetooth/ukcc-bluetooth/bluetoothmiddlewindow.cpp0000664000175000017500000002723315167665770022563 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothmiddlewindow.h" BluetoothMiddleWindow::BluetoothMiddleWindow(BlueToothDBusService * btServer,QWidget * parent): m_btServer(btServer), QWidget(parent) { this->setFocusPolicy(Qt::NoFocus); InitNormalWidgetMiddle(); InitConnectionData(); if (btServer->m_default_bluetooth_adapter) AddMyBluetoothDevices(); } BluetoothMiddleWindow::~BluetoothMiddleWindow() { } void BluetoothMiddleWindow::InitNormalWidgetMiddle() { // KyDebug(); QVBoxLayout *NormalWidgetMiddleLayout = new QVBoxLayout(this); NormalWidgetMiddleLayout->setSpacing(8); NormalWidgetMiddleLayout->setContentsMargins(0,0,0,0); //~ contents_path /Bluetooth/My Devices QLabel *MyDevicesLabel = new QLabel(tr("My Devices"),this); MyDevicesLabel->resize(72,25); MyDevicesLabel->setContentsMargins(16,0,0,0); NormalWidgetMiddleLayout->addWidget(MyDevicesLabel,Qt::AlignTop); _MNormalFrameMiddle = new QFrame(this); _MNormalFrameMiddle->setMinimumWidth(582); _MNormalFrameMiddle->setFrameShape(QFrame::Shape::Box); _MNormalFrameMiddle->setContentsMargins(0,0,0,0); NormalWidgetMiddleLayout->addWidget(_MNormalFrameMiddle,1,Qt::AlignTop); _NormalWidgetPairedDevLayout = new QVBoxLayout(_MNormalFrameMiddle); _NormalWidgetPairedDevLayout->setSpacing(0); _NormalWidgetPairedDevLayout->setContentsMargins(0,0,0,0); _MNormalFrameMiddle->setLayout(_NormalWidgetPairedDevLayout); _MConnectedNormalFrameMiddle = new QWidget(_MNormalFrameMiddle); _MConnectedNormalFrameMiddle->setMinimumWidth(582); // _MConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box); _MConnectedNormalFrameMiddle->setContentsMargins(0,0,0,0); _NormalWidgetPairedDevLayout->addWidget(_MConnectedNormalFrameMiddle); _MNotConnectedNormalFrameMiddle = new QWidget(_MNormalFrameMiddle); _MNotConnectedNormalFrameMiddle->setMinimumWidth(582); // _MNotConnectedNormalFrameMiddle->setFrameShape(QFrame::Shape::Box); _MNotConnectedNormalFrameMiddle->setContentsMargins(0,0,0,0); _NormalWidgetPairedDevLayout->addWidget(_MNotConnectedNormalFrameMiddle); _NormalWidgetConnecededDevLayout = new QVBoxLayout(_MNormalFrameMiddle); _NormalWidgetConnecededDevLayout->setSpacing(0); _NormalWidgetConnecededDevLayout->setContentsMargins(0,0,0,0); _MConnectedNormalFrameMiddle->setLayout(_NormalWidgetConnecededDevLayout); _NormalWidgetNotConnecededDevLayout = new QVBoxLayout(_MNotConnectedNormalFrameMiddle); _NormalWidgetNotConnecededDevLayout->setSpacing(0); _NormalWidgetNotConnecededDevLayout->setContentsMargins(0,0,0,0); _MNotConnectedNormalFrameMiddle->setLayout(_NormalWidgetNotConnecededDevLayout); } void BluetoothMiddleWindow::InitConnectionData() { if (m_btServer) { connect(m_btServer,&BlueToothDBusService::deviceRemoveSignal,this,&BluetoothMiddleWindow::deviceRemoveSlot); connect(m_btServer,&BlueToothDBusService::devicePairedSuccess,this,&BluetoothMiddleWindow::devicePairedSuccessSlot); connect(m_btServer,&BlueToothDBusService::defaultAdapterChangedSignal,this,&BluetoothMiddleWindow::defaultAdapterChangedSlot); } } //void BluetoothMiddleWindow::AddMyDeviceWidgetConnectedAndNotConnected() //{ // //测试代码 //} void BluetoothMiddleWindow::AddMyBluetoothDevices() { if (!BlueToothDBusService::m_default_bluetooth_adapter) return; QStringList pairedDevKeyList = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.keys(); // 存放的就是QMap的key值 QStringList sortlist = BlueToothDBusService::getDefaultAdapterPairedDev(); KyDebug() << pairedDevKeyList; for (QString dev_addr:sortlist) { if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(dev_addr)) { if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->isPaired()) addMyDeviceItemUI(dev_addr); } else { KyWarning() << "error devid: " << dev_addr; } } } void BluetoothMiddleWindow::addMyDeviceItemUI(QString device_address) { KyDebug() << device_address; bluetoothdevicewindowitem *item = this->findChild(device_address); if (item) { KyInfo() << device_address << ":device is exist" ; return; } bool show_line = true; if (_NormalWidgetConnecededDevLayout->count() == 0 && _NormalWidgetNotConnecededDevLayout->count() == 0) show_line = false; item = new bluetoothdevicewindowitem(device_address,show_line,this); if (item) { connect(item,&bluetoothdevicewindowitem::devConnectedChanged,this,[=](bool status){ devConnectedChangedSlot(device_address,status); }); connect(item,&bluetoothdevicewindowitem::bluetoothDeviceItemRemove,this,&BluetoothMiddleWindow::deviceRemoveSlot); if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[device_address]->isConnected()) { item->setParent(_MConnectedNormalFrameMiddle); _NormalWidgetConnecededDevLayout->insertWidget(0,item,1,Qt::AlignTop); } else { item->setParent(_MNotConnectedNormalFrameMiddle); if(_NormalWidgetNotConnecededDevLayout->count() == 0) { item->setLineFrameHidden(true); setLastDevItemWindowLine(false); } // if (bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[device_address]->getDevType() || // bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard == BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[device_address]->getDevType()) // { // setLastDevItemWindowLine(false); // item->setEnabled(false); // _NormalWidgetNotConnecededDevLayout->addWidget(item); // } // else _NormalWidgetNotConnecededDevLayout->insertWidget(0,item,1,Qt::AlignTop); } } } void BluetoothMiddleWindow::removeMyDeviceItemUI(QString device_address) { KyDebug() << device_address; bluetoothdevicewindowitem *item = _MNotConnectedNormalFrameMiddle->findChild(device_address); if (item) { _NormalWidgetNotConnecededDevLayout->removeWidget(item); item->disconnect(); item->deleteLater(); } item = _MConnectedNormalFrameMiddle->findChild(device_address); if (item) { _NormalWidgetConnecededDevLayout->removeWidget(item); item->disconnect(); item->deleteLater(); } if (_NormalWidgetNotConnecededDevLayout->count() == 0 && _NormalWidgetConnecededDevLayout->count() == 0) Q_EMIT myDeviceWindosHiddenSignal(true); else { setLastDevItemWindowLine(true); } } void BluetoothMiddleWindow::setLastDevItemWindowLine(bool status) { //设置最后一个item line是否需要显示 KyDebug() << "" << _NormalWidgetNotConnecededDevLayout->count(); if (_NormalWidgetNotConnecededDevLayout->count() >= 1) { QLayoutItem *item = _NormalWidgetNotConnecededDevLayout->itemAt(_NormalWidgetNotConnecededDevLayout->count()-1); if (item->widget() != 0) { QString device_address = item->widget()->objectName(); KyDebug() << device_address; bluetoothdevicewindowitem *dev_item = _MNotConnectedNormalFrameMiddle->findChild(device_address); if (dev_item) dev_item->setLineFrameHidden(status); } return; } KyDebug() << "" << _NormalWidgetConnecededDevLayout->count(); if (_NormalWidgetConnecededDevLayout->count() >= 1) { QLayoutItem *item = _NormalWidgetConnecededDevLayout->itemAt(_NormalWidgetConnecededDevLayout->count()-1); if (item->widget() != 0) { QString device_address = item->widget()->objectName(); KyDebug() << device_address; bluetoothdevicewindowitem *dev_item = _MConnectedNormalFrameMiddle->findChild(device_address); if (dev_item) dev_item->setLineFrameHidden(status); } } } void BluetoothMiddleWindow::deviceRemoveSlot(QString dev_address) { KyDebug() << dev_address; removeMyDeviceItemUI(dev_address); } void BluetoothMiddleWindow::devConnectedChangedSlot(QString dev_address,bool status) { KyDebug() << dev_address << " ConnectedChanged :" << status; bluetoothdevicewindowitem *item = _MNormalFrameMiddle->findChild(dev_address); if (item) { KyDebug() << dev_address << "==== ConnectedChanged :" << status; if (status) { _NormalWidgetNotConnecededDevLayout->removeWidget(item); item->setParent(_MConnectedNormalFrameMiddle); if ((_NormalWidgetConnecededDevLayout->count() == 0) && (_NormalWidgetNotConnecededDevLayout->count() == 0)) item->setLineFrameHidden(true); else item->setLineFrameHidden(false); setLastDevItemWindowLine(true); _NormalWidgetConnecededDevLayout->insertWidget(0,item,1,Qt::AlignTop); } else { _NormalWidgetConnecededDevLayout->removeWidget(item); item->setParent(_MNotConnectedNormalFrameMiddle); if (_NormalWidgetNotConnecededDevLayout->count() == 0) { item->setLineFrameHidden(true); setLastDevItemWindowLine(false); } else item->setLineFrameHidden(false); _NormalWidgetNotConnecededDevLayout->insertWidget(0,item,1,Qt::AlignTop); } } } void BluetoothMiddleWindow::devicePairedSuccessSlot(QString dev_address) { if (this->isHidden()) Q_EMIT myDeviceWindosHiddenSignal(false); ; addMyDeviceItemUI(dev_address); } void BluetoothMiddleWindow::defaultAdapterChangedSlot(int indx) { KyDebug() << indx; quitWindow(); reloadWindow(); } void BluetoothMiddleWindow::clearMyDevicesUI() { KyDebug() << "Connected dev count :" << _NormalWidgetConnecededDevLayout->count() << "Paired dev count :" << _NormalWidgetNotConnecededDevLayout->count(); //清空连接成功列表数据 QLayoutItem *child; while(_NormalWidgetConnecededDevLayout->count()!=0) { child = _NormalWidgetConnecededDevLayout->takeAt(0); if(child->widget() != 0) { delete child->widget(); } delete child; } //清空未连接列表数据 while(_NormalWidgetNotConnecededDevLayout->count()!=0) { child = _NormalWidgetNotConnecededDevLayout->takeAt(0); if(child->widget() != 0) { delete child->widget(); } delete child; } } void BluetoothMiddleWindow::reloadWindow() { clearMyDevicesUI(); AddMyBluetoothDevices(); } void BluetoothMiddleWindow::quitWindow() { clearMyDevicesUI(); } ukui-bluetooth/ukcc-bluetooth/ukccbluetoothconfig.cpp0000664000175000017500000001611515167665770022205 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "ukccbluetoothconfig.h" QGSettings* ukccbluetoothconfig::ukccGsetting = new QGSettings(GSETTING_SCHEMA_UKCC,GSETTING_PACH_UKCC); ukccbluetoothconfig::ukccbluetoothconfig() { } ukccbluetoothconfig::~ukccbluetoothconfig() { ukccGsetting->deleteLater(); } void ukccbluetoothconfig::launchBluetoothServiceStart(const QString &processName) { KyDebug(); QProcess *process = new QProcess(); QString cmd = processName; //cmd.append(" -o"); KyDebug() << cmd ; process->startDetached(cmd); } void ukccbluetoothconfig::killAppProcess(const quint64 &processId) { KyDebug() << processId; QProcess *process = new QProcess(); QString cmd = QString("kill -9 %1").arg(processId); process->startDetached(cmd); } bool ukccbluetoothconfig::checkProcessRunning(const QString &processName, QList &listProcessId) { KyDebug(); bool res(false); QString strCommand; //if(processName == BluetoothServiceExePath) // strCommand = "ps -ef|grep '" + processName + " -o' |grep -v grep |awk '{print $2}'"; //else strCommand = "ps -ef|grep '" + processName + "' |grep -v grep |awk '{print $2}'"; KyDebug() << strCommand ; QByteArray ba = strCommand.toLatin1(); const char* strFind_ComName = ba.data(); //const char* strFind_ComName = convertQString2char(strCommand); FILE * pPipe = popen(strFind_ComName, "r"); if (pPipe) { std::string com; char name[512] = { 0 }; while (fgets(name, sizeof(name)-1, pPipe) != NULL) { int nLen = strnlen(name, sizeof(name)-1); if (nLen > 0 && name[nLen - 1] == '\n') //&& name[0] == '/') { name[nLen - 1] = '\0'; listProcessId.append(atoi(name)); res = true; break; } } pclose(pPipe); } return res; } static QString executeLinuxCmd(QString strCmd) { QProcess p; p.start("bash", QStringList() <<"-c" << strCmd); p.waitForFinished(); QString strResult = p.readAllStandardOutput(); return strResult.toLower(); } void ukccbluetoothconfig::setEnvPCValue() { KyDebug(); unsigned int productFeatures = 0; char * projectName = ""; char * projectSubName = ""; productFeatures = kdk_system_get_productFeatures(); projectName = kdk_system_get_projectName(); QString qs_projectName = QString(projectName); projectSubName = kdk_system_get_projectSubName(); QString qs_projectSubName = QString(projectSubName); envPC = Environment::NOMAL; QString str = executeLinuxCmd("cat /proc/cpuinfo | grep Hardware"); if(str.length() == 0) { goto FuncEnd; } if(str.indexOf("huawei") != -1 || str.indexOf("pangu") != -1 || str.indexOf("kirin") != -1) { envPC = Environment::HUAWEI; } FuncEnd: if (QFile::exists("/etc/apt/ota_version")) envPC = Environment::LAIKA; else if(qs_projectName.contains("V10SP1-edu",Qt::CaseInsensitive) && qs_projectSubName.contains("mavis",Qt::CaseInsensitive)) { envPC = Environment::MAVIS; } KyInfo() << envPC ; } const QImage ukccbluetoothconfig::loadSvgImage(const QPixmap &source, const PixmapColor &cgColor) { QImage img = source.toImage(); for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0) { switch (cgColor) { case PixmapColor::WHITE: color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); break; case PixmapColor::BLACK: color.setRed(0); color.setGreen(0); color.setBlue(0); img.setPixelColor(x, y, color); break; case PixmapColor::GRAY: color.setRed(152); color.setGreen(163); color.setBlue(164); img.setPixelColor(x, y, color); break; case PixmapColor::BLUE: color.setRed(61); color.setGreen(107); color.setBlue(229); img.setPixelColor(x, y, color); break; default: return img; break; } } } } return img; } const QPixmap ukccbluetoothconfig::loadSvg(const QPixmap &source, const PixmapColor &cgColor) { QImage img = source.toImage(); for (int x = 0; x < img.width(); x++) { for (int y = 0; y < img.height(); y++) { auto color = img.pixelColor(x, y); if (color.alpha() > 0) { switch (cgColor) { case PixmapColor::WHITE: color.setRed(255); color.setGreen(255); color.setBlue(255); img.setPixelColor(x, y, color); break; case PixmapColor::BLACK: color.setRed(0); color.setGreen(0); color.setBlue(0); img.setPixelColor(x, y, color); break; case PixmapColor::GRAY: color.setRed(152); color.setGreen(163); color.setBlue(164); img.setPixelColor(x, y, color); break; case PixmapColor::BLUE: color.setRed(61); color.setGreen(107); color.setBlue(229); img.setPixelColor(x, y, color); break; default: return source; break; } } } } return QPixmap::fromImage(img); } bool ukccbluetoothconfig::ukccBtBuriedSettings(QString pluginName, QString settingsName, QString action, QString value) { #ifdef UKCC_BLUETOOTH_DATA_BURIAL_POINT try { bool res = ukcc::UkccCommon::buriedSettings(pluginName,settingsName,action,value); return res; } catch(std::exception &e) { KyWarning() << e.what(); return false; } #endif return false; } ukui-bluetooth/ukcc-bluetooth/bluetoothbottomwindow.cpp0000664000175000017500000005352615167665770022635 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothbottomwindow.h" #include typedef QPair fruit; //设备显示排序 QVector m_btDevSortList_vec; BluetoothBottomWindow::BluetoothBottomWindow(BlueToothDBusService * btServer,QWidget * parent) : m_btServer(btServer), QWidget(parent) { this->setFocusPolicy(Qt::NoFocus); InitNormalWidgetBottom(); InitConnectionData(); if (btServer->m_default_bluetooth_adapter) AddBluetoothDevices(); } BluetoothBottomWindow::~BluetoothBottomWindow() { } void BluetoothBottomWindow::InitNormalWidgetBottom() { KyDebug(); QVBoxLayout *_MNormalWidgetBottomLayout = new QVBoxLayout(this); _MNormalWidgetBottomLayout->setSpacing(8); _MNormalWidgetBottomLayout->setContentsMargins(0,0,0,0); QHBoxLayout *titleLayout = new QHBoxLayout(this); titleLayout->setSpacing(0); titleLayout->setContentsMargins(0,0,0,0); //~ contents_path /Bluetooth/Bluetooth Devices QLabel *OtherDevicesLabel = new QLabel(tr("Bluetooth Devices"),this); OtherDevicesLabel->resize(72,25); OtherDevicesLabel->setContentsMargins(16,0,10,0); titleLayout->addWidget(OtherDevicesLabel, 1, Qt::AlignLeft); _LoadIcon = new LoadingLabel(this); _LoadIcon->setFixedSize(16,16); _LoadIcon->setTimerStart(); titleLayout->addWidget(_LoadIcon, 1, Qt::AlignLeft); _DevTypeSelectComboBox = new QComboBox(this); _DevTypeSelectComboBox->clear(); _DevTypeSelectComboBox->addItems(devTypeSelectStrList); currentShowTypeFlag = _DEV_TYPE(_DevTypeSelectComboBox->currentIndex()); _DevTypeSelectComboBox->setFocusPolicy(Qt::NoFocus); titleLayout->addStretch(25); titleLayout->addWidget(_DevTypeSelectComboBox, 1, Qt::AlignRight); _MNormalWidgetBottomLayout->addLayout(titleLayout); _MNormalFrameBottom = new QFrame(this); // _MNormalFrameBottom->setMinimumWidth(582); _MNormalFrameBottom->adjustSize(); _MNormalFrameBottom->setFrameShape(QFrame::Shape::Box); _MNormalFrameBottom->setContentsMargins(0,0,0,0); _MNormalWidgetBottomLayout->addWidget(_MNormalFrameBottom,1,Qt::AlignTop); _NormalWidgetCacheDevLayout = new QVBoxLayout(this); _NormalWidgetCacheDevLayout->setSpacing(0); _NormalWidgetCacheDevLayout->setContentsMargins(0,0,0,0); _NormalWidgetCacheDevLayout->setAlignment(Qt::AlignTop); _NormalWidgetCacheDevLayout->addStretch(10); _MNormalFrameBottom->setLayout(_NormalWidgetCacheDevLayout); } void BluetoothBottomWindow::InitConnectionData() { connect(_DevTypeSelectComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(_DevTypeSelectComboBoxSlot(int))); if (m_btServer) { connect(m_btServer,&BlueToothDBusService::deviceAddSignal,this,&BluetoothBottomWindow::deviceAddSlot); connect(m_btServer,&BlueToothDBusService::deviceRemoveSignal,this,&BluetoothBottomWindow::deviceRemoveSlot); connect(m_btServer,&BlueToothDBusService::devicePairedSuccess,this,&BluetoothBottomWindow::devicePairedSuccessSlot); connect(m_btServer,&BlueToothDBusService::adapterDiscoveringChanged,this,&BluetoothBottomWindow::adapterDiscoveringSlot); connect(m_btServer,&BlueToothDBusService::defaultAdapterChangedSignal,this,&BluetoothBottomWindow::defaultAdapterChangedSlot); } } void BluetoothBottomWindow::AddBluetoothDevices() { if (!BlueToothDBusService::m_default_bluetooth_adapter) return; QList devKeyList = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.keys(); // 存放的就是QMap的key值 KyDebug() << devKeyList; for(QString dev_addr:devKeyList) { if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(dev_addr) && !BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->isPaired()) addOneBluetoothDeviceItemUi(dev_addr); } KyDebug() << m_btDevSortList_vec; } void BluetoothBottomWindow::addOneBluetoothDeviceItemUi(QString dev_address) { KyDebug(); //设备不存在 if(!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(dev_address)) { KyDebug() << "device is NULL!"; return ; } if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevName().isEmpty()) { KyDebug() << "device is not name!"; return ; } KyDebug() << dev_address << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevRssi(); //非法设备/和当前显示界面类型选择不一致 if (!whetherToDisplayInTheCurrentInterface(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevType())) { KyInfo() << "Dev Type Not!" ; return ; } //设备界面已存在 bluetoothdevicewindowitem * item = this->findChild(dev_address); if (item) { KyDebug() << "device is exist" ; return; } int insert_index = getDevRssiItemInsertIndex(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevRssi(), dev_address); KyDebug() << "insert_index:"<< insert_index ; if (insert_index == -1) { m_btDevSortList_vec.append(fruit(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevAddress(),BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevRssi())); insert_index = _NormalWidgetCacheDevLayout->count(); } else { m_btDevSortList_vec.insert(insert_index,fruit(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevAddress(),BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->getDevRssi())); if (insert_index > _NormalWidgetCacheDevLayout->count()) insert_index = _NormalWidgetCacheDevLayout->count(); } KyDebug() << "_NormalWidgetCacheDevLayout count:" << _NormalWidgetCacheDevLayout->count() ; KyDebug() << "m_btDevSortList_vec:" << m_btDevSortList_vec; bool showLine = true; if (_NormalWidgetCacheDevLayout->count() == 0) showLine = false; item = new bluetoothdevicewindowitem(dev_address,showLine,this);//一直显示 connect(item,&bluetoothdevicewindowitem::devRssiChanged,this,[=](qint64 value) { KyDebug() << item->objectName() << value ; //显示位置调整 adjustDevItemDisplayPosition(item->objectName(),value); }); connect(item,&bluetoothdevicewindowitem::bluetoothDeviceItemRemove,this,&BluetoothBottomWindow::deviceRemoveSlot); if (insert_index == _NormalWidgetCacheDevLayout->count()) { item->setLineFrameHidden(true); setLastDevItemWindowLine(false); } else { item->setLineFrameHidden(false); } _NormalWidgetCacheDevLayout->insertWidget(insert_index,item,0,Qt::AlignTop); } bool BluetoothBottomWindow::whetherToDisplayInTheCurrentInterface(bluetoothdevice::BLUETOOTH_DEVICE_TYPE devType) { KyDebug() << devType << _DEV_TYPE(_DevTypeSelectComboBox->currentIndex()); if (nullptr != _DevTypeSelectComboBox) currentShowTypeFlag = _DEV_TYPE(_DevTypeSelectComboBox->currentIndex()); if(_DEV_TYPE::BT_All == currentShowTypeFlag)//显示为全部设备时,直接返回true { KyDebug() << "currentShowTypeFlag:" << currentShowTypeFlag ; return true; } _DEV_TYPE temp_dev_type ; if (devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadset || devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadphones || devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtAudiovideo) { temp_dev_type = BT_Audio; } else if (devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse || devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard) { temp_dev_type = BT_Peripherals; } else if (devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer) { temp_dev_type = BT_Computer; } else if (devType == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone) { temp_dev_type = BT_Phone; } else { temp_dev_type = BT_Other; } KyInfo() << "currentShowTypeFlag:" << currentShowTypeFlag << "temp_dev_type:" << temp_dev_type ; if (currentShowTypeFlag == temp_dev_type) { KyInfo() << "dev type == : true" ; return true; } else { KyInfo() << "dev type == : false" ;; return false; } } int BluetoothBottomWindow::getDevRssiItemInsertIndex(qint16 currDevRssi, QString id /*= ""*/) { KyDebug() << "currDevRssi:"<< currDevRssi ; //KyDebug () << "m_btDevSortList_vec:"<< m_btDevSortList_vec ; for(auto it = m_btDevSortList_vec.begin() ; it != m_btDevSortList_vec.end() ; ++it) { //KyDebug() << "it->first(address):"<< it->first << "it->second(rssi):"<< it->second ; if (it->second < currDevRssi) { //KyDebug() << "========index:"<< m_btDevSortList_vec.indexOf(fruit(it->first,it->second)) ; return (m_btDevSortList_vec.indexOf(fruit(it->first,it->second))); } else if (it->second == currDevRssi) { if(it->first < id) { return (m_btDevSortList_vec.indexOf(fruit(it->first,it->second))); } } } return -1; } void BluetoothBottomWindow::_DevTypeSelectComboBoxSlot(int indx) { KyDebug() << indx; ukccbluetoothconfig::ukccBtBuriedSettings(QString("Bluetooth"),QString("DevTypeSelectComboBox"),QString("settings"),QString::number(indx)); currentShowTypeFlag = _DEV_TYPE(indx); //清空列表数据 QLayoutItem *child; while(_NormalWidgetCacheDevLayout->count()!=0) { child = _NormalWidgetCacheDevLayout->takeAt(0); if(child->widget() != 0) { delete child->widget(); } delete child; } m_btDevSortList_vec.clear(); _DevTypeSelectComboBox->clearFocus(); reloadDeviceListItem(currentShowTypeFlag); } void BluetoothBottomWindow::reloadDeviceListItem(BluetoothBottomWindow::_DEV_TYPE flag) { KyDebug() << flag; if (!BlueToothDBusService::m_default_bluetooth_adapter) { KyWarning() << "m_default_bluetooth_adapter is NULL!" ; return ; } //KyInfo() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list; QList devKeyList = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.keys(); // 存放的就是QMap的key值 int count = 0; for (QString dev_addr : devKeyList) { if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->isPaired()) continue; switch (flag) { case _DEV_TYPE::BT_All: if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; break; case _DEV_TYPE::BT_Audio: if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadset || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadphones || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtAudiovideo) { if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; } break; case _DEV_TYPE::BT_Peripherals: if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard) { if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; } break; case _DEV_TYPE::BT_Computer: if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer) { if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; } break; case _DEV_TYPE::BT_Phone: if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone) { if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; } break; case _DEV_TYPE::BT_Other: if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadset || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadphones || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtAudiovideo || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_addr]->getDevType() == bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer) break; else { if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; } break; default: if(count == 0) { addOneBluetoothDeviceItemUi(dev_addr); } else { QTimer::singleShot(50,this,[=]{ addOneBluetoothDeviceItemUi(dev_addr); }); } count ++; break; } } } void BluetoothBottomWindow::deviceAddSlot(QString dev_address) { KyDebug(); if (BlueToothDBusService::m_default_bluetooth_adapter && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(dev_address)) { if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[dev_address]->isPaired()) { if (_LoadIcon->isHidden()) { _LoadIcon->show(); _LoadIcon->setTimerStart(); } KyDebug() << dev_address << ":dev is not pair!" ; addOneBluetoothDeviceItemUi(dev_address); } } } void BluetoothBottomWindow::removeBluetoothDeviceItemUi(QString address) { KyDebug() << address ; //移除蓝牙设备列表的设备 bluetoothdevicewindowitem *item = _MNormalFrameBottom->findChild(address); if(item) { KyDebug() << item->objectName(); _NormalWidgetCacheDevLayout->removeWidget(item); item->disconnect(); item->deleteLater(); } else { KyDebug() << "bluetooth device list NULL!!"; } for(auto it = m_btDevSortList_vec.begin(); it != m_btDevSortList_vec.end() ;++it) { if (it->first == address) { KyDebug() << m_btDevSortList_vec; m_btDevSortList_vec.removeAll(fruit(it->first,it->second)); KyDebug() << m_btDevSortList_vec; break; } } KyDebug() << "remove Item UI end" ; } void BluetoothBottomWindow::deviceRemoveSlot(QString dev_address) { KyDebug() << dev_address; removeBluetoothDeviceItemUi(dev_address); } void BluetoothBottomWindow::devicePairedSuccessSlot(QString dev_address) { KyDebug() << dev_address ; //判断其他设备中是否存在该设备界面 bluetoothdevicewindowitem *other_item = this->findChild(dev_address); if (other_item) removeBluetoothDeviceItemUi(dev_address); } void BluetoothBottomWindow::adapterDiscoveringSlot(bool status) { KyDebug() << status; _LoadIcon->setVisible(status); if (status) _LoadIcon->setTimerStart(); else _LoadIcon->setTimerStop(); } void BluetoothBottomWindow::adjustDevItemDisplayPosition(QString address,quint16 rssiValue) { KyDebug()<< address << rssiValue ; //判断界面是否需要调整位置 int old_devIndx = 0; for(auto it = m_btDevSortList_vec.begin() ; it != m_btDevSortList_vec.end() ; ++it) { if(it->first == address) break; old_devIndx++; } int new_devIndx = getDevRssiItemInsertIndex(rssiValue, address); //和原有位置做对比 if (new_devIndx == old_devIndx || new_devIndx-1 == old_devIndx) { KyDebug() << "No change in position" ; return ; } bluetoothdevicewindowitem *new_item = this->findChild(address); if(new_item) _NormalWidgetCacheDevLayout->removeWidget(new_item); int countIndx = 0; for(auto it = m_btDevSortList_vec.begin() ; it != m_btDevSortList_vec.end() ; ++it) { if(it->first == address) { m_btDevSortList_vec.removeAt(countIndx); break; } countIndx++; } int insert_index = getDevRssiItemInsertIndex(rssiValue, address); //KyInfo() << "insert_index:"<< insert_index ; if (insert_index == -1 || insert_index >= _NormalWidgetCacheDevLayout->count()) { m_btDevSortList_vec.append(fruit(address,rssiValue)); insert_index = _NormalWidgetCacheDevLayout->count(); } else { m_btDevSortList_vec.insert(insert_index,fruit(address,rssiValue)); } if (insert_index == _NormalWidgetCacheDevLayout->count()) { new_item->setLineFrameHidden(true); setLastDevItemWindowLine(false); } else { new_item->setLineFrameHidden(false); setLastDevItemWindowLine(true); } _NormalWidgetCacheDevLayout->insertWidget(insert_index,new_item,0,Qt::AlignTop); } void BluetoothBottomWindow::defaultAdapterChangedSlot(int indx) { KyDebug() << indx; reloadWindow(); } void BluetoothBottomWindow::setLastDevItemWindowLine(bool status) { //设置最后一个item line是否需要显示 KyDebug() << "" << _NormalWidgetCacheDevLayout->count(); if (_NormalWidgetCacheDevLayout->count() >= 1) { QLayoutItem *item = _NormalWidgetCacheDevLayout->itemAt(_NormalWidgetCacheDevLayout->count()-1); if (item->widget() != 0) { QString device_address = item->widget()->objectName(); KyDebug() << device_address; bluetoothdevicewindowitem *dev_item = _MNormalFrameBottom->findChild(device_address); if (dev_item) dev_item->setLineFrameHidden(status); } } } void BluetoothBottomWindow::clearOtherDevicesUI() { KyWarning() << "Other dev count:" << _NormalWidgetCacheDevLayout->count(); //清空列表数据 QLayoutItem *child; while(_NormalWidgetCacheDevLayout->count()!=0) { child = _NormalWidgetCacheDevLayout->takeAt(0); if(child->widget() != 0) { delete child->widget(); } delete child; } KyDebug() << "Other dev list(clean):" << m_btDevSortList_vec ; m_btDevSortList_vec.clear(); } void BluetoothBottomWindow::reloadWindow() { clearOtherDevicesUI(); AddBluetoothDevices(); } void BluetoothBottomWindow::quitWindow() { clearOtherDevicesUI(); } ukui-bluetooth/ukcc-bluetooth/bluetoothmainloadingwindow.cpp0000664000175000017500000000325415167665770023604 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothmainloadingwindow.h" BluetoothMainLoadingWindow::BluetoothMainLoadingWindow() { InitAdapterLoadingWidget(); } BluetoothMainLoadingWindow::~BluetoothMainLoadingWindow() { } void BluetoothMainLoadingWindow::InitAdapterLoadingWidget() { QVBoxLayout *loadingWidgetLayout = new QVBoxLayout(this); loadingWidgetIcon = new LoadingLabel(this); this->setObjectName("adapterLoadingWidget"); loadingWidgetLayout->setSpacing(10); loadingWidgetLayout->setContentsMargins(0,0,0,0); loadingWidgetIcon->setFixedSize(16,16); loadingWidgetIcon->setTimerStart(); loadingWidgetLayout->addStretch(10); loadingWidgetLayout->addWidget(loadingWidgetIcon,1,Qt::AlignCenter); loadingWidgetLayout->addStretch(10); } void BluetoothMainLoadingWindow::DisplayLoadingWindow() { if(loadingWidgetIcon) loadingWidgetIcon->setTimerStart(); } void BluetoothMainLoadingWindow::HiddenLoadingWindow() { if(loadingWidgetIcon) loadingWidgetIcon->setTimerStop(); } ukui-bluetooth/ukcc-bluetooth/bluetoothdeviceitem.cpp0000664000175000017500000005747415167665770022225 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothdeviceitem.h" //#define RADIUS 6.0 #define DEFAULT_FONT_WIDTH 280 /** * @brief * * @param parent * @param dev */ bluetoothdeviceitem::bluetoothdeviceitem( QString dev_address , QWidget *parent): _MDev_addr(dev_address), QPushButton(parent) { KyDebug() << dev_address ; this->setFocusPolicy(Qt::NoFocus); if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(dev_address)) { KyDebug() << dev_address << "not exist"; return; } this->setObjectName(dev_address); devConnectiontimer = new QTimer(this); devConnectiontimer->setInterval(CONNECT_DEVICE_TIMING); connect(devConnectiontimer,&QTimer::timeout,this,[=] { devConnOperationTimeoutSlot(); }); devConnectionFail_timer = new QTimer(this); devConnectionFail_timer->setInterval(CONNECT_ERROR_TIMER_CLEAR); connect(devConnectionFail_timer,&QTimer::timeout,this,[=] { _mConnFailCount = 0 ; devConnectionFail_timer->stop(); }); bindDeviceChangedSignals(); initGsettings(); initInterface(); refreshInterface(); } /** * @brief * */ bluetoothdeviceitem::~bluetoothdeviceitem() { KyDebug() << _MDev_addr ; _mStyle_GSettings->deleteLater(); if (devConnectiontimer) devConnectiontimer->deleteLater(); if (devConnectionFail_timer) devConnectionFail_timer->deleteLater(); } void bluetoothdeviceitem::initGsettings() { if (QGSettings::isSchemaInstalled(GSETTING_UKUI_STYLE)) { _mStyle_GSettings = new QGSettings(GSETTING_UKUI_STYLE); if(_mStyle_GSettings->get("styleName").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") _themeIsBlack = false; else _themeIsBlack = true; _mIconThemeName = _mStyle_GSettings->get("iconThemeName").toString(); connect(_mStyle_GSettings,&QGSettings::changed,this,&bluetoothdeviceitem::mStyle_GSettingsSlot); } } void bluetoothdeviceitem::devStatusLoading() { if (devStatusLabel->isVisible()) devStatusLabel->hide(); if (!devConnectiontimer->isActive()) devConnectiontimer->start(); if (devloadingLabel->isHidden()) devloadingLabel->show(); devloadingLabel->setTimerStart(); } void bluetoothdeviceitem::devFuncOperationSlot() { // KyDebug() << str_opt ; this->clearFocus(); // if ("connect" == str_opt || "disconnect" == str_opt) // { // devStatusLoading(); // } } void bluetoothdeviceitem::devBtnPressedSlot() { this->update(); } void bluetoothdeviceitem::devFuncOpertionRemoveSlot(QString address) { Q_EMIT bluetoothDeviceItemRemove(address); } void bluetoothdeviceitem::devConnOperationTimeoutSlot() { devloadingLabel->hide(); devloadingLabel->setTimerStop(); refreshDevCurrentStatus(); } void bluetoothdeviceitem::initBackground() { this->setProperty("useButtonPalette", true); this->setFlat(true); } /** * @brief * */ void bluetoothdeviceitem::initInterface() { KyDebug() ; this->setMinimumSize(580, 56); initBackground(); devItemHLayout = new QHBoxLayout(this); devItemHLayout->setContentsMargins(16,0,16,0); devItemHLayout->setSpacing(16); devIconLabel = new QLabel(this); devIconLabel->setPixmap(getDevTypeIcon()); devItemHLayout->addWidget(devIconLabel); devNameLabel = new QLabel(this); devNameLabel->setContentsMargins(1,0,1,0); devNameLabel->resize(DEFAULT_FONT_WIDTH,this->height()); devNameLabel->setText(getDevName()); devItemHLayout->addWidget(devNameLabel); devItemHLayout->addStretch(100); devNameLabel->setFocus(); devloadingLabel = new LoadingLabel(this); devloadingLabel->setFixedSize(16,16); devloadingLabel->setTimerStart(); devItemHLayout->addWidget(devloadingLabel, 1, Qt::AlignRight); devloadingLabel->hide();//默认隐藏 devStatusLabel = new QLabel(this); devStatusLabel->setText(getDevStatus()); devItemHLayout->addWidget(devStatusLabel,Qt::AlignRight); devStatusLabel->hide();//默认隐藏 devFuncBtn = new bluetoothdevicefunc(this,_MDev_addr); devItemHLayout->addWidget(devFuncBtn); bindInInterfaceUISignals(); } /** * @brief * */ void bluetoothdeviceitem::bindInInterfaceUISignals() { connect(devFuncBtn,SIGNAL(devFuncOpertionSignal()),this,SLOT(devFuncOperationSlot())); connect(devFuncBtn,SIGNAL(devBtnReleaseSignal()),this,SLOT(devBtnPressedSlot())); connect(devFuncBtn,SIGNAL(devFuncOpertionRemoveSignal(QString)),this,SIGNAL(bluetoothDeviceItemRemove(QString))); } /** * @brief * */ void bluetoothdeviceitem::refreshInterface() { KyDebug(); //优先级状态判断 //if(_MDev->getDevPairing() || _MDev->getDevConnecting()) if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevConnecting()) { devStatusLabel->hide(); devConnectiontimer->start(); devloadingLabel->show(); devloadingLabel->setTimerStart(); } else if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() || BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { devStatusLabel->show(); devloadingLabel->hide(); } else { devStatusLabel->hide(); devloadingLabel->hide(); } devFuncBtn->setVisible(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired()); } void bluetoothdeviceitem::devItemNameChanged(const QString &name) { KyDebug() << name; if (devNameLabel) { QFontMetrics fontWidth(devNameLabel->font());//得到QLabel字符的度量 int font_w = fontWidth.horizontalAdvance(name); QString elidedNote = name ; if (font_w > DEFAULT_FONT_WIDTH) elidedNote = fontWidth.elidedText(name, Qt::ElideMiddle, DEFAULT_FONT_WIDTH);//获取处理后的文本 if(elidedNote != name) { devNameLabel->setToolTip(name); } else { devNameLabel->setToolTip(""); } devNameLabel->setText(elidedNote); } } void bluetoothdeviceitem::devItemTypeChanged(const bluetoothdevice::BLUETOOTH_DEVICE_TYPE &type) { KyDebug() << type; if (devIconLabel) devIconLabel->setPixmap(getDevTypeIcon()); KyDebug() << "end" ; } void bluetoothdeviceitem::devItemStatusChanged(const QString &status) { KyDebug() << status; if (devStatusLabel) devStatusLabel->setText(status); } /** * @brief * */ void bluetoothdeviceitem::bindDeviceChangedSignals() { KyDebug(); if (BlueToothDBusService::m_default_bluetooth_adapter && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) { KyDebug() << "connect dev item"; connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::nameChanged,this,[=](const QString &name) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() <<"nameChanged:" << name ; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevShowName().isEmpty()) devItemNameChanged(name); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::showNameChanged,this,[=](const QString &name) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "showNameChanged:" << name ; devItemNameChanged(name); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::typeChanged,this,[=](bluetoothdevice::BLUETOOTH_DEVICE_TYPE type) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "typeChanged:" << type ; devItemTypeChanged(type); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::pairedChanged,this,[=](bool paired) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "pairedChanged:" << paired ; if (paired) { emit devPairedSuccess(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress()); } refreshDevCurrentStatus(); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::connectedChanged,this,[=](bool connected) { emit this->devConnectedChanged(connected); KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "connectedChanged:" << connected ; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired()) { emit devPairedSuccess(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress()); } refreshDevCurrentStatus(); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::connectingChanged,this,[=](bool connecting) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "connectingChanged:" << connecting ; refreshDevCurrentStatus(); if(connecting) { BlueToothMainWindow::m_device_operating = true ; } else { BlueToothMainWindow::m_device_operating = false; } devFuncBtn->setEnabled(!connecting); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::errorInfoRefresh,this,[=](int errorId , QString errorText) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() <<"error:" << errorId << errorText ; refreshDevCurrentStatus(); if (errorId && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired()) devConnectionFail(); }); connect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr],&bluetoothdevice::rssiChanged,this,[=](qint16 value) { KyDebug()<< BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress() << "rssiChanged:" << value ; if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired()) emit devRssiChanged(value); }); } } /************************************************ * @brief getDevTypeIcon * @param null * @return QPixmap *************************************************/ QPixmap bluetoothdeviceitem::getDevTypeIcon() { KyDebug(); QPixmap icon; QString iconName; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) { switch (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevType()) { case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtPhone: iconName = "phone-symbolic"; break; case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtComputer: iconName = "video-display-symbolic"; break; case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadset: case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtHeadphones: iconName = "audio-headphones-symbolic"; break; case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtAudiovideo: iconName = "audio-speakers-symbolic"; break; case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtKeyboard: iconName = "input-keyboard-symbolic"; break; case bluetoothdevice::BLUETOOTH_DEVICE_TYPE::BtMouse: iconName = "input-mouse-symbolic"; break; default: iconName = "bluetooth-symbolic"; break; } } else { iconName = "bluetooth-symbolic"; } if (_themeIsBlack) { icon = ukccbluetoothconfig::loadSvg(QIcon::fromTheme(iconName).pixmap(DEV_ICON_WH),ukccbluetoothconfig::WHITE); } else { icon = QIcon::fromTheme(iconName).pixmap(DEV_ICON_WH); } return icon; } /************************************************ * @brief getDevName * @param null * @return QString *************************************************/ QString bluetoothdeviceitem::getDevName() { KyDebug() ; QString name; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) name = BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevInterfaceShowName(); else name = "Bluetooth Test Name"; if(devNameLabel) { QFontMetrics fontWidth(devNameLabel->font());//得到QLabel字符的度量 int font_w = fontWidth.horizontalAdvance(name); QString elidedNote = name ; if (font_w > DEFAULT_FONT_WIDTH) elidedNote = fontWidth.elidedText(name, Qt::ElideMiddle, DEFAULT_FONT_WIDTH);//获取处理后的文本 if(elidedNote != name) { devNameLabel->setToolTip(name); return elidedNote; } else { devNameLabel->setToolTip(""); } } return name; } /** * @brief * * @return QString */ QString bluetoothdeviceitem::getDevStatus() { KyDebug(); QString strStatus; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr)) { //注意判断优先级 //if (_MDev->getDevPairing() || _MDev->getDevConnecting()) if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevConnecting()) { strStatus = m_str_connecting; } else if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() && 0 != BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getErrorId()) { strStatus = m_str_connectionfail; } else if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() && !BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { strStatus = m_str_notconnected; } else if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { strStatus = m_str_connected; } else { strStatus = m_str_notpaired; } } else strStatus = m_str_notpaired; return strStatus; } void bluetoothdeviceitem::refreshDevCurrentStatus() { KyDebug() ; if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevConnecting()) { devStatusLoading(); } else if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() && !BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { devItemStatusChanged(getDevStatus()); if (devStatusLabel->isHidden()) { devStatusLabel->show(); } // devStatusLabel->setEnabled(false); //if (devloadingLabel->isVisible()) { devloadingLabel->hide(); devloadingLabel->setTimerStop(); } // if (devFuncFrame->isHidden()) // devFuncFrame->show(); if (devFuncBtn->isHidden()) devFuncBtn->show(); if (devConnectiontimer->isActive()) devConnectiontimer->stop(); } else if (BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isPaired() && BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected()) { devItemStatusChanged(getDevStatus()); if (devStatusLabel->isHidden()) { devStatusLabel->show(); } // devStatusLabel->setEnabled(true); //KyWarning() << "devloadingLabel->isVisible()" << "devFuncFrame->isHidden()" << "devFuncFrame->isVisible()"; //KyWarning() << devloadingLabel->isVisible() << devloadingLabel->isHidden() << devFuncFrame->isHidden() << devFuncFrame->isVisible(); //if (devloadingLabel->isHidden()) { devloadingLabel->hide(); devloadingLabel->setTimerStop(); } //KyWarning() << devFuncFrame->isHidden() << devFuncFrame->isVisible(); // if (devFuncFrame->isHidden()) // devFuncFrame->show(); if (devFuncBtn->isHidden()) devFuncBtn->show(); if (devConnectiontimer->isActive()) devConnectiontimer->stop(); } else if (0 != BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getErrorId()) { devItemStatusChanged(getDevStatus()); if (devStatusLabel->isHidden()) devStatusLabel->show(); //if (devloadingLabel->isVisible()) { devloadingLabel->hide(); devloadingLabel->setTimerStop(); } if(devConnectiontimer->isActive()) devConnectiontimer->stop(); } else { if (devStatusLabel->isVisible()) devStatusLabel->hide(); if (devloadingLabel->isVisible()) { devloadingLabel->hide(); devloadingLabel->setTimerStop(); } if (devConnectiontimer->isActive()) devConnectiontimer->stop(); } devNameLabel->setText(getDevName()); } void bluetoothdeviceitem::devConnectionFail() { KyDebug() << "_mConnFailCount :" << _mConnFailCount << "devConnectionFail_timer->isActive():" << devConnectionFail_timer->isActive(); if ((0 == _mConnFailCount) && !devConnectionFail_timer->isActive()) devConnectionFail_timer->start(); _mConnFailCount++; if (_mConnFailCount > CONNECT_ERROR_COUNT) { _mConnFailCount = 0; devConnectionFail_timer->stop(); showDeviceRemoveWidget(DevRemoveDialog::REMOVE_MANY_TIMES_CONN_FAIL_DEV); } } void bluetoothdeviceitem::showDeviceRemoveWidget(DevRemoveDialog::REMOVE_INTERFACE_TYPE mode) { DevRemoveDialog *mesgBox = new DevRemoveDialog(mode,this); mesgBox->setModal(true); mesgBox->setDialogText(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevInterfaceShowName()); //rejected connect(mesgBox,&DevRemoveDialog::rejected,this,[=]{ _mConnFailCount = 0; devConnectionFail_timer->stop(); devNameLabel->setFocus(); }); //accepted connect(mesgBox,&DevRemoveDialog::accepted,this,[=]{ KyDebug() << "To :" << BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevName() << "Remove" ; BlueToothDBusService::devRemove(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress()); }); //finished connect(mesgBox,&DevRemoveDialog::finished,this,[=](int result){ KyDebug() << "result:" <setFocus(); }); mesgBox->exec(); } void bluetoothdeviceitem::mStyle_GSettingsSlot(const QString &key) { KyDebug() << key; if ("iconThemeName" == key || "icon-theme-name" == key) { _mIconThemeName = _mStyle_GSettings->get("iconThemeName").toString(); if (devIconLabel) devIconLabel->setPixmap(getDevTypeIcon()); } else if ("styleName" == key || "style-name" == key) { if(_mStyle_GSettings->get("style-name").toString() == "ukui-default" || _mStyle_GSettings->get("style-name").toString() == "ukui-light") { _themeIsBlack = false; } else { _themeIsBlack = true; } if (devIconLabel) devIconLabel->setPixmap(getDevTypeIcon()); } else if ("system-font-size" == key) { KyDebug() << key; devNameLabel->setText(getDevName()); } // initBackground(); this->update(); } void bluetoothdeviceitem::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.setRenderHint(QPainter:: Antialiasing, true); //设置渲染,启动反锯齿 painter.setPen(Qt::NoPen); painter.setBrush(this->palette().base().color()); QPalette pal = qApp->palette(); QColor color = pal.color(QPalette::Button); color.setAlphaF(0.5); pal.setColor(QPalette::Button, color); this->setPalette(pal); QPushButton::paintEvent(event); } void bluetoothdeviceitem::mousePressEvent(QMouseEvent *event) { //获取当前时间 _pressCurrentTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); KyInfo() << _pressCurrentTime; QPushButton::mousePressEvent(event); } void bluetoothdeviceitem::mouseReleaseEvent(QMouseEvent *event) { long long _releaseCurrentTime = QDateTime::currentDateTime().toMSecsSinceEpoch(); KyDebug() << "_releaseCurrentTime" << _releaseCurrentTime << "_pressCurrentTime:" << _pressCurrentTime; if(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list.contains(_MDev_addr) && (_releaseCurrentTime - _pressCurrentTime) <= 300) {//点击超时取消操作 if (!BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->isConnected() && !BlueToothMainWindow::m_device_operating) { devStatusLoading(); BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->setDevConnecting(true); BlueToothDBusService::devConnect(BlueToothDBusService::m_default_bluetooth_adapter->m_bt_dev_list[_MDev_addr]->getDevAddress()); } } QPushButton::mouseReleaseEvent(event); } void bluetoothdeviceitem::mouseMoveEvent(QMouseEvent *e) { KyDebug(); } ukui-bluetooth/ukcc-bluetooth/devremovedialog.cpp0000664000175000017500000001451215167665770021317 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "devremovedialog.h" DevRemoveDialog::DevRemoveDialog(REMOVE_INTERFACE_TYPE mode,QWidget *parent):QDialog(parent) { this->m_mode = mode; initGsettings(); this->setFixedSize(380,200); this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); initUI(); initGsettings(); } DevRemoveDialog::~DevRemoveDialog() { gsettings->deleteLater(); } void DevRemoveDialog::initUI() { struct_pos pos; if(REMOVE_MANY_TIMES_CONN_FAIL_DEV == this->m_mode) { title_icon = new QLabel(this); title_icon->setPixmap(QIcon::fromTheme(TITLE_ICON_BLUETOOTH).pixmap(20,22)); pos = getWidgetPos(8,8,20,22, this->width()); title_icon->setGeometry(pos.x, pos.y, pos.width, pos.high); title_text = new QLabel(tr("Bluetooth Connections"),this); pos = getWidgetPos(36,7,320,20, this->width()); title_text->setGeometry(pos.x, pos.y, pos.width, pos.high); title_text->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); } tipLabel = new QLabel(this); pos = getWidgetPos(56,25,320,60, this->width()); tipLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); tipLabel->setAlignment(Qt::AlignVCenter|Qt::AlignLeft); tipLabel->setWordWrap(true); tipLabel->setFocus(); if (REMOVE_HAS_PIN_DEV == this->m_mode) { txtLabel = new QLabel(this); pos = getWidgetPos(55,80,320,65, this->width()); txtLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); txtLabel->setAlignment(Qt::AlignTop|Qt::AlignLeft); txtLabel->setWordWrap(true); QPalette txtPal; txtPal.setColor(QPalette::WindowText,QColor("#818181")); txtLabel->setPalette(txtPal); QString txtStr = tr("After it is removed, the PIN code must be matched for the next connection."); QString newTxtStr = QFontMetrics(this->font()).elidedText(txtStr,Qt::ElideMiddle,txtLabel->width()); QFont txtFont ; txtFont.setPointSize(this->fontInfo().pointSize()); txtLabel->setFont(txtFont); txtLabel->setText(newTxtStr); if (newTxtStr != txtStr) txtLabel->setToolTip(tr("After it is removed, the PIN code must be matched for the next connection.")); } iconLabel = new QLabel(this); pos = getWidgetPos(16,45,22,22, this->width()); iconLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); iconLabel->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(22,22)); closeBtn = new QPushButton(this); pos = getWidgetPos(350,8,20,20, this->width()); closeBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); closeBtn->setFlat(true); closeBtn->setToolTip(tr("close")); closeBtn->setProperty("isWindowButton",0x2); closeBtn->setProperty("useIconHighlihtEffect",0x8); connect(closeBtn,&QPushButton::clicked,this,[=]{ this->close(); }); acceptBtn = new QPushButton(this); pos = getWidgetPos(242,148,120,36, this->width()); acceptBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); acceptBtn->setText(tr("Remove")); connect(acceptBtn,&QPushButton::clicked,this,[=]{ emit accepted(); this->close(); }); if(REMOVE_MANY_TIMES_CONN_FAIL_DEV == this->m_mode) { acceptBtn->setProperty("isImportant", true); } rejectBtn = new QPushButton(this); pos = getWidgetPos(110,148,120,36, this->width()); rejectBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); rejectBtn->setText(tr("Cancel")); connect(rejectBtn,&QPushButton::clicked,this,[=]{ this->close(); }); } void DevRemoveDialog::initGsettings() { if (QGSettings::isSchemaInstalled("org.ukui.style")) { gsettings = new QGSettings("org.ukui.style"); if(gsettings->get("style-name").toString() == "ukui-default" || gsettings->get("style-name").toString() == "ukui-light") isblack = false; else isblack = true; } connect(gsettings,&QGSettings::changed,this,&DevRemoveDialog::gsettingsSlot); } void DevRemoveDialog::setDialogText(const QString &str) { QString txtStr; if (REMOVE_MANY_TIMES_CONN_FAIL_DEV == this->m_mode) txtStr = QString(tr("Connection failed! Please remove it before connecting.")); else txtStr = QString(tr("Are you sure to remove %1 ?")).arg(str); QString newTxtStr = QFontMetrics(this->font()).elidedText(txtStr,Qt::ElideMiddle,tipLabel->width()); QFont tipFont ; tipFont.setPointSize(this->fontInfo().pointSize()); tipLabel->setFont(tipFont); tipLabel->setText(newTxtStr); if (newTxtStr != txtStr) tipLabel->setToolTip(txtStr); } void DevRemoveDialog::gsettingsSlot(const QString &key) { if (key == "styleName") { QPalette palette; if(gsettings->get("style-name").toString() == "ukui-default" || gsettings->get("style-name").toString() == "ukui-light") { palette.setBrush(QPalette::Base,QBrush(Qt::white)); palette.setColor(QPalette::Text,QColor(Qt::black)); isblack = false; } else { palette.setBrush(QPalette::Base,QBrush(Qt::black)); palette.setColor(QPalette::Text,QColor(Qt::white)); isblack = true; } this->setPalette(palette); } } void DevRemoveDialog::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.setPen(Qt::transparent); if (isblack) painter.setBrush(Qt::black); else painter.setBrush(Qt::white); painter.setRenderHint(QPainter::Antialiasing); painter.drawRoundedRect(this->rect(),12,12); } ukui-bluetooth/ukcc-bluetooth/devrenamedialog.cpp0000664000175000017500000001642415167665770021275 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "devrenamedialog.h" DevRenameDialog::DevRenameDialog(QWidget *parent):QDialog(parent) { this->setFixedSize(480,192); this->adjustSize(); this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); this->setAttribute(Qt::WA_TranslucentBackground); initUI(); initGsettings(); } DevRenameDialog::~DevRenameDialog() { gsettings->deleteLater(); } void DevRenameDialog::setRenameInterface(DEV_RENAME_DIALOG_TYPE mode) { this->_mMode = mode; if (DEVRENAMEDIALOG_ADAPTER == mode) { textLabel->setVisible(true); titleLabel->setText(tr("Rename")); } else if (DEVRENAMEDIALOG_BT_DEVICE == mode) { textLabel->setVisible(false); struct_pos pos; pos = getWidgetPos(25,55,435,36, this->width()); lineEdit->setGeometry(pos.x, pos.y, pos.width, pos.high); titleLabel->setFixedSize(300,30); titleLabel->setText(tr("Rename device")); pos = getWidgetPos(20,94,435,25, this->width()); tipLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); } } void DevRenameDialog::setDevName(const QString &str) { lineEdit->setText(str); adapterOldName = str; } void DevRenameDialog::initGsettings() { if (QGSettings::isSchemaInstalled("org.ukui.style")) { gsettings = new QGSettings("org.ukui.style"); if(gsettings->get("style-name").toString() == "ukui-default" || gsettings->get("style-name").toString() == "ukui-light") isblack = false; else isblack = true; _fontSize = gsettings->get("system-font-size").toString().toInt(); } connect(gsettings,&QGSettings::changed,this,&DevRenameDialog::gsettingsSlot); } void DevRenameDialog::gsettingsSlot(const QString &key) { if (key == "styleName") { QPalette palette; if(gsettings->get("style-name").toString() == "ukui-default" || gsettings->get("style-name").toString() == "ukui-light") { palette.setBrush(QPalette::Base,QBrush(Qt::white)); palette.setColor(QPalette::Text,QColor(Qt::black)); isblack = false; } else { palette.setBrush(QPalette::Base,QBrush(Qt::black)); palette.setColor(QPalette::Text,QColor(Qt::white)); isblack = true; } this->setPalette(palette); } } void DevRenameDialog::initUI() { struct_pos pos; QLabel *iconLabel = new QLabel(this); iconLabel->setPixmap(QIcon::fromTheme(TITLE_ICON_BLUETOOTH).pixmap(20,20)); pos = getWidgetPos(10,11,20,20, this->width()); iconLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); titleLabel = new QLabel(this); pos = getWidgetPos(36,5,120,30, this->width()); titleLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); titleLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); closeBtn = new QPushButton(this); pos = getWidgetPos(453,8,20,20, this->width()); closeBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); closeBtn->setFlat(true); closeBtn->setToolTip(tr("close")); closeBtn->setProperty("isWindowButton",0x2); closeBtn->setProperty("useIconHighlihtEffect",0x8); connect(closeBtn,&QPushButton::clicked,this,[=]{ this->close(); }); textLabel = new QLabel(this); pos = getWidgetPos(24,64,60,20, this->width()); textLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); textLabel->setText(tr("Name")); textLabel->setAlignment(Qt::AlignHCenter|Qt::AlignRight); textLabel->adjustSize(); int wigth = textLabel->width(); wigth = wigth - 60; lineEdit = new QLineEdit(this); lineEdit->setFocus(); //lineEdit->setMaxLength(INPUT_STRNAME_MAX); pos = getWidgetPos(100 + wigth,55,355 - wigth,36, this->width()); lineEdit->setGeometry(pos.x, pos.y, pos.width, pos.high); //输入变化时进行长度提示 connect(lineEdit,&QLineEdit::textEdited,this,&DevRenameDialog::lineEditSlot); tipLabel = new QLabel(this); pos = getWidgetPos(96 + wigth,94,400,25, this->width()); tipLabel->setGeometry(pos.x, pos.y, pos.width, pos.high); //tipLabel->setText(tr("Cannot be null")); tipLabel->setText(tr("The value contains 1 to 32 characters")); tipLabel->setVisible(false); tipLabel->setStyleSheet("color: rgba(255, 0, 0, 0.85);\ opacity: 1;"); acceptBtn = new QPushButton(tr("OK"),this); acceptBtn->setProperty("isImportant", true); pos = getWidgetPos(359,130,96,36, this->width()); acceptBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); connect(acceptBtn,&QPushButton::clicked,this,[=]{ qWarning()<< Q_FUNC_INFO << "acceptBtn clicked !" << __LINE__; if ((lineEdit->text().length() >= INPUT_STRNAME_MIN) && (lineEdit->text().length() <= INPUT_STRNAME_MAX) && (lineEdit->text() != adapterOldName)) emit nameChanged(lineEdit->text()); this->close(); }); rejectBtn = new QPushButton(tr("Cancel"),this); pos = getWidgetPos(247,130,96,36, this->width()); rejectBtn->setGeometry(pos.x, pos.y, pos.width, pos.high); connect(rejectBtn,&QPushButton::clicked,this,[=]{ this->close(); }); } void DevRenameDialog::lineEditSlot(const QString &str) { if (str.length() >= INPUT_STRNAME_MIN && str.length() <= INPUT_STRNAME_MAX) { acceptBtn->setDisabled(false); tipLabel->setVisible(false); } else if (INPUT_STRNAME_MIN > str.length()) { acceptBtn->setDisabled(true); tipLabel->setVisible(true); }else { //输入字符超过32,则显示32个字符并提示用户 QString showText = str.left(32); lineEdit->setText(showText); acceptBtn->setDisabled(false); tipLabel->setVisible(true); } } void DevRenameDialog::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter painter(this); painter.setPen(Qt::transparent); if (isblack) painter.setBrush(Qt::black); else painter.setBrush(Qt::white); painter.setRenderHint(QPainter::Antialiasing); painter.drawRoundedRect(this->rect(),12,12); } void DevRenameDialog::keyPressEvent(QKeyEvent * event) { Q_UNUSED(event) switch(event->key()) { case Qt::Key_Return: case Qt::Key_Enter: //if(acceptBtn->isEnabled())//setEnable状态后,emit click 信号不相应,无需判断 emit acceptBtn->click(); break; case Qt::Key_Escape: //if(rejectBtn->isEnabled())//setEnable状态后,emit click 信号不相应,无需判断 emit rejectBtn->click(); break; } } ukui-bluetooth/ukcc-bluetooth/bluetoothdevicefunc.h0000664000175000017500000000436615167665755021662 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHDEVICEFUNC_H #define BLUETOOTHDEVICEFUNC_H #include #include #include #include #include #include #include #include #include #include #include #include "devicebase.h" #include "devrenamedialog.h" #include "devremovedialog.h" //#include "bluetoothmainwindow.h" #include "bluetoothdbusservice.h" #include "windowmanager/windowmanager.h" #define ICON_PATH_NAME "view-more-horizontal-symbolic" class bluetoothdevicefunc : public QPushButton { Q_OBJECT public: bluetoothdevicefunc(QWidget *parent ,QString dev_address); ~bluetoothdevicefunc(); void initGsettings(); void initInterface(); void initBackground(); signals: void devFuncOpertionSignal(); void devFuncOpertionRemoveSignal(QString); void devBtnReleaseSignal(); private slots: void MenuSignalDeviceFunction(QAction *action); void mStyle_GSettingsSlot(const QString &key); void MenuSignalAboutToHide(); protected: void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); private: QMenu * devMenuFunc = nullptr; QGSettings * _mStyle_GSettings = nullptr; QString _MDev_addr ; bool _themeIsBlack = false; QString _mIconThemeName; long long _pressCurrentTime; void showDeviceRenameWidget(); void showDeviceRemoveWidget(DevRemoveDialog::REMOVE_INTERFACE_TYPE mode); }; #endif // BLUETOOTHDEVICEFUNC_H ukui-bluetooth/ukcc-bluetooth/bluetooth.cpp0000664000175000017500000000557615167665755020165 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetooth.h" Environment envPC = Environment::NOMAL; bool global_rightToleft = false; Bluetooth::Bluetooth() : mFirstLoad(true) { KyDebug() << "start" << "++ukccBluetooth========================"; QStringList addrList = BlueToothDBusService::getAllAdapterAddress(); if (!addrList.size()) ukccbluetoothconfig::ukccGsetting->set("show",QVariant(false)); else ukccbluetoothconfig::ukccGsetting->set("show",QVariant(true)); KyDebug() << envPC ; QTranslator * translator = new QTranslator(this); translator->load("/usr/share/ukui-bluetooth/translations/ukcc-bluetooth_" + QLocale::system().name() + ".qm"); QApplication::installTranslator(translator); pluginName = tr("Bluetooth"); pluginType = DEVICES; QString systemLang = QLocale::system().name(); if(systemLang == "ug_CN" || systemLang == "ky_KG" || systemLang == "kk_KZ"){ KyInfo() << "global_rightToleft set true"; global_rightToleft = true; } } Bluetooth::~Bluetooth() { if (!mFirstLoad) { pluginWidget->deleteLater(); } } QString Bluetooth::plugini18nName() { return pluginName; } int Bluetooth::pluginTypes() { return pluginType; } QWidget *Bluetooth::pluginUi() { if (mFirstLoad) { mFirstLoad = false; pluginWidget = new BlueToothMainWindow; } if (!mFirstLoad && (nullptr != pluginWidget)) { BlueToothDBusService::registerClient(); } return pluginWidget; } const QString Bluetooth::name() const { return QStringLiteral("Bluetooth"); } bool Bluetooth::isShowOnHomePage() const { return true; } QIcon Bluetooth::icon() const { return QIcon::fromTheme("bluetooth-active-symbolic"); } bool Bluetooth::isEnable() const { QStringList addrList = BlueToothDBusService::getAllAdapterAddress(); KyDebug() << addrList ; if (addrList.size()) { KyInfo() << "Bluetooth::isEnable is true"; return true; } else { KyInfo() << "Bluetooth::isEnable is false"; return false; } } void Bluetooth::plugin_leave() { if (nullptr != pluginWidget) { //界面切出时注销控制面板注册 BlueToothDBusService::unregisterClient(); } } ukui-bluetooth/ukcc-bluetooth/devremovedialog.h0000664000175000017500000000373215167665755020771 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DEVREMOVEDIALOG_H #define DEVREMOVEDIALOG_H #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" class DevRemoveDialog final : public QDialog { Q_OBJECT public: enum REMOVE_INTERFACE_TYPE { REMOVE_NO_PIN_DEV = 0, REMOVE_HAS_PIN_DEV = 1, REMOVE_MANY_TIMES_CONN_FAIL_DEV = 2 }; Q_ENUM(REMOVE_INTERFACE_TYPE) explicit DevRemoveDialog(REMOVE_INTERFACE_TYPE mode , QWidget *parent = nullptr); ~DevRemoveDialog(); void initUI(); void initGsettings(); void setDialogText(const QString & ); private slots: void gsettingsSlot(const QString &); protected: void paintEvent(QPaintEvent *); private: bool isblack = false; QLabel *tipLabel = nullptr; QLabel *txtLabel = nullptr; QLabel *iconLabel = nullptr; QLabel *title_icon = nullptr; QLabel *title_text = nullptr; QGSettings *gsettings = nullptr; QPushButton *closeBtn = nullptr; QPushButton *acceptBtn = nullptr; QPushButton *rejectBtn = nullptr; REMOVE_INTERFACE_TYPE m_mode = REMOVE_HAS_PIN_DEV; }; #endif // DEVREMOVEDIALOG_H ukui-bluetooth/ukcc-bluetooth/bluetoothmainwindow.h0000664000175000017500000000563015167665755021716 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHMAINWINDOW_H #define BLUETOOTHMAINWINDOW_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "loadinglabel.h" #include "kswitchbutton.h" #include "bluetoothnamelabel.h" #include "bluetoothdeviceitem.h" #include "bluetoothdevicewindowitem.h" #include "bluetoothmainnormalwindow.h" #include "bluetoothmainerrorwindow.h" #include "bluetoothmainloadingwindow.h" enum Window_Type { MAINWINDOW_ERROR_WINDOW = 0, MAINWINDOW_LOADING_INTERFACE, MAINWINDOW_NORMAL_INTERFACE, WINDOW_COUNT }; using namespace kdk; class BluetoothMainNormalWindow; class BlueToothMainWindow : public QMainWindow { Q_OBJECT public: //记录当前是否蓝牙界面是否在操作状态 static bool m_device_operating; //有设备正在操作 explicit BlueToothMainWindow(QWidget *parent = nullptr); ~BlueToothMainWindow(); private slots: void loadingTimeOutSlot(); //dev slot void adapterAddSlot(QString adapter_name); void adapterRemoveSlot(int indx); void btServiceRestartSlot(); void btServiceRestartCompleteSlot(bool); void defaultAdapterChangedSlot(int indx); private: QStackedWidget * m_centralWidget = nullptr; BluetoothMainNormalWindow * m_normalWindow = nullptr; BluetoothMainErrorWindow * m_errorWindow = nullptr; BluetoothMainLoadingWindow * m_loadingWindow = nullptr; QTimer * m_loadingTimer = nullptr; BlueToothDBusService * btServer = nullptr; int m_errType_id ; int m_init_btServer_res ; int m_btServer_errId ; private: void InitBTServerConnection(); void InitWindows(); void InitNormalWindow(); void InitErrorWindow(); void InitLoadingWindow(); void InitLoadingTimer(); void displayNormalWindow(); void displayErrorAbnormalWindow(); void displayErrorNoAdapterWindow(); void displayErrorBluetoothServerInitFailedWindow(); void displayErrorUnknownWindow(); void displayLoadingWindow(); }; #endif // BLUETOOTHMAINWINDOW_H ukui-bluetooth/ukcc-bluetooth/bluetoothbottomwindow.h0000664000175000017500000000602215167665770022267 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHBOTTOMWINDOW_H #define BLUETOOTHBOTTOMWINDOW_H #include #include #include #include #include #include #include "loadinglabel.h" #include "bluetoothdbusservice.h" #include "bluetoothdevicewindowitem.h" class BluetoothBottomWindow : public QWidget { Q_OBJECT public: enum _DEV_TYPE { BT_All = 0, BT_Audio, BT_Peripherals, BT_Computer, BT_Phone, BT_Other, }; Q_ENUM(_DEV_TYPE); BluetoothBottomWindow(BlueToothDBusService * btServer,QWidget * parent = nullptr); ~BluetoothBottomWindow(); const QStringList devTypeSelectStrList = {tr("All"), \ tr("Audio"), \ tr("Peripherals"), \ tr("Computer"), \ tr("Phone"), \ tr("Other")}; void reloadWindow(); void quitWindow(); private Q_SLOTS: void adapterDiscoveringSlot(bool status); void _DevTypeSelectComboBoxSlot(int indx); void deviceAddSlot(QString dev_address); void deviceRemoveSlot(QString dev_address); void devicePairedSuccessSlot(QString dev_address); void adjustDevItemDisplayPosition(QString address,quint16 rssiValue); void defaultAdapterChangedSlot(int); private: BlueToothDBusService * m_btServer = nullptr; QFrame * _MNormalFrameBottom = nullptr; LoadingLabel * _LoadIcon = nullptr; QComboBox * _DevTypeSelectComboBox = nullptr; QVBoxLayout * _NormalWidgetCacheDevLayout = nullptr; _DEV_TYPE currentShowTypeFlag = _DEV_TYPE::BT_All; private: void InitNormalWidgetBottom(); void InitConnectionData(); void AddBluetoothDevices(); void addOneBluetoothDeviceItemUi(QString dev_address); void reloadDeviceListItem(BluetoothBottomWindow::_DEV_TYPE flag); void removeBluetoothDeviceItemUi(QString address); void setLastDevItemWindowLine(bool status); void clearOtherDevicesUI(); bool whetherToDisplayInTheCurrentInterface(bluetoothdevice::BLUETOOTH_DEVICE_TYPE devType); int getDevRssiItemInsertIndex(qint16 currDevRssi, QString id = ""); }; #endif // BLUETOOTHBOTTOMWINDOW_H ukui-bluetooth/ukcc-bluetooth/common.cpp0000664000175000017500000001334715167665770017440 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "common.h" #include #include #include #include #include #include #include extern "C"{ #include #include } #define WLCOM_SERVICE "com.kylin.Wlcom" #define WLCOM_OBJECT "/com/kylin/Wlcom/Input" #define WLCOM_INTERFACE "com.kylin.Wlcom.Input" #define WLCOM_METHED "ListAllInputs" Common::Common(QObject *parent) : QObject(parent) { } static QStringList waylany_getdev(){ QDBusInterface iface(WLCOM_SERVICE, WLCOM_OBJECT, WLCOM_INTERFACE, QDBusConnection::sessionBus()); QStringList v; QDBusMessage reply = iface.call(WLCOM_METHED); if(reply.type() == QDBusMessage::ReplyMessage) { QVariant va = reply.arguments()[0]; const QDBusArgument & dbusArg = va.value(); if (dbusArg.currentSignature() != "a(su)") { KyWarning() << "error data struct, " << dbusArg.currentSignature(); return v; } dbusArg.beginArray(); while (!dbusArg.atEnd()) { dbusArg.beginStructure(); QString str; quint32 num; dbusArg >> str; dbusArg >> num; dbusArg.endStructure(); v.append(str); } dbusArg.endArray(); } else { KyWarning() << reply; } return v; } bool Common::isWayland() { QString sessionType = getenv("XDG_SESSION_TYPE"); if (!sessionType.compare("wayland", Qt::CaseInsensitive)) { return true; } return false; } static int x11_getSystemCurrentMouseAndTouchPadDevCount() { unsigned int count = 0 ; Display *display = XOpenDisplay(NULL); if (display == NULL) { XCloseDisplay(display); return -1; } XDeviceInfo *devices; int num_devices; devices = XListInputDevices(display, &num_devices); if (devices == NULL) { XCloseDisplay(display); return -1; } Atom mouse_prop = XInternAtom(display,STR_MOUSE,false); Atom touchPad_prop = XInternAtom(display,STR_TOUCHPAD,false); for (int i = 0; i < num_devices; i++) { if (devices[i].type == mouse_prop || devices[i].type == touchPad_prop) { QString dev_name = QString(devices[i].name); if (dev_name.contains(STR_MOUSE,Qt::CaseInsensitive) || dev_name.contains(STR_TOUCHPAD,Qt::CaseInsensitive) || dev_name.contains(STR_TRACKPOINT,Qt::CaseInsensitive) || dev_name.contains("MS",Qt::CaseInsensitive) ) { count ++; } } } KyDebug() << "mouse devices count:" << count; XFreeDeviceList(devices); XCloseDisplay(display); return count; } static int wayland_getSystemCurrentMouseAndTouchPadDevCount() { QStringList devices; int count = 0; devices = waylany_getdev(); KyInfo() << devices; for(auto iter : devices) { QString devname = iter; if(devname.endsWith(STR_MOUSE, Qt::CaseInsensitive) || devname.endsWith(STR_TOUCHPAD, Qt::CaseInsensitive) || devname.endsWith(STR_TRACKPOINT, Qt::CaseInsensitive) || devname.endsWith("MS", Qt::CaseInsensitive) ) { count++; } } KyInfo() << "mouse devices count:" << count; return count; } static int x11_getSystemCurrentKeyBoardDevCount() { unsigned int count = 0 ; Display *display = XOpenDisplay(NULL); if (display == NULL) { XCloseDisplay(display); return -1; } XDeviceInfo *devices; int num_devices; devices = XListInputDevices(display, &num_devices); if (devices == NULL) { XCloseDisplay(display); return -1; } Atom keyBoard_prop = XInternAtom(display,STR_KEYBOARD,false); for (int i = 0; i < num_devices; i++) { if(devices[i].type == keyBoard_prop) { QString dev_name = QString(devices[i].name); if (dev_name.contains(STR_KEYBOARD,Qt::CaseInsensitive)) { count++; } } } KyDebug() << "keyBoard devices count:" << count; XFreeDeviceList(devices); XCloseDisplay(display); return count; } static int wayland_getSystemCurrentKeyBoardDevCount() { QStringList devices; int count = 0; devices = waylany_getdev(); KyInfo() << devices; for(auto iter : devices) { QString devname = iter; if(devname.endsWith(STR_KEYBOARD, Qt::CaseInsensitive)) { count++; } } KyInfo() << "keyBoard devices count:" << count; return count; } int Common::getSystemCurrentMouseAndTouchPadDevCount() { if (Common::isWayland()) { return wayland_getSystemCurrentMouseAndTouchPadDevCount(); } return x11_getSystemCurrentMouseAndTouchPadDevCount(); } int Common::getSystemCurrentKeyBoardDevCount() { if (Common::isWayland()) { return wayland_getSystemCurrentKeyBoardDevCount(); } return x11_getSystemCurrentKeyBoardDevCount(); } ukui-bluetooth/ukcc-bluetooth/bluetoothmainwindow.cpp0000664000175000017500000001716115167665755022253 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothmainwindow.h" typedef QPair fruit; //设备显示排序 QVector devShowOrderListVec; bool BlueToothMainWindow::m_device_operating = false; BlueToothMainWindow::BlueToothMainWindow(QWidget *parent): QMainWindow(parent) { KyDebug(); btServer = new BlueToothDBusService(this); m_init_btServer_res = 0 ; if (btServer) { m_init_btServer_res = btServer->initBluetoothServer(); InitBTServerConnection(); } else m_init_btServer_res = 1; KyInfo() << "res:1-- init Bluetooth Server failed!"; KyInfo() << "res:2-- Bluetooth adapter is null!"; KyInfo() << "ukcc start -- bluetooth server res:" << m_init_btServer_res ; InitWindows(); InitLoadingTimer(); if (0 == m_init_btServer_res) { displayNormalWindow(); } else if (1 == m_init_btServer_res) { displayErrorBluetoothServerInitFailedWindow(); } else if (2 == m_init_btServer_res) { displayErrorNoAdapterWindow(); } else { displayErrorUnknownWindow(); } } BlueToothMainWindow::~BlueToothMainWindow() { KyDebug(); if (btServer) btServer->deleteLater(); if(m_loadingTimer) m_loadingTimer->deleteLater(); } void BlueToothMainWindow::InitBTServerConnection() { if (btServer) { connect(btServer,&BlueToothDBusService::adapterAddSignal,this,&BlueToothMainWindow::adapterAddSlot); connect(btServer,&BlueToothDBusService::adapterRemoveSignal,this,&BlueToothMainWindow::adapterRemoveSlot); connect(btServer,&BlueToothDBusService::defaultAdapterChangedSignal,this,&BlueToothMainWindow::defaultAdapterChangedSlot); //bt service update connect(btServer,&BlueToothDBusService::btServiceRestart,this,&BlueToothMainWindow::btServiceRestartSlot); //connect(btServer,&BlueToothDBusService::btServiceRestartComplete,this,&BlueToothMainWindow::btServiceRestartCompleteSlot); } } void BlueToothMainWindow::InitWindows() { m_centralWidget = new QStackedWidget(this); this->setCentralWidget(m_centralWidget); InitNormalWindow(); InitErrorWindow(); InitLoadingWindow(); m_centralWidget->insertWidget(MAINWINDOW_ERROR_WINDOW,m_errorWindow); m_centralWidget->insertWidget(MAINWINDOW_LOADING_INTERFACE,m_loadingWindow); m_centralWidget->insertWidget(MAINWINDOW_NORMAL_INTERFACE,m_normalWindow); } void BlueToothMainWindow::InitNormalWindow() { m_normalWindow = new BluetoothMainNormalWindow(btServer,m_centralWidget); } void BlueToothMainWindow::InitErrorWindow() { m_errorWindow = new BluetoothMainErrorWindow(tr("Bluetooth Adapter loading Failed!"), m_centralWidget); } void BlueToothMainWindow::InitLoadingWindow() { m_loadingWindow = new BluetoothMainLoadingWindow(); } void BlueToothMainWindow::displayNormalWindow() { KyInfo(); if (m_btServer_errId != 0 || m_loadingTimer->isActive()) { m_btServer_errId = 0; m_loadingTimer->stop(); } m_centralWidget->setCurrentIndex(MAINWINDOW_NORMAL_INTERFACE); } void BlueToothMainWindow::displayErrorAbnormalWindow() { m_normalWindow->SetHidden(true); if (m_errorWindow) m_errorWindow->setErrorText(tr("Bluetooth adapter is abnormal!")); m_centralWidget->setCurrentIndex(MAINWINDOW_ERROR_WINDOW);} void BlueToothMainWindow::displayErrorNoAdapterWindow() { m_normalWindow->SetHidden(true); if (m_errorWindow) m_errorWindow->setErrorText(tr("No Bluetooth adapter detected!")); m_centralWidget->setCurrentIndex(MAINWINDOW_ERROR_WINDOW); } void BlueToothMainWindow::displayErrorBluetoothServerInitFailedWindow() { m_normalWindow->SetHidden(true); if (m_errorWindow) m_errorWindow->setErrorText(tr("Bluetooth Service init failed!")); m_centralWidget->setCurrentIndex(MAINWINDOW_ERROR_WINDOW); } void BlueToothMainWindow::displayErrorUnknownWindow() { m_normalWindow->SetHidden(true); if (m_errorWindow) m_errorWindow->setErrorText(tr("Unknown Bluetooth Error!")); m_centralWidget->setCurrentIndex(MAINWINDOW_ERROR_WINDOW); } void BlueToothMainWindow::displayLoadingWindow() { m_normalWindow->SetHidden(true); m_centralWidget->setCurrentIndex(MAINWINDOW_LOADING_INTERFACE); if (m_loadingTimer->isActive()) m_loadingTimer->stop(); m_loadingTimer->start(); } void BlueToothMainWindow::InitLoadingTimer() { //加载蓝牙适配器 m_loadingTimer = new QTimer(this); m_loadingTimer->setInterval(6000); connect(m_loadingTimer,&QTimer::timeout,this,&BlueToothMainWindow::loadingTimeOutSlot); } void BlueToothMainWindow::loadingTimeOutSlot() { if (m_loadingTimer->isActive()) m_loadingTimer->stop(); if(BlueToothDBusService::m_bluetooth_adapter_address_list.size() > 0) { KyInfo() << "exist adapter"; m_normalWindow->reloadWindow(); displayNormalWindow(); return; } if (1 == this->m_errType_id) displayErrorNoAdapterWindow(); else if (2 == this->m_errType_id) displayErrorBluetoothServerInitFailedWindow(); else if (3 == this->m_errType_id) displayErrorAbnormalWindow(); else displayErrorUnknownWindow(); } void BlueToothMainWindow::adapterAddSlot(QString adapter_name) { KyDebug() << "= adapter_name:" << adapter_name << "= BlueToothDBusService::m_bluetooth_adapter_address_list:" << BlueToothDBusService::m_bluetooth_adapter_address_list << "= list size :" << BlueToothDBusService::m_bluetooth_adapter_address_list.size() ; if (MAINWINDOW_NORMAL_INTERFACE!= this->m_centralWidget->currentIndex()) { QTimer::singleShot(500,this,[=]{ m_normalWindow->reloadWindow(); displayNormalWindow(); }); } } void BlueToothMainWindow::adapterRemoveSlot(int indx) { KyDebug() << "remove index:" << indx << "name list size :" << BlueToothDBusService::m_bluetooth_adapter_name_list.size() << "name list:" << BlueToothDBusService::m_bluetooth_adapter_name_list; if (0 == BlueToothDBusService::m_bluetooth_adapter_name_list.size()) { this->m_errType_id = 1; displayLoadingWindow(); } } void BlueToothMainWindow::btServiceRestartSlot() { KyDebug(); displayLoadingWindow(); } void BlueToothMainWindow::btServiceRestartCompleteSlot(bool status) { KyDebug() << status; if (m_loadingTimer->isActive()) m_loadingTimer->stop(); if (status) { if(MAINWINDOW_NORMAL_INTERFACE != this->m_centralWidget->currentIndex()) { m_normalWindow->reloadWindow(); displayNormalWindow(); } } else { if(MAINWINDOW_LOADING_INTERFACE == this->m_centralWidget->currentIndex()) { displayErrorBluetoothServerInitFailedWindow(); } } } void BlueToothMainWindow::defaultAdapterChangedSlot(int indx) { if (BlueToothMainWindow::m_device_operating) BlueToothMainWindow::m_device_operating = false; } ukui-bluetooth/ukcc-bluetooth/bluetoothdevicewindowitem.h0000664000175000017500000000301715167665755023105 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHDEVICEWINDOWITEM_H #define BLUETOOTHDEVICEWINDOWITEM_H #include #include #include #include #include "bluetoothdeviceitem.h" class bluetoothdeviceitem; class bluetoothdevicewindowitem : public QFrame { Q_OBJECT public: bluetoothdevicewindowitem(QString dev_address,bool show_line = false, QWidget *parent = nullptr); ~bluetoothdevicewindowitem(); void setLineFrameHidden(bool hidden); signals: void devFuncOptSignals(); void devPairedSuccess(QString); void devConnectedChanged(bool); void devRssiChanged(qint64); void bluetoothDeviceItemRemove(QString); private: bool m_show_line = false ; QString m_dev_address ; bluetoothdeviceitem * m_devBtn; QFrame *line_frame = nullptr; private: void Init(); }; #endif // BLUETOOTHDEVICEWINDOWITEM_H ukui-bluetooth/ukcc-bluetooth/bluetoothnamelabel.h0000664000175000017500000000441515167665755021462 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHNAMELABEL_H #define BLUETOOTHNAMELABEL_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include "devrenamedialog.h" #include "ukccbluetoothconfig.h" #define DEVNAMELENGTH 30 #define ICON_PENCIL_W 16 #define ICON_PENCIL_H 16 #define ICON_PENCIL_W_H (ICON_PENCIL_W,ICON_PENCIL_H) class BluetoothNameLabel : public QWidget { Q_OBJECT public: BluetoothNameLabel(QWidget *parent = nullptr, int x = 200,int y = 40); ~BluetoothNameLabel(); void set_dev_name(const QString &dev_name); protected: void mousePressEvent(QMouseEvent *event); void mouseDoubleClickEvent(QMouseEvent *event); // void mouseMoveEvent(QMouseEvent *event); void leaveEvent(QEvent *event); void enterEvent(QEvent *event); void resizeEvent(QResizeEvent *event); signals: void sendAdapterName(const QString &value); public slots: void settings_changed(const QString &key); private: QGSettings *settings; bool style_flag = false; QLabel *m_label = nullptr; QLabel *icon_pencil=nullptr; QString device_name; int font_width; QMessageBox *messagebox = nullptr; QHBoxLayout *hLayout = nullptr; DevRenameDialog *renameDialog = nullptr; void showDevRenameDialog(); void setMyNameLabelText(QString); }; #endif // BLUETOOTHNAMELABEL_H ukui-bluetooth/ukcc-bluetooth/bluetoothmainnormalwindow.cpp0000664000175000017500000001165615167665755023467 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothmainnormalwindow.h" BluetoothMainNormalWindow::BluetoothMainNormalWindow(BlueToothDBusService * btServer,QWidget * parent) : m_btServer(btServer), QWidget(parent) { this->setFocusPolicy(Qt::NoFocus); Init(); InitConnectData(); } BluetoothMainNormalWindow::~BluetoothMainNormalWindow() { } void BluetoothMainNormalWindow::Init() { _NormalWidgetMainLayout = new QVBoxLayout(this); _NormalWidgetMainLayout->setSpacing(40); _NormalWidgetMainLayout->setContentsMargins(0,0,0,10); m_topWidget = new BluetoothTopWindow(m_btServer,this); m_middleWidget = new BluetoothMiddleWindow(m_btServer,this); m_bottomWidget = new BluetoothBottomWindow(m_btServer,this); _NormalWidgetMainLayout->addWidget(m_topWidget,1,Qt::AlignTop); _NormalWidgetMainLayout->addWidget(m_middleWidget,1,Qt::AlignTop); _NormalWidgetMainLayout->addWidget(m_bottomWidget,1,Qt::AlignTop); _NormalWidgetMainLayout->addStretch(100); if (m_btServer && (nullptr != m_btServer->m_default_bluetooth_adapter)) m_defaultPowerStatus = m_btServer->m_default_bluetooth_adapter->getAdapterPower(); if (m_defaultPowerStatus) { QStringList devPaired_List= BlueToothDBusService::getDefaultAdapterPairedDev(); if( devPaired_List.count() == 0) m_middleWidget->setHidden(true); else m_middleWidget->setHidden(false); m_bottomWidget->setHidden(false); } else { m_middleWidget->setHidden(true); m_bottomWidget->setHidden(true); } } void BluetoothMainNormalWindow::InitDisplayStatus() { if (m_btServer && (nullptr != m_btServer->m_default_bluetooth_adapter)) m_defaultPowerStatus = m_btServer->m_default_bluetooth_adapter->getAdapterPower(); if (m_defaultPowerStatus) { QStringList devPaired_List= BlueToothDBusService::getDefaultAdapterPairedDev(); if( devPaired_List.count() == 0) m_middleWidget->setHidden(true); else m_middleWidget->setHidden(false); m_bottomWidget->setHidden(false); } else { m_middleWidget->setHidden(true); m_bottomWidget->setHidden(true); } } void BluetoothMainNormalWindow::InitConnectData() { if(m_btServer) { connect(m_btServer,&BlueToothDBusService::adapterPoweredChanged,this,&BluetoothMainNormalWindow::BluetoothSwitchChanged); connect(m_btServer,&BlueToothDBusService::defaultAdapterChangedSignal,this,&BluetoothMainNormalWindow::defaultAdapterChangedSlot); } if (m_topWidget) { connect(m_topWidget,&BluetoothTopWindow::btPowerSwitchChanged,this,&BluetoothMainNormalWindow::BluetoothSwitchChanged); } if (m_middleWidget) { connect(m_middleWidget,&BluetoothMiddleWindow::myDeviceWindosHiddenSignal,this,&BluetoothMainNormalWindow::setHiddenForMyDevice); } } void BluetoothMainNormalWindow::BluetoothSwitchChanged(bool status) { m_defaultPowerStatus = status; QTimer::singleShot(30,this,[=]{ SetHidden(!status); }); } void BluetoothMainNormalWindow::defaultAdapterChangedSlot(int indx) { KyDebug() << indx; QStringList devPaired_List= BlueToothDBusService::getDefaultAdapterPairedDev(); if(devPaired_List.count() == 0) m_middleWidget->setHidden(true); else m_middleWidget->setHidden(false); quitWindow(); reloadWindow(); } void BluetoothMainNormalWindow::SetHidden(bool status) { QStringList devPaired_List= BlueToothDBusService::getDefaultAdapterPairedDev(); if( devPaired_List.count() == 0) m_middleWidget->setHidden(true); else m_middleWidget->setHidden(status); m_bottomWidget->setHidden(status); } void BluetoothMainNormalWindow::setHiddenForMyDevice(bool status) { m_middleWidget->setHidden(status); } void BluetoothMainNormalWindow::reloadWindow() { if (m_topWidget) m_topWidget->reloadWindow(); if (m_middleWidget) m_middleWidget->reloadWindow(); if (m_bottomWidget) m_bottomWidget->reloadWindow(); InitDisplayStatus(); } void BluetoothMainNormalWindow::quitWindow() { if (m_topWidget) m_topWidget->quitWindow(); if (m_middleWidget) m_middleWidget->quitWindow(); if (m_bottomWidget) m_bottomWidget->quitWindow(); } ukui-bluetooth/environment.pri0000664000175000017500000000066715167665770015575 0ustar fengfengFILES_INSTALL_DIR = $$[QT_INSTALL_LIBS]/ukui-control-center SCHEMAS_INSTALL_DIR = /usr/share/glib-2.0/schemas/ SHARE_INSTALL_DIR = /usr/share/ukui-bluetooth/ BIN_INSTALL_DIR = /usr/bin/ ACTIONS_INSTALL_DIR = /usr/share/polkit-1/actions/ SERVICE_INSTALL_DIR = /usr/share/dbus-1/system-services/ CONF_INSTALL_DIR = /usr/share/dbus-1/system.d/ SHARE_TRANSLATIONS_INSTALL_DIR = /usr/share/ukui-bluetooth/translations ukui-bluetooth/ukui-shortcut-bluetooth/0000775000175000017500000000000015167665770017335 5ustar fengfengukui-bluetooth/ukui-shortcut-bluetooth/translations/0000775000175000017500000000000015167665770022056 5ustar fengfengukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_bo_CN.ts0000664000175000017500000000151015167665770030314 0ustar fengfeng BluetoothArea My Devices སྒྲིག་ཆས། More Bluetooth Settings སོ་སྔོན་སྒྲིག་འགོད་ནི་དེ་བས་ཀྱང་མང་བ། New Devices སྒྲིག་ཆས་གསར་བ། Bluetooth is disabled སོ་སྔོན་བྱེད་ལས་ཁ་རྒྱག་ཟིན། ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_ky.ts0000664000175000017500000000133015167665770027757 0ustar fengfeng BluetoothArea My Devices مەنىن ئۈسكۈنەم More Bluetooth Settings داعى ەلە كۅپ بليۇتۇز تەڭشەكتەرى New Devices جاڭى زاپجاستار Bluetooth is disabled بليۇتۇز ەتىپ جىبەرىلدى ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_ar.ts0000664000175000017500000000120515167665770027737 0ustar fengfeng BluetoothArea My Devices More Bluetooth Settings New Devices Bluetooth is disabled ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_zh_CN.ts0000664000175000017500000000120415167665770030335 0ustar fengfeng BluetoothArea My Devices 我的设备 More Bluetooth Settings 更多蓝牙设置 New Devices 新设备 Bluetooth is disabled 蓝牙功能已关闭 ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_zh_Hant.ts0000664000175000017500000000117615167665770030737 0ustar fengfeng BluetoothArea My Devices 我的設備 More Bluetooth Settings 更多藍牙設置 New Devices 新設備 Bluetooth is disabled 藍牙功能已關閉 ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_ug.ts0000664000175000017500000000131515167665770027752 0ustar fengfeng BluetoothArea My Devices مېنىڭ ئۈسكۈنەم More Bluetooth Settings تېخىمۇ كۆپ كۆكچىش تەڭشەكلىرى New Devices يېڭى ئۈسكۈنىلەر Bluetooth is disabled كۆكچىش ئېتىۋېتىلدى ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_mn.ts0000664000175000017500000000145115167665770027752 0ustar fengfeng BluetoothArea My Devices ᠮᠢᠨᠦ ᠲᠥᠬᠥᠭᠡᠷᠦᠮᠵᠢ More Bluetooth Settings ᠨᠡᠩ ᠣᠯᠠᠨ ᠯᠠᠨᠶᠠ ᠳᠤᠬᠢᠷᠠᠭᠤᠯᠤᠯᠳᠠ New Devices ᠰᠢᠨ᠎ᠡ ᠳᠦᠬᠦᠬᠡᠷᠦᠮᠵᠢ Bluetooth is disabled ᠯᠠᠨᠶᠠ ᠴᠢᠳᠠᠪᠬᠢ ᠵᠢ ᠬᠠᠭᠠᠪᠠ ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_kk.ts0000664000175000017500000000131515167665770027744 0ustar fengfeng BluetoothArea My Devices مەنىڭ ئۈسكۈنەم More Bluetooth Settings الٸدە كوپ بليۇتووت تەڭشەۋلەرى New Devices جاڭا جابدىقتار Bluetooth is disabled بليۇتووت قۇلپتاندى ukui-bluetooth/ukui-shortcut-bluetooth/translations/ukui-shortcut-bluetooth_zh_HK.ts0000664000175000017500000000117615167665770030347 0ustar fengfeng BluetoothArea My Devices 我的設備 More Bluetooth Settings 更多藍牙設置 New Devices 新設備 Bluetooth is disabled 藍牙功能已關閉 ukui-bluetooth/ukui-shortcut-bluetooth/widget/0000775000175000017500000000000015167665770020620 5ustar fengfengukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/0000775000175000017500000000000015167665770021235 5ustar fengfengukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/BluetoothArea.qml0000664000175000017500000001415415167665770024513 0ustar fengfengimport QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.15 import QtQuick.Controls.Material 2.3 import org.ukui.shortcut.bluetooth 1.0 import org.ukui.quick.items 1.0 as UkuiItems import org.ukui.quick.platform 1.0 as Platform UkuiItems.DtThemeBackground { id: root backgroundColor: Platform.GlobalTheme.kContainSecondaryAlphaNormal radius: Platform.GlobalTheme.kRadiusWindow Component.onCompleted: { console.log("ukui shortcut bluetooth start") BtInterface.registerClient(1) } Component.onDestruction: { console.log("ukui shortcut bluetooth stop") BtInterface.registerClient(0) } ColumnLayout { anchors.fill: parent spacing: 0 RowLayout { id: bttop width: parent.width Layout.alignment: Qt.AlignTop Layout.preferredHeight: 56 Item { Layout.fillWidth: true } SwitchDelegate { id: btpower checked: BtInterface.btPower onClicked: { BtInterface.btPower = !BtInterface.btPower } Layout.alignment: Qt.AlignRight Layout.rightMargin: 16 width: 50 height: 24 } } Rectangle { Layout.alignment: Qt.AlignTop Layout.fillWidth: true Layout.preferredHeight: 1 height: 1 color: "#0f000000" } Item { visible: !BtInterface.btPower Layout.alignment: Qt.AlignVCenter Layout.fillWidth: true Layout.fillHeight: true UkuiItems.DtThemeText { anchors.centerIn: parent horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter width: parent.width text: qsTr("Bluetooth is disabled") textColor: Platform.GlobalTheme.kFontSecondary } } ScrollView { visible: BtInterface.btPower Layout.alignment: Qt.AlignTop Layout.fillWidth: true Layout.fillHeight: true ScrollBar.vertical.policy: ScrollBar.AsNeeded ScrollBar.horizontal.policy: ScrollBar.AlwaysOff clip: true Flickable { id: myflickable anchors.fill: parent contentHeight: (listPairView.contentHeight>0 ? mydeviceslabel.height : 0) + listPairView.contentHeight + listNotPairView.contentHeight + 40 //contentWidth : parent.width ColumnLayout { Rectangle { id: mydeviceslabel visible: BtInterface.btPower && (listPairView.contentHeight>0 ? true : false) Layout.alignment: Qt.AlignTop height: 40 Label { anchors.left: parent.left anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter text: qsTr("My Devices") } } BluetoothPairedDevList { id : listPairView Layout.alignment: Qt.AlignTop interactive: false implicitHeight: listPairView.contentHeight width: 396 } Rectangle { visible: BtInterface.btPower Layout.alignment: Qt.AlignTop height: 40 Label { id: newDeviceLabel anchors.left: parent.left anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter text: qsTr("New Devices") } BusyIndicator{ anchors.left: newDeviceLabel.right anchors.leftMargin: 16 anchors.verticalCenter: parent.verticalCenter width: 12 height: 12 running: BtInterface.btDiscovering } } BluetoothNotPairedDevlist { id : listNotPairView Layout.alignment: Qt.AlignBottom interactive: false implicitHeight: listNotPairView.contentHeight srollmoving: myflickable.moving width: 396 } } } } Rectangle { Layout.alignment: Qt.AlignBottom Layout.fillWidth: true Layout.preferredHeight: 1 height: 1 color: Qt.rgba(0, 0, 0, 0.06) } Item { Layout.fillWidth: true Layout.preferredHeight: 56 Layout.alignment: Qt.AlignBottom opacity: Theme.windowOpacity UkuiItems.DtThemeText { id: settingLabel anchors.left: parent.left anchors.leftMargin: 24 anchors.verticalCenter: parent.verticalCenter text: qsTr("More Bluetooth Settings") textColor: Platform.GlobalTheme.kFontStrong MouseArea { anchors.fill: parent hoverEnabled: true onClicked: { BtInterface.openBluetoothSetting() } onEntered: { settingLabel.textColor = Platform.GlobalTheme.highlightActive } onExited: { settingLabel.textColor = Platform.GlobalTheme.kFontStrong } } } } } } ukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/EllipsisLabel.qml0000664000175000017500000000040315167665770024471 0ustar fengfengimport QtQuick 2.12 import QtQuick.Controls 2.5 Label { property bool showTooltip: true // 是否显示ToolTip elide: Text.ElideRight ToolTip.text: text ToolTip.visible: (showTooltip && truncated) ? hovered : false ToolTip.delay: 500 } ukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/main.qml0000664000175000017500000000172715167665770022703 0ustar fengfeng/* * Copyright (C) 2024, KylinSoft Co., Ltd. * * 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 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authors: youdiansaodongxi * */ import QtQuick 2.15 import QtQuick.Layouts 1.15 import org.ukui.quick.widgets 1.0 WidgetItem { Layout.fillWidth: true Layout.fillHeight: true clip: true BluetoothArea { anchors.fill: parent } } ukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/BluetoothPairedDevList.qml0000664000175000017500000001201215167665770026331 0ustar fengfeng import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.15 import QtQuick.Controls.Material 2.3 import org.ukui.shortcut.bluetooth 1.0 import org.ukui.quick.items 1.0 as UkuiItems import org.ukui.quick.platform 1.0 as Platform ListView { id: listPairView model: BtInterface.deviceList spacing: 0 Connections { target: BtInterface onUpdatePairedDevice : { console.log(ipos, device) if(-1 != ipos) { var d = listPairView.itemAtIndex(ipos); if(d) { d.updatePairedDeviceAttrs(device, attrs) } } } } // 定义每个项的显示方式 delegate: ItemDelegate { width: listPairView.width height: 45 Layout.leftMargin: 8 checkable: true property bool devConnecting: modelData.Connecting property bool devConnected: modelData.Connected property var devBattery: modelData.Battery property var devName: modelData.Name property var devType: modelData.Type RowLayout { anchors.fill: parent Item { Layout.alignment: Qt.AlignLeft Layout.leftMargin: 16 width: 36 height: 36 UkuiItems.IconButton { visible: !devConnecting iconSource: BtInterface.getBluetoothIcon(devType) anchors.fill: parent id: typeicon radius: parent.width / 2 isHighLight: devConnected width: parent.width height: parent.height } UkuiItems.IconButton { visible: devConnecting iconSource: "ukui-loading-" + String(loadingicon.loading_num % 8) + "-symbolic" anchors.fill: parent id: loadingicon radius: parent.width / 2 isHighLight: devConnected width: parent.width height: parent.height property int loading_num : 0 } Timer { interval: 100 running: devConnecting repeat: true onTriggered:{ loadingicon.loading_num += 1; loadingicon.iconSource = "ukui-loading-" + String(loadingicon.loading_num % 8) + "-symbolic"; } } } EllipsisLabel { id: btname Layout.alignment: Qt.AlignLeft Layout.leftMargin: 8 Layout.preferredWidth: 296 - (batteryItem.visible ? batteryItem.width : 0) text: devName } Item { Layout.fillWidth: true } Item { id: batteryItem visible: (devBattery >= 0 && devConnected) ? true : false Layout.preferredWidth: batterytext.contentWidth + batteryicon.width + 4 Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.rightMargin:24 Label { anchors.right: batteryicon.left anchors.rightMargin: 4 anchors.verticalCenter: parent.verticalCenter id: batterytext text: devBattery + "%" } UkuiItems.Icon { id: batteryicon anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter mode: UkuiItems.Icon.AutoHighlight source: BtInterface.getBluetoothBatteryIcon(devBattery); width: 16 height: 16 } } } onClicked: { // // 设置当前选中项 var key1 = devConnected ? "devDisconnect" : "devConnect"; console.log(key1) var mapData = {}; mapData[key1] = modelData.Addr; BtInterface.setBluetoothConfig(mapData); if(devConnected) { devConnecting = true; } } function updatePairedDeviceAttrs(device, attrs) { if(device === modelData.Addr) { if(attrs.hasOwnProperty("Connecting")) { devConnecting = attrs.Connecting; } if(attrs.hasOwnProperty("Battery")) { devBattery = attrs.Battery; } if(attrs.hasOwnProperty("Name")) { devName = attrs.Name; } if(attrs.hasOwnProperty("Type")) { devType = attrs.Type; } } else { console.log("error:", device, modelData.Addr) } } } } ukui-bluetooth/ukui-shortcut-bluetooth/widget/ui/BluetoothNotPairedDevlist.qml0000664000175000017500000000750415167665770027064 0ustar fengfengimport QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.15 import QtQuick.Controls.Material 2.3 import org.ukui.shortcut.bluetooth 1.0 import org.ukui.quick.items 1.0 as UkuiItems import org.ukui.quick.platform 1.0 as Platform ListView { id: listNotPairView model: BtInterface.notPairDeviceList spacing: 0 property bool srollmoving: false Connections { target: BtInterface onUpdateNotPairedDevice : { console.log("ipos:", ipos, device) if(-1 !== ipos) { var d = listNotPairView.itemAtIndex(ipos); if(d) { d.updateNotPairedDeviceAttrs(device, attrs) } } } } // 定义每个项的显示方式 delegate: ItemDelegate { width: listNotPairView.width height: 45 Layout.leftMargin: 8 checkable: true hoverEnabled: !listNotPairView.srollmoving property bool devConnecting: modelData.Connecting property bool devConnected: modelData.Connected property int devType: modelData.Type property var devName: modelData.Name RowLayout { anchors.fill: parent Item { Layout.alignment: Qt.AlignLeft Layout.leftMargin: 16 width: 36 height: 36 UkuiItems.IconButton { visible: !devConnecting iconSource: BtInterface.getBluetoothIcon(devType) anchors.fill: parent id: typeicon radius: parent.width / 2 anchors.centerIn: parent isHighLight: devConnected } UkuiItems.IconButton { visible: devConnecting iconSource: "ukui-loading-" + String(loadingicon.loading_num % 8) + "-symbolic" anchors.fill: parent id: loadingicon radius: parent.width / 2 isHighLight: devConnected width: parent.width height: parent.height property int loading_num : 0 } Timer { interval: 100 running: devConnecting repeat: true onTriggered:{ loadingicon.loading_num += 1; loadingicon.iconSource = "ukui-loading-" + String(loadingicon.loading_num % 8) + "-symbolic"; } } } EllipsisLabel { id: btname Layout.alignment: Qt.AlignLeft Layout.leftMargin: 8 Layout.preferredWidth: 296 text: devName } Item { Layout.fillWidth: true } } onClicked: { // // 设置当前选中项 var key1 = devConnected ? "devDisconnect" : "devConnect"; console.log(key1) var mapData = {}; mapData[key1] = modelData.Addr; BtInterface.setBluetoothConfig(mapData); } function updateNotPairedDeviceAttrs(device, attrs) { if(device === modelData.Addr) { if(attrs.hasOwnProperty("Connecting")) { devConnecting = attrs.Connecting; } if(attrs.hasOwnProperty("Type")) { devType = attrs.Type; } if(attrs.hasOwnProperty("Name")) { btname.text = attrs.Name } } else { console.log("error:", device, modelData.Addr) } } } } ukui-bluetooth/ukui-shortcut-bluetooth/widget/qml.qrc0000664000175000017500000000042715167665770022123 0ustar fengfeng ui/main.qml ui/BluetoothArea.qml ui/BluetoothPairedDevList.qml ui/BluetoothNotPairedDevlist.qml ui/EllipsisLabel.qml ukui-bluetooth/ukui-shortcut-bluetooth/widget/metadata.json0000664000175000017500000000106215167665770023272 0ustar fengfeng{ "Authors": [ { "Name": "caitao", "Email": "caitao@kylinos.cn" } ], "Id": "org.ukui.shortcut.bluetooth", "Icon": "", "Name": "org-ukui-shortcut-bluetooth", "Name[zh_CN]": "快捷面板蓝牙插件", "Tooltip": "bluetooth", "Tooltip[zh_CN]": "蓝牙", "Description": "org.ukui.shortcut.bluetooth", "Description[zh_CN]": "快捷面板蓝牙插件", "Version": "1.0", "ShowIn": "Shortcut", "WidgetType": "Widget", "Contents": { "Main": "ui/main.qml", "I18n": "translations/ukui-shortcut-bluetooth" } } ukui-bluetooth/ukui-shortcut-bluetooth/translate_generation.sh0000775000175000017500000000055715167665770024113 0ustar fengfeng#!/bin/bash PATH="/usr/lib/qt6/bin:$PATH" ts_list=(`ls translations/*.ts`) source /etc/os-release version=(`echo $ID`) for ts in "${ts_list[@]}" do printf "\nprocess ${ts}\n" if [ "$version" == "fedora" ] || [ "$version" == "opensuse-leap" ] || [ "$version" == "opensuse-tumbleweed" ];then lrelease-qt6 "${ts}" else lrelease "${ts}" fi done ukui-bluetooth/ukui-shortcut-bluetooth/ukui-shortcut-bluetooth.pro0000664000175000017500000000355515167665770024720 0ustar fengfengTEMPLATE = lib TARGET = ukui-shortcut-bluetooth QT += quick dbus core CONFIG += plugin c++11 x11extras link_pkgconfig DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_NO_INFO_OUTPUT DEFINES += QT_NO_DEBUG_OUTPUT LIBS += -lpthread \ -lukui-log4qt PKGCONFIG += x11 xi TARGET = $$qtLibraryTarget($$TARGET) # Input SOURCES += \ plugin/bluetoothinterface.cpp \ plugin/bluetoothqml_plugin.cpp \ plugin/commontool.cpp \ plugin/devicemanager.cpp \ plugin/platformadaptor.cpp HEADERS += \ plugin/CSingleton.h \ plugin/bluetoothinterface.h \ plugin/bluetoothqml_plugin.h \ plugin/commontool.h \ plugin/devicemanager.h \ plugin/platformadaptor.h RESOURCES += widget/qml.qrc CONFIG(release, debug|release) { !system($$PWD/translate_generation.sh): error("Failed to generate translation") } inst1.files += widget/** inst1.path = /usr/share/ukui/widgets/org.ukui.shortcut.bluetooth inst2.files += plugin/qmldir inst2.path = $$[QT_INSTALL_LIBS]/qt6/qml/org/ukui/shortcut/bluetooth qm_files.files += translations/*.qm qm_files.path = /usr/share/ukui/widgets/org.ukui.shortcut.bluetooth/translations target.path = $$[QT_INSTALL_LIBS]/qt6/qml/org/ukui/shortcut/bluetooth TRANSLATIONS += \ translations/ukui-shortcut-bluetooth_zh_CN.ts \ translations/ukui-shortcut-bluetooth_ar.ts \ translations/ukui-shortcut-bluetooth_kk.ts \ translations/ukui-shortcut-bluetooth_mn.ts \ translations/ukui-shortcut-bluetooth_bo_CN.ts \ translations/ukui-shortcut-bluetooth_ky.ts \ translations/ukui-shortcut-bluetooth_ug.ts \ translations/ukui-shortcut-bluetooth_zh_Hant.ts \ translations/ukui-shortcut-bluetooth_zh_HK.ts INSTALLS += inst1 \ inst2 \ target \ qm_files OBJECTS_DIR = ./obj/ MOC_DIR = ./moc/ DISTFILES += \ widget/ui/EllipsisLabel.qml ukui-bluetooth/ukui-shortcut-bluetooth/plugin/0000775000175000017500000000000015167665770020633 5ustar fengfengukui-bluetooth/ukui-shortcut-bluetooth/plugin/bluetoothinterface.cpp0000664000175000017500000001417015167665770025230 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothinterface.h" #include "devicemanager.h" #include "platformadaptor.h" #include "commontool.h" #include #include #include #include #include BluetoothInterface::BluetoothInterface() { KyInfo(); srand(time(0)); COMMONTOOL::instance(); PTAD::instance(); init(); } BluetoothInterface::~BluetoothInterface() { KyInfo(); if(m_ukuiProcess) { m_ukuiProcess->deleteLater(); } } QString BluetoothInterface::getIconData(QString name, int size /*= 16*/) { QIcon icon =QIcon::fromTheme(name); QPixmap pixmap = icon.pixmap(size, size); QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); pixmap.save(&buffer, "PNG"); return "data:image/png;base64," + data.toBase64(); } void BluetoothInterface::init() { m_blueIcon.insert(BluetoothType::Phone, ("phone-symbolic")); m_blueIcon.insert(BluetoothType::Computer, ("video-display-symbolic")); m_blueIcon.insert(BluetoothType::Headset, ("audio-headphones-symbolic")); // m_blueIcon.insert(BluetoothType::Headphones, ("audio-headphones-symbolic")); m_blueIcon.insert(BluetoothType::AudioVideo, ("audio-speakers-symbolic")); m_blueIcon.insert(BluetoothType::Keyboard, ("input-keyboard-symbolic")); m_blueIcon.insert(BluetoothType::Mouse, ("input-mouse-symbolic")); m_blueIcon.insert(BluetoothType::Tablet, ("tablet-symbolic")); m_blueIcon.insert(BluetoothType::Uncategorized, ("bluetooth-symbolic")); } void BluetoothInterface::sendUpdatePairedDevices(const QList > &devices) { emit this->updatePairedDevices(); } void BluetoothInterface::sendUpdateNotPairedDevices(const QList > &devices) { if(nullptr == m_timer) { m_timer = new QTimer(this); m_timer->setInterval(1000); connect(m_timer,&QTimer::timeout, this, [=](){ m_timer->deleteLater(); m_timer = nullptr; KyDebug() << "sendUpdateNotPairedDevices"; emit this->updateNotPairedDevices(); }); m_timer->start(); } } void BluetoothInterface::sendUpdatePairedDevice(const QString &device, const QMap &attrs) { BtAdapterPtr bt = PTAD::getInstance()->getDefaultBtAdapter(); int index = -1; if(bt){ index= bt->getPairedDeviceIter(device); } emit this->updatePairedDevice(index, device, attrs); } void BluetoothInterface::sendUpdateNotPairedDevice(const QString &device, const QMap &attrs) { if(nullptr == m_timer) { BtAdapterPtr bt = PTAD::getInstance()->getDefaultBtAdapter(); int index = -1; if(bt){ index= bt->getNotPairedDeviceIter(device); } KyDebug() << "sendUpdateNotPairedDevice" << index << device; emit this->updateNotPairedDevice(index, device, attrs); } } void BluetoothInterface::sendIsInit(bool v) { KyInfo() << v; m_btInit = v; emit this->isInit(); } void BluetoothInterface::sendIsShowBluetooth(bool v) { KyInfo() << v; emit this->isShowBluetooth(); } void BluetoothInterface::sendBluetoothPower(bool v) { KyInfo() << v; m_btPower = v; emit this->bluetoothPower(); } void BluetoothInterface::sendBluetoothDiscovering(bool v) { KyInfo() << v; m_btDiscovering = v; emit this->bluetoothDiscovering(); } bool BluetoothInterface::getInit() { KyInfo(); return m_btInit; } bool BluetoothInterface::getShowBluetooth() { KyInfo(); return PTAD::getInstance()->getShowBluetooth(); } bool BluetoothInterface::getAdapterPower() { return m_btPower; } bool BluetoothInterface::getAdapterDiscovering() { return m_btDiscovering; } QVariantList BluetoothInterface::getPairedDevices() { QVariantList list; auto arrs = PTAD::getInstance()->pairedDevices(); for(auto iter : arrs){ iter["LoadingIcon"] = BluetoothType::LoadingIcon; //iter["Battery"] = rand() % 101; list.append(iter); } return list; } QVariantList BluetoothInterface::getNotPairedDevices() { QVariantList list; auto arrs = PTAD::getInstance()->notPairedDevices(); for(auto iter : arrs){ iter["LoadingIcon"] = BluetoothType::LoadingIcon; list.append(iter); } return list; } void BluetoothInterface::setAdapterPower(bool v) { QMap attr; attr["Powered"] = v; PTAD::getInstance()->setBluetoothConfig(attr); } void BluetoothInterface::setBluetoothConfig(QMap attrs) { KyInfo() << attrs; PTAD::getInstance()->setBluetoothConfig(attrs); } void BluetoothInterface::openBluetoothSetting() { if(m_ukuiProcess) { //m_ukuiProcess->close(); m_ukuiProcess->deleteLater(); } m_ukuiProcess = new QProcess(); QString cmd = "ukui-control-center"; QStringList arg; arg.clear(); arg << "-m"; arg << "Bluetooth"; KyInfo() << arg; m_ukuiProcess->startDetached(cmd,arg); } QVariant BluetoothInterface::getBluetoothIcon(int itype) { if(m_blueIcon.contains(itype)) { return m_blueIcon[itype]; } return m_blueIcon[BluetoothType::Uncategorized]; } QVariant BluetoothInterface::getBluetoothBatteryIcon(int v) { QString t = QString("battery-level-") + QString::number(v / 10 * 10) + QString("-symbolic"); KyInfo() << t; return t; } void BluetoothInterface::registerClient(bool v) { KyInfo() << v; PTAD::getInstance()->registerClient(v); } ukui-bluetooth/ukui-shortcut-bluetooth/plugin/qmldir0000664000175000017500000000010215167665770022037 0ustar fengfengmodule org.ukui.shortcut.bluetooth plugin ukui-shortcut-bluetooth ukui-bluetooth/ukui-shortcut-bluetooth/plugin/platformadaptor.h0000664000175000017500000000633415167665770024211 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef PLATFORMADAPTOR_H #define PLATFORMADAPTOR_H #include #include #include #include #include #include #include #include #include #include #include "devicemanager.h" #include "CSingleton.h" class PlatformAdaptor : public QObject { Q_OBJECT protected: explicit PlatformAdaptor(QObject *parent = nullptr); ~PlatformAdaptor(void); public: bool getInit(void); bool getShowBluetooth(void); bool getAdapterPower(void); QList> pairedDevices(void) const; QList> notPairedDevices(void) const; void setBluetoothConfig(QMap); BtAdapterPtr getDefaultBtAdapter(void); void sendUpdatePairedDeviceSort(QStringList); void registerClient(bool); protected: QDBusPendingCallWatcher * asyncCall(const QString & methed, const QList & params); QDBusPendingCallWatcher * asyncSessCall(const QString & methed, const QList & params); void getAdapter(void); void getAdapterAttr(QString id); void getPairedDevices(void); void getPairedDeviceAttr(QString id); void getNotPairedDevices(void); void getNotPairedDeviceAttr(QString id); bool whetherNeedInfoUser(); void calcInit(void); protected slots: void getAdapterFinished(QDBusPendingCallWatcher * watcher); void getAdapterAttrFinished(QDBusPendingCallWatcher * watcher); void getPairedDevicesFinished(QDBusPendingCallWatcher * watcher); void getPairedDeviceAttrFinished(QDBusPendingCallWatcher * watcher); void getNotPairedDevicesFinished(QDBusPendingCallWatcher * watcher); void getNotPairedDeviceAttrFinished(QDBusPendingCallWatcher * watcher); void adapterAddSignal(QMap); void adapterAttrChanged(QString, QMap); void adapterRemoveSignal(QString); void deviceAddSignal(QMap); void deviceAttrChanged(QString, QMap); void deviceRemoveSignal(QString, QMap); void updateClient(void); protected: //初始化 bool m_init = false; volatile int m_pending_count = 0; QDBusInterface m_bluetooth_iface; QDBusInterface m_sess_bluetooth_iface; BtAdapterPtr m_dfAdapterPtr; QMap m_adapters; protected: friend class SingleTon; }; typedef SingleTon PTAD; #endif // PLATFORMADAPTOR_H ukui-bluetooth/ukui-shortcut-bluetooth/plugin/devicemanager.h0000664000175000017500000000517315167665770023604 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef DEVICEMANAGER_H #define DEVICEMANAGER_H #include #include #include #include #include class BtAdapter; class BtDevice; typedef QSharedPointer BtDevicePtr; typedef QSharedPointer BtAdapterPtr; class BtDevice { protected: BtDevice(QString id); public: ~BtDevice(); public: QString id() { return m_id; } void setAttr(QMap); QMap getAttr(void); QVariant getAttr(QString); int getRssi(void); bool isMouse(void); bool isKeyboard(void); protected: QString m_id; QMap m_attrs; friend class BtAdapter; }; class BtAdapter : public QObject { Q_OBJECT public: explicit BtAdapter(QString id); ~BtAdapter(); QString id(void) {return m_id;} void setAttr(QMap); QMap getAttr(void); QVariant getAttr(QString); void addPairedDevice(QString id, QMap attrs); void addNotPairedDevice(QString id, QMap attrs); void setDeviceAttr(QString id, QMap attrs); QList > getPairedDevices(void); QList > getNotPairedDevices(void); void removeDevice(QString id); void cleaDevices(void); int getPairedDeviceIter(const QString & id); int getNotPairedDeviceIter(const QString & id); int getKeyboardNum(void); int getMouseNum(void); protected: void calcDeviceList(QString id); void calcNotPairedDeviceList(QString id, bool rssichange = false); void insertDevid(QString id); protected: QString m_id; QMap m_attrs; QMap m_pairedDevices; QMap m_notPairedDevices; QList m_connectDevices; QList m_noConnectDevices; QList m_notPairedDevicelist; }; #endif // DEVICEMANAGER_H ukui-bluetooth/ukui-shortcut-bluetooth/plugin/commontool.h0000664000175000017500000000134515167665770023175 0ustar fengfeng#ifndef COMMONTOOL_H #define COMMONTOOL_H #include #include #include "CSingleton.h" enum BluetoothType { Phone = 0, Modem, Computer, Network, Headset, Headphones, AudioVideo, Keyboard, Mouse, Joypad, Tablet, Peripheral, Camera, Printer, Imaging, Wearable, Toy, Health, //LoadingIcon = 200 LoadingIcon = 200, Uncategorized = 0xffff, }; class CommonTool { public: CommonTool(); ~CommonTool(); bool isWayland(); int getSystemCurrentMouseAndTouchPadDevCount(); int getSystemCurrentKeyBoardDevCount(); friend class SingleTon; }; typedef SingleTon COMMONTOOL; #endif // COMMONTOOL_H ukui-bluetooth/ukui-shortcut-bluetooth/plugin/CSingleton.h0000664000175000017500000000260315167665770023052 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef CSINGLETON_H #define CSINGLETON_H template class SingleTon { public: // 创建单例实例 template static T* instance(Args&&... args) { if (m_pInstance == nullptr) { m_pInstance = new T(std::forward(args)...); } return m_pInstance; } // 获取单例 static T* getInstance() { return m_pInstance; } // 删除单例 static void destroyInstance() { delete m_pInstance; m_pInstance = nullptr; } private: SingleTon(); virtual ~SingleTon(); private: static T* m_pInstance; }; template T* SingleTon::m_pInstance = nullptr; #endif ukui-bluetooth/ukui-shortcut-bluetooth/plugin/bluetoothqml_plugin.h0000664000175000017500000000174615167665770025111 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHQML_PLUGIN_H #define BLUETOOTHQML_PLUGIN_H #include class BluetoothqmlPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) override; }; #endif // BLUETOOTHQML_PLUGIN_H ukui-bluetooth/ukui-shortcut-bluetooth/plugin/platformadaptor.cpp0000664000175000017500000005050215167665770024540 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "platformadaptor.h" #include "ukui-log4qt.h" #include "bluetoothinterface.h" #include "commontool.h" #include #define DBUSSERVICE "com.ukui.bluetooth" #define DBUSPATH "/com/ukui/bluetooth" #define DBUSINTERFACE "com.ukui.bluetooth" PlatformAdaptor::PlatformAdaptor(QObject *parent) : QObject(parent), m_bluetooth_iface(DBUSSERVICE, DBUSPATH, DBUSINTERFACE, QDBusConnection::systemBus()), m_sess_bluetooth_iface(DBUSSERVICE, DBUSPATH, DBUSINTERFACE, QDBusConnection::sessionBus()) { this->getAdapter(); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "updateClient",this, SLOT(updateClient())); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "adapterAddSignal",this, SLOT(adapterAddSignal(QMap))); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "adapterAttrChanged",this, SLOT(adapterAttrChanged(QString, QMap))); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "adapterRemoveSignal",this, SLOT(adapterRemoveSignal(QString))); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "deviceAddSignal",this, SLOT(deviceAddSignal(QMap))); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "deviceAttrChanged",this, SLOT(deviceAttrChanged(QString, QMap))); QDBusConnection::systemBus().connect(DBUSSERVICE,DBUSPATH, DBUSINTERFACE, "deviceRemoveSignal",this, SLOT(deviceRemoveSignal(QString, QMap))); } PlatformAdaptor::~PlatformAdaptor() { KyInfo(); } bool PlatformAdaptor::getInit() { return m_init; } bool PlatformAdaptor::getShowBluetooth() { if(m_adapters.size() > 0) { return true; } return false; } bool PlatformAdaptor::getAdapterPower() { if(m_dfAdapterPtr) { QVariant v = m_dfAdapterPtr->getAttr("Powered"); //KyInfo() << v; if(v.isNull() || v.type() != QVariant::Bool) { return false; } return v.toBool(); } return false; } QList> PlatformAdaptor::pairedDevices() const { if(m_dfAdapterPtr) { return m_dfAdapterPtr->getPairedDevices(); } return QList>(); } QList > PlatformAdaptor::notPairedDevices() const { if(m_dfAdapterPtr) { return m_dfAdapterPtr->getNotPairedDevices(); } return QList>(); } void PlatformAdaptor::setBluetoothConfig(QMap attr) { KyInfo() << attr; QString key; key = "Powered"; if(attr.contains(key)) { bool res = false; if(!attr[key].toBool()) { res = this->whetherNeedInfoUser(); } if (res) { QList params; this->asyncSessCall("showCloseBluetoothInfoDialog", params); } else { QList params; QMap param; param[key] = attr[key]; params.append(param); this->asyncCall("setDefaultAdapterAttr", params); } } key = "devConnect"; if(attr.contains(key) && attr[key].type() == QVariant::String) { QList params; params.append(attr[key].toString()); this->asyncCall(key, params); } key = "devDisconnect"; if(attr.contains(key) && attr[key].type() == QVariant::String) { QList params; params.append(attr[key].toString()); this->asyncCall(key, params); } } BtAdapterPtr PlatformAdaptor::getDefaultBtAdapter() { return m_dfAdapterPtr; } void PlatformAdaptor::sendUpdatePairedDeviceSort(QStringList devlist) { QList params; params.append(devlist); this->asyncCall("updatePairedDeviceSort", params); } void PlatformAdaptor::registerClient(bool v) { QList params; if(v) { QMap attrs; attrs["dbusid"] = QDBusConnection::systemBus().baseService(); attrs["username"] = QString(qgetenv("USER").toStdString().data()); attrs["type"] = 0; params.append(attrs); this->asyncCall("registerClient", params); } else { params.append(QDBusConnection::systemBus().baseService()); this->asyncCall("unregisterClient", params); } } QDBusPendingCallWatcher *PlatformAdaptor::asyncCall(const QString & methed, const QList & params) { if (!m_bluetooth_iface.isValid()) { KyWarning() << "not connect dbus server: " << m_bluetooth_iface.lastError().message(); return nullptr; } QDBusPendingCall pendingCall = m_bluetooth_iface.asyncCallWithArgumentList(methed, params); return new QDBusPendingCallWatcher(pendingCall); } QDBusPendingCallWatcher *PlatformAdaptor::asyncSessCall(const QString &methed, const QList ¶ms) { if (!m_sess_bluetooth_iface.isValid()) { KyWarning() << "not connect dbus server: " << m_sess_bluetooth_iface.lastError().message(); return nullptr; } QDBusPendingCall pendingCall = m_sess_bluetooth_iface.asyncCallWithArgumentList(methed, params); return new QDBusPendingCallWatcher(pendingCall); } void PlatformAdaptor::getAdapterFinished(QDBusPendingCallWatcher * watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QStringList adapterlist; adapterlist = reply.arguments().at(0).value(); KyInfo() << adapterlist; for(auto iter: adapterlist) { if(!m_adapters.contains(iter)) { BtAdapterPtr a(new BtAdapter(iter)); m_adapters[iter] = a; } this->getAdapterAttr(iter); } } } else { KyWarning() << reply.errorMessage(); } this->calcInit(); } void PlatformAdaptor::getAdapterAttrFinished(QDBusPendingCallWatcher *watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QMap attrs; QDBusArgument arg = reply.arguments().at(0).value(); arg >> attrs; QString id; QString key; key = "Addr"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) id = attrs[key].toString(); } if(m_adapters.contains(id)) { m_adapters[id]->setAttr(attrs); } else { KyWarning() << "not exist adapter id:" << id; return; } key = "DefaultAdapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { //默认蓝牙适配器 if(attrs[key].toBool()) { m_dfAdapterPtr = m_adapters[id]; } else { if(m_dfAdapterPtr && m_dfAdapterPtr->id() == id) { m_dfAdapterPtr = nullptr; } return; } } else { return; } this->getPairedDevices(); this->getNotPairedDevices(); } } else { KyWarning() << reply.errorMessage(); } this->calcInit(); } void PlatformAdaptor::getPairedDevicesFinished(QDBusPendingCallWatcher *watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QStringList pairedlist; pairedlist = reply.arguments().at(0).value(); KyInfo() << pairedlist; for(auto iter: pairedlist) { this->getPairedDeviceAttr(iter); } } } else { KyWarning() << reply.errorMessage(); } this->calcInit(); } void PlatformAdaptor::getPairedDeviceAttrFinished(QDBusPendingCallWatcher *watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QMap attrs; QDBusArgument arg = reply.arguments().at(0).value(); arg >> attrs; //KyInfo() << attrs; QString id, ad, key; key = "Addr"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) id = attrs[key].toString(); } key = "Adapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) ad = attrs[key].toString(); } if(m_dfAdapterPtr && m_dfAdapterPtr->id() == ad) { m_dfAdapterPtr->addPairedDevice(id, attrs); } else { KyWarning() << "not default adapter: " << ad; } } } else { KyWarning() << reply.errorMessage(); } this->calcInit(); } void PlatformAdaptor::getNotPairedDevicesFinished(QDBusPendingCallWatcher *watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QStringList alldevlist; alldevlist = reply.arguments().at(0).value(); KyInfo() << alldevlist; for(auto iter: alldevlist) { this->getNotPairedDeviceAttr(iter); } } } else { KyWarning() << reply.errorMessage(); } this->calcInit(); } void PlatformAdaptor::getNotPairedDeviceAttrFinished(QDBusPendingCallWatcher *watcher) { m_pending_count--; QDBusMessage reply = watcher->reply(); if(reply.type() == QDBusMessage::ReplyMessage) { if(reply.arguments().size() > 0) { QMap attrs; QDBusArgument arg = reply.arguments().at(0).value(); arg >> attrs; //KyInfo() << attrs; QString id, ad, key; key = "Addr"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) id = attrs[key].toString(); } key = "Adapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) ad = attrs[key].toString(); } key = "Paired"; if(attrs.contains(key) && attrs[key].type() == QVariant::Bool && attrs[key].toBool()) { KyInfo() << id << " paired"; goto END; } if(m_dfAdapterPtr && m_dfAdapterPtr->id() == ad) { m_dfAdapterPtr->addNotPairedDevice(id, attrs); } else { KyWarning() << "not default adapter: " << ad; } } } else { KyWarning() << reply.errorMessage(); } END: this->calcInit(); } void PlatformAdaptor::adapterAddSignal(QMap attrs) { QString key, devid; int dfa = -1; key = "DefaultAdapter"; // -1:不存在; 0: 非默认蓝牙适配器; 1: 默认蓝牙适配器 if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { dfa = attrs[key].toBool() ? 1 : 0; } key = "Addr"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) devid = attrs[key].toString(); } if(!m_adapters.contains(devid)) { BtAdapterPtr a(new BtAdapter(devid)); m_adapters[devid] = a; } if(1 == dfa) { if(m_dfAdapterPtr) { m_dfAdapterPtr->cleaDevices(); } m_dfAdapterPtr = m_adapters[devid]; } if(m_adapters.contains(devid)) { m_adapters[devid]->setAttr(attrs); } } void PlatformAdaptor::adapterAttrChanged(QString dev, QMap attrs) { QString key; int dfa = -1; key = "DefaultAdapter"; // -1:不存在; 0: 非默认蓝牙适配器; 1: 默认蓝牙适配器 if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { dfa = attrs[key].toBool() ? 1 : 0; } if(m_adapters.contains(dev)) { m_adapters[dev]->setAttr(attrs); } else { BtAdapterPtr a(new BtAdapter(dev)); m_adapters[dev] = a; a->setAttr(attrs); } if(m_dfAdapterPtr && m_dfAdapterPtr->id() == dev) { if(0 == dfa) { m_dfAdapterPtr->cleaDevices(); m_dfAdapterPtr = nullptr; } } else{ if(1 == dfa) { if(m_adapters.contains(dev)) { m_dfAdapterPtr = m_adapters[dev]; m_dfAdapterPtr->cleaDevices(); this->getPairedDevices(); this->getNotPairedDevices(); } } } } void PlatformAdaptor::adapterRemoveSignal(QString devid) { if(m_adapters.contains(devid)) { m_adapters.remove(devid); } if(m_dfAdapterPtr && m_dfAdapterPtr->id() == devid) { m_dfAdapterPtr = nullptr; } if(m_adapters.size() == 0) { BtInterface::getInstance()->sendIsShowBluetooth(false); } } void PlatformAdaptor::deviceAddSignal(QMap attrs) { QString key, devid, adapter; int paired = -1; key = "Paired"; // -1:不存在; 0: 非默认蓝牙适配器; 1: 默认蓝牙适配器 if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { paired = attrs[key].toBool() ? 1 : 0; } key = "Addr"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) devid = attrs[key].toString(); } key = "Adapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) adapter = attrs[key].toString(); } if(1 == paired) { if(m_dfAdapterPtr && m_dfAdapterPtr->id() == adapter) { m_dfAdapterPtr->addPairedDevice(devid, attrs); } else { KyWarning() << "not default adapter: " << adapter << ", devid: " << devid; } } else { if(m_dfAdapterPtr && m_dfAdapterPtr->id() == adapter) { //KyInfo() << "add not pair device"; m_dfAdapterPtr->addNotPairedDevice(devid, attrs); } } } void PlatformAdaptor::deviceAttrChanged(QString devid, QMap attrs) { QString key, adapter; int paired = -1; key = "Paired"; // -1:不存在; 0: 未配对设备; 1: 已配对设备 if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { paired = attrs[key].toBool() ? 1 : 0; } if(1 == paired) { this->getPairedDeviceAttr(devid); } else if(-1 == paired) { if(m_dfAdapterPtr) { m_dfAdapterPtr->setDeviceAttr(devid, attrs); } } } void PlatformAdaptor::deviceRemoveSignal(QString devid, QMap attrs) { QString key, adapter; key = "Adapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::String) { if(attrs[key].toString().length() > 0) adapter = attrs[key].toString(); } if(m_adapters.contains(adapter)) { m_adapters[adapter]->removeDevice(devid); } else { KyWarning() << "not exist adapter: " << adapter; } } void PlatformAdaptor::updateClient() { KyInfo(); m_adapters.clear(); m_dfAdapterPtr = nullptr; m_init = false; BtInterface::getInstance()->sendIsInit(m_init); this->getAdapter(); } void PlatformAdaptor::getAdapter() { QDBusPendingCallWatcher * watcher = this->asyncCall("getAllAdapterAddress", QList()); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getAdapterFinished); } else { KyWarning() << "null pending"; } } void PlatformAdaptor::getAdapterAttr(QString id) { QList params; params.append(id); params.append(""); QDBusPendingCallWatcher * watcher = this->asyncCall("getAdapterAttr", params); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getAdapterAttrFinished); } else { KyWarning() << "null pending"; } } void PlatformAdaptor::getPairedDevices() { QDBusPendingCallWatcher * watcher = this->asyncCall("getDefaultAdapterPairedDev", QList()); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getPairedDevicesFinished); } else { KyWarning() << "null pending"; } } void PlatformAdaptor::getPairedDeviceAttr(QString id) { QList params; params.append(id); QDBusPendingCallWatcher * watcher = this->asyncCall("getDevAttr", params); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getPairedDeviceAttrFinished); } else { KyWarning() << "null pending"; } } void PlatformAdaptor::getNotPairedDevices() { QDBusPendingCallWatcher * watcher = this->asyncCall("getDefaultAdapterAllDev", QList()); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getNotPairedDevicesFinished); } else { KyWarning() << "null pending"; } } void PlatformAdaptor::getNotPairedDeviceAttr(QString id) { QList params; params.append(id); QDBusPendingCallWatcher * watcher = this->asyncCall("getDevAttr", params); if(watcher) { m_pending_count++; this->connect(watcher, &QDBusPendingCallWatcher::finished, this, &PlatformAdaptor::getNotPairedDeviceAttrFinished); } else { KyWarning() << "null pending"; } } bool PlatformAdaptor::whetherNeedInfoUser() { int bluetoothMouseNum = 0; int bluetoothKeyboardNum = 0; if(nullptr != m_dfAdapterPtr) { bluetoothMouseNum = m_dfAdapterPtr->getMouseNum(); bluetoothKeyboardNum = m_dfAdapterPtr->getKeyboardNum(); } if (0 == bluetoothMouseNum && 0 == bluetoothKeyboardNum) { return false; } int systemMouseAndTouchPadAmount = COMMONTOOL::getInstance()->getSystemCurrentMouseAndTouchPadDevCount(); int systemKeyBoardAmount = COMMONTOOL::getInstance()->getSystemCurrentKeyBoardDevCount(); KyDebug() << bluetoothMouseNum << bluetoothKeyboardNum << systemMouseAndTouchPadAmount << systemKeyBoardAmount; if ( -1 == systemKeyBoardAmount && -1 == systemMouseAndTouchPadAmount ) { return false; } if ((bluetoothMouseNum != 0) && (systemMouseAndTouchPadAmount == bluetoothMouseNum)) { return true; } if ((bluetoothKeyboardNum != 0) && (systemKeyBoardAmount == bluetoothKeyboardNum)) { return true; } return false; } void PlatformAdaptor::calcInit() { if(0 == m_pending_count) { if(!m_init) { KyInfo() << "init suc"; m_init = true; BtInterface::getInstance()->sendIsInit(m_init); } } } ukui-bluetooth/ukui-shortcut-bluetooth/plugin/devicemanager.cpp0000664000175000017500000002542115167665770024135 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "devicemanager.h" #include #include "bluetoothinterface.h" #include "platformadaptor.h" #include #include "commontool.h" BtDevice::BtDevice(QString id) { KyInfo() << id; m_id = id; } BtDevice::~BtDevice() { KyInfo() << m_id; } void BtDevice::setAttr(QMap attrs) { //KyInfo() << attrs; if(m_attrs.isEmpty()) { m_attrs = attrs; return; } auto tmp = m_attrs; for (const auto &key : attrs.keys()) { m_attrs[key] = attrs[key]; } bool pair = false; QVariant t = this->getAttr("Paired"); if(t.type() == QVariant::Bool) { pair = t.toBool(); } if(tmp != m_attrs) { if(pair) BtInterface::getInstance()->sendUpdatePairedDevice(m_id, m_attrs); else { BtInterface::getInstance()->sendUpdateNotPairedDevice(m_id, m_attrs); } } } QMap BtDevice::getAttr() { return m_attrs; } QVariant BtDevice::getAttr(QString key) { if(m_attrs.contains(key)) { return m_attrs[key]; } return QVariant(); } int BtDevice::getRssi() { int rssi = 100; QVariant t = this->getAttr("Rssi"); if(t.type() == QVariant::Int) { rssi = t.toInt(); } return rssi; } bool BtDevice::isMouse() { int itype = BluetoothType::Uncategorized; QVariant t = this->getAttr("Type"); if (t.type() == QVariant::Int) { itype = t.toInt(); } if (BluetoothType::Mouse == itype ) { return true; } return false; } bool BtDevice::isKeyboard() { int itype = BluetoothType::Uncategorized; QVariant t = this->getAttr("Type"); if (t.type() == QVariant::Int) { itype = t.toInt(); } if (BluetoothType::Keyboard == itype ) { return true; } return false; } ///////////////////BtAdapter////////////////////////////// BtAdapter::BtAdapter(QString id) { KyInfo() << id; m_id = id; } BtAdapter::~BtAdapter() { KyInfo() << m_id; } void BtAdapter::setAttr(QMap attrs) { //KyInfo() << attrs; QString key; int newdefault = -1; int olddefault = -1; key = "DefaultAdapter"; if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { newdefault = attrs[key].toBool() ? 1 : 0; } if(m_attrs.contains(key) && m_attrs[key].type() == QVariant::Bool) { olddefault = m_attrs[key].toBool() ? 1 : 0; } for (const auto &iter : attrs.keys()) { m_attrs[iter] = attrs[iter]; } key = "Powered"; if(-1 != newdefault && olddefault != newdefault) { if(newdefault) { if(m_attrs.contains(key) && m_attrs[key].type() == QVariant::Bool){ BtInterface::getInstance()->sendBluetoothPower(m_attrs[key].toBool()); } } } else { if(1 == olddefault && attrs.contains(key) && attrs[key].type() == QVariant::Bool){ BtInterface::getInstance()->sendBluetoothPower(attrs[key].toBool()); } } key = "Discovering"; if(attrs.contains(key) && attrs[key].type() == QVariant::Bool) { if(m_attrs.contains("DefaultAdapter") && m_attrs["DefaultAdapter"].type() == QVariant::Bool && m_attrs["DefaultAdapter"].toBool()) { BtInterface::getInstance()->sendBluetoothDiscovering(attrs[key].toBool()); } } } QMap BtAdapter::getAttr() { return m_attrs; } QVariant BtAdapter::getAttr(QString key) { if(m_attrs.contains(key)) { return m_attrs[key]; } return QVariant(); } void BtAdapter::addPairedDevice(QString id, QMap attrs) { BtDevicePtr p = nullptr; if(m_notPairedDevices.contains(id)) { p = m_notPairedDevices[id]; m_notPairedDevices.remove(id); this->calcNotPairedDeviceList(id); } if(!m_pairedDevices.contains(id)) { if(p) { KyInfo() << "use exist devptr: " << id; p->setAttr(attrs); m_pairedDevices[id] = p; } else { BtDevicePtr a(new BtDevice(id)); a->setAttr(attrs); m_pairedDevices[id] = a; } this->calcDeviceList(id); } else { KyInfo() << "devid exist : " << id; m_pairedDevices[id]->setAttr(attrs); this->calcDeviceList(id); } } void BtAdapter::addNotPairedDevice(QString id, QMap attrs) { if(!m_notPairedDevices.contains(id)) { BtDevicePtr a(new BtDevice(id)); a->setAttr(attrs); m_notPairedDevices[id] = a; this->calcNotPairedDeviceList(id); } else { KyInfo() << "devid exist : " << id; m_notPairedDevices[id]->setAttr(attrs); this->calcNotPairedDeviceList(id); } } void BtAdapter::setDeviceAttr(QString id, QMap attrs) { if(m_pairedDevices.contains(id)) { m_pairedDevices[id]->setAttr(attrs); this->calcDeviceList(id); } if(m_notPairedDevices.contains(id)) { bool rssichange = attrs.contains("Rssi"); m_notPairedDevices[id]->setAttr(attrs); this->calcNotPairedDeviceList(id, rssichange); } } QList > BtAdapter::getPairedDevices() { QList > devices; for (const auto & iter: m_connectDevices) { if(m_pairedDevices.contains(iter)) { devices.append(m_pairedDevices[iter]->getAttr()); } } for (const auto & iter: m_noConnectDevices) { if(m_pairedDevices.contains(iter)) { devices.append(m_pairedDevices[iter]->getAttr()); } } return devices; } QList > BtAdapter::getNotPairedDevices() { QList > devices; for(const auto & iter: m_notPairedDevicelist) { if(m_notPairedDevices.contains(iter)) { devices.append(m_notPairedDevices[iter]->getAttr()); } } return devices; } void BtAdapter::removeDevice(QString id) { if(m_pairedDevices.contains(id)) { m_pairedDevices.remove(id); this->calcDeviceList(id); } if(m_notPairedDevices.contains(id)) { m_notPairedDevices.remove(id); this->calcNotPairedDeviceList(id); } } void BtAdapter::cleaDevices() { m_pairedDevices.clear(); m_connectDevices.clear(); m_noConnectDevices.clear(); m_notPairedDevices.clear(); m_notPairedDevicelist.clear(); } int BtAdapter::getPairedDeviceIter(const QString & id) { QList tmp; tmp.append(m_connectDevices); tmp.append(m_noConnectDevices); return tmp.indexOf(id); } int BtAdapter::getNotPairedDeviceIter(const QString & id) { return m_notPairedDevicelist.indexOf(id); } int BtAdapter::getMouseNum() { int icount = 0; for (auto & iter : m_connectDevices) { if(m_pairedDevices.contains(iter)) { if (m_pairedDevices[iter]->isMouse()) { icount++; } } } return icount; } int BtAdapter::getKeyboardNum() { int icount = 0; for (auto & iter : m_connectDevices) { if(m_pairedDevices.contains(iter)) { if (m_pairedDevices[iter]->isKeyboard()) { icount++; } } } return icount; } void BtAdapter::calcDeviceList(QString id) { bool change = false; if(m_pairedDevices.contains(id)) { QVariant t = m_pairedDevices[id]->getAttr("Connected"); bool isconnect = false; if(t.type() == QVariant::Bool) { isconnect = t.toBool(); } if(isconnect) { if(m_connectDevices.contains(id)) { return; } else { m_noConnectDevices.removeOne(id); m_connectDevices.insert(0, id); change = true; } } else { if(m_noConnectDevices.contains(id)) return; else { m_connectDevices.removeOne(id); m_noConnectDevices.insert(0, id); change = true; } } } else { m_noConnectDevices.removeOne(id); m_connectDevices.removeOne(id); change = true; } if(change) { auto devices = getPairedDevices(); BtInterface::getInstance()->sendUpdatePairedDevices(devices); QStringList tmp; tmp.append(m_connectDevices); tmp.append(m_noConnectDevices); //tmp.res std::reverse(tmp.begin(), tmp.end()); PTAD::getInstance()->sendUpdatePairedDeviceSort(tmp); KyInfo() << m_connectDevices << m_noConnectDevices; } } void BtAdapter::calcNotPairedDeviceList(QString id, bool rssichange /*= false*/) { bool change = false; KyInfo() << id << rssichange; if(m_notPairedDevices.contains(id)) { if(!m_notPairedDevicelist.contains(id)) { this->insertDevid(id); change = true; } } else { if(m_notPairedDevicelist.contains(id)) { m_notPairedDevicelist.removeOne(id); change = true; } } if(rssichange) { this->insertDevid(id); change = true; } if(change) { auto devices = getNotPairedDevices(); BtInterface::getInstance()->sendUpdateNotPairedDevices(devices); } } void BtAdapter::insertDevid(QString id) { m_notPairedDevicelist.removeOne(id); int rssi1 = -256; int rssi2 = -256; int insertindex = 0; if(!m_notPairedDevices.contains(id)) { KyWarning() << "not exist devid:" << id; return; } rssi1 = m_notPairedDevices[id]->getRssi(); for(auto iter : m_notPairedDevicelist) { if(m_notPairedDevices.contains(iter)) { rssi2 = m_notPairedDevices[iter]->getRssi(); if(rssi2 < rssi1) { m_notPairedDevicelist.insert(insertindex, id); return; } else if (rssi2 == rssi1) { if(iter < id) { m_notPairedDevicelist.insert(insertindex, id); return; } } } insertindex++; } m_notPairedDevicelist.append(id); } ukui-bluetooth/ukui-shortcut-bluetooth/plugin/commontool.cpp0000664000175000017500000001232615167665770023531 0ustar fengfeng#include "commontool.h" #include #include #include #include #include #include #include extern "C"{ #include #include } #define STR_MOUSE "MOUSE" #define STR_TOUCHPAD "TOUCHPAD" #define STR_KEYBOARD "KEYBOARD" #define STR_TRACKPOINT "TRACKPOINT" #define WLCOM_SERVICE "com.kylin.Wlcom" #define WLCOM_OBJECT "/com/kylin/Wlcom/Input" #define WLCOM_INTERFACE "com.kylin.Wlcom.Input" #define WLCOM_METHED "ListAllInputs" CommonTool::CommonTool() { } CommonTool::~CommonTool() { } static QStringList waylany_getdev(){ QDBusInterface iface(WLCOM_SERVICE, WLCOM_OBJECT, WLCOM_INTERFACE, QDBusConnection::sessionBus()); QStringList v; QDBusMessage reply = iface.call(WLCOM_METHED); if(reply.type() == QDBusMessage::ReplyMessage) { QVariant va = reply.arguments()[0]; const QDBusArgument & dbusArg = va.value(); if (dbusArg.currentSignature() != "a(su)") { KyWarning() << "error data struct, " << dbusArg.currentSignature(); return v; } dbusArg.beginArray(); while (!dbusArg.atEnd()) { dbusArg.beginStructure(); QString str; quint32 num; dbusArg >> str; dbusArg >> num; dbusArg.endStructure(); v.append(str); } dbusArg.endArray(); } else { KyWarning() << reply; } return v; } bool CommonTool::isWayland() { QString sessionType = getenv("XDG_SESSION_TYPE"); if (!sessionType.compare("wayland", Qt::CaseInsensitive)) { return true; } return false; } static int x11_getSystemCurrentMouseAndTouchPadDevCount() { unsigned int count = 0 ; Display *display = XOpenDisplay(NULL); if (display == NULL) { XCloseDisplay(display); return -1; } XDeviceInfo *devices; int num_devices; devices = XListInputDevices(display, &num_devices); if (devices == NULL) { XCloseDisplay(display); return -1; } Atom mouse_prop = XInternAtom(display,STR_MOUSE,false); Atom touchPad_prop = XInternAtom(display,STR_TOUCHPAD,false); for (int i = 0; i < num_devices; i++) { if (devices[i].type == mouse_prop || devices[i].type == touchPad_prop) { QString dev_name = QString(devices[i].name); if (dev_name.contains(STR_MOUSE,Qt::CaseInsensitive) || dev_name.contains(STR_TOUCHPAD,Qt::CaseInsensitive) || dev_name.contains(STR_TRACKPOINT,Qt::CaseInsensitive) || dev_name.contains("MS",Qt::CaseInsensitive) ) { count ++; } } } KyDebug() << "mouse devices count:" << count; XFreeDeviceList(devices); XCloseDisplay(display); return count; } static int wayland_getSystemCurrentMouseAndTouchPadDevCount() { QStringList devices; int count = 0; devices = waylany_getdev(); KyInfo() << devices; for(auto iter : devices) { QString devname = iter; if(devname.endsWith(STR_MOUSE, Qt::CaseInsensitive) || devname.endsWith(STR_TOUCHPAD, Qt::CaseInsensitive) || devname.endsWith(STR_TRACKPOINT, Qt::CaseInsensitive) || devname.endsWith("MS", Qt::CaseInsensitive) ) { count++; } } KyInfo() << "mouse devices count:" << count; return count; } static int x11_getSystemCurrentKeyBoardDevCount() { unsigned int count = 0 ; Display *display = XOpenDisplay(NULL); if (display == NULL) { XCloseDisplay(display); return -1; } XDeviceInfo *devices; int num_devices; devices = XListInputDevices(display, &num_devices); if (devices == NULL) { XCloseDisplay(display); return -1; } Atom keyBoard_prop = XInternAtom(display,STR_KEYBOARD,false); for (int i = 0; i < num_devices; i++) { if(devices[i].type == keyBoard_prop) { QString dev_name = QString(devices[i].name); if (dev_name.contains(STR_KEYBOARD,Qt::CaseInsensitive)) { count++; } } } KyDebug() << "keyBoard devices count:" << count; XFreeDeviceList(devices); XCloseDisplay(display); return count; } static int wayland_getSystemCurrentKeyBoardDevCount() { QStringList devices; int count = 0; devices = waylany_getdev(); KyInfo() << devices; for(auto iter : devices) { QString devname = iter; if(devname.endsWith(STR_KEYBOARD, Qt::CaseInsensitive)) { count++; } } KyInfo() << "keyBoard devices count:" << count; return count; } int CommonTool::getSystemCurrentMouseAndTouchPadDevCount() { if (this->isWayland()) { return wayland_getSystemCurrentMouseAndTouchPadDevCount(); } return x11_getSystemCurrentMouseAndTouchPadDevCount(); } int CommonTool::getSystemCurrentKeyBoardDevCount() { if (this->isWayland()) { return wayland_getSystemCurrentKeyBoardDevCount(); } return x11_getSystemCurrentKeyBoardDevCount(); } ukui-bluetooth/ukui-shortcut-bluetooth/plugin/bluetoothqml_plugin.cpp0000664000175000017500000000222315167665770025433 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #include "bluetoothqml_plugin.h" #include "bluetoothinterface.h" #include #include void BluetoothqmlPlugin::registerTypes(const char *uri) { Q_ASSERT(QString(uri) == QLatin1String("org.ukui.shortcut.bluetooth")); qmlRegisterModule(uri, 1, 0); qmlRegisterSingletonType(uri, 1, 0, "BtInterface", [] (QQmlEngine *, QJSEngine *) -> QObject* { BtInterface::instance(); return BtInterface::getInstance(); }); } ukui-bluetooth/ukui-shortcut-bluetooth/plugin/bluetoothinterface.h0000664000175000017500000000730115167665770024673 0ustar fengfeng/* * Copyright (C) 2023, KylinSoft Co., Ltd. * * 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 3, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * **/ #ifndef BLUETOOTHINTERFACE_H #define BLUETOOTHINTERFACE_H #include #include #include #include #include #include #include #include #include "CSingleton.h" class BluetoothInterface : public QObject { Q_OBJECT Q_PROPERTY(QVariantList deviceList READ getPairedDevices NOTIFY updatePairedDevices) Q_PROPERTY(QVariantList notPairDeviceList READ getNotPairedDevices NOTIFY updateNotPairedDevices) Q_PROPERTY(bool btPower READ getAdapterPower WRITE setAdapterPower NOTIFY bluetoothPower) Q_PROPERTY(bool btDiscovering READ getAdapterDiscovering NOTIFY bluetoothDiscovering) Q_PROPERTY(bool btInit READ getInit NOTIFY isInit) protected: BluetoothInterface(); ~BluetoothInterface(); QString getIconData(QString name, int size = 16); void init(void); public: void sendUpdatePairedDevices(const QList> & devices); void sendUpdateNotPairedDevices(const QList> & devices); void sendUpdatePairedDevice(const QString & device, const QMap& attrs); void sendUpdateNotPairedDevice(const QString & device, const QMap& attrs); void sendIsInit(bool v); void sendIsShowBluetooth(bool v); void sendBluetoothPower(bool v); void sendBluetoothDiscovering(bool v); public slots: //获取是否完成初始化 bool getInit(void); //是否存在蓝牙适配器 bool getShowBluetooth(void); //获取蓝牙适配器开关状态 bool getAdapterPower(void); //获取蓝牙适配器扫描状态 bool getAdapterDiscovering(void); QVariantList getPairedDevices(void); QVariantList getNotPairedDevices(void); void setAdapterPower(bool v); //传输json字符串 void setBluetoothConfig(QMap); //打开控制面板蓝牙 void openBluetoothSetting(void); QVariant getBluetoothIcon(int); QVariant getBluetoothBatteryIcon(int); void registerClient(bool); signals: //蓝牙模块是否初始化完成 void isInit(); //是否存在蓝牙适配器 void isShowBluetooth(); //蓝牙开关状态 void bluetoothPower(); //蓝牙扫描状态 void bluetoothDiscovering(); void updatePairedDevice(int ipos, const QString & device, const QMap& attrs); void updateNotPairedDevice(int ipos, const QString & device, const QMap& attrs); //更新已配对蓝牙设备列表 //devices: list> void updatePairedDevices(); //未配对的临时设备 void updateNotPairedDevices(); protected: bool m_btInit = false; bool m_btPower = false; bool m_btDiscovering = false; QMap m_blueIcon; QMap m_batteryIcon; QProcess * m_ukuiProcess = nullptr; QTimer * m_timer = nullptr; friend class SingleTon; }; typedef SingleTon BtInterface; #endif // BLUETOOTHINTERFACE_H ukui-bluetooth/data/0000775000175000017500000000000015167665770013415 5ustar fengfengukui-bluetooth/data/org.ukui.log4qt.bluetoothserver.gschema.xml0000664000175000017500000000354615167665755023767 0ustar fengfeng "true" hook qt messages Control if hook qt messages "DEBUG,console,daily" config rootLogger's level and appenders config rootLogger's level and appenders:"level,appender" ".yyyy-MM-dd" daily log file pattern set daily log file pattern format:one day "%d{yyyy-MM-dd HH:mm:ss,zzz}(%-4r)[%t]|%-5p| - %m%n" set log message's format set log message's format 3600 set check log files delay time set check log files delay time 7 set log files count set log files count,unit s 512 set log files total size set log files total size, unit M ukui-bluetooth/data/ukui-bluetooth-service.desktop0000664000175000017500000000042315167665755021430 0ustar fengfeng[Desktop Entry] Type=Application Encoding=UTF-8 Name=ukui-bluetooth-daemon Name[zh_CN]=蓝牙服务 Comment=Simple bluetooth server for ukui desktop environment Comment[zh_CN]=UKUI桌面环境蓝牙系统级配置文件修改进程 Exec=/usr/bin/profileDaemon NoDisplay=true ukui-bluetooth/data/org.bluez.obex.conf0000664000175000017500000000147315167665755017137 0ustar fengfeng ukui-bluetooth/data/ukui-bluetooth.desktop0000664000175000017500000000063215167665755017774 0ustar fengfeng[Desktop Entry] Type=Application Encoding=UTF-8 Name=Bluetooth Name[zh_CN]=蓝牙 Name[bo_CN]=སོ་སྔོན། Name[zh_HK]=藍牙 Name[mn]=ᠯᠠᠨᠶᠠ Comment=Simple bluetooth tool for ukui desktop environment Comment[zh_CN]=UKUI桌面环境简单的蓝牙工具 Exec=/usr/bin/ukui-bluetooth Icon=bluetooth StartupNotify=false OnlyShowIn=UKUI; X-UKUI-AutoRestart=true NoDisplay=true Terminal=false ukui-bluetooth/data/connection-failed.svg0000664000175000017500000001173015167665755017524 0ustar fengfeng ukui-bluetooth/data/org.ukui.bluetooth.gschema.xml0000664000175000017500000000476215167665755021330 0ustar fengfeng false bluetooth power switch bluetooth power switch true bluetooth discoverable switch bluetooth discoverable switch "" File save path File save path "" Finally connect the device Last connected device saved [] List of paired devices Save a list of paired devices [] List of paired device address Save a list of paired device address [] List of adapter address Save a list of adapter address "" Save the Adapter used by default Save the Adapter used by default true Whether to display the icon in the tray Whether to display the icon in the tray false Whether to active connection Whether to active connection false Whether to turn on computer leave lock Whether to turn on the lock function after leaving "" Save the leave lock device Save the leave lock device ukui-bluetooth/data/ukui-bluetooth.service0000664000175000017500000000037515167665770017764 0ustar fengfeng[Unit] Description=UKUI Bluetooth service After=lightdm.service [Service] Environment="DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket" Type=simple ExecStart=/usr/bin/bluetoothService Restart=always [Install] WantedBy=multi-user.target ukui-bluetooth/data/org.bluez.Agent1.conf0000664000175000017500000000155715167665755017324 0ustar fengfeng ukui-bluetooth/data/no-bluetooth.svg0000664000175000017500000000212115167665755016554 0ustar fengfeng ukui-bluetooth/data/com.ukui.bluetooth.conf0000664000175000017500000000152015167665755020023 0ustar fengfeng ukui-bluetooth/data/file-transfer-failed.svg0000664000175000017500000000142715167665755020130 0ustar fengfeng ukui-bluetooth/data/file-transfer-success.svg0000664000175000017500000000164515167665755020356 0ustar fengfeng