Skip to content
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

Stop synchronisation when behind a captive portal #11567

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

Conversation

erikjv
Copy link
Contributor

@erikjv erikjv commented Mar 28, 2024

Fixes: #11533

@erikjv erikjv requested a review from TheOneRing March 28, 2024 17:33
@erikjv erikjv self-assigned this Mar 28, 2024
@erikjv erikjv marked this pull request as draft March 28, 2024 17:34
@erikjv
Copy link
Contributor Author

erikjv commented Mar 28, 2024

The SpacesManager still needs to be hooked up. So maybe the Utility code needs to move to libsync.

src/gui/guiutility.cpp Outdated Show resolved Hide resolved
@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch 3 times, most recently from 2728dbe to 7dd72f4 Compare April 4, 2024 15:10
if (onoff) {
_queueGuard.block();
} else {
// TODO: empty queue?
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure. It might depend on how long we were blocked, 10s or 20h...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still not sure what to do with this

Copy link
Member

Choose a reason for hiding this comment

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

Lets clear it.

if (_account->accessManager()->isBehindCaptivePortal()) {
_queueGuard.block();
} else {
// TODO: empty queue?
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this unblock has any use?

Copy link
Member

Choose a reason for hiding this comment

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

How can we be blocked during the construction of the class?

@@ -247,6 +263,7 @@ void AccountState::setState(State state)
} else if (_state == Connected && Utility::internetConnectionIsMetered() && ConfigFile().pauseSyncWhenMetered()) {
_state = PausedDueToMetered;
}
// Do we need an extra state PausedDueToCaptivePortal?
Copy link
Member

Choose a reason for hiding this comment

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

For now we could reuse "Connecting"? In the end its only to display a different string? In which case we could make the "connecting" message conditional on isBehindCaptivePortal

src/gui/main.cpp Outdated Show resolved Hide resolved
Copy link
Member

@TheOneRing TheOneRing left a comment

Choose a reason for hiding this comment

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

For a manual testing action, it has quite a heavy impact on the client...

src/gui/owncloudgui.cpp Show resolved Hide resolved
src/libsync/accessmanager.cpp Outdated Show resolved Hide resolved
@TheOneRing
Copy link
Member

Brainstorming: We have multiple network information things to test, could it make sense to implement a custom one that wraps the native one and allows overriding values?

@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from 7dd72f4 to f10d5eb Compare April 11, 2024 15:44
@erikjv erikjv requested a review from TheOneRing April 11, 2024 15:45
@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch 2 times, most recently from 03c2325 to 4e85060 Compare April 15, 2024 13:56
@erikjv erikjv marked this pull request as ready for review April 15, 2024 14:03
@TheOneRing
Copy link
Member

Please rebase, once done I can start a review.

@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from 5b1e182 to 412851f Compare April 16, 2024 13:55
src/gui/networkinformation.cpp Outdated Show resolved Hide resolved
connect(NetworkInformation::instance(), &NetworkInformation::isBehindCaptivePortalChanged, this, [this](bool) {
// A direct connect is not possible, because then the state parameter of `isBehindCaptivePortalChanged`
// would become the `verifyServerState` argument to `checkConnectivity`.
QTimer::singleShot(0, this, [this] { checkConnectivity(false); });
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to run the check if it changed to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it sets the state to Connecting and triggers the signals so the UI shows paused and captive portal.

Copy link
Member

Choose a reason for hiding this comment

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

Could you add that as a comment? I see the possibility that someone might "Optimize" that call.

@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from 412851f to 07efac2 Compare April 17, 2024 13:28
@erikjv erikjv requested a review from TheOneRing April 17, 2024 14:00
@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from 07efac2 to 8920af8 Compare April 17, 2024 15:04
@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from 8920af8 to fdde86d Compare April 17, 2024 17:32
@@ -27,6 +28,8 @@ namespace OCC {
namespace TestUtils {
TestUtilsPrivate::AccountStateRaii createDummyAccount()
{
// ensure we have an instance of NetworkInformation
NetworkInformation::initialize();
Copy link
Member

Choose a reason for hiding this comment

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


NetworkInformation *NetworkInformation::_instance = nullptr;

static void loadQNetworkInformationBackend()
Copy link
Member

Choose a reason for hiding this comment

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

anonymous namespace please

}

void NetworkInformation::initialize()
{
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the explicit initialize call or could it make sense to merge it with the instance call?

if (onoff) {
_queueGuard.block();
} else {
// TODO: empty queue?
Copy link
Member

Choose a reason for hiding this comment

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

Lets clear it.

if (_account->accessManager()->isBehindCaptivePortal()) {
_queueGuard.block();
} else {
// TODO: empty queue?
Copy link
Member

Choose a reason for hiding this comment

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

How can we be blocked during the construction of the class?

Like we do for when the client is behind a captive portal.
@erikjv erikjv force-pushed the work/pause-sync-behind-captive-portal branch from fdde86d to e6a9593 Compare April 18, 2024 14:14
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.

Detect captive portal and pause sync
2 participants