static void next(void *c, void *v) { if (c) { struct ctx *ctx = c; CharBuffer *b = ctx->b; struct Schedule *s = (struct Schedule *) v; struct ScheduleEntry *entries = hashmapGet(timetable->scheduleEntry, &s->sid); // Loop and find our stanox. Do the entire schedule as a stanox can exist // multiple times on circular & long schedules. if (entries) for (int i = 0; i < s->numEntries; i++) { short tiploc = entries[i].time.tiploc; struct TTTiploc *tpl = hashmapGet(timetable->idTiploc, &tiploc); if (tpl && tpl->stanox == ctx->stanox && (!ctx->filterHour || ctx->hour == ((scheduleTime_getTime(&entries[i].time) / 3600) % 24)) ) appendEntry(ctx, s, entries, i); } } }
void QtgdataClient::onAtomFeedRetrieved(QByteArray reply) { #ifdef QTGDATA_DEBUG qDebug() << "onAtomFeedRetrieved. Client ID: " << ID; #endif XMLParser parser; try { IEntity *entity = parser.parse(reply,reply.size()); if((entity != NULL)&&(entity->getId() != Id::NULLID)) { if(entity->getId() == Id::feed) { atomFeed = createAtomFeed(); IEntity::itConstEntities begin,end; entity->getEntityList(begin,end); if(begin != end) { for(IEntity::itConstEntities it = begin; it != end; it++ ) { IEntity *sit = dynamic_cast<IEntity *>(*it); switch(sit->getId()) { case Id::id: atomFeed->id = sit->getValue(); break; case Id::updated: atomFeed->updated.fromString(sit->getValue(),Qt::ISODate); break; case Id::title: atomFeed->title = sit->getValue(); break; case Id::generator: atomFeed->generator.generator = sit->getValue(); atomFeed->generator.version = sit->getAttribute(AttributeId::version)->sValue; atomFeed->generator.uri = QUrl(sit->getAttribute(AttributeId::uri)->sValue); break; case Id::author: { IEntity *aux = NULL; Author author; if((aux=sit->getEntity(Id::name))) author.name = aux->getValue(); aux = NULL; if(aux=sit->getEntity(Id::uri)) author.uri = QUrl(aux->getValue()); aux = NULL; if(aux=sit->getEntity(Id::email)) author.email = aux->getValue(); atomFeed->authors.append(author); break; } case Id::link: { Link link; link.href = QUrl(sit->getAttribute(AttributeId::href)->sValue); link.rel = sit->getAttribute(AttributeId::rel)->sValue; link.type = sit->getAttribute(AttributeId::type)->sValue; atomFeed->links.append(link); break; } case Id::entry: { AtomEntry *atomEntry = createAtomEntry(); IEntity::itConstEntities entryBegin,entryEnd; sit->getEntityList(entryBegin,entryEnd); for(IEntity::itConstEntities itEntry = entryBegin; itEntry != entryEnd; itEntry++) { IEntity *entry = dynamic_cast<IEntity *>(*itEntry); int id = entry->getId(); switch(id) { case Id::author: { IEntity *author = entry->getEntity(Id::author); if((author)&&(author->getId())) { IEntity *aux = NULL; if((aux=author->getEntity(Id::name))) { Author author; author.name = aux->getValue(); atomEntry->authors.append(author); } } break; } case Id::id: atomEntry->id = entry->getValue(); break; case Id::published: atomEntry->published.fromString(entry->getValue(),Qt::ISODate); break; case Id::updated: atomEntry->updated.fromString(entry->getValue(),Qt::ISODate); break; case Id::summary: atomEntry->summary = entry->getValue(); break; case Id::title: atomEntry->title = entry->getValue(); break; case Id::link: { Link link; link.href = QUrl(entry->getAttribute(AttributeId::href)->sValue); link.rel = entry->getAttribute(AttributeId::rel)->sValue; link.type = entry->getAttribute(AttributeId::type)->sValue; atomEntry->links.append(link); break; } case Id::content: { atomEntry->content.type = entry->getAttribute(AttributeId::type)->sValue; atomEntry->content.content = QByteArray(entry->getValue().toAscii());; break; } default: parseEntry(id,atomEntry,entry); break; } } appendEntry(atomEntry); } } } } emitAtomFeedRetrieved(); } // if feed } delete entity; } catch(XMLParserException e) { qDebug() << e.what(); } }