本文整理汇总了C++中IQ类的典型用法代码示例。如果您正苦于以下问题:C++ IQ类的具体用法?C++ IQ怎么用?C++ IQ使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IQ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleIqID
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);
}
}
示例2: switch
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;
}
}
示例3: mergeRoster
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 );
}
}
示例4: switch
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;
}
示例5: send
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='[email protected]' 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;
}
示例6: handleIq
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;
}
示例7: switch
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;
}
}
示例8: switch
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;
}
}
示例9: main
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;
}
示例10: re
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;
}
示例11: re
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;
}
示例12: switch
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() == "[email protected]" )
m_result2 = true;
break;
}
}
示例13: mergePush
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;
}
示例14: iq
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 );
}
示例15: handleIqID
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(""));
}
}