Ejemplo n.º 1
1
void LibraryScanner::scan ( const QString & directory ) {
	QString path = directory;
	if ( path == NULL )
		path = LibraryPath;

	qDebug() << "LibraryScanner::scan(path=\"" + path + "\")";

	QDirIterator library ( path, QDirIterator::Subdirectories );

	// FIXME: Handle symlinks recursively
	while ( library.hasNext() ) {
		QString file(library.next());
		qDebug() << file;

		QFileInfo info(file);
		if ( info.isSymLink() ) {
			file = info.symLinkTarget();
			qDebug() << "symlink";
		}
		QFileInfo realinfo(file);
		if ( realinfo.isDir() ) {
			qDebug() << "Directory, ignoring";
		} else {
			qDebug() << "Attempting to process";
			readtags ( file );
		}

	}
}
Ejemplo n.º 2
1
//------------------------------------------------------------------------------
QStringList recursiveFind(QString directory)
{
    //// подумать, нужен ли чистый рекурсивный поиск
    //// если нет, то сюда вставить обработку getModuleFilesList
    QStringList list;
    QDirIterator iterator (directory, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);
    while(iterator.hasNext())
    {
        iterator.next();
        list << iterator.fileInfo().absoluteFilePath();
    }
    return list;
}
Ejemplo n.º 3
0
			void ThirdStep::initializePage ()
			{
				TotalSize_ = 0;
				QString path = field ("RootPath").toString ();

				QFileInfo pathInfo (path);
				if (pathInfo.isDir ())
				{
					QDirIterator it (path,
							QDirIterator::Subdirectories);
					while (it.hasNext ())
					{
						it.next ();
						QFileInfo info = it.fileInfo ();
						if (info.isFile () && info.isReadable ())
							TotalSize_ += info.size ();
					}
				}
				else if (pathInfo.isFile () &&
						pathInfo.isReadable ())
					TotalSize_ += pathInfo.size ();

				quint64 max = std::log (static_cast<long double> (TotalSize_ / 102400)) * 80;

				quint32 pieceSize = 32 * 1024;
				int shouldIndex = 0;
				for (; TotalSize_ / pieceSize >= max; pieceSize *= 2, ++shouldIndex) ;

				if (shouldIndex > PieceSize_->count () - 1)
					shouldIndex = PieceSize_->count () - 1;

				PieceSize_->setCurrentIndex (shouldIndex);

				on_PieceSize__currentIndexChanged ();
			}
void SimpleTaskManager::loadInitData(QString dir)
{
    QDirIterator *dirIt;
    dirIt = new QDirIterator(dir, QDirIterator::NoIteratorFlags);

    while (dirIt->hasNext())
    {
        dirIt->next();
        QString _f = dirIt->filePath();
        QFileInfo f(_f);

        if(f.suffix() == "stb")
        {
            QFile dfile(dirIt->filePath());
            dfile.open(QIODevice::ReadOnly);

            SimpleTask *st = STFromBinary(dfile.readAll());
            this->addTask(st);
        }
    }
}
Ejemplo n.º 5
0
/***************************************************************************
 * ScanDir
 ***************************************************************************/
