Skip to content

Network Remote V2 #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

lister54
Copy link

@lister54 lister54 commented Mar 1, 2025

This is an updated version of the code I wrote originally. As I wanted to keep track of changes in the original I creates a new fork and appliedf my changes there.

I also have workign clients for Linux and Android and am hoping somebody else is interested in this feature,

I have one outstanding issue on Ubuntu
[1276/1276 11.5/sec] Linking CXX executable strawberry
/usr/bin/ld: warning: libicui18n.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicui18n.so.74
/usr/bin/ld: warning: libicuuc.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicuuc.so.74

but the app is working fine otherwise.
I've built and run the app in Qt Creator 15.0.1

@poldi171254
Copy link

Do I need to do anything else to get this approved?

Copy link
Member

@jonaski jonaski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm stopping review now, too many issues here:

  • Use rebase instead of merge with master so the new changes gets added on top of master.
  • Squash any commits that are corrections to the previous commits.
  • Remove all changes which are not related to the new feature, like newlines elsewhere, or unrelated changes.
  • The formatting of the code is inconsistent with the codebase, please use 2 spaces for indent everywhere, curly brace on the same line as the function declaration, snake case for variable names everywhere. Consider running it through clang-format to fix some of it (set DisableFormat to false in .clang-format), but only run it on the new code.
  • The naming is too generic, ie.: "Client", either everything should be namespaced inside NetworkRemote, or prefix all classes with NetworkRemote. I prefer the latter since that's the style we use.
  • Use Qt stringliterals (https://doc.qt.io/qt-6/qt-literals-stringliterals.html) instead of QStringLiteral / QLatin1String (Except for in headers).
  • Use Qt Protobuf (https://doc.qt.io/qt-6/qtprotobuf-index.html) instead of protobuf directly, that avoids all the string conversions and use of std::string.
  • Remove Application and include only the objects you use.
  • Use Settings instead of QSettings (core/settings.h), this is so we can add some modifications to where the config is stored.
  • Some objects are allocated on heap and not free'd that could be allocated on the stack.
  • I think we should use signals/slots to reload settings (like most other places) instead of the singleton.
  • Add missing copyright headers.
  • Make network remote a optional feature with optional_component

I started porting the networkremote code from Clementine to Qt 6 and Qt Protobuf a while ago, but the code in Clementine had a lot of issues. I've published it in the networkremote branch, it's unfinished and basically a mess, so it requires a lot more work, but it has more features than you've added here, but I'm not sure when I have time to finish it.

int remote_port_;
QHostAddress ipAddr_;
TcpServer *server_;
QThread *original_thread_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remote_port_ is used in networkremote.cpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

original_thread_ is not used, that's the line I commented on

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its still here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@jonaski jonaski mentioned this pull request Mar 5, 2025
@poldi171254
Copy link

Happy to work on all the changes you requested if that get's the functionality over the line; I may need some help/clarification on some of the issues though
I appreciate that the Clementine Remote had more functions, but when I started I thought that some basic functionality was better than not having this at all

jonaski and others added 14 commits April 7, 2025 18:14
You need to restart Strawberry for this setting to take affect
You need to restart Strawberry for this setting to take affect.
Renamed classes to be less ambiguous

Save before clientmanager changes

This works after major change in clientmanager

Cleaned up formatting

Still works
…n where I wasn't sure what was meant or how to resolve the issue.

I reformatted all my code and used Qt stringliterals where applicable
Cmake now uses Qt Protobuf
I removed Application where I could. Still needed where I need acces to the player.
All objects should now be freed.
I have hardcoded the CMAKE_INSTALL_RPATH as RPATH seems to be a requirement when using Ninja as the cmake generator. Ubuntu currently comes with 6.4.2, but the QtCreator is on 6.8 I'm pulling in the library from the Creator

Not sure what you meant by "I think we should use signals/slots to reload settings (like most other places) instead of the singleton"
Not sure what the Copyright header should look like. Do I put my name on this?
I have not made the Network remote optional yet as I wanted to get the code sorted out first

I still have have one outstanding issue on Ubuntu
[1276/1276 11.5/sec] Linking CXX executable strawberry
/usr/bin/ld: warning: libicui18n.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicui18n.so.74
/usr/bin/ld: warning: libicuuc.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicuuc.so.74
@poldi171254
Copy link

I have resolved most of the issues you have raised, but have left some of them unresolved as they have my comments and need in some cases answers/clarification

Is there a standard copyright I canshould use?

I will make the Network remote optional in the meantime

@@ -29,6 +29,10 @@ endif()
if(LINUX)
include(cmake/Rpm.cmake)
include(cmake/Deb.cmake)
# RPATH seems to be a requirement when using Ninja as the cmake generator.
# as Ubuntu currently comes with 6.4.2, but the QtCreator is on 6.8 I'm pulling in the library from the Creator
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
Copy link
Member

@jonaski jonaski Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why you need this, but this shouldn't be hard-coded in CMakeLists.txt, you can easily pass -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE to cmake if you need this.

# RPATH seems to be a requirement when using Ninja as the cmake generator.
# as Ubuntu currently comes with 6.4.2, but the QtCreator is on 6.8 I'm pulling in the library from the Creator
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "/home/llist/Qt/6.9.0/gcc_64/lib")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this

@jonaski
Copy link
Member

jonaski commented Apr 23, 2025

I have resolved most of the issues you have raised, but have left some of them unresolved as they have my comments and need in some cases answers/clarification

The formatting is still wrong, I don't know if you have pushed all the changes, I see mostly unrelated commits merged in. Please rebase with master to clean it up.

Is there a standard copyright I canshould use?

You can just copy one from the other files.

@jonaski
Copy link
Member

jonaski commented Apr 23, 2025

This is an updated version of the code I wrote originally. As I wanted to keep track of changes in the original I creates a new fork and appliedf my changes there.

I also have workign clients for Linux and Android and am hoping somebody else is interested in this feature,

I have one outstanding issue on Ubuntu [1276/1276 11.5/sec] Linking CXX executable strawberry /usr/bin/ld: warning: libicui18n.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicui18n.so.74 /usr/bin/ld: warning: libicuuc.so.73, needed by /home/llist/Qt/6.8.2/gcc_64/lib/libQt6Core.so.6.8.2, may conflict with libicuuc.so.74

but the app is working fine otherwise. I've built and run the app in Qt Creator 15.0.1

It seems like you have 2 conflicting ICU libraries, one on your system and one in /home/llist/Qt/6.8.2/gcc_64/lib/, strawberry probably links your systems version so you need to pass flags to cmake to make it use the same version used by the Qt installation, otherwise you'll have 2 conflicting versions linked which can lead to collision. This is unrelated to the changes so this should be removed from the PR description and commit message.

@poldi171254
Copy link

I think I have now completed the code as per your feedback.
I'd appreciate if you could review the code before I attempt to resolve the cmake issues.

Copy link
Member

@jonaski jonaski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to run the code through formatting first to fix all the incorrect indent and variable names

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.14)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is minimum CMake version increased?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular need, but thought it didn't hurt being on a later version given that I didn't find any problems.
I have changed this back to 3.13

