rendered paste bodyC++ 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;
}
surface.SetColor(config.get_int("red"),config.get_int("green"),config.get_int("blue"), config.get_int("alpha"));
string text;
string::size_type text_pos;
stringstream converter;
int value;
for(double i = 0; ;i++)
{
//see keyboard and exit if F2 is pressed
botton = keyboard.GetKeyState(DIKI_F2);
if( botton == DIKS_DOWN) //verbose mode
return 1;
botton = keyboard.GetKeyState(DIKI_ESCAPE);
if( botton == DIKS_DOWN) // exit if escape is pressed
return 1;
//from here start an hight development code about a new way to handle text
if((text_pos = text.rfind("Booting process at")) != string::npos)
{
converter << text.substr(text_pos + 18, 2);
converter >> value;
if(value == 10)
upgrade_bar(25, surface, progressbar);
if(value == 20)
upgrade_bar(45, surface, progressbar);
if(value == 30)
upgrade_bar(55, surface, progressbar);
if(value == 40)
upgrade_bar(70, surface, progressbar);
if(value == 50)
upgrade_bar(85, surface, progressbar);
if(value == 60)
upgrade_bar(90, surface, progressbar);
if(value == 70)
upgrade_bar(100, surface, progressbar);
}
else
text = load_text();
//end of hight development section
if(text.find("[fail]") != string::npos ||
text.find("error") != string::npos ||
text.find("command not found") != string::npos)
{
if(config.get("autoverboseonerror") == "yes")
{
provider = dfb.CreateImageProvider((config.get("errorimg")).c_str());
provider.RenderTo( surface, NULL );
sleep(1);
system("chvt 1");
break;
}
}
/*if( i == 1000 )
break;*/
} //for statement closed
sleep(5); //wait until xdm/gdm is ready
return 0;
}
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));
/*
if(text.find("[fail]") != string::npos || text.find("error") != string::npos || text.find("command not found") != string::npos)
{
if(spl_get("autoverboseonerror") == "yes")
{
provider = dfb.CreateImageProvider((spl_get("errorimg")).c_str());
provider.RenderTo( surface, NULL );
sleep(1);
system("chvt 1");
break;
}
}
if( i == 1000 )
break;
*/
} //for statement closed