Exemple #1
0
AJ_Status MarshalAllRootProperties(AJ_Message* reply)
{
    AJ_Status status;
    AJ_Arg rootGetAllArray;
    AJ_Arg dictArg;

    status = AJ_MarshalContainer(reply, &rootGetAllArray, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(reply, &dictArg, AJ_ARG_DICT_ENTRY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "s", PROPERTY_TYPE_VERSION_NAME);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalVariant(reply, PROPERTY_TYPE_VERSION_SIG);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVersionRootProperties(reply);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalCloseContainer(reply, &dictArg);
    if (status != AJ_OK) {
        return status;
    }
    return AJ_MarshalCloseContainer(reply, &rootGetAllArray);
}
Exemple #2
0
AJ_Status marshalDatePropertyValue(DatePropertyValue* datePropertyValue, AJ_Message* reply)
{
    AJ_Status status;
    AJ_Arg outerStructArg, innerStructArg;

    status = AJ_MarshalVariant(reply, DATE_PROPERTY_SIG);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(reply, &outerStructArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "q", DATE_PROPERTY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(reply, &innerStructArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }

    status = AJ_MarshalArgs(reply, "qqq", datePropertyValue->mDay, datePropertyValue->month, datePropertyValue->fullYear);
    if (status != AJ_OK) {
        return status;
    }

    status = AJ_MarshalCloseContainer(reply, &innerStructArg);
    if (status != AJ_OK) {
        return status;
    }
    return AJ_MarshalCloseContainer(reply, &outerStructArg);
}
Exemple #3
0
AJ_Status marshalTimePropertyValue(TimePropertyValue* timePropertyValue, AJ_Message* reply)
{
    AJ_Status status;
    AJ_Arg outerStructArg, innerStructArg;

    status = AJ_MarshalVariant(reply, TIME_PROPERTY_SIG);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(reply, &outerStructArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "q", TIME_PROPERTY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(reply, &innerStructArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }

    status = AJ_MarshalArgs(reply, "qqq", timePropertyValue->hour, timePropertyValue->minute, timePropertyValue->second);
    if (status != AJ_OK) {
        return status;
    }

    status = AJ_MarshalCloseContainer(reply, &innerStructArg);
    if (status != AJ_OK) {
        return status;
    }
    return AJ_MarshalCloseContainer(reply, &outerStructArg);
}
AJ_Status AJOBS_GetScanInfoHandler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Message reply;
    AJ_Arg array;
    AJ_Arg structure;
    uint32_t elapsed;

    AJ_InfoPrintf(("Handling GetScanInfo request\n"));

    status = AJ_MarshalReplyMsg(msg, &reply);
    if (status != AJ_OK) {
        return status;
    }

    elapsed = AJ_GetElapsedTime(AJOBS_GetLastScanTime(), TRUE);
    if (elapsed > 0) {
        elapsed /= 60000;
    }
    status = AJ_MarshalArgs(&reply, "q", (uint16_t) elapsed);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(&reply, &array, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }

    int i = 0;
    for (; i < AJOBS_GetScanInfoCount(); ++i) {
        status = AJ_MarshalContainer(&reply, &structure, AJ_ARG_STRUCT);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalArgs(&reply, "s", (AJOBS_GetScanInfos())[i].ssid);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalArgs(&reply, "n", (AJOBS_GetScanInfos())[i].authType);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalCloseContainer(&reply, &structure);
        if (status != AJ_OK) {
            return status;
        }
    }

    status = AJ_MarshalCloseContainer(&reply, &array);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_DeliverMsg(&reply);
    if (status != AJ_OK) {
        return status;
    }

    return status;
}
/*
 * Handles a property GET request so marshals the property value to return
 */
AJ_Status AJOBS_PropGetHandler(AJ_Message* replyMsg, uint32_t propId, void* context)
{
    AJ_Status status = AJ_OK;
    AJ_Arg structure;
    const AJOBS_Error* obError = AJOBS_GetError();
    if (propId == OBS_VERSION_PROP) {
        status = AJ_MarshalArgs(replyMsg, "q", AJSVC_OnboardingVersion);
    } else if (propId == OBS_STATE_PROP) {
        status = AJ_MarshalArgs(replyMsg, "n", AJOBS_GetState());
    } else if (propId == OBS_LASTERROR_PROP) {
        status = AJ_MarshalContainer(replyMsg, &structure, AJ_ARG_STRUCT);
        if (status != AJ_OK) {
            goto Exit;
        }
        status = AJ_MarshalArgs(replyMsg, "ns", obError->code, obError->message);
        if (status != AJ_OK) {
            goto Exit;
        }
        status = AJ_MarshalCloseContainer(replyMsg, &structure);
    } else {
        status = AJ_ERR_UNEXPECTED;
    }

Exit:

    return status;
}
AJ_Status marshalAllPropertyProperties(BaseWidget* widget, AJ_Message* reply, uint16_t language)
{
    AJ_Status status;
    AJ_Arg propertyGetAllArray;

    status = AJ_MarshalContainer(reply, &propertyGetAllArray, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }

    status = marshalAllBaseProperties(widget, reply, language);
    if (status != AJ_OK) {
        return status;
    }

    status = AddPropertyForGetAll(reply, PROPERTY_TYPE_OPTPARAMS_NAME, PROPERTY_TYPE_OPTPARAMS_SIG, widget, language, marshalPropertyOptParam);
    if (status != AJ_OK) {
        return status;
    }

    status = AddPropertyForGetAll(reply, PROPERTY_TYPE_VALUE_NAME, PROPERTY_TYPE_VALUE_SIG, widget, language, (MarshalWidgetFptr)marshalPropertyValue);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &propertyGetAllArray);
}
Exemple #7
0
AJ_Status AddPropertyForGetAll(AJ_Message* reply, char* key, const char* sig,
                               BaseWidget* widget, uint16_t language, MarshalWidgetFptr functionPtr)
{
    AJ_Status status;
    AJ_Arg dictArg;

    status = AJ_MarshalContainer(reply, &dictArg, AJ_ARG_DICT_ENTRY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "s", key);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalVariant(reply, sig);
    if (status != AJ_OK) {
        return status;
    }
    status = functionPtr(widget, reply, language);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &dictArg);
}
AJ_Status marshalConstraintList(BaseWidget* widget, ConstraintList* constraints, AJ_Message* reply, uint16_t numConstraints,
                                const char* signature, uint16_t language)
{
    AJ_Status status;
    AJ_Arg arrayArg, opParams;
    uint16_t cnt;
    PropertyWidget* propWidget = (PropertyWidget*)widget;

    status = StartComplexOptionalParam(reply, &opParams, PROPERTY_CONSTRAINT_LIST, PROPERTY_CONSTRAINT_LIST_SIG);
    if (status != AJ_OK) {
        return status;
    }

    status = AJ_MarshalContainer(reply, &arrayArg, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }

    for (cnt = 0; cnt < numConstraints; cnt++) {
        const void* value;
        const char* display;
        if (propWidget->optParams.getConstraint) {
            display = propWidget->optParams.getConstraint(propWidget, cnt, &value, language);
        } else if (constraints[cnt].getDisplay != 0) {
            value = constraints[cnt].value;
            display = constraints[cnt].getDisplay(language);
        } else {
            value = constraints[cnt].value;
            display = constraints[cnt].display[language];
        }
        status = AddConstraintValue(reply, signature, value, display);
        if (status != AJ_OK) {
            return status;
        }
    }

    status = AJ_MarshalCloseContainer(reply, &arrayArg);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &opParams);
}
static AJ_Status MarshalSessionOpts(AJ_Message* msg, const AJ_SessionOpts* opts)
{
    AJ_Arg dictionary;

    AJ_MarshalContainer(msg, &dictionary, AJ_ARG_ARRAY);

    AJ_MarshalArgs(msg, "{sv}", "traf",  "y", opts->traffic);
    AJ_MarshalArgs(msg, "{sv}", "multi", "b", opts->isMultipoint);
    AJ_MarshalArgs(msg, "{sv}", "prox",  "y", opts->proximity);
    AJ_MarshalArgs(msg, "{sv}", "trans", "q", opts->transports);

    AJ_MarshalCloseContainer(msg, &dictionary);

    return AJ_OK;
}
Exemple #10
0
static AJ_Status SendSignal(AJ_BusAttachment* bus, uint32_t sessionId)
{
    AJ_Status status;
    AJ_Message msg;


    status = AJ_MarshalSignal(bus, &msg, PRX_MY_SIGNAL, ServiceName, sessionId, 0, 0);
    if (status == AJ_OK) {
        AJ_Arg arg;
        status = AJ_MarshalContainer(&msg, &arg, AJ_ARG_ARRAY);
        status = AJ_MarshalCloseContainer(&msg, &arg);
    }
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
AJ_Status marshalPropertyOptParam(BaseWidget* widget, AJ_Message* reply, uint16_t language)
{
    PropertyOptParams* optParams = &((PropertyWidget*)widget)->optParams;
    AJ_Status status;
    AJ_Arg propertyOptParams;

    status = StartOptionalParams(reply, &propertyOptParams);
    if (status != AJ_OK) {
        return status;
    }

    status = marshalBaseOptParam(widget, reply, language);
    if (status != AJ_OK) {
        return status;
    }

    if (optParams->getUnitOfMeasure) {
        const char* unitOfMeasure = optParams->getUnitOfMeasure(language);
        status = AddBasicOptionalParam(reply, PROPERTY_UNIT_OF_MEASURE, PROPERTY_UNIT_OF_MEASURE_SIG, &unitOfMeasure);
        if (status != AJ_OK) {
            return status;
        }
    } else if (optParams->unitOfMeasure) {
        const char* unitOfMeasure = optParams->unitOfMeasure[language];
        status = AddBasicOptionalParam(reply, PROPERTY_UNIT_OF_MEASURE, PROPERTY_UNIT_OF_MEASURE_SIG, &unitOfMeasure);
        if (status != AJ_OK) {
            return status;
        }
    }

    if (optParams->constraintList && optParams->numConstraints) {
        status = marshalConstraintList(optParams->constraintList, reply, optParams->numConstraints, ((PropertyWidget*)widget)->signature, language);
        if (status != AJ_OK) {
            return status;
        }
    }

    if (optParams->constraintRangeDefined) {
        status = marshalConstraintRange(&optParams->constraintRange, reply);
        if (status != AJ_OK) {
            return status;
        }
    }

    return AJ_MarshalCloseContainer(reply, &propertyOptParams);
}
Exemple #12
0
AJ_Status marshalConstraintRange(ConstraintRange* constraints, AJ_Message* reply)
{
    AJ_Status status;
    AJ_Arg constraintRange;

    status = StartComplexOptionalParam(reply, &constraintRange, PROPERTY_CONSTRAINT_RANGE, PROPERTY_CONSTRAINT_RANGE_SIG);
    if (status != AJ_OK) {
        return status;
    }

    status = AddConstraintRange(reply, *constraints->signature, constraints->minValue, constraints->maxValue, constraints->increment);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &constraintRange);
}
Exemple #13
0
AJ_Status AddHints(AJ_Message* reply, const uint16_t hints[], uint16_t numHints)
{
    AJ_Status status;
    AJ_Arg arrayArg;
    uint16_t cnt;

    status = AJ_MarshalContainer(reply, &arrayArg, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }
    for (cnt = 0; cnt < numHints; cnt++)
        status = AJ_MarshalArgs(reply, "q", hints[cnt]);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &arrayArg);
}
Exemple #14
0
AJ_Status AddBasicOptionalParam(AJ_Message* reply, uint16_t key, const char* sig, const void* value)
{
    AJ_Status status;
    AJ_Arg dictArg;

    status = AJ_MarshalContainer(reply, &dictArg, AJ_ARG_DICT_ENTRY);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "q", key);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVariant(reply, sig, value);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &dictArg);
}
Exemple #15
0
AJ_Status AddConstraintValue(AJ_Message* reply, const char* sig, const void* value, const char* displayValue)
{
    AJ_Status status;
    AJ_Arg structArg;

    status = AJ_MarshalContainer(reply, &structArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVariant(reply, sig, value);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalArgs(reply, "s", displayValue);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &structArg);
}
Exemple #16
0
AJ_Status AddConstraintRange(AJ_Message* reply, const char* valueSig, const void* min, const void* max, const void* increment)
{
    AJ_Status status;
    AJ_Arg structArg;

    status = AJ_MarshalContainer(reply, &structArg, AJ_ARG_STRUCT);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVariant(reply, valueSig, min);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVariant(reply, valueSig, max);
    if (status != AJ_OK) {
        return status;
    }
    status = MarshalVariant(reply, valueSig, increment);
    if (status != AJ_OK) {
        return status;
    }

    return AJ_MarshalCloseContainer(reply, &structArg);
}
Exemple #17
0
int AJ_Main()
{
    AJ_Status status = AJ_OK;
    AJ_BusAttachment bus;
    uint8_t connected = FALSE;
    uint32_t sessionId = 0;
    X509CertificateChain* node;

    /*
     * One time initialization before calling any other AllJoyn APIs
     */
    AJ_Initialize();

    AJ_PrintXML(AppObjects);
    AJ_RegisterObjects(AppObjects, NULL);
    AJ_AboutRegisterPropStoreGetter(AboutPropGetter);

    SetBusAuthPwdCallback(MyBusAuthPwdCB);
    while (TRUE) {
        AJ_Message msg;

        if (!connected) {
            status = AJ_StartService(&bus, NULL, CONNECT_TIMEOUT, FALSE, ServicePort, ServiceName, AJ_NAME_REQ_DO_NOT_QUEUE, NULL);
            if (status != AJ_OK) {
                continue;
            }
            AJ_InfoPrintf(("StartService returned AJ_OK\n"));
            AJ_InfoPrintf(("Connected to Daemon:%s\n", AJ_GetUniqueName(&bus)));

            AJ_SetIdleTimeouts(&bus, 10, 4);

            connected = TRUE;
#ifdef SECURE_OBJECT
            status = AJ_SetObjectFlags("/org/alljoyn/alljoyn_test", AJ_OBJ_FLAG_SECURE, 0);
            if (status != AJ_OK) {
                AJ_ErrPrintf(("Error calling AJ_SetObjectFlags.. [%s] \n", AJ_StatusText(status)));
                return -1;
            }
#endif

#if defined(SECURE_INTERFACE) || defined(SECURE_OBJECT)

            /* Register a callback for providing bus authentication password */
            AJ_BusSetPasswordCallback(&bus, PasswordCallback);
            AJ_BusEnableSecurity(&bus, suites, numsuites);
            AJ_BusSetAuthListenerCallback(&bus, AuthListenerCallback);
#endif

            /* Configure timeout for the link to the daemon bus */
            AJ_SetBusLinkTimeout(&bus, 60); // 60 seconds
        }

        status = AJ_UnmarshalMsg(&bus, &msg, UNMARSHAL_TIMEOUT);
        if (AJ_ERR_TIMEOUT == status && AJ_ERR_LINK_TIMEOUT == AJ_BusLinkStateProc(&bus)) {
            status = AJ_ERR_READ;
        }
        if (status != AJ_OK) {
            if (status == AJ_ERR_TIMEOUT) {
                AppDoWork();
                continue;
            }
        }

        if (status == AJ_OK) {
            switch (msg.msgId) {

            case AJ_REPLY_ID(AJ_METHOD_ADD_MATCH):
                if (msg.hdr->msgType == AJ_MSG_ERROR) {
                    AJ_InfoPrintf(("Failed to add match\n"));
                    status = AJ_ERR_FAILURE;
                } else {
                    status = AJ_OK;
                }
                break;

            case AJ_METHOD_ACCEPT_SESSION:
                {
                    uint16_t port;
                    char* joiner;
                    AJ_UnmarshalArgs(&msg, "qus", &port, &sessionId, &joiner);
                    if (port == ServicePort) {
                        status = AJ_BusReplyAcceptSession(&msg, TRUE);
                        AJ_InfoPrintf(("Accepted session session_id=%u joiner=%s\n", sessionId, joiner));
                    } else {
                        status = AJ_BusReplyAcceptSession(&msg, FALSE);
                        AJ_InfoPrintf(("Accepted rejected session_id=%u joiner=%s\n", sessionId, joiner));
                    }
                }
                break;

            case APP_MY_PING:
                status = AppHandlePing(&msg);
                break;

            case APP_GET_PROP:
                status = AJ_BusPropGet(&msg, PropGetHandler, NULL);
                break;

            case APP_SET_PROP:
                status = AJ_BusPropSet(&msg, PropSetHandler, NULL);
                if (status == AJ_OK) {
                    AJ_InfoPrintf(("Property successfully set to %d.\n", propVal));
                } else {
                    AJ_InfoPrintf(("Property set attempt unsuccessful. Status = 0x%04x.\n", status));
                }
                break;

            case AJ_SIGNAL_SESSION_LOST_WITH_REASON:
                {
                    uint32_t id, reason;
                    AJ_UnmarshalArgs(&msg, "uu", &id, &reason);
                    AJ_InfoPrintf(("Session lost. ID = %u, reason = %u", id, reason));
                    if (CancelAdvertiseName) {
                        status = AJ_BusAdvertiseName(&bus, ServiceName, AJ_TRANSPORT_ANY, AJ_BUS_START_ADVERTISING, 0);
                    }
                    status = AJ_ERR_SESSION_LOST;
                }
                break;

            case AJ_SIGNAL_SESSION_JOINED:
                if (CancelAdvertiseName) {
                    status = AJ_BusAdvertiseName(&bus, ServiceName, AJ_TRANSPORT_ANY, AJ_BUS_STOP_ADVERTISING, 0);
                }
                break;

            case AJ_REPLY_ID(AJ_METHOD_CANCEL_ADVERTISE):
            case AJ_REPLY_ID(AJ_METHOD_ADVERTISE_NAME):
                if (msg.hdr->msgType == AJ_MSG_ERROR) {
                    status = AJ_ERR_FAILURE;
                }
                break;

            case AJ_REPLY_ID(AJ_METHOD_BUS_SET_IDLE_TIMEOUTS):
                {
                    uint32_t disposition, idleTo, probeTo;
                    if (msg.hdr->msgType == AJ_MSG_ERROR) {
                        status = AJ_ERR_FAILURE;
                    }
                    AJ_UnmarshalArgs(&msg, "uuu", &disposition, &idleTo, &probeTo);
                    AJ_InfoPrintf(("SetIdleTimeouts response disposition=%u idleTimeout=%u probeTimeout=%u\n", disposition, idleTo, probeTo));
                }
                break;

            case APP_MY_SIGNAL:
                AJ_InfoPrintf(("Received my_signal\n"));
                status = AJ_OK;

                if (ReflectSignal) {
                    AJ_Message out;
                    AJ_Arg arg;
                    AJ_MarshalSignal(&bus, &out, APP_MY_SIGNAL, msg.sender, msg.sessionId, 0, 0);
                    AJ_MarshalContainer(&out, &arg, AJ_ARG_ARRAY);
                    AJ_MarshalCloseContainer(&out, &arg);
                    AJ_DeliverMsg(&out);
                    AJ_CloseMsg(&out);
                }
                break;

            default:
                /*
                 * Pass to the built-in bus message handlers
                 */
                status = AJ_BusHandleBusMessage(&msg);
                break;
            }

            // Any received packets indicates the link is active, so call to reinforce the bus link state
            AJ_NotifyLinkActive();
        }
        /*
         * Unarshaled messages must be closed to free resources
         */
        AJ_CloseMsg(&msg);

        if ((status == AJ_ERR_READ) || (status == AJ_ERR_LINK_DEAD)) {
            AJ_InfoPrintf(("AllJoyn disconnect\n"));
            AJ_InfoPrintf(("Disconnected from Daemon:%s\n", AJ_GetUniqueName(&bus)));
            AJ_Disconnect(&bus);
            connected = FALSE;
            /*
             * Sleep a little while before trying to reconnect
             */
            AJ_Sleep(10 * 1000);
        }
    }
    AJ_WarnPrintf(("svclite EXIT %d\n", status));

#if defined(SECURE_INTERFACE) || defined(SECURE_OBJECT)
    // Clean up certificate chain
    while (chain) {
        node = chain;
        chain = chain->next;
        AJ_Free(node->certificate.der.data);
        AJ_Free(node);
    }
#endif

    return status;
}
Exemple #18
0
int AJ_Main()
{
    AJ_Status status;
    AJ_BusAttachment bus;
    AJ_Message txMsg;
    AJ_Message rxMsg;
    AJ_Arg arg;
    AJ_Arg array1;
    AJ_Arg array2;
    AJ_Arg struct1;
    AJ_Arg struct2;
    size_t sz;
    uint32_t i;
    uint32_t j;
    uint32_t k;
    uint32_t key;
    uint32_t len;
    uint32_t u;
    uint32_t v;
    int32_t n;
    int32_t m;
    uint16_t q;
    uint16_t r;
    uint8_t y;
    char* str;
    char* sig;
    void* raw;

    bus.sock.tx.direction = AJ_IO_BUF_TX;
    bus.sock.tx.bufSize = sizeof(txBuffer);
    bus.sock.tx.bufStart = txBuffer;
    bus.sock.tx.readPtr = bus.sock.tx.bufStart;
    bus.sock.tx.writePtr = bus.sock.tx.bufStart;
    bus.sock.tx.send = TxFunc;

    bus.sock.rx.direction = AJ_IO_BUF_RX;
    bus.sock.rx.bufSize = sizeof(rxBuffer);
    bus.sock.rx.bufStart = rxBuffer;
    bus.sock.rx.readPtr = bus.sock.rx.bufStart;
    bus.sock.rx.writePtr = bus.sock.rx.bufStart;
    bus.sock.rx.recv = RxFunc;

    /*
     * Set the hook
     */
#ifndef NDEBUG
    MutterHook = MsgInit;
#else
    AJ_Printf("mutter only works in DEBUG builds\n");
    return -1;
#endif

    for (i = 0; i < ArraySize(testSignature); ++i) {

        status = AJ_MarshalSignal(&bus, &txMsg, i, "mutter.service", 0, 0, 0);
        if (status != AJ_OK) {
            break;
        }

        switch (i) {
        case 0:
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (key = 0; key < ArraySize(Fruits); ++key) {
                AJ_Arg dict;
                CHECK(AJ_MarshalContainer(&txMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_MarshalArgs(&txMsg, "us", key, Fruits[key]));
                CHECK(AJ_MarshalCloseContainer(&txMsg, &dict));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            break;

        case 1:
            CHECK(AJ_MarshalArgs(&txMsg, "u", 11111));
            CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_MarshalArgs(&txMsg, "usu", 22222, "hello", 33333));
            CHECK(AJ_MarshalContainer(&txMsg, &struct2, AJ_ARG_STRUCT));
            CHECK(AJ_MarshalArgs(&txMsg, "ii", -100, -200));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &struct2));
            CHECK(AJ_MarshalArgs(&txMsg, "qsq", 4444, "goodbye", 5555));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            CHECK(AJ_MarshalArgs(&txMsg, "yyy", 1, 2, 3));
            break;

        case 2:
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (u = 0; u < ArraySize(Fruits); ++u) {
                CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
                CHECK(AJ_MarshalArgs(&txMsg, "us", u, Fruits[u]));
                CHECK(AJ_MarshalArg(&txMsg, AJ_InitArg(&arg, AJ_ARG_BYTE, AJ_ARRAY_FLAG, Data8, u)));
                CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            break;

        case 3:
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (j = 0; j < 3; ++j) {
                CHECK(AJ_MarshalContainer(&txMsg, &array2, AJ_ARG_ARRAY));
                for (k = j; k < ArraySize(Fruits); ++k) {
                    CHECK(AJ_MarshalArgs(&txMsg, "s", Fruits[k]));
                }
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array2));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            break;

        case 4:
            CHECK(AJ_MarshalArgs(&txMsg, "i", 987654321));
            CHECK(AJ_MarshalVariant(&txMsg, "a(ii)"));
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (j = 0; j < 16; ++j) {
                CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
                CHECK(AJ_MarshalArgs(&txMsg, "ii", j + 1, (j + 1) * 100));
                CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            CHECK(AJ_MarshalArgs(&txMsg, "i", 123456789));
            break;

        case 5:
            CHECK(AJ_MarshalVariant(&txMsg, "(ivi)"));
            CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_MarshalArgs(&txMsg, "i", 1212121));
            CHECK(AJ_MarshalVariant(&txMsg, "s"));
            CHECK(AJ_MarshalArgs(&txMsg, "s", "inner variant"));
            CHECK(AJ_MarshalArgs(&txMsg, "i", 3434343));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            break;

        case 6:
            CHECK(AJ_MarshalVariant(&txMsg, "v"));
            CHECK(AJ_MarshalVariant(&txMsg, "v"));
            CHECK(AJ_MarshalVariant(&txMsg, "v"));
            CHECK(AJ_MarshalVariant(&txMsg, "v"));
            CHECK(AJ_MarshalVariant(&txMsg, "s"));
            CHECK(AJ_MarshalArgs(&txMsg, "s", "deep variant"));
            break;

        case 7:
            CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_MarshalVariant(&txMsg, "i"));
            CHECK(AJ_MarshalArgs(&txMsg, "i", 1212121));
            CHECK(AJ_MarshalVariant(&txMsg, "s"));
            CHECK(AJ_MarshalArgs(&txMsg, "s", "variant"));
            CHECK(AJ_MarshalVariant(&txMsg, "ay"));
            CHECK(AJ_MarshalArg(&txMsg, AJ_InitArg(&arg, AJ_ARG_BYTE, AJ_ARRAY_FLAG, Data8, sizeof(Data8))));
            CHECK(AJ_MarshalVariant(&txMsg, "aq"));
            CHECK(AJ_MarshalArg(&txMsg, AJ_InitArg(&arg, AJ_ARG_UINT16, AJ_ARRAY_FLAG, Data16, sizeof(Data16))));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            break;

        case 8:
            CHECK(AJ_MarshalArgs(&txMsg, "uq", 0xF00F00F0, 0x0707));
            len = 5000;
            CHECK(AJ_DeliverMsgPartial(&txMsg, len + 4));
            CHECK(AJ_MarshalRaw(&txMsg, &len, 4));
            for (j = 0; j < len; ++j) {
                uint8_t n = (uint8_t)j;
                CHECK(AJ_MarshalRaw(&txMsg, &n, 1));
            }
            break;

        case 9:
            len = 500;
            u = len * sizeof(TestStruct);
            CHECK(AJ_DeliverMsgPartial(&txMsg, u + sizeof(u) + 4));
            CHECK(AJ_MarshalRaw(&txMsg, &u, sizeof(u)));
            /*
             * Structs are always 8 byte aligned
             */
            u = 0;
            CHECK(AJ_MarshalRaw(&txMsg, &u, 4));
            for (j = 0; j < len; ++j) {
                TestStruct ts;
                ts.a = j;
                ts.b = j + 1;
                ts.c = j + 2;
                ts.d = j + 3;
                CHECK(AJ_MarshalRaw(&txMsg, &ts, sizeof(ts)));
            }
            break;

        case 10:
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            break;

        case 11:
            CHECK(AJ_MarshalArgs(&txMsg, "y", 127));
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (key = 0; key < ArraySize(Colors); ++key) {
                AJ_Arg dict;
                CHECK(AJ_MarshalContainer(&txMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_MarshalArgs(&txMsg, "ss", Colors[key], Fruits[key]));
                CHECK(AJ_MarshalCloseContainer(&txMsg, &dict));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            break;

        case 12:
            CHECK(AJ_MarshalArgs(&txMsg, "y", 0x11));
            CHECK(AJ_MarshalArgs(&txMsg, "y", 0x22));
            CHECK(AJ_MarshalArgs(&txMsg, "y", 0x33));
            CHECK(AJ_MarshalArgs(&txMsg, "y", 0x44));
            CHECK(AJ_MarshalArgs(&txMsg, "y", 0x55));
            CHECK(AJ_MarshalContainer(&txMsg, &array1, AJ_ARG_ARRAY));
            for (key = 0; key < ArraySize(Colors); ++key) {
                AJ_Arg dict;
                CHECK(AJ_MarshalContainer(&txMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_MarshalArgs(&txMsg, "ys", (uint8_t)key, Colors[key]));
                CHECK(AJ_MarshalCloseContainer(&txMsg, &dict));
            }
            if (status == AJ_OK) {
                CHECK(AJ_MarshalCloseContainer(&txMsg, &array1));
            }
            break;

        case 13:
            CHECK(AJ_MarshalContainer(&txMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_MarshalArgs(&txMsg, "i", 3434343));
            CHECK(AJ_MarshalArg(&txMsg, AJ_InitArg(&arg, AJ_ARG_BYTE, AJ_ARRAY_FLAG, Data8, sizeof(Data8))));
            CHECK(AJ_MarshalCloseContainer(&txMsg, &struct1));
            break;
        }
        if (status != AJ_OK) {
            AJ_Printf("Failed %d\n", i);
            break;
        }

        AJ_Printf("deliver\n");
        AJ_DeliverMsg(&txMsg);

        status = AJ_UnmarshalMsg(&bus, &rxMsg, 0);
        if (status != AJ_OK) {
            break;
        }

        switch (i) {
        case 0:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (TRUE) {
                char* fruit;
                AJ_Arg dict;
                CHECK(AJ_UnmarshalContainer(&rxMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_UnmarshalArgs(&rxMsg, "us", &key, &fruit));
                AJ_Printf("Unmarshal[%d] = %s\n", key, fruit);
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &dict));
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 1:
            CHECK(AJ_UnmarshalArgs(&rxMsg, "u", &u));
            AJ_Printf("Unmarshal %u\n", u);
            CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "usu", &u, &str, &v));
            AJ_Printf("Unmarshal %u %s %u\n", u, str, v);
            CHECK(AJ_UnmarshalContainer(&rxMsg, &struct2, AJ_ARG_STRUCT));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "ii", &n, &m));
            AJ_Printf("Unmarshal %d %d\n", n, m);
            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct2));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "qsq", &q, &str, &r));
            AJ_Printf("Unmarshal %u %s %u\n", q, str, r);
            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            AJ_Printf("Unmarshal %d\n", y);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            AJ_Printf("Unmarshal %d\n", y);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            AJ_Printf("Unmarshal %d\n", y);
            break;

        case 2:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (status == AJ_OK) {
                CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
                CHECK(AJ_UnmarshalArgs(&rxMsg, "us", &u, &str));
                CHECK(AJ_UnmarshalArg(&rxMsg, &arg));
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 3:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (status == AJ_OK) {
                CHECK(AJ_UnmarshalContainer(&rxMsg, &array2, AJ_ARG_ARRAY));
                while (status == AJ_OK) {
                    CHECK(AJ_UnmarshalArg(&rxMsg, &arg));
                    AJ_Printf("Unmarshal %s\n", arg.val.v_string);
                }
                /*
                 * We expect AJ_ERR_NO_MORE
                 */
                if (status == AJ_ERR_NO_MORE) {
                    CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array2));
                }
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 4:
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &j));
            AJ_Printf("Unmarshal %d\n", j);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (status == AJ_OK) {
                CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
                CHECK(AJ_UnmarshalArgs(&rxMsg, "ii", &j, &k));
                AJ_Printf("Unmarshal[%d] %d\n", j, k);
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status != AJ_ERR_NO_MORE) {
                break;
            }
            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &j));
            AJ_Printf("Unmarshal %d\n", j);
            break;

        case 5:
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &j));
            AJ_Printf("Unmarshal %d\n", j);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "s", &str));
            AJ_Printf("Unmarshal %s\n", str);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &j));
            AJ_Printf("Unmarshal %d\n", j);
            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            break;

        case 6:
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "s", &str));
            AJ_Printf("Unmarshal %s\n", str);
            break;

        case 7:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &j));
            AJ_Printf("Unmarshal %d\n", j);
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArgs(&rxMsg, "s", &str));
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArg(&rxMsg, &arg));
            CHECK(AJ_UnmarshalVariant(&rxMsg, (const char**)&sig));
            AJ_Printf("Unmarshal variant %s\n", sig);
            CHECK(AJ_UnmarshalArg(&rxMsg, &arg));
            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            break;

        case 8:
            CHECK(AJ_UnmarshalArgs(&rxMsg, "uq", &j, &q));
            AJ_Printf("Unmarshal %x\n", j);
            AJ_Printf("Unmarshal %x\n", q);
            CHECK(AJ_UnmarshalRaw(&rxMsg, (const void**)&raw, sizeof(len), &sz));
            len = *((uint32_t*)raw);
            AJ_Printf("UnmarshalRaw %d\n", len);
            for (j = 0; j < len; ++j) {
                uint8_t v;
                CHECK(AJ_UnmarshalRaw(&rxMsg, (const void**)&raw, 1, &sz));
                v = *((uint8_t*)raw);
                if (v != (uint8_t)j) {
                    status = AJ_ERR_FAILURE;
                    break;
                }
            }
            break;

        case 9:
            CHECK(AJ_UnmarshalRaw(&rxMsg, (const void**)&raw, 4, &sz));
            len = *((uint32_t*)raw) / sizeof(TestStruct);
            /*
             * Structs are always 8 byte aligned
             */
            CHECK(AJ_UnmarshalRaw(&rxMsg, (const void**)&raw, 4, &sz));
            for (j = 0; j < len; ++j) {
                TestStruct* ts;
                CHECK(AJ_UnmarshalRaw(&rxMsg, (const void**)&ts, sizeof(TestStruct), &sz));
                if ((ts->a != j) || (ts->b != (j + 1)) || (ts->c != (j + 2)) || (ts->d != (j + 3))) {
                    status = AJ_ERR_FAILURE;
                    break;
                }
            }
            break;

        case 10:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            status = AJ_UnmarshalArg(&rxMsg, &arg);
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 11:
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (TRUE) {
                AJ_Arg dict;
                char* fruit;
                char* color;
                CHECK(AJ_UnmarshalContainer(&rxMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_UnmarshalArgs(&rxMsg, "ss", &color, &fruit));
                AJ_Printf("Unmarshal[%s] = %s\n", color, fruit);
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &dict));
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 12:
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "y", &y));
            CHECK(AJ_UnmarshalContainer(&rxMsg, &array1, AJ_ARG_ARRAY));
            while (TRUE) {
                AJ_Arg dict;
                char* color;
                CHECK(AJ_UnmarshalContainer(&rxMsg, &dict, AJ_ARG_DICT_ENTRY));
                CHECK(AJ_UnmarshalArgs(&rxMsg, "ys", &y, &color));
                AJ_Printf("Unmarshal[%d] = %s\n", y, color);
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &dict));
            }
            /*
             * We expect AJ_ERR_NO_MORE
             */
            if (status == AJ_ERR_NO_MORE) {
                CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &array1));
            }
            break;

        case 13:
            CHECK(AJ_UnmarshalContainer(&rxMsg, &struct1, AJ_ARG_STRUCT));
            CHECK(AJ_UnmarshalArgs(&rxMsg, "i", &n));
            AJ_ASSERT(n == 3434343);

            CHECK(AJ_UnmarshalArg(&rxMsg, &arg));
            for (j = 0; j < arg.len; ++j) {
                uint8_t val = arg.val.v_byte[j];
                AJ_Printf("Unmarhsalled array1[%u] = %u\n", j, val);
                AJ_ASSERT(val == Data8[j]);
            }

            CHECK(AJ_UnmarshalCloseContainer(&rxMsg, &struct1));
            break;
        }

        if (status != AJ_OK) {
            AJ_Printf("Failed %d\n", i);
            break;
        }
        AJ_CloseMsg(&rxMsg);
        AJ_Printf("Passed %d\n", i);

    }
    if (status != AJ_OK) {
        AJ_Printf("Marshal/Unmarshal unit test[%d] failed %d\n", i, status);
    }

    return status;
}
Exemple #19
0
static AJ_Status AboutPropGetter(AJ_Message* reply, const char* language)
{
    AJ_Status status = AJ_OK;
    AJ_Arg array;
    AJ_GUID theAJ_GUID;
    char machineIdValue[UUID_LENGTH * 2 + 1];
    machineIdValue[UUID_LENGTH * 2] = '\0';

    if ((language != NULL) && (0 != strcmp(language, "en")) && (0 != strcmp(language, ""))) {
        /* the language supplied was not supported */
        status = AJ_ERR_NO_MATCH;
    }

    if (status == AJ_OK) {
        status = AJ_MarshalContainer(reply, &array, AJ_ARG_ARRAY);
        if (status == AJ_OK) {
            status = AJ_GetLocalGUID(&theAJ_GUID);
            if (status == AJ_OK) {
                AJ_GUID_ToString(&theAJ_GUID, machineIdValue, UUID_LENGTH * 2 + 1);
            }
            if (status == AJ_OK) {
                status = MarshalAppId(reply, &machineIdValue[0]);
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "AppName", "s", "svclite");
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "DeviceId", "s", machineIdValue);
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "DeviceName", "s", "Tester");
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "Manufacturer", "s", "QCE");
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "ModelNumber", "s", "1.0");
            }
            //SupportedLanguages
            if (status == AJ_OK) {
                AJ_Arg dict;
                AJ_Arg languageListArray;
                status = AJ_MarshalContainer(reply, &dict, AJ_ARG_DICT_ENTRY);
                if (status == AJ_OK) {
                    status = AJ_MarshalArgs(reply, "s", "SupportedLanguages");
                }
                if (status == AJ_OK) {
                    status = AJ_MarshalVariant(reply, "as");
                }
                if (status == AJ_OK) {
                    status = AJ_MarshalContainer(reply, &languageListArray, AJ_ARG_ARRAY);
                }
                if (status == AJ_OK) {
                    status = AJ_MarshalArgs(reply, "s", "en");
                }
                if (status == AJ_OK) {
                    status = AJ_MarshalCloseContainer(reply, &languageListArray);
                }
                if (status == AJ_OK) {
                    status = AJ_MarshalCloseContainer(reply, &dict);
                }

            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "Description", "s", "svclite test app");
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "DefaultLanguage", "s", "en");
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "SoftwareVersion", "s", AJ_GetVersion());
            }
            if (status == AJ_OK) {
                status = AJ_MarshalArgs(reply, "{sv}", "AJSoftwareVersion", "s", AJ_GetVersion());
            }
        }
        if (status == AJ_OK) {
            status = AJ_MarshalCloseContainer(reply, &array);
        }
    }
    return status;
}
/**
 * Marshal Notification
 */
