enum i2c_channel_operation_result dce_i2c_hw_engine_wait_on_operation_result( struct dce_i2c_hw *dce_i2c_hw, uint32_t timeout, enum i2c_channel_operation_result expected_result) { enum i2c_channel_operation_result result; uint32_t i = 0; if (!timeout) return I2C_CHANNEL_OPERATION_SUCCEEDED; do { result = get_channel_status( dce_i2c_hw, NULL); if (result != expected_result) break; udelay(1); ++i; } while (i < timeout); return result; }
void IRCSession::on_topic(const IRCTopicMessage &message) { IRCJoinedChannel status = get_channel_status(message.get_channel()); status.topic = message.get_topic(); status.topic_author = message.get_prefix(); set_channel_status(status); cb_channel_topic_updated(message.get_channel()); }
void IRCSession::on_join(const IRCJoinMessage &message) { if (message.get_user() == our_nickname) { IRCJoinedChannel channel = get_channel_status(message.get_channel()); channel.name = message.get_channel(); channel.users.clear(); set_channel_status(channel); cb_joined(message.get_channel()); } else { IRCJoinedChannel channel = get_channel_status(message.get_channel()); channel.name = message.get_channel(); channel.users.push_back(message.get_user()); set_channel_status(channel); cb_user_joined(message.get_channel(), message.get_user()); } }
void IRCSession::on_rpl_notopic(const IRCNumericReply &message) { if (message.get_param_count() >= 2) { IRCNick target = IRCNick::from_raw(message.get_param(0)); IRCChannel channel = IRCChannel::from_raw(message.get_param(1)); IRCJoinedChannel status = get_channel_status(channel); status.topic = IRCText(); status.topic_time = 0; status.topic_author = IRCNick(); set_channel_status(status); } }
void IRCSession::on_kick(const IRCKickMessage &message) { IRCJoinedChannel channel = get_channel_status(message.get_channel()); channel.name = message.get_channel(); std::vector<IRCNick>::iterator it = std::find(channel.users.begin(), channel.users.end(), message.get_user()); if(it != channel.users.end()) { channel.users.erase(it); set_channel_status(channel); } if (message.has_comment()) cb_user_kicked(message.get_user(), message.get_channel(), message.get_target(), message.get_comment()); else cb_user_kicked(message.get_user(), message.get_channel(), message.get_target(), IRCText()); }
void IRCSession::on_rpl_topicwhotime(const IRCNumericReply &message) { if (message.get_param_count() >= 3) { IRCNick target = IRCNick::from_raw(message.get_param(0)); IRCChannel channel = IRCChannel::from_raw(message.get_param(1)); IRCNick author = IRCNick::from_raw(message.get_param(2)); unsigned int timestamp = uicore::Text::parse_uint32(message.get_param(3)); IRCJoinedChannel status = get_channel_status(channel); status.topic_time = timestamp; status.topic_author = author; set_channel_status(status); cb_channel_topic_updated(channel); } }
void IRCSession::on_rpl_namereply(const IRCNumericReply &message) { if (message.get_param_count() >= 4) { IRCChannel channel = IRCChannel::from_raw(message.get_param(2)); std::string nicks = message.get_param(3); std::vector<std::string> nick_list = uicore::Text::split(nicks, " "); IRCJoinedChannel status = get_channel_status(channel); for (unsigned int i=0; i<nick_list.size(); i++) { IRCNick nick = IRCNick::from_raw(nick_list[i]); status.users.push_back(nick); } set_channel_status(status); cb_channel_names_updated(channel); } }
void IRCSession::on_part(const IRCPartMessage &message) { for (size_t i=0; i<message.get_channel_count(); i++) { if (message.get_user() == our_nickname) cb_parted(message.get_channel(i)); else { IRCJoinedChannel channel = get_channel_status(message.get_channel(i)); channel.name = message.get_channel(i); std::vector<IRCNick>::iterator it = std::find(channel.users.begin(), channel.users.end(), message.get_user()); if(it != channel.users.end()) { channel.users.erase(it); set_channel_status(channel); } cb_user_parted(message.get_channel(i), message.get_user(), IRCText()); } } }