mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Imported login manager code. Real stuff is not implemented yet...
This commit is contained in:
parent
54fc91849c
commit
ed9c4a0228
1
Jamfile
1
Jamfile
@ -23,6 +23,7 @@ SubInclude TOP edewm ;
|
||||
SubInclude TOP efiler ;
|
||||
SubInclude TOP eiconman ;
|
||||
SubInclude TOP eimage ;
|
||||
SubInclude TOP elma ;
|
||||
SubInclude TOP etimedate ;
|
||||
SubInclude TOP etip ;
|
||||
SubInclude TOP evoke ;
|
||||
|
49
elma/Background.cpp
Normal file
49
elma/Background.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include "Background.h"
|
||||
#include <FL/Fl_Shared_Image.h>
|
||||
#include <edelib/Debug.h>
|
||||
|
||||
bool Background::load_images(const char* bpath, const char* ppath) {
|
||||
EASSERT(bpath != NULL);
|
||||
EASSERT(ppath != NULL);
|
||||
|
||||
fl_register_images();
|
||||
|
||||
// get background image first
|
||||
img = Fl_Shared_Image::get(bpath);
|
||||
if(!img)
|
||||
return false;
|
||||
|
||||
// scale if needed
|
||||
if(img->w() != w() && img->h() != h()) {
|
||||
Fl_Image* scaled = img->copy(w(), h());
|
||||
// Fl_Shared_Image contains correct pointers, so we can replace this
|
||||
img = scaled;
|
||||
}
|
||||
|
||||
// panel image
|
||||
panel_img = Fl_Shared_Image::get(ppath);
|
||||
if(!panel_img)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Background::draw(void) {
|
||||
if(img)
|
||||
img->draw(x(), y());
|
||||
|
||||
if(panel_img)
|
||||
panel_img->draw(x() + panel_img_x, y() + panel_img_y);
|
||||
}
|
46
elma/Background.h
Normal file
46
elma/Background.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef __BACKGROUND_H__
|
||||
#define __BACKGROUND_H__
|
||||
|
||||
#include <FL/Fl_Box.h>
|
||||
|
||||
class Fl_Image;
|
||||
|
||||
/*
|
||||
* Background composer; it will compose background image
|
||||
* with panel image and blend panel image on background if applicable.
|
||||
*
|
||||
* This class is intentionaly created (instead everything plop inside
|
||||
* one class) so in the future I can easily add scaled image smoothing
|
||||
* and (optinaly) better blending.
|
||||
*/
|
||||
class Background : public Fl_Box {
|
||||
private:
|
||||
Fl_Image* img;
|
||||
Fl_Image* panel_img;
|
||||
|
||||
int panel_img_x;
|
||||
int panel_img_y;
|
||||
public:
|
||||
Background(int X, int Y, int W, int H) : Fl_Box(X, Y, W, H, 0),
|
||||
img(0), panel_img(0), panel_img_x(0), panel_img_y(0) { }
|
||||
|
||||
~Background() { }
|
||||
|
||||
bool load_images(const char* bpath, const char* ppath);
|
||||
void panel_pos(int X, int Y) { panel_img_x = X; panel_img_y = Y; }
|
||||
virtual void draw(void);
|
||||
};
|
||||
|
||||
#endif
|
134
elma/ElmaWindow.cpp
Normal file
134
elma/ElmaWindow.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include <FL/Fl.h>
|
||||
#include <edelib/Debug.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "ElmaWindow.h"
|
||||
#include "Background.h"
|
||||
#include "TextArea.h"
|
||||
|
||||
static void timeout_cb(void* e) {
|
||||
ElmaWindow* win = (ElmaWindow*)e;
|
||||
win->allow_input();
|
||||
}
|
||||
|
||||
ElmaWindow::ElmaWindow(int W, int H) : Fl_Double_Window(0, 0, W, H),
|
||||
bkg(0), user_in(0), pass_in(0), error_display(0), info_display(0) {
|
||||
|
||||
deny_mode = false;
|
||||
}
|
||||
|
||||
ElmaWindow::~ElmaWindow() {
|
||||
}
|
||||
|
||||
bool ElmaWindow::load_everything(void) {
|
||||
begin();
|
||||
bkg = new Background(0, 0, w(), h());
|
||||
if(!bkg->load_images("themes/default/background.jpg", "themes/default/panel.png"))
|
||||
return false;
|
||||
|
||||
//bkg->panel_pos(35, 189);
|
||||
bkg->panel_pos(235, 489);
|
||||
|
||||
//user_in = new TextArea(428, 351, 184, 28, "Username: ");
|
||||
user_in = new TextArea(240, 489, 184, 30, "Username: ");
|
||||
user_in->labelcolor(FL_WHITE);
|
||||
user_in->textfont(FL_HELVETICA_BOLD);
|
||||
user_in->textsize(14);
|
||||
|
||||
//pass_in = new TextArea(428, 351, 184, 28, "Password: ");
|
||||
pass_in = new TextArea(240, 489, 184, 30, "Password: ");
|
||||
pass_in->labelcolor(FL_WHITE);
|
||||
pass_in->textfont(FL_HELVETICA_BOLD);
|
||||
pass_in->textsize(14);
|
||||
pass_in->type(FL_SECRET_INPUT);
|
||||
pass_in->hide();
|
||||
|
||||
//error_display = new Fl_Box(418, 390, 184, 28);
|
||||
error_display = new Fl_Box(240, 520, 184, 28);
|
||||
error_display->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
|
||||
error_display->labelcolor(FL_WHITE);
|
||||
error_display->labelsize(14);
|
||||
error_display->hide();
|
||||
|
||||
info_display = new Fl_Box(10, 10, 184, 28);
|
||||
info_display->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_CLIP);
|
||||
info_display->labelcolor(FL_GRAY);
|
||||
info_display->label("EDE version 2.0");
|
||||
end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ElmaWindow::validate_user(void) {
|
||||
EDEBUG("username: %s\n", user_in->value() ? user_in->value() : "none");
|
||||
EDEBUG("password: %s\n", pass_in->value() ? pass_in->value() : "none");
|
||||
|
||||
error_display->show();
|
||||
error_display->label("Bad username or password");
|
||||
|
||||
deny_input();
|
||||
|
||||
Fl::add_timeout(3.0, timeout_cb, this);
|
||||
}
|
||||
|
||||
void ElmaWindow::allow_input(void) {
|
||||
deny_mode = false;
|
||||
|
||||
if(error_display->visible()) {
|
||||
error_display->hide();
|
||||
error_display->label(0);
|
||||
}
|
||||
|
||||
if(user_in->visible())
|
||||
user_in->activate();
|
||||
if(pass_in->visible())
|
||||
pass_in->activate();
|
||||
}
|
||||
|
||||
void ElmaWindow::deny_input(void) {
|
||||
deny_mode = true;
|
||||
|
||||
if(user_in->visible())
|
||||
user_in->deactivate();
|
||||
if(pass_in->visible())
|
||||
pass_in->deactivate();
|
||||
}
|
||||
|
||||
int ElmaWindow::handle(int event) {
|
||||
if(event == FL_KEYBOARD) {
|
||||
if(deny_mode)
|
||||
return 1;
|
||||
|
||||
if(Fl::event_key() == FL_Enter) {
|
||||
if(user_in->visible()) {
|
||||
user_in->hide();
|
||||
pass_in->show();
|
||||
// don't remember password
|
||||
pass_in->value(0);
|
||||
} else {
|
||||
user_in->show();
|
||||
pass_in->hide();
|
||||
|
||||
validate_user();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Fl_Double_Window::handle(event);
|
||||
}
|
43
elma/ElmaWindow.h
Normal file
43
elma/ElmaWindow.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef __ELMAWINDOW_H__
|
||||
#define __ELMAWINDOW_H__
|
||||
|
||||
#include <FL/Fl_Double_Window.h>
|
||||
|
||||
class Background;
|
||||
class TextArea;
|
||||
class Fl_Box;
|
||||
|
||||
class ElmaWindow : public Fl_Double_Window {
|
||||
private:
|
||||
Background* bkg;
|
||||
TextArea* user_in;
|
||||
TextArea* pass_in;
|
||||
Fl_Box* error_display;
|
||||
Fl_Box* info_display;
|
||||
bool deny_mode;
|
||||
|
||||
void validate_user(void);
|
||||
|
||||
public:
|
||||
ElmaWindow(int W, int H);
|
||||
~ElmaWindow();
|
||||
|
||||
void allow_input(void);
|
||||
void deny_input(void);
|
||||
|
||||
bool load_everything(void);
|
||||
virtual int handle(int event);
|
||||
};
|
||||
#endif
|
16
elma/Jamfile
Normal file
16
elma/Jamfile
Normal file
@ -0,0 +1,16 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# Part of Equinox Desktop Environment (EDE).
|
||||
# Copyright (c) 2008 EDE Authors.
|
||||
#
|
||||
# This program is licensed under terms of the
|
||||
# GNU General Public License version 2 or newer.
|
||||
# See COPYING for details.
|
||||
|
||||
SubDir TOP elma ;
|
||||
|
||||
SOURCE = Background.cpp NumLock.cpp ElmaWindow.cpp elma.cpp ;
|
||||
|
||||
EdeProgram elma : $(SOURCE) ;
|
||||
TranslationStrings locale : $(SOURCE) ;
|
68
elma/NumLock.cpp
Normal file
68
elma/NumLock.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
*
|
||||
* Based on SLiM (Simple Login Manager) numlock code by:
|
||||
* Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
|
||||
* Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
|
||||
*
|
||||
* which in turn they ripped from KDE and nicely provide authors
|
||||
* so I'm doing that too:
|
||||
*
|
||||
* Copyright (C) 2000-2001 Lubos Lunak <l.lunak@kde.org>
|
||||
* Copyright (C) 2001 Oswald Buddenhagen <ossi@kde.org>
|
||||
*
|
||||
* And for else, blame me (Sanel).
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include "NumLock.h"
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <string.h>
|
||||
|
||||
static unsigned int numlock_mask(Display* dpy) {
|
||||
XkbDescPtr xkb = XkbGetKeyboard(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
|
||||
if(xkb == NULL)
|
||||
return 0;
|
||||
|
||||
char* modstr;
|
||||
unsigned int mask = 0;
|
||||
|
||||
for(int i = 0; i < XkbNumVirtualMods; i++) {
|
||||
modstr = XGetAtomName(xkb->dpy, xkb->names->vmods[i]);
|
||||
if(modstr != NULL && strcmp(modstr, "NumLock") == 0) {
|
||||
XkbVirtualModsToReal(xkb, 1 << i, &mask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XkbFreeKeyboard(xkb, 0, True);
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool numlock_xkb_init(Display* dpy) {
|
||||
int opcode, event, error;
|
||||
int maj, min;
|
||||
|
||||
return XkbLibraryVersion(&maj, &min) && XkbQueryExtension(dpy, &opcode, &event, &error, &maj, &min);
|
||||
}
|
||||
|
||||
void numlock_on(Display* dpy) {
|
||||
unsigned int mask = numlock_mask(dpy);
|
||||
if(!mask)
|
||||
return;
|
||||
XkbLockModifiers(dpy, XkbUseCoreKbd, mask, mask);
|
||||
}
|
||||
|
||||
void numlock_off(Display* dpy) {
|
||||
unsigned int mask = numlock_mask(dpy);
|
||||
if(!mask)
|
||||
return;
|
||||
XkbLockModifiers(dpy, XkbUseCoreKbd, mask, 0);
|
||||
}
|
22
elma/NumLock.h
Normal file
22
elma/NumLock.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef __NUMLOCK_H__
|
||||
#define __NUMLOCK_H__
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
bool numlock_xkb_init(Display* dpy);
|
||||
void numlock_on(Display* dpy);
|
||||
void numlock_off(Display* dpy);
|
||||
|
||||
#endif
|
51
elma/TextArea.h
Normal file
51
elma/TextArea.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#ifndef __TEXTAREA_H__
|
||||
#define __TEXTAREA_H__
|
||||
|
||||
#include <FL/Fl_Input.h>
|
||||
|
||||
#include <edelib/Debug.h>
|
||||
|
||||
/*
|
||||
* Creates Fl_Input-like widget, but without any box. It is not the same as
|
||||
* Fl_Input::box(FL_NO_BOX) because box is not drawn and Fl_Input will not
|
||||
* redraw itself on changes. As help, we request from parent to redraw region
|
||||
* where this widget resides.
|
||||
*/
|
||||
class TextArea : public Fl_Input {
|
||||
public:
|
||||
TextArea(int X, int Y, int W, int H, const char* l = 0) : Fl_Input(X, Y, W, H, l) {
|
||||
box(FL_NO_BOX);
|
||||
}
|
||||
|
||||
~TextArea() { }
|
||||
|
||||
virtual int handle(int event) {
|
||||
// FLTK can send FL_NO_EVENT, so be carefull
|
||||
if(!event)
|
||||
return 0;
|
||||
|
||||
// not needed, parent will redraw us
|
||||
if(event == FL_SHOW || event == FL_HIDE)
|
||||
return 1;
|
||||
|
||||
int ret = Fl_Input::handle(event);
|
||||
if(ret);
|
||||
parent()->damage(FL_DAMAGE_ALL, x(), y(), w(), h());
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
28
elma/elma.conf
Normal file
28
elma/elma.conf
Normal file
@ -0,0 +1,28 @@
|
||||
[elma]
|
||||
|
||||
# path for X server
|
||||
default_xserver = /usr/X11R6/bin/X
|
||||
|
||||
# commands for login and halt
|
||||
halt = /sbin/shutdown -h now
|
||||
reboot = /sbin/shutdown -r now
|
||||
|
||||
# full path to xauth binary
|
||||
xauth = /usr/X11R6/bin/xauth
|
||||
|
||||
# xauth file for server
|
||||
xauth_file = /var/run/elma.auth
|
||||
|
||||
# login command, executed after succesful login
|
||||
# NOTE: if you don't have bash you have to adjust
|
||||
# the command to default or prefered shell
|
||||
# i.e. for freebsd use:
|
||||
# login_cmd = exec /bin/sh - ~/.xinitrc
|
||||
|
||||
login_cmd = exec /bin/bash -login ~/.xinitrc
|
||||
|
||||
# default theme
|
||||
theme = default
|
||||
|
||||
# enable/disable NumLock (1/0, true/false)
|
||||
numlock = true
|
91
elma/elma.cpp
Normal file
91
elma/elma.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ELMA, Ede Login MAnager
|
||||
* Part of Equinox Desktop Environment (EDE).
|
||||
* Copyright (c) 2008 EDE Authors.
|
||||
*
|
||||
* This program is licensed under terms of the
|
||||
* GNU General Public License version 2 or newer.
|
||||
* See COPYING for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <FL/x.h>
|
||||
#include <FL/Fl.h>
|
||||
#include <edelib/String.h>
|
||||
#include "Background.h"
|
||||
#include "TextArea.h"
|
||||
#include "ElmaWindow.h"
|
||||
#include "NumLock.h"
|
||||
|
||||
#define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0))
|
||||
|
||||
void help(void) {
|
||||
puts("Usage: elma [OPTIONS]");
|
||||
puts("EDE login manager responsible to log you into X seesion");
|
||||
puts("and initiate EDE startup\n");
|
||||
puts("Options:");
|
||||
puts(" -h, --help this help");
|
||||
puts(" -c, --config [FILE] use FILE as config file");
|
||||
puts(" -t, --test test mode for theme preview (assume X server is running)\n");
|
||||
}
|
||||
|
||||
const char* next_param(int curr, char** argv, int argc) {
|
||||
int j = curr + 1;
|
||||
if(j >= argc)
|
||||
return NULL;
|
||||
if(argv[j][0] == '-')
|
||||
return NULL;
|
||||
return argv[j];
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
const char* config_file = NULL;
|
||||
bool test_mode = false;
|
||||
|
||||
if(argc > 1) {
|
||||
const char* a;
|
||||
for(int i = 1; i < argc; i++) {
|
||||
a = argv[i];
|
||||
if(CHECK_ARGV(a, "-h", "--help")) {
|
||||
help();
|
||||
return 0;
|
||||
} else if(CHECK_ARGV(a, "-c", "--config")) {
|
||||
config_file = next_param(i, argv, argc);
|
||||
if(!config_file) {
|
||||
puts("Missing configuration filename");
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
} else if(CHECK_ARGV(a, "-t", "--test")) {
|
||||
test_mode = true;
|
||||
} else {
|
||||
printf("Unknown parameter '%s'. Run 'elma -h' for options\n", a);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fl_open_display();
|
||||
|
||||
int dx, dy, dw, dh;
|
||||
Fl::screen_xywh(dx, dy, dw, dh);
|
||||
|
||||
numlock_xkb_init(fl_display);
|
||||
|
||||
ElmaWindow* win = new ElmaWindow(dw, dh);
|
||||
if(!win->load_everything()) {
|
||||
delete win;
|
||||
return 1;
|
||||
}
|
||||
|
||||
win->clear_border();
|
||||
win->show();
|
||||
win->cursor(FL_CURSOR_NONE);
|
||||
|
||||
numlock_off(fl_display);
|
||||
|
||||
return Fl::run();
|
||||
}
|
2
elma/themes/default/AUTHOR
Normal file
2
elma/themes/default/AUTHOR
Normal file
@ -0,0 +1,2 @@
|
||||
The wallpaper is copyright (c) by Martina Woll
|
||||
http://www.martinawoll.de
|
BIN
elma/themes/default/background.jpg
Normal file
BIN
elma/themes/default/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 389 KiB |
BIN
elma/themes/default/panel.png
Normal file
BIN
elma/themes/default/panel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 278 B |
3
elma/themes/fragile/AUTHOR
Normal file
3
elma/themes/fragile/AUTHOR
Normal file
@ -0,0 +1,3 @@
|
||||
http://whitestar98.deviantart.com
|
||||
|
||||
http://whitestar98.deviantart.com/art/fragile-33934982
|
BIN
elma/themes/fragile/background.jpg
Normal file
BIN
elma/themes/fragile/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
1
elma/themes/passenger/AUTHOR
Normal file
1
elma/themes/passenger/AUTHOR
Normal file
@ -0,0 +1 @@
|
||||
http://whitestar98.deviantart.com
|
BIN
elma/themes/passenger/background.jpg
Normal file
BIN
elma/themes/passenger/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
3
elma/themes/sky/AUTHOR
Normal file
3
elma/themes/sky/AUTHOR
Normal file
@ -0,0 +1,3 @@
|
||||
http://whitestar98.deviantart.com
|
||||
|
||||
http://whitestar98.deviantart.com/art/painted-sky-35289794
|
BIN
elma/themes/sky/background.jpg
Normal file
BIN
elma/themes/sky/background.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
Loading…
Reference in New Issue
Block a user