sBool sButtonControl::OnCommand(sInt cmd) { switch(cmd) { case sCMD_TRIGGER: if(!(Style&sBCS_STATIC)) { if(RadioPtr) { if(Style & sBCS_RADIO) *RadioPtr = RadioValue; else if(Style & sBCS_TOGGLE) *RadioPtr = !*RadioPtr; else if(Style & sBCS_TOGGLEBIT) *RadioPtr = *RadioPtr ^ RadioValue; sGui->Notify(RadioPtr,sizeof(sInt)); // Parent->Update(); } SendChange(); SendDone(); } break; case sCMD_ENTERHOVER: case sCMD_LEAVEHOVER: case sCMD_ENTERFOCUS: case sCMD_LEAVEFOCUS: Update(); break; } return 0; }
mozilla::ipc::IPCResult TestRacyUndeferChild::RecvStart() { if (!CallSpam()) fail("calling Spam"); if (!SendDone()) fail("sending Done"); return IPC_OK(); }
void SendData(int *abc, int len) { while (len) { xil_printf("Data is %d\n\r", *abc); abc++; len--; } SendDone(); return; }
bool TestRacyUndeferChild::RecvStart() { if (!CallSpam()) fail("calling Spam"); if (!SendDone()) fail("sending Done"); return true; }
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ), nus ( this ), nand ( this ) { ui->setupUi(this); nandInited = false; root = NULL; uidDirty = false; sharedDirty = false; nandDirty = false; ui->mainToolBar->setVisible( false );//hide toolbar for now //resize buttons to be same size QFontMetrics fm( fontMetrics() ); int max = fm.width( ui->pushButton_CachePathBrowse->text() ); max = MAX( max, fm.width( ui->pushButton_GetTitle->text() ) ); max = MAX( max, fm.width( ui->pushButton_initNand->text() ) ); max = MAX( max, fm.width( ui->pushButton_nandPath->text() ) ); max += 20; ui->pushButton_CachePathBrowse->setFixedWidth( max ); ui->pushButton_GetTitle->setFixedWidth( max ); ui->pushButton_initNand->setFixedWidth( max ); ui->pushButton_nandPath->setFixedWidth( max ); Wad::SetGlobalCert( QByteArray( (const char*)&certs_dat, CERTS_DAT_SIZE ) ); //connect to the nus object so we can respond to what it is saying with pretty stuff in the gui connect( &nus, SIGNAL( SendDownloadProgress( int ) ), ui->progressBar_dl, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTitleProgress( int ) ), ui->progressBar_title, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendTotalProgress( int ) ), ui->progressBar_whole, SLOT( setValue( int ) ) ); connect( &nus, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) ); connect( &nus, SIGNAL( SendError( const QString &, const NusJob & ) ), this, SLOT( GetError( const QString &, const NusJob & ) ) ); connect( &nus, SIGNAL( SendDone() ), this, SLOT( NusIsDone() ) ); connect( &nus, SIGNAL( SendData( const NusJob & ) ), this, SLOT( ReceiveTitleFromNus( const NusJob & ) ) ); //connect to the nand.bin to get text and crap from it connect( &nand, SIGNAL( SendError( const QString & ) ), this, SLOT( GetError( const QString & ) ) ); connect( &nand, SIGNAL( SendText( QString ) ), ui->statusBar, SLOT( showMessage( QString ) ) ); LoadSettings(); QStringList args = QCoreApplication::arguments(); if( args.size() > 1 && QFileInfo( args.at( 1 ) ).exists() ) { ui->lineEdit_nandPath->setText( args.at( 1 ) ); InitNand( args.at( 1 ) ); } else { ui->lineEdit_nandPath->setText( "./testNand.bin" ); } }
void SleepModeCommand(int client) { int error; char *name; int np, ip, ngot; int value, selection; // // prepare beginning of error message in case we need to use it // error=0; // //parse arguments and do it // np=CommandParameterMany(); for(ip=0; ip<np; ip++) { name=CommandParameterName(ip); if (strlen(name)==0) continue; // sometime there are tab or space at the end count as np with name as "", skip it selection=ParameterSelect(name,SleepModeParameter,sizeof(SleepModeParameter)/sizeof(SleepModeParameter[0])); switch(selection) { case SleepMode: ngot=SformatInput(CommandParameterValue(ip,0)," %d ",&value); if(ngot != 1 || (value < SleepModeMin || value > SleepModeMax)) { ErrorPrint(ParseBadValue, CommandParameterValue(value, 0),"mode"); error++; } break; default: break; } } if (error == 0) { if (CurrentSleepMode == value) { UserPrint("The device is currently in %s mode.\n", (value == SLEEP_MODE_SLEEP ? "sleep" : (value == SLEEP_MODE_WAKEUP ? "wakeup" : "deep sleep"))); } else { SendOn(client); DeviceSleepMode(value); SendOff(client); CurrentSleepMode = value; } } SendDone(client); }
mozilla::ipc::IPCResult TestCancelChild::RecvTest3_1() { if (SendTest3_2()) fail("sending Test3_2"); uint32_t value = 0; if (!SendCheckParent(&value)) fail("Test1 CheckParent"); if (value != 12) fail("Test1 CheckParent reply"); if (!SendDone()) fail("sending Done"); return IPC_OK(); }
bool NotifyCmd::Stage2() { HiddenWorld *hw = mWorld->hw; if (mOnOff) { for (uint32 i=0; i<hw->mNumUsers; ++i) { if (mReplyAddress == hw->mUsers[i]) { // already in table - don't fail though.. SendFailureWithIntValue(&mReplyAddress, "/notify", "notify: already registered\n", hw->mClientIDdict->at(mReplyAddress)); scprintf("/notify : already registered\n"); return false; } } // add reply address to user table if (hw->mNumUsers >= hw->mMaxUsers) { SendFailure(&mReplyAddress, "/notify", "too many users\n"); scprintf("too many users\n"); return false; } uint32 clientID = hw->mClientIDs[hw->mClientIDTop++]; // pop an ID hw->mClientIDdict->insert(std::pair<ReplyAddress, uint32>(mReplyAddress,clientID)); hw->mUsers[hw->mNumUsers++] = mReplyAddress; SendDoneWithIntValue("/notify", clientID); } else { for (uint32 i=0; i<hw->mNumUsers; ++i) { if (mReplyAddress == hw->mUsers[i]) { // remove from list hw->mClientIDs[--hw->mClientIDTop] = hw->mClientIDdict->at(mReplyAddress); // push the freed ID hw->mClientIDdict->erase(mReplyAddress); hw->mUsers[i] = hw->mUsers[--hw->mNumUsers]; SendDone("/notify"); return false; } } SendFailure(&mReplyAddress, "/notify", "not registered\n"); scprintf("not registered\n"); } return false; }
bool TestManyChildAllocsChild::RecvGo() { for (int i = 0; i < NALLOCS; ++i) { PTestManyChildAllocsSubChild* child = SendPTestManyChildAllocsSubConstructor(); if (!child) fail("can't send ctor()"); if (!child->SendHello()) fail("can't send Hello()"); } size_t len = ManagedPTestManyChildAllocsSubChild().Length(); if (NALLOCS != len) fail("expected %lu kids, got %lu", NALLOCS, len); if (!SendDone()) fail("can't send Done()"); return true; }
void NoiseFloorCommand(int client) { int nfc[MCHAIN],nfe[MCHAIN]; int ip, np; int error; int attempt; int margin; int index; int code; int timeout; int ngot; int nf[2*MCHAIN]; int nfmany; char buffer[MBUFFER]; char *name; int frequency; int ht40; int rxchain; int reset; int bandwidth; // // prepare beginning of error message in case we need to use it // error=0; timeout= 100; nfmany=1; nf[0]=-110; margin=MERROR; attempt=MATTEMPT; frequency= -1; ht40=2; bandwidth=BW_AUTOMATIC; rxchain=0x7; reset=0; // // parse arguments and do it // np=CommandParameterMany(); for(ip=0; ip<np; ip++) { name=CommandParameterName(ip); index=ParameterSelectIndex(name,NoiseFloorParameter,sizeof(NoiseFloorParameter)/sizeof(NoiseFloorParameter[0])); if(index>=0) { code=NoiseFloorParameter[index].code; switch(code) { case LinkParameterFrequency: ngot=ParseIntegerList(ip,name,&frequency,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case LinkParameterHt40: ngot=ParseIntegerList(ip,name,&ht40,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } else { switch(ht40){ case 0: bandwidth=BW_HT20; break; case 1: bandwidth=BW_HT40_PLUS; break; case -1: bandwidth=BW_HT40_MINUS; break; case 2: bandwidth=BW_AUTOMATIC; break; default: error++; break; } } break; case LinkParameterChain: case LinkParameterRxChain: ngot=ParseIntegerList(ip,name,&rxchain,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case LinkParameterReset: ngot=ParseIntegerList(ip,name,&reset,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; case NoiseFloorValue: nfmany=ParseInteger(ip,name,2*MCHAIN,nf); if(nfmany<=0) { error++; } break; case NoiseFloorTimeout: ngot=ParseInteger(ip,name,1,&timeout); if(ngot<=0) { error++; } break; case NoiseFloorMargin: ngot=ParseInteger(ip,name,1,&margin); if(ngot<=0) { error++; } break; case NoiseFloorAttempt: ngot=ParseInteger(ip,name,1,&attempt); if(ngot<=0) { error++; } break; case LinkParameterBandwidth: ngot=ParseIntegerList(ip,name,&bandwidth,&NoiseFloorParameter[index]); if(ngot<=0) { error++; } break; default: ErrorPrint(ParseBadParameter,name); error++; break; } } else { error++; ErrorPrint(ParseBadParameter,name); } } if(nfmany<=0) { SendError(client,"target noise floor value is required."); error++; } if(reset) { if(frequency<=0) { SendError(client,"frequency is required."); error++; } } if(attempt>0 && (attempt%2)==0) { attempt++; } // // do it // if(error==0) { // // if there's no card loaded, return error // if(CardCheckAndLoad(-1)!=0) { ErrorPrint(CardNoneLoaded); return; } if(frequency>0) { error=CardResetIfNeeded(frequency,rxchain,rxchain,reset,bandwidth); if(error!=0) { return; } } error=NoiseFloorDo(frequency,nf,nfmany,margin,attempt,timeout,0,nfc,nfe,MCHAIN); if(error!=0) { SformatOutput(buffer,MBUFFER-1,"Noise Floor Calibration error = %d",error); buffer[MBUFFER-1]=0; SendError(client,buffer); } } SendDone(client); }
void AsyncPlugInCmd::Stage4() { bool result = !mStage4 || (mStage4)(mWorld, mCmdData); if (result && mCmdName && mReplyAddress.mReplyFunc != null_reply_func) SendDone((char*)mCmdName); }
void LoadSynthDefDirCmd::Stage4() { SendDone("/d_loadDir"); }
void RecvSynthDefCmd::Stage4() { SendDone("/d_recv"); }
void AudioQuitCmd::Stage4() { SendDone("/quit"); mWorld->hw->mQuitProgram->post(); }
// // interpolates into the stored data structure and returns the value that will be used // void TargetPowerGetCommand(int client) { int np, ip; char *name; char buffer[MBUFFER]; int error; int parseStatus=0, nc=0, lc=0; int index; int code; int it, nfrequency, frequency[MLOOP]; int ir, nrate, rate[MRATE], nvrate, vrate[MRATE]; double tp; int rlegacy,rht20,rht40,rerror,ngot,extra; int nvalue; // // install default parameter values // error=0; // // a bunch of frequencies // nfrequency=1; frequency[0]= 2412; // // all rates // nrate=1; rate[0]=RATE_INDEX_6; // // parse arguments and do it // np=CommandParameterMany(); for(ip=0; ip<np; ip++) { name=CommandParameterName(ip); index=ParameterSelectIndex(name,TargetPowerParameter,sizeof(TargetPowerParameter)/sizeof(TargetPowerParameter[0])); if(index>=0) { code=TargetPowerParameter[index].code; switch(code) { case LinkParameterFrequency: nfrequency=ParseIntegerList(ip,name,frequency,&TargetPowerParameter[index]); if(nfrequency<=0) { error++; } break; case LinkParameterRate: nvalue=CommandParameterValueMany(ip); // // check if it might be the old mask codes // rerror=1; if(nvalue==3) { rerror=0; rlegacy=0; rht20=0; rht40=0; ngot=SformatInput(CommandParameterValue(ip,0)," %x %1c",&rlegacy,&extra); if(ngot!=1) { rerror++; } if(nvalue>=2) { ngot=SformatInput(CommandParameterValue(ip,1)," %x %1c",&rht20,&extra); if(ngot!=1) { rerror++; } } if(nvalue>=3) { ngot=SformatInput(CommandParameterValue(ip,2)," %x %1c",&rht40,&extra); if(ngot!=1) { rerror++; } } if(rerror<=0) { nrate=RateCount(rlegacy,rht20,rht40,rate); UserPrint("Note: Please use rate names as possible. Rate masks will be obsolete in the future.\n"); } } if(rerror!=0) { nrate=ParseIntegerList(ip,name,rate,&TargetPowerParameter[index]); if(nrate<=0) { error++; } else { nrate=RateExpand(rate,nrate); nrate=vRateExpand(rate,nrate); } } break; default: ErrorPrint(ParseBadParameter,name); error++; break; } } else { error++; ErrorPrint(ParseBadParameter,name); } } if(error<=0) { // // check if card is loaded // if(!CardValid()) { ErrorPrint(CardNoneLoaded); } else { ErrorPrint(NartDataHeader,"|tp|frequency|rate||target|"); for(it=0; it<nfrequency; it++) { for(ir=0; ir<nrate; ir++) { DeviceTargetPowerGet(frequency[it],rate[ir],&tp); if (IS_vRate(rate[ir])) SformatOutput(buffer,MBUFFER-1,"|tp|%d|%s||%.1lf|",frequency[it],vRateStrAll[rate[ir]-numRateCodes],tp); else SformatOutput(buffer,MBUFFER-1,"|tp|%d|%s||%.1lf|",frequency[it],rateStrAll[rate[ir]],tp); buffer[MBUFFER-1]=0; ErrorPrint(NartData,buffer); } } } } SendDone(client); }
// // interpolates into the stored data structure and returns the value that will be used // void NoiseFloorGetCommand(int client) { int np, ip; char *name; char buffer[MBUFFER]; int error; int index; int code; int it, nfrequency, frequency[MLOOP]; int nchain, chain; int nf, nfp; int ich; // // prepare beginning of error message in case we need to use it // error=0; nfrequency=1; frequency[0]= 2412; nchain=1; chain= 0x7; // // parse arguments and do it // np=CommandParameterMany(); for(ip=0; ip<np; ip++) { name=CommandParameterName(ip); index=ParameterSelectIndex(name,NoiseFloorGetParameter,sizeof(NoiseFloorGetParameter)/sizeof(NoiseFloorGetParameter[0])); if(index>=0) { code=NoiseFloorGetParameter[index].code; switch(code) { case LinkParameterFrequency: nfrequency=ParseIntegerList(ip,name,frequency,&NoiseFloorGetParameter[index]); if(nfrequency<=0) { error++; } break; case LinkParameterChain: nchain=ParseHexList(ip,name,&chain,&NoiseFloorGetParameter[index]); if(nchain<=0) { error++; } break; default: ErrorPrint(ParseBadParameter,name); error++; break; } } else { error++; ErrorPrint(ParseBadParameter,name); } } if(error<=0) { // // check if card is loaded // if(!CardValid()) { ErrorPrint(CardNoneLoaded); } else { ErrorPrint(NartDataHeader,"|nfg|frequency|chain||nf|nfp|"); for(it=0; it<nfrequency; it++) { for(ich=0; ich<3; ich++) { if((1<<ich)&chain) { nf=DeviceNoiseFloorGet(frequency[it], ich); nfp=DeviceNoiseFloorPowerGet(frequency[it], ich); SformatOutput(buffer,MBUFFER-1,"|nfg|%d|%x||%d|%d|",frequency[it],1<<ich,nf,nfp); buffer[MBUFFER-1]=0; ErrorPrint(NartData,buffer); } } } } } SendDone(client); }
MojErr SmtpSendMailCommand::HandleResponse(const std::string& line) { try { switch (m_write_state) { case State_SendMailFrom: { MojLogInfo(m_log, "MAIL FROM command response"); if (m_status == Status_Ok) { MojLogInfo(m_log, "MAIL FROM command +OK"); m_toIdx = 0; if(m_toIdx < m_toAddress.size()) { m_write_state = State_SendRcptTo; } else { m_error.errorCode = MailError::BAD_RECIPIENTS; // Error out if for some reason there is no recipient. m_error.errorOnEmail = true; m_error.errorOnAccount = false; m_error.internalError = "Error setting forward address"; m_write_state = State_SendErrorRset; } WriteEmail(); } else { MojLogInfo(m_log, "MAIL FROM command -ERR"); m_error = GetStandardError(); m_error.internalError = "Error setting reverse address"; m_write_state = State_SendErrorRset; WriteEmail(); } break; } case State_SendRcptTo: { MojLogInfo(m_log, "RCPT TO command response"); if (m_status == Status_Ok) { m_toIdx++; if (m_toIdx < m_toAddress.size()) { MojLogInfo(m_log, "RCPT TO command +OK, more to come"); m_write_state = State_SendRcptTo; } else { MojLogInfo(m_log, "RCPT TO command +OK, done"); m_write_state = State_SendData; } WriteEmail(); } else { MojLogInfo(m_log, "RCPT TO command -ERR"); m_error = GetStandardError(); if (m_status == 550) { // general failure means bad recipient m_error.errorCode = MailError::BAD_RECIPIENTS; m_error.errorOnEmail = true; m_error.errorOnAccount = false; } // 452 is technically a non-fatal error that says no more recipients can be // added, on the expectation we'll go and send our mail, and then send a // copy to the next batch of recipients. Instead, we'll treat this as a // permanent error, and not send it to anyone (by sending RSET, and not DATA). // 552 is (as the spec says) an old and occasionally seen typo of 452. if (m_status == 452 || m_status == 552) { m_error.errorCode = MailError::BAD_RECIPIENTS; // too many, actually m_error.errorOnEmail = true; m_error.errorOnAccount = false; } m_error.internalError = "Error setting forward address"; m_write_state = State_SendErrorRset; WriteEmail(); } break; } case State_SendData: { MojLogInfo(m_log, "DATA command response"); if (m_status == Status_Ok) { MojLogInfo(m_log, "DATA command +OK"); m_write_state = State_SendBody; WriteEmail(); } else { MojLogInfo(m_log, "DATA command -ERR"); m_error = GetStandardError(); m_error.internalError = "Error starting mail body"; m_write_state = State_SendErrorRset; WriteEmail(); } break; } case State_SendBody: { MojLogInfo(m_log, "BODY command response"); if (m_status == Status_Ok) { MojLogInfo(m_log, "BODY command +OK"); m_write_state = State_SendRset; WriteEmail(); } else { MojLogInfo(m_log, "BODY command -ERR"); m_error = GetStandardError(); m_error.internalError = "Error completing send"; m_write_state = State_SendErrorRset; WriteEmail(); } break; } case State_SendRset: { MojLogInfo(m_log, "RSET command response"); if (m_status == Status_Ok) { MojLogInfo(m_log, "RSET command +OK"); SendDone(); } else { MojLogInfo(m_log, "RSET command -ERR"); m_error = GetStandardError(); m_error.internalError = "Error resetting"; HandleSmtpError(m_error); } break; } case State_SendErrorRset: { // Handle an error response after clearing an error: if we had one bad e-mail, we want to // be sure we are in a good state before going to the next e-mail. HandleSmtpError(m_error); break; } default: { MojLogInfo(m_log, "Unknown write mail state %d in SmtpSendMailCommand::HandleResponse", m_write_state); HandleFailure("bad HandleResponse state"); break; } } } catch(const std::exception& e) { HandleException(e, __func__, __FILE__, __LINE__); } catch(...) { HandleUnknownException(); } return MojErrNone; }
void LoadSynthDefCmd::Stage4() { SendDone("/d_load"); }