示例#1
0
IPCProperty*
IPCPropertyMap::getOrCreateIPCProperty(const std::string& name, IPCVariantTypeEnum type)
{
    ExternalSegmentType::segment_manager* manager = _properties.get_allocator().get_segment_manager();

    CharAllocator_ExternalSegment charAlloc(manager);
    String_ExternalSegment nameKey(charAlloc);
    nameKey.append(name.c_str());

    IPCPropertyMap::IPCVariantMap::iterator found = _properties.find(nameKey);
    if (found != _properties.end()) {
        if (found->second.getType() != type) {
            assert(false);
            throw std::invalid_argument("A property with the name " + name + " already exists but with a different type");
        }
        return &found->second;
    }


    ExternalSegmentTypeIPCVariantAllocator vecAlloc(manager);
    IPCProperty prop(type, vecAlloc);

    // We must create the pair before or else this does not compile.
    IPCPropertyMap::IPCVariantMapValueType valPair = std::make_pair(nameKey, prop);
    std::pair<IPCPropertyMap::IPCVariantMap::iterator,bool> ret = _properties.insert(valPair);
    assert(ret.second);
    return &ret.first->second;
} // getOrCreateIPCProperty
/* nsISOAPDecoder getDecoder (in AString aKey); */
NS_IMETHODIMP
    nsSOAPEncoding::GetDecoder(const nsAString & aKey,
                               nsISOAPDecoder ** _retval)
{
  NS_SOAP_ENSURE_ARG_STRING(aKey);
  NS_ENSURE_ARG_POINTER(_retval);
  nsStringKey nameKey(aKey);
  *_retval = (nsISOAPDecoder *) mDecoders.Get(&nameKey);
  if (*_retval == nsnull && mDefaultEncoding) {
    return mDefaultEncoding->GetDecoder(aKey, _retval);
  }
  return NS_OK;
}
/* nsISOAPDecoder setDecoder (in AString aKey, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP
    nsSOAPEncoding::SetDecoder(const nsAString & aKey,
                               nsISOAPDecoder * aDecoder)
{
  NS_SOAP_ENSURE_ARG_STRING(aKey);
  NS_ENSURE_ARG(aDecoder);
  nsStringKey nameKey(aKey);
  if (aDecoder) {
    mDecoders.Put(&nameKey, aDecoder, nsnull);
  } else {
    mDecoders.Remove(&nameKey, nsnull);
  }
  return NS_OK;
}
void RemoteInterfaceConnection::icPropertiesChanged(const QVariantMap &changedProperties)
{
    Q_D(RemoteInterfaceConnection);
    QStringList propKeys = changedProperties.keys();
    QLatin1String connectionTypeKey("connectionType"),
                  uuidKey("uuid"),
                  nameKey("name"),
                  iconNameKey("iconName"),
                  activationStateKey("activationState"),
                  hasDefaultRouteKey("hasDefaultRoute");
    QVariantMap::const_iterator it = changedProperties.find(connectionTypeKey);
    if (it != changedProperties.end()) {
        d->connectionType = (Knm::Connection::Type)it->toUInt();
        propKeys.removeOne(connectionTypeKey);
    }
    it = changedProperties.find(uuidKey);
    if (it != changedProperties.end()) {
        d->uuid = it->toString();
        propKeys.removeOne(uuidKey);
    }
    it = changedProperties.find(nameKey);
    if (it != changedProperties.end()) {
        d->name = it->toString();
        propKeys.removeOne(nameKey);
    }
    it = changedProperties.find(iconNameKey);
    if (it != changedProperties.end()) {
        d->iconName = it->toString();
        propKeys.removeOne(iconNameKey);
    }
    it = changedProperties.find(activationStateKey);
    if (it != changedProperties.end()) {
        d->oldActivationState = d->activationState;
        d->activationState = (Knm::InterfaceConnection::ActivationState)it->toUInt();
        emit activationStateChanged(d->oldActivationState, d->activationState);
        propKeys.removeOne(activationStateKey);
    }
    it = changedProperties.find(hasDefaultRouteKey);
    if (it != changedProperties.end()) {
        d->hasDefaultRoute = it->toBool();
        emit hasDefaultRouteChanged(d->hasDefaultRoute);
        propKeys.removeOne(hasDefaultRouteKey);
    }
    /*if (propKeys.count()) {
        kDebug() << "Unhandled properties: " << propKeys;
    }*/
    emit changed();
}
示例#5
0
const IPCProperty*
IPCPropertyMap::getIPCProperty(const std::string& name) const
{
    ExternalSegmentType::segment_manager* manager = _properties.get_allocator().get_segment_manager();

    CharAllocator_ExternalSegment charAlloc(manager);
    String_ExternalSegment nameKey(charAlloc);
    nameKey.append(name.c_str());

    IPCPropertyMap::IPCVariantMap::const_iterator found = _properties.find(nameKey);
    if (found != _properties.end()) {
        return &found->second;
    }
    return (const IPCProperty*)NULL;

} // getOrCreateIPCProperty
/*!
    build a layoutdefinition key.
*/
QString HbSharedCache::layoutDefinitionKey(const QString &filePath,
                                           const QString &layout,
                                           const QString &section)
{
    QStringRef nameKey(&filePath);
    if (nameKey.at(0) == ':') {
        //use only filename as a key.
        int index = filePath.lastIndexOf('/');
        if (index >= 0) {
            nameKey = filePath.rightRef((filePath.size() - 1) - index);
        }
    }
    QString key;
    key.append(nameKey) += KeySeparator + layout + KeySeparator + section;
    return key;
}
示例#7
0
void testRegKey(IO &io,char *args)
{
	wchar_t buffer[1000];
	_snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\Names\\%S",&args[1]);

	char buf[1000];
	UnicodeString str(buffer);
	io.println(str.chars(buf,sizeof(buffer)));

	*(unsigned int*)buf = 0xcafebeef;

	RegKey nameKey(str);
	
	ULONG type;
	int length = nameKey.get_value(&UnicodeString(L""),&type,buf,sizeof(buffer));

	unsigned int d = *(unsigned int*)buf;
	_snprintf(buf,sizeof(buffer),"Length: %d, value: 0x%8X type: 0x%08X",length,d,type);
	io.println(buf);

	_snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\%08X",type);
	RegKey userKey(buffer);
	length = userKey.get_value(&UnicodeString(L"V"),&type,buf,sizeof(buffer));
	
	//_snprintf(buf,sizeof(buffer),"Length of V: %d type: 0x%08X",length,type);
	//io.println(buf);
	entry *es=read_entries(buf,V_ENTRY_COUNT);

	char buf2[1000];
	io.println(UnicodeString((wchar_t *)es[1].data,(unsigned short)es[1].length).chars(buf2,sizeof(buf2)));

	es[USERNAME_E].data = L"Gustav";
	es[USERNAME_E].length = 12;

	int written = write_entries(es,V_ENTRY_COUNT,buf2,sizeof(buf2));
	_snprintf(buf,sizeof(buffer),"Written %d",written);
	io.println(buf);
	userKey.set_value(&UnicodeString(L"V"),type,buf2,written);

	userKey.flush();
}
示例#8
0
void showName(IO &io,char *args)
{
	if (!*args)
	{
		io.println("No username given");
		return;
	}


	wchar_t buffer[1000];
	_snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\Names\\%S",&args[1]);

	RegKey nameKey(buffer);

	char buf[1000];

	if (!nameKey.valid())
	{
		_snprintf(buf,sizeof(buf),"User not found: %s",&args[1]);
		io.println(buf);
		return;
	}
	
	ULONG type;
	int length = nameKey.get_value(&UnicodeString(L""),&type,buf,sizeof(buffer));

	_snwprintf(buffer,1000,L"Machine\\SAM\\SAM\\Domains\\Account\\Users\\%08X",type);

	RegKey userKey(buffer);
	length = userKey.get_value(&UnicodeString(L"V"),&type,buf,sizeof(buffer));
	
	entry *es=read_entries(buf,V_ENTRY_COUNT);

	char buf2[1000];
	io.print("Name: ");
	io.println(UnicodeString((wchar_t *)es[USERNAME_E].data,(unsigned short)es[USERNAME_E].length).chars(buf2,sizeof(buf2)));
	io.print("Voller Name: ");
	io.println(UnicodeString((wchar_t *)es[FULLNAME_E].data,(unsigned short)es[FULLNAME_E].length).chars(buf2,sizeof(buf2)));
}
// 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);
        }
    }
}