void CreateDiscussionsHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			universal_resource error_desc;
			ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			error_desc = XL("biz.CreateDiscussions.fail");

			callback_(true, error_desc, jobj);
		}else{
			if(iq.findExtension(kExtUser_iq_filter_creatediscussions))
			{
				boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_creatediscussions)->tag());
				if (tag)
				{
					gloox::Tag* tag2 = tag->findChild("item");
					if (tag)
					{
						jobj["session_id"] = gWrapInterface::instance().append_discussions_domain(tag2->findAttribute("id"));
						jobj["group_name"] = tag2->findAttribute("topic");

						callback_(false,XL(""),jobj);
						return;
					}
				}
			}
			ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			callback_(true, XL("biz.CreateDiscussions.fail"), jobj);
		}
	}
Example #2
0
  void Client::processResourceBind( const IQ& iq )
  {
    switch( iq.subtype() )
    {
      case IQ::Result:
      {
        const ResourceBind* rb = iq.findExtension<ResourceBind>( ExtResourceBind );
        if( !rb || !rb->jid() )
        {
          notifyOnResourceBindError( 0 );
          break;
        }

        m_jid = rb->jid();
        m_resourceBound = true;
        m_selectedResource = m_jid.resource();
        notifyOnResourceBind( m_jid.resource() );

        if( m_streamFeatures & StreamFeatureSession )
          createSession();
        else
          connected();
        break;
      }
      case IQ::Error:
      {
        notifyOnResourceBindError( iq.error() );
        break;
      }
      default:
        break;
    }
  }
Example #3
0
  void RosterManager::handleIqID( const IQ& iq, int context )
  {
    if( iq.subtype() == IQ::Result ) // initial roster
    {
      const Query* q = iq.findExtension<Query>( ExtRoster );
      if( q )
        mergeRoster( q->roster() );

      if( context == RequestRoster )
      {
        if( m_parent )
          m_parent->rosterFilled();

        if( m_rosterListener )
          m_rosterListener->handleRoster( m_roster );
      }
    }
    else if( iq.subtype() == IQ::Error )
    {
      if( context == RequestRoster && m_parent )
        m_parent->rosterFilled();

      if( m_rosterListener )
        m_rosterListener->handleRosterError( iq );
    }
  }
Example #4
0
    bool Session::handleIq( const IQ& iq )
    {
      const Jingle* j = iq.findExtension<Jingle>( ExtJingle );
      if( !j || j->sid() != m_sid || !m_handler || !m_parent )
        return false;

      switch( j->action() )
      {
        case SessionAccept:
          m_state = Active;
          m_responder = j->responder();
          break;
        case SessionInitiate:
          m_state = Pending;
          m_initiator = j->initiator();
          if( !m_responder )
            m_responder = m_parent->jid();
          break;
        case SessionTerminate:
          m_state = Ended;
          break;
        default:
          break;
      }

      IQ re( IQ::Result, iq.from(), iq.id() );
      m_parent->send( re );

      m_handler->handleSessionAction( j->action(), this, j );

      return true;
    }
Example #5
0
void TestInitiator::send( IQ& iq, IqHandler*, int ctx )
{
  m_result = false;
  iq.setFrom( JID( "self" ) );
  Tag* t = iq.tag();
  std::string expected;

//   printf( "TestInitiator: test %d: %s\n", m_test, t->xml().c_str() );

  switch( m_test )
  {
    case 1:
    {
      expected = "<iq to='foo@bar' from='self' id='id' type='set'><jingle xmlns='" + XMLNS_JINGLE + "' action='session-initiate' initiator='notself' sid='somesid'/></iq>";
      if( t->xml() == expected )
        m_result = true;
      else
        fprintf( stderr, "Jingle::Session test %d\nHave:     %s\nExpected: %s\n", m_test, t->xml().c_str(), expected.c_str() );
      res->sm()->handleIq( iq );
      break;
    }
  }

  delete t;
}
	bool CreateDiscussionsHandler::handleIq( const IQ& iq )
	{
		if(iq.findExtension(kExtUser_iq_filter_creatediscussions))
		{
			boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_creatediscussions)->tag());
			if (tag)
			{
				gloox::Tag* tag2 = tag->findChild("item");
				if (tag2)
				{
					json::jobject jobj;
					jobj["type"] = "add";
					json::jobject group;
					group["session_id"] = gWrapInterface::instance().append_discussions_domain(tag2->findAttribute("id"));
					group["group_name"] =  tag2->findAttribute("topic");
					jobj["group_info"].arr_push(group);
					gWrapInterface::instance().discussions_list_change(jobj);
					return true;
				}
			}
		}

		ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
		return false;
	}
