Пример #1
0
void
Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
{
    foreach ( const QString& path, moduleConfigurationCandidates( Settings::instance()->debugMode(), m_name, configFileName ) )
    {
        QFile configFile( path );
        if ( configFile.exists() && configFile.open( QFile::ReadOnly | QFile::Text ) )
        {
            QByteArray ba = configFile.readAll();

            YAML::Node doc = YAML::Load( ba.constData() );
            if ( doc.IsNull() )
            {
                cDebug() << "Found empty module configuration" << path;
                // Special case: empty config files are valid,
                // but aren't a map.
                return;
            }
            if ( !doc.IsMap() )
            {
                cWarning() << "Bad module configuration format" << path;
                return;
            }

            cDebug() << "Loaded module configuration" << path;
            m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap();
            m_emergency = m_maybe_emergency
                          && m_configurationMap.contains( EMERGENCY )
                          && m_configurationMap[ EMERGENCY ].toBool();
            return;
        }
    }
Пример #2
0
bp::object
gettext_path()
{
    // TODO: distinguish between -d runs and normal runs
    // TODO: can we detect DESTDIR-installs?
    QStringList candidatePaths = QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, "locale", QStandardPaths::LocateDirectory );
    QString extra = QCoreApplication::applicationDirPath();
    _add_localedirs( candidatePaths, extra ); // Often /usr/local/bin
    if ( !extra.isEmpty() )
    {
        QDir d( extra );
        if ( d.cd( "../share/locale" ) ) // Often /usr/local/bin/../share/locale -> /usr/local/share/locale
            _add_localedirs( candidatePaths, d.canonicalPath() );
    }
    _add_localedirs( candidatePaths, QDir().canonicalPath() ); // .

    cDebug() << "Standard paths" << candidatePaths;

    for ( auto lang : _gettext_languages() )
        for ( auto localedir : candidatePaths )
        {
            QDir ldir( localedir );
            cDebug() << "Checking" << lang << "in" <<ldir.canonicalPath();
            if ( ldir.cd( lang ) )
                return bp::object( localedir.toStdString() );
        }
    return bp::object();  // None
}
Пример #3
0
void
ViewModule::loadSelf()
{
    if ( m_loader )
    {
        PluginFactory* pf = qobject_cast< PluginFactory* >( m_loader->instance() );
        if ( !pf )
        {
            cDebug() << Q_FUNC_INFO << "No factory:" << m_loader->errorString();
            return;
        }

        m_viewStep = pf->create< Calamares::ViewStep >();
        if ( !m_viewStep )
        {
            cDebug() << Q_FUNC_INFO << "create() failed" << m_loader->errorString();
            return;
        }
//        cDebug() << "ViewModule loading self for instance" << instanceKey()
//                 << "\nViewModule at address" << this
//                 << "\nCalamares::PluginFactory at address" << pf
//                 << "\nViewStep at address" << m_viewStep;

        m_viewStep->setModuleInstanceKey( instanceKey() );
        m_viewStep->setConfigurationMap( m_configurationMap );
        ViewManager::instance()->addViewStep( m_viewStep );
        m_loaded = true;
        cDebug() << "ViewModule" << instanceKey() << "loading complete.";
    }
}
Пример #4
0
bool
canBeResized( PartitionCoreModule* core, const QString& partitionPath )
{
    //FIXME: check for max partitions count on DOS MBR
    cDebug() << "checking if" << partitionPath << "can be resized.";
    QString partitionWithOs = partitionPath;
    if ( partitionWithOs.startsWith( "/dev/" ) )
    {
        cDebug() << partitionWithOs << "seems like a good path";
        bool canResize = false;
        DeviceModel* dm = core->deviceModel();
        for ( int i = 0; i < dm->rowCount(); ++i )
        {
            Device* dev = dm->deviceForIndex( dm->index( i ) );
            Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, partitionWithOs );
            if ( candidate )
            {
                cDebug() << "found Partition* for" << partitionWithOs;
                return canBeResized( candidate );
            }
        }
    }

    cDebug() << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
    return false;
}
Пример #5
0
CalamaresApplication::CalamaresApplication( int& argc, char *argv[] )
    : QApplication( argc, argv )
    , m_mainwindow( 0 )
{
    setOrganizationName( QLatin1String( CALAMARES_ORGANIZATION_NAME ) );
    setOrganizationDomain( QLatin1String( CALAMARES_ORGANIZATION_DOMAIN ) );
    setApplicationName( QLatin1String( CALAMARES_APPLICATION_NAME ) );
    setApplicationVersion( QLatin1String( CALAMARES_VERSION ) );

    QString startupLocale = QLocale::system().uiLanguages().first();
    CalamaresUtils::installTranslator( startupLocale, this );

    QFont f = font();

    cDebug() << "Default font ====="
             << "\nPixel size:   " << f.pixelSize()
             << "\nPoint size:   " << f.pointSize()
             << "\nPoint sizeF:  " << f.pointSizeF()
             << "\nFont family:  " << f.family()
             << "\nMetric height:" << QFontMetrics( f ).height();
    // The following line blocks for 15s on Qt 5.1.0
    cDebug() << "Font height:" << QFontMetrics( f ).height();
    CalamaresUtils::setDefaultFontSize( f.pointSize() );

    cDebug() << "Available languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' );
}
Пример #6
0
bool
canBeReplaced( Partition* candidate )
{
    if ( !candidate )
        return false;

    bool ok = false;
    double requiredStorageGB = Calamares::JobQueue::instance()
                                    ->globalStorage()
                                    ->value( "requiredStorageGB" )
                                    .toDouble( &ok );

    qint64 availableStorageB = candidate->capacity();
    qint64 requiredStorageB = ( requiredStorageGB + 0.5 ) * 1024 * 1024 * 1024;
    cDebug() << "Required  storage B:" << requiredStorageB
             << QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
    cDebug() << "Storage capacity  B:" << availableStorageB
             << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
             << "for" << candidate->partitionPath() << "   length:" << candidate->length();

    if ( ok &&
         availableStorageB > requiredStorageB )
    {
        cDebug() << "Partition" << candidate->partitionPath() << "authorized for replace install.";

        return true;
    }
    return false;
}
Пример #7
0
void
ModuleManager::doInit()
{
    // We start from a list of paths in m_paths. Each of those is a directory that
    // might (should) contain Calamares modules of any type/interface.
    // For each modules search path (directory), it is expected that each module
    // lives in its own subdirectory. This subdirectory must have the same name as
    // the module name, and must contain a settings file named module.desc.
    // If at any time the module loading procedure finds something unexpected, it
    // silently skips to the next module or search path. --Teo 6/2014
    for ( const QString& path : m_paths )
    {
        QDir currentDir( path );
        if ( currentDir.exists() && currentDir.isReadable() )
        {
            const QStringList subdirs = currentDir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot );
            for ( const QString& subdir : subdirs )
            {
                currentDir.setPath( path );
                bool success = currentDir.cd( subdir );
                if ( success )
                {
                    QFileInfo descriptorFileInfo( currentDir.absoluteFilePath( QLatin1Literal( "module.desc") ) );
                    if ( ! ( descriptorFileInfo.exists() && descriptorFileInfo.isReadable() ) )
                    {
                        cDebug() << Q_FUNC_INFO << "unreadable file: "
                                 << descriptorFileInfo.absoluteFilePath();
                        continue;
                    }

                    bool ok = false;
                    QVariantMap moduleDescriptorMap = CalamaresUtils::loadYaml( descriptorFileInfo, &ok );
                    QString moduleName = ok ? moduleDescriptorMap.value( "name" ).toString() : QString();

                    if ( ok && ( moduleName == currentDir.dirName() ) &&
                            !m_availableDescriptorsByModuleName.contains( moduleName ) )
                    {
                        m_availableDescriptorsByModuleName.insert( moduleName, moduleDescriptorMap );
                        m_moduleDirectoriesByModuleName.insert( moduleName,
                                                                descriptorFileInfo.absoluteDir().absolutePath() );
                    }
                }
                else
                {
                    cWarning() << "Cannot cd into module directory "
                               << path << "/" << subdir;
                }
            }
        }
        else
            cDebug() << "ModuleManager bad search path" << path;
    }
    // At this point m_availableModules is filled with whatever was found in the
    // search paths.
    emit initDone();
}
Пример #8
0
void AudioModel::load_audio_done(AudioPlayer *audio)
{
    load_count--;

    cDebug() << "[AUDIO load done]";

    if (load_count <= 0)
    {
        cDebug() << "[AUDIO LOAD DONE sending signal]";
        load_done.emit();
    }
}
Пример #9
0
CalamaresApplication::~CalamaresApplication()
{
    cDebug( LOGVERBOSE ) << "Shutting down Calamares...";

//    if ( JobQueue::instance() )
//        JobQueue::instance()->stop();

//    delete m_mainwindow;

//    delete JobQueue::instance();

    cDebug( LOGVERBOSE ) << "Finished shutdown.";
}
Пример #10
0
void CameraModel::load_camera_done(Camera *camera)
{
    load_count--;

    cDebug() << "[CAMERA load done]";

    if (load_count <= 0)
    {

        cDebug() << "[CAMERA LOAD DONE sending signal]";
        load_done.emit();
    }
}
Пример #11
0
bool
canBeResized( Partition* candidate )
{
    if ( !candidate )
        return false;

    if ( !candidate->fileSystem().supportGrow() ||
         !candidate->fileSystem().supportShrink() )
        return false;

    if ( KPMHelpers::isPartitionFreeSpace( candidate ) )
        return false;

    if ( candidate->roles().has( PartitionRole::Primary ) )
    {
        PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() );
        if ( !table )
            return false;

        if ( table->numPrimaries() >= table->maxPrimaries() )
            return false;
    }

    bool ok = false;
    double requiredStorageGB = Calamares::JobQueue::instance()
                                    ->globalStorage()
                                    ->value( "requiredStorageGB" )
                                    .toDouble( &ok );

    qint64 availableStorageB = candidate->available();

    // We require a little more for partitioning overhead and swap file
    // TODO: maybe make this configurable?
    qint64 requiredStorageB = ( requiredStorageGB + 0.5 + 2.0 ) * 1024 * 1024 * 1024;
    cDebug() << "Required  storage B:" << requiredStorageB
             << QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
    cDebug() << "Available storage B:" << availableStorageB
             << QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
             << "for" << candidate->partitionPath() << "   length:" << candidate->length()
             << "   sectorsUsed:" << candidate->sectorsUsed() << "   fsType:" << candidate->fileSystem().name();

    if ( ok &&
         availableStorageB > requiredStorageB )
    {
        cDebug() << "Partition" << candidate->partitionPath() << "authorized for resize + autopartition install.";

        return true;
    }
    return false;
}
Пример #12
0
Calamares::JobResult
CreatePartitionTableJob::exec()
{
    Report report( 0 );
    QString message = tr( "The installer failed to create a partition table on %1." ).arg( m_device->name() );

    CoreBackend* backend = CoreBackendManager::self()->backend();
    QScopedPointer< CoreBackendDevice > backendDevice( backend->openDevice( m_device->deviceNode() ) );
    if ( !backendDevice.data() )
    {
        return Calamares::JobResult::error(
                   message,
                   tr( "Could not open device %1." ).arg( m_device->deviceNode() )
               );
    }

    QScopedPointer< PartitionTable > table( createTable() );
    cDebug() << "Creating new partition table of type" << table->typeName()
             << ", uncommitted yet:\n" << table;

    QProcess lsblk;
    lsblk.setProgram( "lsblk" );
    lsblk.setProcessChannelMode( QProcess::MergedChannels );
    lsblk.start();
    lsblk.waitForFinished();
    cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput();

    QProcess mount;
    mount.setProgram( "mount" );
    mount.setProcessChannelMode( QProcess::MergedChannels );
    mount.start();
    mount.waitForFinished();
    cDebug() << "mount:\n" << mount.readAllStandardOutput();

    bool ok = backendDevice->createPartitionTable( report, *table );
    if ( !ok )
    {
        return Calamares::JobResult::error(
                    message,
                    QString( "Text: %1\nCommand: %2\nOutput: %3\nStatus: %4" )
                        .arg( report.toText() )
                        .arg( report.command() )
                        .arg( report.output() )
                        .arg( report.status() )
               );
    }

    return Calamares::JobResult::ok();
}
Пример #13
0
void PlasmaLnfPage::winnowThemes()
{
    auto plasmaThemes = plasma_themes();
    bool winnowed = true;
    int winnow_index = 0;
    while ( winnowed )
    {
        winnowed = false;
        winnow_index = 0;

        for ( auto& enabled_theme : m_enabledThemes )
        {
            ThemeInfo* t = plasmaThemes.findById( enabled_theme.id );
            if ( t == nullptr )
            {
                cDebug() << "Removing" << enabled_theme.id;
                winnowed = true;
                break;
            }
            ++winnow_index;
        }

        if ( winnowed )
        {
            m_enabledThemes.removeAt( winnow_index );
        }
    }
}
Пример #14
0
void ActivityAudioListView::browserShowPlaylistTracks(Params &infos, Params pl_infos)
{
    if (!infos.Exists("count")) return;

    EmitSignal("browser,loading,stop", "calaos");

    cDebug() << "RESULT infos: " << pl_infos.toString();

    pl_infos.Add("count", infos["count"]);
    int count;
    from_string(infos["count"], count);

    int pl_id;
    from_string(pl_infos["id"], pl_id);

    CREATE_GENLIST_HELPER(glist);

    GenlistItemPlaylistHeader *header = new GenlistItemPlaylistHeader(evas, parent, player_current->getPlayer(), pl_infos, pl_id);
    header->Append(glist);

    for (int i = 0;i < count;i++)
    {
        GenlistItemTrack *item = new GenlistItemTrack(evas, parent, player_current->getPlayer(), i, GenlistItemTrack::TRACK_PLAYLIST, pl_id);
        item->Append(glist);
    }

    elm_naviframe_item_push(pager_browser, NULL, NULL, NULL, glist, "calaos");
}
Пример #15
0
bool IntroCode::codeSubmitFail(const RPCError &error) {
	stopCheck();
	code.setDisabled(false);
	const QString &err = error.type();
	if (err == "PHONE_NUMBER_INVALID" || err == "PHONE_CODE_EXPIRED") { // show error
		onBack();
		return true;
	} else if (err == "PHONE_CODE_EMPTY" || err == "PHONE_CODE_INVALID") {
		showError(lang(lng_bad_code));
		code.setFocus();
		return true;
	} else if (err == "PHONE_NUMBER_UNOCCUPIED") { // success, need to signUp
		intro()->setCode(sentCode);
		intro()->onIntroNext();
		return true;
	}
	if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
		showError(lang(lng_flood_error));
		code.setFocus();
		return true;
	}
	if (cDebug()) { // internal server error
		showError(err + ": " + error.description());
	} else {
		showError(lang(lng_server_error));
	}
	code.setFocus();
	return false;
}
Пример #16
0
void GenlistItemArtist::artistItemGet_cb(Params &infos)
{
    cDebug() << "Got infos..." << infos.toString();
    item_infos = infos;

    elm_genlist_item_fields_update(item, "text", ELM_GENLIST_ITEM_FIELD_TEXT);
}
Пример #17
0
void ActivityAudioListView::browserShowYearAlbum(Params &infos, Params year_infos)
{
    if (!infos.Exists("count")) return;

    EmitSignal("browser,loading,stop", "calaos");

    cDebug() << "RESULT infos: " << year_infos.toString();

    year_infos.Add("count", infos["count"]);
    int count;
    from_string(infos["count"], count);

    int year_id;
    from_string(year_infos["year"], year_id);

    CREATE_GENLIST_HELPER(glist);

    for (int i = 0;i < count;i++)
    {
        GenlistItemAlbum *item = new GenlistItemAlbum(evas, parent, player_current->getPlayer(), i, GenlistItemAlbum::ALBUM_YEAR, year_id);
        item->Append(glist);
        item->setUserData(item);
        item->item_selected.connect(sigc::mem_fun(*this, &ActivityAudioListView::albumSelected));
    }

    elm_naviframe_item_push(pager_browser, NULL, NULL, NULL, glist, "calaos");
}
Пример #18
0
QList< Calamares::job_ptr >
PartitionCoreModule::jobs() const
{
    QList< Calamares::job_ptr > lst;
    QList< Device* > devices;

    lst << Calamares::job_ptr( new ClearTempMountsJob() );

    for ( auto info : m_deviceInfos )
    {
        if ( info->isDirty() )
            lst << Calamares::job_ptr( new ClearMountsJob( info->device.data() ) );
    }

    for ( auto info : m_deviceInfos )
    {
        lst << info->jobs;
        devices << info->device.data();
    }
    cDebug() << "Creating FillGlobalStorageJob with bootLoader path" << m_bootLoaderInstallPath;
    lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) );


    QStringList jobsDebug;
    foreach ( auto job, lst )
    {
        jobsDebug.append( job->prettyName() );
    }
