void AJS_CPS_SignalMetadataChanged(AJ_BusAttachment* aj, AJS_Widget* ajsWidget) { uint32_t session = AJCPS_GetCurrentSessionId(); /* * Nothing to do unless the control panel is loaded and in a session */ if (objectList && session) { /* * This is a little fragile because the indices might change if the interface definitions change * but there is no easy way to figure out what message id to use. */ uint32_t sigId = AJ_ENCODE_MESSAGE_ID(AJCPS_OBJECT_LIST_INDEX, ajsWidget->index, WIDGET_IFACE_INDEX, METADATA_CHANGED_INDEX); /* * Need to find the message id for the value changed signal for this widget */ AJ_InfoPrintf(("SignalMetadataChanged %s\n", ajsWidget->path)); (void)AJCPS_SendPropertyChangedSignal(aj, sigId, session); } }
/** * 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, ¬TextArray, 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, ¬TextArray); 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, ¬TextArray); if (status != AJ_OK) { goto ErrorExit; } return AJ_OK; ErrorExit: AJ_ErrPrintf(("MarshalNotification failed: '%s'\n", AJ_StatusText(status))); return status; }