Example #7
0
  void FlexibleOffline::handleIqID( const IQ& iq, int context )
  {
    if( !m_flexibleOfflineHandler )
      return;

    switch( context )
    {
      case FORequestMsgs:
        switch( iq.subtype() )
        {
          case IQ::Result:
            m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrRequestSuccess );
            break;
          case IQ::Error:
            switch( iq.error()->error() )
            {
              case StanzaErrorForbidden:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrForbidden );
                break;
              case StanzaErrorItemNotFound:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrItemNotFound );
                break;
              default:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrUnknownError );
                break;
            }
            break;
          default:
            break;
        }
        break;
      case FORemoveMsgs:
        switch( iq.subtype() )
        {
          case IQ::Result:
            m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrRemoveSuccess );
            break;
          case IQ::Error:
            switch( iq.error()->error() )
            {
              case StanzaErrorForbidden:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrForbidden );
                break;
              case StanzaErrorItemNotFound:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrItemNotFound );
                break;
              default:
                m_flexibleOfflineHandler->handleFlexibleOfflineResult( FomrUnknownError );
                break;
            }
            break;
          default:
            break;
        }
        break;
    }
  }
Example #8
0
  void NonSaslAuth::handleIqID( const IQ& iq, int context )
  {
    switch( iq.subtype() )
    {
      case IQ::Error:
      {
        const Error* e = iq.error();
        if( e )
        {
          switch( e->error() )
          {
            case StanzaErrorConflict:
              m_parent->setAuthFailure( NonSaslConflict );
              break;
            case StanzaErrorNotAcceptable:
              m_parent->setAuthFailure( NonSaslNotAcceptable );
              break;
            case StanzaErrorNotAuthorized:
              m_parent->setAuthFailure( NonSaslNotAuthorized );
              break;
            default:
              break;
          }
        }
        m_parent->setAuthed( false );
        m_parent->disconnect( ConnAuthenticationFailed );
        break;
      }
      case IQ::Result:
        switch( context )
        {
          case TrackRequestAuthFields:
          {
            const Query* q = iq.findExtension<Query>( ExtNonSaslAuth );
            if( !q )
              return;

            const std::string& id = m_parent->getID();

            IQ re( IQ::Set, JID(), id );
            re.addExtension( q->newInstance( m_parent->username(), m_sid,
                                             m_parent->password(),
                                             m_parent->jid().resource() ) );
            m_parent->send( re, this, TrackSendAuth );
            break;
          }
          case TrackSendAuth:
            m_parent->setAuthed( true );
            m_parent->connected();
            break;
        }
        break;

      default:
        break;
    }
  }
