本文整理汇总了C++中JID::resource方法的典型用法代码示例。如果您正苦于以下问题:C++ JID::resource方法的具体用法?C++ JID::resource怎么用?C++ JID::resource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JID
的用法示例。
在下文中一共展示了JID::resource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makePurpleUsernameRoom
void IRCProtocol::makePurpleUsernameRoom(User *user, const JID &to, std::string &name) {
std::string username = to.username();
// "#pidgin%[email protected]/HanzZ" -> "HanzZ"
if (!to.resource().empty() && to.resource() != "bot") {
username = to.resource();
}
// "hanzz%[email protected]/bot" -> "hanzz"
else if (to.resource() == "bot") {
size_t pos = username.find("%");
if (pos != std::string::npos)
username.erase((int) pos, username.length() - (int) pos);
}
// "#pidgin%[email protected]" -> #pidgin
else {
size_t pos = username.find("%");
if (pos != std::string::npos)
username.erase((int) pos, username.length() - (int) pos);
}
std::for_each( username.begin(), username.end(), replaceJidCharacters() );
name.assign(username);
}
示例2: handleDiscoInfo
void jConference::handleDiscoInfo(const JID &from, const Disco::Info &info, int /*context*/)
{
QString bare = utils::fromStd(from.bare());
QString resource = utils::fromStd(from.resource());
if(Room *room = m_rooms.value(bare))
{
QHash<QString,MucContact> &contacts = room->contacts_list;
if(!contacts.contains(resource))
return;
jBuddy::ResourceInfo &resource_info = contacts[resource].m_info;
jClientIdentification::instance().newInfo(info, &resource_info);
}
}
示例3: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
JID j;
// -------
name = "bare JID ctor";
j = JID( "[email protected]" );
if( j.bare() != "[email protected]" || j.username() != "abc" || j.server() != "server.dom" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "full JID ctor";
j = JID( "[email protected]/res" );
if( j.full() != "[email protected]/res" || j.username() != "abc" || j.server() != "server.dom"
|| j.resource() != "res" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "server + resource ctor";
j = JID( "server.dom/res" );
if( j.full() != "server.dom/res" || j.server() != "server.dom" || j.resource() != "res" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "server ctor";
j = JID( "server.dom" );
if( j.full() != "server.dom" || j.server() != "server.dom" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "prepped node";
j = JID( "[email protected]" );
if( j.bare() != "[email protected]" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "prepped dom";
j = JID( "[email protected]" );
if( j.bare() != "[email protected]" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "resource getter";
j = JID( "[email protected]/rEsOurCe" );
if( j.resource() != "rEsOurCe" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "node getter";
j = JID( "[email protected]/rEsOurCe" );
if( j.username() != "abc" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "server getter";
j = JID( "[email protected]/rEsOurCe" );
if( j.server() != "server.dom" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "bare JID getter";
j = JID( "[email protected]/rEsOurCe" );
JID t1( "[email protected]/rEsOurCe");
if( j.bareJID() != t1.bareJID() )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "clear jid";
//.........这里部分代码省略.........