consoled-manager.c revision ce7b9f50c3fadbad22feeb28e4429ad9bee02bcc
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <libudev.h>
#include <stdlib.h>
#include <string.h>
#include "consoled.h"
#include "grdev.h"
#include "idev.h"
#include "log.h"
#include "sd-bus.h"
#include "sd-daemon.h"
#include "sd-event.h"
#include "sd-login.h"
#include "sysview.h"
#include "unifont.h"
#include "util.h"
int r;
if (!m)
return -ENOMEM;
r = sd_event_default(&m->event);
if (r < 0)
return r;
r = sd_event_set_watchdog(m->event, true);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
r = sd_bus_open_system(&m->sysbus);
if (r < 0)
return r;
if (r < 0)
return r;
r = unifont_new(&m->uf);
if (r < 0)
return r;
r = sysview_context_new(&m->sysview,
m->event,
m->sysbus,
NULL);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
*out = m;
m = NULL;
return 0;
}
if (!m)
return NULL;
assert(!m->workspace_list);
free(m);
return NULL;
}
int r;
if (r < 0)
return 0;
}
Session *s;
int r;
if (r < 0) {
log_error("Cannot request session control on '%s': %s",
return r;
}
r = session_new(&s, m, session);
if (r < 0) {
log_error("Cannot create session on '%s': %s",
return r;
}
return 0;
}
Session *s;
if (!s)
return 0;
session_free(s);
return 0;
}
Session *s;
if (!s)
return 0;
session_add_device(s, device);
return 0;
}
Session *s;
if (!s)
return 0;
return 0;
}
Session *s;
if (!s)
return 0;
return 0;
}
Session *s;
if (!s)
return 0;
if (error < 0) {
log_error("Cannot take session control on '%s': %s",
session_free(s);
return -error;
}
return 0;
}
int r;
assert(m);
r = manager_sysview_session_filter(m, event);
break;
r = manager_sysview_session_add(m, event);
break;
r = manager_sysview_session_remove(m, event);
break;
r = manager_sysview_session_attach(m, event);
break;
r = manager_sysview_session_detach(m, event);
break;
r = manager_sysview_session_refresh(m, event);
break;
r = manager_sysview_session_control(m, event);
break;
default:
r = 0;
break;
}
return r;
}
int manager_run(Manager *m) {
int r;
assert(m);
if (r < 0)
return r;
r = sd_event_loop(m->event);
return r;
}