/** * Starts in a specified byte offset of the opened disk images and looks for a * volume system or file system. Will call processFile() on each file * that is found. * @param a_start Byte offset to start analyzing from. * @param a_vtype Volume system type to analyze * @return 1 if an error occured (messages will have been registered) and 0 on success */ uint8_t TskAuto::findFilesInVs(TSK_OFF_T a_start, TSK_VS_TYPE_ENUM a_vtype) { if (!m_img_info) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_NOTOPEN); tsk_error_set_errstr("findFilesInVs -- img_info"); registerError(); return 1; } TSK_VS_INFO *vs_info; // USE mm_walk to get the volumes if ((vs_info = tsk_vs_open(m_img_info, a_start, a_vtype)) == NULL) { /* we're going to ignore this error to avoid confusion if the * fs_open passes. */ tsk_error_reset(); if(tsk_verbose) fprintf(stderr, "findFilesInVs: Error opening volume system, trying as a file system\n"); /* There was no volume system, but there could be a file system * Errors will have been registered */ findFilesInFs(a_start); } // process the volume system else { TSK_FILTER_ENUM retval = filterVs(vs_info); if ((retval == TSK_FILTER_STOP) || (retval == TSK_FILTER_SKIP)|| (m_stopAllProcessing)) return m_errors.empty() ? 0 : 1; /* Walk the allocated volumes (skip metadata and unallocated volumes) */ if (tsk_vs_part_walk(vs_info, 0, vs_info->part_count - 1, m_volFilterFlags, vsWalkCb, this)) { registerError(); tsk_vs_close(vs_info); return 1; } tsk_vs_close(vs_info); } return m_errors.empty() ? 0 : 1; }
TransferReceiver::ResultCode TransferReceiver::addFrame(const RxFrame& frame, TransferBufferAccessor& tba) { if ((frame.getMonotonicTimestamp().isZero()) || (frame.getMonotonicTimestamp() < prev_transfer_ts_) || (frame.getMonotonicTimestamp() < this_transfer_ts_)) { return ResultNotComplete; } const bool not_initialized = !isInitialized(); const bool receiver_timed_out = isTimedOut(frame.getMonotonicTimestamp()); const bool same_iface = frame.getIfaceIndex() == iface_index_; const bool first_fame = frame.isFirst(); const TidRelation tid_rel = getTidRelation(frame); const bool iface_timed_out = (frame.getMonotonicTimestamp() - this_transfer_ts_).toUSec() > (int64_t(transfer_interval_usec_) * 2); // FSM, the hard way const bool need_restart = (not_initialized) || (receiver_timed_out) || (same_iface && first_fame && (tid_rel == TidFuture)) || (iface_timed_out && first_fame && (tid_rel == TidFuture)); if (need_restart) { const bool error = !not_initialized && !receiver_timed_out; if (error) { registerError(); } UAVCAN_TRACE("TransferReceiver", "Restart [not_inited=%i, iface_timeout=%i, recv_timeout=%i, same_iface=%i, first_frame=%i, tid_rel=%i], %s", int(not_initialized), int(iface_timed_out), int(receiver_timed_out), int(same_iface), int(first_fame), int(tid_rel), frame.toString().c_str()); tba.remove(); iface_index_ = frame.getIfaceIndex(); tid_ = frame.getTransferID(); next_frame_index_ = 0; buffer_write_pos_ = 0; this_transfer_crc_ = 0; if (!first_fame) { tid_.increment(); return ResultNotComplete; } } if (!validate(frame)) { return ResultNotComplete; } return receive(frame, tba); }
/** * Starts in sector 0 of the opened disk images and looks for a * volume or file system. Will call processFile() on each file * that is found. * @return 1 if an error occured (message will have been registered) and 0 on success */ uint8_t TskAuto::findFilesInImg() { if (!m_img_info) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_NOTOPEN); tsk_error_set_errstr("findFilesInImg -- img_info"); registerError(); return 1; } return findFilesInVs(0); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), localServer(0), bHasActivated(false), cardUpdateProcess(0) { connect(settingsCache, SIGNAL(pixmapCacheSizeChanged(int)), this, SLOT(pixmapCacheSizeChanged(int))); pixmapCacheSizeChanged(settingsCache->getPixmapCacheSize()); client = new RemoteClient; connect(client, SIGNAL(connectionClosedEventReceived(const Event_ConnectionClosed &)), this, SLOT(processConnectionClosedEvent(const Event_ConnectionClosed &))); connect(client, SIGNAL(serverShutdownEventReceived(const Event_ServerShutdown &)), this, SLOT(processServerShutdownEvent(const Event_ServerShutdown &))); connect(client, SIGNAL(loginError(Response::ResponseCode, QString, quint32)), this, SLOT(loginError(Response::ResponseCode, QString, quint32))); connect(client, SIGNAL(socketError(const QString &)), this, SLOT(socketError(const QString &))); connect(client, SIGNAL(serverTimeout()), this, SLOT(serverTimeout())); connect(client, SIGNAL(statusChanged(ClientStatus)), this, SLOT(statusChanged(ClientStatus))); connect(client, SIGNAL(protocolVersionMismatch(int, int)), this, SLOT(protocolVersionMismatch(int, int))); connect(client, SIGNAL(userInfoChanged(const ServerInfo_User &)), this, SLOT(userInfoReceived(const ServerInfo_User &)), Qt::BlockingQueuedConnection); connect(client, SIGNAL(registerAccepted()), this, SLOT(registerAccepted())); connect(client, SIGNAL(registerAcceptedNeedsActivate()), this, SLOT(registerAcceptedNeedsActivate())); connect(client, SIGNAL(registerError(Response::ResponseCode, QString, quint32)), this, SLOT(registerError(Response::ResponseCode, QString, quint32))); connect(client, SIGNAL(activateAccepted()), this, SLOT(activateAccepted())); connect(client, SIGNAL(activateError()), this, SLOT(activateError())); clientThread = new QThread(this); client->moveToThread(clientThread); clientThread->start(); createActions(); createMenus(); tabSupervisor = new TabSupervisor(client); connect(tabSupervisor, SIGNAL(setMenu(QList<QMenu *>)), this, SLOT(updateTabMenu(QList<QMenu *>))); connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded())); connect(tabSupervisor, SIGNAL(maximize()), this, SLOT(maximize())); tabSupervisor->addDeckEditorTab(0); setCentralWidget(tabSupervisor); retranslateUi(); resize(900, 700); restoreGeometry(settingsCache->getMainWindowGeometry()); aFullScreen->setChecked(windowState() & Qt::WindowFullScreen); if (QSystemTrayIcon::isSystemTrayAvailable()) { createTrayActions(); createTrayIcon(); } connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts())); refreshShortcuts(); }
/** * Processes the file system represented by the given TSK_FS_INFO * pointer. Will Call processFile() on each file that is found. * * @param a_fs_info Pointer to a previously opened file system. * * @returns 1 if an error occured (messages will have been registered) and 0 on success */ uint8_t TskAuto::findFilesInFs(TSK_FS_INFO * a_fs_info) { if (a_fs_info == NULL) { tsk_error_reset(); tsk_error_set_errno(TSK_ERR_AUTO_NOTOPEN); tsk_error_set_errstr("findFilesInFs - fs_info"); registerError(); return 1; } findFilesInFsInt(a_fs_info, a_fs_info->root_inum); return m_errors.empty() ? 0 : 1; }
/*! * Adds the profile in the config file. */ void XmppConfigDialog::add() { //Checking if we can add this account. if (ui.profileNameEdit->text() == "" || ui.jidEdit->text() == "" || ui.passwordEdit->text() == "") { QMessageBox::critical(this, tr("Profiles"), QString("You *must* supply a profile name, a JID and a password."), QMessageBox::Ok); return; } for (int i = 0; i < profiles.count(); i++) { if (profiles[i].name() == ui.profileNameEdit->text()) { QMessageBox::critical(this, tr("Profiles"), QString("A profile with the name \"%1\" already exists.").arg(ui.profileNameEdit->text()), QMessageBox::Ok); return; } } QString pName = ui.profileNameEdit->text(); Jid pJid = Jid(ui.jidEdit->text()); QString pPass = ui.passwordEdit->text(); QString pServer = ui.personnalServerEdit->text(); QString pPort = ui.portEdit->text(); Profile p(pName); p.setData(pJid, pPass, pServer, pPort); if (ui.registerBox->isChecked()) { // Register new account. xmpp = new Xmpp(); task = new Task(); xmppReg = new XmppReg(task, xmpp); connect(xmpp, SIGNAL(readyRead()), SLOT(read())); connect(xmppReg, SIGNAL(finished()), SLOT(regFinished())); connect(xmppReg, SIGNAL(error()), SLOT(registerError())); xmppReg->registerAccount(p); } else { // FIXME:This should be in another Method (also run after registering) addProfile(p); } }
void RemoteClient::registerResponse(const Response &response) { const Response_Register &resp = response.GetExtension(Response_Register::ext); switch(response.response_code()) { case Response::RespRegistrationAccepted: emit registerAccepted(); doLogin(); break; case Response::RespRegistrationAcceptedNeedsActivation: emit registerAcceptedNeedsActivate(); doLogin(); break; default: emit registerError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), resp.denied_end_time()); setStatus(StatusDisconnecting); doDisconnectFromServer(); break; } }
openstudio::path OSRunner::getPathArgumentValue(const std::string& argument_name, const std::map<std::string,OSArgument>& user_arguments) { std::stringstream ss; auto it = user_arguments.find(argument_name); if (it != user_arguments.end()) { if (it->second.hasValue()) { return it->second.valueAsPath(); } else if (it->second.hasDefaultValue()) { return it->second.defaultValueAsPath(); } } ss << "No value found for argument '" << argument_name << "'."; if (it != user_arguments.end()) { ss << " Full argument as passed in by user:" << std::endl << it->second; } registerError(ss.str()); LOG_AND_THROW(ss.str()); return openstudio::path(); }
int TransferSender::send(const uint8_t* payload, unsigned payload_len, MonotonicTime tx_deadline, MonotonicTime blocking_deadline, TransferType transfer_type, NodeID dst_node_id, TransferID tid) const { Frame frame(data_type_id_, transfer_type, dispatcher_.getNodeID(), dst_node_id, tid); frame.setPriority(priority_); frame.setStartOfTransfer(true); UAVCAN_TRACE("TransferSender", "%s", frame.toString().c_str()); /* * Checking if we're allowed to send. * In passive mode we can send only anonymous transfers, if they are enabled. */ if (dispatcher_.isPassiveMode()) { const bool allow = allow_anonymous_transfers_ && (transfer_type == TransferTypeMessageBroadcast) && (int(payload_len) <= frame.getPayloadCapacity()); if (!allow) { return -ErrPassiveMode; } } dispatcher_.getTransferPerfCounter().addTxTransfer(); /* * Sending frames */ if (frame.getPayloadCapacity() >= payload_len) // Single Frame Transfer { const int res = frame.setPayload(payload, payload_len); if (res != int(payload_len)) { UAVCAN_ASSERT(0); UAVCAN_TRACE("TransferSender", "Frame payload write failure, %i", res); registerError(); return (res < 0) ? res : -ErrLogic; } frame.setEndOfTransfer(true); UAVCAN_ASSERT(frame.isStartOfTransfer() && frame.isEndOfTransfer() && !frame.getToggle()); const CanIOFlags flags = frame.getSrcNodeID().isUnicast() ? flags_ : (flags_ | CanIOFlagAbortOnError); return dispatcher_.send(frame, tx_deadline, blocking_deadline, flags, iface_mask_); } else // Multi Frame Transfer { UAVCAN_ASSERT(!dispatcher_.isPassiveMode()); UAVCAN_ASSERT(frame.getSrcNodeID().isUnicast()); int offset = 0; { TransferCRC crc = crc_base_; crc.add(payload, payload_len); static const int BUFLEN = sizeof(static_cast<CanFrame*>(0)->data); uint8_t buf[BUFLEN]; buf[0] = uint8_t(crc.get() & 0xFFU); // Transfer CRC, little endian buf[1] = uint8_t((crc.get() >> 8) & 0xFF); (void)copy(payload, payload + BUFLEN - 2, buf + 2); const int write_res = frame.setPayload(buf, BUFLEN); if (write_res < 2) { UAVCAN_TRACE("TransferSender", "Frame payload write failure, %i", write_res); registerError(); return write_res; } offset = write_res - 2; UAVCAN_ASSERT(int(payload_len) > offset); } int num_sent = 0; while (true) { const int send_res = dispatcher_.send(frame, tx_deadline, blocking_deadline, flags_, iface_mask_); if (send_res < 0) { registerError(); return send_res; } num_sent++; if (frame.isEndOfTransfer()) { return num_sent; // Number of frames transmitted } frame.setStartOfTransfer(false); frame.flipToggle(); UAVCAN_ASSERT(offset >= 0); const int write_res = frame.setPayload(payload + offset, payload_len - unsigned(offset)); if (write_res < 0) { UAVCAN_TRACE("TransferSender", "Frame payload write failure, %i", write_res); registerError(); return write_res; } offset += write_res; UAVCAN_ASSERT(offset <= int(payload_len)); if (offset >= int(payload_len)) { frame.setEndOfTransfer(true); } } } UAVCAN_ASSERT(0); return -ErrLogic; // Return path analysis is apparently broken. There should be no warning, this 'return' is unreachable. }
bool OSRunner::validateUserArguments(const std::vector<OSArgument>& script_arguments, const std::map<std::string, OSArgument>& user_arguments) { bool result(true); std::stringstream ss; AttributeVector argumentValueAttributes; for (const OSArgument& script_argument : script_arguments) { auto it = user_arguments.find(script_argument.name()); if (it == user_arguments.end()) { // script_argument is not in user_arguments // this is only okay for purely optional arguments if (script_argument.required() || script_argument.hasDefaultValue()) { ss << "Argument " << script_argument.name() << " is required or has a default value, "; ss << "but is not in user_arguments."; registerError(ss.str()); ss.str(""); result = false; } } else { // script_argument is in user_arguments OSArgument user_argument = it->second; // check that names still match if (user_argument.name() != script_argument.name()) { ss << "User argument name '" << user_argument.name() << "' does not match map key "; ss << script_argument.name() << "."; registerWarning(ss.str()); ss.str(""); } // check that types still match if (user_argument.type() != script_argument.type()) { ss << "User argument type " << user_argument.type().valueName() << " does not match "; ss << "script argument type " << script_argument.type().valueName() << "."; registerError(ss.str()); ss.str(""); result = false; } // check that we have values if ((script_argument.required()) && !(user_argument.hasValue() || user_argument.hasDefaultValue())) { ss << "Script argument '" << script_argument.name() << "' is required, "; ss << "but the user argument does not have a value or default value set."; registerError(ss.str()); ss.str(""); result = false; } // check for default value mismatch if (script_argument.hasDefaultValue() && !user_argument.hasDefaultValue()) { ss << "Script argument '" << script_argument.name() << "' has a default value, but the "; ss << "user-supplied version does not."; registerWarning(ss.str()); ss.str(""); } if (!script_argument.hasDefaultValue() && user_argument.hasDefaultValue()) { ss << "Script argument '" << script_argument.name() << "' does not have a default value, "; ss << "but the user-supplied version does."; registerWarning(ss.str()); ss.str(""); } if (script_argument.hasDefaultValue() && user_argument.hasDefaultValue() && (user_argument.type() == script_argument.type())) { ss << "The default value of script argument " << std::endl << script_argument << std::endl; ss << "does not match that of the corresponding user argument " << std::endl << user_argument << "."; switch (script_argument.type().value()) { case OSArgumentType::Boolean : if (user_argument.defaultValueAsBool() != script_argument.defaultValueAsBool()) { registerWarning(ss.str()); } break; case OSArgumentType::Double : if (user_argument.defaultValueAsDouble() != script_argument.defaultValueAsDouble()) { registerWarning(ss.str()); } break; case OSArgumentType::Quantity : if (user_argument.defaultValueAsQuantity() != script_argument.defaultValueAsQuantity()) { registerWarning(ss.str()); } break; case OSArgumentType::Integer : if (user_argument.defaultValueAsInteger() != script_argument.defaultValueAsInteger()) { registerWarning(ss.str()); } break; case OSArgumentType::String : case OSArgumentType::Choice : case OSArgumentType::Path : if (user_argument.defaultValueAsString() != script_argument.defaultValueAsString()) { registerWarning(ss.str()); } break; default : OS_ASSERT(false); } ss.str(""); } // check for domain mismatch if (script_argument.hasDomain() && !user_argument.hasDomain()) { ss << "Script argument '" << script_argument.name() << "' has a specified domain, but the "; ss << "user-supplied version does not."; registerWarning(ss.str()); ss.str(""); } if (!script_argument.hasDomain() && user_argument.hasDomain()) { ss << "Script argument '" << script_argument.name() << "' does not have a specified domain, "; ss << "but the user-supplied version does."; registerWarning(ss.str()); ss.str(""); } if (script_argument.hasDomain() && user_argument.hasDomain() && (user_argument.type() == script_argument.type())) { ss << "The domain of script argument " << std::endl << script_argument << std::endl; ss << "does not match that of the corresponding user argument " << std::endl << user_argument << "."; switch (script_argument.type().value()) { case OSArgumentType::Boolean: // DLM: should bool's even have domains? if (user_argument.domainAsBool() != script_argument.domainAsBool()) { registerWarning(ss.str()); } break; case OSArgumentType::Double: if (user_argument.domainAsDouble() != script_argument.domainAsDouble()) { registerWarning(ss.str()); } break; case OSArgumentType::Quantity: // DLM: deprecated forget about getting this to compile //if (user_argument.domainAsQuantity() != script_argument.domainAsQuantity()) { // registerWarning(ss.str()); //} break; case OSArgumentType::Integer: if (user_argument.domainAsInteger() != script_argument.domainAsInteger()) { registerWarning(ss.str()); } break; case OSArgumentType::String: case OSArgumentType::Choice: case OSArgumentType::Path: if (user_argument.domainAsString() != script_argument.domainAsString()) { registerWarning(ss.str()); } break; default: OS_ASSERT(false); } ss.str(""); } // success, set the values if (result) { Quantity q; switch(user_argument.type().value()) { case OSArgumentType::Boolean : if (user_argument.hasValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.valueAsBool())); } else if (user_argument.hasDefaultValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.defaultValueAsBool())); } break; case OSArgumentType::Double : if (user_argument.hasValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.valueAsDouble())); } else if (user_argument.hasDefaultValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.defaultValueAsDouble())); } break; case OSArgumentType::Quantity : if (user_argument.hasValue()) { q = user_argument.valueAsQuantity(); } else if (user_argument.hasDefaultValue()) { q = user_argument.defaultValueAsQuantity(); } argumentValueAttributes.push_back(Attribute(user_argument.name(),q.value(),q.units().print())); break; case OSArgumentType::Integer : if (user_argument.hasValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.valueAsInteger())); } else if (user_argument.hasDefaultValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.defaultValueAsInteger())); } break; case OSArgumentType::String : case OSArgumentType::Choice : case OSArgumentType::Path : if (user_argument.hasValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.valueAsString())); } else if (user_argument.hasDefaultValue()) { argumentValueAttributes.push_back(Attribute(user_argument.name(),user_argument.defaultValueAsString())); } break; default: OS_ASSERT(false); } } } } if (result) { for (Attribute& attribute : argumentValueAttributes) { registerAttribute(attribute); } } return result; }