void MainObject::gpoStateData(int matrix,unsigned line,bool state) { // LogLine(RDConfig::LogWarning,QString().sprintf("gpoStateData(%d,%d,%d)",matrix,line,state)); BroadcastCommand(QString().sprintf("GO %d %u %d %d!",matrix,line,state, ripcd_gpo_mask[matrix][line])); }
void MainObject::ReadRmlSocket(QSocketDevice *dev,RDMacro::Role role, bool echo) { char buffer[RD_RML_MAX_LENGTH]; char cmd[RD_RML_MAX_LENGTH+4]; QString output; int n; QHostAddress peer_addr; RDMacro macro; while((n=dev->readBlock(buffer,RD_RML_MAX_LENGTH))>0) { buffer[n]=0; if(macro.parseString(buffer,n)) { macro.setRole(role); macro.setAddress(dev->peerAddress()); macro.setEchoRequested(echo); macro.generateString(buffer,RD_RML_MAX_LENGTH); switch(role) { case RDMacro::Cmd: sprintf(cmd,"MS %s %d %s",(const char *)macro.address().toString(), echo,buffer); RunLocalMacros(¯o); BroadcastCommand(cmd); break; case RDMacro::Reply: sprintf(cmd,"ME %s %d %s",(const char *)macro.address().toString(), echo,buffer); break; default: break; } } else { LogLine(RDConfig::LogWarning, QString().sprintf("received malformed rml: \"%s\" from %s:%u", buffer, (const char *)dev->peerAddress().toString(), dev->peerPort())); if(echo) { macro.setRole(RDMacro::Reply); macro.setCommand(RDMacro::NN); macro.setArg(0,"-"); macro.setArgQuantity(1); macro.setAddress(dev->peerAddress()); sendRml(¯o); } } } }
void MainObject::gpoChangedData(int matrix,int line,bool state) { if(state) { LogLine(RDConfig::LogInfo,QString().sprintf("GPO %d:%d ON",matrix,line+1)); } else { LogLine(RDConfig::LogInfo,QString().sprintf("GPO %d:%d OFF",matrix,line+1)); } ripcd_gpo_state[matrix][line]=state; BroadcastCommand(QString().sprintf("GO %d %d %d %d!",matrix,line,state, ripcd_gpo_mask[matrix][line])); if(!ripcd_gpo_mask[matrix][line]) { return; } if(ripcd_gpo_macro[matrix][line][state]>0) { ExecCart(ripcd_gpo_macro[matrix][line][state]); } }
void MainObject::DispatchCommand(int ch) { QString default_name; char str[RD_RML_MAX_LENGTH]; RDMacro macro; char buffer[RD_RML_MAX_LENGTH]; char cmd[RD_RML_MAX_LENGTH+4]; int echo=0; QHostAddress addr; // // Common Commands // Authentication not required to execute these! // if(!strcmp(args[ch][0],"DC")) { // Drop Connection socket[ch]->close(); KillSocket(ch); return; } if(!strcmp(args[ch][0],"PW")) { // Password Authenticate if(!strcmp(args[ch][1],ripcd_config->password())) { auth[ch]=true; EchoCommand(ch,"PW +!"); return; } else { auth[ch]=false; EchoCommand(ch,"PW -!"); return; } } // // Priviledged Commands // Authentication required to execute these! // if(!auth[ch]) { EchoArgs(ch,'-'); return; } if(!strcmp(args[ch][0],"RU")) { // Request User EchoCommand(ch,(const char *)QString(). sprintf("RU %s!",(const char *)rdstation->userName())); return; } if(!strcmp(args[ch][0],"SU")) { // Set User SetUser(args[ch][1]); } if(!strcmp(args[ch][0],"MS")) { // Send RML Command if(argnum[ch]<4) { return; } strcpy(str,args[ch][3]); for(int i=4;i<argnum[ch];i++) { strcat(str," "); strcat(str,args[ch][i]); } strcat(str,"!"); } if(macro.parseString(str,strlen(str))) { addr.setAddress(args[ch][1]); macro.setAddress(addr); macro.setRole(RDMacro::Cmd); /* char temp[RD_RML_MAX_LENGTH]; macro.generateString(temp,RD_RML_MAX_LENGTH); LogLine(QString().sprintf("RECEIVED: %s ADDR: %s\n",temp,(const char *)macro.address().toString())); */ if(!macro.address().isNull()) { if(macro.address()==rdstation->address()) { // Local Loopback macro.generateString(buffer,RD_RML_MAX_LENGTH); if(macro.echoRequested()) { echo=1; } sprintf(cmd,"MS %s %d %s",(const char *)macro.address().toString(), echo,buffer); RunLocalMacros(¯o); BroadcastCommand(cmd); } else { sendRml(¯o); } } } if(!strcmp(args[ch][0],"ME")) { // Send RML Reply if(argnum[ch]<4) { return; } strcpy(str,args[ch][3]); for(int i=4;i<argnum[ch];i++) { strcat(str," "); strcat(str,args[ch][i]); } strcat(str,"!"); } if(macro.parseString(str,strlen(str))) { QHostAddress addr; addr.setAddress(args[ch][1]); macro.setAddress(addr); macro.setRole(RDMacro::Reply); if(macro.address()==rdstation->address()) { // Local Loopback macro.generateString(buffer,RD_RML_MAX_LENGTH); sprintf(cmd,"ME %s 0 %s",(const char *)macro.address().toString(), buffer); BroadcastCommand(cmd); } else { sendRml(¯o); } } if(!strcmp(args[ch][0],"RG")) { // Reload the GPI Table LoadGpiTable(); } if(!strcmp(args[ch][0],"GI")) { // Send Complete GPI Status int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpi(ch,matrix); } if(!strcmp(args[ch][0],"GO")) { // Send Complete GPO Status int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpo(ch,matrix); } if(!strcmp(args[ch][0],"GM")) { // Send Complete GPI Mask States int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpiMask(ch,matrix); } if(!strcmp(args[ch][0],"GN")) { // Send Complete GPI Mask States int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpoMask(ch,matrix); } if(!strcmp(args[ch][0],"GC")) { // Send Complete GPI Cart Assignments int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpiCart(ch,matrix); } if(!strcmp(args[ch][0],"GD")) { // Send Complete GPO Cart Assignments int matrix; sscanf(args[ch][1],"%d",&matrix); SendGpoCart(ch,matrix); } if(!strcmp(args[ch][0],"TA")) { // Send Onair Flag State EchoCommand(ch,QString().sprintf("TA %d!",ripc_onair_flag)); } }
void MainObject::SetUser(QString username) { rdstation->setUserName(username); BroadcastCommand(QString().sprintf("RU %s!",(const char *)username)); }
static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static activePage = 0; switch (msg) { /* init */ case WM_INITDIALOG: { LOCALDATA *data = LocalAlloc(LPTR, sizeof(LOCALDATA)); HINSTANCE inst = (HINSTANCE)lParam; TCITEM item; /* init */ SetWindowLong(hwnd, GWL_USERDATA, (LONG)data); data->htab = GetDlgItem(hwnd, IDC_TABS); data->hdlg = NULL; /* add pages */ item.mask = TCIF_TEXT; data->all[0] = CreateDialog(inst, MAKEINTRESOURCE(IDD_CONFIG_GENERAL), hwnd, GeneralProc); item.pszText = "General"; TabCtrl_InsertItem(data->htab, 0, &item); data->all[1] = CreateDialog(inst, MAKEINTRESOURCE(IDD_CONFIG_OUTPUT), hwnd, OutputProc); item.pszText = "Output"; TabCtrl_InsertItem(data->htab, 1, &item); /* get rect (after adding pages) */ GetWindowRect(data->htab, &data->r); ScreenToClientRect(hwnd, &data->r); TabCtrl_AdjustRect(data->htab, 0, &data->r); /* simulate item change */ TabCtrl_SetCurSel(data->htab, activePage); OnSelChange(hwnd); } return TRUE; /* destory */ case WM_DESTROY: { LOCALDATA *data = (LOCALDATA*)GetWindowLong(hwnd, GWL_USERDATA); int i; activePage = TabCtrl_GetCurSel(data->htab); for (i=0; i<NUM_PAGES; i++) DestroyWindow(data->all[i]); LocalFree(data); } break; /* commands */ case WM_COMMAND: switch (LOWORD(wParam)) { /* ok/cancel */ case IDOK: BroadcastCommand(hwnd, IDOK); /* fall through */ case IDCANCEL: EndDialog(hwnd, LOWORD(wParam)); return TRUE; case IDC_RESET: SendCommand(hwnd, IDC_RESET); break; } break; /* notification */ case WM_NOTIFY: if (LOWORD(wParam) == IDC_TABS) { NMHDR *hdr = (NMHDR*)lParam; switch (hdr->code) { case TCN_SELCHANGE: OnSelChange(hwnd); break; } } break; } return 0; }