AkmSensor::AkmSensor() : SensorBase(NULL, NULL), mEnabled(0), mPendingMask(0), mInputReader(32) { /* Open the library before opening the input device. The library * creates a uinput device. */ if (loadAKMLibrary() == 0) { data_name = "compass_sensor"; data_fd = openInput("compass_sensor"); } //Incase first time fails if(data_fd < 0){ ALOGI("%s: retrying to open compass sensor", LOGTAG); data_fd = openInput("compass_sensor"); } if(data_fd > 0){ ALOGI("%s: compass sensor successfully opened: %i", LOGTAG, data_fd); }else{ ALOGI("%s: failed to open compass sensor", LOGTAG); } memset(mPendingEvents, 0, sizeof(mPendingEvents)); mPendingEvents[MagneticField].version = sizeof(sensors_event_t); mPendingEvents[MagneticField].sensor = ID_M; mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; // read the actual value of all sensors if they're enabled already struct input_absinfo absinfo; short flags = 0; if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) { mEnabled |= 1<<MagneticField; if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) { mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Y), &absinfo)) { mPendingEvents[MagneticField].magnetic.y = absinfo.value * CONVERT_M_Y; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Z), &absinfo)) { mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z; } } }
SensorBase::SensorBase(const char* dev_name, const char* data_name) : dev_name(dev_name), data_name(data_name), dev_fd(-1), data_fd(-1), mEnabled(false) { if (data_name) { data_fd = openInput(data_name); } }
bool PassportDevice::isDeviceType() { // Variables... ConfigLine command; char line[1024]; bool found = false; int lineCount = 0; int returnCode = 0; // Open and check the contents of the file... returnCode = openInput(); if (returnCode != 0) return false; // The process device configuration file loop... while ((feof(inputFile) == 0) && (found == false) && (lineCount < 15)) { // Read a line from the config... readLine(line, sizeof(line)); // Split it up into parts... command.setConfigLine(line); if ((strcmp(command.part(0), "#") == 0) && (strcmp(command.part(1), "box") == 0) && (strcmp(command.part(2), "type") == 0) && (strcmp(command.part(3), ":") == 0)) found = true; else if ((strcmp(command.part(0), "#") == 0) && (strcmp(command.part(1), "software") == 0) && (strcmp(command.part(2), "version") == 0) && (strcmp(command.part(3), ":") == 0)) found = true; } fclose(inputFile); return found; }
bool CiscoCSSDevice::isDeviceType() { // Variables... char line[1024]; bool found = false; int count = 0; int returnCode = 0; // Open and check the contents of the file... returnCode = openInput(); if (returnCode != 0) return false; // The process device configuration file loop... while ((feof(inputFile) == 0) && (found == false) && (count < 15)) { // Read a line from the config... readLine(line, sizeof(line)); if (strncmp(line, "!*************************** GLOBAL ***************************", 63) == 0) found = true; count++; } fclose(inputFile); return found; }
SensorBase::SensorBase( const char* dev_name, const char* data_name, const struct SensorContext* context /* = NULL */) : dev_name(dev_name), data_name(data_name), algo(NULL), dev_fd(-1), data_fd(-1), mEnabled(0) { if (context != NULL) { CalibrationManager& cm(CalibrationManager::getInstance()); algo = cm.getCalAlgo(context->sensor); /* Set up the sensors_meta_data_event_t event*/ meta_data.version = META_DATA_VERSION; meta_data.sensor = context->sensor->handle; meta_data.type = SENSOR_TYPE_META_DATA; meta_data.reserved0 = 0; meta_data.timestamp = 0LL; meta_data.meta_data.what = META_DATA_FLUSH_COMPLETE; meta_data.meta_data.sensor = context->sensor->handle; } if (data_name) { data_fd = openInput(data_name); } }
void run() { do { kxMovieError errCode = openInput(_file.c_str()); if (errCode == kxMovieErrorNone) { errCode = openAudioStream(); } if (errCode == kxMovieErrorNone) { _signals.fileOpen(errCode == kxMovieErrorNone, _audioCodecCtx->channels, _audioCodecCtx->sample_rate, _signals._pusr); } else { _signals.fileOpen(errCode == kxMovieErrorNone, 0, 0, _signals._pusr); break; } do { decodeFrames(0.1); IceUtil::Mutex::Lock lock(_mutex); if (_stopFlag || _isEOF) { break; } } while (true); if (_isEOF) { _signals.fileEOF(_signals._pusr); //SP::printf("download finished!!!!!!! \n"); } else { //SP::printf("download aborted !!!!!!! \n"); } } while (false) ; closeAudioStream(); }
SensorBase::SensorBase( const char* dev_name, const char* data_name) : dev_name(dev_name), data_name(data_name), dev_fd(-1), data_fd(-1) { data_fd = openInput(data_name); }
AccelSensor::AccelSensor() : SensorBase(NULL, NULL), mEnabled(0), mPendingMask(0), mInputReader(32), mMinPollDelay(0), mMaxPollDelay(0) { #if defined(ACCELEROMETER_SENSOR_MMA7660) data_name = "mma7660"; #elif defined(ACCELEROMETER_SENSOR_MMA8451) data_name = "mma8451"; #elif defined(ACCELEROMETER_SENSOR_MMA8450) data_name = "mma8450"; #else #error you must define accelerometer properly data_name = NULL; data_fd = -1; #endif if (data_name) { data_fd = openInput(data_name); getPollFile(data_name); } memset(mPendingEvents, 0, sizeof(mPendingEvents)); mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); mPendingEvents[Accelerometer].sensor = ID_A; mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; // read the actual value of all sensors if they're enabled already struct input_absinfo absinfo; short flags = 0; if (accel_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) { mEnabled |= 1<<Accelerometer; #ifdef GSENSOR_XY_REVERT if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) { mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) { mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y; } #else if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) { mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) { mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y; } #endif if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) { mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z; } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); display(); connect(ui->openFBut, SIGNAL( clicked() ), SLOT( openInput() )); connect(ui->pushSha, SIGNAL( clicked() ), SLOT( clickedSha() )); }
SensorBase::SensorBase( const char* dev_name, const char* data_name) : dev_name(dev_name), data_name(data_name), dev_fd(-1), data_fd(-1) { data_fd = openInput(data_name); LOGE("trm SensorBase: openInput %s, data_fd %x",data_name,data_fd); }
SensorBase::SensorBase( const char* dev_name, const char* data_name) : dev_name(dev_name), data_name(data_name), dev_fd(-1), data_fd(-1), mInputReader(64) { if (data_name) data_fd = openInput(data_name); }
/* * Reading sensor events generated by input event subsystem in kernel driver. */ int ProximitySensor::readEvents (sensors_event_t* data, int count) { if (count < 1) { return -EINVAL; } if (mHasPendingEvent) { mHasPendingEvent = false; mPendingEvent.timestamp = getTimestamp(); *data = mPendingEvent; return mEnabled ? 1 : 0; } // data_fd technically set in super class constructor but value got overwritten // so data_fd is set new data_fd = openInput("SRF02 input event module"); ssize_t n = mInputReader.fill(data_fd); if (n < 0) { return n; } int numEventRecieved = 0; input_event const* event; while (count && mInputReader.readEvent(&event)) { // evaluating event type set in kernel driver int type = event->type; // ALOGD("sensor in ProximitySensor readEvents() - event->type is: %d", type); if (type == EV_ABS) { if (event->code == ABS_DISTANCE) { // ALOGD("sensor in ProximitySensor readEvents() in if event->code == ABS_DISTANCE -> input event kernel"); mPendingEvent.sensor = ID_PX; mPendingEvent.type = SENSOR_TYPE_PROXIMITY; mPendingEvent.distance = (float) event->value; // ALOGD("sensor srf02 - value is : %d \n ", event->value); } } else if (type == EV_SYN) { // ALOGD("sensor in ProximitySensor readEvents() in if type == EV_SYN"); mPendingEvent.timestamp = timevalToNano(event->time); if (mEnabled) { *data++ = mPendingEvent; count--; numEventRecieved++; } } else { ALOGE ("ProximitySensor: unknown event (type=%d, code=%d)", type, event->code); } mInputReader.next(); mHasPendingEvent=true; } return numEventRecieved; }
SensorBase::SensorBase( const char* dev_name, const char* data_name) : mDevName(dev_name), mDataName(data_name), mDevFd(-1), mDataFd(-1) { ALOGV("%s(): dev_name=%s", __func__, dev_name); if (mDataName) { mDataFd = openInput(mDataName); } }
bool RtspStreamWorker::prepareStream(AVFormatContext **context, AVDictionary *options) { if (!openInput(context, options)) return false; if (!findStreamInfo(*context, options)) return false; openCodecs(*context, options); return true; }
RiffImportDlg::RiffImportDlg(QWidget *parent) : QDialog(parent), ui(new Ui::RiffImportDlg) { m_riff = new Riff(this); connect(m_riff, SIGNAL(signalInstrument(int, int, QString)), SLOT(slotInstrument(int, int, QString))); connect(m_riff, SIGNAL(signalSoundFont(QString, QString, QString)), SLOT(slotCompleted(QString, QString, QString))); connect(m_riff, SIGNAL(signalDLS(QString, QString, QString)), SLOT(slotCompleted(QString, QString, QString))); ui->setupUi(this); connect(ui->m_inputBtn, SIGNAL(clicked()), SLOT(openInput())); connect(ui->m_outputBtn, SIGNAL(clicked()), SLOT(openOutput())); }
Accelerometer::Accelerometer() : SensorBase(NULL, NULL), mEnabled(0), mHasPendingEvent(false), mInputReader( 32) { data_name = "gsensor"; data_fd = openInput("gsensor"); mPendingEvent.version = sizeof(sensors_event_t); mPendingEvent.sensor = ID_A; mPendingEvent.type = SENSOR_TYPE_ACCELEROMETER; mPendingEvent.acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; delay_time = -1LL; }
static void checkDeviceReplugged() { static unsigned long last_mtime; static unsigned long last_mtime_nsec; struct stat st; if (stat(DEV_CHECK_REPLUGGED, &st) != 0) return; //printf("DEV_CHECK_REPLUGGED: %s %ld", DEV_CHECK_REPLUGGED, st.st_mtime); if (st.st_mtime != last_mtime || st.st_mtime_nsec != last_mtime_nsec) { openInput(); } last_mtime = st.st_mtime; last_mtime_nsec = st.st_mtime_nsec; }
SensorBase::SensorBase( const char* dev_name, const char* data_name) : dev_name(dev_name), data_name(data_name), dev_fd(-1), data_fd(-1) { if (data_name) { data_fd = openInput(data_name); } fifo_fd = -1; fifo_name = NULL; mBatchEnabled = 0; mFlushed = 0; }
SensorBase::SensorBase( const char* dev_name, const char* data_name, const struct SensorContext* context /* = NULL */) : dev_name(dev_name), data_name(data_name), algo(NULL), dev_fd(-1), data_fd(-1) { if (context != NULL) { CalibrationManager& cm(CalibrationManager::getInstance()); algo = cm.getCalAlgo(context->sensor); } if (data_name) { data_fd = openInput(data_name); } }
void VideoInput::createDecoder() { deleteDecoder(); switchPending_ = false; if (decOpts_.input.empty()) { foundDecOpts(decOpts_); return; } auto decoder = std::unique_ptr<MediaDecoder>(new MediaDecoder()); if (emulateRate_) decoder->emulateRate(); decoder->setInterruptCallback( [](void* data) -> int { return not static_cast<VideoInput*>(data)->isCapturing(); }, this); if (decoder->openInput(decOpts_) < 0) { RING_ERR("Could not open input \"%s\"", decOpts_.input.c_str()); foundDecOpts(decOpts_); return; } /* Data available, finish the decoding */ if (decoder->setupFromVideoData() < 0) { RING_ERR("decoder IO startup failed"); foundDecOpts(decOpts_); return; } decOpts_.width = decoder->getWidth(); decOpts_.height = decoder->getHeight(); decOpts_.framerate = decoder->getFps(); RING_DBG("created decoder with video params : size=%dX%d, fps=%lf", decOpts_.width, decOpts_.height, decOpts_.framerate.real()); decoder_ = std::move(decoder); foundDecOpts(decOpts_); /* Signal the client about readable sink */ sink_->setFrameSize(decoder_->getWidth(), decoder_->getHeight()); }
SensorBase::SensorBase( const char* dev_name, const char* data_name, sensor_t* sensor_info /* = NULL */) : dev_name(dev_name), data_name(data_name), algo(NULL), dev_fd(-1), data_fd(-1) { if (sensor_info != NULL) { CalibrationManager *cm = CalibrationManager::defaultCalibrationManager(); if (cm != NULL) algo = cm->getCalAlgo(sensor_info); } if (data_name) { data_fd = openInput(data_name); } }
/** @brief Subscribe to capture sound from the opened input device. If the input device is not open, it will be opened before capturing. */ void Audio::subscribeInput() { qDebug() << "subscribing input" << inputSubscriptions; if (!inputSubscriptions++) { openInput(Settings::getInstance().getInDev()); openOutput(Settings::getInstance().getOutDev()); #if (!FIX_SND_PCM_PREPARE_BUG) if (alInDev) { qDebug() << "starting capture"; alcCaptureStart(alInDev); } #endif } }
int main(int argc, char* argv[]) { initSDL(); SDL_EnableUNICODE(1); SDL_WM_SetCaption("Remote PC Keyboard", "Remote PC Keyboard"); openInput(); createGuiMain(); while( true ) { mainLoop(); } deinitSDL(); return 0; }
SensorBase::SensorBase( const char* dev_name, const char* data_name, const char* fifo_name) : dev_name(dev_name), data_name(data_name),fifo_name(fifo_name), dev_fd(-1), data_fd(-1), fifo_fd(-1) { if (data_name) { data_fd = openInput(data_name); } if(fifo_name){ open_fifo_device(); } mBatchEnabled = 0; mFlushed = 0; }
void OSCPlugin::setPort(int num, QString port) { qDebug() << Q_FUNC_INFO; if (num >= OSC_INPUTS) return; QSettings settings; QString key = QString("OSCplugin/Input%1/server_port").arg(num); settings.setValue(key, QVariant(port)); if (port != m_ports[num]) { m_ports[num] = port; openInput(num); } }
ProximitySensor::ProximitySensor() : SensorBase(NULL, NULL), mEnabled(0), mInputReader(4), mHasPendingEvent(false), sensor_index(-1), mThreshold_h(0), mThreshold_l(0), mBias(0) { int i; mPendingEvent.version = sizeof(sensors_event_t); mPendingEvent.sensor = SENSORS_PROXIMITY_HANDLE; mPendingEvent.type = SENSOR_TYPE_PROXIMITY; memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); for(i = 0; i < SUPPORTED_PSENSOR_COUNT; i++) { data_name = data_device_name[i]; // data_fd is not initialized if data_name passed // to SensorBase is NULL. data_fd = openInput(data_name); if (data_fd > 0) { sensor_index = i; break; } } if (data_fd > 0) { snprintf(input_sysfs_path, sizeof(input_sysfs_path), input_sysfs_path_list[i], input_name); input_sysfs_path_len = strlen(input_sysfs_path); enable(0, 1); } ALOGI("The proximity sensor path is %s",input_sysfs_path); }
bool KateApp::startupKate () { // user specified session to open if (m_args->isSet ("startanon")) { sessionManager()->activateSession (sessionManager()->giveSession (""), false, false); } else if (m_args->isSet ("start")) { sessionManager()->activateSession (sessionManager()->giveSession (m_args->getOption("start")), false, false); } else if (!m_args->isSet( "stdin" ) && (m_args->count() == 0)) // only start session if no files specified { // let the user choose session if possible if (!sessionManager()->chooseSession ()) { kDebug() << "chooseSession returned false, exiting"; // we will exit kate now, notify the rest of the world we are done #ifdef Q_WS_X11 KStartupInfo::appStarted (startupId()); #endif return false; } } else { sessionManager()->activateSession( KateSession::Ptr(new KateSession (sessionManager(), QString())), false, false ); } // oh, no mainwindow, create one, should not happen, but make sure ;) if (mainWindows() == 0) newMainWindow (); // notify about start #ifdef Q_WS_X11 KStartupInfo::setNewStartupId( activeMainWindow(), startupId()); #endif QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding").toUtf8()) : 0; bool tempfileSet = KCmdLineArgs::isTempFileSet(); KTextEditor::Document *doc = 0; const QString codec_name = codec ? codec->name() : QString(); KateDocManager::self()->setSuppressOpeningErrorDialogs(true); QList<KUrl> urls; for (int z = 0; z < m_args->count(); z++) { // this file is no local dir, open it, else warn const bool noDir = !m_args->url(z).isLocalFile() || !QFileInfo (m_args->url(z).toLocalFile()).isDir(); if (noDir) { urls << m_args->url(z); } else { KMessageBox::sorry( activeMainWindow(), i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.", m_args->url(z).url()) ); } } doc = activeMainWindow()->viewManager()->openUrls(urls, codec_name, tempfileSet); KateDocManager::self()->setSuppressOpeningErrorDialogs(false); // handle stdin input if( m_args->isSet( "stdin" ) ) { QTextStream input(stdin, QIODevice::ReadOnly); // set chosen codec if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + '\n' ); } while( !line.isNull() ); openInput (text); } else if ( doc ) activeMainWindow()->viewManager()->activateView( doc ); if ( activeMainWindow()->viewManager()->viewCount () == 0 ) activeMainWindow()->viewManager()->activateView(m_docManager->document (0)); int line = 0; int column = 0; bool nav = false; if (m_args->isSet ("line")) { line = m_args->getOption ("line").toInt() - 1; nav = true; } if (m_args->isSet ("column")) { column = m_args->getOption ("column").toInt() - 1; nav = true; } if (nav && activeMainWindow()->viewManager()->activeView ()) activeMainWindow()->viewManager()->activeView ()->setCursorPosition (KTextEditor::Cursor (line, column)); // show the nice tips KTipDialog::showTip(activeMainWindow()); activeMainWindow()->setAutoSaveSettings(); kDebug() << "KateApplication::init finished successful"; return true; }
AkmSensor::AkmSensor() : SensorBase(NULL, NULL), mEnabled(0), mPendingMask(0), mInputReader(32) { /* Open the library before opening the input device. The library * creates a uinput device. */ if (loadAKMLibrary() == 0) { data_name = "compass_sensor"; data_fd = openInput("compass_sensor"); } memset(mPendingEvents, 0, sizeof(mPendingEvents)); mPendingEvents[Accelerometer].version = sizeof(sensors_event_t); mPendingEvents[Accelerometer].sensor = ID_A; mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER; mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH; mPendingEvents[MagneticField].version = sizeof(sensors_event_t); mPendingEvents[MagneticField].sensor = ID_M; mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD; mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH; mPendingEvents[Orientation ].version = sizeof(sensors_event_t); mPendingEvents[Orientation ].sensor = ID_O; mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION; mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH; // read the actual value of all sensors if they're enabled already struct input_absinfo absinfo; short flags = 0; if (akm_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) { mEnabled |= 1<<Accelerometer; if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) { mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) { mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) { mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z; } } if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) { mEnabled |= 1<<MagneticField; if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) { mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Y), &absinfo)) { mPendingEvents[MagneticField].magnetic.y = absinfo.value * CONVERT_M_Y; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Z), &absinfo)) { mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z; } } if (akm_is_sensor_enabled(SENSOR_TYPE_ORIENTATION)) { mEnabled |= 1<<Orientation; if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_YAW), &absinfo)) { mPendingEvents[Orientation].orientation.azimuth = absinfo.value; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PITCH), &absinfo)) { mPendingEvents[Orientation].orientation.pitch = absinfo.value; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ROLL), &absinfo)) { mPendingEvents[Orientation].orientation.roll = -absinfo.value; } if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ORIENT_STATUS), &absinfo)) { mPendingEvents[Orientation].orientation.status = uint8_t(absinfo.value & SENSOR_STATE_MASK); } } // disable temperature sensor, since it is not supported akm_disable_sensor(SENSOR_TYPE_TEMPERATURE); }
bool KateApp::startupKate () { // user specified session to open if (m_args->isSet ("start")) { sessionManager()->activateSession (sessionManager()->giveSession (QString::fromLocal8Bit(m_args->getOption("start"))), false, false); } else { // let the user choose session if possible if (!sessionManager()->chooseSession ()) { // we will exit kate now, notify the rest of the world we are done KStartupInfo::appStarted (startupId()); return false; } } // oh, no mainwindow, create one, should not happen, but make sure ;) if (mainWindows() == 0) newMainWindow (); // notify about start KStartupInfo::setNewStartupId( activeMainWindow(), startupId()); QTextCodec *codec = m_args->isSet("encoding") ? QTextCodec::codecForName(m_args->getOption("encoding")) : 0; bool tempfileSet = KCmdLineArgs::isTempFileSet(); Kate::Document::setOpenErrorDialogsActivated (false); uint id = 0; for (int z=0; z<m_args->count(); z++) { // this file is no local dir, open it, else warn bool noDir = !m_args->url(z).isLocalFile() || !QDir (m_args->url(z).path()).exists(); if (noDir) { // open a normal file if (codec) id = activeMainWindow()->viewManager()->openURL( m_args->url(z), codec->name(), false, tempfileSet ); else id = activeMainWindow()->viewManager()->openURL( m_args->url(z), QString::null, false, tempfileSet ); } else KMessageBox::sorry( activeMainWindow(), i18n("The file '%1' could not be opened: it is not a normal file, it is a folder.").arg(m_args->url(z).url()) ); } Kate::Document::setOpenErrorDialogsActivated (true); // handle stdin input if( m_args->isSet( "stdin" ) ) { QTextIStream input(stdin); // set chosen codec if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + "\n" ); } while( !line.isNull() ); openInput (text); } else if ( id ) activeMainWindow()->viewManager()->activateView( id ); if ( activeMainWindow()->viewManager()->viewCount () == 0 ) activeMainWindow()->viewManager()->activateView(m_docManager->firstDocument()->documentNumber()); int line = 0; int column = 0; bool nav = false; if (m_args->isSet ("line")) { line = m_args->getOption ("line").toInt(); nav = true; } if (m_args->isSet ("column")) { column = m_args->getOption ("column").toInt(); nav = true; } if (nav) activeMainWindow()->viewManager()->activeView ()->setCursorPosition (line, column); // show the nice tips KTipDialog::showTip(activeMainWindow()); return true; }
int CheckPointDevice::process() { // Variables... policyCollections *policyPointer = 0; string configDirectory; string tempFilename; struct stat *fileStats = 0; int returnCode = 0; bool addedPolicies = false; /* CheckPoint files to process... Key: * tables.C - Contains a list of the other files... Objects: * objects_5_0.C * objects.C_41 * objects.C Rules: * *.W files * rules.C Rules + Comments: * rulebases_5_0.fws * rulebases.fws Users: * fwauth.NDB */ // Check if input is a directory (required)... fileStats = new (struct stat); memset(fileStats, 0, sizeof(struct stat)); stat(config->inputSource, fileStats); if ((fileStats->st_mode & S_IFMT) != S_IFDIR) { delete fileStats; return deviceerror_inputnotadirectory; } delete fileStats; // Add Directory slash if it does not already exist configDirectory.assign(config->inputSource); #if !defined(__WIN32__) if (configDirectory.c_str()[configDirectory.length() - 1] != '/') configDirectory.append("/"); #else if (configDirectory.c_str()[configDirectory.length() - 1] != '\\') configDirectory.append("\\"); #endif // Process CheckPoint Object Files... tempFilename.assign(configDirectory); tempFilename.append("objects_5_0.C"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); if (returnCode != 0) { tempFilename.assign(configDirectory); tempFilename.append("objects.C_41"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); if (returnCode != 0) { tempFilename.assign(configDirectory); tempFilename.append("objects.C"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); } } if (returnCode != 0) return deviceerror_objectsfilenotfound; returnCode = processDevice(); fclose(inputFile); if (returnCode != 0) return returnCode; // Process CheckPoint Rules Files... // Try policy collection first... policyPointer = policies; while (policyPointer != 0) { tempFilename.assign(configDirectory); tempFilename.append(policyPointer->policyName); tempFilename.append(".W"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); if (returnCode == 0) { returnCode = ((CheckPointFilter *)filter)->processWRulesDevice(this, policyPointer->policyName.c_str(), policyPointer->active); fclose(inputFile); addedPolicies = true; } policyPointer = policyPointer->next; returnCode = 0; } // If policies still have not been added... if (addedPolicies == false) { tempFilename.assign(configDirectory); tempFilename.append("rules.C"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); if (returnCode == 0) { returnCode = ((CheckPointFilter *)filter)->processRRulesDevice(this); fclose(inputFile); } } // Process CheckPoint Rules With Comments Files... tempFilename.assign(configDirectory); tempFilename.append("rulebases_5_0.fws"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); if (returnCode != 0) { tempFilename.assign(configDirectory); tempFilename.append("rulebases.fws"); config->inputSource = tempFilename.c_str(); returnCode = openInput(); } if (returnCode == 0) { returnCode = ((CheckPointFilter *)filter)->processFRulesDevice(this); fclose(inputFile); } else returnCode = 0; // Process Users... // Post processing defaults... setPostCommonDefaults(); // Post device specific processing defaults... setPostDefaults(); return returnCode; }