Esempio n. 1
0
void FileContentIndexer::registerMonitor(const QDBusMessage& message)
{
    if (!m_registeredMonitors.contains(message.service())) {
        m_registeredMonitors << message.service();
        m_monitorWatcher.addWatchedService(message.service());
    }
}
Esempio n. 2
0
void ObexAgentManager::UnregisterAgent(const QDBusObjectPath &path, const QDBusMessage &msg)
{
    if (m_agent == path && m_service == msg.service()) {
        m_agent = QDBusObjectPath();
        m_service.clear();
    }
}
Esempio n. 3
0
/// Implementation of the D-Bus method Subscribe
void PropertyAdaptor::Subscribe(const QDBusMessage &msg, QVariantList& values, quint64& timestamp)
{
    contextDebug() << "Subscribe called";

    // Store the information of the subscription. For each property, we record
    // which clients have subscribed.
    QString client = msg.service();

    if (clientServiceNames.contains(client) == false) {
        clientServiceNames.insert(client);
        if (clientServiceNames.size() == 1) {
            propertyPrivate->setSubscribed();
        }
        serviceWatcher.addWatchedService(client);
    }
    else {
        contextDebug() << "Client" << client << "subscribed to property" << propertyPrivate->key << "multiple times";
    }
    // Don't treat the "client sends 2 Subscribe calls" as an error.  When the
    // provider is not running (e.g., during boot), the subscriber might send 2
    // Subscribe calls: one of them before the provider is running, and the
    // other when it notices that the provider has started.

    // Construct the return values
    Get(values, timestamp);
}
Esempio n. 4
0
QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int) const
{
    qDBusConnectionAsyncCallService = message.service();
    qDBusConnectionAsyncCallPath = message.path();
    qDBusConnectionAsyncCallInterface = message.interface();
    qDBusConnectionAsyncCallMember = message.member();
    qDBusConnectionAsyncCallArguments = message.arguments();
    return QDBusPendingCall::fromCompletedCall(QDBusMessage());
}
Esempio n. 5
0
QDebug operator<<(QDebug dbg, const QDBusMessage &msg)
{
    dbg.nospace() << "QDBusMessage(type=" << msg.type()
                  << ", service=" << msg.service();
    if (msg.type() == QDBusMessage::MethodCallMessage ||
        msg.type() == QDBusMessage::SignalMessage)
        dbg.nospace() << ", path=" << msg.path()
                      << ", interface=" << msg.interface()
                      << ", member=" << msg.member();
    if (msg.type() == QDBusMessage::ErrorMessage)
        dbg.nospace() << ", error name=" << msg.errorName()
                      << ", error message=" << msg.errorMessage();
    dbg.nospace() << ", signature=" << msg.signature()
                  << ", contents=(";
    debugVariantList(dbg, msg.arguments());
    dbg.nospace() << ") )";
    return dbg.space();
}
Esempio n. 6
0
credentials_t::credentials_t(const QDBusMessage &message)
: uid("nobody"), gid("nobody")
{
  QString sender = message.service() ;
  uint32_t user_id = get_name_owner_from_dbus_sync(Maemo::Timed::bus(), sender) ;

  if (user_id == ~0u)
    log_warning("can't get user (uid) of the caller, already terminated?") ;
  else
  {
    passwd *info = getpwuid(user_id) ;
    if (info)
    {
      uid = info->pw_name ;
      gid = gidToName(info->pw_gid) ;
    }
  }
}
Esempio n. 7
0
/// Implementation of the D-Bus method Unsubscribe
void PropertyAdaptor::Unsubscribe(const QDBusMessage &msg)
{
    contextDebug() << "Unsubscribe called";
    QString client = msg.service();

    if (clientServiceNames.remove(client)) {
        if (clientServiceNames.size() == 0) {
            propertyPrivate->setUnsubscribed();
        }
        serviceWatcher.removeWatchedService(client);
    }
    else {
        contextDebug() << "Client" << client << "unsubscribed from property" <<
                       propertyPrivate->key << "without subscribing";
        // Don't treat the "client sends Unsubscribe for a non-subscribed
        // property" as an error.  The intention of the client is to not be
        // subscribed, so there's nothing to do.
    }
}
void QDBusViewer::dumpMessage(const QDBusMessage &message)
{
    QList<QVariant> args = message.arguments();
    QString out = QLatin1String("Received ");

    switch (message.type()) {
    case QDBusMessage::SignalMessage:
        out += QLatin1String("signal ");
        break;
    case QDBusMessage::ErrorMessage:
        out += QLatin1String("error message ");
        break;
    case QDBusMessage::ReplyMessage:
        out += QLatin1String("reply ");
        break;
    default:
        out += QLatin1String("message ");
        break;
    }

    out += QLatin1String("from ");
    out += message.service();
    if (!message.path().isEmpty())
        out += QLatin1String(", path ") + message.path();
    if (!message.interface().isEmpty())
        out += QLatin1String(", interface <i>") + message.interface() + QLatin1String("</i>");
    if (!message.member().isEmpty())
        out += QLatin1String(", member ") + message.member();
    out += QLatin1String("<br>");
    if (args.isEmpty()) {
        out += QLatin1String("&nbsp;&nbsp;(no arguments)");
    } else {
        out += QLatin1String("&nbsp;&nbsp;Arguments: ");
        foreach (QVariant arg, args) {
            QString str = Qt::escape(QDBusUtil::argumentToString(arg));
            // turn object paths into clickable links
            str.replace(objectPathRegExp, QLatin1String("[ObjectPath: <a href=\"qdbus://bus\\1\">\\1</a>]"));
            out += str;
            out += QLatin1String(", ");
        }
        out.chop(2);
    }
Esempio n. 9
0
static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
{
    QScriptValue v = engine->newVariant(QVariant::fromValue(message));
    v.setProperty(QLatin1String("service"), QScriptValue(engine, message.service()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("path"), QScriptValue(engine, message.path()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("interface"), QScriptValue(engine, message.interface()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("member"), QScriptValue(engine, message.member()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("type"), QScriptValue(engine, message.type()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("signature"), QScriptValue(engine, message.signature()), QScriptValue::ReadOnly);
    v.setProperty(QLatin1String("isReplyRequired"), QScriptValue(engine, message.isReplyRequired()), QScriptValue::ReadOnly);

    v.setProperty(QLatin1String("delayedReply"), QScriptValue(engine, message.isDelayedReply()));
    QScriptValue argValue = engine->newArray();
    const QList<QVariant> args = message.arguments();
    for (int i = 0; i < args.count(); ++i)
        argValue.setProperty(QScriptValue(engine, i).toString(),
                             engine->newVariant(args.at(i)));

    v.setProperty(QLatin1String("arguments"), argValue);

    return v;
}
Esempio n. 10
0
credentials_t Aegis::credentials_from_dbus_connection(const QDBusMessage &message)
{
  // We are doing this in a kinda insecure way. Two steps:
  // 1. Ask dbus daemon, what is the pid of the client.
  // --- race race race --- (please someone file a bug about it) --- race race race ---
  // 2. Ask aegis kernel extension, what are the credentials of given pid.

  QString sender = message.service() ;
  /* "returns "sender" on inbound messages
      and "service" on outbound messages
      which saves one QString object and
      confuses at least me ..." -- so true ! */

  // 1. Ask DBus daemon, what is the PID of the 'sender':

  uint32_t owner_id = get_name_owner_from_dbus_sync(Maemo::Timed::bus(), sender) ;

  if (owner_id == ~0u)
  {
    log_warning("can't get owner (pid) of the caller, already terminated?") ;
    return credentials_t() ;
  }

  pid_t pid = owner_id ;

  // 2. Getting aegis credentials from the kernel, by pid

  creds_t aegis_creds = creds_gettask(pid) ;

  // Don't check result, as NULL is a valid set of aegis credentials

  credentials_t creds = Aegis::credentials_from_creds_t(aegis_creds) ;

  creds_free(aegis_creds) ;

  return creds ;
}
Esempio n. 11
0
void ObexAgentManager::RegisterAgent(const QDBusObjectPath &path, const QDBusMessage &msg)
{
    m_agent = path;
    m_service = msg.service();
}
Esempio n. 12
0
void FileContentIndexer::unregisterMonitor(const QDBusMessage& message)
{
    m_registeredMonitors.removeAll(message.service());
    m_monitorWatcher.removeWatchedService(message.service());
}