Пример #1
0
int main(int argc, char **argv)
{
	int c, f = 0, error = 0;
	extern char *optarg;
	extern int optind;
	char isoqlogconf[256];


	while (!error && (c = getopt(argc,argv,"f:hv")) != -1) {
        	switch (c) {
        	case 'v':
			puts(VERSION_STRING);
	        	exit(0);
	        	break;
		case 'h':
			puts("Usage: isoqlog [-f isoqlog.conf]");
			exit(0);
			break;
		case 'f':
			strncpy(isoqlogconf, optarg, 256);
			f = 1;
       			break;
		default:
			error = 1;
			puts("Usage: isoqlog [-f isoqlog.conf]");
			exit(-1);
			break;
       		} 
	}

	general.from_cnt = 0;
	general.to_cnt = 0;
	general.from_byte = 0;
	
	if (f == 0) 
		readconfig(CONFIGFILE); /* CONFIGFILE variable is defined in config.h */
	else 
		readconfig(isoqlogconf);
	loadLang(langfile);

	if (strcmp(logtype, "qmail-multilog") == 0) 
		openlogdir(logstore);
	else
	if (strcmp(logtype, "qmail-syslog") == 0)
		readQmailLogFile(logstore);
	else
	if (strcmp(logtype, "sendmail") == 0)
		readSendmailLogFile(logstore);
	else
	if (strcmp(logtype, "postfix") == 0)
		readSendmailLogFile(logstore);
	else
        if (strcmp(logtype, "exim") == 0)
		readEximLogFile(logstore);

	createHtml();
	return 0;
}
Пример #2
0
void KImGalleryPlugin::slotExecute()
{
    m_progressDlg=0L;
    if ( !parent() || !parent()->inherits("KonqDirPart"))
    {
        KMessageBox::sorry( 0L, i18n("Could not create the plugin, please report a bug."));
        return;
    }
    m_part = static_cast<KonqDirPart *>(parent());
    if (!m_part->url().isLocalFile()) {	//TODO support remote URLs too?
        KMessageBox::sorry(m_part->widget(), i18n("Creating an image gallery works only on local folders."));
        return;
    }
    kdDebug(90170) << "dialog is ok" << endl;
    m_configDlg = new KIGPDialog(m_part->widget(), m_part->url().path(+1));

    if ( m_configDlg->exec() == QDialog::Accepted ) {
        kdDebug(90170) << "dialog is ok" << endl;
        m_configDlg->writeConfig();
        m_copyFiles = m_configDlg->copyOriginalFiles();
        m_recurseSubDirectories = m_configDlg->recurseSubDirectories();
        m_useCommentFile = m_configDlg->useCommentFile();
        m_imagesPerRow = m_configDlg->getImagesPerRow();

        KURL url(m_configDlg->getImageName());
        if ( !url.isEmpty() && url.isValid()) {
            m_progressDlg = new QProgressDialog(m_part->widget(), "progressDlg", true );
            QObject::connect(m_progressDlg, SIGNAL( cancelled() ), this, SLOT( slotCancelled() ) );

            m_progressDlg->setLabelText( i18n("Creating thumbnails") );
            m_progressDlg->setCancelButton(new KPushButton(KStdGuiItem::cancel(),m_progressDlg));
            m_cancelled = false;
            m_progressDlg->show();
            if ( createHtml( url, m_part->url().path(), m_configDlg->recursionLevel() > 0 ? m_configDlg->recursionLevel() + 1 : 0 , m_configDlg->getImageFormat()) ) {
                kapp->invokeBrowser(url.url());	// Open a browser to show the result
            } else {
                deleteCancelledGallery(url, m_part->url().path(), m_configDlg->recursionLevel() > 0 ? m_configDlg->recursionLevel() + 1 : 0, m_configDlg->getImageFormat());
            }
        }
    } else {
        kdDebug(90170) << "dialog is not ok" << endl;
    }
    delete m_progressDlg;
}
Пример #3
0
bool KImGalleryPlugin::createHtml(const KURL& url, const QString& sourceDirName, int recursionLevel, const QString& imageFormat)
{
    if(m_cancelled) return false;


    if( !parent() || !parent()->inherits("KonqDirPart"))
        return false;
    KonqDirPart * part = static_cast<KonqDirPart *>(parent());

    QStringList subDirList;
    if (m_recurseSubDirectories && (recursionLevel >= 0)) { //recursionLevel == 0 means endless
        QDir toplevel_dir = QDir( sourceDirName );
        toplevel_dir.setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
        subDirList = toplevel_dir.entryList();

        for (QStringList::ConstIterator it = subDirList.begin(); it != subDirList.end() && !m_cancelled; it++) {
            const QString currentDir = *it;
            if (currentDir == "." || currentDir == "..") { continue;} //disregard the "." and ".." directories
            QDir subDir = QDir( url.directory() + "/" + currentDir );
            if (!subDir.exists()) {
                subDir.setPath( url.directory() );
                if (!(subDir.mkdir(currentDir, false))) {
                    KMessageBox::sorry(part->widget(), i18n("Couldn't create folder: %1").arg(subDir.path()));
                    continue;
                } else {
                    subDir.setPath( url.directory() + "/" + currentDir );
                }
            }
            if(!createHtml( KURL( subDir.path() + "/" + url.fileName() ), sourceDirName + "/" + currentDir,
                            recursionLevel > 1 ? recursionLevel - 1 : 0, imageFormat)) { return false; }
        }
    }

    if (m_useCommentFile) {
        loadCommentFile();
    }

    kdDebug(90170) << "sourceDirName: " << sourceDirName << endl;
    //We're interested in only the patterns, so look for the first |
    //#### perhaps an accessor should be added to KImageIO instead?
    QString filter = KImageIO::pattern(KImageIO::Reading).section('|', 0, 0);

    QDir imageDir( sourceDirName, filter.latin1(),
                   QDir::Name|QDir::IgnoreCase, QDir::Files|QDir::Readable);

    const QString imgGalleryDir = url.directory();
    kdDebug(90170) << "imgGalleryDir: " << imgGalleryDir << endl;

    // Create the "thumbs" subdirectory if necessary
    QDir thumb_dir( imgGalleryDir + QString::fromLatin1("/thumbs/"));
    if (createDirectory(thumb_dir, imgGalleryDir, "thumbs") == false)
        return false;

    // Create the "images" subdirectory if necessary
    QDir images_dir( imgGalleryDir + QString::fromLatin1("/images/"));
    if (m_copyFiles) {
        if (createDirectory(images_dir, imgGalleryDir, "images") == false)
            return false;
    }

    QFile file( url.path() );
    kdDebug(90170) << "url.path(): " << url.path() << ", thumb_dir: "<< thumb_dir.path()
              << ", imageDir: "<< imageDir.path() << endl;

    if ( imageDir.exists() && file.open(IO_WriteOnly) ) {
        QTextStream stream(&file);
        stream.setEncoding(QTextStream::Locale);

        createHead(stream);
        createBody(stream, sourceDirName, subDirList, imageDir, url, imageFormat); //ugly

        file.close();

        return !m_cancelled;

    } else {
        KMessageBox::sorry(m_part->widget(),i18n("Couldn't open file: %1").arg(url.path(+1)));
        return false;
    }
}