Ejemplo n.º 1
0
/**
 * Initialize AllJoyn and connect to local daemon.
 */
JNIEXPORT jint JNICALL Java_org_alljoyn_bus_samples_simpleclient_Client_simpleOnCreate(JNIEnv* env,
                                                                                       jobject jobj)
{
    QStatus status = ER_OK;
    const char* daemonAddr = "unix:abstract=alljoyn";

    /* Set AllJoyn logging */
    // QCC_SetLogLevels("ALLJOYN=7;ALL=1");
    QCC_UseOSLogging(true);

    /* Create message bus */
    s_bus = new BusAttachment("client", true);

    /* Add org.alljoyn.bus.samples.simple interface */
    InterfaceDescription* testIntf = NULL;
    status = s_bus->CreateInterface(SIMPLE_SERVICE_INTERFACE_NAME, testIntf);
    if (ER_OK == status) {
        testIntf->AddMethod("Ping", "s",  "s", "outStr, inStr", 0);
        testIntf->Activate();
    } else {
        LOGE("Failed to create interface \"%s\" (%s)", SIMPLE_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    }


    /* Start the msg bus */
    if (ER_OK == status) {
        status = s_bus->Start();
        if (ER_OK != status) {
            LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
        }
    }

    LOGD("\n Registering BUS Listener\n");
    /* Install discovery and name changed callbacks */
    if (ER_OK == status) {
        JavaVM* vm;
        env->GetJavaVM(&vm);
        s_busListener = new MyBusListener(vm, jobj);
        s_bus->RegisterBusListener(*s_busListener);
    }

    LOGD("\n Connecting to Daemon \n");
    /* Connect to the daemon */
    if (ER_OK == status) {
        status = s_bus->Connect(daemonAddr);
        if (ER_OK != status) {
            LOGE("BusAttachment::Connect(\"%s\") failed (%s)", daemonAddr, QCC_StatusText(status));
        }
    }
    LOGD("\n Looking for ADVERTISED name \n");
    /* Find an advertised name with the Prefix */
    status = s_bus->FindAdvertisedName(SIMPLE_SERVICE_WELL_KNOWN_NAME_PREFIX);
    if (ER_OK != status) {
        LOGE("\n Error while calling FindAdvertisedName \n");
    }

    return (int) status;
}
Ejemplo n.º 2
0
QStatus CreateInterface(string interfaceName)
{
    InterfaceDescription *intf = NULL;
    QStatus status = s_msgBus->CreateInterface(interfaceName.c_str(), intf);

    if (ER_OK == status) {
        cout << "Created message interface" <<endl;
        intf->AddMethod("on", "y", "s", "pinNum, ackStr", 0);
        intf->AddMethod("off", "y", "s", "pinNum, ackStr", 0);
        intf->Activate();
    } else {
        cout << "Could not create interface '"<< interfaceName <<"'" << endl;
    }

    return status;
}
int CDECL_CALL main()
{
    if (AllJoynInit() != ER_OK) {
        return 1;
    }
#ifdef ROUTER
    if (AllJoynRouterInit() != ER_OK) {
        AllJoynShutdown();
        return 1;
    }
#endif
    {
        BusAttachment busAttachment("AddInterfaceFromCode", true);
        busAttachment.Start();

        /// [code_interface_adding_to_busAttachment]
        InterfaceDescription* exampleIntf = NULL;
        QStatus status = busAttachment.CreateInterface(::com::example::name, exampleIntf);
        if (ER_OK == status) {
            status = exampleIntf->AddMethod("Echo", "s", "s", "input_arg,return_arg");
        }
        if (ER_OK == status) {
            status = exampleIntf->AddSignal("Chirp", "s", "sound", MEMBER_ANNOTATE_SESSIONCAST);
        }
        if (ER_OK == status) {
            status = exampleIntf->AddProperty("Volume", "i", PROP_ACCESS_RW);
        }
        if (ER_OK == status) {
            exampleIntf->Activate();
        } else {
            printf("Failed to create interface %s\n", ::com::example::name);
        }
        /// [code_interface_adding_to_busAttachment]

        const InterfaceDescription* interfaceFromBus = busAttachment.GetInterface(::com::example::name);
        if (interfaceFromBus == NULL) {
            printf("Failed to Get %s\n", ::com::example::name);
        } else {
            printf("Read the %s interface back from the BusAttachment.\n%s\n", ::com::example::name, interfaceFromBus->Introspect().c_str());
        }
    }
#ifdef ROUTER
    AllJoynRouterShutdown();
#endif
    AllJoynShutdown();
    return 0;
}
Ejemplo n.º 4
0
bool ChatObject::CreateInterfaces()
{
    const char* ifName = CHAT_SERVICE_INTERFACE_NAME;
    InterfaceDescription* chatIntf = NULL;

    status = ajConnection->busAttachment->CreateInterface(ifName, chatIntf);
    assert(chatIntf);
    if (ER_OK == status) {
        chatIntf->AddSignal("Chat", "s",  "str", 0);
        chatIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        return false;
    }
    NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    return true;
}
Ejemplo n.º 5
0
void ChatConnection::createMessageBus()
{
    QStatus status = ER_OK;
    NotifyUser(MSG_STATUS, "Create message bus.");
    ajn::BusAttachment* bus = new BusAttachment("chat", true);
    this->busAttachment = bus;
    this->busListener = new MyBusListener();
    this->busListener->SetListenCallback(JoinNotifier);
    this->busListener->SetConnection(this);
    /* Create org.alljoyn.bus.samples.chat interface */
    InterfaceDescription* chatIntf;
    status = bus->CreateInterface(CHAT_SERVICE_INTERFACE_NAME, chatIntf);
    if (ER_OK == status) {
        chatIntf->AddSignal("Chat", "s",  "str", 0);
        chatIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    }
    /* Create and register the bus object that will be used to send and receive signals */
    ChatObject* chatObject = new ChatObject(*bus, CHAT_SERVICE_OBJECT_PATH);
    this->chatObject = chatObject;
    this->busAttachment->RegisterBusObject(*chatObject);
    chatObject->SetConnection(this);
}
Ejemplo n.º 6
0
bool XferObject::CreateInterfaces()
{
    const char* ifName = XFER_SERVICE_INTERFACE_NAME;
    InterfaceDescription* xferIntf = NULL;
    status = ajConnection->busAttachment->CreateInterface(ifName, xferIntf);
    assert(xferIntf);
    if (ER_OK == status) {
        xferIntf->AddMethod("query", "si",  "i", "filename, filesize, acceptsize ", 0);
        xferIntf->AddMethod("initiate", "ii",  "i", "segmentSize, nSegs, acceptsize ", 0);
        xferIntf->AddMethod("receive", "ayii",  "i", "segment, serialNum. segSize , success ", 0);
        xferIntf->AddMethod("status", "i",  "i", "unused , status ", 0);
        xferIntf->AddMethod("close", "i",  "i", "unused , success ", 0);
        xferIntf->AddMethod("error", "i",  "i", "unused , error ", 0);
        xferIntf->Activate();
    } else {
        NotifyUser(MSG_ERROR, "Failed to create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        return false;
    }
    NotifyUser(MSG_SYSTEM, "Create interface \"%s\" (%s)\n", XFER_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
    return true;
}
Ejemplo n.º 7
0
/** Main entry point */
int main(int argc, char** argv, char** envArg)
{
    QStatus status = ER_OK;

    printf("AllJoyn Library version: %s\n", ajn::GetVersion());
    printf("AllJoyn Library build info: %s\n", ajn::GetBuildInfo());

    /* Install SIGINT handler */
    signal(SIGINT, SigIntHandler);

#ifdef _WIN32
    qcc::String connectArgs = "tcp:addr=127.0.0.1,port=9956";
#else
    qcc::String connectArgs = "unix:abstract=bluebus";
#endif

    /* Create message bus */
    g_msgBus = new BusAttachment("myApp", true);


    /* Add org.alljoyn.Bus.method_sample interface */
    InterfaceDescription* testIntf = NULL;
    status = g_msgBus->CreateInterface(SERVICE_NAME, testIntf);
    if (status == ER_OK) {
        printf("Interface Created.\n");
        testIntf->AddMethod("cat", "ss",  "s", "inStr1,inStr2,outStr", 0);
        testIntf->Activate();
    } else {
        printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n");
    }

    /* Start the msg bus */
    status = g_msgBus->Start();
    if (ER_OK == status) {
        printf("BusAttachement started.\n");
        /* Register  local objects and connect to the daemon */
        BasicSampleObject testObj(*g_msgBus, SERVICE_PATH);
        g_msgBus->RegisterBusObject(testObj);

        /* Create the client-side endpoint */
        status = g_msgBus->Connect(connectArgs.c_str());
        if (ER_OK != status) {
            printf("Failed to connect to \"%s\"\n", connectArgs.c_str());
            exit(1);
        } else {
            printf("Connected to '%s'\n", connectArgs.c_str());
        }

        if (ER_OK == status) {
            while (g_interrupt == false) {
#ifdef _WIN32
                Sleep(100);
#else
                usleep(100 * 1000);
#endif
            }
        }
    } else {
        printf("BusAttachment::Start failed\n");
    }

    /* Clean up msg bus */
    if (g_msgBus) {
        BusAttachment* deleteMe = g_msgBus;
        g_msgBus = NULL;
        delete deleteMe;
    }

    return (int) status;
}
Ejemplo n.º 8
0
/** Main entry point */
int main(int argc, char** argv, char** envArg)
{
    QStatus status = ER_OK;

    printf("AllJoyn Library version: %s\n", ajn::GetVersion());
    printf("AllJoyn Library build info: %s\n", ajn::GetBuildInfo());

    /* Install SIGINT handler */
    signal(SIGINT, SigIntHandler);

    const char* connectArgs = getenv("BUS_ADDRESS");
    if (connectArgs == NULL) {
#ifdef _WIN32
        connectArgs = "tcp:addr=127.0.0.1,port=9956";
#else
        connectArgs = "unix:abstract=alljoyn";
#endif
    }

    /* Create message bus */
    g_msgBus = new BusAttachment("myApp", true);

    /* Add org.alljoyn.Bus.method_sample interface */
    InterfaceDescription* testIntf = NULL;
    status = g_msgBus->CreateInterface(INTERFACE_NAME, testIntf);
    if (status == ER_OK) {
        printf("Interface Created.\n");
        testIntf->AddMethod("cat", "ss",  "s", "inStr1,inStr2,outStr", 0);
        testIntf->Activate();
    } else {
        printf("Failed to create interface 'org.alljoyn.Bus.method_sample'\n");
    }


    /* Start the msg bus */
    if (ER_OK == status) {
        status = g_msgBus->Start();
        if (ER_OK != status) {
            printf("BusAttachment::Start failed\n");
        } else {
            printf("BusAttachment started.\n");
        }
    }

    /* Connect to the bus */
    if (ER_OK == status) {
        status = g_msgBus->Connect(connectArgs);
        if (ER_OK != status) {
            printf("BusAttachment::Connect(\"%s\") failed\n", connectArgs);
        } else {
            printf("BusAttchement connected to %s\n", connectArgs);
        }
    }

    /* Register a bus listener in order to get discovery indications */
    if (ER_OK == status) {
        g_msgBus->RegisterBusListener(g_busListener);
        printf("BusListener Registered.\n");
    }

    /* Begin discovery on the well-known name of the service to be called */
    if (ER_OK == status) {
        status = g_msgBus->FindAdvertisedName(SERVICE_NAME);
        if (status != ER_OK) {
            printf("org.alljoyn.Bus.FindAdvertisedName failed (%s))\n", QCC_StatusText(status));
        }
    }

    /* Wait for join session to complete */
    while (!s_joinComplete  && !g_interrupt) {
#ifdef _WIN32
        Sleep(1000);
#else
        usleep(100 * 1000);
#endif
    }

    if (status == ER_OK && g_interrupt == false) {
        ProxyBusObject remoteObj(*g_msgBus, SERVICE_NAME, SERVICE_PATH, s_sessionId);
        const InterfaceDescription* alljoynTestIntf = g_msgBus->GetInterface(INTERFACE_NAME);
        assert(alljoynTestIntf);
        remoteObj.AddInterface(*alljoynTestIntf);

        Message reply(*g_msgBus);
        MsgArg inputs[2];
        inputs[0].Set("s", "Hello ");
        inputs[1].Set("s", "World!");
        status = remoteObj.MethodCall(SERVICE_NAME, "cat", inputs, 2, reply, 5000);
        if (ER_OK == status) {
            printf("%s.%s ( path=%s) returned \"%s\"\n", SERVICE_NAME, "cat",
                   SERVICE_PATH, reply->GetArg(0)->v_string.str);
        } else {
            printf("MethodCall on %s.%s failed", SERVICE_NAME, "cat");
        }
    }

    /* Deallocate bus */
    if (g_msgBus) {
        BusAttachment* deleteMe = g_msgBus;
        g_msgBus = NULL;
        delete deleteMe;
    }

    printf("basic client exiting with status %d (%s)\n", status, QCC_StatusText(status));

    return (int) status;
}
Ejemplo n.º 9
0
/*
 * Class:     org_alljoyn_bus_samples_simpleservice_Service
 * Method:    startService
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_org_alljoyn_bus_samples_simpleservice_Service_startService(JNIEnv* env, jobject jobj,
                                                                                           jstring jServiceName, jstring packageNameStrObj)
{
    QStatus status = ER_OK;

    jboolean iscopy;
    const char* serviceNameStr = env->GetStringUTFChars(jServiceName, &iscopy);
    serviceName = "";
    serviceName += SIMPLE_SERVICE_WELL_KNOWN_NAME_PREFIX;
    serviceName += serviceNameStr;

    SessionOpts opts(SessionOpts::TRAFFIC_MESSAGES, false, SessionOpts::PROXIMITY_ANY, TRANSPORT_ANY);

    const char* daemonAddr = "unix:abstract=alljoyn";

    /* Initialize AllJoyn only once */
    if (!s_bus) {
        const char* packageNameStr = env->GetStringUTFChars(packageNameStrObj, &iscopy);
        s_bus = new BusAttachment("service", true);

        /* Add org.alljoyn.samples.simple interface */
        InterfaceDescription* testIntf = NULL;
        status = s_bus->CreateInterface(SIMPLE_SERVICE_INTERFACE_NAME, testIntf);
        if (ER_OK == status) {
            testIntf->AddMethod("Ping", "s",  "s", "inStr,outStr", 0);
            testIntf->Activate();
        } else {
            LOGE("Failed to create interface %s (%s)", SIMPLE_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        }

        /* Start the msg bus */
        if (ER_OK == status) {
            status = s_bus->Start();
        } else {
            LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
        }

        /* Connect to the daemon */
        if (ER_OK == status) {
            status = s_bus->Connect(daemonAddr);
            if (ER_OK != status) {
                LOGE("Connect to %s failed (%s)", daemonAddr, QCC_StatusText(status));
            }
        }

        /* Register the bus listener */
        JavaVM* vm;
        env->GetJavaVM(&vm);
        if (ER_OK == status) {
            s_busListener = new MyBusListener(vm, jobj);
            s_bus->RegisterBusListener(*s_busListener);
            LOGD("\n Bus Listener registered \n");
        }

        /* Register service object */
        s_obj = new ServiceObject(*s_bus, SIMPLE_SERVICE_OBJECT_PATH, vm, jobj);
        s_bus->RegisterBusObject(*s_obj);

        /* Bind the session port*/
        if (ER_OK == status) {
            SessionPort sp = SESSION_PORT;
            status = s_bus->BindSessionPort(sp, opts, *s_busListener);
            if (ER_OK != status) {
                LOGE("BindSessionPort failed (%s)\n", QCC_StatusText(status));
            } else {
                LOGD("\n Bind Session Port to %d was successful \n", SESSION_PORT);
            }
        }
        env->ReleaseStringUTFChars(packageNameStrObj, packageNameStr);
    }

    /* Request name */
    status = s_bus->RequestName(serviceName.c_str(), DBUS_NAME_FLAG_DO_NOT_QUEUE);
    if (ER_OK != status) {
        LOGE("RequestName(%s) failed (status=%s)\n", serviceName.c_str(), QCC_StatusText(status));
        status = (status == ER_OK) ? ER_FAIL : status;
    } else {
        LOGD("\n Request Name was successful");
    }

    /* Advertise the name */
    if (ER_OK == status) {

        status = s_bus->AdvertiseName(serviceName.c_str(), opts.transports);
        if (status != ER_OK) {
            LOGD("Failed to advertise name %s (%s) \n", serviceName.c_str(), QCC_StatusText(status));
        } else {
            LOGD("\n Name %s was successfully advertised", serviceName.c_str());
        }
    }
    env->ReleaseStringUTFChars(jServiceName, serviceNameStr);
    env->DeleteLocalRef(jServiceName);
    return (jboolean) true;
}
Ejemplo n.º 10
0
/**
 * Initialize AllJoyn and connect to local daemon.
 */
JNIEXPORT jint JNICALL Java_org_alljoyn_bus_samples_chat_Chat_jniOnCreate(JNIEnv* env, jobject jobj,
                                                                          jstring packageNameStrObj)
{
    QStatus status = ER_OK;
    const char* packageNameStr = NULL;
    InterfaceDescription* chatIntf = NULL;
    const char* daemonAddr = "unix:abstract=alljoyn";
    JavaVM* vm;
    jobject jglobalObj = NULL;

    packageNameStr = env->GetStringUTFChars(packageNameStrObj, NULL);
    if (!packageNameStr) {
        LOGE("GetStringUTFChars failed");
        status = ER_FAIL;
        goto exit;
    }
    /* Create message bus */
    s_bus = new BusAttachment(packageNameStr, true);
    if (!s_bus) {
        LOGE("new BusAttachment failed");
        status = ER_FAIL;
        goto exit;
    }

    /* Create org.alljoyn.bus.samples.chat interface */
    status = s_bus->CreateInterface(CHAT_SERVICE_INTERFACE_NAME, chatIntf);
    if (ER_OK != status) {
        LOGE("Failed to create interface \"%s\" (%s)", CHAT_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
        goto exit;
    }
    status = chatIntf->AddSignal("Chat", "s",  "str", 0);
    if (ER_OK != status) {
        LOGE("Failed to AddSignal \"Chat\" (%s)", QCC_StatusText(status));
        goto exit;
    }
    chatIntf->Activate();

    /* Start the msg bus */
    status = s_bus->Start();
    if (ER_OK != status) {
        LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
        goto exit;
    }

    /* Connect to the daemon */
    status = s_bus->Connect(daemonAddr);
    if (ER_OK != status) {
        LOGE("BusAttachment::Connect(\"%s\") failed (%s)", daemonAddr, QCC_StatusText(status));
        goto exit;
    }

    /* Create and register the bus object that will be used to send out signals */
    if (0 != env->GetJavaVM(&vm)) {
        LOGE("GetJavaVM failed");
        status = ER_FAIL;
        goto exit;
    }
    jglobalObj = env->NewGlobalRef(jobj);
    if (!jglobalObj) {
        LOGE("NewGlobalRef failed");
        status = ER_FAIL;
        goto exit;
    }
    s_chatObj = new ChatObject(*s_bus, CHAT_SERVICE_OBJECT_PATH, vm, jglobalObj);
    if (!s_chatObj) {
        LOGE("new ChatObject failed");
        status = ER_FAIL;
        goto exit;
    }
    jglobalObj = NULL; /* ChatObject owns global reference now */
    status = s_bus->RegisterBusObject(*s_chatObj);
    if (ER_OK != status) {
        LOGE("BusAttachment::RegisterBusObject() failed (%s)", QCC_StatusText(status));
        goto exit;
    }
    LOGD("\n Bus Object created and registered \n");

    /* Register a bus listener in order to get discovery indications */
    s_busListener = new MyBusListener();
    if (!s_busListener) {
        LOGE("new BusListener failed");
        status = ER_FAIL;
        goto exit;
    }
    s_bus->RegisterBusListener(*s_busListener);

exit:
    if (ER_OK != status) {
        delete s_bus;
        s_bus = NULL;

        delete s_chatObj;
        s_chatObj = NULL;

        delete s_busListener;
        s_busListener = NULL;

        if (jglobalObj) {
            env->DeleteGlobalRef(jglobalObj);
        }
    }
    if (packageNameStr) {
        env->ReleaseStringUTFChars(packageNameStrObj, packageNameStr);
    }
    return (jint) status;
}
Ejemplo n.º 11
0
/*
 * Class:     org_alljoyn_jni_AllJoynAndroidExt
 * Method:    jniOnCreate
 * Signature: (Ljava/lang/String;)I
 */
JNIEXPORT jint JNICALL Java_org_alljoyn_jni_AllJoynAndroidExt_jniOnCreate(JNIEnv*env, jobject jobj, jstring packageNameStrObj) {


    QStatus status = ER_OK;
    const char* packageNameStr = NULL;
    const char* daemonAddr = "unix:abstract=alljoyn";
    InterfaceDescription* scanIntf = NULL;
    JavaVM* vm;
    jobject jglobalObj = NULL;

    jglobalObj = env->NewGlobalRef(jobj);

    env->GetJavaVM(&vm);

    packageNameStr = env->GetStringUTFChars(packageNameStrObj, NULL);
    if (!packageNameStr) {
        LOGE("GetStringUTFChars failed");
        status = ER_FAIL;
    }

    while (true) {

        /* Create message bus */
        s_bus = new BusAttachment("AllJoynAndroidExtService", true);
        if (!s_bus) {
            LOGE("new BusAttachment failed");
        } else {
            /* Create org.alljoyn.bus.samples.chat interface */
            status = s_bus->CreateInterface(SCAN_SERVICE_INTERFACE_NAME, scanIntf);
            if (ER_OK != status) {
                LOGE("Failed to create interface \"%s\" (%s)", SCAN_SERVICE_INTERFACE_NAME, QCC_StatusText(status));
            } else {
                status = scanIntf->AddMethod("Scan", "b",  "a(ssb)", "results");
                if (ER_OK != status) {
                    LOGE("Failed to AddMethod \"Scan\" (%s)", QCC_StatusText(status));
                }

                status = scanIntf->AddMethod("GetHomeDir", NULL, "s", "results");
                if (ER_OK != status) {
                    LOGE("Failed to AddMethod \"GetHomeDir\" (%s)", QCC_StatusText(status));
                }

                scanIntf->Activate();

                /* Register service object */
                s_obj = new ScanService(*s_bus, SCAN_SERVICE_OBJECT_PATH, vm, jglobalObj);
                status = s_bus->RegisterBusObject(*s_obj);
                if (ER_OK != status) {
                    LOGE("BusAttachment::RegisterBusObject failed (%s)", QCC_StatusText(status));
                } else {
                    /* Start the msg bus */
                    status = s_bus->Start();
                    if (ER_OK != status) {
                        LOGE("BusAttachment::Start failed (%s)", QCC_StatusText(status));
                    } else {
                        /* Connect to the daemon */
                        status = s_bus->Connect(daemonAddr);
                        if (ER_OK != status) {
                            //LOGE("BusAttachment::Connect(\"%s\") failed (%s)", daemonAddr, QCC_StatusText(status));
                            s_bus->Disconnect(daemonAddr);
                            s_bus->UnregisterBusObject(*s_obj);
                            delete s_obj;
                        } else {
                            LOGE("BusAttachment::Connect(\"%s\") SUCCEDDED (%s)", daemonAddr, QCC_StatusText(status));
                            break;
                        }
                    }
                }
            }
        }
        //LOGD("Sleeping before trying to reconnect to the daemon");
        sleep(5);
        //LOGD("Up from sleep");
    }


    /* Request name */
    status = s_bus->RequestName(SERVICE_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE);
    if (ER_OK != status) {
        LOGE("RequestName(%s) failed (status=%s)\n", SERVICE_NAME, QCC_StatusText(status));
        status = (status == ER_OK) ? ER_FAIL : status;
    } else {
        LOGE("\n Request Name was successful");
    }


    return (jint) 1;


}
Ejemplo n.º 12
0
static QStatus BuildInterface(BusAttachment& bus)
{
    QStatus status;

    InterfaceDescription* intf = NULL;
    status = bus.CreateInterface(INTF_NAME, intf);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("IsOpen", "b", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("IsOpen", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("Location", "s", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("Location", "org.freedesktop.DBus.Property.EmitsChangedSignal", "true");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddProperty("KeyCode", "u", PROP_ACCESS_READ);
    QCC_ASSERT(ER_OK == status);
    status = intf->AddPropertyAnnotation("KeyCode", "org.freedesktop.DBus.Property.EmitsChangedSignal", "invalidates");
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("Open", "", "", "");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddMethod("Close", "", "", "");
    QCC_ASSERT(ER_OK == status);
    status = intf->AddMethod("KnockAndRun", "", "", "", MEMBER_ANNOTATE_NO_REPLY);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("GetUI", "", "s", "outStr", 0);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddMethod("CallFunc", "s", "s", "in", 0);
    QCC_ASSERT(ER_OK == status);

    status = intf->AddSignal("PersonPassedThrough", "s", "name", MEMBER_ANNOTATE_SESSIONCAST);
    QCC_ASSERT(ER_OK == status);

    intf->Activate();

    return status;
}