const std::vector<DeviceRef>& DeviceManagerPulseAudio::getDevices() { if( mDevices.empty() ) { parseDevices( DeviceInfo::INPUT ); parseDevices( DeviceInfo::OUTPUT ); } return mDevices; }
bool CRazberry::GetUpdates() { std::string sResult; #ifndef DEBUG_ZWAVE_INT std::string szURL=GetControllerURL(); bool bret; bret=HTTPClient::GET(szURL,sResult); if (!bret) { _log.Log(LOG_ERROR,"Razberry: Error getting update data!"); return 0; } #else sResult=readInputTestFile("update.json"); #endif Json::Value root; Json::Reader jReader; bool ret=jReader.parse(sResult,root); if (!ret) { _log.Log(LOG_ERROR,"Razberry: Invalid data received!"); return 0; } for (Json::Value::iterator itt=root.begin(); itt!=root.end(); ++itt) { std::string kName=itt.key().asString(); const Json::Value obj=(*itt); if (kName=="updateTime") { std::string supdateTime=obj.asString(); m_updateTime=(time_t)atol(supdateTime.c_str()); } else if (kName=="devices") { parseDevices(obj); } else { std::vector<std::string> results; StringSplit(kName,".",results); if (results.size()>1) { if (kName.find("lastReceived")==std::string::npos) UpdateDevice(kName,obj); } } } return true; }
bool CRazberry::GetInitialDevices() { m_updateTime=0; std::string sResult; #ifndef DEBUG_ZWAVE_INT std::string szURL=GetControllerURL(); bool bret; bret=HTTPClient::GET(szURL,sResult); if (!bret) { _log.Log(LOG_ERROR,"Razberry: Error getting data!"); return 0; } #else sResult=readInputTestFile("test.json"); #endif Json::Value root; Json::Reader jReader; bool ret=jReader.parse(sResult,root); if (!ret) { _log.Log(LOG_ERROR,"Razberry: Invalid data received!"); return 0; } Json::Value jval; jval=root["controller"]; if (jval.empty()==true) return 0; m_controllerID=jval["data"]["nodeId"]["value"].asInt(); for (Json::Value::iterator itt=root.begin(); itt!=root.end(); ++itt) { const std::string kName=itt.key().asString(); if (kName=="devices") { parseDevices(*itt); } else if (kName=="updateTime") { std::string supdateTime=(*itt).asString(); m_updateTime=(time_t)atol(supdateTime.c_str()); } } return true; }
/** * Parse the NetDMFNode type, described below. * * The thing to keep in mind while examining an individual * NetDMFNode is that ROSS (most likely) will not create * a corresponding LP but rather attach it to another * previously-defined LP via the LPID NetDMFParameter. * * A NetDMFNode contains a single network node. @verbatim <Node Name="Person1" NodeId="1"> <Device ... > <Stack... > </Node> @endverbatim */ void parseNodes(NetDMFElement *elmt) { /* LP ID to pair the current tag with */ long LPID = -1; if (NetDMFPlatform *parent = dynamic_cast<NetDMFPlatform*>(elmt)) { int totalNodes = parent->GetNumberOfNodes(); for (int i = 0; i < totalNodes; i++) { NetDMFNode *nodeItem = parent->GetNode(i); std::vector<NetDMFDevice *> devices; std::vector<NetDMFParameter *> params; parseDevices(nodeItem, devices); parseParameters(nodeItem, params); if (devices.size() == 0) { printf("Ignoring Node with no devices: %s, %lld", nodeItem->GetName(), nodeItem->GetNodeId()); continue; } if (devices.size() > 1) { for (unsigned int j = 1; j < devices.size(); j++) { printf("Ignoring Device named: %s", (devices[j])->GetName()); } } for (unsigned int j = 0; j < params.size(); j++) { if (0 == strcmp(params[j]->GetName(), "IPv4MulticastMembership")) { // Possibly do something in ROSS } } for (unsigned int j = 0; j < params.size(); j++) { // printf("PARAM: %s: %s\n", params[j]->GetName(), // params[j]->GetValue()); if (0 == strcmp(params[j]->GetName(), "LPID")) { std::istringstream iss(params[j]->GetValue()); iss >> LPID; printf("LPID is now %ld\n", LPID); // Call attachNodetoLP routine here attach_node_to_lp(LPID, nodeItem->GetNodeId()); } } }
void load_ini() { xmlDocPtr doc; xmlNodePtr cur; GList* list_controllers = NULL; printf("Loading configuration file %s\n", FILENAME); doc = xmlParseFile(FILENAME); if (doc == NULL ) { printf("Document not parsed successfully. \n"); create_ini(); goto suite; } cur = xmlDocGetRootElement(doc); if (cur == NULL) { printf("Empty document\n"); xmlFreeDoc(doc); create_ini(); goto suite; } if (xmlStrcmp(cur->name, (const xmlChar *) "ardrone")) { printf("Document of the wrong type, root node != ardrone"); xmlFreeDoc(doc); create_ini(); goto suite; } cur = cur->xmlChildrenNode; while (cur != NULL) { if ((!xmlStrcmp(cur->name, (const xmlChar *)"devices"))){ parseDevices (doc, cur); } cur = cur->next; } xmlFreeDoc(doc); suite: search_devices(&list_controllers); GList *it, *it2; for (it = devices; it; it = it->next) { Controller_info *c; c = (Controller_info *) it->data; for (it2 = list_controllers; it2; it2 = it2->next) { Controller_info *c2; c2 = (Controller_info *) it2->data; if (c->serial == c2->serial) { c->filename = strdup(c2->filename); break; } } } for (it = list_controllers; it; it = it->next) { Controller_info *c; c = (Controller_info *) it->data; if (c->serial == default_control->serial) break; } if (!it) { default_control->def = FALSE; default_control = devices->data; default_control->def = TRUE; } printf("Loading complete\n"); }
static void _model_info_merge_data (_model_info_t *self, xmlNodePtr node) { /* Define the XML element tags that we are able to merge. */ const xmlChar *device = (xmlChar *) "device"; const xmlChar *profiles = (xmlChar *) "profile-set"; const xmlChar *commands = (xmlChar *) "command-set"; const xmlChar *capabilities = (xmlChar *) "capabilities"; const xmlChar *cap_option = (xmlChar *) "option"; const xmlChar *cap_mode = (xmlChar *) "mode"; char *tmp; require (self); if (!node) return; node = node->xmlChildrenNode; while (node) { if (!xmlIsBlankNode (node)) { if (0 == xmlStrcmp (node->name, device)) { char *tmp = NULL; tmp = parseDevices (node, MODEL_OVERSEAS); if (tmp) self->overseas = tmp; tmp = parseDevices (node, MODEL_JAPAN); if (tmp) self->japan = tmp; } else if (0 == xmlStrcmp (node->name, profiles)) { EpsonScanHard profile = parseProfiles (node); if (profile) self->profile = profile; } else if (0 == xmlStrcmp (node->name, commands)) { scan_command_t *command = parseCommands_set (node); if (command) self->command = command; } else if (0 == xmlStrcmp (node->name, capabilities)) { tmp = (char *)xmlGetProp(node, (const xmlChar *) cap_mode); if(strcmp_c(tmp, "duplex") == 0){ capability_data_t *capability = parseCapabilities (node); if (capability) { self->adf_duplex = capability; self->adf_duplex->option = (char *)xmlGetProp(node, (const xmlChar *) cap_option); self->adf_duplex->mode = tmp; } }else { capability_data_t *capability = parseCapabilities (node); if (capability) { self->dfault = capability; self->dfault->option = (char *)xmlGetProp(node, (const xmlChar *) cap_option); self->dfault->mode = tmp; } } } } node = node->next; } self->from_file = true; }
DeviceManagerPulseAudio::DeviceManagerPulseAudio() { parseDevices( DeviceInfo::INPUT ); parseDevices( DeviceInfo::OUTPUT ); }