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


C++ Subscription::status方法代码示例

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


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

示例1: handleSubscription

  void RosterManager::handleSubscription( const Subscription& s10n )
  {
    if( !m_rosterListener )
      return;

    switch( s10n.subtype() )
    {
      case Subscription::Subscribe:
      {
        bool answer = m_rosterListener->handleSubscriptionRequest( s10n.from(), s10n.status() );
        if( m_syncSubscribeReq )
        {
          ackSubscriptionRequest( s10n.from(), answer );
        }
        break;
      }
      case Subscription::Subscribed:
      {
//         Subscription p( Subscription::Subscribe, s10n.from().bareJID() );
//         m_parent->send( p );

        m_rosterListener->handleItemSubscribed( s10n.from() );
        break;
      }

      case Subscription::Unsubscribe:
      {
        Subscription p( Subscription::Unsubscribed, s10n.from().bareJID() );
        m_parent->send( p );

        bool answer = m_rosterListener->handleUnsubscriptionRequest( s10n.from(), s10n.status() );
        if( m_syncSubscribeReq && answer )
          remove( s10n.from().bare() );
        break;
      }

      case Subscription::Unsubscribed:
      {
//         Subscription p( Subscription::Unsubscribe, s10n.from().bareJID() );
//         m_parent->send( p );

        m_rosterListener->handleItemUnsubscribed( s10n.from() );
        break;
      }

      default:
        break;
    }
  }
开发者ID:junction,项目名称:jn-tapi,代码行数:49,代码来源:rostermanager.cpp

示例2: main

int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  Tag *s10n = new Tag( "presence" );
  s10n->addAttribute( "from", "[email protected]/gloox" );
  s10n->addAttribute( "to", "[email protected]/gloox" );
  new Tag( s10n, "status", "the status" );
  Subscription* i = 0;

  // -------
  name = "parse Subscription subscribe";
  s10n->addAttribute( "type", "subscribe" );
  i = new Subscription( s10n );
  if( i->subtype() != Subscription::Subscribe
      || i->from().full() != "[email protected]/gloox" || i->to().full() != "[email protected]/gloox"
      || i->status() != "the status" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parse Subscription subscribed";
  s10n->addAttribute( "type", "subscribed" );
  i = new Subscription( s10n );
  if( i->subtype() != Subscription::Subscribed
      || i->from().full() != "[email protected]/gloox" || i->to().full() != "[email protected]/gloox"
      || i->status() != "the status" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parse Subscription unsubscribe";
  s10n->addAttribute( "type", "unsubscribe" );
  i = new Subscription( s10n );
  if( i->subtype() != Subscription::Unsubscribe
      || i->from().full() != "[email protected]/gloox" || i->to().full() != "[email protected]/gloox"
      || i->status() != "the status" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parse Subscription unsubscribed";
  s10n->addAttribute( "type", "unsubscribed" );
  i = new Subscription( s10n );
  if( i->subtype() != Subscription::Unsubscribed
      || i->from().full() != "[email protected]/gloox" || i->to().full() != "[email protected]/gloox"
      || i->status() != "the status" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  {
    name = "new simple Subscription subscribe";
    Subscription s( Subscription::Subscribe, JID( "[email protected]/blah" ), "the status",
                          "the xmllang" );
    s.setFrom( JID( "[email protected]" ) );
    Tag* i = s.tag();
    if( i->name() != "presence" || !i->hasAttribute( "type", "subscribe" )
        || !i->hasAttribute( "to", "[email protected]/blah" ) || !i->hasAttribute( "from", "[email protected]" )
        || !i->hasChildWithCData( "status", "the status" )
        || !i->hasChild( "status", "xml:lang", "the xmllang" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), i->xml().c_str() );
    }
    delete i;
  }

  // -------
  {
    name = "new simple Subscription subscribed";
    Subscription s( Subscription::Subscribed, JID( "[email protected]/blah" ), "the status",
                          "the xmllang" );
    s.setFrom( JID( "[email protected]" ) );
    Tag* i = s.tag();
    if( i->name() != "presence" || !i->hasAttribute( "type", "subscribed" )
        || !i->hasAttribute( "to", "[email protected]/blah" ) || !i->hasAttribute( "from", "[email protected]" )
        || !i->hasChildWithCData( "status", "the status" )
        || !i->hasChild( "status", "xml:lang", "the xmllang" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), i->xml().c_str() );
    }
    delete i;
//.........这里部分代码省略.........
开发者ID:github188,项目名称:BasicFunctionCodeBase,代码行数:101,代码来源:subscription_test.cpp


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