Example #9
0
int main() {
	const map<string, constants> comands = { { "add", constants::add },{ "get", constants::get },{ "del", constants::del } };

	wstring libName;
	wcin >> libName;
	LPCWSTR wLibName = libName.c_str();
	HINSTANCE lib = LoadLibrary(wLibName);
	if (!lib) {
		cout << "Library not found" << endl;
		return 0;
	}
	int n;
	cin >> n;
	string line, word;
	IQ<> *(*getQueue)() = (IQ<> *(*)())GetProcAddress(lib, "GetSomeIQ");
	if (!getQueue)
		return 0;
	IQ<> *pQueue = getQueue();
	if (!pQueue)
		return 0;
	cin.get();
	for (int i = 0; i < n; ++i) {
		getline(cin, line);
		istringstream ss(line);
		ss >> word;
		try {
			switch (comands.at(word)) {
			case constants::add:
				int value;
				ss >> value;
				pQueue->push(value);
				break;
			case constants::get:
				try {
					cout << pQueue->top() << endl;
				}
				catch (...) {
					cout << "Queue is empty" << endl;
				}
				break;
			case constants::del:
				pQueue->pop();
				break;
			}
		}
		catch (...) {
			cout << "Unknown command" << endl;
		}
	}
	FreeLibrary(lib);
	system("pause");
	return 0;
}
Example #10
0
  bool PrivacyManager::handleIq( const IQ& iq )
  {
    const Query* q = iq.findExtension<Query>( ExtPrivacy );
    if( iq.subtype() != IQ::Set || !m_privacyListHandler
        || !q || q->name().empty() )
      return false;

    m_privacyListHandler->handlePrivacyListChanged( q->name() );
    IQ re( IQ::Result, JID(), iq.id() );
    m_parent->send( re );
    return true;
  }
Example #11
0
  bool LastActivity::handleIq( const IQ& iq )
  {
    const Query* q = iq.findExtension<Query>( ExtLastActivity );
    if( !q || iq.subtype() != IQ::Get )
      return false;

    IQ re( IQ::Result, iq.from(), iq.id() );
    re.addExtension( new Query( EmptyString, (long)( time( 0 ) - m_active ) ) );
    m_parent->send( re );

    return true;
  }
Example #12
0
void TestInitiator::send( const IQ& iq )
{
//   printf( "TestInitiator::senD(IQ): %s\n", iq.tag()->xml().c_str() );
  m_result2 = false;

  switch( m_test )
  {
    case 2:
    case 3:
      if( iq.subtype() == IQ::Result && iq.to().full() == "foo@bar" )
        m_result2 = true;
      break;
  }
}
Example #13
0
 void Client::processCreateSession( const IQ& iq )
 {
   switch( iq.subtype() )
   {
     case IQ::Result:
       connected();
       break;
     case IQ::Error:
       notifyOnSessionCreateError( iq.error() );
       break;
     default:
       break;
   }
 }
Example #14
0
  bool RosterManager::handleIq( const IQ& iq )
  {
    if( iq.subtype() != IQ::Set ) // FIXME add checks for 'from' attribute (empty or bare self jid?)
      return false;

    // single roster item push
    const Query* q = iq.findExtension<Query>( ExtRoster );
    if( q && q->roster().size() )
      mergePush( q->roster() );

    IQ re( IQ::Result, JID(), iq.id() );
    m_parent->send( re );
    return true;
  }
