Esempio n. 1
0
void QCALLTYPE COMDynamicWrite::TermCreateClass(QCall::ModuleHandle pModule, INT32 tk, QCall::ObjectHandleOnStack retType)
{
    QCALL_CONTRACT;
    
    TypeHandle typeHnd;

    BEGIN_QCALL;
    
    _ASSERTE(pModule->GetReflectionModule()->GetClassWriter()); 

    // Use the same service, regardless of whether we are generating a normal
    // class, or the special class for the module that holds global functions
    // & methods.
    pModule->GetReflectionModule()->AddClass(tk);

    // manually load the class if it is not the global type
    if (!IsNilToken(tk))
    {
        TypeKey typeKey(pModule, tk);
        typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());
    }

    if (!typeHnd.IsNull())
    {
        GCX_COOP();
        retType.Set(typeHnd.GetManagedClassObject());
    }

    END_QCALL;

    return;
}
Esempio n. 2
0
QScriptValue ModuleProperties::moduleProperties(QScriptContext *context, QScriptEngine *engine,
                                                bool oneValue)
{
    if (Q_UNLIKELY(context->argumentCount() < 2)) {
        return context->throwError(QScriptContext::SyntaxError,
                                   Tr::tr("Function moduleProperties() expects 2 arguments"));
    }

    const QScriptValue objectWithProperties = context->thisObject();
    const QScriptValue typeScriptValue = objectWithProperties.property(typeKey());
    if (Q_UNLIKELY(!typeScriptValue.isString())) {
        return context->throwError(QScriptContext::TypeError,
                QLatin1String("Internal error: __type not set up"));
    }
    const QScriptValue ptrScriptValue = objectWithProperties.property(ptrKey());
    if (Q_UNLIKELY(!ptrScriptValue.isNumber())) {
        return context->throwError(QScriptContext::TypeError,
                QLatin1String("Internal error: __internalPtr not set up"));
    }

    const void *ptr = reinterpret_cast<const void *>(qscriptvalue_cast<quintptr>(ptrScriptValue));
    PropertyMapConstPtr properties;
    const Artifact *artifact = 0;
    if (typeScriptValue.toString() == productType()) {
        properties = static_cast<const ResolvedProduct *>(ptr)->moduleProperties;
    } else if (typeScriptValue.toString() == artifactType()) {
        artifact = static_cast<const Artifact *>(ptr);
        properties = artifact->properties;
    } else {
        return context->throwError(QScriptContext::TypeError,
                                   QLatin1String("Internal error: invalid type"));
    }

    ScriptEngine * const qbsEngine = static_cast<ScriptEngine *>(engine);
    const QString moduleName = context->argument(0).toString();
    const QString propertyName = context->argument(1).toString();

    QVariant value;
    if (qbsEngine->isPropertyCacheEnabled())
        value = qbsEngine->retrieveFromPropertyCache(moduleName, propertyName, oneValue,
                                                     properties);
    if (!value.isValid()) {
        if (oneValue)
            value = PropertyFinder().propertyValue(properties->value(), moduleName, propertyName);
        else
            value = PropertyFinder().propertyValues(properties->value(), moduleName, propertyName);
        const Property p(moduleName, propertyName, value);
        if (artifact)
            qbsEngine->addPropertyRequestedFromArtifact(artifact, p);
        else
            qbsEngine->addPropertyRequestedInScript(p);

        // Cache the variant value. We must not cache the QScriptValue here, because it's a
        // reference and the user might change the actual object.
        if (qbsEngine->isPropertyCacheEnabled())
            qbsEngine->addToPropertyCache(moduleName, propertyName, oneValue, properties, value);
    }
    return engine->toScriptValue(value);
}
void AccountSettings::editAccount(QMailAccount *account)
{
    QMailAccountConfiguration config;
    if (account->id().isValid()) {
        config = QMailAccountConfiguration(account->id());
    } else {
        account->setStatus(QMailAccount::UserEditable, true);
        account->setStatus(QMailAccount::UserRemovable, true);
    }

    QDialog *editAccountView;
    bool wasPreferred(account->status() & QMailAccount::PreferredSender);

    EditAccount *e = new EditAccount(this, "EditAccount");
    e->setAccount(account, &config);
    editAccountView = e;

    editAccountView->setMinimumSize(QSize(400,400));
    int ret = editAccountView->exec();

    delete editAccountView;

    if (ret == QDialog::Accepted) {
        QMailAccountId previousPreferredId;
        if ((account->status() & QMailAccount::PreferredSender) && !wasPreferred) {
            // This account is now preferred - see if there is a predecessor that must be deselected
            QMailAccountKey preferredKey(QMailAccountKey::status(QMailAccount::PreferredSender, QMailDataComparator::Includes));
            QMailAccountKey typeKey(QMailAccountKey::messageType(account->messageType()));

            QMailAccountIdList previousIds = QMailStore::instance()->queryAccounts(preferredKey & typeKey);
            if (!previousIds.isEmpty())
                previousPreferredId = previousIds.first();
        }

        preExisting = account->id().isValid();
        if (preExisting) {
            QMailStore::instance()->updateAccount(account, &config);
        } else {
            QMailStore::instance()->addAccount(account, &config);
            accountView->setCurrentIndex(accountModel->index(accountModel->rowCount() - 1, 0));
        }

        if ((account->status() & QMailAccount::PreferredSender) && !wasPreferred) {
            if (previousPreferredId.isValid()) {
                QMailAccount previousAccount(previousPreferredId);
                previousAccount.setStatus(QMailAccount::PreferredSender, false);
                QMailStore::instance()->updateAccount(&previousAccount);

                QMessageBox::warning(this,
                                     tr("New default account"),
                                     tr("<qt>Your previous default mail account has been unchecked</qt>"),
                                     QMessageBox::Ok);
            }
        }

        QTimer::singleShot(0, this, SLOT(testConfiguration()));
    }
}
Esempio n. 4
0
static QMailAccountIdList sendingAccounts(QMailMessage::MessageType messageType)
{
    QMailAccountKey statusKey(QMailAccountKey::status(QMailAccount::CanTransmit, QMailDataComparator::Includes));
    statusKey &= QMailAccountKey::status(QMailAccount::Enabled, QMailDataComparator::Includes);
    QMailAccountKey typeKey(QMailAccountKey::messageType(messageType));
    QMailAccountIdList accountIds = QMailStore::instance()->queryAccounts(statusKey & typeKey);
    return accountIds;

}
Esempio n. 5
0
void ModuleProperties::init(QScriptValue objectWithProperties, const void *ptr,
                            const QString &type)
{
    QScriptEngine * const engine = objectWithProperties.engine();
    objectWithProperties.setProperty(QLatin1String("moduleProperties"),
                                     engine->newFunction(ModuleProperties::js_moduleProperties, 2));
    objectWithProperties.setProperty(QLatin1String("moduleProperty"),
                                     engine->newFunction(ModuleProperties::js_moduleProperty, 2));
    objectWithProperties.setProperty(ptrKey(), engine->toScriptValue(quintptr(ptr)));
    objectWithProperties.setProperty(typeKey(), type);
}
Esempio n. 6
0
void KfindTabWidget::updateDateLabels(int type, int value)
{
  QString typeKey(type == 0 ? QLatin1Char('i') : type == 1 ? QLatin1Char('h') : type == 2 ? QLatin1Char('d') : type == 3 ? QLatin1Char('m') : QLatin1Char('y'));
  rb[1]->setText(ki18ncp("during the previous minute(s)/hour(s)/...; "
                         "dynamic context 'type': 'i' minutes, 'h' hours, 'd' days, 'm' months, 'y' years",
                         "&during the previous", "&during the previous").subs(value).inContext(QLatin1String("type"), typeKey).toString());
  betweenType->setItemText(0, i18ncp("use date ranges to search files by modified time", "minute", "minutes", value));
  betweenType->setItemText(1, i18ncp("use date ranges to search files by modified time", "hour", "hours", value));
  betweenType->setItemText(2, i18ncp("use date ranges to search files by modified time", "day", "days", value));
  betweenType->setItemText(3, i18ncp("use date ranges to search files by modified time", "month", "months", value));
  betweenType->setItemText(4, i18ncp("use date ranges to search files by modified time", "year", "years", value));
}
Esempio n. 7
0
FCIMPLEND