static AJ_Status AJNS_Producer_MarshalNotificationMsg(AJ_BusAttachment* busAttachment, AJ_Message* msg, AJNS_Notification* notification, uint32_t ttl)
{
    AJ_Status status = AJ_OK;
    AJ_Arg attrbtArray;
    AJ_Arg customAttributeArray;
    AJ_Arg notTextArray;
    AJ_Arg richAudioArray;
    AJ_Arg dictArg;
    AJ_Arg customAttributeDictArg;
    AJ_Arg structArg;
    AJ_Arg audioStructArg;
    AJ_Arg richAudioAttrArray;
    int8_t indx;

    if (notification == NULL) 
	{
    //    AJ_InfoPrintf(("Nothing to send\n"));
        return status;
    }

    status = AJ_MarshalSignal(busAttachment, msg, AJ_ENCODE_MESSAGE_ID(AJNS_OBJECT_LIST_INDEX, NOTIFICATION_OBJECT_INDEX + notification->messageType, 1, 0), NULL, 0, AJ_FLAG_SESSIONLESS, ttl);
    if (status != AJ_OK) 
	{
        AJ_ErrPrintf(("Could not Marshal Signal\n"));
        return status;
    }

    ///////////////////       Proto     /////////////////////
    status = AJ_MarshalArgs(msg, "q", notification->version);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    MessgeId    /////////////////////
    status = AJ_MarshalArgs(msg, "i", notification->notificationId);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    MessageType   ////////////////////////////
    status = AJ_MarshalArgs(msg, "q", notification->messageType);
    if (status != AJ_OK) 
	{
        goto ErrorExit;

    }

    ///////////////////    DeviceId   ////////////////////////////
    status = AJ_MarshalArgs(msg, "s", notification->deviceId);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    DeviceName   ////////////////////////////
    status = AJ_MarshalArgs(msg, "s", notification->deviceName);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    AppId   ////////////////////////////
    status = AJSVC_MarshalAppId(msg, notification->appId);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    AppName   ////////////////////////////
    status = AJ_MarshalArgs(msg, "s", notification->appName);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    Attributes   ////////////////////////////
    status = AJ_MarshalContainer(msg, &attrbtArray, AJ_ARG_ARRAY);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    if (notification->content->richIconUrl != 0) 
	{
        status = AJ_MarshalContainer(msg, &dictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_RICH_CONTENT_ICON_URL_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "s");
        if (status != AJ_OK)
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "s", notification->content->richIconUrl);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &dictArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }
    if (notification->content->numAudioUrls > 0) 
	{
        status = AJ_MarshalContainer(msg, &richAudioArray, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_RICH_CONTENT_AUDIO_URL_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "a(ss)");
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalContainer(msg, &richAudioAttrArray, AJ_ARG_ARRAY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }

        for (indx = 0; indx < notification->content->numAudioUrls; indx++) 
		{
            if ((strlen(notification->content->richAudioUrls[indx].key) == 0) || (strlen(notification->content->richAudioUrls[indx].value) == 0)) 
			{
                AJ_ErrPrintf(("Rich Audio Language/Url can not be empty\n"));
                AJ_MarshalCloseContainer(msg, &richAudioArray);
                status = AJ_ERR_DISALLOWED;
                goto ErrorExit;
            }
            status = AJ_MarshalContainer(msg, &audioStructArg, AJ_ARG_STRUCT);
            if (status != AJ_OK) 
			{
                goto ErrorExit;
            }
            status = AJ_MarshalArgs(msg, "ss", notification->content->richAudioUrls[indx].key, notification->content->richAudioUrls[indx].value);
            if (status != AJ_OK) 
			{
                goto ErrorExit;
            }
            status = AJ_MarshalCloseContainer(msg, &audioStructArg);
            if (status != AJ_OK) 
			{
                goto ErrorExit;
            }
        }

        status = AJ_MarshalCloseContainer(msg, &richAudioAttrArray);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }

        status = AJ_MarshalCloseContainer(msg, &richAudioArray);
        if (status != AJ_OK)
		{
            goto ErrorExit;
        }
    }

    if (notification->content->richIconObjectPath != 0) 
	{
        status = AJ_MarshalContainer(msg, &dictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_RICH_CONTENT_ICON_OBJECT_PATH_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "s");
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "s", notification->content->richIconObjectPath);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &dictArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }

    if (notification->content->richAudioObjectPath != 0) 
	{
        status = AJ_MarshalContainer(msg, &dictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_RICH_CONTENT_AUDIO_OBJECT_PATH_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "s");
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "s", notification->content->richAudioObjectPath);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &dictArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }

    if (notification->content->controlPanelServiceObjectPath != 0) 
	{
        status = AJ_MarshalContainer(msg, &dictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_CONTROLPANELSERVICE_OBJECT_PATH_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "s");
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "s", notification->content->controlPanelServiceObjectPath);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &dictArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }

    if (notification->version > 1) 
	{
        status = AJ_MarshalContainer(msg, &dictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK)
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "i", AJNS_ORIGINAL_SENDER_NAME_ATTRIBUTE_KEY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalVariant(msg, "s");
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "s", notification->originalSenderName);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &dictArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }

    status = AJ_MarshalCloseContainer(msg, &attrbtArray);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////    Custom Attributes   ///////////////////
    status = AJ_MarshalContainer(msg, &customAttributeArray, AJ_ARG_ARRAY);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    for (indx = 0; indx < notification->content->numCustomAttributes; indx++) 
	{
        status = AJ_MarshalContainer(msg, &customAttributeDictArg, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "ss", notification->content->customAttributes[indx].key, notification->content->customAttributes[indx].value);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &customAttributeDictArg);
        if (status != AJ_OK)
		{
            goto ErrorExit;
        }
    }

    status = AJ_MarshalCloseContainer(msg, &customAttributeArray);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    ///////////////////   Notifications   ////////////////////////////
    status = AJ_MarshalContainer(msg, &notTextArray, AJ_ARG_ARRAY);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    for (indx = 0; indx < notification->content->numTexts; indx++) 
	{
        if ((strlen(notification->content->texts[indx].key) == 0) || (strlen(notification->content->texts[indx].value) == 0)) 
		{
            AJ_ErrPrintf(("Language/Text can not be empty\n"));
            AJ_MarshalCloseContainer(msg, &notTextArray);
            status = AJ_ERR_DISALLOWED;
            goto ErrorExit;
        }
        status = AJ_MarshalContainer(msg, &structArg, AJ_ARG_STRUCT);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalArgs(msg, "ss", notification->content->texts[indx].key, notification->content->texts[indx].value);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
        status = AJ_MarshalCloseContainer(msg, &structArg);
        if (status != AJ_OK) 
		{
            goto ErrorExit;
        }
    }

    status = AJ_MarshalCloseContainer(msg, &notTextArray);
    if (status != AJ_OK) 
	{
        goto ErrorExit;
    }

    return AJ_OK;

