bool ATMainWindow_c::winEvent( MSG *m, long *result ) { if ( 1 ) // minimize to tray { switch ( m->message ) { case WM_SIZE: { if ( m_bMinimizeToTray ) { if ( m->wParam == SIZE_MINIMIZED ) { ShowWindow(winId(), SW_HIDE); return true; } } } break; case WM_HOTKEY: { HotKey(LOWORD(m->lParam), HIWORD(m->lParam)); return true; } default: break; } } return QWidget::winEvent(m, result); }
int autodisconnect(void) { int count; char autodb[80]; int i; DDPut(sd[dlautodcstr]); for (count = 9; count; count--) { sleep(1); i = HotKey(HOT_QUICK); if (i == 3) { DDPut("\n\n"); return 0; } if (!checkcarrier()) return 0; ddprintf("%2.2d", count); } DDPut("\n\n"); snprintf(autodb, sizeof autodb, "Connection closed by automatic disconnection at %s\n", currt()); writelog(autodb); dropcarrier(); return 1; }
eOSState cOsdMenu::ProcessKey(eKeys Key) { if (subMenu) { eOSState state = subMenu->ProcessKey(Key); if (state == osBack) return CloseSubMenu(); return state; } cOsdItem *item = Get(current); if (marked < 0 && item) { eOSState state = item->ProcessKey(Key); if (state != osUnknown) { DisplayCurrent(true); return state; } } switch (int(Key)) { case k0: return osUnknown; case k1...k9: return hasHotkeys ? HotKey(Key) : osUnknown; case kUp|k_Repeat: case kUp: CursorUp(); break; case kDown|k_Repeat: case kDown: CursorDown(); break; case kLeft|k_Repeat: case kLeft: PageUp(); break; case kRight|k_Repeat: case kRight: PageDown(); break; case kBack: return osBack; case kOk: if (marked >= 0) { SetStatus(NULL); if (marked != current) Move(marked, current); marked = -1; break; } // else run into default default: if (marked < 0) return osUnknown; } return osContinue; }
int fileattach(void) { char olddir[1024]; char fabuf[1024]; FILE *falist; int cnt = 0; struct dirent *dent; DIR *dh; if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } recfiles(currnode->MULTI_TEMPORARY, 0); snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); /* FIXME: check falist == NULL */ falist = fopen(fabuf, "w"); if ((dh = opendir(currnode->MULTI_TEMPORARY))) { getcwd(olddir, 1024); chdir(currnode->MULTI_TEMPORARY); while ((dent = readdir(dh))) { if (dent->d_name[0] == '.' && (dent->d_name[1] == '\0' || (dent->d_name[1] == '.' && dent->d_name[2] == '\0'))) continue; if (!strcmp(".packtmp", dent->d_name)) continue; deldir(".packtmp"); ddprintf(sd[afqstr], dent->d_name); if (HotKey(HOT_YESNO) == 1) { fprintf(falist, "%s\n", dent->d_name); cnt++; } else { unlink(dent->d_name); } if (!checkcarrier()) break; } chdir(olddir); closedir(dh); } fclose(falist); if (!cnt) { snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); } return 1; }
void killflood(void) { DDPut(sd[dlkillfloodstr]); delayt = 3; for (;;) { int i; if (!checkcarrier()) break; i = HotKey(HOT_DELAY); if (!checkcarrier()) break; if (i == 0 || i == 255 || i == 'y' || i == 'Y') break; } DDPut("\n"); }
void registerHotKeyWrapper(int id, string key, bool repeat) { string alt = "alt"; string shift = "shift"; string ctrl = "ctrl"; UINT modifier = repeat ? 0 : MOD_NOREPEAT; HotKey hotkey = HotKey(key); if (hotkey.alt) { modifier |= MOD_ALT; } if (hotkey.shift) { modifier |= MOD_SHIFT; } if (hotkey.ctrl) { modifier |= MOD_CONTROL; } RegisterHotKey(NULL, id, modifier, hotkey.key); }
int edfile(char *lineedmem, size_t memsize, int reply, struct DayDream_Message *header) { int edtype = 0; int hola; edtype = 0; if (user.user_toggles & (1L << 11)) { DDPut(sd[emfsedstr]); hola = HotKey(HOT_YESNO); if (hola == 0) return 0; if (hola == 1) edtype = 1; } else if (user.user_toggles & (1L << 0)) { edtype = 1; } memset(lineedmem, 0, memsize); if (edtype) return fsed(lineedmem, memsize, reply, header); else return lineed(lineedmem, memsize, reply, header); }
static int create_new_account(void) { DDPut(sd[newucstr]); switch (HotKey(HOT_NOYES)) { case 1: if (CreateNewAccount()) { clog.cl_userid = user.user_account_id; clog.cl_firstcall = user.user_firstcall; clog.cl_logon = time(0); if (user.user_connections == 0) clog.cl_flags |= CL_NEWUSER; clog.cl_bpsrate = bpsrate; getin(); return 1; } return 0; case 2: DDPut("\n"); return 0; default: return 1; } }
int tagconfs(void) { uint8_t backup[8]; char tbuf[500]; const char *sta; char inp[90]; const char *s; char tok[90]; conference_t *mc; struct iterator *iterator; int i; int screenl; for (i = 0; i < 8; i++) { backup[i] = selcfg[2048 + i]; } vagain: DDPut("[2J[H"); i = 0; screenl = user.user_screenlength; iterator = conference_iterator(); while ((mc = (conference_t *) iterator_next(iterator))) { if (checkconfaccess(mc->conf.CONF_NUMBER, &user)) { i++; if (i == 3) { DDPut("\n"); i = 1; screenl--; if (screenl == 1) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n' || !checkcarrier()) break; if (hot == 'C' || hot == 'c') { screenl = 20000000; } else { screenl = user.user_screenlength; } } } if (isconftagged(mc->conf.CONF_NUMBER)) { sta = "ON"; } else sta = "OFF"; ddprintf(sd[togglinestr], mc->conf.CONF_NUMBER, mc->conf.CONF_NAME, sta); } } iterator_discard(iterator); DDPut("\n"); for (;;) { DDPut(sd[tcpromptstr]); inp[0] = 0; if (!(Prompt(inp, 80, 0))) return 0; s = inp; if (!*inp) { strlcpy(inp, "s", sizeof inp); } for (;;) { if (strtoken(tok, &s, sizeof tok) > sizeof tok) continue; if (!*tok) break; if (!strcasecmp(tok, "c")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = backup[i]; } return 0; } else if (!strcasecmp(tok, "v")) { goto vagain; } else if (!strcasecmp(tok, "s")) { int selfd; snprintf(tbuf, sizeof tbuf, "users/%d/selected.dat", user.user_account_id); selfd = open(tbuf, O_WRONLY | O_CREAT, 0666); if (selfd != -1) { fsetperm(selfd, 0666); safe_write(selfd, &selcfg, 2056); close(selfd); } return 0; } else if (!strcasecmp(tok, "-")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = 0; } DDPut(sd[tcalloffstr]); } else if (!strcasecmp(tok, "+")) { for (i = 0; i < 8; i++) { selcfg[2048 + i] = 255; } DDPut(sd[tcallonstr]); } else { i = atoi(tok); if (i > 0 && i < 65 && checkconfaccess(i, &user)) { iterator = conference_iterator(); while ((mc = (conference_t *) iterator_next(iterator))) { if (mc->conf.CONF_NUMBER == i) { if (selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] & (1L << (mc->conf.CONF_NUMBER - 1) % 8)) { selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] &= ~(1L << (mc->conf.CONF_NUMBER - 1) % 8); } else { selcfg[2048 + (mc->conf.CONF_NUMBER - 1) / 8] |= (1L << (mc->conf.CONF_NUMBER - 1) % 8); } break; } } iterator_discard(iterator); } } } } }
BOOL ViWmManager::monitorEnumerator( HMONITOR hMonitor , HDC /* hdcMonitor */ , LPRECT /* intersectionRect */ , LPARAM userData ) { static int monitorCount = 0; ViWmManager &instance = *reinterpret_cast<ViWmManager*>( userData ); DesktopLayout &myLayout = instance.currentLayout; MONITORINFOEX minfo; minfo.cbSize = sizeof( MONITORINFOEX ); GetMonitorInfo( hMonitor, &minfo ); // as MSDN state that some value may be negative for non-primary // displays, we abs the width & height to get correct value to // work on. int winWidth = abs(minfo.rcWork.right - minfo.rcWork.left); int winHeight = abs(minfo.rcWork.bottom - minfo.rcWork.top); // yeah our nice window... HWND fullScreenWin = CreateWindowEx ( WS_EX_LAYERED | WS_EX_NOACTIVATE | (monitorCount == 0 ? WS_EX_APPWINDOW : 0) , fullScreenWindowClassName , TEXT("ABack") , WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS /* style */ , minfo.rcWork.left , minfo.rcWork.top , winWidth , winHeight , NULL , NULL /* menu */ , GetModuleHandle(0) , NULL ); if (!fullScreenWin) { int err = GetLastError(); MessageBox( NULL , TEXT("Error Creating Background Window") , TEXT("Error") , MB_OK | MB_ICONERROR); exit( err ); /* Bail */ } // if NULL, we need to create the menu action // a bit hugly :s if ( monitorCount++ == 0 ) { instance.hotkeysDefinition.push_back( HotKey( 'Z', new Actions::ActionMenu( instance.globalHotkeyListener , instance.hotkeysDefinition ))); } // ok we need our window to be always on bottom, let's hack to get that // we also specify our really wanted size =) SetWindowPos( fullScreenWin , HWND_BOTTOM , minfo.rcWork.left , minfo.rcWork.top , winWidth , winHeight , /*SWP_NOACTIVATE | */SWP_NOMOVE | SWP_NOSIZE ); Renderer::RenderWindow *newWindow = new Renderer::RenderWindow( fullScreenWin , minfo.rcWork.left , minfo.rcWork.top , winWidth , winHeight ); Screen newScreen ( *newWindow , minfo.rcWork.left , minfo.rcWork.top , winWidth , winHeight ); myLayout.push_back( newScreen ); // we make the window transparent here newWindow->begin( true ); newWindow->end(); assert( myLayout.size() >= 1 ); return TRUE; }
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { hotkeys.push_back(HotKey(MOD_WIN, 0x41, 0x00e, VkKeyScan('A'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x43, 0x00f, VkKeyScan('C'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x56, 0x010, VkKeyScan('V'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x56, 0x011, VkKeyScan('V'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x54, 0x012, VkKeyScan('T'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x58, 0x013, VkKeyScan('X'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x57, 0x014, VkKeyScan('W'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x46, 0x015, VkKeyScan('F'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x52, 0x016, VkKeyScan('R'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x53, 0x017, VkKeyScan('S'), VK_CONTROL, 0x9d)); hotkeys.push_back(HotKey(MOD_WIN, 0x53, 0x018, VK_TAB, VK_LMENU, 0xb8)); hotkeys.push_back(HotKey(MOD_WIN, 0x20, 0x019, VK_SPACE, VK_LMENU, 0xb8)); hotkeys.push_back(HotKey(MOD_WIN, 0x51, 0x020, VK_F4, VK_LMENU, 0xb8)); hotkeys.push_back(HotKey(MOD_WIN, 0x8f, 0x021, VK_TAB, VK_LMENU, 0xb8)); while (true) { MSG msg; while(GetMessage(&msg, NULL, 0, 0) > 0) { if (msg.message == WM_HOTKEY) { for (std::vector<HotKey>::iterator i = hotkeys.begin(); i != hotkeys.end(); ++i) { if ((*i).identifier() == msg.wParam) { (*i).press(); } } } TranslateMessage(&msg); DispatchMessage(&msg); } } return 0; }
int pagesysop(const char *reas) { struct DayDream_PageMsg pm; struct sockaddr_un name; int sock; time_t ctim; int i; changenodestatus("Paging SysOp"); reason[0] = 0; if (reas) strlcpy(reason, reas, sizeof reason); TypeFile("pagesysop", TYPE_MAKE | TYPE_WARN); if (maincfg.CFG_FLAGS & (1L << 0)) { if (reason[0] == 0) { DDPut(sd[psreasonstr]); if (!(Prompt(reason, 75, 0))) return 0; if (reason[0] == 0) { DDPut("\n"); return 0; } } } clog.cl_flags |= CL_PAGEDSYSOP; sock = socket(AF_UNIX, SOCK_DGRAM, 0); if (sock < 0) return 0; pm.pm_cmd = 2; ctim = time(0); *pm.pm_string = 0; if (onlinestat) snprintf(pm.pm_string, sizeof pm.pm_string, "\n\n%s / %s (node %d) paged you on %s\n", user.user_realname, user.user_handle, node, ctime(&ctim)); if (reason[0]) { strlcat(pm.pm_string, "Reason: ", sizeof pm.pm_string); strlcat(pm.pm_string, reason, sizeof pm.pm_string); strlcat(pm.pm_string, "\n\n", sizeof pm.pm_string); } name.sun_family = AF_UNIX; strlcpy(name.sun_path, YELLDSOCK, sizeof name.sun_path); if (sendto(sock, &pm, sizeof(struct DayDream_PageMsg), 0, (struct sockaddr *) &name, sizeof(struct sockaddr_un)) < 0) { DDPut(sd[pspageoffstr]); close(sock); return 0; } pages--; ddprintf(sd[pspagingstr], maincfg.CFG_SYSOPNAME); pageflag = 0; for (i = 0; i < 20; i++) { unsigned char c; DDPut("."); delayt = 1; while ((c = HotKey(HOT_QUICK))) { if (c == 255) break; if (c == 3) { DDPut(sd[psabortstr]); i = 21; break; } } if (pageflag) break; pm.pm_cmd = 1; name.sun_family = AF_UNIX; strlcpy(name.sun_path, YELLDSOCK, sizeof name.sun_path); sendto(sock, &pm, sizeof(struct DayDream_PageMsg), 0, (struct sockaddr *) &name, sizeof(struct sockaddr_un)); sleep(1); } if (i == 20) DDPut(sd[psnosysopstr]); close(sock); return 0; }
/* FIXME: rethink */ int lineed(char *buffer, size_t bufsize, int mode, struct DayDream_Message *msg) { int i, j; char lbuf[300]; char *s; int row; *wrapbuf = 0; row = 1; DDPut(sd[leheadstr]); if (mode) row = quote(buffer, bufsize); for (;;) { snprintf(lbuf, sizeof lbuf, "%c", maincfg.CFG_LINEEDCHAR); while (row != 495) { ddprintf(sd[lelinestr], row); s = buffer + (row - 1) * 80; *s = 0; if (!(Prompt(s, 75, PROMPT_WRAP))) return 0; if (!*s || !strcasecmp(lbuf, s)) break; row++; } for (;;) { DDPut(sd[lepromptstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; if (!strcasecmp(lbuf, "a")) { DDPut(sd[lesureabortstr]); i = HotKey(HOT_NOYES); if (!i || i == 1) return 0; } else if (!strcasecmp(lbuf, "c")) { TypeFile("lineedcommands", TYPE_WARN | TYPE_MAKE); } else if (!strcasecmp(lbuf, "d")) { if ((row = delete_lines(row, buffer)) == -1) return 0; } else if (!strcasecmp(lbuf, "e")) { DDPut(sd[leedlinstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; i = atoi(lbuf); if (!(i < 1 || i > (row - 1))) { ddprintf(sd[leedpstr], i); s = buffer + (i - 1) * 80; if (!(Prompt(s, 75, 0))) return 0; } } else if (!strcasecmp(lbuf, "r")) { break; } else if (!strcasecmp(lbuf, "f")) { if (msg && *msg->MSG_ATTACH) { fileattach(); } else { DDPut(sd[noattachstr]); } } else if ((!strcasecmp(lbuf, "i")) && row < 495) { DDPut(sd[insertstr]); lbuf[0] = 0; if (!(Prompt(lbuf, 3, 0))) return 0; DDPut("\nInsert does not work yet, sorry...\n\n"); } else if (!strcasecmp(lbuf, "l")) { int lcount = user.user_screenlength; i = row - 1; j = 1; while (i) { s = buffer + (j - 1) * 80; ddprintf(sd[lellinestr], j, s); lcount--; if (lcount == 0) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n') break; if (hot == 'C' || hot == 'c') { lcount = -1; } else { lcount = user.user_screenlength; } } j++; i--; } } else if (!strcasecmp(lbuf, "s")) { return row - 1; } else if (!strcasecmp(lbuf, "q")) { if (!mode) { DDPut(sd[lereperrorstr]); } row = quote(s, strlen(s)); } } } }
int tagmessageareas(void) { uint8_t backup[32]; char tbuf[500]; const char *sta; msgbase_t *mb; int bcnt; char inp[90]; const char *s; char tok[90]; int screenl; int i, j; memcpy(backup, &selcfg[(conference()->conf.CONF_NUMBER - 1) * 32], sizeof backup); vagain: DDPut("[2J[H"); screenl = user.user_screenlength; bcnt = conference()->conf.CONF_MSGBASES; for (i = j = 0; j < bcnt; j++) { mb = conference()->msgbases[j]; i++; if (i == 3) { DDPut("\n"); i = 1; screenl--; if (screenl == 1) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n' || !checkcarrier()) break; if (hot == 'C' || hot == 'c') { screenl = 20000000; } else { screenl = user.user_screenlength; } } } if (isbasetagged(conference()->conf.CONF_NUMBER, mb->MSGBASE_NUMBER)) { sta = "ON"; } else sta = "OFF"; ddprintf(sd[tbclinestr], mb->MSGBASE_NUMBER, mb->MSGBASE_NAME, sta); } DDPut("\n"); for (;;) { DDPut(sd[tbpromptstr]); inp[0] = 0; if (!(Prompt(inp, 80, 0))) return 0; s = inp; if (!*inp) { strlcpy(inp, "s", sizeof inp); } for (;;) { if (strtoken(tok, &s, sizeof tok) > sizeof tok) continue; if (!*tok) break; if (!strcasecmp(tok, "c")) { memcpy(&selcfg[(conference()->conf.CONF_NUMBER - 1) * 32], backup, sizeof backup); return 0; } else if (!strcasecmp(tok, "v")) { goto vagain; } else if (!strcasecmp(tok, "s")) { int selfd; snprintf(tbuf, sizeof tbuf, "users/%d/selected.dat", user.user_account_id); selfd = open(tbuf, O_WRONLY | O_CREAT, 0666); if (selfd != -1) { fsetperm(selfd, 0666); safe_write(selfd, &selcfg, 2056); close(selfd); } return 0; } else if (!strcasecmp(tok, "-")) { for (i = 0; i < 32; i++) { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + i] = 0; } DDPut(sd[tballoffstr]); } else if (!strcasecmp(tok, "+")) { bcnt = conference()->conf.CONF_MSGBASES; for (i = 0; i < bcnt; i++) { mb = conference()->msgbases[i]; selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8); } DDPut(sd[tballonstr]); } else { i = atoi(tok); if (i) { for (j = 0; j < conference()->conf.CONF_MSGBASES; j++) { mb = conference()->msgbases[j]; if (i == mb->MSGBASE_NUMBER) { if (selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] & (1L << (mb->MSGBASE_NUMBER - 1) % 8)) { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] &= ~(1L << (mb->MSGBASE_NUMBER - 1) % 8); } else { selcfg[((conference()->conf.CONF_NUMBER - 1) * 32) + (mb->MSGBASE_NUMBER - 1) / 8] |= (1L << (mb->MSGBASE_NUMBER - 1) % 8); } break; } } } } } } }
int bulletins(char *params) { char bdir[200]; char menunam[240]; char bullb[500]; char tbuf[400]; char nbu[240]; int first = 0; int menfd; const char *srcstrh; changenodestatus("Viewing bulletins"); snprintf(bdir, sizeof bdir, "%s/bulletins/", conference()->conf.CONF_PATH); snprintf(menunam, sizeof menunam, "%sbulletinmenu.%s", bdir, ansi ? "gfx" : "txt"); menfd = open(menunam, O_RDONLY); if (menfd == -1) { snprintf(bdir, sizeof bdir, "bulletins/"); snprintf(menunam, sizeof menunam, "bulletins/bulletinmenu.%s", ansi ? "gfx" : "txt"); menfd = open(menunam, O_RDONLY); if (menfd == -1) { DDPut(sd[bunobullsstr]); return 0; } } close(menfd); srcstrh = params; for (;;) { int bulnum; if (strtoken(bullb, &srcstrh, sizeof bullb) > sizeof bullb) continue; if (!*bullb) { if (!first) TypeFile(menunam, TYPE_WARN); DDPut(sd[bumenustr]); *tbuf = 0; if (!(Prompt(tbuf, 60, 0))) return 0; srcstrh = tbuf; if (strtoken(bullb, &srcstrh, sizeof bullb) > sizeof bullb) return 0; if (!*bullb) return 0; } first = 1; if (*bullb == 'q' || *bullb == 'Q') return 0; if (*bullb == 'l' || *bullb == 'L' || *bullb == '?') { TypeFile(menunam, TYPE_WARN); } else if ((bulnum = atoi(bullb))) { snprintf(nbu, sizeof nbu, "%sbulletin.%d.%s", bdir, bulnum, ansi ? "gfx" : "txt"); if (TypeFile(nbu, TYPE_WARN)) { if (!(user.user_toggles & (1L << 4))) { DDPut(sd[pause2str]); HotKey(0); } } } } }
bool MenuBar::Key(dword key, int count) { LLOG("KEY " << GetKeyDesc(key)); bool horz = IsChild(); if((horz ? key == K_RIGHT : key == K_DOWN)) { Ctrl *ctrl = GetFocusChildDeep(); LLOG("MenuBar::Key(" << key << ") -> IterateFocusForward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane)); if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(ctrl && IterateFocusForward(ctrl, &pane, false, false, true)) return true; Ctrl *f = pane.GetFirstChild(); if(!f) return true; if(f->IsEnabled()) { f->SetFocus(); return true; } if(IterateFocusForward(pane.GetFirstChild(), &pane, false, false, true)) return true; } else if((horz ? key == K_LEFT : key == K_UP)) { Ctrl *ctrl = GetFocusChildDeep(); LLOG("MenuBar::Key(" << key << ") -> IterateFocusBackward for " << UPP::Name(ctrl) << ", pane " << UPP::Name(&pane)); if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(ctrl && IterateFocusBackward(ctrl, &pane, false, true)) return true; Ctrl *f = pane.GetLastChild(); if(!f) return true; if(f->IsEnabled()) { f->SetFocus(); return true; } if(IterateFocusBackward(pane.GetLastChild(), &pane, false, true)) return true; } else if(parentmenu && !parentmenu->IsChild() && key == K_LEFT || key == K_ESCAPE) { if(HasMouseDeep()) GetMouseCtrl()->Refresh(); if(parentmenu && parentmenu->submenu) parentmenu->submenuitem->SetFocus(); else if(IsChild() && HasFocusDeep()) { if(restorefocus) restorefocus->SetFocus(); doeffect = true; return true; } if(IsPopUp()) { SubmenuClose(); return true; } doeffect = true; } if(parentmenu && parentmenu->IsChild() && parentmenu->GetActiveSubmenu() && parentmenu->pane.GetFirstChild() && parentmenu->submenuitem) { Ctrl *smi = parentmenu->submenuitem; Ctrl *q = smi; q->Refresh(); if(key == K_RIGHT) for(;;) { q = q->GetNext(); if(!q) q = parentmenu->pane.GetFirstChild(); if(q == smi) break; if(PullMenu(q)) { q->Refresh(); SyncState(); return true; } } if(key == K_LEFT) for(;;) { q = q->GetPrev(); if(!q) q = parentmenu->pane.GetLastChild(); if(q == smi) break; if(PullMenu(q)) { q->Refresh(); SyncState(); return true; } } } LLOG("MenuBar::Key -> HotKey"); return HotKey(key); }
int entermsg(struct DayDream_Message *msg, int reply, char *params) { char ebuf[1024]; int hola; int msgfd; char *s; struct DayDream_Message header; char *lineedmem; int recoff; if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E' && ((access1 & (1L << SECB_FIDOMESSAGE)) == 0)) { DDPut(sd[emnofidomsgstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N' && ((access2 & (1L << SECB_SENDNETMAIL)) == 0)) { DDPut(sd[emnonetmsgstr]); return 0; } changenodestatus("Entering a message"); if (msg) { memcpy(&header, msg, sizeof(struct DayDream_Message)); } else { s = (char *) &header; memset(&header, 0, sizeof(struct DayDream_Message)); if (params) strncpy(header.MSG_RECEIVER, params, 25); } if (current_msgbase->MSGBASE_FLAGS & (1L << 0) && current_msgbase->MSGBASE_FLAGS & (1L << 1)) { DDPut(sd[emnomsgsstr]); return 0; } DDPut(sd[emhead1str]); DDPut(current_msgbase->MSGBASE_NAME); ebuf[0] = 0; strlcat(ebuf, sd[emhead2str], sizeof ebuf); hola = 61 - strlen(current_msgbase->MSGBASE_NAME); while (hola) { strlcat(ebuf, "-", sizeof ebuf); hola--; } DDPut(ebuf); ddprintf(sd[emhead3str], highest); DDPut(sd[emhead4str]); if ((current_msgbase->MSGBASE_FLAGS & (1L << 0)) || (header.MSG_FLAGS & (1L << 0))) { DDPut(sd[emprvstr]); header.MSG_FLAGS |= (1L << 0); } else { DDPut(sd[empubstr]); } header.MSG_CREATION = time(0); DDPut(sd[emhead5str]); DDPut(ctime(&header.MSG_CREATION)); DDPut(sd[emhead6str]); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_AUTHOR, user.user_handle, sizeof header.MSG_AUTHOR); } else { strlcpy(header.MSG_AUTHOR, user.user_realname, sizeof header.MSG_AUTHOR); } DDPut(header.MSG_AUTHOR); for (;;) { askrec: DDPut(sd[emhead7str]); if (!(Prompt(header.MSG_RECEIVER, 25, 0))) return 0; if (header.MSG_RECEIVER[0] == 0 || (!strcasecmp(header.MSG_RECEIVER, "all")) || (!strcasecmp(header.MSG_RECEIVER, "all users"))) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else { DDPut(sd[emhead9str]); header.MSG_RECEIVER[0] = 0; break; } } else if (!strcasecmp(header.MSG_RECEIVER, "eall")) { if (current_msgbase->MSGBASE_FLAGS & (1L << 0)) { DDPut(sd[emhead8str]); HotKey(0); header.MSG_RECEIVER[0] = 0; } else if (access1 & (1L << SECB_EALLMESSAGE)) { header.MSG_RECEIVER[0] = -1; DDPut(sd[emhead10str]); break; } else { DDPut(sd[emnopoststr]); HotKey(0); header.MSG_RECEIVER[0] = 0; } } else { if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'L') { struct userbase user; if (!strcasecmp(header.MSG_RECEIVER, "sysop")) { recoff = 0; } else { recoff = findusername(header.MSG_RECEIVER); } if (recoff == -1 || getubentbyid(recoff, &user) == -1) { DDPut(sd[emnouserstr]); HotKey(0); goto askrec; } if (!checkconfaccess(conference()->conf.CONF_NUMBER, &user)) { DDPut(sd[emnoaccessstr]); HotKey(0); } DDPut("[5;12H [5;12H"); if (current_msgbase->MSGBASE_FLAGS & (1L << 2)) { strlcpy(header.MSG_RECEIVER, user.user_handle, sizeof header.MSG_RECEIVER); } else { strlcpy(header.MSG_RECEIVER, user.user_realname, sizeof header.MSG_RECEIVER); } DDPut(header.MSG_RECEIVER); break; } else break; } } DDPut(sd[emsubjectstr]); if (!(Prompt(header.MSG_SUBJECT, 67, 0))) return 0; if (header.MSG_SUBJECT[0] == 0) { DDPut(sd[emabortedstr]); return 0; } DDPut("[11;1H [11;1H"); if (header.MSG_RECEIVER[0] == 0 || header.MSG_RECEIVER[0] == -1 || header.MSG_FLAGS & (1L << 0) || current_msgbase->MSGBASE_FLAGS & (1L << 1)) { } else { DDPut(sd[emisprivatestr]); hola = HotKey(HOT_NOYES); if (hola == 0) return 0; if (hola == 1) header.MSG_FLAGS |= MSG_FLAGS_PRIVATE; } if ((header.MSG_FLAGS & (1L << 0)) == 0 && (access1 & (1L << SECB_PUBLICMESSAGE)) == 0) { DDPut(sd[emnopubstr]); return 0; } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { if (header.MSG_FN_DEST_NET) { snprintf(ebuf, sizeof ebuf, "%d:%d/%d.%d", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_DEST_POINT); } else { *ebuf = 0; } DDPut(sd[emnetaddstr]); if (!(Prompt(ebuf, 30, 0))) return 0; if (!str2addr(ebuf, &header.MSG_FN_DEST_ZONE, &header.MSG_FN_DEST_NET, &header.MSG_FN_DEST_NODE, &header.MSG_FN_DEST_POINT)) return 0; if(access2 & (1L << SECB_CRASH)) { DDPut(sd[emnetcrashstr]); if(HotKey(HOT_NOYES) == 1) { header.MSG_FLAGS |= MSG_FLAGS_CRASH; } } DDPut(sd[emnetkillstr]); if(HotKey(HOT_YESNO) == 1) { header.MSG_FLAGS |= MSG_FLAGS_KILL_SENT; } } *header.MSG_ATTACH = 0; if (current_msgbase->MSGBASE_FLAGS & (1L << 5)) { if ((header.MSG_FLAGS & (1L << 0)) && (access2 & (1L << SECB_PVTATTACH))) { *header.MSG_ATTACH = 1; } else if (((header.MSG_FLAGS & (1L << 0)) == 0) && (access2 & (1L << SECB_PUBATTACH))) { *header.MSG_ATTACH = 1; } } if (reply) { if (!askqlines()) { snprintf(ebuf, sizeof ebuf, "%s/daydream%d.msg", DDTMP, node); unlink(ebuf); } DDPut("\n\n"); } /* XXX: size should be replaced by a constant! */ lineedmem = (char *) xmalloc(80 * 500); hola = edfile(lineedmem, 80 * 500, reply, &header); if (hola == 0) { char fabuf[1024]; DDPut(sd[emaborted2str]); free(lineedmem); if (cleantemp() == -1) { DDPut(sd[tempcleanerrstr]); return 0; } snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); unlink(fabuf); return 0; } DDPut(sd[emsavingstr]); getmsgptrs(); highest++; header.MSG_NUMBER = highest; if (setmsgptrs() == 0) { free(lineedmem); return 0; } if (*header.MSG_ATTACH) { char fabuf[1024]; FILE *fd; snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node); if ((fd = fopen(fabuf, "r"))) { char hoobab[1024]; snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/fa%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); mkdir(hoobab, 0777); setperm(hoobab, 0777); while (fgetsnolf(hoobab, 1024, fd)) { char sr[1024]; char de[1024]; snprintf(sr, sizeof sr, "%s/%s", currnode->MULTI_TEMPORARY, hoobab); snprintf(de, sizeof de, "%s/messages/base%3.3d/fa%5.5d/%s", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, hoobab); newrename(sr, de); } fclose(fd); snprintf(hoobab, sizeof hoobab, "%s/messages/base%3.3d/msf%5.5d", conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER); newrename(fabuf, hoobab); } else { *header.MSG_ATTACH = 0; } } if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { header.MSG_FN_ORIG_ZONE = current_msgbase->MSGBASE_FN_ZONE; header.MSG_FN_ORIG_NET = current_msgbase->MSGBASE_FN_NET; header.MSG_FN_ORIG_NODE = current_msgbase->MSGBASE_FN_NODE; header.MSG_FN_ORIG_POINT = current_msgbase->MSGBASE_FN_POINT; header.MSG_FLAGS |= (1L << 2); } if ((msgfd = ddmsg_open_base(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, O_RDWR | O_CREAT, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); lseek(msgfd, 0, SEEK_END); safe_write(msgfd, &header, sizeof(struct DayDream_Message)); ddmsg_close_base(msgfd); if ((msgfd = ddmsg_open_msg(conference()->conf.CONF_PATH, current_msgbase->MSGBASE_NUMBER, header.MSG_NUMBER, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) { DDPut(sd[emwriteerrstr]); free(lineedmem); return 0; } fsetperm(msgfd, 0666); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { char ub[128]; int uq; strlcpy(ub, current_msgbase->MSGBASE_FN_TAG, sizeof ub); strupr(ub); snprintf(ebuf, sizeof ebuf, "AREA:%s\n", ub); safe_write(msgfd, ebuf, strlen(ebuf)); if ((uq = getfidounique())) { snprintf(ebuf, sizeof ebuf, "\001MSGID: %d:%d/%d.%d %8.8x\n", current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_POINT, uq); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_ORIGINAL) { if (getreplyid(header.MSG_ORIGINAL, ebuf, sizeof ebuf)) safe_write(msgfd, ebuf, strlen(ebuf)); } } } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'N') { snprintf(ebuf, sizeof ebuf, "\001INTL %d:%d/%d %d:%d/%d\n", header.MSG_FN_DEST_ZONE, header.MSG_FN_DEST_NET, header.MSG_FN_DEST_NODE, header.MSG_FN_ORIG_ZONE, header.MSG_FN_ORIG_NET, header.MSG_FN_ORIG_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); if (header.MSG_FN_DEST_POINT) { snprintf(ebuf, sizeof ebuf, "\001TOPT %d\n", header.MSG_FN_DEST_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } if (header.MSG_FN_ORIG_POINT) { snprintf(ebuf, sizeof ebuf, "\001FMPT %d\n", header.MSG_FN_ORIG_POINT); safe_write(msgfd, ebuf, strlen(ebuf)); } } s = lineedmem; while (hola) { snprintf(ebuf, sizeof ebuf, "%s\n", s); safe_write(msgfd, ebuf, strlen(ebuf)); hola--; s = &s[80]; } // place holder, user auto-sig goes here // snprintf(ebuf, sizeof ebuf, "signature here"); // safe_write(msgfd, ebuf, strlen(ebuf)); if (toupper(current_msgbase->MSGBASE_FN_FLAGS) == 'E') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n * Origin: %s (%d:%d/%d)\nSEEN-BY: %d/%d\n", versionstring, current_msgbase->MSGBASE_FN_ORIGIN, current_msgbase->MSGBASE_FN_ZONE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE, current_msgbase->MSGBASE_FN_NET, current_msgbase->MSGBASE_FN_NODE); safe_write(msgfd, ebuf, strlen(ebuf)); } else if (toupper(current_msgbase->MSGBASE_FN_FLAGS) != 'L') { snprintf(ebuf, sizeof ebuf, "\n--- DayDream BBS/UNIX (" UNAME ") %s\n", versionstring); safe_write(msgfd, ebuf, strlen(ebuf)); } ddmsg_close_msg(msgfd); DDPut(sd[emdonestr]); free(lineedmem); if (header.MSG_FLAGS & (1L << 0)) { user.user_pvtmessages++; clog.cl_pvtmessages++; } else { user.user_pubmessages++; clog.cl_pubmessages++; } return 1; }
eOSState cOsdMenu::HotKey(eKeys Key) { #ifdef USE_LIEMIEXT bool match = false; bool highlight = false; int item_nr; int i; if (Key == kNone) { if (lastActivity.TimedOut()) Key = kOk; else return osContinue; } else { lastActivity.Set(MENUKEY_TIMEOUT); } for (cOsdItem *item = Last(); item; item = Prev(item)) { #else for (cOsdItem *item = First(); item; item = Next(item)) { #endif /* LIEMIEXT */ const char *s = item->Text(); #ifdef USE_LIEMIEXT i = 0; item_nr = 0; if (s && (s = skipspace(s)) != '\0' && '0' <= s[i] && s[i] <= '9') { do { item_nr = item_nr * 10 + (s[i] - '0'); } while ( !((s[++i] == '\t')||(s[i] == ' ')) && (s[i] != '\0') && ('0' <= s[i]) && (s[i] <= '9')); if ((Key == kOk) && (item_nr == key_nr)) { #else if (s && (s = skipspace(s)) != NULL) { if (*s == Key - k1 + '1') { #endif /* LIEMIEXT */ current = item->Index(); RefreshCurrent(); Display(); cRemote::Put(kOk, true); #ifdef USE_LIEMIEXT key_nr = -1; #endif /* LIEMIEXT */ break; } #ifdef USE_LIEMIEXT else if (Key != kOk) { if (!highlight && (item_nr == (Key - k0))) { highlight = true; current = item->Index(); } if (!match && (key_nr == -1) && ((item_nr / 10) == (Key - k0))) { match = true; key_nr = (Key - k0); } else if (((key_nr == -1) && (item_nr == (Key - k0))) || (!match && (key_nr >= 0) && (item_nr == (10 * key_nr + Key - k0)))) { current = item->Index(); cRemote::Put(kOk, true); key_nr = -1; break; } } #endif /* LIEMIEXT */ } } #ifdef USE_LIEMIEXT if ((!match) && (Key != kNone)) { key_nr = -1; } #endif /* LIEMIEXT */ #if REELVDR // RC: returning osContinue prevents the main menu and prob. others from automatic closing. side effects? //DDD("return osUnknown"); return osUnknown; #else return osContinue; #endif } eOSState cOsdMenu::AddSubMenu(cOsdMenu *SubMenu) { delete subMenu; subMenu = SubMenu; #if REELVDR /* close any preview/pip channels when adding a submenu, since it does not belong to the submenu*/ if(cReelBoxBase::Instance()) { cReelBoxBase::Instance()->StartPip(false); printf("\033[0;92mStop pip\033[0m\n"); } // Clear ID3 tags and cover-art/thumbnails that are stored in skinreel3's // global variables, // new osd should set the necessary thumbnails and id3 infos itself. #if 0 // thumbnails in install wizard were not shown! cPlugin *skinPlugin = cPluginManager::GetPlugin("skinreel3"); if (skinPlugin) { skinPlugin->Service("setThumb", NULL); skinPlugin->Service("setId3Infos", NULL); } #endif #endif subMenu->Display(); return osContinue; // convenience return value } eOSState cOsdMenu::CloseSubMenu() { delete subMenu; subMenu = NULL; RefreshCurrent(); Display(); return osContinue; // convenience return value } #ifdef REELVDR //#define SEPARATORS ":-\0" #define SEPARATORS ":-" ///< take menu-title substrings befor one of this chars eOSState cOsdMenu::DisplayHelpMenu(const char *Title) { char title[128]; // if we get Menu at first we assume Main Menu if (strstr(Title,tr("Main Menu")) == Title) { strncpy(title,tr("Main Menu"),128); } else { const char *sep = SEPARATORS; while (*sep != '\0') { //printf (" \t\t --- sep %c \n", *sep); char *s = NULL; strncpy(title,Title,128); title[127] = '\0'; s = strchr(title,*sep); if (s) { *s = '\0'; //break; } sep++; } } //cHelpSection *hs = HelpMenus.GetSectionByTitle(title); //return AddSubMenu(new cMenuHelp(hs, title)); } #endif /* REELVDR */ eOSState cOsdMenu::ProcessKey(eKeys Key) { if (subMenu) { eOSState state = subMenu->ProcessKey(Key); if (state == osBack) return CloseSubMenu(); return state; } cOsdItem *item = Get(current); if (marked < 0 && item) { eOSState state = item->ProcessKey(Key); if (state != osUnknown) { DisplayCurrent(true); return state; } } switch (int(Key)) { #ifdef USE_LIEMIEXT case kNone: case k0...k9: return hasHotkeys ? HotKey(Key) : osUnknown; #else case k0: return osUnknown; case k1...k9: return hasHotkeys ? HotKey(Key) : osUnknown; #endif /* LIEMIEXT */ case kUp|k_Repeat: case kUp: CursorUp(); break; case kDown|k_Repeat: case kDown: CursorDown(); break; case kLeft|k_Repeat: case kLeft: PageUp(); break; case kRight|k_Repeat: case kRight: PageDown(); break; case kBack: return osBack; #ifdef REELVDR case kInfo: return DisplayHelpMenu(title); #endif /* REELVDR */ case kOk: if (marked >= 0) { SetStatus(NULL); if (marked != current) Move(marked, current); marked = -1; break; } // else run into default default: if (marked < 0) return osUnknown; } return osContinue; }
/* FIXME! better to move this to entermsg.c */ int askqlines(void) { char qbuffer[200]; char input[100]; int ql; int lcount; int outp; int startn; int endn; int line; FILE *qfd, *msgfd; snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.mtm", DDTMP, node); if (!(qfd = fopen(qbuffer, "r"))) return 0; DDPut("\n"); for (;;) { ql = 0; lcount = user.user_screenlength; outp = 1; while (fgets(input, 77, qfd)) { ql++; if (outp) { ddprintf(sd[lel2str], ql, input); lcount--; } if (lcount == 0) { int hot; DDPut(sd[morepromptstr]); hot = HotKey(0); DDPut("\r \r"); if (hot == 'N' || hot == 'n') { outp = 0; lcount = -1; } else if (hot == 'C' || hot == 'c') { lcount = -1; } else { lcount = user.user_screenlength; } } } ddprintf(sd[lequotestr], ql); qbuffer[0] = 0; if (!(Prompt(qbuffer, 3, PROMPT_NOCRLF))) { fclose(qfd); return 0; } if (!strcasecmp(qbuffer, "l")) { DDPut("\n\n"); fseek(qfd, 0, SEEK_SET); } else if ((!strcasecmp(qbuffer, "*")) || *qbuffer == 0) { startn = 1; endn = ql; break; } else if ((startn = atoi(qbuffer))) { DDPut(sd[ledeltostr]); qbuffer[0] = 0; if (!(Prompt(qbuffer, 3, PROMPT_NOCRLF))) { fclose(qfd); return 0; } if ((endn = atoi(qbuffer))) { break; } else { fclose(qfd); return 0; } } else { fclose(qfd); return 0; } } fseek(qfd, 0, SEEK_SET); if (startn < 1 || endn > ql) { fclose(qfd); return 0; } line = 1; snprintf(qbuffer, sizeof qbuffer, "%s/daydream%d.msg", DDTMP, node); if (!(msgfd = fopen(qbuffer, "w"))) { fclose(qfd); return 0; } while (fgets(input, 77, qfd)) { if (startn <= line && endn >= line) { fputs(input, msgfd); } line++; } fclose(qfd); fclose(msgfd); return 1; }