Tag* GSIOTInfo::tag() const { Tag* t = new Tag( "gsiot" ); t->setXmlns( XMLNS_GSIOT ); Tag *tiot = new Tag( t, "iot" ); tiot->addAttribute( "ver", g_IOTGetVersion()+"(build "+g_IOTGetBuildInfo()+")" ); if( m_deviceList.size()>0){ std::list<GSIOTDevice *>::const_iterator it = m_deviceList.begin(); for(;it!=m_deviceList.end();it++){ Tag *c = new Tag(t, "device"); c->addAttribute("id",(*it)->getId()); c->addAttribute("name",ASCIIToUTF8((*it)->getName())); c->addAttribute("type",(*it)->getType()); if( (*it)->getType()!=(*it)->getExType() && IOT_DEVICE_Unknown!=(*it)->getExType() ){ c->addAttribute( "extype", (*it)->getExType() ); } if( !(*it)->getVer().empty() && (*it)->getVer()!="1.0" ) c->addAttribute("ver",(*it)->getVer()); c->addAttribute("readtype",(*it)->getReadType()); const defUseable useable = (*it)->get_all_useable_state(); if( defUseable_OK != useable ) { c->addAttribute("useable",useable); }; // 默认可用,不可用时才提供此值 const defAlarmState AlarmState = (*it)->GetCurAlarmState(); if( macAlarmState_IsAlarm(AlarmState) ) { c->addAttribute( "almst", AlarmState ); }; // 默认正常 const std::string PrePicChangeCode = (*it)->GetPrePicChangeCode(); if( !PrePicChangeCode.empty() ) { c->addAttribute( "prepic", PrePicChangeCode ); }; } } return t; }
bool Registration::handleIq( Stanza *stanza ) { if( stanza->subtype() == StanzaIqError ) { Tag *e = stanza->findChild( "error" ); if( e->empty() || !m_registrationHandler ) return false; if( e->hasChild( "conflict" ) || e->hasAttribute( "code", "409" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_CONFLICT ); else if( e->hasChild( "not-acceptable" ) || e->hasAttribute( "code", "406" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_NOT_ACCEPTABLE ); else if( e->hasChild( "bad-request" ) || e->hasAttribute( "code", "400" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_BAD_REQUEST ); else if( e->hasChild( "forbidden" ) || e->hasAttribute( "code", "403" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_FORBIDDEN ); else if( e->hasChild( "registration-required" ) || e->hasAttribute( "code", "407" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_REGISTRATION_REQUIRED ); else if( e->hasChild( "unexpected-request" ) || e->hasAttribute( "code", "400" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_UNEXPECTED_REQUEST ); else if( e->hasChild( "not-authorized" ) || e->hasAttribute( "code", "401" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_NOT_AUTHORIZED ); else if( e->hasChild( "not-allowed" ) || e->hasAttribute( "code", "405" ) ) m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_NOT_ALLOWED ); else m_registrationHandler->handleRegistrationResult( RegistrationHandler::UNKNOWN_ERROR ); } return false; }
// ---- Client::SessionCreation ---- Tag* Client::SessionCreation::tag() const { Tag* t = new Tag( "session" ); t->setXmlns( XMLNS_STREAM_SESSION ); return t; }
void TagTest::testRIDIsolation() { { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_0")); AKVERIFYEXEC(select); } Tag tag; tag.setGid("gid"); tag.setType("mytype"); tag.setRemoteId("rid_0"); TagCreateJob *createJob = new TagCreateJob(tag, this); AKVERIFYEXEC(createJob); QVERIFY(createJob->tag().isValid()); qint64 tagId; { TagFetchJob *fetchJob = new TagFetchJob(this); AKVERIFYEXEC(fetchJob); Q_FOREACH (const Tag &tag, fetchJob->tags()) { qDebug() << tag.gid(); } QCOMPARE(fetchJob->tags().count(), 1); QCOMPARE(fetchJob->tags().first().gid(), QByteArray("gid")); QCOMPARE(fetchJob->tags().first().type(), QByteArray("mytype")); QCOMPARE(fetchJob->tags().first().remoteId(), QByteArray("rid_0")); tagId = fetchJob->tags().first().id(); } { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_1")); AKVERIFYEXEC(select); } tag.setRemoteId("rid_1"); createJob = new TagCreateJob(tag, this); createJob->setMergeIfExisting(true); AKVERIFYEXEC(createJob); QVERIFY(createJob->tag().isValid()); { TagFetchJob *fetchJob = new TagFetchJob(this); AKVERIFYEXEC(fetchJob); QCOMPARE(fetchJob->tags().count(), 1); QCOMPARE(fetchJob->tags().first().gid(), QByteArray("gid")); QCOMPARE(fetchJob->tags().first().type(), QByteArray("mytype")); QCOMPARE(fetchJob->tags().first().remoteId(), QByteArray("rid_1")); QCOMPARE(fetchJob->tags().first().id(), tagId); } TagDeleteJob *deleteJob = new TagDeleteJob(Tag(tagId), this); AKVERIFYEXEC(deleteJob); { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("")); AKVERIFYEXEC(select); } }
// . also sets m_sitePathDepth to what it should be // . -1 indicates unknown (not enough data, etc.) or host/domain is the site // . returns false if blocked, true otherwise // . returns true and sets g_errno on error // . sets m_site to reference into "url" so XmlDoc::updateTagdb() can just // pass a bunch of site ptrs to msg9a // . "url" MUST BE NORMALIZED via Url.cpp. so using Links' buffer is ok! // . TODO: consider setting "state" to null if your url host has tons of inlinx bool SiteGetter::getSite ( char *url , TagRec *gr , int32_t timestamp, //char *coll , collnum_t collnum, int32_t niceness , //bool addTags , void *state , void (* callback)(void *state) ) { // save it m_gr = gr; m_url = url; //m_coll = coll; m_collnum = collnum; //m_addTags = addTags; m_state = state; m_callback = callback; m_timestamp= timestamp; m_niceness = niceness; m_errno = 0; // is it domain only? m_hasSubdomain = ::hasSubdomain ( url ); // reset m_siteLen = 0; m_site[0] = '\0'; m_allDone = false; m_addedTag.reset(); // set this to unknown for now m_sitePathDepth = -1; m_oldSitePathDepth = -1; // reset this just in case g_errno = 0; // // HARDCODED algos // // ~ /user/ /users/ /profile/ myspace facebook linkedin // if ( setRecognizedSite ( ) ) { m_allDone = true; return true; } // bail if nothing else we can do if ( ! gr ) return setSite ( ) ; CollectionRec *cr = g_collectiondb.getRec ( collnum ); // g_errno should be set if this is NULL if ( ! cr ) return true; //if ( ! cr->m_subsiteDetectionEnabled ) return true; // check the current tag for an age Tag *tag = gr->getTag("sitepathdepth"); // if there and the age is young, skip it int32_t age = -1; //int32_t now = getTimeGlobal(); //if ( tag ) age = now - tag->m_timestamp; // to parse conssitently for the qa test "qatest123" coll use // "timestamp" as the "current time" if ( tag ) age = timestamp - tag->m_timestamp; // if there, at least get it (might be -1) if ( tag ) m_oldSitePathDepth = atol ( tag->getTagData() ); // . if older than 10 days, we need to redo it // . if caller give us a timestamp of 0, never redo it! if ( age > 10*24*60*60 && timestamp != 0 ) age = -1; //if ( strstr(m_url,"http://www.topix.com/yp/albuquerque/c/community-religion-and-spirituality-churches") ) // log("hey"); // . if our site quality is low, forget about dividing it up too // . if age is valid, skip it // . also if caller does not want a callback, like XmlDoc.cpp, // then use whatever we got if ( age >= 0 || ! m_state ) { // || hostRootNumInlinks < 500 ) { // do not add to tagdb m_state = NULL; // just use what we had, it is not expired m_sitePathDepth = m_oldSitePathDepth; // . now set the site with m_sitePathDepth // . sanity check, should not block since m_state is NULL if ( ! setSite () ) { char *xx=NULL;*xx=0; } // we did not block return true; } // right now we only run on host #0 so we do not flood the cluster // with queries... if ( g_hostdb.m_hostId != 0 ) { // do not add to tagdb and do not block! m_state = NULL; // . use a sitepathdepth of -1 by default then, until host #0 // has a chance to evaluate // . a sitepathdepth of -1 means to use the full hostname // as the site m_sitePathDepth = -1; // sanity check, should not block since m_state is NULL if ( ! setSite () ) { char *xx=NULL;*xx=0; } // we did not block return true; } // . initial path depth // . this actually includes the first subdir name, up to, but not // including the /, according to Url::getPathEnd() // . start with the broadest site as our possible subsite first // in order to reduce errors i guess. because if we have examples: // xyz.com/fred/ // xyz.com/jamie/ // xyz.com/bob/ ... // and we also have: // xyz.com/home/users/fred/ // xyz.com/home/users/jamie/ // xyz.com/home/users/bob/ ... // then we need the first set to take precedence! m_pathDepth = 0; // set our fill url class. do not addWWW //m_u.set ( m_url , gbstrlen(m_url) , false ); // must have http:// i guess if ( strncmp(m_url,"http",4) ) { g_errno = EBADURL; return true; // don't let bad input from pageparser core us! char *xx=NULL;*xx=0; } // how many can we do? false = countFilename? //m_maxPathDepth = m_u.getPathDepth ( false ); // . pathDepth==0 for "www.xyz.com" // . pathDepth==0 for "www.xyz.com/" // . pathDepth==0 for "www.xyz.com/foo" // . pathDepth==1 for "www.xyz.com/foo/" // . pathDepth==1 for "www.xyz.com/foo/x" // . pathDepth==2 for "www.xyz.com/foo/x/" // . pathDepth==2 for "www.xyz.com/foo/x/y" // . true --> we have the protocol, http:// in m_url m_maxPathDepth = getPathDepth ( m_url , true ); // get it. return false if it blocked. return getSiteList(); }
void taglib_tag_set_comment(TagLib_Tag *tag, const char *comment) { Tag *t = reinterpret_cast<Tag *>(tag); t->setComment(String(comment, unicodeStrings ? String::UTF8 : String::Latin1)); }
void taglib_tag_set_year(TagLib_Tag *tag, unsigned int year) { Tag *t = reinterpret_cast<Tag *>(tag); t->setYear(year); }
int main( int /*argc*/, char** /*argv*/ ) { int fail = 0; std::string name; Tag *t; // ------- { name = "empty tag() test"; Receipt r( Receipt::Invalid ); t = r.tag(); if( t ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete t; t = 0; } // ------- { name = "request"; Receipt r( Receipt::Request ); t = r.tag(); if( t->xml() != "<request xmlns='"+ XMLNS_RECEIPTS + "'/>" ) { ++fail; fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() ); } delete t; t = 0; } // ------- { name = "received"; Receipt r( Receipt::Received ); t = r.tag(); if( t->xml() != "<received xmlns='"+ XMLNS_RECEIPTS + "'/>" ) { ++fail; fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() ); } delete t; t = 0; } StanzaExtensionFactory sef; sef.registerExtension( new Receipt( Receipt::Invalid ) ); // ------- { name = "Receipt::Request/SEFactory test"; Tag* f = new Tag( "message" ); new Tag( f, "request", "xmlns", XMLNS_RECEIPTS ); Message msg( Message::Normal, JID(), "" ); sef.addExtensions( msg, f ); const Receipt* se = msg.findExtension<Receipt>( ExtReceipt ); if( se == 0 || se->rcpt() != Receipt::Request ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete f; } // ------- { name = "Receipt::Received/SEFactory test"; Tag* f = new Tag( "message" ); new Tag( f, "received", "xmlns", XMLNS_RECEIPTS ); Message msg( Message::Normal, JID(), "" ); sef.addExtensions( msg, f ); const Receipt* se = msg.findExtension<Receipt>( ExtReceipt ); if( se == 0 || se->rcpt() != Receipt::Received ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete f; } printf( "Receipt: " ); if( fail == 0 ) { printf( "OK\n" ); return 0; } else { fprintf( stderr, "%d test(s) failed\n", fail ); return 1; } }
DefineSpriteTag::DefineSpriteTag(RECORDHEADER h, std::istream& in, RootMovieClip* root):DictionaryTag(h,root) { in >> SpriteID >> FrameCount; LOG(LOG_TRACE,"DefineSprite ID: " << SpriteID); //Create a non top level TagFactory TagFactory factory(in, false); Tag* tag; bool done=false; bool empty=true; do { tag=factory.readTag(root); /* We need no locking here, because the vm can only * access this object after construction */ switch(tag->getType()) { case DICT_TAG: delete tag; throw ParseException("Dictionary tag inside a sprite. Should not happen."); case DISPLAY_LIST_TAG: addToFrame(static_cast<DisplayListTag*>(tag)); empty=false; break; case SHOW_TAG: { delete tag; frames.emplace_back(Frame()); empty=true; break; } case SYMBOL_CLASS_TAG: case ABC_TAG: case CONTROL_TAG: case ACTION_TAG: delete tag; throw ParseException("Control tag inside a sprite. Should not happen."); case FRAMELABEL_TAG: addFrameLabel(frames.size()-1,static_cast<FrameLabelTag*>(tag)->Name); delete tag; empty=false; break; case TAG: delete tag; LOG(LOG_NOT_IMPLEMENTED,_("Unclassified tag inside Sprite?")); break; case END_TAG: delete tag; done=true; if(empty && frames.size()!=FrameCount) frames.pop_back(); break; } } while(!done); if(frames.size()!=FrameCount) { //This condition is not critical as Sprites are not executed while being parsed LOG(LOG_CALLS,_("Inconsistent frame count in Sprite ID ") << SpriteID); } setFramesLoaded(frames.size()); }
void Group::addTag(const Tag &tag) { if (!util::checkEntityInput(tag, false)) { throw UninitializedEntity(); } backend()->addTag(tag.id()); }
bool Group::removeTag(const Tag &tag) { if (!util::checkEntityInput(tag, false)) { return false; } return backend()->removeTag(tag.id()); }
bool Group::hasTag(const Tag &tag) const { if (!util::checkEntityInput(tag, false)) { return false; } return backend()->hasTag(tag.id()); }
void add( const Tag& tag ) { m_tags.insert( std::make_pair( tag.getName(), tag ) ); }
std::list<Tag *> M3U8Parser::parseEntries(stream_t *stream) { std::list<Tag *> entrieslist; Tag *lastTag = NULL; char *psz_line; while((psz_line = vlc_stream_ReadLine(stream))) { if(*psz_line == '#') { if(!strncmp(psz_line, "#EXT", 4)) //tag { std::string key; std::string attributes; const char *split = strchr(psz_line, ':'); if(split) { key = std::string(psz_line + 1, split - psz_line - 1); attributes = std::string(split + 1); } else { key = std::string(psz_line + 1); } if(!key.empty()) { Tag *tag = TagFactory::createTagByName(key, attributes); if(tag) entrieslist.push_back(tag); lastTag = tag; } } } else if(*psz_line) { /* URI */ if(lastTag && lastTag->getType() == AttributesTag::EXTXSTREAMINF) { AttributesTag *streaminftag = static_cast<AttributesTag *>(lastTag); /* master playlist uri, merge as attribute */ Attribute *uriAttr = new (std::nothrow) Attribute("URI", std::string(psz_line)); if(uriAttr) streaminftag->addAttribute(uriAttr); } else /* playlist tag, will take modifiers */ { Tag *tag = TagFactory::createTagByName("", std::string(psz_line)); if(tag) entrieslist.push_back(tag); } lastTag = NULL; } else // drop { lastTag = NULL; } free(psz_line); } return entrieslist; }
void taglib_tag_set_artist(TagLib_Tag *tag, const char *artist) { Tag *t = reinterpret_cast<Tag *>(tag); t->setArtist(String(artist, unicodeStrings ? String::UTF8 : String::Latin1)); }
Tag Element::add_tag(const Tag &tag) { m_tags[tag.key()] = tag.value(); return tag; }
void taglib_tag_set_album(TagLib_Tag *tag, const char *album) { Tag *t = reinterpret_cast<Tag *>(tag); t->setAlbum(String(album, unicodeStrings ? String::UTF8 : String::Latin1)); }
Tag* PrivacyManager::Query::tag() const { Tag* t = new Tag( "query" ); t->setXmlns( XMLNS_PRIVACY ); std::string child; switch( m_context ) { case PLRequestList: case PLRemove: case PLStore: child = "list"; break; case PLDefault: case PLUnsetDefault: child = "default"; break; case PLActivate: case PLUnsetActivate: child = "active"; break; default: case PLRequestNames: return t; break; } Tag* c = new Tag( t, child ); if( !m_names.empty() ) c->addAttribute( "name", (*m_names.begin()) ); int count = 0; PrivacyListHandler::PrivacyList::const_iterator it = m_items.begin(); for( ; it != m_items.end(); ++it ) { Tag* i = new Tag( c, "item" ); switch( (*it).type() ) { case PrivacyItem::TypeJid: i->addAttribute( TYPE, "jid" ); break; case PrivacyItem::TypeGroup: i->addAttribute( TYPE, "group" ); break; case PrivacyItem::TypeSubscription: i->addAttribute( TYPE, "subscription" ); break; default: break; } switch( (*it).action() ) { case PrivacyItem::ActionAllow: i->addAttribute( "action", "allow" ); break; case PrivacyItem::ActionDeny: i->addAttribute( "action", "deny" ); break; } int pType = (*it).packetType(); if( pType != 15 ) { if( pType & PrivacyItem::PacketMessage ) new Tag( i, "message" ); if( pType & PrivacyItem::PacketPresenceIn ) new Tag( i, "presence-in" ); if( pType & PrivacyItem::PacketPresenceOut ) new Tag( i, "presence-out" ); if( pType & PrivacyItem::PacketIq ) new Tag( i, "iq" ); } i->addAttribute( "value", (*it).value() ); i->addAttribute( "order", ++count ); } return t; }
void taglib_tag_set_genre(TagLib_Tag *tag, const char *genre) { Tag *t = reinterpret_cast<Tag *>(tag); t->setGenre(String(genre, unicodeStrings ? String::UTF8 : String::Latin1)); }
inline bool operator()(const uint32_t a,const Tag &b) const { return (a < b.id()); }
void taglib_tag_set_track(TagLib_Tag *tag, unsigned int track) { Tag *t = reinterpret_cast<Tag *>(tag); t->setTrack(track); }
inline bool operator()(const Tag &a,const uint32_t b) const { return (a.id() < b); }
void TagTest::testDeleteRIDIsolation() { Tag tag; tag.setGid("gid"); tag.setType("mytype"); tag.setRemoteId("rid_0"); { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_0")); AKVERIFYEXEC(select); TagCreateJob *createJob = new TagCreateJob(tag, this); AKVERIFYEXEC(createJob); QVERIFY(createJob->tag().isValid()); tag.setId(createJob->tag().id()); } tag.setRemoteId("rid_1"); { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral("akonadi_knut_resource_1")); AKVERIFYEXEC(select); TagCreateJob *createJob = new TagCreateJob(tag, this); createJob->setMergeIfExisting(true); AKVERIFYEXEC(createJob); QVERIFY(createJob->tag().isValid()); } Akonadi::Monitor monitor; monitor.setTypeMonitored(Akonadi::Monitor::Tags); QSignalSpy signalSpy(&monitor, SIGNAL(tagRemoved(Akonadi::Tag))); TagDeleteJob *deleteJob = new TagDeleteJob(tag, this); AKVERIFYEXEC(deleteJob); // Other tests notifications might interfere due to notification compression on server QTRY_VERIFY(signalSpy.count() >= 1); Tag removedTag; while (!signalSpy.isEmpty()) { const Tag t = signalSpy.takeFirst().takeFirst().value<Akonadi::Tag>(); if (t.id() == tag.id()) { removedTag = t; break; } } QVERIFY(removedTag.isValid()); QVERIFY(removedTag.remoteId().isEmpty()); { ResourceSelectJob *select = new ResourceSelectJob(QStringLiteral(""), this); AKVERIFYEXEC(select); } }
inline bool operator()(const Tag *a,const Tag &b) const { return (a->id() < b.id()); }
bool NonSaslAuth::handleIqID( Stanza *stanza, int context ) { switch( stanza->subtype() ) { case StanzaIqError: { m_parent->setAuthed( false ); m_parent->disconnect( ConnAuthenticationFailed ); Tag *t = stanza->findChild( "error" ); if( t ) { if( t->hasChild( "conflict" ) || t->hasAttribute( "code", "409" ) ) m_parent->setAuthFailure( NonSaslConflict ); else if( t->hasChild( "not-acceptable" ) || t->hasAttribute( "code", "406" ) ) m_parent->setAuthFailure( NonSaslNotAcceptable ); else if( t->hasChild( "not-authorized" ) || t->hasAttribute( "code", "401" ) ) m_parent->setAuthFailure( NonSaslNotAuthorized ); } break; } case StanzaIqResult: switch( context ) { case TRACK_REQUEST_AUTH_FIELDS: { const std::string& id = m_parent->getID(); Tag *iq = new Tag( "iq" ); iq->addAttribute( "id", id ); iq->addAttribute( "type", "set" ); Tag *query = new Tag( iq, "query" ); query->addAttribute( "xmlns", XMLNS_AUTH ); new Tag( query, "username", m_parent->jid().username() ); new Tag( query, "resource", m_parent->jid().resource() ); Tag *q = stanza->findChild( "query" ); if( ( q->hasChild( "digest" ) ) && !m_sid.empty() ) { SHA sha; sha.feed( m_sid ); sha.feed( m_parent->password() ); sha.finalize(); new Tag( query, "digest", sha.hex() ); } else { new Tag( query, "password", m_parent->password() ); } m_parent->trackID( this, id, TRACK_SEND_AUTH ); m_parent->send( iq ); break; } case TRACK_SEND_AUTH: m_parent->setAuthed( true ); m_parent->connected(); break; } break; default: break; } return false; }
inline bool operator()(const Tag &a,const Tag *b) const { return (a.id() < b->id()); }
bool Registration::handleIqID( Stanza *stanza, int context ) { if( stanza->subtype() != StanzaIqResult ) return false; if( !m_registrationHandler ) return false; switch( context ) { case FETCH_REGISTRATION_FIELDS: { Tag *q = stanza->findChild( "query" ); if( q->hasChild( "registered" ) ) { m_registrationHandler->handleAlreadyRegistered(); break; } if( q->hasChild( "x", "xmlns", XMLNS_X_DATA ) ) { DataForm form( q->findChild( "x", "xmlns", XMLNS_X_DATA ) ); m_registrationHandler->handleDataForm( form ); } if( q->hasChild( "x", "xmlns", XMLNS_X_OOB ) ) { Tag *x = q->findChild( "x", "xmlns", XMLNS_X_OOB ); std::string url; if( x->hasChild( "url" ) ) url = x->findChild( "url" )->cdata(); std::string desc; if( x->hasChild( "url" ) ) url = x->findChild( "url" )->cdata(); m_registrationHandler->handleOOB( url, desc ); } int fields = 0; std::string instructions; if( q->hasChild( "username" ) ) fields |= FIELD_USERNAME; if( q->hasChild( "nick" ) ) fields |= FIELD_NICK; if( q->hasChild( "password" ) ) fields |= FIELD_PASSWORD; if( q->hasChild( "name" ) ) fields |= FIELD_NAME; if( q->hasChild( "first" ) ) fields |= FIELD_FIRST; if( q->hasChild( "last" ) ) fields |= FIELD_LAST; if( q->hasChild( "email" ) ) fields |= FIELD_EMAIL; if( q->hasChild( "address" ) ) fields |= FIELD_ADDRESS; if( q->hasChild( "city" ) ) fields |= FIELD_CITY; if( q->hasChild( "state" ) ) fields |= FIELD_STATE; if( q->hasChild( "zip" ) ) fields |= FIELD_ZIP; if( q->hasChild( "phone" ) ) fields |= FIELD_PHONE; if( q->hasChild( "url" ) ) fields |= FIELD_URL; if( q->hasChild( "date" ) ) fields |= FIELD_DATE; if( q->hasChild( "misc" ) ) fields |= FIELD_MISC; if( q->hasChild( "text" ) ) fields |= FIELD_TEXT; if( q->hasChild( "instructions" ) ) instructions = q->findChild( "instructions" )->cdata(); m_registrationHandler->handleRegistrationFields( fields, instructions ); break; } case CREATE_ACCOUNT: m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_SUCCESS ); break; case CHANGE_PASSWORD: m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_SUCCESS ); break; case REMOVE_ACCOUNT: m_registrationHandler->handleRegistrationResult( RegistrationHandler::REGISTRATION_SUCCESS ); break; } return false; }
void taglib_tag_set_title(TagLib_Tag *tag, const char *title) { Tag *t = reinterpret_cast<Tag *>(tag); t->setTitle(String(title, unicodeStrings ? String::UTF8 : String::Latin1)); }
TEST(Gloox, RosterManagerQuery) { int fail = 0; std::string name; Tag *t; // ------- { name = "request roster"; RosterManager::Query rq; t = rq.tag(); if( t->xml() != "<query xmlns='" + XMLNS_ROSTER + "'/>" ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete t; t = 0; } // ------- { name = "add/update item"; StringList sl; sl.push_back( "group1" ); sl.push_back( "group2" ); RosterManager::Query rq( JID( "foof" ), "name", sl ); t = rq.tag(); if( t->xml() != "<query xmlns='" + XMLNS_ROSTER + "'>" "<item jid='foof' name='name'>" "<group>group1</group>" "<group>group2</group>" "</item></query>" ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete t; t = 0; } // ------- { name = "remove item"; RosterManager::Query rq( JID( "foof" ) ); t = rq.tag(); if( t->xml() != "<query xmlns='" + XMLNS_ROSTER + "'>" "<item jid='foof' subscription='remove'/>" "</query>" ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete t; t = 0; } // ------- { name = "initial roster"; Tag* q = new Tag( "query" ); q->setXmlns( XMLNS_ROSTER ); Tag* i = new Tag( q, "item", "jid", "foo1" ); i->addAttribute( "name", "name1" ); i->addAttribute( "subscription", "from" ); i = new Tag( q, "item", "jid", "foo2" ); i->addAttribute( "name", "name2" ); i->addAttribute( "subscription", "both" ); RosterManager::Query rq( q ); t = rq.tag(); if( *t != *q || rq.roster().size() != 2 ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete t; t = 0; delete q; } // ------- { name = "roster push"; Tag* q = new Tag( "query" ); q->setXmlns( XMLNS_ROSTER ); Tag* i = new Tag( q, "item", "jid", "foo1" ); i->addAttribute( "name", "name1" ); i->addAttribute( "subscription", "from" ); new Tag( i, "group", "group1" ); new Tag( i, "group", "group2" ); RosterManager::Query rq( q ); t = rq.tag(); if( *t != *q ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); printf( " got: %s\n", t->xml().c_str() ); printf( "expected: %s\n", q->xml().c_str() ); } delete t; t = 0; delete q; } // ------- name = "RosterManager::Query/SEFactory test"; StanzaExtensionFactory sef; sef.registerExtension( new RosterManager::Query() ); Tag* f = new Tag( "iq" ); new Tag( f, "query", "xmlns", XMLNS_ROSTER ); IQ iq( IQ::Set, JID(), "" ); sef.addExtensions( iq, f ); const RosterManager::Query* se = iq.findExtension<RosterManager::Query>( ExtRoster ); if( se == 0 ) { ++fail; fprintf( stderr, "test '%s' failed\n", name.c_str() ); } delete f; EXPECT_EQ(0, fail); // if( fail == 0 ) // { // printf( "RosterManager::Query: OK\n" ); // return 0; // } // else // { // fprintf( stderr, "RosterManager::Query: %d test(s) failed\n", fail ); // return 1; // } }
Tag* Event::tag() const { if( !m_valid ) return 0; Tag* event = new Tag( "event", XMLNS, XMLNS_PUBSUB_EVENT ); Tag* child = new Tag( event, util::lookup( m_type, eventTypeValues ) ); Tag* item = 0; switch( m_type ) { case PubSub::EventCollection: { item = new Tag( child, "node", "id", m_node ); item->addChildCopy( m_config ); break; } case PubSub::EventPurge: case PubSub::EventDelete: case PubSub::EventConfigure: child->addAttribute( "node", m_node ); if( m_type == PubSub::EventConfigure ) child->addChildCopy( m_config ); break; case PubSub::EventItems: case PubSub::EventItemsRetract: { child->addAttribute( "node", m_node ); if( m_itemOperations ) { Tag* item; ItemOperation* op; ItemOperationList::const_iterator itt = m_itemOperations->begin(); for( ; itt != m_itemOperations->end(); ++itt ) { op = (*itt); item = new Tag( child, op->retract ? "retract" : "item", "id", op->item ); if( op->payload ) item->addChildCopy( op->payload ); } } break; } default: delete event; return 0; } if( m_subscriptionIDs || !m_collection.empty() ) { Tag* headers = new Tag( event, "headers", XMLNS, "http://jabber.org/protocol/shim" ); StringList::const_iterator it = m_subscriptionIDs->begin(); for( ; it != m_subscriptionIDs->end(); ++it ) { (new Tag( headers, "header", "name", "pubsub#subid" ))->setCData( (*it) ); } if( !m_collection.empty() ) (new Tag( headers, "header", "name", "pubsub#collection" ) ) ->setCData( m_collection ); } return event; }