Tag* XmppGSAuth_base::tagAuth_base( bool hasmethod ) const { Tag *tAuth = new Tag( "authority" ); if( hasmethod ) { tAuth->addAttribute( "method", m_srcmethod ); } // ÏȼÓÈëÀ´±ö defmapGSIOTUser::const_iterator it = GSIOTUserMgr::usermapFind( m_mapUser, XMPP_GSIOTUser_Guest ); if( it!=m_mapUser.end() ) { GSIOTUser *pUser = it->second; tAuth->addChild( pUser->tag(m_TagParam) ); } for( defmapGSIOTUser::const_iterator it=m_mapUser.begin(); it!=m_mapUser.end(); ++it ) { GSIOTUser *pUser = it->second; if( GSIOTUserMgr::IsGuest(pUser) ) continue; tAuth->addChild( pUser->tag(m_TagParam) ); } return tAuth; }
Tag* DataForm::tag() const { if( m_type == TypeInvalid ) return 0; Tag* x = new Tag( "x" ); x->setXmlns( XMLNS_X_DATA ); x->addAttribute( TYPE, util::lookup( m_type, dfTypeValues ) ); if( !m_title.empty() ) new Tag( x, "title", m_title ); StringList::const_iterator it_i = m_instructions.begin(); for( ; it_i != m_instructions.end(); ++it_i ) new Tag( x, "instructions", (*it_i) ); FieldList::const_iterator it = m_fields.begin(); for( ; it != m_fields.end(); ++it ) x->addChild( (*it)->tag() ); if( m_reported != NULL ) { x->addChild( m_reported->tag() ); } ItemList::const_iterator iti = m_items.begin(); for( ; iti != m_items.end(); ++iti ) x->addChild( (*iti)->tag() ); return x; }
Tag* Search::Query::tag() const { Tag* t = new Tag( "query" ); t->setXmlns( XMLNS_SEARCH ); if( m_form ) t->addChild( m_form->tag() ); else if( m_fields ) { if( !m_instructions.empty() ) new Tag( t, "instructions", m_instructions ); if( m_fields & SearchFieldFirst ) new Tag( t, "first", m_values.first() ); if( m_fields & SearchFieldLast ) new Tag( t, "last", m_values.last() ); if( m_fields & SearchFieldNick ) new Tag( t, "nick", m_values.nick() ); if( m_fields & SearchFieldEmail ) new Tag( t, "email", m_values.email() ); } else if( !m_srl.empty() ) { SearchResultList::const_iterator it = m_srl.begin(); for( ; it != m_srl.end(); ++it ) { t->addChild( (*it)->tag() ); } } return t; }
Tag* XmppGSEvent::tag() const { Tag* i = new Tag( "gsiot" ); i->setXmlns( XMLNS_GSIOT_EVENT ); Tag *tmgr = new Tag( i,"event" ); tmgr->addAttribute( "method", m_srcmethod ); if( m_pDevice ) tmgr->addChild( m_pDevice->tag(m_TagParam) ); if( m_TagParam.isValid && m_TagParam.isResult ) { ; } else { new Tag( tmgr, "state", m_runstate?"1":"0" ); } Tag *cdo = new Tag( tmgr, "do" ); for( std::list<ControlEvent*>::const_iterator it=m_Events.begin(); it!=m_Events.end(); ++it ) { cdo->addChild( (*it)->tag(m_TagParam) ); } return i; }
Tag* Registration::Query::tag() const { Tag* t = new Tag( "query" ); t->setXmlns( XMLNS_REGISTER ); if( !m_instructions.empty() ) new Tag( t, "instructions", m_instructions ); if ( m_reg ) new Tag( t, "registered" ); if( m_form ) t->addChild( m_form->tag() ); else if( m_oob ) t->addChild( m_oob->tag() ); else if( m_del ) new Tag( t, "remove" ); else if( m_fields ) { if( m_fields & FieldUsername ) new Tag( t, "username", m_values.username ); if( m_fields & FieldNick ) new Tag( t, "nick", m_values.nick ); if( m_fields & FieldPassword ) new Tag( t, "password", m_values.password ); if( m_fields & FieldName ) new Tag( t, "name", m_values.name ); if( m_fields & FieldFirst ) new Tag( t, "first", m_values.first ); if( m_fields & FieldLast ) new Tag( t, "last", m_values.last ); if( m_fields & FieldEmail ) new Tag( t, "email", m_values.email ); if( m_fields & FieldAddress ) new Tag( t, "address", m_values.address ); if( m_fields & FieldCity ) new Tag( t, "city", m_values.city ); if( m_fields & FieldState ) new Tag( t, "state", m_values.state ); if( m_fields & FieldZip ) new Tag( t, "zip", m_values.zip ); if( m_fields & FieldPhone ) new Tag( t, "phone", m_values.phone ); if( m_fields & FieldUrl ) new Tag( t, "url", m_values.url ); if( m_fields & FieldDate ) new Tag( t, "date", m_values.date ); if( m_fields & FieldMisc ) new Tag( t, "misc", m_values.misc ); if( m_fields & FieldText ) new Tag( t, "text", m_values.text ); } return t; }
static void sendXhtmlTag(Tag *body, void *data) { Tag *stanzaTag = (Tag*) data; if (body) { Tag *html = new Tag("html"); html->addAttribute("xmlns", "http://jabber.org/protocol/xhtml-im"); body->addAttribute("xmlns", "http://www.w3.org/1999/xhtml"); html->addChild(body); stanzaTag->addChild(html); } Transport::instance()->send(stanzaTag); }
Tag* DataForm::tag() const { if( m_type == FormTypeInvalid ) return 0; Tag *x = new Tag( "x" ); x->addAttribute( "xmlns", XMLNS_X_DATA ); if( !m_title.empty() ) new Tag( x, "title", m_title ); StringList::const_iterator it_i = m_instructions.begin(); for( ; it_i != m_instructions.end(); ++it_i ) new Tag( x, "instructions", (*it_i) ); FieldList::const_iterator it = m_fields.begin(); for( ; it != m_fields.end(); ++it ) { DataFormItem *i = dynamic_cast<DataFormItem*>( (*it) ); if( i ) { x->addChild( i->tag() ); continue; } DataFormReported *r = dynamic_cast<DataFormReported*>( (*it) ); if( r ) { x->addChild( r->tag() ); continue; } x->addChild( (*it)->tag() ); } switch( m_type ) { case FormTypeForm: x->addAttribute( "type", "form" ); break; case FormTypeSubmit: x->addAttribute( "type", "submit" ); break; case FormTypeCancel: x->addAttribute( "type", "cancel" ); break; case FormTypeResult: x->addAttribute( "type", "result" ); break; default: break; } return x; }
Tag* Adhoc::Command::tag() const { if( m_node.empty() ) return 0; Tag* c = new Tag( "command" ); c->setXmlns( XMLNS_ADHOC_COMMANDS ); c->addAttribute( "node", m_node ); if( m_actions != 0 ) { // Multi-stage command response if( m_status != InvalidStatus ) c->addAttribute( "status", statusString( m_status ) ); else c->addAttribute( "status", statusString( Executing ) ); Tag* actions = new Tag( c, "actions" ); if( m_action != InvalidAction ) c->addAttribute( "execute", actionString( m_action ) ); else c->addAttribute( "execute", actionString( Complete ) ); if( ( m_actions & Previous ) == Previous ) new Tag( actions, "prev" ); if( ( m_actions & Next ) == Next ) new Tag( actions, "next" ); if( ( m_actions & Complete ) == Complete ) new Tag( actions, "complete" ); } else { // Single-stage command request/response or Multi-stage command request if( m_action != InvalidAction ) c->addAttribute( "action", actionString( m_action ) ); if( m_status != InvalidStatus ) c->addAttribute( "status", statusString( m_status ) ); } if ( !m_sessionid.empty() ) c->addAttribute( "sessionid", m_sessionid ); if( m_plugin && *m_plugin ) c->addChild( m_plugin->tag() ); NoteList::const_iterator it = m_notes.begin(); for( ; it != m_notes.end(); ++it ) c->addChild( (*it)->tag() ); return c; }
Tag* Forward::tag() const { if( !m_stanza ) return 0; Tag* f = new Tag( "forwarded" ); f->setXmlns( XMLNS_STANZA_FORWARDING ); if( m_delay ) f->addChild( m_delay->tag() ); if( m_stanza ) f->addChild( m_stanza->tag() ); return f; }
void AdhocTag::addBoolean(const std::string &label, const std::string &var, bool value) { if (xdata == NULL) initXData(); Tag *field = new Tag("field"); field->addAttribute("type", "boolean"); field->addAttribute("label", label); field->addAttribute("var", var); if (value) field->addChild(new Tag("value", "1")); else field->addChild(new Tag("value", "0")); xdata->addChild(field); }
void AdhocTag::addListSingle(const std::string &label, const std::string &var, std::list <std::string> &values) { if (xdata == NULL) initXData(); Tag *field = new Tag("field"); field->addAttribute("type", "list-single"); field->addAttribute("label", label); field->addAttribute("var", var); for (std::list<std::string>::iterator it = values.begin(); it != values.end(); it++) { Tag *option = new Tag("option"); option->addChild( new Tag("value", *it) ); field->addChild(option); } xdata->addChild(field); }
ConfigHandler::ConfigHandler(User *user, const std::string &from, const std::string &id) : m_from(from), m_user(user) { setRequestType(CALLER_ADHOC); std::string bare(JID(from).bare()); IQ _response(IQ::Result, from, id); Tag *response = _response.tag(); response->addAttribute("from", Transport::instance()->jid()); AdhocTag *adhocTag = new AdhocTag(Transport::instance()->getId(), "transport_irc_config", "executing"); adhocTag->setAction("complete"); adhocTag->setTitle("IRC Nickserv password configuration"); adhocTag->setInstructions("Choose the server you want to change password for."); std::map <std::string, std::string> values; std::map<std::string, UserRow> users = Transport::instance()->sql()->getUsersByJid(bare); for (std::map<std::string, UserRow>::iterator it = users.begin(); it != users.end(); it++) { std::string server = (*it).second.jid.substr(bare.size()); values[server] = stringOf((*it).second.id); m_userId.push_back(stringOf((*it).second.id)); } adhocTag->addListSingle("IRC server", "irc_server", values); adhocTag->addTextPrivate("New NickServ password", "password"); response->addChild(adhocTag); Transport::instance()->send(response); }
Tag* Message::tag() const { if( m_subtype == Invalid ) return 0; Tag* t = new Tag( "message" ); if( m_to ) t->addAttribute( "to", m_to.full() ); if( m_from ) t->addAttribute( "from", m_from.full() ); if( !m_id.empty() ) t->addAttribute( "id", m_id ); if( !m_timestamp.empty() ) t->addAttribute( "timestamp", m_timestamp ); t->addAttribute( TYPE, typeString( m_subtype ) ); getLangs( m_bodies, m_body, "body", t ); getLangs( m_subjects, m_subject, "subject", t ); getLangs( m_htmls, m_html, "html", t ); if( !m_thread.empty() ) new Tag( t, "thread", m_thread ); StanzaExtensionList::const_iterator it = m_extensionList.begin(); for( ; it != m_extensionList.end(); ++it ) t->addChild( (*it)->tag() ); return t; }
authRequest *SpectrumRosterManager::handleAuthorizationRequest(PurpleAccount *account, const char *remote_user, const char *id, const char *alias, const char *message, gboolean on_list, PurpleAccountRequestAuthorizationCb authorize_cb, PurpleAccountRequestAuthorizationCb deny_cb, void *user_data) { std::string name(remote_user); authRequest *req = new authRequest; req->authorize_cb = authorize_cb; req->deny_cb = deny_cb; req->user_data = user_data; req->account = m_user->account(); req->who = name; req->mainJID = m_user->jid(); m_authRequests[name] = req; Log(m_user->jid(), "purpleAuthorizeReceived: " << name << "on_list:" << on_list); // std::for_each( name.begin(), name.end(), replaceBadJidCharacters() ); if (Transport::instance()->getConfiguration().jid_escaping) { name = JID::escapeNode(name); } else { std::for_each( name.begin(), name.end(), replaceBadJidCharacters() ); } // send subscribe presence to user Tag *tag = new Tag("presence"); tag->addAttribute("type", "subscribe" ); tag->addAttribute("from", name + "@" + Transport::instance()->jid()); tag->addAttribute("to", m_user->jid()); if (alias) { Tag *nick = new Tag("nick", std::string(alias)); nick->addAttribute("xmlns","http://jabber.org/protocol/nick"); tag->addChild(nick); } Transport::instance()->send(tag); return req; }
const std::string SIProfileFT::requestFT( const JID& to, const std::string& name, long size, const std::string& hash, const std::string& desc, const std::string& date, const std::string& mimetype, int streamTypes ) { if( name.empty() || size <= 0 || !m_manager ) return EmptyString; Tag* file = new Tag( "file", XMLNS, XMLNS_SI_FT ); file->addAttribute( "name", name ); file->addAttribute( "size", size ); if( !hash.empty() ) file->addAttribute( "hash", hash ); if( !date.empty() ) file->addAttribute( "date", date ); if( !desc.empty() ) new Tag( file, "desc", desc ); if( m_ranged ) new Tag( file, "range" ); Tag* feature = new Tag( "feature", XMLNS, XMLNS_FEATURE_NEG ); DataForm df( TypeForm ); DataFormField* dff = df.addField( DataFormField::TypeListSingle, "stream-method" ); StringMap sm; if( streamTypes & FTTypeS5B ) sm["s5b"] = XMLNS_BYTESTREAMS; if( streamTypes & FTTypeIBB ) sm["ibb"] = XMLNS_IBB; if( streamTypes & FTTypeOOB ) sm["oob"] = XMLNS_IQ_OOB; dff->setOptions( sm ); feature->addChild( df.tag() ); return m_manager->requestSI( this, to, XMLNS_SI_FT, file, feature, mimetype ); }
void CapabilityHandlerTest::handleDiscoInfoBadIdentity() { int context = m_handler->waitForCapabilities("http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0=", "[email protected]/psi"); CPPUNIT_ASSERT (m_handler->hasVersion(context)); Tag *query = new Tag("query"); query->addAttribute("xmlns", "http://jabber.org/protocol/disco#info"); query->addAttribute("node", "http://code.google.com/p/exodus#QgayPKawpkPSDYmwT/WM94uAlu0="); Tag *identity = new Tag("identity"); identity->addAttribute("category", "not-client"); identity->addAttribute("name", "Exodus 0.9.1"); identity->addAttribute("type", "pc"); query->addChild(identity); m_user->setConnected(false); m_user->setReadyForConnect(true); m_user->setResource("psi", 50, 0); m_handler->handleDiscoInfo(JID("[email protected]/psi"), query, context); CPPUNIT_ASSERT (m_user->isConnected() == false); CPPUNIT_ASSERT (m_user->hasFeature(GLOOX_FEATURE_ROSTERX, "psi") == false); CPPUNIT_ASSERT (m_user->hasFeature(GLOOX_FEATURE_FILETRANSFER, "psi") == false); CPPUNIT_ASSERT (m_user->hasFeature(GLOOX_FEATURE_CHATSTATES, "psi") == false); CPPUNIT_ASSERT (m_user->hasFeature(GLOOX_FEATURE_XHTML_IM, "psi") == false); }
Tag* Presence::tag() const { if( m_subtype == Invalid ) return 0; Tag* t = new Tag( "presence" ); if( m_to ) t->addAttribute( "to", m_to.full() ); if( m_from ) t->addAttribute( "from", m_from.full() ); const std::string& type = typeString( m_subtype ); if( !type.empty() ) { if( type != "available" ) t->addAttribute( "type", type ); } else { const std::string& show = showString( m_subtype ); if( !show.empty() ) new Tag( t, "show", show ); } new Tag( t, "priority", util::int2string( m_priority ) ); getLangs( m_stati, m_status, "status", t ); StanzaExtensionList::const_iterator it = m_extensionList.begin(); for( ; it != m_extensionList.end(); ++it ) t->addChild( (*it)->tag() ); return t; }
Tag * AdhocTag::generateResponse(const std::string &action) { IQ _response(IQ::Result, m_from, m_id); _response.setFrom(Transport::instance()->jid()); Tag *response = _response.tag(); if (action != "") { response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), action) ); return response; } if (hasAttribute("action", "cancel")) response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "canceled") ); else response->addChild( new AdhocTag(findAttribute("sessionid"), findAttribute("node"), "completed") ); return response; }
Tag* PrivateXML::Query::tag() const { Tag* t = new Tag( "query" ); t->setXmlns( XMLNS_PRIVATE_XML ); if( m_privateXML ) t->addChild( m_privateXML->clone() ); return t; }
virtual void handleMessage( const Message& msg, MessageSession * /*session*/ ) { printf( "type: %d, subject: %s, message: %s, thread id: %s\n", msg.subtype(), msg.subject().c_str(), msg.body().c_str(), msg.thread().c_str() ); Tag *m = new Tag( "message" ); m->addAttribute( "from", j->jid().full() ); m->addAttribute( "to", msg.from().full() ); m->addAttribute( "type", "chat" ); Tag *b = new Tag( "body", "You said:\n> " + msg.body() + "\nI like that statement." ); m->addChild( b ); if( !msg.subject().empty() ) { Tag *s = new Tag( "subject", "Re:" + msg.subject() ); m->addChild( s ); } j->send( m ); }
Tag* IOData::tag() const { if( m_type == TypeInvalid ) return 0; Tag* i = new Tag( "iodata" ); i->setXmlns( XMLNS_IODATA ); i->addAttribute( "type", util::lookup( m_type, ioTypes ) ); Tag* t = 0; switch( m_type ) { case TypeInput: i->addChild( m_in ); break; case TypeIoSchemataResult: i->addChild( m_in ); i->addChild( m_out ); new Tag( i, "desc", m_desc ); break; case TypeOutput: i->addChild( m_out ); break; case TypeError: i->addChild( m_error ); break; case TypeStatus: t = new Tag( i, "status" ); if( m_status.elapsed >= 0 ) new Tag( t, "elapsed", util::int2string( m_status.elapsed ) ); if( m_status.remaining >= 0 ) new Tag( t, "remaining", util::int2string( m_status.remaining ) ); if( m_status.percentage >= 0 ) new Tag( t, "percentage", util::int2string( m_status.percentage ) ); if( m_status.info.length() ) new Tag( t, "information", m_status.info ); break; case TypeIoSchemataGet: case TypeGetStatus: case TypeGetOutput: default: break; } return i; }
Tag* XmppGSAuth_User::tag() const { Tag* i = new Tag( "gsiot" ); i->setXmlns( XMLNS_GSIOT_AUTHORITY_USER ); i->addChild( this->tagAuth_base(false) ); return i; }
Tag* XmppGSAuth::tag() const { Tag* i = new Tag( "gsiot" ); i->setXmlns( XMLNS_GSIOT_AUTHORITY ); i->addChild( this->tagAuth_base(m_isSet) ); return i; }
void SpectrumMUCConversation::sendTopic(AbstractUser *user) { Tag *m = new Tag("message"); m->addAttribute("from", m_jid + "/" + m_topicUser); m->addAttribute("to", user->jid() + m_res); m->addAttribute("type", "groupchat"); m->addChild( new Tag("subject", m_topic) ); Transport::instance()->send(m); }
Tag* Item::tag() const { Tag* t = new Tag( "item" ); t->addAttribute( "id", m_id ); if( m_payload ) t->addChild( m_payload->clone() ); return t; }
void GlooxRegisterHandler::sendError(int code, const std::string &err, const Tag *iqTag) { Tag *iq = new Tag("iq"); iq->addAttribute("type", "error"); iq->addAttribute("from", Transport::instance()->jid()); iq->addAttribute("to", iqTag->findAttribute("from")); iq->addAttribute("id", iqTag->findAttribute("id")); Tag *error = new Tag("error"); error->addAttribute("code", code); error->addAttribute("type", "modify"); Tag *bad = new Tag(err); bad->addAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas"); error->addChild(bad); iq->addChild(error); Transport::instance()->send(iq); }
void AdhocTag::addFixedText(const std::string &text) { if (xdata == NULL) initXData(); Tag *field = new Tag("field"); field->addAttribute("type", "fixed"); field->addChild(new Tag("value", text)); xdata->addChild(field); }
Tag* DataFormItem::tag() const { Tag* i = new Tag ( "item" ); DataFormFieldContainer::FieldList::const_iterator it = m_fields.begin(); for( ; it != m_fields.end(); ++it ) { i->addChild( (*it)->tag() ); } return i; }
Tag* DataFormReported::tag() const { Tag* r = new Tag ( "reported" ); DataFormFieldContainer::FieldList::const_iterator it = m_fields.begin(); for( ; it != m_fields.end(); ++it ) { r->addChild( (*it)->tag() ); } return r; }
virtual void handlePrivateXML( const std::string& /*tag*/, Tag */*xml*/ ) { printf( "received privatexml...\n" ); Tag *x = new Tag( "test" ); x->addAttribute( "xmlns", "http://camaya.net/jabber/test" ); std::string id = j->getID(); Tag *b = new Tag( "blah", id ); x->addChild( b ); p->storeXML( x, this ); };