当前位置: 首页>>代码示例>>C++>>正文


C++ JID::username方法代码示例

本文整理汇总了C++中JID::username方法的典型用法代码示例。如果您正苦于以下问题:C++ JID::username方法的具体用法?C++ JID::username怎么用?C++ JID::username使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JID的用法示例。


在下文中一共展示了JID::username方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleFTRequest

void XmppFileTransfer::handleFTRequest( const JID& from, const std::string& id, const std::string& sid,
	const std::string& name, long size, const std::string& hash,
	const std::string& date, const std::string& mimetype,
	const std::string& desc, int /*stypes*/, long /*offset*/, long /*length*/ )
{
	std::string filePath;
	if(ftListener && ftListener->RecvFileTransferRequest(from.server(), from.username(), sid, name, size, hash, date, mimetype, desc, filePath))
	{
		FileInformation fi;
		fi.filename = name;
		fi.filepath = filePath;
		fi.ansifilename = Utf8ToAnsi(name.c_str());
		fi.ansifilepath = Utf8ToAnsi(filePath.c_str());
		fi.filesize = size;
		fi.handedsize = 0;
		fi.type = 2;
		fi.SOCKstream = NULL;
		fi.ftListener = ftListener;
		fileList.insert(std::make_pair(sid, fi));

		f->acceptFT( from, id, SIProfileFT::FTTypeS5B );
	}
	else
		f->declineFT(from, sid, SIManager::RequestRejected);
}
开发者ID:wuyingfengsui,项目名称:V6Chat,代码行数:25,代码来源:XmppFileTransfer.cpp

示例2: 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);
}
开发者ID:hanzz,项目名称:spectrum,代码行数:21,代码来源:irc.cpp

示例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";
//.........这里部分代码省略.........
开发者ID:PeterXu,项目名称:sipstack,代码行数:101,代码来源:jid_test.cpp

示例4: handleVCard

void TalkCard::handleVCard(const JID & jid, const VCard * vcard)
{
        if (!vcard) {
                DLOG("empty %s's vcard!\n", jid.full().c_str());
                return ;
        }

        Bodies& bodies = Bodies::Get_Bodies();
        const JID& myjid = bodies.get_jid();

        char *random =
                g_strdup_printf("%x", g_random_int());
        const char *dirname = GUnit::getIconPath();
        char *filename =
                g_build_filename(dirname, random, NULL);
        int f_size;
        int n_size;

        struct stat f_stat;
        DLOG("geting %s vcard\n", jid.username().c_str());

        //获取自己的vcard照片

        if (myjid.bare() == jid.bare()) {
                //bodies.set_vcard(vcard);

                const std::string m_file = bodies.getAccountTag("icon");

                if ((!m_file.empty())
                                && (!access(m_file.c_str(), F_OK))) {


                        if (stat(m_file.c_str(), &f_stat))
                                return ;

                        f_size = f_stat.st_size;
                } else
                        f_size = 0;

                if (!vcard->photo().type.empty()) {
                        n_size = vcard->photo().binval.size();

                        if (f_size != n_size) {
                                DLOG("orig picture size = %d,new size= %d\n", f_size, n_size);
                                std::ofstream fout(filename);
                                fout.write((const char *) vcard->
                                           photo().binval.c_str(),
                                           vcard->photo().binval.
                                           size());
                                fout.close();

                                bodies.setAccountTag("icon", filename);
                                bodies.get_main_window().set_logo(filename);
                        }
                }

        }

        Buddy *buddy =
                bodies.get_buddy_list().find_buddy(jid.
                                                   bare
                                                   ());
        assert(buddy);
        //buddy->set_vcard(vcard);

        const std::string & buddyname = buddy->get_jid();
        const std::string & f_file =
                bodies.get_main_window().get_buddy_view().getBlistTag("buddy", buddyname, "icon");

        if ((!f_file.empty())
                        && (!access(f_file.c_str(), F_OK))) {

                if (stat(f_file.c_str(), &f_stat))
                        return ;

                f_size = f_stat.st_size;
        } else
                f_size = 0;

        if (!vcard->photo().binval.empty()) {
                n_size = vcard->photo().binval.size();

                if (f_size != n_size) {
                        DLOG("orig picture size = %d,new size= %d\n", f_size, n_size);
                        std::ofstream fout(filename);
                        fout.write((const char *) vcard->
                                   photo().binval.c_str(),
                                   n_size);
                        fout.close();
                        bodies.get_main_window().get_buddy_view().setBlistTag("buddy",
                                        buddyname,
                                        "icon",
                                        filename);
                }
        }


        buddy->refreshinfo();
}
开发者ID:ericxsun,项目名称:icalk,代码行数:99,代码来源:TalkCard.cpp


注:本文中的JID::username方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。