Example #15
0
void TestResponder::send( const IQ& iq )
{
  m_result2 = false;
//   printf( "TestResponder::senD(IQ): %s\n", iq.tag()->xml().c_str() );

  switch( m_test )
  {
    case 1:
      if( iq.subtype() == IQ::Result && iq.to().full() == "self" )
      {
//         printf( "m_result2 = true;\n" );
        m_result2 = true;
      }
      break;
  }
}
Example #16
0
  void VCardManager::fetchVCard( const JID& jid, VCardHandler* vch )
  {
    if( !m_parent || !vch )
      return;

    TrackMap::const_iterator it = m_trackMap.find( jid.bare() );
    if( it != m_trackMap.end() )
      return;

    const std::string& id = m_parent->getID();
    IQ iq ( IQ::Get, jid, id );
    iq.addExtension( new VCard() );

    m_trackMap[id] = vch;
    m_parent->send( iq, this,VCardHandler::FetchVCard  );
  }
	void GroupsAdminManageMemberHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				callback_(true,XL("biz.GroupsAdminManageMember.fail"));
				return;
			}
			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"));
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"));
			}
			else if (e->error() == StanzaErrorGone)
			{
				universal_resource err;
				err.res_key="biz.crwod.iq_error.answer_apply_gone";
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,消息已过期!"));
				callback_(false,err);
			}
			else if (e->error() == StanzaErrorForbidden)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,自己不是管理员"));
				callback_(true,XL("biz.crwod.iq_error.admin_forbidden"));
			}			
			else if (e->error() == StanzaErrorResourceConstraint)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,群成员已经满"));
				callback_(true,XL("biz.crwod.iq_error.admin_resource-constraint"));
			}
			else if (e->error() == StanzaErrorConflict)
			{
				universal_resource err;
				err.res_key="biz.crwod.iq_error.admin_Conflict";
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,该成员已加入群"));
				callback_(false,err);
			}
			else if (e->error() == StanzaErrorItemNotFound)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,找不到此群。"));
				callback_(true,XL("biz.crwod.iq_error.item-not-found"));
			}else
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.GroupsAdminManageMember.fail"));
			}

		}else{
			callback_(false,XL(""));		
		}
	}
	/*
	 <iq type=’result’from=’[email protected]’ to=’[email protected]’>
	 <queryxmlns=’groups:share:file:delete’>
	 <item id=‘2’ />
	 </query>
	 </iq>
	*/
	void InviteIntoGroupsHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.InviteIntoGroups.fail"));
				return;
			}

			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"));
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"));
			}
			else if (e->error() == StanzaErrorConflict)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,被邀请人已经在群里。"));
				callback_(true,XL("biz.crwod.iq_error.invite_conflict"));
			}
			else if (e->error() == StanzaErrorResourceConstraint)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,群已经满员。"));
				callback_(true,XL("biz.crwod.iq_error.invite_resource-constraint"));
			}
			else if (e->error() == StanzaErrorNotAllowed)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,邀请人不是管理员。"));
				callback_(true,XL("biz.crwod.iq_error.invite_not-allowed"));
			}else
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.InviteIntoGroups.fail"));
			}
		}else{
			callback_(false,XL(""));
		}
	}
Example #19
0
bool GlooxRegisterHandler::handleIq(const IQ &iq) {
	Tag *iqTag = iq.tag();
	if (!iqTag) return true;

	bool ret = handleIq(iqTag);
	delete iqTag;
	return ret;
}
Example #20
0
void Search::handleIqID( const IQ& iq, int context )
{
    TrackMap::iterator it = m_track.find( iq.id() );
    if( it != m_track.end() )
    {
        switch( iq.subtype() )
        {
        case IQ::Result:
        {
            const Query* q = iq.findExtension<Query>( ExtSearch );
            if( !q )
                return;

            switch( context )
            {
            case FetchSearchFields:
            {
                if( q->form() )
                {
                    (*it).second->handleSearchFields( iq.from(), q->form() );
                }
                else
                {
                    (*it).second->handleSearchFields( iq.from(), q->fields(), q->instructions() );
                }
                break;
            }
            case DoSearch:
            {
                if( q->form() )
                {
                    (*it).second->handleSearchResult( iq.from(), q->form() );
                }
                else
                {
                    (*it).second->handleSearchResult( iq.from(), q->result() );
                }
                break;
            }
            }
            break;
        }
        case IQ::Error:
            (*it).second->handleSearchError( iq.from(), iq.error() );
            break;

        default:
            break;
        }

        m_track.erase( it );
    }

    return;
}
Example #21
0
  void SIManager::handleIqID( const IQ& iq, int context )
  {
    switch( iq.subtype() )
    {
      case IQ::Result:
        if( context == OfferSI )
        {
          TrackMap::iterator it = m_track.find( iq.id() );
          if( it != m_track.end() )
          {
            const SI* si = iq.findExtension<SI>( ExtSI );
            if( !si /*|| si->profile().empty()*/ )
              return;

//             Tag* si = iq.query();
//             Tag* ptag = 0;
//             Tag* fneg = 0;
//             if( si && si->name() == "si" && si->xmlns() == XMLNS_SI )
//             {
//               ptag = si->findChildWithAttrib( XMLNS, (*it).second.profile );
//               fneg = si->findChild( "feature", XMLNS, XMLNS_FEATURE_NEG );
//             }

            // FIXME: remove above commented code and
            // check corectness of last 3 params!
            (*it).second.sih->handleSIRequestResult( iq.from(), iq.to(), (*it).second.sid, *si );
            m_track.erase( it );
          }
        }
        break;
      case IQ::Error:
        if( context == OfferSI )
        {
          TrackMap::iterator it = m_track.find( iq.id() );
          if( it != m_track.end() )
          {
            (*it).second.sih->handleSIRequestError( iq, (*it).second.sid );
            m_track.erase( it );
          }
        }
        break;
      default:
        break;
    }
  }
