⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mucroom.cpp

📁 Jabber code library, developed with c
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            else if( code == "104" )              /*m_configChanged =*/ (void)true;            else if( code == "170" )              m_flags |= FlagPublicLogging;            else if( code == "171" )              m_flags &= ~FlagPublicLogging;            else if( code == "172" )            {              setNonAnonymous();            }            else if( code == "173" )            {              setSemiAnonymous();            }            else if( code == "174" )            {              setFullyAnonymous();            }          }          else if( (*it)->name() == "decline" )          {            std::string reason;            JID invitee( (*it)->findAttribute( "from" ) );            if( (*it)->hasChild( "reason" ) )              reason = (*it)->findChild( "reason" )->cdata();            m_roomHandler->handleMUCInviteDecline( this, invitee, reason );            return;          }          // call some handler?        }      }      else if( m_roomConfigHandler && ( x = stanza->findChild( "x", "xmlns", XMLNS_X_DATA ) ) != 0 )      {        DataForm df( x );        m_roomConfigHandler->handleMUCRequest( this, df );        return;      }      if( !stanza->subject().empty() )      {        m_roomHandler->handleMUCSubject( this, stanza->from().resource(), stanza->subject() );      }      else if( !stanza->body().empty() )      {        JID from;        std::string when;        bool privMsg = false;        bool history = false;        if( ( x = stanza->findChild( "x", "xmlns", XMLNS_X_DELAY ) ) != 0 )        {          from.setJID( x->findAttribute( "from" ) );          when = x->findAttribute( "stamp" );          history = true;        }        if( stanza->subtype() == StanzaMessageChat ||            stanza->subtype() == StanzaMessageNormal )          privMsg = true;        m_roomHandler->handleMUCMessage( this, stanza->from().resource(), stanza->body(),                                          history, when, privMsg );      }    }  }  bool MUCRoom::handleIqID( Stanza *stanza, int context )  {    if( !m_roomConfigHandler )      return false;    switch( stanza->subtype() )    {      case StanzaIqResult:        return handleIqResult( stanza, context );        break;      case StanzaIqError:        return handleIqError( stanza, context );        break;      default:        break;    }    return false;  }  bool MUCRoom::handleIqResult( Stanza *stanza, int context )  {    switch( context )    {      case SetRNone:      case SetVisitor:      case SetParticipant:      case SetModerator:      case SetANone:      case SetOutcast:      case SetMember:      case SetAdmin:      case SetOwner:      case CreateInstantRoom:      case CancelRoomCreation:      case DestroyRoom:      case StoreVoiceList:      case StoreBanList:      case StoreMemberList:      case StoreModeratorList:      case StoreAdminList:        m_roomConfigHandler->handleMUCConfigResult( this, true, (MUCOperation)context );        return true;        break;      case RequestRoomConfig:      {        Tag *x = 0;        Tag *q = stanza->findChild( "query", "xmlns", XMLNS_MUC_OWNER );        if( q )          x = q->findChild( "x", "xmlns", XMLNS_X_DATA );        if( x )        {          DataForm df( x );          m_roomConfigHandler->handleMUCConfigForm( this, df );        }        return true;        break;      }      case RequestVoiceList:      case RequestBanList:      case RequestMemberList:      case RequestModeratorList:      case RequestOwnerList:      case RequestAdminList:      {        Tag *x = 0;        Tag *q = stanza->findChild( "query", "xmlns", XMLNS_MUC_OWNER );        if( q )          x = q->findChild( "x", "xmlns", XMLNS_X_DATA );        if( x )        {          MUCListItemList itemList;          const Tag::TagList& items = x->findChildren( "item" );          Tag::TagList::const_iterator it = items.begin();          for( ; it != items.end(); ++it )          {            MUCListItem item;            item.jid = 0;            item.role = getEnumRole( (*it)->findAttribute( "role" ) );            item.affiliation = getEnumAffiliation( (*it)->findAttribute( "affiliation" ) );            if( (*it)->hasAttribute( "jid" ) )              item.jid = new JID( (*it)->findAttribute( "jid" ) );            item.nick = (*it)->findAttribute( "nick" );            itemList.push_back( item );          }          m_roomConfigHandler->handleMUCConfigList( this, itemList, (MUCOperation)context );          MUCListItemList::iterator itl = itemList.begin();          for( ; itl != itemList.end(); ++itl )            delete (*itl).jid;        }        return true;        break;      }      default:        break;    }    return false;  }  bool MUCRoom::handleIqError( Stanza * /*stanza*/, int context )  {    switch( context )    {      case SetRNone:      case SetVisitor:      case SetParticipant:      case SetModerator:      case SetANone:      case SetOutcast:      case SetMember:      case SetAdmin:      case SetOwner:      case CreateInstantRoom:      case CancelRoomCreation:      case RequestRoomConfig:      case DestroyRoom:      case RequestVoiceList:      case StoreVoiceList:      case RequestBanList:      case StoreBanList:      case RequestMemberList:      case StoreMemberList:      case RequestModeratorList:      case StoreModeratorList:      case RequestOwnerList:      case StoreOwnerList:      case RequestAdminList:      case StoreAdminList:        m_roomConfigHandler->handleMUCConfigResult( this, false, (MUCOperation)context );        break;    }    return false;  }  void MUCRoom::handleDiscoInfoResult( Stanza *stanza, int context )  {    switch( context )    {      case GetRoomInfo:      {        int oldflags = m_flags;        m_flags = 0;        if( oldflags & FlagPublicLogging )          m_flags |= FlagPublicLogging;        std::string name;        DataForm *df = 0;        Tag *q = stanza->findChild( "query" );        if( q )        {          const Tag::TagList& l = q->children();          Tag::TagList::const_iterator it = l.begin();          for( ; it != l.end(); ++it )          {            if( (*it)->name() == "feature" )            {              if( (*it)->findAttribute( "var" ) == "muc_hidden" )                m_flags |= FlagHidden;              else if( (*it)->findAttribute( "var" ) == "muc_membersonly" )                m_flags |= FlagMembersOnly;              else if( (*it)->findAttribute( "var" ) == "muc_moderated" )                m_flags |= FlagModerated;              else if( (*it)->findAttribute( "var" ) == "muc_nonanonymous" )                setNonAnonymous();              else if( (*it)->findAttribute( "var" ) == "muc_open" )                m_flags |= FlagOpen;              else if( (*it)->findAttribute( "var" ) == "muc_passwordprotected" )                m_flags |= FlagPasswordProtected;              else if( (*it)->findAttribute( "var" ) == "muc_persistent" )                m_flags |= FlagPersistent;              else if( (*it)->findAttribute( "var" ) == "muc_public" )                m_flags |= FlagPublic;              else if( (*it)->findAttribute( "var" ) == "muc_semianonymous" )                setSemiAnonymous();              else if( (*it)->findAttribute( "var" ) == "muc_temporary" )                m_flags |= FlagTemporary;              else if( (*it)->findAttribute( "var" ) == "muc_fullyanonymous" )                setFullyAnonymous();              else if( (*it)->findAttribute( "var" ) == "muc_unmoderated" )                m_flags |= FlagUnmoderated;              else if( (*it)->findAttribute( "var" ) == "muc_unsecured" )                m_flags |= FlagUnsecured;            }            else if( (*it)->name() == "identity" )            {              name = (*it)->findAttribute( "name" );            }            else if( (*it)->name() == "x" && (*it)->hasAttribute( "xmlns", XMLNS_X_DATA ) )            {              df = new DataForm( (*it) );            }          }        }        if( m_roomHandler )          m_roomHandler->handleMUCInfo( this, m_flags, name, df );        break;      }      default:        break;    }  }  void MUCRoom::handleDiscoItemsResult( Stanza *stanza, int context )  {    if( !m_roomHandler )      return;    switch( context )    {      case GetRoomItems:      {        Tag *q = stanza->findChild( "query" );        if( q )        {          StringMap items;          const Tag::TagList& l = q->children();          Tag::TagList::const_iterator it = l.begin();          for( ; it != l.end(); ++it )          {            if( (*it)->name() == "item" && (*it)->hasAttribute( "jid" ) )            {              items[(*it)->findAttribute( "name" )] = (*it)->findAttribute( "jid" );            }          }          m_roomHandler->handleMUCItems( this, items );        }        break;      }      default:        break;    }  }  void MUCRoom::handleDiscoError( Stanza * /*stanza*/, int context )  {    if( !m_roomHandler )      return;    switch( context )    {      case GetRoomInfo:        m_roomHandler->handleMUCInfo( this, 0, "", 0 );        break;      case GetRoomItems:      {        StringMap items;        m_roomHandler->handleMUCItems( this, items );        break;      }      default:        break;    }  }  StringList MUCRoom::handleDiscoNodeFeatures( const std::string& /*node*/ )  {    return StringList();  }  StringMap MUCRoom::handleDiscoNodeIdentities( const std::string& /*node*/, std::string& /*name*/ )  {    return StringMap();  }  DiscoNodeItemList MUCRoom::handleDiscoNodeItems( const std::string& node )  {    DiscoNodeItemList l;    if( node != XMLNS_MUC_ROOMS )      return l;    if( m_publish )    {      DiscoNodeItem item;      item.jid = m_nick.bare();      if( m_publishNick )        item.name = m_nick.resource();      l.push_back( item );    }    return l;  }  MUCRoomRole MUCRoom::getEnumRole( const std::string& role )  {    if( role == "moderator" )      return RoleModerator;    if( role == "participant" )      return RoleParticipant;    if( role == "visitor" )      return RoleVisitor;    return RoleNone;  }  MUCRoomAffiliation MUCRoom::getEnumAffiliation( const std::string& affiliation )  {    if( affiliation == "owner" )      return AffiliationOwner;    if( affiliation == "admin" )      return AffiliationAdmin;    if( affiliation == "member" )      return AffiliationMember;    if( affiliation == "outcast" )      return AffiliationOutcast;    return AffiliationNone;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -