Пример #1
0
void FileMonitor::saveState()
{
    ofstream out(stateFileName.c_str());
	for (size_t i = 0; i < files.size(); i++) {
        MonitorItem *item = files[i];
        out << item->getName() << '\t' << item->storeState() << endl;
    }
}
Пример #2
0
void ConfigPage::removeMonitor()
{
    MonitorItem *currentItem = dynamic_cast<MonitorItem *>( m_page->monitors->currentItem() );
    if ( !currentItem )
        return;

    MonitorConfigMap::Iterator monitorIt = m_monitors.find( currentItem->text( 0 ) );
    if ( monitorIt == m_monitors.end() )
        return;

    m_monitors.remove( monitorIt );
    delete currentItem;
}
Пример #3
0
QStringList MonitorItemThread::createRes(const cl_opts& cl)
{
   QStringList tabRefs;

   LockRes(my_config);

   int monitorItems = 0;
   MONITORRES *monitorRes;
   foreach_res(my_config, monitorRes, R_MONITOR) {
      monitorItems++;
   }

   if (monitorItems != 1) {
      Emsg2(M_ERROR_TERM, 0,
         _("Error: %d Monitor resources defined in %s. "
           "You must define one and only one Monitor resource.\n"),
            monitorItems, cl.configfile);
   }

   monitor = reinterpret_cast<MONITORRES*>(my_config->GetNextRes(R_MONITOR, (RES *)NULL));

   int nitems = 0;

   DIRRES* dird;
   foreach_res(my_config, dird, R_DIRECTOR) {
      MonitorItem* item = new MonitorItem;
      item->setType(R_DIRECTOR);
      item->setResource(dird);
      item->setConnectTimeout(monitor->DIRConnectTimeout);
      item->connectToMainWindow(MainWindow::instance());
      tabRefs.append(item->get_name());
      items.append(item);
      nitems++;
   }
Пример #4
0
void MonitorItemThread::run()
{
   /* all this must be run in the same
    * context of the MonitorItemThread  */

   lmgr_init_thread();

   if (monitor) {
      refreshTimer->start(monitor->RefreshInterval * 1000);
   }

   exec();

   while (items.count()) {
      MonitorItem* item = items.first();
      item->disconnect();
      delete item;
      items.removeFirst();
   }

   term_msg(); // this cannot be called twice, however
}
Пример #5
0
int FileMonitor::loadState()
{
    ifstream in(stateFileName.c_str());;
    int cnt = 0;
    for (string line; getline(in, line); cnt++) {
        cout << "line: " << line << endl;
        size_t pos = line.find('\t');
        if (pos == string::npos || !pos) {
			cout << "loadState failed parse line: " << line << endl;
            return -1;
        }
        string name = line.substr(0, pos);
        string state = line.substr(pos + 1);
        MonitorItem *item = findByName(name);
        if (!item) {
            cout << "Found state for not watched file: " << name << endl;
            continue;
        }
        item->restoreState(state);
        cout << "read state for '" << name << "' - '" << state << "'\n"; 
    }
    return cnt;
}
Пример #6
0
void ConfigPage::modifyMonitor()
{
    MonitorItem *currentItem = dynamic_cast<MonitorItem *>( m_page->monitors->currentItem() );
    if ( !currentItem )
        return;

    MonitorConfigMap::Iterator monitorIt = m_monitors.find( currentItem->text( 0 ) );
    if ( monitorIt == m_monitors.end() )
        return;

    MonitorDialog dlg( *monitorIt, m_hosts, this );
    if ( dlg.exec() ) {
        MonitorConfig newMonitor = dlg.monitorConfig();

        if ( newMonitor.name != monitorIt.key() ) {
            m_monitors.remove( monitorIt );
            monitorIt = m_monitors.insert( newMonitor.name, newMonitor );
        } else
            *monitorIt = newMonitor;

        currentItem->setFromMonitor( newMonitor );
    }
}
Пример #7
0
 foreach_res(my_config, stored, R_STORAGE) {
    MonitorItem* item = new MonitorItem;
    item->setType(R_STORAGE);
    item->setResource(stored);
    item->setConnectTimeout(monitor->SDConnectTimeout);
    item->connectToMainWindow(MainWindow::instance());
    tabRefs.append(item->get_name());
    items.append(item);
    nitems++;
 }
 foreach_res(filed, R_CLIENT) {
    MonitorItem* item = new MonitorItem;
    item->setType(R_CLIENT);
    item->setResource(filed);
    item->setConnectTimeout(monitor->FDConnectTimeout);
    item->connectToMainWindow(MainWindow::instance());
    tabRefs.append(item->get_name());
    items.append(item);
    nitems++;
 }