Example #22
0
AdhocTag::AdhocTag(const IQ &stanza) : Tag("command") {
    m_from = stanza.from().full();
    m_id = stanza.id();
    xdata = NULL;
    Tag *iq = stanza.tag();
    Tag *command = iq->findChild("command");
    if (command) {
        const Tag::AttributeList & attributes = command->attributes();
        for (Tag::AttributeList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
            addAttribute(std::string((*it)->name()), std::string((*it)->value()));
        }
        Tag *x = command->findChildWithAttrib("xmlns","jabber:x:data");
        if (x) {
            xdata = x->clone();
            addChild(xdata);
        }
    }
    delete iq;
}
Example #23
0
  bool SIManager::handleIq( const IQ& iq )
  {
    TrackMap::iterator itt = m_track.find( iq.id() );
    if( itt != m_track.end() )
      return false;

    const SI* si = iq.findExtension<SI>( ExtSI );
    if( !si || si->profile().empty() )
      return false;

    HandlerMap::const_iterator it = m_handlers.find( si->profile() );
    if( it != m_handlers.end() && (*it).second )
    {
      (*it).second->handleSIRequest( iq.from(), iq.to(), iq.id(), *si );
      return true;
    }

    return false;
  }
Example #24
0
  bool Adhoc::handleIq( const IQ& iq )
  {
    if( iq.subtype() != IQ::Set )
      return false;

    const Adhoc::Command* ac = iq.findExtension<Adhoc::Command>( ExtAdhocCommand );
    if( !ac || ac->node().empty())
      return false;

    AdhocCommandProviderMap::const_iterator it = m_adhocCommandProviders.find( ac->node() );
    if( it != m_adhocCommandProviders.end() )
    {
      const std::string& sess = ac->sessionID().empty() ? m_parent->getID() : ac->sessionID();
      m_activeSessions[sess] = iq.id();
      (*it).second->handleAdhocCommand( iq.from(), *ac, sess );
      return true;
    }

    return false;
  }
Example #25
0
 void ClientBase::send( IQ& iq, IqHandler*, int )
 {
   Tag* tag = iq.tag();
   switch( m_test )
   {
     case 1:
     {
       break;
     }
   }
   delete tag;
 }
Example #26
0
  void ClientBase::send( IQ& iq, IqHandler* ih, int ctx )
  {
    const PrivateXML::Query* q = iq.findExtension<PrivateXML::Query>( ExtPrivateXML );
    if( !q )
      return;

    Tag* tag = q->tag();
    switch( m_test )
    {
      case 1:
      {
        if( iq.subtype() == IQ::Set
            && tag && *(tag->findChild( "foo", "xmlns", "test" )) == *t1 )
        {
          IQ re( IQ::Result, iq.from(), iq.id() );
          re.addExtension( new PrivateXML::Query() );
          ih->handleIqID( re, ctx );
        }
        break;
      }
      case 2:
      {
        if( iq.subtype() == IQ::Get
            && tag && tag->hasChild( "foo", "xmlns", "test" ) )
        {
          IQ re( IQ::Result, iq.from(), iq.id() );
          re.addExtension( new PrivateXML::Query( t1->clone() ) );
          ih->handleIqID( re, ctx );
        }
        break;
      }
    }
    delete tag;
  }
