Example #1
0
//=========================================
// Member call for handleNotificationEvent
//-----------------------------------------
bool Notify::sendSignal (int fd,int flag) {
	sigprocmask(SIG_BLOCK, &block_set,0);
	if ( mNotifyDirs[fd] ) {
		QString* pFolder = mNotifyDirs[fd];
		QPoint*  count   = mNotifyCount[fd];
		QStringList tokens = pFolder->split ( "/" );
		QString folder  = tokens.first();
		QString dirname = tokens.last();
		switch (flag) {
			case QBIFF_CREATE:
				printf ("________create %s %p\n",pFolder->toLatin1().data(),count);
				if (dirname == "new") {
					count -> rx()++;
				} else {
					count -> ry()++;
				}
				sigCreate ( &folder,count );
			break;
			case QBIFF_DELETE:
				printf ("________delete %s %p\n",pFolder->toLatin1().data(),count);
				if (dirname == "new") {
					count -> rx()--;
				} else {
					count -> ry()--;
				}
				sigDelete ( &folder,count );
			break;
			default:
			break;
		}
		sigNotify ( &folder,count );
		sigprocmask(SIG_UNBLOCK, &block_set,0);
		return true;
	}
	sigprocmask(SIG_UNBLOCK, &block_set,0);
	return false;
}
FGFSIoFile::FGFSIoFile (QString filename)
{
  file = new QFile(this);
  file->setFileName(filename);
  if (!file->open(QIODevice::ReadOnly)) {
    DEBUGP(LOGDEBUG, "FGFSIo::" << file->errorString());
    qFatal ("FGFSIo::FGFSIoFile: could not be opended: %i", file->error());
  }
  initCommon();
  if (file->size() >0) {
    file->seek(file->size());
  }
  connect(file, SIGNAL(readyRead()),
	  this, SLOT(slotIoRead())) ;
  
  notifier= new QFileSystemWatcher();
  notifier->addPath(file->fileName());
  DEBUGP(LOGDEBUG, "watch:" << notifier->files());
  connect(this, SIGNAL(sigNotify()),
  	  this, SLOT(slotIoRead()));
  connect(notifier, SIGNAL(fileChanged(const QString)),
    	  this, SLOT (slotIoRead(const QString)));

}
void FGFSIoFile::slotIoRead(const QString foo) {
   DEBUGP(LOGBULK, "entered" << foo);
  emit sigNotify();
}