コード例 #1
0
void CodecsInstaller::okClicked()
{
    bool ok = installFile(":/libmad.so", "/opt/qtmoko/lib/libmad.so.0")
           && installFile(":/libmadplugin.so",
               "/opt/qtmoko/plugins/codecs/libmadplugin.so");

    if(ok) {
        QMessageBox::information(this, tr("codecs installer"),
            tr("MP3 codec installed sucessfully, you can uninstall this program now."));
        close();
    }
}
コード例 #2
0
int FwLoader::loadSingle(FILE *f)
{
    long pos = ftell(f);

    fseek(f, 0L, SEEK_END);
    long endpos = ftell(f);     // determine file length

    fseek(f, pos, SEEK_SET);    // reset

    unsigned swVersion, hwVersion;
    if (!bootloaderVersionIsCompatible(swVersion, hwVersion)) {
        return EIO;
    }

    /*
     * This file doesn't specify which hardware version it was built for.
     * Because we can't guarantee the version of the hardware, we decline
     * to install on anything other than the default HW rev.
     *
     * This obviously doesn't address the case in which somebody builds
     * for a new HW rev but packages it in an old deploy format,
     * but maybe it helps prevent a few mixups.
     */

    if (hwVersion != DEFAULT_HW_VERSION) {
        fprintf(stderr, "error: attempting to install untagged firmware on non-default hardware\n");
        return EIO;
    }

    if (!installFile(f, endpos - pos)) {
        return EIO;
    }

    return EOK;
}
コード例 #3
0
void createLegalFiles( const QString &directory, const QString &name, const QString &email )
{
    QDir input( directory );
    QFile authorsFile( input.filePath( "AUTHORS.txt" ) );
    if ( authorsFile.open( QFile::WriteOnly | QFile::Truncate ) ) {
        QTextStream stream( &authorsFile );
        stream << name << " <" << email << ">";
    }
    authorsFile.close();

    QFile licenseFile( input.filePath( "LICENSE.txt" ) );
    if ( licenseFile.open( QFile::WriteOnly | QFile::Truncate ) ) {
        QTextStream stream( &licenseFile );
        stream << "The ogg files in this directory are licensed under the creative commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license. ";
        stream << "See http://creativecommons.org/licenses/by-sa/3.0/ and the file CC-BY-SA-3.0 in this directory.";
    }
    licenseFile.close();

    QFile installFile( input.filePath( "INSTALL.txt" ) );
    if ( installFile.open( QFile::WriteOnly | QFile::Truncate ) ) {
        QTextStream stream( &installFile );
        stream << "To install this voice guidance speaker in Marble, copy the entire directory to the audio/speakers/ directory in Marble's data path.\n\n";
        stream << "For example, if this directory is called 'MySpeaker' and you want to use it on the Nokia N900, copy the directory with all files to /home/user/MyDocs/.local/share/marble/audio/speakers/MySpeaker\n\n";
        stream << "Afterwards start Marble on the N900 and press the routing info box (four icons on the bottom) for two seconds with the pen. Enter the configuration dialog and choose the 'MySpeaker' speaker.\n\n";
        stream << "Check http://edu.kde.org/marble/speakers.php for updates and more speakers.";
    }
    installFile.close();
}
コード例 #4
0
int FwLoader::loadContainer(FILE *f)
{
    unsigned swVersion, hwVersion;
    if (!bootloaderVersionIsCompatible(swVersion, hwVersion)) {
        return EIO;
    }

    uint32_t fileFormatVersion;
    if (fread(&fileFormatVersion, sizeof fileFormatVersion, 1, f) != 1) {
        return EIO;
    }

    for (;;) {

        Header hdr;
        if (fread(&hdr, sizeof hdr, 1, f) != 1) {
            if (!feof(f)) {
                fprintf(stderr, "fin read err\n");
                return EIO;
            }

            fprintf(stderr, "no image found for bootloader HW Rev %d\n", hwVersion);
            return EINVAL;
        }

        // look for a firmware binary that matches this base's hwVersion
        // and try to install it
        switch (hdr.key) {

        case Deployer::FirmwareBinary: {

            uint32_t hwRev, fwSize;
            if (!readFirmwareBinaryHeader(f, hwRev, fwSize)) {
                return EIO;
            }

            // found a valid hardware rev?
            if (hwRev == hwVersion) {
                return installFile(f, fwSize) ? EOK : EIO;
            }

            fseek(f, fwSize, SEEK_CUR); // skip data we're not interested in
            break;
        }

        default:
            // skip past data we're not interested in
            fseek(f, hdr.size, SEEK_CUR);
            break;
        }
    }

    return EINVAL;  // didn't find a file to install
}
コード例 #5
0
void UpdateInstaller::installFiles()
{
	std::vector<UpdateScriptFile>::const_iterator iter = m_script->filesToInstall().begin();
	int filesInstalled = 0;
	for (;iter != m_script->filesToInstall().end();iter++)
	{
		installFile(*iter);
		++filesInstalled;
		if (m_observer)
		{
			int toInstallCount = static_cast<int>(m_script->filesToInstall().size());
			double percentage = ((1.0 * filesInstalled) / toInstallCount) * 100.0;
			m_observer->updateProgress(static_cast<int>(percentage));
		}
	}
}
コード例 #6
0
void InstallDialog::downloadNextFile()
{
    //TRACE_OBJ
    if (!m_itemsToInstall.count()) {
        m_ui.cancelButton->setEnabled(false);
        m_ui.closeButton->setEnabled(true);
        m_ui.statusLabel->setText(tr("Done."));
        m_ui.progressBar->hide();
        updateDocItemList();
        updateInstallButton();
        return;
    }

    QListWidgetItem *item = m_itemsToInstall.dequeue();
    m_currentCheckSum = item->data(QCH_CHECKSUM).toString();
    QString fileName = item->data(QCH_FILENAME).toString();
    QString saveFileName = m_ui.pathLineEdit->text() + QDir::separator()
        + fileName;

    if (QFile::exists(saveFileName)
        && QMessageBox::information(this, m_windowTitle,
        tr("The file %1 already exists. Do you want to overwrite it?")
        .arg(saveFileName), QMessageBox::Yes | QMessageBox::No,
        QMessageBox::Yes) == QMessageBox::No) {
        installFile(saveFileName);
        downloadNextFile();
        return;        
    }

    m_ui.statusLabel->setText(tr("Downloading %1...").arg(fileName));
    m_ui.progressBar->show();

    const QUrl url(QString("http://qt.nokia.com/doc/assistantdocs/") + fileName);
    
    m_httpAborted = false;
    m_networkReply = m_networkAccessManager->get(QNetworkRequest(url));
    m_networkReply->setProperty(targetFileProperty, QVariant(saveFileName));
    if (debug)
        qDebug() << "Sending " << url.toString() << saveFileName;

    m_ui.cancelButton->setEnabled(true);
    m_ui.closeButton->setEnabled(false);    
}
コード例 #7
0
ファイル: main.cpp プロジェクト: 02JanDal/soqute
int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);
	QStringList args = a.arguments();
	if (args.size() < 4) {
		out << "Usage: " << args[0] << " <version> <qtdir> <platform> [load]\n" << flush;
		return 1;
	}
	const QString version = args[1];
	const QDir qtdir = QDir(args[2]);
	const QString platform = args[3];
	if (args.size() > 5) {
		if (args[4] == "load") {
			silent = false;
		}
	}
	if (!QRegularExpression("\\d\\.\\d\\.\\d").match(version).hasMatch()) {
		out << "<version> has to be in the format #.#.#\n" << flush;
		return 1;
	}

	const QString short_version = version.left(3);

	GetFiles::version = version;

	// mappings etc.
	QList<FileGroup> mappings;
	mappings.append(FileGroup("bin", &GetFiles::binaryFiles));
	mappings.append(FileGroup("doc", &GetFiles::docFiles));
	mappings.append(FileGroup("examples", &GetFiles::exampleFiles));
	mappings.append(FileGroup("imports", &GetFiles::importsFiles));
	mappings.append(FileGroup("include", &GetFiles::includeFolders));
	mappings.append(FileGroup("lib", &GetFiles::libFiles));
	mappings.append(FileGroup("libexec", &GetFiles::libExecFiles));
	mappings.append(FileGroup("mkspecs", &GetFiles::mkSpecFiles));
	mappings.append(FileGroup("phrasebooks", &GetFiles::phrasebookFiles));
	mappings.append(FileGroup("plugins", &GetFiles::pluginNames));
	mappings.append(FileGroup("qml", &GetFiles::qmlFiles));
	mappings.append(FileGroup("translations", &GetFiles::translationFiles));
	QStringList modules;
	for (const FileGroup &files : mappings) {
		modules.append((files.fileGetter)().keys());
	}
	modules.removeDuplicates();

	out << "Copying files for the following modules: " << modules.join(", ") << "\n" << flush;

	QDir baseDir;
	for (const QString &module : modules) {
		if (baseDir.exists(module + ".tar.gz")) {
			out << "Skiping already existing module " << module << "\n" << flush;
			continue;
		}
		out << "Copying files for module " << module << "\n" << flush;
		baseDir.mkdir(module);
		QDir dir(baseDir);
		dir.cd(module);

		for (const FileGroup &files : mappings) {
			QStringList fs = (files.fileGetter)()[module];
			if (fs.isEmpty()) {
				continue;
			}
			out << "  Copying " << files.name << " files...\n" << flush;
			QDir fromDir(qtdir);
			fromDir.cd(files.name);
			QDir toDir(dir);
			toDir.mkdir(files.name);
			toDir.cd(files.name);
			copyFiles(fs, fromDir, toDir);
		}

		out << "  Creating install file for module " << module << "...\n" << flush;
		{
			QFile installFile(dir.absoluteFilePath("install.js"));
			if (!installFile.open(QFile::WriteOnly | QFile::Truncate)) {
				out << "Error opening install file: " << installFile.errorString() << "\n";
				return -1;
			}

			QTextStream js(&installFile);

			js << "FileSystem.mkpath(Paths.installPath);\n";
			for (const FileGroup &groups : mappings) {
				if (groups.fileGetter().contains(module)) {
					js << "FileSystem.install(\"" << groups.name
					   << "\", Paths.installPath + \"/" << groups.name << "\");\n";
				}
			}
			js << "\n";

			js.flush();
			installFile.close();
		}

		out << "  Creating removal file for module " << module << "...\n" << flush;
		{
			QFile removalFile(dir.absoluteFilePath("remove.js"));
			if (!removalFile.open(QFile::WriteOnly | QFile::Truncate)) {
				out << "Error opening remove file: " << removalFile.errorString() << "\n";
				return -1;
			}

			QTextStream js(&removalFile);

			for (const FileGroup &group : mappings) {
				QStringList files = (group.fileGetter)()[module];
				for (const QString &file : files) {
					js << "FileSystem.remove(Paths.installPath + \"/" << group.name << "/"
					   << file << "\");\n";
				}
			}
			js << "\n";

			js.flush();
			removalFile.close();
		}

		out << "  Creating archive for module " << module << "...\n" << flush;
		{
			KArchive *arch = new KTar(baseDir.absoluteFilePath(
				QString("%1-%2-%3.tar.gz").arg(module, version, platform)));
			arch->open(QIODevice::ReadWrite);
			for (const QString &directory : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
				arch->addLocalDirectory(dir.absoluteFilePath(directory), directory);
			}
			for (const QString &file : dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
				arch->addLocalFile(dir.absoluteFilePath(file), file);
			}
			arch->close();
		}
	}

	out << "Creating metadata file...\n" << flush;
	{
		QFile meta(baseDir.absoluteFilePath("meta.json"));
		meta.open(QFile::WriteOnly | QFile::Truncate);
		QMap<QString, QString> descs = GetFiles::descriptions();
		QMap<QString, QStringList> deps = GetFiles::dependencies();
		QMap<QString, QMap<QString, QStringList>> ndeps = GetFiles::nativeDependencies();
		QJsonArray root;
		for (const QString &module : modules) {
			QStringList dependencies = deps[module];
			dependencies.removeAll("");
			dependencies.removeDuplicates();
			QMap<QString, QStringList> nDependencies = ndeps[module];
			QJsonObject m;
			m.insert("id", module);
			m.insert("description", descs[module]);
			m.insert("version", version);
			m.insert("platform", platform);
			m.insert("url", QString("http://localhost/soqute/archives/%1-%2-%3.tar.gz")
								.arg(module, version, platform));
			QJsonArray deps;
			for (const QString &dep : dependencies) {
				QJsonObject obj;
				obj.insert("id", dep);
				obj.insert("version", version);
				deps.append(obj);
			}
			m.insert("dependencies", deps);
			QJsonObject nativeDependencies;
			for (const QString &manager : nDependencies.keys()) {
				QJsonArray packages = QJsonArray::fromStringList(nDependencies[manager]);
				nativeDependencies.insert(manager, packages);
			}
			m.insert("nativeDependencies", nativeDependencies);
			root.append(m);
		}
		meta.write(QJsonDocument(root).toJson());
	}

	out << "Installing files to server...\n" << flush;
	{
		QDir serverRoot("/var/www");
		if (!serverRoot.exists("soqute")) {
			serverRoot.mkdir("soqute");
		}
		serverRoot.cd("soqute");
		if (!serverRoot.exists("archives")) {
			serverRoot.mkdir("archives");
		}
		serverRoot.cd("archives");
		for (const QString &archive :
			 baseDir.entryList(QStringList() << "*.tar.gz", QDir::Files)) {
			out << "  Installing " << archive << " to server...\n" << flush;
			if (serverRoot.exists(archive)) {
				serverRoot.remove(archive);
			}
			QFile::copy(baseDir.absoluteFilePath(archive),
						serverRoot.absoluteFilePath(archive));
		}
		serverRoot.cdUp();
		out << "  Installing meta.json to server...\n" << flush;
		if (serverRoot.exists("meta.json")) {
			QFile server(serverRoot.absoluteFilePath("meta.json"));
			Q_ASSERT(server.open(QFile::ReadOnly | QFile::Truncate));
			QFile local(baseDir.absoluteFilePath("meta.json"));
			Q_ASSERT(local.open(QFile::ReadOnly));
			QJsonDocument serverDoc = QJsonDocument::fromJson(server.readAll());
			server.close();
			QJsonArray serverArray = serverDoc.array();
			QJsonDocument localDoc = QJsonDocument::fromJson(local.readAll());
			local.close();
			QJsonArray localArray = localDoc.array();
			QVariantList res = serverArray.toVariantList();
			res.append(localArray.toVariantList());
			Q_ASSERT(server.open(QFile::WriteOnly | QFile::Truncate));
			server.write(QJsonDocument(QJsonArray::fromVariantList(res)).toJson());
			server.close();
		} else {
			QFile::copy(baseDir.absoluteFilePath("meta.json"),
						serverRoot.absoluteFilePath("meta.json"));
		}
	}

	out << "Done\n" << flush;
	return 0;
}
コード例 #8
0
void InstallDialog::httpRequestFinished(QNetworkReply *reply)
{
    //TRACE_OBJ

    const QString targetFile = reply->property(targetFileProperty).toString();
    if (targetFile == QLatin1String(docInfoTargetFileId)) {
        m_ui.progressBar->hide();
        if (reply->error() != QNetworkReply::NoError) {
            QMessageBox::information(this, m_windowTitle,
                tr("Download failed: %1.")
                .arg(m_networkReply->errorString()));
            return;
        }
        if (!m_httpAborted) {
            while (reply->canReadLine()) {
                QByteArray ba = reply->readLine();
                const QStringList lst = QString::fromLatin1(ba.constData()).split(QLatin1Char('|'));
                if (lst.count() != 4) {
                    QMessageBox::information(this, m_windowTitle,
                        tr("Documentation info file is corrupt!"));
                } else {
                    QListWidgetItem *item = new QListWidgetItem(m_ui.listWidget);
                    item->setText(lst.at(2).trimmed());
                    item->setData(QCH_FILENAME, lst.first());
                    item->setData(QCH_NAMESPACE, lst.at(1));
                    item->setData(QCH_CHECKSUM, lst.last().trimmed());
                }
            }
            updateDocItemList();
        }
        m_ui.statusLabel->setText(tr("Done."));
        m_ui.cancelButton->setEnabled(false);        
        m_ui.closeButton->setEnabled(true);
        updateInstallButton();
        return;
    }

    // Download of file
    if (reply->error() != QNetworkReply::NoError) {
        QMessageBox::warning(this, m_windowTitle,
            tr("Download failed: %1.")
            .arg(reply->errorString()));
        downloadNextFile();
        return;
    }

    if (m_httpAborted) {
        downloadNextFile();
        return;
    }

    QFile file(targetFile);
    if (!file.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
        QMessageBox::information(this, m_windowTitle,
                                 tr("Unable to save the file %1: %2.")
                                 .arg(targetFile).arg(file.errorString()));
        downloadNextFile();
        return;
    }
    const QByteArray data = reply->readAll();
    file.write(data);
    file.close();

    const QByteArray digest = QCryptographicHash::hash(data, QCryptographicHash::Md5);
    const QString checkSum = QString::fromLatin1(digest.toHex());

    if (checkSum.isEmpty() || m_currentCheckSum != checkSum) {
        file.remove();
        QMessageBox::warning(this, m_windowTitle,
                             tr("Download failed: Downloaded file is corrupted."));
        downloadNextFile();
        return;
    }

    m_ui.statusLabel->setText(tr("Installing documentation %1...")
                              .arg(QFileInfo(targetFile).fileName()));
    m_ui.progressBar->setMaximum(0);
    m_ui.statusLabel->setText(tr("Done."));
    installFile(targetFile);
    downloadNextFile();
}