//**************************************************
// LoadInMemoryTypeByName
// Explicitly loading an in memory type
// <TODO>@todo: this function is not dealing with nested type correctly yet.
// We will need to parse the full name by finding "+" for enclosing type, etc.</TODO>
//**************************************************
void QCALLTYPE COMModule::LoadInMemoryTypeByName(QCall::ModuleHandle pModule, LPCWSTR wszFullName)
{
    QCALL_CONTRACT;
    
    TypeHandle      typeHnd;

    BEGIN_QCALL;

    if (!pModule->IsReflection())  
        COMPlusThrow(kNotSupportedException, W("NotSupported_NonReflectedType"));   

    RefClassWriter * pRCW = pModule->GetReflectionModule()->GetClassWriter();
    _ASSERTE(pRCW);

    // it is ok to use public import API because this is a dynamic module anyway. We are also receiving Unicode full name as
    // parameter.
    IMetaDataImport * pImport = pRCW->GetRWImporter();

    if (wszFullName == NULL)
        IfFailThrow( E_FAIL );

    // look up the handle
    mdTypeDef  td;
    HRESULT hr = pImport->FindTypeDefByName(wszFullName, mdTokenNil, &td);
    if (FAILED(hr))
    {
        if (hr != CLDB_E_RECORD_NOTFOUND)
            COMPlusThrowHR(hr);

        // Get the UTF8 version of strFullName
        MAKE_UTF8PTR_FROMWIDE(szFullName, wszFullName);
        pModule->GetAssembly()->ThrowTypeLoadException(szFullName, IDS_CLASSLOAD_GENERAL);
    }

    TypeKey typeKey(pModule, td);
    typeHnd = pModule->GetClassLoader()->LoadTypeHandleForTypeKey(&typeKey, TypeHandle());

    END_QCALL;

    return;
}
QMessageAccountId QMessageAccount::defaultAccount(QMessage::Type type)
{
    if (QMailStore *store = mailStoreInstance()) {
        QMailAccountKey typeKey(QMailAccountKey::messageType(convert(type), QMailDataComparator::Includes));
        QMailAccountKey enabledKey(QMailAccountKey::status(QMailAccount::Enabled));

        // See if there is a preferred sender
        QMailAccountKey preferredKey(QMailAccountKey::status(QMailAccount::PreferredSender));
        foreach (const QMailAccountId &id, store->queryAccounts(typeKey & enabledKey & preferredKey)) {
            return convert(id);
        }

        // See if there are any sending accounts for this type
        QMailAccountKey capableKey(QMailAccountKey::status(QMailAccount::CanTransmit));
        foreach (const QMailAccountId &id, store->queryAccounts(typeKey & enabledKey & capableKey)) {
            return convert(id);
        }
    }
// IRIX 6.x
void qt_parseSpoolInterface(QList<QPrinterDescription> *printers)
{
    QDir lp(QLatin1String("/usr/spool/lp/interface"));
    if (!lp.exists())
        return;
    QFileInfoList files = lp.entryInfoList();
    if(files.isEmpty())
        return;

    for (int i = 0; i < files.size(); ++i) {
        QFileInfo printer = files.at(i);

        if (!printer.isFile())
            continue;

        // parse out some information
        QFile configFile(printer.filePath());
        if (!configFile.open(QIODevice::ReadOnly))
            continue;

        QByteArray line;
        line.resize(1025);
        QString namePrinter;
        QString hostName;
        QString hostPrinter;
        QString printerType;

        QString nameKey(QLatin1String("NAME="));
        QString typeKey(QLatin1String("TYPE="));
        QString hostKey(QLatin1String("HOSTNAME="));
        QString hostPrinterKey(QLatin1String("HOSTPRINTER="));

        while (!configFile.atEnd() &&
                (configFile.readLine(line.data(), 1024)) > 0) {
            QString uline = QString::fromLocal8Bit(line);
            if (uline.startsWith(typeKey) ) {
                printerType = uline.mid(nameKey.length());
                printerType = printerType.simplified();
            } else if (uline.startsWith(hostKey)) {
                hostName = uline.mid(hostKey.length());
                hostName = hostName.simplified();
            } else if (uline.startsWith(hostPrinterKey)) {
                hostPrinter = uline.mid(hostPrinterKey.length());
                hostPrinter = hostPrinter.simplified();
            } else if (uline.startsWith(nameKey)) {
                namePrinter = uline.mid(nameKey.length());
                namePrinter = namePrinter.simplified();
            }
        }
        configFile.close();

        printerType = printerType.trimmed();
        if (printerType.indexOf(QLatin1String("postscript"), 0, Qt::CaseInsensitive) < 0)
            continue;

        int ii = 0;
        while ((ii = namePrinter.indexOf(QLatin1Char('"'), ii)) >= 0)
            namePrinter.remove(ii, 1);

        if (hostName.isEmpty() || hostPrinter.isEmpty()) {
            qt_perhapsAddPrinter(printers, printer.fileName(),
                                 QLatin1String(""), namePrinter);
        } else {
            QString comment;
            comment = namePrinter;
            comment += QLatin1String(" (");
            comment += hostPrinter;
            comment += QLatin1Char(')');
            qt_perhapsAddPrinter(printers, printer.fileName(),
                                 hostName, comment);
        }
    }
}