Skip to content

Commit

Permalink
re-use connection and use main code for dbus
Browse files Browse the repository at this point in the history
It is a must to re-use the GDM connection to ensure that
launching the new session does work.

Also, the branch from Robert Ancell is not needed anymore; with
the current code in the main branch is enough.
  • Loading branch information
sergio-costas committed Nov 7, 2023
1 parent 17a86b7 commit b102dba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
3 changes: 1 addition & 2 deletions packages/ubuntu_bootstrap/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ flutter:
dependency_overrides:
dbus:
git:
url: https://github.com/robert-ancell/dbus.dart.git
ref: client-no-hello
url: https://github.com/canonical/dbus.dart.git
3 changes: 1 addition & 2 deletions packages/ubuntu_init/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,4 @@ flutter:
dependency_overrides:
dbus:
git:
url: https://github.com/robert-ancell/dbus.dart.git
ref: client-no-hello
url: https://github.com/canonical/dbus.dart.git
28 changes: 19 additions & 9 deletions packages/ubuntu_provision/lib/src/services/gdm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@ final log = Logger('dart_gdm_service');

class GdmService {
bool _testing = false;
DBusClient? gdmClient;

void setTesting() {
_testing = true;
}

Future<DBusClient> getClientConnection() async {
var gdmObject = DBusRemoteObject(DBusClient.system(),
name: 'org.gnome.DisplayManager',
path: DBusObjectPath('/org/gnome/DisplayManager/Manager'));
var response = await gdmObject.callMethod(
'org.gnome.DisplayManager.Manager', 'OpenSession', [],
replySignature: DBusSignature('s'));
var address = response.values[0].asString();
return DBusClient(DBusAddress(address), messageBus: false);
if (gdmClient == null) {
log.info('Asking for GDM connection');
var gdmObject = DBusRemoteObject(DBusClient.system(),
name: 'org.gnome.DisplayManager',
path: DBusObjectPath('/org/gnome/DisplayManager/Manager'));
var response = await gdmObject.callMethod(
'org.gnome.DisplayManager.Manager', 'OpenSession', [],
replySignature: DBusSignature('s'));
var address = response.values[0].asString();
gdmClient = DBusClient(DBusAddress(address), messageBus: false);
} else {
log.info('Re-using GDM connection');
}
return gdmClient!;
}

Future<DBusRemoteObject> getGreeter() async {
log.info('Getting Greeter GDM connection');
var connection = await getClientConnection();
var greeter = DBusRemoteObject(connection,
name: 'org.gnome.DisplayManager.Greeter',
Expand All @@ -35,6 +43,7 @@ class GdmService {
}

Future<DBusRemoteObject> getUserVerifier() async {
log.info('Getting User Verifier GDM connection');
var connection = await getClientConnection();
var userVerifier = DBusRemoteObject(connection,
name: 'org.gnome.DisplayManager.UserVerifier',
Expand Down Expand Up @@ -83,7 +92,7 @@ class GdmService {
infoQuerySignal
.listen((signal) => log.info('InfoQuery signal received $signal'));
problemSignal
.listen((signal) => log.info('Problem signal received $signal'));
.listen((signal) => log.warning('Problem signal received $signal'));
secretInfoQuerySignal.listen((signal) {
log.info('SecretInfoQuery signal received $signal');
unawaited(userVerifier.callMethod(
Expand All @@ -98,6 +107,7 @@ class GdmService {
completer.complete();
});

log.info('Starting user verification');
unawaited(userVerifier.callMethod(
'org.gnome.DisplayManager.UserVerifier',
'BeginVerificationForUser',
Expand Down
3 changes: 1 addition & 2 deletions packages/ubuntu_provision/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,4 @@ flutter:
dependency_overrides:
dbus:
git:
url: https://github.com/robert-ancell/dbus.dart.git
ref: client-no-hello
url: https://github.com/canonical/dbus.dart.git
3 changes: 1 addition & 2 deletions packages/ubuntu_provision_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ dependencies:
dependency_overrides:
dbus:
git:
url: https://github.com/robert-ancell/dbus.dart.git
ref: client-no-hello
url: https://github.com/canonical/dbus.dart.git

0 comments on commit b102dba

Please sign in to comment.