bool IndicatorWidget::init(QString check_img, QString ok_img, QString avail_img, QString download_img, QString install_img, QString error_img, CAbstractUpdateController *upd_controller) { if (!upd_controller) return false; mStateImages[CAbstractUpdateController::eCHECKING]= check_img; mStateImages[CAbstractUpdateController::eFULLY_UPDATED]= ok_img; mStateImages[CAbstractUpdateController::eUPDATING]= download_img; mStateImages[CAbstractUpdateController::eUPDATING_ERROR]= error_img; mStateImages[CAbstractUpdateController::eUPDATES_AVAIL]= avail_img; mInstallImage= install_img; mDownloadImage= download_img; mpUC = upd_controller; stateChanged(mpUC->currentState()); connect(mpUC, SIGNAL(stateChanged(CAbstractUpdateController::EUpdateControllerState)), this, SLOT(stateChanged(CAbstractUpdateController::EUpdateControllerState))); connect(mpUC, SIGNAL(progress(CAbstractUpdateController::SProgress)), this, SLOT(progress(CAbstractUpdateController::SProgress))); connect(mpUC, SIGNAL(updateError(QString)), this, SLOT(updateError(QString))); connect(ui->checkButton, SIGNAL(clicked()), mpUC, SLOT(check())); connect(ui->installButton , SIGNAL(clicked()), mpUC, SLOT(updateAll())); connect(ui->cancelButton , SIGNAL(clicked()), mpUC, SLOT(cancel())); return true; }
bool CD_drive::readTrackInfo(char track, CDTRACKINFO *trackInfo2) { ULONG ulParamLen; ULONG ulDataLen; ULONG rc; BOOL returnBool = FALSE; CDAUDIOTRACKINFOPARAM trackParam; CDAUDIOTRACKINFODATA trackInfo[2]; memcpy(trackParam.signature,TAG,4); trackParam.trackNum = track; rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, &trackParam, sizeof(trackParam), &ulParamLen, &trackInfo[0], sizeof(trackInfo[0]), &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x reading track %d info",rc,track); else { trackParam.trackNum = track+1; rc = 0; if(trackParam.trackNum <= cdInfo.lastTrack) { rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK, &trackParam, sizeof(trackParam), &ulParamLen, &trackInfo[1], sizeof(trackInfo[1]), &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x",rc); } else trackInfo[1].address = cdInfo.leadOutAddress; if(!rc) { ULONG LBA[2]; MSF length; LBA[0] = getLBA(trackInfo[0].address); LBA[1] = getLBA(trackInfo[1].address); /* -150 because we want length, not an address */ length = getMSF(LBA[1]-LBA[0]-150); trackInfo2->start = trackInfo[0].address; trackInfo2->end = trackInfo[1].address; trackInfo2->length = length; trackInfo2->size = (LBA[1]-LBA[0])*2352; trackInfo2->data = (trackInfo[0].info & 0x40) ? TRUE : FALSE; trackInfo2->channels = (trackInfo[0].info & 0x80) ? 4 : 2; trackInfo2->number = track; returnBool = TRUE; } } return returnBool; }
void openLog() { if (!_debug || _logFile) return; wstring logPath = L"DebugLogs"; if (!CreateDirectory(logPath.c_str(), NULL)) { DWORD errorCode = GetLastError(); if (errorCode && errorCode != ERROR_ALREADY_EXISTS) { updateError(L"Failed to create log directory", errorCode); return; } } SYSTEMTIME stLocalTime; GetLocalTime(&stLocalTime); static const int maxFileLen = MAX_PATH * 10; WCHAR logName[maxFileLen]; wsprintf(logName, L"DebugLogs\\%04d%02d%02d_%02d%02d%02d_upd.txt", stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay, stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond); _logFile = CreateFile(logName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (_logFile == INVALID_HANDLE_VALUE) { // :( updateError(L"Failed to create log file", GetLastError()); _logFile = 0; return; } }
void ProcessRunner::run() { if (!process) process = new QProcess(); #ifdef WIN32 QProcessEnvironment env = env.systemEnvironment(); env.insert("CYGWIN", "nodosfilewarning"); process->setProcessEnvironment(env); #endif connect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()), Qt::DirectConnection); connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()), Qt::DirectConnection); if(arguments) process->start(program, *arguments); else process->start(program); interact(process); process->waitForFinished(-1); // no timeout process->close(); disconnect(process, SIGNAL(readyReadStandardError()), this, SLOT(updateError())); disconnect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText())); }
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data) { if (data.eObjectType == wizobjectDocumentAttachment) { if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData)) { Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName); return false; } } else { CString strFileName = GetObjectFileName(data); if (!::WizSaveDataToFile(strFileName, data.arrayData)) { Q_EMIT updateError("Failed to save document data: " + data.strDisplayName); return false; } } if (data.eObjectType == wizobjectDocument) { WIZDOCUMENTDATA document; if (DocumentFromGUID(data.strObjectGUID, document)) { Q_EMIT documentDataModified(document); } UpdateDocumentAbstract(data.strObjectGUID); } SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true); return true; }
bool QApplicationConfig::connectSocket() { m_context = new PollingZMQContext(this, 1); connect(m_context, SIGNAL(pollError(int,QString)), this, SLOT(pollError(int,QString))); m_context->start(); m_configSocket = m_context->createSocket(ZMQSocket::TYP_DEALER, this); m_configSocket->setLinger(0); m_configSocket->setIdentity(QString("%1-%2").arg("appconfig").arg(QCoreApplication::applicationPid()).toLocal8Bit()); try { m_configSocket->connectTo(m_configUri); } catch (const zmq::error_t &e) { QString errorString; errorString = QString("Error %1: ").arg(e.num()) + QString(e.what()); updateError(SocketError, errorString); updateState(Error); return false; } connect(m_configSocket, SIGNAL(messageReceived(QList<QByteArray>)), this, SLOT(configMessageReceived(QList<QByteArray>))); return true; }
bool CD_drive::play(char track) { ULONG ulParamLen; ULONG ulDataLen; ULONG rc; BOOL returnBool = FALSE; CDPLAYAUDIOPARAM playParam; CDTRACKINFO trackInfo; memcpy(playParam.signature,TAG,4); playParam.addressingMode = MODE_MSF; if(!readTrackInfo(track, &trackInfo)) return FALSE; playParam.start = trackInfo.start; playParam.end = trackInfo.end; rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_PLAYAUDIO, &playParam, sizeof(playParam), &ulParamLen, NULL, 0, &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x playing track %d",rc,track); else returnBool = TRUE; return returnBool; }
void QApplicationCommand::updateState(QApplicationCommand::State state, QApplicationCommand::ConnectionError error, const QString &errorString) { if (state != m_connectionState) { m_connectionState = state; emit connectionStateChanged(m_connectionState); if (m_connectionState == Connected) { if (m_connected != true) { m_connected = true; emit connectedChanged(true); } } else { if (m_connected != false) { m_connected = false; emit connectedChanged(m_connected); } } } updateError(error, errorString); }
void QApplicationConfig::pollError(int errorNum, const QString &errorMsg) { QString errorString; errorString = QString("Error %1: ").arg(errorNum) + errorMsg; updateError(SocketError, errorString); updateState(Error); }
bool CWizDatabase::UpdateAttachment(const WIZDOCUMENTATTACHMENTDATAEX& data) { bool bRet = false; WIZDOCUMENTATTACHMENTDATAEX dataTemp; if (AttachmentFromGUID(data.strGUID, dataTemp)) { bRet = ModifyAttachmentInfoEx(data); bool changed = dataTemp.strDataMD5 != data.strDataMD5; if (changed) { SetObjectDataDownloaded(data.strGUID, "attachment", false); } } else { bRet = CreateAttachmentEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update attachment: " + data.strName); } return bRet; }
void QApplicationLauncher::updateState(Service::State state, Service::ConnectionError error, QString errorString) { if (state != m_connectionState) { if (m_connected) // we are not connected anymore { stopSubscribeHeartbeat(); clearSync(); m_connected = false; emit connectedChanged(false); } else if (state == Service::Connected) { m_connected = true; emit connectedChanged(true); } m_connectionState = state; emit connectionStateChanged(m_connectionState); if ((state == Service::Disconnected) || (state == Service::Error)) { initializeObject(); } } updateError(error, errorString); }
void QApplicationStatus::updateState(QApplicationStatus::State state, QApplicationStatus::ConnectionError error, const QString &errorString) { if (state != m_connectionState) { if (m_connected) // we are not connected anymore { stopStatusHeartbeat(); clearSync(); m_connected = false; emit connectedChanged(false); } else if (state == Connected) { m_connected = true; emit connectedChanged(true); } m_connectionState = state; emit connectionStateChanged(m_connectionState); if ((state == Disconnected) || (state == Error)) { initializeObject(MotionChannel); initializeObject(ConfigChannel); initializeObject(IoChannel); initializeObject(TaskChannel); initializeObject(InterpChannel); } } updateError(error, errorString); }
void QApplicationConfig::stop() { // cleanup here disconnectSocket(); updateState(Disconnected); updateError(NoError, ""); // clear the error here }
void writeLog(const wstring &msg) { if (!_logFile) return; wstring full = msg + L'\n'; DWORD written = 0; BOOL result = WriteFile(_logFile, full.c_str(), full.size() * sizeof(wchar_t), &written, 0); if (!result) { updateError((L"Failed to write log entry '" + msg + L"'").c_str(), GetLastError()); closeLog(); return; } BOOL flushr = FlushFileBuffers(_logFile); if (!flushr) { updateError((L"Failed to flush log on entry '" + msg + L"'").c_str(), GetLastError()); closeLog(); return; } }
void QApplicationCommand::stop() { #ifdef QT_DEBUG DEBUG_TAG(1, "command", "stop") #endif cleanup(); updateState(Disconnected); updateError(NoError, ""); // clear the error here }
void COutputWindow::execute(const QString &command) { compiler = new QProcess(this); compiler->addArgument(command); connect(compiler, SIGNAL(readyReadStderr()), this, SLOT(updateError())); connect(compiler, SIGNAL(readyReadStdout()), this, SLOT(updateText())); connect(compiler, SIGNAL(processExited()), this, SLOT(updateExit())); compiler->start(); }
bool CWizDatabase::UpdateDocument(const WIZDOCUMENTDATAEX& data) { bool bRet = false; WIZDOCUMENTDATAEX dataTemp; if (DocumentFromGUID(data.strGUID, dataTemp)) { if (data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO) { bRet = ModifyDocumentInfoEx(data); if (dataTemp.strDataMD5 != data.strDataMD5) { SetObjectDataDownloaded(data.strGUID, "document", false); } } else { bRet = true; } } else { Q_ASSERT(data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO); bRet = CreateDocumentEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update document: " + data.strTitle); } WIZDOCUMENTDATA dataRet = data; bool resetVersion = false; if (!data.arrayParam.empty()) { SetDocumentParams(dataRet, data.arrayParam); resetVersion = true; } if (!data.arrayTagGUID.empty()) { SetDocumentTags(dataRet, data.arrayTagGUID); resetVersion = true; } if (resetVersion) { //reset document info ModifyDocumentInfoEx(data); } return bRet; }
error System::addLibrary(const char* funcname, const char* buffer, size_t buffersize) { LuaState L = m_luaState; LuaStatePreserve preserve(L); lua_getglobal(L,funcname); lua_pushlstring(L,buffer,buffersize); if (lua_pcall(L,1,0,FXERROR)){ updateError(); return true; } return false; }
bool mainWindow::offlineUpdate() { QString updateFileName = QFileDialog::getOpenFileName(this, tr("Select Update File"), ".", tr("yadsa update file (*.yadsa)")); if(updateFileName.isEmpty()) return true; std::ifstream updateFile(qPrintable(updateFileName),std::ios::in | std::ios::binary); std::ofstream targetFile(dbFilePath,std::ios::in | std::ios::binary | std::ios::app); if(!updateFile || !targetFile) { updateError(); return false; } updateFile.seekg(0,std::ios::end); if(updateFile.tellg()==0) { updateError(); return false; } updateFile.seekg(0); //to add check for confirming valid update file disc a; while(updateFile.read((char *) &a, sizeof(a))) { soft b; targetFile.write((char *) &a, sizeof(a)); for(int i=0;i<a.count;i++) { updateFile.read((char *) &b, sizeof(b)); targetFile.write((char *) &b, sizeof(b)); } } updateFile.close(); targetFile.close(); QMessageBox::information(this,tr("Success"),tr("Update successful<br />Reloading Archive...")); loadArchive(); return true; }
bool CD_drive::close() { ULONG rc; rc = DosClose(hCDDrive); opened = false; if(rc) { updateError("DosClose failed with return code %d closing drive",rc); return false; } return true; }
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data) { qDebug() << "update object data, name: " << data.strDisplayName << "guid: " << data.strObjectGUID; if (data.eObjectType == wizobjectDocumentAttachment) { if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData)) { Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName); return false; } } else if (data.eObjectType == wizobjectDocument) { WIZDOCUMENTDATA document; if (!DocumentFromGUID(data.strObjectGUID, document)) { qDebug() << "\n[Fatal] update object data failed, can't find database record!\n"; return false; } CString strFileName = GetObjectFileName(data); if (!::WizSaveDataToFile(strFileName, data.arrayData)) { Q_EMIT updateError("Failed to save document data: " + data.strDisplayName); return false; } Q_EMIT documentDataModified(document); UpdateDocumentAbstract(data.strObjectGUID); setDocumentSearchIndexed(data.strObjectGUID, false); } else { Q_ASSERT(0); } SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true); return true; }
int MoodBox::SetupDialogFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = ServerFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updateFinished(); break; case 1: updateError(); break; default: ; } _id -= 2; } return _id; }
void QApplicationConfig::sendConfigMessage(const QByteArray &data) { if (m_configSocket == NULL) { // disallow sending messages when not connected return; } try { m_configSocket->sendMessage(data); } catch (const zmq::error_t &e) { QString errorString; errorString = QString("Error %1: ").arg(e.num()) + QString(e.what()); updateError(SocketError, errorString); updateState(Error); } }
bool CWizDatabase::UpdateTag(const WIZTAGDATA& data) { bool bRet = false; WIZTAGDATA dataTemp; if (TagFromGUID(data.strGUID, dataTemp)) { bRet = ModifyTagEx(data); } else { bRet = CreateTagEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update tag: " + data.strName); } return bRet; }
StorageType System::groupGenerateStorage( GroupID group, GeneratorType gentype, int bufferelements, ParameterStorage* buffer ) { LuaState L = m_luaState; LuaStateObjOperation idop(L,(size_t)group); lua_getglobal (L, "fxgroupstore"); lua_pushvalue (L,-2); lua_pushinteger (L, gentype); if ( lua_pcall (L,2,3,FXERROR) ){ updateError(); assert(0 && "storage computation failed"); return STORAGE_NONE; } if (!(lua_isnumber(L,-3) && lua_isnumber(L,-2) && lua_istable (L,-1))){ return STORAGE_NONE; } int elements = (int)lua_tointeger(L,-2); for (int i = 0; i < elements && i < bufferelements; i++){ lua_rawgeti (L, -1, i + 1); lua_getfield(L, -1, "size"); assert(lua_isnumber(L,-1)); buffer[i].size = lua_tointeger(L,-1); lua_getfield(L, -2, "offset"); assert(lua_isnumber(L,-1)); buffer[i].offset = lua_tointeger(L,-1); lua_getfield(L, -3, "stride"); assert(lua_isnumber(L,-1)); buffer[i].stride = lua_tointeger(L,-1); lua_getfield(L, -4, "element"); assert(lua_isnumber(L,-1)); buffer[i].element = lua_tointeger(L,-1); lua_getfield(L, -5, "align"); assert(lua_isnumber(L,-1)); buffer[i].align = lua_tointeger(L,-1); lua_pop(L,6); } return (StorageType)lua_tointeger(L,-3); }
bool CWizDatabase::updateMessage(const WIZMESSAGEDATA& msg) { bool bRet = false; WIZMESSAGEDATA msgTemp; if (messageFromId(msg.nId, msgTemp)) { bRet = modifyMessageEx(msg); } else { bRet = createMessageEx(msg); } if (!bRet) { Q_EMIT updateError("Failed to update message: " + msg.title); } return bRet; }
bool CWizDatabase::UpdateStyle(const WIZSTYLEDATA& data) { bool bRet = false; WIZSTYLEDATA dataTemp; if (StyleFromGUID(data.strGUID, dataTemp)) { bRet = ModifyStyleEx(data); } else { bRet = CreateStyleEx(data); } if (!bRet) { Q_EMIT updateError("Failed to update style: " + data.strName); } return bRet; }
double execLocalOp(ShadowOpInfo* info, Real realVal, ShadowValue* res, ShadowValue** args){ if (no_reals) return 0; int nargs = numFloatArgs(info); double exactRoundedArgs[4]; for(int i = 0; i < nargs; ++i){ exactRoundedArgs[i] = getDouble(args[i]->real); } double locallyApproximateResult; if (info->op_code == 0x0){ locallyApproximateResult = runEmulatedWrappedOp(info->op_type, exactRoundedArgs); } else { locallyApproximateResult = runEmulatedOp(info->op_code, exactRoundedArgs); } return updateError(&(info->agg.local_error), realVal, locallyApproximateResult); }
bool CD_drive::stop() { ULONG ulParamLen; ULONG ulDataLen; ULONG rc; BOOL returnBool = FALSE; char tag[4]; memcpy(tag,TAG,4); rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_STOPAUDIO, tag, 4, &ulParamLen, NULL, 0, &ulDataLen); if(rc) updateError("DosDevIOCtl failed with return code 0x%x stopping playing.",rc); else returnBool = TRUE; return returnBool; }
bool CWizDatabase::UpdateDeletedGUID(const WIZDELETEDGUIDDATA& data) { bool bRet = false; CString strType = WIZOBJECTDATA::ObjectTypeToTypeString(data.eType); bool bExists = false; ObjectExists(data.strGUID, strType, bExists); if (!bExists) return true; bRet = DeleteObject(data.strGUID, strType, false); if (!bRet) { Q_EMIT updateError("Failed to delete object: " + data.strGUID + " type: " + strType); } return bRet; }