mUpnpAction *SelectAction(mUpnpService *service) { mUpnpAction *action; int n; char key; int actionNum; n = 0; for (action = mupnp_service_getactions(service); action != NULL; action = mupnp_action_next(action)) { key = 'a' + n; if ('z' < key) break; printf(" [%c] = %s\n", key, mupnp_action_getname(action)); n++; } printf("Select Action : "); key = kbgetkey(); key = tolower(key); printf("%c\n", key); if (!isalpha(key)) return NULL; actionNum = key - 'a'; action = mupnp_service_getactions(service); for (n=0; n<actionNum; n++) action = mupnp_action_next(action); return action; }
bool mupnp_upnpav_dms_condir_init(mUpnpAvServer *dms) { mUpnpDevice *dev; mUpnpService *service; mUpnpAction* action; dev = mupnp_upnpav_dms_getdevice(dms); if (!dev) return false; service = mupnp_device_getservicebytype(dev, CG_UPNPAV_DMS_CONTENTDIRECTORY_SERVICE_TYPE); if (!service) return false; if (mupnp_service_parsedescription(service, CG_UPNPAV_DMS_CONTENTDIRECTORY_SERVICE_DESCRIPTION, mupnp_strlen(CG_UPNPAV_DMS_CONTENTDIRECTORY_SERVICE_DESCRIPTION)) == false) return false; mupnp_service_setactionlistener(service, mupnp_upnpav_dms_condir_actionreceived); for (action=mupnp_service_getactions(service); action; action=mupnp_action_next(action)) mupnp_action_setuserdata(action, dms); mupnp_upnpav_dms_condir_setsystemupdateid(dms, 1); return true; }
void PrintDeviceInfo(mUpnpDevice *dev, int indent) { char indentStr[128]; int n; mUpnpService *service; int serviceCnt; mUpnpAction *action; int actionCnt; mUpnpArgumentList *arg; int argCnt; mUpnpStateVariable *stateVar; int stateVarCnt; for (n=0; n<indent && n<(sizeof(indentStr)-1); n++) indentStr[n] = ' '; indentStr[n] = '\0'; serviceCnt = 0; for (service = mupnp_device_getservices(dev); service != NULL; service = mupnp_service_next(service)) { printf("%s service[%d] = %s\n", indentStr, ++serviceCnt, mupnp_service_getservicetype(service)); actionCnt = 0; for (action = mupnp_service_getactions(service); action != NULL; action = mupnp_action_next(action)) { printf("%s action[%d] = %s\n", indentStr, ++actionCnt, mupnp_action_getname(action)); argCnt = 0; for (arg = mupnp_action_getarguments(action); arg != NULL; arg = mupnp_argument_next(arg)) { printf("%s arg[%d] = %s\n", indentStr, ++argCnt, mupnp_argument_getname(arg)); } } stateVarCnt = 0; for (stateVar = mupnp_service_getstatevariables(service); stateVar != NULL; stateVar = mupnp_statevariable_next(stateVar)) { printf("%s stateVar[%d] = %s = %s\n", indentStr, ++stateVarCnt, mupnp_statevariable_getname(stateVar), mupnp_statevariable_getvalue(stateVar)); } } }