Reformat project with clang-format
This commit is contained in:
parent
a8adedd100
commit
dc8f3e209e
11 changed files with 178 additions and 113 deletions
|
@ -105,7 +105,9 @@ void BluetoothLinkProvider::serviceDiscovered(const QBluetoothServiceInfo &old_i
|
|||
{
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered executed ";
|
||||
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered info: " << old_info.device().address() << old_info.serviceName() << old_info.serviceDescription() << old_info.socketProtocol() << old_info.isValid() << old_info.isComplete() << old_info.isRegistered() << old_info.serviceClassUuids();
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::serviceDiscovered info: " << old_info.device().address() << old_info.serviceName()
|
||||
<< old_info.serviceDescription() << old_info.socketProtocol() << old_info.isValid() << old_info.isComplete()
|
||||
<< old_info.isRegistered() << old_info.serviceClassUuids();
|
||||
|
||||
auto info = *(new QBluetoothServiceInfo(old_info));
|
||||
info.setServiceUuid(mServiceUuid);
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
namespace MdnsWrapper
|
||||
{
|
||||
|
||||
const char *recordTypeToStr(int rtype)
|
||||
{
|
||||
switch (rtype) {
|
||||
|
@ -79,10 +78,22 @@ static sockaddr_in6 qHostAddressToSockaddr6(QHostAddress hostAddress)
|
|||
}
|
||||
|
||||
// Callback that handles responses to a query
|
||||
static int query_callback(int sock, const struct sockaddr* from, size_t addrlen, mdns_entry_type_t entry_type,
|
||||
uint16_t query_id, uint16_t record_type, uint16_t rclass, uint32_t ttl, const void* data,
|
||||
size_t size, size_t name_offset, size_t name_length, size_t record_offset,
|
||||
size_t record_length, void* user_data) {
|
||||
static int query_callback(int sock,
|
||||
const struct sockaddr *from,
|
||||
size_t addrlen,
|
||||
mdns_entry_type_t entry_type,
|
||||
uint16_t query_id,
|
||||
uint16_t record_type,
|
||||
uint16_t rclass,
|
||||
uint32_t ttl,
|
||||
const void *data,
|
||||
size_t size,
|
||||
size_t name_offset,
|
||||
size_t name_length,
|
||||
size_t record_offset,
|
||||
size_t record_length,
|
||||
void *user_data)
|
||||
{
|
||||
Q_UNUSED(sock);
|
||||
Q_UNUSED(addrlen);
|
||||
Q_UNUSED(query_id);
|
||||
|
@ -92,13 +103,15 @@ static int query_callback(int sock, const struct sockaddr* from, size_t addrlen,
|
|||
Q_UNUSED(name_offset);
|
||||
Q_UNUSED(name_length);
|
||||
|
||||
//qCDebug(KDECONNECT_CORE) << "Received DNS record of type" << recordTypeToStr(record_type) << "from socket" << sock << "with type" << entryTypeToStr(entry_type);
|
||||
// qCDebug(KDECONNECT_CORE) << "Received DNS record of type" << recordTypeToStr(record_type) << "from socket" << sock << "with type" <<
|
||||
// entryTypeToStr(entry_type);
|
||||
|
||||
Discoverer::MdnsService *discoveredService = (Discoverer::MdnsService *)user_data;
|
||||
|
||||
switch (record_type) {
|
||||
case MDNS_RECORDTYPE_PTR: {
|
||||
// We don't use mdns_record_parse_ptr() because we want to extract just the service name instead of the full "<instance-name>._<service-type>._tcp.local." string
|
||||
// We don't use mdns_record_parse_ptr() because we want to extract just the service name instead of the full
|
||||
// "<instance-name>._<service-type>._tcp.local." string
|
||||
mdns_string_pair_t instanceNamePos = mdns_get_next_substring(data, size, record_offset);
|
||||
discoveredService->name = QString::fromLatin1((char *)data + instanceNamePos.offset, instanceNamePos.length);
|
||||
// static char instanceNameBuffer[256];
|
||||
|
@ -251,7 +264,8 @@ static mdns_string_t createMdnsString(const QByteArray &str)
|
|||
return mdns_string_t{str.constData(), (size_t)str.length()};
|
||||
}
|
||||
|
||||
int countCommonLeadingBits(quint32 int1, quint32 int2) {
|
||||
int countCommonLeadingBits(quint32 int1, quint32 int2)
|
||||
{
|
||||
int count = 0;
|
||||
while (int1 != 0 && int2 != 0) {
|
||||
if ((int1 & 0x80000000) == (int2 & 0x80000000)) {
|
||||
|
@ -349,10 +363,22 @@ static mdns_record_t createMdnsRecord(const Announcer::AnnouncedInfo &self,
|
|||
}
|
||||
|
||||
// Callback handling questions incoming on service sockets
|
||||
static int service_callback(int sock, const struct sockaddr* from, size_t addrlen, mdns_entry_type_t entry_type,
|
||||
uint16_t query_id, uint16_t record_type, uint16_t rclass, uint32_t ttl, const void* data,
|
||||
size_t size, size_t name_offset, size_t name_length, size_t record_offset,
|
||||
size_t record_length, void* user_data) {
|
||||
static int service_callback(int sock,
|
||||
const struct sockaddr *from,
|
||||
size_t addrlen,
|
||||
mdns_entry_type_t entry_type,
|
||||
uint16_t query_id,
|
||||
uint16_t record_type,
|
||||
uint16_t rclass,
|
||||
uint32_t ttl,
|
||||
const void *data,
|
||||
size_t size,
|
||||
size_t name_offset,
|
||||
size_t name_length,
|
||||
size_t record_offset,
|
||||
size_t record_length,
|
||||
void *user_data)
|
||||
{
|
||||
Q_UNUSED(ttl);
|
||||
Q_UNUSED(name_length);
|
||||
Q_UNUSED(record_offset);
|
||||
|
@ -379,9 +405,20 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
|||
|
||||
uint16_t unicast = (rclass & MDNS_UNICAST_RESPONSE);
|
||||
if (unicast) {
|
||||
ret = mdns_query_answer_unicast(sock, from, addrlen, sendbuffer, sizeof(sendbuffer), query_id,
|
||||
(mdns_record_type_t)record_type, nameMdnsString.str, nameMdnsString.length,
|
||||
answer, nullptr, 0, nullptr, 0);
|
||||
ret = mdns_query_answer_unicast(sock,
|
||||
from,
|
||||
addrlen,
|
||||
sendbuffer,
|
||||
sizeof(sendbuffer),
|
||||
query_id,
|
||||
(mdns_record_type_t)record_type,
|
||||
nameMdnsString.str,
|
||||
nameMdnsString.length,
|
||||
answer,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
0);
|
||||
} else {
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0, nullptr, 0);
|
||||
}
|
||||
|
@ -409,12 +446,22 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
|||
|
||||
uint16_t unicast = (rclass & MDNS_UNICAST_RESPONSE);
|
||||
if (unicast) {
|
||||
ret = mdns_query_answer_unicast(sock, from, addrlen, sendbuffer, sizeof(sendbuffer), query_id,
|
||||
(mdns_record_type_t)record_type, nameMdnsString.str, nameMdnsString.length,
|
||||
answer, nullptr, 0, additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_unicast(sock,
|
||||
from,
|
||||
addrlen,
|
||||
sendbuffer,
|
||||
sizeof(sendbuffer),
|
||||
query_id,
|
||||
(mdns_record_type_t)record_type,
|
||||
nameMdnsString.str,
|
||||
nameMdnsString.length,
|
||||
answer,
|
||||
nullptr,
|
||||
0,
|
||||
additional.constData(),
|
||||
additional.length());
|
||||
} else {
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0,
|
||||
additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0, additional.constData(), additional.length());
|
||||
}
|
||||
}
|
||||
} else if (name == self.serviceInstance) {
|
||||
|
@ -439,12 +486,22 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
|||
|
||||
uint16_t unicast = (rclass & MDNS_UNICAST_RESPONSE);
|
||||
if (unicast) {
|
||||
ret = mdns_query_answer_unicast(sock, from, addrlen, sendbuffer, sizeof(sendbuffer), query_id,
|
||||
(mdns_record_type_t)record_type, nameMdnsString.str, nameMdnsString.length,
|
||||
answer, nullptr, 0, additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_unicast(sock,
|
||||
from,
|
||||
addrlen,
|
||||
sendbuffer,
|
||||
sizeof(sendbuffer),
|
||||
query_id,
|
||||
(mdns_record_type_t)record_type,
|
||||
nameMdnsString.str,
|
||||
nameMdnsString.length,
|
||||
answer,
|
||||
nullptr,
|
||||
0,
|
||||
additional.constData(),
|
||||
additional.length());
|
||||
} else {
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0,
|
||||
additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0, additional.constData(), additional.length());
|
||||
}
|
||||
}
|
||||
} else if (name == self.hostname) {
|
||||
|
@ -465,12 +522,22 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
|||
|
||||
uint16_t unicast = (rclass & MDNS_UNICAST_RESPONSE);
|
||||
if (unicast) {
|
||||
ret = mdns_query_answer_unicast(sock, from, addrlen, sendbuffer, sizeof(sendbuffer), query_id,
|
||||
(mdns_record_type_t)record_type, nameMdnsString.str, nameMdnsString.length,
|
||||
answer, nullptr, 0, additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_unicast(sock,
|
||||
from,
|
||||
addrlen,
|
||||
sendbuffer,
|
||||
sizeof(sendbuffer),
|
||||
query_id,
|
||||
(mdns_record_type_t)record_type,
|
||||
nameMdnsString.str,
|
||||
nameMdnsString.length,
|
||||
answer,
|
||||
nullptr,
|
||||
0,
|
||||
additional.constData(),
|
||||
additional.length());
|
||||
} else {
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0,
|
||||
additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0, additional.constData(), additional.length());
|
||||
}
|
||||
} else if (((record_type == MDNS_RECORDTYPE_AAAA) || (record_type == MDNS_RECORDTYPE_ANY)) && !self.addressesV6.empty()) {
|
||||
// The AAAA query was for our qualified hostname and we have an IPv6 address, answer with an AAAA
|
||||
|
@ -489,12 +556,22 @@ static int service_callback(int sock, const struct sockaddr* from, size_t addrle
|
|||
|
||||
uint16_t unicast = (rclass & MDNS_UNICAST_RESPONSE);
|
||||
if (unicast) {
|
||||
ret = mdns_query_answer_unicast(sock, from, addrlen, sendbuffer, sizeof(sendbuffer), query_id,
|
||||
(mdns_record_type_t)record_type, nameMdnsString.str, nameMdnsString.length,
|
||||
answer, nullptr, 0, additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_unicast(sock,
|
||||
from,
|
||||
addrlen,
|
||||
sendbuffer,
|
||||
sizeof(sendbuffer),
|
||||
query_id,
|
||||
(mdns_record_type_t)record_type,
|
||||
nameMdnsString.str,
|
||||
nameMdnsString.length,
|
||||
answer,
|
||||
nullptr,
|
||||
0,
|
||||
additional.constData(),
|
||||
additional.length());
|
||||
} else {
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0,
|
||||
additional.constData(), additional.length());
|
||||
ret = mdns_query_answer_multicast(sock, sendbuffer, sizeof(sendbuffer), answer, nullptr, 0, additional.constData(), additional.length());
|
||||
}
|
||||
}
|
||||
} // else request is not for me
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*/
|
||||
namespace MdnsWrapper
|
||||
{
|
||||
|
||||
class KDECONNECTCORE_EXPORT Discoverer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -19,7 +19,6 @@ extern "C" {
|
|||
|
||||
namespace SslHelper
|
||||
{
|
||||
|
||||
QString getSslError()
|
||||
{
|
||||
char buf[256];
|
||||
|
|
|
@ -34,11 +34,7 @@ IndicatorHelper::IndicatorHelper()
|
|||
m_splashScreen = new QSplashScreen(splashPixmap);
|
||||
|
||||
// Icon is white, set the text color to black
|
||||
m_splashScreen->showMessage(
|
||||
i18n("Launching") + QStringLiteral("\n"),
|
||||
Qt::AlignHCenter | Qt::AlignBottom,
|
||||
Qt::black
|
||||
);
|
||||
m_splashScreen->showMessage(i18n("Launching") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::black);
|
||||
m_splashScreen->show();
|
||||
}
|
||||
|
||||
|
@ -88,11 +84,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd)
|
|||
}
|
||||
|
||||
// Start daemon
|
||||
m_splashScreen->showMessage(
|
||||
i18n("Launching daemon") + QStringLiteral("\n"),
|
||||
Qt::AlignHCenter | Qt::AlignBottom,
|
||||
Qt::black
|
||||
);
|
||||
m_splashScreen->showMessage(i18n("Launching daemon") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::black);
|
||||
|
||||
// Here we will try to bring our private session D-Bus
|
||||
if (!hasUsableSessionBus) {
|
||||
|
@ -101,11 +93,7 @@ int IndicatorHelper::daemonHook(QProcess &kdeconnectd)
|
|||
DBusHelper::launchDBusDaemon();
|
||||
// Wait for dbus daemon env
|
||||
QProcess getLaunchdDBusEnv;
|
||||
m_splashScreen->showMessage(
|
||||
i18n("Waiting D-Bus") + QStringLiteral("\n"),
|
||||
Qt::AlignHCenter | Qt::AlignBottom,
|
||||
Qt::black
|
||||
);
|
||||
m_splashScreen->showMessage(i18n("Waiting D-Bus") + QStringLiteral("\n"), Qt::AlignHCenter | Qt::AlignBottom, Qt::black);
|
||||
int retry = 0;
|
||||
getLaunchdDBusEnv.setProgram(QStringLiteral("launchctl"));
|
||||
getLaunchdDBusEnv.setArguments({QStringLiteral("getenv"), QStringLiteral(KDECONNECT_SESSION_DBUS_LAUNCHD_ENV)});
|
||||
|
|
|
@ -78,8 +78,7 @@ DeviceNotificationsDbusInterface::DeviceNotificationsDbusInterface(const QString
|
|||
|
||||
NotificationDbusInterface::NotificationDbusInterface(const QString &deviceId, const QString ¬ificationId, QObject *parent)
|
||||
: OrgKdeKdeconnectDeviceNotificationsNotificationInterface(DaemonDbusInterface::activatedService(),
|
||||
QLatin1String("/modules/kdeconnect/devices/%1/notifications/").arg(deviceId)
|
||||
+ notificationId,
|
||||
QLatin1String("/modules/kdeconnect/devices/%1/notifications/").arg(deviceId) + notificationId,
|
||||
QDBusConnection::sessionBus(),
|
||||
parent)
|
||||
, id(notificationId)
|
||||
|
|
|
@ -26,7 +26,8 @@ K_PLUGIN_CLASS_WITH_JSON(MprisControlPlugin, "kdeconnect_mpriscontrol.json")
|
|||
|
||||
namespace
|
||||
{
|
||||
const QString DEFAULT_PLAYER = i18nc("@title Users select this to control the current media player when we can't detect a specific player name like VLC", "Current Player");
|
||||
const QString DEFAULT_PLAYER =
|
||||
i18nc("@title Users select this to control the current media player when we can't detect a specific player name like VLC", "Current Player");
|
||||
}
|
||||
|
||||
MprisControlPlugin::MprisControlPlugin(QObject *parent, const QVariantList &args)
|
||||
|
@ -289,7 +290,6 @@ bool MprisControlPlugin::sendAlbumArt(std::variant<NetworkPacket, QString> const
|
|||
void MprisControlPlugin::handleDefaultPlayer(const NetworkPacket &np)
|
||||
{
|
||||
if (np.has(QStringLiteral("action"))) {
|
||||
|
||||
INPUT input = {0};
|
||||
input.type = INPUT_KEYBOARD;
|
||||
|
||||
|
@ -306,16 +306,13 @@ void MprisControlPlugin::handleDefaultPlayer(const NetworkPacket &np)
|
|||
} else if (action == QStringLiteral("Stop")) {
|
||||
input.ki.wVk = VK_MEDIA_STOP;
|
||||
::SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
else if (action == QStringLiteral("Next")) {
|
||||
} else if (action == QStringLiteral("Next")) {
|
||||
input.ki.wVk = VK_MEDIA_NEXT_TRACK;
|
||||
::SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
else if (action == QStringLiteral("Previous")) {
|
||||
} else if (action == QStringLiteral("Previous")) {
|
||||
input.ki.wVk = VK_MEDIA_PREV_TRACK;
|
||||
::SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
else if (action == QStringLiteral("Stop")) {
|
||||
} else if (action == QStringLiteral("Stop")) {
|
||||
input.ki.wVk = VK_MEDIA_STOP;
|
||||
::SendInput(1, &input, sizeof(INPUT));
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
#include <core/kdeconnectplugin.h>
|
||||
#include <core/kdeconnectpluginconfig.h>
|
||||
|
||||
namespace {
|
||||
namespace
|
||||
{
|
||||
// https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html
|
||||
inline constexpr const char *NOTIFY_SIGNATURE = "susssasa{sv}i";
|
||||
inline constexpr const char *IMAGE_DATA_SIGNATURE = "iiibiiay";
|
||||
|
@ -142,7 +143,6 @@ QVariant nextVariant(DBusMessageIter *iter)
|
|||
case DBUS_TYPE_STRING:
|
||||
return QVariant(QString::fromUtf8(value.str));
|
||||
case DBUS_STRUCT_BEGIN_CHAR: {
|
||||
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -330,7 +330,8 @@ void DBusNotificationsListener::onNotify(const QString &appName,
|
|||
auto it = hints.constFind(QStringLiteral("image-data"));
|
||||
if (it != hints.cend() || (it = hints.constFind(QStringLiteral("image_data"))) != hints.cend()) {
|
||||
iconSource = iconForImageData(it.value());
|
||||
} else if ((it = hints.constFind(QStringLiteral("image-path"))) != hints.cend() || (it = hints.constFind(QStringLiteral("image_path"))) != hints.cend()) {
|
||||
} else if ((it = hints.constFind(QStringLiteral("image-path"))) != hints.cend()
|
||||
|| (it = hints.constFind(QStringLiteral("image_path"))) != hints.cend()) {
|
||||
iconSource = iconForIconName(it.value().toString());
|
||||
} else if (!appIcon.isEmpty()) {
|
||||
iconSource = iconForIconName(appIcon);
|
||||
|
|
|
@ -38,7 +38,10 @@ private Q_SLOTS:
|
|||
|
||||
QSignalSpy spy(&discoverer, &MdnsWrapper::Discoverer::serviceFound);
|
||||
|
||||
connect(&discoverer, &MdnsWrapper::Discoverer::serviceFound, this, [instanceName, instancePort, txtKey, txtValue](const MdnsWrapper::Discoverer::MdnsService &service) {
|
||||
connect(&discoverer,
|
||||
&MdnsWrapper::Discoverer::serviceFound,
|
||||
this,
|
||||
[instanceName, instancePort, txtKey, txtValue](const MdnsWrapper::Discoverer::MdnsService &service) {
|
||||
QCOMPARE(instanceName, service.name);
|
||||
QCOMPARE(instancePort, service.port);
|
||||
QVERIFY(service.txtRecords.size() == 1);
|
||||
|
|
Loading…
Reference in a new issue