ErrorExit:

    AJ_ErrPrintf(("MarshalNotification failed: '%s'\n", AJ_StatusText(status)));
    return status;
}
AJ_Status AJSVC_PropertyStore_ReadAll(AJ_Message* msg, AJSVC_PropertyStoreCategoryFilter filter, int8_t langIndex)
{
    AJ_Status status = AJ_OK;
    AJ_Arg array;
    AJ_Arg array2;
    AJ_Arg dict;
    const char* value;
    AJ_Arg arg;
    uint8_t rawValue[16];
    uint8_t index;
    const char* ajVersion;

    AJ_InfoPrintf(("PropertyStore_ReadAll()\n"));

    status = AJ_MarshalContainer(msg, &array, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }

    //AJSVC_PropertyStoreFieldIndices fieldIndex = 0;
    int fieldIndex = 0;
    for (; fieldIndex < AJSVC_PROPERTY_STORE_NUMBER_OF_KEYS; fieldIndex++) {
#ifdef CONFIG_SERVICE
        if (propertyStoreProperties[fieldIndex].mode7Public && (filter.bit0About || (filter.bit1Config && propertyStoreProperties[fieldIndex].mode0Write) || (filter.bit2Announce && propertyStoreProperties[fieldIndex].mode1Announce))) {
#else
        if (propertyStoreProperties[fieldIndex].mode7Public && (filter.bit0About || (filter.bit2Announce && propertyStoreProperties[fieldIndex].mode1Announce))) {
#endif
            value = AJSVC_PropertyStore_GetValueForLang((AJSVC_PropertyStoreFieldIndices)fieldIndex, langIndex);

            if (value == NULL && fieldIndex >= AJSVC_PROPERTY_STORE_NUMBER_OF_MANDATORY_KEYS) {     // Non existing values are skipped!
                AJ_WarnPrintf(("PropertyStore_ReadAll - Failed to get value for field=(name=%s, index=%d) and language=(name=%s, index=%d), skipping.\n", AJSVC_PropertyStore_GetFieldName((AJSVC_PropertyStoreFieldIndices)fieldIndex), (int)fieldIndex, AJSVC_PropertyStore_GetLanguageName(langIndex), (int)langIndex));
            } else {
                if (fieldIndex == AJSVC_PROPERTY_STORE_APP_ID) {
                    if (value == NULL) {
                        AJ_ErrPrintf(("PropertyStore_ReadAll - Failed to get value for mandatory field=(name=%s, index=%d) and language=(name=%s, index=%d), aborting.\n", AJSVC_PropertyStore_GetFieldName((AJSVC_PropertyStoreFieldIndices)fieldIndex), (int)fieldIndex, AJSVC_PropertyStore_GetLanguageName(langIndex), (int)langIndex));
                        return AJ_ERR_NULL;
                    }

                    status = AJ_MarshalContainer(msg, &dict, AJ_ARG_DICT_ENTRY);
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", propertyStoreProperties[fieldIndex].keyName);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalVariant(msg, "ay");
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_HexToRaw(value, 0, rawValue, (size_t)sizeof(rawValue));
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArg(msg, AJ_InitArg(&arg, AJ_ARG_BYTE, AJ_ARRAY_FLAG, rawValue, sizeof(rawValue)));
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalCloseContainer(msg, &dict);
                    if (status != AJ_OK) {
                        return status;
                    }
#ifdef CONFIG_SERVICE
                } else if (fieldIndex == AJSVC_PROPERTY_STORE_MAX_LENGTH) {
                    status = AJ_MarshalContainer(msg, &dict, AJ_ARG_DICT_ENTRY);
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", propertyStoreProperties[fieldIndex].keyName);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalVariant(msg, "q");
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "q", DEVICE_NAME_VALUE_LENGTH);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalCloseContainer(msg, &dict);
                    if (status != AJ_OK) {
                        return status;
                    }
                    AJ_InfoPrintf(("Has key [%s] runtime Value [%d]\n", propertyStoreProperties[AJSVC_PROPERTY_STORE_MAX_LENGTH].keyName, DEVICE_NAME_VALUE_LENGTH));
#endif
                } else if (fieldIndex == AJSVC_PROPERTY_STORE_AJ_SOFTWARE_VERSION) {
                    ajVersion = AJ_GetVersion();
                    if (ajVersion == NULL) {
                        AJ_ErrPrintf(("PropertyStore_ReadAll - Failed to get value for mandatory field=(name=%s, index=%d) and language=(name=%s, index=%d), aborting.\n", AJSVC_PropertyStore_GetFieldName((AJSVC_PropertyStoreFieldIndices)fieldIndex), (int)fieldIndex, AJSVC_PropertyStore_GetLanguageName(langIndex), (int)langIndex));
                        return AJ_ERR_NULL;
                    }

                    status = AJ_MarshalContainer(msg, &dict, AJ_ARG_DICT_ENTRY);
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", propertyStoreProperties[fieldIndex].keyName);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalVariant(msg, "s");
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", ajVersion);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalCloseContainer(msg, &dict);
                    if (status != AJ_OK) {
                        return status;
                    }
                    AJ_InfoPrintf(("Has key [%s] runtime Value [%s]\n", propertyStoreProperties[AJSVC_PROPERTY_STORE_AJ_SOFTWARE_VERSION].keyName, ajVersion));
                } else {
                    if (value == NULL) {
                        AJ_ErrPrintf(("PropertyStore_ReadAll - Failed to get value for mandatory field=(name=%s, index=%d) and language=(name=%s, index=%d), aborting.\n", AJSVC_PropertyStore_GetFieldName((AJSVC_PropertyStoreFieldIndices)fieldIndex), (int)fieldIndex, AJSVC_PropertyStore_GetLanguageName(langIndex), (int)langIndex));
                        return AJ_ERR_NULL;
                    }

                    status = AJ_MarshalContainer(msg, &dict, AJ_ARG_DICT_ENTRY);
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", propertyStoreProperties[fieldIndex].keyName);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalVariant(msg, "s");
                    if (status != AJ_OK) {
                        return status;
                    }
                    status = AJ_MarshalArgs(msg, "s", value);
                    if (status != AJ_OK) {
                        return status;
                    }

                    status = AJ_MarshalCloseContainer(msg, &dict);
                    if (status != AJ_OK) {
                        return status;
                    }
                }
            }
        }
    }

    if (filter.bit0About) {
        // Add supported languages
        status = AJ_MarshalContainer(msg, &dict, AJ_ARG_DICT_ENTRY);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalArgs(msg, "s", defaultLanguagesKeyName);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalVariant(msg, "as");
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalContainer(msg, &array2, AJ_ARG_ARRAY);
        if (status != AJ_OK) {
            return status;
        }

        index = AJSVC_PROPERTY_STORE_NO_LANGUAGE_INDEX;
        for (; index < AJSVC_PROPERTY_STORE_NUMBER_OF_LANGUAGES; index++) {
            status = AJ_MarshalArgs(msg, "s", propertyStoreDefaultLanguages[index]);
            if (status != AJ_OK) {
                return status;
            }
        }

        status = AJ_MarshalCloseContainer(msg, &array2);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalCloseContainer(msg, &dict);
        if (status != AJ_OK) {
            return status;
        }
    }
    status = AJ_MarshalCloseContainer(msg, &array);
    if (status != AJ_OK) {
        return status;
    }

    return status;
}

#ifdef CONFIG_SERVICE
AJ_Status AJSVC_PropertyStore_Update(const char* key, int8_t langIndex, const char* value)
{
    AJSVC_PropertyStoreFieldIndices fieldIndex = AJSVC_PropertyStore_GetFieldIndex(key);
    if (fieldIndex == AJSVC_PROPERTY_STORE_ERROR_FIELD_INDEX || fieldIndex >= AJSVC_PROPERTY_STORE_NUMBER_OF_CONFIG_KEYS) {
        return AJ_ERR_INVALID;
    }
    if (!UpdateFieldInRAM(fieldIndex, langIndex, value)) {
        return AJ_ERR_FAILURE;
    }
    return AJ_OK;
}
Exemple #22
0
AJ_Status MyAboutPropGetter(AJ_Message* reply, const char* language)
{

	
	AJ_Status status = (0 == strcmp(language, "")) ? AJ_OK : AJ_ERR_NO_MATCH;
	
	int langIndex = -1;
	while(languages[++langIndex] && status == AJ_ERR_NO_MATCH){
		fflush(stdout);
		if ((0 != strcmp(language, languages[langIndex]))) continue;
        status = AJ_OK;
	}  	
	if (status != AJ_OK) {
        return status;
    }
		
    AJ_Arg array;
    
//    char guidStr[16 * 2 + 1];
    uint8_t appId[16];
//	memset(guidStr, '\0', sizeof(guidStr));
	
	char* propDeviceId = (char*)GetProperty("DeviceId");
//	if (propDeviceId){
//		strcpy(guidStr, propDeviceId);
//	} else {
//		AJ_GUID guid;
//		status = AJ_GetLocalGUID(&guid);
//	    if (status != AJ_OK) {
//	        return status;
//	    }
//		AJ_GUID_ToString(&guid, guidStr, sizeof(guidStr));		
//	}
	
	char* propAppId = (char*)GetProperty("AppId");

	status = AJ_HexToRaw(propAppId, 0, appId, 16);
    if (status != AJ_OK) {
        return status;
    }
	
	
    status = AJ_MarshalContainer(reply, &array, AJ_ARG_ARRAY);
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "AppId", "ay", appId, 16);
    }
    if (status == AJ_OK) {
//		printf("AppName: %s\n", (char*)GetProperty("AppName"));
        status = AJ_MarshalArgs(reply, "{sv}", "AppName", "s", (char*)GetProperty("AppName"));
    }
	
    if (status == AJ_OK) {
//		printf("DeviceId: %s\n", propDeviceId);
        status = AJ_MarshalArgs(reply, "{sv}", "DeviceId", "s", propDeviceId);
    }
    if (status == AJ_OK) {
		// not mandatory
		char * DeviceName = (char*)GetProperty("DeviceName");
		if (DeviceName){
//			printf("DeviceName: %s\n", DeviceName);
			status = AJ_MarshalArgs(reply, "{sv}", "DeviceName", "s", DeviceName);
		}
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "Manufacturer", "s", (char*)GetProperty("Manufacturer"));
    }
	if (status == AJ_OK) {
		// not mandatory
		char * DateOfManufacture = (char*)GetProperty("DateOfManufacture");
		if (DateOfManufacture){
			status = AJ_MarshalArgs(reply, "{sv}", "DateOfManufacture", "s", DateOfManufacture);
		}
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "ModelNumber", "s", (char*)GetProperty("ModelNumber"));
    }
	if (status == AJ_OK) {
		// not mandatory
		char * SupportUrl = (char*)GetProperty("SupportUrl");
		if (SupportUrl){
			status = AJ_MarshalArgs(reply, "{sv}", "SupportUrl", "s", SupportUrl);
		}
    }
    //SupportedLanguages
    if (status == AJ_OK) {
        AJ_Arg dict;
        AJ_Arg languageListArray;
        status = AJ_MarshalContainer(reply, &dict, AJ_ARG_DICT_ENTRY);
        if (status == AJ_OK) {
            status = AJ_MarshalArgs(reply, "s", "SupportedLanguages");
        }
        if (status == AJ_OK) {
            status = AJ_MarshalVariant(reply, "as");
        }
        if (status == AJ_OK) {
            status = AJ_MarshalContainer(reply, &languageListArray, AJ_ARG_ARRAY);
        }
		int langIndex = -1;
		while(languages[++langIndex]){
			if (status == AJ_OK) {
	            status = AJ_MarshalArgs(reply, "s", languages[langIndex]);
	        }			
		}        
        if (status == AJ_OK) {
            status = AJ_MarshalCloseContainer(reply, &languageListArray);
        }
        if (status == AJ_OK) {
            status = AJ_MarshalCloseContainer(reply, &dict);
        }
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "Description", "s", (char*)GetProperty("Description"));
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "DefaultLanguage", "s", languages[0]);
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "SoftwareVersion", "s", AJ_GetVersion());
    }
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(reply, "{sv}", "AJSoftwareVersion", "s", AJ_GetVersion());
    }
    if (status == AJ_OK) {
        status = AJ_MarshalCloseContainer(reply, &array);
    }
    return status;
}