Ejemplo n.º 1
0
    ScanService(BusAttachment& bus, const char* path, JavaVM* vm, jobject jobj) : BusObject(bus, path), vm(vm), jobj(jobj)
    {

        QStatus status;

        /* Add the chat interface to this object */
        const InterfaceDescription* scanIntf = bus.GetInterface(SCAN_SERVICE_INTERFACE_NAME);
        assert(scanIntf);
        AddInterface(*scanIntf);

        /* Store the Chat signal member away so it can be quickly looked up when signals are sent */
        scanMethodMember = scanIntf->GetMember("Scan");
        assert(scanMethodMember);

        const MethodEntry methodEntries[] = {
            { scanIntf->GetMember("Scan"), static_cast<MessageReceiver::MethodHandler>(&ScanService::Scan) }
        };

        status = AddMethodHandlers(methodEntries, ARRAY_SIZE(methodEntries));

        if (ER_OK != status) {
            LOGE("Failed to register method handlers for AllJoynAndroidExtService (%s)", QCC_StatusText(status));
        }

    }
Ejemplo n.º 2
0
    BasicSampleObject(BusAttachment& bus, const char* path) :
        BusObject(bus, path)
    {
        /** Add the test interface to this object */
        const InterfaceDescription* exampleIntf = bus.GetInterface(SERVICE_NAME);
        assert(exampleIntf);
        AddInterface(*exampleIntf);

        /** Register the method handlers with the object */
        const MethodEntry methodEntries[] = {
            { exampleIntf->GetMember("cat"), static_cast<MessageReceiver::MethodHandler>(&BasicSampleObject::Cat) }
        };
        QStatus status = AddMethodHandlers(methodEntries, sizeof(methodEntries) / sizeof(methodEntries[0]));
        if (ER_OK != status) {
            printf("Failed to register method handlers for BasicSampleObject");
        }
    }
Ejemplo n.º 3
0
    ServiceObject(BusAttachment& bus, const char* path, JavaVM* vm, jobject jobj)
        : BusObject(bus, path), vm(vm), jobj(jobj), isNameAcquired(false)
    {
        QStatus status;

        /* Add the service interface to this object */
        const InterfaceDescription* regTestIntf = bus.GetInterface(SIMPLE_SERVICE_INTERFACE_NAME);
        assert(regTestIntf);
        AddInterface(*regTestIntf);

        /* Register the method handlers with the object */
        const MethodEntry methodEntries[] = {
            { regTestIntf->GetMember("Ping"), static_cast<MessageReceiver::MethodHandler>(&ServiceObject::Ping) }
        };
        status = AddMethodHandlers(methodEntries, ARRAY_SIZE(methodEntries));
        if (ER_OK != status) {
            LOGE("Failed to register method handlers for ServiceObject (%s)", QCC_StatusText(status));
        }
    }
Ejemplo n.º 4
0
    ChatObject(BusAttachment& bus, const char* path, JavaVM* vm, jobject jobj) : BusObject(bus, path), vm(vm), jobj(jobj)
    {
        QStatus status;

        /* Add the chat interface to this object */
        const InterfaceDescription* chatIntf = bus.GetInterface(CHAT_SERVICE_INTERFACE_NAME);
        QCC_ASSERT(chatIntf);
        AddInterface(*chatIntf);

        /* Store the Chat signal member away so it can be quickly looked up when signals are sent */
        chatSignalMember = chatIntf->GetMember("Chat");
        QCC_ASSERT(chatSignalMember);

        /* Register signal handler */
        status =  bus.RegisterSignalHandler(this,
                                            static_cast<MessageReceiver::SignalHandler>(&ChatObject::ChatSignalHandler),
                                            chatSignalMember,
                                            NULL);

        if (ER_OK != status) {
            LOGE("Failed to register s_advertisedNamesignal handler for ChatObject::Chat (%s)", QCC_StatusText(status));
        }
    }
Ejemplo n.º 5
0
/* Bus object */
ChatObject::ChatObject(BusAttachment& bus, const char* path) : BusObject(bus, path), chatSignalMember(NULL)
{
    QStatus status;

    /* Add the chat interface to this object */
    const InterfaceDescription* chatIntf = bus.GetInterface(CHAT_SERVICE_INTERFACE_NAME);
    assert(chatIntf);
    AddInterface(*chatIntf);

    /* Store the Chat signal member away so it can be quickly looked up when signals are sent */
    chatSignalMember = chatIntf->GetMember("Chat");
    assert(chatSignalMember);

    /* Register signal handler */
    status =  bus.RegisterSignalHandler(this,
                                        static_cast<MessageReceiver::SignalHandler>(&ChatObject::ChatSignalHandler),
                                        chatSignalMember,
                                        NULL);

    if (ER_OK != status) {
        NotifyUser(MSG_ERROR, "Failed to register signal handler for ChatObject::Chat (%s)\n", QCC_StatusText(status));
    }
}
Ejemplo n.º 6
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    handler = new UHandler();
    try_drawer = new TryDrawUI();
    drawer = new CDrawUI();
    if (AllJoynInit() != ER_OK) {
        printf("Ping: Error1.\n");
        exit(1);
        //return EXIT_FAILURE;
    }
//#ifdef ROUTER
    if (AllJoynRouterInit() != ER_OK) {
        AllJoynShutdown();
        printf("Ping: Error2.\n");
        exit(1);
        //return EXIT_FAILURE;
    }
//#endif

    BusAttachment* bus = new BusAttachment("door_consumer", true);

    if (ER_OK != SetupBusAttachment(*bus)) {
        printf("Ping: Error3.\n");
        exit(1);
        //return EXIT_FAILURE;
       // void DrawUI()
    }

    const char* intfname = INTF_NAME;
    Observer* obs = new Observer(*bus, &intfname, 1);
    DoorListener* listener = new DoorListener();
    listener->observer = obs;
    listener->bus = bus;
    obs->RegisterListener(*listener);
    bus->RegisterSignalHandler(listener, static_cast<MessageReceiver::SignalHandler>(&DoorListener::PersonPassedThrough), bus->GetInterface(INTF_NAME)->GetMember("PersonPassedThrough"), NULL);

//    bool done = false;
//    while (!done) { }
//            string input;
//            cout << "> ";
//            getline(cin, input);
//            done = !Parse(*bus, obs, input);
//        }

//    // Cleanup
//    obs->UnregisterAllListeners();
//    delete obs; // Must happen before deleting the original bus
//    delete listener;
//    delete bus;
//    bus = NULL;

//    //#ifdef ROUTER
//        AllJoynRouterShutdown();
//    //#endif
//        AllJoynShutdown();
//        printf("Ping: Error4.\n");
//        exit(1);
//        //return EXIT_SUCCESS;

     engine = new QQmlApplicationEngine();
    engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}