void *einit_feedback_visual_fbsplash_worker_thread (void *irr) { einit_feedback_visual_fbsplash_worker_thread_running = 1; while (einit_feedback_visual_fbsplash_worker_thread_keep_running) { while (fbsplash_commandQ) { char *command = NULL; emutex_lock (&fbsplash_commandQ_mutex); if (fbsplash_commandQ) { if ((command = fbsplash_commandQ[0])) { void *it = command; command = estrdup (command); fbsplash_commandQ = (char **)setdel ((void **)fbsplash_commandQ, it); } } emutex_unlock (&fbsplash_commandQ_mutex); if (command) { // notice (1, command); FILE *fifo = efopen (fbsplash_fifo, "w"); if (fifo) { eprintf (fifo, "%s\n", command); fclose (fifo); } free (command); }/* else { notice (1, "repaint"); FILE *fifo = efopen (fbsplash_fifo, "w"); if (fifo) { eprintf (fifo, "repaint\n", command); fclose (fifo); } }*/ } emutex_lock (&fbsplash_commandQ_cond_mutex); pthread_cond_wait (&fbsplash_commandQ_cond, &fbsplash_commandQ_cond_mutex); emutex_unlock (&fbsplash_commandQ_cond_mutex); } return NULL; }
static pager pagercreate(void) { ConsoleData p; int w, h, i, x, y, w0, h0; pager c; menuitem m; p = newconsoledata((consolefn) ? consolefn : FixedFont, pagerrow, pagercol, 0, 0, guiColors, PAGER, 0, 0); if (!p) return NULL; /* if (ismdi()) { x = y = w = h = 0; } else { w = WIDTH ; h = HEIGHT; x = (devicewidth(NULL) - w) / 2; y = (deviceheight(NULL) - h) / 2 ; } */ w = WIDTH ; h = HEIGHT; /* centre a single pager, randomly place each of multiple pagers */ #ifdef USE_MDI if(ismdi()) { RECT *pR = RgetMDIsize(); w0 = pR->right; h0 = pR->bottom; } else { #endif w0 = devicewidth(NULL); h0 = deviceheight(NULL); #ifdef USE_MDI } #endif x = (w0 - w) / 2; x = x > 20 ? x:20; y = (h0 - h) / 2; y = y > 20 ? y:20; if(pagerMultiple) { #ifdef Win32 DWORD rand = GetTickCount(); #else int rand = 0; #endif int w0 = 0.4*x, h0 = 0.4*y; w0 = w0 > 20 ? w0 : 20; h0 = h0 > 20 ? h0 : 20; x += (rand % w0) - w0/2; y += ((rand/w0) % h0) - h0/2; } c = (pager) newwindow("PAGER", rect(x, y, w, h), Document | StandardWindow | Menubar | VScrollbar | HScrollbar | TrackMouse); if (!c) { freeConsoleData(p); return NULL; } setdata(c, p); if(h == 0) HEIGHT = getheight(c); if(w == 0) WIDTH = getwidth(c); COLS = WIDTH / FW - 1; ROWS = HEIGHT / FH - 1; BORDERX = (WIDTH - COLS*FW) / 2; BORDERY = (HEIGHT - ROWS*FH) / 2; gsetcursor(c, ArrowCursor); gchangescrollbar(c, VWINSB, 0, 0, ROWS, 0); gchangescrollbar(c, HWINSB, 0, COLS-1, COLS, 1); setbackground(c, guiColors[pagerbg]); #ifdef USE_MDI if (ismdi()) { int btsize = 24; rect r = rect(2, 2, btsize, btsize); control tb, bt; addto(c); MCHECK(tb = newtoolbar(btsize + 4)); gsetcursor(tb, ArrowCursor); addto(tb); MCHECK(bt = newtoolbutton(open_image, r, menueditoropen)); MCHECK(addtooltip(bt, G_("Open script"))); gsetcursor(bt, ArrowCursor); /* wants NULL as data, not the pager */ r.x += (btsize + 6) ; MCHECK(bt = newtoolbutton(copy1_image, r, pagerpaste)); MCHECK(addtooltip(bt, G_("Paste to console"))); gsetcursor(bt, ArrowCursor); setdata(bt, (void *) c); r.x += (btsize + 6) ; MCHECK(bt = newtoolbutton(copy1_image, r, pagerpastecmds)); MCHECK(addtooltip(bt, G_("Paste commands to console"))); gsetcursor(bt, ArrowCursor); setdata(bt, (void *) c); r.x += (btsize + 6) ; MCHECK(bt = newtoolbutton(print_image, r, pagerprint)); MCHECK(addtooltip(bt, G_("Print"))); gsetcursor(bt, ArrowCursor); setdata(bt, (void *) c); r.x += (btsize + 6) ; MCHECK(bt = newtoolbutton(console_image, r, pagerconsole)); MCHECK(addtooltip(bt, G_("Return focus to Console"))); gsetcursor(bt, ArrowCursor); setdata(bt, (void *) c); } #endif addto(c); MCHECK(m = gpopup(pagermenuact, PagerPopup)); setdata(m, c); setdata(p->mpopcopy = PagerPopup[0].m, c); setdata(p->mpoppaste = PagerPopup[1].m, c); setdata(p->mpoppastecmds = PagerPopup[2].m, c); setdata(PagerPopup[3].m, c); setdata(PagerPopup[5].m, c); setdata(PagerPopup[7].m, c); MCHECK(m = newmenubar(pagermenuact)); setdata(m, c); MCHECK(newmenu(G_("File"))); MCHECK(m = newmenuitem(G_("New script"), 'N', menueditornew)); MCHECK(m = newmenuitem(G_("Open script..."), 'O', menueditoropen)); MCHECK(m = newmenuitem(G_("Print..."), 'P', pagerprint)); setdata(m, c); MCHECK(m = newmenuitem(G_("Save to File..."), 'S', pagersavefile)); setdata(m, c); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Close"), 0, pagerclose)); setdata(m, c); MCHECK(newmenu(G_("Edit"))); MCHECK(p->mcopy = newmenuitem(G_("Copy"), 'C', pagercopy)); setdata(p->mcopy, c); MCHECK(p->mpaste = newmenuitem(G_("Paste to console"), 'V', pagerpaste)); setdata(p->mpaste, c); MCHECK(p->mpastecmds = newmenuitem(G_("Paste commands to console"), 0, pagerpastecmds)); setdata(p->mpastecmds, c); MCHECK(m = newmenuitem(G_("Select all"), 'A', pagerselectall)); setdata(m, c); if (!pagerMultiple) { MCHECK(newmenu(G_("View"))); for (i = 0; i < PAGERMAXKEPT; i++) { snprintf(pagerTitles[i], PAGERMAXTITLE+8, "&%c. ", 'A' + i); MCHECK(pagerMenus[i] = newmenuitem(&pagerTitles[i][1], 0, pagerchangeview)); setvalue(pagerMenus[i], i); } } #ifdef USE_MDI if (ismdi()) newmdimenu(); if (ismdi() && !(RguiMDI & RW_TOOLBAR)) toolbar_hide(); #endif MCHECK(BM = newbitmap(WIDTH, HEIGHT, 2)); setdata(c, p); sethit(c, console_sbf); setresize(c, consoleresize); setredraw(c, drawconsole); setdel(c, delpager); setclose(c, pagerbclose); setkeyaction(c, console_ctrlkeyin); setkeydown(c, console_normalkeyin); setmousedrag(c, console_mousedrag); setmouserepeat(c, console_mouserep); setmousedown(c, console_mousedown); return(c); }
static editor neweditor(void) { int x, y, w, h, w0, h0; editor c; menuitem m; textbox t; long flags; font editorfn = (consolefn ? consolefn : FixedFont); EditorData p = neweditordata(0, NULL); DWORD rand; w = (pagercol + 1)*fontwidth(editorfn); h = (pagerrow + 1)*fontheight(editorfn) + 1; #ifdef USE_MDI if(ismdi()) { RECT *pR = RgetMDIsize(); w0 = pR->right; h0 = pR->bottom; } else { #endif w0 = devicewidth(NULL); h0 = deviceheight(NULL); #ifdef USE_MDI } #endif x = (w0 - w) / 2; x = x > 20 ? x : 20; y = (h0 - h) / 2; y = y > 20 ? y : 20; rand = GetTickCount(); w0 = 0.4*x; h0 = 0.4*y; w0 = w0 > 20 ? w0 : 20; h0 = h0 > 20 ? h0 : 20; x += (rand % w0) - w0/2; y += ((rand/w0) % h0) - h0/2; flags = StandardWindow | Menubar; #ifdef USE_MDI if (ismdi()) flags |= Document; #endif c = (editor) newwindow("", rect(x, y, w, h), flags); t = newrichtextarea(NULL, rect(0, 0, w, h)); setdata(c, t); setdata(t, p); gsetcursor(c, ArrowCursor); setforeground(c, guiColors[editorfg]); setbackground(c, guiColors[editorbg]); setbackground(t, guiColors[editorbg]); #ifdef USE_MDI if (ismdi() && (RguiMDI & RW_TOOLBAR)) { int btsize = 24; rect r = rect(2, 2, btsize, btsize); control tb, bt; addto(c); MCHECK(tb = newtoolbar(btsize + 4)); addto(tb); MCHECK(bt = newtoolbutton(open_image, r, menueditoropen)); MCHECK(addtooltip(bt, G_("Open script"))); setdata(bt, c); r.x += (btsize + 1) ; MCHECK(bt = newtoolbutton(save_image, r, menueditorsave)); MCHECK(addtooltip(bt, G_("Save script"))); setdata(bt, c); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(copy1_image, r, menueditorrun)); MCHECK(addtooltip(bt, G_("Run line or selection"))); setdata(bt, t); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(console_image, r, editorconsole)); MCHECK(addtooltip(bt, G_("Return focus to Console"))); r.x += (btsize + 6); MCHECK(bt = newtoolbutton(print_image, r, editorprint)); MCHECK(addtooltip(bt, G_("Print script"))); setdata(bt, t); MCHECK(addtooltip(bt, G_("Print"))); } #endif addto(c); /* Right-click context menu */ MCHECK(m = gpopup(editormenuact, EditorPopup)); setdata(m, t); setdata(EditorPopup[0].m, t); setdata(EditorPopup[2].m, t); setdata(p->mpopcut = EditorPopup[4].m, t); setdata(p->mpopcopy = EditorPopup[5].m, t); setdata(EditorPopup[6].m, t); setdata(p->mpopdelete = EditorPopup[7].m, t); setdata(EditorPopup[9].m, t); addto(c); MCHECK(m = newmenubar(editormenuact)); setdata(m, t); MCHECK(newmenu(G_("File"))); MCHECK(m = newmenuitem(G_("New script"), 'N', menueditornew)); setdata(m, c); MCHECK(m = newmenuitem(G_("Open script..."), 'O', menueditoropen)); setdata(m, c); MCHECK(m = newmenuitem(G_("Save"), 'S', menueditorsave)); setdata(m, c); MCHECK(m = newmenuitem(G_("Save as..."), 0, menueditorsaveas)); setdata(m, c); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Print..."), 0, editorprint)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Close script"), 0, menueditorclose)); setdata(m, c); MCHECK(newmenu(G_("Edit"))); MCHECK(m = newmenuitem(G_("Undo"), 'Z', editorundo)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(p->mcut = newmenuitem(G_("Cut"), 'X', editorcut)); setdata(p->mcut, t); MCHECK(p->mcopy = newmenuitem(G_("Copy"), 'C', editorcopy)); setdata(p->mcopy, t); MCHECK(m = newmenuitem(G_("Paste"), 'V', editorpaste)); setdata(m, t); MCHECK(p->mdelete = newmenuitem(G_("Delete"), 0, editordelete)); setdata(p->mdelete, t); MCHECK(m = newmenuitem(G_("Select all"), 'A', editorselectall)); setdata(m, t); MCHECK(newmenuitem(G_("Clear console"), 'L', menuclear)); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(m = newmenuitem(G_("Run line or selection"), 'R', menueditorrun)); setdata(m, t); MCHECK(m = newmenuitem(G_("Run all"), 0, editorrunall)); setdata(m, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(p->mfind = newmenuitem(G_("Find..."), 'F', editorfind)); setdata(p->mfind, t); MCHECK(p->mreplace = newmenuitem(G_("Replace..."), 'H', editorreplace)); setdata(p->mreplace, t); MCHECK(m = newmenuitem("-", 0, NULL)); MCHECK(newmenuitem(G_("GUI preferences..."), 0, menuconfig)); /* Packages menu should go here */ p->pmenu = (PkgMenuItems) malloc(sizeof(struct structPkgMenuItems)); RguiPackageMenu(p->pmenu); #ifdef USE_MDI newmdimenu(); /* Create and fill the 'Window' menu */ #endif MCHECK(m = newmenu(G_("Help"))); MCHECK(newmenuitem(G_("Editor"), 0, menueditorhelp)); MCHECK(newmenuitem("-", 0, NULL)); p->hmenu = (HelpMenuItems) malloc(sizeof(struct structHelpMenuItems)); RguiCommonHelp(m, p->hmenu); settextfont(t, editorfn); setforeground(t, guiColors[editorfg]); setresize(c, editorresize); setclose(c, editorclose); setdel(c, editordel); setdel(t, textboxdel); setonfocus(c, editorfocus); setkeyaction(t, editorcontrolkeydown); setkeydown(t, editorasciikeydown); /* Store pointer to new editor in global array */ REditors[neditors] = c; ++neditors; return c; }
uint16_t service_usage_query (enum einit_usage_query task, const struct lmodule *module, const char *service) { uint16_t ret = 0; struct stree *ha; char **t; uint32_t i; struct service_usage_item *item; if ((!module || !module->module) && !service) return 0; emutex_lock (&service_usage_mutex); if (task & service_not_in_use) { ret |= service_not_in_use; struct stree *ha = service_usage; /* a service is "in use" if * it's the provider for something, and * it's the only provider for that for that specific service, and * all of the users of that service use the */ while (ha) { if (((struct service_usage_item *)(ha->value))->users && (((struct service_usage_item *)(ha->value))->provider) && ((((struct service_usage_item *)(ha->value))->provider)[0]) && (!((((struct service_usage_item *)(ha->value))->provider)[1])) && inset ((const void **)(((struct service_usage_item *)(ha->value))->provider), module, -1)) { /* this one might be a culprit */ uint32_t i = 0, r = 0; for (; (((struct service_usage_item *)(ha->value))->users)[i]; i++) { if ((((struct service_usage_item *)(ha->value))->users)[i]->si && (((struct service_usage_item *)(ha->value))->users)[i]->si->requires) { if (inset ((const void **)((((struct service_usage_item *)(ha->value))->users)[i]->si->requires), ha->key, SET_TYPE_STRING)) { r++; } } } /* yep, really is in use */ if (i == r) { ret ^= service_not_in_use; break; } } ha = streenext (ha); } } else if (task & service_requirements_met) { ret |= service_requirements_met; if (module->si && (t = module->si->requires)) { for (i = 0; t[i]; i++) { if (!service_usage || !(ha = streefind (service_usage, t[i], tree_find_first)) || !((struct service_usage_item *)(ha->value))->provider) { ret ^= service_requirements_met; break; } } } } else if (task & service_update) { modules_last_change = time(NULL); if (module->status & status_enabled) { if (module->si && (t = module->si->requires)) { for (i = 0; t[i]; i++) { if (service_usage && (ha = streefind (service_usage, t[i], tree_find_first)) && (item = (struct service_usage_item *)ha->value)) { item->users = (struct lmodule **)setadd ((void **)item->users, (void *)module, SET_NOALLOC); } } } if (module->si && (t = module->si->provides)) { for (i = 0; t[i]; i++) { if (service_usage && (ha = streefind (service_usage, t[i], tree_find_first)) && (item = (struct service_usage_item *)ha->value)) { item->provider = (struct lmodule **)setadd ((void **)item->provider, (void *)module, SET_NOALLOC); } else { struct service_usage_item nitem; memset (&nitem, 0, sizeof (struct service_usage_item)); nitem.provider = (struct lmodule **)setadd ((void **)nitem.provider, (void *)module, SET_NOALLOC); service_usage = streeadd (service_usage, t[i], &nitem, sizeof (struct service_usage_item), NULL); } } } } /* more cleanup code */ ha = service_usage; while (ha) { item = (struct service_usage_item *)ha->value; if (!(module->status & status_enabled)) { item->provider = (struct lmodule **)setdel ((void **)item->provider, (void *)module); item->users = (struct lmodule **)setdel ((void **)item->users, (void *)module); } if (!item->provider && !item->users) { // service_usage = streedel (service_usage, ha); service_usage = streedel (ha); ha = service_usage; } else ha = streenext (ha); } } else if (task & service_is_required) { if (service_usage && (ha = streefind (service_usage, service, tree_find_first)) && (item = (struct service_usage_item *)ha->value) && (item->users)) ret |= service_is_required; } else if (task & service_is_provided) { if (service_usage && (ha = streefind (service_usage, service, tree_find_first)) && (item = (struct service_usage_item *)ha->value) && (item->provider)) ret |= service_is_provided; } emutex_unlock (&service_usage_mutex); return ret; }
void einit_feedback_visual_fbsplash_boot_event_handler(struct einit_event *ev) { /* preinit */ if ((ev->type == einit_boot_devices_available) && !(coremode & einit_mode_ipconly)) { if (einit_initial_environment) { /* check for kernel params */ uint32_t i = 0; char start_splash = 0, *ttypatch = NULL, *splashargs = NULL; for (; einit_initial_environment[i]; i++) { if (strstr (einit_initial_environment[i], "splash=") == einit_initial_environment[i]) { start_splash = 1; splashargs = einit_initial_environment[i]+7; if (!ttypatch) ttypatch = "tty1"; } else if ((strstr (einit_initial_environment[i], "console=") == einit_initial_environment[i]) || (strstr (einit_initial_environment[i], "einitty=") == einit_initial_environment[i])) { ttypatch = einit_initial_environment[i]+8; } } if (splashargs && *splashargs) { char *fbtheme = NULL/*, *fbmode = NULL*/; if (splashargs) { char **p = str2set (',', splashargs); if (p) { for (i = 0; p[i]; i++) { char *sep = strchr (p[i], ':'); if (sep) { *sep = 0; sep++; if (strmatch (p[i], "theme")) { fbtheme = estrdup (sep); } }/* else { fbmode = estrdup(p[i]); }*/ } free (p); } } if (fbtheme) { struct cfgnode *node = cfg_getnode ("configuration-feedback-visual-fbsplash-theme", NULL); if (node && node->arbattrs) { uint32_t u = 0; for (; node->arbattrs[u]; u+=2) { if (strmatch(node->arbattrs[u], "s")) { notice (4, "patching fbsplash theme to %s", fbtheme); node->arbattrs[u+1] = fbtheme; node->svalue = fbtheme; } } } } /* if (fbmode) { }*/ } else fbsplash_disabled = 1; if (ttypatch && *ttypatch) { struct cfgnode *node = cfg_getnode ("configuration-feedback-visual-std-io", NULL); /* patch console */ if (node && node->arbattrs) { uint32_t ri = 0; for (; node->arbattrs[ri]; ri+=2) { if (strmatch (node->arbattrs[ri], "stdio")) { char tx[BUFFERSIZE]; if (ttypatch[0] == '/') esprintf (tx, BUFFERSIZE, "%s", ttypatch); else esprintf (tx, BUFFERSIZE, "/dev/%s", ttypatch); notice (4, "patching stdio output to go to %s", tx); node->arbattrs[ri+1] = estrdup(tx); } else if (strmatch (node->arbattrs[ri], "activate-vt")) { notice (4, "removing activate-vt= instruction"); node->arbattrs = (char **)setdel ((void **)node->arbattrs, node->arbattrs[ri]); node->arbattrs = (char **)setdel ((void **)node->arbattrs, node->arbattrs[ri]); } } } } if (start_splash) { struct einit_event ee = evstaticinit(einit_core_change_service_status); ee.argv = (char **)setadd ((void **)ee.set, "splashd", SET_TYPE_STRING); ee.argv = (char **)setadd ((void **)ee.set, "enable", SET_TYPE_STRING); event_emit (&ee, einit_event_flag_broadcast); evstaticdestroy(ee); notice (4, "enabling feedack (fbsplash)"); einit_feedback_visual_fbsplash_enable(); } } } }