Example #27
0
  void Adhoc::handleIqID( const IQ& iq, int context )
  {
    if( context != ExecuteAdhocCommand )
      return;

    m_adhocTrackMapMutex.lock();
    AdhocTrackMap::iterator it = m_adhocTrackMap.find( iq.id() );
    bool haveIdHandler = ( it != m_adhocTrackMap.end() );
    m_adhocTrackMapMutex.unlock();
    if( !haveIdHandler || (*it).second.context != context
        || (*it).second.remote != iq.from() )
      return;

    switch( iq.subtype() )
    {
      case IQ::Error:
        (*it).second.ah->handleAdhocError( iq.from(), iq.error(), (*it).second.handlerContext );
        break;
      case IQ::Result:
      {
        const Adhoc::Command* ac = iq.findExtension<Adhoc::Command>( ExtAdhocCommand );
        if( ac )
          (*it).second.ah->handleAdhocExecutionResult( iq.from(), *ac, (*it).second.handlerContext );
        break;
      }
      default:
        break;
    }
    m_adhocTrackMapMutex.lock();
    m_adhocTrackMap.erase( it );
    m_adhocTrackMapMutex.unlock();
  }
Example #28
0
  void PrivateXML::handleIqID( const IQ& iq, int context )
  {
    TrackMap::iterator t = m_track.find( iq.id() );
    if( t == m_track.end() )
      return;

    if( iq.subtype() == IQ::Result )
    {
      if( context == RequestXml )
      {
        const Query* q = iq.findExtension<Query>( ExtPrivateXML );
        if( q )
          (*t).second->handlePrivateXML( q->privateXML() );
      }
      else if( context == StoreXml )
        (*t).second->handlePrivateXMLResult( iq.id(), PrivateXMLHandler::PxmlStoreOk );
    }
    else if( iq.subtype() == IQ::Error )
    {
      if( context == RequestXml )
        (*t).second->handlePrivateXMLResult( iq.id(), PrivateXMLHandler::PxmlRequestError );
      else if( context == StoreXml )
        (*t).second->handlePrivateXMLResult( iq.id(), PrivateXMLHandler::PxmlStoreError );
    }

    m_track.erase( t );
  }
 void ClientBase::send( const IQ& iq, IqHandler*, int )
 {
   tag = iq.tag();
   if( !tag || tag->xml() != testValues[m_context][1] )
   {
     printf( "test failed: %s\n", testValues[m_context][0].c_str() );
     printf( "- %s\n", testValues[m_context][1].c_str() );
     if( tag )
       printf( "- %s\n", tag->xml().c_str() );
     ++failed;
   }
   delete tag;
 }
void SOCKS5BytestreamManager::acknowledgeStreamHost( bool success, const JID& jid,
        const std::string& sid )
{
    AsyncTrackMap::const_iterator it = m_asyncTrackMap.find( sid );
    if( it == m_asyncTrackMap.end() || !m_parent )
        return;

    const AsyncS5BItem& item = (*it).second;

    IQ* iq = 0;

    if( item.incoming )
    {
        iq = new IQ( IQ::Result, item.from.full(), item.id );
        if( item.to )
            iq->setFrom( item.to );

        if( success )
            iq->addExtension( new Query( jid, sid, false ) );
        else
            iq->addExtension( new Error( StanzaErrorTypeCancel, StanzaErrorItemNotFound ) );

        m_parent->send( *iq );
    }
    else
    {
        if( success )
        {
            const std::string& id = m_parent->getID();
            iq = new IQ( IQ::Set, jid.full(), id );
            iq->addExtension( new Query( item.from, sid, true ) );

            m_trackMap[id] = sid;
            m_parent->send( *iq, this, S5BActivateStream );
        }
    }

    delete iq;
}