本文整理汇总了C++中QDBusMessage::createErrorReply方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusMessage::createErrorReply方法的具体用法?C++ QDBusMessage::createErrorReply怎么用?C++ QDBusMessage::createErrorReply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusMessage
的用法示例。
在下文中一共展示了QDBusMessage::createErrorReply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: propertyWriteReply
static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &interface_name,
const QByteArray &property_name, int status)
{
switch (status) {
case PropertyNotFound:
return propertyNotFoundError(msg, interface_name, property_name);
case PropertyTypeMismatch:
return msg.createErrorReply(QDBusError::InvalidArgs,
QString::fromLatin1("Invalid arguments for writing to property %1%2%3")
.arg(interface_name,
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
QString::fromLatin1(property_name)));
case PropertyReadOnly:
return msg.createErrorReply(QDBusError::PropertyReadOnly,
QString::fromLatin1("Property %1%2%3 is read-only")
.arg(interface_name,
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
QString::fromLatin1(property_name)));
case PropertyWriteFailed:
return msg.createErrorReply(QDBusError::InternalError,
QString::fromLatin1("Internal error"));
case PropertyWriteSuccess:
return msg.createReply();
}
Q_ASSERT_X(false, "", "Should not be reached");
return QDBusMessage();
}
示例2: GetVariable
Values AsebaNetworkInterface::GetVariable(const QString& node, const QString& variable, const QDBusMessage &message)
{
// make sure the node exists
NodesNamesMap::const_iterator nodeIt(nodesNames.find(node));
if (nodeIt == nodesNames.end())
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("node %0 does not exists").arg(node)));
return Values();
}
const unsigned nodeId(nodeIt.value());
unsigned pos(unsigned(-1));
unsigned length(unsigned(-1));
// check whether variable is user-defined
const UserDefinedVariablesMap::const_iterator userVarMapIt(userDefinedVariablesMap.find(node));
if (userVarMapIt != userDefinedVariablesMap.end())
{
const VariablesMap& userVarMap(userVarMapIt.value());
const VariablesMap::const_iterator userVarIt(userVarMap.find(variable.toStdWString()));
if (userVarIt != userVarMap.end())
{
pos = userVarIt->second.first;
length = userVarIt->second.second;
}
}
// if variable is not user-defined, check whether it is provided by this node
if (pos == unsigned(-1))
{
bool ok1, ok2;
pos = getVariablePos(nodeId, variable.toStdWString(), &ok1);
length = getVariableSize(nodeId, variable.toStdWString(), &ok2);
if (!(ok1 && ok2))
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("variable %0 does not exists in node %1").arg(variable).arg(node)));
return Values();
}
}
// send request to aseba network
{
GetVariables msg(nodeId, pos, length);
hub->sendMessage(msg);
}
// build bookkeeping for async reply
RequestData *request = new RequestData;
request->nodeId = nodeId;
request->pos = pos;
message.setDelayedReply(true);
request->reply = message.createReply();
pendingReads.push_back(request);
return Values();
}
示例3: interfaceNotFoundError
static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const QString &interface_name)
{
return msg.createErrorReply(QDBusError::UnknownInterface,
QString::fromLatin1("Interface %1 was not found in object %2")
.arg(interface_name)
.arg(msg.path()));
}
示例4: getCurrentUrl
void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
if (!g.sh || !g.sh->isRunning() || ! g.uiSession) {
QDBusConnection::sessionBus().send(msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
return;
}
QString host, user, pw;
unsigned short port;
QUrl u;
g.sh->getConnectionInfo(host, port, user, pw);
u.setScheme(QLatin1String("mumble"));
u.setHost(host);
u.setPort(port);
u.setUserName(user);
#if QT_VERSION >= 0x050000
QUrlQuery query;
query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
u.setQuery(query);
#else
u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
#endif
QStringList path;
Channel *c = ClientUser::get(g.uiSession)->cChannel;
while (c->cParent) {
path.prepend(c->qsName);
c = c->cParent;
}
u.setPath(path.join(QLatin1String("/")));
QDBusConnection::sessionBus().send(msg.createReply(QString::fromLatin1(u.toEncoded())));
}
示例5: SendEventName
void AsebaNetworkInterface::SendEventName(const QString& name, const Values& data, const QDBusMessage &message)
{
size_t event;
if (commonDefinitions.events.contains(name.toStdWString(), &event))
SendEvent(event, data);
else
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("no event named %0").arg(name)));
}
示例6: IgnoreEventName
void EventFilterInterface::IgnoreEventName(const QString& name, const QDBusMessage &message)
{
size_t event;
if (network->commonDefinitions.events.contains(name.toStdWString(), &event))
network->ignoreEvent(this, event);
else
network->DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("no event named %0").arg(name)));
}
示例7: getTalkingUsers
void MumbleDBus::getTalkingUsers(const QDBusMessage &msg) {
if (!g.sh || !g.sh->isRunning() || ! g.uiSession) {
QDBusConnection::sessionBus().send(msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
return;
}
QStringList names;
foreach(ClientUser *cu, ClientUser::getTalking()) {
names.append(cu->qsName);
}
示例8: GetNodeName
QString AsebaNetworkInterface::GetNodeName(const quint16 nodeId, const QDBusMessage &message) const
{
const QString nodeName(QString::fromStdWString(getNodeName(nodeId)));
if (nodeName.isEmpty())
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("node %0 does not exists").arg(nodeId)));
return 0;
}
return nodeName;
}
示例9: IsConnected
bool AsebaNetworkInterface::IsConnected(const QString& node, const QDBusMessage &message) const
{
NodesNamesMap::const_iterator nodeIt(nodesNames.find(node));
if (nodeIt == nodesNames.end())
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("node %0 does not exists").arg(node)));
return 0;
}
return nodes.find(nodeIt.value())->second.connected;
}
示例10: openUrl
void MumbleDBus::openUrl(const QString &url, const QDBusMessage &msg) {
QUrl u = QUrl::fromEncoded(url.toLatin1());
bool valid = u.isValid();
valid = valid && (u.scheme() == QLatin1String("mumble"));
if (! valid) {
QDBusConnection::sessionBus().send(msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.url"), QLatin1String("Invalid URL")));
} else {
g.mw->openUrl(u);
}
}
示例11:
static inline QDBusMessage
propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name)
{
return msg.createErrorReply(QDBusError::UnknownProperty,
QString::fromLatin1("Property %1%2%3 was not found in object %4")
.arg(interface_name,
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
QString::fromLatin1(property_name),
msg.path()));
}
示例12: createErrorReply
QScriptValue QScriptDBusMessageConstructor::createErrorReply(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 2)
return engine->nullValue();
QDBusMessage msg;
scriptValueToMessage(context->thisObject(), msg);
QString name = context->argument(0).toString();
QString errMsg = context->argument(1).toString();
return messageToScriptValue(engine, msg.createErrorReply(name, errMsg));
}
示例13: SetVariable
void AsebaNetworkInterface::SetVariable(const QString& node, const QString& variable, const Values& data, const QDBusMessage &message) const
{
// make sure the node exists
NodesNamesMap::const_iterator nodeIt(nodesNames.find(node));
if (nodeIt == nodesNames.end())
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("node %0 does not exists").arg(node)));
return;
}
const unsigned nodeId(nodeIt.value());
unsigned pos(unsigned(-1));
// check whether variable is user-defined
const UserDefinedVariablesMap::const_iterator userVarMapIt(userDefinedVariablesMap.find(node));
if (userVarMapIt != userDefinedVariablesMap.end())
{
const VariablesMap& userVarMap(userVarMapIt.value());
const VariablesMap::const_iterator userVarIt(userVarMap.find(variable.toStdWString()));
if (userVarIt != userVarMap.end())
{
pos = userVarIt->second.first;
}
}
// if variable is not user-defined, check whether it is provided by this node
if (pos == unsigned(-1))
{
bool ok;
pos = getVariablePos(nodeId, variable.toStdWString(), &ok);
if (!ok)
{
DBusConnectionBus().send(message.createErrorReply(QDBusError::InvalidArgs, QString("variable %0 does not exists in node %1").arg(variable).arg(node)));
return;
}
}
SetVariables msg(nodeId, pos, toAsebaVector(data));
hub->sendMessage(msg);
}
示例14: propertyWriteReply
static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &interface_name,
const QByteArray &property_name, int status)
{
switch (status) {
case PropertyNotFound:
return propertyNotFoundError(msg, interface_name, property_name);
case PropertyTypeMismatch:
return msg.createErrorReply(QDBusError::InvalidArgs,
QString::fromLatin1("Invalid arguments for writing to property %1%2%3")
.arg(interface_name,
QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
QString::fromLatin1(property_name)));
case PropertyWriteFailed:
return msg.createErrorReply(QDBusError::InternalError,
QString::fromLatin1("Internal error"));
case PropertyWriteSuccess:
return msg.createReply();
}
Q_UNREACHABLE();
}
示例15: DisconnectProfile
void DeviceInterface::DisconnectProfile(const QString &uuid, const QDBusMessage &msg)
{
if (!uuids().contains(uuid)) {
QDBusMessage error = msg.createErrorReply(QStringLiteral("org.bluez.Error.DoesNotExist"), QStringLiteral("Profile UUID not supported"));
QDBusConnection::sessionBus().send(error);
return;
}
if (!m_connectedUuids.contains(uuid)) {
QDBusMessage error = msg.createErrorReply(QStringLiteral("org.bluez.Error.NotConnected"), QStringLiteral("Profile not connected"));
QDBusConnection::sessionBus().send(error);
return;
}
if (uuid == MediaPlayerUuid) {
disconnectMediaPlayer();
} else {
Q_UNIMPLEMENTED();
}
Object::changeProperty(QStringLiteral("Connected"), false);
}