Пример #19
0
qint64
swapSuggestion( const qint64 availableSpaceB )
{

#define MiB * static_cast< qint64 >( 1024 ) * 1024
#define GiB * static_cast< qint64 >( 1024 ) * 1024 * 1024

    // swap(mem) = max(2, 2 * mem), if mem < 2 GiB
    //           = mem,             if 2 GiB <= mem < 8 GiB
    //           = mem / 2,         if 8 GIB <= mem < 64 GiB
    //           = 4 GiB,           if mem >= 64 GiB

    qint64 suggestedSwapSizeB = 0;
    qint64 availableRamB = CalamaresUtils::System::instance()->getPhysicalMemoryB();
    qreal overestimationFactor = 1.01;
    if ( !availableRamB )
    {
        availableRamB = CalamaresUtils::System::instance()->getTotalMemoryB();
        overestimationFactor = 1.10;
    }

    bool ensureSuspendToDisk =
        Calamares::JobQueue::instance()->globalStorage()->
            value( "ensureSuspendToDisk" ).toBool();

    if ( ensureSuspendToDisk )
    {
        if ( availableRamB < 4 GiB )
            suggestedSwapSizeB = qMax( 2 GiB, availableRamB * 2 );
        else if ( availableRamB >= 4 GiB && availableRamB < 8 GiB )
            suggestedSwapSizeB = 8 GiB;
        else
            suggestedSwapSizeB = availableRamB;

        suggestedSwapSizeB *= overestimationFactor;
    }
    else //if we don't care about suspend to disk
    {
        if ( availableRamB < 2 GiB )
            suggestedSwapSizeB = qMax( 2 GiB, availableRamB * 2 );
        else if ( availableRamB >= 2 GiB && availableRamB < 8 GiB )
            suggestedSwapSizeB = availableRamB;
        else if ( availableRamB >= 8 GiB && availableRamB < 64 GiB )
            suggestedSwapSizeB = availableRamB / 2;
        else
            suggestedSwapSizeB = 4 GiB;

        suggestedSwapSizeB *= overestimationFactor;

        // don't use more than 10% of available space
        qreal maxSwapDiskRatio = 1.10;
        qint64 maxSwapSizeB = availableSpaceB * maxSwapDiskRatio;
        if ( suggestedSwapSizeB > maxSwapSizeB )
            suggestedSwapSizeB = maxSwapSizeB;
    }

    cDebug() << "Suggested swap size:" << suggestedSwapSizeB / 1024. / 1024. /1024. << "GiB";

    return suggestedSwapSizeB;
}
Пример #20
0
void
ViewModule::loadSelf()
{
    if ( m_loader )
    {
        PluginFactory* pf = qobject_cast< PluginFactory* >( m_loader->instance() );
        if ( !pf )
        {
            cWarning() << Q_FUNC_INFO << "No factory:" << m_loader->errorString();
            return;
        }

        m_viewStep = pf->create< Calamares::ViewStep >();
        if ( !m_viewStep )
        {
            cWarning() << Q_FUNC_INFO << "create() failed" << m_loader->errorString();
            return;
        }
    }

    // TODO: allow internal view steps to be created here; they would
    //       have to be linked into the main application somehow.

    // If any method created the view step, use it now.
    if ( m_viewStep )
    {
        m_viewStep->setModuleInstanceKey( instanceKey() );
        m_viewStep->setConfigurationMap( m_configurationMap );
        ViewManager::instance()->addViewStep( m_viewStep );
        m_loaded = true;
        cDebug() << "ViewModule" << instanceKey() << "loading complete.";
    }
    else
        cWarning() << Q_FUNC_INFO << "No view step was created";
}
Пример #21
0
void debugLogWrite(const char *file, int32 line, const QString &v) {
	if (!cDebug() || !debugLogStream) return;

	const char *last = strstr(file, "/"), *found = 0;
	while (last) {
		found = last;
		last = strstr(last + 1, "/");
	}
	last = strstr(file, "\\");
	while (last) {
		found = last;
		last = strstr(last + 1, "\\");
	}
	if (found) {
		file = found + 1;
	}

	{
		QMutexLocker lock(&debugLogMutex);

		logsInitDebug(); // maybe need to reopen new file

		QString msg(QString("%1 %2 (%3 : %4)\n").arg(debugLogEntryStart()).arg(v).arg(file).arg(line));
		(*debugLogStream) << msg;
		debugLogStream->flush();
#ifdef Q_OS_WIN
//		OutputDebugString(reinterpret_cast<const wchar_t *>(msg.utf16()));
#elif defined Q_OS_MAC
        objc_outputDebugString(msg);
#elif defined Q_OS_LINUX && defined _DEBUG
//        std::cout << msg.toUtf8().constData();
#endif
	}
}
Пример #22
0
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
	sentRequest = 0;
	stopCheck();
	_pwdField.setDisabled(false);
	_codeField.setDisabled(false);
	const QString &err = error.type();
	if (err == "PASSWORD_EMPTY") {
		intro()->onIntroBack();
		return true;
	} else if (err == "PASSWORD_RECOVERY_NA") {
		recoverStartFail(error);
		return true;
	} else if (err == "PASSWORD_RECOVERY_EXPIRED") {
		_emailPattern = QString();
		onToPassword();
		return true;
	} else if (err == "CODE_INVALID") {
		showError(lang(lng_signin_wrong_code));
		_codeField.selectAll();
		_codeField.notaBene();
		return true;
	} else if (mtpIsFlood(error)) {
		showError(lang(lng_flood_error));
		_codeField.notaBene();
		return true;
	}
	if (cDebug()) { // internal server error
		showError(err + ": " + error.description());
	} else {
		showError(lang(lng_server_error));
	}
	_codeField.setFocus();
	return false;
}
Пример #23
0
QWidget*
PythonQtViewStep::widget()
{
    if ( m_widget->layout()->count() > 1 )
        cDebug() << "WARNING: PythonQtViewStep wrapper widget has more than 1 child. "
                    "This should never happen.";

    bool nothingChanged = m_cxt.evalScript(
        "_calamares_module.widget() in _calamares_module_basewidget.children()" ).toBool();
    if ( nothingChanged )
        return m_widget;

    // Else, we either don't have a child widget, or we have a child widget that
    // was previously set and doesn't apply any more since the Python module
    // set a new one.

    // First we clear the layout, which should only ever have 1 item.
    // We only remove from the layout and not delete because Python is in charge
    // of memory management for these widgets.
    while ( m_widget->layout()->itemAt( 0 ) )
        m_widget->layout()->takeAt( 0 );

    m_cxt.evalScript(
        "_calamares_module_basewidget.layout().addWidget(_calamares_module.widget())" );

    return m_widget;
}
Пример #24
0
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
	sentRequest = 0;
	stopCheck();
	_pwdField.setDisabled(false);
	_codeField.setDisabled(false);
	const QString &err = error.type();
	if (err == "PASSWORD_HASH_INVALID") {
		showError(lang(lng_signin_bad_password));
		_pwdField.selectAll();
		_pwdField.notaBene();
		return true;
	} else if (err == "PASSWORD_EMPTY") {
		intro()->onIntroBack();
	} else if (mtpIsFlood(error)) {
		showError(lang(lng_flood_error));
		_pwdField.notaBene();
		return true;
	}
	if (cDebug()) { // internal server error
		showError(err + ": " + error.description());
	} else {
		showError(lang(lng_server_error));
	}
	_pwdField.setFocus();
	return false;
}
Пример #25
0
bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
	if (MTP::isFloodError(error)) {
		stopCheck();
		_sentRequest = 0;
		showPhoneError(langFactory(lng_flood_error));
		return true;
	}
	if (MTP::isDefaultHandledError(error)) return false;

	stopCheck();
	_sentRequest = 0;
	auto &err = error.type();
	if (err == qstr("PHONE_NUMBER_FLOOD")) {
		Ui::show(Box<InformBox>(lang(lng_error_phone_flood)));
		return true;
	} else if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
		showPhoneError(langFactory(lng_bad_phone));
		return true;
	}
	if (cDebug()) { // internal server error
		auto text = err + ": " + error.description();
		showPhoneError([text] { return text; });
	} else {
		showPhoneError(langFactory(lng_server_error));
	}
	return false;
}
Пример #26
0
InstallationViewStep::InstallationViewStep( QObject* parent )
    : ViewStep( parent )
    , m_widget( new QWidget )
{
    m_progressBar = new QProgressBar;
    m_progressBar->setMaximum( 10000 );
    m_label = new QLabel;
    QVBoxLayout* layout = new QVBoxLayout( m_widget );
    QVBoxLayout* innerLayout = new QVBoxLayout;

    m_slideShow = new QQuickWidget;
    layout->addWidget( m_slideShow );
    CalamaresUtils::unmarginLayout( layout );

    layout->addLayout( innerLayout );
    m_slideShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_slideShow->setResizeMode( QQuickWidget::SizeRootObjectToView );

    m_slideShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() );

    if ( !Calamares::Branding::instance()->slideshowPath().isEmpty() )
        m_slideShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()
                                                     ->slideshowPath() ) );

    innerLayout->addSpacing( CalamaresUtils::defaultFontHeight() / 2 );
    innerLayout->addWidget( m_progressBar );
    innerLayout->addWidget( m_label );

    connect( JobQueue::instance(), &JobQueue::progress,
             this, &InstallationViewStep::updateFromJobQueue );

    cDebug() << "QML import paths:" << m_slideShow->engine()->importPathList();
}
Пример #27
0
void Application::onEnableDebugMode() {
	if (!cDebug()) {
		logsInitDebug();
		cSetDebug(true);
	}
	App::wnd()->hideLayer();
}
Пример #28
0
void Application::startUpdateCheck(bool forceWait) {
	updateCheckTimer.stop();
	if (updateRequestId || updateThread || updateReply || !cAutoUpdate()) return;
	
	int32 updateInSecs = cLastUpdateCheck() + 3600 + (rand() % 3600) - unixtime();
	bool sendRequest = (updateInSecs <= 0 || updateInSecs > 7200);
	if (!sendRequest && !forceWait) {
		QDir updates(cWorkingDir() + "tupdates");
		if (updates.exists()) {
			QFileInfoList list = updates.entryInfoList(QDir::Files);
			for (QFileInfoList::iterator i = list.begin(), e = list.end(); i != e; ++i) {
                if (QRegularExpression("^(tupdate|tmacupd|tlinuxupd|tlinux32upd)\\d+$", QRegularExpression::CaseInsensitiveOption).match(i->fileName()).hasMatch()) {
					sendRequest = true;
				}
			}
		}
	}
    if (cManyInstance() && !cDebug()) return; // only main instance is updating

	if (sendRequest) {
		QNetworkRequest checkVersion(cUpdateURL());
		if (updateReply) updateReply->deleteLater();

		App::setProxySettings(updateManager);
		updateReply = updateManager.get(checkVersion);
		connect(updateReply, SIGNAL(finished()), this, SLOT(updateGotCurrent()));
		connect(updateReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(updateFailedCurrent(QNetworkReply::NetworkError)));
//		updateRequestId = MTP::send(MTPhelp_GetAppUpdate(MTP_string(cApiDeviceModel()), MTP_string(cApiSystemVersion()), MTP_string(cApiAppVersion()), MTP_string(cApiLang())), rpcDone(&Application::onAppUpdate), rpcFail(&Application::onAppUpdateFail);
		emit updateChecking();
	} else {
		updateCheckTimer.start((updateInSecs + 5) * 1000);
	}
}
Пример #29
0
bool IntroPhone::phoneSubmitFail(const RPCError &error) {
	if (MTP::isFloodError(error)) {
		stopCheck();
		sentRequest = 0;
		showError(lang(lng_flood_error));
		enableAll(true);
		return true;
	}
	if (MTP::isDefaultHandledError(error)) return false;

	stopCheck();
	sentRequest = 0;
	const QString &err = error.type();
	if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
		showError(lang(lng_bad_phone));
		enableAll(true);
		return true;
	}
	if (cDebug()) { // internal server error
		showError(err + ": " + error.description());
	} else {
		showError(lang(lng_server_error));
	}
	enableAll(true);
	return false;
}
Пример #30
0
Calamares::JobResult
DummyCppJob::exec()
{
    // Ported from dummypython
    QProcess::execute( "/bin/sh", QStringList() << "-c" << "touch ~/calamares-dummycpp" );
    QString accumulator = QDateTime::currentDateTimeUtc().toString( Qt::ISODate ) + '\n';
    accumulator += QStringLiteral( "Calamares version: " ) + CALAMARES_VERSION_SHORT + '\n';
    accumulator += QStringLiteral( "This job's name: " ) + prettyName() + '\n';
    accumulator += QStringLiteral( "Configuration map: %1\n" ).arg( variantMapToString( m_configurationMap ) );
    accumulator += QStringLiteral( "   *** globalstorage test ***\n" );
    Calamares::GlobalStorage *globalStorage = Calamares::JobQueue::instance()->globalStorage();
    accumulator += QStringLiteral( "lala: " ) + (globalStorage->contains( "lala" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
    accumulator += QStringLiteral( "foo: " ) + (globalStorage->contains( "foo" ) ? QStringLiteral( "true" ) : QStringLiteral( "false" )) + '\n';
    accumulator += QStringLiteral( "count: " ) + QString::number( globalStorage->count() ) + '\n';
    globalStorage->insert( "item2", "value2" );
    globalStorage->insert( "item3", 3 );
    accumulator += QStringLiteral( "keys: %1\n" ).arg( globalStorage->keys().join( ',' ) );
    accumulator += QStringLiteral( "remove: %1\n" ).arg( QString::number( globalStorage->remove( "item2" ) ) );
    accumulator += QStringLiteral( "values: %1 %2 %3\n" ).arg(
        globalStorage->value( "foo" ).toString(),
        globalStorage->value( "item2" ).toString(),
        globalStorage->value( "item3" ).toString() );

    emit progress( 0.1 );
    cDebug() << "[DUMMYCPP]: " << accumulator;

    globalStorage->debugDump();
    emit progress( 0.5 );

    QThread::sleep( 3 );

    return Calamares::JobResult::ok();
}