bool CChat::CreateChannel(LPCTSTR pszName, LPCTSTR pszPassword, CChatMember *pMember) { ADDTOCALLSTACK("CChat::CreateChannel"); if ( pMember ) { CClient *pClient = pMember->GetClient(); if ( pClient && !pClient->IsPriv(PRIV_GM) && !(g_Cfg.m_iChatFlags & CHATF_CHANNELCREATION) ) { CGString sName; FormatName(sName, NULL, true); pMember->SendChatMsg(CHATMSG_PlayerMessage, sName, " Channel creation is disabled."); return false; } } if ( !IsValidName(pszName, false) ) { if ( pMember ) pMember->SendChatMsg(CHATMSG_InvalidConferenceName); return false; } else if ( FindChannel(pszName) ) { if ( pMember ) pMember->SendChatMsg(CHATMSG_DuplicatedConferenceName); return false; } CChatChannel *pChannel = new CChatChannel(pszName, pszPassword, !pMember); m_Channels.InsertTail(pChannel); BroadcastAddChannel(pChannel); if ( pMember && (g_Cfg.m_iChatFlags & CHATF_CHANNELMODERATION) ) pChannel->SetModerator(pMember->GetChatName()); return true; }
size_t CPlotData::GetBaselinePointCount(unsigned int nChannel) { CPlotChannel *pChannel = FindChannel(nChannel); size_t nRtn = (pChannel == NULL) ? 0 : pChannel->GetBaselinePointCount(); return nRtn; }
double *CPlotData::GetBaselineTimePoints(unsigned int nChannel) { CPlotChannel *pChannel = FindChannel(nChannel); double *pdRtn = (pChannel == NULL) ? NULL : pChannel->GetBaselineX(); return pdRtn; }
unsigned int CPlotData::GetBaselineStart(unsigned int nChannel) { CPlotChannel *pChannel = FindChannel(nChannel); unsigned int nRtn = (pChannel == NULL) ? 0 : pChannel->GetBaselineStart(); return nRtn; }
int ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { struct Channel *chptr = 0; struct ModeBuf mbuf; struct Membership *member = 0; if (parc < 3) return need_more_params(sptr, "MODE"); if (IsLocalChannel(parv[1])) return 0; if (!(chptr = FindChannel(parv[1]))) return set_user_mode(cptr, sptr, parc, parv); ClrFlag(sptr, FLAG_TS8); if (IsServer(sptr)) { if (cli_uworld(sptr)) modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ MODEBUF_DEST_SERVER | /* Send mode to servers */ MODEBUF_DEST_HACK4)); /* Send a HACK(4) message */ else modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ MODEBUF_DEST_SERVER | /* Send mode to servers */ MODEBUF_DEST_HACK3)); /* Send a HACK(3) message */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* Set the mode */ MODE_PARSE_STRICT | /* Interpret it strictly */ MODE_PARSE_FORCE), NULL); /* And force it to be accepted */ } else { if (!IsChannelService(sptr) && (!(member = find_member_link(chptr, sptr)) || (!IsChanOp(member) && !IsHalfOp(member)))) { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_SERVER | /* Send mode to server */ MODEBUF_DEST_HACK2 | /* Send a HACK(2) message */ MODEBUF_DEST_DEOP | /* Deop the source */ MODEBUF_DEST_BOUNCE)); /* And bounce the MODE */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_STRICT | /* Interpret it strictly */ MODE_PARSE_BOUNCE), member); /* And bounce the MODE */ } else { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ MODEBUF_DEST_SERVER)); /* Send mode to servers */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* Set the mode */ MODE_PARSE_STRICT | /* Interpret it strictly */ MODE_PARSE_FORCE), member); /* And force it to be accepted */ } } return modebuf_flush(&mbuf); }
short SetCurrentChannel (SOCKET hChannel) { short i = FindChannel (hChannel); if (i < 0) return -1; ssd.iChannel = i; return 0; }
CCircuitry* CNeighbour::SetChannel(CCircuitry* pChannel) { LPCTSTR xUserId = pChannel->m_xUserId; CCircuitry* pChannel2 = FindChannel( xUserId ); if ( pChannel2 ) pChannel2->Release(); m_pList.SetAt( xUserId, pChannel ); return pChannel; }
CChannel* CNetwork::SetChannel(CChannel* pChannel) { LPCTSTR xJobId = pChannel->m_xJobId; CChannel* pChannel2 = FindChannel( xJobId ); if ( pChannel2 ) pChannel2->Release(); m_pList.SetAt( xJobId, pChannel ); return pChannel; }
void ChannelHandler::RemoveNick(string Nick, string Channel) { if(Channel.length()) { FindChannel(Channel)->RemoveNameIfExists(Nick); }else{ for (std::list<MessageBoxCF *>::iterator tempIter = ChannelList->begin(); tempIter != ChannelList->end(); tempIter++) { (*tempIter)->RemoveNameIfExists(Nick); } } }
/** Handle a local user's attempt to get or set a channel topic. * * \a parv has the following elements: * \li \a parv[1] is the channel name * \li \a parv[\a parc - 1] is the topic (if \a parc > 2) * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int m_topic(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; char *topic = 0, *name, *p = 0; if (parc < 2) return need_more_params(sptr, "TOPIC"); if (parc > 2) topic = parv[parc - 1]; for (; (name = ircd_strtok(&p, parv[1], ",")); parv[1] = 0) { chptr = 0; /* Does the channel exist */ if (!IsChannelName(name) || !(chptr = FindChannel(name))) { send_reply(sptr,ERR_NOSUCHCHANNEL,name); continue; } /* Trying to check a topic outside a secret channel */ if ((topic || SecretChannel(chptr)) && !find_channel_member(sptr, chptr)) { send_reply(sptr, ERR_NOTONCHANNEL, chptr->chname); continue; } /* only asking for topic */ if (!topic) { if (chptr->topic[0] == '\0') send_reply(sptr, RPL_NOTOPIC, chptr->chname); else { send_reply(sptr, RPL_TOPIC, chptr->chname, chptr->topic); send_reply(sptr, RPL_TOPICWHOTIME, chptr->chname, chptr->topic_nick, chptr->topic_time); } } #if defined(DDB) || defined(SERVICES) else if ((chptr->mode.mode & MODE_TOPICLIMIT) && !(is_chan_owner(sptr, chptr) || is_chan_op(sptr, chptr))) #else else if ((chptr->mode.mode & MODE_TOPICLIMIT) && !is_chan_op(sptr, chptr)) #endif send_reply(sptr, ERR_CHANOPRIVSNEEDED, chptr->chname); else if (!client_can_send_to_channel(sptr, chptr, 1)) send_reply(sptr, ERR_CANNOTSENDTOCHAN, chptr->chname); else do_settopic(sptr,cptr,chptr,topic,0); } return 0; }
bool CslIrcSession::ConvertToChannelEncoding(const wxString& name,const wxString& text, wxCharBuffer& buffer) { CslIrcChannel *channel; if ((channel=FindChannel(name))) { buffer=channel->Encoding.ToServer(text); return true; } return false; }
short UnregisterChannel (SOCKET hChannel) { short i = FindChannel (hChannel); if (i < 0) return -1; if (i < --(ssd.nChannels)) ssd.channels [i] = ssd.channels [ssd.nChannels]; ssd.channels [ssd.nChannels] = INVALID_SOCKET; if (ssd.iChannel >= ssd.nChannels) ssd.iChannel = 0; return 0; }
bool OSOutput::SetPrintLevel(std::string name, ENUM_OUTPUT_LEVEL* level, int dim) { int k = FindChannel(name); if (k < 0) throw ErrorClass("Device was not defined before"); for (int i=1; i<dim; i++) { if (level[i] < 0) throw ErrorClass("printLevel must be nonnegative"); else if (level[i] >= ENUM_OUTPUT_LEVEL_NUMBER_OF_LEVELS) throw ErrorClass("illegal printLevel specified"); } return (outputChannel[k]->setAllPrintLevels(level, dim)); }
void ProcOnTopic(BN_PInfo I, const char Chan[], const char Who[], const char Msg[]) { char *string; IRCChannel_t *channel; string = (char *)malloc(MAX_STRING_LENGTH); sprintf(string, "%s changes topic to %s\n", Who, Msg); channel = FindChannel((IRCServer_t *)I->User, Chan); db_add_logentry( channel, (char *)Who, TYPE_TOPIC, string, true ); db_update_nick( channel, (char *)Who, true, true ); free( string ); }
void ProcOnMode(BN_PInfo I, const char Channel[], const char Who[], const char Msg[]) { char *string; IRCChannel_t *channel; string = (char *)malloc(MAX_STRING_LENGTH); sprintf(string, "Mode for %s by %s : %s\n", Channel, Who, Msg); channel = FindChannel((IRCServer_t *)I->User, Channel); db_add_logentry( channel, (char *)Who, TYPE_MODE, string, true ); db_update_nick( channel, (char *)Who, true, true ); free( string ); }
void CChat::JoinChannel(LPCTSTR pszName, LPCTSTR pszPassword, CChatMember *pMember) { ADDTOCALLSTACK("CChat::JoinChannel"); ASSERT(pMember); CClient *pMemberClient = pMember->GetClient(); ASSERT(pMemberClient); CChatChannel *pNewChannel = FindChannel(pszName); if ( !pNewChannel ) { pMemberClient->addChatSystemMessage(CHATMSG_NoConference, pszName); return; } pszName = pNewChannel->m_sName; // fix case-sensitive mismatch CChatChannel *pCurrentChannel = pMember->GetChannel(); if ( pCurrentChannel && (pCurrentChannel == pNewChannel) ) { pMember->SendChatMsg(CHATMSG_AlreadyInConference, pszName); return; } else if ( !pNewChannel->m_sPassword.IsEmpty() && (!pszPassword || (strcmp(static_cast<LPCTSTR>(pNewChannel->m_sPassword), pszPassword) != 0)) ) { if ( pMemberClient->m_UseNewChatSystem ) { CGString sName; FormatName(sName, NULL, true); pMember->SendChatMsg(CHATMSG_PlayerMessage, sName, " Your client version can't join channels with password."); } else pMemberClient->addChatSystemMessage(CHATMSG_IncorrectPassword); return; } /*else if ( pNewChannel->m_Members.GetCount() >= UCHAR_MAX ) { pMemberClient->addChatSystemMessage(CHATMSG_ConferenceIsFull, pszName); return; }*/ // Leave current channel if ( pCurrentChannel ) pCurrentChannel->RemoveMember(pMember); // Join the new channel pNewChannel->AddMember(pMember); pNewChannel->SendMember(pMember); // send this member to all others clients pMemberClient->addChatSystemMessage(CHATCMD_JoinedChannel, pszName); if ( !pMemberClient->m_UseNewChatSystem ) pNewChannel->FillMembersList(pMember); // fill the members list on this client }
/** Handle an OPMODE message from an operator. * * \a parv has the same elements as for m_mode(). * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr = 0; struct ModeBuf mbuf; char *chname; const char *qreason; int force = 0; if (!feature_bool(FEAT_CONFIG_OPERCMDS)) return send_reply(sptr, ERR_DISABLED, "OPMODE"); if (parc < 3) return need_more_params(sptr, "OPMODE"); chname = parv[1]; if (*chname == '!') { chname++; if (!HasPriv(sptr, IsLocalChannel(chname) ? PRIV_FORCE_LOCAL_OPMODE : PRIV_FORCE_OPMODE)) return send_reply(sptr, ERR_NOPRIVILEGES); force = 1; } if (!HasPriv(sptr, IsLocalChannel(chname) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE)) return send_reply(sptr, ERR_NOPRIVILEGES); if (!IsChannelName(chname) || !(chptr = FindChannel(chname))) return send_reply(sptr, ERR_NOSUCHCHANNEL, chname); if (!force && (qreason = find_quarantine(chptr->chname))) return send_reply(sptr, ERR_QUARANTINED, chptr->chname, qreason); modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */ MODEBUF_DEST_SERVER | /* And to server */ MODEBUF_DEST_OPMODE | /* Use OPMODE */ MODEBUF_DEST_HACK4 | /* Generate a HACK(4) notice */ MODEBUF_DEST_LOG)); /* Log the mode changes to OPATH */ mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2, (MODE_PARSE_SET | /* set the modes on the channel */ MODE_PARSE_FORCE), /* And force them to be accepted */ NULL); modebuf_flush(&mbuf); /* flush the modes */ return 0; }
void ProcOnAction(BN_PInfo I, const char Chan[], const char Who[], const char Msg[]) { IRCServer_t *server; IRCChannel_t *channel; char nick[256]; server = (IRCServer_t *)I->User; channel = FindChannel(server, Chan); db_add_logentry( channel, (char *)Who, TYPE_ACTION, (char *)Msg, true ); db_update_nick( channel, (char *)Who, true, true ); BN_ExtractNick(Who, nick, 256); regexp_parse( server, channel, nick, (char *)Msg, TYPE_ACTION ); }
VTextureWeightmapChannel* VTextureWeightmapChannelCollection::CreateChannel(const VTerrainConfig &config, VTextureWeightmapChannelResource *pRes, int iResX, int iResY) { if (!pRes) return NULL; VTextureWeightmapChannel* pFound = FindChannel(pRes); if (!pFound) { pFound = new VTextureWeightmapChannel(pRes,iResX,iResY); Add(pFound); if (config.m_bSortTextureChannels) SortByResourceSortingKey(false); // keep this list sorted } return pFound; }
void Server::Leave(Connection* connection, QString channel_name) { Channel* channel = FindChannel(channel_name); if(channel != NULL) { channel->Remove(connection); SendConfirm(connection, LEAVE_ACC, 1, channel_name); SendList(channel->GetName()); } else { qDebug("LEAVE::channel doesn't exist"); SendConfirm(connection, LEAVE_ACC, 0, channel_name); } }
Channel* Server::Create(Connection* connection, QString channel_name) { if(FindChannel(channel_name) == NULL && channel_name.size() > 0) { Channel* channel = new Channel(channel_name); addChannel(channel); SendConfirm(connection, CREATE_ACC, 1, channel_name); return channel; } else { SendConfirm(connection, CREATE_ACC, 0, channel_name); return NULL; } }
/** Forwards a numeric message from a remote server. * @param numeric Value of numeric message. * @param nnn If non-zero, treat parv[1] as a numnick; else as a client name. * @param cptr Client that originated the numeric. * @param sptr Peer that sent us the numeric. * @param parc Count of valid arguments in \a parv. * @param parv Argument list. * @return Zero (always). */ int do_numeric(int numeric, int nnn, struct Client *cptr, struct Client *sptr, int parc, char *parv[]) { struct Client *acptr = 0; struct Channel *achptr = 0; char num[4]; /* Avoid trash, we need it to come from a server and have a target */ if ((parc < 2) || !IsServer(sptr)) return 0; /* Who should receive this message ? Will we do something with it ? Note that we use findUser functions, so the target can't be neither a server, nor a channel (?) nor a list of targets (?) .. u2.10 should never generate numeric replies to non-users anyway Ahem... it can be a channel actually, csc bots use it :\ --Nem */ if (IsChannelName(parv[1])) achptr = FindChannel(parv[1]); else acptr = (nnn) ? (findNUser(parv[1])) : (FindUser(parv[1])); if (((!acptr) || (cli_from(acptr) == cptr)) && !achptr) return 0; /* Remap low number numerics, not that I understand WHY.. --Nemesi */ /* numerics below 100 talk about the current 'connection', you're not * connected to a remote server so it doesn't make sense to send them * remotely - but the information they contain may be useful, so we * remap them up. Weird, but true. -- Isomer */ if (numeric < 100) numeric += 100; ircd_snprintf(0, num, sizeof(num), "%03d", numeric); /* Since 2.10.10.pl14 we rewrite numerics from remote servers to appear to * come from the local server */ if (acptr) sendcmdto_one((feature_bool(FEAT_HIS_REWRITE) && !IsOper(acptr)) ? &me : sptr, num, num, acptr, "%C %s", acptr, parv[2]); else sendcmdto_channel_butone(feature_bool(FEAT_HIS_REWRITE) ? &me : sptr, num, num, achptr, cptr, SKIP_DEAF | SKIP_BURST, '\0', "%H %s", achptr, parv[2]); return 0; }
Channel* Server::Join(Connection* connection, QString channel_name) { Channel* channel = FindChannel(channel_name); if(channel != NULL) { channel->Add(connection); SendConfirm(connection, JOIN_ACC, 1, channel_name); SendList(channel->GetName()); } else { qDebug("JOIN::channel doesn't exist"); SendConfirm(connection, JOIN_ACC, 0, channel_name); } return channel; }
/** Handle a WALLVOICES message from a local client. * * \a parv has the following elements: * \li \a parv[1] is the name of the channel to which to send * \li \a parv[\a parc - 1] is the message to send * * See @ref m_functions for discussion of the arguments. * @param[in] cptr Client that sent us the message. * @param[in] sptr Original source of message. * @param[in] parc Number of arguments. * @param[in] parv Argument vector. */ int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; const char *ch; assert(0 != cptr); assert(cptr == sptr); if (parc < 2 || EmptyString(parv[1])) return send_reply(sptr, ERR_NORECIPIENT, "WALLVOICES"); if (parc < 3 || EmptyString(parv[parc - 1])) return send_reply(sptr, ERR_NOTEXTTOSEND); if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) { if (client_can_send_to_channel(sptr, chptr, 0) && !(chptr->mode.mode & MODE_NONOTICE)) { if ((chptr->mode.mode & MODE_NOPRIVMSGS) && check_target_limit(sptr, chptr, chptr->chname, 0)) return 0; #if 0 /* +cC checks */ if (chptr->mode.mode & MODE_NOCOLOUR) for (ch=parv[parc - 1];*ch;ch++) if (*ch==2 || *ch==3 || *ch==22 || *ch==27 || *ch==31) { return 0; } if ((chptr->mode.mode & MODE_NOCTCP) && ircd_strncmp(parv[parc - 1],"\001ACTION ",8)) for (ch=parv[parc - 1];*ch;) if (*ch++==1) { return 0; } #endif RevealDelayedJoinIfNeeded(sptr, chptr); sendcmdto_channel(sptr, CMD_WALLVOICES, chptr, cptr, SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, "%H :+ %s", chptr, parv[parc - 1]); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); } else send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); return 0; }
void ProcOnPart(BN_PInfo I, const char Chan[], const char Who[], const char Msg[]) { char *string; IRCChannel_t *channel; char nick[256]; string = (char *)malloc(MAX_STRING_LENGTH); BN_ExtractNick(Who, nick, 256); sprintf(string, "%s (%s) has left %s (%s)\n", nick, Who, Chan, Msg); channel = FindChannel((IRCServer_t *)I->User, Chan); db_add_logentry( channel, nick, TYPE_PART, string, false ); db_update_nick( channel, nick, false, false ); db_nick_history( channel, nick, HIST_LEAVE ); free( string ); }
int OSOutput::AddChannel(std::string name) { if (FindChannel(name) >= 0) { if (name == "stdout") return 0; else return 1; } bool noMem = false; try { int ndev; int i; if (this->outputChannel == NULL) ndev = 0; else ndev = this->nOfOutputs; noMem = true; OSOutputChannel** temp = new OSOutputChannel*[ndev+1]; //Allocate the new pointers noMem = false; for (i = 0; i < ndev; i++) temp[i] = this->outputChannel[i]; //copy the pointers delete[] this->outputChannel; //delete old pointers // add in the new element noMem = true; temp[ndev] = new OSOutputChannel(name); noMem = false; this->outputChannel = temp; //hook the new pointers into the data structure this->nOfOutputs = ++ndev; return 0; } catch(const ErrorClass& eclass) { if (noMem) return 2; return 3; } }// AddChannel
bool CslIrcSession::JoinChannel(const wxString& name,const wxString& password) { if (m_state!=STATE_CONNECTED) return false; CslIrcChannel *channel; if ((channel=FindChannel(name))) { if (channel->Connected) return false; } else m_channels.Add(new CslIrcChannel(name,password)); return irc_cmd_join(m_context.Session,U2A(name),U2A(password))==0; }
void server_relay_channel_notice(struct Client* sptr, const char* name, const char* text) { struct Channel* chptr; assert(0 != sptr); assert(0 != name); assert(0 != text); if (0 == (chptr = FindChannel(name))) return; /* * This first: Almost never a server/service * Servers may have channel services, need to check for it here */ if (client_can_send_to_channel(sptr, chptr) || IsChannelService(sptr)) { sendcmdto_channel_butone(sptr, CMD_NOTICE, chptr, cli_from(sptr), SKIP_DEAF | SKIP_BURST, "%H :%s", chptr, text); } }
void ChannelHandler::CloseChannel(string Name) { MessageBoxCF *temp = FindChannel(Name); bool WasMainChannel = false; if(!SelectedChannel->GetName().compare(Name)){ SelectChannel("unknownRecievedMsgs"); if(!Name.compare( "unknownRecievedMsgs")) WasMainChannel = true; } ChannelList->remove(temp); delete(temp); if(WasMainChannel) { this->SelectedChannel = NULL; SelectChannel(Name); } SendMessage(g_pWindow,WM_PAINT,0,0); }
/* * ms_wallvoices - server message handler */ int ms_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) { struct Channel *chptr; assert(0 != cptr); assert(0 != sptr); if (parc < 3 || !IsUser(sptr)) return 0; if (!IsLocalChannel(parv[1]) && (chptr = FindChannel(parv[1]))) { if (client_can_send_to_channel(sptr, chptr, 1)) { sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr, SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, "%H :%s", chptr, parv[parc - 1]); } else send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); } return 0; }