Logo Search packages:      
Sourcecode: sbnc version File versions  Download package

void CUser::SetIRCConnection ( CIRCConnection IRC  ) 

SetIRCConnection

Sets the IRC connection object for the user.

Parameters:
IRC the irc connection

Definition at line 837 of file User.cpp.

References CIRCConnection::GetChannels(), GetClientConnectionMultiplexer(), CIRCConnection::GetCurrentNick(), CVector< Type >::GetLength(), CCore::GetModules(), GetNick(), GetUsername(), CCore::LogUser(), m_IRC, m_IRCStats, m_LastReconnect, hash_t< Type >::Name, CClientConnection::SetNick(), CObject< ObjectType, OwnerType >::SetOwner(), CConnection::SetTrafficStats(), and CConnection::WriteLine().

Referenced by CUser(), CIRCConnection::Destroy(), CIRCConnection::Kill(), CClientConnection::ProcessBncCommand(), and Reconnect().

                                                {
      const CVector<CModule *> *Modules;
      CIRCConnection *OldIRC;
      bool WasNull;

      if (GetClientConnectionMultiplexer() != NULL && m_IRC != NULL) {
//          GetClientConnection()->SetPreviousNick(m_IRC->GetCurrentNick());
            GetClientConnectionMultiplexer()->SetNick(m_IRC->GetCurrentNick());
      }

      if (m_IRC == NULL) {
            WasNull = true;
      } else {
            WasNull = false;

            m_IRC->SetOwner(NULL);
      }

      OldIRC = m_IRC;
      m_IRC = IRC;

      Modules = g_Bouncer->GetModules();

      if (IRC == NULL && !WasNull) {
            for (unsigned int i = 0; i < Modules->GetLength(); i++) {
                  (*Modules)[i]->ServerDisconnect(GetUsername());
            }

            CClientConnection *Client = GetClientConnectionMultiplexer();;

            if (Client != NULL) {
                  CHashtable<CChannel *, false, 16> *Channels;
                  unsigned int i;
                  hash_t<CChannel *> *ChannelHash;

                  Channels = OldIRC->GetChannels();

                  i = 0;
                  while ((ChannelHash = Channels->Iterate(i++)) != NULL) {
                        Client->WriteLine(":shroudbnc.info KICK %s %s :Disconnected from the IRC server.", ChannelHash->Name, GetNick());
                  }
            }

            g_Bouncer->LogUser(this, "User %s disconnected from the server.", GetUsername());
      } else if (IRC) {
            for (unsigned int i = 0; i < Modules->GetLength(); i++) {
                  (*Modules)[i]->ServerConnect(GetUsername());
            }

            m_LastReconnect = g_CurrentTime;

            IRC->SetTrafficStats(m_IRCStats);
      }
}


Generated by  Doxygen 1.6.0   Back to index