@@ -172,6 +176,15 @@ if(UNIX AND NOT APPLE)
endif()
find_package(X11 COMPONENTS X11_xcb)
endif()

find_package(Qt6 REQUIRED COMPONENTS Protobuf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using multiple find_package lines for the same library is bad practice. Move Protobuf to QT_OPTIONAL_COMPONENTS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really out of my depth here and used a solution I found from examples & tutorials.
I need the first find_package for the Qt6 protobuf package and the second find_package for protobuf_generate.
If I comment any of them out cmake fails.


find_package(Qt6 REQUIRED COMPONENTS Protobuf)
if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove: No need to use Protobuf directly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@@ -172,6 +176,15 @@ if(UNIX AND NOT APPLE)
endif()
find_package(X11 COMPONENTS X11_xcb)
endif()

find_package(Qt6 REQUIRED COMPONENTS Protobuf)
if(NOT Protobuf_FOUND)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove: No need to use Protobuf directly.

find_package(Qt6 REQUIRED COMPONENTS Protobuf)
if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove: No need to use Protobuf directly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above


class NetworkRemoteTcpServer : public QObject
{
Q_OBJECT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 space for indent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean

void StartServer(QHostAddress ipAddr, int port);
void StopServer();

private:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 space for indent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Application *app_;
QTcpServer *server_;
QTcpSocket *socket_;
NetworkRemoteClientManager *clientMgr_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake case for variables

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

: QObject(parent),
app_(app),
msg_(new nw::remote::Message),
responeSong_(new nw::remote::ResponseSongMetadata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


bytesOut_ = msg_->ByteSizeLong();

if(socket_->isWritable())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(socket_->isWritable())
if (socket_->isWritable())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonaski
Copy link
Member

jonaski commented May 1, 2025

Commit 18de736 looks wrong, it looks like you modified my commit with changes from this PR.
Like I pointed out earlier please rebase with master to avoid the commit mess.

{
ui_->setupUi(this);
const int iconSize = style()->pixelMetric(QStyle::PM_TabBarIconSize);
setWindowIcon(IconLoader::Load(QStringLiteral("network-remote"), true, 0,iconSize));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
setWindowIcon(IconLoader::Load(QStringLiteral("network-remote"), true, 0,iconSize));
setWindowIcon(IconLoader::Load(u"network-remote"_s), true, 0, style()->pixelMetric(QStyle::PM_TabBarIconSize)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gives the following warning in Qt Creator
networkremotesettingspage.cpp:39:56: Too many arguments to function call, expected single argument 'icon', have 4 arguments
qwidget.h:378:10: 'setWindowIcon' declared here

void NetworkRemoteSettingsPage::Load()
{
ui_->portSelected->setRange(5050, 65535);
ui_->ip_address->setText(QStringLiteral("0.0.0.0"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You included Qt::Literals::StringLiterals but you forgot to actually use it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


ui_->useRemoteClient->setCheckable(true);
ui_->useRemoteClient->setChecked(settings_->UserRemote());
if (settings_->UserRemote()){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (settings_->UserRemote()){
if (settings_->UserRemote()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants