static AJ_Status PropAccessAll(AJ_Message* msg, PropCallback* cb) { AJ_Status status; AJ_Message reply; const char* iface; AJ_InfoPrintf(("PropAccessAll(msg=0x%p, cb=0x%p)\n", msg, cb)); status = AJ_UnmarshalArgs(msg, "s", &iface); if (status == AJ_OK) { status = AJ_MarshalReplyMsg(msg, &reply); } if (status == AJ_OK) { status = AJ_MarshalAllPropertiesArgs(&reply, iface, cb->Get, cb->context); } if (status != AJ_OK) { AJ_MarshalStatusMsg(msg, &reply, status); } return AJ_DeliverMsg(&reply); }
static AJ_Status PropAccess(AJ_Message* msg, PropCallback* cb, uint8_t op) { AJ_Status status; AJ_Message reply; uint32_t propId; const char* sig; AJ_InfoPrintf(("PropAccess(msg=0x%p, cb=0x%p, op=%d.)\n", msg, cb, op)); /* * Find out which property is being accessed and whether the access is a GET or SET */ status = AJ_UnmarshalPropertyArgs(msg, &propId, &sig); if (status == AJ_OK) { AJ_MarshalReplyMsg(msg, &reply); /* * Callback to let the application marshal or unmarshal the value */ if (op == AJ_PROP_GET) { AJ_MarshalVariant(&reply, sig); status = cb->Get(&reply, propId, cb->context); } else { const char* variant; AJ_UnmarshalVariant(msg, &variant); /* * Check that the value has the expected signature */ if (strcmp(sig, variant) == 0) { status = cb->Set(msg, propId, cb->context); } else { AJ_InfoPrintf(("PropAccess(): AJ_ERR_SIGNATURE\n")); status = AJ_ERR_SIGNATURE; } } } if (status != AJ_OK) { AJ_MarshalStatusMsg(msg, &reply, status); } return AJ_DeliverMsg(&reply); }
static AJ_Status ExecuteAction(AJ_Message* msg, uint8_t action, void* context) { AJS_Widget* widget = (AJS_Widget*)objectList[OBJ_INDEX(msg->msgId)].context; AJ_Status status; AJ_Message reply; /* * Need to make a clone of the message and close the original */ msg = AJS_CloneAndCloseMessage(widget->dukCtx, msg); if (!msg) { return AJ_ERR_RESOURCES; } /* * Call into JavaScript object to perform action */ status = AJS_CP_ExecuteAction(widget, action); if (status == AJ_OK) { AJ_MarshalReplyMsg(msg, &reply); } else { AJ_MarshalStatusMsg(msg, &reply, status); } return AJ_DeliverMsg(&reply); }
static AJ_Status SetWidgetProp(AJ_Message* msg) { AJS_Widget* widget = NULL; AJ_Message reply; AJ_Status status; uint32_t propId; const char* vsig; AJ_InfoPrintf(("SetWidgetProp %s\n", msg->objPath)); status = AJ_UnmarshalPropertyArgs(msg, &propId, &vsig); /* * Two levels of variant because Set always uses a variant and the property type for the widget * is not known until runtime so is specified as a variant type in the property widget interface. */ if (status == AJ_OK) { status = AJ_UnmarshalVariant(msg, &vsig); } if (status == AJ_OK) { status = AJ_UnmarshalVariant(msg, &vsig); } if (status == AJ_OK) { widget = (AJS_Widget*)objectList[OBJ_INDEX(propId)].context; /* * Value is the only property that is writeable. Figure out how to unmarshal it. */ switch (widget->property.wdt.signature[0]) { case 'i': status = AJ_UnmarshalArgs(msg, "i", &widget->property.val.i); break; case 'q': status = AJ_UnmarshalArgs(msg, "q", &widget->property.val.q); break; case 'b': status = AJ_UnmarshalArgs(msg, "b", &widget->property.val.b); break; case 'd': status = AJ_UnmarshalArgs(msg, "d", &widget->property.val.d); break; case 's': status = AJ_UnmarshalArgs(msg, "s", &widget->property.val.s); break; default: { AJ_Arg st; uint16_t propertyType; status = AJ_UnmarshalContainer(msg, &st, AJ_ARG_STRUCT); if (status != AJ_OK) { break; } status = AJ_UnmarshalArgs(msg, "q", &propertyType); if (status != AJ_OK) { break; } /* * For some reason the implementors of the control panel service used 0/1 to * distingsuish between date/time rather than 1/2. Incrementing the property type * fixes this oversight. */ if (++propertyType != widget->property.wdt.propertyType) { status = AJ_ERR_INVALID; break; } if (propertyType == TIME_VALUE_PROPERTY) { status = AJ_UnmarshalArgs(msg, "(qqq)", &widget->property.val.time.hour, &widget->property.val.time.minute, &widget->property.val.time.second); } else { status = AJ_UnmarshalArgs(msg, "(qqq)", &widget->property.val.date.mDay, &widget->property.val.date.month, &widget->property.val.date.fullYear); } /* * Signal that the value has been changed */ AJS_CPS_SignalValueChanged(AJS_GetBusAttachment(), widget); if (status == AJ_OK) { status = AJ_UnmarshalCloseContainer(msg, &st); } } break; } } else { return AJ_ERR_RESOURCES; } /* * Need to make a clone of the message and close the original */ msg = AJS_CloneAndCloseMessage(widget->dukCtx, msg); if (!msg) { return AJ_ERR_RESOURCES; } if (status == AJ_OK) { /* * Call JavaScript to report the value change */ status = AJS_CPS_OnValueChanged(widget); } else { AJ_ErrPrintf(("SetWidgetProp %s\n", AJ_StatusText(status))); } if (status == AJ_OK) { AJ_MarshalReplyMsg(msg, &reply); } else { AJ_MarshalStatusMsg(msg, &reply, status); } AJ_DeliverMsg(&reply); return status; }