~josharenson/lightdm/withhold-invalid-x-args

« back to all changes in this revision

Viewing changes to src/seat.c

  • Committer: Robert Ancell
  • Date: 2013-07-26 05:14:58 UTC
  • mto: This revision was merged to the branch mainline in revision 1741.
  • Revision ID: robert.ancell@canonical.com-20130726051458-wisoh90t3eyfkinc
Test that trying to start a Mir session from a VT seat does the right thing

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
    /* The session to set active when it starts */
49
49
    Session *session_to_activate;
 
50
  
 
51
    /* TRUE once we have started */
 
52
    gboolean started;
50
53
 
51
54
    /* TRUE if stopping this seat (waiting for displays to stop) */
52
55
    gboolean stopping;
318
321
    g_signal_handlers_disconnect_matched (display_server, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
319
322
    seat->priv->display_servers = g_list_remove (seat->priv->display_servers, display_server);
320
323
 
321
 
    if (seat->priv->stopping)
 
324
    if (seat->priv->stopping || !seat->priv->started)
322
325
    {
323
326
        check_stopped (seat);
324
327
        g_object_unref (display_server);
495
498
 
496
499
    g_debug ("Session stopped");
497
500
 
 
501
    g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
 
502
    seat->priv->sessions = g_list_remove (seat->priv->sessions, session);
 
503
 
498
504
    display_server = session_get_display_server (session);
 
505
    if (!display_server)
 
506
    {
 
507
        g_object_unref (session);
 
508
        return;
 
509
    }
499
510
 
500
511
    /* Cleanup */
501
512
    if (!IS_GREETER (session))
506
517
            run_script (seat, display_server, script, session_get_user (session));
507
518
    }
508
519
 
509
 
    g_signal_handlers_disconnect_matched (session, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, seat);
510
 
    seat->priv->sessions = g_list_remove (seat->priv->sessions, session);
511
 
 
512
520
    /* We were waiting for this session, but it didn't start :( */
513
521
    // FIXME: Start a greeter on this?
514
522
    if (session == seat->priv->session_to_activate)
1082
1090
    g_debug ("Creating display server of type %s", session_type);
1083
1091
 
1084
1092
    display_server = SEAT_GET_CLASS (seat)->create_display_server (seat, session_type);
 
1093
    if (!display_server)
 
1094
        return NULL;
 
1095
 
1085
1096
    seat->priv->display_servers = g_list_append (seat->priv->display_servers, display_server);
1086
1097
    g_signal_connect (display_server, "ready", G_CALLBACK (display_server_ready_cb), seat);
1087
1098
    g_signal_connect (display_server, "stopped", G_CALLBACK (display_server_stopped_cb), seat);
1307
1318
    gboolean autologin_guest;
1308
1319
    gboolean autologin_in_background;
1309
1320
    Session *session = NULL, *background_session = NULL;
1310
 
    DisplayServer *display_server;
1311
1321
 
1312
1322
    g_debug ("Starting seat");
1313
1323
 
1314
1324
    /* If this display server doesn't have a session running on it, just start it */
1315
1325
    if (!get_start_local_sessions (seat))
1316
1326
    {
 
1327
        DisplayServer *display_server;
1317
1328
        display_server = create_display_server (seat, "x"); // FIXME: Not necessarily an X seat, but not sure what to put here
1318
1329
        return display_server_start (display_server);
1319
1330
    }
1333
1344
            session = create_guest_session (seat);
1334
1345
        else if (autologin_username != NULL)
1335
1346
            session = create_user_session (seat, autologin_username);
 
1347
 
 
1348
        if (session)
 
1349
            session_set_pam_service (session, AUTOLOGIN_SERVICE);
 
1350
 
 
1351
        /* Load in background if required */
 
1352
        if (autologin_in_background && session)
 
1353
        {
 
1354
            background_session = session;
 
1355
            session = NULL;
 
1356
        }
1336
1357
      
1337
1358
        if (session)
1338
1359
        {
 
1360
            DisplayServer *display_server;
 
1361
 
1339
1362
            if (seat->priv->session_to_activate)
1340
1363
                g_object_unref (seat->priv->session_to_activate);
1341
1364
            seat->priv->session_to_activate = g_object_ref (session);
1342
 
            session_set_pam_service (session, AUTOLOGIN_SERVICE);
1343
 
        }
1344
1365
 
1345
 
        /* Load in background if required */
1346
 
        if (autologin_in_background && session)
1347
 
        {
1348
 
            background_session = session;
1349
 
            session = NULL;
 
1366
            display_server = create_display_server (seat, session_get_session_type (session));
 
1367
            session_set_display_server (session, display_server);
 
1368
            if (!display_server || !display_server_start (display_server))
 
1369
            {
 
1370
                g_debug ("Can't create display server for automatic login");
 
1371
                session_stop (session);
 
1372
                if (display_server)
 
1373
                    display_server_stop (display_server);
 
1374
                session = NULL;
 
1375
            }
1350
1376
        }
1351
1377
    }
1352
1378
 
1354
1380
    if (!session)
1355
1381
    {
1356
1382
        Greeter *greeter_session;
 
1383
        DisplayServer *display_server;
1357
1384
 
1358
1385
        greeter_session = create_greeter_session (seat);
 
1386
        if (!greeter_session)
 
1387
        {
 
1388
            g_debug ("Failed to create greeter session");
 
1389
            return FALSE;
 
1390
        }
 
1391
 
1359
1392
        if (seat->priv->session_to_activate)
1360
1393
            g_object_unref (seat->priv->session_to_activate);
1361
1394
        seat->priv->session_to_activate = g_object_ref (greeter_session);
1373
1406
            if (autologin_guest)
1374
1407
                greeter_set_hint (greeter_session, "autologin-guest", "true");
1375
1408
        }
 
1409
 
 
1410
        display_server = create_display_server (seat, session_get_session_type (session));
 
1411
        session_set_display_server (session, display_server);
 
1412
        if (!display_server || !display_server_start (display_server))
 
1413
        {
 
1414
            g_debug ("Can't create display server for greeter");
 
1415
            session_stop (session);
 
1416
            if (display_server)
 
1417
                display_server_stop (display_server);
 
1418
            session = NULL;
 
1419
        }
1376
1420
    }
1377
1421
 
1378
1422
    /* Fail if can't start a session */
1382
1426
        return FALSE;
1383
1427
    }
1384
1428
 
1385
 
    display_server = create_display_server (seat, session_get_session_type (session));
1386
 
    if (!display_server)
1387
 
        return FALSE;
1388
 
 
1389
 
    /* Start display server to show session on */
1390
 
    session_set_display_server (session, display_server);
1391
 
    if (!display_server_start (display_server))
1392
 
        return FALSE;
1393
 
 
1394
1429
    /* Start background session */
1395
1430
    if (background_session)
1396
1431
    {
1402
1437
            g_warning ("Failed to start display server for background session");
1403
1438
    }
1404
1439
 
 
1440
    seat->priv->started = TRUE;
1405
1441
    return TRUE;
1406
1442
}
1407
1443