<commit_before>#include "argumentlist.h"
#include "epolleventdispatcher.h"
#include "itransceiverclient.h"
#include "localsocket.h"
#include "message.h"
#include "transceiver.h"

#include <iostream>

using namespace std;

void printArguments(ArgumentList::ReadCursor reader )
{
    // TODO - this is well-known though
}

void fillHelloMessage(Message *hello)
{
    hello->setType(Message::MethodCallMessage);
    hello->setDestination(string("org.freedesktop.DBus"));
    hello->setInterface(string("org.freedesktop.DBus"));
    hello->setPath(string("/org/freedesktop/DBus"));
    hello->setMethod(string("Hello"));
}

class ReplyPrinter : public ITransceiverClient
{
    // reimplemented from ITransceiverClient
    virtual void messageReceived(Message *m);
};

void ReplyPrinter::messageReceived(Message *m)
{
    cout << "Reply, pretty-printed:\n" << m->prettyPrint();
}

int main(int argc, char *argv[])
{

    EpollEventDispatcher dispatcher;

    Transceiver transceiver(&dispatcher);
    ReplyPrinter receiver;
    transceiver.setClient(&receiver);
    {
        Message hello(1);
        fillHelloMessage(&hello);
        transceiver.sendAsync(&hello);
        while (true) {
            dispatcher.poll();
        }
    }

    return 0;
}<commit_msg>Dselpunk: Set up eavesdropping and pretty-print the snarfed messages.<commit_after>#include "argumentlist.h"
#include "epolleventdispatcher.h"
#include "itransceiverclient.h"
#include "localsocket.h"
#include "message.h"
#include "transceiver.h"

#include <iostream>

using namespace std;


void fillHelloMessage(Message *hello)
{
    hello->setType(Message::MethodCallMessage);
    hello->setDestination(string("org.freedesktop.DBus"));
    hello->setInterface(string("org.freedesktop.DBus"));
    hello->setPath(string("/org/freedesktop/DBus"));
    hello->setMethod(string("Hello"));
}

class ReplyPrinter : public ITransceiverClient
{
    // reimplemented from ITransceiverClient
    virtual void messageReceived(Message *m);
};

void ReplyPrinter::messageReceived(Message *m)
{
    cout << "\nReceived:\n" << m->prettyPrint();
}

int main(int argc, char *argv[])
{

    EpollEventDispatcher dispatcher;

    Transceiver transceiver(&dispatcher);
    ReplyPrinter receiver;
    transceiver.setClient(&receiver);
    {
        Message hello(1);
        fillHelloMessage(&hello);
        cout << "Sending:\n" << hello.prettyPrint() << '\n';
        transceiver.sendAsync(&hello);

        Message spyEnable(2);
        spyEnable.setType(Message::MethodCallMessage);
        spyEnable.setDestination(string("org.freedesktop.DBus"));
        spyEnable.setInterface(string("org.freedesktop.DBus"));
        spyEnable.setPath(string("/org/freedesktop/DBus"));
        spyEnable.setMethod(string("AddMatch"));
        ArgumentList argList;
        ArgumentList::WriteCursor writer = argList.beginWrite();
        writer.writeString(cstring("eavesdrop=true,type='method_call'"));
        writer.finish();
        spyEnable.setArgumentList(argList);
        transceiver.sendAsync(&spyEnable);
        while (true) {
            dispatcher.poll();
        }
    }


    return 0;
}
{'fraction_non_alphanumeric': 0.13748006379585326, 'fraction_numerical': 0.001594896331738437, 'mean_word_length': 3.9385826771653543, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2180588', 'n_tokens_mistral': 987, 'n_tokens_neox': 947, 'n_words': 163}