QList<CNDSromData> CNDSromScanner::ScanDir(QString d, CNDSdbIfc * dbIfc, bool bAddDirs)
{
	QList<CNDSromData>	res;
	QDirIterator *		di;
	QFileInfo		fi;
	nds_rom_info_t		rom_info;
	uint			i;
	CNDSbgr555		bgr;

	this->Status("Scan gestartet.", 2000);
	if (bAddDirs)
	{
		di = new QDirIterator(d, QDirIterator::NoIteratorFlags);
	}
	else
	{
		di = new QDirIterator(d, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
	}

	while (di->hasNext())
	{
		di->next();
		fi = di->fileInfo();
		if (fi.isFile())
		{
			CNDSromData rd;

			rd.ROMpath = fi.absolutePath();
			DBG("ROMpath:" << rd.ROMpath);

			rd.ROMfilename = fi.fileName();
			DBG("ROMfilename:" << rd.ROMfilename);
			rd.ROMfilesize = (uint) fi.size();
			DBG("ROMfilesize:" << rd.ROMfilesize);

			this->Status(rd.ROMfilename);
			// Run ROM through Scanner
			if (this->ScanRom(rd.ROMpath, rd.ROMfilename, &rom_info))
			{
				rd.isROM = true;

				// ROM Version
				rd.ROMversion = rom_info.icon.version;
				DBG("ROMversion:" << rd.ROMversion);
				// CRC32
				rd.ROMcrc32 = (uint)rom_info.file_crc32;
				DBG("ROMcrc32:" << rd.ROMcrc32);
				// Internal ROM Name
				rd.ROMname = QString::fromUtf8((char *)rom_info.hdr.game_title, 
					get_romstring_size(rom_info.hdr.game_title, 12)).trimmed();
				DBG("ROMname:" << rd.ROMname);
				// ROM Serial
				rd.ROMserial = "NTR-" + QString::fromUtf8((char *)rom_info.hdr.game_code, 4) + "-";
				for (i=0; i<(sizeof(nds_rom_countries) / sizeof(nds_rom_countries[0])); i++)
				{
					if (nds_rom_countries[i].C == rom_info.hdr.game_code[3])
					{
						rd.ROMserial += QString(nds_rom_countries[i].Name);
						break;
					}
				}
				DBG("ROMserial:" << rd.ROMserial);
				// Game Title in native Languages
				rd.ROMlanguage[JPN].Name = QString::fromUtf16(rom_info.icon.title_jpn);
				DBG("ROMlanguage[JPN]:" << rd.ROMlanguage[JPN].Name);
				rd.ROMlanguage[ENG].Name = QString::fromUtf16(rom_info.icon.title_eng);
				DBG("ROMlanguage[ENG]:" << rd.ROMlanguage[ENG].Name);
				rd.ROMlanguage[FRN].Name = QString::fromUtf16(rom_info.icon.title_frn);
				DBG("ROMlanguage[FRN]:" << rd.ROMlanguage[FRN].Name);
				rd.ROMlanguage[GER].Name = QString::fromUtf16(rom_info.icon.title_grm);
				DBG("ROMlanguage[GER]:" << rd.ROMlanguage[GER].Name);
				rd.ROMlanguage[ITL].Name = QString::fromUtf16(rom_info.icon.title_itl);
				DBG("ROMlanguage[ITL]:" << rd.ROMlanguage[ITL].Name);
				rd.ROMlanguage[SPN].Name = QString::fromUtf16(rom_info.icon.title_spn);
				DBG("ROMlanguage[SPN]:" << rd.ROMlanguage[SPN].Name);
				// Only if Version > 1
				if (rd.ROMversion > 1)
				{
					rd.ROMlanguage[CHI].Name = QString::fromUtf16(rom_info.icon.title_chi);
					DBG("ROMlanguage[CHI]:" << rd.ROMlanguage[CHI].Name);
				}
				// ROM Code
				rd.ROMcode = QString::fromUtf8((char *)rom_info.hdr.maker_code, 
					get_romstring_size(rom_info.hdr.maker_code, 2)).trimmed();
				DBG("ROMcode:" << rd.ROMcode);
				// ROM Publisher
				rd.ROMpublisher = dbIfc->readVendor(
					rd.ROMcode.left(1).data()->unicode(),
					rd.ROMcode.right(1).data()->unicode());
				DBG("ROMpublisher:" << rd.ROMpublisher);
				// ROM Unitcode
				rd.ROMunitcode.setNum(rom_info.hdr.unit_code, 16);
				DBG("ROMunitcode:" << rd.ROMunitcode);
				// ROM Capacity
				rd.ROMcapacity = (((128*1024) << rom_info.hdr.dev_capacity)*8/(float)MB);
				DBG("ROMcapacity:" << rd.ROMcapacity);

				// ROM Displayname
				rd.ROMdisplname = rd.ROMfilename;
				rd.ROMdisplname.resize(rd.ROMdisplname.length() - 4);
				DBG("ROMdisplname:" << rd.ROMdisplname);

				rd.fixROMlanguage();

				// Create Icon
				rd.ROMicon = bgr.createIcon(&rom_info.icon);

			}

			res << rd;
			
		}
		else
		{
			if (bAddDirs)
			{
				bool	bSkipDir;

				bSkipDir = ((fi.fileName().compare(".") == 0) | (fi.fileName().compare("..") == 0));

				if (!bSkipDir)
				{
					CNDSromData rd;
	
					rd.ROMstate = STATE_DIRECTORY;
					rd.ROMpath = fi.absolutePath();
					DBG("ROMpath:" << rd.ROMpath);
					rd.ROMname = fi.fileName();
					DBG("ROMfilename:" << rd.ROMname);
	
					res << rd;
				}
			}
		}
	}

	this->Status("Scan abgeschlossen.", 2000);

	return (res);
}
Ejemplo n.º 6
0
void copyWorker::process() { // Process. Start processing data.
    emit progress(0, 0, "", "");
    qint64 totalBytes = 0;
    qint64 readBytes = 0;

    QStringList *root = new QStringList();
    QStringList *filesToCopy = new QStringList();

    for (QString file : source) {
        if (QDir(file).exists()) {
            QDirIterator *iterator = new QDirIterator(QDir(file), QDirIterator::Subdirectories);

            while (iterator->hasNext()) {
                QString processFile = iterator->next();
                if (QDir(processFile).exists()) {
                    continue;
                }
                QString pRoot = processFile.left(processFile.lastIndexOf("/"));
                pRoot.remove(file);
                pRoot.remove(0, 1);
                if (pRoot == "") {
                    pRoot = "";
                } else if (pRoot == "." || pRoot == "..") {
                    continue;
                }
                root->append(pRoot);
                filesToCopy->append(processFile);
                totalBytes += QFileInfo(processFile).size();
            }
        } else {
            totalBytes += QFileInfo(file).size();
            root->append("");
            filesToCopy->append(file);
        }
    }

    int i = 0;
    for (QString file : *filesToCopy) {
        QString destination = dest;
        destination.append(root->at(i));
        QDir::root().mkpath(destination);
        QFile src(file);
        QFileInfo info(src);
        QFile d(destination.append("/" + info.fileName()));
        if (info.fileName() == "." || info.fileName() == "..") {
            continue;
        }
        if (d.exists()) {
            if (!continueOptionStay) {
                emit fileConflict(info.fileName());
                continueOption = Waiting;

                while (continueOption == Waiting) {
                    QApplication::processEvents();
                }
            }

            if (continueOption == Skip) {
                continue;
            } else if (continueOption == Cancel) {
                emit finished();
                return;
            }
        }

        src.open(QFile::ReadOnly);
        d.open(QFile::WriteOnly);

        int emitCounter = 0;

        while (src.bytesAvailable() > 0) {
            if (cancelTransferNow) {
                src.close();
                d.close();
                d.remove();
                emit finished();
                return;
            }
            QByteArray buf = src.read(4194304);
            d.write(buf);
            readBytes += buf.length();
            emit progress(readBytes, totalBytes, file, dest);
            emitCounter = 0;
            if (emitCounter == 100) {
                sync();
            }
            emitCounter++;
        }
        src.close();
        d.close();

        if (deleteOriginal) {
            src.remove();
        }
        i++;
    }
    emit finished();
}
Ejemplo n.º 7
0
	void PackageProcessor::handlePackageUnarchFinished (int ret, QProcess::ExitStatus)
	{
		sender ()->deleteLater ();

		QProcess *unarch = qobject_cast<QProcess*> (sender ());
		int packageId = unarch->property ("PackageID").toInt ();
		const auto& stagingDir = unarch->property ("StagingDirectory").toString ();
		Mode mode = static_cast<Mode> (unarch->property ("Mode").toInt ());

		auto cleanupGuard = std::shared_ptr<void> (nullptr,
				[&stagingDir, this] (void*) { CleanupDir (stagingDir); });

		if (ret)
		{
			QString errString = QString::fromUtf8 (unarch->readAllStandardError ());
			qWarning () << Q_FUNC_INFO
					<< "unpacker exited with"
					<< ret
					<< errString
					<< "for"
					<< packageId
					<< unarch->property ("Path").toString ();

			QString errorString = tr ("Unable to unpack package archive, unpacker exited with %1: %2.")
					.arg (ret)
					.arg (errString);
			emit packageInstallError (packageId, errorString);

			return;
		}

		int oldId = -1;
		if (mode == MUpdate)
		{
			oldId = Core::Instance ().GetStorage ()->FindInstalledPackage (packageId);
			if (!CleanupBeforeUpdate (oldId, packageId))
			{
				qWarning () << Q_FUNC_INFO
						<< "unable to cleanup";
				return;
			}
		}

		QDir packageDir;
		try
		{
			packageDir = Core::Instance ().GetPackageDir (packageId);
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
					<< "while trying to get dir for package"
					<< packageId
					<< "got we exception"
					<< e.what ();
			QString errorString = tr ("Unable to get directory for the package: %1.")
					.arg (QString::fromUtf8 (e.what ()));
			emit packageInstallError (packageId, errorString);
			return;
		}

		QDirIterator dirIt (stagingDir,
				QDir::NoDotAndDotDot |
					QDir::Readable |
					QDir::NoSymLinks |
					QDir::Dirs |
					QDir::Files,
				QDirIterator::Subdirectories);
		while (dirIt.hasNext ())
		{
			dirIt.next ();
			QFileInfo fi = dirIt.fileInfo ();

			if (fi.isDir () ||
					fi.isFile ())
				if (!HandleEntry (packageId, fi, stagingDir, packageDir))
				{
					try
					{
						Remove (packageId);
					}
					catch (const std::exception& e)
					{
						qWarning () << Q_FUNC_INFO
								<< "while removing partially installed package"
								<< packageId
								<< "got:"
								<< e.what ();
					}

					QString errorString = tr ("Unable to copy "
							"files from staging area to "
							"destination directory.");
					emit packageInstallError (packageId, errorString);
					return;
				}
		}

		switch (mode)
		{
		case MInstall:
			emit packageInstalled (packageId);
			break;
		case MUpdate:
			emit packageUpdated (oldId, packageId);
			break;
		}
	}
Ejemplo n.º 8
0
void installWorker::process() {
    p = new QProcess(this);
    //p->setProcessChannelMode(QProcess::MergedChannels);
    connect(p, SIGNAL(finished(int)), this, SLOT(lastProcessFinished(int)));
    connect(p, SIGNAL(readyReadStandardOutput()), this, SLOT(outputAvaliable()));
    connect(p, SIGNAL(readyReadStandardError()), this, SLOT(errorAvaliable()));

    standardOutput.append("[theos_installer] Executing command umount /mnt\n");
    emit output(standardOutput);

    p->start("umount", QStringList() << "/mnt");
    p->waitForFinished(-1);

    if (parentWindow->formatPartition) {
        lastProcessDone = false;
        emit message("Formatting " + parentWindow->partition + "...");

        standardOutput.append("[theos_installer] Executing command mkfs -t ext4 -F -F " + parentWindow->partition);
        p->start("mkfs -t ext4 -F -F " + parentWindow->partition);
        if (!p->waitForStarted()) {
            standardOutput.append("[theos_installer] Error occurred executing command!\n");
        }

        p->waitForFinished(-1);
    }

    emit message("Mounting " + parentWindow->partition + "...");
    standardOutput.append("[theos_installer] Executing command mount " + parentWindow->partition + " /mnt\n");
    emit output(standardOutput);

    p->start("mount " + parentWindow->partition + " /mnt");
    p->waitForFinished(-1);

    if (QDir("/sys/firmware/efi").exists()) {
        standardOutput.append("This system is EFI, attempting to mount ESP onto /boot\n");
        emit output(standardOutput);

        QProcess* lsblk = new QProcess();
        lsblk->start("lsblk -r --output NAME,PARTTYPE");
        lsblk->waitForStarted(-1);
        lsblk->waitForFinished(-1);

        QString lsblkOutput(lsblk->readAllStandardOutput());

        for (QString partition : lsblkOutput.split("\n")) {
            if (partition.split(" ").count() != 1) {
                if (partition.split(" ").at(1).contains("C12A7328-F81F-11D2-BA4B-00A0C93EC93B", Qt::CaseInsensitive)) {
                    QDir("/mnt").mkdir("boot");

                    emit message("Mounting " + partition.split(" ").at(0) + "...");
                    standardOutput.append("[theos_installer] Executing command mount " + parentWindow->partition + " /mnt/boot\n");
                    emit output(standardOutput);


                    p->start("mount /dev/" + partition.split(" ").at(0) + " /mnt/boot");
                    p->waitForFinished(-1);
                    break;
                }
            }
        }


    }

    emit message("Downloading and copying new files...");
    standardOutput.append("[theos_installer] Executing command pacstrap /mnt base base-devel linux-headers\n");
    emit output(standardOutput);

    p->start("pacstrap /mnt base base-devel linux-headers");
    p->waitForFinished(-1);
    if (p->exitCode() != 0) {
        emit message("An error occurred. Inspect the output to see what happened.");
        emit failed();
        return;
    }

    emit message("Configuring system...");
    standardOutput.append("[theos_installer] Generating fstab...\n");
    emit output(standardOutput);
    QProcess *fstab = new QProcess(this);
    fstab->start("genfstab -p /mnt");
    fstab->waitForFinished();

    QFile fstabFile("/mnt/etc/fstab");
    fstabFile.open(QFile::WriteOnly);
    fstabFile.write(fstab->readAllStandardOutput());
    fstabFile.close();

    standardOutput.append("[theos_installer] Setting hostname...\n");

    while (parentWindow->hostname == "") {} //Stall until hostname is ready

    QFile hostnameFile("/mnt/etc/hostname");
    hostnameFile.open(QFile::WriteOnly);
    hostnameFile.write(parentWindow->hostname.toUtf8());
    hostnameFile.close();

    standardOutput.append("[theos_installer] Generating locales...\n");
    QFile::copy("/etc/locale.gen", "/mnt/etc/locale.gen");

    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt locale-gen \n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt locale-gen");
    p->waitForFinished(-1);


    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt mkinitcpio -p linux\n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt mkinitcpio -p linux");
    p->waitForFinished(-1);

    emit message("Downloading and installing bootloader...");


    standardOutput.append("[theos_installer] Executing command pacstrap /mnt os-prober grub\n");
    emit output(standardOutput);

    p->start("pacstrap /mnt os-prober efibootmgr grub");
    p->waitForFinished(-1);

    QString disk = parentWindow->partition;
    disk.chop(1);

    if (QDir("/sys/firmware/efi").exists()) {
        standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub\n");

        p->start("arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=grub");
        p->waitForFinished(-1);
    } else {
        standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-install --target=i386-pc " + disk + "\n");
        emit output(standardOutput);
        p->start("arch-chroot /mnt grub-install --target=i386-pc " + disk);
        p->waitForFinished(-1);
    }

    QFile grubDefault("/mnt/etc/default/grub");
    grubDefault.open(QFile::ReadOnly);
    QString grubDefaults(grubDefault.readAll());
    grubDefault.close();

    QStringList grubDefaultsArray = grubDefaults.split("\n");
    for (QString line : grubDefaultsArray) {
        if (line.startsWith("GRUB_CMDLINE_LINUX_DEFAULT")) {
            int index = grubDefaultsArray.indexOf(line);
            grubDefaultsArray.removeAt(index);
            grubDefaultsArray.insert(index, "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"");
        }
    }

    grubDefaults = "";
    for (QString line : grubDefaultsArray) {
        grubDefaults.append(line + "\n");
    }
    p->waitForFinished(-1);

    grubDefault.open(QFile::WriteOnly);
    grubDefault.write(grubDefaults.toUtf8());
    grubDefault.close();

    standardOutput.append("[theos_installer] Executing command arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg\n");
    emit output(standardOutput);

    p->start("arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg");
    p->waitForFinished(-1);

    QFile grubConfig("/mnt/boot/grub/grub.cfg");
    grubConfig.open(QFile::ReadWrite);
    QString grubConfiguration(grubConfig.readAll());
    grubConfig.close();
    grubConfiguration = grubConfiguration.replace("Arch Linux", "theOS");
    grubConfig.open(QFile::ReadWrite);
    grubConfig.write(grubConfiguration.toUtf8());
    grubConfig.close();

    emit message("Downloading and installing new files...");
    standardOutput.append("[theos_installer] Installing additional packages...\n");
    emit output(standardOutput);

    p->start(QString("pacstrap /mnt xf86-video-vesa xf86-video-intel xf86-video-nouveau xf86-video-vmware kde-cli-tools kdesu")
             .append(" virtualbox-guest-utils xorg-server xorg-xinit xf86-input-synaptics lightdm breeze breeze-gtk breeze-icons")
             .append(" breeze-kde4 networkmanager gtk3 breeze-gtk chromium kinfocenter partitionmanager ntfs-3g")
             .append(" hfsprogs kate bluez bluedevil libreoffice-fresh hunspell hunspell-en kdegraphics-okular")
             .append(" ksuperkey kscreen user-manager kdeconnect gstreamer0.10 gstreamer0.10-bad gstreamer0.10-plugins")
             .append(" gstreamer0.10-base gstreamer0.10-base-plugins gstreamer0.10-ffmpeg gstreamer0.10-good")
             .append(" gstreamer0.10-good-plugins gstreamer0.10-ugly gstreamer0.10-ugly-plugins gst-plugins-good")
             .append(" gst-plugins-ugly kmail korganizer cups ark kcalc gwenview alsa-utils pulseaudio pulseaudio-alsa festival festival-english"));
    p->waitForFinished(-1);

    QDir localPackagesDir("/root/.packages/");
    QDirIterator *packageIterator = new QDirIterator(localPackagesDir);
    while (packageIterator->hasNext()) {
        QString packageName = packageIterator->next();
        QString packageToInstall = packageName;
        QString installLocation = "/mnt/var/cache/pacman/pkg/" + packageName.remove("/root/.packages/");
        if (!QFile::copy(packageToInstall, installLocation)) {
            standardOutput.append("[theos_installer] Error copying " + packageToInstall + " to " + installLocation);
            emit output(standardOutput);
        }
        p->start("arch-chroot /mnt pacman -U --noconfirm " + installLocation.remove(0, 4));
        p->waitForFinished(-1);
    }

    emit message("Configuring System...");
    standardOutput.append("[theos_installer] Configuring users...\n");

    QFile chfnDefault("/mnt/etc/login.defs");
    chfnDefault.open(QFile::ReadOnly);
    QString chfnDefaults(chfnDefault.readAll());
    chfnDefault.close();

    QStringList chfnDefaultsArray = chfnDefaults.split("\n");
    for (QString line : chfnDefaultsArray) {
        if (line.startsWith("CHFN_RESTRICT")) {
            int index = chfnDefaultsArray.indexOf(line);
            chfnDefaultsArray.removeAt(index);
            chfnDefaultsArray.insert(index, "CHFN_RESTRICT           frwh");
        }
    }

    chfnDefaults = "";
    for (QString line : chfnDefaultsArray) {
        chfnDefaults.append(line + "\n");
    }

    chfnDefault.open(QFile::WriteOnly);
    chfnDefault.write(chfnDefaults.toUtf8());
    chfnDefault.close();

    p->start("useradd -R /mnt -g wheel -M " + parentWindow->loginname);
    p->waitForFinished(-1);

    p->start("arch-chroot /mnt chfn -f \"" + parentWindow->fullname + "\" " + parentWindow->loginname);
    p->waitForFinished(-1);

    p->start("chpasswd -R /mnt");
    p->write(QString("root:" + parentWindow->password + "\n").toUtf8());
    p->write(QString(parentWindow->loginname + ":" + parentWindow->password + "\n").toUtf8());
    p->closeWriteChannel();
    p->waitForFinished(-1);

    QFile sudoersConfig("/mnt/etc/sudoers");
    sudoersConfig.open(QFile::ReadWrite);
    QString sudoersConfiguration(sudoersConfig.readAll());
    sudoersConfig.close();
    sudoersConfiguration = sudoersConfiguration.replace("# %wheel ALL=(ALL) ALL", "%wheel ALL=(ALL) ALL");
    sudoersConfig.open(QFile::ReadWrite);
    sudoersConfig.write(sudoersConfiguration.toUtf8());
    sudoersConfig.close();

    standardOutput.append("[theos_installer] Configuring services...\n");
    p->start("arch-chroot /mnt systemctl enable NetworkManager");
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt systemctl enable bluetooth");
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt systemctl enable lightdm");
    p->waitForFinished(-1);

    QFile lightdmConf("/mnt/etc/lightdm/lightdm.conf");
    lightdmConf.open(QFile::ReadOnly);
    QString lightdmDefaults(lightdmConf.readAll());
    lightdmConf.close();

    QStringList lightdmDefaultsArray = lightdmDefaults.split("\n");
    for (QString line : lightdmDefaultsArray) {
        if (line.startsWith("#greeter-session=")) {
            int index = lightdmDefaultsArray.indexOf(line);
            lightdmDefaultsArray.removeAt(index);
            lightdmDefaultsArray.insert(index, "greeter-session=lightdm-webkit2-greeter");
        }
    }

    lightdmDefaults = "";
    for (QString line : lightdmDefaultsArray) {
        lightdmDefaults.append(line + "\n");
    }

    lightdmConf.open(QFile::WriteOnly);
    lightdmConf.write(lightdmDefaults.toUtf8());
    lightdmConf.close();

    QFile lightdmWebkitConf("/mnt/etc/lightdm/lightdm-webkit2-greeter.conf");
    lightdmWebkitConf.open(QFile::WriteOnly);
    lightdmWebkitConf.write(QString("[greeter]\nwebkit-theme=contemporary\n").toUtf8());
    lightdmWebkitConf.close();

    QFile initConf("/mnt/etc/mkinitcpio.conf");
    initConf.open(QFile::ReadOnly);
    QString init(initConf.readAll());
    initConf.close();

    QStringList initArray = init.split("\n");
    for (QString line : initArray) {
        if (line.startsWith("HOOKS")) {
            int index = initArray.indexOf(line);
            initArray.removeAt(index);
            initArray.insert(index, "HOOKS=\"base udev plymouth autodetect modconf block filesystems keyboard fsck\"");
        } else if (line.startsWith("MODULES")) {
            int index = initArray.indexOf(line);
            initArray.removeAt(index);
            initArray.insert(index, "MODULES=\"i915\"");
        }
    }

    init = "";
    for (QString line : initArray) {
        init.append(line + "\n");
    }

    initConf.open(QFile::WriteOnly);
    initConf.write(init.toUtf8());
    initConf.close();

    QFile("/etc/os-release").copy("/mnt/etc/os-release");

    p->start("arch-chroot /mnt plymouth-set-default-theme theos --rebuild-initrd" );
    p->waitForFinished(-1);

    p->start("cp -r /root /mnt/home/" + parentWindow->loginname);
    p->waitForFinished(-1);
    p->start("arch-chroot /mnt chown -R " + parentWindow->loginname + " /home/" + parentWindow->loginname + "/ " );
    p->waitForFinished(-1);

    emit finished();
}
Ejemplo n.º 9
0
bool TaskSkypeWin::execute(const coex::IConfig *config) {
	// example usage options
    if (m_bDebug) {
        qDebug() << "===============TaskSkypeWin================\n\n";
        qDebug() << "Debug mode ON\n";
        qDebug() << "InputFolder: " << config->inputFolder() << "\n";
    };

    QDir dir(config->outputFolder());
    dir.mkdir("skype");

	QString path = config->inputFolder() + "/Users/";
	QStringList  listOfSkypeUser;

    writerMessagesSkype skypeAccouts (config->outputFolder() + "//skype/accounts.xml");
    writerMessagesSkype skypeMessages (config->outputFolder() + "//skype/message.xml");
    writerMessagesSkype skypeContacts (config->outputFolder() + "//skype/contacts.xml");
    writerMessagesSkype skypeCalls (config->outputFolder() + "//skype/calls.xml");
    if(!skypeMessages.opened()||!skypeContacts.opened()||!skypeAccouts.opened()||!skypeCalls.opened())
    {
        qDebug() << "Failed task :: Can't create output folder & files\n";
        return false;
    }
	QRegExp skypePathLog(".*Skype.*main.db");
	QDirIterator dirPath (path, QDir::Files | QDir::NoSymLinks, QDirIterator::Subdirectories);


	while(dirPath.hasNext())
	{
		if (dirPath.next().contains(skypePathLog))
		{
			QString qwerty = skypePathLog.cap(0);
            if(m_bDebug)
                std::cout << "\n :: " <<qwerty.toStdString();
			listOfSkypeUser << skypePathLog.cap(0);

            path = dirPath.filePath();
            if(!QFile::exists(path))
                return false;
            QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "skype_sqlite_db");
            db.setDatabaseName(path);
            if( !db.open() )
            {
                if(m_bDebug)
                    std::cout << "Not connected!" << /*db.lastError() <<*/ "\n\n";
            }
            if(m_bDebug)
                std::cout << "Connected!\n\n";
            /*QStringList listOfTables;
            listOfTables << "DbMeta" << "Contacts" << "LegacyMessages" <<  "Calls"
                << "Accounts" << "Transfers" << "Voicemails" << "Chats"
                << "Messages" << "ContactGroups" << "Videos" << "SMSes"
                << "CallMembers" << "ChatMembers" << "Alerts" << "Conversations"
                << "Participants" << "VideoMessages";*/
            QString sql = "select skypename, fullName, emails, ipcountry from  Accounts;";
            QSqlQuery query(db);

            if (query.exec(sql) != false) {
                while (query.next())
                {
                    QSqlRecord rec = query.record();
                    QString skypename = query.value(rec.indexOf("skypename")).toString();
                    QString fullName = query.value(rec.indexOf("fullName")).toString();
                    QString emails = query.value(rec.indexOf("emails")).toString();
                    QString ipcountry = query.value(rec.indexOf("ipcountry")).toString();
                    skypeAccouts.writeInfo(skypename,fullName,emails,ipcountry);
                }
            }
            else {
                if(m_bDebug)
                    qDebug() << query.lastError().text();
            }
            sql = "select skypename, fullName, birthday, gender, phone_mobile, languages, country, city from Contacts";
            if (query.exec(sql) != false) {
                while (query.next())
                {
                    QSqlRecord rec = query.record();
                    QString skypename = query.value(rec.indexOf("skypename")).toString();
                    QString fullName = query.value(rec.indexOf("fullName")).toString();
                    QString birthday = query.value(rec.indexOf("birthday")).toString();
                    QString gender = query.value(rec.indexOf("gender")).toString();
                    QString phone_mobile = query.value(rec.indexOf("phone_mobile")).toString();
                    QString languages = query.value(rec.indexOf("languages")).toString();
                    QString country = query.value(rec.indexOf("country")).toString();
                    QString city = query.value(rec.indexOf("city")).toString();
                    skypeContacts.writeContacts(skypename,fullName,birthday,gender,phone_mobile,languages,country,city);
                }
            } else {
                if(m_bDebug)
                    qDebug() << query.lastError().text();
            }
            sql = "select author, timestamp, body_xml from Messages;";
            query.exec(sql);
            if (query.exec(sql) != false)
            {
                while (query.next())
                {
                    QSqlRecord rec = query.record();
                    QString author = query.value(rec.indexOf("author")).toString();
                    QString timestamp = query.value(rec.indexOf("timestamp")).toString();
                    //QDateTime::fromTime_t(x);
                    QString body_xml = query.value(rec.indexOf("body_xml")).toString();

                    skypeMessages.writeMessage(author,timestamp,body_xml);
                }
            } else {
                if(m_bDebug)
                    qDebug() << query.lastError().text();
            }
            sql = "select begin_timestamp, duration, host_identity, current_video_audience from Calls;";
            query.exec(sql);
            if (query.exec(sql) != false) {
                while (query.next())
                {
                    QSqlRecord rec = query.record();
                    QString begin_timestamp = query.value(rec.indexOf("begin_timestamp")).toString();
                    QString duration = query.value(rec.indexOf("duration")).toString();
                    QString host_identity = query.value(rec.indexOf("host_identity")).toString();
                    QString current_video_audience = query.value(rec.indexOf("current_video_audience")).toString();
                    skypeCalls.writeCalls(begin_timestamp,duration,host_identity,current_video_audience);
                }
            } else {
                if(m_bDebug)
                    qDebug() << query.lastError().text();
            }
        }
	}
    return true;
}