C++ stuff:
int splashy_child_boot()
{
IDirectFB dfb;
IDirectFBImageProvider provider;
IDirectFBSurface surface;
DFBSurfaceDescription desc;
IDirectFBInputDevice keyboard;
//load configuration
xml_parser config("/etc/splashy/config.xml");
config.read("splashy");
//initializing Directfb
DirectFB::Init();
dfb = DirectFB::Create();
dfb.SetCooperativeLevel( DFSCL_FULLSCREEN); //used to disable inputs from mouse and reduce overhead (about 15% of CPU usage)
//begin hight development section to find out te width and height of framebuffer
//look at http://directfb.org/docs/DirectFB_Reference/IDirectFB_EnumVideoModes.html
//end development section
provider = dfb.CreateImageProvider((config.get("boot")).c_str());
provider.GetSurfaceDescription( &desc );
//flags to set the default surface as main surface
desc.flags = DSDESC_CAPS;
desc.caps = DSCAPS_PRIMARY;
surface = dfb.CreateSurface( desc );
provider.RenderTo( surface, NULL ); //it writes on the framebuffer the background image
//setting up keyboard
keyboard = dfb.GetInputDevice(DIDID_KEYBOARD);
DFBInputDeviceKeyState botton = DIKS_UP;
//starting bars stuff!
DFBRectangle progressbar;
int screenWidth, screenHeight;
surface.GetSize(&screenWidth, &screenHeight); //retrieve informations
progressbar.x = screenWidth*config.get_int("x")/100;
progressbar.y = screenHeight*config.get_int("y")/100;
progressbar.w = screenWidth*config.get_int("width")/100;
progressbar.h = screenHeight*config.get_int("height")/100;
surface.DrawRectangle(progressbar);
//set the filling color of the progressbar
if(config.get_int("red") > 255 || config.get_int("green") > 255 || config.get_int("blue") > 255 || config.get_int("alpha") > 255)
{
cout << "error: red, green, blue or alpha tags in the configuration file contains wrong value" << endl;
return 3;
}
C stuff
int splashy_child_boot()
{
splashy_video_t video;
video_start_splash(&video, "/etc/splashy/background.jpg");
/*starting bars stuff!*/
DFBRectangle progressbar;
video_draw_progressbar(&video, &progressbar);
GString *screen_text = NULL; /* Host the screen text read for processing */
gchar *screen_position, /* Host the last position or NULL if isn't found */
*last_screen_position, /* Host the last real position */
*percent_symbol; /* Host the address of % symbol */
/*setting up keyboard*/
DFBInputDeviceKeyState botton;
IDirectFBInputDevice *keyboard;
video.dfb->GetInputDevice(video.dfb, DIDID_KEYBOARD, &keyboard);
gint i; /* Used to iterate inside of for */
for(i = 0;;i++)
{
/*see keyboard and exit if F2 is pressed */
keyboard->GetKeyState(keyboard, DIKI_F2, &botton);
if( botton == DIKS_DOWN) /* verbose mode */
return 1;
keyboard->GetKeyState(keyboard, DIKI_ESCAPE, &botton);
if( botton == DIKS_DOWN) /* exit if escape is pressed */
return 1;
/* Read the screen */
screen_text = load_text(']');
/* Locate the last 'Booting process at ' string and
check what is the value there. */
last_screen_position = 0;
while ((screen_position = strstr(screen_text->str, "Booting process at ")) != NULL)
last_screen_position = screen_position;
/* If not found, wait and try again. */
if ( last_screen_position == 0 ) {
usleep(10);
continue;
}
percent_symbol = strchr(last_screen_position, '%');
video_update_progressbar(&video,
&progressbar,
strtol(last_screen_position,
&percent_symbol, 10));