bool CZapitClient::receive_channel_list(BouquetChannelList& channels, const bool utf_encoded) { CZapitMessages::responseGeneralInteger responseInteger; responseGetBouquetChannels response; channels.clear(); if (CBasicClient::receive_data((char* )&responseInteger, sizeof(responseInteger))) { channels.reserve(responseInteger.number); while (responseInteger.number-- > 0) { if (!CBasicClient::receive_data((char*)&response, sizeof(responseGetBouquetChannels))) return false; response.nr++; if (!utf_encoded) { char buffer[CHANNEL_NAME_SIZE + 1]; buffer[CHANNEL_NAME_SIZE] = (char) 0x00; cstrncpy(buffer, response.name, sizeof(buffer)); cstrncpy(response.name, ZapitTools::UTF8_to_Latin1(buffer), sizeof(response.name)); } channels.push_back(response); } } return true; }
/* bouquets are numbered starting at 0 */ void CZapitClient::getBouquets(BouquetList& bouquets, const bool emptyBouquetsToo, const bool utf_encoded, channelsMode mode) { char buffer[30 + 1]; CZapitMessages::commandGetBouquets msg; VALGRIND_PARANOIA; msg.emptyBouquetsToo = emptyBouquetsToo; msg.mode = mode; OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex); send(CZapitMessages::CMD_GET_BOUQUETS, (char*)&msg, sizeof(msg)); responseGetBouquets response; while (CBasicClient::receive_data((char*)&response, sizeof(responseGetBouquets))) { if (response.bouquet_nr == RESPONSE_GET_BOUQUETS_END_MARKER) break; if (!utf_encoded) { cstrncpy(buffer, response.name, sizeof(buffer)); cstrncpy(response.name, ZapitTools::UTF8_to_Latin1(buffer).c_str(), sizeof(buffer)); } bouquets.push_back(response); } close_connection(); }
/* expand the <hline> tag into a buffer Mind that the line may not fully be expanded, 'remainders' with broken color codes are really dreadful */ void expand_hline(char *str, char *dest, int bufsize, int width) { char *p; int l, n; if (str == NULL || dest == NULL || bufsize <= 0) return; if ((p = cstristr(str, "<hline>")) == NULL) { cstrncpy(dest, str, bufsize); return; } l = p - str; if (l >= bufsize) { cstrncpy(dest, str, bufsize); return; } if (l > 0) cstrncpy(dest, str, l+1); else *dest = 0; p += 7; n = strlen(p); if (n > 0) { int cl, c; cl = color_strlen(dest); c = color_strlen(p); while(l + n < bufsize && cl < width) { cstrcat(dest, p, bufsize); l += n; cl += c; } } /* remaining part: this is commented out because it has a habit of chopping op color codes, giving ugly results n = bufsize - l; if (n > 0) cstrncpy(dest+l, p, n); */ while((p = cstristr(dest, "<hline>")) != NULL) /* filter out duplicate codes */ memmove(p, p+7, strlen(p+7)+1); }
/* expand the <center> tag into a buffer This tag doesn't go well together with other tags */ void expand_center(char *str, char *dest, int bufsize, int width) { char *p; int l, n; if (str == NULL || dest == NULL || bufsize <= 0) return; if ((p = cstristr(str, "<center>")) == NULL) { cstrncpy(dest, str, bufsize); return; } l = p - str; if (l >= bufsize) { cstrncpy(dest, str, bufsize); return; } if (l > 0) cstrncpy(dest, str, l); else l = 0; dest[l] = 0; p += 8; n = width/2 - color_strlen(p)/2 - l; while(n > 0 && l < bufsize-1) { dest[l] = ' '; l++; n--; } dest[l] = 0; n = strlen(p); if (l + n >= bufsize) { n = bufsize - l; if (n > 0) cstrncpy(dest+l, p, n); } else cstrcpy(dest+l, p, bufsize - l); while((p = cstristr(dest, "<center>")) != NULL) /* filter out duplicate codes */ memmove(p, p+8, strlen(p+8)+1); }
void CTimerdClient::registerEvent(unsigned int eventID, unsigned int clientID, const char * const udsName) { CEventServer::commandRegisterEvent msg2; VALGRIND_PARANOIA(msg2); msg2.eventID = eventID; msg2.clientID = clientID; cstrncpy(msg2.udsName, udsName, sizeof(msg2.udsName)); send(CTimerdMsg::CMD_REGISTEREVENT, (char*)&msg2, sizeof(msg2)); close_connection(); }
void CSectionsdClient::registerEvent(const unsigned int eventID, const unsigned int clientID, const char * const udsName) { CEventServer::commandRegisterEvent msg2; VALGRIND_PARANOIA(msg2); msg2.eventID = eventID; msg2.clientID = clientID; cstrncpy(msg2.udsName, udsName, sizeof(msg2.udsName)); send(sectionsd::CMD_registerEvents, (char*)&msg2, sizeof(msg2)); close_connection(); }
int main() { int length = __VERIFIER_nondet_int(); int n = __VERIFIER_nondet_int(); if (length < 1) { length = 1; } if (n < 1) { n = 1; } char* nondetArea = (char*) alloca(n * sizeof(char)); char* nondetString = (char*) alloca(length * sizeof(char)); nondetString[length-1] = '\0'; cstrncpy(nondetArea, nondetString, n); return 0; }
void CZapitClient::registerEvent(const unsigned int eventID, const unsigned int clientID, const char * const udsName) { CEventServer::commandRegisterEvent msg; VALGRIND_PARANOIA; msg.eventID = eventID; msg.clientID = clientID; cstrncpy(msg.udsName, udsName, sizeof(msg.udsName)); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex); send(CZapitMessages::CMD_REGISTEREVENTS, (char*)&msg, sizeof(msg)); close_connection(); }
void StringPool::InsertString(Crude::String TargetString) { unsigned int MemoryUsed = MemoryBlocks.Get()->MemoryUsed; if ((MemoryUsed + TargetString.Length()) >= MEMORYBLOCK_SIZE) { CreateMemoryBlock(); MemoryBlocks.Slide(); } cstrncpy(TargetString.Data(), MemoryBlocks.Get()->Memory + (MemoryUsed), TargetString.Length() + 1); MemoryBlocks.Get()->MemoryUsed += TargetString.Length() + 1; }
static int internal_sub(const CHAR_TYPE* s, const CHAR_TYPE* source, regmatch matches[10], CHAR_TYPE* dest) { register int length = 0; register int no; register const CHAR_TYPE* src = source; register int len = 0; register CHAR_TYPE* dst = dest; register CHAR_TYPE c; while ((c = *src++) != LIT('\0')) { if (c == LIT('&')) no = 0; else if (c == LIT('\\') && cisdigit(*src)) no = *src++ - LIT('0'); else no = -1; if (no < 0) { /* Ordinary character. */ if (c == LIT('\\') && (*src == LIT('\\') || *src == LIT('&'))) c = *src++; ++length; if(dst) *dst++ = c; } else if (matches[no].begin != -1 && matches[no].end != -1 && matches[no].end > matches[no].begin) { len = matches[no].end - matches[no].begin; length += len; if(dst) { cstrncpy(dst, s + matches[no].begin, len); dst += len; if(*(dst - 1) == LIT('\0')) return REGEXP_EEND; } } } if(dst) { *dst++ = LIT('\0'); return 1; } else return length + 1; }
/* long color codes look like '<yellow>', '<white>', '<hotkey>', etc. parsing the long color code is a slow function... but it makes programming with color coded strings a lot easier task it's more or less sorted in order of most frequent appearance to make it less slow cpos is the cursor position, which is used in <hline> and <center> tags for <hline>, the function recurses with Out_text() if dev is NULL, it produces no output */ int long_color_code(StringIO *dev, User *usr, char *code, int *cpos, int *lines, int max_lines, int dont_auto_color) { int i, c, color; char colorbuf[MAX_COLORBUF], buf[PRINT_BUF], *p; if (usr == NULL || code == NULL || !*code || cpos == NULL || lines == NULL) return 0; for(i = 0; i < NUM_COLORS; i++) { if (i == HOTKEY) continue; bufprintf(colorbuf, sizeof(colorbuf), "<%s>", color_table[i].name); if (!cstrnicmp(code, colorbuf, strlen(colorbuf))) { if (!(usr->flags & USR_ANSI)) return strlen(colorbuf)-1; c = usr->color = color_table[i].key; color = Ansi_Color(usr, c); if (usr->flags & USR_BOLD) bufprintf(buf, sizeof(buf), "\x1b[1;%dm", color); else bufprintf(buf, sizeof(buf), "\x1b[%dm", color); put_StringIO(dev, buf); return strlen(colorbuf)-1; } } /* Blinking is really irritating... if (!cstrnicmp(code, "<flash>", 7) || !cstrnicmp(code, "<blink>", 7)) { if (!(usr->flags & USR_ANSI)) return 6; usr->color = KEY_CTRL('F'); color = Ansi_Color(usr, KEY_CTRL('F')); if (usr->flags & USR_BOLD) bufprintf(buf, sizeof(buf), "\x1b[1;%dm", color); else bufprintf(buf, sizeof(buf), "\x1b[%dm", color); put_StringIO(dev, buf); return 6; } */ if (!cstrnicmp(code, "<hotkey>", 8)) { c = code[8]; if (!c) return 7; print_hotkey(usr, c, buf, sizeof(buf), cpos); put_StringIO(dev, buf); return 8; } if (!cstrnicmp(code, "<key>", 5)) { c = code[5]; if (!c) return 4; /* Don't do this; the <key> code is used in the Help files to keep this from happening if (usr->flags & USR_UPPERCASE_HOTKEYS) c = ctoupper(c); */ if (usr->flags & USR_ANSI) { if (usr->flags & USR_BOLD) bufprintf(buf, sizeof(buf), "\x1b[1;%dm%c\x1b[1;%dm", color_table[usr->colors[HOTKEY]].value, c, Ansi_Color(usr, usr->color)); else bufprintf(buf, sizeof(buf), "\x1b[%dm%c\x1b[%dm", color_table[usr->colors[HOTKEY]].value, c, Ansi_Color(usr, usr->color)); (*cpos)++; } else { bufprintf(buf, sizeof(buf), "<%c>", c); *cpos += 3; } put_StringIO(dev, buf); return 5; } if (!cstrnicmp(code, "<beep>", 6)) { if (usr->flags & USR_BEEP) write_StringIO(dev, "\a", 1); return 5; } if (!cstrnicmp(code, "<normal>", 8)) { if (usr->flags & USR_ANSI) { bufprintf(buf, sizeof(buf), "\x1b[0;%dm", color_table[usr->colors[BACKGROUND]].value+10); put_StringIO(dev, buf); } else if (usr->flags & USR_BOLD) put_StringIO(dev, "\x1b[0m"); if (usr->flags & USR_BOLD) put_StringIO(dev, "\x1b[1m"); return 7; } if (!cstrnicmp(code, "<default>", 9)) { if (usr->flags & (USR_ANSI | USR_BOLD)) put_StringIO(dev, "\x1b[0m"); return 8; } if (!cstrnicmp(code, "<lt>", 4)) { if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { auto_color(usr, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } write_StringIO(dev, "<", 1); (*cpos)++; if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { restore_colorbuf(usr, usr->color, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } return 3; } if (!cstrnicmp(code, "<gt>", 4)) { if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { auto_color(usr, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } write_StringIO(dev, ">", 1); (*cpos)++; if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { restore_colorbuf(usr, usr->color, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } return 3; } /* there are two special codes for use in help files and stuff... <hline> and <center> especially the code for hline is cryptic, but the idea is that it fills the line to the width of the terminal */ if (!cstrnicmp(code, "<hline>", 7)) { int l; code += 7; if (!*code) return 6; c = ((usr->display->term_width-1) > PRINT_BUF) ? PRINT_BUF : (usr->display->term_width-1); cstrncpy(buf, code, c); /* it stinks, but you have to remove all chars that can reset the cursor pos */ p = buf; while(*p) { if (*p == KEY_CTRL('X') || *p == '\b') memmove(p, p+1, strlen(p+1)+1); else { if (*p == '\n') { /* don't go over newlines */ *p = 0; break; } p++; } } l = strlen(buf); i = color_strlen(buf); while(*cpos + i < usr->display->term_width-1) Out_text(dev, usr, buf, cpos, lines, max_lines, AUTO_COLOR_FORCED); /* recurse */ if (*cpos + i >= usr->display->term_width-1) { /* 'partial put' of the remainder */ buf[color_index(buf, c - *cpos)] = 0; Out_text(dev, usr, buf, cpos, lines, max_lines, AUTO_COLOR_FORCED); } return 6+l; } if (!cstrnicmp(code, "<center>", 8)) { code += 8; if (!*code) return 7; c = strlen(code); c = (c > PRINT_BUF) ? PRINT_BUF : c; cstrncpy(buf, code, c); buf[c-1] = 0; if ((p = cstrchr(buf, '\n')) != NULL) /* don't go over newlines */ *p = 0; i = (usr->display->term_width-1)/2 - color_strlen(buf)/2 - *cpos; while(i > 0) { write_StringIO(dev, " ", 1); (*cpos)++; i--; } return 7; } if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { auto_color(usr, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } write_StringIO(dev, "<", 1); (*cpos)++; if ((usr->flags & USR_ANSI) && !(usr->flags & USR_DONT_AUTO_COLOR) && !dont_auto_color) { restore_colorbuf(usr, usr->color, colorbuf, MAX_COLORBUF); put_StringIO(dev, colorbuf); } return 0; }
/********************************************************************************* * Constructor - opens rc-input device, selects rc-hardware and starts threads * *********************************************************************************/ CRCInput::CRCInput(bool &_timer_wakeup) { timerid= 1; repeatkeys = NULL; timer_wakeup = &_timer_wakeup; longPressAny = false; // pipe for internal event-queue // ----------------------------- if (pipe(fd_pipe_high_priority) < 0) { perror("fd_pipe_high_priority"); exit(-1); } fcntl(fd_pipe_high_priority[0], F_SETFL, O_NONBLOCK ); fcntl(fd_pipe_high_priority[1], F_SETFL, O_NONBLOCK ); if (pipe(fd_pipe_low_priority) < 0) { perror("fd_pipe_low_priority"); exit(-1); } fcntl(fd_pipe_low_priority[0], F_SETFL, O_NONBLOCK ); fcntl(fd_pipe_low_priority[1], F_SETFL, O_NONBLOCK ); // open event-library // ----------------------------- fd_event = 0; //network-setup struct sockaddr_un servaddr; int clilen; memset(&servaddr, 0, sizeof(struct sockaddr_un)); servaddr.sun_family = AF_UNIX; cstrncpy(servaddr.sun_path, NEUTRINO_UDS_NAME, sizeof(servaddr.sun_path)); clilen = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path); unlink(NEUTRINO_UDS_NAME); //network-setup if ((fd_event = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { perror("[neutrino] socket\n"); } if ( bind(fd_event, (struct sockaddr*) &servaddr, clilen) <0 ) { perror("[neutrino] bind failed...\n"); exit(-1); } if (listen(fd_event, 25) !=0) { perror("[neutrino] listen failed...\n"); exit( -1 ); } for (int i = 0; i < NUMBER_OF_EVENT_DEVICES; i++) { fd_rc[i] = -1; } clickfd = -1; repeat_block = repeat_block_generic = 0; open(); rc_last_key = KEY_MAX; firstKey = true; longPressEnd = 0; //select and setup remote control hardware set_rc_hw(); }
int main (int argc, char** argv) { int i; uint32_t j; //uint32_t k; uint64_t ii; int bouquet = -1; unsigned int channel = 0; unsigned int count; int diseqcRepeats = -1; int diseqcType = -1; uint64_t satmask = 0xFFFF; int audio = 0; int mute = -1; int volume = -1; int nvod = -1; int arat = -1; int m43 = -1; int lockrc = -1; const char * channelName = NULL; bool playback = false; bool recordmode = false; bool radio = false; bool reload = false; bool register_neutrino = false; bool savebouquets = false; bool show_satellites = false; bool set_pal = false; int set_hd = 0; bool scan = false; bool rezap = false; bool zapByName = false; bool killzapit = false; bool enterStandby = false; bool leaveStandby = false; bool sendMotorCommand = false; bool quiet = false; bool getchannel = false; bool aspectratio = false; bool mode43 = false; uint8_t motorCmdType = 0; uint8_t motorCmd = 0; uint8_t motorNumParameters = 0; uint8_t motorParam1 = 0; uint8_t motorParam2 = 0; uint8_t motorAddr = 0; uint32_t diseqc[5]; unsigned int tmp; int scan_mode = 1; t_channel_id zapsid = 0; /* command line */ for (i = 1; i < argc; i++) { if (!strncmp(argv[i], "-a", 2)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &audio); continue; } } else if (!strncmp(argv[i], "-dr", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcRepeats); continue; } } else if (!strncmp(argv[i], "-dt", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &diseqcType); continue; } } else if (!strncmp(argv[i], "-q", 2)) { quiet = true; continue; } else if (!strncmp(argv[i], "-c", 2)) { reload = true; continue; } else if (!strncmp(argv[i], "-esb", 4)) { enterStandby = true; continue; } else if (!strncmp(argv[i], "-kill", 5)) { killzapit = true; continue; } else if (!strncmp(argv[i], "-lsb", 4)) { leaveStandby = true; continue; } else if (!strncmp(argv[i], "-rz", 3)) { rezap = true; continue; } else if (!strncmp(argv[i], "-mute", 5)) { mute = 1; continue; } else if (!strncmp(argv[i], "-m", 2)) { if (i < argc - 6) { sscanf(argv[++i], "%x", &tmp); motorCmdType = tmp; sscanf(argv[++i], "%x", &tmp); motorAddr = tmp; sscanf(argv[++i], "%x", &tmp); motorCmd = tmp; sscanf(argv[++i], "%x", &tmp); motorNumParameters = tmp; sscanf(argv[++i], "%x", &tmp); motorParam1 = tmp; sscanf(argv[++i], "%x", &tmp); motorParam2 = tmp; printf("[pzapit] motor command = %x %x %x %x %x %x\n", motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); sendMotorCommand = true; continue; } } else if (!strncmp(argv[i], "-rn", 3)) { register_neutrino = true; continue; } else if (!strncmp(argv[i], "-nvod", 5)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &nvod); continue; } } else if (!strncmp(argv[i], "-n", 2)) { if (i < argc - 1) { zapByName = true; channelName = argv[++i]; continue; } } else if (!strncmp(argv[i], "-p", 2)) { playback = true; continue; } else if (!strncmp(argv[i], "-ra", 3)) { radio = true; continue; } else if (!strncmp(argv[i], "-re", 3)) { recordmode = true; continue; } else if (!strncmp(argv[i], "-var", 4)) { aspectratio = true; if (i < argc - 1) sscanf(argv[++i], "%d", &arat); continue; } else if (!strncmp(argv[i], "-vm43", 5)) { mode43 = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &m43); continue; } #if 0 //FIXME howto read aspect mode back? continue; #endif } else if (!strncmp(argv[i], "-sb", 3)) { savebouquets = true; continue; } else if (!strncmp(argv[i], "-se", 3)) { if (i < argc - 2) { sscanf(argv[++i], "%" SCNd64 "", &satmask); sscanf(argv[++i], "%d", &diseqc[0]); /* diseqc[0] = strlen(argv[i+1]); for (i++, j = 0; j <= diseqc[0]; j++) { diseqc[j+1] = argv[i][j] - 48; } */ continue; } } else if (!strncmp(argv[i], "-sh", 3)) { show_satellites = true; continue; } else if (!strncmp(argv[i], "-st", 3)) { scan = true; if (i < argc - 1) { sscanf(argv[++i], "%d", &scan_mode); } continue; } else if (!strncmp(argv[i], "--pal", 4)) { set_pal = true; continue; } else if (!strncmp(argv[i], "--1080", 6)) { set_hd = 8; continue; } else if (!strncmp(argv[i], "--1083", 6)) { set_hd = 9; continue; } else if (!strncmp(argv[i], "--1082", 6)) { set_hd = 10; continue; } else if (!strncmp(argv[i], "--720", 5)) { set_hd = 7; continue; } else if (!strncmp(argv[i], "-unmute", 7)) { mute = 0; continue; } else if (!strncmp(argv[i], "-vol", 4)) { if (i < argc - 1) { sscanf(argv[++i], "%d", &volume); continue; } } else if (!strncmp(argv[i], "-gi", 3)) { getchannel = true; continue; } else if (!strncmp(argv[i], "-zi", 3)) { if (i < argc - 1) { sscanf(argv[++i], "%" SCNx64 "", &zapsid); continue; } } else if (!strncmp(argv[i], "-lockrc", 7)) { lockrc = 1; continue; } else if (!strncmp(argv[i], "-unlockrc", 9)) { lockrc = 0; continue; } else if (i < argc - 1) { if ((sscanf(argv[i], "%d", &bouquet) > 0) && (sscanf(argv[++i], "%u", &channel) > 0)) continue; } else if (sscanf(argv[i], "%d", &bouquet) > 0) continue; return usage(argv[0]); } /* create zapit client */ CZapitClient zapit; #if 0 TP_params TP; TP.TP_id = 12345; TP.polarization = 1; TP.feparams.Frequency = 11727000; TP.feparams.u.qpsk.SymbolRate = 27500000; TP.feparams.u.qpsk.FEC_inner = (CodeRate) 3; zapit.scan_TP(TP); exit(0); #endif /* send diseqc 1.2 motor command */ if (sendMotorCommand) { zapit.sendMotorCommand(motorCmdType, motorAddr, motorCmd, motorNumParameters, motorParam1, motorParam2); return 0; } /* kill zapit*/ if (killzapit) { zapit.shutdown(); std::cout << "zapit shot down :)" << std::endl; return 0; } if (enterStandby) { zapit.setStandby(true); return 0; } if (leaveStandby) { zapit.setStandby(false); return 0; } /* audio mute */ if (mute != -1) { std::cout << "mute/unmute" << std::endl; zapit.muteAudio(mute); return 0; } if (volume != -1) { std::cout << "set volume" << std::endl; zapit.setVolume(volume, volume); return 0; } if (lockrc != -1) { zapit.lockRc(lockrc); return 0; } if (rezap) { zapit.Rezap(); return 0; } /* reload services */ if (reload) { std::cout << "reloading channels" << std::endl; zapit.reinitChannels(); return 0; } if (register_neutrino) { #define NEUTRINO_UDS_NAME "/tmp/neutrino.sock" std::cout << "registering neutrino" << std::endl; for (int ic = CZapitClient::FIRST_EVENT_MARKER; ic < CZapitClient::LAST_EVENT_MARKER; ic++) zapit.registerEvent(ic, 222, NEUTRINO_UDS_NAME); return 0; } if (diseqcType != -1) { zapit.setDiseqcType((diseqc_t) diseqcType); if (diseqcRepeats == -1) return 0; } if (diseqcRepeats != -1) { zapit.setDiseqcRepeat(diseqcRepeats); return 0; } if (playback) { if (zapit.isPlayBackActive()) zapit.stopPlayBack(); else zapit.startPlayBack(); if (!recordmode) return 0; } if (recordmode) { zapit.setRecordMode(!zapit.isRecordModeActive()); return 0; } if (aspectratio) { if(arat >= 0) zapit.setAspectRatio(arat); else { zapit.getAspectRatio(&arat); printf("%d\n", arat); } return 0; } if (mode43) { if(m43 >= 0) zapit.setMode43(m43); else { zapit.getMode43(&m43); printf("%d\n",m43); } return 0; } if (savebouquets) { zapit.saveBouquets(); return 0; } if (show_satellites) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::responseGetSatelliteList>::const_iterator rI; for ( ii = 0, rI = satelliteList.begin(); rI != satelliteList.end(); ii++, rI++) printf("%" PRId64 " : %s %d\n", ii, rI->satName, rI->satPosition); //std::cout << (1 << ii) << ": " << rI->satName << std::endl; return 0; } else if (satmask != 0xFFFF) { std::vector<CZapitClient::responseGetSatelliteList> satelliteList; zapit.getScanSatelliteList(satelliteList); std::vector<CZapitClient::commandSetScanSatelliteList> newSatelliteList; CZapitClient::commandSetScanSatelliteList item; for (j = 0; j < satelliteList.size(); j++) { if (satmask == j) { std::cout << "diseqc " << diseqc[0] << ": " << satelliteList[j].satName << std::endl; cstrncpy(item.satName, satelliteList[j].satName, sizeof(item.satName) - 1); item.position = diseqc[0]; newSatelliteList.push_back(item); break; } } zapit.setScanSatelliteList(newSatelliteList); return 0; } /* transponderscan */ if (scan) { unsigned int satellite; unsigned int processed_transponder; unsigned int transponder; unsigned int services; printf("Start scan, mode %d\n", scan_mode); zapit.startScan(scan_mode); while (zapit.isScanReady(satellite, processed_transponder, transponder, services) == false) { std::cout << "satellite: " << satellite << ", transponder: " << processed_transponder <<", of: " << transponder << ", services: " << services << std::endl; sleep(1); } return 0; } if (set_pal) { //zapit.stopPlayBack(); zapit.setVideoSystem(2); //zapit.startPlayBack(); return 0; } if (set_hd) { //zapit.stopPlayBack(); zapit.setVideoSystem(set_hd); //zapit.startPlayBack(); return 0; } if (getchannel) { t_channel_id channelid = zapit.getCurrentServiceID(); printf("%" PRIx64 " (%s)\n", channelid, (zapit.getChannelName(channelid)).c_str()); return 0; } /* choose source mode */ zapit.setMode(radio ? CZapitClient::MODE_RADIO : CZapitClient::MODE_TV); if (zapsid > 0) { printf("Zapping to: %" PRIx64 " (%s) ", zapsid, (zapit.getChannelName(zapsid)).c_str()); tmp = zapit.zapTo_serviceID(zapsid); if (!tmp) printf("failed"); printf("\n"); return tmp; } /* set audio channel */ if (audio) { zapit.setAudioChannel(audio - 1); return 0; } if (nvod != -1) { zapit.zaptoNvodSubService(nvod); return 0; } else { std::vector<CZapitClient::responseGetBouquetChannels> channels; if (zapByName) { zapit.getChannels(channels); std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, ++channel) { if (!strcasecmp(ch_resp->name, channelName)) { std::cout << "found channel number: " << channel << std::endl; goto channel_found; } } std::cout << "channel not found." << std::endl; return 0; } else /* zap by bouquet number and channel number */ { /* read channel list */ if (bouquet != -1) zapit.getBouquetChannels(bouquet - 1, channels, CZapitClient::MODE_CURRENT, true); /* display bouquet list */ else { std::vector<CZapitClient::responseGetBouquets> bouquets; std::vector<CZapitClient::responseGetBouquets>::const_iterator b_resp; zapit.getBouquets(bouquets, false); for (b_resp = bouquets.begin(); b_resp != bouquets.end(); ++b_resp) std::cout << (b_resp->bouquet_nr + 1) << ": " << b_resp->name << std::endl; return 0; } /* display channel list */ if (!channel) { std::vector<CZapitClient::responseGetBouquetChannels>::const_iterator ch_resp; for (ch_resp = channels.begin(), channel = 1; ch_resp != channels.end(); ch_resp++, ++channel) //std::cout << channel << ": " << ch_resp->name << ": " << ch_resp->channel_id<< std::endl; printf("%3d: %s (%04x)\n", channel, ch_resp->name, (short) (ch_resp->channel_id &0xFFFF)); return 0; } } /* zap */ if (channel > channels.size()) { std::cout << "Only " << channels.size() << " channels in bouquet " << bouquet << std::endl; return 0; } channel_found: zapit.zapTo(channels[channel-1].nr); std::cout << "zapped to " << channels[channel-1].name << std::endl; } if (!quiet) { CZapitClient::responseGetPIDs pids; zapit.getPIDS(pids); if (pids.PIDs.vpid) std::cout << " video: 0x" << std::hex << pids.PIDs.vpid << std::endl; if (pids.PIDs.vtxtpid) std::cout << "teletext: 0x" << std::hex << pids.PIDs.vtxtpid << std::endl; if (pids.PIDs.pcrpid) std::cout << " pcr: 0x" << std::hex << pids.PIDs.pcrpid << std::endl; for (count = 0; count < pids.APIDs.size(); count++) { std::cout << " audio " << std::dec << count + 1 << ": 0x" << std::hex << pids.APIDs[count].pid << " (" << pids.APIDs[count].desc; if (pids.APIDs[count].is_ac3) std::cout << ", ac3"; else if (pids.APIDs[count].is_aac) std::cout << ", aac"; else std::cout << ", unknown"; std::cout << ")" << std::endl; } } return 0; }
int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) { const char * key = actionKey.c_str(); if (strcmp(key, "modifytimer") == 0) { timerlist[selected].announceTime = timerlist[selected].alarmTime -60; if (timerlist[selected].eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS) Timer->getWeekdaysFromStr(&timerlist[selected].eventRepeat, m_weekdaysStr); if (timerlist[selected].eventType == CTimerd::TIMER_RECORD) { timerlist[selected].announceTime -= 120; // 2 more mins for rec timer if (timer_apids_dflt) timerlist[selected].apids = TIMERD_APIDS_CONF; else timerlist[selected].apids = (unsigned char)((timer_apids_std * TIMERD_APIDS_STD) | (timer_apids_ac3 * TIMERD_APIDS_AC3) | (timer_apids_alt * TIMERD_APIDS_ALT)); Timer->modifyTimerAPid(timerlist[selected].eventID,timerlist[selected].apids); Timer->modifyRecordTimerEvent(timerlist[selected].eventID, timerlist[selected].announceTime, timerlist[selected].alarmTime, timerlist[selected].stopTime, timerlist[selected].eventRepeat, timerlist[selected].repeatCount,timerlist[selected].recordingDir); } else { Timer->modifyTimerEvent(timerlist[selected].eventID, timerlist[selected].announceTime, timerlist[selected].alarmTime, timerlist[selected].stopTime, timerlist[selected].eventRepeat, timerlist[selected].repeatCount); } return menu_return::RETURN_EXIT; } else if (strcmp(key, "newtimer") == 0) { timerNew.announceTime=timerNew.alarmTime-60; CTimerd::EventInfo eventinfo; CTimerd::RecordingInfo recinfo; eventinfo.epgID=0; eventinfo.epg_starttime=0; eventinfo.channel_id=timerNew.channel_id; eventinfo.apids = TIMERD_APIDS_CONF; eventinfo.recordingSafety = false; eventinfo.autoAdjustToEPG = false; timerNew.standby_on = (timerNew_standby_on == 1); void *data=NULL; if (timerNew.eventType == CTimerd::TIMER_STANDBY) data=&(timerNew.standby_on); /* else if (timerNew.eventType==CTimerd::TIMER_NEXTPROGRAM || */ else if (timerNew.eventType == CTimerd::TIMER_ZAPTO || timerNew.eventType == CTimerd::TIMER_RECORD) { if (timerNew_channel_name == "---") return menu_return::RETURN_REPAINT; if (timerNew.eventType==CTimerd::TIMER_RECORD) { recinfo.epgID=0; recinfo.epg_starttime=0; recinfo.channel_id=timerNew.channel_id; recinfo.apids=TIMERD_APIDS_CONF; recinfo.recordingSafety = false; recinfo.autoAdjustToEPG = false; // FIXME -- add GUI option? timerNew.announceTime-= 120; // 2 more mins for rec timer cstrncpy(recinfo.recordingDir,timerNew.recordingDir,sizeof(recinfo.recordingDir)); data = &recinfo; } else data= &eventinfo; } else if (timerNew.eventType==CTimerd::TIMER_REMIND) data= timerNew.message; else if (timerNew.eventType==CTimerd::TIMER_EXEC_PLUGIN) { if (timerNew_pluginName == "---") return menu_return::RETURN_REPAINT; data = (void*)timerNew_pluginName.c_str(); } if (timerNew.eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS) Timer->getWeekdaysFromStr(&timerNew.eventRepeat, m_weekdaysStr); if (Timer->addTimerEvent(timerNew.eventType,data,timerNew.announceTime,timerNew.alarmTime, timerNew.stopTime,timerNew.eventRepeat,timerNew.repeatCount,false) == -1) { bool forceAdd = askUserOnTimerConflict(timerNew.announceTime,timerNew.stopTime); if (forceAdd) { Timer->addTimerEvent(timerNew.eventType,data,timerNew.announceTime,timerNew.alarmTime, timerNew.stopTime, timerNew.eventRepeat,timerNew.repeatCount,true); } } return menu_return::RETURN_EXIT; } else if (strncmp(key, "SC:", 3) == 0) { int delta; sscanf(&(key[3]), SCANF_CHANNEL_ID_TYPE "%n", &timerNew.channel_id, &delta); timerNew_channel_name = std::string(key + 3 + delta + 1); g_RCInput->postMsg(CRCInput::RC_timeout, 0); // leave underlying menu also g_RCInput->postMsg(CRCInput::RC_timeout, 0); // leave underlying menu also return menu_return::RETURN_EXIT; } else if(actionKey == "rec_dir1") { parent->hide(); const char *action_str = "RecDir1"; std::string tmp(timerlist[selected].recordingDir); if(chooserDir(tmp, true, action_str)) { cstrncpy(timerlist[selected].recordingDir, tmp, sizeof(timerlist[selected].recordingDir)); printf("[timerlist] new %s dir %s\n", action_str, timerlist[selected].recordingDir); } return menu_return::RETURN_REPAINT; } else if(actionKey == "rec_dir2") { parent->hide(); const char *action_str = "RecDir2"; std::string tmp(timerNew.recordingDir); if(chooserDir(tmp, true, action_str)-1) { cstrncpy(timerNew.recordingDir, tmp, sizeof(timerNew.recordingDir)); printf("[timerlist] new %s dir %s\n", action_str, timerNew.recordingDir); } return menu_return::RETURN_REPAINT; } if (parent) { parent->hide(); } saved_dispmode = (int)CVFD::getInstance()->getMode(); int ret = show(); CVFD::getInstance()->setMode((CVFD::MODES)saved_dispmode); return ret; /* if( ret > -1) { return menu_return::RETURN_REPAINT; } else if( ret == -1) { // -1 bedeutet nur REPAINT return menu_return::RETURN_REPAINT; } else { // -2 bedeutet EXIT_ALL return menu_return::RETURN_EXIT_ALL; }*/ }